Connetc 2 Arduino to same SRAM

Hi everybody. I wuold like to start some experiments with SRAM.

I would like to create a simple computer using 2 Arduino connected to a breadboard where there is a SRAM chip.
The first Arduino, the "CPU", will execute some code and generate several datas (for example a Game of Life) that it will write into the SRAM chip.

The second Arduino, the "VDC" (Video Display Controller) will read from the same memory the datas and will display them into an LCD.

My question is: how can I connect the two Arduino to the same RAM?
Is there a way to tell an Arduino not to access the RAM when this is busy ( for read/write) with the other Arduino?

Don't ask me with I don't use the same Arduino for both tasks: in this experiment I would like to learn how to share the chips between mCs.

1 Like

I would like to use some sort of less "exotic" components, like normal SRAMs or I2Cs.
Let me explain. It's just in the old computers from '80s: a way to have alternative access to the same addresses of memory.
First "A" writes, then "B" reads, then "A" writes again and "B" reads and so on.

You can use less exotic components, but you just move the complexity to your bus arbitration.
Since the Arduino's aren't synced. this really is a non-trivial problem.

Actually the old school way to do it was with dual port memory. One port sat on the computers bus and the other port sat on the video controller's bus. That's why it was called "video memory". They don't used it any more because video card markers wanted to take advantage of the commodity pricing of DRAMs so they added complexity to their designs to accommodate the limitations.

How much memory do you need for your frame buffer? You could use the local memory of the "video arduino" and code it to look like a SPI ram (or parallel even if you have enough extra pins).

Will you be using serial-access SRAM, or parallel access?
If parallel, you need have tri-state (or open collector) buffers on the address, data, and control lines such that one arduino can access the part without interference from the other.
The Master arduino can have an output pin that it toggles to let the slave know it is done accessing the SRAM, and the slave can do the same back to signal it is done reading (assuming similar rate of data in & out).
Same for Serial SRAM, such as

Fewer pins to control.
The Arduino-arduino could be serial comm's also, #1 saying (I wrote xx bytes at location yy), and the second sending simple message back (reading, done reading).

The mega arduino using the 1280 chip has hardware features in the chip to handle interfacing to external ram, the information is in the avr 1280 datasheet. You will require either dual port ram or extra circuitry to prevent collisions if trying to share the ram with two mega boards.

Lefty

Thanks for the suggestions to everyone.

Serial Vs. Parallel:
I don't know :wink:
This project should be a test before using my new Z80B that I got from Ebay :slight_smile:
The second Arduino will be replaced by the Z80 in a future, so I have to find some components that:

  • can be built together;
  • can be accessed from both systems (Arduino/Z80);
  • are easy to find and cheap.

I could try to use I2C SRAMs, that in a future could be accessed from the Z80 via a I2C bus controller like PCF8584.

I think this approach would be a lot of fun. Just need a handful of chips.

Ohhhhh :o
thanks!!! even if I don't undestand much of the schematic ;D

Well, you've got an address bus, A0-A15. you've got a data bus, D0-D15. You've got 3 shared control lines, ChipSelect, OutputEnable, WriteEnable, all active low (/).
Then you've got control lines from each arduino to work their respective shift registers.
One set of controls to shift out an address. One set of controls to shift out the data to be written. One set of controls to shift in the data to be read. One set of controls to do the read/write of the SRAM once the address is in place.
So a sequence might go like this (after determining that it was one sides turn to access the SRAM via lines I didn't put in)

  • shift out address, load it to the output register (shift registers are usually double registers, shift in to the the 1st then, then load the 2nd one all at once)
  • if writing, shift out data, load it to the output register
  • turn on the registers output enable
  • bring ChipSelect Low
  • if writing, bring WriteEnable low, then back high
  • bring ChipSelect High (can be together, the combinationi of the two does the writing)
  • if reading bring ChipSelect and Output Enable Low (can be together, the combination does the reading)

latch the data into the shift in register
shift in the data to the arduino
Bring the SRAMS CS & OE high

  • shift out the next address & data byte
  • repeat control signals, or turn off register OutputEnable if done

If the addressing will always be sequential addresses, the shift registers could be replaced with pre-loadable counters instead, then just load in the start address and count up for the next address.
The Shift register can even be just octal buffers like 74xx374, can be wired up to look like the first stage of shift register since you will not care if the address lines to the SRAM wiggle around while loading, you just need them loaded prior to the SRAM chip select going low.

Thank you for the details. I'll study on this schematic trying to get out some sort of circuit.

Try this, need to paste the 2 together.

Superb!
Thank veeeery much :smiley:

Of course, a simpler approach of sharing a serial SRAM via SPI or I2C would require far less components, but is less impressive looking on a breadboard and would not take nearly as much coding. But if you happen to enjoy the actual wiring, debugging, etc this can be a lot more fun!
Can also expand & add other memory also - just need to either add more address lines for a bigger chip, or more Chip Selects to other chips.

My will is to build a very simple 8 bit computer.
The second Arduino should be replaced by a Z80. So I will have to connect some sort of input, like joystick and keyboard.

I've found a simple OS, too. CamelForth, that is available for Z80. For the software side, I think to use BBC Basic, also for Z80.

But right now, this scheme is an important step for me :wink: