A spot of bad news;
I have been thinking lately,
but the Z80 has a 16bit address bus. If i am correct, FFFF, is 1111111111111111 in binary, and 65535 in decimal. All of those are 16bit in binary, and this just so happens to be the max that the address bus can do. So, if all the addresses are used up, then how can i address other things, like an I/O chip, or a buffer, or some Flash Memory, or a CRT Controller?
In software you run into the same problem. The largest registers in the Z80 are 16bit so that's the largest range you can address.I know things vary from one chip to another, but i am talking a generic explanation. Could someone explain the "Whole picture" to me? Please? Thanks! (Oh, also, i am talking hardware AND software, thanks!)
Yes, this is normal. The older chips were alot more power hungry than the equivilant chip made today. The typical current draw for a Z80A is around 90ma which is 0.45 watt at 5V, so it will get warm.Ok, i built the circuit, and it works just fine. The only thing that concerns me, is the Z80 gets warm. I'm not talking really hot, just lukewarm. Is this normal? I am feeding 5 volts into it, so, what?
Simply, when the Z80 is reset, it sets the address lines to 0x0000. It then pulses RD and MREQ low to read some info from ROM/RAM via the data bus at that address. Because of the way that the test circuit is designed, the Z80 sees 0x00 on the data bus because the 470R resistors are all tied to ground. 0x00 to the Z80 is a NOP instruction (An instruction that does nothing but waste one cycle of execution time) so the Z80 then increments the address buss by one more so that it is now 0x0001 and reads the next instruction. The resistors keep saying NOP and the Z80 keeps incrementing the address bus. Therefore the LEDs keep flashing the same pattern over and over. If there was an actual ROM chip there, the Z80 would excute the instructions contained in the ROM and the data bus would contain meaningfull op-codes that would flash a LED on an IO port or something.I am curious, though, what is the CPU looking for on the address bus? A0-A2 keep going up by one, then starting over?
--- Old programmers never die. They just call without return ---
Basically you can't. As you've figured out, the Z80 can only address 64K of memory. You have to divide your RAM / ROM and Video RAM so it's sum total fits the 64K address space. 32K Ram 16K ROM and 16K video would max you out. IO is mapped separately on the Z80 using the pin IORQ (IO request) as opposed to the MREQ (Memory Request) pin.
Simply, when the Z80 is reset, it sets the address lines to 0x0000. It then pulses RD and MREQ low to read some info from ROM/RAM via the data bus at that address. Because of the way that the test circuit is designed, the Z80 sees 0x00 on the data bus because the 470R resistors are all tied to ground. 0x00 to the Z80 is a NOP instruction (An instruction that does nothing but waste one cycle of execution time) so the Z80 then increments the address buss by one more so that it is now 0x0001 and reads the next instruction. The resistors keep saying NOP and the Z80 keeps incrementing the address bus. Therefore the LEDs keep flashing the same pattern over and over. If there was an actual ROM chip there, the Z80 would execute the instructions contained in the ROM and the data bus would contain meaningful op-codes that would flash a LED on an IO port or something.
What the Z80 does is sets the address lines and then activates the MREQ & RD pins when it wants something from Memory. When it wants to read an IO port the Z80 sets the address lines and activates the IORQ & RD pins. So effectively IO and Memory addresses are multiplexed on the address bus by the Z80. It is up to you to wire the correct chips to either the IORQ or MREQ lines.So, the address bus is only for memory? Then how would i connect a Video Controller, or an I/O device? Or would you connect the IORQ and the MREQ to a multiplexer, and then let that decide what gets the busses?
No problem. I can see that you are making the effort and that's what counts.Please forgive my lack of knowledge on this subject, i can guarantee you that i am doing my homework, and i like to give credit where credit is due.
Exactly!Oh! So the Z80 is looking for that first bit of code! I see! So, the address bus looks for ROM, and the data bus will give the CPU the command?
It would take forever even with the ozone hole. Better to get an Electrically erasable one instead of a UV erasable.I don't think so. I have looked at some of the EPROM datasheet's, and they need a certain pattern of UV to erase them Good idea though!
Not exactly. Decoding determines if that will be true or not.If the Z80 can address up to 64k of memory, and i have 32k of ROM and 16k of RAM, then ROM will have the addresses 0x0001 to 0x7FFF, and ROM will have 0x8000 to 0xFFFF, correct?
Not exactly. Typically, with the Z80, the 32K ROM would go from 0x0000 to 0x7FFF. Then the 16K of RAM could go from 0x8000 to 0xBFFF. The address space of 0xC000 to 0xFFFF would be unused in this example or you could map the RAM into this space instead. How things get their address number depends on how you wire it up as I will explain below.I don't get how things get their address number.
If the Z80 can address up to 64k of memory, and i have 32k of ROM and 16k of RAM, then ROM will have the addresses 0x0001 to 0x7FFF, and ROM will have 0x8000 to 0xFFFF, correct?
It is determined by how the address is decoded. Lets say, just for this example, you have 16 equal sized (4k) memory devices that you want to interface on the Z80 address buss. This would make them 4K memory devices maximum because 64 / 16 = 4.But i don't understand how i can address other hardware. If i want to address a certain chip, then how do i know what it's address is?
0xF000 + 0x0FFF = 0xFFFF
^ ^^^ ^^^^
1st 2nd entire thing
Not exactly. Typically, with the Z80, the 32K ROM would go from 0x0000 to 0x7FFF. Then the 16K of RAM could go from 0x8000 to 0xBFFF. The address space of 0xC000 to 0xFFFF would be unused in this example or you could map the RAM into this space instead. How things get their address number depends on how you wire it up as I will explain below
It is determined by how the address is decoded. Lets say, just for this example, you have 16 equal sized (4k) memory devices that you want to interface on the Z80 address buss. This would make them 4K memory devices maximum because 64 / 16 = 4.
Ok, so what you do in your mind is split the Hex digits that represent the address buss into two parts:
Code:
0xF000 + 0x0FFF = 0xFFFF
^ ^^^ ^^^^
1st 2nd entire thing
The upper digit controls a 1 of 16 demultiplexer. It will select one of the 16 memory devices. The lower 3 digits select memory within the device selected by the demultiplexer. For example:
0x1ABC will select byte number 0xABC in memory device #1
0x2ABC will select byte number 0xABC in memory device #2
0xAABC will select byte number 0xABC in memory device #10
0x1678 will select byte number 0x678 in memory device #1
and so on...
The same basic rules apply for accessing IO or Memory mapped devices. The only difference is whether the Z80 exerts the MREQ or the IOREQ line which are tied to the correct address demultiplexer ( One Demux for Mem and one for IO devices).
Yes, exactly like that; connect the enable line of one demux up to the to the MemRQ and the enable line of the other to the IORQ line from the Z80.The only thing i still don't understand yet, is how to select memory or i/o. Should there be another mux/demux? Would i connect the enable lines of the demux's up to the to the MemRQ and the IORQ?
It is possible to use a diode matrix and a demux wired to the lower address lines to create your own ROM, but that would be very painfull to do. You can also play around a bit by rewiring some of the resistors on the databus to +5V instead of Gnd. You'll see a change on the address LEDs flash pattern.was wondering, is it possible to add a DIP switch to the data lines, and then hard wire a program?
This is one site that looks easy to use:Sounds like it might be fun. How would i figure out what the commands are in binary?
Ok, are you sitting down? On the toilet? Ready?Am i correct when i say that is what the commands are in binary? The tops of the charts, they say something like "00+X". I know that the X means add the number of the command in the column. Is this true? If it is, i just might crap my pants!
And now, you've gone and made my day. Thank you!I owe much of it to you, kchriste. Thank you! You didn't give up on me, AND I FINALLY UNDERSTAND IT!
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?