Memory-mapping logic - a thought
- commodorejohn
- Posts: 299
- Joined: 21 Jan 2016
- Location: Placerville, CA
- Contact:
Memory-mapping logic - a thought
I'm gearing up to put together an RC2014 system based on bluesky6's 6502 board, but I don't care for the existing RAM/ROM boards much (most of them are oriented towards a 32KB/32KB split, which I've never cared for.) I'd like something with a little more RAM in high memory. However, I'm less an electronics engineer and more a programmer who can solder, so I'm working primarily off a basic knowledge of digital logic and would like to get some advice on my tentative game plan from people who actually know what they're doing - hence this thread.
Anyway, to start with the purely theoretical end of things, here's what I have planned from a logic standpoint. The goal is to use two 32KB SRAMs and an 8KB EEPROM plus some logic to give a large area of contiguous RAM with a modest ROM up top. (bluesky's 6502 board already takes care of diking out a page for I/O, so I don't need to worry about that; if the /MREQ line on the RC2014 bus is active, we know that it's not an I/O request.) One additional feature I'd like is for the visible ROM size to be configurable and everything below that to be RAM, so that if I want to move on from running a ROM language interpreter to, say, using a small bootloader to load software off of a CF card, I can reclaim any unneeded ROM space without having to rewire the board.
So the memory elements we'll call RAM A ($0000-7FFF,) RAM B ($8000-ROM base,) and ROM (ROM base-$FFFF.) If I've got all this right, RAM A is by far the simplest piece of the puzzle: the /CS select line can simply be /MREQ ORed with A15, no questions asked.
The top half of memory is a little more complicated. I know a lot of designs just use a 3:8 demultiplexer, but bluesky's 6502 design alerted me to the existence of the 74688 8-bit comparator, which, rather than having multiple select outputs (most of which are redundant for my purposes,) has just one output and allows a lot more flexibility on the input. The way I figure it, setting it up to check that A13-A15 are all high gives the default address range of $0000-DFFF for RAM and $E000-FFFF for ROM, and the additional compare inputs can be jumpered either to result in always-true or check additional address lines (resulting in a smaller ROM window at the top of memory, up to a single page if desired.) Finally, tying the 74688's /E enable line to /MREQ, the result is that its /P=Q output is only low during an access to the top area of memory - exactly what's needed for the ROM's /CS line.
RAM B is where I'm having some difficulty. The basic criteria are pretty simple: its /CS line should be low only when /MREQ is low, /P=Q is high, and A15 is high. The problem I'm having is figuring out a good way to do this without an unnecessarily high parts count. If /MREQ is inverted, this matches the truth table for a 3-input NAND gate, and on bluesky's 6502 board /MREQ is just the inverse of /IORQ, so that is available. Is it a safe assumption to do things this way? I'm not too bothered if it fails over in Z80-land since I have no plans to use it in that capacity.
If the 3-input NAND approach is useable, then the board can feature a 7410 with three of them, leaving two from which to create the OR gate for RAM A. Since the inverse of /MREQ is already available, one NAND gate can be used as an inverter for A15, and the other can give the result of !/MREQ !& !A15 which should be low only when /MREQ and A15 are both low - exactly what's needed for RAM A's /CS line.
Does this all look correct? Did I miss anything obvious? I think I have it pretty well worked out, but I'm no expert on the low-level hardware end of things...
Anyway, to start with the purely theoretical end of things, here's what I have planned from a logic standpoint. The goal is to use two 32KB SRAMs and an 8KB EEPROM plus some logic to give a large area of contiguous RAM with a modest ROM up top. (bluesky's 6502 board already takes care of diking out a page for I/O, so I don't need to worry about that; if the /MREQ line on the RC2014 bus is active, we know that it's not an I/O request.) One additional feature I'd like is for the visible ROM size to be configurable and everything below that to be RAM, so that if I want to move on from running a ROM language interpreter to, say, using a small bootloader to load software off of a CF card, I can reclaim any unneeded ROM space without having to rewire the board.
So the memory elements we'll call RAM A ($0000-7FFF,) RAM B ($8000-ROM base,) and ROM (ROM base-$FFFF.) If I've got all this right, RAM A is by far the simplest piece of the puzzle: the /CS select line can simply be /MREQ ORed with A15, no questions asked.
The top half of memory is a little more complicated. I know a lot of designs just use a 3:8 demultiplexer, but bluesky's 6502 design alerted me to the existence of the 74688 8-bit comparator, which, rather than having multiple select outputs (most of which are redundant for my purposes,) has just one output and allows a lot more flexibility on the input. The way I figure it, setting it up to check that A13-A15 are all high gives the default address range of $0000-DFFF for RAM and $E000-FFFF for ROM, and the additional compare inputs can be jumpered either to result in always-true or check additional address lines (resulting in a smaller ROM window at the top of memory, up to a single page if desired.) Finally, tying the 74688's /E enable line to /MREQ, the result is that its /P=Q output is only low during an access to the top area of memory - exactly what's needed for the ROM's /CS line.
RAM B is where I'm having some difficulty. The basic criteria are pretty simple: its /CS line should be low only when /MREQ is low, /P=Q is high, and A15 is high. The problem I'm having is figuring out a good way to do this without an unnecessarily high parts count. If /MREQ is inverted, this matches the truth table for a 3-input NAND gate, and on bluesky's 6502 board /MREQ is just the inverse of /IORQ, so that is available. Is it a safe assumption to do things this way? I'm not too bothered if it fails over in Z80-land since I have no plans to use it in that capacity.
If the 3-input NAND approach is useable, then the board can feature a 7410 with three of them, leaving two from which to create the OR gate for RAM A. Since the inverse of /MREQ is already available, one NAND gate can be used as an inverter for A15, and the other can give the result of !/MREQ !& !A15 which should be low only when /MREQ and A15 are both low - exactly what's needed for RAM A's /CS line.
Does this all look correct? Did I miss anything obvious? I think I have it pretty well worked out, but I'm no expert on the low-level hardware end of things...
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: Memory-mapping logic - a thought
commodorejohn wrote:
I'm gearing up to put together an RC2014 system based on bluesky6's 6502 board, but I don't care for the existing RAM/ROM boards much (most of them are oriented towards a 32KB/32KB split...
With a 128KB SRAM you just tie A16 to ground and work with A0-A15. Your glue logic selects it if the address is below your magic ROM threshold. That's what I did in my POC unit, using nothing more than two gates (RAM is $0000-$CFFF).
Quote:
I know a lot of designs just use a 3:8 demultiplexer, but bluesky's 6502 design alerted me to the existence of the 74688 8-bit comparator...
The other consideration would be programmable logic, which usually has a fixed prop time that is not affected by logic complexity (in most cases).
- Attachments
-
- 74ac138_decoder.pdf
- 74AC138 3-8 Decoder/Demuxer
- (668.04 KiB) Downloaded 203 times
-
- issi_61c1024al.pdf
- 128K SRAM
- (842.18 KiB) Downloaded 216 times
x86? We ain't got no x86. We don't NEED no stinking x86!
- commodorejohn
- Posts: 299
- Joined: 21 Jan 2016
- Location: Placerville, CA
- Contact:
Re: Memory-mapping logic - a thought
Hmm, I hadn't realized the propagation time on it was that long. I suppose programmable logic would be another option - I have no familiarity with designing for it, but then again this whole thing is going to be a learning experience to begin with.
- GARTHWILSON
- Forum Moderator
- Posts: 8775
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Memory-mapping logic - a thought
Check out 74LVC:
http://www.ti.com/paramsearch/docs/para ... ax=5.25;36
Very fast, and most of them can use 5V power supply (not just 3.3V and 5V I/O tolerance!)
http://www.ti.com/paramsearch/docs/para ... ax=5.25;36
Very fast, and most of them can use 5V power supply (not just 3.3V and 5V I/O tolerance!)
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: Memory-mapping logic - a thought
commodorejohn wrote:
Hmm, I hadn't realized the propagation time on it was that long.
Quote:
I suppose programmable logic would be another option - I have no familiarity with designing for it, but then again this whole thing is going to be a learning experience to begin with.
If you can work out the logic using discrete parts you can work out the logic in a GAL or CPLD. You can also design an effective and fast machine using 74AC logic—that's what my POC V1 unit has, and it will boot at 15 MHz. What the programmable logic route gives you is the ability to develop a more elaborate memory map without having to get paranoid about prop delays.
GARTHWILSON wrote:
Check out 74LVC:
http://www.ti.com/paramsearch/docs/para ... ax=5.25;36
Very fast, and most of them can use 5V power supply (not just 3.3V and 5V I/O tolerance!)
http://www.ti.com/paramsearch/docs/para ... ax=5.25;36
Very fast, and most of them can use 5V power supply (not just 3.3V and 5V I/O tolerance!)
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: Memory-mapping logic - a thought
To make it simple, use two 32KB RAM chips.
Since you are using your own memory design, you can choose to connect pins 1-2 of the A15 option header. This will give you the raw A15 with no inversion.
The lower 32KB can be enabled with A15=0. You don't need to gate it with the /MREQ signal of the RC2014 bus.
For the upper 32KB, use a 74HCT138 (or 74ACT138 if you're concerned about speed, available from Mouser) to decode A14 and A13 to give you 4 blocks of 8KB. Of course, you would qualify the '138 with A15=1. The '138 output for the highest 8KB will be used for the EPROM.
The other 3 relevant outputs of the '138 will need to be ANDed and then ORed with /MREQ to generate the chipselect for the upper SRAM. A 3-input AND gate is the 74HCT11 which is also available from Mouser as is the ACT version.
Yes, the '138 has 8 outputs but since we are decoding only for A14 and A13, we will probably just tie pin 3 to ground to get 4 usable outputs.
Since you are using your own memory design, you can choose to connect pins 1-2 of the A15 option header. This will give you the raw A15 with no inversion.
The lower 32KB can be enabled with A15=0. You don't need to gate it with the /MREQ signal of the RC2014 bus.
For the upper 32KB, use a 74HCT138 (or 74ACT138 if you're concerned about speed, available from Mouser) to decode A14 and A13 to give you 4 blocks of 8KB. Of course, you would qualify the '138 with A15=1. The '138 output for the highest 8KB will be used for the EPROM.
The other 3 relevant outputs of the '138 will need to be ANDed and then ORed with /MREQ to generate the chipselect for the upper SRAM. A 3-input AND gate is the 74HCT11 which is also available from Mouser as is the ACT version.
Yes, the '138 has 8 outputs but since we are decoding only for A14 and A13, we will probably just tie pin 3 to ground to get 4 usable outputs.
- commodorejohn
- Posts: 299
- Joined: 21 Jan 2016
- Location: Placerville, CA
- Contact:
Re: Memory-mapping logic - a thought
Yeah, the '138 design is a pretty standard one, and if I don't go for the PLD approach I'll probably fall back on that. It just irks me somewhat to have a whole 8KB of RAM sitting there untouched underneath $E000-FFFF and it'd be nice to at least have the option to shrink the ROM window smaller than that if I feel like it.
I'm curious about this, though. Is gating with /MREQ unnecessary strictly because the I/O page is hard-wired to be in the upper half of memory? I'm thinking of putting the 74688 for the I/O select on a standoff and changing the wiring to relocate it to $0200 instead, so that might not work in that case.
bluesky6 wrote:
The lower 32KB can be enabled with A15=0. You don't need to gate it with the /MREQ signal of the RC2014 bus.
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: Memory-mapping logic - a thought
bluesky6 wrote:
For the upper 32KB, use a 74HCT138 (or 74ACT138 if you're concerned about speed, available from Mouser)...A 3-input AND gate is the 74HCT11 which is also available from Mouser as is the ACT version.
x86? We ain't got no x86. We don't NEED no stinking x86!
- GARTHWILSON
- Forum Moderator
- Posts: 8775
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Memory-mapping logic - a thought
Perhaps the '139 would be helpful. It's a dual 2-to-4 decoder, each decoder being sort of like half a '138, although it doesn't have as many gate inputs.
The 74LVC page I linked to earlier has loads of other small gates and gate pairs that might get you the functions you need and still get you in under timing budget even if it takes two or three parts, since you can get cascaded gate pairs with 3.5ns-4.5ns typ prop. delay, and even pairs of parts may land you in the 8ns range.
The 74LVC page I linked to earlier has loads of other small gates and gate pairs that might get you the functions you need and still get you in under timing budget even if it takes two or three parts, since you can get cascaded gate pairs with 3.5ns-4.5ns typ prop. delay, and even pairs of parts may land you in the 8ns range.
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Re: Memory-mapping logic - a thought
commodorejohn wrote:
I'm curious about this, though. Is gating with /MREQ unnecessary strictly because the I/O page is hard-wired to be in the upper half of memory? I'm thinking of putting the 74688 for the I/O select on a standoff and changing the wiring to relocate it to $0200 instead, so that might not work in that case.
BigDumbDinosaur wrote:
Unless the system contains devices that have TTL-level inputs, ACT and HCT logic is unnecessary and actually imposes a small performance penalty.
But what’s all this obsession with speed/performance anyhow?
If you want the absolute fastest, run a 6502 emulator on an Intel PC. Or for physical, use an SBC with PLCC devices and EPLD/FPGA logic. A simple bus-based design like the RC2014 will impose speed limitations e.g. bus signal integrity, signal lengths etc.
GARTHWILSON wrote:
Perhaps the '139 would be helpful. It's a dual 2-to-4 decoder, each decoder being sort of like half a '138, although it doesn't have as many gate inputs.
Re: Memory-mapping logic - a thought
If you are going to use an EEPROM you probably not trying to break any speed records - most EEPROMs do require about 120..150ns access time. This would roughly end up in 3 MHz cycle time. Using an EEPROM you should remember to insert a jumper or a pushbutton and pullup resistor into /WE to inhibit inadvertent writes.
You didn't say anything about I/O - your decode logic needs at least to have one deselect input (unselect RAM and ROM) to add somehow somewhere I/O space!
If you wish to change the RAM-ROM boundary (even dynamically during runtime) you could use an adder instead of a comparator. They are both similar slow (propagation delay time). Using the CARRYOUT from the adder to select ROM (and deselect RAM) you could change the takeover address as you wish.
Consider a 128K RAM and a 64K or more (Flash-)EPROM. With a four bit adder (74xx83) adding X to A15..A12 produces a carry for X >= 1. That means you could vary the amount of RAM from 4K (adding $F yielding RAM at $0000..$0FFF) minimum up to full 64K RAM (adding $0). The latter means NO ROM at all! If X comes from an I/O device (like 65C22) these lines are inputs after reset, so 4 pullup resistors are needed to start with X=$F => 4K RAM / 60K ROM. The power on setup program may change this then.
my 2 cents
You didn't say anything about I/O - your decode logic needs at least to have one deselect input (unselect RAM and ROM) to add somehow somewhere I/O space!
If you wish to change the RAM-ROM boundary (even dynamically during runtime) you could use an adder instead of a comparator. They are both similar slow (propagation delay time). Using the CARRYOUT from the adder to select ROM (and deselect RAM) you could change the takeover address as you wish.
Consider a 128K RAM and a 64K or more (Flash-)EPROM. With a four bit adder (74xx83) adding X to A15..A12 produces a carry for X >= 1. That means you could vary the amount of RAM from 4K (adding $F yielding RAM at $0000..$0FFF) minimum up to full 64K RAM (adding $0). The latter means NO ROM at all! If X comes from an I/O device (like 65C22) these lines are inputs after reset, so 4 pullup resistors are needed to start with X=$F => 4K RAM / 60K ROM. The power on setup program may change this then.
my 2 cents
- commodorejohn
- Posts: 299
- Joined: 21 Jan 2016
- Location: Placerville, CA
- Contact:
Re: Memory-mapping logic - a thought
GaBuZoMeu wrote:
If you are going to use an EEPROM you probably not trying to break any speed records - most EEPROMs do require about 120..150ns access time. This would roughly end up in 3 MHz cycle time.
Quote:
Using an EEPROM you should remember to insert a jumper or a pushbutton and pullup resistor into /WE to inhibit inadvertent writes.
Quote:
You didn't say anything about I/O - your decode logic needs at least to have one deselect input (unselect RAM and ROM) to add somehow somewhere I/O space!
Quote:
If you wish to change the RAM-ROM boundary (even dynamically during runtime) you could use an adder instead of a comparator. They are both similar slow (propagation delay time). Using the CARRYOUT from the adder to select ROM (and deselect RAM) you could change the takeover address as you wish.
Quote:
If X comes from an I/O device (like 65C22) these lines are inputs after reset, so 4 pullup resistors are needed to start with X=$F => 4K RAM / 60K ROM. The power on setup program may change this then.
Re: Memory-mapping logic - a thought
commodorejohn wrote:
Quote:
If X comes from an I/O device (like 65C22) these lines are inputs after reset, so 4 pullup resistors are needed to start with X=$F => 4K RAM / 60K ROM. The power on setup program may change this then.
B.T.W.: this way you could use a (faster) Flash-EPROM (like SST39Fxxx). They could be programmed in circuit - but only if you can access at least 32K. By switching in a few pages you can program that device and then reduce its appearance back to something you desire. Once only a fraction is accessible it cannot programmed or erased accidantially.
Re: Memory-mapping logic - a thought
commodorejohn wrote:
GaBuZoMeu wrote:
If you are going to use an EEPROM you probably not trying to break any speed records - most EEPROMs do require about 120..150ns access time. This would roughly end up in 3 MHz cycle time.
Using a CMOS CPU gives some better figures: a larger fraction of PHI2=0 already provides a valid address. So (again roughly) 3/4 of a cycle = tACC which then would cause tCYCLE = 4/3 tACC or 4/3 x 120ns = 160ns = 6 MHz. This is without decoding penalty. I guess you would end up somewhere around 5 MHz.
- commodorejohn
- Posts: 299
- Joined: 21 Jan 2016
- Location: Placerville, CA
- Contact:
Re: Memory-mapping logic - a thought
Ah, you know, I think I was confusing EEPROM with UV-erase EPROM, which I believe I have in 45ns form.