From 360079d096c5609d580220065fa31ba08e7a8317 Mon Sep 17 00:00:00 2001 From: David Steele Date: Tue, 20 Sep 2022 15:07:01 +0100 Subject: [PATCH] CORE-798 Make EL GIP Library FPGA Vendor Independent. Pof_protocol V3 - fpga vendor independent. Change Pof_Tx to fpga vendor independent FIFOs in common/1 --- generic_ip/pof_protocol/3/doc/pof_tx_3.json | 150 ++++ .../pof_protocol/3/sim/sim_pof_txrx_one.do | 83 ++ .../pof_protocol/3/sim/sim_pof_txrx_zero.do | 83 ++ .../pof_protocol/3/sim/wave_pof_txrx_one.do | 228 ++++++ .../pof_protocol/3/sim/wave_pof_txrx_zero.do | 219 ++++++ generic_ip/pof_protocol/3/src/pof_rx_3.vhd | 385 ++++++++++ generic_ip/pof_protocol/3/src/pof_tx_3.vhd | 315 ++++++++ .../pof_protocol/3/src/pof_uart_regen_3.vhd | 122 +++ .../pof_protocol/3/src/pof_uart_rx_3.vhd | 126 +++ .../3/src/test/pof_tx_rx_3_one_tb.vhd | 720 ++++++++++++++++++ .../3/src/test/pof_tx_rx_3_zero_tb.vhd | 694 +++++++++++++++++ generic_ip/pof_protocol/3/src/uart_tx_3.vhd | 164 ++++ generic_ip/pof_protocol/Readme.txt | 3 +- 13 files changed, 3291 insertions(+), 1 deletion(-) create mode 100644 generic_ip/pof_protocol/3/doc/pof_tx_3.json create mode 100644 generic_ip/pof_protocol/3/sim/sim_pof_txrx_one.do create mode 100644 generic_ip/pof_protocol/3/sim/sim_pof_txrx_zero.do create mode 100644 generic_ip/pof_protocol/3/sim/wave_pof_txrx_one.do create mode 100644 generic_ip/pof_protocol/3/sim/wave_pof_txrx_zero.do create mode 100644 generic_ip/pof_protocol/3/src/pof_rx_3.vhd create mode 100644 generic_ip/pof_protocol/3/src/pof_tx_3.vhd create mode 100644 generic_ip/pof_protocol/3/src/pof_uart_regen_3.vhd create mode 100644 generic_ip/pof_protocol/3/src/pof_uart_rx_3.vhd create mode 100644 generic_ip/pof_protocol/3/src/test/pof_tx_rx_3_one_tb.vhd create mode 100644 generic_ip/pof_protocol/3/src/test/pof_tx_rx_3_zero_tb.vhd create mode 100644 generic_ip/pof_protocol/3/src/uart_tx_3.vhd diff --git a/generic_ip/pof_protocol/3/doc/pof_tx_3.json b/generic_ip/pof_protocol/3/doc/pof_tx_3.json new file mode 100644 index 0000000..2fb7f9d --- /dev/null +++ b/generic_ip/pof_protocol/3/doc/pof_tx_3.json @@ -0,0 +1,150 @@ +[{ + "ip_name": "pof_tx_3", + "bus": "csr", + "addr_width" : "3", + "description": "POF-Transmitter", + "registers": { + "control" : { + "address" : "0", + "width" : "12", + "description" : "Control register", + "fields": { + "enable" : { + "type" : "w", + "bit_len" : "1", + "reset" : "0x0", + "description" : "POF-Tx enable" + }, + "Reserved0" : { + "type" : "rsv", + "bit_len" : "1", + "description" : "Reserved bits" + }, + "clr_fifo_level_max" : { + "type" : "w0", + "bit_len" : "1", + "reset" : "0x0", + "description" : "Clears the fifo_level maximum value to zero" + }, + "Reserved1" : { + "type" : "rsv", + "bit_len" : "1", + "description" : "Reserved bits" + }, + "bit_div" : { + "type" : "w", + "bit_len" : "4", + "reset" : "0x2", + "description" : "UART-Tx bit-rate division ratio" + }, + "print_start_event_gen" : { + "type" : "w", + "bit_len" : "1", + "reset" : "0x0", + "description": "Enables queuing up events in the POF-Tx FIFO, each time there is a change in Print-Start value. Otherwise block only transmits on next enc/PD event or keepalive. Leaving at zero does NOT stop print_start being communicated - change the selector to SW to force a value. Only used when PROTOCOL_VERSION=1." + }, + "print_start_src" : { + "type" : "w", + "bit_len" : "1", + "reset" : "0x0", + "description" : "Specifies the source of Print-Start: 0 => input pin, 1 => software driven (print_start_sw). Only used when PROTOCOL_VERSION=1" + }, + "print_start_sw" : { + "type" : "w", + "bit_len" : "1", + "reset" : "0x0", + "description" : "Specifies the value of Print-Start when print_start_src = 1. Only used when PROTOCOL_VERSION=1" + }, + "Reserved2" : { + "type" : "rsv", + "bit_len" : "1", + "description" : "Reserved bits" + } + } + }, + "status" : { + "address" : "1", + "width" : "12", + "description" : "Status register", + "fields": { + "Reserved0" : { + "type" : "rsv", + "bit_len" : "1", + "description" : "Resereved bits" + }, + "ovfl_err" : { + "type" : "r", + "bit_len" : "1", + "reset" : "0x0", + "description" : "Overflow error" + }, + "Reserved1" : { + "type" : "rsv", + "bit_len" : "9", + "description" : "Reserved bits" + }, + "print_start_val" : { + "type" : "r", + "bit_len" : "1", + "reset" : "0x0", + "description" : "Print-Start status. Only used when PROTOCOL_VERSION=1" + } + } + }, + "error_inject" : { + "address" : "2", + "width" : "1", + "type" : "w0", + "reset" : "0x0", + "description" : "Inject a parity error on the next transmitted data" + }, + "timing" : { + "address" : "3", + "width" : "26", + "description" : "Timing Constants", + "fields": { + "keepalive_period" : { + "type" : "w", + "bit_len" : "10", + "reset" : "0x64", + "description" : "Specifies the keep-alive period" + }, + "Reserved" : { + "type" : "rsv", + "bit_len" : "6", + "description" : "Reserved bits" + }, + "init_blocked_period" : { + "type" : "w", + "bit_len" : "10", + "reset" : "0xC8", + "description" : "Specifies a guard period for the first event after an init pulse" + } + } + }, + "fifo_level" : { + "address" : "4", + "width" : "26", + "description" : "Monitors FIFO level status", + "fields": { + "fifo_level" : { + "type" : "r", + "bit_len" : "10", + "reset" : "0x0", + "description" : "current value of fifo_level" + }, + "Reserved" : { + "type" : "rsv", + "bit_len" : "6", + "description" : "Reserved bits" + }, + "max_fifo_level" : { + "type" : "r", + "bit_len" : "10", + "reset" : "0x0", + "description" : "maximum value for fifo_level" + } + } + } + } +}] diff --git a/generic_ip/pof_protocol/3/sim/sim_pof_txrx_one.do b/generic_ip/pof_protocol/3/sim/sim_pof_txrx_one.do new file mode 100644 index 0000000..d25e07c --- /dev/null +++ b/generic_ip/pof_protocol/3/sim/sim_pof_txrx_one.do @@ -0,0 +1,83 @@ +# Simulation macro Net-Sync testbench + +.main clear + +# Cleanup libraries +foreach lib [list work OSVVM] { + file delete -force -- $lib + vlib $lib +} + +set COMP_ONLY 0 + +set TB_PATH ./../src/test +set COMMON_PATH ../../../common/0/src +set OSVVM_PATH $COMMON_PATH/test/OSVVM + +set WORKLIB work + +vlib ./work +vmap work ./work + +if {$COMP_ONLY == 0} { +# Compile the constrained random related packages + vlib OSVVM + vcom -2008 -work OSVVM \ + $OSVVM_PATH/RandomBasePkg.vhd \ + $OSVVM_PATH/SortListPkg_int.vhd \ + $OSVVM_PATH/RandomPkg.vhd \ + $OSVVM_PATH/NamePkg.vhd \ + $OSVVM_PATH/MessagePkg.vhd \ + $OSVVM_PATH/CoveragePkg.vhd +} + +# compile the UUTs: +#vcom -2008 -work $WORKLIB $COMMON_PATH/pkg_functions.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/common_pkg.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/sync_wire.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/sync_wire_redge.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/sync_reset.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/sync_pulse.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/sync_pulse_vec_push.vhd +#vcom -2008 -work $WORKLIB ../src/altera/fifo_16x8.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/altera/sync_fifo.vhd +vcom -2008 -work $WORKLIB ../src/pof_tx_3_pkg_auto.vhd +vcom -2008 -work $WORKLIB ../src/pof_tx_3_csr_regs_auto.vhd +vcom -2008 -work $WORKLIB ../src/uart_tx_3.vhd +vcom -2008 -work $WORKLIB ../src/pof_uart_rx_3.vhd +vcom -2008 -work $WORKLIB ../src/pof_tx_3.vhd +vcom -2008 -work $WORKLIB ../src/pof_rx_3.vhd + + +# Compile the testbench and the other components supporting the test +if {$COMP_ONLY == 0} { + # Test support packages + vcom -2008 -work $WORKLIB $COMMON_PATH/test/common_test_pkg.vhd + vcom -2008 -work $WORKLIB $COMMON_PATH/test/log_pkg.vhd + vcom -2008 -work $WORKLIB $COMMON_PATH/test/avalon_verify_pkg.vhd + + # Testbench + vcom -2008 -work $WORKLIB $TB_PATH/pof_tx_rx_3_one_tb.vhd + + vsim -t ps work.pof_tx_rx_3_one_tb + + + add wave /pof_tx_rx_3_one_tb/* + add wave /pof_tx_rx_3_one_tb/iPOF_TX/* + add wave /pof_tx_rx_3_one_tb/iPOF_RX/* + + # remove warnings from standard numeric/arithmetic packages (speed-up simulation) + set StdArithNoWarnings 1 + set NumericStdNoWarnings 1 + + do wave_pof_txrx_one.do + + when -label end_of_simulation {test_completed == true} {echo "Simulation Completed"; stop ;} + run -all + + #run 1 ms; +} + + + + diff --git a/generic_ip/pof_protocol/3/sim/sim_pof_txrx_zero.do b/generic_ip/pof_protocol/3/sim/sim_pof_txrx_zero.do new file mode 100644 index 0000000..590a282 --- /dev/null +++ b/generic_ip/pof_protocol/3/sim/sim_pof_txrx_zero.do @@ -0,0 +1,83 @@ +# Simulation macro Net-Sync testbench + +.main clear + +# Cleanup libraries +foreach lib [list work OSVVM] { + file delete -force -- $lib + vlib $lib +} + +set COMP_ONLY 0 + +set TB_PATH ./../src/test +set COMMON_PATH ../../../common/0/src +set OSVVM_PATH $COMMON_PATH/test/OSVVM + +set WORKLIB work + +vlib ./work +vmap work ./work + +if {$COMP_ONLY == 0} { +# Compile the constrained random related packages + vlib OSVVM + vcom -2008 -work OSVVM \ + $OSVVM_PATH/RandomBasePkg.vhd \ + $OSVVM_PATH/SortListPkg_int.vhd \ + $OSVVM_PATH/RandomPkg.vhd \ + $OSVVM_PATH/NamePkg.vhd \ + $OSVVM_PATH/MessagePkg.vhd \ + $OSVVM_PATH/CoveragePkg.vhd +} + +# compile the UUTs: +#vcom -2008 -work $WORKLIB $COMMON_PATH/pkg_functions.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/common_pkg.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/sync_wire.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/sync_wire_redge.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/sync_reset.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/sync_pulse.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/sync_pulse_vec_push.vhd +#vcom -2008 -work $WORKLIB ../src/altera/fifo_16x8.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/altera/sync_fifo.vhd +vcom -2008 -work $WORKLIB ../src/pof_tx_3_pkg_auto.vhd +vcom -2008 -work $WORKLIB ../src/pof_tx_3_csr_regs_auto.vhd +vcom -2008 -work $WORKLIB ../src/uart_tx_3.vhd +vcom -2008 -work $WORKLIB ../src/pof_uart_rx_3.vhd +vcom -2008 -work $WORKLIB ../src/pof_tx_3.vhd +vcom -2008 -work $WORKLIB ../src/pof_rx_3.vhd + + +# Compile the testbench and the other components supporting the test +if {$COMP_ONLY == 0} { + # Test support packages + vcom -2008 -work $WORKLIB $COMMON_PATH/test/common_test_pkg.vhd + vcom -2008 -work $WORKLIB $COMMON_PATH/test/log_pkg.vhd + vcom -2008 -work $WORKLIB $COMMON_PATH/test/avalon_verify_pkg.vhd + + # Testbench + vcom -2008 -work $WORKLIB $TB_PATH/pof_tx_rx_3_zero_tb.vhd + + vsim -t ps work.pof_tx_rx_3_zero_tb + + + add wave /pof_tx_rx_3_zero_tb/* + add wave /pof_tx_rx_3_zero_tb/iPOF_TX/* + add wave /pof_tx_rx_3_zero_tb/iPOF_RX/* + + # remove warnings from standard numeric/arithmetic packages (speed-up simulation) + set StdArithNoWarnings 1 + set NumericStdNoWarnings 1 + + do wave_pof_txrx_zero.do + + when -label end_of_simulation {test_completed == true} {echo "Simulation Completed"; stop ;} + run -all + + #run 1 ms; +} + + + + diff --git a/generic_ip/pof_protocol/3/sim/wave_pof_txrx_one.do b/generic_ip/pof_protocol/3/sim/wave_pof_txrx_one.do new file mode 100644 index 0000000..cfe675c --- /dev/null +++ b/generic_ip/pof_protocol/3/sim/wave_pof_txrx_one.do @@ -0,0 +1,228 @@ +onerror {resume} +quietly WaveActivateNextPane {} 0 +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/clk +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/reset_n +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/avs_read +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/avs_write +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/sel_slave_0 +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/sel_slave_1 +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/avs_write_sl0 +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/avs_read_sl0 +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/avs_write_sl1 +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/avs_read_sl1 +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/init_tx +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/init_rx +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/dir_in +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/pd_in +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/inc_pos +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/dec_pos +add wave -noupdate -expand -group TB -radix decimal /pof_tx_rx_3_one_tb/abs_position +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/tx_data +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/rx_data +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/init_out +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/dir_out +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/enc_out +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/pd_out +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/inc_pos_out +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/dec_pos_out +add wave -noupdate -expand -group TB -radix decimal /pof_tx_rx_3_one_tb/abs_pos_out +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/print_start_in +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/print_start_out +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/ps_flip_cnt +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/test_completed +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/running +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/configuring +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/passed +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/failed +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/stimuli_completed +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/avs_address +add wave -noupdate -expand -group TB -radix hexadecimal /pof_tx_rx_3_one_tb/avs_writedata +add wave -noupdate -expand -group TB -radix hexadecimal /pof_tx_rx_3_one_tb/avs_readdata_sl0 +add wave -noupdate -expand -group TB -radix hexadecimal /pof_tx_rx_3_one_tb/avs_readdata_sl1 +add wave -noupdate -expand -group TB -radix decimal /pof_tx_rx_3_one_tb/abs_position_d +add wave -noupdate -expand -group TB -radix decimal /pof_tx_rx_3_one_tb/swathe_pos +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/swathe_cnt +add wave -noupdate -expand -group TB -radix hexadecimal /pof_tx_rx_3_one_tb/avs_m +add wave -noupdate -expand -group TB -radix hexadecimal /pof_tx_rx_3_one_tb/avs_s +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/detected_error +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/dir_discr_cnt +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/pd_discr_cnt +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/pd_in_cnt +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/pd_out_cnt +add wave -noupdate -expand -group TB -radix decimal /pof_tx_rx_3_one_tb/abs_position +add wave -noupdate -expand -group TB -radix decimal /pof_tx_rx_3_one_tb/abs_pos_out +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/pos_discr_cnt +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/end_of_swathe +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/enc_pulse_cnt +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/dir_err +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/pd_err +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/pos_err +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/enc_err +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/ovfl_err +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/ps_err +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/injected_errors +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/sent_packets +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/injected_error_type +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/max_pos +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/min_pos +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/exp_enc_pulse +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/exp_enc_cnt +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/error_rate_thres +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/one_pps +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/max_error_flag +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/rx_watchdog +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/rx_watchdog_en +add wave -noupdate -expand -group TB /pof_tx_rx_3_one_tb/rx_watchdog_clr +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/reset_n +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/clk +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/init +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/pd_in +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/inc_pos +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/dec_pos +add wave -noupdate -group POF-Tx -radix decimal /pof_tx_rx_3_one_tb/iPOF_TX/abs_position +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/tx_data +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/avs_address +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/avs_write +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/avs_writedata +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/avs_read +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/avs_readdata +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/rd_event +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/wr_event +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/empty +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/full +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/tx_ready +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/rd_event_d +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/wr_event_i +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/enable +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/toggle_sync +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/toggle_pd +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/add_keepalive +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/ovfl_err +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/init_d +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/init_gen +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/init_v +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/init_blocked +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/init_blk_cnt +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/parity_bit +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/inject_error +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/inject_error_req +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/pd_event +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/pd_event_d +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/pd_event_dd +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/gray +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/clear +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/pd_in_d +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/pd_gen +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/clk +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/symbol_valid +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/symbol +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/clr_fifo_lmax +add wave -noupdate -group POF-Tx -radix unsigned /pof_tx_rx_3_one_tb/iPOF_TX/keepalive_period +add wave -noupdate -group POF-Tx -radix unsigned /pof_tx_rx_3_one_tb/iPOF_TX/init_blocked_period +add wave -noupdate -group POF-Tx -radix unsigned /pof_tx_rx_3_one_tb/iPOF_TX/fifo_level +add wave -noupdate -group POF-Tx -radix unsigned /pof_tx_rx_3_one_tb/iPOF_TX/fifo_level_max +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/tx_data +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/event_in_i +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/event_in +add wave -noupdate -group POF-Tx /pof_tx_rx_3_one_tb/iPOF_TX/event_out +add wave -noupdate -group POF-Tx -radix decimal /pof_tx_rx_3_one_tb/iPOF_TX/keepalive_cnt +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/reset_n +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/clk +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/init +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/rx_clk +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/rx_data +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/init_out +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/pd_out +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/inc_pos +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/dec_pos +add wave -noupdate -group POF-Rx -radix decimal /pof_tx_rx_3_one_tb/iPOF_RX/abs_pos +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/print_start_out +add wave -noupdate -group POF-Rx -radix unsigned /pof_tx_rx_3_one_tb/iPOF_RX/error_rate_thres +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/one_pps +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/max_error_flag +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/rx_watchdog +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/rx_watchdog_en +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/rx_watchdog_clr +add wave -noupdate -group POF-Rx -radix unsigned /pof_tx_rx_3_one_tb/iPOF_RX/rx_wd_cnt +add wave -noupdate -group POF-Rx -radix unsigned /pof_tx_rx_3_one_tb/iPOF_RX/error_rate_cnt +add wave -noupdate -group POF-Rx -radix unsigned /pof_tx_rx_3_one_tb/iPOF_RX/error_rate +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/clear +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/clear_i +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/inc_pos_i +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/dec_pos_i +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/enable +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/sync_gen +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/pd_gen +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/symbol_error +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/rx_symbol_val +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/rx_symbol +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/rx_symbol_val_v +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/symbol_valid_i +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/symbol_valid_d +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/toggle_sync +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/sync_confirmed +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/sync_toggle_test +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/sync +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/toggle_pd +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/pd_confirmed +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/pd_toggle_test +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/pd +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/print_start_in +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/print_start_out +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/ps_flip_cnt +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/ps_gen +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/ps_new +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/ps_confirmed +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/ps_test +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/rx_error +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/rx_error_i +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/print_start_i +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/valid_pos +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/upd_pos +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/corr_done +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/corr_sign +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/skip_cnt +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/skip_pos +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/symbol_valid +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/symbol +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/apply_corr +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/clk_cnt +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/dist +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/abs_dist +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/next_pos_lsb +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/curr_pos_lsb +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/pos_corr +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/max_dist +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/gray_pos +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/symbol_i +add wave -noupdate -group POF-Rx -radix unsigned /pof_tx_rx_3_one_tb/iPOF_RX/parity_err_cnt +add wave -noupdate -group POF-Rx -radix decimal /pof_tx_rx_3_one_tb/iPOF_RX/abs_pos_i +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/inc_pos_ii +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/dec_pos_ii +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/GEN_RX_SYMBOL/iRX_SYMBOL/data_width +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/GEN_RX_SYMBOL/iRX_SYMBOL/reset_n +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/GEN_RX_SYMBOL/iRX_SYMBOL/clk +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/GEN_RX_SYMBOL/iRX_SYMBOL/init +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/GEN_RX_SYMBOL/iRX_SYMBOL/data_out +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/GEN_RX_SYMBOL/iRX_SYMBOL/data_out_valid +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/GEN_RX_SYMBOL/iRX_SYMBOL/rx_data +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/GEN_RX_SYMBOL/iRX_SYMBOL/rx_data_i +add wave -noupdate -group POF-Rx /pof_tx_rx_3_one_tb/iPOF_RX/GEN_RX_SYMBOL/iRX_SYMBOL/data +TreeUpdate [SetDefaultTree] +WaveRestoreCursors {{Cursor 1} {1338555000 ps} 0} +quietly wave cursor active 1 +configure wave -namecolwidth 305 +configure wave -valuecolwidth 100 +configure wave -justifyvalue left +configure wave -signalnamewidth 0 +configure wave -snapdistance 10 +configure wave -datasetprefix 0 +configure wave -rowmargin 4 +configure wave -childrowmargin 2 +configure wave -gridoffset 0 +configure wave -gridperiod 1 +configure wave -griddelta 40 +configure wave -timeline 0 +configure wave -timelineunits ps +update +WaveRestoreZoom {4636240802 ps} {7857466274 ps} diff --git a/generic_ip/pof_protocol/3/sim/wave_pof_txrx_zero.do b/generic_ip/pof_protocol/3/sim/wave_pof_txrx_zero.do new file mode 100644 index 0000000..2d01215 --- /dev/null +++ b/generic_ip/pof_protocol/3/sim/wave_pof_txrx_zero.do @@ -0,0 +1,219 @@ +onerror {resume} +quietly WaveActivateNextPane {} 0 +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/rx_watchdog_clr +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/rx_watchdog_en +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/rx_watchdog +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/max_error_flag +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/one_pps +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/error_rate_thres +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/exp_enc_cnt +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/exp_enc_pulse +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/min_pos +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/max_pos +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/injected_errors +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/sent_packets +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/injected_error_type +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/ovfl_err +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/enc_err +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/pos_err +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/pd_err +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/dir_err +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/enc_pulse_cnt +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/end_of_swathe +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/pos_discr_cnt +add wave -noupdate -expand -group TB -radix decimal /pof_tx_rx_2_zero_tb/abs_pos_out +add wave -noupdate -expand -group TB -radix decimal /pof_tx_rx_2_zero_tb/abs_position +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/pd_out_cnt +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/pd_in_cnt +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/pd_discr_cnt +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/dir_discr_cnt +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/detected_error +add wave -noupdate -expand -group TB -radix hexadecimal /pof_tx_rx_2_zero_tb/avs_s +add wave -noupdate -expand -group TB -radix hexadecimal /pof_tx_rx_2_zero_tb/avs_m +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/swathe_cnt +add wave -noupdate -expand -group TB -radix decimal /pof_tx_rx_2_zero_tb/swathe_pos +add wave -noupdate -expand -group TB -radix decimal /pof_tx_rx_2_zero_tb/abs_position_d +add wave -noupdate -expand -group TB -radix hexadecimal /pof_tx_rx_2_zero_tb/avs_readdata_sl1 +add wave -noupdate -expand -group TB -radix hexadecimal /pof_tx_rx_2_zero_tb/avs_readdata_sl0 +add wave -noupdate -expand -group TB -radix hexadecimal /pof_tx_rx_2_zero_tb/avs_writedata +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/avs_address +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/stimuli_completed +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/failed +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/passed +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/configuring +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/running +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/test_completed +add wave -noupdate -expand -group TB -radix decimal /pof_tx_rx_2_zero_tb/abs_pos_out +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/dec_pos_out +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/inc_pos_out +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/pd_out +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/enc_out +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/dir_out +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/init_out +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/rx_data +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/tx_data +add wave -noupdate -expand -group TB -radix decimal /pof_tx_rx_2_zero_tb/abs_position +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/dec_pos +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/inc_pos +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/pd_in +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/dir_in +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/init_rx +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/init_tx +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/avs_read_sl1 +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/avs_write_sl1 +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/avs_read_sl0 +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/avs_write_sl0 +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/sel_slave_1 +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/sel_slave_0 +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/avs_write +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/avs_read +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/clk +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/reset_n +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/injected_errors +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/sent_packets +add wave -noupdate -expand -group TB /pof_tx_rx_2_zero_tb/injected_error_type +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/reset_n +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/clk +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/init +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/pd_in +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/inc_pos +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/dec_pos +add wave -noupdate -group POF-Tx -radix decimal /pof_tx_rx_2_zero_tb/iPOF_TX/abs_position +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/tx_data +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/avs_address +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/avs_write +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/avs_writedata +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/avs_read +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/avs_readdata +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/rd_event +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/wr_event +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/empty +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/full +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/tx_ready +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/rd_event_d +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/wr_event_i +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/enable +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/toggle_sync +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/toggle_pd +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/add_keepalive +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/ovfl_err +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/init_d +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/init_gen +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/init_v +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/init_blocked +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/init_blk_cnt +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/parity_bit +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/inject_error +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/inject_error_req +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/pd_event +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/pd_event_d +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/pd_event_dd +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/gray +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/clear +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/pd_in_d +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/pd_gen +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/clk +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/symbol_valid +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/symbol +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/clr_fifo_lmax +add wave -noupdate -group POF-Tx -radix unsigned /pof_tx_rx_2_zero_tb/iPOF_TX/keepalive_period +add wave -noupdate -group POF-Tx -radix unsigned /pof_tx_rx_2_zero_tb/iPOF_TX/init_blocked_period +add wave -noupdate -group POF-Tx -radix unsigned /pof_tx_rx_2_zero_tb/iPOF_TX/fifo_level +add wave -noupdate -group POF-Tx -radix unsigned /pof_tx_rx_2_zero_tb/iPOF_TX/fifo_level_max +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/tx_data +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/event_in_i +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/event_in +add wave -noupdate -group POF-Tx /pof_tx_rx_2_zero_tb/iPOF_TX/event_out +add wave -noupdate -group POF-Tx -radix decimal /pof_tx_rx_2_zero_tb/iPOF_TX/keepalive_cnt +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/reset_n +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/clk +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/init +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/rx_clk +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/rx_data +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/init_out +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/pd_out +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/inc_pos +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/dec_pos +add wave -noupdate -group POF-Rx -radix decimal /pof_tx_rx_2_zero_tb/iPOF_RX/abs_pos +add wave -noupdate -group POF-Rx -radix unsigned /pof_tx_rx_2_zero_tb/iPOF_RX/error_rate_thres +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/one_pps +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/max_error_flag +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/rx_watchdog +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/rx_watchdog_en +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/rx_watchdog_clr +add wave -noupdate -group POF-Rx -radix unsigned /pof_tx_rx_2_zero_tb/iPOF_RX/rx_wd_cnt +add wave -noupdate -group POF-Rx -radix unsigned /pof_tx_rx_2_zero_tb/iPOF_RX/error_rate_cnt +add wave -noupdate -group POF-Rx -radix unsigned /pof_tx_rx_2_zero_tb/iPOF_RX/error_rate +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/clear +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/clear_i +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/inc_pos_i +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/dec_pos_i +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/enable +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/sync_gen +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/pd_gen +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/symbol_error +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/rx_symbol_val +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/rx_symbol +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/rx_symbol_val_v +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/symbol_valid_i +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/symbol_valid_d +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/toggle_sync +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/sync_confirmed +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/sync_toggle_test +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/sync +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/toggle_pd +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/pd_confirmed +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/pd_toggle_test +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/pd +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/rx_error +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/rx_error_i +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/print_start_i +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/valid_pos +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/upd_pos +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/corr_done +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/corr_sign +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/skip_cnt +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/skip_pos +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/symbol_valid +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/symbol +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/apply_corr +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/clk_cnt +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/dist +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/abs_dist +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/next_pos_lsb +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/curr_pos_lsb +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/pos_corr +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/max_dist +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/gray_pos +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/symbol_i +add wave -noupdate -group POF-Rx -radix unsigned /pof_tx_rx_2_zero_tb/iPOF_RX/parity_err_cnt +add wave -noupdate -group POF-Rx -radix decimal /pof_tx_rx_2_zero_tb/iPOF_RX/abs_pos_i +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/inc_pos_ii +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/dec_pos_ii +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/GEN_RX_SYMBOL/iRX_SYMBOL/data_width +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/GEN_RX_SYMBOL/iRX_SYMBOL/reset_n +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/GEN_RX_SYMBOL/iRX_SYMBOL/clk +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/GEN_RX_SYMBOL/iRX_SYMBOL/init +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/GEN_RX_SYMBOL/iRX_SYMBOL/data_out +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/GEN_RX_SYMBOL/iRX_SYMBOL/data_out_valid +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/GEN_RX_SYMBOL/iRX_SYMBOL/rx_data +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/GEN_RX_SYMBOL/iRX_SYMBOL/rx_data_i +add wave -noupdate -group POF-Rx /pof_tx_rx_2_zero_tb/iPOF_RX/GEN_RX_SYMBOL/iRX_SYMBOL/data +TreeUpdate [SetDefaultTree] +WaveRestoreCursors {{Cursor 1} {2137525000 ps} 0} +quietly wave cursor active 1 +configure wave -namecolwidth 305 +configure wave -valuecolwidth 100 +configure wave -justifyvalue left +configure wave -signalnamewidth 0 +configure wave -snapdistance 10 +configure wave -datasetprefix 0 +configure wave -rowmargin 4 +configure wave -childrowmargin 2 +configure wave -gridoffset 0 +configure wave -gridperiod 1 +configure wave -griddelta 40 +configure wave -timeline 0 +configure wave -timelineunits ps +update +WaveRestoreZoom {0 ps} {3221225472 ps} diff --git a/generic_ip/pof_protocol/3/src/pof_rx_3.vhd b/generic_ip/pof_protocol/3/src/pof_rx_3.vhd new file mode 100644 index 0000000..81fdd9d --- /dev/null +++ b/generic_ip/pof_protocol/3/src/pof_rx_3.vhd @@ -0,0 +1,385 @@ +------------------------------------------------------------------------------- +-- Title : pof_rx +-- Project : SMB +------------------------------------------------------------------------------- +-- File : pof_rx_3.vhd +-- Author : Gianmarco Girau +-- Company : Global Inkjet Systems +-- Created : 2017-08-23 +-- Last update: 2021-08-06 +-- SVN ID : Git +-- Standard : VHDL'08 +------------------------------------------------------------------------------- +-- Description: +-- Deserializes and decodes the EMS (SMB) output, received from the POF. +------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity pof_rx_3 is + generic( + GEN_BIT_DIV : integer := 6 + ); + port( + reset_n : in std_logic; -- on clk domain + clk : in std_logic; + -- + init : in std_logic; + rx_clk : in std_logic; + rx_data : in std_logic; + init_out : out std_logic; + pd_out : out std_logic; + print_start : out std_logic; + inc_pos : out std_logic; + dec_pos : out std_logic; + abs_pos : out std_logic_vector(31 downto 0); + -- C&S + pof_protocol_version : in std_logic := '0'; -- 0 for zero, 1 for one + enable : in std_logic; + error_rate_thres : in std_logic_vector(7 downto 0); + one_pps : in std_logic; + max_error_flag : out std_logic; + rx_watchdog : out std_logic; + rx_watchdog_en : in std_logic; + rx_watchdog_clr : in std_logic; + parity_err_cnt : out std_logic_vector(15 downto 0); + skip_pos_cnt : out std_logic_vector(15 downto 0)); +end entity pof_rx_3; + +architecture rtl of pof_rx_3 is + + -- check the parity bit (odd parity) + function odd_parity_check(data : std_logic_vector) return std_logic is + variable parity_bit : std_logic := '0'; + begin + for n in 0 to data'length - 1 loop + parity_bit := parity_bit xor data(n); + end loop; -- n + return parity_bit; + end function odd_parity_check; + + -- Gray-to-Binary coding + function gray2bin(gray : std_logic_vector) return std_logic_vector is + variable bin : std_logic_vector(gray'range); + begin + bin(gray'length - 1) := gray(gray'length - 1); + for i in gray'length - 2 downto 0 loop + bin(i) := bin(i + 1) xor gray(i); + end loop; -- n + return bin; + end function gray2bin; + + signal clear, symbol_ok, inc_pos_i, dec_pos_i : std_logic; + signal sync_gen, pd_gen, symbol_error : std_logic; + signal symbol_valid, symbol_valid_i, symbol_valid_d : std_logic; -- on clk domain + signal toggle_sync, sync_confirmed, sync_toggle_test, sync : std_logic; + signal toggle_pd, pd_confirmed, pd_toggle_test, pd : std_logic; + signal ps_gen, ps_new, ps_confirmed, ps_test : std_logic; + signal valid_pos, upd_pos, corr_done, corr_sign : std_logic; + signal skip_pos, apply_corr, inc_pos_ii, dec_pos_ii : std_logic; + signal rx_error, rx_error_i, print_start_i : std_logic; + signal rx_symbol_val, clear_i, skip_pos_d, pos_recovery : std_logic; + signal max_error_flag_i : std_logic; + -- + signal clk_cnt : std_logic_vector(1 downto 0); + signal dist, abs_dist, skip_cnt : std_logic_vector(3 downto 0); + signal next_pos_lsb, curr_pos_lsb : std_logic_vector(3 downto 0); + signal pos_corr, max_dist : std_logic_vector(3 downto 0); + signal gray_pos : std_logic_vector(3 downto 0); + signal symbol, rx_symbol, rx_symbol_0, rx_symbol_1 : std_logic_vector(8 downto 0); -- symbol and rx_symbol* are on rx_clk + signal rx_symbol_val_0, rx_symbol_val_1 : std_logic; + signal rx_error_0, rx_error_1 : std_logic; + signal rx_wd_cnt : std_logic_vector(9 downto 0); + signal parity_err_cnt_i, skip_pos_cnt_i : std_logic_vector(15 downto 0); + signal error_rate_cnt, error_rate : std_logic_vector(15 downto 0); + signal abs_pos_i : std_logic_vector(31 downto 0); + signal reset_n_rx : std_logic; -- reset on rx_clk domain + + +begin + + clear <= not enable or init; + + iSyncReset : entity work.sync_reset + port map( + async_rstN => reset_n, + clk => clk, + sync_rstN => reset_n_rx); + ----------------------------------------------------------------------------- + -- De-serialize symbols (Serial clock at 300 MHz - typical) + ----------------------------------------------------------------------------- + + + iRX_SYMBOL_protver0 : entity work.pof_uart_rx_3 + generic map( + GEN_BIT_DIV => GEN_BIT_DIV, + data_width => 8) + port map( + reset_n => reset_n, -- contains synchroniser + clk => rx_clk, + init => clear_i, -- already synchronised to rx_clk + data_out => rx_symbol_0(7 downto 0), -- on rx_clk domain - gets synchronised in pof_rx_2 + data_out_valid => rx_symbol_val_0, -- on rx_clk domain - gets synchronised in pof_rx_2 + rx_error => rx_error_0, -- on rx_clk domain - gets synchronised in pof_rx_2 + rx_data => rx_data); -- asynchronous - gets synchronised in the uart + + rx_symbol_0(8) <= '0'; + + iRX_SYMBOL_protver1 : entity work.pof_uart_rx_3 + generic map( + GEN_BIT_DIV => GEN_BIT_DIV, + data_width => 9) + port map( + reset_n => reset_n, + clk => rx_clk, + init => clear_i, + data_out => rx_symbol_1, + data_out_valid => rx_symbol_val_1, + rx_error => rx_error_1, + rx_data => rx_data); + + + + -- Synchronize to the local clock + iSYNC_SYMBOL_VAL : entity work.sync_pulse_vec_push + generic map( + SYNC_STAGES => 2, + VEC_WIDTH => symbol'length + ) + port map( + clk_a => rx_clk, + rst_n_a => reset_n, + pulse_a => rx_symbol_val, + busy_a => open, + vec_a => rx_symbol, + clk_b => clk, + rst_n_b => reset_n_rx, + pulse_b => symbol_valid, + vec_b => symbol + ); + + iSYNC_RX_ERROR : entity work.sync_pulse + generic map( + SYNC_STAGES => 2 + ) + port map( + clk_in => rx_clk, + rst_n => reset_n_rx, + pulse_in => rx_error, + clk_out => clk, + pulse_out => rx_error_i + ); + + -- synchronize clear to tx_clk + iSYNC_CLEAR : entity work.sync_wire + generic map(rst_val => '1', sync_stages => 2) + port map( + rstN => reset_n_rx, clk => rx_clk, async_in => clear, sync_out => clear_i); + + ----------------------------------------------------------------------------- + -- Toggle-Bits Decoding + ----------------------------------------------------------------------------- + + pTOGGLE_DEC : process(clk) + begin + if (clk = '1' and clk'event) then + -- Toggle Bits: + -- Sync + if (clear = '1') then + toggle_sync <= '0'; + elsif (sync_confirmed = '1') then + toggle_sync <= not toggle_sync; + end if; + if (clear = '1' or sync_confirmed = '1' or (symbol_valid_i = '1' and symbol(0) = toggle_sync)) then + sync_toggle_test <= '0'; + elsif (sync_gen = '1') then + sync_toggle_test <= '1'; + end if; + sync <= sync_confirmed; + -- PD + if (clear = '1') then + toggle_pd <= '0'; + elsif (pd_confirmed = '1') then + toggle_pd <= not toggle_pd; + end if; + if (clear = '1' or pd_confirmed = '1' or (symbol_valid_i = '1' and symbol(2) = toggle_pd)) then + pd_toggle_test <= '0'; + elsif (pd_gen = '1') then + pd_toggle_test <= '1'; + end if; + pd <= pd_confirmed; + -- Print Start/Stop + if (ps_gen = '1') then + ps_new <= symbol(7); + end if; + if (clear = '1' or ps_confirmed = '1' or (symbol_valid_i = '1' and symbol(7) /= ps_new)) then + ps_test <= '0'; + elsif (ps_gen = '1') then + ps_test <= '1'; + end if; + if (init = '1' or enable = '0') then + print_start_i <= '0'; + elsif (ps_confirmed = '1') then + print_start_i <= ps_new; + end if; + -- + symbol_valid_i <= symbol_valid and symbol_ok; + symbol_error <= symbol_valid and not symbol_ok; + if (clear = '1') then + parity_err_cnt_i <= (others => '0'); + elsif (symbol_error = '1') then + parity_err_cnt_i <= std_logic_vector(unsigned(parity_err_cnt_i) + 1); + end if; + end if; + end process pTOGGLE_DEC; + + -- The received symbol is assumed to be vaild when there is not parity error + -- and when the two bits with the PD-toggle bit are equal + symbol_ok <= '1' when odd_parity_check(symbol) = '1' and (symbol(1) = symbol(2)) else '0'; + + sync_gen <= '1' when symbol_valid_i = '1' and symbol(0) /= toggle_sync else '0'; + pd_gen <= '1' when symbol_valid_i = '1' and symbol(2) /= toggle_pd else '0'; + -- + sync_confirmed <= sync_gen and sync_toggle_test; + pd_confirmed <= pd_gen and pd_toggle_test; + -- + init_out <= sync; + pd_out <= pd; + + parity_err_cnt <= parity_err_cnt_i; + + gen_print_start : process(all) is + begin + if pof_protocol_version = '0' then + ps_confirmed <= '0'; + print_start <= '0'; + + rx_symbol <= rx_symbol_0; + rx_symbol_val <= rx_symbol_val_0; + rx_error <= rx_error_0; + else + ps_confirmed <= ps_gen and ps_test; + print_start <= print_start_i; + + rx_symbol <= rx_symbol_1; + rx_symbol_val <= rx_symbol_val_1; + rx_error <= rx_error_1; + end if; + end process gen_print_start; + ps_gen <= '1' when (pof_protocol_version = '1' and symbol_valid_i = '1' and symbol(7) /= print_start_i) else '0'; + + ----------------------------------------------------------------------------- + -- Position management & Error Recovery + ----------------------------------------------------------------------------- + + gray_pos <= symbol(6 downto 3); + next_pos_lsb <= gray2bin(gray_pos); + curr_pos_lsb <= abs_pos_i(3 downto 0); + + --dist <= std_logic_vector(signed(next_pos_lsb)-signed(curr_pos_lsb)); + abs_dist <= dist when dist(3) = '0' else std_logic_vector(unsigned(not dist) + 1); + + pPOS_MNG : process(clk) + begin + if (clk = '1' and clk'event) then + dist <= std_logic_vector(signed(next_pos_lsb) - signed(curr_pos_lsb)); + symbol_valid_d <= symbol_valid_i; + if (clear = '1' or (symbol_valid_d = '1' and signed(dist) = 0) or pos_recovery = '1') then + max_dist <= "0001"; + elsif (skip_pos = '1' or rx_error_i = '1') then + max_dist <= std_logic_vector(unsigned(max_dist) + 1); + end if; + if (symbol_valid_d = '1' and valid_pos = '1') then + pos_corr <= abs_dist; + elsif (apply_corr = '1') then + pos_corr <= std_logic_vector(unsigned(pos_corr) - 1); + end if; + if (clear = '1' or corr_done = '1') then + upd_pos <= '0'; + elsif (symbol_valid_d = '1' and valid_pos = '1') then + upd_pos <= '1'; + end if; + if (upd_pos = '0' or unsigned(clk_cnt) = 2) then + clk_cnt <= (others => '0'); + else + clk_cnt <= std_logic_vector(unsigned(clk_cnt) + 1); + end if; + if (symbol_valid_d = '1' and valid_pos = '1') then + corr_sign <= dist(3); + end if; + inc_pos_i <= inc_pos_ii; + dec_pos_i <= dec_pos_ii; + inc_pos <= inc_pos_i; + dec_pos <= dec_pos_i; + if (clear = '1' or sync = '1') then + abs_pos_i <= (others => '0'); + elsif (inc_pos_ii = '1') then + abs_pos_i <= std_logic_vector(signed(abs_pos_i) + 1); + elsif (dec_pos_ii = '1') then + abs_pos_i <= std_logic_vector(signed(abs_pos_i) - 1); + end if; + abs_pos <= abs_pos_i; + skip_pos_d <= skip_pos; + if (clear = '1' or (symbol_valid_d = '1' and valid_pos = '1')) then + skip_cnt <= (others => '0'); + elsif (skip_pos = '1' and skip_pos_d = '0') then + skip_cnt <= std_logic_vector(unsigned(skip_cnt) + 1); + end if; + if (clear = '1') then + skip_pos_cnt_i <= (others => '0'); + elsif (skip_pos_d = '1') then + skip_pos_cnt_i <= std_logic_vector(unsigned(skip_pos_cnt_i) + 1); + end if; + end if; + end process pPOS_MNG; + + skip_pos <= '1' when (symbol_valid = '1' and symbol_ok = '0') or (symbol_valid_d = '1' and valid_pos = '0') else '0'; + + pos_recovery <= '1' when unsigned(skip_cnt) >= 3 else '0'; + valid_pos <= '1' when unsigned(abs_dist) <= unsigned(max_dist) or pos_recovery = '1' else '0'; + + apply_corr <= '1' when upd_pos = '1' and clk_cnt = "01" else '0'; + corr_done <= '1' when signed(dist) = 0 else '0'; + + inc_pos_ii <= '1' when apply_corr = '1' and corr_sign = '0' else '0'; + dec_pos_ii <= '1' when apply_corr = '1' and corr_sign = '1' else '0'; + + skip_pos_cnt <= skip_pos_cnt_i; + + ----------------------------------------------------------------------------- + -- Additional logic for error reporting + ----------------------------------------------------------------------------- + + pERROR_REPORTING : process(clk) + begin + if (clk = '1' and clk'event) then + if (clear = '1' or one_pps = '1') then + error_rate_cnt <= (others => '0'); + elsif (symbol_error = '1') then + error_rate_cnt <= std_logic_vector(unsigned(error_rate_cnt) + 1); + end if; + if (clear = '1') then + error_rate <= (others => '0'); + elsif (one_pps = '1') then + error_rate <= error_rate_cnt; + end if; + max_error_flag <= not clear and max_error_flag_i; + if (clear = '1' or symbol_valid_i = '1' or rx_watchdog_clr = '1') then + rx_wd_cnt <= (others => '0'); + else + rx_wd_cnt <= std_logic_vector(unsigned(rx_wd_cnt) + 1); + end if; + if (clear = '1' or rx_watchdog_clr = '1' or rx_watchdog_en = '0' or sync = '1') then + rx_watchdog <= '0'; + elsif (unsigned(rx_wd_cnt) > 1000) then + rx_watchdog <= '1'; + end if; + end if; + end process pERROR_REPORTING; + + max_error_flag_i <= '1' when unsigned(error_rate) > unsigned(error_rate_thres) else '0'; + +end architecture rtl; diff --git a/generic_ip/pof_protocol/3/src/pof_tx_3.vhd b/generic_ip/pof_protocol/3/src/pof_tx_3.vhd new file mode 100644 index 0000000..fe55a35 --- /dev/null +++ b/generic_ip/pof_protocol/3/src/pof_tx_3.vhd @@ -0,0 +1,315 @@ +------------------------------------------------------------------------------- +-- Title : pof_tx_3 +-- Project : SMB +------------------------------------------------------------------------------- +-- File : pof_tx_3.vhd +-- Author : Gianmarco Girau +-- Company : Global Inkjet Systems +-- Created : 2017-08-22 +-- Last update: 2021-71-06 +-- SVN ID : Git +-- Standard : VHDL'08 +------------------------------------------------------------------------------- +-- Description: +-- Encodes the EMS output into a serial format to be distributed over the POF +------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity pof_tx_3 is + generic ( + DEVICE_FAMILY : string := "Cyclone V" + ); + port( + reset_n : in std_logic; + clk : in std_logic; + init : in std_logic; + init_done : out std_logic; + pd_in : in std_logic; + print_start : in std_logic := '0'; + pof_protocol_version : in std_logic := '0'; + inc_pos : in std_logic; + dec_pos : in std_logic; + abs_position : in std_logic_vector(31 downto 0); + tx_data : out std_logic; + -- Avalon MM Interface + avs_address : in std_logic_vector(2 downto 0); + avs_write : in std_logic; + avs_writedata : in std_logic_vector(31 downto 0); + avs_read : in std_logic; + avs_readdata : out std_logic_vector(31 downto 0)); +end entity pof_tx_3; + +architecture rtl of pof_tx_3 is + + function odd_parity(data : std_logic_vector) return std_logic is + variable parity_bit : std_logic := '1'; + begin + for n in 0 to data'length - 1 loop + parity_bit := parity_bit xor data(n); + end loop; -- n + return parity_bit; + end function odd_parity; + + function bin2gray(bin : std_logic_vector) return std_logic_vector is + variable gray : std_logic_vector(bin'range); + begin + gray := bin xor ('0' & bin(bin'length - 1 downto 1)); + return gray; + end function bin2gray; + + signal rd_event, wr_event, empty, full, tx_ready : std_logic; + signal rd_event_d, wr_event_i, symbol_valid : std_logic; + signal enable, toggle_sync, toggle_pd : std_logic; + signal add_keepalive, ovfl_err, init_d, init_gen : std_logic; + signal clear, pd_in_d, pd_gen, parity_bit : std_logic; + signal inject_error, inject_error_req : std_logic; + signal pd_event, pd_event_d, pd_event_dd : std_logic; + signal init_blocked, pd_event_ddd, delayed_pos : std_logic; + signal clr_fifo_lmax : std_logic; + signal print_start_en, print_start_src : std_logic; + signal print_start_sw, print_start_val : std_logic; + signal print_start_val_d, print_start_event : std_logic; + signal print_start_event_d, print_start_gen : std_logic; + -- + signal delayed_pos_v : std_logic_vector(2 downto 0); + signal init_v, gray, bit_div : std_logic_vector(3 downto 0); + signal latched_pos : std_logic_vector(3 downto 0); + signal event_in_i : std_logic_vector(7 downto 0); + signal event_in, event_out : std_logic_vector(8 downto 0); + signal symbol : std_logic_vector(8 downto 0); + signal init_blk_cnt : std_logic_vector(9 downto 0) := (others => '0'); + signal keepalive_cnt : std_logic_vector(9 downto 0); + signal keepalive_period : std_logic_vector(9 downto 0); + signal init_blocked_period : std_logic_vector(9 downto 0); + signal fifo_level, fifo_level_max : std_logic_vector(9 downto 0); + signal tx_data_0, tx_data_1 : std_logic; + signal tx_ready_0, tx_ready_1 : std_logic; + + +begin + + clear <= (not enable) or init_d; + + ----------------------------------------------------------------------------- + -- Encode events and queue these in a FIFO + ----------------------------------------------------------------------------- + + pEVENT_GEN : process(clk) + begin + if (clk = '1' and clk'event) then + init_d <= init; + if (init = '0' and init_d = '1') then + -- set up int_v to create 2 packets with the new toggle_sync value when init set low + init_v <= "1100"; + -- start timer so this doesn't get triggered again too soon + -- the local clear will still hapen as that depends on init_d + init_blk_cnt <= init_blocked_period; + else + init_v <= '0' & init_v(3 downto 1); + if (init_blocked = '1') then + init_blk_cnt <= std_logic_vector(unsigned(init_blk_cnt) - 1); + end if; + end if; + if (enable = '0') then + toggle_sync <= '0'; + elsif (init = '1' and init_d = '0' and init_blocked = '0') then + -- toggle the bit just when init set high. + toggle_sync <= not toggle_sync; + end if; + + pd_in_d <= pd_in; + pd_event_d <= pd_event; + pd_event_dd <= pd_event_d; + pd_event_ddd <= pd_event_dd; + if (pd_event = '1') then + latched_pos <= abs_position(3 downto 0); + end if; + if ((dec_pos = '1' or inc_pos = '1') and pd_gen = '1') then + delayed_pos_v <= "111"; + else + delayed_pos_v <= '0' & delayed_pos_v(2 downto 1); + end if; + if (enable = '0') then + toggle_pd <= '0'; + elsif (pd_event = '1') then + toggle_pd <= not toggle_pd; + end if; + if (print_start_src = '0') then + print_start_val <= print_start; + else + print_start_val <= print_start_sw; + end if; + print_start_val_d <= print_start_val; + print_start_event <= print_start_en and (print_start_val xor print_start_val_d); + print_start_event_d <= print_start_event; + wr_event <= wr_event_i or add_keepalive; + event_in <= parity_bit & event_in_i; + if (enable = '0' or wr_event_i = '1') then + keepalive_cnt <= keepalive_period; + else + keepalive_cnt <= std_logic_vector(unsigned(keepalive_cnt) - 1); + end if; + if (clear = '1') then + ovfl_err <= '0'; + elsif (wr_event = '1' and full = '1') then + ovfl_err <= '1'; + end if; + if (clear = '1' or wr_event = '1') then + inject_error <= '0'; + elsif (inject_error_req = '1') then + inject_error <= '1'; + end if; + if (clear = '1' or clr_fifo_lmax = '1') then + fifo_level_max <= (others => '0'); + elsif (unsigned(fifo_level) > unsigned(fifo_level_max)) then + fifo_level_max <= fifo_level; + end if; + init_done <= not (init_d or init_blocked); -- true only when the init messages have been transmitted (based on timing) + end if; + end process pEVENT_GEN; + + init_gen <= init_v(0); + + init_blocked <= '1' when unsigned(init_blk_cnt) /= 0 else '0'; + + pd_event <= pd_in and not pd_in_d; + pd_gen <= pd_event or pd_event_d or pd_event_dd; + + + protocol_ver_sel : process(all) is + begin + if pof_protocol_version = '0' then + + print_start_gen <= '0'; + event_in_i <= '0' & gray & toggle_pd & toggle_pd & toggle_sync; + symbol <= '0' & event_out(8) & event_out(6 downto 0); + tx_data <= tx_data_0; + tx_ready <= tx_ready_0; + else + -- Two symbols are queued up in the FIFO each time there is a change in value + -- on Print-Start/Stop + print_start_gen <= print_start_event or print_start_event_d; + -- toggle_pd is repeated twice in the tx word, to improve resiliance against + -- double bit-flips errors + event_in_i <= print_start_val & gray & toggle_pd & toggle_pd & toggle_sync; + symbol <= event_out; + tx_data <= tx_data_1; + tx_ready <= tx_ready_1; + end if; + end process protocol_ver_sel; + + delayed_pos <= delayed_pos_v(0) and pd_event_ddd; + + wr_event_i <= enable and (init_gen or pd_gen or dec_pos or inc_pos or delayed_pos or print_start_gen); + + add_keepalive <= '1' when wr_event_i = '0' and unsigned(keepalive_cnt) = 0 else '0'; + + gray <= bin2gray(latched_pos) when (pd_event_d = '1' or pd_event_dd = '1') else bin2gray(abs_position(3 downto 0)); + + parity_bit <= odd_parity(event_in_i) xor inject_error; + + iQUEUE_EVENT : entity work.sync_fifo + generic map ( + DEVICE_FAMILY => DEVICE_FAMILY, + DATA_WIDTH => 9, + DEPTH => 1024, + SHOWAHEAD => "OFF", + REGISTER_OUTPUT => "OFF" + ) + port map ( + sclr => clear, + clk => clk, + wrdata => event_in, + rdreq => rd_event, + wrreq => wr_event, + empty => empty, + full => full, + rddata => event_out, + usedw => fifo_level); + + + ----------------------------------------------------------------------------- + -- Transmit symbols over serial link + ----------------------------------------------------------------------------- + + pGET_EVENT : process(clk) + begin + if(clk = '1' and clk'event) then + rd_event_d <= rd_event; + symbol_valid <= rd_event_d; + end if; + end process pGET_EVENT; + + rd_event <= '1' when tx_ready = '1' and empty = '0' and rd_event_d = '0' and symbol_valid = '0' else '0'; + + iTX_SYMBOL_pofprotver0 : entity work.uart_tx_3 + generic map( + data_width => 8) + port map( + reset_n => reset_n, + clk => clk, + bit_div => bit_div, + init => clear, + ready => tx_ready_0, + data_in => symbol(7 downto 0), + data_valid => symbol_valid, + tx_data => tx_data_0); + + iTX_SYMBOLpofprotver1 : entity work.uart_tx_3 + generic map( + data_width => 9) + port map( + reset_n => reset_n, + clk => clk, + bit_div => bit_div, + init => clear, + ready => tx_ready_1, + data_in => symbol, + data_valid => symbol_valid, + tx_data => tx_data_1); + + ----------------------------------------------------------------------------- + -- C&S registers + ----------------------------------------------------------------------------- + + pof_tx_csr_regs_inst : entity work.pof_tx_3_csr_regs + generic map( + ADDR_DECODE_WIDTH => 3 + ) + port map( + -- Clock and reset + clk => clk, + rst_n => reset_n, + + -- auto-generated + + -- Internal signal ports + control_enable => enable, + control_bit_div => bit_div, + control_print_start_event_gen => print_start_en, + control_print_start_src => print_start_src, + control_print_start_sw => print_start_sw, + timing_keepalive_period => keepalive_period, + timing_init_blocked_period => init_blocked_period, + control_clr_fifo_level_max => clr_fifo_lmax, + error_inject => inject_error_req, + status_ovfl_err => ovfl_err, + status_print_start_val => print_start_val, + fifo_level_fifo_level => fifo_level, + fifo_level_max_fifo_level => fifo_level_max, + + -- end auto-generated + + -- Slave bus port + avs_address => avs_address(2 downto 0), + avs_write => avs_write, + avs_writedata => avs_writedata, + avs_read => avs_read, + avs_readdata => avs_readdata + ); + +end architecture rtl; diff --git a/generic_ip/pof_protocol/3/src/pof_uart_regen_3.vhd b/generic_ip/pof_protocol/3/src/pof_uart_regen_3.vhd new file mode 100644 index 0000000..b323b64 --- /dev/null +++ b/generic_ip/pof_protocol/3/src/pof_uart_regen_3.vhd @@ -0,0 +1,122 @@ +------------------------------------------------------------------------------- +-- Title : uart_regen +-- Project : EMB-1 +------------------------------------------------------------------------------- +-- File : uart_regen.vhd +-- Author : Gianmarco Girau/Simon Southwell +-- Company : Global Inkjet Systems +-- Created : 2017-10-31 +-- Last update: 2021-06-07 +-- SVN ID : Git +-- Standard : VHDL'08 +------------------------------------------------------------------------------- +-- Description: +-- Regenerate the UART signal +------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity pof_uart_regen_3 is + generic( + GEN_BIT_DIV : integer := 6; + data_width : natural range 1 to 31 := 8 + ); + port( + reset_n : in std_logic; + clk : in std_logic; + enable : in std_logic; + bypass_en : in std_logic; + uart_rx : in std_logic; + uart_tx : out std_logic); +end entity pof_uart_regen_3; + +architecture rtl of pof_uart_regen_3 is + + signal uart_rx_i : std_logic; + signal uart_regen : std_logic; + signal receiving : std_logic; + signal sample_cnt_unary : std_logic_vector(GEN_BIT_DIV - 1 downto 0); + signal bit_cnt_unary : std_logic_vector(data_width + 1 downto 0); + signal enable_i : std_logic; + signal bypass_en_i : std_logic; + +begin + + -- output mux (maybe register?) + uart_tx <= uart_rx when bypass_en_i = '1' else uart_regen; + + ----------------------------------------------------------------------------- + -- Input Synchronization from outside device or other clock domain + ----------------------------------------------------------------------------- + + iSYNC_IN_UARTRX : entity work.sync_wire + generic map( + rst_val => '1', + sync_stages => 3) + port map( + rstN => reset_n, + clk => clk, + async_in => uart_rx, + sync_out => uart_rx_i); + + iSYNC_IN_ENABLE : entity work.sync_wire + generic map( + rst_val => '1', + sync_stages => 3) + port map( + rstN => reset_n, + clk => clk, + async_in => enable, + sync_out => enable_i); + + iSYNC_IN_BYPASS : entity work.sync_wire + generic map( + rst_val => '1', + sync_stages => 3) + port map( + rstN => reset_n, + clk => clk, + async_in => bypass_en, + sync_out => bypass_en_i); + + pREGEN : process(clk) + begin + if clk = '1' and clk'event then + if enable_i = '0' or bypass_en_i = '1' then + receiving <= '0'; + bit_cnt_unary <= std_logic_vector(to_unsigned(1, bit_cnt_unary'length)); + sample_cnt_unary <= std_logic_vector(to_unsigned(1, sample_cnt_unary'length)); + uart_regen <= '1'; + else + -- If start bit seen when not receiving, start receiving and start unary sample count shifting (with rotation). + -- Keep rotating whilst receiving. + if (receiving = '0' and uart_rx_i = '0') or receiving = '1' then + receiving <= '1'; + sample_cnt_unary <= sample_cnt_unary(sample_cnt_unary'high - 1 downto 0) & sample_cnt_unary(sample_cnt_unary'high); + end if; + + end if; + + -- At half way regenerate the input + if sample_cnt_unary(GEN_BIT_DIV / 2 - 1) = '1' then + uart_regen <= uart_rx_i; + end if; + + -- After half way, up the bit count + if sample_cnt_unary(GEN_BIT_DIV / 2) = '1' then + bit_cnt_unary <= bit_cnt_unary(bit_cnt_unary'high - 1 downto 0) & bit_cnt_unary(bit_cnt_unary'high); + end if; + + -- If at the end of the last (stop) bit clear the receiving state. + if sample_cnt_unary(GEN_BIT_DIV - 1) = '1' and bit_cnt_unary(0) = '1' then + receiving <= '0'; + end if; + + end if; + + end process pREGEN; + +end architecture rtl; diff --git a/generic_ip/pof_protocol/3/src/pof_uart_rx_3.vhd b/generic_ip/pof_protocol/3/src/pof_uart_rx_3.vhd new file mode 100644 index 0000000..e53649f --- /dev/null +++ b/generic_ip/pof_protocol/3/src/pof_uart_rx_3.vhd @@ -0,0 +1,126 @@ +------------------------------------------------------------------------------- +-- Title : pof_uart_rx +-- Project : EMB-1 +------------------------------------------------------------------------------- +-- File : pof_uart_rx.vhd +-- Author : Gianmarco Girau/Simon Southwell +-- Company : Global Inkjet Systems +-- Created : 2016-10-24 +-- Last update: 2021-06-07 +-- SVN ID : Git +-- Standard : VHDL'08 +------------------------------------------------------------------------------- +-- Description: +-- Simple UART receiver, used to receive data over the POF, 1 start, 1 stop +-- bit, no parity +------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity pof_uart_rx_3 is + generic( + GEN_BIT_DIV : integer := 6; + data_width : natural range 1 to 31 := 8 + ); + port( + reset_n : in std_logic; + clk : in std_logic; + init : in std_logic; + data_out : out std_logic_vector(data_width - 1 downto 0); + data_out_valid : out std_logic; + rx_error : out std_logic; + rx_data : in std_logic); +end entity pof_uart_rx_3; + +architecture rtl of pof_uart_rx_3 is + + signal rx_data_i : std_logic; + signal data : std_logic_vector(data_width + 1 downto 0); + + signal bit_cnt_unary : std_logic_vector(data_width + 1 downto 0); + signal sample_cnt_unary : std_logic_vector(GEN_BIT_DIV-1 downto 0); + signal receiving : std_logic; + signal init_int : std_logic := '0'; + +begin + + ----------------------------------------------------------------------------- + -- Input Synchronization + ----------------------------------------------------------------------------- + + iSYNC_IN : entity work.sync_wire + generic map( + rst_val => '1', + sync_stages => 3) + port map( + rstN => reset_n, + clk => clk, + async_in => rx_data, + sync_out => rx_data_i); + + ----------------------------------------------------------------------------- + -- UART registers and sequential logic + ----------------------------------------------------------------------------- + + pRX : process(clk) + begin + if clk = '1' and clk'event then + + init_int <= init; + + -- Data out valid will pulse + data_out_valid <= '0'; + rx_error <= '0'; + + -- If initialising, only clear control state + if init_int = '1' then + + receiving <= '0'; + bit_cnt_unary <= std_logic_vector(to_unsigned(1, bit_cnt_unary'length)); + sample_cnt_unary <= std_logic_vector(to_unsigned(1, sample_cnt_unary'length)); + + else + + -- If start bit seen when not receiving, start receiving and start unary sample count shifting (with rotation). + -- Keep rotating whilst receiving. + if (receiving = '0' and rx_data_i = '0') or receiving = '1' then + receiving <= '1'; + sample_cnt_unary <= sample_cnt_unary(sample_cnt_unary'high-1 downto 0) & sample_cnt_unary(sample_cnt_unary'high); + end if; + + end if; + + -- At half way shift in the data (LSB first) and shift (with rotation) the unary bit count + if sample_cnt_unary(GEN_BIT_DIV/2 - 1) = '1' then + data <= rx_data_i & data(data'high downto 1); + end if; + + -- After half way, up the bit count + if sample_cnt_unary(GEN_BIT_DIV/2) = '1' then + bit_cnt_unary <= bit_cnt_unary(bit_cnt_unary'high-1 downto 0) & bit_cnt_unary(bit_cnt_unary'high); + end if; + + -- Extract the payload bits from the input shift register + data_out <= data(data_width downto 1); + + -- If at the end of the last (stop) bit, update data out and set valid. + -- Clear the receiving state. + if sample_cnt_unary(GEN_BIT_DIV-1) = '1' and bit_cnt_unary(0) = '1' then + + -- Data is valid if stop bit a 1 + data_out_valid <= data(data_width+1); + + -- It is an error if the stop bit is 0 + rx_error <= not data(data_width+1); + + -- Clear receiving flag + receiving <= '0'; + end if; + + end if; + end process pRX; + +end architecture rtl; diff --git a/generic_ip/pof_protocol/3/src/test/pof_tx_rx_3_one_tb.vhd b/generic_ip/pof_protocol/3/src/test/pof_tx_rx_3_one_tb.vhd new file mode 100644 index 0000000..67a3822 --- /dev/null +++ b/generic_ip/pof_protocol/3/src/test/pof_tx_rx_3_one_tb.vhd @@ -0,0 +1,720 @@ +------------------------------------------------------------------------------- +-- Title : pof_tx_rx_tb +-- Project : HMB daisy-chaining +------------------------------------------------------------------------------- +-- File : pof_tx_rx_tb.vhd +-- Author : GMG +-- Company : Global Inkjet Systems +-- Created : 2017-08-29 +-- Last update: 2020-01-31 +-- SVN ID : Git +-- Standard : VHDL'2008 +------------------------------------------------------------------------------- +-- Description: +-- Testbench for verifying the transmission over the POF with emb2poftx and +-- pofrx2hmb blocks +------------------------------------------------------------------------------- + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +library OSVVM; +use OSVVM.RandomBasePkg.all; +use OSVVM.RandomPkg.all; + +use work.log_pkg.all; +use work.avalon_verify_pkg.all; + +use work.log_pkg.all; + +entity pof_tx_rx_3_one_tb is + -- .. +end entity pof_tx_rx_3_one_tb; + +architecture behav of pof_tx_rx_3_one_tb is + + constant CLK_PERIOD : time := 10 ns; -- 100MHz + constant RX_CLK_PERIOD : time := 3.333 ns; -- 300MHz + + constant NUM_ITERATIONS : natural := 10; + constant SWATHE_LEN : integer := 1000; + constant START_DIR : std_logic := '0'; + constant INJECT_ERROR_PERC : real := 3.0; -- percentage of injected errors + constant DISCR_THRES : natural := 2000; + constant TIME_INT : time := 800 ns; + + constant UART_BIT_DIV : integer := 6; -- divide by 6 + + constant SYMBOL_LEN : natural := 8; -- UART symbol length, excluding + -- start/stop and parity bits + + -- Print-Start toggling period + constant PS_SWITCH_PER : natural := 5000; + + type injected_error_t is (DATA_ERROR, START_BIT_ERROR, STOP_BIT_ERROR); + + + -- Logging Verbosity Level + constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM; + + signal clk, rx_clk, rx_clk_i, reset_n : std_logic := '0'; + signal avs_read, avs_write, sel_slave_0, sel_slave_1 : std_logic; + signal avs_write_sl0, avs_read_sl0 : std_logic; + signal avs_write_sl1, avs_read_sl1 : std_logic; + signal init_tx, init_rx, dir_in, pd_in, inc_pos, dec_pos : std_logic; + signal tx_data, rx_data, init_out, dir_out : std_logic; + signal pd_out, inc_pos_out, dec_pos_out, end_of_swathe : std_logic; + signal print_start_in, print_start_out : std_logic; + signal ps_flip_cnt : natural := 0; + -- + signal test_completed, running, configuring : boolean; + signal passed, failed, stimuli_completed : boolean; + signal detected_error : boolean := false; + -- + signal avs_address : std_logic_vector(2 downto 0); + signal avs_writedata : std_logic_vector(31 downto 0); + signal avs_readdata_sl0, avs_readdata_sl1 : std_logic_vector(31 downto 0); + signal abs_position, abs_position_d : std_logic_vector(31 downto 0); + signal abs_pos_out : std_logic_vector(31 downto 0); + -- + signal swathe_cnt, swathe_pos : integer; + signal dir_discr_cnt, pd_discr_cnt : integer; + signal pos_discr_cnt : integer; + signal pd_in_cnt, pd_out_cnt : integer; + signal enc_pulse_cnt : integer; + signal dir_err, pd_err, ovfl_err, ps_err : std_logic; + signal pos_err, enc_err, dir_in_d : std_logic; + signal injected_errors : integer; + signal sent_packets : integer; + signal max_pos, min_pos : integer; + signal injected_error_type : injected_error_t; + signal max_pos_d, min_pos_d : integer; + signal exp_enc_cnt : integer; + signal exp_enc_pulse, enc_discr : std_logic; + signal enc_out, enc_out_d : std_logic; + signal error_rate_thres : std_logic_vector(7 downto 0); + signal one_pps : std_logic; + signal max_error_flag : std_logic; + signal rx_watchdog : std_logic; + signal rx_watchdog_en : std_logic; + signal rx_watchdog_clr : std_logic; + -- + signal enable_rx : std_logic; + signal parity_err_cnt : std_logic_vector(15 downto 0); + signal skip_pos_cnt : std_logic_vector(15 downto 0); + -- + signal avs_m : mm_m_rec_t; + signal avs_s : mm_s_rec_t; + -- + shared variable error_logged : boolean; + + +begin -- architecture behav + + clk <= not clk after 0.5 * CLK_PERIOD; + + rx_clk_i <= not rx_clk_i after 0.5 * RX_CLK_PERIOD; + rx_clk <= rx_clk_i after 1 ns; + + ----------------------------------------------------------------------------- + -- UUTs + ----------------------------------------------------------------------------- + + iPOF_TX : entity work.pof_tx_3 + + port map( + reset_n => reset_n, + clk => clk, + init => init_tx, + pd_in => pd_in, + print_start => print_start_in, + pof_protocol_version => '1', + inc_pos => inc_pos, + dec_pos => dec_pos, + abs_position => abs_position, + tx_data => tx_data, + avs_address => avs_address, + avs_write => avs_write_sl0, + avs_writedata => avs_writedata, + avs_read => avs_read_sl0, + avs_readdata => avs_readdata_sl0); + + iPOF_RX : entity work.pof_rx_3 + generic map( + GEN_BIT_DIV => UART_BIT_DIV) + port map( + reset_n => reset_n, + clk => clk, + init => init_rx, + rx_clk => rx_clk, + rx_data => rx_data, + init_out => init_out, + pd_out => pd_out, + print_start => print_start_out, + inc_pos => inc_pos_out, + dec_pos => dec_pos_out, + abs_pos => abs_pos_out, + pof_protocol_version => '1', + enable => enable_rx, + error_rate_thres => error_rate_thres, + one_pps => one_pps, + max_error_flag => max_error_flag, + rx_watchdog => rx_watchdog, + rx_watchdog_en => rx_watchdog_en, + rx_watchdog_clr => rx_watchdog_clr, + parity_err_cnt => parity_err_cnt, + skip_pos_cnt => skip_pos_cnt); + + --rx_data <= tx_data after 40 ns; + rx_data <= transport tx_data after 40 ns; + + ----------------------------------------------------------------------------- + -- UUT configuration and control + ----------------------------------------------------------------------------- + + clk_clk <= clk; + reset_reset_n <= reset_n; + + avs_s.mm_readdata <= avs_readdata_sl0 when sel_slave_0 = '1' else + avs_readdata_sl1 when sel_slave_1 = '1' else (others => '0'); + + avs_readdata_sl1 <= (others => '0'); + + avs_s.mm_readdatavalid <= '0'; + + avs_s.mm_waitrequest <= '0'; + avs_s.use_readvalid <= true; + + avs_address <= avs_m.mm_address(avs_address'range); + avs_write <= avs_m.mm_write; + avs_writedata <= avs_m.mm_writedata; + avs_read <= avs_m.mm_read; + -- + avs_write_sl0 <= avs_write and sel_slave_0; + --avs_write_sl1 <= avs_write and sel_slave_1; + avs_write_sl1 <= '0'; + -- + avs_read_sl0 <= avs_read and sel_slave_0; + --avs_read_sl1 <= avs_read and sel_slave_1; + avs_read_sl1 <= '0'; + + -- 1-PPS generation: make it faster than 1-PPS for simulation reasons + pEMULATE_1PPS : process + begin + one_pps <= '0'; + for n in 1 to 99999 loop + wait until clk = '1' and clk'event; + end loop; -- 1 to 9999 + one_pps <= '1'; + wait until clk = '1' and clk'event; + end process pEMULATE_1PPS; + + pUUT_CTRL : process + variable addr : std_logic_vector(31 downto 0) := (others => '0'); + variable data : std_logic_vector(31 downto 0) := (others => '0'); + begin + + enable_rx <= '0'; + -- + rx_watchdog_en <= '0'; + rx_watchdog_clr <= '0'; + error_rate_thres <= X"0A"; + + sel_slave_0 <= '0'; + sel_slave_1 <= '0'; + + configuring <= true; + + -- initilialize the Avalon master-bus + mm_m_init(avs_m); + + if (reset_n = '0') then + wait until reset_n = '1'; + wait for 100 ns; + wait until clk = '1' and clk'event; + end if; + + log("Configuring POF-Tx ... ", VLOW, true); + sel_slave_0 <= '1'; + -- Config netfork_rx control registers: + -- disable the block + addr := std_logic_vector(to_unsigned(0, 32)); + data := X"0000_0021"; + mm_32b_write(addr, data, avs_s, avs_m); + + sel_slave_0 <= '0'; + sel_slave_1 <= '1'; + wait until clk = '1' and clk'event; + + log("Configuring POF-Rx ... ", VLOW, true); + enable_rx <= '1'; + rx_watchdog_en <= '1'; + + log("Configuration completed.", VLOW, true); + configuring <= false; + + wait; + + end process pUUT_CTRL; + + ----------------------------------------------------------------------------- + -- Stimuli Generation + ----------------------------------------------------------------------------- + + pSTIMULI_REGs : process(clk) + begin + if (reset_n = '0') then + abs_position_d <= (others => '0'); + print_start_in <= '0'; + ps_flip_cnt <= 0; + elsif (clk = '1' and clk'event) then + abs_position_d <= abs_position; + if (running = true) then + if (ps_flip_cnt = PS_SWITCH_PER - 1) then + ps_flip_cnt <= 0; + print_start_in <= not print_start_in; + else + ps_flip_cnt <= ps_flip_cnt + 1; + end if; + end if; + end if; + end process pSTIMULI_REGs; + + inc_pos <= '1' when signed(abs_position) = signed(abs_position_d) + 1 else '0'; + dec_pos <= '1' when signed(abs_position) = signed(abs_position_d) - 1 else '0'; + + pSTIMULI : process + variable rv : RandomPType; + variable tmp_int : integer; + variable rand_time : time; + variable end_of_stimuli : boolean; + variable pd_dist : integer; + begin + + -- initialization + init_rx <= '0'; + -- + init_tx <= '0'; + dir_in <= START_DIR; + pd_in <= '0'; + abs_position <= (others => '0'); + swathe_pos <= 0; + pd_dist := 0; + -- + swathe_cnt <= 0; + stimuli_completed <= false; + end_of_swathe <= '0'; + + -- generating the stimulus + wait until running = true; + wait for 200 ns; + -- Send a Init/Sync pulse + wait until clk = '1' and clk'event; + init_tx <= '1'; + wait until clk = '1' and clk'event; + init_tx <= '0'; + wait for 500 ns; + -- Send a second init pulse and verify that it is ignored (because too + -- close to the previous) + wait until clk = '1' and clk'event; + init_tx <= '1'; + wait until clk = '1' and clk'event; + init_tx <= '0'; + wait for 2500 ns; + -- Send a third pulse (after a bigger interval from the previous). + -- Verify that this time the pulse is accepted + wait until clk = '1' and clk'event; + init_tx <= '1'; + wait until clk = '1' and clk'event; + init_tx <= '0'; + wait for 500 ns; + wait until clk = '1' and clk'event; + -- + -- generate the forward swathe + end_of_stimuli := false; + while end_of_stimuli = false loop + swathe_pos <= 0; + wait until clk = '1' and clk'event; + while swathe_pos /= SWATHE_LEN loop + -- generate a position increment + tmp_int := rv.RandInt(1, 100); + --tmp_int := 100; + if (tmp_int < 20) then + -- generate a position increment opposite to the swathe direction + swathe_pos <= swathe_pos - 1; + if (dir_in = '0') then + abs_position <= std_logic_vector(signed(abs_position) - 1); + else + abs_position <= std_logic_vector(signed(abs_position) + 1); + end if; + else + swathe_pos <= swathe_pos + 1; + if (dir_in = '0') then + abs_position <= std_logic_vector(signed(abs_position) + 1); + else + abs_position <= std_logic_vector(signed(abs_position) - 1); + end if; + end if; + -- + tmp_int := rv.RandInt(1, 100); + if (tmp_int <= 5 and pd_dist >= 10) then + pd_dist := 0; + -- generate a PD increment: the PD might be either concurrent or not + -- to the position increment + tmp_int := rv.RandInt(1, 3); + case tmp_int is + when 2 => + -- wait less than the transmission time + wait for 90 ns; + wait until clk = '1' and clk'event; + when 3 => + -- wait more than the transmission time + wait for 290 ns; + wait until clk = '1' and clk'event; + when others => null; + end case; + pd_in <= '1'; + wait until clk = '1' and clk'event; + pd_in <= '0'; + end if; + pd_dist := pd_dist + 1; + rand_time := rv.RandInt(-25, 25) * (10 ns); + wait for TIME_INT + rand_time; + end loop; -- swathe_pos /= SWATHE_LEN + + wait for 25 us; + end_of_swathe <= '1'; + wait until clk = '1' and clk'event; + end_of_swathe <= '0'; + -- reverse direction + if (dir_in /= START_DIR) then + if (swathe_cnt = NUM_ITERATIONS) then + end_of_stimuli := true; + else + swathe_cnt <= swathe_cnt + 1; + end if; + end if; + if (end_of_stimuli = false) then + wait until clk = '1' and clk'event; + dir_in <= not dir_in; + -- Wait some time to make sure the change of direction is transmitted. + -- Note: if the position starts changing before the receiver was able to + -- confirm the change of direction, then some encoder pulses may not be + -- generated + wait for 1 us; + wait until clk = '1' and clk'event; + end if; + end loop; -- end_of_stimuli = false + + stimuli_completed <= true; + wait; + + end process pSTIMULI; + + ----------------------------------------------------------------------------- + -- Error injection + ----------------------------------------------------------------------------- + + -- Randomly change the payload of the data transmitted over the UART. + -- Insert 1, 2 or 3 errors per data word + -- Note: an error on the start bit of the UART will can cause more than 3 + -- errors per data word, therefore this error injection method does not cover + -- all the possible cases + + pERROR_INJECTION : process + -- + alias symbol_valid is <>; + alias symbol is <>; + -- + alias uart_tx_set_tx_data is <>; + -- + variable rv : RandomPType; + variable rv_et : RandomPType; + variable et_sel : natural; + variable sbe_len : natural; + variable flip_vect : std_logic_vector(SYMBOL_LEN downto 0); + variable last_flip : std_logic_vector(SYMBOL_LEN downto 0); + variable bit_flips : integer range 0 to 3; + variable b0, b1, b2 : integer range 0 to 8; + variable exclude_1 : integer_vector(0 downto 0); + variable exclude_2 : integer_vector(1 downto 0); + variable last_inj_err : integer; + begin + sent_packets <= 0; + injected_errors <= 0; + last_inj_err := 0; + if (running /= true) then + wait until running = true; + end if; + + while running loop + wait until symbol_valid = '1' and symbol_valid'event; + sent_packets <= sent_packets + 1; + if (last_inj_err > 0) then + last_inj_err := last_inj_err - 1; + end if; + if (last_inj_err = 0 and rv.RandInt(1, 10000) < integer(INJECT_ERROR_PERC * 100.0)) then + -- Select the type of error to inject: The error type distribution is + -- as follows: + -- 80% of data errors, including errors on the parity-bit + -- 10% of start-bit errors + -- 10% of stop-bit errors + last_inj_err := 5; + et_sel := rv_et.RandInt(1, 100); + if (et_sel < 80) then + injected_error_type <= DATA_ERROR; + -- Inject an error: + -- Number of bits to flip in the tx word + bit_flips := rv.RandInt(1, 3); + --bit_flips := 2; + b0 := rv.RandInt(0, SYMBOL_LEN); + exclude_1(0) := b0; + b1 := rv.RandInt(min => 0, max => SYMBOL_LEN, exclude => exclude_1); + exclude_2 := (0 => b0, 1 => b1); + b2 := rv.RandInt(min => 0, max => SYMBOL_LEN, exclude => exclude_2); + flip_vect := (others => '0'); + flip_vect(b0) := '1'; + if (bit_flips >= 2) then + flip_vect(b1) := '1'; + end if; + if (bit_flips = 3) then + flip_vect(b2) := '1'; + end if; + -- Prevent situations with two consecutive bit flips on bit 0,1 and 2 + if ((flip_vect(0) = '1' and last_flip(0) = '1') or (flip_vect(1) = '1' and last_flip(1) = '1') or (flip_vect(2) = '1' and last_flip(2) = '1')) then + flip_vect := (others => '0'); + end if; + log("bit-flip = " & to_string(bit_flips) & ", flip_vect = " & to_string(flip_vect) & ".", VLOW); + symbol <= force symbol xor flip_vect; + injected_errors <= injected_errors + 1; + wait until clk = '1' and clk'event; + wait until clk = '1' and clk'event; + symbol <= release; + last_flip := flip_vect; + + elsif (et_sel < 90) then + last_flip := (others => '0'); + injected_error_type <= START_BIT_ERROR; + -- Directly force tx_data to low for some time + sbe_len := rv_et.RandInt(3, 10); + injected_errors <= injected_errors + 1; + log("Injected error on the UART Start-Bit.", VLOW); + tx_data <= force '0'; + for i in 1 to sbe_len loop + wait until clk = '1' and clk'event; + end loop; -- i + tx_data <= release; + else + last_flip := (others => '0'); + injected_error_type <= STOP_BIT_ERROR; + -- To create an error on the UART stop-bit, force to zero the signal + -- used to switch tx_data to high, at the end of the message + uart_tx_set_tx_data <= force '0'; + sbe_len := rv_et.RandInt(20, 25); + for i in 1 to sbe_len loop + wait until clk = '1' and clk'event; + end loop; -- i + -- issue the stop bit + uart_tx_set_tx_data <= force '1'; + wait until clk = '1' and clk'event; + uart_tx_set_tx_data <= force '0'; + wait until clk = '1' and clk'event; + uart_tx_set_tx_data <= release; + injected_errors <= injected_errors + 1; + log("Injected error on the UART Stop-Bit.", VLOW); + end if; + else + last_flip := (others => '0'); + end if; + end loop; + + end process pERROR_INJECTION; + + ----------------------------------------------------------------------------- + -- Output Checking + ----------------------------------------------------------------------------- + + -- No more check on dir_out!!! + dir_out <= dir_in; + + pEVENT_MONITOR : process(clk) + begin + if (clk = '1' and clk'event) then + if (reset_n = '0' or init_tx = '1' or running = false or dir_in = dir_out) then + dir_discr_cnt <= 0; + elsif (dir_in /= dir_out) then + dir_discr_cnt <= dir_discr_cnt + 1; + end if; + if (reset_n = '0' or init_tx = '1' or running = false) then + dir_err <= '0'; + elsif (dir_discr_cnt > DISCR_THRES) then + dir_err <= '1'; + if (error_logged = false) then + log("ERROR: Detected Discrepancy in the Direction: Discrepancy Count bigger than " & to_string(DISCR_THRES) & ".", VLOW); + error_logged := true; + end if; + end if; + if (reset_n = '0' or init_tx = '1' or running = false) then + pd_in_cnt <= 0; + elsif (pd_in = '1') then + pd_in_cnt <= pd_in_cnt + 1; + end if; + if (reset_n = '0' or init_tx = '1' or running = false) then + pd_out_cnt <= 0; + elsif (pd_out = '1') then + pd_out_cnt <= pd_out_cnt + 1; + end if; + if (reset_n = '0' or init_tx = '1' or running = false or pd_in_cnt = pd_out_cnt) then + pd_discr_cnt <= 0; + elsif (pd_in_cnt /= pd_out_cnt) then + pd_discr_cnt <= pd_discr_cnt + 1; + end if; + if (reset_n = '0' or init_tx = '1' or running = false) then + pd_err <= '0'; + elsif (pd_discr_cnt > DISCR_THRES) then + pd_err <= '1'; + if (error_logged = false) then + log("ERROR: Misaligned PD count: Discrepancy Count bigger than " & to_string(DISCR_THRES) & ".", VLOW); + error_logged := true; + end if; + end if; + if (reset_n = '0' or init_tx = '1' or running = false or signed(abs_position) = signed(abs_pos_out)) then + pos_discr_cnt <= 0; + elsif (signed(abs_position) /= signed(abs_pos_out)) then + pos_discr_cnt <= pos_discr_cnt + 1; + end if; + if (reset_n = '0' or init_tx = '1' or running = false) then + pos_err <= '0'; + elsif (pos_discr_cnt > DISCR_THRES) then + pos_err <= '1'; + if (error_logged = false) then + log("ERROR: Misaligned in the Absolute-Position: Discrepancy Count bigger than " & to_string(DISCR_THRES) & ".", VLOW); + error_logged := true; + end if; + end if; + dir_in_d <= dir_in; + if (reset_n = '0' or init_tx = '1' or running = false or dir_in /= dir_in_d) then + enc_pulse_cnt <= 0; + elsif (enc_out = '1') then + enc_pulse_cnt <= enc_pulse_cnt + 1; + end if; + if (reset_n = '0' or init_tx = '1' or running = false) then + enc_err <= '0'; + elsif (end_of_swathe = '1' and enc_pulse_cnt /= SWATHE_LEN) then + enc_err <= '1'; + end if; + if (reset_n = '0') then + ps_err <= '0'; + elsif (running = true and ps_flip_cnt = integer(0.9 * real(PS_SWITCH_PER)) and print_start_out /= print_start_in) then + ps_err <= '1'; + if (error_logged = false) then + log("ERROR: Print-Start error.", VLOW); + error_logged := true; + end if; + end if; + max_pos_d <= max_pos; + min_pos_d <= min_pos; + if ((dir_in = '0' and max_pos /= max_pos_d) or (dir_in = '1' and min_pos /= min_pos_d)) then + exp_enc_pulse <= '1'; + else + exp_enc_pulse <= '0'; + end if; + enc_out_d <= enc_out; + end if; + end process pEVENT_MONITOR; + + enc_discr <= enc_out_d xor exp_enc_pulse; + + pMIN_MAX_POS : process(reset_n, end_of_swathe, abs_pos_out) + begin + if (reset_n = '0' or end_of_swathe = '1') then + max_pos <= -SWATHE_LEN; + elsif (signed(abs_pos_out) > max_pos) then + max_pos <= to_integer(signed(abs_pos_out)); + end if; + if (reset_n = '0' or end_of_swathe = '1') then + min_pos <= SWATHE_LEN; + elsif (signed(abs_pos_out) < min_pos) then + min_pos <= to_integer(signed(abs_pos_out)); + end if; + end process pMIN_MAX_POS; + + exp_enc_cnt <= max_pos - min_pos; + + ovfl_err <= <>; + + pERR_DETECT : process(reset_n, clk) + begin + if (reset_n = '0') then + detected_error <= false; + error_logged := false; + elsif (clk = '1' and clk'event) then + if (ovfl_err = '1' or dir_err = '1' or pd_err = '1' or pos_err = '1' or ps_err = '1') then + if (ovfl_err = '1') then + log("ERROR: Detected Overflow Error.", VLOW); + end if; + detected_error <= true; + end if; + end if; + end process pERR_DETECT; + + + ----------------------------------------------------------------------------- + -- Testbench Control + ----------------------------------------------------------------------------- + + pTB_CTRL : process + begin + + -- Set the verbosity level for logging + set_log_verbosity(VERBOSITY_LEVEL); + set_log_verbosity(VHIGH); + + log_header("POF Transfer Tx/Rx verification:", VLOW); + + test_completed <= false; + running <= false; + passed <= false; + failed <= false; + + -- Reset + reset_n <= '0'; + wait for 100 ns; + wait until clk = '1' and clk'event; + reset_n <= '1'; + + if (configuring /= true) then + wait until configuring = true; + end if; + wait until configuring = false; + running <= true; + + wait until stimuli_completed = true or detected_error = true; + + if (stimuli_completed = true) then + -- wait enough time to make sure that a max length package can be propagated + wait for 20 us; + else + wait for 20 us; + end if; + + log_separator_line(VLOW); + if (detected_error = true) then + failed <= true; + log("FAILURE: test completed with errors.", VLOW); + else + passed <= true; + log("Sent Packets = " & to_string(sent_packets) & ", Injected errors = " & to_string(injected_errors) & ".", VLOW); + log("SUCCESS: test successfully completed.", VLOW); + end if; + log_separator_line(VLOW); + test_completed <= true; + running <= false; + + wait; + + end process pTB_CTRL; + + +end architecture behav; diff --git a/generic_ip/pof_protocol/3/src/test/pof_tx_rx_3_zero_tb.vhd b/generic_ip/pof_protocol/3/src/test/pof_tx_rx_3_zero_tb.vhd new file mode 100644 index 0000000..54a39a9 --- /dev/null +++ b/generic_ip/pof_protocol/3/src/test/pof_tx_rx_3_zero_tb.vhd @@ -0,0 +1,694 @@ +------------------------------------------------------------------------------- +-- Title : pof_tx_rx_tb +-- Project : HMB daisy-chaining +------------------------------------------------------------------------------- +-- File : pof_tx_rx_tb.vhd +-- Author : GMG +-- Company : Global Inkjet Systems +-- Created : 2017-08-29 +-- Last update: 2020-01-31 +-- SVN ID : Git +-- Standard : VHDL'2008 +------------------------------------------------------------------------------- +-- Description: +-- Testbench for verifying the transmission over the POF with emb2poftx and +-- pofrx2hmb blocks +------------------------------------------------------------------------------- + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +library OSVVM; +use OSVVM.RandomBasePkg.all; +use OSVVM.RandomPkg.all; + +use work.log_pkg.all; +use work.avalon_verify_pkg.all; + +use work.log_pkg.all; + +entity pof_tx_rx_3_zero_tb is + -- .. +end entity pof_tx_rx_3_zero_tb; + +architecture behav of pof_tx_rx_3_zero_tb is + + constant CLK_PERIOD : time := 10 ns; -- 100MHz + constant RX_CLK_PERIOD : time := 3.333 ns; -- 300MHz + + constant NUM_ITERATIONS : natural := 10; + constant SWATHE_LEN : integer := 1000; + constant START_DIR : std_logic := '0'; + constant INJECT_ERROR_PERC : real := 3.0; -- percentage of injected errors + constant DISCR_THRES : natural := 2000; + constant TIME_INT : time := 800 ns; + + constant UART_BIT_DIV : integer := 6; -- divide by 6 + + constant SYMBOL_LEN : natural := 7; -- UART symbol length, excluding + -- start/stop and parity bits + + type injected_error_t is (DATA_ERROR, START_BIT_ERROR, STOP_BIT_ERROR); + + -- Logging Verbosity Level + constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM; + + signal clk, rx_clk, rx_clk_i, reset_n : std_logic := '0'; + signal avs_read, avs_write, sel_slave_0, sel_slave_1 : std_logic; + signal avs_write_sl0, avs_read_sl0 : std_logic; + signal avs_write_sl1, avs_read_sl1 : std_logic; + signal init_tx, init_rx, dir_in, pd_in, inc_pos, dec_pos : std_logic; + signal tx_data, rx_data, init_out, dir_out : std_logic; + signal pd_out, inc_pos_out, dec_pos_out, end_of_swathe : std_logic; + -- + signal test_completed, running, configuring : boolean; + signal passed, failed, stimuli_completed : boolean; + signal detected_error : boolean := false; + -- + signal avs_address : std_logic_vector(2 downto 0); + signal avs_writedata : std_logic_vector(31 downto 0); + signal avs_readdata_sl0, avs_readdata_sl1 : std_logic_vector(31 downto 0); + signal abs_position, abs_position_d : std_logic_vector(31 downto 0); + signal abs_pos_out : std_logic_vector(31 downto 0); + -- + signal swathe_cnt, swathe_pos : integer; + signal dir_discr_cnt, pd_discr_cnt : integer; + signal pos_discr_cnt : integer; + signal pd_in_cnt, pd_out_cnt : integer; + signal enc_pulse_cnt : integer; + signal dir_err, pd_err, ovfl_err : std_logic; + signal pos_err, enc_err, dir_in_d : std_logic; + signal injected_errors : integer; + signal sent_packets : integer; + signal max_pos, min_pos : integer; + signal injected_error_type : injected_error_t; + signal max_pos_d, min_pos_d : integer; + signal exp_enc_cnt : integer; + signal exp_enc_pulse, enc_discr : std_logic; + signal enc_out, enc_out_d : std_logic; + signal error_rate_thres : std_logic_vector(7 downto 0); + signal one_pps : std_logic; + signal max_error_flag : std_logic; + signal rx_watchdog : std_logic; + signal rx_watchdog_en : std_logic; + signal rx_watchdog_clr : std_logic; + -- + signal enable_rx : std_logic; + signal parity_err_cnt : std_logic_vector(15 downto 0); + signal skip_pos_cnt : std_logic_vector(15 downto 0); + -- + signal avs_m : mm_m_rec_t; + signal avs_s : mm_s_rec_t; + -- + shared variable error_logged : boolean; + + +begin -- architecture behav + + clk <= not clk after 0.5 * CLK_PERIOD; + + rx_clk_i <= not rx_clk_i after 0.5 * RX_CLK_PERIOD; + rx_clk <= rx_clk_i after 1 ns; + + ----------------------------------------------------------------------------- + -- UUTs + ----------------------------------------------------------------------------- + + iPOF_TX : entity work.pof_tx_3 + + port map( + reset_n => reset_n, + clk => clk, + init => init_tx, + pd_in => pd_in, + print_start => open, + pof_protocol_version => '0', + inc_pos => inc_pos, + dec_pos => dec_pos, + abs_position => abs_position, + tx_data => tx_data, + avs_address => avs_address, + avs_write => avs_write_sl0, + avs_writedata => avs_writedata, + avs_read => avs_read_sl0, + avs_readdata => avs_readdata_sl0); + + iPOF_RX : entity work.pof_rx_3 + generic map( + GEN_BIT_DIV => UART_BIT_DIV) + port map( + reset_n => reset_n, + clk => clk, + init => init_rx, + rx_clk => rx_clk, + rx_data => rx_data, + init_out => init_out, + pd_out => pd_out, + print_start => open, + inc_pos => inc_pos_out, + dec_pos => dec_pos_out, + abs_pos => abs_pos_out, + pof_protocol_version => '0', + enable => enable_rx, + error_rate_thres => error_rate_thres, + one_pps => one_pps, + max_error_flag => max_error_flag, + rx_watchdog => rx_watchdog, + rx_watchdog_en => rx_watchdog_en, + rx_watchdog_clr => rx_watchdog_clr, + parity_err_cnt => parity_err_cnt, + skip_pos_cnt => skip_pos_cnt); + + --rx_data <= tx_data after 40 ns; + rx_data <= transport tx_data after 40 ns; + + ----------------------------------------------------------------------------- + -- UUT configuration and control + ----------------------------------------------------------------------------- + + clk_clk <= clk; + reset_reset_n <= reset_n; + + avs_s.mm_readdata <= avs_readdata_sl0 when sel_slave_0 = '1' else + avs_readdata_sl1 when sel_slave_1 = '1' else (others => '0'); + + avs_readdata_sl1 <= (others => '0'); + + avs_s.mm_readdatavalid <= '0'; + avs_s.mm_waitrequest <= '0'; + avs_s.use_readvalid <= true; + + avs_address <= avs_m.mm_address(avs_address'range); + avs_write <= avs_m.mm_write; + avs_writedata <= avs_m.mm_writedata; + avs_read <= avs_m.mm_read; + -- + avs_write_sl0 <= avs_write and sel_slave_0; + --avs_write_sl1 <= avs_write and sel_slave_1; + avs_write_sl1 <= '0'; + -- + avs_read_sl0 <= avs_read and sel_slave_0; + --avs_read_sl1 <= avs_read and sel_slave_1; + avs_read_sl1 <= '0'; + + -- 1-PPS generation: make it faster than 1-PPS for simulation reasons + pEMULATE_1PPS : process + begin + one_pps <= '0'; + for n in 1 to 99999 loop + wait until clk = '1' and clk'event; + end loop; -- 1 to 9999 + one_pps <= '1'; + wait until clk = '1' and clk'event; + end process pEMULATE_1PPS; + + pUUT_CTRL : process + variable addr : std_logic_vector(31 downto 0) := (others => '0'); + variable data : std_logic_vector(31 downto 0) := (others => '0'); + begin + + enable_rx <= '0'; + -- + rx_watchdog_en <= '0'; + rx_watchdog_clr <= '0'; + error_rate_thres <= X"0A"; + + sel_slave_0 <= '0'; + sel_slave_1 <= '0'; + + configuring <= true; + + -- initilialize the Avalon master-bus + mm_m_init(avs_m); + + if (reset_n = '0') then + wait until reset_n = '1'; + wait for 100 ns; + wait until clk = '1' and clk'event; + end if; + + log("Configuring POF-Tx ... ", VLOW, true); + sel_slave_0 <= '1'; + -- Config netfork_rx control registers: + -- disable the block + addr := std_logic_vector(to_unsigned(0, 32)); + data := X"0000_0021"; + mm_32b_write(addr, data, avs_s, avs_m); + + sel_slave_0 <= '0'; + sel_slave_1 <= '1'; + wait until clk = '1' and clk'event; + + log("Configuring POF-Rx ... ", VLOW, true); + enable_rx <= '1'; + rx_watchdog_en <= '1'; + + log("Configuration completed.", VLOW, true); + configuring <= false; + + wait; + + end process pUUT_CTRL; + + ----------------------------------------------------------------------------- + -- Stimuli Generation + ----------------------------------------------------------------------------- + + pSTIMULI_REGs : process(clk) + begin + if (reset_n = '0') then + abs_position_d <= (others => '0'); + elsif (clk = '1' and clk'event) then + abs_position_d <= abs_position; + end if; + end process pSTIMULI_REGs; + + inc_pos <= '1' when signed(abs_position) = signed(abs_position_d) + 1 else '0'; + dec_pos <= '1' when signed(abs_position) = signed(abs_position_d) - 1 else '0'; + + pSTIMULI : process + variable rv : RandomPType; + variable tmp_int : integer; + variable rand_time : time; + variable end_of_stimuli : boolean; + variable pd_dist : integer; + begin + + -- initialization + init_rx <= '0'; + -- + init_tx <= '0'; + dir_in <= START_DIR; + pd_in <= '0'; + abs_position <= (others => '0'); + swathe_pos <= 0; + pd_dist := 0; + -- + swathe_cnt <= 0; + stimuli_completed <= false; + end_of_swathe <= '0'; + + -- generating the stimulus + wait until running = true; + wait for 200 ns; + -- Send a Init/Sync pulse + wait until clk = '1' and clk'event; + init_tx <= '1'; + wait until clk = '1' and clk'event; + init_tx <= '0'; + wait for 500 ns; + -- Send a second init pulse and verify that it is ignored (because too + -- close to the previous) + wait until clk = '1' and clk'event; + init_tx <= '1'; + wait until clk = '1' and clk'event; + init_tx <= '0'; + wait for 2500 ns; + -- Send a third pulse (after a bigger interval from the previous). + -- Verify that this time the pulse is accepted + wait until clk = '1' and clk'event; + init_tx <= '1'; + wait until clk = '1' and clk'event; + init_tx <= '0'; + wait for 500 ns; + wait until clk = '1' and clk'event; + -- + -- generate the forward swathe + end_of_stimuli := false; + while end_of_stimuli = false loop + swathe_pos <= 0; + wait until clk = '1' and clk'event; + while swathe_pos /= SWATHE_LEN loop + -- generate a position increment + tmp_int := rv.RandInt(1, 100); + --tmp_int := 100; + if (tmp_int < 20) then + -- generate a position increment opposite to the swathe direction + swathe_pos <= swathe_pos - 1; + if (dir_in = '0') then + abs_position <= std_logic_vector(signed(abs_position) - 1); + else + abs_position <= std_logic_vector(signed(abs_position) + 1); + end if; + else + swathe_pos <= swathe_pos + 1; + if (dir_in = '0') then + abs_position <= std_logic_vector(signed(abs_position) + 1); + else + abs_position <= std_logic_vector(signed(abs_position) - 1); + end if; + end if; + -- + tmp_int := rv.RandInt(1, 100); + if (tmp_int <= 5 and pd_dist >= 10) then + pd_dist := 0; + -- generate a PD increment: the PD might be either concurrent or not + -- to the position increment + tmp_int := rv.RandInt(1, 3); + case tmp_int is + when 2 => + -- wait less than the transmission time + wait for 90 ns; + wait until clk = '1' and clk'event; + when 3 => + -- wait more than the transmission time + wait for 290 ns; + wait until clk = '1' and clk'event; + when others => null; + end case; + pd_in <= '1'; + wait until clk = '1' and clk'event; + pd_in <= '0'; + end if; + pd_dist := pd_dist + 1; + rand_time := rv.RandInt(-25, 25) * (10 ns); + wait for TIME_INT + rand_time; + end loop; -- swathe_pos /= SWATHE_LEN + + wait for 25 us; + end_of_swathe <= '1'; + wait until clk = '1' and clk'event; + end_of_swathe <= '0'; + -- reverse direction + if (dir_in /= START_DIR) then + if (swathe_cnt = NUM_ITERATIONS) then + end_of_stimuli := true; + else + swathe_cnt <= swathe_cnt + 1; + end if; + end if; + if (end_of_stimuli = false) then + wait until clk = '1' and clk'event; + dir_in <= not dir_in; + -- Wait some time to make sure the change of direction is transmitted. + -- Note: if the position starts changing before the receiver was able to + -- confirm the change of direction, then some encoder pulses may not be + -- generated + wait for 1 us; + wait until clk = '1' and clk'event; + end if; + end loop; -- end_of_stimuli = false + + stimuli_completed <= true; + wait; + + end process pSTIMULI; + + ----------------------------------------------------------------------------- + -- Error injection + ----------------------------------------------------------------------------- + + -- Randomly change the payload of the data transmitted over the UART. + -- Insert 1, 2 or 3 errors per data word + -- Note: an error on the start bit of the UART will can cause more than 3 + -- errors per data word, therefore this error injection method does not cover + -- all the possible cases + + pERROR_INJECTION : process + -- + alias symbol_valid is <>; + alias symbol is <>; + -- + alias uart_tx_set_tx_data is <>; + -- + variable rv : RandomPType; + variable rv_et : RandomPType; + variable et_sel : natural; + variable sbe_len : natural; + variable flip_vect : std_logic_vector(SYMBOL_LEN downto 0); + variable last_flip : std_logic_vector(SYMBOL_LEN downto 0); + variable bit_flips : integer range 0 to 3; + variable b0, b1, b2 : integer range 0 to 8; + variable exclude_1 : integer_vector(0 downto 0); + variable exclude_2 : integer_vector(1 downto 0); + variable last_inj_err : integer; + begin + sent_packets <= 0; + injected_errors <= 0; + last_inj_err := 0; + if (running /= true) then + wait until running = true; + end if; + + while running loop + wait until symbol_valid = '1' and symbol_valid'event; + sent_packets <= sent_packets + 1; + if (last_inj_err > 0) then + last_inj_err := last_inj_err - 1; + end if; + if (last_inj_err = 0 and rv.RandInt(1, 10000) < integer(INJECT_ERROR_PERC * 100.0)) then + -- Select the type of error to inject: The error type distribution is + -- as follows: + -- 80% of data errors, including errors on the parity-bit + -- 10% of start-bit errors + -- 10% of stop-bit errors + last_inj_err := 5; + et_sel := rv_et.RandInt(1, 100); + if (et_sel < 80) then + injected_error_type <= DATA_ERROR; + -- Inject an error: + -- Number of bits to flip in the tx word + bit_flips := rv.RandInt(1, 3); + --bit_flips := 2; + b0 := rv.RandInt(0, SYMBOL_LEN); + exclude_1(0) := b0; + b1 := rv.RandInt(min => 0, max => SYMBOL_LEN, exclude => exclude_1); + exclude_2 := (0 => b0, 1 => b1); + b2 := rv.RandInt(min => 0, max => SYMBOL_LEN, exclude => exclude_2); + flip_vect := (others => '0'); + flip_vect(b0) := '1'; + if (bit_flips >= 2) then + flip_vect(b1) := '1'; + end if; + if (bit_flips = 3) then + flip_vect(b2) := '1'; + end if; + -- Prevent situations with two consecutive bit flips on bit 0,1 and 2 + if ((flip_vect(0) = '1' and last_flip(0) = '1') or (flip_vect(1) = '1' and last_flip(1) = '1') or (flip_vect(2) = '1' and last_flip(2) = '1')) then + flip_vect := (others => '0'); + end if; + log("Injected paylod data error: bit-flip = " & to_string(bit_flips) & ", flip_vect = " & to_string(flip_vect) & ".", VLOW); + symbol(7 downto 0) <= force symbol(7 downto 0) xor flip_vect; + injected_errors <= injected_errors + 1; + wait until clk = '1' and clk'event; + wait until clk = '1' and clk'event; + symbol <= release; + last_flip := flip_vect; + + elsif (et_sel < 90) then + last_flip := (others => '0'); + injected_error_type <= START_BIT_ERROR; + -- Directly force tx_data to low for some time + sbe_len := rv_et.RandInt(3, 10); + injected_errors <= injected_errors + 1; + log("Injected error on the UART Start-Bit.", VLOW); + tx_data <= force '0'; + for i in 1 to sbe_len loop + wait until clk = '1' and clk'event; + end loop; -- i + tx_data <= release; + else + last_flip := (others => '0'); + injected_error_type <= STOP_BIT_ERROR; + -- To create an error on the UART stop-bit, force to zero the signal + -- used to switch tx_data to high, at the end of the message + uart_tx_set_tx_data <= force '0'; + sbe_len := rv_et.RandInt(20, 25); + for i in 1 to sbe_len loop + wait until clk = '1' and clk'event; + end loop; -- i + -- issue the stop bit + uart_tx_set_tx_data <= force '1'; + wait until clk = '1' and clk'event; + uart_tx_set_tx_data <= force '0'; + wait until clk = '1' and clk'event; + uart_tx_set_tx_data <= release; + injected_errors <= injected_errors + 1; + log("Injected error on the UART Stop-Bit.", VLOW); + end if; + else + last_flip := (others => '0'); + end if; + end loop; + + end process pERROR_INJECTION; + + ----------------------------------------------------------------------------- + -- Output Checking + ----------------------------------------------------------------------------- + + -- No more check on dir_out!!! + dir_out <= dir_in; + + pEVENT_MONITOR : process(clk) + begin + if (clk = '1' and clk'event) then + if (reset_n = '0' or init_tx = '1' or running = false or dir_in = dir_out) then + dir_discr_cnt <= 0; + elsif (dir_in /= dir_out) then + dir_discr_cnt <= dir_discr_cnt + 1; + end if; + if (reset_n = '0' or init_tx = '1' or running = false) then + dir_err <= '0'; + elsif (dir_discr_cnt > DISCR_THRES) then + dir_err <= '1'; + if (error_logged = false) then + log("ERROR: Detected Discrepancy in the Direction: Discrepancy Count bigger than " & to_string(DISCR_THRES) & ".", VLOW); + error_logged := true; + end if; + end if; + if (reset_n = '0' or init_tx = '1' or running = false) then + pd_in_cnt <= 0; + elsif (pd_in = '1') then + pd_in_cnt <= pd_in_cnt + 1; + end if; + if (reset_n = '0' or init_tx = '1' or running = false) then + pd_out_cnt <= 0; + elsif (pd_out = '1') then + pd_out_cnt <= pd_out_cnt + 1; + end if; + if (reset_n = '0' or init_tx = '1' or running = false or pd_in_cnt = pd_out_cnt) then + pd_discr_cnt <= 0; + elsif (pd_in_cnt /= pd_out_cnt) then + pd_discr_cnt <= pd_discr_cnt + 1; + end if; + if (reset_n = '0' or init_tx = '1' or running = false) then + pd_err <= '0'; + elsif (pd_discr_cnt > DISCR_THRES) then + pd_err <= '1'; + if (error_logged = false) then + log("ERROR: Misaligned PD count: Discrepancy Count bigger than " & to_string(DISCR_THRES) & ".", VLOW); + error_logged := true; + end if; + end if; + if (reset_n = '0' or init_tx = '1' or running = false or signed(abs_position) = signed(abs_pos_out)) then + pos_discr_cnt <= 0; + elsif (signed(abs_position) /= signed(abs_pos_out)) then + pos_discr_cnt <= pos_discr_cnt + 1; + end if; + if (reset_n = '0' or init_tx = '1' or running = false) then + pos_err <= '0'; + elsif (pos_discr_cnt > DISCR_THRES) then + pos_err <= '1'; + if (error_logged = false) then + log("ERROR: Misaligned in the Absolute-Position: Discrepancy Count bigger than " & to_string(DISCR_THRES) & ".", VLOW); + error_logged := true; + end if; + end if; + dir_in_d <= dir_in; + if (reset_n = '0' or init_tx = '1' or running = false or dir_in /= dir_in_d) then + enc_pulse_cnt <= 0; + elsif (enc_out = '1') then + enc_pulse_cnt <= enc_pulse_cnt + 1; + end if; + if (reset_n = '0' or init_tx = '1' or running = false) then + enc_err <= '0'; + elsif (end_of_swathe = '1' and enc_pulse_cnt /= SWATHE_LEN) then + enc_err <= '1'; + end if; + max_pos_d <= max_pos; + min_pos_d <= min_pos; + if ((dir_in = '0' and max_pos /= max_pos_d) or (dir_in = '1' and min_pos /= min_pos_d)) then + exp_enc_pulse <= '1'; + else + exp_enc_pulse <= '0'; + end if; + enc_out_d <= enc_out; + end if; + end process pEVENT_MONITOR; + + enc_discr <= enc_out_d xor exp_enc_pulse; + + pMIN_MAX_POS : process(reset_n, end_of_swathe, abs_pos_out) + begin + if (reset_n = '0' or end_of_swathe = '1') then + max_pos <= -SWATHE_LEN; + elsif (signed(abs_pos_out) > max_pos) then + max_pos <= to_integer(signed(abs_pos_out)); + end if; + if (reset_n = '0' or end_of_swathe = '1') then + min_pos <= SWATHE_LEN; + elsif (signed(abs_pos_out) < min_pos) then + min_pos <= to_integer(signed(abs_pos_out)); + end if; + end process pMIN_MAX_POS; + + exp_enc_cnt <= max_pos - min_pos; + + ovfl_err <= <>; + + pERR_DETECT : process(reset_n, clk) + begin + if (reset_n = '0') then + detected_error <= false; + error_logged := false; + elsif (clk = '1' and clk'event) then + if (ovfl_err = '1' or dir_err = '1' or pd_err = '1' or pos_err = '1') then + if (ovfl_err = '1') then + log("ERROR: Detected Overflow Error.", VLOW); + end if; + detected_error <= true; + end if; + end if; + end process pERR_DETECT; + + + ----------------------------------------------------------------------------- + -- Testbench Control + ----------------------------------------------------------------------------- + + pTB_CTRL : process + begin + + -- Set the verbosity level for logging + set_log_verbosity(VERBOSITY_LEVEL); + set_log_verbosity(VHIGH); + + log_header("POF Transfer Tx/Rx verification:", VLOW); + + test_completed <= false; + running <= false; + passed <= false; + failed <= false; + + -- Reset + reset_n <= '0'; + wait for 100 ns; + wait until clk = '1' and clk'event; + reset_n <= '1'; + + if (configuring /= true) then + wait until configuring = true; + end if; + wait until configuring = false; + running <= true; + + wait until stimuli_completed = true or detected_error = true; + + if (stimuli_completed = true) then + -- wait enough time to make sure that a max length package can be propagated + wait for 20 us; + else + wait for 20 us; + end if; + + log_separator_line(VLOW); + if (detected_error = true) then + failed <= true; + log("FAILURE: test completed with errors.", VLOW); + else + passed <= true; + log("Sent Packets = " & to_string(sent_packets) & ", Injected errors = " & to_string(injected_errors) & ".", VLOW); + log("SUCCESS: test successfully completed.", VLOW); + end if; + log_separator_line(VLOW); + test_completed <= true; + running <= false; + + wait; + + end process pTB_CTRL; + + +end architecture behav; diff --git a/generic_ip/pof_protocol/3/src/uart_tx_3.vhd b/generic_ip/pof_protocol/3/src/uart_tx_3.vhd new file mode 100644 index 0000000..6b39419 --- /dev/null +++ b/generic_ip/pof_protocol/3/src/uart_tx_3.vhd @@ -0,0 +1,164 @@ +------------------------------------------------------------------------------- +-- Title : uart_tx +-- Project : EMB-1 +------------------------------------------------------------------------------- +-- File : uart_tx.vhd +-- Author : Gianmarco Girau +-- Company : Global Inkjet Systems +-- Created : 2016-10-24 +-- Last update: 2021-06-07 +-- SVN ID : Git +-- Standard : VHDL'08 +------------------------------------------------------------------------------- +-- Description: +-- Simple UART trasmitter, used to trasmit data over the POF, 1 start, 1 stop +-- bit, no parity +------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity uart_tx_3 is + generic( + data_width : natural range 1 to 31); + port( + reset_n : in std_logic; + clk : in std_logic; + bit_div : in std_logic_vector(3 downto 0); -- number of clock cycles per tx bit + init : in std_logic; + ready : out std_logic; + data_in : in std_logic_vector(data_width-1 downto 0); + data_valid : in std_logic; + tx_data : out std_logic); +end entity uart_tx_3; + +architecture rtl of uart_tx_3 is + + type fsm_state_t is (idle, send_start_bit, send_data, send_stop_bit); + + signal fsm_state_curr, fsm_state_next : fsm_state_t; + -- + signal ld_data, shf_data, rst_bit_cnt, inc_bit_cnt : std_logic; + signal rst_clk_cnt, end_of_bit, end_of_tx : std_logic; + signal rst_tx_data, set_tx_data, ld_tx_data : std_logic; + signal ready_i : std_logic; + -- + signal data : std_logic_vector(data_width-1 downto 0); + signal clk_cnt : std_logic_vector(3 downto 0); + signal bit_cnt : std_logic_vector(5 downto 0); + +begin + + ----------------------------------------------------------------------------- + -- UART registers and sequential logic + ----------------------------------------------------------------------------- + + pREGs : process(clk) + begin + if(clk ='1' and clk'event) then + if(ld_data = '1') then + data <= data_in; + elsif(shf_data = '1') then + data <= '0' & data(data'high downto 1); + end if; + if(rst_bit_cnt = '1') then + bit_cnt <= (others => '0'); + elsif(inc_bit_cnt = '1') then + bit_cnt <= std_logic_vector(unsigned(bit_cnt)+1); + end if; + if(rst_clk_cnt = '1' or end_of_bit = '1') then + clk_cnt <= (others => '0'); + else + clk_cnt <= std_logic_vector(unsigned(clk_cnt)+1); + end if; + if(rst_tx_data = '1') then + tx_data <= '0'; + elsif(set_tx_data = '1') then + tx_data <= '1'; + elsif(ld_tx_data = '1') then + tx_data <= data(0); + end if; + end if; + end process pREGs; + + end_of_bit <= '1' when unsigned(clk_cnt) = (unsigned(bit_div)-1) else '0'; + end_of_tx <= '1' when unsigned(bit_cnt) = data_width else '0'; + + --shf_data <= inc_bit_cnt; + shf_data <= ld_tx_data; + inc_bit_cnt <= ld_tx_data; + + ----------------------------------------------------------------------------- + -- FSM + ----------------------------------------------------------------------------- + + -- FSM state register + pFSM_SR : process(reset_n, clk) + begin + if(reset_n = '0') then + fsm_state_curr <= idle; + elsif(clk = '1' and clk'event) then + fsm_state_curr <= fsm_state_next; + end if; + end process pFSM_SR; + + -- FSM Combinational Logic + pFSM_CL : process(fsm_state_curr, init, data_valid, end_of_bit, end_of_tx) + begin + --default assignments + ready_i <= '0'; + rst_clk_cnt <= '0'; + rst_tx_data <= '0'; + set_tx_data <= '0'; + ld_tx_data <= '0'; + rst_bit_cnt <= '0'; + ld_data <= '0'; + -- + fsm_state_next <= fsm_state_curr; + + if(init = '1') then + set_tx_data <= '1'; + fsm_state_next <= idle; + else + case fsm_state_curr is + when idle => + ready_i <= '1'; + ld_data <= '1'; + rst_clk_cnt <= '1'; + rst_bit_cnt <= '1'; + set_tx_data <= '1'; + if(data_valid = '1') then + rst_tx_data <= '1'; + fsm_state_next <= send_start_bit; + end if; + + when send_start_bit => + if(end_of_bit = '1') then + ld_tx_data <= '1'; + fsm_state_next <= send_data; + end if; + + when send_data => + if(end_of_bit = '1') then + ld_tx_data <= '1'; + if(end_of_tx = '1') then + set_tx_data <= '1'; + fsm_state_next <= send_stop_bit; + end if; + end if; + + when send_stop_bit => + if(end_of_bit = '1') then + fsm_state_next <= idle; + end if; + + when others => null; + end case; + end if; + end process pFSM_CL; + + ready <= ready_i; + +end architecture rtl; diff --git a/generic_ip/pof_protocol/Readme.txt b/generic_ip/pof_protocol/Readme.txt index af8d0d7..3d11f1d 100644 --- a/generic_ip/pof_protocol/Readme.txt +++ b/generic_ip/pof_protocol/Readme.txt @@ -1,2 +1,3 @@ - Major Version 0: Original POF Protocol -- Major Version 1: Modified POF Protocol, including Start/Stop Print bit for W&H \ No newline at end of file +- Major Version 1: Modified POF Protocol, including Start/Stop Print bit for W&H +V3 - fpga vendor independent. Change Pof_Tx to fpga vendor independent FIFOs \ No newline at end of file