RTL Studio Open IDE

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

Mediumverilogsimsyn

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.

  1. Choose Open in IDE. RTL Studio loads the packaged workspace for 8-Bit Differential Encoder/Decoder (NRZ-D) — L1 Upgrade — L2 Upgrade.
  2. Read the Verilog module in the editor. The catalog line for this block: 8-Bit Differential Encoder/Decoder with Stream Enable and Lock Detect.
  3. Run the packaged testbench with the in-browser Verilator simulator, then open the VCD in the waveform viewer.
  4. 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_out for differential encoding.
  • Registered Pipeline: Includes a registered pipeline stage to register input and previous output, improving timing performance.
  • Stream Enable Control: Supports a stream_en signal 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_in and valid_out signals with enable gating.

Ports

Port NameDirectionWidthDescription
clkInput1Clock input
rst_nInput1Active-low synchronous reset
stream_enInput1Stream enable control signal
data_inInput[7:0]Input data bus
valid_inInput1Input valid signal
data_outOutput[7:0]Encoded/decoded data bus
valid_outOutput1Output valid signal
lock_detectOutput1Lock 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.

  1. Pipeline Stage: The input data and previous output are registered. The XOR operation computes the new output based on these registered values.
  2. Lock Detect Logic: A counter tracks consecutive zero bytes in the input stream. When the count reaches 8, the lock_detect output is asserted. Any non-zero byte resets the counter to zero.
  3. Stream Enable: The stream_en signal gates the processing of valid_in. When stream_en is low, the output valid is deasserted, and the internal state (including prev_out_reg and zero_count) is held.

Integration

To integrate this IP into your design:

  1. Instantiate the module differential_encoder_registered_pipelined_8bit_stream_enable_lock.
  2. Connect your system clock to clk and active-low reset to rst_n.
  3. Drive data_in and valid_in with your source data.
  4. Control flow with stream_en.
  5. Monitor lock_detect for 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 CaseDescriptionResult
TC1Reset StatePASS
TC2Basic Encoding (NRZ-D)PASS
TC3Stream Enable ControlPASS
TC4Lock Detect - 8 consecutive zerosPASS
TC5Lock Detect Reset on non-zeroPASS
TC6Lock Detect - 8 consecutive zeros againPASS

More in Coding & Line Codes

All Coding & Line Codes blocks