SystemVerilog #69 · 2026-12-01 · Latches in always_comb · Easy · about 12 min

A command decoder with no memory

Write op_decode: a purely combinational decoder for a 3-bit command op. Every output is a function of the current op and nothing else: no output may ever depend on an earlier value of op.

op meaning rd_en wr_en ack err
0 idle 0 0 0 0
1 read 1 0 0 0
2 write 0 1 0 0
3 read and acknowledge 1 0 1 0
4 write and acknowledge 0 1 1 0
5, 6, 7 illegal 0 0 0 1

Example: op = 3 gives rd_en = 1, ack = 1, the others 0. If op then changes to 6, only err is 1.

Use always_comb. Fill in op_decode.sv. Run tries seven commands.

Write and run your answer in the browser. The hidden tests check it, and it’s free.