A monitor that packs bytes into words was written as testbench code, with waits on clock edges and a delay. Move it to the hardware side: rewrite it as clocked logic that Yosys accepts, with the same behaviour.
Hardware context: A two-top bench and the hybrid's transactor checked by the judge's Yosys flow. A monitor rewritten so it synthesizes.
A bench that could go into an emulator keeps its timed parts on the hardware side, and those parts must synthesize. The monitor below works in a simulator. It waits for edges inside an always block and uses a #1 delay: code a synthesis tool cannot build.
Rewrite byte_packer as clocked logic. Take a byte on each rising edge of clk where valid is 1. After every fourth byte, show the word on word, first byte in bits 7:0. Raise word_valid for exactly one cycle, and add one to words. word changes only together with word_valid. An active-low reset clears the partial word, words and word_valid.
Your module runs in Icarus against scripts with gaps and resets, then the pinned Yosys synthesizes it. Both must pass. A text rule refuses any # delay before anything runs.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
scenario | 4 | input of each check |
Full specification
module byte_packer(input logic clk, resetn, valid, input logic [7:0] data,
output logic word_valid, output logic [31:0] word, output logic [15:0] words);
...
endmodule
| Edge | valid | data | After the edge |
|---|---|---|---|
| 1 | 1 | 0x11 | one byte held |
| 2 | 0 | x | nothing changes |
| 3 | 1 | 0x22 | two bytes held |
| 4 | 1 | 0x33 | three bytes held |
| 5 | 1 | 0x44 | word = 0x44332211, word_valid = 1, words + 1 |
| 6 | 0 | x | word_valid = 0; word keeps its value |
Examples
Example 1
Eight Bytes, Back to Back- Input
8 bytes
- Output
pulses = 2, long_pulses = 0, moved = 0, words = 2, xor_words = 0x909ce8a4
Two words, two one-cycle pulses; words ends at 2.
Example 2
Gaps Between Bytes- Input
8 bytes with gaps
- Output
pulses = 2, long_pulses = 0, moved = 0, words = 2, xor_words = 0xcc444444
Gaps do not count: seven bytes make one word and leave three held.
Example 3
A Reset in the Middle of a Word- Input
6 bytes, a reset
- Output
pulses = 1, long_pulses = 0, moved = 0, words = 1, xor_words = 0xb4b3b2b1
The reset throws away the two bytes before it; the four after it make one word.
Constraints and Contract
- Keep the module name and the ports.
- No delays, no waits on events inside an always block, no initial block.
- Yosys must synthesize it with no latch.
Hints
Hint 1
A counter of bytes held replaces the loop of four waits.
Hint 2
Keep the first three bytes in a register; the fourth goes straight into word.
Hint 3
Every output is a flop on clk with the asynchronous reset.
What the grader checks: Seven scripts check the words, the one-cycle pulses, that word moves only with word_valid, and the count. Then Yosys synthesizes your module and must report no error and no latch. The grader does not run it on an emulator; none is available here.
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.
7 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 2 problems on this path