Bus Interfaces
2-Bit Read/Write Command Decode
Combinational module that decodes a 2-bit opcode into separate Read, Write, and Illegal status signals.
About this block
Simulate it in the Verilog IDE
2-Bit Read/Write Command Decode is a Verilog reference block in the Bus Interfaces catalog. AXI, APB, Wishbone, and other on-chip bus interface adapters. Marked Easy: a small block you can read, simulate, and synthesize in one sitting.
This IP decodes a 2-bit opcode into distinct Read, Write, and Illegal signals. It supports four states: Read (2'b01), Write (2'b10), and two Illegal states (2'b00, 2'b11). The design is purely combinational with no internal state or clock dependency.
This IP provides a robust and simple decoder for 2-bit read/write commands.
It is suitable for simple bus interfaces or instruction decoders where low latency and deterministic behavior are required.
- Choose Open in IDE. RTL Studio loads the packaged workspace for 2-Bit Read/Write Command Decode.
- Read the Verilog module in the editor. The catalog line for this block: Combinational module that decodes a 2-bit opcode into separate Read, Write, and Illegal status signals.
- Run the packaged testbench with the in-browser Verilator simulator, then open the VCD in the waveform viewer.
- Run Yosys in the same IDE for a generic netlist. Sky130 liberty mapping is a separate Pro library option.
RTL Studio is the Verilog simulator and IDE around this block: Slang lint, Verilator, VCD waveforms, and Yosys, in the browser. Simulation guide · Yosys guide.
Features
- Decodes 2-bit
opcodeinput. - Asserts
rdfor opcode2'b01. - Asserts
wrfor opcode2'b10. - Asserts
illfor opcodes2'b00and2'b11. - Zero latency combinational logic.
Architecture
The module uses simple boolean assignments to decode the command.
Ports
| Port | Direction | Width | Description |
|---|---|---|---|
| opcode | Input | 2 | Command opcode |
| rd | Output | 1 | Read active signal |
| wr | Output | 1 | Write active signal |
| ill | Output | 1 | Illegal command signal |
Verification
The testbench verifies all four possible opcode combinations.
| Test Case | Opcode | Expected rd | Expected wr | Expected ill | Result |
|---|---|---|---|---|---|
| TC1 | 01 | 1 | 0 | 0 | PASS |
| TC2 | 10 | 0 | 1 | 0 | PASS |
| TC3 | 00 | 0 | 0 | 1 | PASS |
| TC4 | 11 | 0 | 0 | 1 | PASS |
All tests passed with zero errors. Use your simulator's waveform viewer with sim/dump.vcd to inspect signal transitions.
### Running the Simulation
To run the verification:
- Ensure your Verilog simulator (e.g., Icarus Verilog, ModelSim) is installed.
- Run the testbench:
- Check the console output for
INFO: PASS. - View waveforms:
More in Bus Interfaces
- 4-Slot Address Chip-Select Decoder
- 8-Bit Address Range Hit
- 8-Bit Hold-on-Stall Register
- 8-Bit Valid/Ready Register Slice
- 8-Bit Write Merge with Byte Mask
- AHB-Lite Simple Master
- AHB-Lite Single-Beat Master
- AHB-Lite Slave Interface
- APB3 Master (Single-Transaction Pipeline)
- APB3 Master with Burst Support and Backpressure Handling
- APB3 Slave Register Interface
- AXI-Lite 4-Register Bank
- AXI-Lite Read-Only Slave 4 Regs
- AXI-Lite Write-Only Slave 4 Regs
- AXI-Stream 1-to-2 Demux
- AXI-Stream Broadcast 1-to-2