SMB-187 - Encoder Multiplier - Committing before changing the divider block used for velocity estimation
This commit is contained in:
parent
88f4323270
commit
b0e0c24da7
8 changed files with 459 additions and 31 deletions
|
|
@ -116,5 +116,6 @@ def run_msim_script(sim_job, cmd_line_mode = 1):
|
|||
if __name__ == "__main__":
|
||||
|
||||
print("Running Generic-Sequencer testbench ...")
|
||||
run_msim_script("sim_enc_mult", cmd_line_mode=1)
|
||||
#run_msim_script("sim_enc_mult", cmd_line_mode=1)
|
||||
run_msim_script("sim_all", cmd_line_mode=1)
|
||||
|
||||
|
|
|
|||
14
generic_ip/encoder_multiply/0/sim/sim_all.do
Normal file
14
generic_ip/encoder_multiply/0/sim/sim_all.do
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Simulation macro
|
||||
|
||||
.main clear
|
||||
|
||||
do sim_speed_detect.do
|
||||
do sim_enc_mult.do 0
|
||||
do sim_enc_mult.do 1
|
||||
do sim_enc_mult.do 2
|
||||
do sim_enc_mult.do 3
|
||||
do sim_enc_mult.do 4
|
||||
do sim_enc_mult.do 5
|
||||
do sim_enc_mult.do 6
|
||||
do sim_enc_mult.do 7
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ add wave -noupdate /encoder_multiply_tb/iMULT/norm_pos
|
|||
add wave -noupdate /encoder_multiply_tb/iMULT/norm_pos_d
|
||||
add wave -noupdate /encoder_multiply_tb/iMULT/norm_neg
|
||||
add wave -noupdate /encoder_multiply_tb/iMULT/norm_neg_d
|
||||
add wave -noupdate -radix unsigned /encoder_multiply_tb/iMULT/mult_val
|
||||
#add wave -noupdate -radix unsigned /encoder_multiply_tb/iMULT/mult_val
|
||||
add wave -noupdate -radix decimal /encoder_multiply_tb/iMULT/pulse_cnt
|
||||
add wave -noupdate -radix decimal /encoder_multiply_tb/iMULT/m_pulse_cnt
|
||||
add wave -noupdate -radix unsigned /encoder_multiply_tb/iMULT/m_norm_value
|
||||
|
|
@ -102,7 +102,7 @@ add wave -noupdate /encoder_multiply_tb/iSPEED/data_valid
|
|||
add wave -noupdate /encoder_multiply_tb/iSPEED/step_cnt
|
||||
add wave -noupdate -radix unsigned /encoder_multiply_tb/iSPEED/first_addr
|
||||
add wave -noupdate -radix unsigned /encoder_multiply_tb/iSPEED/last_addr
|
||||
add wave -noupdate /encoder_multiply_tb/iSPEED/div_remain
|
||||
#add wave -noupdate /encoder_multiply_tb/iSPEED/div_remain
|
||||
add wave -noupdate -radix decimal /encoder_multiply_tb/iSPEED/step_balance
|
||||
add wave -noupdate -radix decimal /encoder_multiply_tb/iSPEED/step_bal_m1
|
||||
add wave -noupdate -radix unsigned /encoder_multiply_tb/iSPEED/loc_time
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@ add wave -noupdate /encoder_speed_detect_tb/step_pos_out
|
|||
add wave -noupdate /encoder_speed_detect_tb/step_neg_out
|
||||
add wave -noupdate /encoder_speed_detect_tb/delta_t_norm
|
||||
add wave -noupdate /encoder_speed_detect_tb/time_out_flag
|
||||
add wave -noupdate /encoder_speed_detect_tb/div_cpu_mode
|
||||
add wave -noupdate -radix unsigned /encoder_speed_detect_tb/cpu_dividend
|
||||
add wave -noupdate -radix unsigned /encoder_speed_detect_tb/cpu_divisor
|
||||
add wave -noupdate -radix unsigned /encoder_speed_detect_tb/cpu_quotient
|
||||
add wave -noupdate -radix decimal /encoder_speed_detect_tb/abs_pos
|
||||
add wave -noupdate /encoder_speed_detect_tb/setup
|
||||
add wave -noupdate /encoder_speed_detect_tb/running
|
||||
|
|
@ -34,6 +38,10 @@ add wave -noupdate -radix hexadecimal /encoder_speed_detect_tb/iUUT/delta_t
|
|||
add wave -noupdate /encoder_speed_detect_tb/iUUT/step_pos_out
|
||||
add wave -noupdate /encoder_speed_detect_tb/iUUT/step_neg_out
|
||||
add wave -noupdate /encoder_speed_detect_tb/iUUT/time_out_flag
|
||||
add wave -noupdate /encoder_speed_detect_tb/iUUT/div_cpu_mode
|
||||
add wave -noupdate -radix unsigned /encoder_speed_detect_tb/iUUT/cpu_dividend
|
||||
add wave -noupdate -radix unsigned /encoder_speed_detect_tb/iUUT/cpu_divisor
|
||||
add wave -noupdate -radix unsigned /encoder_speed_detect_tb/iUUT/cpu_quotient
|
||||
add wave -noupdate /encoder_speed_detect_tb/iUUT/new_step
|
||||
add wave -noupdate /encoder_speed_detect_tb/iUUT/data_valid
|
||||
add wave -noupdate /encoder_speed_detect_tb/iUUT/step_type
|
||||
|
|
@ -57,16 +65,13 @@ add wave -noupdate -radix unsigned /encoder_speed_detect_tb/iUUT/last_addr
|
|||
add wave -noupdate -radix unsigned /encoder_speed_detect_tb/iUUT/loc_time
|
||||
add wave -noupdate -radix unsigned /encoder_speed_detect_tb/iUUT/time_diff_i
|
||||
add wave -noupdate -radix unsigned /encoder_speed_detect_tb/iUUT/delta_t_i
|
||||
add wave -noupdate -radix unsigned /encoder_speed_detect_tb/iUUT/delta_t_ii
|
||||
add wave -noupdate -radix unsigned /encoder_speed_detect_tb/iUUT/delta_t_iii
|
||||
add wave -noupdate /encoder_speed_detect_tb/iUUT/div_done
|
||||
add wave -noupdate -radix decimal /encoder_speed_detect_tb/iUUT/time_diff
|
||||
add wave -noupdate -radix unsigned /encoder_speed_detect_tb/iUUT/tag_last_i
|
||||
add wave -noupdate -radix hexadecimal /encoder_speed_detect_tb/iUUT/new_tag
|
||||
add wave -noupdate -radix hexadecimal /encoder_speed_detect_tb/iUUT/tag_first
|
||||
add wave -noupdate -radix hexadecimal /encoder_speed_detect_tb/iUUT/tag_last
|
||||
TreeUpdate [SetDefaultTree]
|
||||
WaveRestoreCursors {{Cursor 1} {20565000 ps} 0}
|
||||
WaveRestoreCursors {{Cursor 1} {21545000 ps} 0}
|
||||
quietly wave cursor active 1
|
||||
configure wave -namecolwidth 330
|
||||
configure wave -valuecolwidth 145
|
||||
|
|
@ -82,4 +87,4 @@ configure wave -griddelta 40
|
|||
configure wave -timeline 0
|
||||
configure wave -timelineunits ps
|
||||
update
|
||||
WaveRestoreZoom {0 ps} {1907949568 ps}
|
||||
WaveRestoreZoom {363272911 ps} {2271222479 ps}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
-- Author : Gianmarco Girau
|
||||
-- Company : Global Inkjet Systems
|
||||
-- Created : 2019-02-27
|
||||
-- Last update: 2019-03-22
|
||||
-- Last update: 2019-03-27
|
||||
-- SVN ID : Git
|
||||
-- Standard : VHDL'2008
|
||||
-------------------------------------------------------------------------------
|
||||
|
|
@ -40,7 +40,7 @@ entity encoder_speed_detect_0 is
|
|||
clk : in std_logic;
|
||||
init : in std_logic;
|
||||
enable : in std_logic;
|
||||
avg_steps : in std_logic_vector( 7 downto 0);
|
||||
avg_steps : in std_logic_vector( 6 downto 0);
|
||||
delta_init : in std_logic_vector(27 downto 0);
|
||||
time_out : in std_logic_vector(27 downto 0);
|
||||
step_pos : in std_logic;
|
||||
|
|
@ -48,7 +48,11 @@ entity encoder_speed_detect_0 is
|
|||
delta_t : out std_logic_vector(39 downto 0);
|
||||
step_pos_out : out std_logic;
|
||||
step_neg_out : out std_logic;
|
||||
time_out_flag : out std_logic);
|
||||
time_out_flag : out std_logic;
|
||||
div_cpu_mode : in std_logic;
|
||||
cpu_dividend : in std_logic_vector(30 downto 0);
|
||||
cpu_divisor : in std_logic_vector( 5 downto 0);
|
||||
cpu_quotient : out std_logic_vector(30 downto 0));
|
||||
end encoder_speed_detect_0;
|
||||
|
||||
architecture rtl of encoder_speed_detect_0 is
|
||||
|
|
@ -60,12 +64,16 @@ architecture rtl of encoder_speed_detect_0 is
|
|||
|
||||
attribute altera_attribute : string;
|
||||
attribute altera_attribute of rtl : architecture is
|
||||
"-name SDC_STATEMENT ""set_multicycle_path -from {*iDIVIDE|lpm_divide*} -to {*iDIVIDE|lpm_divide*} -setup 4 -end""; " &
|
||||
"-name SDC_STATEMENT ""set_multicycle_path -from {*iDIVIDE|lpm_divide*} -to {*:iVEL_MEAS|delta_t[*]*} -setup 4 -end""; " &
|
||||
"-name SDC_STATEMENT ""set_multicycle_path -from {*iVEL_MEAS|step_bal_m1[*]} -to {*iDIVIDE|lpm_divide*} -setup -end 4""; " &
|
||||
"-name SDC_STATEMENT ""set_multicycle_path -from {*iVEL_MEAS|time_diff_i[*]} -to {*iDIVIDE|lpm_divide*} -setup -end 4""; " &
|
||||
"-name SDC_STATEMENT ""set_multicycle_path -from {*iDIVIDE|lpm_divide*} -to {*:iVEL_MEAS|delta_t[*]*} -hold -end 3""; " &
|
||||
"-name SDC_STATEMENT ""set_multicycle_path -from {*iVEL_MEAS|step_bal_m1[*]} -to {*iDIVIDE|lpm_divide*} -hold -end 3""; " &
|
||||
"-name SDC_STATEMENT ""set_multicycle_path -from {*iVEL_MEAS|time_diff_i[*]} -to {*iDIVIDE|lpm_divide*} -hold -end 3""";
|
||||
"-name SDC_STATEMENT ""set_multicycle_path -from {*iDIVIDE|lpm_divide*} -to {*:iVEL_MEAS|cpu_quotient[*]*} -setup 4 -end""; " &
|
||||
"-name SDC_STATEMENT ""set_multicycle_path -from {*iVEL_MEAS|step_bal_m1[*]} -to {*iDIVIDE|lpm_divide*} -setup 4 -end""; " &
|
||||
"-name SDC_STATEMENT ""set_multicycle_path -from {*iVEL_MEAS|time_diff_i[*]} -to {*iDIVIDE|lpm_divide*} -setup 4 -end""; " &
|
||||
"-name SDC_STATEMENT ""set_multicycle_path -from {*iDIVIDE|lpm_divide*} -to {*iDIVIDE|lpm_divide*} -hold 3 -end""; " &
|
||||
"-name SDC_STATEMENT ""set_multicycle_path -from {*iDIVIDE|lpm_divide*} -to {*:iVEL_MEAS|delta_t[*]*} -hold 3 -end""; " &
|
||||
"-name SDC_STATEMENT ""set_multicycle_path -from {*iDIVIDE|lpm_divide*} -to {*:iVEL_MEAS|cpu_quotient[*]*} -hold 3 -end""; " &
|
||||
"-name SDC_STATEMENT ""set_multicycle_path -from {*iVEL_MEAS|step_bal_m1[*]} -to {*iDIVIDE|lpm_divide*} -hold 3 -end""; " &
|
||||
"-name SDC_STATEMENT ""set_multicycle_path -from {*iVEL_MEAS|time_diff_i[*]} -to {*iDIVIDE|lpm_divide*} -hold 3 -end""";
|
||||
|
||||
signal step_type, step_pos_i, step_neg_i : std_logic;
|
||||
signal inc_last, inc_first, avg_transient_on : std_logic;
|
||||
|
|
@ -74,14 +82,14 @@ architecture rtl of encoder_speed_detect_0 is
|
|||
signal inc_step_cnt, write_last : std_logic;
|
||||
signal first_step, time_out_flag_d : std_logic;
|
||||
signal last_step_type, enforce_delta_min : std_logic;
|
||||
--signal div_done : std_logic;
|
||||
--
|
||||
signal div_cpu_mode_v : std_logic_vector(DIV_MULTICYCLE_PATH_N*(DIV_PIPE_STAGES+1) downto 0);
|
||||
signal data_valid : std_logic_vector(DIV_MULTICYCLE_PATH_N*(DIV_PIPE_STAGES+1)+2 downto 0);
|
||||
signal step_cnt, first_addr, last_addr : std_logic_vector( 7 downto 0);
|
||||
signal step_balance, step_bal_m1 : std_logic_vector( 9 downto 0);
|
||||
signal step_cnt, step_bal_m1, step_balance : std_logic_vector( 6 downto 0);
|
||||
signal first_addr, last_addr : std_logic_vector( 7 downto 0);
|
||||
signal loc_time, time_out_cnt : std_logic_vector(27 downto 0);
|
||||
signal time_diff : std_logic_vector(29 downto 0);
|
||||
signal time_diff_i, delta_t_i, delta_t_ii : std_logic_vector(30 downto 0);
|
||||
signal time_diff_i, delta_t_i : std_logic_vector(30 downto 0);
|
||||
signal new_tag, tag_last_i : std_logic_vector(31 downto 0);
|
||||
signal tag_first, tag_last : std_logic_vector(31 downto 0);
|
||||
|
||||
|
|
@ -153,7 +161,17 @@ begin
|
|||
else
|
||||
step_bal_m1 <= std_logic_vector(-signed(step_balance)-1);
|
||||
end if;
|
||||
elsif(div_cpu_mode = '1') then
|
||||
step_bal_m1 <= '0' & cpu_divisor;
|
||||
end if;
|
||||
if(data_valid(2) = '1') then
|
||||
time_diff_i <= std_logic_vector(resize(unsigned(time_diff),31));
|
||||
elsif(div_cpu_mode = '1') then
|
||||
time_diff_i <= cpu_dividend;
|
||||
end if;
|
||||
div_cpu_mode_v <= div_cpu_mode_v(div_cpu_mode_v'left-1 downto 0) & div_cpu_mode;
|
||||
if(div_cpu_mode_v(div_cpu_mode_v'left) = '1') then
|
||||
cpu_quotient <= delta_t_i;
|
||||
end if;
|
||||
if(init = '1' or new_step = '1') then
|
||||
time_out_cnt <= time_out;
|
||||
|
|
@ -181,8 +199,6 @@ begin
|
|||
end if;
|
||||
end process pSEQ_LOGIC;
|
||||
|
||||
delta_t_i <= delta_t_ii;
|
||||
|
||||
time_out_flag_i <= '1' when unsigned(time_out_cnt) = 1 else '0';
|
||||
|
||||
time_out_flag <= time_out_flag_d;
|
||||
|
|
@ -230,7 +246,7 @@ begin
|
|||
clock => clk,
|
||||
denom => step_bal_m1(5 downto 0),
|
||||
numer => time_diff_i,
|
||||
quotient => delta_t_ii,
|
||||
quotient => delta_t_i,
|
||||
remain => open);
|
||||
|
||||
end architecture rtl;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
-- Author : GMG
|
||||
-- Company : Global Inkjet Systems
|
||||
-- Created : 2019-03-05
|
||||
-- Last update: 2019-03-20
|
||||
-- Last update: 2019-03-26
|
||||
-- SVN ID : Git
|
||||
-- Standard : VHDL'2008
|
||||
-------------------------------------------------------------------------------
|
||||
|
|
@ -69,10 +69,14 @@ architecture behav of encoder_multiply_tb is
|
|||
signal mult_sel : std_logic_vector(2 downto 0);
|
||||
signal delta_t : std_logic_vector(39 downto 0);
|
||||
signal delta_t_i : std_logic_vector(39 downto 0);
|
||||
signal avg_steps : std_logic_vector( 7 downto 0);
|
||||
signal avg_steps : std_logic_vector( 6 downto 0);
|
||||
signal delta_init : std_logic_vector(27 downto 0);
|
||||
signal time_out : std_logic_vector(27 downto 0);
|
||||
signal time_out_flag : std_logic;
|
||||
signal div_cpu_mode : std_logic;
|
||||
signal cpu_dividend : std_logic_vector(30 downto 0);
|
||||
signal cpu_divisor : std_logic_vector( 5 downto 0);
|
||||
signal cpu_quotient : std_logic_vector(30 downto 0);
|
||||
signal step_pos : std_logic;
|
||||
signal step_neg : std_logic;
|
||||
signal step_pos_in : std_logic;
|
||||
|
|
@ -337,7 +341,11 @@ begin -- architecture behav
|
|||
delta_t => delta_t_i,
|
||||
step_pos_out => step_pos,
|
||||
step_neg_out => step_neg,
|
||||
time_out_flag => time_out_flag);
|
||||
time_out_flag => time_out_flag,
|
||||
div_cpu_mode => div_cpu_mode,
|
||||
cpu_dividend => cpu_dividend,
|
||||
cpu_divisor => cpu_divisor,
|
||||
cpu_quotient => cpu_quotient);
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Support Logic
|
||||
|
|
@ -385,11 +393,15 @@ begin -- architecture behav
|
|||
enable <= '0';
|
||||
mult_sel <= (others => '0');
|
||||
|
||||
avg_steps <= std_logic_vector(to_unsigned(FILT_AVG,8));
|
||||
avg_steps <= std_logic_vector(to_unsigned(FILT_AVG,7));
|
||||
delta_init <= std_logic_vector(to_unsigned(maximum(DELTA_TMIN,2*MULT_VALUE), delta_init'length));
|
||||
--
|
||||
time_out <= std_logic_vector(to_unsigned(6000, time_out'length));
|
||||
|
||||
div_cpu_mode <= '0';
|
||||
cpu_dividend <= (others => '0');
|
||||
cpu_divisor <= (others => '0');
|
||||
|
||||
delta_t <= (others => '0');
|
||||
step_pos_in <= '0';
|
||||
step_neg_in <= '0';
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
-- Author : GMG
|
||||
-- Company : Global Inkjet Systems
|
||||
-- Created : 2019-03-05
|
||||
-- Last update: 2019-03-22
|
||||
-- Last update: 2019-03-26
|
||||
-- SVN ID : Git
|
||||
-- Standard : VHDL'2008
|
||||
-------------------------------------------------------------------------------
|
||||
|
|
@ -62,7 +62,7 @@ architecture behav of encoder_speed_detect_tb is
|
|||
signal clk : std_logic := '0';
|
||||
signal init : std_logic;
|
||||
signal enable : std_logic;
|
||||
signal avg_steps : std_logic_vector( 7 downto 0);
|
||||
signal avg_steps : std_logic_vector( 6 downto 0);
|
||||
signal delta_init : std_logic_vector(27 downto 0);
|
||||
signal time_out : std_logic_vector(27 downto 0);
|
||||
signal step_pos : std_logic;
|
||||
|
|
@ -71,6 +71,10 @@ architecture behav of encoder_speed_detect_tb is
|
|||
signal step_pos_out : std_logic;
|
||||
signal step_neg_out : std_logic;
|
||||
signal time_out_flag : std_logic;
|
||||
signal div_cpu_mode : std_logic;
|
||||
signal cpu_dividend : std_logic_vector(30 downto 0);
|
||||
signal cpu_divisor : std_logic_vector( 5 downto 0);
|
||||
signal cpu_quotient : std_logic_vector(30 downto 0);
|
||||
--
|
||||
signal abs_pos : std_logic_vector(31 downto 0);
|
||||
signal delta_t_norm : integer;
|
||||
|
|
@ -272,7 +276,11 @@ begin -- architecture behav
|
|||
delta_t => delta_t,
|
||||
step_pos_out => step_pos_out,
|
||||
step_neg_out => step_neg_out,
|
||||
time_out_flag => time_out_flag);
|
||||
time_out_flag => time_out_flag,
|
||||
div_cpu_mode => div_cpu_mode,
|
||||
cpu_dividend => cpu_dividend,
|
||||
cpu_divisor => cpu_divisor,
|
||||
cpu_quotient => cpu_quotient);
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Support Logic
|
||||
|
|
@ -313,13 +321,17 @@ begin -- architecture behav
|
|||
init <= '0';
|
||||
enable <= '0';
|
||||
|
||||
avg_steps <= std_logic_vector(to_unsigned(FILT_AVG,8));
|
||||
avg_steps <= std_logic_vector(to_unsigned(FILT_AVG,7));
|
||||
delta_init <= std_logic_vector(to_unsigned(DELTA_TMIN, delta_init'length));
|
||||
--
|
||||
time_out <= std_logic_vector(to_unsigned(6000, time_out'length));
|
||||
|
||||
step_pos <= '0';
|
||||
step_neg <= '0';
|
||||
|
||||
div_cpu_mode <= '0';
|
||||
cpu_dividend <= (others => '0');
|
||||
cpu_divisor <= (others => '0');
|
||||
|
||||
setup <= false;
|
||||
running <= false;
|
||||
|
|
@ -341,6 +353,67 @@ begin -- architecture behav
|
|||
---------------------------------------------------------------------------
|
||||
|
||||
running <= true;
|
||||
|
||||
log_separator_line(VLOW);
|
||||
log("Parallel Divider Verification ...", VLOW);
|
||||
log_separator_line(VLOW);
|
||||
|
||||
wait_clk_cycles(10);
|
||||
cpu_dividend <= std_logic_vector(to_unsigned(100,31));
|
||||
cpu_divisor <= std_logic_vector(to_unsigned(1,6));
|
||||
div_cpu_mode <= '1';
|
||||
wait_clk_cycles(1);
|
||||
div_cpu_mode <= '0';
|
||||
wait_clk_cycles(10);
|
||||
if(unsigned(cpu_quotient) /= 100) then
|
||||
log("ERROR: while executing cpu-division", VLOW);
|
||||
error_flag := true;
|
||||
wait for 10 us;
|
||||
end if;
|
||||
|
||||
wait_clk_cycles(10);
|
||||
cpu_dividend <= std_logic_vector(to_unsigned(100,31));
|
||||
cpu_divisor <= std_logic_vector(to_unsigned(2,6));
|
||||
div_cpu_mode <= '1';
|
||||
wait_clk_cycles(1);
|
||||
div_cpu_mode <= '0';
|
||||
wait_clk_cycles(10);
|
||||
if(unsigned(cpu_quotient) /= 50) then
|
||||
log("ERROR: while executing cpu-division", VLOW);
|
||||
error_flag := true;
|
||||
wait for 10 us;
|
||||
end if;
|
||||
|
||||
wait_clk_cycles(10);
|
||||
cpu_dividend <= std_logic_vector(to_unsigned(100,31));
|
||||
cpu_divisor <= std_logic_vector(to_unsigned(5,6));
|
||||
div_cpu_mode <= '1';
|
||||
wait_clk_cycles(1);
|
||||
div_cpu_mode <= '0';
|
||||
wait_clk_cycles(10);
|
||||
if(unsigned(cpu_quotient) /= 20) then
|
||||
log("ERROR: while executing cpu-division", VLOW);
|
||||
error_flag := true;
|
||||
wait for 10 us;
|
||||
end if;
|
||||
|
||||
wait_clk_cycles(10);
|
||||
cpu_dividend <= std_logic_vector(to_unsigned(100,31));
|
||||
cpu_divisor <= std_logic_vector(to_unsigned(10,6));
|
||||
div_cpu_mode <= '1';
|
||||
wait_clk_cycles(1);
|
||||
div_cpu_mode <= '0';
|
||||
wait_clk_cycles(10);
|
||||
if(unsigned(cpu_quotient) /= 10) then
|
||||
log("ERROR: while executing cpu-division", VLOW);
|
||||
error_flag := true;
|
||||
wait for 10 us;
|
||||
end if;
|
||||
|
||||
log("Completed.", VLOW);
|
||||
wait_clk_cycles(10);
|
||||
|
||||
|
||||
log_separator_line(VLOW);
|
||||
log("Encoder-Speed-Detection verification:", VLOW);
|
||||
log_separator_line(VLOW);
|
||||
|
|
|
|||
307
generic_ip/pulse_generator/1/src/test/spitting_verify_tb.vhd
Normal file
307
generic_ip/pulse_generator/1/src/test/spitting_verify_tb.vhd
Normal file
|
|
@ -0,0 +1,307 @@
|
|||
-------------------------------------------------------------------------------
|
||||
-- Title : spitting_verify_tb
|
||||
-- Project : Pulse-Generator
|
||||
-------------------------------------------------------------------------------
|
||||
-- File : spitting_verify_tb.vhd
|
||||
-- Author : GMG
|
||||
-- Company : Global Inkjet Systems
|
||||
-- Created : 2018-09-11
|
||||
-- Last update: 2019-04-04
|
||||
-- SVN ID : Git
|
||||
-- Standard : VHDL'2008
|
||||
-------------------------------------------------------------------------------
|
||||
-- Description:
|
||||
-- Verify the spitting logic in 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 spitting_verify_tb is
|
||||
-- ..
|
||||
end entity spitting_verify_tb;
|
||||
|
||||
architecture behav of spitting_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;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue