RAM banking
Posted: Wed May 03, 2023 8:12 pm
In my memory map, $0000-$7FFF is mapped to RAM (A15=0), and I want to implement banking of a segment in range $1000-$7FFF.
Since I'm using AS6C4008 SRAM, I can have 16x 32-KB banks. (I can throw in more SRAMs for more banks though!)
I want to do this with discrete components only: it would be trivial to do this with 6522, but I don't want to waste entire port of 6522 just for this job.
My kernel uses first 4K of RAM ($0000-$0FFF) for its own purposes (zeropage, stack, video memory, etc), so I want to switch banks only for $1000-$7FFF (when A14 | A13 | A12 == 1) - this is where loadable programs will live, and each of them will get its own bank. And yes, I'll be wasting first 4KB of each bank just to make addressing easier.
Here's what I came up with so far:
The plan is:
- $0000-$0FFF is always in the same bank (A15-A18 pulled high).
- $1000-$7FFF is banked with the help of A15-A18 that's latched by '574.
- $8000-$FFFF does not activate RAM at all (A15=1), so I don't care about the value of A15 that comes from CPU.
Here's how I expect it to work:
- Bank selection is initiated when CPU writes to a memory location where the '574 is mapped (/EN is asserted). I think of putting this in my IO segment and activating it with one of '138-s outputs.
- The data line is then latched by '574 at the end of the cycle (once Ф2 goes low).
- '574 stays transparent (A15-A18 pulled high) for all writes to $0000-$0FFF.
- Once CPU attempts to write to $1000-$7FFF, '574 is activated (/ACCESS is asserted), and so the specific bank is activated.
I'd like some feedback on this approach, and also several questions:
- Is it OK to have A15-A18 pulled high? I need this for non-banked RAM segment to work ($0000-$0FFF). Should I use small resistor ratings for higher throughput? (I heard high-rating resistors increase capacitance and thus slow down maximum switching speed. I want to run this thing @ 8 MHz.)
- My concept is write-only. However, it would be nice to be able to READ current bank number as well! The only solution I can think of is to have another transparent latch in reverse direction which would be activated when R/W is high, so that I can "read" the byte from the '574.
- Are there any potential caveats with my approach?
Thanks in advance! Any thoughts are welcome.
Since I'm using AS6C4008 SRAM, I can have 16x 32-KB banks. (I can throw in more SRAMs for more banks though!)
I want to do this with discrete components only: it would be trivial to do this with 6522, but I don't want to waste entire port of 6522 just for this job.
My kernel uses first 4K of RAM ($0000-$0FFF) for its own purposes (zeropage, stack, video memory, etc), so I want to switch banks only for $1000-$7FFF (when A14 | A13 | A12 == 1) - this is where loadable programs will live, and each of them will get its own bank. And yes, I'll be wasting first 4KB of each bank just to make addressing easier.
Here's what I came up with so far:
The plan is:
- $0000-$0FFF is always in the same bank (A15-A18 pulled high).
- $1000-$7FFF is banked with the help of A15-A18 that's latched by '574.
- $8000-$FFFF does not activate RAM at all (A15=1), so I don't care about the value of A15 that comes from CPU.
Here's how I expect it to work:
- Bank selection is initiated when CPU writes to a memory location where the '574 is mapped (/EN is asserted). I think of putting this in my IO segment and activating it with one of '138-s outputs.
- The data line is then latched by '574 at the end of the cycle (once Ф2 goes low).
- '574 stays transparent (A15-A18 pulled high) for all writes to $0000-$0FFF.
- Once CPU attempts to write to $1000-$7FFF, '574 is activated (/ACCESS is asserted), and so the specific bank is activated.
I'd like some feedback on this approach, and also several questions:
- Is it OK to have A15-A18 pulled high? I need this for non-banked RAM segment to work ($0000-$0FFF). Should I use small resistor ratings for higher throughput? (I heard high-rating resistors increase capacitance and thus slow down maximum switching speed. I want to run this thing @ 8 MHz.)
- My concept is write-only. However, it would be nice to be able to READ current bank number as well! The only solution I can think of is to have another transparent latch in reverse direction which would be activated when R/W is high, so that I can "read" the byte from the '574.
- Are there any potential caveats with my approach?
Thanks in advance! Any thoughts are welcome.