Bus Interfaces
8-Bit Write Merge with Byte Mask
Combinational logic for merging 8-bit data using a byte mask.
About this block
Simulate it in the Verilog IDE
8-Bit Write Merge with Byte Mask 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 implements a combinational write-merge logic for 8-bit data paths. It selectively updates data bits based on an 8-bit byte mask. Bits where the mask is high are updated from the input data. Bits where the mask is low retain their previous value. This primitive is useful for partial register updates or bus merging.
This IP provides a simple and efficient byte-masked write merge function.
It is suitable for low-latency data path modifications.
- Choose Open in IDE. RTL Studio loads the packaged workspace for 8-Bit Write Merge with Byte Mask.
- Read the Verilog module in the editor. The catalog line for this block: Combinational logic for merging 8-bit data using a byte mask.
- 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.
Architecture
The design uses a single combinational assignment statement. It performs bitwise AND operations for both new and old data. The results are combined using a bitwise OR operation. This approach ensures zero latency and minimal area overhead.
Interface
The module exposes three input ports and one output port. All signals are 8 bits wide.
| Signal | Direction | Width | Description |
|---|---|---|---|
din | Input | 8 | New data to be merged |
old | Input | 8 | Previous data to preserve |
mask | Input | 8 | Byte mask for selection |
dout | Output | 8 | Merged output data |
Verification
The testbench verifies four distinct merge scenarios. It checks full preservation, full overwrite, and partial merges. All test cases passed successfully in the simulation log.
| Test Case | Mask | Din | Old | Expected | Result |
|---|---|---|---|---|---|
| TC1 | 0x00 | 0xAA | 0x55 | 0x55 | PASS |
| TC2 | 0xFF | 0xCC | 0x55 | 0xCC | PASS |
| TC3 | 0xF0 | 0xF0 | 0x05 | 0xF5 | PASS |
| TC4 | 0x0F | 0x0F | 0x50 | 0x5F | PASS |
### Expected Simulation Output
After Run Simulation, the Log panel should show:
TC1 PASS mask=0TC2 PASS mask=FFTC3 PASS mask=F0TC4 PASS mask=0FINFO: PASS
More in Bus Interfaces
- 2-Bit Read/Write Command Decode
- 4-Slot Address Chip-Select Decoder
- 8-Bit Address Range Hit
- 8-Bit Hold-on-Stall Register
- 8-Bit Valid/Ready Register Slice
- 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