File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,30 @@ You can use the provided `traffic.v` and `traffic_tb.v`.
127
127
128
128
![ traffic wave] ( traffic.png )
129
129
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
+
130
154
## Other exercises
131
155
132
156
- ** 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`.
135
159
cycles.
136
160
- (TODO describe) ** SPI transmit module** : Given a byte, transmit it as a
137
161
series of bits.
138
- - (TODO describe) ** Memory module** : Implement a 256-byte memory with separate
139
- read and write ports.
140
162
141
163
## Links
142
164
You can’t perform that action at this time.
0 commit comments