Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

What is multiplexing?

Status
Not open for further replies.
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?
I am curious, though, what is the CPU looking for on the address bus? A0-A2 keep going up by one, then starting over? Is it looking for ROM? What can possibly be done with the numbers 0-7(%111)? I still don't understand how to address. I will draw a schematic of how i understand this will all work, then i will post it, and see what you people think. Can someone explain addressing at a scale larger than just RAM/ROM? Please? Thanks.
 
A spot of bad news;
I have been thinking lately,
:D :D :D :D :D

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?

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.

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!)
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.
The Pentium chips have an upper limit on the amount of memory they can address also. They can address extra memory using what is called a Memory Manager chipset, but things get complicated when you do this. If you want to address memory it is best to choose a CPU that can address all that you will need.
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?
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.
I am curious, though, what is the CPU looking for on the address bus? A0-A2 keep going up by one, then starting over?
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.
If you put 16 LEDs on all the address lines, you would see that they all are toggling. Effectively they are counting from 0x0000 to 0xFFFF. The address lines also do DRAM refresh sequences between memory reads so don't let that mess with your mind. :D
 
Last edited:
--- Old programmers never die. They just call without return ---

ROFL! God, i haven't heard a joke that good in a long time! Thanks, you just brightened up my night! :)


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.

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? 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. :)

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.

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? Ok, things are clearing up now. Thanks a bunch. Once i get a camera, i will start posting pictures for you. I have a crappy one, but i don't have the software right now. I will get the disk from my friend the next time is see him. :)
 
Hi,
I think sunlight will erase an erasable.
But i'm not sure. I've never tried it.

John :)
 
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! :)
 
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?
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.
Video controllers are usually accessed via both Memory and IO commands. In simple terms, the pixels you see on your screen are just bytes in RAM mapped into the memory address space of your computer. Setting up the video card controller is done via IO ports or registers built into the controller.
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.
No problem. I can see that you are making the effort and that's what counts.
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?
Exactly!
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!
It would take forever even with the ozone hole. Better to get an Electrically erasable one instead of a UV erasable.
 
Last edited:
Oh well maybe not.

What pattern? i thought the ultra violet to be sufficient to erase,
i dunno about a pattern ....
although i've never actually done it, ive got the kit for the job,
but ive never used it.

John :)
 
I would suggest that you avoid building a video controller at this point. It isn't necessary at this point. You can either build a software UART, just like with a PIC, or add a hardware UART.

Basically, the microprocessor, like the microcontroller, is an input/output sequencing machine. To get the commands and data it needs, it "reads" from other devices (including memory). It also "writes" data to other devices. It chooses the device via the address lines and the control signals. When reading, the processor knows if it is fetching instruction bytes or data bytes.

You establish your address decoding scheme that chooses where data will be read or written, given a memory or port address. Closely related to this are the memory map and port map - tables or diagrams that tell you what to expect at each memory or port address. This is part of your design - it's your choice. (By the way, I/O can be made to look like memory, and memory can be made to look like I/O.)
 
Last edited:
Dont worry, i don't plan on making a video controller quite yet. :) I was just asking "what if" type questions. I still don't understand how Memory and other chips use the address bus. I know i have already asked for a lot from you, but could i have a diagram that explains this? I just don't understand it.
 
Ok, i am going to try to explain what i don't understand. So, i hope this goes well. :)

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?

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? I cant think of any examples off hand, but i know i have a few chips that require an address. I know there are a Memory Request, and an I/O Request, but how does this work? Do i hook up a multiplexer? If so, then what type? Oh, i am still so confused! I just don't get how to address the other hardware.

How do i choose what device is giving/receiving data through the data lines? Through addressing, correct? If so, then how do i assign an address to a certain device?
Ok, i just though of a device that i have that requires addressing. I have a Real Time Clock. The part number is RP5C15. How do i connect these type of devices to the address bus, plus the memory? This is really confusing me. :confused:
 
Decoding is the key.

Here is a block diagram of one of many address decoding schemes.

The address decoder is the logic that determines whether a chip will be used or not. Its input is some or all of the address lines. It can be combined with a memory or I/O request signal. I show the requests signals as extra inputs to the decoders. Its output is the signal that will be connected to a chip's enable/select pin.

Chips that are designed to interface to microprocessors have at least one signal called "chip enable" or "chip select". When the chip is enabled or selected, you can write data to it or retrieve data from it.

Decoding can be as simple as a single address line. Or you can decode with NAND gates. Another scheme is to use a decoder chip (see kchriste's schematic) to get multiple select outputs. Some chips have multiple enable/select inputs (see RAM chip in Nigel's schematic), which means they can do some or all of the decoding.

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. Decoding determines if that will be true or not.
 

Attachments

  • SramIF1.JPG
    SramIF1.JPG
    19.2 KB · Views: 166
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?
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.
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?
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).
 
Last edited:
So, there should be more circuitry? But there are only 16 address lines? If the RAM chip requires 12 address lines, then there are only four left for controlling the address decoder? AAH! This is so confusing. I refuse to give up, though. I have been adding more and more circuitry to that test circuit. I was wondering, is it possible to add a DIP switch to the data lines, and then hard wire a program? Like flip all of the switches to make it seem like there is a command there? I know some commands take multiple clock cycles to activate, but, is there any simple things i could do while i wait for the thing that i am going to order come? I just want to play around, but is there anything fun i can do with it right now? I have gathered quite a bit of hardware over the summer. I have a TON of SN74LS244's, and quite a few F/Fs. Any ideas? I am board. And this circuit looks too sexy to disassemble.

Could i run the z80 right from a PC? Could i connect my parallel port to the datalines, and hook up a few other do-dads, then do you think i could run the thing? Sounds like it might be fun. How would i figure out what the commands are in binary?
 
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

Aaah, now i feel embarrassed. I meant 32k of ROM and 32k of ram. Not 16k, sorry. I don't think very well when i am tired. When you reply, it is about midnight here, you will have to bare with me. :) So, it would have been right, if i hadn't made that typo? Cool. :cool:

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).

I didn't understand a thing there. I am really to tired to understand anything right now. I will sleep on it, and then i will re-read this entire tread tomorrow. Maybe i overlooked something? I am hoping it will jump start something in my head. :) lol. Thanks! If i have anymore questions, i will post them! You both have been very helpful so far! :) Thanks a million!
 
Last edited:
Aah-ha! I get the addressing now! The demux will chose what chip has access to the busses? So while one chip is active, then the others are all in the high impedance state? Ok. :)

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?
 
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?
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.
was wondering, is it possible to add a DIP switch to the data lines, and then hard wire a program?
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.

Sounds like it might be fun. How would i figure out what the commands are in binary?
This is one site that looks easy to use:
http://www.cantrell.org.uk/david/tech/cpc/cpc-firmware/z80index.pl
This site gives a brief decription of each instruction:
http://fms.komkon.org/comp/CPUs/z80.txt
 
Last edited:
Awesome! Ok, tomorrow after i get home, i will draw up a schematic of what i think should work. I am hopping you can tell me if it is correct or not.

Also, i have been thinking about putting the data on the EEPROM. Is there any hardware and software out there to do all of this for me? I could make the stuff on my own, but i don't want this to be the reason i give up. I don't want to buy anything, so when i say hardware, i mean the schematics. :) Thanks kchriste!

Oh, i almost forgot. I am getting the software that is for my camera this weekend, so i will be able to post pictures! :) (They aren't very hires, but they may give a good idea :))
 
Check this link out. It requires an XML viewer, but i think it is my answered prayer. (although i don't believe in God, it is just a figure of speech. :) )

https://www.ticalc.org/pub/text/z80/z80.zip

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! :) Am i correct, or am dreaming. I am pretty damn sure i am right, because i checked, and 00 is in fact a NOP, and it takes EXACTALLY 4 clocking cycles to finish the command! :) :) :) :) :)

Tomorrow my friend, is going to come over. I am going to build a circuit to manually program this thing! OOOh! I am so excited! So, there are exactly 256 commands available. Aaah, this is AWESOME!

I owe much of it to you, kchriste. Thank you! You didn't give up on me, AND I FINALLY UNDERSTAND IT! I don't think i know this on a basic level, anymore. I think i have reached MODERATE LEVEL! Thank you SO MUCH! Man, electronics are awesome! Especially when they work like you think they should! :) Thank you, thank you, thank you! Now that i know the binary commands, i think i should be able to make my own compiler! :cool:

Oooh, i already have ideas! Tomorrow is going to be an interesting day! :)
 
Last edited:
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!
Ok, are you sitting down? On the toilet? Ready?
.
..
...
....
......
YES! It's true! :D

I owe much of it to you, kchriste. Thank you! You didn't give up on me, AND I FINALLY UNDERSTAND IT!
And now, you've gone and made my day. Thank you! :)
 
*Sigh* We built a VERY nice switch board, but i ran out of jumper wires, hex inverters, and resistors. :( I am going to order the components tomorrow(Monday). This is what i have on my list so-far(All prices are in US currency);

1. 16k EEPROM...........................................$2.29
2. 16k SRAM..............................................$1.79
3. 100 LEDs (assorted)................................$6.95
4. 200 Resistors(assorted.............................$5.49
5. 100 POTs (100Ω to 5MΩ).........................$6.95

There is most likely a few more thing i will get, but i am looking through the catalog right now. :)
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top