Wire a RAM in five steps
- Place a RAM from the Memory library.
- Connect the address (A), the data input (DI) and the data output (DO).
- Connect Store and Load: they are separate pins in the default mode.
- Connect a clock to the clock pin.
- Write, then read: Store = 1 with a rising edge, then Load = 1 with a rising edge.
| Address | in | Address: location accessed in memory |
|---|---|---|
| Data | out | Data: value loaded from address |
| Input | in | Input: value to be stored at address |
| Load | in | Load: if 1, load memory to output |
| Store | in | Store: if 1, store input to memory |
| Clock | in | Clock: memory value updates on rise from 0 to 1 |
No rows match.
Describe this circuit
Components: Input pin A; Input pin DI; Input pin Load; Input pin Store; Input pin CLK; RAM 1; Output pin DO.
- Input pin A connects to RAM 1 (net A, a), 8 bits wide.
- Input pin DI connects to RAM 1 (net DI, di), 8 bits wide.
- Input pin Load connects to RAM 1 (net Load, load).
- Input pin Store connects to RAM 1 (net Store, store).
- Input pin CLK connects to RAM 1 (net CLK, clk).
- RAM 1 connects to Output pin DO (net do, DO), 8 bits wide.
| # | A | DI | Load | Store | CLK | DO |
|---|---|---|---|---|---|---|
| 0x3 | 0xab | 0 | 1 | 0 | U | |
| 0x3 | 0xab | 0 | 1 | 1 | U | |
| 0x3 | 0xab | 0 | 0 | 0 | U | |
| 0x3 | 0x0 | 1 | 0 | 0 | U | |
| 0x3 | 0x0 | 1 | 0 | 1 | 0xab | |
| 0x3 | 0x0 | 1 | 0 | 0 | 0xab | |
| 0x4 | 0x0 | 1 | 0 | 1 | 0x0 | |
| 0x4 | 0x0 | 0 | 0 | 0 | 0x0 | |
| 0x4 | 0x0 | 0 | 0 | 1 | 0x0 | |
| 0x3 | 0x0 | 1 | 0 | 0 | 0x0 | |
| 0x3 | 0x0 | 1 | 0 | 1 | 0xab | |
| 0x3 | 0x11 | 1 | 1 | 0 | 0xab | |
| 0x3 | 0x11 | 1 | 1 | 1 | 0x11 | |
| 0x3 | 0x11 | 1 | 0 | 0 | 0x11 | |
| 0x3 | 0x0 | 1 | 0 | 1 | 0x11 |
Download circ-ram-basic.circ.
Choose the data bus mode
The attribute is called Data bus implementation. Its options in 5.0.0 are One bidirectional data bus, Separate data buses with latched output and Separate data buses with controlled output (strings in the 5.0.0 table, F73). Classic 2.7.1 called it Data Interface, with One synchronous load/store port, One asynchronous load/store port and Separate load and store ports (strings in the 2.7.1 jar).
- Latched output (the mode we tested): the output keeps the last loaded value.
- Bidirectional bus: one data port for reading and writing. Stop other drivers while the RAM drives, using controlled buffers.
- Controlled output: according to the project notes, new in 5.0.0, the output floats when the load control is off, so several RAMs can share a bus. We did not test it.
Stop the RAM from writing
In our test writes happened only on a rising edge with Store at 1. Keep Store at 0 when you do not want to write, and do not gate the clock with AND logic (Clock and simulation). We did not test floating Store, the Trigger options or the Read behavior attribute.
Line enables: a 5.0.0 change reported by the project
Contents: start, clear, load and save
Right-click a RAM for Edit Contents, Clear Contents, Load Image and Save Image. From the command line, --load fills a RAM or ROM and --save writes a RAM (see command line). Image formats and their errors are explained on ROM and loading memory contents.
Bigger memories and dual port
The Memory library also has a Dual Port RAM. We did not test it, or the address-width limits, so this page gives no figures for them.
Common mistakes
- Store or Load wired to the clock instead of a control signal.
- Load left at 0, so the output never shows a value.
- A shared bus without tri-state: red wire, E (wire colours).
- Expecting an unwritten address to be anything but 0.
Version differences
| Feature | 2.7.1 | 5.0.0 |
|---|---|---|
| Bus attribute name | 2.7.1: yesData Interface | 5.0.0: yesData bus implementation |
| Default RAM ports | 2.7.1: yes6 ports, bidirectional data | 5.0.0: yes6 ports, separate data in and out |
| Controlled-output mode | 2.7.1: nonot in 2.7.1 | 5.0.0: untestedper the project notes |
See also all components.