Skip to content

Commit db10b4f

Browse files
committed
Add memory module exercise
1 parent 616fdb0 commit db10b4f

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

verilog/README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,30 @@ You can use the provided `traffic.v` and `traffic_tb.v`.
127127

128128
![traffic wave](traffic.png)
129129

130+
## Memory module
131+
132+
Implement a 256-byte memory module with read and write ports.
133+
134+
module memory(input wire clk,
135+
input wire ren,
136+
input wire [7:0] raddr,
137+
output reg [7:0] rdata,
138+
input wire wen,
139+
input wire [7:0] waddr,
140+
input wire [7:0] wdata);
141+
142+
- When `ren` (read enable) is set, in the next cycle set `rdata` to the byte at
143+
`raddr` address.
144+
- When `wen` (write enable) is set, in the next cycle set the byte at `waddr`
145+
address to `wdata`.
146+
- Both operations (read and write) can happen in the same cycle.
147+
148+
Write a test bench. What will be the result of reading uninitialized memory?
149+
How to initialize the memory to 0?
150+
151+
Hint: You can use a `$display` statement to print debug messages while the
152+
module is working (for instance, `"Storing byte XX at address YY"`).
153+
130154
## Other exercises
131155

132156
- **Clock divider**: Given a clock signal, output a slower clock signal that
@@ -135,8 +159,6 @@ You can use the provided `traffic.v` and `traffic_tb.v`.
135159
cycles.
136160
- (TODO describe) **SPI transmit module**: Given a byte, transmit it as a
137161
series of bits.
138-
- (TODO describe) **Memory module**: Implement a 256-byte memory with separate
139-
read and write ports.
140162

141163
## Links
142164

0 commit comments

Comments
 (0)