6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 15, 2024 4:12 am

All times are UTC




Post new topic Reply to topic  [ 24 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Address decoding logic
PostPosted: Thu Nov 01, 2012 5:36 pm 
Offline

Joined: Thu Nov 01, 2012 5:21 pm
Posts: 6
Hello,

I'm currently assembling a parts list for my first SBC. I have been following schematics of other members (and non members) online, and have a decent idea of the layout and schematic that I'm looking for. One area that did not match however was the decoding logic. I have no experience in this area, and didn't find much information online. I decided to keep things simple, and let the upper 4 bits of the address space define the logic points. I sketched out my proposed decoding logic, and hope that someone can provide feedback.

Memory Map:

0000 - CFFF RAM
D000 - DFFF I/O
E000 - FFFF ROM

*edit* Adding address table to add to the logic:
Code:
15|14|13|12|
1 |1 |0 |0 | RAM
1 |1 |0 |1 | I/O
1 |1 |1 |0 | ROM


Please see attached image for schematic.


Attachments:
decoding_logic.jpg
decoding_logic.jpg [ 91.1 KiB | Viewed 1275 times ]
Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 01, 2012 5:59 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8541
Location: Southern California
Welcome!

Quote:
One area that did not match however was the decoding logic. I have no experience in this area, and didn't find much information online.

section in the primer: http://wilsonminesco.com/6502primer/addr_decoding.html

Your RAM must have phase 2 brought into the write-enabling. (Maybe you're doing it in another circuit you're not showing.) Since RAM tends to be a lot faster than ROM, you can optionally bring the phase 2 into the RAM's select logic instead which may simplify things without slowing the system down.

A couple of things to address: You have A14 and A15 going into an AND gate for the RAM (and that going into another AND), which means both A14 and A15 will have to be high to enable RAM, meaning that to start, you won't get any RAM outside the C000-FFFF area. Also, inverting A12 before going into an AND for ROM select will exclude the range of F000-FFFF, and you'll definitely need that, at least for the vectors.

Also, enables are mostly active-low, probably because NAND and NOR gates tend to be faster than AND and OR gates.

_________________
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?


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 01, 2012 6:19 pm 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
Consider using 16k rom, so you can install systems like EhBasic.


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 01, 2012 11:08 pm 
Offline

Joined: Thu Nov 01, 2012 5:21 pm
Posts: 6
Thanks Garth,

I found the link very useful. There's a lot to think about, but so far it's been a big help. Phi2 and WE / OE for ram will be addressed in a more complete schematic. I addressed the problems you pointed out, and only had to add an extra logic gate to make things fit. As per your article, this is still probably over complicated.

I took your suggestion for integrating Phi2 into select. I added it to the other select lines as well.


Dajgoro, I am hoping to do most of my programming in CC65. I also have (lofty) goals of someday adding an MMU to the system so I wanted to save as much space as I could for memory.


Attachments:
address_logic2.jpg
address_logic2.jpg [ 34.13 KiB | Viewed 1255 times ]
Top
 Profile  
Reply with quote  
PostPosted: Fri Nov 02, 2012 1:02 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8541
Location: Southern California
Quote:
I took your suggestion for integrating Phi2 into select. I added it to the other select lines as well.

Most 65-family I/O ICs can't have phase 2 in the chip selects. The selects have to be valid and stable a certain amount of time before phase 2 goes up. And since ROM tends to be slower, letting it get started before phase 2 goes up helps get a greater system speed from a given ROM speed, so you won't generally want it there for ROM with a 6502 system (although you do for a 65816 system). IOW, just bring phase 2 into the RAM select, not the others.

_________________
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?


Top
 Profile  
Reply with quote  
PostPosted: Fri Nov 02, 2012 2:43 pm 
Offline

Joined: Thu Nov 01, 2012 5:21 pm
Posts: 6
OK I removed Phi2 from the other select lines. Thanks again.


Top
 Profile  
Reply with quote  
PostPosted: Fri Nov 02, 2012 2:48 pm 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
HCF wrote:
Dajgoro, I am hoping to do most of my programming in CC65. I also have (lofty) goals of someday adding an MMU to the system so I wanted to save as much space as I could for memory.


Ah, CC65 i am still trying to figure out how to make it boot from rom properly. Now i am in the phase in constructing a new cpu board with an memory mapper(sorta mmu) and dma.
How are you planning to boot your cc65 programs into ram?

Looking at the sbc-2 schematic, i can see that phi2 is only integrated into the r/w signal and not in the chip select. I followed that schematic when building my sbc and it works. So if i didn't miss something on the schematic that means that when phi2 is not active, the ram actually reads on a write cycle(but for a very short amount of time).


Top
 Profile  
Reply with quote  
PostPosted: Fri Nov 02, 2012 6:56 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8487
Location: Midwestern USA
HCF wrote:
Memory Map:

0000 - CFFF RAM
D000 - DFFF I/O
E000 - FFFF ROM

Here's how I did it in my POC V1:
Attachment:
File comment: POC V1 Glue Logic (orig)
sbc_v1_glue_logic.gif
sbc_v1_glue_logic.gif [ 34.87 KiB | Viewed 1218 times ]

The WDL signal goes low only when RWB goes low and Ø2 goes high, which in this case, means the EPROM will not be selected if a write is in progress. In this particular case, the write goes to nothing, as nothing will be selected. You could rig it up to write to RAM, which means it would be bleeding through in the $E000-$FFFF range.

As Garth previously noted, you do not want to write to any hardware while Ø2 is low, as the address and data buses may be in a state of flux at that time. In particular, you could corrupt a RAM location with a wild write while Ø2 is low. So the WDL signal does double duty.

The 74AC138 decoder produces eight active low chip selects in one page increments in the range $D000-$D7FF, which is more than enough for your first project. Incidentally, avoid the temptation to use 74LS logic. Stick with 74AC or 74HC, the former being preferable for reduced propagation time and better fanout.

As for using Ø2 to qualify chip selects, I strongly recommend that you do not do so. Both the 65C02 and 65C816 will have stabilized the address bus by the middle of Ø2 low, at which time a valid chip select is possible (the 65C816 also has two outputs to assist in determining when the address bus is valid). Qualifying chip selects with Ø2 needlessly limits the circuit's performance, as the window for accessing memory or I/O is narrowed to about one-half the bus cycle time. In my POC V1 unit, which can run at 12.5 MHz, I do not qualify selects with Ø2.

GARTHWILSON wrote:
Most 65-family I/O ICs can't have phase 2 in the chip selects. The selects have to be valid and stable a certain amount of time before phase 2 goes up.

Please take note of this characteristic if you plan to use 65xx peripheral silicon. Otherwise you will be scratching your head and using dirty words while trying to get your unit to function.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Fri Nov 02, 2012 7:25 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8487
Location: Midwestern USA
Here's some more circuitry:
Attachment:
File comment: Read/write qualification with Ø2.
read_write_qual.gif
read_write_qual.gif [ 17.51 KiB | Viewed 1215 times ]

The above circuit generates read/write signals qualified with Ø2, with the truth table explaining the whole mess. This circuit or something similar to it should be included in your design. It will work with the 65C02 and the 65C816, as long as the latter's bank addressing feature is not being used.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Fri Nov 02, 2012 8:56 pm 
Offline

Joined: Thu Nov 01, 2012 5:21 pm
Posts: 6
As mentioned previously I removed the Phi2 signal from the other select leads. I like your use of quad input gates BDD.. it simplifies the logic count.

I plan to use 74AC logic as recommended. Initial speed will be 1 or 2 mhz. I will probably pickup the quad logic gates however to mimic your sbc1 setup.

Building logic gates is a bit tricky for me to keep track of in my head so far. Is there an easy way to bump up your I/O select logic to 512 bytes per increment?

The R/W qualification circuit looks simpler as well. I am using the WDC 65C02 processor.


Last edited by HCF on Fri Nov 02, 2012 9:14 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Fri Nov 02, 2012 8:59 pm 
Offline

Joined: Thu Nov 01, 2012 5:21 pm
Posts: 6
Dajgoro wrote:

Ah, CC65 i am still trying to figure out how to make it boot from rom properly. Now i am in the phase in constructing a new cpu board with an memory mapper(sorta mmu) and dma.
How are you planning to boot your cc65 programs into ram?

Looking at the sbc-2 schematic, i can see that phi2 is only integrated into the r/w signal and not in the chip select. I followed that schematic when building my sbc and it works. So if i didn't miss something on the schematic that means that when phi2 is not active, the ram actually reads on a write cycle(but for a very short amount of time).


What are you using for a memory mapper?

For booting purposes I plan to follow an approach others used of having a simple terminal program that connects via serial cable. Programs will be uploaded and then executed until something more permanent is designed.


Top
 Profile  
Reply with quote  
PostPosted: Fri Nov 02, 2012 10:53 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8487
Location: Midwestern USA
HCF wrote:
As mentioned previously I removed the Phi2 signal from the other select leads. I like your use of quad input gates BDD.. it simplifies the logic count.

I plan to use 75AC logic as recommended, and the delay times are under 10ms a piece. Initial speed will be 1 or 2 mhz. I will probably pickup the quad logic gates however to mimic your sbc1 setup.

I assume you meant 74AC...

The quad gates not only simplify decoding circuitry, they consume less board space. I fooled around with several combinations of gates before settling on the above circuit.

Quote:
Building logic gates is a bit tricky for me to keep track of in my head so far. Is there an easy way to bump up your I/O select logic to 512 bytes per increment?

Well... :? :lol: It wouldn't be good to tell you exactly how to do it because you wouldn't be learning anything that way. So I'll give you some hints.

The A12-A15 inputs to U6 and U9 are what select the I/O block when the address is $Dxxx, where xxx is anything. That is, the expression A15 & A14 & !A13 & A12 must be true in order for I/O block selection to take place (where & is logical AND and ! is logical NOT). The resulting bit pattern, 1101, is hex $D, so it is patent that the page-wise "partitioning" of the I/O space is determined by the bit pattern on the 'AC138's A0, A1 and A2 inputs.

As you can see, the MPU's A8, A9 and A10 lines drive A0, A1 and A2 on the decoder. A8 is equal to 2^8, A9 is equal to 2^9 and A10 is equal to 2^10. 2^8=256, so that's where the one page increment comes from. The final hint involves the A11 line, which you don't see anywhere in the circuit... :D There are only three inputs to the decoder, so you should be able figure it out from here.

BTW, any particular reason for partitioning the I/O block in two page chunks? You're not gaining anything by doing so, as the 74AC138 only has 8 outputs. I use one page increments because it opens the door to adding another decoder to fill the range $D800-$DFFF, allowing up to 16 devices, if the need arises.

Quote:
The R/W qualification circuit looks simpler as well. I am using the WDC 65C02 processor.

Using the WDC part is a wise choice, as it is the definitive version, plus it can be run at any speed you might care to try (up to 20 MHz at 5 volts). Be sure to pull up unused inputs to Vcc to avoid unpleasant surprises.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Sat Nov 03, 2012 12:12 am 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
HCF wrote:
What are you using for a memory mapper?


I use the 74LS612, but somebody here called it "old silicon".
It fits my needs, so i decided to use it.
I bough it form ebay, here is the item:
http://www.ebay.com/itm/1PCS-SN74LS612N ... 33772b1fc2


Top
 Profile  
Reply with quote  
PostPosted: Sat Nov 03, 2012 1:25 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8487
Location: Midwestern USA
Dajgoro wrote:
HCF wrote:
What are you using for a memory mapper?


I use the 74LS612, but somebody here called it "old silicon".
It fits my needs, so i decided to use it.
I bough it form ebay, here is the item:
http://www.ebay.com/itm/1PCS-SN74LS612N ... 33772b1fc2

Old, slow, weak fanout and at four dollars each, way overpriced. I would only consider buying one of these things if I were trying to revive vintage hardware. Everything that the 'LS612 can do can be done much faster, more elegantly and for less money in a PLD.

Once you get to where you want to break free of the 65C02's 64 KB limit you should focus your attention on the 65C816, rather than use smoke and mirrors to trick the 'C02 into seeing more RAM than it can actually address. Just an opinion, of course.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Sat Nov 03, 2012 3:58 am 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
An xc9536 or xc9572 cpld can be used as a memory mapper, since they are cheap and run on 5V.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 21 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: