[net.micro.apple] bank switching for large memories

timborn@ihlpg.UUCP (Tim Born) (04/21/86)

After looking at several memory expansion boards for my Apple ][+, I think I
understand the concept, but I would like more details of how the bank switching
really works.  The 16Kb expansion depends on decoding one of the $Cxxx locations
to determine if the access is for on-board or in-slot RAM.  Why do you 
have to access the location twice?

For the 128Kb expansion, what mechanism is used?  How big are the "chunks"
that are switched?  Are all chunks switched into the same region in the address
spectrum, or can a 16Kb expansion coexist peacefully with a 128Kb expansion?
Can two 128Kb expansions coexist in harmony?  Do the companies that make
the 1 MEG (!) expansions use a different technique?  Has any sort of
standard evolved?  I noticed that some expansion boards need a ribbon cable
connected to the motherboard, others do not.  Why???

If anyone could shed some light on this subject, I would be most grateful.
Would this be of general interest to the rest of the net.micro.apple?

Thanks,
tim born
...ihnp4!ihlpg!timborn

nazgul@apollo.uucp (Kee Hinckley) (04/25/86)

In article <1840@ihlpg.UUCP> timborn@ihlpg.UUCP (Tim Born) writes:
> 
> For the 128Kb expansion, what mechanism is used?  How big are the "chunks"
> that are switched?  Are all chunks switched into the same region in the address
> spectrum, or can a 16Kb expansion coexist peacefully with a 128Kb expansion?
> Can two 128Kb expansions coexist in harmony?  Do the companies that make
> the 1 MEG (!) expansions use a different technique?  Has any sort of
> standard evolved?  I noticed that some expansion boards need a ribbon cable
> connected to the motherboard, others do not.  Why???
> 
> If anyone could shed some light on this subject, I would be most grateful.
> Would this be of general interest to the rest of the net.micro.apple?
> 

There are 3 techniques used.  One just bank switches those top 16K.  One
bank switches on the whole 64K (though you can be selective to some degree
about what gets switched (not a good idea to bank switch your stack)).
The latter is the technique used by the 64K expansion card and Applied
Engineering.  The third technique (used by Apples RAM expansion card) 
treats the memory as a device and you call it to get bytes.  Apple aside
the 64K bank switch seems to be what most people are doing.  There
is an article on all of this in a recent A+, you should read that to
be sure, my memory isn't the best.


                                            -kee

--

                         ...decvax!wanginst!apollo!nazgul

This is the Turn of a Plausible Phrase
That thickened the Erudite Verbal Haze
Cloaking Constant K
That saved the Summary
Based on the Mummery
Hiding the Flaw
That lay in the Theory Jack built.

                    A Space Child's Mother Goose
                    (4 more messages to finish this poem!)

sjl@myrias (04/25/86)

> After looking at several memory expansion boards for my Apple ][+, I think I
> understand the concept, but I would like more details of how the bank
> switching really works.
> ...
> For the 128Kb expansion, what mechanism is used?  How big are the "chunks"
> that are switched?  Are all chunks switched into the same region in the
> address spectrum, or can a 16Kb expansion coexist peacefully with a 128Kb
> expansion? Can two 128Kb expansions coexist in harmony?  Do the companies
> that make the 1 MEG (!) expansions use a different technique?  Has any sort
> of standard evolved?  I noticed that some expansion boards need a ribbon
> cable connected to the motherboard, others do not.  Why???
> ...
>
> tim born
> ...ihnp4!ihlpg!timborn


I am also interested in this area. To get the information flowing, let me
throw in what I know.

The "standard" 16K expension (ie Microsoft RAM card) actually fits into
the 12K of address space between $D000 and $FFFF, overlapping the space
otherwise occupied by the ROMs. This is accomplished by providing a 12K
bank which maps from $D000 to $FFFF and a 4K bank that maps from $D000
to $DFFF. When the 4K bank is selected, the bottom 4K of the 12K bank is
invisible, but the top 8K is visible. Think of this as a 16K bank
consisting of an 8K bank which is always visible when the 16K bank is
active, and two 4K bank of which exactly one is visible when the 16K
bank is active.

The "standard" 128K card simply extends this scheme by providing multiple
16K banks, each of which looks exactly like the 16K bank of the standard
16K card. A 128K card consists of 8 16K banks, each of which is mapped as
described above. Multiple 128K cards can be used at once (with at most 1
active at a time), and 128K cards can coexist with 16K cards. Apparently,
intermediate sizes of cards (32K, 64K) have also been made (or can be made
by partially populating a 128K card), and they can also be used in
conjunction with other cards.

"Non-standard" 128K cards also exist, such as the MicroTek Q-Disk. This
card works by mapping a selectable 256 byte page of its 128K memory into
the 256 bytes provided in the $Cxxx space for each card. This is not
useful as bank switched program memory, but works fine for RAM disk.

My own configuration consists of a 16K Microsoft RAM card in slot 0, a
128K MicroTek Q-Disk in slot 4, and a 128K Saturn card in slot 5. I run
Apple Pascal 1.1 almost exclusively, which uses the 16K card for operating
system code. I use both 128K cards as RAM disks. If I am short of slots, I
can remove the 16K card and move the 128K Saturn card (a "Standard" 128K
card) to slot 0. The Pascal system will then use 16K of the 128K Saturn
card, and I can use the remaining 112K as RAM disk. My computer is an
Apple ][+.

There is a problem with the "standard" memory mapping scheme. If you want
to use interrupts, you have to set an interrupt vector at $FFFA, $FFFC or
$FFFE (depending on what you want to trap) to point to your interrupt
handler. This is a hardware feature of the 6502 processor and cannot be
changed. Unfortunately, these interrupt vectors are in the bank switched
memory, so you have to duplicate your interrupt vectors in every 16K bank,
and avoid using the top 6 bytes of each bank for anything else. Most Apple
users will not find this to be a problem, because most apple programs do
not use interrupts of any kind, except possibly for trapping the BREAK
key.

I have no idea how the 1Meg and larger cards are implemented. I suspect
that they are not done using the "standard" scheme I have described above,
because a 128K card uses all of the 16 io locations assigned to it in page
$C0xx for bank selection. In fact, I suspect that they do not provide
mappable memory at all, but rather provide a fast way of copying memory
into and out of the card. Can anyone fill me in on this?

   Stuart Lomas
   Myrias Research Corporation
   Edmonton, Alberta, Canada
   ihnp4!alberta!myrias!sjl

koko@uthub (04/26/86)

> 
> > After looking at several memory expansion boards for my Apple ][+, I think I
> > understand the concept, but I would like more details of how the bank
> > switching really works.
> > ...
> > For the 128Kb expansion, what mechanism is used?  How big are the "chunks"
> > that are switched?  Are all chunks switched into the same region in the
> > address spectrum, or can a 16Kb expansion coexist peacefully with a 128Kb
> > expansion? Can two 128Kb expansions coexist in harmony?  Do the companies
> > that make the 1 MEG (!) expansions use a different technique?  Has any sort
> > of standard evolved?  I noticed that some expansion boards need a ribbon
> > cable connected to the motherboard, others do not.  Why???
> > ...
> >
> > tim born

	All of the memory expansion boards which are available use dynamic
RAM.  This means that the RAM chips need dynamic refresh logic.  On the cards
without the ribbon cable, there is a binary counter which runs continuously
and generates a refresh address for the memory chips every memory cycle.
On the cards with the cable, however, the refresh address is siphoned off
from the motherboard through the cable and then is gated into memory chips
on the expansion board.  This saves some chips, and hence some power and
heat.  (Note that the displaced RAM chip is connected, pin-for-pin, to the
cable when it is plugged into the expansion board.)  A disadvantage of
this approach is that the board only adds six RAM chips instead of eight,
only 12K of expansion RAM instead of 16K is added.  (However, for running
CP/M with the Z80 card, this does not matter.)  Also, since each chip is
only one bit wide -- 4116's are used -- there is a need for multiplexing
logic for mapping the bits into a rectangular 12-K by 8 block.


			Mike Kokodyniak, University of Toronto
> > ...ihnp4!ihlpg!timborn
>