641 PRBS Generator

641 : PRBS Generator

  • Author: Ivan M Bow
  • Description: Generates a PRBS that is configureable up to 8-bits.
  • GitHub repository
  • GDS submitted
  • Wokwi project
  • Extra docs
  • Clock: The input drives the output frequency. Hz
  • External hardware: Connection to SPI port, clock input, and analyzer to observe.

How it works

Pseudo Random Binary Sequence (PRBS) Generator

######### Author: Ivan M Bow

This project was created using Wokwi and submitted to Tiny Tapeout for fabrication. The goal is to create a fully configurable, burst PRBS output. See Wiki for implementation details of PRBS and details on the operations of and polynomials for Linear-Feedback-Shift-Registers (LFSR).

Features
  • Implements a Galois LFSR with XOR taps for PRN generation.
  • Estimated 500kHz Max output PRBS rate, at PRBS2.
    • With 8-bit polynomial, 30 MHz should be achievable.
    • Max frequency reduces as PRBS size is reduced.
      • Estimated Max = (30 MHz / 2 ^ (8 - Nbits))
  • Fail safe all 0’s check to ensure no lock up.
  • Clock Divider
  • SPI Interface
    • CLK, MOSI, CS
    • SPI Mode 0, CS Active Low, MSB First
  • Register access for configuration
  • Differential Output
  • Look-ahead Outputs
    • For each of the differential outputs, the next bit coming is output.
    • Useful for waveshaping or other information.
  • Logic added in so a bit cannot be XOR’ed if the previous bit is disabled.
    • The highest order bit is not XOR’ed with the output bit, despite being in the poly.
  • Enable pin for starting and resetting the output.
  • Data pin for inverting the output.
Description

The 8-bit PRBS generator has several 8-bit registers that are used to configure the output. Using the Tiny Tapeout board that is supplied with each project, the PRBS generator will take in a clock of any frequency output by the RP2040. The input clock is divided by the configured factor of 2, then this frequency is used to run the generator. The bit length and the polynomial of the output are configured in the registers. The output of the PRBS generator starts when the enable pin is set high.

There are 2 counters that control the output of the PRBS generator. The binary sequence will run for a configured number of times, with an output “clock” indicating this “rate”. For Example, if the register is set to 20, the PRBS will be repeated 10 times, the output clock goes low, then another 10 times, and the output clock goes high. The idea behind this clock output is to signal to an external device for sending data. When the output clock goes low, the data needs to be set. When the output clock goes high, the data on the input pin is clocked in for the remainder of the output clock period.

The data bit is XOR’ed with the PRBS output to create a non-inverted or inverted sequence. A register is configured to have the number of data bits that will be clocked into the PRBS generator. This number of data bits is the number of clock periods that are given from the output clock. Once the number of data bits has been completed, the PRBS generator automatically stops running. The generator remains off until the enable pin goes low, which resets the generator, and then high again to start another “data bits” cycles of the PRBS.

Registers are configured using SPI. For setting up each 8-bit register, the first byte sent is the command byte and must be hexadecimal 0x80, plus the address of the register to be configured. The second byte sent is the data that will be placed in the register and stored until changed or reset. The address field is the last 3-bits of the command byte and valid range is 1-5. Chip select high resets the command byte, and only 1 register may be written to per cycle of chip select.

A debug setup has been included for easy setup and testing. The debug mode sets the generator to divide the input clock by 16, the sequences per data bit to 7, the data bits count to 7, enables bits 0x0F (4 bits), and the polynomial to 0x0C (x^4 + x^3 + 1). To use the debug feature, start by placing all inputs low (including RST_N) to reset all registers and counters. Then:

  1. Set the RST_N line high.
  2. Set DEBUG high.
  3. Set ENABLE high.

The PRBS generator is now running, and the data line can be toggled to invert the output.

Registers
  • 5 registers control the PRBS generator

    • Register 0: Command and Address of register to configure *
    • Register 1: Clock Divider **
    • Register 2: PRBS count per data bit ***
    • Register 3: Count of data bits ***
    • Register 4: Bits to enable ****
    • Register 5: Polynomial XOR taps to enable *****
  • Addressing and commands happen in a single CS session.

    • CS low -> 0x80 + 3-bit address -> 8-bit data -> CS high
  • Reset_N clears all registers

Inputs
  • CLK (RP2040 Clock)
  • RST_N (Reset Low)
  • IN0: SPI CS (Active Low)
  • IN1: SPI CLK (Active High)
  • IN2: SPI MOSI
  • IN3: ENABLE (PRBS Generator Enable - Active High)
  • IN4: DATA Bit Input
  • IN5: No Connect
  • IN6: No Connect
  • IN7: DEBUG (Debug mode - Active high)
Outputs
  • OUT0: PRBS_OUT_1 (PRBS Positive Look-ahead)
  • OUT1: PRBS_OUT (PRBS Positive)
  • OUT2: PRBS_OUT_N (PRBS Negative)
  • OUT3: PRBS_OUT_N_1 (PRBS Negative Look-ahead)
  • OUT4: DATA_CLK (Data Clock Output)
  • OUT5: BUSY (PRBS Running)
  • OUT6: CLK_OUT (RP2040 Clock)
  • OUT7: CLK_PRBS_OUT (PRBS Generator Clock)
Bidirectional

(All DIO are set to output and used for debug purposes.)

  • D0: REG_SEL_0
  • D1: REG_SEL_1
  • D2: REG_SEL_2
  • D3: PRBS_CLK_BYPASS
  • D4: DATA_COUNT_CLK
  • D5: DATA_COUNT_COMB_OUT
  • D6: SEQ_COUNT_COMB_OUT
  • D7: No Connect
Register Contents
Register 0: Command & Address
7 6 5 4 3 2 1 0
C0 X X X X A2 A1 A0
  • bits [7] - 0: Nothing occurs. 1: Writes the following word into the register
  • bits [6:3] - Do Not Care
  • bits [1:2] - 3-bit address of register to place the following data in.
    • (Address 0 is this register.)
Register 1: Clock Divider
7 6 5 4 3 2 1 0
X X X X X D2 D1 D0
  • bits [7:3] - Do Not Care
  • bits [2:0] - Clock Divider
    • 0: /1
    • 1: /2
    • 2: /4
    • 3: /8
    • 4: /16
    • 5: /32
    • 6: /64
    • 7: /128
Register 2: Polynomial Enable Bits
7 6 5 4 3 2 1 0
E8 E7 E6 E5 E4 E3 E2 E1
  • bits [7:0] - E(n+1) is the enable bit for the polynomial size.
    • E() is 1 indexed to match the polynomial exponents.
      • 3-bit polynomial is b'111 or h'7.
      • 8-bit polynomial is b'11111111 or h’FF.
    • Bits must be sequential from bit 0. Other values are undefined.
Register 3: Polynomial Tap Bits
7 6 5 4 3 2 1 0
x^8 x^7 x^6 x^5 x^4 x^3 x^2 x^1
  • bits [7:0] - E(n+1) is the enable bit for the polynomial taps.
    • E() is 1 indexed to match the polynomial exponents.
      • x^4 + x^2 + 1 is b'1010 or h’A.
      • x^5 + x^4 + x^3 + 1 is b'11100 or h'1C.
*     Do not address the command byte register, address 0. If the command byte is written to as
        data, then the data could trigger the command byte to transfer to another register,
        whose address is based on the contents of bits 0-2 when bit 7 is triggered.
**    Clock divider bits 3-7 are unused and have no effect.
***   How the counters operate, a count of "0" is considered to be 65,536. Additionally, a count
        of "1" does not work as expected, and is equivalent to a count of "0".
****  Bits must be enabled sequentially, starting with bit 0. Any bit enable value that is not
        sequential is an undefined state. I do not believe it will break anything, but I have not
        looked into what this will do to the output.
***** Enabling an XOR tap bypasses the bit enable register setting. For example, if bits 0-4 are
        enabled but bit 6 has the XOR tap set, then the output polynomial will be x^6 + the rest
        of the polynomial settings.

How to test

  1. Clear inputs and reset to ensure known states.
  2. Configure the registers using SPI or using the debug_setup pin.
  3. Set “output_en” high and observe “prbs_out”.
  4. Toggle “data_in” to invert “prbs_out” on next rising edge of “data_clk”.
  5. To restart PRBS after “busy” goes low, clear “output_en” and set “output_en” again.

IO

# Input Output Bidirectional
0 spi_cs prbs_out_1 debug_out_reg_sel_0
1 spi_clk prbs_out debug_out_reg_sel_1
2 spi_mosi prbs_out_n debug_out_reg_sel_2
3 output_en prbs_out_n_1 debug_out_prbs_clk_bypass
4 data_in data_clk debug_out_data_count_clk
5 none busy debug_out_data_count_comb_out
6 none debug_out_system_clk debug_out_seq_count_comb_out
7 debug_setup debug_out_prbs_clk none

Chip location

Controller Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux tt_um_chip_rom (Chip ROM) tt_um_factory_test (TinyTapeout 05 Factory Test) tt_um_loopback (TinyTapeout 05 Loopback Test Module) tt_um_Leaky_Integrate_Fire_nfjesifb (Leaky Integrate and Fire Neuron Model) tt_um_topModuleKA (Time Multiplexed Neuron Ckt) tt_um_sap_1 (SAP-1 Computer) tt_um_lif (Leaky Integrate-and-Fire Neuron (Verilog Demo)) tt_um_jleugeri_ticktocktokens (TickTockTokens) tt_um_LSNN (Spiking LSTM Network) tt_um_if (Integrate-and-Fire Neuron. (Verilog Demo)) tt_um_mihailocode_neural_network (Neural network on chip) tt_um_hls_lfi (Simple Leaky Integrate and Fire (LIF) Neuron) tt_um_diadatp_spigot_e (e Spigot) tt_um_kskyou (Continued Fraction Calculator) tt_um_wokwi_380005495431181313 (Water Pump Controller) tt_um_EventFilter (Event Denoising Circuit) tt_um_wokwi_380416099936681985 (7 segment seconds (Verilog Demo)) tt_um_freq_hcohensa (Frequency Encoder/Decoder) tt_um_wokwi_380410498092232705 (UART Greeter with RNN Module) tt_um_wokwi_380120751165092865 (WS2812B LED strip driver) tt_um_wokwi_380408486941145089 (Tiny Tapeout 5 Workshop) tt_um_wokwi_380409169798008833 (Tiny Tapeout 1) tt_um_wokwi_380409488188706817 (Supercon Workshop) tt_um_matrix_multiplier (Matrix Multiplier) tt_um_wokwi_380408594272345089 (Clock Divider) tt_um_wokwi_380408784463076353 (Binary Counter) tt_um_wokwi_380408396356749313 (ring osc test) tt_um_7segx4_clock_abhishek_top (7 segment clock with 4 digits) tt_um_wokwi_380409481852161025 (test001) tt_um_hodgkin_huxley (Hodgkin-Huxley Chip Design) tt_um_wokwi_380408823952452609 (Character Selector) tt_um_wokwi_380409904919056385 (Intructouction to PRBS) tt_um_wokwi_380409081067502593 (tto5 Supercon Project) tt_um_jmadden173_delta_modulation (Delta Modulation Spike Encoding) tt_um_wokwi_380409086743445505 (GameOfLife) tt_um_reflex_game (Reflex Game) tt_um_wokwi_380409019830656001 (Logic Gates Tapeout) tt_um_Fiona_CMU (Stream Cipher w/ LSR) tt_um_wokwi_380409532780455937 (tt5modifyd) tt_um_alu_chip (ALU Chip) tt_um_wokwi_380408936929183745 (Tapeout Test) tt_um_rjmorgan11_calculator_chip (Calculator chip) tt_um_wokwi_380409369220404225 (Shifty Snakey) tt_um_synth_GyanepsaaS (Synth) tt_um_wokwi_380408774591779841 (Sawtooth Generator) tt_um_wokwi_380197591775930369 (Blinking A) tt_um_wokwi_380409393770716161 (Supercon 2023) tt_um_mvm (Sparsity Aware Matrix Vector Multiplication) tt_um_wokwi_380408455148316673 (Ring Oscillator and Clock Source Switch) tt_um_mv_mult_alrdelcr (Matrix Vector Multiplication (Verilog Demo)) tt_um_wokwi_380416361853146113 (IDK WHAT TO DO) tt_um_wokwi_379319062779062273 (7-segment display logic system ) tt_um_wokwi_380409568391147521 (Hardware Trojan Example) tt_um_wokwi_379824923824476161 (Analog Clock) tt_um_wokwi_380145600224164865 (7 segment display) tt_um_wokwi_379889284755158017 (W_Li_10/28) tt_um_wokwi_380408409844584449 (Supecon Gate Play) tt_um_manjushettar (ECE 183 - Integrate and Fire Network Chip Design) tt_um_wokwi_380409236812508161 (tto5) tt_um_rebel2_balanced_ternary_ALU (REBEL-2 Balanced Ternary ALU) tt_um_wokwi_380229599886002177 (Stochastic Multiplier) tt_um_jeffdi_seven_segment_seconds (7 segment seconds - count down) tt_um_wokwi_380416616536542209 (TT05 Submission) tt_um_lif_n (Leaky Integrate-and-Fire Neuron) tt_um_wokwi_379764885531576321 (Count via LFSR) tt_um_dlmiles_tt05_i2c_bert (I2C BERT) tt_um_loopback_ericsmi (tt05-loopback tile with input skew measurement) tt_um_flappy_vga_cutout1 (Flappy VGA) tt_um_async_proc_paulschulz (Asynchronous Parallel Processor Demonstrator) tt_um_wokwi_380055891603379201 (Hex Countdown) tt_um_nickjhay_processor (Matrix multiply coprocessor (8x8 1bit)) tt_um_htfab_cell_tester (Standard cell generator and tester) tt_um_wta (Winner-Take-All Network (Verilog Demo)) tt_um_muncherkin_lioncage (Lion cage) tt_um_seven_segment_seconds_ksandov4 (Brain Inspired Random Dropout Circuit) tt_um_seanvenadas (Event-Based Denoising Circuit) tt_um_wokwi_378231665807713281 (RAM cell test) tt_um_rejunity_ay8913 (Classic 8-bit era Programmable Sound Generator AY-3-8913) tt_um_rnn (RNN (Demo)) tt_um_gharenthi_top (STDP Neuron) tt_um_SNN (Basic Spiking Neural Network) tt_um_btflv_8bit_fp_adder (8 bit floating point adder) tt_um_perceptron (Perceptron Hardcoded) tt_um_jkprz (Cheap and quick STDP) tt_um_topLevel_derekabarca (Brain-Inspired Oscillatory Network) tt_um_uwuifier (UART uwuifier) tt_um_perceptron_connorguzi (Perceptron and basic binary neural network) tt_um_hadirkhan10_lif_neuron (Leaky Integrate-and-Fire Neuron) tt_um_wokwi_380119282165535745 (7 segment seconds) tt_um_uabc_electronica_2023 (UABC-ELECTRONICA) tt_um_proppy_bytebeat (bytebeat) tt_um_meriac_play_tune (Super Mario Tune on A Piezo Speaker) tt_um_wrapper_inputblackboxoutput (Byte Computer) tt_um_vhdl_seven_segment_seconds (7 segment seconds (VHDL Demo)) tt_um_cejmu (4-Bit ALU) tt_um_rejunity_sn76489 (Classic 8-bit era Programmable Sound Generator SN76489) tt_um_minipit_stevej (Miniature Programmable Interrupt Timer) tt_um_gchenfc_seven_segment_gerry (7-segment Name Display) tt_um_supertails_tetris (Tetris) tt_um_mabhari_seven_segment_seconds (Simple_Timer-MBA) tt_um_njzhu_uart (UART Receiver) tt_um_wokwi_376553022662786049 (AGL CorticoNeuro-1) tt_um_adaptive_lif (Leaky-Integrated Fire Neuron) tt_um_myuart (MyUART) tt_um_wokwi_380438365946734593 (UART test) tt_um_tkmheart (Heart Rhythm Analyzer) tt_um_stdp (Spike-timing dependent plasticity (Verilog Demo)) tt_um_wokwi_380465686251921409 (Tiny Tapeout 5 TM project1) tt_um_thermocouple (Thermocouple-to-temperature converter (digital backend)) tt_um_wokwi_380412382001715201 (Naive 8-bit Binary Counter) tt_um_asinghani_tinyscanchain_tt05 (tinyscanchain Test Design) tt_um_carlosgs99_cro_udg (6 digit chronometer.) tt_um_suhrojo (Convolutional Network Circuit Chip Design) tt_um_mvm_ (Matrix Vector Multiplication Accelerator) tt_um_perceptron_neuromeme (Perceptron (Neuromeme)) tt_um_czlucius_alu (4 Bit ALU) tt_um_BNNNeuron (Binary Neural Network (Verilog Demo)) tt_um_urish_skullfet (SkullFET) tt_um_ja1tye_sound_generator (Wavetable Sound Generator) tt_um_jaylennee_wta_pwm (PWM signal generation with Winner-Take-All selection) tt_um_joerdsonsilva_top (Multimode Modem) tt_um_toivoh_synth (Analog emulation monosynth) tt_um_tiny_game_of_life (Tiny Game of Life) tt_um_mingkaic1_stack_machine (Stack Machine) tt_um_morningjava_top (ChipTune) tt_um_urish_silife (Game of Life 8x8 (siLife)) tt_um_tt05_analog_test (TT05 Analog Testmacro (Ringo, DAC)) tt_um_wokwi_380409528895479809 (RBUART) tt_um_mattngaw_fp8 (8-bit Floating-Point Adder) tt_um_chip_inventor_music__6_bit_count (6 bit Counter and Piano Music created by Chip Inventor) tt_um_4_bit_pipeline_multiplier (4 Bit Pipelined Multiplier) tt_um_wokwi_380477805171811329 (2-Bit ALU + Dice) tt_um_wokwi_380490286828784641 (TT02 Wokwi 7seg remake) tt_um_wokwi_380361576213660673 (ping pong asic) tt_um_prg (A Boolean function based pseudo random number generator (PRNG)) tt_um_digital_clock_sellicott (Digital Desk Clock) tt_um_haozhezhu_top (4-bit FIFO/LIFO) tt_um_top_mole99 (One Sprite Pony) tt_um_GrayCounter_ariz207 (4 bit Sync Gray Code Counter) tt_um_clkdiv (Clock and Random Number Gen) tt_um_matt_divider_test (TT05 Analog Test) tt_um_tomkeddie_a (VGA Experiments) tt_um_rejunity_rule110 (Rule110 cell automata) tt_um_no_time_for_squares_tommythorn (No Time for Squares) tt_um_urish_silife_max (Game of Life 8x32 (siLife)) tt_um_gfg_development_tros (TROS) tt_um_chatgpt_snn_mtomlin5 (ChatGPT designed Spiking Neural Network) tt_um_ks_pyamnihc (Karplus-Strong String Synthesis) tt_um_dinogame (VGA Dino Game) tt_um_himanshu5_prog_chipTop (Dual Compute Unit) tt_um_rtfb_collatz (Collatz conjecture brute-forcer) tt_um_retospect_neurochip (Field Programmable Neural Array) tt_um_urish_dffram (DFFRAM Example (128 bytes)) tt_um_rejunity_snn (Chonky SNN) tt_um_hh (Hodgkin-Huxley Neuron) tt_um_wokwi_377426511818305537 (PRBS Generator) tt_um_devinatkin_stopwatch (Stop Watch) tt_um_algofoogle_vga_spi_rom (vga_spi_rom) tt_um_blink (RO and counter) tt_um_ttl74hc595_v2 (8-Bit Shift Register with Output Latches 74HC595) tt_um_psychogenic_neptuneproportional (Neptune guitar tuner (proportional window, version b, debug output on bidir pins, larger set of frequencies)) tt_um_urish_simon (Simon Says game) tt_um_kianV_rv32ima_uLinux_SoC (KianV uLinux SoC) tt_um_urish_ringosc_cnt (Ring oscillator with counter) tt_um_sunaofurukawa_cpu_8bit (cpu_8bit) tt_um_vga_clock (VGA clock) tt_um_seven_segment_seconds (7 segment seconds (Verilog Demo)) tt_um_frequency_counter (Frequency counter) tt_um_rgb_mixer (RGB Mixer) tt_um_MichaelBell_spi_peri (SPI Peripheral) tt_um_multiplexed_clock (Multiplexed clock) tt_um_psychogenic_shaman (Shaman: SHA-256 hasher) tt_um_yubex_metastability_experiment (metastability experiment) Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available