Memory Mapped Input and Output

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Memory Mapped Input and Output

Wain L
I am really confused as to how ram can be used to draw pictures or get input from keyboards and stuff like that. someone please explain
Reply | Threaded
Open this post in threaded view
|

Re: Memory Mapped Input and Output

WBahn
Administrator
It's fairly simple, actually.

Imagine you are the processor and the RAM is a whiteboard. There are a bunch of difference boxes on the whiteboard representing the different RAM addresses. When you want to change a value in memory, you walk over to the board and write a new value there. When you want to read a value in memory, you simply look at the value written there.

But now I'm sitting off to the side and I can also look to see what is written on some portion of the board. I use the values I see to set pixels on the display either one or off. That's what the display controller does.

In the case of the keyboard buffer, I also have the ability to write to some of the memory addresses on the board so that when you look over there, you see the value I wrote.

Physically, this can be implemented in one of a number of ways. One way is to simply use a MUX so that someone else can take over control of the RAM address and data lines. Perhaps the CPU has control on one half of the clock cycle (the half that it needs to make things work) and the external controllers have control on the other half. There's also such a thing as dual-port RAM where the RAM has two sets of address lines and data lines. One of them can be used to read and write to the RAM while the other can only be used to read from the RAM. The CPU has access to the read/write side of the screen RAM while it only has read access to the keyboard RAM.
Reply | Threaded
Open this post in threaded view
|

Re: Memory Mapped Input and Output

Wain L
So, for example say you have one memory address set as an output register. Is there a way to make it so that all the memory is contained in one place? for example if i had 10 addresses and one of them as output, can i have all the 10 slots together or do i have to have one of them somewhere else specifically for output?
Reply | Threaded
Open this post in threaded view
|

Re: Memory Mapped Input and Output

WBahn
Administrator
Wain L wrote
So, for example say you have one memory address set as an output register. Is there a way to make it so that all the memory is contained in one place? for example if i had 10 addresses and one of them as output, can i have all the 10 slots together or do i have to have one of them somewhere else specifically for output?
I don't think I'm following exactly what you are asking. Are talking about all 10 output registers being at the same address? Or about all 10 output registers being located in ten adjacent memory addresses?

If the latter, than yes. In fact that makes it easier. But, in theory, you could park them wherever you wanted them.

On the old PCs you had the I/O bus which was little more than a section of the RAM address space that mapped to a bunch of card slots on the motherboard. You configured the card, usually with jumpers, to respond to a certain range of addresses and it was your responsibility to make sure that no two cards overlapped in the ranges they responded to.
Reply | Threaded
Open this post in threaded view
|

Re: Memory Mapped Input and Output

Wain L
But I need all the memory slots together as a single unit for compactness. I have to do actual wiring, not that HDL thingy that does wiring for you. How would i do it so a single register can use its output for things like a screen but also be used for the actual alu and cpu?
Reply | Threaded
Open this post in threaded view
|

Re: Memory Mapped Input and Output

Wain L
In reply to this post by WBahn
most drawings ive seen tell me to have the ram unit and then next to it the io ports. i dont want to do that because it requires a lot of wiring and that takes time and looks bad. is there any way to still get the same functionality with all the ram and io as a single unit?
Reply | Threaded
Open this post in threaded view
|

Re: Memory Mapped Input and Output

Wain L
In reply to this post by WBahn
Also, how would I connect a screen to the CPU? the book said that i needed to make the ram be the screen, so those 16 kilobytes of ram are the screen. how does that work? is there a way to do it like a matrix decoder so it uses less memory??? please help im very confused
Reply | Threaded
Open this post in threaded view
|

Re: Memory Mapped Input and Output

WBahn
Administrator
In reply to this post by Wain L
A single register can store just one single value at a time. If you use a single register as your entire interface for everything, you will become bottlenecked by having to service that register constantly. If you use it for both input and output, that also means that you have to multiplex it and it is only available for input a portion of the time. You will need to implement a protocol in hardware to manage all of that.

Implementing a bus interface is much, much easier. You already have a bunch of address lines and data lines running from your CPU to you RAM. You use those same lines (assuming you don't have dual port RAM) to communicate with all of your other devices, including your screen and your keyboard and everything else. A common approach is to have a master clock running at one speed and then you cut that in half so that you have two clocks running at have speed. One clocks the CPU and the other clocks the peripherals. You then have a simple MUX that switches the buses between the two.