Skip to content

Commit 2ea743d

Browse files
committed
Add clock divider and serial exercises
1 parent ed9618a commit 2ea743d

File tree

1 file changed

+32
-7
lines changed

1 file changed

+32
-7
lines changed

verilog/README.md

+32-7
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,18 @@ set, and reset to 0 whenever `rst` (reset) is set:
109109

110110
![counter wave](counter.png)
111111

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+
112124
## Traffic light controller
113125

114126
module traffic(input wire clk,
@@ -127,6 +139,26 @@ You can use the provided `traffic.v` and `traffic_tb.v`.
127139

128140
![traffic wave](traffic.png)
129141

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+
130162
## Memory module
131163

132164
Implement a 256-byte memory module with read and write ports.
@@ -151,13 +183,6 @@ How to initialize the memory to 0?
151183
Hint: You can use a `$display` statement to print debug messages while the
152184
module is working (for instance, `"Storing byte XX at address YY"`).
153185

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-
161186
## Links
162187

163188
- [Verilog cheatsheet](https://www.cl.cam.ac.uk/teaching/0910/ECAD+Arch/files/verilogcheatsheet.pdf) (PDF)

0 commit comments

Comments
 (0)