ELGIP-149 ELGIP-150 Reverted pof_tx_0 changes. Introduced major version 2 of pof_tx/pof_rx that handle both pof protocols via a generic.

This commit is contained in:
Christos Spirotis 2021-06-08 15:27:19 +01:00
commit cffb201ccc
15 changed files with 3310 additions and 34 deletions

View file

@ -38,8 +38,6 @@ vcom -2008 -work $WORKLIB $COMMON_PATH/sync_wire.vhd
vcom -2008 -work $WORKLIB $COMMON_PATH/sync_wire_redge.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_0_pkg_auto.vhd
vcom -2008 -work $WORKLIB ../src/pof_tx_0_csr_regs_auto.vhd
vcom -2008 -work $WORKLIB ../src/uart_tx_0.vhd
vcom -2008 -work $WORKLIB ../src/pof_uart_rx_0.vhd
vcom -2008 -work $WORKLIB ../src/pof_tx_0.vhd

View file

@ -225,44 +225,47 @@ gray <= bin2gray(latched_pos) when (pd_event_d = '1' or pd_event_dd = '1') else
-- C&S registers
-----------------------------------------------------------------------------
pof_tx_0_csr_regs_inst : entity work.pof_tx_0_csr_regs
generic map (
ADDR_DECODE_WIDTH => 3
)
port map (
-- Clock and reset
clk => clk,
rst_n => reset_n,
-- auto-generated
-- Internal signal ports
csr_enable => enable,
csr_bit_div => bit_div,
timing_keepalive_period => keepalive_period,
timing_init_blocked_period => init_blocked_period,
csr_clr_fifo_level_max => clr_fifo_lmax,
error_inject => inject_error_req,
csr_ovfl_err => ovfl_err,
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
);
pCTRL_STATUS : process(reset_n, clk)
begin
if(reset_n = '0') then
avs_readdatavalid <= '0';
enable <= '0';
clr_fifo_lmax <= '0';
bit_div <= "0010";
keepalive_period <= std_logic_vector(to_unsigned(KEEPALIVE_PERIOD_DEF, 10));
init_blocked_period <= std_logic_vector(to_unsigned(INIT_BLOCKED_PERIOD_DEF, 10));
elsif(clk = '1' and clk'event) then
inject_error_req <= '0';
clr_fifo_lmax <= '0';
-- CTRL registers
if(avs_write = '1') then
case avs_address is
when CSR =>
enable <= avs_writedata(0);
clr_fifo_lmax <= avs_writedata(2);
bit_div <= avs_writedata(7 downto 4);
when ERROR_INJ_REG =>
inject_error_req <= avs_writedata(0);
when TIMING_REG =>
keepalive_period <= avs_writedata( 9 downto 0);
init_blocked_period <= avs_writedata(25 downto 16);
when others => null;
end case;
end if;
-- Read Ctrl & Status registers
avs_readdatavalid <= avs_read;
if(avs_read = '1') then
case avs_address is
when CSR =>
avs_readdata <= X"000000" & bit_div & b"0" & clr_fifo_lmax & ovfl_err & enable;
when TIMING_REG =>
avs_readdata <= 6x"0" & init_blocked_period & 6x"0" & keepalive_period;
when FIFO_LEVEL_REG =>
avs_readdata <= 6x"0" & fifo_level_max & 6x"0" & fifo_level;
when others =>
avs_readdata <= X"BAD1BAD0";
end case;
end if;
end if;
end process pCTRL_STATUS;

View file

@ -0,0 +1,2 @@
Major version 2 of the protocol uses autogenerated registers and by using the generic PROTOCOL_VER
the user can select which version of the pof protocol they want to use.

View file

@ -0,0 +1,150 @@
[{
"ip_name": "pof_tx_2",
"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. 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"
}
}
}
}
}]

View file

@ -0,0 +1,80 @@
# 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 ../src/altera/fifo_16x8.vhd
vcom -2008 -work $WORKLIB $COMMON_PATH/altera/sync_fifo.vhd
vcom -2008 -work $WORKLIB ../src/pof_tx_2_pkg_auto.vhd
vcom -2008 -work $WORKLIB ../src/pof_tx_2_csr_regs_auto.vhd
vcom -2008 -work $WORKLIB ../src/uart_tx_2.vhd
vcom -2008 -work $WORKLIB ../src/pof_uart_rx_2.vhd
vcom -2008 -work $WORKLIB ../src/pof_tx_2.vhd
vcom -2008 -work $WORKLIB ../src//pof_rx_2.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_2_one_tb.vhd
vsim -t ps work.pof_tx_rx_2_one_tb
add wave /pof_tx_rx_2_one_tb/*
add wave /pof_tx_rx_2_one_tb/iPOF_TX/*
add wave /pof_tx_rx_2_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;
}

View file

@ -0,0 +1,80 @@
# 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 ../src/altera/fifo_16x8.vhd
vcom -2008 -work $WORKLIB $COMMON_PATH/altera/sync_fifo.vhd
vcom -2008 -work $WORKLIB ../src/pof_tx_2_pkg_auto.vhd
vcom -2008 -work $WORKLIB ../src/pof_tx_2_csr_regs_auto.vhd
vcom -2008 -work $WORKLIB ../src/uart_tx_2.vhd
vcom -2008 -work $WORKLIB ../src/pof_uart_rx_2.vhd
vcom -2008 -work $WORKLIB ../src/pof_tx_2.vhd
vcom -2008 -work $WORKLIB ../src/pof_rx_2.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_2_zero_tb.vhd
vsim -t ps work.pof_tx_rx_2_zero_tb
add wave /pof_tx_rx_2_zero_tb/*
add wave /pof_tx_rx_2_zero_tb/iPOF_TX/*
add wave /pof_tx_rx_2_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;
}

View file

@ -0,0 +1,228 @@
onerror {resume}
quietly WaveActivateNextPane {} 0
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/clk
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/reset_n
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/avs_read
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/avs_write
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/sel_slave_0
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/sel_slave_1
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/avs_write_sl0
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/avs_read_sl0
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/avs_write_sl1
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/avs_read_sl1
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/init_tx
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/init_rx
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/dir_in
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/pd_in
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/inc_pos
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/dec_pos
add wave -noupdate -expand -group TB -radix decimal /pof_tx_rx_2_one_tb/abs_position
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/tx_data
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/rx_data
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/init_out
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/dir_out
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/enc_out
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/pd_out
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/inc_pos_out
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/dec_pos_out
add wave -noupdate -expand -group TB -radix decimal /pof_tx_rx_2_one_tb/abs_pos_out
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/print_start_in
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/print_start_out
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/ps_flip_cnt
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/test_completed
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/running
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/configuring
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/passed
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/failed
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/stimuli_completed
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/avs_address
add wave -noupdate -expand -group TB -radix hexadecimal /pof_tx_rx_2_one_tb/avs_writedata
add wave -noupdate -expand -group TB -radix hexadecimal /pof_tx_rx_2_one_tb/avs_readdata_sl0
add wave -noupdate -expand -group TB -radix hexadecimal /pof_tx_rx_2_one_tb/avs_readdata_sl1
add wave -noupdate -expand -group TB -radix decimal /pof_tx_rx_2_one_tb/abs_position_d
add wave -noupdate -expand -group TB -radix decimal /pof_tx_rx_2_one_tb/swathe_pos
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/swathe_cnt
add wave -noupdate -expand -group TB -radix hexadecimal /pof_tx_rx_2_one_tb/avs_m
add wave -noupdate -expand -group TB -radix hexadecimal /pof_tx_rx_2_one_tb/avs_s
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/detected_error
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/dir_discr_cnt
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/pd_discr_cnt
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/pd_in_cnt
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/pd_out_cnt
add wave -noupdate -expand -group TB -radix decimal /pof_tx_rx_2_one_tb/abs_position
add wave -noupdate -expand -group TB -radix decimal /pof_tx_rx_2_one_tb/abs_pos_out
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/pos_discr_cnt
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/end_of_swathe
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/enc_pulse_cnt
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/dir_err
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/pd_err
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/pos_err
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/enc_err
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/ovfl_err
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/ps_err
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/injected_errors
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/sent_packets
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/injected_error_type
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/max_pos
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/min_pos
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/exp_enc_pulse
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/exp_enc_cnt
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/error_rate_thres
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/one_pps
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/max_error_flag
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/rx_watchdog
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/rx_watchdog_en
add wave -noupdate -expand -group TB /pof_tx_rx_2_one_tb/rx_watchdog_clr
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/reset_n
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/clk
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/init
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/pd_in
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/inc_pos
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/dec_pos
add wave -noupdate -group POF-Tx -radix decimal /pof_tx_rx_2_one_tb/iPOF_TX/abs_position
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/tx_data
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/avs_address
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/avs_write
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/avs_writedata
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/avs_read
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/avs_readdata
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/rd_event
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/wr_event
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/empty
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/full
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/tx_ready
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/rd_event_d
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/wr_event_i
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/enable
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/toggle_sync
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/toggle_pd
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/add_keepalive
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/ovfl_err
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/init_d
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/init_gen
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/init_v
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/init_blocked
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/init_blk_cnt
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/parity_bit
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/inject_error
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/inject_error_req
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/pd_event
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/pd_event_d
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/pd_event_dd
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/gray
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/clear
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/pd_in_d
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/pd_gen
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/clk
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/symbol_valid
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/symbol
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/clr_fifo_lmax
add wave -noupdate -group POF-Tx -radix unsigned /pof_tx_rx_2_one_tb/iPOF_TX/keepalive_period
add wave -noupdate -group POF-Tx -radix unsigned /pof_tx_rx_2_one_tb/iPOF_TX/init_blocked_period
add wave -noupdate -group POF-Tx -radix unsigned /pof_tx_rx_2_one_tb/iPOF_TX/fifo_level
add wave -noupdate -group POF-Tx -radix unsigned /pof_tx_rx_2_one_tb/iPOF_TX/fifo_level_max
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/tx_data
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/event_in_i
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/event_in
add wave -noupdate -group POF-Tx /pof_tx_rx_2_one_tb/iPOF_TX/event_out
add wave -noupdate -group POF-Tx -radix decimal /pof_tx_rx_2_one_tb/iPOF_TX/keepalive_cnt
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/reset_n
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/clk
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/init
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/rx_clk
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/rx_data
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/init_out
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/pd_out
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/inc_pos
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/dec_pos
add wave -noupdate -group POF-Rx -radix decimal /pof_tx_rx_2_one_tb/iPOF_RX/abs_pos
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/print_start_out
add wave -noupdate -group POF-Rx -radix unsigned /pof_tx_rx_2_one_tb/iPOF_RX/error_rate_thres
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/one_pps
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/max_error_flag
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/rx_watchdog
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/rx_watchdog_en
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/rx_watchdog_clr
add wave -noupdate -group POF-Rx -radix unsigned /pof_tx_rx_2_one_tb/iPOF_RX/rx_wd_cnt
add wave -noupdate -group POF-Rx -radix unsigned /pof_tx_rx_2_one_tb/iPOF_RX/error_rate_cnt
add wave -noupdate -group POF-Rx -radix unsigned /pof_tx_rx_2_one_tb/iPOF_RX/error_rate
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/clear
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/clear_i
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/inc_pos_i
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/dec_pos_i
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/enable
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/sync_gen
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/pd_gen
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/symbol_error
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/rx_symbol_val
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/rx_symbol
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/rx_symbol_val_v
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/symbol_valid_i
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/symbol_valid_d
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/toggle_sync
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/sync_confirmed
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/sync_toggle_test
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/sync
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/toggle_pd
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/pd_confirmed
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/pd_toggle_test
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/pd
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/print_start_in
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/print_start_out
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/ps_flip_cnt
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/ps_gen
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/ps_new
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/ps_confirmed
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/ps_test
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/rx_error
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/rx_error_i
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/print_start_i
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/valid_pos
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/upd_pos
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/corr_done
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/corr_sign
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/skip_cnt
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/skip_pos
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/symbol_valid
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/symbol
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/apply_corr
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/clk_cnt
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/dist
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/abs_dist
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/next_pos_lsb
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/curr_pos_lsb
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/pos_corr
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/max_dist
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/gray_pos
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/symbol_i
add wave -noupdate -group POF-Rx -radix unsigned /pof_tx_rx_2_one_tb/iPOF_RX/parity_err_cnt
add wave -noupdate -group POF-Rx -radix decimal /pof_tx_rx_2_one_tb/iPOF_RX/abs_pos_i
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/inc_pos_ii
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/dec_pos_ii
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/GEN_RX_SYMBOL/iRX_SYMBOL/data_width
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/GEN_RX_SYMBOL/iRX_SYMBOL/reset_n
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/GEN_RX_SYMBOL/iRX_SYMBOL/clk
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/GEN_RX_SYMBOL/iRX_SYMBOL/init
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/GEN_RX_SYMBOL/iRX_SYMBOL/data_out
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/GEN_RX_SYMBOL/iRX_SYMBOL/data_out_valid
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/GEN_RX_SYMBOL/iRX_SYMBOL/rx_data
add wave -noupdate -group POF-Rx /pof_tx_rx_2_one_tb/iPOF_RX/GEN_RX_SYMBOL/iRX_SYMBOL/rx_data_i
add wave -noupdate -group POF-Rx /pof_tx_rx_2_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}

View file

@ -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}

View file

@ -0,0 +1,372 @@
-------------------------------------------------------------------------------
-- Title : pof_rx
-- Project : SMB
-------------------------------------------------------------------------------
-- File : pof_rx_2.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_2 is
generic(
PROTOCOL_VER : integer range 0 to 1;
GEN_BIT_DIV : integer := 6
);
port(
reset_n : in std_logic;
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
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_2;
architecture rtl of pof_rx_2 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;
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, rx_error_v : std_logic_vector( 3 downto 0);
signal gray_pos, rx_symbol_val_v : std_logic_vector( 3 downto 0);
signal symbol, symbol_i, rx_symbol : std_logic_vector( 8 downto 0);
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);
begin
clear <= not enable or init;
-----------------------------------------------------------------------------
-- De-serialize symbols (Serial clock at 300 MHz - typical)
-----------------------------------------------------------------------------
GEN_RX_SYMBOL : IF PROTOCOL_VER = 0 GENERATE
iRX_SYMBOL : entity work.pof_uart_rx_2
generic map(
GEN_BIT_DIV => GEN_BIT_DIV,
data_width => 8)
port map(
reset_n => reset_n,
clk => rx_clk,
init => clear_i,
data_out => rx_symbol(7 downto 0),
data_out_valid => rx_symbol_val,
rx_error => rx_error,
rx_data => rx_data);
rx_symbol(8) <= '0';
ELSIF PROTOCOL_VER = 1 GENERATE
iRX_SYMBOL : entity work.pof_uart_rx_2
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,
data_out_valid => rx_symbol_val,
rx_error => rx_error,
rx_data => rx_data);
END GENERATE GEN_RX_SYMBOL;
-- Synchronize to the local clock
pLATCH_RX_DATA : process(rx_clk)
begin
if (rx_clk = '1' and rx_clk'event) then
if (rx_symbol_val = '1') then
symbol <= rx_symbol;
end if;
if (rx_symbol_val = '1') then
rx_symbol_val_v <= "1111";
else
rx_symbol_val_v <= '0' & rx_symbol_val_v(3 downto 1);
end if;
if (rx_error = '1') then
rx_error_v <= "1111";
else
rx_error_v <= '0' & rx_error_v(3 downto 1);
end if;
end if;
end process pLATCH_RX_DATA;
iSYNC_SYMBOL_VAL : entity work.sync_wire_rEdge
generic map(rst_val => '0', sync_stages => 3)
port map(rstN => reset_n, clk => clk, async_in => rx_symbol_val_v(0), sync_out => symbol_valid);
iSYNC_RX_ERROR : entity work.sync_wire_rEdge
generic map(rst_val => '0', sync_stages => 3)
port map(rstN => reset_n, clk => clk, async_in => rx_error_v(0), sync_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, 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_i(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_i(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_i(7);
end if;
if (clear = '1' or ps_confirmed = '1' or (symbol_valid_i = '1' and symbol_i(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;
symbol_i <= symbol;
-- 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_i(0) /= toggle_sync else '0';
pd_gen <= '1' when symbol_valid_i = '1' and symbol_i(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 : IF PROTOCOL_VER = 0 GENERATE
ps_gen <= '0';
ps_confirmed <= '0';
print_start <= '0';
ELSIF PROTOCOL_VER = 1 GENERATE
ps_gen <= '1' when symbol_valid_i = '1' and symbol_i(7) /= print_start_i else '0';
ps_confirmed <= ps_gen and ps_test;
print_start <= print_start_i;
END GENERATE GEN_PRINT_START;
-----------------------------------------------------------------------------
-- Position management & Error Recovery
-----------------------------------------------------------------------------
gray_pos <= symbol_i(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;

View file

@ -0,0 +1,334 @@
-------------------------------------------------------------------------------
-- Title : pof_tx_2
-- Project : SMB
-------------------------------------------------------------------------------
-- File : pof_tx_2.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_2 is
generic (
PROTOCOL_VER : integer range 0 to 1
);
port(
reset_n : in std_logic;
clk : in std_logic;
init : in std_logic;
pd_in : in std_logic;
print_start : 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_2;
architecture rtl of pof_tx_2 is
constant CSR : std_logic_vector( 2 downto 0) := b"000";
constant ERROR_INJ_REG : std_logic_vector( 2 downto 0) := b"001";
constant TIMING_REG : std_logic_vector( 2 downto 0) := b"010";
constant FIFO_LEVEL_REG : std_logic_vector( 2 downto 0) := b"011";
constant KEEPALIVE_PERIOD_DEF : integer := 100;
constant INIT_BLOCKED_PERIOD_DEF : integer := 200;
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 event_in_no_start : std_logic_vector( 7 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);
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 = '1' and init_d = '0' and init_blocked = '0') then
init_v <= "1100";
else
init_v <= '0' & init_v(3 downto 1);
end if;
if(enable = '0') then
toggle_sync <= '0';
elsif(init_d = '1' and init_blocked = '0') then
toggle_sync <= not toggle_sync;
end if;
if(init_gen = '1') then
init_blk_cnt <= init_blocked_period;
elsif(init_blocked = '1') then
init_blk_cnt <= std_logic_vector(unsigned(init_blk_cnt)-1);
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(init_gen = '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;
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;
-- Two symbols are queued up in the FIFO each time there is a change in value
-- on Print-Start/Stop
GEN_PRINT_START_GEN : IF PROTOCOL_VER = 0 GENERATE
print_start_gen <= '0';
ELSIF PROTOCOL_VER = 1 GENERATE
print_start_gen <= print_start_event or print_start_event_d;
END GENERATE GEN_PRINT_START_GEN;
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));
-- toggle_pd is repeated twice in the tx word, to improve resiliance against
-- double bit-flips errors
GEN_EVENT_IN_I : IF PROTOCOL_VER = 0 GENERATE
event_in_i <= '0' & gray & toggle_pd & toggle_pd & toggle_sync;
ELSIF PROTOCOL_VER = 1 GENERATE
event_in_i <= print_start_val & gray & toggle_pd & toggle_pd & toggle_sync;
END GENERATE GEN_EVENT_IN_I;
parity_bit <= odd_parity(event_in_i) xor inject_error;
GEN_QUEUE_EVENT : IF PROTOCOL_VER = 0 GENERATE
event_in_no_start <= event_in(8) & event_in(6 downto 0);
iQUEUE_EVENT : entity work.sync_fifo
generic map (
FIFO_WIDTH => 8,
FIFO_DEPTH => 1024)
port map (
sclr => clear,
clock => clk,
data => event_in_no_start,
rdreq => rd_event,
wrreq => wr_event,
empty => empty,
full => full,
q => event_out(7 downto 0),
usedw => fifo_level);
ELSIF PROTOCOL_VER = 1 GENERATE
iQUEUE_EVENT : entity work.sync_fifo
generic map (
FIFO_WIDTH => 9,
FIFO_DEPTH => 1024)
port map (
sclr => clear,
clock => clk,
data => event_in,
rdreq => rd_event,
wrreq => wr_event,
empty => empty,
full => full,
q => event_out,
usedw => fifo_level);
END GENERATE GEN_QUEUE_EVENT;
-----------------------------------------------------------------------------
-- 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';
symbol <= event_out;
GEN_TX_SYMBOL : IF PROTOCOL_VER = 0 GENERATE
iTX_SYMBOL : entity work.uart_tx_2
generic map (
data_width => 8)
port map (
reset_n => reset_n,
clk => clk,
bit_div => bit_div,
init => clear,
ready => tx_ready,
data_in => symbol(7 downto 0),
data_valid => symbol_valid,
tx_data => tx_data);
ELSIF PROTOCOL_VER = 1 GENERATE
iTX_SYMBOL : entity work.uart_tx_2
generic map (
data_width => 9)
port map (
reset_n => reset_n,
clk => clk,
bit_div => bit_div,
init => clear,
ready => tx_ready,
data_in => symbol,
data_valid => symbol_valid,
tx_data => tx_data);
END GENERATE GEN_TX_SYMBOL;
-----------------------------------------------------------------------------
-- C&S registers
-----------------------------------------------------------------------------
pof_tx_2_csr_regs_inst : entity work.pof_tx_2_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;

View file

@ -0,0 +1,100 @@
-------------------------------------------------------------------------------
-- 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_2 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_2;
architecture rtl of pof_uart_regen_2 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);
begin
-- output mux (maybe register?)
uart_tx <= uart_rx when bypass_en = '1' else uart_regen;
-----------------------------------------------------------------------------
-- 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 => uart_rx,
sync_out => uart_rx_i);
pREGEN : process(clk)
begin
if clk = '1' and clk'event then
if enable = '0' or bypass_en = '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;

View file

@ -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_2 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_2;
architecture rtl of pof_uart_rx_2 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;

View file

@ -0,0 +1,724 @@
-------------------------------------------------------------------------------
-- 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_2_one_tb is
-- ..
end entity pof_tx_rx_2_one_tb;
architecture behav of pof_tx_rx_2_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 := 2.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_2
generic map(
PROTOCOL_VER => 1)
port map(
reset_n => reset_n,
clk => clk,
init => init_tx,
pd_in => pd_in,
print_start => print_start_in,
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_2
generic map(
PROTOCOL_VER => 1,
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,
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');
variable init_done : boolean := false;
variable fifo_level : integer;
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 <<signal iPOF_TX.symbol_valid : std_logic>>;
alias symbol is <<signal iPOF_TX.symbol : std_logic_vector>>;
--
alias uart_tx_set_tx_data is <<signal iPOF_TX.GEN_TX_SYMBOL.iTX_SYMBOL.set_tx_data : std_logic>>;
--
variable rv : RandomPType;
variable rv_et : RandomPType;
variable rv_sbe : 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 test : std_logic_vector(5 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 <= <<signal iPOF_TX.ovfl_err : std_logic>>;
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;

View file

@ -0,0 +1,696 @@
-------------------------------------------------------------------------------
-- 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_2_zero_tb is
-- ..
end entity pof_tx_rx_2_zero_tb;
architecture behav of pof_tx_rx_2_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_2
generic map(
PROTOCOL_VER => 0)
port map(
reset_n => reset_n,
clk => clk,
init => init_tx,
pd_in => pd_in,
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_2
generic map(
PROTOCOL_VER => 0,
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,
inc_pos => inc_pos_out,
dec_pos => dec_pos_out,
abs_pos => abs_pos_out,
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');
variable init_done : boolean := false;
variable fifo_level : integer;
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 <<signal iPOF_TX.symbol_valid : std_logic>>;
alias symbol is <<signal iPOF_TX.symbol : std_logic_vector>>;
--
alias uart_tx_set_tx_data is <<signal iPOF_TX.GEN_TX_SYMBOL.iTX_SYMBOL.set_tx_data : std_logic>>;
--
variable rv : RandomPType;
variable rv_et : RandomPType;
variable rv_sbe : 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 test : std_logic_vector(5 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 <= <<signal iPOF_TX.ovfl_err : std_logic>>;
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;

View file

@ -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_2 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_2;
architecture rtl of uart_tx_2 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;