Receive bytes sent LSB first, one bit per valid edge, and pulse ready for one cycle when each byte is complete.
Hardware context: A 6-bit display scroll register with separate controls, and a receiver and transmitter for 8-bit sensor readings sent LSB first. Receive LSB-first bytes with a bit counter and a one-cycle ready pulse.
A sensor link sends 8-bit readings one bit at a time, LSB first. A bit is present only at edges where valid is 1, so bits may have gaps. The rest of the chip wants whole bytes and a one-cycle signal when a new byte arrives.
This is an Implement problem. Complete rx8: a shift register, a bit counter, a data register and a ready flag. The check runs twenty edges per case.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
script | 60 | input of each check |
Full specification
module rx8 (
input logic clk,
input logic rst, // synchronous reset: no bits received yet
input logic valid, // 1: sin carries a bit at this edge
input logic sin, // serial data, LSB first
output logic [7:0] data, // the last complete byte; holds until the next byte is complete
output logic ready // 1 for one cycle, right after the edge that took the 8th bit
);
...
endmodule
| At a rising edge | Effect |
|---|---|
| rst = 1 | no bits received yet; data = 00, ready = 0 |
| valid = 1 | take sin as the next bit; the first bit of a byte is its bit 0 |
| valid = 1 and it is the 8th bit | data shows the byte and ready is 1 until the next edge |
| any other edge | ready is 0; data keeps the last complete byte |
Each case starts with a reset edge. The result shows ready after every edge and data after edges 4, 8, 12, 16 and 20.
Examples
Example 1
One Byte, 0x35, with No Gaps- Input
per edge (R = reset, - = no bit, else the bit): 10101100------------
- Output
ready_by_edge = 'b00000000000010000000, data_after_edge4 = 0x0, data_after_edge8 = 0x35, data_after_edge12 = 0x35, data_after_edge16 = 0x35, data_after_edge20 = 0x35
The bits 1, 0, 1, 0, 1, 1, 0, 0 arrive LSB first: 0x35. After the 8th edge data is 35 and ready is 1 for one edge (bit 7 of ready_by_edge, counting edges from 0).
Example 2
Gaps Between Bits, Then a Second Byte- Input
per edge (R = reset, - = no bit, else the bit): 1-1-1-0-0001101111--
- Output
ready_by_edge = 'b00000000100000000000, data_after_edge4 = 0x0, data_after_edge8 = 0x0, data_after_edge12 = 0x87, data_after_edge16 = 0x87, data_after_edge20 = 0x87
Edges with valid = 0 take no bit. The first byte completes later than eight edges, and data keeps it while the second byte fills.
Example 3
A Reset in the Middle of a Byte- Input
per edge (R = reset, - = no bit, else the bit): 111R0000000011111111
- Output
ready_by_edge = 'b10000000100000000000, data_after_edge4 = 0x0, data_after_edge8 = 0x0, data_after_edge12 = 0x0, data_after_edge16 = 0x0, data_after_edge20 = 0xff
The reset throws away the three bits received so far. The count starts again, so the next byte needs eight more bits.
Constraints and Contract
- All inputs are known 0/1 values and change only between edges.
- Keep the module name and the ports. The design must synthesize with no latches.
Hints
Hint 1
LSB first: the first bit must end in bit 0 after eight shifts. So shift toward bit 0 and put the new bit in bit 7.
Hint 2
A 3-bit counter counts the bits of the byte. The byte is complete on the edge that takes a bit while the count is 7.
Hint 3
Clear ready at every edge, then set it only on the completing edge. Copy the full byte into data at that same edge.
What the grader checks: Three directed and twelve seeded scripts of twenty edges, with gaps and resets in the middle of a byte. ready is compared with a JavaScript model after every edge and data after every fourth edge. Synthesis must report no latches.
The submitted design must synthesize with 0 latches and no combinational loop. Counts come from the pinned open-source synthesis flow. They are proxies for logic size and depth, not physical area or timing.
15 checks on Icarus Verilog + Yosys · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 3 steps and the final capstone