Coding & Line Codes
8-Bit Differential Encoder/Decoder (NRZ-D) — L1 Upgrade — L2 Upgrade
8-Bit Differential Encoder/Decoder with Stream Enable and Lock Detect
About this block
Simulate it in the Verilog IDE
8-Bit Differential Encoder/Decoder (NRZ-D) — L1 Upgrade — L2 Upgrade is a Verilog reference block in the Coding & Line Codes catalog. Line codes, serializers, and digital encoding/decoding blocks. Marked Medium: more state or a wider datapath, still one workspace in the IDE.
This IP core implements an 8-bit Non-Return-to-Zero Differential (NRZ-D) encoder.
It features a registered pipeline stage for high-frequency operation, stream enable control for flow management, and a lock-detect mechanism for idle stream synchronization.
The design is fully verified and ready for integration into high-speed data paths.
- Choose Open in IDE. RTL Studio loads the packaged workspace for 8-Bit Differential Encoder/Decoder (NRZ-D) — L1 Upgrade — L2 Upgrade.
- Read the Verilog module in the editor. The catalog line for this block: 8-Bit Differential Encoder/Decoder with Stream Enable and Lock Detect.
- 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
- 8-bit Parallel Data Path: Supports 8-bit input and output data buses.
- NRZ-D Encoding: Implements
data_out = data_in ^ prev_outfor differential encoding. - Registered Pipeline: Includes a registered pipeline stage to register input and previous output, improving timing performance.
- Stream Enable Control: Supports a
stream_ensignal to pause processing without losing internal state. - Lock Detect Mechanism: Asserts a flag after detecting 8 consecutive zero-byte inputs, useful for idle detection.
- Synchronous Reset: All internal registers are reset synchronously via
rst_n. - Valid Signal Propagation: Handles
valid_inandvalid_outsignals with enable gating.
Ports
| Port Name | Direction | Width | Description |
|---|---|---|---|
clk | Input | 1 | Clock input |
rst_n | Input | 1 | Active-low synchronous reset |
stream_en | Input | 1 | Stream enable control signal |
data_in | Input | [7:0] | Input data bus |
valid_in | Input | 1 | Input valid signal |
data_out | Output | [7:0] | Encoded/decoded data bus |
valid_out | Output | 1 | Output valid signal |
lock_detect | Output | 1 | Lock detect flag (high after 8 zeros) |
Architecture
The module uses a single pipeline stage to register the input data and the previous output value. This ensures that the XOR operation uses stable registered values.
- Pipeline Stage: The input data and previous output are registered. The XOR operation computes the new output based on these registered values.
- Lock Detect Logic: A counter tracks consecutive zero bytes in the input stream. When the count reaches 8, the
lock_detectoutput is asserted. Any non-zero byte resets the counter to zero. - Stream Enable: The
stream_ensignal gates the processing ofvalid_in. Whenstream_enis low, the output valid is deasserted, and the internal state (includingprev_out_regandzero_count) is held.
Integration
To integrate this IP into your design:
- Instantiate the module
differential_encoder_registered_pipelined_8bit_stream_enable_lock. - Connect your system clock to
clkand active-low reset torst_n. - Drive
data_inandvalid_inwith your source data. - Control flow with
stream_en. - Monitor
lock_detectfor idle stream detection.
Verification
The testbench verifies reset behavior, basic encoding, stream enable control, and lock detect logic. All test cases passed successfully in the simulation log.
| Test Case | Description | Result |
|---|---|---|
| TC1 | Reset State | PASS |
| TC2 | Basic Encoding (NRZ-D) | PASS |
| TC3 | Stream Enable Control | PASS |
| TC4 | Lock Detect - 8 consecutive zeros | PASS |
| TC5 | Lock Detect Reset on non-zero | PASS |
| TC6 | Lock Detect - 8 consecutive zeros again | PASS |
More in Coding & Line Codes
- 4-Bit Hex to 7-Segment Display Decoder
- 4b/6b Run-Length Limited Encoder
- 8-bit Huffman Encoder (Static Table)
- 8-Bit Manchester Encoder (IEEE 802.3 Compliant)
- 8-Bit Nibble-Swap Endian Converter — L1 Upgrade — L2 Upgrade
- 8-Bit Parallel Descrambler
- 8-Bit Run-Length Decoder (RLE)
- 8b/10b Encoder and Decoder
- Additive Scrambler 8-bit — L2 Upgrade
- Bit Unstuffer After 5 Ones — L2 Upgrade
- Golay (24,12) Encoder with Syndrome Calculator
- Hamming (7,4) Decoder
- Hamming (7,4) Encoder
- HDLC Bit Stuffing (5 Ones)
- HDLC Bit-Stuff Remover
- NRZ-to-NRZI Line Encoder — L2 Upgrade