HMBFDHV-83 JSON file updated for minor version number. Test Bench now has a jittery TX clock to simulate real variations between source and destination

This commit is contained in:
Damian Smith 2019-03-15 13:38:09 +00:00
commit 69df190705
2 changed files with 377 additions and 291 deletions

View file

@ -36,7 +36,7 @@
"minor_number" : {
"type" : "c",
"bit_len" : "8",
"reset" : "0x00",
"reset" : "0x01",
"description" : "Minor number"
},
"major_number" : {

View file

@ -40,27 +40,30 @@ end fire_pulse_manager_1_tb;
architecture behav of fire_pulse_manager_1_tb is
constant CH_NUM : integer := 4;
constant DEV_NUM : integer := 2;
constant CLK_PERIOD : time := 10.0 ns;
constant CLK_FREQ : real := 100.0e6;
constant CH_NUM : integer := 4;
constant DEV_NUM : integer := 2;
constant RX_CLK_PERIOD : time := 5.0 ns; -- clock period for used by the
-- UART-Rx on the POF
constant POF_DELAY : time := 30 ns; -- Total delay from POF-Tx input to POF-Rx output
constant CLK_PERIOD : time := 10.0 ns;
constant CLK_FREQ : real := 100.0e6;
constant NUM_ITERATIONS : natural := 5;
constant SWATHE_LEN : integer := 600;
constant START_DIR : std_logic := '0';
constant TIME_INT : time := 5000 ns;
constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM;
constant TX_CLK_PERIOD : time := CLK_PERIOD; -- nominally the same as clk_period
type ch_offset_t is array (0 to CH_NUM-1) of integer;
constant RX_CLK_PERIOD : time := 5.0 ns; -- clock period for used by the
-- UART-Rx on the POF
constant POF_DELAY : time := 30 ns; -- Total delay from POF-Tx input to POF-Rx output
constant NUM_ITERATIONS : natural := 5;
constant SWATHE_LEN : integer := 600;
constant START_DIR : std_logic := '0';
constant TIME_INT : time := 5000 ns;
constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM;
type ch_offset_t is array (0 to CH_NUM - 1) of integer;
signal ch_offset : ch_offset_t := (100, 308, 316, 324);
type avs_read_bus_t is array (0 to DEV_NUM-1) of std_logic_vector(31 downto 0);
type avs_read_bus_t is array (0 to DEV_NUM - 1) of std_logic_vector(31 downto 0);
signal reset_n : std_logic := '0';
signal clk : std_logic := '0';
@ -68,11 +71,11 @@ architecture behav of fire_pulse_manager_1_tb is
signal pof_tx, pof_rx : std_logic;
signal ch_pulse_out : std_logic_vector(3 downto 0);
signal avs_address : std_logic_vector(14 downto 0);
signal avs_write : std_logic_vector(DEV_NUM-1 downto 0);
signal avs_write : std_logic_vector(DEV_NUM - 1 downto 0);
signal avs_writedata : std_logic_vector(31 downto 0);
signal avs_read : std_logic_vector(DEV_NUM-1 downto 0);
signal avs_readdatavalid : std_logic_vector(DEV_NUM-1 downto 0);
signal avs_readdata : avs_read_bus_t;
signal avs_read : std_logic_vector(DEV_NUM - 1 downto 0);
signal avs_readdatavalid : std_logic_vector(DEV_NUM - 1 downto 0);
signal avs_readdata : avs_read_bus_t;
--
signal init_tx : std_logic;
signal pd_in : std_logic;
@ -90,24 +93,24 @@ architecture behav of fire_pulse_manager_1_tb is
signal end_of_swathe : std_logic;
signal test_completed : boolean;
signal running : boolean;
signal configuring : boolean;
signal configuring : boolean;
signal passed : boolean;
signal failed : boolean;
signal stimuli_completed : boolean;
signal detected_error : boolean := false;
signal registers_read : boolean := false;
signal reprogram_offset : boolean := false;
signal detected_error : boolean := false;
signal registers_read : boolean := false;
signal reprogram_offset : boolean := false;
--
signal avs_m : mm_m_rec_t;
signal avs_s : mm_s_rec_t;
signal sel_slave_0 : std_logic;
signal sel_slave_1 : std_logic;
signal avs_m : mm_m_rec_t;
signal avs_s : mm_s_rec_t;
signal sel_slave_0 : std_logic;
signal sel_slave_1 : std_logic;
--
type pd_cnt_t is array(0 to CH_NUM-1) of integer;
signal pd_cnt : pd_cnt_t;
type fp_cnt_t is array(0 to CH_NUM-1) of integer;
signal fp_cnt : fp_cnt_t;
type pd_cnt_t is array (0 to CH_NUM - 1) of integer;
signal pd_cnt : pd_cnt_t;
type fp_cnt_t is array (0 to CH_NUM - 1) of integer;
signal fp_cnt : fp_cnt_t;
-- generate the NCO increment corresponding to a given output frequency
function freq2NCO_inc(
@ -115,35 +118,118 @@ architecture behav of fire_pulse_manager_1_tb is
variable nco_inc : std_logic_vector(31 downto 0);
begin
nco_inc := std_logic_vector(to_unsigned(integer((f_out/f_clk)*(2.0**32)),32));
nco_inc := std_logic_vector(to_unsigned(integer((f_out / f_clk) * (2.0**32)), 32));
return nco_inc;
end function freq2NCO_inc;
begin -- behav
signal tx_clk : std_logic;
begin -- behav
clk_pr : process
begin
clk <= '0';
wait for 0.5*CLK_PERIOD;
wait for 0.5 * CLK_PERIOD;
clk <= '1';
wait for 0.5*CLK_PERIOD;
wait for 0.5 * CLK_PERIOD;
end process clk_pr;
tx_clk_pr : process
variable rv : RandomPType;
begin
wait for 0.25 * TX_CLK_PERIOD;
-- offset tx_clk relative to rx_clk
while true loop
-- make tx_clk not quite stable relative to rx_clk
tx_clk <= '0';
wait for 0.5 * TX_CLK_PERIOD - 10 ps;
tx_clk <= '1';
wait for 0.5 * TX_CLK_PERIOD;
tx_clk <= '0';
wait for 0.5 * TX_CLK_PERIOD + 10 ps;
tx_clk <= '1';
wait for 0.5 * TX_CLK_PERIOD;
tx_clk <= '0';
wait for 0.5 * TX_CLK_PERIOD - 10 ps;
tx_clk <= '1';
wait for 0.5 * TX_CLK_PERIOD;
tx_clk <= '0';
wait for 0.5 * TX_CLK_PERIOD + 10 ps;
tx_clk <= '1';
wait for 0.5 * TX_CLK_PERIOD;
tx_clk <= '0';
wait for 0.5 * TX_CLK_PERIOD + 10 ps;
tx_clk <= '1';
wait for 0.5 * TX_CLK_PERIOD;
tx_clk <= '0';
wait for 0.5 * TX_CLK_PERIOD;
tx_clk <= '1';
wait for 0.5 * TX_CLK_PERIOD;
tx_clk <= '0';
wait for 0.5 * TX_CLK_PERIOD;
tx_clk <= '1';
wait for 0.5 * TX_CLK_PERIOD;
tx_clk <= '0';
wait for 0.5 * TX_CLK_PERIOD;
tx_clk <= '1';
wait for 0.5 * TX_CLK_PERIOD;
tx_clk <= '0';
wait for 0.5 * TX_CLK_PERIOD - 10 ps;
tx_clk <= '1';
wait for 0.5 * TX_CLK_PERIOD;
tx_clk <= '0';
wait for 0.5 * TX_CLK_PERIOD - 10 ps;
tx_clk <= '1';
wait for 0.5 * TX_CLK_PERIOD;
tx_clk <= '0';
wait for 0.5 * TX_CLK_PERIOD;
tx_clk <= '1';
wait for 0.5 * TX_CLK_PERIOD;
tx_clk <= '0';
wait for 0.5 * TX_CLK_PERIOD;
tx_clk <= '1';
wait for 0.5 * TX_CLK_PERIOD;
tx_clk <= '0';
wait for 0.5 * TX_CLK_PERIOD;
tx_clk <= '1';
wait for 0.5 * TX_CLK_PERIOD;
tx_clk <= '0';
wait for 0.5 * TX_CLK_PERIOD + 10 ps;
tx_clk <= '1';
wait for 0.5 * TX_CLK_PERIOD;
end loop;
end process tx_clk_pr;
rx_clk_pr : process
begin
rx_clk <= '0';
wait for 0.5*RX_CLK_PERIOD;
wait for 0.5 * RX_CLK_PERIOD;
rx_clk <= '1';
wait for 0.5*RX_CLK_PERIOD;
wait for 0.5 * RX_CLK_PERIOD;
end process rx_clk_pr;
-----------------------------------------------------------------------------
-- DUTs : Fire Pulse Manager
-----------------------------------------------------------------------------
iDUT : entity work.fire_pulse_manager_1
port map (
port map(
reset_n => reset_n,
clk => clk,
rx_clk => rx_clk,
@ -161,18 +247,18 @@ begin -- behav
avs_read => avs_read(0),
avs_readdatavalid => avs_readdatavalid(0),
avs_readdata => avs_readdata(0)
);
);
pof_rx <= transport tx_data after POF_DELAY;
-----------------------------------------------------------------------------
-- POF Tx
-----------------------------------------------------------------------------
iPOF_TX : entity work.pof_tx_1
port map (
port map(
reset_n => reset_n,
clk => clk,
clk => tx_clk,
init => init_tx,
pd_in => pd_in,
inc_pos => inc_pos,
@ -185,97 +271,97 @@ begin -- behav
avs_read => avs_read(1),
avs_readdatavalid => avs_readdatavalid(1),
avs_readdata => avs_readdata(1)
);
);
-----------------------------------------------------------------------------
-- Stimuli Generation
-----------------------------------------------------------------------------
pSTIMULI_REGs: process(clk)
pSTIMULI_REGs : process(clk)
begin
if(clk = '1' and clk'event) then
if (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';
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 end_of_stimuli : boolean;
variable rv : RandomPType;
variable end_of_stimuli : boolean;
variable rv : RandomPType;
begin
-- initialization
init_tx <= '0';
dir_in <= START_DIR;
pd_in <= '0';
abs_position <= (others => '0');
swathe_pos <= 0;
init_tx <= '0';
dir_in <= START_DIR;
pd_in <= '0';
abs_position <= (others => '0');
swathe_pos <= 0;
--
swathe_cnt <= 0;
swathe_cnt <= 0;
stimuli_completed <= false;
end_of_swathe <= '0';
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';
init_tx <= '1';
wait until clk = '1' and clk'event;
init_tx <= '0';
init_tx <= '0';
wait for 500 ns;
--
-- generate the forward swathe
end_of_stimuli := false;
while end_of_stimuli = false loop
swathe_pos <= 0;
for i in 0 to CH_NUM-1 loop
for i in 0 to CH_NUM - 1 loop
ch_offset(i) <= rv.RandInt(0, 379);
end loop;
reprogram_offset <= true;
wait until configuring = true;
reprogram_offset <= false;
wait until configuring = false;
wait until clk = '1' and clk'event;
while swathe_pos /= SWATHE_LEN loop
--generate a position increment
swathe_pos <= swathe_pos+1;
if(dir_in = '0') then
abs_position <= std_logic_vector(signed(abs_position)+1);
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);
abs_position <= std_logic_vector(signed(abs_position) - 1);
end if;
--
if (swathe_pos = 16) then
if (swathe_pos = 16) then
-- generate a PD increment: the PD might be either concurren or not
-- to the position increment
wait for 0.5*CLK_PERIOD;
wait for 0.5 * CLK_PERIOD;
pd_in <= '1';
wait for 100 ns;
wait until clk = '1' and clk'event;
pd_in <= '0';
end if;
wait for TIME_INT;
end loop; -- swathe_pos /= SWATHE_LEN
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-1) then
if (dir_in /= START_DIR) then
if (swathe_cnt = NUM_ITERATIONS - 1) then
end_of_stimuli := true;
else
swathe_cnt <= swathe_cnt +1;
swathe_cnt <= swathe_cnt + 1;
end if;
end if;
if(end_of_stimuli = false) then
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.
@ -284,12 +370,12 @@ begin -- behav
-- generated
wait for 1 us;
wait until clk = '1' and clk'event;
end if;
end loop; -- end_of_stimuli = false
end if;
end loop; -- end_of_stimuli = false
stimuli_completed <= true;
wait;
end process pSTIMULI;
-----------------------------------------------------------------------------
@ -297,18 +383,18 @@ begin -- behav
-----------------------------------------------------------------------------
pTB_CTRL : process
type fp_arrived_t is array(0 to CH_NUM-1) of boolean;
variable fp_arrived : fp_arrived_t;
type fp_arrived_time_t is array(0 to CH_NUM-1) of integer;
type fp_arrived_t is array (0 to CH_NUM - 1) of boolean;
variable fp_arrived : fp_arrived_t;
type fp_arrived_time_t is array (0 to CH_NUM - 1) of integer;
variable fp_arrived_time : fp_arrived_time_t;
variable fp_arrived_agg : integer;
variable pd_arrived_time : integer;
begin
-- init_signal_spy("/iDUT/abs_pos","abs_spy",0);
-- init_signal_spy("/iDUT/pd_pulse","pd_spy",0);
init_signal_spy("abs_position","abs_spy",0);
init_signal_spy("pd_in","pd_spy",0);
-- init_signal_spy("/iDUT/abs_pos","abs_spy",0);
-- init_signal_spy("/iDUT/pd_pulse","pd_spy",0);
init_signal_spy("abs_position", "abs_spy", 0);
init_signal_spy("pd_in", "pd_spy", 0);
-- Set the verbosity level for logging
set_log_verbosity(VERBOSITY_LEVEL);
@ -327,46 +413,46 @@ begin -- behav
wait until clk = '1' and clk'event;
reset_n <= '1';
if(configuring /= true) then
if (configuring /= true) then
wait until configuring = true;
end if;
wait until configuring = false;
running <= true;
log("Running test ... ",VLOW, true);
log("Running test ... ", VLOW, true);
while stimuli_completed = false loop
while stimuli_completed = false loop
wait until ((pd_spy = '1' and pd_spy'event) or stimuli_completed);
if (stimuli_completed) then
exit;
end if;
pd_arrived_time := to_integer(signed(abs_spy));
for i in 0 to CH_NUM-1 loop
fp_arrived(i) := false;
pd_arrived_time := to_integer(signed(abs_spy));
for i in 0 to CH_NUM - 1 loop
fp_arrived(i) := false;
fp_arrived_time(i) := 0;
end loop;
log("Product detect fired @ " & integer'image(pd_arrived_time) & " ... ",VLOW, true);
fp_arrived_agg := 0;
log("Product detect fired @ " & integer'image(pd_arrived_time) & " ... ", VLOW, true);
fp_arrived_agg := 0;
while fp_arrived_agg < CH_NUM loop
fp_arrived_agg := 0;
for i in 0 to CH_NUM-1 loop
for i in 0 to CH_NUM - 1 loop
if fp_arrived(i) = true then
fp_arrived_agg := fp_arrived_agg + 1;
end if;
end if;
end loop;
wait until (unsigned(ch_pulse_out) /= 0 or stimuli_completed);
if (stimuli_completed) then
if (stimuli_completed) then
exit;
end if;
for i in 0 to CH_NUM-1 loop
for i in 0 to CH_NUM - 1 loop
if ch_pulse_out(i) = '1' and fp_arrived(i) = false then
fp_arrived(i) := true;
fp_arrived_time(i) := to_integer(signed(abs_spy));
fp_arrived(i) := true;
fp_arrived_time(i) := to_integer(signed(abs_spy));
log("Channel CH" & integer'image(i) & " Fire pulse logged @ " & integer'image(fp_arrived_time(i)) & " ... ", VLOW, true);
if (abs(pd_arrived_time - fp_arrived_time(i)) /= ch_offset(i)) then
if (abs (pd_arrived_time - fp_arrived_time(i)) /= ch_offset(i)) then
log("Channel CH" & integer'image(i) & " OFFSET INCORRECT !!! ", VLOW, true);
detected_error <= true;
end if;
@ -375,7 +461,7 @@ begin -- behav
end loop;
end loop;
if(stimuli_completed = true) then
if (stimuli_completed = true) then
-- wait enough time to make sure that a max length package can be propagated
wait for 20 us;
end if;
@ -383,22 +469,22 @@ begin -- behav
if (registers_read = false) then
wait until registers_read = true;
end if;
-- Report PD and FP counter from pulse generator
for i in 0 to CH_NUM-1 loop
for i in 0 to CH_NUM - 1 loop
log("Channel CH" & integer'image(i) & " PDin counter value : " & integer'image(pd_cnt(i)) & " ... ", VLOW, true);
log("Channel CH" & integer'image(i) & " FPout counter value : " & integer'image(fp_cnt(i)) & " ... ", VLOW, true);
if (pd_cnt(i) /= (NUM_ITERATIONS)*2) then
if (pd_cnt(i) /= (NUM_ITERATIONS) * 2) then
detected_error <= true;
end if;
if (fp_cnt(i) /= (NUM_ITERATIONS)*2*100) then
if (fp_cnt(i) /= (NUM_ITERATIONS) * 2 * 100) then
detected_error <= true;
end if;
end loop;
wait until clk = '1' and clk'event;
if(detected_error = true) then
if (detected_error = true) then
failed <= true;
log("FAILURE: test completed with errors.", VLOW);
else
@ -407,16 +493,16 @@ begin -- behav
end if;
log_separator_line(VLOW);
test_completed <= true;
running <= false;
wait;
running <= false;
wait;
end process pTB_CTRL;
pUUT_CTRL : process
variable addr : std_logic_vector(31 downto 0) := (others => '0');
variable data : std_logic_vector(31 downto 0) := (others => '0');
variable ratio_int : integer;
variable ratio_slv : std_logic_vector(33 downto 0);
variable addr : std_logic_vector(31 downto 0) := (others => '0');
variable data : std_logic_vector(31 downto 0) := (others => '0');
variable ratio_int : integer;
variable ratio_slv : std_logic_vector(33 downto 0);
begin
sel_slave_0 <= '0';
@ -425,38 +511,38 @@ begin -- behav
-- initilialize the Avalon master-bus
mm_m_init(avs_m);
if(reset_n = '0') then
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 POFTX ... ",VLOW, true);
log("Configuring POFTX ... ", VLOW, true);
sel_slave_1 <= '1';
-- Config netfork_tx control registers:
-- enable the block
addr := std_logic_vector(to_unsigned(0, 32));
data := X"0000_0021";
addr := std_logic_vector(to_unsigned(0, 32));
data := X"0000_0021";
mm_32b_write(addr, data, avs_s, avs_m);
sel_slave_1 <= '0';
sel_slave_0 <= '1';
wait until clk = '1' and clk'event;
log("Configuring EMUL ... ",VLOW, true);
log("Configuring EMUL ... ", VLOW, true);
-- Configure Encoder NCO freq
addr := std_logic_vector(to_unsigned(6144+to_integer(unsigned(CSR_ENC_NCO_INC_ADDR)), 32));
addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_ENC_NCO_INC_ADDR)), 32));
data := freq2NCO_inc(200.0e3, CLK_FREQ);
-- Write the data to the register
mm_32b_write(addr, data, avs_s, avs_m);
-- Enable outputs
addr := std_logic_vector(to_unsigned(6144+to_integer(unsigned(CSR_OUT_ENABLE_ADDR)), 32));
addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_OUT_ENABLE_ADDR)), 32));
data := X"000000FF";
-- Write the data to the register
mm_32b_write(addr, data, avs_s, avs_m);
log("Configuring FPM ... ",VLOW, true);
mm_32b_write(addr, data, avs_s, avs_m);
log("Configuring FPM ... ", VLOW, true);
-- Config fire_pulse_manager control registers:
-- Enable the POF-Rx
addr := std_logic_vector(to_unsigned(3, 32));
@ -474,217 +560,217 @@ begin -- behav
-- Write the data to the register
mm_32b_write(addr, data, avs_s, avs_m);
config_pg_l : for i in 0 to CH_NUM-1 loop
-- Disable/Re-enable first the whole pulse_generator
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(PULSE_GEN_CTRL_REG)), 32));
data := (others => '0');
mm_32b_write(addr, data, avs_s, avs_m);
data := (0 => '1', 16 => '1', others => '0');
mm_32b_write(addr, data, avs_s, avs_m);
-- Disable/Re-enable the Channel Controller sequencer
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(CH_CTRL_CTRL_REG)), 32));
data := (others => '0');
mm_32b_write(addr, data, avs_s, avs_m);
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(CH_CTRL_CTRL_REG)), 32));
data := (0 => '1', others => '0');
mm_32b_write(addr, data, avs_s, avs_m);
-- set the sub-pixel offset
data := std_logic_vector(to_unsigned(0, 32));
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(SP_OFFSET_INT)), 32));
mm_32b_write(addr, data, avs_s, avs_m);
data := std_logic_vector(to_unsigned(0, 32));
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(SP_OFFSET_FRAC)), 32));
mm_32b_write(addr, data, avs_s, avs_m);
-- set the division ratio
ratio_int := integer(2.0*real(2**24));
ratio_slv := std_logic_vector(to_unsigned(ratio_int, 34));
-- Set the integer part of the div-ratio
data(31 downto 10) := (others => '0');
data( 9 downto 0) := ratio_slv(33 downto 24);
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(DIV_RATIO_INT)), 32));
mm_32b_write(addr, data, avs_s, avs_m);
-- Set the fractional part of the div-ratio
data(31 downto 24) := (others => '0');
data(23 downto 0) := ratio_slv(23 downto 0);
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(DIV_RATIO_FRAC)), 32));
mm_32b_write(addr, data, avs_s, avs_m);
-- Disable/Enable the fractional divider
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(FRAC_DIV_CTRL_REG)), 32));
data := (others => '0');
mm_32b_write(addr, data, avs_s, avs_m);
data := (0 => '1', others => '0');
mm_32b_write(addr, data, avs_s, avs_m);
-- Configure the Channel Offset (Both DIR_0 and DIR_1):
-- DIR_0
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(CH_OFFSET_D0_REG)), 32));
data := std_logic_vector(to_unsigned(ch_offset(i), 32));
mm_32b_write(addr, data, avs_s, avs_m);
-- DIR_1
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(CH_OFFSET_D1_REG)), 32));
data := std_logic_vector(to_unsigned(ch_offset(i), 32));
mm_32b_write(addr, data, avs_s, avs_m);
-- Configure the Channel Delay
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(CH_DELAY_REG)), 32));
data := std_logic_vector(to_unsigned(0, 32));
mm_32b_write(addr, data, avs_s, avs_m);
-- Fill Sequencer RAM with simple swathe DIR-0
-- 0x00, 0x30000000 – Reset the vector output value
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(SEQ_RAM_OFFSET)), 32));
data := X"30000000";
mm_32b_write(addr, data, avs_s, avs_m);
-- 0x01, 0x10000001 – Trigger Mask (PD trigger enabled)
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(SEQ_RAM_OFFSET)+1), 32));
data := X"10000001";
mm_32b_write(addr, data, avs_s, avs_m);
-- 0x02, 0x20000001 – Wait for a single PD event
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(SEQ_RAM_OFFSET)+2), 32));
data := X"20000001";
mm_32b_write(addr, data, avs_s, avs_m);
-- 0x03, 0x30006404 – Issue a request for starting the generation of 100 fire pulses (DIR-0)
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(SEQ_RAM_OFFSET)+3), 32));
data := X"30006404";
mm_32b_write(addr, data, avs_s, avs_m);
-- 0x04, 0x30006400 – De-assert the request bit (start_image_req)
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(SEQ_RAM_OFFSET)+4), 32));
data := X"30006400";
mm_32b_write(addr, data, avs_s, avs_m);
-- 0x05, 0x80000258 – Wait till POS END
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(SEQ_RAM_OFFSET)+5), 32));
data := X"80000258";
mm_32b_write(addr, data, avs_s, avs_m);
-- 0x06, 0xC0000000 – Jump to DIR-1
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(SEQ_RAM_OFFSET)+6), 32));
data := X"C0000010";
mm_32b_write(addr, data, avs_s, avs_m);
-- Fill Sequencer RAM with simple swathe DIR-1
-- 0x10, 0x30000000 – Reset the vector output value
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(SEQ_RAM_OFFSET)+16), 32));
data := X"30000001";
mm_32b_write(addr, data, avs_s, avs_m);
-- 0x11, 0x10000001 – Trigger Mask (PD trigger enabled)
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(SEQ_RAM_OFFSET)+17), 32));
data := X"10000001";
mm_32b_write(addr, data, avs_s, avs_m);
-- 0x12, 0x20000001 – Wait for a single PD event
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(SEQ_RAM_OFFSET)+18), 32));
data := X"20000001";
mm_32b_write(addr, data, avs_s, avs_m);
-- 0x13, 0x30006405 – Issue a request for starting the generation of 100 fire pulses (DIR-1)
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(SEQ_RAM_OFFSET)+19), 32));
data := X"30006405";
mm_32b_write(addr, data, avs_s, avs_m);
-- 0x14, 0x30006401 – De-assert the request bit (start_image_req)
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(SEQ_RAM_OFFSET)+20), 32));
data := X"30006401";
mm_32b_write(addr, data, avs_s, avs_m);
-- 0x15, 0x80000000 – Wait till POS START
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(SEQ_RAM_OFFSET)+21), 32));
data := X"80000000";
mm_32b_write(addr, data, avs_s, avs_m);
-- 0x16, 0xC0000000 – Jump to DIR-0
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(SEQ_RAM_OFFSET)+22), 32));
data := X"C0000000";
mm_32b_write(addr, data, avs_s, avs_m);
-- Start Sequencer
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(SEQ_CSR_OFFSET)+3), 32));
data := (0 => '1', others => '0');
mm_32b_write(addr, data, avs_s, avs_m);
config_pg_l : for i in 0 to CH_NUM - 1 loop
-- Disable/Re-enable first the whole pulse_generator
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(PULSE_GEN_CTRL_REG)), 32));
data := (others => '0');
mm_32b_write(addr, data, avs_s, avs_m);
data := (0 => '1', 16 => '1', others => '0');
mm_32b_write(addr, data, avs_s, avs_m);
-- Disable/Re-enable the Channel Controller sequencer
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(CH_CTRL_CTRL_REG)), 32));
data := (others => '0');
mm_32b_write(addr, data, avs_s, avs_m);
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(CH_CTRL_CTRL_REG)), 32));
data := (0 => '1', others => '0');
mm_32b_write(addr, data, avs_s, avs_m);
-- set the sub-pixel offset
data := std_logic_vector(to_unsigned(0, 32));
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SP_OFFSET_INT)), 32));
mm_32b_write(addr, data, avs_s, avs_m);
data := std_logic_vector(to_unsigned(0, 32));
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SP_OFFSET_FRAC)), 32));
mm_32b_write(addr, data, avs_s, avs_m);
-- set the division ratio
ratio_int := integer(2.0 * real(2**24));
ratio_slv := std_logic_vector(to_unsigned(ratio_int, 34));
-- Set the integer part of the div-ratio
data(31 downto 10) := (others => '0');
data(9 downto 0) := ratio_slv(33 downto 24);
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(DIV_RATIO_INT)), 32));
mm_32b_write(addr, data, avs_s, avs_m);
-- Set the fractional part of the div-ratio
data(31 downto 24) := (others => '0');
data(23 downto 0) := ratio_slv(23 downto 0);
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(DIV_RATIO_FRAC)), 32));
mm_32b_write(addr, data, avs_s, avs_m);
-- Disable/Enable the fractional divider
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(FRAC_DIV_CTRL_REG)), 32));
data := (others => '0');
mm_32b_write(addr, data, avs_s, avs_m);
data := (0 => '1', others => '0');
mm_32b_write(addr, data, avs_s, avs_m);
-- Configure the Channel Offset (Both DIR_0 and DIR_1):
-- DIR_0
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(CH_OFFSET_D0_REG)), 32));
data := std_logic_vector(to_unsigned(ch_offset(i), 32));
mm_32b_write(addr, data, avs_s, avs_m);
-- DIR_1
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(CH_OFFSET_D1_REG)), 32));
data := std_logic_vector(to_unsigned(ch_offset(i), 32));
mm_32b_write(addr, data, avs_s, avs_m);
-- Configure the Channel Delay
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(CH_DELAY_REG)), 32));
data := std_logic_vector(to_unsigned(0, 32));
mm_32b_write(addr, data, avs_s, avs_m);
-- Fill Sequencer RAM with simple swathe DIR-0
-- 0x00, 0x30000000 – Reset the vector output value
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET)), 32));
data := X"30000000";
mm_32b_write(addr, data, avs_s, avs_m);
-- 0x01, 0x10000001 – Trigger Mask (PD trigger enabled)
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 1), 32));
data := X"10000001";
mm_32b_write(addr, data, avs_s, avs_m);
-- 0x02, 0x20000001 – Wait for a single PD event
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 2), 32));
data := X"20000001";
mm_32b_write(addr, data, avs_s, avs_m);
-- 0x03, 0x30006404 – Issue a request for starting the generation of 100 fire pulses (DIR-0)
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 3), 32));
data := X"30006404";
mm_32b_write(addr, data, avs_s, avs_m);
-- 0x04, 0x30006400 – De-assert the request bit (start_image_req)
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 4), 32));
data := X"30006400";
mm_32b_write(addr, data, avs_s, avs_m);
-- 0x05, 0x80000258 – Wait till POS END
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 5), 32));
data := X"80000258";
mm_32b_write(addr, data, avs_s, avs_m);
-- 0x06, 0xC0000000 – Jump to DIR-1
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 6), 32));
data := X"C0000010";
mm_32b_write(addr, data, avs_s, avs_m);
-- Fill Sequencer RAM with simple swathe DIR-1
-- 0x10, 0x30000000 – Reset the vector output value
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 16), 32));
data := X"30000001";
mm_32b_write(addr, data, avs_s, avs_m);
-- 0x11, 0x10000001 – Trigger Mask (PD trigger enabled)
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 17), 32));
data := X"10000001";
mm_32b_write(addr, data, avs_s, avs_m);
-- 0x12, 0x20000001 – Wait for a single PD event
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 18), 32));
data := X"20000001";
mm_32b_write(addr, data, avs_s, avs_m);
-- 0x13, 0x30006405 – Issue a request for starting the generation of 100 fire pulses (DIR-1)
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 19), 32));
data := X"30006405";
mm_32b_write(addr, data, avs_s, avs_m);
-- 0x14, 0x30006401 – De-assert the request bit (start_image_req)
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 20), 32));
data := X"30006401";
mm_32b_write(addr, data, avs_s, avs_m);
-- 0x15, 0x80000000 – Wait till POS START
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 21), 32));
data := X"80000000";
mm_32b_write(addr, data, avs_s, avs_m);
-- 0x16, 0xC0000000 – Jump to DIR-0
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 22), 32));
data := X"C0000000";
mm_32b_write(addr, data, avs_s, avs_m);
-- Start Sequencer
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_CSR_OFFSET) + 3), 32));
data := (0 => '1', others => '0');
mm_32b_write(addr, data, avs_s, avs_m);
end loop config_pg_l;
-- Init the encoder NCO - Preset Abs-Pos
addr := std_logic_vector(to_unsigned(6144+to_integer(unsigned(CSR_ENC_CTRL_ADDR)), 32));
addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_ENC_CTRL_ADDR)), 32));
data := 32X"B";
-- Write the data to the register
mm_32b_write(addr, data, avs_s, avs_m);
log("Configuration completed.",VLOW, true);
log("Configuration completed.", VLOW, true);
configuring <= false;
while stimuli_completed = false loop
wait until reprogram_offset = true or stimuli_completed = true;
if (stimuli_completed) then
if (stimuli_completed) then
exit;
end if;
configuring <= true;
log("Reprogramming offset ... ",VLOW, true);
config_of_l : for i in 0 to CH_NUM-1 loop
-- Configure the Channel Offset (Both DIR_0 and DIR_1):
-- DIR_0
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(CH_OFFSET_D0_REG)), 32));
data := std_logic_vector(to_unsigned(ch_offset(i), 32));
mm_32b_write(addr, data, avs_s, avs_m);
-- DIR_1
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(CH_OFFSET_D1_REG)), 32));
data := std_logic_vector(to_unsigned(ch_offset(i), 32));
mm_32b_write(addr, data, avs_s, avs_m);
log("Reprogramming offset ... ", VLOW, true);
config_of_l : for i in 0 to CH_NUM - 1 loop
-- Configure the Channel Offset (Both DIR_0 and DIR_1):
-- DIR_0
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(CH_OFFSET_D0_REG)), 32));
data := std_logic_vector(to_unsigned(ch_offset(i), 32));
mm_32b_write(addr, data, avs_s, avs_m);
-- DIR_1
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(CH_OFFSET_D1_REG)), 32));
data := std_logic_vector(to_unsigned(ch_offset(i), 32));
mm_32b_write(addr, data, avs_s, avs_m);
end loop;
configuring <= false;
-- issue PD
addr := std_logic_vector(to_unsigned(6144+to_integer(unsigned(CSR_PD_CTRL_ADDR)), 32));
data := 32X"3";
addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_PD_CTRL_ADDR)), 32));
data := 32X"3";
-- Write the data to the register
mm_32b_write(addr, data, avs_s, avs_m);
if dir_in = '0' then
log("Running 600 steps in DIR-0 ...", VLOW);
addr := std_logic_vector(to_unsigned(6144+to_integer(unsigned(CSR_PULSE_NUM_ADDR)), 32));
addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_PULSE_NUM_ADDR)), 32));
data := 32X"258";
-- Write the data to the register
mm_32b_write(addr, data, avs_s, avs_m);
addr := std_logic_vector(to_unsigned(6144+to_integer(unsigned(CSR_ENC_CTRL_ADDR)), 32));
addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_ENC_CTRL_ADDR)), 32));
data := 32X"11";
-- Write the data to the register
mm_32b_write(addr, data, avs_s, avs_m);
addr := std_logic_vector(to_unsigned(6144+to_integer(unsigned(CSR_ENC_CTRL_ADDR)), 32));
addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_ENC_CTRL_ADDR)), 32));
data := 32X"31";
-- Write the data to the register
mm_32b_write(addr, data, avs_s, avs_m);
else
log("Running 600 steps in DIR-1 ...", VLOW);
addr := std_logic_vector(to_unsigned(6144+to_integer(unsigned(CSR_PULSE_NUM_ADDR)), 32));
addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_PULSE_NUM_ADDR)), 32));
data := 32X"258";
-- Write the data to the register
mm_32b_write(addr, data, avs_s, avs_m);
addr := std_logic_vector(to_unsigned(6144+to_integer(unsigned(CSR_ENC_CTRL_ADDR)), 32));
addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_ENC_CTRL_ADDR)), 32));
data := 32X"15";
-- Write the data to the register
mm_32b_write(addr, data, avs_s, avs_m);
addr := std_logic_vector(to_unsigned(6144+to_integer(unsigned(CSR_ENC_CTRL_ADDR)), 32));
addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_ENC_CTRL_ADDR)), 32));
data := 32X"35";
-- Write the data to the register
mm_32b_write(addr, data, avs_s, avs_m);
end if;
end loop;
-- Read PD and FP counter from pulse generator
for i in 0 to CH_NUM-1 loop
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(PD_IN_CNT_REG)), 32));
for i in 0 to CH_NUM - 1 loop
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(PD_IN_CNT_REG)), 32));
mm_32b_read(addr, data, avs_s, avs_m);
pd_cnt(i) <= to_integer(unsigned(data));
addr := std_logic_vector(to_unsigned(8192+(2048*i)+to_integer(unsigned(FIRE_REQ_CNT_REG)), 32));
addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(FIRE_REQ_CNT_REG)), 32));
mm_32b_read(addr, data, avs_s, avs_m);
fp_cnt(i) <= to_integer(unsigned(data));
end loop;
registers_read <= true;
wait;
end process pUUT_CTRL;
clk_clk <= clk;
reset_reset_n <= reset_n;
avs_s.mm_readdata <= avs_readdata(0) when sel_slave_0 = '1' else
avs_s.mm_readdata <= avs_readdata(0) when sel_slave_0 = '1' else
avs_readdata(1) when sel_slave_1 = '1' else (others => '0');
avs_s.mm_readdatavalid <= avs_readdatavalid(0) when sel_slave_0 = '1' else
avs_readdatavalid(1) when sel_slave_1 = '1' else '0';
avs_s.mm_waitrequest <= '0';
avs_s.use_readvalid <= true;
avs_s.mm_waitrequest <= '0';
avs_s.use_readvalid <= true;
avs_address <= avs_m.mm_address(avs_address'range);
avs_write(0) <= avs_m.mm_write and sel_slave_0;