@@ -109,6 +109,18 @@ set, and reset to 0 whenever `rst` (reset) is set:
109
109
110
110
![ counter wave] ( counter.png )
111
111
112
+ ## Clock divider
113
+
114
+ Given a clock signal, output a clock signal that is 4 times slower.
115
+
116
+ module clock_divider(input wire clk_in,
117
+ output wire clk_out);
118
+
119
+ In other words, we should get:
120
+
121
+ clk_in: 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 ....
122
+ clk_out: 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 ....
123
+
112
124
## Traffic light controller
113
125
114
126
module traffic(input wire clk,
@@ -127,6 +139,26 @@ You can use the provided `traffic.v` and `traffic_tb.v`.
127
139
128
140
![ traffic wave] ( traffic.png )
129
141
142
+ ## Parallel to serial
143
+
144
+ Write a module that receives an 8-bit value and converts it to single bits.
145
+
146
+ module serial(input wire clk,
147
+ input wire in,
148
+ input wire [7:0] data,
149
+ output wire out);
150
+
151
+ - Normally, ` out ` should be 0.
152
+ - The user should raise ` in ` to 1 for a single cycle, and set ` data ` to a
153
+ desired value in the same cycle.
154
+ - Then, during the following 8 cycles, ` out ` should contain consecutive bits
155
+ of ` data ` (highest to lowest).
156
+ - After that, ` out ` should go back to 0.
157
+
158
+ For instance, if we set ` in = 1 ` and ` data = 8'b01101001 ` for a single cycle;
159
+ ` out ` should be set to: 0, 1, 1, 0, 1, 0, 0, 1. Then it should return to 0
160
+ until ` in ` is raised again.
161
+
130
162
## Memory module
131
163
132
164
Implement a 256-byte memory module with read and write ports.
@@ -151,13 +183,6 @@ How to initialize the memory to 0?
151
183
Hint: You can use a ` $display ` statement to print debug messages while the
152
184
module is working (for instance, ` "Storing byte XX at address YY" ` ).
153
185
154
- ## Other exercises
155
-
156
- - ** Clock divider** : Given a clock signal, output a slower clock signal that
157
- changes every 1024 (` 1 << 10 ` ) cycles.
158
- - ** Shift register** : Output the bits from input wire, delayed by 8 clock
159
- cycles.
160
-
161
186
## Links
162
187
163
188
- [ Verilog cheatsheet] ( https://www.cl.cam.ac.uk/teaching/0910/ECAD+Arch/files/verilogcheatsheet.pdf ) (PDF)
0 commit comments