SMB-147 - Updating enc_pd_emul testbench to run in the generic-ip repository. Moved fractional divider and pd-jitter verification testbenches from the SMB repository

This commit is contained in:
gianmarcogirau 2018-12-19 16:37:30 +00:00
commit 4a42477b4b
10 changed files with 1511 additions and 5 deletions

View file

@ -1,5 +1,5 @@
[{
"ip_name": "emul_1",
"ip_name": "enc_pd_emul_1",
"bus": "csr",
"description": "Encoder/PD emulator",
"addr_hi_bit" : "6",

View file

@ -2,8 +2,15 @@
#.main clear
set OSVVM_PATH ../../common/0/src/test/OSVVM
set COMMON_PATH ../../common/0/src
# Cleanup libraries
foreach lib [list work OSVVM] {
file delete -force -- $lib
vlib $lib
}
set OSVVM_PATH ../../../common/0/src/test/OSVVM
set COMMON_PATH ../../../common/0/src
set SEQUENCER_PATH ../../../generic_sequencer/15/src
set WORKLIB work
@ -11,7 +18,12 @@ vlib ./work
vmap work ./work
# Compile the UUT
do com_smb.do
vcom -2008 -work $WORKLIB $COMMON_PATH/common_pkg.vhd
vcom -2008 -work $WORKLIB $SEQUENCER_PATH/dpram_sclk_15.vhd
vcom -2008 -work $WORKLIB $SEQUENCER_PATH/generic_sequencer_15_pkg.vhd
vcom -2008 -work $WORKLIB $SEQUENCER_PATH/generic_sequencer_15.vhd
vcom -2008 -work $WORKLIB ./../src/enc_pd_emul_1_pkg.vhd
vcom -2008 -work $WORKLIB ./../src/enc_pd_emul_1.vhd
# Compile the constrained random related packages
vlib OSVVM

View file

@ -1,5 +1,5 @@
[{
"ip_name": "pulse_gen_1",
"ip_name": "pulse_generator_1",
"bus": "csr",
"description": "Generate Fire-Requests, based on the absolute position and PD inputs",
"addr_hi_bit" : "9",

View file

@ -0,0 +1,79 @@
# 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 SRC_PATH ../src
set COMMON_PATH ../../../common/0/src
set SEQUENCER_PATH ../../../generic_sequencer/15
set OSVVM_PATH ../../../common/0/src/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 work $COMMON_PATH/common_pkg.vhd
vcom -2008 -work $WORKLIB $SRC_PATH/altera/sync_fifo_1.vhd
vcom -2008 -work $WORKLIB $SRC_PATH/queue_and_delay_1.vhd
vcom -2008 -work $WORKLIB $SRC_PATH/pulse_conditioning_1.vhd
vcom -2008 -work $WORKLIB $SEQUENCER_PATH/src/dpram_sclk_15.vhd
vcom -2008 -work $WORKLIB $SEQUENCER_PATH/src/generic_sequencer_15_pkg.vhd
vcom -2008 -work $WORKLIB $SEQUENCER_PATH/src/generic_sequencer_15.vhd
vcom -2008 -work $WORKLIB $SRC_PATH/simple_frac_div_1.vhd
vcom -2008 -work $WORKLIB $SRC_PATH/pulse_generator_1_pkg.vhd
vcom -2008 -work $WORKLIB $SRC_PATH/pulse_generator_1.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/pd_jitter_verify_tb.vhd
vsim -t ps work.pd_jitter_verify_tb
#add wave /pd_jitter_verify_tb/*
#add wave /pd_jitter_verify_tb/iUUT/*
# remove warnings from standard numeric/arithmetic packages (speed-up simulation)
set StdArithNoWarnings 1
set NumericStdNoWarnings 1
do wave_pd_jitter.do
when -label end_of_simulation {test_completed == true} {echo "Simulation Completed"; stop ;}
run -all
#run 1 ms;
}

View file

@ -0,0 +1,67 @@
# Simulation macro
.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 OSVVM_PATH ../../../common/0/src/test/OSVVM
set COMMON_PATH ../../../common/0/src
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 ../src/simple_frac_div_1.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
# Testbench
vcom -2008 -work $WORKLIB $TB_PATH/simple_frac_div_tb.vhd
vsim -t ps work.simple_frac_div_tb
#add wave /simple_frac_div_tb/*
#add wave /simple_frac_div_tb/iUUT/*
# remove warnings from standard numeric/arithmetic packages (speed-up simulation)
set StdArithNoWarnings 1
set NumericStdNoWarnings 1
do wave_simple_frac_div.do
when -label end_of_simulation {test_completed == true} {echo "Simulation Completed"; stop ;}
run -all
#run 1 ms;
}

View file

@ -0,0 +1,179 @@
onerror {resume}
quietly WaveActivateNextPane {} 0
add wave -noupdate /pd_jitter_verify_tb/reset_n
add wave -noupdate /pd_jitter_verify_tb/clk
add wave -noupdate /pd_jitter_verify_tb/init
add wave -noupdate /pd_jitter_verify_tb/enc_in
add wave -noupdate /pd_jitter_verify_tb/pd_in
add wave -noupdate -radix decimal /pd_jitter_verify_tb/abs_position
add wave -noupdate /pd_jitter_verify_tb/dp_dir
add wave -noupdate /pd_jitter_verify_tb/pulse_out
add wave -noupdate /pd_jitter_verify_tb/filtered_pd
add wave -noupdate /pd_jitter_verify_tb/ch_pd
add wave -noupdate /pd_jitter_verify_tb/pd_in_cnt
add wave -noupdate /pd_jitter_verify_tb/pd_out_cnt
add wave -noupdate /pd_jitter_verify_tb/ch_mask
add wave -noupdate /pd_jitter_verify_tb/raw_pulse_out
add wave -noupdate -radix hexadecimal /pd_jitter_verify_tb/avs_address
add wave -noupdate /pd_jitter_verify_tb/avs_write
add wave -noupdate -radix hexadecimal /pd_jitter_verify_tb/avs_writedata
add wave -noupdate /pd_jitter_verify_tb/avs_read
add wave -noupdate /pd_jitter_verify_tb/avs_readdatavalid
add wave -noupdate -radix hexadecimal /pd_jitter_verify_tb/avs_readdata
add wave -noupdate /pd_jitter_verify_tb/avs_m
add wave -noupdate /pd_jitter_verify_tb/avs_s
add wave -noupdate /pd_jitter_verify_tb/test_completed
add wave -noupdate /pd_jitter_verify_tb/setup
add wave -noupdate /pd_jitter_verify_tb/running
add wave -noupdate /pd_jitter_verify_tb/error_flag
add wave -noupdate /pd_jitter_verify_tb/passed
add wave -noupdate /pd_jitter_verify_tb/failed
add wave -noupdate /pd_jitter_verify_tb/iUUT/clk
add wave -noupdate /pd_jitter_verify_tb/iUUT/reset_n
add wave -noupdate /pd_jitter_verify_tb/iUUT/init
add wave -noupdate /pd_jitter_verify_tb/iUUT/enc_in
add wave -noupdate /pd_jitter_verify_tb/iUUT/pd_in
add wave -noupdate -radix decimal /pd_jitter_verify_tb/iUUT/abs_position
add wave -noupdate /pd_jitter_verify_tb/iUUT/dp_dir
add wave -noupdate /pd_jitter_verify_tb/iUUT/pulse_out
add wave -noupdate /pd_jitter_verify_tb/iUUT/gen_filt_pd
add wave -noupdate /pd_jitter_verify_tb/iUUT/filtered_pd
add wave -noupdate /pd_jitter_verify_tb/iUUT/pd_pulse
add wave -noupdate /pd_jitter_verify_tb/iUUT/first_pd
add wave -noupdate /pd_jitter_verify_tb/iUUT/filt_pd
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_pd
add wave -noupdate -radix decimal /pd_jitter_verify_tb/iUUT/last_pd_pos
add wave -noupdate /pd_jitter_verify_tb/iUUT/close_to_zero
add wave -noupdate /pd_jitter_verify_tb/iUUT/close_to_mid
add wave -noupdate /pd_jitter_verify_tb/iUUT/mid_cross
add wave -noupdate /pd_jitter_verify_tb/iUUT/mid_crossed
add wave -noupdate /pd_jitter_verify_tb/iUUT/zero_cross
add wave -noupdate /pd_jitter_verify_tb/iUUT/abs_pos_msb_old
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_mask
add wave -noupdate /pd_jitter_verify_tb/iUUT/raw_pulse_out
add wave -noupdate -radix hexadecimal /pd_jitter_verify_tb/iUUT/avs_address
add wave -noupdate /pd_jitter_verify_tb/iUUT/avs_write
add wave -noupdate -radix hexadecimal /pd_jitter_verify_tb/iUUT/avs_writedata
add wave -noupdate /pd_jitter_verify_tb/iUUT/avs_read
add wave -noupdate /pd_jitter_verify_tb/iUUT/avs_readdatavalid
add wave -noupdate -radix hexadecimal /pd_jitter_verify_tb/iUUT/avs_readdata
add wave -noupdate /pd_jitter_verify_tb/iUUT/init_de
add wave -noupdate /pd_jitter_verify_tb/iUUT/init_qd
add wave -noupdate /pd_jitter_verify_tb/iUUT/enable
add wave -noupdate /pd_jitter_verify_tb/iUUT/loc_pd
add wave -noupdate /pd_jitter_verify_tb/iUUT/pd_queue_error
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_start_req
add wave -noupdate /pd_jitter_verify_tb/iUUT/filt_pd_d
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_write
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_read
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_busy
add wave -noupdate /pd_jitter_verify_tb/iUUT/enable_i
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_mask_i
add wave -noupdate /pd_jitter_verify_tb/iUUT/bypass_ch_ctrl
add wave -noupdate /pd_jitter_verify_tb/iUUT/bypass_delay_equal
add wave -noupdate /pd_jitter_verify_tb/iUUT/div_pulse
add wave -noupdate /pd_jitter_verify_tb/iUUT/gated_pulse
add wave -noupdate /pd_jitter_verify_tb/iUUT/retimed_pulse
add wave -noupdate /pd_jitter_verify_tb/iUUT/pulse_out_i
add wave -noupdate /pd_jitter_verify_tb/iUUT/avs_write_i
add wave -noupdate /pd_jitter_verify_tb/iUUT/avs_read_d
add wave -noupdate /pd_jitter_verify_tb/iUUT/avs_read_i
add wave -noupdate /pd_jitter_verify_tb/iUUT/de_queue_error
add wave -noupdate /pd_jitter_verify_tb/iUUT/cnt_dir
add wave -noupdate /pd_jitter_verify_tb/iUUT/dp_dir_i
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_mask_d
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_start_req_i
add wave -noupdate /pd_jitter_verify_tb/iUUT/bypass_pulse_div
add wave -noupdate /pd_jitter_verify_tb/iUUT/set_first_pd
add wave -noupdate /pd_jitter_verify_tb/iUUT/loc_pulse_out_d
add wave -noupdate /pd_jitter_verify_tb/iUUT/loc_pulse
add wave -noupdate /pd_jitter_verify_tb/iUUT/first_pulse
add wave -noupdate /pd_jitter_verify_tb/iUUT/dp_dir_d
add wave -noupdate /pd_jitter_verify_tb/iUUT/overdrive_rst
add wave -noupdate /pd_jitter_verify_tb/iUUT/overdrv_event
add wave -noupdate /pd_jitter_verify_tb/iUUT/pulse_scale_out
add wave -noupdate /pd_jitter_verify_tb/iUUT/start_img_req
add wave -noupdate /pd_jitter_verify_tb/iUUT/start_img_req_d
add wave -noupdate /pd_jitter_verify_tb/iUUT/start_img
add wave -noupdate /pd_jitter_verify_tb/iUUT/start_img_d
add wave -noupdate /pd_jitter_verify_tb/iUUT/start_img_dd
add wave -noupdate /pd_jitter_verify_tb/iUUT/fire_enable
add wave -noupdate /pd_jitter_verify_tb/iUUT/img_completed
add wave -noupdate /pd_jitter_verify_tb/iUUT/sw_ctrl_dp_dir
add wave -noupdate /pd_jitter_verify_tb/iUUT/enable_out
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_start_req_d
add wave -noupdate /pd_jitter_verify_tb/iUUT/add_img_size
add wave -noupdate /pd_jitter_verify_tb/iUUT/add_img_size_d
add wave -noupdate /pd_jitter_verify_tb/iUUT/abort_fire
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_csr_write
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_csr_read
add wave -noupdate /pd_jitter_verify_tb/iUUT/frac_div_en_i
add wave -noupdate /pd_jitter_verify_tb/iUUT/upd_max_pos
add wave -noupdate /pd_jitter_verify_tb/iUUT/upd_min_pos
add wave -noupdate /pd_jitter_verify_tb/iUUT/frac_div_en
add wave -noupdate /pd_jitter_verify_tb/iUUT/upd_max_pos_i
add wave -noupdate /pd_jitter_verify_tb/iUUT/upd_min_pos_i
add wave -noupdate /pd_jitter_verify_tb/iUUT/dir_change
add wave -noupdate /pd_jitter_verify_tb/iUUT/pd_in_d
add wave -noupdate /pd_jitter_verify_tb/iUUT/filt_pd_i
add wave -noupdate /pd_jitter_verify_tb/iUUT/abs_pos_lsb
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_start_req_ii
add wave -noupdate /pd_jitter_verify_tb/iUUT/prevent_div_restart
add wave -noupdate /pd_jitter_verify_tb/iUUT/rst_jitter
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_csr_addr
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_trigger_in
add wave -noupdate /pd_jitter_verify_tb/iUUT/avs_addr
add wave -noupdate /pd_jitter_verify_tb/iUUT/pulse_width
add wave -noupdate /pd_jitter_verify_tb/iUUT/pulse_width_ext
add wave -noupdate /pd_jitter_verify_tb/iUUT/init_v
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_start_addr
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_address
add wave -noupdate /pd_jitter_verify_tb/iUUT/avs_address_i
add wave -noupdate /pd_jitter_verify_tb/iUUT/overdrive_events
add wave -noupdate /pd_jitter_verify_tb/iUUT/overdrive_thres
add wave -noupdate /pd_jitter_verify_tb/iUUT/pulse_interval
add wave -noupdate /pd_jitter_verify_tb/iUUT/img_size
add wave -noupdate /pd_jitter_verify_tb/iUUT/pixel_cnt
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_vector_out
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_offset
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_delay
add wave -noupdate /pd_jitter_verify_tb/iUUT/avs_readdata_i
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_writedata
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_readdata
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_csr_writedata
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_csr_readdata
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_offset_dir0
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_offset_dir1
add wave -noupdate /pd_jitter_verify_tb/iUUT/abs_pos_max
add wave -noupdate /pd_jitter_verify_tb/iUUT/abs_pos_min
add wave -noupdate /pd_jitter_verify_tb/iUUT/div_offset
add wave -noupdate /pd_jitter_verify_tb/iUUT/div_ratio
add wave -noupdate /pd_jitter_verify_tb/iUUT/rst_dbg_cnt
add wave -noupdate /pd_jitter_verify_tb/iUUT/div_pulse_d
add wave -noupdate /pd_jitter_verify_tb/iUUT/div_pulse_p
add wave -noupdate /pd_jitter_verify_tb/iUUT/retimed_pulse_d
add wave -noupdate /pd_jitter_verify_tb/iUUT/retimed_pulse_p
add wave -noupdate /pd_jitter_verify_tb/iUUT/pulse_out_ii
add wave -noupdate /pd_jitter_verify_tb/iUUT/pulse_out_d
add wave -noupdate /pd_jitter_verify_tb/iUUT/pulse_out_p
add wave -noupdate /pd_jitter_verify_tb/iUUT/div_pulse_cnt
add wave -noupdate /pd_jitter_verify_tb/iUUT/retimed_pulse_cnt
add wave -noupdate /pd_jitter_verify_tb/iUUT/pulse_out_cnt
TreeUpdate [SetDefaultTree]
WaveRestoreCursors {{Cursor 1} {35005000 ps} 0}
quietly wave cursor active 1
configure wave -namecolwidth 281
configure wave -valuecolwidth 146
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 {21553836 ps} {37018220 ps}

View file

@ -0,0 +1,76 @@
onerror {resume}
quietly WaveActivateNextPane {} 0
add wave -noupdate /simple_frac_div_tb/reset_n
add wave -noupdate /simple_frac_div_tb/clk
add wave -noupdate /simple_frac_div_tb/enable
add wave -noupdate /simple_frac_div_tb/dir
add wave -noupdate -radix hexadecimal /simple_frac_div_tb/offset
add wave -noupdate -radix hexadecimal /simple_frac_div_tb/ratio
add wave -noupdate -radix decimal /simple_frac_div_tb/abs_pos
add wave -noupdate /simple_frac_div_tb/fire
add wave -noupdate -radix unsigned /simple_frac_div_tb/fire_cnt
add wave -noupdate /simple_frac_div_tb/div_ratio
add wave -noupdate /simple_frac_div_tb/pixel_offset
add wave -noupdate /simple_frac_div_tb/pos
add wave -noupdate /simple_frac_div_tb/test_completed
add wave -noupdate /simple_frac_div_tb/configuring
add wave -noupdate /simple_frac_div_tb/running
add wave -noupdate /simple_frac_div_tb/passed
add wave -noupdate /simple_frac_div_tb/failed
add wave -noupdate /simple_frac_div_tb/pTB_CTRL/delta_pos
add wave -noupdate /simple_frac_div_tb/pTB_CTRL/init_pos
add wave -noupdate /simple_frac_div_tb/pTB_CTRL/dir_m
add wave -noupdate /simple_frac_div_tb/pTB_CTRL/tot_steps
add wave -noupdate /simple_frac_div_tb/pTB_CTRL/result
add wave -noupdate /simple_frac_div_tb/pTB_CTRL/test_idx
add wave -noupdate /simple_frac_div_tb/iUUT/clk
add wave -noupdate /simple_frac_div_tb/iUUT/enable
add wave -noupdate /simple_frac_div_tb/iUUT/upd_max_pos
add wave -noupdate /simple_frac_div_tb/iUUT/upd_min_pos
add wave -noupdate -radix decimal /simple_frac_div_tb/iUUT/abs_pos_max
add wave -noupdate -radix decimal /simple_frac_div_tb/iUUT/abs_pos_min
add wave -noupdate /simple_frac_div_tb/iUUT/dir
add wave -noupdate -radix hexadecimal /simple_frac_div_tb/iUUT/offset
add wave -noupdate -radix hexadecimal /simple_frac_div_tb/iUUT/ratio
add wave -noupdate -radix decimal /simple_frac_div_tb/iUUT/abs_pos
add wave -noupdate /simple_frac_div_tb/iUUT/fire
add wave -noupdate -radix unsigned /simple_frac_div_tb/iUUT/fire_cnt
add wave -noupdate /simple_frac_div_tb/iUUT/enable_d
add wave -noupdate /simple_frac_div_tb/iUUT/start
add wave -noupdate /simple_frac_div_tb/iUUT/inc_pos
add wave -noupdate /simple_frac_div_tb/iUUT/dec_pos
add wave -noupdate /simple_frac_div_tb/iUUT/new_max
add wave -noupdate /simple_frac_div_tb/iUUT/new_min
add wave -noupdate /simple_frac_div_tb/iUUT/delta_wrap
add wave -noupdate -radix decimal /simple_frac_div_tb/iUUT/pos_diff
add wave -noupdate -radix decimal /simple_frac_div_tb/iUUT/pos_max
add wave -noupdate -radix decimal /simple_frac_div_tb/iUUT/pos_min
add wave -noupdate -radix decimal /simple_frac_div_tb/iUUT/dist_pos
add wave -noupdate -radix decimal /simple_frac_div_tb/iUUT/dist_neg
add wave -noupdate /simple_frac_div_tb/iUUT/update
add wave -noupdate -radix unsigned /simple_frac_div_tb/iUUT/fire_cnt_i
add wave -noupdate /simple_frac_div_tb/iUUT/zeros
add wave -noupdate -radix unsigned /simple_frac_div_tb/iUUT/delta_pos
add wave -noupdate -radix decimal /simple_frac_div_tb/iUUT/pos_diff
add wave -noupdate -radix unsigned /simple_frac_div_tb/iUUT/abs_pos_d
add wave -noupdate -radix unsigned /simple_frac_div_tb/iUUT/delta_pos_ext
add wave -noupdate -radix decimal /simple_frac_div_tb/iUUT/ideal_fire
add wave -noupdate -radix decimal /simple_frac_div_tb/iUUT/firing_error
TreeUpdate [SetDefaultTree]
WaveRestoreCursors {{Cursor 1} {212441 ps} 0}
quietly wave cursor active 1
configure wave -namecolwidth 266
configure wave -valuecolwidth 182
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 {333726927 ps} {334251215 ps}

View file

@ -0,0 +1,592 @@
-------------------------------------------------------------------------------
-- Title : pd_jitter_verify_tb
-- Project : EMB/SMB
-------------------------------------------------------------------------------
-- File : pd_jitter_verify_tb.vhd
-- Author : GMG
-- Company : Global Inkjet Systems
-- Created : 2018-09-11
-- Last update: 2018-12-19
-- SVN ID : Git
-- Standard : VHDL'2008
-------------------------------------------------------------------------------
-- Description:
-- Verify the PD jitter mechanism on the Pulse-Generator
-------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.math_real.all;
use work.log_pkg.all;
use work.avalon_verify_pkg.all;
use work.pulse_generator_1_pkg.all;
entity pd_jitter_verify_tb is
-- ..
end entity pd_jitter_verify_tb;
architecture behav of pd_jitter_verify_tb is
constant CLK_PERIOD : time := 10 ns;
-- Logging Verbosity Level
constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM;
-----------------------------------------------------------------------------
-- TB Functions / Procedures
-----------------------------------------------------------------------------
procedure wait_latency(
signal clk : in std_logic;
cycles : in natural) is
begin
for i in 1 to cycles loop
wait until clk = '1' and clk'event;
end loop; -- i
end procedure wait_latency;
-----------------------------------------------------------------------------
-- Signal declarations
-----------------------------------------------------------------------------
signal reset_n : std_logic := '0';
signal clk : std_logic := '0';
signal init : std_logic;
signal pd_in : std_logic;
signal abs_position : std_logic_vector(31 downto 0);
signal dp_dir : std_logic;
signal pulse_out : std_logic;
signal filtered_pd : std_logic;
signal ch_pd : std_logic;
signal ch_mask : std_logic;
signal raw_pulse_out : std_logic;
signal avs_address : std_logic_vector(9 downto 0);
signal avs_write : std_logic;
signal avs_writedata : std_logic_vector(31 downto 0);
signal avs_read : std_logic;
signal avs_readdatavalid : std_logic;
signal avs_readdata : std_logic_vector(31 downto 0);
--
signal avs_m : mm_m_rec_t;
signal avs_s : mm_s_rec_t;
--
signal pd_in_cnt : integer;
signal pd_out_cnt : integer;
--
signal test_completed : boolean;
signal setup : boolean;
signal running : boolean;
signal error_flag : boolean;
signal passed : boolean;
signal failed : boolean;
begin -- architecture behav
clk <= not clk after 0.5*CLK_PERIOD;
-----------------------------------------------------------------------------
-- UUT
-----------------------------------------------------------------------------
iUUT: entity work.pulse_generator_1
generic map (
pulse_delay_equal_en => true,
out_pulse_condition => true)
port map (
clk => clk,
reset_n => reset_n,
init => init,
pd_in => pd_in,
abs_position => abs_position,
dp_dir => dp_dir,
pulse_out => pulse_out,
filtered_pd => filtered_pd,
ch_pd => ch_pd,
ch_mask => ch_mask,
raw_pulse_out => raw_pulse_out,
avs_address => avs_address,
avs_write => avs_write,
avs_writedata => avs_writedata,
avs_read => avs_read,
avs_readdatavalid => avs_readdatavalid,
avs_readdata => avs_readdata);
-----------------------------------------------------------------------------
-- Avalon interface
-----------------------------------------------------------------------------
clk_clk <= clk;
reset_reset_n <= reset_n;
avs_s.mm_readdata <= avs_readdata;
avs_s.mm_readdatavalid <= avs_readdatavalid;
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;
pCNT_CH_PD : process(reset_n, clk)
begin
if(reset_n = '0') then
pd_out_cnt <= 0;
elsif(clk = '1' and clk'event) then
if(ch_pd = '1') then
pd_out_cnt <= pd_out_cnt + 1;
end if;
end if;
end process pCNT_CH_PD;
-----------------------------------------------------------------------------
-- Testbench Logic
-----------------------------------------------------------------------------
pTB_CTRL : process
alias dp_dir is <<signal iUUT.dp_dir_i : std_logic>>;
procedure issue_pd(valid_pd : boolean := true) is
begin
wait until clk = '1' and clk'event;
pd_in <= '1';
wait until clk = '1' and clk'event;
pd_in <= '0';
if(valid_pd = true) then
pd_in_cnt <= pd_in_cnt + 1;
end if;
end procedure issue_pd;
procedure check_pd is
begin
for i in 1 to 12 loop
wait until clk = '1' and clk'event;
end loop; -- i
if(pd_out_cnt /= pd_in_cnt) then
if(pd_out_cnt > pd_in_cnt) then
log("ERROR: Detected faulty Channel PD.", VLOW);
else
log("ERROR: Missing Channel PD.", VLOW);
end if;
error_flag <= true;
end if;
end procedure check_pd;
variable addr : std_logic_vector(31 downto 0) := (others => '0');
variable data : std_logic_vector(31 downto 0) := (others => '0');
begin
-- Set the verbosity level for logging
set_log_verbosity(VERBOSITY_LEVEL);
--set_log_verbosity(VHIGH);
-- initilialize the Avalon master-bus
mm_m_init(avs_m);
log_header("PD Jitter verification:", VLOW);
setup <= false;
running <= false;
passed <= false;
error_flag <= false;
init <= '0';
pd_in <= '0';
pd_in_cnt <= 0;
abs_position <= (others => '0');
-- Reset
reset_n <= '0';
wait for 100 ns;
wait until clk = '1' and clk'event;
reset_n <= '1';
wait for 200 ns;
-- enable the pulse generator
addr := std_logic_vector(resize(unsigned(PULSE_GEN_CTRL_REG), 32));
data := X"0000_0001";
mm_32b_write(addr, data, avs_s, avs_m);
---------------------------------------------------------------------------
-- DP-DIR = '0'
---------------------------------------------------------------------------
log("DP-DIR = '0'", VLOW);
log_separator_line(VLOW);
dp_dir <= force '0';
wait for 200 ns;
wait until clk = '1' and clk'event;
init <= '1';
wait until clk = '1' and clk'event;
wait until clk = '1' and clk'event;
wait until clk = '1' and clk'event;
init <= '0';
wait for 200 ns;
wait until clk = '1' and clk'event;
---------------------------------------------------------------------------
-- DIR-0, Init Pos = 0
---------------------------------------------------------------------------
log("Issueing PD on ABS_POS = 0", VLOW);
for n in 0 to 9 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
log("Go back to ABS_POS = 0", VLOW);
for n in 0 to 9 loop
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
log("Issueing again PD on ABS_POS = 0", VLOW);
for n in 0 to 9 loop
issue_pd(false);
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
for n in 0 to 9 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
wait for 1 us;
---------------------------------------------------------------------------
-- DIR-0, Init Pos = -10
---------------------------------------------------------------------------
log("Issueing PD DIR-0, on ABS_POS = -10", VLOW);
abs_position <= std_logic_vector(to_signed(-10,32));
wait_latency(clk, 3);
init <= '1';
wait_latency(clk, 2);
init <= '0';
wait_latency(clk, 10);
log("Issueing PD on ABS_POS = -10", VLOW);
for n in 0 to 9 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
log("Go back to ABS_POS = -10", VLOW);
for n in 0 to 9 loop
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
log("Issueing again PD on ABS_POS = -10", VLOW);
for n in 0 to 9 loop
issue_pd(false);
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
for n in 0 to 9 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
wait for 1 us;
---------------------------------------------------------------------------
-- DIR-0, Mid-crossing
---------------------------------------------------------------------------
log_separator_line(VLOW);
log("DP-DIR = '0', Mid-Crossing", VLOW);
log_separator_line(VLOW);
abs_position <= X"7FFFFFF8";
wait_latency(clk, 3);
init <= '1';
wait_latency(clk, 2);
init <= '0';
wait_latency(clk, 10);
log("Issueing PD on ABS_POS = 0x7FFFFFF8", VLOW);
for n in 0 to 15 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
log("Go back to ABS_POS = 0x7FFFFFF8", VLOW);
for n in 0 to 15 loop
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
log("Issueing again PD on ABS_POS = 0x7FFFFFF8", VLOW);
for n in 0 to 15 loop
issue_pd(false);
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
for n in 0 to 15 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
log("Performing a zero-crossing", VLOW);
wait_latency(clk, 10);
abs_position <= std_logic_vector(to_signed(-10,32));
wait_latency(clk, 10);
issue_pd;
for n in 0 to 19 loop
abs_position <= std_logic_vector(signed(abs_position)+ 1);
wait_latency(clk, 10);
end loop; -- n
issue_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
wait_latency(clk, 10);
abs_position <= X"7FFFFFF8";
log("Issueing a second set of PDs at ABS_POS = 0x7FFFFFF8", VLOW);
wait_latency(clk, 10);
for n in 0 to 15 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
wait for 1 us;
---------------------------------------------------------------------------
-- DP-DIR = '1'
---------------------------------------------------------------------------
log_separator_line(VLOW);
log("DP-DIR = '1'", VLOW);
log_separator_line(VLOW);
dp_dir <= force '1';
abs_position <= std_logic_vector(to_signed(0,32));
wait for 200 ns;
wait until clk = '1' and clk'event;
init <= '1';
wait until clk = '1' and clk'event;
wait until clk = '1' and clk'event;
wait until clk = '1' and clk'event;
init <= '0';
wait for 200 ns;
wait until clk = '1' and clk'event;
---------------------------------------------------------------------------
-- DIR-1, Init Pos = 0
---------------------------------------------------------------------------
log("Issueing PD on ABS_POS = 0", VLOW);
for n in 0 to 9 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
log("Go back to ABS_POS = 0", VLOW);
for n in 0 to 9 loop
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
log("Issueing again PD on ABS_POS = 0", VLOW);
for n in 0 to 9 loop
issue_pd(false);
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
for n in 0 to 9 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
wait for 1 us;
---------------------------------------------------------------------------
-- DIR-1, Init Pos = +10
---------------------------------------------------------------------------
abs_position <= std_logic_vector(to_signed(+10,32));
wait_latency(clk, 3);
init <= '1';
wait_latency(clk, 2);
init <= '0';
wait_latency(clk, 10);
log("Issueing PD on ABS_POS = +10", VLOW);
for n in 0 to 9 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
log("Go back to ABS_POS = +10", VLOW);
for n in 0 to 9 loop
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
log("Issueing again PD on ABS_POS = +10", VLOW);
for n in 0 to 9 loop
issue_pd(false);
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
for n in 0 to 9 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
wait for 1 us;
---------------------------------------------------------------------------
-- DIR-1, Mid-crossing
---------------------------------------------------------------------------
log_separator_line(VLOW);
log("DP-DIR = '1', Mid-Crossing", VLOW);
log_separator_line(VLOW);
abs_position <= X"80000008";
wait_latency(clk, 3);
init <= '1';
wait_latency(clk, 2);
init <= '0';
wait_latency(clk, 10);
log("Issueing PD on ABS_POS = 0x80000008", VLOW);
for n in 0 to 15 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
log("Go back to ABS_POS = 0x80000008", VLOW);
for n in 0 to 15 loop
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
log("Issueing again PD on ABS_POS = 0x80000008", VLOW);
for n in 0 to 15 loop
issue_pd(false);
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
for n in 0 to 15 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
log("Performing a zero-crossing", VLOW);
wait_latency(clk, 10);
abs_position <= std_logic_vector(to_signed(+10,32));
wait_latency(clk, 10);
issue_pd;
for n in 0 to 19 loop
abs_position <= std_logic_vector(signed(abs_position)- 1);
wait_latency(clk, 10);
end loop; -- n
issue_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
wait_latency(clk, 10);
abs_position <= X"80000008";
log("Issueing a second set of PDs at ABS_POS = 0x80000008", VLOW);
wait_latency(clk, 10);
for n in 0 to 15 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
wait for 20 us;
running <= false;
passed <= true after 100 ns;
wait;
end process pTB_CTRL;
failed <= error_flag after 100 ns;
pREPORT_RESULT : process
begin
wait until failed = true or passed = true;
wait for 1 us;
log_separator_line(VLOW);
if(failed = true) then
log("FAILURE: test completed with errors.", VLOW);
elsif(passed = true) then
log("SUCCESS: test successfully completed.", VLOW);
end if;
log_separator_line(VLOW);
test_completed <= true;
end process pREPORT_RESULT;
end architecture behav;

View file

@ -0,0 +1,501 @@
-------------------------------------------------------------------------------
-- Title : simple_frac_div_tb
-- Project : EMB/SMB
-------------------------------------------------------------------------------
-- File : simple_frac_div_tb.vhd
-- Author : GMG
-- Company : Global Inkjet Systems
-- Created : 2017-12-06
-- Last update: 2018-12-19
-- SVN ID : Git
-- Standard : VHDL'2008
-------------------------------------------------------------------------------
-- Description:
-- Testbench for the simple_frac_div.vhd
-------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.math_real.all;
library OSVVM;
use OSVVM.RandomBasePkg.all;
use OSVVM.RandomPkg.all;
use work.log_pkg.all;
entity simple_frac_div_tb is
-- ..
end entity simple_frac_div_tb;
architecture behav of simple_frac_div_tb is
constant CLK_PERIOD : time := 10 ns;
-- Logging Verbosity Level
constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM;
constant MAX_DIST : natural := 10000;
-- define the percentage of reverse steps, with respect to the intended
-- direction, while advancing the position:
-- 0 => no reverse movement at all
-- 20 => 20% of position increments are in the opposite dirtection
-- 49 => Essentially this is an oscillation around the centre position with a
-- tiny bias in the intended direction!
constant POS_RANDOM_PERC : natural range 0 to 49 := 0; -- define
constant INTRA_POS_LATENCY : natural := 3; -- number of clock cycles between position increments
-----------------------------------------------------------------------------
-- TB Functions / Procedures
-----------------------------------------------------------------------------
procedure wait_latency(
signal clk : in std_logic;
cycles : in natural) is
begin
for i in 1 to cycles loop
wait until clk = '1' and clk'event;
end loop; -- i
end procedure wait_latency;
-- convert the div_ratio to a fixed point integer with a 24 bits fractional part
function ratio_to_fixed_point (ratio : real) return std_logic_vector is
variable ratio_int : natural;
begin
ratio_int := integer(ratio*real(2**24));
return std_logic_vector(to_unsigned(ratio_int, 34));
end function ratio_to_fixed_point;
-- convert the sub-pixel offset to a fixed point integer with a 24 bits fractional part
function offset_to_fixed_point (off : real; ratio: real) return std_logic_vector is
variable offset_int : natural;
begin
offset_int := integer(off*ratio*real(2**24));
return std_logic_vector(to_unsigned(offset_int, 34));
end function offset_to_fixed_point;
function check_result(ratio : real; offset : real; delta_pos : integer; fire_cnt : integer; silent_mode : boolean := false) return boolean is
variable res : boolean;
variable exp_fire : integer;
begin
if(real(delta_pos) < ratio*offset) then
exp_fire := 0;
else
--exp_fire := integer(real(delta_pos)/ratio - offset+0.5);
exp_fire := integer((1.0 + real(delta_pos)/ratio - offset));
end if;
if(silent_mode = false) then
log("Check Result:",VMEDIUM);
log("ratio = " & to_string(ratio) & ", offset = " & to_string(offset) & ", delta_pos = " & to_string(delta_pos),VMEDIUM);
end if;
if(abs(exp_fire-fire_cnt) <= 1) then
res := true;
if(silent_mode = false) then
log("Check Result:",VMEDIUM);
log("ratio = " & to_string(ratio) & ", offset = " & to_string(offset) & ", delta_pos = " & to_string(delta_pos),VMEDIUM);
log("Expected Fire-Pulses = " & to_string(exp_fire) & ", detected = " & to_string(fire_cnt),VMEDIUM);
end if;
else
res := false;
log("Check Result:",VMEDIUM);
log("ratio = " & to_string(ratio) & ", offset = " & to_string(offset) & ", delta_pos = " & to_string(delta_pos),VMEDIUM);
log("ERROR: Expected Fire-Pulses = " & to_string(exp_fire) & ", detected = " & to_string(fire_cnt),VMEDIUM);
end if;
return res;
end function check_result;
-----------------------------------------------------------------------------
-- Signal declarations
-----------------------------------------------------------------------------
signal reset_n : std_logic := '0';
signal clk : std_logic := '0';
signal enable : std_logic;
signal upd_max_pos : std_logic;
signal upd_min_pos : std_logic;
signal abs_pos_max : std_logic_vector(31 downto 0);
signal abs_pos_min : std_logic_vector(31 downto 0);
signal dir : std_logic;
signal offset : std_logic_vector(33 downto 0);
signal ratio : std_logic_vector(33 downto 0);
signal abs_pos : std_logic_vector(31 downto 0);
signal fire : std_logic;
signal fire_cnt : std_logic_vector(31 downto 0);
--
signal div_ratio : real := 1.0;
signal pixel_offset : real := 0.0;
signal pos : integer := 0;
signal tot_fire_num : integer := 0;
--
signal test_completed : boolean;
signal configuring : boolean;
signal running : boolean;
signal passed : boolean;
signal failed : boolean;
begin -- architecture behav
clk <= not clk after 0.5*CLK_PERIOD;
-----------------------------------------------------------------------------
-- UUTs
-----------------------------------------------------------------------------
iUUT : entity work.simple_frac_div_1
port map (
clk => clk,
enable => enable,
dir => dir,
upd_max_pos => upd_max_pos,
upd_min_pos => upd_min_pos,
abs_pos_max => abs_pos_max,
abs_pos_min => abs_pos_min,
offset => offset,
ratio => ratio,
abs_pos => abs_pos,
fire => fire,
fire_cnt => fire_cnt);
ratio <= ratio_to_fixed_point(div_ratio);
offset <= offset_to_fixed_point(pixel_offset, div_ratio);
abs_pos <= std_logic_vector(to_signed(pos,32));
-----------------------------------------------------------------------------
-- Support Logic
-----------------------------------------------------------------------------
pSupport : process(clk)
begin
if(clk = '1' and clk'event) then
if(enable = '0') then
tot_fire_num <= 0;
elsif(fire = '1') then
tot_fire_num <= tot_fire_num +1;
end if;
end if;
end process pSupport;
-----------------------------------------------------------------------------
-- Testbench Logic
-----------------------------------------------------------------------------
pTB_CTRL : process
variable delta_pos : integer := 0;
variable init_pos : integer;
variable dir_m : integer;
variable tot_steps : integer;
variable result : boolean;
variable test_idx : natural;
variable rv : RandomPType;
procedure run_test is
variable steps : integer;
variable sel_dir : integer;
begin
log_header("Test-case " & to_string(test_idx), VMEDIUM);
wait_latency(clk, 1);
if dir = '0' then
dir_m := 1;
else
dir_m := -1;
end if;
init_pos := pos;
-- reset the absolute position memory
enable <= '0';
upd_max_pos <= '0';
upd_min_pos <= '0';
wait_latency(clk, 1);
upd_max_pos <= '1';
upd_min_pos <= '1';
wait_latency(clk, 1);
upd_max_pos <= '0';
upd_min_pos <= '0';
-- restart the divider
wait_latency(clk, 1);
enable <= '1';
wait_latency(clk, INTRA_POS_LATENCY);
-- run the steps
steps := 0;
loop_pos: while steps < tot_steps loop
wait_latency(clk, INTRA_POS_LATENCY);
/*
-- check the result and report
delta_pos := dir_m * (pos - init_pos);
result := check_result(div_ratio, pixel_offset, delta_pos, tot_fire_num, true);
exit loop_pos when result = false;
*/
sel_dir := rv.RandInt(1, 100);
if(sel_dir > POS_RANDOM_PERC) then
-- move in the intended direction
pos <= pos + dir_m;
steps := steps + 1;
else
-- move in the opposite direction
pos <= pos - dir_m;
steps := steps - 1;
end if;
end loop loop_pos;
-- wait the propagation of the latency
wait_latency(clk, INTRA_POS_LATENCY);
-- check the result and report
delta_pos := dir_m * (pos - init_pos);
if(result /= false) then
result := check_result(div_ratio, pixel_offset, delta_pos, tot_fire_num);
end if;
log("div_ratio = " & to_string(div_ratio), VMEDIUM);
end procedure run_test;
begin
-- Set the verbosity level for logging
set_log_verbosity(VERBOSITY_LEVEL);
--set_log_verbosity(VHIGH);
log_header("Fractional Divider verification:", VLOW);
test_completed <= false;
configuring <= false;
running <= false;
passed <= false;
failed <= false;
enable <= '0';
dir <= '1';
-- Reset
reset_n <= '0';
wait for 100 ns;
wait until clk = '1' and clk'event;
reset_n <= '1';
result := true;
test_idx := 0;
---------------------------------------------------------------------------
-- Test-00
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 4.000;
pixel_offset <= 0.0;
dir <= '0';
tot_steps := 100000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-01
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 1.001;
pixel_offset <= 0.0;
dir <= '0';
tot_steps := 10000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-02
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 1.002;
pixel_offset <= 0.9;
dir <= '1';
tot_steps := 10000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-03
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 1.333;
pixel_offset <= 1.5;
dir <= '0';
tot_steps := 10000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-04
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 4.008;
pixel_offset <= 0.25;
dir <= '0';
tot_steps := 10000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-05
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 4.000;
pixel_offset <= 0.0;
dir <= '0';
tot_steps := 10000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-06
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 4.000;
pixel_offset <= 0.25;
dir <= '0';
tot_steps := 10000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-07
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 4.000;
pixel_offset <= 0.5;
dir <= '0';
tot_steps := 10000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-08
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 4.000;
pixel_offset <= 0.75;
dir <= '0';
tot_steps := 10000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-09
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 4.000;
pixel_offset <= 1.0;
dir <= '0';
tot_steps := 10000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-10
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 4.000;
pixel_offset <= 0.12;
dir <= '0';
tot_steps := 10000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-11
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 4.000;
pixel_offset <= 0.13;
dir <= '0';
tot_steps := 10000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-12
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 126.0;
pixel_offset <= 0.99;
dir <= '0';
tot_steps := 10000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-13
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 126.0;
pixel_offset <= 0.0;
dir <= '0';
tot_steps := 10000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-14 - Very long test to check internal-reg-saturation
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 4.000;
pixel_offset <= 0.0;
dir <= '0';
tot_steps := 100000;
run_test;
end if;
---------------------------------------------------------------------------
-- Random Tests
---------------------------------------------------------------------------
for n in 1 to 20 loop
if(result /= false) then
test_idx := test_idx+1;
-- the div_ratio fractional part must be a multiple of 0.001
div_ratio <= 0.001*real(rv.RandInt(1000, 50000));
if((rv.RandInt(1,10) mod 2) = 0) then
dir <= '0';
else
dir <= '1';
end if;
tot_steps := rv.RandInt(5000, 20000);
run_test;
end if;
end loop; -- n
wait for 200 ns;
log_separator_line(VLOW);
if(result = false) then
failed <= true;
log("FAILURE: test completed with errors.", VLOW);
else
passed <= true;
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;