From d087dc4845cd35cdba3f35aed69ffa3df67a82c9 Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Tue, 2 Apr 2019 16:52:14 +0100 Subject: [PATCH 01/29] ELGIP-45 - Modified the set of instructions leading to an update of the trigger selection register --- .../generic_sequencer/15/doc/generic_sequencer_15.json | 2 +- .../generic_sequencer/15/src/generic_sequencer_15.vhd | 8 ++++---- .../15/src/test/generic_sequencer_15_tb.vhd | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/generic_ip/generic_sequencer/15/doc/generic_sequencer_15.json b/generic_ip/generic_sequencer/15/doc/generic_sequencer_15.json index ddd5298..c49a131 100644 --- a/generic_ip/generic_sequencer/15/doc/generic_sequencer_15.json +++ b/generic_ip/generic_sequencer/15/doc/generic_sequencer_15.json @@ -37,7 +37,7 @@ "minor_number" : { "type" : "c", "bit_len" : "8", - "reset" : "0x11", + "reset" : "0x12", "description" : "Minor number" }, "major_number" : { diff --git a/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd b/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd index 0b82676..535c0e6 100644 --- a/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd +++ b/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd @@ -6,14 +6,14 @@ -- Author : Robbie Temple (original) -- Company : Global Inkjet Systems -- Created : 2016-05-12 --- Last update: 2019-03-05 +-- Last update: 2019-04-02 -- SVN ID : Git -- Standard : VHDL'2008 ------------------------------------------------------------------------------- -- Description: -- Generic Sequencer core ------------------------------------------------------------------------------- --- altera vhdl_input_version vhdl_2008 + library ieee; use ieee.std_logic_1164.all; @@ -74,7 +74,7 @@ architecture rtl of generic_sequencer_15 is ----------------------------------------------------------------------------- constant CSR_IP_ID : std_logic_vector(31 downto 0) := x"0000FF01"; - constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000F11"; + constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000F12"; type fsm_t is (s_idle, s_init, s_fetch, s_decode, -- @@ -494,7 +494,7 @@ begin end if; end process pFSM_CL; - ld_trig_sel <= '1' when decode = '1' and opcode /= CMD_JUMP else '0'; + ld_trig_sel <= '1' when decode = '1' and (opcode = CMD_TRIG_WAIT or opcode = CMD_VEC_RAMP_UP or opcode = CMD_VEC_RAMP_DN) else '0'; -- pSEQ_REGs : process(reset_n, clk) diff --git a/generic_ip/generic_sequencer/15/src/test/generic_sequencer_15_tb.vhd b/generic_ip/generic_sequencer/15/src/test/generic_sequencer_15_tb.vhd index c4d77dd..8c8ddcd 100644 --- a/generic_ip/generic_sequencer/15/src/test/generic_sequencer_15_tb.vhd +++ b/generic_ip/generic_sequencer/15/src/test/generic_sequencer_15_tb.vhd @@ -27,7 +27,7 @@ architecture behav of generic_sequencer_15_tb is constant QUEUE_EN : boolean := true; constant CSR_IP_ID : std_logic_vector(31 downto 0) := x"0000FF01"; - constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000F11"; + constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000F12"; constant CLK_PERIOD : time := 10 ns; From 8ff74295134639c079a056a696ef364bcd2f93e0 Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Wed, 3 Apr 2019 10:36:11 +0100 Subject: [PATCH 02/29] ELGIP-46 ELGIP-6 - Fixed the corresponding bugs --- .../generic_sequencer/15/sim/wave_gen_seq.do | 8 +- .../15/src/dpram_sclk_15.vhd | 74 ------------------- .../15/src/generic_sequencer_15.vhd | 20 ++--- .../15/src/test/generic_sequencer_15_tb.vhd | 74 +++++++++++++++---- 4 files changed, 74 insertions(+), 102 deletions(-) delete mode 100644 generic_ip/generic_sequencer/15/src/dpram_sclk_15.vhd diff --git a/generic_ip/generic_sequencer/15/sim/wave_gen_seq.do b/generic_ip/generic_sequencer/15/sim/wave_gen_seq.do index adf4996..fb47da3 100644 --- a/generic_ip/generic_sequencer/15/sim/wave_gen_seq.do +++ b/generic_ip/generic_sequencer/15/sim/wave_gen_seq.do @@ -64,6 +64,9 @@ add wave -noupdate -radix hexadecimal /generic_sequencer_15_tb/iUUT/operand_1 add wave -noupdate -radix hexadecimal /generic_sequencer_15_tb/iUUT/operand_2 add wave -noupdate -radix hexadecimal /generic_sequencer_15_tb/iUUT/operand_comp add wave -noupdate -radix hexadecimal /generic_sequencer_15_tb/iUUT/subcode +add wave -noupdate /generic_sequencer_15_tb/iUUT/alu_upd +add wave -noupdate -radix hexadecimal /generic_sequencer_15_tb/iUUT/r1 +add wave -noupdate /generic_sequencer_15_tb/iUUT/flag add wave -noupdate /generic_sequencer_15_tb/iUUT/inc_ram_addr add wave -noupdate -radix hexadecimal /generic_sequencer_15_tb/iUUT/jump_addr_ext add wave -noupdate -radix hexadecimal /generic_sequencer_15_tb/iUUT/jump_addr @@ -86,14 +89,11 @@ add wave -noupdate -radix decimal /generic_sequencer_15_tb/iUUT/queue_add add wave -noupdate -radix decimal /generic_sequencer_15_tb/iUUT/queue_add_i add wave -noupdate -radix unsigned /generic_sequencer_15_tb/iUUT/queue_left add wave -noupdate -radix unsigned /generic_sequencer_15_tb/iUUT/queue_exec -add wave -noupdate /generic_sequencer_15_tb/iUUT/alu_upd add wave -noupdate /generic_sequencer_15_tb/iUUT/jump_r1 add wave -noupdate /generic_sequencer_15_tb/iUUT/loop_active add wave -noupdate /generic_sequencer_15_tb/iUUT/loop_upd add wave -noupdate /generic_sequencer_15_tb/iUUT/loop_done add wave -noupdate -radix unsigned /generic_sequencer_15_tb/iUUT/loop_cnt -add wave -noupdate -radix hexadecimal /generic_sequencer_15_tb/iUUT/r1 -add wave -noupdate /generic_sequencer_15_tb/iUUT/flag add wave -noupdate /generic_sequencer_15_tb/iUUT/ld_trig_mask add wave -noupdate /generic_sequencer_15_tb/iUUT/ld_trig_sel add wave -noupdate -radix hexadecimal /generic_sequencer_15_tb/iUUT/trig_mask @@ -133,7 +133,7 @@ add wave -noupdate /generic_sequencer_15_tb/iUUT/ld_start_addr add wave -noupdate /generic_sequencer_15_tb/iUUT/ld_pos add wave -noupdate /generic_sequencer_15_tb/iUUT/flag TreeUpdate [SetDefaultTree] -WaveRestoreCursors {{Cursor 1} {27385000 ps} 0} +WaveRestoreCursors {{Cursor 1} {16785000 ps} 0} quietly wave cursor active 1 configure wave -namecolwidth 283 configure wave -valuecolwidth 194 diff --git a/generic_ip/generic_sequencer/15/src/dpram_sclk_15.vhd b/generic_ip/generic_sequencer/15/src/dpram_sclk_15.vhd deleted file mode 100644 index 41de48f..0000000 --- a/generic_ip/generic_sequencer/15/src/dpram_sclk_15.vhd +++ /dev/null @@ -1,74 +0,0 @@ -------------------------------------------------------------------------------- --- Title : dpram_sclk --- Project : Dual-Port, single clock RAM -------------------------------------------------------------------------------- --- File : dpram_sclk.vhd --- Author : GMG --- Company : Global Inkjet Systems --- Created : 2018-04-24 --- Last update: 2018-04-24 --- SVN ID : Git --- Standard : VHDL'2008 -------------------------------------------------------------------------------- --- Description: --- True Dual-Port, single clock RAM -------------------------------------------------------------------------------- - -library ieee; -use ieee.std_logic_1164.all; -use ieee.numeric_std.all; - -use work.common_pkg.all; - -entity dpram_sclk_15 is - generic( - WIDTH : natural := 32; - DEPTH : natural := 256); - port( - clk : in std_logic; - -- Port-A - addr_a : in std_logic_vector(log2(DEPTH)-1 downto 0); - we_a : in std_logic := '1'; - data_a : in std_logic_vector(WIDTH-1 downto 0); - q_a : out std_logic_vector(WIDTH-1 downto 0); - -- Port-B - addr_b : in std_logic_vector(log2(DEPTH)-1 downto 0); - we_b : in std_logic := '1'; - data_b : in std_logic_vector(WIDTH-1 downto 0); - q_b : out std_logic_vector(WIDTH-1 downto 0)); -end dpram_sclk_15; - -architecture rtl of dpram_sclk_15 is - - -- Build a 2-D array type for the RAM - subtype word_t is std_logic_vector(WIDTH-1 downto 0); - type memory_t is array(DEPTH-1 downto 0) of word_t; - - -- Declare the RAM - shared variable ram : memory_t; - -begin - - -- Port A - pPORT_A : process(clk) - begin - if(clk = '1' and clk'event) then - if(we_a = '1') then - ram(to_integer(unsigned(addr_a))) := data_a; - end if; - q_a <= ram(to_integer(unsigned(addr_a))); - end if; - end process pPORT_A; - - -- Port B - pPORT_B : process(clk) - begin - if(clk = '1' and clk'event) then - if(we_b = '1') then - ram(to_integer(unsigned(addr_b))) := data_b; - end if; - q_b <= ram(to_integer(unsigned(addr_b))); - end if; - end process pPORT_B; - -end rtl; diff --git a/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd b/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd index 535c0e6..5d30387 100644 --- a/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd +++ b/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd @@ -6,7 +6,7 @@ -- Author : Robbie Temple (original) -- Company : Global Inkjet Systems -- Created : 2016-05-12 --- Last update: 2019-04-02 +-- Last update: 2019-04-03 -- SVN ID : Git -- Standard : VHDL'2008 ------------------------------------------------------------------------------- @@ -585,8 +585,8 @@ begin ld_jmp_addr <= '1' when decode = '1' and (jump_abs = '1' or jump_rel = '1' or jump_r1 = '1') else '0'; - jump_abs <= '1' when (opcode = CMD_JUMP and (subcode = X"0" or (subcode = X"1" and flag = '0') or (subcode = X"2" and flag = '1'))) or (opcode = CMD_END and subcode = X"1") else '0'; - jump_rel <= '1' when (opcode = CMD_BRANCH and (subcode = X"0" or (subcode = X"1" and flag = '0') or (subcode = X"2" and flag = '1'))) or (opcode = CMD_LOOP and loop_done = '0') or (opcode = CMD_END and subcode = X"2") else '0'; + jump_abs <= '1' when (opcode = CMD_JUMP and (subcode = X"0" or (subcode = X"1" and flag = '1') or (subcode = X"2" and flag = '0'))) or (opcode = CMD_END and subcode = X"1") else '0'; + jump_rel <= '1' when (opcode = CMD_BRANCH and (subcode = X"0" or (subcode = X"1" and flag = '1') or (subcode = X"2" and flag = '0'))) or (opcode = CMD_LOOP and loop_done = '0') or (opcode = CMD_END and subcode = X"2") else '0'; jump_r1 <= '1' when opcode = CMD_JUMP and subcode = X"F" else '0'; save_ret_addr <= ld_jmp_addr; @@ -686,6 +686,7 @@ begin gALU_GEN: if ALU_EN = true generate pALU_REGs : process(clk) + variable r1_next : std_logic_vector(11 downto 0); begin if(clk = '1' and clk'event) then -- Update ALU register R1 @@ -694,13 +695,14 @@ begin elsif(alu_upd = '1') then case subcode is when x"2" => - r1 <= operand_1; + r1_next := operand_1; when x"3" => - r1 <= std_logic_vector(signed(r1) + signed(operand_1)); + r1_next := std_logic_vector(signed(r1) + signed(operand_1)); when x"4" => - r1 <= std_logic_vector(signed(r1) - signed(operand_1)); + r1_next := std_logic_vector(signed(r1) - signed(operand_1)); when others => null; end case; + r1 <= r1_next; end if; -- Update ALU flag if(alu_upd = '1') then @@ -711,14 +713,14 @@ begin else flag <= '0'; end if; - when x"1" | x"3" | x"4" => + when x"1"=> if(r1 = operand_1) then flag <= '1'; else flag <= '0'; end if; - when x"2" => - if(unsigned(operand_1) = 0) then + when x"2" | x"3" | x"4" => + if(signed(r1_next) = 0) then flag <= '1'; else flag <= '0'; diff --git a/generic_ip/generic_sequencer/15/src/test/generic_sequencer_15_tb.vhd b/generic_ip/generic_sequencer/15/src/test/generic_sequencer_15_tb.vhd index 8c8ddcd..6f629a2 100644 --- a/generic_ip/generic_sequencer/15/src/test/generic_sequencer_15_tb.vhd +++ b/generic_ip/generic_sequencer/15/src/test/generic_sequencer_15_tb.vhd @@ -255,32 +255,32 @@ begin mm_32b_write(x"00000090", x"1000000F", seq_mm_s_rec, seq_mm_m_rec); -- TRIG_MASK mm_32b_write(x"00000091", x"30000000", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET mm_32b_write(x"00000092", x"20000001", seq_mm_s_rec, seq_mm_m_rec); -- TRIG_WAIT - mm_32b_write(x"00000093", x"A000000F", seq_mm_s_rec, seq_mm_m_rec); -- ALU - mm_32b_write(x"00000094", x"C2000090", seq_mm_s_rec, seq_mm_m_rec); -- JUMP (meant to fail) + mm_32b_write(x"00000093", x"A000000C", seq_mm_s_rec, seq_mm_m_rec); -- ALU + mm_32b_write(x"00000094", x"C1000090", seq_mm_s_rec, seq_mm_m_rec); -- JUMP (meant to fail) mm_32b_write(x"00000095", x"30000001", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET mm_32b_write(x"00000096", x"A000000F", seq_mm_s_rec, seq_mm_m_rec); -- ALU - mm_32b_write(x"00000097", x"C20000E0", seq_mm_s_rec, seq_mm_m_rec); -- JUMP + mm_32b_write(x"00000097", x"C10000E0", seq_mm_s_rec, seq_mm_m_rec); -- JUMP mm_32b_write(x"00000098", x"30000002", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET mm_32b_write(x"00000099", x"A20000A5", seq_mm_s_rec, seq_mm_m_rec); -- ALU mm_32b_write(x"0000009A", x"A100005A", seq_mm_s_rec, seq_mm_m_rec); -- ALU - mm_32b_write(x"0000009B", x"C2000090", seq_mm_s_rec, seq_mm_m_rec); -- JUMP (meant to fail) + mm_32b_write(x"0000009B", x"C1000090", seq_mm_s_rec, seq_mm_m_rec); -- JUMP (meant to fail) mm_32b_write(x"0000009C", x"30000003", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET mm_32b_write(x"0000009D", x"A10000A5", seq_mm_s_rec, seq_mm_m_rec); -- ALU - mm_32b_write(x"0000009E", x"C20000E2", seq_mm_s_rec, seq_mm_m_rec); -- JUMP + mm_32b_write(x"0000009E", x"C10000E2", seq_mm_s_rec, seq_mm_m_rec); -- JUMP mm_32b_write(x"0000009F", x"30000004", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET mm_32b_write(x"000000A0", x"A3000001", seq_mm_s_rec, seq_mm_m_rec); -- ALU mm_32b_write(x"000000A1", x"A10000A5", seq_mm_s_rec, seq_mm_m_rec); -- ALU - mm_32b_write(x"000000A2", x"C10000E2", seq_mm_s_rec, seq_mm_m_rec); -- JUMP + mm_32b_write(x"000000A2", x"C20000E2", seq_mm_s_rec, seq_mm_m_rec); -- JUMP mm_32b_write(x"000000A3", x"30000005", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET mm_32b_write(x"000000A4", x"A10000A6", seq_mm_s_rec, seq_mm_m_rec); -- ALU - mm_32b_write(x"000000A5", x"C20000E2", seq_mm_s_rec, seq_mm_m_rec); -- JUMP + mm_32b_write(x"000000A5", x"C10000E2", seq_mm_s_rec, seq_mm_m_rec); -- JUMP mm_32b_write(x"000000A6", x"30000006", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET mm_32b_write(x"000000A7", x"A4000002", seq_mm_s_rec, seq_mm_m_rec); -- ALU mm_32b_write(x"000000A8", x"A10000A5", seq_mm_s_rec, seq_mm_m_rec); -- ALU - mm_32b_write(x"000000A9", x"C10000E2", seq_mm_s_rec, seq_mm_m_rec); -- JUMP + mm_32b_write(x"000000A9", x"C20000E2", seq_mm_s_rec, seq_mm_m_rec); -- JUMP mm_32b_write(x"000000AA", x"30000007", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET mm_32b_write(x"000000AB", x"A10000A4", seq_mm_s_rec, seq_mm_m_rec); -- ALU - mm_32b_write(x"000000AC", x"C20000E2", seq_mm_s_rec, seq_mm_m_rec); -- JUMP + mm_32b_write(x"000000AC", x"C10000E2", seq_mm_s_rec, seq_mm_m_rec); -- JUMP mm_32b_write(x"000000AD", x"30000008", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET mm_32b_write(x"000000AE", x"A20000E2", seq_mm_s_rec, seq_mm_m_rec); -- ALU mm_32b_write(x"000000AF", x"CF000000", seq_mm_s_rec, seq_mm_m_rec); -- JUMP @@ -296,18 +296,18 @@ begin mm_32b_write(x"000000C1", x"30000000", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET mm_32b_write(x"000000C2", x"20000001", seq_mm_s_rec, seq_mm_m_rec); -- TRIG_WAIT mm_32b_write(x"000000C3", x"D0000002", seq_mm_s_rec, seq_mm_m_rec); -- BRANCH - mm_32b_write(x"000000C4", x"C00000B0", seq_mm_s_rec, seq_mm_m_rec); -- JUMP (to not be executed) + mm_32b_write(x"000000C4", x"C00000C0", seq_mm_s_rec, seq_mm_m_rec); -- JUMP (to not be executed) mm_32b_write(x"000000C5", x"30000001", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET mm_32b_write(x"000000C6", x"A2000055", seq_mm_s_rec, seq_mm_m_rec); -- ALU mm_32b_write(x"000000C7", x"A10000AA", seq_mm_s_rec, seq_mm_m_rec); -- ALU - mm_32b_write(x"000000C8", x"D1000002", seq_mm_s_rec, seq_mm_m_rec); -- BRANCH - mm_32b_write(x"000000C9", x"C00000B0", seq_mm_s_rec, seq_mm_m_rec); -- JUMP (to not be executed) + mm_32b_write(x"000000C8", x"D2000002", seq_mm_s_rec, seq_mm_m_rec); -- BRANCH + mm_32b_write(x"000000C9", x"C00000C0", seq_mm_s_rec, seq_mm_m_rec); -- JUMP (to not be executed) mm_32b_write(x"000000CA", x"30000002", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET mm_32b_write(x"000000CB", x"A1000055", seq_mm_s_rec, seq_mm_m_rec); -- ALU - mm_32b_write(x"000000CC", x"D1000FF4", seq_mm_s_rec, seq_mm_m_rec); -- BRANCH (to not be executed) + mm_32b_write(x"000000CC", x"D2000FF4", seq_mm_s_rec, seq_mm_m_rec); -- BRANCH (to not be executed) mm_32b_write(x"000000CD", x"30000003", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET - mm_32b_write(x"000000CE", x"D2000002", seq_mm_s_rec, seq_mm_m_rec); -- BRANCH - mm_32b_write(x"000000CF", x"C00000B0", seq_mm_s_rec, seq_mm_m_rec); -- JUMP (to not be executed) + mm_32b_write(x"000000CE", x"D1000002", seq_mm_s_rec, seq_mm_m_rec); -- BRANCH + mm_32b_write(x"000000CF", x"C00000C0", seq_mm_s_rec, seq_mm_m_rec); -- JUMP (to not be executed) mm_32b_write(x"000000D0", x"30000004", seq_mm_s_rec, seq_mm_m_rec); -- BRANCH mm_32b_write(x"000000D1", x"F0000000", seq_mm_s_rec, seq_mm_m_rec); -- END @@ -359,6 +359,19 @@ begin mm_32b_write(x"00000140", x"20000001", seq_mm_s_rec, seq_mm_m_rec); -- TRIG_WAIT mm_32b_write(x"00000141", x"30000B00", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET mm_32b_write(x"00000142", x"F1000131", seq_mm_s_rec, seq_mm_m_rec); -- END_AND_QUEUE-(JUMP to ox131) + + -- BRANCH, ALU (2): Check Zero Flag update on ALU ADD/SUB + mm_32b_write(x"00000150", x"30000000", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000151", x"A2000000", seq_mm_s_rec, seq_mm_m_rec); -- MOV R1, Op1 + mm_32b_write(x"00000152", x"A3000001", seq_mm_s_rec, seq_mm_m_rec); -- ADD R1,R1, OP1 + mm_32b_write(x"00000153", x"D2000002", seq_mm_s_rec, seq_mm_m_rec); -- BRANCH PC+2 IF FLAG/=0 + mm_32b_write(x"00000154", x"C0000000", seq_mm_s_rec, seq_mm_m_rec); -- JUMP (to not be executed) + mm_32b_write(x"00000155", x"30000003", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000156", x"A4000001", seq_mm_s_rec, seq_mm_m_rec); -- SUB R1,R1, OP1 + mm_32b_write(x"00000157", x"D1000002", seq_mm_s_rec, seq_mm_m_rec); -- BRANCH PC+2 IF FLAG=0 + mm_32b_write(x"00000158", x"C0000000", seq_mm_s_rec, seq_mm_m_rec); -- JUMP (to not be executed) + mm_32b_write(x"00000159", x"30000007", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"0000015A", x"F0000000", seq_mm_s_rec, seq_mm_m_rec); -- END -- @@ -1219,6 +1232,37 @@ begin log("Completed.", VLOW); + wait_clk_cycles(10); + + --------------------------------------------------------------------------- + -- BRANCH/ALU Test (2) + --------------------------------------------------------------------------- + + wait_clk_cycles(20); + + log_separator_line(VLOW); + log("Verifying BRANCH, ALU instructions (2) ...", VLOW); + + -- Issue a start request + trigger_in <= (others => '0'); + wait until clk = '1' and clk'event; + start_addr <= std_logic_vector(to_unsigned((16+5)*16, log2(SEQ_DEPTH))); + start_req <= '1'; + wait until clk = '1' and clk'event; + start_req <= '0'; + + -- Issue a trigger event at the time + + check_vector(7, 24x"0"); + check_vector(vect_out_lat+6, 24x"3"); + check_vector(vect_out_lat+6, 24x"7"); + + if(busy /= '0') then + wait until busy = '0'; + end if; + + log("Completed.", VLOW); + wait_clk_cycles(10); --------------------------------------------------------------------------- From b9500b28ea6b141f04dcdcbb09250bcbbf0cb3d9 Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Fri, 5 Apr 2019 10:20:04 +0100 Subject: [PATCH 03/29] ELGIP-47 - Fixed issue with Bus Burst instruction --- .../generic_sequencer/15/sim/wave_gen_seq.do | 2 +- .../15/src/generic_sequencer_15.vhd | 19 +++---- .../15/src/test/generic_sequencer_15_tb.vhd | 52 +++++++++++-------- 3 files changed, 42 insertions(+), 31 deletions(-) diff --git a/generic_ip/generic_sequencer/15/sim/wave_gen_seq.do b/generic_ip/generic_sequencer/15/sim/wave_gen_seq.do index fb47da3..94318de 100644 --- a/generic_ip/generic_sequencer/15/sim/wave_gen_seq.do +++ b/generic_ip/generic_sequencer/15/sim/wave_gen_seq.do @@ -111,9 +111,9 @@ add wave -noupdate /generic_sequencer_15_tb/iUUT/clr_vec_ii add wave -noupdate /generic_sequencer_15_tb/iUUT/op_cnt add wave -noupdate /generic_sequencer_15_tb/iUUT/op_cnt_done add wave -noupdate /generic_sequencer_15_tb/iUUT/inc_op_cnt -add wave -noupdate /generic_sequencer_15_tb/iUUT/bus_ack add wave -noupdate -radix hexadecimal /generic_sequencer_15_tb/iUUT/bus_data add wave -noupdate /generic_sequencer_15_tb/iUUT/bus_valid +add wave -noupdate /generic_sequencer_15_tb/iUUT/bus_ack add wave -noupdate /generic_sequencer_15_tb/iUUT/bus_valid_i add wave -noupdate /generic_sequencer_15_tb/iUUT/bus_pause add wave -noupdate -radix hexadecimal /generic_sequencer_15_tb/iUUT/pos_store diff --git a/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd b/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd index 5d30387..8e35272 100644 --- a/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd +++ b/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd @@ -6,7 +6,7 @@ -- Author : Robbie Temple (original) -- Company : Global Inkjet Systems -- Created : 2016-05-12 --- Last update: 2019-04-03 +-- Last update: 2019-04-04 -- SVN ID : Git -- Standard : VHDL'2008 ------------------------------------------------------------------------------- @@ -132,7 +132,7 @@ architecture rtl of generic_sequencer_15 is signal r1_data_valid : std_logic; -- strobe to cause R1 to be updated with R1_data value signal decode, clr_vec, ld_vec : std_logic; - signal bus_valid_i, busy_i : std_logic; + signal bus_valid_i, busy_i : std_logic; signal ld_start_addr, inc_ram_addr : std_logic; signal ld_trig_mask, ld_trig_sel : std_logic; signal ld_pos : std_logic; @@ -438,13 +438,14 @@ begin end if; when s_bus_burst => - if(BUS_BURST_EN = true) then - if(op_cnt_done = '1') then + if(BUS_BURST_EN = true) then + bus_valid_i <= '1'; + if(op_cnt_done = '1' and bus_ack = '1') then + bus_valid_i <= '0'; fsm_nxt <= s_fetch; - elsif(bus_ack = '1' and bus_pause = '0') then + elsif(bus_pause = '0') then inc_ram_addr <= '1'; inc_op_cnt <= '1'; - bus_valid_i <= '1'; end if; else fsm_nxt <= s_fetch; @@ -637,11 +638,11 @@ begin pBURST_REGs : process(clk) begin if(clk = '1' and clk'event) then - bus_valid <= bus_valid_i; - bus_pause <= bus_valid_i; + bus_valid <= bus_valid_i and not (bus_ack and bus_pause); + bus_pause <= bus_valid_i and (not bus_ack or inc_ram_addr); if(seq_enable = '0') then bus_data <= (others => '0'); - elsif(bus_valid_i = '1') then + elsif(bus_valid_i = '1' and (bus_pause = '0' or bus_ack = '1')) then bus_data <= ram_rd_data(BUS_WIDTH-1 downto 0); end if; end if; diff --git a/generic_ip/generic_sequencer/15/src/test/generic_sequencer_15_tb.vhd b/generic_ip/generic_sequencer/15/src/test/generic_sequencer_15_tb.vhd index 6f629a2..48d4475 100644 --- a/generic_ip/generic_sequencer/15/src/test/generic_sequencer_15_tb.vhd +++ b/generic_ip/generic_sequencer/15/src/test/generic_sequencer_15_tb.vhd @@ -435,14 +435,14 @@ begin end if; end loop; -- n if(valid = false) then - log("ERROR: cannot detect bus_valid before timeout.", VLOW); + log("ERROR: cannot detect bus_valid before timeout (Expected value = " & to_hstring(exp_val) & ").", VLOW); error_flag <= true; wait; else if(bus_data /= exp_val) then log("ERROR: detected bus_data = 0x" & to_hstring(bus_data) & ", expected = 0x" & to_hstring(exp_val) & ".", VLOW); - error_flag <= true; - wait; + error_flag <= true; + wait; end if; end if; end procedure check_burst_data; @@ -706,16 +706,24 @@ begin trigger_in <= (0 => '1', others => '0'); wait_clk_cycles(1); trigger_in <= (others => '0'); - wait_clk_cycles(5); + wait_clk_cycles(2); + if(bus_valid /='1') then + wait until bus_valid = '1'; + end if; bus_ack <= '1'; - check_burst_data(X"DEADBEEF", 4); - check_burst_data(X"BADA5555", 4); - check_burst_data(X"CAFEF00D", 4); - check_burst_data(X"DEADBEEF", 4); - check_burst_data(X"FFFF0000", 4); - check_burst_data(X"0000FFFF", 4); + check_burst_data(X"DEADBEEF", 1); + wait_clk_cycles(2); + check_burst_data(X"BADA5555", 1); + wait_clk_cycles(2); + check_burst_data(X"CAFEF00D", 1); + wait_clk_cycles(2); + check_burst_data(X"DEADBEEF", 1); + wait_clk_cycles(4); + check_burst_data(X"FFFF0000", 1); + wait_clk_cycles(4); + check_burst_data(X"0000FFFF", 1); - wait until busy = '0'; + wait until bus_valid = '0'; bus_ack <= '0'; wait_clk_cycles(10); @@ -733,34 +741,36 @@ begin trigger_in <= (others => '0'); wait_clk_cycles(5); bus_ack <= '1'; + --wait_clk_cycles(1); + --bus_ack <= '0'; + check_burst_data(X"DEADBEEF", 1); wait_clk_cycles(1); bus_ack <= '0'; - check_burst_data(X"DEADBEEF", 4); wait_clk_cycles(3); bus_ack <= '1'; + check_burst_data(X"BADA5555", 1); + wait_clk_cycles(1); + bus_ack <= '0'; + wait_clk_cycles(1); + bus_ack <= '1'; + check_burst_data(X"CAFEF00D", 1); wait_clk_cycles(1); bus_ack <= '0'; - check_burst_data(X"BADA5555", 4); wait_clk_cycles(3); bus_ack <= '1'; + check_burst_data(X"DEADBEEF", 1); wait_clk_cycles(1); bus_ack <= '0'; - check_burst_data(X"CAFEF00D", 4); wait_clk_cycles(3); bus_ack <= '1'; + check_burst_data(X"FFFF0000", 1); wait_clk_cycles(1); bus_ack <= '0'; - check_burst_data(X"DEADBEEF", 4); wait_clk_cycles(3); bus_ack <= '1'; + check_burst_data(X"0000FFFF", 1); wait_clk_cycles(1); bus_ack <= '0'; - check_burst_data(X"FFFF0000", 4); - wait_clk_cycles(3); - bus_ack <= '1'; - wait_clk_cycles(1); - bus_ack <= '0'; - check_burst_data(X"0000FFFF", 4); wait until busy = '0'; wait_clk_cycles(10); From 00af445c13b32952eea4e08dae5a1dd60e209f51 Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Mon, 29 Apr 2019 11:46:41 +0100 Subject: [PATCH 04/29] Removing old files to enable merging from master --- .../encoder_multiply/0/sim/sim_enc_mult.do | 55 --- .../0/src/encoder_multiply_0.vhd | 167 ------- .../0/src/test/encoder_multiply_0_tb.vhd | 438 ------------------ 3 files changed, 660 deletions(-) delete mode 100644 generic_ip/encoder_multiply/0/sim/sim_enc_mult.do delete mode 100644 generic_ip/encoder_multiply/0/src/encoder_multiply_0.vhd delete mode 100644 generic_ip/encoder_multiply/0/src/test/encoder_multiply_0_tb.vhd diff --git a/generic_ip/encoder_multiply/0/sim/sim_enc_mult.do b/generic_ip/encoder_multiply/0/sim/sim_enc_mult.do deleted file mode 100644 index 021ac83..0000000 --- a/generic_ip/encoder_multiply/0/sim/sim_enc_mult.do +++ /dev/null @@ -1,55 +0,0 @@ -# Simulation macro - -#.main clear - -# 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 WORKLIB work - -vlib ./work -vmap work ./work - -# Compile the UUT -vcom -2008 -work $WORKLIB ./../src/encoder_multiply_0.vhd - -# 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 support files -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 - -# Compile the testbench -#vcom -2008 -work $WORKLIB ./../src/test/encoder_mulyiply_tb.vhd - -#vsim -t ps work.encoder_multiply_tb - - -#add wave /encoder_multiply_tb/* -#add wave /encoder_multiply_tb/iUUT/* - -# remove warnings from standard numeric/arithmetic packages (speed-up simulation) -set StdArithNoWarnings 1 -set NumericStdNoWarnings 1 - -#do wave_enc_mult.do - -#when -label end_of_simulation {test_completed == true} {echo "Simulation Completed"; stop ;} -#run -all - -#run 100 us; \ No newline at end of file diff --git a/generic_ip/encoder_multiply/0/src/encoder_multiply_0.vhd b/generic_ip/encoder_multiply/0/src/encoder_multiply_0.vhd deleted file mode 100644 index b09d9e4..0000000 --- a/generic_ip/encoder_multiply/0/src/encoder_multiply_0.vhd +++ /dev/null @@ -1,167 +0,0 @@ -------------------------------------------------------------------------------- --- Title : encoder_multiply --- Project : Generic -------------------------------------------------------------------------------- --- File : encoder_multiply_0.vhd --- Author : Gianmarco Girau --- Company : Global Inkjet Systems --- Created : 2019-02-27 --- Last update: 2019-03-04 --- SVN ID : Git --- Standard : VHDL'2008 -------------------------------------------------------------------------------- --- Description: --- Encoder Multiply block -------------------------------------------------------------------------------- - -------------------------------------------------------------------------------- --- Port Map: --- init : clears the internal state when '1' --- enable : do not update the internal state when '0' --- mult_sel: mult_value = 2**mult_sel => max is 7 --- delta_t : average time difference between pulses, with signed magnitude, --- fixed point representation (8 bits mantissa), top bit is the sign: --- 0 => avg time between pos steps, 1 => avg time between neg steps --- step_pos_in : positive encoder step, before multiplication --- step_neg_in : negative encoder step, before multiplication --- step_pos_out : positive encoder step, before multiplication --- step_neg_out : negative encoder step, before multiplication -------------------------------------------------------------------------------- - -library ieee; -use ieee.std_logic_1164.all; -use ieee.numeric_std.all; - -entity encoder_multiply is - port( - reset_n : in std_logic; - clk : in std_logic; - init : in std_logic; - enable : in std_logic; - mult_sel : in std_logic_vector( 2 downto 0); - delta_t : in std_logic_vector(47 downto 0); - step_pos_in : in std_logic; - step_neg_in : in std_logic; - step_pos_out : out std_logic; - step_neg_out : out std_logic); -end encoder_multiply; - -architecture rtl of encoder_multiply is - - /* - function compute_mult(mult_sel : std_logic_vector(2 downto 0)) return std_logic_vector(7 downto 0) is - variable mult_value : std_logic_vector(7 downto 0); - begin - mult_value := (0 => '1', others => '0') sll(to_integer(unsigned(mult_sel))); - return mult_value; - end function compute_mult; - */ - - -- number of bits to represent the maximum multiplication value (e.g. 8 => M = 128) - constant MULT_W : natural := 8; - -- Number of bits used to represent the encoder pulse count, before the multiplication - constant PULSE_CNT_W : natural := 8+1; - -- Number of bits used to represent the encoder pulse count, after the multiplication - constant M_PULSE_CNT_W : natural := (MULT_W + PULSE_CNT_W); - - -- To prevent counter saturation, subtract a fixed amount each time the - -- counters exceed a given value - constant NORM_VALUE : natural := 2**(PULSE_CNT_W-2); - - - - signal init_d, step_pos, step_neg : std_logic; - signal m_step_pos, m_step_neg : std_logic; - signal sign, sign_i : std_logic; - signal time_cnt_zero : std_logic; - signal norm_pos, norm_pos_d : std_logic; - signal norm_neg, norm_neg_d : std_logic; - signal mult_val, kmax : std_logic_vector(MULT_W-1 downto 0); - signal pulse_cnt : std_logic_vector(PULSE_CNT_W-1 downto 0); - signal m_pulse_cnt, m_norm_value : std_logic_vector(M_PULSE_CNT_W-1 downto 0); - signal delta_m_pos, delta_m_neg : std_logic_vector(M_PULSE_CNT_W-1 downto 0); - signal time_cnt : std_logic_vector(27 downto 0); - signal m_delta_t : std_logic_vector(38-MULT_W downto 0); - signal delta_t_i : std_logic_vector(38 downto 0); - -begin - - pSEQ_LOGIC_RST : process(reset_n, clk) - begin - if(reset_n = '0') then - mult_val <= (0 => '1', others => '0'); - elsif(clk = '1' and clk'event) then - if(init_d = '1') then - mult_val <= std_logic_vector(to_unsigned(1, MULT_W)) sll(to_integer(unsigned(mult_sel))); - end if; - end if; - end process pSEQ_LOGIC_RST; - - pSEQ_LOGIC : process(clk) - variable mult_pulse_cnt : std_logic_vector(M_PULSE_CNT_W-1 downto 0); - begin - if(clk = '1' and clk'event) then - init_d <= init; - kmax <= std_logic_vector(unsigned(mult_val)-1); - if(init_d = '1') then - pulse_cnt <= (others => '0'); - elsif(step_pos = '1') then - pulse_cnt <= std_logic_vector(signed(pulse_cnt)+1); - elsif(step_neg = '1') then - pulse_cnt <= std_logic_vector(signed(pulse_cnt)-1); - elsif(norm_pos = '1') then - pulse_cnt <= std_logic_vector(signed(pulse_cnt)-NORM_VALUE); - elsif(norm_neg = '1') then - pulse_cnt <= std_logic_vector(signed(pulse_cnt)+NORM_VALUE); - end if; - if(init_d = '1') then - m_pulse_cnt <= (others => '0'); - elsif(m_step_pos = '1') then - m_pulse_cnt <= std_logic_vector(signed(m_pulse_cnt)+1); - elsif(m_step_neg = '1') then - m_pulse_cnt <= std_logic_vector(signed(m_pulse_cnt)-1); - elsif(norm_pos = '1') then - m_pulse_cnt <= std_logic_vector(signed(m_pulse_cnt)-signed(m_norm_value)); - elsif(norm_neg = '1') then - m_pulse_cnt <= std_logic_vector(signed(m_pulse_cnt)+signed(m_norm_value)); - end if; - if(m_step_pos = '1' or m_step_neg = '1') then - time_cnt <= m_delta_t(27 downto 0); - elsif(time_cnt_zero = '0') then - time_cnt <= std_logic_vector(unsigned(time_cnt)-1); - end if; - m_delta_t <= delta_t_i srl to_integer(unsigned(mult_sel)); - sign <= sign_i; - mult_pulse_cnt := pulse_cnt sll to_integer(unsigned(mult_sel)); - delta_m_pos <= std_logic_vector(signed(mult_pulse_cnt) + signed(kmax)); - delta_m_neg <= std_logic_vector(signed(mult_pulse_cnt) - signed(kmax)); - step_pos_out <= m_step_pos; - step_neg_out <= m_step_neg; - if(signed(pulse_cnt) = NORM_VALUE and norm_pos_d = '0') then - norm_pos <= '1'; - else - norm_pos <= '0'; - end if; - norm_pos_d <= norm_pos; - if(signed(pulse_cnt) = -NORM_VALUE and norm_neg_d = '0') then - norm_neg <= '1'; - else - norm_neg <= '0'; - end if; - norm_neg_d <= norm_neg; - m_norm_value <= std_logic_vector(to_unsigned(NORM_VALUE, M_PULSE_CNT_W)) sll (to_integer(unsigned(mult_sel))); - end if; - end process pSEQ_LOGIC; - - step_pos <= step_pos_in and enable; - step_neg <= step_neg_in and enable; - - delta_t_i <= delta_t(46 downto 8); - sign_i <= delta_t(47); - - time_cnt_zero <= '1' when unsigned(time_cnt) = 0 else '0'; - - m_step_pos <= '1' when sign = '0' and time_cnt_zero = '1' and signed(m_pulse_cnt) < signed(delta_m_pos) else '0'; - m_step_neg <= '1' when sign = '1' and time_cnt_zero = '1' and signed(m_pulse_cnt) > signed(delta_m_pos) else '0'; - -end architecture rtl; diff --git a/generic_ip/encoder_multiply/0/src/test/encoder_multiply_0_tb.vhd b/generic_ip/encoder_multiply/0/src/test/encoder_multiply_0_tb.vhd deleted file mode 100644 index 2aa1d2d..0000000 --- a/generic_ip/encoder_multiply/0/src/test/encoder_multiply_0_tb.vhd +++ /dev/null @@ -1,438 +0,0 @@ -------------------------------------------------------------------------------- --- Title : encoder_multiply_tb --- Project : EMB/SMB -------------------------------------------------------------------------------- --- File : encoder_multiply_tb.vhd --- Author : GMG --- Company : Global Inkjet Systems --- Created : 2019-03-05 --- Last update: 2019-03-05 --- SVN ID : Git --- Standard : VHDL'2008 -------------------------------------------------------------------------------- --- Description: --- Testbench for the encoder_multiply block -------------------------------------------------------------------------------- - -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 encoder_multiply_tb is - -- .. -end entity encoder_multiply_tb; - -architecture behav of encoder_multiply_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 - - ----------------------------------------------------------------------------- - -- 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 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.encoder_multiply - port map ( - reset_n => reset_n, - clk => clk, - init => init, - enable => enable, - mult_sel => mult_sel, - delta_t => delta_t, - step_pos_in => step_pos_in, - step_neg_in => step_neg_in, - step_pos_out => step_pos_out, - step_neg_out => step_neg_out); - - ----------------------------------------------------------------------------- - -- Support Logic - ----------------------------------------------------------------------------- - - pGEN_POS : process(clk) - begin - if(clk = '1' and clk'event) then - if(init = '1') then - abs_pos <= (others => '0'); - elsif(step_pos_in = '1') then - abs_pos <= std_logic_vector(unsigned(abs_pos)+1); - elsif(step_neg_in = '1') then - abs_pos <= std_logic_vector(unsigned(abs_pos)-1); - end if; - if(init = '1') then - m_abs_pos <= (others => '0'); - elsif(step_pos_out = '1') then - m_abs_pos <= std_logic_vector(unsigned(m_abs_pos)+1); - elsif(step_neg_out = '1') then - m_abs_pos <= std_logic_vector(unsigned(m_abs_pos)-1); - end if; - end if; - end process pGEN_POS; - - ----------------------------------------------------------------------------- - -- 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; From e78dd2d7888010a52b4382a72f97840ec9dc2116 Mon Sep 17 00:00:00 2001 From: Damian Smith Date: Fri, 10 May 2019 15:03:34 +0100 Subject: [PATCH 05/29] ELGIP-47 ELGIP-46 ELGIP-6 ELGIP-45 reinstated VHDL 2008 statement needed for qsys component editor --- .../15/src/generic_sequencer_15.vhd | 434 +++++++++--------- 1 file changed, 217 insertions(+), 217 deletions(-) diff --git a/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd b/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd index 8e35272..299d952 100644 --- a/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd +++ b/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd @@ -6,14 +6,14 @@ -- Author : Robbie Temple (original) -- Company : Global Inkjet Systems -- Created : 2016-05-12 --- Last update: 2019-04-04 +-- Last update: 2019-05-10 -- SVN ID : Git -- Standard : VHDL'2008 ------------------------------------------------------------------------------- -- Description: -- Generic Sequencer core ------------------------------------------------------------------------------- - +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; @@ -24,17 +24,17 @@ use work.generic_sequencer_15_pkg.all; entity generic_sequencer_15 is generic( - TRIGGER_WIDTH : natural range 1 to 16 := 16; - VECTOR_WIDTH : natural range 1 to 24 := 12; - BUS_WIDTH : natural range 1 to 32 := 12; - POS_WIDTH : natural range 1 to 24 := 12; + TRIGGER_WIDTH : natural range 1 to 16 := 16; + VECTOR_WIDTH : natural range 1 to 24 := 12; + BUS_WIDTH : natural range 1 to 32 := 12; + POS_WIDTH : natural range 1 to 24 := 12; SEQ_DEPTH : natural range 256 to 4096 := 256; - ADD_VEC_PIPE : boolean := false; -- Add a pipeline register on vector_out - VECT_RAMP_EN : boolean := false; - BUS_BURST_EN : boolean := false; - POS_BUS_EN : boolean := false; - ALU_EN : boolean := false; - QUEUE_EN : boolean := false); + ADD_VEC_PIPE : boolean := false; -- Add a pipeline register on vector_out + VECT_RAMP_EN : boolean := false; + BUS_BURST_EN : boolean := false; + POS_BUS_EN : boolean := false; + ALU_EN : boolean := false; + QUEUE_EN : boolean := false); port( -- clk : in std_logic; @@ -46,23 +46,23 @@ entity generic_sequencer_15 is avs_csr_read : in std_logic; avs_csr_readdata : out std_logic_vector(31 downto 0) := (others => '0'); -- - avs_seq_address : in std_logic_vector(log2(SEQ_DEPTH)-1 downto 0); + avs_seq_address : in std_logic_vector(log2(SEQ_DEPTH) - 1 downto 0); avs_seq_write : in std_logic; avs_seq_writedata : in std_logic_vector(31 downto 0); avs_seq_read : in std_logic; avs_seq_readdata : out std_logic_vector(31 downto 0) := (others => '0'); -- start_req : in std_logic; - start_addr : in std_logic_vector(log2(SEQ_DEPTH)-1 downto 0); + start_addr : in std_logic_vector(log2(SEQ_DEPTH) - 1 downto 0); -- - trigger_in : in std_logic_vector(TRIGGER_WIDTH-1 downto 0); - pos_in : in std_logic_vector(POS_WIDTH-1 downto 0); + trigger_in : in std_logic_vector(TRIGGER_WIDTH - 1 downto 0); + pos_in : in std_logic_vector(POS_WIDTH - 1 downto 0); -- busy : out std_logic; -- - vector_out : out std_logic_vector(VECTOR_WIDTH-1 downto 0); + vector_out : out std_logic_vector(VECTOR_WIDTH - 1 downto 0); -- - bus_data : out std_logic_vector(BUS_WIDTH-1 downto 0); + bus_data : out std_logic_vector(BUS_WIDTH - 1 downto 0); bus_valid : out std_logic; bus_ack : in std_logic); end entity generic_sequencer_15; @@ -74,8 +74,8 @@ architecture rtl of generic_sequencer_15 is ----------------------------------------------------------------------------- constant CSR_IP_ID : std_logic_vector(31 downto 0) := x"0000FF01"; - constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000F12"; - + constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000F12"; + type fsm_t is (s_idle, s_init, s_fetch, s_decode, -- s_trig_mask, s_trig_wait, @@ -93,46 +93,46 @@ architecture rtl of generic_sequencer_15 is -- Signals ----------------------------------------------------------------------------- - signal fsm, fsm_nxt : fsm_t; + signal fsm, fsm_nxt : fsm_t; - signal seq_cfg_aux : std_logic_vector(31 downto 0) := 32x"0"; + signal seq_cfg_aux : std_logic_vector(31 downto 0) := 32x"0"; signal seq_enable : std_logic; signal rst_vector_out : std_logic; signal debug_mode : std_logic; - - signal ram_rd_addr : std_logic_vector(log2(SEQ_DEPTH)-1 downto 0); - signal ram_rd_data : std_logic_vector(31 downto 0); - - signal operand_1 : std_logic_vector(11 downto 0); - signal operand_2 : std_logic_vector(11 downto 0); - signal operand_comp : std_logic_vector(23 downto 0); - signal opcode : std_logic_vector( 3 downto 0); - signal subcode : std_logic_vector( 3 downto 0); - signal jump_addr_ext : std_logic_vector(11 downto 0); - signal jump_addr : std_logic_vector(log2(SEQ_DEPTH)-1 downto 0); - signal pc_value : std_logic_vector(log2(SEQ_DEPTH)-1 downto 0); - signal pos_store : std_logic_vector(POS_WIDTH - 1 downto 0); - signal pos_target : std_logic_vector(POS_WIDTH - 1 downto 0); + signal ram_rd_addr : std_logic_vector(log2(SEQ_DEPTH) - 1 downto 0); + signal ram_rd_data : std_logic_vector(31 downto 0); - signal trig_mask : std_logic_vector(TRIGGER_WIDTH - 1 downto 0); - signal trig_sel : std_logic_vector(3 downto 0); - signal trig_int : std_logic; + signal operand_1 : std_logic_vector(11 downto 0); + signal operand_2 : std_logic_vector(11 downto 0); + signal operand_comp : std_logic_vector(23 downto 0); + signal opcode : std_logic_vector(3 downto 0); + signal subcode : std_logic_vector(3 downto 0); + signal jump_addr_ext : std_logic_vector(11 downto 0); + signal jump_addr : std_logic_vector(log2(SEQ_DEPTH) - 1 downto 0); + signal pc_value : std_logic_vector(log2(SEQ_DEPTH) - 1 downto 0); - signal vector_out_i : std_logic_vector(VECTOR_WIDTH-1 downto 0); - signal ramp_val : std_logic_vector(VECTOR_WIDTH-1 downto 0); + signal pos_store : std_logic_vector(POS_WIDTH - 1 downto 0); + signal pos_target : std_logic_vector(POS_WIDTH - 1 downto 0); - signal op_cnt : std_logic_vector(11 downto 0); - signal loop_cnt : std_logic_vector(11 downto 0); + signal trig_mask : std_logic_vector(TRIGGER_WIDTH - 1 downto 0); + signal trig_sel : std_logic_vector(3 downto 0); + signal trig_int : std_logic; - signal return_addr : std_logic_vector(log2(SEQ_DEPTH)-1 downto 0); + signal vector_out_i : std_logic_vector(VECTOR_WIDTH - 1 downto 0); + signal ramp_val : std_logic_vector(VECTOR_WIDTH - 1 downto 0); - signal r1, r1_data : std_logic_vector(11 downto 0); - signal r1_data_valid : std_logic; -- strobe to cause R1 to be updated with R1_data value + signal op_cnt : std_logic_vector(11 downto 0); + signal loop_cnt : std_logic_vector(11 downto 0); + + signal return_addr : std_logic_vector(log2(SEQ_DEPTH) - 1 downto 0); + + signal r1, r1_data : std_logic_vector(11 downto 0); + signal r1_data_valid : std_logic; -- strobe to cause R1 to be updated with R1_data value signal decode, clr_vec, ld_vec : std_logic; - signal bus_valid_i, busy_i : std_logic; + signal bus_valid_i, busy_i : std_logic; signal ld_start_addr, inc_ram_addr : std_logic; signal ld_trig_mask, ld_trig_sel : std_logic; signal ld_pos : std_logic; @@ -150,8 +150,8 @@ architecture rtl of generic_sequencer_15 is signal vector_val_cpu : std_logic; signal vector_cpu : std_logic_vector(VECTOR_WIDTH - 1 downto 0); - signal step_req : std_logic; - signal fetch_enable : std_logic; + signal step_req : std_logic; + signal fetch_enable : std_logic; signal clr_seq_queue : std_logic; signal clr_seq_queue_i : std_logic; @@ -164,9 +164,9 @@ architecture rtl of generic_sequencer_15 is signal seq_completed : std_logic; signal seq_queue_empty : std_logic; signal set_queue_empty : std_logic; - signal queue_add : std_logic_vector( 7 downto 0); - signal queue_add_i : std_logic_vector( 7 downto 0); - signal queue_left : std_logic_vector( 7 downto 0); + signal queue_add : std_logic_vector(7 downto 0); + signal queue_add_i : std_logic_vector(7 downto 0); + signal queue_left : std_logic_vector(7 downto 0); signal queue_exec : std_logic_vector(15 downto 0); @@ -182,7 +182,7 @@ begin AVS_PROC : process(clk, reset_n) is begin if reset_n = '0' then - avs_csr_readdata <= (others => '0'); + avs_csr_readdata <= (others => '0'); seq_enable <= '0'; rst_vector_out <= '0'; debug_mode <= '0'; @@ -194,29 +194,29 @@ begin seq_queue_empty <= '0'; elsif clk'event and clk = '1' then -- - avs_csr_readdata <= (others => '0'); + avs_csr_readdata <= (others => '0'); vector_val_cpu <= '0'; step_req <= '0'; clr_seq_queue <= '0'; clr_seq_queue_exe <= '0'; queue_add_flag <= '0'; - - if(ALU_EN = true) then - if(busy_i = '0') then + + if (ALU_EN = true) then + if (busy_i = '0') then r1_data_valid <= '0'; end if; end if; - if(QUEUE_EN = true and set_queue_empty = '1') then + if (QUEUE_EN = true and set_queue_empty = '1') then seq_queue_empty <= '1'; end if; if avs_csr_write = '1' then case avs_csr_address is when CSR_CTRL_ADDR => - seq_enable <= avs_csr_writedata(0); - rst_vector_out <= avs_csr_writedata(4); - if(QUEUE_EN = true) then + seq_enable <= avs_csr_writedata(0); + rst_vector_out <= avs_csr_writedata(4); + if (QUEUE_EN = true) then clr_seq_queue <= avs_csr_writedata(8); clr_seq_queue_exe <= avs_csr_writedata(9); end if; @@ -231,14 +231,14 @@ begin when CSR_STEP_ADDR => step_req <= '1'; when CSR_R1_ADDR => - if(ALU_EN = true) then + if (ALU_EN = true) then r1_data <= avs_csr_writedata(R1_data'range); r1_data_valid <= '1'; end if; when CSR_SEQ_QUEUE_ADDR => - if(QUEUE_EN = true) then + if (QUEUE_EN = true) then queue_add_flag <= '1'; - queue_add <= avs_csr_writedata( 7 downto 0); + queue_add <= avs_csr_writedata(7 downto 0); end if; when others => null; end case; @@ -252,10 +252,10 @@ begin avs_csr_readdata <= "00" & std_logic_vector(to_unsigned(TRIGGER_WIDTH, 6)) & std_logic_vector(to_unsigned(VECTOR_WIDTH, 6)) & std_logic_vector(to_unsigned(BUS_WIDTH, 6)) & std_logic_vector(to_unsigned(POS_WIDTH, 6)) & std_logic_vector(to_unsigned(log2(SEQ_DEPTH), 6)); when CSR_CTRL_ADDR => avs_csr_readdata <= 21x"0" & seq_queue_empty & 5x"0" & rst_vector_out & debug_mode & busy & '0' & seq_enable; - seq_queue_empty <= '0'; + seq_queue_empty <= '0'; when CSR_PC_ADDR => - avs_csr_readdata(log2(SEQ_DEPTH)-1+ 16 downto 16) <= return_addr; - avs_csr_readdata(log2(SEQ_DEPTH)-1 downto 0) <= pc_value; + avs_csr_readdata(log2(SEQ_DEPTH) - 1 + 16 downto 16) <= return_addr; + avs_csr_readdata(log2(SEQ_DEPTH) - 1 downto 0) <= pc_value; when CSR_TRIGGER_ADDR => avs_csr_readdata(TRIGGER_WIDTH - 1 downto 0) <= trigger_in; when CSR_VECTOR_ADDR => @@ -267,7 +267,7 @@ begin when CSR_POS_STORE_ADDR => avs_csr_readdata(POS_WIDTH - 1 downto 0) <= pos_store; when CSR_SEQ_QUEUE_ADDR => - if(QUEUE_EN = true) then + if (QUEUE_EN = true) then avs_csr_readdata <= queue_exec & queue_left & x"00"; end if; when others => null; @@ -279,9 +279,9 @@ begin seq_cfg_aux(0) <= '1' when ADD_VEC_PIPE = true else '0'; seq_cfg_aux(1) <= '1' when VECT_RAMP_EN = true else '0'; seq_cfg_aux(2) <= '1' when BUS_BURST_EN = true else '0'; - seq_cfg_aux(3) <= '1' when POS_BUS_EN = true else '0'; - seq_cfg_aux(4) <= '1' when ALU_EN = true else '0'; - seq_cfg_aux(5) <= '1' when QUEUE_EN = true else '0'; + seq_cfg_aux(3) <= '1' when POS_BUS_EN = true else '0'; + seq_cfg_aux(4) <= '1' when ALU_EN = true else '0'; + seq_cfg_aux(5) <= '1' when QUEUE_EN = true else '0'; trig_int <= trigger_in(to_integer(unsigned(trig_sel))) and trig_mask(to_integer(unsigned(trig_sel))); @@ -290,9 +290,9 @@ begin ----------------------------------------------------------------------------- iRAM : entity work.generic_seq_ram_15 - generic map ( + generic map( SEQ_DEPTH => SEQ_DEPTH) - port map ( + port map( clock => clk, address_a => avs_seq_address, wren_a => avs_seq_write, @@ -314,10 +314,10 @@ begin -- FSM Status Register pFSM_SR : process(reset_n, clk) begin - if(reset_n = '0') then - fsm <= s_idle; - elsif(clk = '1' and clk'event) then - fsm <= fsm_nxt; + if (reset_n = '0') then + fsm <= s_idle; + elsif (clk = '1' and clk'event) then + fsm <= fsm_nxt; end if; end process pFSM_SR; @@ -325,7 +325,7 @@ begin pFSM_CL : process(all) begin -- Default assignments - fsm_nxt <= fsm; + fsm_nxt <= fsm; -- decode <= '0'; clr_vec_i <= '0'; @@ -339,53 +339,53 @@ begin loop_upd <= '0'; seq_completed <= '0'; set_queue_empty <= '0'; - if(BUS_BURST_EN = true) then - bus_valid_i <= '0'; + if (BUS_BURST_EN = true) then + bus_valid_i <= '0'; end if; - if(ALU_EN = true) then - alu_upd <= '0'; + if (ALU_EN = true) then + alu_upd <= '0'; end if; - if(POS_BUS_EN = true) then + if (POS_BUS_EN = true) then ld_pos <= '0'; end if; -- Determine next state - if(seq_enable = '0') then - busy_i <= '0'; - if(rst_vector_out = '1') then + if (seq_enable = '0') then + busy_i <= '0'; + if (rst_vector_out = '1') then clr_vec_i <= '1'; end if; fsm_nxt <= s_idle; - elsif(start_req_i = '1') then + elsif (start_req_i = '1') then busy_i <= '0'; ld_start_addr <= '1'; - fsm_nxt <= s_init; + fsm_nxt <= s_init; else case fsm is - + when s_idle => - busy_i <= '0'; + busy_i <= '0'; if seq_enable = '1' and start_req_i = '1' then ld_start_addr <= '1'; - fsm_nxt <= s_init; + fsm_nxt <= s_init; end if; - + when s_init => - if(rst_vector_out = '1') then + if (rst_vector_out = '1') then clr_vec_i <= '1'; - end if; + end if; fsm_nxt <= s_fetch; - + when s_fetch => - if(fetch_enable = '1') then + if (fetch_enable = '1') then inc_ram_addr <= '1'; fetch_op <= '1'; - fsm_nxt <= s_decode; + fsm_nxt <= s_decode; end if; - + when s_return => fsm_nxt <= s_fetch; - + when s_decode => decode <= '1'; case opcode is @@ -408,89 +408,89 @@ begin when CMD_END => fsm_nxt <= s_end; when others => null; end case; - + when s_trig_mask => ld_trig_mask <= '1'; - fsm_nxt <= s_fetch; + fsm_nxt <= s_fetch; when s_trig_wait => - if(trig_int = '1') then + if (trig_int = '1') then inc_op_cnt <= '1'; end if; - if(op_cnt_done = '1') then + if (op_cnt_done = '1') then fsm_nxt <= s_fetch; end if; when s_vec_set => - ld_vec <= '1'; + ld_vec <= '1'; fsm_nxt <= s_fetch; when s_vec_ramp => - if(VECT_RAMP_EN = false) then + if (VECT_RAMP_EN = false) then fsm_nxt <= s_fetch; else - if(trig_int = '1') then + if (trig_int = '1') then inc_op_cnt <= '1'; - if(op_cnt_done = '1') then + if (op_cnt_done = '1') then fsm_nxt <= s_fetch; end if; end if; end if; when s_bus_burst => - if(BUS_BURST_EN = true) then + if (BUS_BURST_EN = true) then bus_valid_i <= '1'; - if(op_cnt_done = '1' and bus_ack = '1') then + if (op_cnt_done = '1' and bus_ack = '1') then bus_valid_i <= '0'; - fsm_nxt <= s_fetch; - elsif(bus_pause = '0') then - inc_ram_addr <= '1'; - inc_op_cnt <= '1'; + fsm_nxt <= s_fetch; + elsif (bus_pause = '0') then + inc_ram_addr <= '1'; + inc_op_cnt <= '1'; end if; else fsm_nxt <= s_fetch; end if; when s_pos_store => - if(POS_BUS_EN = true) then + if (POS_BUS_EN = true) then ld_pos <= '1'; end if; fsm_nxt <= s_fetch; when s_pos_wait => - if(pos_in = pos_target) then + if (pos_in = pos_target) then fsm_nxt <= s_fetch; end if; - + when s_alu => - if(ALU_EN = true) then - alu_upd <= '1'; + if (ALU_EN = true) then + alu_upd <= '1'; end if; fsm_nxt <= s_fetch; - + when s_jump | s_branch => fsm_nxt <= s_fetch; when s_loop => loop_upd <= '1'; - fsm_nxt <= s_fetch; - + fsm_nxt <= s_fetch; + when s_end => - if(subcode = x"0") then + if (subcode = x"0") then fsm_nxt <= s_idle; - elsif(QUEUE_EN = true and (subcode = x"1" or subcode = x"2")) then - if(unsigned(queue_left) > 0) then + elsif (QUEUE_EN = true and (subcode = x"1" or subcode = x"2")) then + if (unsigned(queue_left) > 0) then seq_completed <= '1'; - fsm_nxt <= s_fetch; + fsm_nxt <= s_fetch; else set_queue_empty <= '1'; - fsm_nxt <= s_end; + fsm_nxt <= s_end; end if; else fsm_nxt <= s_idle; - end if; - - when others => null; + end if; + + when others => null; end case; end if; end process pFSM_CL; @@ -502,42 +502,42 @@ begin begin if (reset_n = '0') then vector_out_i <= (others => '0'); - elsif(clk = '1' and clk'event) then - start_req_d <= start_req; + elsif (clk = '1' and clk'event) then + start_req_d <= start_req; fetch_enable <= (not debug_mode) or (debug_mode and step_req); - if(fetch_op = '1') then + if (fetch_op = '1') then pc_value <= ram_rd_addr; end if; - if(fetch_op = '1') then + if (fetch_op = '1') then operand_comp <= ram_rd_data(23 downto 0); subcode <= ram_rd_data(27 downto 24); end if; - busy <= busy_i; - if(ld_start_addr = '1') then + busy <= busy_i; + if (ld_start_addr = '1') then ram_rd_addr <= start_addr; - elsif(ld_jmp_addr = '1') then + elsif (ld_jmp_addr = '1') then ram_rd_addr <= jump_addr; - elsif(ld_ret_addr = '1') then + elsif (ld_ret_addr = '1') then ram_rd_addr <= return_addr; - elsif(inc_ram_addr = '1') then - ram_rd_addr <= std_logic_vector(unsigned(ram_rd_addr)+1); + elsif (inc_ram_addr = '1') then + ram_rd_addr <= std_logic_vector(unsigned(ram_rd_addr) + 1); end if; - if(ld_trig_mask = '1') then + if (ld_trig_mask = '1') then trig_mask <= operand_comp(TRIGGER_WIDTH - 1 downto 0); end if; - if(ld_trig_sel = '1') then + if (ld_trig_sel = '1') then trig_sel <= subcode; end if; - if(ld_vec = '1' and subcode = "0001") then + if (ld_vec = '1' and subcode = "0001") then clr_vec_ii <= '1'; else - clr_vec_ii <= '0'; + clr_vec_ii <= '0'; end if; - if(clr_vec = '1') then + if (clr_vec = '1') then vector_out_i <= (others => '0'); - elsif(ld_vec = '1') then - vector_out_i <= operand_comp(VECTOR_WIDTH-1 downto 0); - elsif(VECT_RAMP_EN = true and inc_op_cnt = '1') then + elsif (ld_vec = '1') then + vector_out_i <= operand_comp(VECTOR_WIDTH - 1 downto 0); + elsif (VECT_RAMP_EN = true and inc_op_cnt = '1') then if ramp_up = '1' and ramp_val(ramp_val'high) = '0' and vector_out_i(vector_out_i'high) = '1' then vector_out_i <= (others => '1'); elsif ramp_up = '0' and ramp_val(ramp_val'high) = '1' and vector_out_i(vector_out_i'high) = '0' then @@ -545,80 +545,80 @@ begin else vector_out_i <= ramp_val; end if; - elsif(vector_val_cpu = '1') then - vector_out_i <=vector_cpu; + elsif (vector_val_cpu = '1') then + vector_out_i <= vector_cpu; end if; - if(save_ret_addr = '1') then + if (save_ret_addr = '1') then return_addr <= ram_rd_addr; end if; - if(decode = '1') then + if (decode = '1') then op_cnt <= (others => '0'); - elsif(inc_op_cnt = '1') then - op_cnt <= std_logic_vector(unsigned(op_cnt)+1); + elsif (inc_op_cnt = '1') then + op_cnt <= std_logic_vector(unsigned(op_cnt) + 1); end if; - if(start_req_i = '1' or (loop_done = '1' and loop_upd = '1')) then + if (start_req_i = '1' or (loop_done = '1' and loop_upd = '1')) then loop_active <= '0'; - elsif(decode = '1' and opcode = CMD_LOOP) then + elsif (decode = '1' and opcode = CMD_LOOP) then loop_active <= '1'; - end if; - if(loop_active = '0' and opcode = CMD_LOOP) then + end if; + if (loop_active = '0' and opcode = CMD_LOOP) then loop_cnt <= (others => '0'); - elsif(loop_upd = '1') then - loop_cnt <= std_logic_vector(unsigned(loop_cnt)+1); + elsif (loop_upd = '1') then + loop_cnt <= std_logic_vector(unsigned(loop_cnt) + 1); end if; end if; end process pSEQ_REGs; loop_done <= '1' when unsigned(loop_cnt) = unsigned(operand_2) else '0'; - operand_1 <= operand_comp(11 downto 0); + operand_1 <= operand_comp(11 downto 0); operand_2 <= operand_comp(23 downto 12); clr_vec <= clr_vec_i or clr_vec_ii; op_cnt_done <= '1' when op_cnt = operand_1 else '0'; - jump_addr_ext <= operand_1 when jump_abs = '1' else - std_logic_vector(signed('0' & ram_rd_addr)+signed(operand_1)-1) when jump_rel = '1' else + jump_addr_ext <= operand_1 when jump_abs = '1' else + std_logic_vector(signed('0' & ram_rd_addr) + signed(operand_1) - 1) when jump_rel = '1' else r1; jump_addr <= jump_addr_ext(jump_addr'range); ld_jmp_addr <= '1' when decode = '1' and (jump_abs = '1' or jump_rel = '1' or jump_r1 = '1') else '0'; - jump_abs <= '1' when (opcode = CMD_JUMP and (subcode = X"0" or (subcode = X"1" and flag = '1') or (subcode = X"2" and flag = '0'))) or (opcode = CMD_END and subcode = X"1") else '0'; + jump_abs <= '1' when (opcode = CMD_JUMP and (subcode = X"0" or (subcode = X"1" and flag = '1') or (subcode = X"2" and flag = '0'))) or (opcode = CMD_END and subcode = X"1") else '0'; jump_rel <= '1' when (opcode = CMD_BRANCH and (subcode = X"0" or (subcode = X"1" and flag = '1') or (subcode = X"2" and flag = '0'))) or (opcode = CMD_LOOP and loop_done = '0') or (opcode = CMD_END and subcode = X"2") else '0'; - jump_r1 <= '1' when opcode = CMD_JUMP and subcode = X"F" else '0'; + jump_r1 <= '1' when opcode = CMD_JUMP and subcode = X"F" else '0'; save_ret_addr <= ld_jmp_addr; - ld_ret_addr <= '1' when decode = '1' and (opcode = CMD_RETURN) else '0'; + ld_ret_addr <= '1' when decode = '1' and (opcode = CMD_RETURN) else '0'; ----------------------------------------------------------------------------- -- Others - Generics dependent ----------------------------------------------------------------------------- - gVECT_NO_PIPE: if ADD_VEC_PIPE = false generate + gVECT_NO_PIPE : if ADD_VEC_PIPE = false generate vector_out <= vector_out_i; end generate gVECT_NO_PIPE; - gVECT_PIPE: if ADD_VEC_PIPE = true generate + gVECT_PIPE : if ADD_VEC_PIPE = true generate pVECT_PIPE : process(clk) begin - if(clk = '1' and clk'event) then + if (clk = '1' and clk'event) then vector_out <= vector_out_i; end if; end process pVECT_PIPE; end generate gVECT_PIPE; - gRAMP_GEN: if VECT_RAMP_EN = true generate + gRAMP_GEN : if VECT_RAMP_EN = true generate ramp_val <= std_logic_vector(unsigned(vector_out_i) + unsigned(operand_2)) when ramp_up = '1' else std_logic_vector(unsigned(vector_out_i) - unsigned(operand_2)); pRAMP_REGs : process(clk) begin - if(clk = '1' and clk'event) then - if(decode = '1') then - if(opcode = CMD_VEC_RAMP_UP) then + if (clk = '1' and clk'event) then + if (decode = '1') then + if (opcode = CMD_VEC_RAMP_UP) then ramp_up <= '1'; else ramp_up <= '0'; @@ -626,31 +626,31 @@ begin end if; end if; end process pRAMP_REGs; - + end generate gRAMP_GEN; - gRAMP_NOGEN: if VECT_RAMP_EN = false generate + gRAMP_NOGEN : if VECT_RAMP_EN = false generate ramp_val <= (others => '0'); end generate gRAMP_NOGEN; - gBUS_BURST_GEN: if BUS_BURST_EN = true generate + gBUS_BURST_GEN : if BUS_BURST_EN = true generate pBURST_REGs : process(clk) begin - if(clk = '1' and clk'event) then + if (clk = '1' and clk'event) then bus_valid <= bus_valid_i and not (bus_ack and bus_pause); bus_pause <= bus_valid_i and (not bus_ack or inc_ram_addr); - if(seq_enable = '0') then + if (seq_enable = '0') then bus_data <= (others => '0'); - elsif(bus_valid_i = '1' and (bus_pause = '0' or bus_ack = '1')) then - bus_data <= ram_rd_data(BUS_WIDTH-1 downto 0); + elsif (bus_valid_i = '1' and (bus_pause = '0' or bus_ack = '1')) then + bus_data <= ram_rd_data(BUS_WIDTH - 1 downto 0); end if; end if; end process pBURST_REGs; end generate gBUS_BURST_GEN; - gBUS_BURST_NOGEN: if BUS_BURST_EN = false generate + gBUS_BURST_NOGEN : if BUS_BURST_EN = false generate bus_valid <= '0'; bus_pause <= '0'; @@ -658,15 +658,15 @@ begin end generate gBUS_BURST_NOGEN; - gPOS_GEN: if POS_BUS_EN = true generate + gPOS_GEN : if POS_BUS_EN = true generate pPOS_REGs : process(clk) begin - if(clk = '1' and clk'event) then - if(ld_pos = '1') then + if (clk = '1' and clk'event) then + if (ld_pos = '1') then pos_store <= pos_in; end if; - if(decode = '1') then + if (decode = '1') then case subcode is when X"0" => pos_target <= operand_comp(pos_in'range); @@ -681,19 +681,19 @@ begin end if; end if; end process pPOS_REGs; - + end generate gPOS_GEN; - gALU_GEN: if ALU_EN = true generate + gALU_GEN : if ALU_EN = true generate pALU_REGs : process(clk) variable r1_next : std_logic_vector(11 downto 0); begin - if(clk = '1' and clk'event) then + if (clk = '1' and clk'event) then -- Update ALU register R1 - if(busy_i = '0' and r1_data_valid = '1') then + if (busy_i = '0' and r1_data_valid = '1') then r1 <= R1_data; - elsif(alu_upd = '1') then + elsif (alu_upd = '1') then case subcode is when x"2" => r1_next := operand_1; @@ -706,22 +706,22 @@ begin r1 <= r1_next; end if; -- Update ALU flag - if(alu_upd = '1') then + if (alu_upd = '1') then case subcode is when x"0" => - if((trigger_in(TRIGGER_WIDTH-1 downto 0) and trig_mask(TRIGGER_WIDTH-1 downto 0)) = (operand_comp(TRIGGER_WIDTH-1 downto 0) and trig_mask(TRIGGER_WIDTH-1 downto 0))) then + if ((trigger_in(TRIGGER_WIDTH - 1 downto 0) and trig_mask(TRIGGER_WIDTH - 1 downto 0)) = (operand_comp(TRIGGER_WIDTH - 1 downto 0) and trig_mask(TRIGGER_WIDTH - 1 downto 0))) then flag <= '1'; else flag <= '0'; end if; - when x"1"=> - if(r1 = operand_1) then + when x"1" => + if (r1 = operand_1) then flag <= '1'; else flag <= '0'; end if; when x"2" | x"3" | x"4" => - if(signed(r1_next) = 0) then + if (signed(r1_next) = 0) then flag <= '1'; else flag <= '0'; @@ -731,51 +731,51 @@ begin end if; end if; end process pALU_REGs; - + end generate gALU_GEN; - gALU_NOGEN: if ALU_EN = false generate + gALU_NOGEN : if ALU_EN = false generate r1 <= (others => '0'); flag <= '0'; - + end generate gALU_NOGEN; gQUEUE_GEN : if QUEUE_EN = true generate pQUEUE_REGs : process(clk) - Begin - if(clk = '1' and clk'event) then + begin + if (clk = '1' and clk'event) then queue_add_flag_d <= queue_add_flag and seq_completed; - queue_inc <= queue_add_flag_i and (not queue_add(queue_add'left)); - queue_dec <= queue_add_flag_i and queue_add(queue_add'left); - if(queue_add_flag = '1' and queue_add(queue_add'left) = '1') then - queue_add_i <= std_logic_vector(unsigned(not(queue_add)) + 1); + queue_inc <= queue_add_flag_i and (not queue_add(queue_add'left)); + queue_dec <= queue_add_flag_i and queue_add(queue_add'left); + if (queue_add_flag = '1' and queue_add(queue_add'left) = '1') then + queue_add_i <= std_logic_vector(unsigned(not (queue_add)) + 1); else queue_add_i <= queue_add; end if; - if(seq_enable = '0' or clr_seq_queue_i = '1') then + if (seq_enable = '0' or clr_seq_queue_i = '1') then queue_left <= (others => '0'); - elsif(seq_completed = '1') then - queue_left <= std_logic_vector(unsigned(queue_left)-1); - elsif(queue_inc = '1') then - queue_left <= std_logic_vector(unsigned(queue_left)+unsigned(queue_add_i)); - elsif(queue_dec = '1') then - queue_left <= std_logic_vector(unsigned(queue_left)-unsigned(queue_add_i)); - end if; - if(seq_enable = '0' or clr_seq_queue_exe = '1') then - queue_exec <= (others => '0'); - elsif(seq_completed = '1') then - queue_exec <= std_logic_vector(unsigned(queue_exec)+1); + elsif (seq_completed = '1') then + queue_left <= std_logic_vector(unsigned(queue_left) - 1); + elsif (queue_inc = '1') then + queue_left <= std_logic_vector(unsigned(queue_left) + unsigned(queue_add_i)); + elsif (queue_dec = '1') then + queue_left <= std_logic_vector(unsigned(queue_left) - unsigned(queue_add_i)); end if; - end if; + if (seq_enable = '0' or clr_seq_queue_exe = '1') then + queue_exec <= (others => '0'); + elsif (seq_completed = '1') then + queue_exec <= std_logic_vector(unsigned(queue_exec) + 1); + end if; + end if; end process pQUEUE_REGs; clr_seq_queue_i <= '1' when clr_seq_queue = '1' or (queue_dec = '1' and unsigned(queue_left) < unsigned(queue_add_i)) else '0'; -- if seq_completed is asserted together with queue_add_flag, delay -- queue_add_flag of 1 clock cycle - queue_add_flag_i <= queue_add_flag or queue_add_flag_d; + queue_add_flag_i <= queue_add_flag or queue_add_flag_d; end generate gQUEUE_GEN; From ddd0af1d79ca342db0b084999e9a3a7c5a9c6fec Mon Sep 17 00:00:00 2001 From: Simon Southwell Date: Tue, 14 May 2019 12:41:53 +0100 Subject: [PATCH 06/29] HMBFDHV-78 Adding generic to control instantiation, or not, of virtual memory TLB lookup and associated logic so that projects not using these features can reduce the resource requirements of the block. --- .../data_streamer/7/src/data_streamer_7.vhd | 398 ++++++++++-------- 1 file changed, 212 insertions(+), 186 deletions(-) diff --git a/generic_ip/data_streamer/7/src/data_streamer_7.vhd b/generic_ip/data_streamer/7/src/data_streamer_7.vhd index d93f672..12fc5c4 100644 --- a/generic_ip/data_streamer/7/src/data_streamer_7.vhd +++ b/generic_ip/data_streamer/7/src/data_streamer_7.vhd @@ -42,8 +42,9 @@ use work.pkg_functions.all; entity data_streamer_7 is generic ( - NUM_EXT_DSTS : natural range 1 to 16 := 5; - CMD_QUEUE_DEPTH : natural range 1 to 1024 := 32 + NUM_EXT_DSTS : natural range 1 to 16 := 5; + CMD_QUEUE_DEPTH : natural range 1 to 1024 := 32; + EXCLUDE_VIRTUAL_MAPPING_LOGIC : boolean := false ); port( @@ -106,7 +107,7 @@ architecture rtl of data_streamer_7 is constant CONST_IP_ID_NUMBER : std_logic_vector(7 downto 0) := 8x"0d"; constant CONST_IP_ID_MFR_NUMBER: std_logic_vector(7 downto 0) := 8x"04"; - constant CONST_IP_VER_MINOR : std_logic_vector(7 downto 0) := 8x"01"; + constant CONST_IP_VER_MINOR : std_logic_vector(7 downto 0) := 8x"02"; constant CONST_IP_VER_MAJOR : std_logic_vector(7 downto 0) := 8x"07"; subtype CMD_BITS is natural range 3 downto 0; @@ -204,6 +205,8 @@ architecture rtl of data_streamer_7 is signal cmd_port_wr_int : std_logic; signal cmd_port_int : std_logic_vector(31 downto 0); + + signal is_slim : std_logic; begin @@ -242,7 +245,9 @@ begin -- --------------------------------------- -- Address translation queue -- --------------------------------------- - tlb_queue_inst : entity work.tlb_queue_7 + + GEN_TLB: if not EXCLUDE_VIRTUAL_MAPPING_LOGIC generate + tlb_queue_inst : entity work.tlb_queue_7 generic map( QUEUE_DEPTH => CMD_QUEUE_DEPTH ) @@ -259,10 +264,35 @@ begin empty => tlb_empty ); + + end generate; + -- --------------------------------------- -- COMBINATORIAL SIGNALS -- --------------------------------------- + + GEN_SLIM : if EXCLUDE_VIRTUAL_MAPPING_LOGIC generate + is_slim <= '1'; + end generate; + + GEN_NOT_SLIM : if not EXCLUDE_VIRTUAL_MAPPING_LOGIC generate + is_slim <= '0'; + + -- Flag when the address low bits (page offset) are 0 + addr_offset_is_zero <= '1' when curr_vaddr(11 downto 2) = 10x"0" else '0'; + + -- Flag when remaining_burst count is 0 + remaining_burst_is_zero <= '1' when remaining_burst = 12x"0" else '0'; + + -- Calculate the number of words from the address page offset to the end of the page + count_to_page_bdry <= PAGE_WORD_LEN - unsigned(curr_vaddr(11 downto 2)); + + page_num <= curr_vaddr(31 downto 12) when use_latched_addr = '1' else cmd_data_q(31 downto 12); + + -- Flag when the command queue output (paramter 0 bits) match the TLB virtual address + vaddr_match <= '1' when page_num = tlb_rd_data(19 downto 0) else '0'; + end generate; cmd_q_write_int <= cmd_port_wr_int or dest_port_wr_int(NUM_EXT_DSTS); cmd_q_write <= cmd_q_write_int and not cmd_full; @@ -276,20 +306,6 @@ begin cmd_read <= (cmd_available and not cmd_pending and not data_cmd_active and not tlb_cmd_active and loop_count_is_zero) or cmd_gobble or pop_parameter; - -- Flag when the address low bits (page offset) are 0 - addr_offset_is_zero <= '1' when curr_vaddr(11 downto 2) = 10x"0" else '0'; - - -- Flag when remaining_burst count is 0 - remaining_burst_is_zero <= '1' when remaining_burst = 12x"0" else '0'; - - -- Calculate the number of words from the address page offset to the end of the page - count_to_page_bdry <= PAGE_WORD_LEN - unsigned(curr_vaddr(11 downto 2)); - - page_num <= curr_vaddr(31 downto 12) when use_latched_addr = '1' else cmd_data_q(31 downto 12); - - -- Flag when the command queue output (paramter 0 bits) match the TLB virtual address - vaddr_match <= '1' when page_num = tlb_rd_data(19 downto 0) else '0'; - -- Flag when there is enough space in the command queue for a LD_CMD_Q transfer cmd_dest_rdy <= '1' when status_queue_space >= remaining_burst else '0'; @@ -304,7 +320,7 @@ begin okay_to_transfer <= avm_active_read and dst_port_rdy; -- Combined errors signal - cmd_error <= tlb_mismatch_err or tlb_empty_err or auto_load_err or + cmd_error <= (not is_slim and (tlb_mismatch_err or tlb_empty_err)) or auto_load_err or bad_cmd_err or cpu_race_err or overrun_err; -- An AVM read is active when read asserted and no wait request @@ -388,7 +404,7 @@ begin end if; -- Latch the command value when not pending for use in processing any subsequent parameters - if (cmd_pending = '0' and loop_count_is_zero = '1') or (tlb_write = '1' and cmd_available = '1') then + if (cmd_pending = '0' and loop_count_is_zero = '1') or (is_slim = '0' and tlb_write = '1' and cmd_available = '1') then cmd_data <= cmd_data_q; end if; @@ -475,136 +491,137 @@ begin -- Reading data into the command queue (CMD_LD_CMD_Q) is almost identical, but for a -- different destination. when CMD_RD_DATA_VADDR | CMD_LD_CMD_Q => - - if cmd_pending = '0' then - -- Latch the word length into the remaining burst counter - remaining_burst <= cmd_data(CMD_PARAM0_WORDLEN); - - loop_is_first <= '1'; - - if cmd_data(CMD_BITS) = CMD_LD_CMD_Q then - -- Destination index for command queue is one above the defined number of external desitinations. - dst_sel <= std_logic_vector(to_unsigned(NUM_EXT_DSTS, 4)); - - -- Flag that auto-loading commands are now active whenever a LD_CMD_Q is written. - -- This will not be cleared until the command queue is empty and no outstanding - -- data transfers - auto_cmd_active <= '1'; - else - -- Latch the destination index - dst_sel <= cmd_data(CMD_DEST_BITS); - end if; - - -- Command is now pending until parameters (if any processed) and command completed. - cmd_pending <= '1'; - - -- For virtual commands, flag to pop the virtual address parameter - fetch_vaddr <= '1'; - - -- Won't commit to the read until cmd_pending phase and destination is ready - read_committed <= '0'; - - -- Clear the state that inidicates that the correct TLB map is found. - checked_tlb <= '0'; - - elsif dst_port_rdy = '1' or read_committed = '1' then - - -- As the destination has been seen as ready, commit to the reads, including the multi-burst page crossing accesses - read_committed <= '1'; - - -- If a new TLB entry was extracted, check it matches otherwise it's an error - if tlb_read_last = '1' and vaddr_match = '0' then - tlb_mismatch_err <= '1'; - end if; - - -- If the virtual address does not match that at the o/p of the TLB queue, - -- pop the value from the queue to get the next one. Only check this if not validated - -- before, since the parameter may have been popped from the queue. - if checked_tlb = '0' then - -- Pop the entry - tlb_read <= not vaddr_match and not tlb_read and not tlb_empty; - - -- It is an error if the queue is empty - tlb_empty_err <= tlb_empty; - - -- Flag that we checked the TLB output already - checked_tlb <= '1'; - - else - - -- If first cycle with virtual address parameter from queue, latch the - -- low bits this cycle to relieve timing on processing in the following cycles. - if fetch_vaddr = '1' then - if use_latched_addr = '0' then - curr_vaddr <= cmd_data_q; - diag_2 <= cmd_data_q; - end if; - fetch_vaddr <= '0'; - - elsif data_cmd_active = '0' then - -- If address low bits are not page aligned... - if not addr_offset_is_zero then - - -- If burst does not cross a page boundary then set burst length to remaining - -- words, set remaining count to 0 and clear multi-burst flag as this is the last - -- transfer. - if count_to_page_bdry >= unsigned(remaining_burst) then - var_multi_burst := '0'; - - avm_rx_burstcount <= remaining_burst; - var_remaining_burst := (others => '0'); - -- If burst crosses a page boundary, set the burst count to take us up to - -- the next page boundary, and subtract that length from remaining count. - -- Subsequent bursts should all be page aligned. - else - avm_rx_burstcount <= "00" & std_logic_vector(count_to_page_bdry); - var_remaining_burst := std_logic_vector(unsigned(remaining_burst) - count_to_page_bdry); + if is_slim = '0' then + if cmd_pending = '0' then + -- Latch the word length into the remaining burst counter + remaining_burst <= cmd_data(CMD_PARAM0_WORDLEN); + + loop_is_first <= '1'; + + if cmd_data(CMD_BITS) = CMD_LD_CMD_Q then + -- Destination index for command queue is one above the defined number of external desitinations. + dst_sel <= std_logic_vector(to_unsigned(NUM_EXT_DSTS, 4)); + + -- Flag that auto-loading commands are now active whenever a LD_CMD_Q is written. + -- This will not be cleared until the command queue is empty and no outstanding + -- data transfers + auto_cmd_active <= '1'; + else + -- Latch the destination index + dst_sel <= cmd_data(CMD_DEST_BITS); + end if; + + -- Command is now pending until parameters (if any processed) and command completed. + cmd_pending <= '1'; + + -- For virtual commands, flag to pop the virtual address parameter + fetch_vaddr <= '1'; + + -- Won't commit to the read until cmd_pending phase and destination is ready + read_committed <= '0'; + + -- Clear the state that inidicates that the correct TLB map is found. + checked_tlb <= '0'; + + elsif dst_port_rdy = '1' or read_committed = '1' then + + -- As the destination has been seen as ready, commit to the reads, including the multi-burst page crossing accesses + read_committed <= '1'; + + -- If a new TLB entry was extracted, check it matches otherwise it's an error + if tlb_read_last = '1' and vaddr_match = '0' then + tlb_mismatch_err <= '1'; + end if; + + -- If the virtual address does not match that at the o/p of the TLB queue, + -- pop the value from the queue to get the next one. Only check this if not validated + -- before, since the parameter may have been popped from the queue. + if checked_tlb = '0' then + -- Pop the entry + tlb_read <= not vaddr_match and not tlb_read and not tlb_empty; + + -- It is an error if the queue is empty + tlb_empty_err <= tlb_empty; + + -- Flag that we checked the TLB output already + checked_tlb <= '1'; + + else + + -- If first cycle with virtual address parameter from queue, latch the + -- low bits this cycle to relieve timing on processing in the following cycles. + if fetch_vaddr = '1' then + if use_latched_addr = '0' then + curr_vaddr <= cmd_data_q; + diag_2 <= cmd_data_q; end if; - - -- Address low bits are page aligned... - else - -- If remaining burst is equal or less than a page, set burst to be remaining - -- count, set the count to 0 and clear the multi-burst variable as this is the last - -- transfer. - if unsigned(remaining_burst) <= PAGE_WORD_LEN then - var_multi_burst := '0'; - - avm_rx_burstcount <= remaining_burst; - var_remaining_burst := (others => '0'); - - -- If the remaining count is greater than a page, set the burst length to a page - -- and subtract the length from the remaining count. + fetch_vaddr <= '0'; + + elsif data_cmd_active = '0' then + -- If address low bits are not page aligned... + if not addr_offset_is_zero then + + -- If burst does not cross a page boundary then set burst length to remaining + -- words, set remaining count to 0 and clear multi-burst flag as this is the last + -- transfer. + if count_to_page_bdry >= unsigned(remaining_burst) then + var_multi_burst := '0'; + + avm_rx_burstcount <= remaining_burst; + var_remaining_burst := (others => '0'); + -- If burst crosses a page boundary, set the burst count to take us up to + -- the next page boundary, and subtract that length from remaining count. + -- Subsequent bursts should all be page aligned. + else + avm_rx_burstcount <= "00" & std_logic_vector(count_to_page_bdry); + var_remaining_burst := std_logic_vector(unsigned(remaining_burst) - count_to_page_bdry); + end if; + + -- Address low bits are page aligned... else - avm_rx_burstcount <= std_logic_vector(to_unsigned(PAGE_WORD_LEN, 12)); - var_remaining_burst := std_logic_vector(unsigned(remaining_burst) - PAGE_WORD_LEN); + -- If remaining burst is equal or less than a page, set burst to be remaining + -- count, set the count to 0 and clear the multi-burst variable as this is the last + -- transfer. + if unsigned(remaining_burst) <= PAGE_WORD_LEN then + var_multi_burst := '0'; + + avm_rx_burstcount <= remaining_burst; + var_remaining_burst := (others => '0'); + + -- If the remaining count is greater than a page, set the burst length to a page + -- and subtract the length from the remaining count. + else + avm_rx_burstcount <= std_logic_vector(to_unsigned(PAGE_WORD_LEN, 12)); + var_remaining_burst := std_logic_vector(unsigned(remaining_burst) - PAGE_WORD_LEN); + end if; end if; - end if; - - -- When transfer initiated, update the remaining burst count to take in to account - -- the words requested. - if avm_active_read = '1' then - remaining_burst <= var_remaining_burst; - end if; - - -- The address to use is the TLB physical address bits, and the addr lower bits. - avm_rx_address <= tlb_rd_data(39 downto 20) & curr_vaddr(11 downto 0); - - -- Issue the read command. Hold until active (no wait request). - avm_rx_read <= not avm_active_read; - - -- Flag as data transfer active only if source and destination are ready - data_cmd_active <= avm_active_read; - - -- Complete command (clear pending) when source and destination ready - -- and not a multi-burst command - cmd_pending <= not avm_active_read or var_multi_burst; - - -- Flag when a LD_CMD_Q command popped from the queue and has started running (i.e. when cmd_pending cleared) - if cmd_data(CMD_BITS) = CMD_LD_CMD_Q then - -- It is an error to have insufficient space left when executing LD_CMD_Q, as - -- it is a lock condition. - if not dst_port_rdy then - auto_load_err <= '1'; + + -- When transfer initiated, update the remaining burst count to take in to account + -- the words requested. + if avm_active_read = '1' then + remaining_burst <= var_remaining_burst; + end if; + + -- The address to use is the TLB physical address bits, and the addr lower bits. + avm_rx_address <= tlb_rd_data(39 downto 20) & curr_vaddr(11 downto 0); + + -- Issue the read command. Hold until active (no wait request). + avm_rx_read <= not avm_active_read; + + -- Flag as data transfer active only if source and destination are ready + data_cmd_active <= avm_active_read; + + -- Complete command (clear pending) when source and destination ready + -- and not a multi-burst command + cmd_pending <= not avm_active_read or var_multi_burst; + + -- Flag when a LD_CMD_Q command popped from the queue and has started running (i.e. when cmd_pending cleared) + if cmd_data(CMD_BITS) = CMD_LD_CMD_Q then + -- It is an error to have insufficient space left when executing LD_CMD_Q, as + -- it is a lock condition. + if not dst_port_rdy then + auto_load_err <= '1'; + end if; end if; end if; end if; @@ -613,16 +630,18 @@ begin -- When a TLB load command, grab the parameters, and push to the queue when CMD_LD_ADDR_MAP => - if cmd_pending = '0' then - cmd_pending <= '1'; - pop_parameter <= '1'; - paddr <= cmd_data(CMD_PARAM_0); - else - cmd_pending <= '0'; - tlb_cmd_active <= '1'; - tlb_write <= '1'; - tlb_wr_data <= paddr & cmd_data_q(31 downto 12); - diag_2 <= cmd_data_q; + if is_slim = '0' then + if cmd_pending = '0' then + cmd_pending <= '1'; + pop_parameter <= '1'; + paddr <= cmd_data(CMD_PARAM_0); + else + cmd_pending <= '0'; + tlb_cmd_active <= '1'; + tlb_write <= '1'; + tlb_wr_data <= paddr & cmd_data_q(31 downto 12); + diag_2 <= cmd_data_q; + end if; end if; -- A NOP command @@ -673,24 +692,27 @@ begin -- Clear the strip active flag data_cmd_active <= '0'; - -- Increment the latched virtual address's page number, and set the offset - -- bits to zero, as next burst starts from thebegiinng of the next virtual - -- page. - curr_vaddr <= std_logic_vector(unsigned(curr_vaddr(31 downto 12)) + 1) & 12x"0"; - - - -- If more bursts to come, flag to use the latched virtual address, and clear - -- set the fetch_vaddr flag to indicate re-checking of TLB mapping required - if remaining_burst_is_zero = '0' then - use_latched_addr <= '1'; - fetch_vaddr <= '1'; - -- If at the end of the last burst, clear the use_latched_addr and fetch_vaddr state - else - use_latched_addr <= '0'; - fetch_vaddr <= '0'; + if is_slim = '0' then + + -- Increment the latched virtual address's page number, and set the offset + -- bits to zero, as next burst starts from thebegiinng of the next virtual + -- page. + curr_vaddr <= std_logic_vector(unsigned(curr_vaddr(31 downto 12)) + 1) & 12x"0"; + + + -- If more bursts to come, flag to use the latched virtual address, and clear + -- set the fetch_vaddr flag to indicate re-checking of TLB mapping required + if remaining_burst_is_zero = '0' then + use_latched_addr <= '1'; + fetch_vaddr <= '1'; + -- If at the end of the last burst, clear the use_latched_addr and fetch_vaddr state + else + use_latched_addr <= '0'; + fetch_vaddr <= '0'; + end if; + + checked_tlb <= '0'; end if; - - checked_tlb <= '0'; end if; @@ -707,7 +729,7 @@ begin -- A TLB load command is cmpeted in the cycle after the TLB queue was written, to ensure -- that the new translatin is available for the next command. - if tlb_write_last = '1' then + if is_slim = '0' and tlb_write_last = '1' then tlb_cmd_active <= '0'; end if; @@ -728,7 +750,7 @@ begin -- Latch the read data for the pixel buffer when data arrives from memory if avm_rx_readdatavalid = '1' then - if control_msb = '1' then + if is_slim = '0' and control_msb = '1' then dest_port_wr_data_int <= avm_rx_readdata( 7 downto 0) & avm_rx_readdata(15 downto 8) & avm_rx_readdata(23 downto 16) & avm_rx_readdata(31 downto 24); else @@ -736,12 +758,14 @@ begin end if; end if; + if is_slim = '0' then -- Assert IRQ if number of used command queue spaces falls below watermark - if unsigned(usedw) < unsigned(control_watermark) and cmd_full = '0' then - irq <= '1'; - else - -- Assert the interrupt if there's an error - irq <= cmd_error; + if unsigned(usedw) < unsigned(control_watermark) and cmd_full = '0' then + irq <= '1'; + else + -- Assert the interrupt if there's an error + irq <= cmd_error; + end if; end if; -- Process the LD_CMD_Q count. Increment when pushed to queue (if not popping) and @@ -750,14 +774,16 @@ begin cmd_pending <= '0'; cmd_available <= '0'; data_cmd_active <= '0'; - read_committed <= '0'; - fetch_vaddr <= '0'; - checked_tlb <= '0'; - use_latched_addr <= '0'; + if is_slim ='0' then + read_committed <= '0'; + fetch_vaddr <= '0'; + checked_tlb <= '0'; + use_latched_addr <= '0'; + end if; end if; -- This is a debug signal to expose the variable if needed - multi_burst_last <= var_multi_burst; + multi_burst_last <= not is_slim and var_multi_burst; if control_clr_dst0_count = '1' then diag_dst0_count <= (others => '0'); From fd869005c04d263a0fad678ccf59b8254520358d Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Fri, 17 May 2019 10:41:23 +0100 Subject: [PATCH 07/29] ELGIP-46 - Renamed signal "flag" to "zero_flag" to improve code clarity --- .../15/src/generic_sequencer_15.vhd | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd b/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd index 299d952..93c8597 100644 --- a/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd +++ b/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd @@ -6,7 +6,7 @@ -- Author : Robbie Temple (original) -- Company : Global Inkjet Systems -- Created : 2016-05-12 --- Last update: 2019-05-10 +-- Last update: 2019-05-17 -- SVN ID : Git -- Standard : VHDL'2008 ------------------------------------------------------------------------------- @@ -136,7 +136,7 @@ architecture rtl of generic_sequencer_15 is signal ld_start_addr, inc_ram_addr : std_logic; signal ld_trig_mask, ld_trig_sel : std_logic; signal ld_pos : std_logic; - signal flag, alu_upd : std_logic; + signal zero_flag, alu_upd : std_logic; signal clr_vec_i, clr_vec_ii : std_logic; signal fetch_op, ramp_up : std_logic; signal op_cnt_done, inc_op_cnt : std_logic; @@ -586,8 +586,8 @@ begin ld_jmp_addr <= '1' when decode = '1' and (jump_abs = '1' or jump_rel = '1' or jump_r1 = '1') else '0'; - jump_abs <= '1' when (opcode = CMD_JUMP and (subcode = X"0" or (subcode = X"1" and flag = '1') or (subcode = X"2" and flag = '0'))) or (opcode = CMD_END and subcode = X"1") else '0'; - jump_rel <= '1' when (opcode = CMD_BRANCH and (subcode = X"0" or (subcode = X"1" and flag = '1') or (subcode = X"2" and flag = '0'))) or (opcode = CMD_LOOP and loop_done = '0') or (opcode = CMD_END and subcode = X"2") else '0'; + jump_abs <= '1' when (opcode = CMD_JUMP and (subcode = X"0" or (subcode = X"1" and zero_flag = '1') or (subcode = X"2" and zero_flag = '0'))) or (opcode = CMD_END and subcode = X"1") else '0'; + jump_rel <= '1' when (opcode = CMD_BRANCH and (subcode = X"0" or (subcode = X"1" and zero_flag = '1') or (subcode = X"2" and zero_flag = '0'))) or (opcode = CMD_LOOP and loop_done = '0') or (opcode = CMD_END and subcode = X"2") else '0'; jump_r1 <= '1' when opcode = CMD_JUMP and subcode = X"F" else '0'; save_ret_addr <= ld_jmp_addr; @@ -710,21 +710,21 @@ begin case subcode is when x"0" => if ((trigger_in(TRIGGER_WIDTH - 1 downto 0) and trig_mask(TRIGGER_WIDTH - 1 downto 0)) = (operand_comp(TRIGGER_WIDTH - 1 downto 0) and trig_mask(TRIGGER_WIDTH - 1 downto 0))) then - flag <= '1'; + zero_flag <= '1'; else - flag <= '0'; + zero_flag <= '0'; end if; when x"1" => if (r1 = operand_1) then - flag <= '1'; + zero_flag <= '1'; else - flag <= '0'; + zero_flag <= '0'; end if; when x"2" | x"3" | x"4" => if (signed(r1_next) = 0) then - flag <= '1'; + zero_flag <= '1'; else - flag <= '0'; + zero_flag <= '0'; end if; when others => null; end case; From ae26e0c6c69eecd4f94464fff8a8759bf4e22c97 Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Fri, 17 May 2019 10:51:40 +0100 Subject: [PATCH 08/29] ELGIP-45 Added a Pragma to signal out-of-bound trigger selection --- generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd b/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd index 93c8597..a46146a 100644 --- a/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd +++ b/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd @@ -285,6 +285,10 @@ begin trig_int <= trigger_in(to_integer(unsigned(trig_sel))) and trig_mask(to_integer(unsigned(trig_sel))); + --pragma translate_off + assert (to_integer(unsigned(trig_sel)) < TRIGGER_WIDTH) report "ERROR: trig_sel out of selectable trigger mask" severity failure; + --pragma translate_off + ----------------------------------------------------------------------------- -- Dual-Port Memory buffer ----------------------------------------------------------------------------- From 5e32a1d607de9ec6e1738424b74811b71ab7f2d9 Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Fri, 17 May 2019 13:39:08 +0100 Subject: [PATCH 09/29] ELGIP-46 - Missed from previous modification (flag renamed to zero_flag) --- generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd b/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd index a46146a..a46d94e 100644 --- a/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd +++ b/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd @@ -740,8 +740,8 @@ begin gALU_NOGEN : if ALU_EN = false generate - r1 <= (others => '0'); - flag <= '0'; + r1 <= (others => '0'); + zero_flag <= '0'; end generate gALU_NOGEN; From 561aa7bf6e9dd79d0aea6eabd5d8bd59ee674bb2 Mon Sep 17 00:00:00 2001 From: Damian Smith Date: Mon, 20 May 2019 15:49:19 +0100 Subject: [PATCH 10/29] ELGIP-46 pragma error corrected (was leaving translation off!) --- generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd b/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd index a46d94e..6e7048a 100644 --- a/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd +++ b/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd @@ -287,7 +287,7 @@ begin --pragma translate_off assert (to_integer(unsigned(trig_sel)) < TRIGGER_WIDTH) report "ERROR: trig_sel out of selectable trigger mask" severity failure; - --pragma translate_off + --pragma translate_on ----------------------------------------------------------------------------- -- Dual-Port Memory buffer From 6a2ef72157c8a40913f601abc854ccea4378d823 Mon Sep 17 00:00:00 2001 From: Damian Smith Date: Tue, 21 May 2019 17:10:06 +0100 Subject: [PATCH 11/29] HMBFDHV-83 Declared in JSON as a minor change so far as timing is unchanged. pipelined the maths on delay times to help improve timing closure. --- generic_ip/common/0/src/queue_and_delay.vhd | 24 +- .../fire_pulse_manager/1/doc/fpm_ctrl_1.json | 2 +- .../fire_pulse_manager/1/sim/sim_fpm.do | 4 +- .../1/src/fire_pulse_manager_1.vhd | 579 +++++++++--------- .../1/doc/pulse_generator_1.json | 2 +- .../1/src/pulse_generator_1.vhd | 452 +++++++------- .../1/src/queue_and_delay_1.vhd | 174 +++--- 7 files changed, 619 insertions(+), 618 deletions(-) diff --git a/generic_ip/common/0/src/queue_and_delay.vhd b/generic_ip/common/0/src/queue_and_delay.vhd index 8e087e5..e5b67e4 100644 --- a/generic_ip/common/0/src/queue_and_delay.vhd +++ b/generic_ip/common/0/src/queue_and_delay.vhd @@ -68,7 +68,7 @@ architecture RTL of queue_and_delay is signal cnt_dir_i, wave_out_i_d, new_event : std_logic; signal wave_out_ii, shf_enable : std_logic; signal delay_line : std_logic_vector( 7 downto 0); - signal local_time, local_time_d, event_time : std_logic_vector(31 downto 0); + signal int_time, local_time_d, event_time : std_logic_vector(31 downto 0); begin -- RTL @@ -93,7 +93,7 @@ begin -- RTL FIFO_DEPTH => queue_size) port map ( clock => clk, - data => local_time, + data => int_time, rdreq => fifo_rd_en, sclr => init, wrreq => toggle_in, @@ -118,24 +118,24 @@ begin -- RTL -- Time reference: either use the external one or generate it locally gTIME_REF0: if use_ext_time = true generate - local_time <= ext_time; + int_time <= ext_time; - shf_enable <= '1' when local_time /= local_time_d else '0'; + shf_enable <= '1' when int_time /= local_time_d else '0'; - --pTimeElapsed : process(cnt_dir, local_time, event_time, delay) + --pTimeElapsed : process(cnt_dir, int_time, event_time, delay) pTimeElapsed : process(clk) begin if(clk = '1' and clk'event) then - local_time_d <= local_time; + local_time_d <= int_time; cnt_dir_i <= cnt_dir; if(cnt_dir_i = '0') then - if(signed(local_time) >= signed(event_time) + signed(delay)) then + if(signed(int_time) >= signed(event_time) + signed(delay)) then time_elapsed <= '1'; else time_elapsed <= '0'; end if; else - if(signed(local_time) <= signed(event_time) - signed(delay)) then + if(signed(int_time) <= signed(event_time) - signed(delay)) then time_elapsed <= '1'; else time_elapsed <= '0'; @@ -152,18 +152,18 @@ begin -- RTL pGEN_LOC_REF : process(rstN, clk) begin if(rstN = '0') then - local_time <= (others => '0'); + int_time <= (others => '0'); elsif(clk = '1' and clk'event) then if(init = '1') then - local_time <= (others => '0'); + int_time <= (others => '0'); else - local_time <= std_logic_vector(unsigned(local_time)+1); + int_time <= std_logic_vector(unsigned(int_time)+1); end if; end if; end process pGEN_LOC_REF; new_event <= fifo_rd_en; - time_elapsed <= '1' when unsigned(local_time) >= unsigned(event_time) + unsigned(delay) else '0'; + time_elapsed <= '1' when unsigned(int_time) >= unsigned(event_time) + unsigned(delay) else '0'; shf_enable <= '1'; diff --git a/generic_ip/fire_pulse_manager/1/doc/fpm_ctrl_1.json b/generic_ip/fire_pulse_manager/1/doc/fpm_ctrl_1.json index 0bb3b6b..ec932f6 100644 --- a/generic_ip/fire_pulse_manager/1/doc/fpm_ctrl_1.json +++ b/generic_ip/fire_pulse_manager/1/doc/fpm_ctrl_1.json @@ -36,7 +36,7 @@ "minor_number" : { "type" : "c", "bit_len" : "8", - "reset" : "0x01", + "reset" : "0x02", "description" : "Minor number" }, "major_number" : { diff --git a/generic_ip/fire_pulse_manager/1/sim/sim_fpm.do b/generic_ip/fire_pulse_manager/1/sim/sim_fpm.do index 53ac1ed..f6ba4aa 100644 --- a/generic_ip/fire_pulse_manager/1/sim/sim_fpm.do +++ b/generic_ip/fire_pulse_manager/1/sim/sim_fpm.do @@ -72,13 +72,13 @@ vcom -2008 -work $WORKLIB $TB_PATH/fire_pulse_manager_1_tb.vhd vsim -t ps work.fire_pulse_manager_1_tb # Add waves -add wave -r sim:/fire_pulse_manager_1_tb/* +#add wave -r sim:/fire_pulse_manager_1_tb/* # remove warnings from standard numeric/arithmetic packages (speed-up simulation) set StdArithNoWarnings 1 set NumericStdNoWarnings 1 -when -label end_of_simulation {test_completed == true} {echo "Simulation Completed"; stop ;} +#when -label end_of_simulation {test_completed == true} {echo "Simulation Completed"; stop ;} run -all diff --git a/generic_ip/fire_pulse_manager/1/src/fire_pulse_manager_1.vhd b/generic_ip/fire_pulse_manager/1/src/fire_pulse_manager_1.vhd index b250435..b7126c5 100644 --- a/generic_ip/fire_pulse_manager/1/src/fire_pulse_manager_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/fire_pulse_manager_1.vhd @@ -19,7 +19,6 @@ library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; -library work; use work.fire_pulse_1_pkg.all; entity fire_pulse_manager_1 is @@ -31,14 +30,14 @@ entity fire_pulse_manager_1 is pof_rx : in std_logic; pof_tx : out std_logic; pof_iso_en : out std_logic; - fire_pulse : out std_logic_vector(ch_num-1 downto 0); - mon_pt : out std_logic_vector( 3 downto 0); -- Monitoring Points - -- on header J7 + fire_pulse : out std_logic_vector(ch_num - 1 downto 0); + mon_pt : out std_logic_vector(3 downto 0); -- Monitoring Points + -- on header J7 -- Interrupt Senders ins_fpm_irq_0 : out std_logic; - ins_fpm_irq_1 : out std_logic; - ins_fpm_irq_2 : out std_logic; - ins_fpm_irq_3 : out std_logic; + ins_fpm_irq_1 : out std_logic; -- @suppress "Unused port: ins_fpm_irq_1 is not used in work.fire_pulse_manager_1(rtl)" + ins_fpm_irq_2 : out std_logic; -- @suppress "Unused port: ins_fpm_irq_2 is not used in work.fire_pulse_manager_1(rtl)" + ins_fpm_irq_3 : out std_logic; -- @suppress "Unused port: ins_fpm_irq_3 is not used in work.fire_pulse_manager_1(rtl)" -- Avalon MM (Slave) Interface avs_address : in std_logic_vector(14 downto 0); avs_write : in std_logic; @@ -49,241 +48,119 @@ entity fire_pulse_manager_1 is end entity fire_pulse_manager_1; architecture rtl of fire_pulse_manager_1 is - - signal reset_n_i : std_logic; + + signal reset_n_i : std_logic; -- - signal cs_addr : std_logic_vector(10 downto 0); - signal cs_write_en : std_logic_vector(blk_num-1 downto 0); - signal cs_write_data : std_logic_vector(31 downto 0); - signal cs_read_en : std_logic_vector(blk_num-1 downto 0); - signal cs_read_valid : std_logic_vector(blk_num-1 downto 0); - signal cs_read_data : std_logic_vector(32*blk_num-1 downto 0); + signal cs_addr : std_logic_vector(10 downto 0); + signal cs_write_en : std_logic_vector(blk_num - 1 downto 0); + signal cs_write_data : std_logic_vector(31 downto 0); + signal cs_read_en : std_logic_vector(blk_num - 1 downto 0); + signal cs_read_valid : std_logic_vector(blk_num - 1 downto 0); + signal cs_read_data : std_logic_vector(32 * blk_num - 1 downto 0); -- - signal cs_ctrl_write_en : std_logic; - signal cs_ctrl_read_en : std_logic; - signal cs_ctrl_read_valid : std_logic; - signal cs_ctrl_read_data : std_logic_vector(31 downto 0); + signal cs_ctrl_write_en : std_logic; + signal cs_ctrl_read_en : std_logic; + signal cs_ctrl_read_valid : std_logic; + signal cs_ctrl_read_data : std_logic_vector(31 downto 0); -- - signal cs_pg_write_en : std_logic_vector(ch_num-1 downto 0); - signal cs_pg_read_en : std_logic_vector(ch_num-1 downto 0); - signal cs_pg_read_valid : std_logic_vector(ch_num-1 downto 0); - signal cs_pg_read_data : std_logic_vector(32*ch_num-1 downto 0); + signal cs_pg_write_en : std_logic_vector(ch_num - 1 downto 0); + signal cs_pg_read_en : std_logic_vector(ch_num - 1 downto 0); + signal cs_pg_read_valid : std_logic_vector(ch_num - 1 downto 0); + signal cs_pg_read_data : std_logic_vector(32 * ch_num - 1 downto 0); -- - signal cs_nsnk_write_en : std_logic; - signal cs_nsnk_read_en : std_logic; - signal cs_nsnk_read_valid : std_logic; - signal cs_nsnk_read_data : std_logic_vector(31 downto 0); + signal cs_nsnk_write_en : std_logic; + signal cs_nsnk_read_en : std_logic; + signal cs_nsnk_read_valid : std_logic; + signal cs_nsnk_read_data : std_logic_vector(31 downto 0); -- - signal cs_log_write_en : std_logic; - signal cs_log_read_en : std_logic; - signal cs_log_read_valid : std_logic; - signal cs_log_read_data : std_logic_vector(31 downto 0); + signal cs_log_write_en : std_logic; + signal cs_log_read_en : std_logic; + signal cs_log_read_valid : std_logic; + signal cs_log_read_data : std_logic_vector(31 downto 0); -- - signal cs_ie_write_en : std_logic; - signal cs_ie_read_en : std_logic; - signal cs_ie_read_valid : std_logic; - signal cs_ie_read_data : std_logic_vector(31 downto 0); + signal cs_ie_write_en : std_logic; + signal cs_ie_read_en : std_logic; + signal cs_ie_read_valid : std_logic; + signal cs_ie_read_data : std_logic_vector(31 downto 0); -- - signal enable_rx : std_logic; - signal uart_regen_bypass : std_logic; - signal upd_max_pos : std_logic; - signal upd_min_pos : std_logic; - signal max_error_flag : std_logic; - signal rx_watchdog : std_logic; - signal rx_watchdog_en : std_logic; - signal rx_watchdog_clr : std_logic; - signal bit_div : std_logic_vector( 3 downto 0); - signal error_rate_thres : std_logic_vector( 7 downto 0); - signal parity_err_cnt : std_logic_vector(15 downto 0); - signal skip_pos_cnt : std_logic_vector(15 downto 0); - signal mon_point_src : std_logic_vector(15 downto 0); - signal fine_time : std_logic_vector(27 downto 0); - signal coarse_time : std_logic_vector(31 downto 0); + signal enable_rx : std_logic; + signal uart_regen_bypass : std_logic; + signal upd_max_pos : std_logic; + signal upd_min_pos : std_logic; + signal max_error_flag : std_logic; + signal rx_watchdog : std_logic; + signal rx_watchdog_en : std_logic; + signal rx_watchdog_clr : std_logic; + signal bit_div : std_logic_vector(3 downto 0); + signal error_rate_thres : std_logic_vector(7 downto 0); + signal parity_err_cnt : std_logic_vector(15 downto 0); + signal skip_pos_cnt : std_logic_vector(15 downto 0); + signal mon_point_src : std_logic_vector(15 downto 0); + signal fine_time : std_logic_vector(27 downto 0); + signal coarse_time : std_logic_vector(31 downto 0); -- - signal remote_init : std_logic; - signal dp_dir : std_logic_vector(ch_num-1 downto 0); - signal set_pos_ie : std_logic; - signal enc_pulse : std_logic; - signal enc_pulse_ie : std_logic; - signal enc_pulse_pof : std_logic; - signal pd_pulse : std_logic; - signal pd_pulse_ie : std_logic; - signal pd_pulse_pof : std_logic; - signal inc_pos : std_logic; - signal inc_pos_pof : std_logic; - signal inc_pos_ie : std_logic; - signal dec_pos : std_logic; - signal dec_pos_pof : std_logic; - signal dec_pos_ie : std_logic; - signal abs_pos : std_logic_vector(31 downto 0); - signal abs_pos_pof : std_logic_vector(31 downto 0); - signal abs_pos_ie : std_logic_vector(39 downto 0); + signal remote_init : std_logic; + signal dp_dir : std_logic_vector(ch_num - 1 downto 0); + signal set_pos_ie : std_logic; + signal enc_pulse : std_logic; + signal enc_pulse_ie : std_logic; + signal enc_pulse_pof : std_logic; + signal pd_pulse : std_logic; + signal pd_pulse_ie : std_logic; + signal pd_pulse_pof : std_logic; + signal inc_pos : std_logic; + signal inc_pos_pof : std_logic; + signal inc_pos_ie : std_logic; + signal dec_pos : std_logic; + signal dec_pos_pof : std_logic; + signal dec_pos_ie : std_logic; + signal abs_pos : std_logic_vector(31 downto 0); + signal abs_pos_pof : std_logic_vector(31 downto 0); + signal abs_pos_ie : std_logic_vector(39 downto 0); -- - signal ch_pd, ch_pulse_out : std_logic_vector(ch_num-1 downto 0); - signal ch_raw_pulse, ch_mask : std_logic_vector(ch_num-1 downto 0); - signal fire_pulse_i : std_logic_vector(ch_num-1 downto 0); - signal src_sel : std_logic_vector(1 downto 0); + signal ch_pd, ch_pulse_out : std_logic_vector(ch_num - 1 downto 0); + signal ch_raw_pulse, ch_mask : std_logic_vector(ch_num - 1 downto 0); + signal fire_pulse_i : std_logic_vector(ch_num - 1 downto 0); + signal src_sel : std_logic_vector(1 downto 0); -- - signal one_pps : std_logic; - signal ext_fp_det : std_logic_vector(15 downto 0); - signal ext_fp_gen : std_logic_vector(15 downto 0); - signal pof_rx_regen : std_logic; + signal one_pps : std_logic; + signal ext_fp_det : std_logic_vector(15 downto 0); + signal ext_fp_gen : std_logic_vector(15 downto 0); + signal pof_rx_regen : std_logic; begin - ----------------------------------------------------------------------------- - -- Synchronize the input reset (h2f_reset) to the clock (from PLL) - ----------------------------------------------------------------------------- - - iSyncReset : entity work.sync_reset - port map ( - async_rstN => reset_n, - clk => clk, - sync_rstN => reset_n_i); - - - ----------------------------------------------------------------------------- - -- C&S Register Interface Splitting - ----------------------------------------------------------------------------- - - iCS_BUS_ITF: entity work.cs_bus_ift_1 - generic map ( - blk_num => blk_num) - port map ( - rstN => reset_n_i, - clk => clk, - avs_address => avs_address(14 downto 0), - avs_write => avs_write, - avs_writedata => avs_writedata, - avs_read => avs_read, - avs_readdatavalid => avs_readdatavalid, - avs_readdata => avs_readdata, - cs_addr => cs_addr, - cs_we => cs_write_en, - cs_wr_data => cs_write_data, - cs_re => cs_read_en, - cs_rv => cs_read_valid, - cs_rd_data => cs_read_data); - - cs_ctrl_write_en <= cs_write_en(fp_ctrl_id); - cs_pg_write_en_g : for i in 1 to ch_num generate - cs_pg_write_en(i-1) <= cs_write_en(pg_ch_id+i-1); - end generate; - cs_nsnk_write_en <= cs_write_en(net_snk_id); - cs_log_write_en <= cs_write_en(log_blk_id); - cs_ie_write_en <= cs_write_en(int_enc_id); - - cs_ctrl_read_en <= cs_read_en(fp_ctrl_id); - cs_pg_read_en_g : for i in 1 to ch_num generate - cs_pg_read_en(i-1) <= cs_read_en(pg_ch_id+i-1); - end generate; - cs_nsnk_read_en <= cs_read_en(net_snk_id); - cs_log_read_en <= cs_read_en(log_blk_id); - cs_ie_read_en <= cs_read_en(int_enc_id); - - cs_read_valid(fp_ctrl_id) <= cs_ctrl_read_valid; - cs_read_valid_pg_g : for i in 1 to ch_num generate - cs_read_valid(pg_ch_id+i-1) <= cs_pg_read_valid(i-1); - end generate; - cs_read_valid(net_snk_id) <= cs_nsnk_read_valid; - cs_read_valid(log_blk_id) <= cs_log_read_valid; - cs_read_valid(int_enc_id) <= cs_ie_read_valid; - - cs_read_data(31+32*fp_ctrl_id downto 32*fp_ctrl_id) <= cs_ctrl_read_data; - cs_read_data_pg_g : for i in 1 to ch_num generate - cs_read_data(31+32*(pg_ch_id+i-1) downto 32*(pg_ch_id+i-1)) <= cs_pg_read_data(31+32*(i-1) downto 32*(i-1)); - end generate; - cs_read_data(31+32*net_snk_id downto 32*net_snk_id) <= cs_nsnk_read_data; - cs_read_data(31+32*log_blk_id downto 32*log_blk_id) <= cs_log_read_data; - cs_read_data(31+32*int_enc_id downto 32*int_enc_id) <= cs_ie_read_data; - - ----------------------------------------------------------------------------- - -- Fire-Pulse-Manager Controller - ----------------------------------------------------------------------------- - - iCTRL: entity work.fire_pulse_ctrl_1 - port map ( - reset_n => reset_n_i, - clk => clk, - src_sel => src_sel, - uart_regen_bypass => uart_regen_bypass, - upd_max_pos => upd_max_pos, - upd_min_pos => upd_min_pos, - enable_rx => enable_rx, - uart_bit_div => bit_div, - error_rate_thres => error_rate_thres, - max_error_flag => max_error_flag, - rx_watchdog => rx_watchdog, - rx_watchdog_en => rx_watchdog_en, - rx_watchdog_clr => rx_watchdog_clr, - parity_err_cnt => parity_err_cnt, - skip_pos_cnt => skip_pos_cnt, - mon_point_src => mon_point_src, - mon_points => mon_pt, - coarse_time => coarse_time, - fine_time => fine_time, - one_pps => one_pps, - ext_fp_det => ext_fp_det, - ext_fp_gen => ext_fp_gen, - ins_fpm_irq_0 => ins_fpm_irq_0, - avs_address => cs_addr(3 downto 0), - avs_write => cs_ctrl_write_en, - avs_writedata => cs_write_data, - avs_read => cs_ctrl_read_en, - avs_readdatavalid => cs_ctrl_read_valid, - avs_readdata => cs_ctrl_read_data); - - -- Output multiplexer - fire_pulse_i <= ch_pulse_out when src_sel(0) = '1' else (others => pof_rx_regen); - fire_pulse <= fire_pulse_i; - - pd_pulse <= pd_pulse_pof when src_sel(1) = '0' else pd_pulse_ie; - enc_pulse <= enc_pulse_pof when src_sel(1) = '0' else enc_pulse_ie; - abs_pos <= abs_pos_pof when src_sel(1) = '0' else abs_pos_ie(31 downto 0); - inc_pos <= inc_pos_pof when src_sel(1) = '0' else inc_pos_ie; - dec_pos <= dec_pos_pof when src_sel(1) = '0' else dec_pos_ie; - mon_point_src( 0) <= remote_init; - mon_point_src( 1) <= dp_dir(0); - mon_point_src( 2) <= pd_pulse; - mon_point_src( 3) <= enc_pulse; - mon_point_src( 4) <= ch_pd(0); - mon_point_src( 5) <= ch_pulse_out(0); - mon_point_src( 6) <= ch_raw_pulse(0); - mon_point_src( 7) <= ch_mask(0); - mon_point_src( 8) <= pof_rx; - mon_point_src( 9) <= fire_pulse_i(0); - -- - mon_point_src(15 downto 10) <= (others => '0'); - - pof_iso_en <= enable_rx; ----------------------------------------------------------------------------- -- Pulse Generator ----------------------------------------------------------------------------- pulse_generator_g : for i in 1 to ch_num generate - iCH_PG: entity work.pulse_generator_1 - generic map( - out_pulse_condition => true) - port map ( - clk => clk, - reset_n => reset_n_i, - init => remote_init, - pd_in => pd_pulse, - abs_position => abs_pos, - dp_dir => dp_dir(i-1), - pulse_out => ch_pulse_out(i-1), - ch_pd => ch_pd(i-1), - ch_mask => ch_mask(i-1), - raw_pulse_out => ch_raw_pulse(i-1), - enc_pulse => open, - avs_address => cs_addr(9 downto 0), - avs_write => cs_pg_write_en(i-1), - avs_writedata => cs_write_data, - avs_read => cs_pg_read_en(i-1), - avs_readdatavalid => cs_pg_read_valid(i-1), - avs_readdata => cs_pg_read_data(31+32*(i-1) downto 32*(i-1))); + iCH_PG : entity work.pulse_generator_1 + generic map( + PD_QUEUE_SIZE => 64, -- make default explicit + PULSE_DELAY_EQUAL_EN => true, -- make default explicit + OUT_PULSE_CONDITION => true) + port map( + clk => clk, + reset_n => reset_n_i, + init => remote_init, + pd_in => pd_pulse, + abs_position => abs_pos, + dp_dir => dp_dir(i - 1), + pulse_out => ch_pulse_out(i - 1), + filtered_pd => open, + ch_pd => ch_pd(i - 1), + ch_mask => ch_mask(i - 1), + raw_pulse_out => ch_raw_pulse(i - 1), + enc_pulse => open, + avs_address => cs_addr(9 downto 0), + avs_write => cs_pg_write_en(i - 1), + avs_writedata => cs_write_data, + avs_read => cs_pg_read_en(i - 1), + avs_readdatavalid => cs_pg_read_valid(i - 1), + avs_readdata => cs_pg_read_data(31 + 32 * (i - 1) downto 32 * (i - 1))); end generate; ----------------------------------------------------------------------------- -- POF Interface @@ -291,37 +168,37 @@ begin -- POF Receiver iPOF_RX : entity work.pof_rx_1 - port map ( - reset_n => reset_n_i, - clk => clk, - init => '0', - rx_clk => rx_clk, - rx_data => pof_rx, - init_out => remote_init, - dp_dir => dp_dir(0), - enc_out => enc_pulse_pof, - pd_out => pd_pulse_pof, - inc_pos => inc_pos_pof, - dec_pos => dec_pos_pof, - abs_pos => abs_pos_pof, - enable => enable_rx, - bit_div => bit_div, - error_rate_thres => error_rate_thres, - one_pps => one_pps, - upd_max_pos => upd_max_pos, - upd_min_pos => upd_min_pos, - max_error_flag => max_error_flag, - rx_watchdog => rx_watchdog, - rx_watchdog_en => rx_watchdog_en, - rx_watchdog_clr => rx_watchdog_clr, - parity_err_cnt => parity_err_cnt, - skip_pos_cnt => skip_pos_cnt); + port map( + reset_n => reset_n_i, + clk => clk, + init => '0', + rx_clk => rx_clk, + rx_data => pof_rx, + init_out => remote_init, + dp_dir => dp_dir(0), + enc_out => enc_pulse_pof, + pd_out => pd_pulse_pof, + inc_pos => inc_pos_pof, + dec_pos => dec_pos_pof, + abs_pos => abs_pos_pof, + enable => enable_rx, + bit_div => bit_div, + error_rate_thres => error_rate_thres, + one_pps => one_pps, + upd_max_pos => upd_max_pos, + upd_min_pos => upd_min_pos, + max_error_flag => max_error_flag, + rx_watchdog => rx_watchdog, + rx_watchdog_en => rx_watchdog_en, + rx_watchdog_clr => rx_watchdog_clr, + parity_err_cnt => parity_err_cnt, + skip_pos_cnt => skip_pos_cnt); -- UART signal regeneration iUART_REGEN : entity work.uart_regen_1 - generic map ( + generic map( data_width => 8) - port map ( + port map( reset_n => reset_n, clk => rx_clk, bit_div => bit_div, @@ -335,25 +212,25 @@ begin ----------------------------------------------------------------------------- fire_pulse_ext_i : entity work.fire_pulse_ext_1 - port map ( - reset_n => reset_n_i, - clk => clk, + port map( + reset_n => reset_n_i, + clk => clk, - ext_fp_det => ext_fp_det, - ext_fp_gen => ext_fp_gen, + ext_fp_det => ext_fp_det, + ext_fp_gen => ext_fp_gen, - ext_in => pof_rx, - ext_out => pof_rx_regen - ); + ext_in => pof_rx, + ext_out => pof_rx_regen + ); ----------------------------------------------------------------------------- -- Internal encoder generator ----------------------------------------------------------------------------- - iEMUL: entity work.enc_pd_emul_1 - generic map ( + iEMUL : entity work.enc_pd_emul_1 + generic map( SEQ_ENABLE => false) - port map ( + port map( clk => clk, reset_n => reset_n_i, ttl_pd => open, @@ -376,33 +253,163 @@ begin avs_readdata => cs_ie_read_data); enc_pulse_ie <= inc_pos_ie when dp_dir(0) = '0' else dec_pos_ie; - - ----------------------------------------------------------------------------- - -- NetSync Sink - ----------------------------------------------------------------------------- - -- Not instantiated yet - pNSNK_RD_VALID : process(clk) - begin - if(clk = '1' and clk'event) then - cs_nsnk_read_valid <= cs_nsnk_read_en; - end if; - end process pNSNK_RD_VALID; - - cs_nsnk_read_data <= X"DEAD_BEEF"; + gInfrastructure : if true generate + ----------------------------------------------------------------------------- + -- Synchronize the input reset (h2f_reset) to the clock (from PLL) + ----------------------------------------------------------------------------- - ----------------------------------------------------------------------------- - -- Event Logger - ----------------------------------------------------------------------------- + iSyncReset : entity work.sync_reset + port map( + async_rstN => reset_n, + clk => clk, + sync_rstN => reset_n_i); + + + ----------------------------------------------------------------------------- + -- C&S Register Interface Splitting + ----------------------------------------------------------------------------- + + iCS_BUS_ITF : entity work.cs_bus_ift_1 + generic map( + blk_num => blk_num) + port map( + rstN => reset_n_i, + clk => clk, + avs_address => avs_address(14 downto 0), + avs_write => avs_write, + avs_writedata => avs_writedata, + avs_read => avs_read, + avs_readdatavalid => avs_readdatavalid, + avs_readdata => avs_readdata, + cs_addr => cs_addr, + cs_we => cs_write_en, + cs_wr_data => cs_write_data, + cs_re => cs_read_en, + cs_rv => cs_read_valid, + cs_rd_data => cs_read_data); + + cs_ctrl_write_en <= cs_write_en(fp_ctrl_id); + cs_pg_write_en_g : for i in 1 to ch_num generate + cs_pg_write_en(i - 1) <= cs_write_en(pg_ch_id + i - 1); + end generate; + cs_nsnk_write_en <= cs_write_en(net_snk_id); + cs_log_write_en <= cs_write_en(log_blk_id); + cs_ie_write_en <= cs_write_en(int_enc_id); + + cs_ctrl_read_en <= cs_read_en(fp_ctrl_id); + cs_pg_read_en_g : for i in 1 to ch_num generate + cs_pg_read_en(i - 1) <= cs_read_en(pg_ch_id + i - 1); + end generate; + cs_nsnk_read_en <= cs_read_en(net_snk_id); + cs_log_read_en <= cs_read_en(log_blk_id); + cs_ie_read_en <= cs_read_en(int_enc_id); + + cs_read_valid(fp_ctrl_id) <= cs_ctrl_read_valid; + cs_read_valid_pg_g : for i in 1 to ch_num generate + cs_read_valid(pg_ch_id + i - 1) <= cs_pg_read_valid(i - 1); + end generate; + cs_read_valid(net_snk_id) <= cs_nsnk_read_valid; + cs_read_valid(log_blk_id) <= cs_log_read_valid; + cs_read_valid(int_enc_id) <= cs_ie_read_valid; + + cs_read_data(31 + 32 * fp_ctrl_id downto 32 * fp_ctrl_id) <= cs_ctrl_read_data; + cs_read_data_pg_g : for i in 1 to ch_num generate + cs_read_data(31 + 32 * (pg_ch_id + i - 1) downto 32 * (pg_ch_id + i - 1)) <= cs_pg_read_data(31 + 32 * (i - 1) downto 32 * (i - 1)); + end generate; + cs_read_data(31 + 32 * net_snk_id downto 32 * net_snk_id) <= cs_nsnk_read_data; + cs_read_data(31 + 32 * log_blk_id downto 32 * log_blk_id) <= cs_log_read_data; + cs_read_data(31 + 32 * int_enc_id downto 32 * int_enc_id) <= cs_ie_read_data; + + ----------------------------------------------------------------------------- + -- Fire-Pulse-Manager Controller + ----------------------------------------------------------------------------- + + iCTRL : entity work.fire_pulse_ctrl_1 + port map( + reset_n => reset_n_i, + clk => clk, + src_sel => src_sel, + uart_regen_bypass => uart_regen_bypass, + upd_max_pos => upd_max_pos, + upd_min_pos => upd_min_pos, + enable_rx => enable_rx, + uart_bit_div => bit_div, + error_rate_thres => error_rate_thres, + max_error_flag => max_error_flag, + rx_watchdog => rx_watchdog, + rx_watchdog_en => rx_watchdog_en, + rx_watchdog_clr => rx_watchdog_clr, + parity_err_cnt => parity_err_cnt, + skip_pos_cnt => skip_pos_cnt, + mon_point_src => mon_point_src, + mon_points => mon_pt, + coarse_time => coarse_time, + fine_time => fine_time, + one_pps => one_pps, + ext_fp_det => ext_fp_det, + ext_fp_gen => ext_fp_gen, + ins_fpm_irq_0 => ins_fpm_irq_0, + avs_address => cs_addr(3 downto 0), + avs_write => cs_ctrl_write_en, + avs_writedata => cs_write_data, + avs_read => cs_ctrl_read_en, + avs_readdatavalid => cs_ctrl_read_valid, + avs_readdata => cs_ctrl_read_data); + + -- Output multiplexer + fire_pulse_i <= ch_pulse_out when src_sel(0) = '1' else (others => pof_rx_regen); + fire_pulse <= fire_pulse_i; + + pd_pulse <= pd_pulse_pof when src_sel(1) = '0' else pd_pulse_ie; + enc_pulse <= enc_pulse_pof when src_sel(1) = '0' else enc_pulse_ie; + abs_pos <= abs_pos_pof when src_sel(1) = '0' else abs_pos_ie(31 downto 0); + inc_pos <= inc_pos_pof when src_sel(1) = '0' else inc_pos_ie; + dec_pos <= dec_pos_pof when src_sel(1) = '0' else dec_pos_ie; + + mon_point_src(0) <= remote_init; + mon_point_src(1) <= dp_dir(0); + mon_point_src(2) <= pd_pulse; + mon_point_src(3) <= enc_pulse; + mon_point_src(4) <= ch_pd(0); + mon_point_src(5) <= ch_pulse_out(0); + mon_point_src(6) <= ch_raw_pulse(0); + mon_point_src(7) <= ch_mask(0); + mon_point_src(8) <= pof_rx; + mon_point_src(9) <= fire_pulse_i(0); + -- + mon_point_src(15 downto 10) <= (others => '0'); + + pof_iso_en <= enable_rx; + + ----------------------------------------------------------------------------- + -- NetSync Sink + ----------------------------------------------------------------------------- + + -- Not instantiated yet + pNSNK_RD_VALID : process(clk) + begin + if (clk = '1' and clk'event) then + cs_nsnk_read_valid <= cs_nsnk_read_en; + end if; + end process pNSNK_RD_VALID; + + cs_nsnk_read_data <= X"DEAD_BEEF"; + + ----------------------------------------------------------------------------- + -- Event Logger + ----------------------------------------------------------------------------- + + -- Not instantiated yet + pLOG_RD_VALID : process(clk) + begin + if (clk = '1' and clk'event) then + cs_log_read_valid <= cs_log_read_en; + end if; + end process pLOG_RD_VALID; + + cs_log_read_data <= X"DEAD_BEEF"; + + end generate gInfrastructure; - -- Not instantiated yet - pLOG_RD_VALID : process(clk) - begin - if(clk = '1' and clk'event) then - cs_log_read_valid <= cs_log_read_en; - end if; - end process pLOG_RD_VALID; - - cs_log_read_data <= X"DEAD_BEEF"; - end architecture rtl; diff --git a/generic_ip/pulse_generator/1/doc/pulse_generator_1.json b/generic_ip/pulse_generator/1/doc/pulse_generator_1.json index fe31d79..8cef6b2 100644 --- a/generic_ip/pulse_generator/1/doc/pulse_generator_1.json +++ b/generic_ip/pulse_generator/1/doc/pulse_generator_1.json @@ -50,7 +50,7 @@ "minor_number" : { "type" : "c", "bit_len" : "8", - "reset" : "0x04", + "reset" : "0x05", "description" : "Minor number" }, "major_number" : { diff --git a/generic_ip/pulse_generator/1/src/pulse_generator_1.vhd b/generic_ip/pulse_generator/1/src/pulse_generator_1.vhd index fae6365..febcc50 100644 --- a/generic_ip/pulse_generator/1/src/pulse_generator_1.vhd +++ b/generic_ip/pulse_generator/1/src/pulse_generator_1.vhd @@ -32,42 +32,42 @@ use work.pulse_generator_1_pkg.all; entity pulse_generator_1 is generic( - PD_QUEUE_SIZE : natural range 32 to 1024 := 64; - PULSE_DELAY_EQUAL_EN : boolean := true; - OUT_PULSE_CONDITION : boolean := true); + PD_QUEUE_SIZE : natural range 32 to 1024 := 64; + PULSE_DELAY_EQUAL_EN : boolean := true; + OUT_PULSE_CONDITION : boolean := true); port( - clk : in std_logic; - reset_n : in std_logic := '1'; + clk : in std_logic; + reset_n : in std_logic := '1'; -- - init : in std_logic; + init : in std_logic; -- Sequencer I/Os - pd_in : in std_logic; - abs_position : in std_logic_vector(31 downto 0); - dp_dir : out std_logic; - pulse_out : out std_logic; + pd_in : in std_logic; + abs_position : in std_logic_vector(31 downto 0); + dp_dir : out std_logic; + pulse_out : out std_logic; -- diagnostic outputs - filtered_pd : out std_logic; - ch_pd : out std_logic; - ch_mask : out std_logic; - raw_pulse_out : out std_logic; - enc_pulse : out std_logic; + filtered_pd : out std_logic; + ch_pd : out std_logic; + ch_mask : out std_logic; + raw_pulse_out : out std_logic; + enc_pulse : out std_logic; ----------------------------------------------------------------------- -- Avalon MM Interface ----------------------------------------------------------------------- - avs_address : in std_logic_vector( 9 downto 0); - avs_write : in std_logic; - avs_writedata : in std_logic_vector(31 downto 0); - avs_read : in std_logic; - avs_readdatavalid : out std_logic; - avs_readdata : out std_logic_vector(31 downto 0)); + avs_address : in std_logic_vector(9 downto 0); + avs_write : in std_logic; + avs_writedata : in std_logic_vector(31 downto 0); + avs_read : in std_logic; + avs_readdatavalid : out std_logic; + avs_readdata : out std_logic_vector(31 downto 0)); end entity pulse_generator_1; architecture rtl of pulse_generator_1 is -- constants - constant CSR_IP_ID : std_logic_vector(31 downto 0) := x"0000FF13"; - constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000104"; + constant CSR_IP_ID : std_logic_vector(31 downto 0) := x"0000FF13"; + constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000104"; signal init_de, init_qd, enable, loc_pd, pd_queue_error : std_logic; @@ -76,10 +76,10 @@ architecture rtl of pulse_generator_1 is signal ch_mask_i, bypass_ch_ctrl, bypass_delay_equal : std_logic; signal div_pulse, gated_pulse, retimed_pulse, pulse_out_i : std_logic; signal avs_write_i, avs_read_d, avs_read_i, de_queue_error : std_logic; - signal cnt_dir, dp_dir_i, ch_mask_d, ch_ctrl_start_req_i : std_logic; + signal cnt_dir, dp_dir_i, ch_mask_d, ch_ctrl_start_req_i : std_logic; -- @suppress "signal ch_mask_d is never read" (testbench) signal set_first_pd, pulse_out_ii : std_logic; signal loc_pulse_out_d, loc_pulse, first_pulse, dp_dir_d : std_logic; - signal overdrive_rst, overdrv_event, pulse_scale_out : std_logic; + signal overdrive_rst, overdrv_event : std_logic; signal start_img_req, start_img_req_d, start_img, start_img_d : std_logic; signal start_img_dd, fire_enable, img_completed : std_logic; signal sw_ctrl_dp_dir, enable_out, ch_ctrl_start_req_d : std_logic; @@ -95,27 +95,27 @@ architecture rtl of pulse_generator_1 is signal div_pulse_i, spitting_enable, spit_pulse : std_logic; signal seq_bus_valid, spit_nco_msb : std_logic; -- - signal abs_pos_msb_old : std_logic_vector( 1 downto 0); - signal ch_ctrl_csr_addr, ch_ctrl_trigger_in : std_logic_vector( 3 downto 0); - signal avs_addr : std_logic_vector( 4 downto 0); - signal pulse_width, pulse_width_ext, init_v : std_logic_vector( 7 downto 0); - signal ch_ctrl_start_addr : std_logic_vector( 7 downto 0); - signal ch_ctrl_address : std_logic_vector( 7 downto 0); - signal avs_address_i : std_logic_vector( 9 downto 0); - signal overdrive_events, overdrive_thres : std_logic_vector(15 downto 0); - signal pulse_interval : std_logic_vector(15 downto 0); - signal img_size, pixel_cnt : std_logic_vector(23 downto 0); - signal ch_ctrl_vector_out : std_logic_vector(23 downto 0); - signal ch_offset, ch_delay, avs_readdata_i : std_logic_vector(31 downto 0); - signal ch_ctrl_writedata, ch_ctrl_readdata : std_logic_vector(31 downto 0); - signal ch_ctrl_csr_writedata : std_logic_vector(31 downto 0); - signal ch_ctrl_csr_readdata : std_logic_vector(31 downto 0); - signal ch_offset_dir0, ch_offset_dir1 : std_logic_vector(31 downto 0); - signal abs_pos_max, abs_pos_min : std_logic_vector(31 downto 0); - signal last_pd_pos : std_logic_vector(31 downto 0); - signal pd_in_cnt, fire_req_cnt : std_logic_vector(31 downto 0); - signal seq_bus_data, spit_nco, spit_nco_inc : std_logic_vector(31 downto 0); - signal div_offset, div_ratio : std_logic_vector(33 downto 0); + signal abs_pos_msb_old : std_logic_vector(1 downto 0); + signal ch_ctrl_csr_addr, ch_ctrl_trigger_in : std_logic_vector(3 downto 0); + signal avs_addr : std_logic_vector(4 downto 0); + signal pulse_width, pulse_width_ext, init_v : std_logic_vector(7 downto 0); + signal ch_ctrl_start_addr : std_logic_vector(7 downto 0); + signal ch_ctrl_address : std_logic_vector(7 downto 0); + signal avs_address_i : std_logic_vector(9 downto 0); + signal overdrive_events, overdrive_thres : std_logic_vector(15 downto 0); + signal pulse_interval : std_logic_vector(15 downto 0); + signal img_size, pixel_cnt : std_logic_vector(23 downto 0); + signal ch_ctrl_vector_out : std_logic_vector(23 downto 0); + signal ch_offset, ch_delay, avs_readdata_i : std_logic_vector(31 downto 0); + signal ch_ctrl_writedata, ch_ctrl_readdata : std_logic_vector(31 downto 0); + signal ch_ctrl_csr_writedata : std_logic_vector(31 downto 0); + signal ch_ctrl_csr_readdata : std_logic_vector(31 downto 0); + signal ch_offset_dir0, ch_offset_dir1 : std_logic_vector(31 downto 0); + signal abs_pos_max, abs_pos_min : std_logic_vector(31 downto 0); + signal last_pd_pos : std_logic_vector(31 downto 0); + signal pd_in_cnt, fire_req_cnt : std_logic_vector(31 downto 0); + signal seq_bus_data, spit_nco, spit_nco_inc : std_logic_vector(31 downto 0); + signal div_offset, div_ratio : std_logic_vector(33 downto 0); begin @@ -131,38 +131,38 @@ begin gen_filt_pd <= '1' when pd_pulse = '1' and (first_pd = '1' or (dp_dir_i = '0' and close_to_zero = '1' and signed(abs_position) > signed(last_pd_pos)) or - (dp_dir_i = '0' and close_to_mid = '1' and unsigned(abs_position) > unsigned(last_pd_pos)) or + (dp_dir_i = '0' and close_to_mid = '1' and unsigned(abs_position) > unsigned(last_pd_pos)) or (dp_dir_i = '1' and close_to_zero = '1' and signed(abs_position) < signed(last_pd_pos)) or - (dp_dir_i = '1' and close_to_mid = '1' and unsigned(abs_position) < unsigned(last_pd_pos))) else '0'; + (dp_dir_i = '1' and close_to_mid = '1' and unsigned(abs_position) < unsigned(last_pd_pos))) else '0'; close_to_zero <= '1' when abs_position(31 downto 30) = "00" or abs_position(31 downto 30) = "11" else '0'; close_to_mid <= '1' when abs_position(31 downto 30) = "01" or abs_position(31 downto 30) = "10" else '0'; - set_first_pd <= '1' when init_qd = '1' or (dp_dir_i = '0' and upd_max_pos_i = '1') or (dp_dir_i = '1' and upd_min_pos_i = '1') or rst_jitter = '1' or (mid_cross = '1' and mid_crossed = '0') else '0'; - + set_first_pd <= '1' when init_qd = '1' or (dp_dir_i = '0' and upd_max_pos_i = '1') or (dp_dir_i = '1' and upd_min_pos_i = '1') or rst_jitter = '1' or (mid_cross = '1' and mid_crossed = '0') else '0'; + pPD_JITTER_MNG : process(clk) begin - if(clk = '1' and clk'event) then - pd_in_d <= pd_in; - if(set_first_pd = '1') then + if (clk = '1' and clk'event) then + pd_in_d <= pd_in; + if (set_first_pd = '1') then first_pd <= '1'; - elsif(filt_pd = '1') then + elsif (filt_pd = '1') then first_pd <= '0'; - end if; - filt_pd <= gen_filt_pd; - filt_pd_d <= filt_pd; - if(set_first_pd = '1' or gen_filt_pd = '1') then + end if; + filt_pd <= gen_filt_pd; + filt_pd_d <= filt_pd; + if (set_first_pd = '1' or gen_filt_pd = '1') then last_pd_pos <= abs_position; end if; abs_pos_msb_old <= abs_position(31 downto 30); - if(init_qd = '1' or zero_cross = '1') then + if (init_qd = '1' or zero_cross = '1') then mid_crossed <= '0'; - elsif(mid_cross = '1') then + elsif (mid_cross = '1') then mid_crossed <= '1'; end if; end if; end process pPD_JITTER_MNG; - + mid_cross <= '1' when (dp_dir_i = '0' and abs_position(31 downto 30) = "10" and abs_pos_msb_old = "01") or (dp_dir_i = '1' and abs_position(31 downto 30) = "01" and abs_pos_msb_old = "10") else '0'; zero_cross <= '1' when (dp_dir_i = '0' and abs_position(31 downto 30) = "00" and abs_pos_msb_old = "11") or (dp_dir_i = '1' and abs_position(31 downto 30) = "11" and abs_pos_msb_old = "00") else '0'; @@ -178,11 +178,11 @@ begin -- next increment of absolute position pLOC_PD_IN : process(clk) begin - if(clk = '1' and clk'event) then + if (clk = '1' and clk'event) then abs_pos_lsb <= abs_position(0); - if(filt_pd = '1' and filt_pd_d = '0') then + if (filt_pd = '1' and filt_pd_d = '0') then filt_pd_i <= '1'; - elsif(init = '1' or (filt_pd = '0' and filt_pd_i = '1' and abs_position(0) /= abs_pos_lsb)) then + elsif (init = '1' or (filt_pd = '0' and filt_pd_i = '1' and abs_position(0) /= abs_pos_lsb)) then filt_pd_i <= '0'; end if; end if; @@ -190,11 +190,11 @@ begin -- Note on the maximum size of queue: long PD queues must be taken care of at SW -- level, here the size is limited to 128 (on the PMB it was 16) - iPD_queue: entity work.queue_and_delay_1 - generic map ( + iPD_queue : entity work.queue_and_delay_1 + generic map( use_ext_time => true, - queue_size => 2*PD_QUEUE_SIZE) - port map ( + queue_size => 2 * PD_QUEUE_SIZE) + port map( rstN => reset_n, clk => clk, init => init_qd, @@ -207,13 +207,13 @@ begin -- make sure the PD queue is always cleared whenever there is a change of direction dir_change <= dp_dir_i xor dp_dir_d; - init_qd <= not enable or init or dir_change; + init_qd <= not enable or init or dir_change; -- channel offset selection pCH_OFF_SEL : process(clk) begin - if(clk = '1' and clk'event) then - if(dp_dir_i = '0') then + if (clk = '1' and clk'event) then + if (dp_dir_i = '0') then ch_offset <= ch_offset_dir0; else ch_offset <= ch_offset_dir1; @@ -229,8 +229,8 @@ begin pDIR_CHG : process(clk) begin - if(clk = '1' and clk'event) then - if(bypass_ch_ctrl = '1') then + if (clk = '1' and clk'event) then + if (bypass_ch_ctrl = '1') then dp_dir_i <= sw_ctrl_dp_dir; else dp_dir_i <= ch_ctrl_vector_out(0); @@ -254,8 +254,8 @@ begin -- - Gating signal (ch_mask) i_channel_control : entity work.generic_sequencer_15 - generic map ( - TRIGGER_WIDTH => 4, + generic map( + TRIGGER_WIDTH => 4, VECTOR_WIDTH => 24, BUS_WIDTH => 32, POS_WIDTH => 24, @@ -266,31 +266,31 @@ begin POS_BUS_EN => true, ALU_EN => false, QUEUE_EN => true) - port map ( - clk => clk, - reset_n => reset_n, - avs_csr_address => ch_ctrl_csr_addr, - avs_csr_write => ch_ctrl_csr_write, - avs_csr_writedata => ch_ctrl_csr_writedata, - avs_csr_read => ch_ctrl_csr_read, - avs_csr_readdata => ch_ctrl_csr_readdata, - avs_seq_address => ch_ctrl_address, - avs_seq_write => ch_ctrl_write, - avs_seq_writedata => ch_ctrl_writedata, - avs_seq_read => ch_ctrl_read, - avs_seq_readdata => ch_ctrl_readdata, - start_req => ch_ctrl_start_req, - start_addr => ch_ctrl_start_addr, - trigger_in => ch_ctrl_trigger_in, - pos_in => abs_position(23 downto 0), - busy => ch_ctrl_busy, - vector_out => ch_ctrl_vector_out, - bus_data => seq_bus_data, - bus_valid => seq_bus_valid, - bus_ack => '1'); + port map( + clk => clk, + reset_n => reset_n, + avs_csr_address => ch_ctrl_csr_addr, + avs_csr_write => ch_ctrl_csr_write, + avs_csr_writedata => ch_ctrl_csr_writedata, + avs_csr_read => ch_ctrl_csr_read, + avs_csr_readdata => ch_ctrl_csr_readdata, + avs_seq_address => ch_ctrl_address, + avs_seq_write => ch_ctrl_write, + avs_seq_writedata => ch_ctrl_writedata, + avs_seq_read => ch_ctrl_read, + avs_seq_readdata => ch_ctrl_readdata, + start_req => ch_ctrl_start_req, + start_addr => ch_ctrl_start_addr, + trigger_in => ch_ctrl_trigger_in, + pos_in => abs_position(23 downto 0), + busy => ch_ctrl_busy, + vector_out => ch_ctrl_vector_out, + bus_data => seq_bus_data, + bus_valid => seq_bus_valid, + bus_ack => '1'); ch_ctrl_trigger_in <= (0 => loc_pd, 1 => fire_enable, 2 => gated_pulse, 3 => (not fire_enable)); - + ch_mask_i <= fire_enable or ch_ctrl_vector_out(1) or bypass_ch_ctrl; -- output to the monitoring point/event-logger @@ -304,60 +304,60 @@ begin --clock cycle ch_ctrl_start_req_i <= ch_ctrl_start_req_ii and enable and not init; - ch_ctrl_start_req <= ch_ctrl_start_req_i and not ch_ctrl_start_req_d; + ch_ctrl_start_req <= ch_ctrl_start_req_i and not ch_ctrl_start_req_d; - pGEN_IMAGE: process(clk) + pGEN_IMAGE : process(clk) begin - if(clk = '1' and clk'event) then + if (clk = '1' and clk'event) then ch_ctrl_start_req_d <= ch_ctrl_start_req_i; - start_img_req_d <= start_img_req; - start_img_d <= start_img; - start_img_dd <= start_img_d; - add_img_size_d <= add_img_size; - if(img_completed = '1' or enable = '0' or abort_fire = '1') then + start_img_req_d <= start_img_req; + start_img_d <= start_img; + start_img_dd <= start_img_d; + add_img_size_d <= add_img_size; + if (img_completed = '1' or enable = '0' or abort_fire = '1') then fire_enable <= '0'; - elsif(start_img_dd = '1' and fire_enable = '0') then + elsif (start_img_dd = '1' and fire_enable = '0') then fire_enable <= '1'; end if; - if(start_img = '1' and fire_enable = '0') then - img_size <= X"00" & ch_ctrl_vector_out(23 downto 8); - elsif(add_img_size = '1' and add_img_size_d = '0') then - img_size <= std_logic_vector(unsigned(img_size)+unsigned(ch_ctrl_vector_out(23 downto 8))); + if (start_img = '1' and fire_enable = '0') then + img_size <= X"00" & ch_ctrl_vector_out(23 downto 8); + elsif (add_img_size = '1' and add_img_size_d = '0') then + img_size <= std_logic_vector(unsigned(img_size) + unsigned(ch_ctrl_vector_out(23 downto 8))); end if; - if(start_img = '1' and fire_enable = '0') then - pixel_cnt <= (others => '0'); - elsif(fire_enable = '1' and div_pulse = '1') then - pixel_cnt <= std_logic_vector(unsigned(pixel_cnt)+1); + if (start_img = '1' and fire_enable = '0') then + pixel_cnt <= (others => '0'); + elsif (fire_enable = '1' and div_pulse = '1') then + pixel_cnt <= std_logic_vector(unsigned(pixel_cnt) + 1); end if; end if; end process pGEN_IMAGE; - start_img <= start_img_req and not start_img_req_d; + start_img <= start_img_req and not start_img_req_d; img_completed <= '1' when fire_enable = '1' and unsigned(pixel_cnt) = unsigned(img_size) else '0'; -- DO NOT REMOVE: USED BY THE TESTBENCH! -- synthesis translate_off p_ch_mask_d : process(clk) begin - if(clk = '1' and clk'event) then + if (clk = '1' and clk'event) then ch_mask_d <= ch_mask_i; end if; end process p_ch_mask_d; -- synthesis translate_on - + ----------------------------------------------------------------------------- -- Fractional Divider ----------------------------------------------------------------------------- iFracDiv : entity work.simple_frac_div_1 - port map ( + port map( clk => clk, enable => frac_div_en, - dir => dp_dir_i, upd_max_pos => upd_max_pos, upd_min_pos => upd_min_pos, abs_pos_max => abs_pos_max, abs_pos_min => abs_pos_min, + dir => dp_dir_i, offset => div_offset, ratio => div_ratio, abs_pos => abs_position, @@ -373,7 +373,7 @@ begin p_pulse_div_switch : process(clk) begin - if(clk = '1' and clk'event) then + if (clk = '1' and clk'event) then rst_jitter <= ch_ctrl_vector_out(5); upd_max_pos <= upd_max_pos_i or init_v(0) or dir_change or (rst_jitter and not dp_dir_i); upd_min_pos <= upd_min_pos_i or init_v(0) or dir_change or (rst_jitter and dp_dir_i); @@ -390,18 +390,18 @@ begin pSPITTING_LOGIC : process(clk) begin - if(clk = '1' and clk'event) then + if (clk = '1' and clk'event) then spitting_enable <= ch_ctrl_vector_out(6); - if(seq_bus_valid = '1') then + if (seq_bus_valid = '1') then spit_nco_inc <= seq_bus_data; end if; - if(spitting_enable = '0') then + if (spitting_enable = '0') then spit_nco <= (others => '0'); else - spit_nco <= std_logic_vector(unsigned(spit_nco)+unsigned(spit_nco_inc)); + spit_nco <= std_logic_vector(unsigned(spit_nco) + unsigned(spit_nco_inc)); end if; - spit_nco_msb <= spit_nco(spit_nco'left); - spit_pulse <= spit_nco(spit_nco'left) and not spit_nco_msb; + spit_nco_msb <= spit_nco(spit_nco'left); + spit_pulse <= spit_nco(spit_nco'left) and not spit_nco_msb; end if; end process pSPITTING_LOGIC; @@ -417,12 +417,12 @@ begin -- compendate for variation in the channel delay when daisy-chaining multiple -- EMBs/HMBs: - gPULSE_DELAY_EQUAL: if PULSE_DELAY_EQUAL_EN = true generate - iDE: entity work.queue_and_delay_1 - generic map ( + gPULSE_DELAY_EQUAL : if PULSE_DELAY_EQUAL_EN = true generate + iDE : entity work.queue_and_delay_1 + generic map( use_ext_time => false, queue_size => 256) - port map ( + port map( rstN => reset_n, clk => clk, init => init_de, @@ -437,7 +437,7 @@ begin end generate gPULSE_DELAY_EQUAL; - gNOT_PULSE_DELAY_EQUAL: if PULSE_DELAY_EQUAL_EN = false generate + gNOT_PULSE_DELAY_EQUAL : if PULSE_DELAY_EQUAL_EN = false generate retimed_pulse <= gated_pulse; @@ -447,8 +447,8 @@ begin p_delay_equal_switch : process(clk) begin - if(clk = '1' and clk'event) then - if(bypass_delay_equal = '1') then + if (clk = '1' and clk'event) then + if (bypass_delay_equal = '1') then pulse_out_i <= gated_pulse; else pulse_out_i <= retimed_pulse; @@ -464,27 +464,27 @@ begin pODRV_CHK : process(clk) begin - if(clk = '1' and clk'event) then + if (clk = '1' and clk'event) then loc_pulse_out_d <= pulse_out_i; - if(enable = '0' or overdrive_rst = '1' or unsigned(pulse_interval) = 2**16-1) then + if (enable = '0' or overdrive_rst = '1' or unsigned(pulse_interval) = 2**16 - 1) then first_pulse <= '1'; - elsif(loc_pulse = '1') then + elsif (loc_pulse = '1') then first_pulse <= '0'; end if; - if(loc_pulse = '1') then + if (loc_pulse = '1') then pulse_interval <= (others => '0'); else - pulse_interval <= std_logic_vector(unsigned(pulse_interval)+1); + pulse_interval <= std_logic_vector(unsigned(pulse_interval) + 1); end if; - if(loc_pulse = '1' and first_pulse = '0' and unsigned(pulse_interval) < unsigned(overdrive_thres)) then + if (loc_pulse = '1' and first_pulse = '0' and unsigned(pulse_interval) < unsigned(overdrive_thres)) then overdrv_event <= '1'; else overdrv_event <= '0'; end if; - if(enable = '0' or overdrive_rst = '1') then + if (enable = '0' or overdrive_rst = '1') then overdrive_events <= (others => '0'); - elsif(overdrv_event = '1') then - overdrive_events <= std_logic_vector(unsigned(overdrive_events)+1); + elsif (overdrv_event = '1') then + overdrive_events <= std_logic_vector(unsigned(overdrive_events) + 1); end if; end if; end process pODRV_CHK; @@ -493,10 +493,10 @@ begin -- Pulse Width Conditioning ----------------------------------------------------------------------------- - gOUT_COND: if OUT_PULSE_CONDITION = true generate - - iPC: entity work.pulse_conditioning_1 - port map ( + gOUT_COND : if OUT_PULSE_CONDITION = true generate + + iPC : entity work.pulse_conditioning_1 + port map( reset_n => reset_n, clk => clk, enable => enable, @@ -510,7 +510,7 @@ begin fire_req <= pulse_out_ii when bypass_pulse_cond = '0' else pulse_out_i; end generate gOUT_COND; - + gOUT_BYPASS : if OUT_PULSE_CONDITION = false generate pulse_out <= pulse_out_i; @@ -524,22 +524,22 @@ begin pEdgeDetect_Cnt : process(clk) begin - if(clk = '1' and clk'event) then - fire_req_d <= fire_req; - if(init = '1' or enable = '0' or rst_diag_regs = '1') then + if (clk = '1' and clk'event) then + fire_req_d <= fire_req; + if (init = '1' or enable = '0' or rst_diag_regs = '1') then pd_in_cnt <= (others => '0'); - elsif(pd_pulse = '1') then - pd_in_cnt <= std_logic_vector(unsigned(pd_in_cnt)+1); + elsif (pd_pulse = '1') then + pd_in_cnt <= std_logic_vector(unsigned(pd_in_cnt) + 1); end if; - if(init = '1' or enable = '0' or rst_diag_regs = '1') then + if (init = '1' or enable = '0' or rst_diag_regs = '1') then fire_req_cnt <= (others => '0'); - elsif(fire_req_p = '1') then - fire_req_cnt <= std_logic_vector(unsigned(fire_req_cnt)+1); + elsif (fire_req_p = '1') then + fire_req_cnt <= std_logic_vector(unsigned(fire_req_cnt) + 1); end if; end if; end process pEdgeDetect_Cnt; - - fire_req_p <= fire_req and not fire_req_d; + + fire_req_p <= fire_req and not fire_req_d; ----------------------------------------------------------------------------- -- C&S registers (Avalon-MM I/F) @@ -553,12 +553,12 @@ begin ch_ctrl_write <= '1' when avs_write = '1' and avs_address(9) = '1' else '0'; ch_ctrl_csr_write <= '1' when avs_write = '1' and avs_address(9 downto 5) = "00001" else '0'; - avs_read_i <= '1' when avs_read = '1' and avs_address(9) = '0' else '0'; - ch_ctrl_read <= '1' when avs_read = '1' and avs_address(9) = '1' else '0'; - ch_ctrl_csr_read <= '1' when avs_read = '1' and avs_address(9 downto 5) = "00001" else '0'; + avs_read_i <= '1' when avs_read = '1' and avs_address(9) = '0' else '0'; + ch_ctrl_read <= '1' when avs_read = '1' and avs_address(9) = '1' else '0'; + ch_ctrl_csr_read <= '1' when avs_read = '1' and avs_address(9 downto 5) = "00001" else '0'; + + avs_addr <= avs_address(4 downto 0); - avs_addr <= avs_address(4 downto 0); - ch_ctrl_address <= avs_address(ch_ctrl_address'range); ch_ctrl_csr_addr <= avs_address(ch_ctrl_csr_addr'range); @@ -567,8 +567,8 @@ begin pINIT : process(clk) begin - if(clk = '1' and clk'event) then - if(init = '1') then + if (clk = '1' and clk'event) then + if (init = '1') then init_v <= (others => '1'); else init_v <= '0' & init_v(init_v'high downto 1); @@ -580,86 +580,86 @@ begin pCTRL_STATUS : process(reset_n, clk) begin - if(reset_n = '0') then - avs_read_d <= '0'; - avs_readdatavalid <= '0'; - avs_readdata_i <= (others => '0'); + if (reset_n = '0') then + avs_read_d <= '0'; + avs_readdatavalid <= '0'; + avs_readdata_i <= (others => '0'); -- - enable_i <= '0'; - bypass_ch_ctrl <= '0'; - bypass_pulse_cond <= '0'; - bypass_delay_equal <= '0'; - sw_ctrl_dp_dir <= '0'; - enable_out <= '0'; - abort_fire <= '0'; + enable_i <= '0'; + bypass_ch_ctrl <= '0'; + bypass_pulse_cond <= '0'; + bypass_delay_equal <= '0'; + sw_ctrl_dp_dir <= '0'; + enable_out <= '0'; + abort_fire <= '0'; -- - ch_offset_dir0 <= (others => '0'); - ch_offset_dir1 <= (others => '0'); - ch_delay <= (others => '0'); + ch_offset_dir0 <= (others => '0'); + ch_offset_dir1 <= (others => '0'); + ch_delay <= (others => '0'); -- ch_ctrl_start_req_ii <= '0'; - ch_ctrl_start_addr <= (others => '0'); + ch_ctrl_start_addr <= (others => '0'); -- - frac_div_en_i <= '0'; - upd_max_pos_i <= '0'; - upd_min_pos_i <= '0'; + frac_div_en_i <= '0'; + upd_max_pos_i <= '0'; + upd_min_pos_i <= '0'; -- - pulse_width <= std_logic_vector(to_unsigned(20,8)); -- 200 ns at clk=100MHz - pulse_width_ext <= std_logic_vector(to_unsigned(50,8)); -- 500 ns at clk=100MHz + pulse_width <= std_logic_vector(to_unsigned(20, 8)); -- 200 ns at clk=100MHz + pulse_width_ext <= std_logic_vector(to_unsigned(50, 8)); -- 500 ns at clk=100MHz -- - overdrive_rst <= '0'; - overdrive_thres <= std_logic_vector(to_unsigned(100-1,16)); + overdrive_rst <= '0'; + overdrive_thres <= std_logic_vector(to_unsigned(100 - 1, 16)); -- - div_offset <= (others => '0'); - div_ratio <= (others => '0'); - elsif(clk = '1' and clk'event) then + div_offset <= (others => '0'); + div_ratio <= (others => '0'); + elsif (clk = '1' and clk'event) then -- CTRL registers - if(avs_write_i = '1' and avs_address(9 downto 4) = "000000") then + if (avs_write_i = '1' and avs_address(9 downto 4) = "000000") then case avs_addr is when PULSE_GEN_CTRL_REG => - enable_i <= avs_writedata(0); - bypass_ch_ctrl <= avs_writedata(1); - bypass_pulse_cond <= avs_writedata(2); - bypass_delay_equal <= avs_writedata(3); - sw_ctrl_dp_dir <= avs_writedata(4); - enable_out <= avs_writedata(16); - abort_fire <= avs_writedata(17); - rst_diag_regs <= avs_writedata(18); + enable_i <= avs_writedata(0); + bypass_ch_ctrl <= avs_writedata(1); + bypass_pulse_cond <= avs_writedata(2); + bypass_delay_equal <= avs_writedata(3); + sw_ctrl_dp_dir <= avs_writedata(4); + enable_out <= avs_writedata(16); + abort_fire <= avs_writedata(17); + rst_diag_regs <= avs_writedata(18); when CH_OFFSET_D0_REG => - ch_offset_dir0 <= avs_writedata; + ch_offset_dir0 <= avs_writedata; when CH_DELAY_REG => - ch_delay <= avs_writedata; + ch_delay <= avs_writedata; when CH_CTRL_CTRL_REG => ch_ctrl_start_req_ii <= avs_writedata(0); - ch_ctrl_start_addr <= avs_writedata(15 downto 8); + ch_ctrl_start_addr <= avs_writedata(15 downto 8); when FRAC_DIV_CTRL_REG => - frac_div_en_i <= avs_writedata(0); - upd_max_pos_i <= avs_writedata(1); - upd_min_pos_i <= avs_writedata(2); + frac_div_en_i <= avs_writedata(0); + upd_max_pos_i <= avs_writedata(1); + upd_min_pos_i <= avs_writedata(2); when PULSE_WIDTH_REG => - pulse_width <= avs_writedata( 7 downto 0); - pulse_width_ext <= avs_writedata(23 downto 16); + pulse_width <= avs_writedata(7 downto 0); + pulse_width_ext <= avs_writedata(23 downto 16); when OVERDRV_THRES_REG => - overdrive_rst <= avs_writedata(0); - overdrive_thres <= avs_writedata(31 downto 16); + overdrive_rst <= avs_writedata(0); + overdrive_thres <= avs_writedata(31 downto 16); when CH_OFFSET_D1_REG => - ch_offset_dir1 <= avs_writedata; + ch_offset_dir1 <= avs_writedata; when DIV_RATIO_INT => - div_ratio(33 downto 24) <= avs_writedata( 9 downto 0); + div_ratio(33 downto 24) <= avs_writedata(9 downto 0); when DIV_RATIO_FRAC => - div_ratio(23 downto 0) <= avs_writedata(23 downto 0); + div_ratio(23 downto 0) <= avs_writedata(23 downto 0); when SP_OFFSET_INT => - div_offset(33 downto 24) <= avs_writedata( 9 downto 0); + div_offset(33 downto 24) <= avs_writedata(9 downto 0); when SP_OFFSET_FRAC => - div_offset(23 downto 0) <= avs_writedata(23 downto 0); + div_offset(23 downto 0) <= avs_writedata(23 downto 0); when others => null; end case; end if; - + -- Read Ctrl & Status registers avs_read_d <= avs_read; avs_readdatavalid <= avs_read_d; - if(avs_read_i = '1') then + if (avs_read_i = '1') then case avs_addr is when CSR_IP_ID_ADDR => avs_readdata_i <= CSR_IP_ID; @@ -667,13 +667,13 @@ begin avs_readdata_i <= CSR_IP_VER; when PULSE_GEN_CTRL_REG => avs_readdata_i(31 downto 8) <= (8 => ch_mask_i, 9 => fire_enable, 10 => dp_dir, 16 => enable_out, 17 => abort_fire, 18 => rst_diag_regs, others => '0'); - avs_readdata_i( 7 downto 4) <= b"0" & de_queue_error & pd_queue_error & sw_ctrl_dp_dir; - avs_readdata_i( 3 downto 0) <= bypass_delay_equal & bypass_pulse_cond & bypass_ch_ctrl & enable_i; - when CH_OFFSET_D0_REG => + avs_readdata_i(7 downto 4) <= b"0" & de_queue_error & pd_queue_error & sw_ctrl_dp_dir; + avs_readdata_i(3 downto 0) <= bypass_delay_equal & bypass_pulse_cond & bypass_ch_ctrl & enable_i; + when CH_OFFSET_D0_REG => avs_readdata_i <= ch_offset_dir0; - when CH_OFFSET_D1_REG => + when CH_OFFSET_D1_REG => avs_readdata_i <= ch_offset_dir1; - when CH_DELAY_REG => + when CH_DELAY_REG => avs_readdata_i <= ch_delay; when CH_CTRL_CTRL_REG => avs_readdata_i <= X"0000" & ch_ctrl_start_addr & X"0" & "00" & ch_ctrl_busy & ch_ctrl_start_req_ii; @@ -682,7 +682,7 @@ begin when PULSE_WIDTH_REG => avs_readdata_i <= X"00" & pulse_width_ext & X"00" & pulse_width; when OVERDRV_THRES_REG => - avs_readdata_i(15 downto 0) <= (0 => overdrive_rst, others => '0'); + avs_readdata_i(15 downto 0) <= (0 => overdrive_rst, others => '0'); avs_readdata_i(31 downto 16) <= overdrive_thres; when OVERDRV_EVENT_REG => avs_readdata_i <= X"0000" & overdrive_events; @@ -710,11 +710,11 @@ begin else avs_readdata_i <= X"BAD1BAD0"; end if; - if(avs_read = '1') then + if (avs_read = '1') then avs_address_i <= avs_address; end if; -- output multiplexer - case? avs_address_i( 9 downto 5) is + case? avs_address_i(9 downto 5) is when "00000" => avs_readdata <= avs_readdata_i; when "00001" => @@ -723,8 +723,8 @@ begin avs_readdata <= ch_ctrl_readdata; when others => avs_readdata <= X"BAD1BAD0"; - end case?; + end case?; end if; - end process pCTRL_STATUS; + end process pCTRL_STATUS; end architecture rtl; diff --git a/generic_ip/pulse_generator/1/src/queue_and_delay_1.vhd b/generic_ip/pulse_generator/1/src/queue_and_delay_1.vhd index a160bcd..c35d3e8 100644 --- a/generic_ip/pulse_generator/1/src/queue_and_delay_1.vhd +++ b/generic_ip/pulse_generator/1/src/queue_and_delay_1.vhd @@ -29,48 +29,34 @@ use work.common_pkg.all; entity queue_and_delay_1 is generic( - use_ext_time : boolean := false; - queue_size : natural range 16 to 8192 := 1024); - port ( - rstN : in std_logic; - clk : in std_logic; - init : in std_logic; - cnt_dir : in std_logic; -- specify the direction of the cnt (0 => up, 1 - -- => down), when use_ext_time is set to ture - delay : in std_logic_vector(31 downto 0); - ext_time : in std_logic_vector(31 downto 0); - wave_in : in std_logic; - wave_out : out std_logic; - ovf_error : out std_logic); + use_ext_time : boolean := false; + queue_size : natural range 16 to 8192 := 1024); + port( + rstN : in std_logic; + clk : in std_logic; + init : in std_logic; + cnt_dir : in std_logic; -- specify the direction of the cnt (0 => up, 1 => down), when use_ext_time is set to ture + delay : in std_logic_vector(31 downto 0); + ext_time : in std_logic_vector(31 downto 0); + wave_in : in std_logic; + wave_out : out std_logic; + ovf_error : out std_logic); end queue_and_delay_1; architecture RTL of queue_and_delay_1 is - component sync_fifo_1 - generic ( - FIFO_WIDTH : natural range 1 to 32; - FIFO_DEPTH : natural range 1 to 8192); - port ( - clock : in std_logic; - data : in std_logic_vector (FIFO_WIDTH-1 downto 0); - rdreq : in std_logic; - sclr : in std_logic; - wrreq : in std_logic; - empty : out std_logic; - full : out std_logic; - q : out std_logic_vector (FIFO_WIDTH-1 downto 0); - usedw : out std_logic_vector (log2(FIFO_DEPTH)-1 downto 0)); - end component; + signal toggle_in, toggle_out, time_elapsed : std_logic; + signal wave_in_d, wave_out_i, pending_trans : std_logic; + signal fifo_rd_en, fifo_empty, fifo_full : std_logic; + signal cnt_dir_i, wave_out_i_d, new_event : std_logic; + signal wave_out_ii, shf_enable : std_logic; + signal delay_line : std_logic_vector(7 downto 0); + signal local_time, local_time_d, event_time : std_logic_vector(31 downto 0); + signal internal_time : std_logic_vector(31 downto 0); -- internally generated time when ext_time not being used + signal sLocal_time_minus_delay, sLocal_time_plus_delay : signed(local_time'high + 1 downto 0); + signal TR1_Local_time_minus_delay : signed(local_time'high + 2 downto 0); - signal toggle_in, toggle_out,time_elapsed : std_logic; - signal wave_in_d, wave_out_i, pending_trans : std_logic; - signal fifo_rd_en, fifo_empty, fifo_full : std_logic; - signal cnt_dir_i, wave_out_i_d, new_event : std_logic; - signal wave_out_ii, shf_enable : std_logic; - signal delay_line : std_logic_vector( 7 downto 0); - signal local_time, local_time_d, event_time : std_logic_vector(31 downto 0); - -begin -- RTL +begin -- RTL ----------------------------------------------------------------------------- -- Detect transitions in the input signal and memorize those events in a @@ -82,20 +68,20 @@ begin -- RTL pInputEdgeDetect : process(clk) begin - if(clk = '1' and clk'event) then + if (clk = '1' and clk'event) then wave_in_d <= wave_in; end if; end process pInputEdgeDetect; - iENTRY_QUEUE: sync_fifo_1 + iENTRY_QUEUE : entity work.sync_fifo_1 generic map( FIFO_WIDTH => 32, FIFO_DEPTH => queue_size) - port map ( + port map( + sclr => init, clock => clk, data => local_time, rdreq => fifo_rd_en, - sclr => init, wrreq => toggle_in, empty => fifo_empty, full => fifo_full, @@ -105,74 +91,82 @@ begin -- RTL -- Check Overflow error: pCHECK_OVF : process(rstN, clk) begin - if(rstN = '0') then - ovf_error <= '0'; - elsif(clk = '1' and clk'event) then - if(init = '1') then + if (rstN = '0') then + ovf_error <= '0'; + elsif (clk = '1' and clk'event) then + if (init = '1') then ovf_error <= '0'; - elsif(toggle_in = '1' and fifo_full = '1') then + elsif (toggle_in = '1' and fifo_full = '1') then ovf_error <= '1'; end if; end if; - end process pCHECK_OVF; + end process pCHECK_OVF; -- Time reference: either use the external one or generate it locally - gTIME_REF0: if use_ext_time = true generate + gTIME_REF0 : if use_ext_time = true generate pLATCH_LOCTIME : process(clk) begin - if(clk = '1' and clk'event) then - local_time <= ext_time; + if (clk = '1' and clk'event) then + local_time <= ext_time; + sLocal_time_minus_delay <= resize(signed(ext_time) - signed(delay), sLocal_time_minus_delay'length); + sLocal_time_plus_delay <= resize(signed(ext_time) + signed(delay), sLocal_time_plus_delay'length); end if; end process pLATCH_LOCTIME; - + shf_enable <= '1' when local_time /= local_time_d else '0'; --pTimeElapsed : process(cnt_dir, local_time, event_time, delay) pTimeElapsed : process(clk) begin - if(clk = '1' and clk'event) then + if (clk = '1' and clk'event) then local_time_d <= local_time; - cnt_dir_i <= cnt_dir; - if(cnt_dir_i = '0') then - if(signed(local_time) >= signed(event_time) + signed(delay)) then + cnt_dir_i <= cnt_dir; + if (cnt_dir_i = '0') then + if sLocal_time_minus_delay >= resize(signed(event_time), sLocal_time_minus_delay'length) then time_elapsed <= '1'; else time_elapsed <= '0'; end if; else - if(signed(local_time) <= signed(event_time) - signed(delay)) then + if sLocal_time_plus_delay <= resize(signed(event_time), sLocal_time_plus_delay'length) then time_elapsed <= '1'; else time_elapsed <= '0'; end if; end if; - new_event <= fifo_rd_en; + new_event <= fifo_rd_en; end if; end process pTimeElapsed; - + + end generate gTIME_REF0; - gTIME_REF1: if use_ext_time = false generate + gTIME_REF1 : if use_ext_time = false generate pGEN_LOC_REF : process(rstN, clk) begin - if(rstN = '0') then - local_time <= (others => '0'); - elsif(clk = '1' and clk'event) then - if(init = '1') then - local_time <= (others => '0'); + if (rstN = '0') then + internal_time <= (others => '0'); + local_time <= (others => '0'); + TR1_Local_time_minus_delay <= (others => '0'); + elsif (clk = '1' and clk'event) then + local_time <= internal_time; + --TODO check that this still works - Q&D test bench? + TR1_Local_time_minus_delay <= resize(signed(b"0" & internal_time) - signed(b"0" & delay), TR1_Local_time_minus_delay'length); + if (init = '1') then + internal_time <= (others => '0'); else - local_time <= std_logic_vector(unsigned(local_time)+1); + internal_time <= std_logic_vector(unsigned(internal_time) + 1); end if; end if; end process pGEN_LOC_REF; - new_event <= fifo_rd_en; - time_elapsed <= '1' when unsigned(local_time) >= unsigned(event_time) + unsigned(delay) else '0'; + new_event <= fifo_rd_en; + time_elapsed <= '1' when TR1_Local_time_minus_delay >= signed(resize(unsigned(event_time), TR1_Local_time_minus_delay'length)) else '0'; shf_enable <= '1'; - + end generate gTIME_REF1; ----------------------------------------------------------------------------- @@ -182,28 +176,28 @@ begin -- RTL -- Read the signal transitions recorded in the FIFO, apply the static delay pDELAY_WAVE_GEN : process(clk) begin - if(clk = '1' and clk'event) then - if(init = '1' or (time_elapsed = '1' and new_event = '0')) then + if (clk = '1' and clk'event) then + if (init = '1' or (time_elapsed = '1' and new_event = '0')) then pending_trans <= '0'; - elsif(new_event = '1') then + elsif (new_event = '1') then pending_trans <= '1'; end if; - if(pending_trans = '0' and fifo_empty = '0' and fifo_rd_en = '0' and new_event = '0') then + if (pending_trans = '0' and fifo_empty = '0' and fifo_rd_en = '0' and new_event = '0') then fifo_rd_en <= '1'; else fifo_rd_en <= '0'; - end if; + end if; end if; end process pDELAY_WAVE_GEN; pGEN_OUT : process(rstN, clk) begin - if(rstN = '0') then - wave_out_i <= '0'; - elsif(clk = '1' and clk'event) then - if(init = '1') then + if (rstN = '0') then + wave_out_i <= '0'; + elsif (clk = '1' and clk'event) then + if (init = '1') then wave_out_i <= wave_in_d; - elsif(toggle_out = '1') then + elsif (toggle_out = '1') then wave_out_i <= not wave_out_i; end if; end if; @@ -213,14 +207,14 @@ begin -- RTL -- to achieve small delays (< 8). pDELAY_THROUGH_SHF : process(clk) begin - if(clk = '1' and clk'event) then - if(shf_enable = '1') then + if (clk = '1' and clk'event) then + if (shf_enable = '1') then delay_line <= delay_line(6 downto 0) & wave_in; end if; end if; end process pDELAY_THROUGH_SHF; - toggle_out <= time_elapsed and pending_trans; + toggle_out <= time_elapsed and pending_trans; -- When using the external counter, the input signal might have multiple rising and -- falling events whitout a change a value in the counter. When this happens, @@ -228,26 +222,26 @@ begin -- RTL -- block. To make the behaviour more predictable, when using the external -- counter, a positive edge detector is inserted at the output. - gOUT_GEN0: if use_ext_time = false generate + gOUT_GEN0 : if use_ext_time = false generate wave_out_ii <= wave_out_i when unsigned(delay) >= 8 else delay_line(to_integer(unsigned(delay(2 downto 0)))); - - pOUT_GEN0: process(clk) + + pOUT_GEN0 : process(clk) begin - if(clk = '1' and clk'event) then + if (clk = '1' and clk'event) then wave_out <= wave_out_ii; end if; end process pOUT_GEN0; end generate gOUT_GEN0; - gOUT_GEN1: if use_ext_time = true generate - - pOUT_GEN1: process(clk) + gOUT_GEN1 : if use_ext_time = true generate + + pOUT_GEN1 : process(clk) begin - if(clk = '1' and clk'event) then + if (clk = '1' and clk'event) then wave_out_i_d <= wave_out_i; - wave_out <= wave_out_i and not wave_out_i_d; + wave_out <= wave_out_i and not wave_out_i_d; end if; end process pOUT_GEN1; From c21e1dc854746341f7ce396a4547f4906f0caeb8 Mon Sep 17 00:00:00 2001 From: Damian Smith Date: Wed, 22 May 2019 11:17:40 +0100 Subject: [PATCH 12/29] HMBFDHV-83 modified uart_regen in similar way to uart_rx to improve timing on high-speed domain --- .../fire_pulse_manager/1/src/uart_regen_1.vhd | 100 ++++++++---------- 1 file changed, 45 insertions(+), 55 deletions(-) diff --git a/generic_ip/fire_pulse_manager/1/src/uart_regen_1.vhd b/generic_ip/fire_pulse_manager/1/src/uart_regen_1.vhd index 20f4e37..6fd265b 100644 --- a/generic_ip/fire_pulse_manager/1/src/uart_regen_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/uart_regen_1.vhd @@ -22,50 +22,39 @@ entity uart_regen_1 is generic( data_width : natural range 1 to 31); port( - reset_n : in std_logic; - clk : in std_logic; - bit_div : in std_logic_vector(3 downto 0); -- number of clock cycles per tx bit - enable : in std_logic; - bypass_en : in std_logic; - uart_rx : in std_logic; - uart_tx : out std_logic); + reset_n : in std_logic; + clk : in std_logic; + bit_div : in std_logic_vector(3 downto 0); -- number of clock cycles per tx bit + enable : in std_logic; + bypass_en : in std_logic; + uart_rx : in std_logic; + uart_tx : out std_logic); end entity uart_regen_1; architecture rtl of uart_regen_1 is - component sync_wire_1 - generic ( - rst_val : std_logic; - sync_stages : positive); - port ( - rstN : in std_logic; - clk : in std_logic; - async_in : in std_logic; - sync_out : out std_logic); - end component; - type fsm_state_t is (s_init, s_idle, s_regen); - signal fsm_state_curr, fsm_state_next : fsm_state_t; + signal fsm_state_curr, fsm_state_next : fsm_state_t; -- - signal uart_rx_i, ld_data, rst_bit_cnt, inc_bit_cnt : std_logic; - signal rst_clk_cnt, end_of_bit, end_of_rx : std_logic; - signal uart_regen, uart_regen_i : std_logic; + signal uart_rx_i, ld_data, rst_bit_cnt, inc_bit_cnt : std_logic; + signal rst_clk_cnt, end_of_bit, end_of_rx : std_logic; + signal uart_regen, uart_regen_i : std_logic; -- - signal clk_cnt : std_logic_vector(3 downto 0); - signal bit_cnt : std_logic_vector(5 downto 0); - + signal clk_cnt : std_logic_vector(3 downto 0); + signal bit_cnt : std_logic_vector(5 downto 0); + begin ----------------------------------------------------------------------------- -- Input Synchronization ----------------------------------------------------------------------------- - iSYNC_IN : sync_wire_1 - generic map ( + iSYNC_IN : entity work.sync_wire_1 + generic map( rst_val => '1', sync_stages => 3) - port map ( + port map( rstN => reset_n, clk => clk, async_in => uart_rx, @@ -80,32 +69,37 @@ begin pREGs : process(clk) begin - if(clk ='1' and clk'event) then - if(rst_bit_cnt = '1') then + if (clk = '1' and clk'event) then + if (rst_bit_cnt = '1') then bit_cnt <= (others => '0'); - elsif(inc_bit_cnt = '1') then - bit_cnt <= std_logic_vector(unsigned(bit_cnt)+1); + elsif (inc_bit_cnt = '1') then + bit_cnt <= std_logic_vector(unsigned(bit_cnt) + 1); end if; - if(rst_clk_cnt = '1' or end_of_bit = '1') then - clk_cnt <= (others => '0'); + ld_data <= '0'; + if clk_cnt = ('0' & std_logic_vector(unsigned(bit_div(bit_div'high downto 1)) + 1)) then + ld_data <= '1'; + end if; + + if (rst_clk_cnt = '1' or end_of_bit = '1') then + clk_cnt <= std_logic_vector(unsigned(bit_div) - 1); else - clk_cnt <= std_logic_vector(unsigned(clk_cnt)+1); + clk_cnt <= std_logic_vector(unsigned(clk_cnt) - 1); end if; - if(enable = '0') then + if (enable = '0') then uart_regen_i <= '1'; - elsif(ld_data = '1') then + elsif (ld_data = '1') then uart_regen_i <= uart_rx_i; end if; uart_regen <= uart_regen_i; end if; end process pREGs; - end_of_bit <= '1' when unsigned(clk_cnt) = (unsigned(bit_div)-1) else '0'; - end_of_rx <= '1' when unsigned(bit_cnt) = data_width+1 else '0'; + end_of_bit <= '1' when unsigned(clk_cnt) = 0 else '0'; + end_of_rx <= '1' when unsigned(bit_cnt) = data_width + 1 else '0'; -- output mux uart_tx <= uart_rx when bypass_en = '1' else uart_regen; - + ----------------------------------------------------------------------------- -- FSM ----------------------------------------------------------------------------- @@ -113,15 +107,15 @@ begin -- FSM state register pFSM_SR : process(clk) begin - if(clk = '1' and clk'event) then - if(enable = '0' or bypass_en = '1') then + if (clk = '1' and clk'event) then + if (enable = '0' or bypass_en = '1') then fsm_state_curr <= s_init; else fsm_state_curr <= fsm_state_next; end if; end if; end process pFSM_SR; - + -- FSM Combinational Logic pFSM_CL : process(fsm_state_curr, uart_rx_i, end_of_bit, end_of_rx, clk_cnt, bit_div) begin @@ -129,31 +123,28 @@ begin rst_clk_cnt <= '0'; rst_bit_cnt <= '0'; inc_bit_cnt <= '0'; - ld_data <= '0'; -- fsm_state_next <= fsm_state_curr; case fsm_state_curr is when s_init => - if(uart_rx_i = '1') then + if (uart_rx_i = '1') then fsm_state_next <= s_idle; end if; - + when s_idle => - if(uart_rx_i = '0') then + if (uart_rx_i = '0') then rst_clk_cnt <= '1'; rst_bit_cnt <= '1'; fsm_state_next <= s_regen; end if; when s_regen => - if(unsigned(clk_cnt) = (unsigned(bit_div(bit_div'high downto 1))-1)) then - ld_data <= '1'; - end if; - if(end_of_bit = '1') then - inc_bit_cnt <= '1'; - if(end_of_rx = '1') then - if(uart_rx_i = '1') then + + if (end_of_bit = '1') then + inc_bit_cnt <= '1'; + if (end_of_rx = '1') then + if (uart_rx_i = '1') then fsm_state_next <= s_idle; else fsm_state_next <= s_init; @@ -161,7 +152,6 @@ begin end if; end if; - when others => null; end case; end process pFSM_CL; From e21e804433b0963459517743437a8083a5a29c3e Mon Sep 17 00:00:00 2001 From: Damian Smith Date: Thu, 23 May 2019 09:44:59 +0100 Subject: [PATCH 13/29] HMBFDHV-83 ELGIP-58 changed comments referring to 200MHz. Improved metastability handling in pof_rx, using synchronisers with attributes included to handle CDC. Corrected sensitivity list in uart_regen_1 and added a note on metastability. Put a note in the testbench as it runs at 200MHz rx_clk, but we recommend 300MHz so it is both specific, and not ideal. --- .../fire_pulse_manager/1/sim/sim_fpm.do | 4 +- .../1/src/fire_pulse_manager_1.vhd | 14 +- .../fire_pulse_manager/1/src/pof_rx_1.vhd | 276 +++++++++--------- .../fire_pulse_manager/1/src/sync_wire_1.vhd | 38 +-- .../1/src/sync_wire_rEdge_1.vhd | 38 +-- .../1/src/test/fire_pulse_manager_1_tb.vhd | 2 +- .../fire_pulse_manager/1/src/uart_regen_1.vhd | 19 +- .../fire_pulse_manager/1/src/uart_rx_1.vhd | 1 - .../doc/generic_versioning.json | 2 +- 9 files changed, 208 insertions(+), 186 deletions(-) diff --git a/generic_ip/fire_pulse_manager/1/sim/sim_fpm.do b/generic_ip/fire_pulse_manager/1/sim/sim_fpm.do index f6ba4aa..c2dc034 100644 --- a/generic_ip/fire_pulse_manager/1/sim/sim_fpm.do +++ b/generic_ip/fire_pulse_manager/1/sim/sim_fpm.do @@ -37,11 +37,11 @@ vcom -2008 -work $WORKLIB $GENERIC_PATH/generic_sequencer/15/src/generic_sequenc vcom -2008 -work $WORKLIB $GENERIC_PATH/generic_sequencer/15/src/generic_sequencer_15.vhd # Pulse Generator +vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/altera/sync_fifo_1.vhd vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/pulse_generator_1_pkg.vhd vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/pulse_conditioning_1.vhd vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/queue_and_delay_1.vhd vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/simple_frac_div_1.vhd -vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/altera/sync_fifo_1.vhd vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/pulse_generator_1.vhd # Enc PD Emul @@ -51,9 +51,9 @@ vcom -2008 -work $WORKLIB $GENERIC_PATH/enc_pd_emul/1/src/enc_pd_emul_1.vhd # Fire-Pulse-Manager vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_1_pkg.vhd vcom -2008 -work $WORKLIB $SRC_PATH/uart_rx_1.vhd +vcom -2008 -work $WORKLIB $SRC_PATH/sync_wire_1.vhd vcom -2008 -work $WORKLIB $SRC_PATH/uart_regen_1.vhd vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_ctrl_1.vhd -vcom -2008 -work $WORKLIB $SRC_PATH/sync_wire_1.vhd vcom -2008 -work $WORKLIB $SRC_PATH/sync_wire_rEdge_1.vhd vcom -2008 -work $WORKLIB $SRC_PATH/pof_rx_1.vhd vcom -2008 -work $WORKLIB $SRC_PATH/cs_bus_itf_1.vhd diff --git a/generic_ip/fire_pulse_manager/1/src/fire_pulse_manager_1.vhd b/generic_ip/fire_pulse_manager/1/src/fire_pulse_manager_1.vhd index b7126c5..ba478c3 100644 --- a/generic_ip/fire_pulse_manager/1/src/fire_pulse_manager_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/fire_pulse_manager_1.vhd @@ -25,7 +25,7 @@ entity fire_pulse_manager_1 is port( reset_n : in std_logic; clk : in std_logic; -- 100MHz - rx_clk : in std_logic; -- 200MHz + rx_clk : in std_logic; -- 300MHz (recommended for 50MBd POF Link) -- Datapath I/Os pof_rx : in std_logic; pof_tx : out std_logic; @@ -35,9 +35,10 @@ entity fire_pulse_manager_1 is -- on header J7 -- Interrupt Senders ins_fpm_irq_0 : out std_logic; - ins_fpm_irq_1 : out std_logic; -- @suppress "Unused port: ins_fpm_irq_1 is not used in work.fire_pulse_manager_1(rtl)" - ins_fpm_irq_2 : out std_logic; -- @suppress "Unused port: ins_fpm_irq_2 is not used in work.fire_pulse_manager_1(rtl)" - ins_fpm_irq_3 : out std_logic; -- @suppress "Unused port: ins_fpm_irq_3 is not used in work.fire_pulse_manager_1(rtl)" + -- unused 1 to 3 + ins_fpm_irq_1 : out std_logic; + ins_fpm_irq_2 : out std_logic; + ins_fpm_irq_3 : out std_logic; -- Avalon MM (Slave) Interface avs_address : in std_logic_vector(14 downto 0); avs_write : in std_logic; @@ -361,6 +362,11 @@ begin fire_pulse_i <= ch_pulse_out when src_sel(0) = '1' else (others => pof_rx_regen); fire_pulse <= fire_pulse_i; + -- Unused IRQs - set low until needed to give defined state + ins_fpm_irq_1 <= '0'; + ins_fpm_irq_2 <= '0'; + ins_fpm_irq_3 <= '0'; + pd_pulse <= pd_pulse_pof when src_sel(1) = '0' else pd_pulse_ie; enc_pulse <= enc_pulse_pof when src_sel(1) = '0' else enc_pulse_ie; abs_pos <= abs_pos_pof when src_sel(1) = '0' else abs_pos_ie(31 downto 0); diff --git a/generic_ip/fire_pulse_manager/1/src/pof_rx_1.vhd b/generic_ip/fire_pulse_manager/1/src/pof_rx_1.vhd index 0de5657..768e0b8 100644 --- a/generic_ip/fire_pulse_manager/1/src/pof_rx_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/pof_rx_1.vhd @@ -20,32 +20,32 @@ use ieee.numeric_std.all; entity pof_rx_1 is port( - reset_n : in std_logic; - clk : in std_logic; + reset_n : in std_logic; + clk : in std_logic; -- - init : in std_logic; - rx_clk : in std_logic; - rx_data : in std_logic; - init_out : out std_logic; - dp_dir : in std_logic; - enc_out : out std_logic; - pd_out : out std_logic; - inc_pos : out std_logic; - dec_pos : out std_logic; - abs_pos : out std_logic_vector(31 downto 0); + init : in std_logic; + rx_clk : in std_logic; + rx_data : in std_logic; + init_out : out std_logic; + dp_dir : in std_logic; + enc_out : out std_logic; + pd_out : out std_logic; + inc_pos : out std_logic; + dec_pos : out std_logic; + abs_pos : out std_logic_vector(31 downto 0); -- C&S - enable : in std_logic; - bit_div : in std_logic_vector( 3 downto 0); - error_rate_thres : in std_logic_vector( 7 downto 0); - one_pps : in std_logic; - upd_max_pos : in std_logic; - upd_min_pos : in std_logic; - max_error_flag : out std_logic; - rx_watchdog : out std_logic; - rx_watchdog_en : in std_logic; - rx_watchdog_clr : in std_logic; - parity_err_cnt : out std_logic_vector(15 downto 0); - skip_pos_cnt : out std_logic_vector(15 downto 0)); + enable : in std_logic; + bit_div : in std_logic_vector(3 downto 0); + error_rate_thres : in std_logic_vector(7 downto 0); + one_pps : in std_logic; + upd_max_pos : in std_logic; + upd_min_pos : in std_logic; + max_error_flag : out std_logic; + rx_watchdog : out std_logic; + rx_watchdog_en : in std_logic; + rx_watchdog_clr : in std_logic; + parity_err_cnt : out std_logic_vector(15 downto 0); + skip_pos_cnt : out std_logic_vector(15 downto 0)); end entity pof_rx_1; architecture rtl of pof_rx_1 is @@ -54,9 +54,9 @@ architecture rtl of pof_rx_1 is function odd_parity_check(data : std_logic_vector) return std_logic is variable parity_bit : std_logic := '0'; begin - for n in 0 to data'length-1 loop + for n in 0 to data'length - 1 loop parity_bit := parity_bit xor data(n); - end loop; -- n + end loop; -- n return parity_bit; end function odd_parity_check; @@ -64,10 +64,10 @@ architecture rtl of pof_rx_1 is function gray2bin(gray : std_logic_vector) return std_logic_vector is variable bin : std_logic_vector(gray'range); begin - bin(gray'length-1) := gray(gray'length-1); - for i in gray'length-2 downto 0 loop - bin(i) := bin(i+1) xor gray(i); - end loop; -- n + bin(gray'length - 1) := gray(gray'length - 1); + for i in gray'length - 2 downto 0 loop + bin(i) := bin(i + 1) xor gray(i); + end loop; -- n return bin; end function gray2bin; @@ -82,30 +82,36 @@ architecture rtl of pof_rx_1 is signal rx_symbol_val, clear_i, skip_pos_d, pos_recovery : std_logic; signal dp_dir_d, dp_dir_change, max_error_flag_i : std_logic; -- - signal clk_cnt : std_logic_vector( 1 downto 0); - signal dist, abs_dist, skip_cnt : std_logic_vector( 3 downto 0); - signal next_pos_lsb, curr_pos_lsb : std_logic_vector( 3 downto 0); - signal pos_corr, max_dist, rx_error_v : std_logic_vector( 3 downto 0); - signal gray_pos, rx_symbol_val_v : std_logic_vector( 3 downto 0); - signal symbol, symbol_i, rx_symbol : std_logic_vector( 7 downto 0); - signal rx_wd_cnt : std_logic_vector( 9 downto 0); - signal parity_err_cnt_i, skip_pos_cnt_i : std_logic_vector(15 downto 0); - signal error_rate_cnt, error_rate : std_logic_vector(15 downto 0); - signal abs_pos_i, pos_max, pos_min : std_logic_vector(31 downto 0); - signal dist_pos, dist_neg : std_logic_vector(31 downto 0); - + signal clk_cnt : std_logic_vector(1 downto 0); + signal dist, abs_dist, skip_cnt : std_logic_vector(3 downto 0); + signal next_pos_lsb, curr_pos_lsb : std_logic_vector(3 downto 0); + signal pos_corr, max_dist, rx_error_v : std_logic_vector(3 downto 0); + signal gray_pos, rx_symbol_val_v : std_logic_vector(3 downto 0); + signal symbol_i, rx_symbol : std_logic_vector(7 downto 0); + signal rx_wd_cnt : std_logic_vector(9 downto 0); + signal parity_err_cnt_i, skip_pos_cnt_i : std_logic_vector(15 downto 0); + signal error_rate_cnt, error_rate : std_logic_vector(15 downto 0); + signal abs_pos_i, pos_max, pos_min : std_logic_vector(31 downto 0); + signal dist_pos, dist_neg : std_logic_vector(31 downto 0); + signal symbol_sample : std_logic; + + -- declare false path as symbol_i is sampled only when safe as validated by symbol_sample + attribute altera_attribute : string; + attribute altera_attribute of rtl : architecture is + "-name SDC_STATEMENT ""set_false_path -from [get_keepers *] -to [get_keepers {*pof_rx_1:*symbol_i\[*\]}]"" "; + begin clear <= not enable or init; ----------------------------------------------------------------------------- - -- De-serialize symbols (Serial clock at 200 MHz) + -- De-serialize symbols (Serial clock at Higher Speed ( Rx Clock probably 300 MHz) ----------------------------------------------------------------------------- - + iRX_SYMBOL : entity work.uart_rx_1 - generic map ( + generic map( data_width => 8) - port map ( + port map( reset_n => reset_n, clk => rx_clk, bit_div => bit_div, @@ -118,16 +124,14 @@ begin -- Synchronize to the local clock pLATCH_RX_DATA : process(rx_clk) begin - if(rx_clk = '1' and rx_clk'event) then - if(rx_symbol_val = '1') then - symbol <= rx_symbol; - end if; - if(rx_symbol_val = '1') then + if (rx_clk = '1' and rx_clk'event) then + -- relies on rx_clk <= 3 times clk + if (rx_symbol_val = '1') then rx_symbol_val_v <= "1111"; else rx_symbol_val_v <= '0' & rx_symbol_val_v(3 downto 1); end if; - if(rx_error = '1') then + if (rx_error = '1') then rx_error_v <= "1111"; else rx_error_v <= '0' & rx_error_v(3 downto 1); @@ -136,17 +140,18 @@ begin end process pLATCH_RX_DATA; iSYNC_SYMBOL_VAL : entity work.sync_wire_rEdge_1 - generic map (rst_val => '0', sync_stages => 3) - port map (rstN => reset_n, clk => clk, async_in => rx_symbol_val_v(0), sync_out => symbol_valid); + generic map(rst_val => '0', sync_stages => 2) + port map(rstN => reset_n, clk => clk, async_in => rx_symbol_val_v(0), sync_out => symbol_sample); -- symbol_sample will become symbol_valid iSYNC_RX_ERROR : entity work.sync_wire_rEdge_1 - generic map (rst_val => '0', sync_stages => 3) - port map (rstN => reset_n, clk => clk, async_in => rx_error_v(0), sync_out => rx_error_i); - -- synchronize clear to tx_clk - iSYNC_CLEAR: entity work.sync_wire_1 - generic map (rst_val => '1', sync_stages => 2) - port map ( - rstN => reset_n, clk => rx_clk, async_in => clear, sync_out => clear_i); + generic map(rst_val => '0', sync_stages => 3) + port map(rstN => reset_n, clk => clk, async_in => rx_error_v(0), sync_out => rx_error_i); -- Caution! Separate metastability path so don't rely on relative timing + + -- synchronize clear to rx_clk + iSYNC_CLEAR : entity work.sync_wire_1 + generic map(rst_val => '1', sync_stages => 2) + port map( + rstN => reset_n, clk => rx_clk, async_in => clear, sync_out => clear_i); ----------------------------------------------------------------------------- -- Toggle-Bits Decoding @@ -154,56 +159,58 @@ begin pTOGGLE_DEC : process(clk) begin - if(clk = '1' and clk'event) then + if (clk = '1' and clk'event) then -- Toggle Bits - if(clear = '1') then + if (clear = '1') then toggle_sync <= '0'; - elsif(sync_confirmed = '1') then - toggle_sync <= not toggle_sync; + elsif (sync_confirmed = '1') then + toggle_sync <= not toggle_sync; end if; - if(clear = '1' or sync_confirmed = '1' or (symbol_valid_i = '1' and symbol_i(0) = toggle_sync)) then + if (clear = '1' or sync_confirmed = '1' or (symbol_valid_i = '1' and symbol_i(0) = toggle_sync)) then sync_toggle_test <= '0'; - elsif(sync_gen = '1') then + elsif (sync_gen = '1') then sync_toggle_test <= '1'; end if; - sync <= sync_confirmed; - sync_d <= sync; - if(clear = '1') then + sync <= sync_confirmed; + sync_d <= sync; + if (clear = '1') then toggle_pd <= '0'; - elsif(pd_confirmed = '1') then - toggle_pd <= not toggle_pd; + elsif (pd_confirmed = '1') then + toggle_pd <= not toggle_pd; end if; - if(clear = '1' or pd_confirmed = '1' or (symbol_valid_i = '1' and symbol_i(2) = toggle_pd)) then + if (clear = '1' or pd_confirmed = '1' or (symbol_valid_i = '1' and symbol_i(2) = toggle_pd)) then pd_toggle_test <= '0'; - elsif(pd_gen = '1') then + elsif (pd_gen = '1') then pd_toggle_test <= '1'; end if; - pd <= pd_confirmed; + pd <= pd_confirmed; -- + if symbol_sample = '1' then + symbol_i <= rx_symbol; + end if; + symbol_valid <= symbol_sample; symbol_valid_i <= symbol_valid and symbol_ok; symbol_error <= symbol_valid and not symbol_ok; - if(clear = '1') then + if (clear = '1') then parity_err_cnt_i <= (others => '0'); - elsif(symbol_error = '1') then - parity_err_cnt_i <= std_logic_vector(unsigned(parity_err_cnt_i)+1); + elsif (symbol_error = '1') then + parity_err_cnt_i <= std_logic_vector(unsigned(parity_err_cnt_i) + 1); end if; end if; end process pTOGGLE_DEC; - symbol_i <= symbol; - -- The received symbol is assumed to be vaild when there is not parity error -- and when the two bits with the PD-toggle bit are equal - symbol_ok <= '1' when odd_parity_check(symbol) = '1' and (symbol(1) = symbol(2)) else '0'; + symbol_ok <= '1' when odd_parity_check(symbol_i) = '1' and (symbol_i(1) = symbol_i(2)) else '0'; - sync_gen <= '1' when symbol_valid_i = '1' and symbol_i(0) /= toggle_sync else '0'; - pd_gen <= '1' when symbol_valid_i = '1' and symbol_i(2) /= toggle_pd else '0'; + sync_gen <= '1' when symbol_valid_i = '1' and symbol_i(0) /= toggle_sync else '0'; + pd_gen <= '1' when symbol_valid_i = '1' and symbol_i(2) /= toggle_pd else '0'; -- sync_confirmed <= sync_gen and sync_toggle_test; - pd_confirmed <= pd_gen and pd_toggle_test; + pd_confirmed <= pd_gen and pd_toggle_test; -- - init_out <= sync; - pd_out <= pd; + init_out <= sync; + pd_out <= pd; parity_err_cnt <= parity_err_cnt_i; @@ -215,64 +222,63 @@ begin next_pos_lsb <= gray2bin(gray_pos); curr_pos_lsb <= abs_pos_i(3 downto 0); - --dist <= std_logic_vector(signed(next_pos_lsb)-signed(curr_pos_lsb)); - abs_dist <= dist when dist(3) = '0' else std_logic_vector(unsigned(not dist)+1); + abs_dist <= dist when dist(3) = '0' else std_logic_vector(unsigned(not dist) + 1); pPOS_MNG : process(clk) begin - if(clk = '1' and clk'event) then - dist <= std_logic_vector(signed(next_pos_lsb)-signed(curr_pos_lsb)); + if (clk = '1' and clk'event) then + dist <= std_logic_vector(signed(next_pos_lsb) - signed(curr_pos_lsb)); symbol_valid_d <= symbol_valid_i; - if(clear = '1' or (symbol_valid_d = '1' and signed(dist) = 0) or pos_recovery = '1') then + if (clear = '1' or (symbol_valid_d = '1' and signed(dist) = 0) or pos_recovery = '1') then max_dist <= "0001"; - elsif(skip_pos = '1' or rx_error_i = '1') then + elsif (skip_pos = '1' or rx_error_i = '1') then max_dist <= std_logic_vector(unsigned(max_dist) + 1); end if; - if(symbol_valid_d = '1' and valid_pos = '1') then + if (symbol_valid_d = '1' and valid_pos = '1') then pos_corr <= abs_dist; - elsif(apply_corr = '1') then - pos_corr <= std_logic_vector(unsigned(pos_corr)-1); + elsif (apply_corr = '1') then + pos_corr <= std_logic_vector(unsigned(pos_corr) - 1); end if; - if(clear = '1' or corr_done = '1') then + if (clear = '1' or corr_done = '1') then upd_pos <= '0'; - elsif(symbol_valid_d = '1' and valid_pos = '1') then + elsif (symbol_valid_d = '1' and valid_pos = '1') then upd_pos <= '1'; end if; - if(upd_pos = '0' or unsigned(clk_cnt) = 2) then + if (upd_pos = '0' or unsigned(clk_cnt) = 2) then clk_cnt <= (others => '0'); else - clk_cnt <= std_logic_vector(unsigned(clk_cnt)+1); + clk_cnt <= std_logic_vector(unsigned(clk_cnt) + 1); end if; - if(symbol_valid_d = '1' and valid_pos = '1') then + if (symbol_valid_d = '1' and valid_pos = '1') then corr_sign <= dist(3); end if; - inc_pos_i <= inc_pos_ii; - dec_pos_i <= dec_pos_ii; - inc_pos <= inc_pos_i; - dec_pos <= dec_pos_i; - if(clear = '1' or sync = '1') then + inc_pos_i <= inc_pos_ii; + dec_pos_i <= dec_pos_ii; + inc_pos <= inc_pos_i; + dec_pos <= dec_pos_i; + if (clear = '1' or sync = '1') then abs_pos_i <= (others => '0'); - elsif(inc_pos_ii = '1') then - abs_pos_i <= std_logic_vector(signed(abs_pos_i)+1); - elsif(dec_pos_ii = '1') then - abs_pos_i <= std_logic_vector(signed(abs_pos_i)-1); + elsif (inc_pos_ii = '1') then + abs_pos_i <= std_logic_vector(signed(abs_pos_i) + 1); + elsif (dec_pos_ii = '1') then + abs_pos_i <= std_logic_vector(signed(abs_pos_i) - 1); end if; - abs_pos <= abs_pos_i; - skip_pos_d <= skip_pos; - if(clear = '1' or (symbol_valid_d = '1' and valid_pos = '1')) then + abs_pos <= abs_pos_i; + skip_pos_d <= skip_pos; + if (clear = '1' or (symbol_valid_d = '1' and valid_pos = '1')) then skip_cnt <= (others => '0'); - elsif(skip_pos = '1' and skip_pos_d = '0') then - skip_cnt <= std_logic_vector(unsigned(skip_cnt)+1); + elsif (skip_pos = '1' and skip_pos_d = '0') then + skip_cnt <= std_logic_vector(unsigned(skip_cnt) + 1); end if; - if(clear = '1') then + if (clear = '1') then skip_pos_cnt_i <= (others => '0'); - elsif(skip_pos_d = '1') then - skip_pos_cnt_i <= std_logic_vector(unsigned(skip_pos_cnt_i)+1); + elsif (skip_pos_d = '1') then + skip_pos_cnt_i <= std_logic_vector(unsigned(skip_pos_cnt_i) + 1); end if; end if; end process pPOS_MNG; - skip_pos <= '1' when (symbol_valid = '1' and symbol_ok = '0') or (symbol_valid_d = '1' and valid_pos = '0' ) else '0'; + skip_pos <= '1' when (symbol_valid = '1' and symbol_ok = '0') or (symbol_valid_d = '1' and valid_pos = '0') else '0'; pos_recovery <= '1' when unsigned(skip_cnt) >= 3 else '0'; valid_pos <= '1' when unsigned(abs_dist) <= unsigned(max_dist) or pos_recovery = '1' else '0'; @@ -291,26 +297,26 @@ begin pERROR_REPORTING : process(clk) begin - if(clk = '1' and clk'event) then - if(clear = '1' or one_pps = '1') then + if (clk = '1' and clk'event) then + if (clear = '1' or one_pps = '1') then error_rate_cnt <= (others => '0'); - elsif(symbol_error = '1') then - error_rate_cnt <= std_logic_vector(unsigned(error_rate_cnt)+1); + elsif (symbol_error = '1') then + error_rate_cnt <= std_logic_vector(unsigned(error_rate_cnt) + 1); end if; - if(clear = '1') then + if (clear = '1') then error_rate <= (others => '0'); - elsif(one_pps = '1') then + elsif (one_pps = '1') then error_rate <= error_rate_cnt; end if; max_error_flag <= not clear and max_error_flag_i; - if(clear = '1' or symbol_valid_i = '1' or rx_watchdog_clr = '1') then + if (clear = '1' or symbol_valid_i = '1' or rx_watchdog_clr = '1') then rx_wd_cnt <= (others => '0'); else - rx_wd_cnt <= std_logic_vector(unsigned(rx_wd_cnt)+1); + rx_wd_cnt <= std_logic_vector(unsigned(rx_wd_cnt) + 1); end if; - if(clear = '1' or rx_watchdog_clr = '1' or rx_watchdog_en = '0' or sync = '1') then + if (clear = '1' or rx_watchdog_clr = '1' or rx_watchdog_en = '0' or sync = '1') then rx_watchdog <= '0'; - elsif(unsigned(rx_wd_cnt) > 1000) then + elsif (unsigned(rx_wd_cnt) > 1000) then rx_watchdog <= '1'; end if; end if; @@ -334,24 +340,24 @@ begin pENC_MNG : process(clk) begin - if(clk = '1' and clk'event) then + if (clk = '1' and clk'event) then dp_dir_d <= dp_dir; - if(sync_d = '1' or dp_dir_change = '1' or new_max = '1' or upd_max_pos = '1') then + if (sync_d = '1' or dp_dir_change = '1' or new_max = '1' or upd_max_pos = '1') then pos_max <= abs_pos_i; end if; - if(sync_d = '1' or dp_dir_change = '1' or new_min = '1' or upd_min_pos = '1') then + if (sync_d = '1' or dp_dir_change = '1' or new_min = '1' or upd_min_pos = '1') then pos_min <= abs_pos_i; end if; - enc_out <= new_min or new_max; + enc_out <= new_min or new_max; end if; end process pENC_MNG; dp_dir_change <= dp_dir xor dp_dir_d; - dist_pos <= std_logic_vector(signed(abs_pos_i)-signed(pos_max)); - dist_neg <= std_logic_vector(signed(pos_min)-signed(abs_pos_i)); + dist_pos <= std_logic_vector(signed(abs_pos_i) - signed(pos_max)); + dist_neg <= std_logic_vector(signed(pos_min) - signed(abs_pos_i)); new_max <= '1' when inc_pos_i = '1' and dp_dir = '0' and dist_pos(31) = '0' and unsigned(dist_pos(3 downto 0)) /= 0 else '0'; new_min <= '1' when dec_pos_i = '1' and dp_dir = '1' and dist_neg(31) = '0' and unsigned(dist_neg(3 downto 0)) /= 0 else '0'; - + end architecture rtl; diff --git a/generic_ip/fire_pulse_manager/1/src/sync_wire_1.vhd b/generic_ip/fire_pulse_manager/1/src/sync_wire_1.vhd index 52fd605..4f35c29 100644 --- a/generic_ip/fire_pulse_manager/1/src/sync_wire_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/sync_wire_1.vhd @@ -3,17 +3,18 @@ ------------------------------------------------------------------------------- -- File : sync_wire.vhd -- Author : Gianmarco Girau --- Company : On my own +-- Company : GIS -- Target : Generic (simulation), Generic (synthesis) -- Dependency : none ------------------------------------------------------------------------------- -- Description: synchronize a std_logic signal to a clock domain ------------------------------------------------------------------------------- --- Last update: 2015-08-17 +-- Last update: 2019-05-22 ------------------------------------------------------------------------------- -- Revisions : -- Date Version Author Description -- 2010-10-25 1.0 gmg Created +-- 2019-05-22 1.1 ds added altera attribute ------------------------------------------------------------------------------- library ieee; @@ -24,36 +25,39 @@ entity sync_wire_1 is rst_val : std_logic := '0'; sync_stages : positive := 2); port( - rstN : in std_logic; - clk : in std_logic; - async_in : in std_logic; - sync_out : out std_logic); + rstN : in std_logic; + clk : in std_logic; + async_in : in std_logic; + sync_out : out std_logic); end sync_wire_1; architecture RTL of sync_wire_1 is - signal sync_sig : std_logic_vector(sync_stages-1 downto 0); - + signal sync_sig : std_logic_vector(sync_stages - 1 downto 0); + -- declare false path for the input to the synchroniser + attribute altera_attribute : string; + attribute altera_attribute of RTL : architecture is + "-name SDC_STATEMENT ""set_false_path -from [get_keepers *] -to [get_keepers {*sync_wire_1:*sync_sig\[0\]}]"" "; begin pSYNC : process(rstN, clk) begin - if(rstN = '0') then - for n in 0 to sync_stages-1 loop + if (rstN = '0') then + for n in 0 to sync_stages - 1 loop sync_sig(n) <= rst_val; - end loop; -- n - elsif(clk = '1' and clk'event) then - for n in 0 to sync_stages-1 loop - if(n = 0) then + end loop; -- n + elsif (clk = '1' and clk'event) then + for n in 0 to sync_stages - 1 loop + if (n = 0) then sync_sig(0) <= async_in; else - sync_sig(n) <= sync_sig(n-1); + sync_sig(n) <= sync_sig(n - 1); end if; - end loop; -- n + end loop; -- n end if; end process pSYNC; - sync_out <= sync_sig(sync_stages-1); + sync_out <= sync_sig(sync_stages - 1); end RTL; diff --git a/generic_ip/fire_pulse_manager/1/src/sync_wire_rEdge_1.vhd b/generic_ip/fire_pulse_manager/1/src/sync_wire_rEdge_1.vhd index 5d2b1bb..8e76c52 100644 --- a/generic_ip/fire_pulse_manager/1/src/sync_wire_rEdge_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/sync_wire_rEdge_1.vhd @@ -3,17 +3,18 @@ ------------------------------------------------------------------------------- -- File : sync_wire_rEdge.vhd -- Author : Gianmarco Girau --- Company : On my own +-- Company : GIS -- Target : Generic (simulation), Generic (synthesis) -- Dependency : none ------------------------------------------------------------------------------- -- Description: synchronize a std_logic signal to a clock domain with rising edge ------------------------------------------------------------------------------- --- Last update: 2015-08-17 +-- Last update: 2019-05-22 ------------------------------------------------------------------------------- -- Revisions : -- Date Version Author Description -- 2010-12-03 1.0 gmg Created +-- 2019-05-22 1.1 ds added altera attribute ------------------------------------------------------------------------------- library ieee; @@ -24,39 +25,42 @@ entity sync_wire_rEdge_1 is rst_val : std_logic := '0'; sync_stages : positive := 2); port( - rstN : in std_logic; - clk : in std_logic; - async_in : in std_logic; - sync_out : out std_logic); + rstN : in std_logic; + clk : in std_logic; + async_in : in std_logic; + sync_out : out std_logic); end sync_wire_rEdge_1; architecture RTL of sync_wire_rEdge_1 is signal sync_out_i, sync_out_d : std_logic; - signal sync_sig : std_logic_vector(sync_stages-1 downto 0); - + signal sync_sig : std_logic_vector(sync_stages - 1 downto 0); + -- declare false path for the input to the synchroniser + attribute altera_attribute : string; + attribute altera_attribute of RTL : architecture is + "-name SDC_STATEMENT ""set_false_path -from [get_keepers *] -to [get_keepers {*sync_wire_rEdge_1:*sync_sig\[0\]}]"" "; begin pSYNC : process(rstN, clk) begin - if(rstN = '0') then + if (rstN = '0') then sync_out_d <= rst_val; - for n in 0 to sync_stages-1 loop + for n in 0 to sync_stages - 1 loop sync_sig(n) <= rst_val; - end loop; -- n - elsif(clk = '1' and clk'event) then + end loop; -- n + elsif (clk = '1' and clk'event) then sync_out_d <= sync_out_i; - for n in 0 to sync_stages-1 loop - if(n = 0) then + for n in 0 to sync_stages - 1 loop + if (n = 0) then sync_sig(0) <= async_in; else - sync_sig(n) <= sync_sig(n-1); + sync_sig(n) <= sync_sig(n - 1); end if; - end loop; -- n + end loop; -- n end if; end process pSYNC; - sync_out_i <= sync_sig(sync_stages-1); + sync_out_i <= sync_sig(sync_stages - 1); -- rising edge detect sync_out <= sync_out_i and not sync_out_d; diff --git a/generic_ip/fire_pulse_manager/1/src/test/fire_pulse_manager_1_tb.vhd b/generic_ip/fire_pulse_manager/1/src/test/fire_pulse_manager_1_tb.vhd index 12eca4f..37a7746 100644 --- a/generic_ip/fire_pulse_manager/1/src/test/fire_pulse_manager_1_tb.vhd +++ b/generic_ip/fire_pulse_manager/1/src/test/fire_pulse_manager_1_tb.vhd @@ -48,7 +48,7 @@ architecture behav of fire_pulse_manager_1_tb is constant CLK_FREQ : real := 100.0e6; constant TX_CLK_PERIOD : time := CLK_PERIOD; -- nominally the same as clk_period - + -- TODO Try different receive oversampling ratios - 300MHz is in the real system constant RX_CLK_PERIOD : time := 5.0 ns; -- clock period for used by the -- UART-Rx on the POF diff --git a/generic_ip/fire_pulse_manager/1/src/uart_regen_1.vhd b/generic_ip/fire_pulse_manager/1/src/uart_regen_1.vhd index 6fd265b..dd67a54 100644 --- a/generic_ip/fire_pulse_manager/1/src/uart_regen_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/uart_regen_1.vhd @@ -22,13 +22,15 @@ entity uart_regen_1 is generic( data_width : natural range 1 to 31); port( - reset_n : in std_logic; - clk : in std_logic; - bit_div : in std_logic_vector(3 downto 0); -- number of clock cycles per tx bit - enable : in std_logic; - bypass_en : in std_logic; - uart_rx : in std_logic; - uart_tx : out std_logic); + reset_n : in std_logic; + clk : in std_logic; -- faster clock (2 or 3 times 100MHz) + -- On 100MHz clock + bit_div : in std_logic_vector(3 downto 0); -- number of clock cycles per tx bit + enable : in std_logic; + bypass_en : in std_logic; + -- + uart_rx : in std_logic; + uart_tx : out std_logic); end entity uart_regen_1; architecture rtl of uart_regen_1 is @@ -60,6 +62,7 @@ begin async_in => uart_rx, sync_out => uart_rx_i); + -- FIXME - don't agree with this statement - metastability can be more subtle. Could put the state vector into an undefined value. -- NOTE : No NEED TO SYNCHRONIZE TO THE LOCAL CLOCK inputs enable, bypass_en -- and bit_biv BECAUSE THOSE SIGNALS ARE PREDOMINANTLY STATIC @@ -117,7 +120,7 @@ begin end process pFSM_SR; -- FSM Combinational Logic - pFSM_CL : process(fsm_state_curr, uart_rx_i, end_of_bit, end_of_rx, clk_cnt, bit_div) + pFSM_CL : process(all) begin --default assignments rst_clk_cnt <= '0'; diff --git a/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd b/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd index 7980f24..bbb7eed 100644 --- a/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd @@ -181,7 +181,6 @@ begin end if; end if; - when others => null; end case; end process pFSM_CL; diff --git a/generic_ip/generic_versioning/doc/generic_versioning.json b/generic_ip/generic_versioning/doc/generic_versioning.json index d7268ce..a2c191e 100644 --- a/generic_ip/generic_versioning/doc/generic_versioning.json +++ b/generic_ip/generic_versioning/doc/generic_versioning.json @@ -4,7 +4,7 @@ "bus": "csr", "addr_width": "4", "description": "This block is the generic versioning", - "notes" : "NB: this block is a key component that is parsed externally, and cannot be renamed with major number tags in order to be processed correctly. Therefore do not modify the source code for this block. If a change is required for a project then a whole new component will be necessary and this signed off in review by the embedded logic line manager.", + "notes": "NB: this block is a key component that is parsed externally, and cannot be renamed with major number tags in order to be processed correctly. Therefore do not modify the source code for this block. If a change is required for a project then a whole new component will be necessary and this signed off in review by the embedded logic line manager.", "registers": { "ip_id": { "address": "0", From d4f14ab631fe2ab8cc701e3a6a0e90f747db9cdf Mon Sep 17 00:00:00 2001 From: Damian Smith Date: Fri, 24 May 2019 16:33:31 +0100 Subject: [PATCH 14/29] HMBFDHV-83 ELGIP-58 New Clock Domain Crossing handshake block to take a register safely across. False Paths declared in sync blocks. bit_div signals synchronised into the blocks using rx_clk to avoid metastability. POF_RX sync/metastability fixed compared to previous mod. Test Bench now has RX_CLK at 300MHz to match expected usage. --- generic_ip/common/0/src/sync_reset.vhd | 8 +- .../1/src/cdc_data_handshake_1.vhd | 118 ++++++++++ .../1/src/fire_pulse_ctrl_1.vhd | 165 ++++++------- .../1/src/fire_pulse_manager_1.vhd | 221 ++++++++++-------- .../fire_pulse_manager/1/src/pof_rx_1.vhd | 142 ++++++----- .../fire_pulse_manager/1/src/sync_wire_1.vhd | 2 +- .../1/src/sync_wire_rEdge_1.vhd | 2 +- .../1/src/test/fire_pulse_manager_1_tb.vhd | 8 +- .../fire_pulse_manager/1/src/uart_regen_1.vhd | 20 +- .../fire_pulse_manager/1/src/uart_rx_1.vhd | 13 +- 10 files changed, 430 insertions(+), 269 deletions(-) create mode 100644 generic_ip/fire_pulse_manager/1/src/cdc_data_handshake_1.vhd diff --git a/generic_ip/common/0/src/sync_reset.vhd b/generic_ip/common/0/src/sync_reset.vhd index 8b7d37f..6aeea6b 100644 --- a/generic_ip/common/0/src/sync_reset.vhd +++ b/generic_ip/common/0/src/sync_reset.vhd @@ -31,14 +31,18 @@ architecture RTL of sync_reset is signal sync_rstN_i : std_logic; + -- declare false path as reset is meant to be applied asynchronously + attribute altera_attribute : string; + attribute altera_attribute of RTL : architecture is + "-name SDC_STATEMENT ""set_false_path -from [get_keepers *] -to [get_keepers {*sync_reset:*sync_rstN*}]"" "; begin pSYNC : process(async_rstN, clk) begin - if(async_rstN = '0') then + if (async_rstN = '0') then sync_rstN_i <= '0'; sync_rstN <= '0'; - elsif(clk = '1' and clk'event) then + elsif (clk = '1' and clk'event) then sync_rstN_i <= '1'; sync_rstN <= sync_rstN_i; end if; diff --git a/generic_ip/fire_pulse_manager/1/src/cdc_data_handshake_1.vhd b/generic_ip/fire_pulse_manager/1/src/cdc_data_handshake_1.vhd new file mode 100644 index 0000000..5bea55c --- /dev/null +++ b/generic_ip/fire_pulse_manager/1/src/cdc_data_handshake_1.vhd @@ -0,0 +1,118 @@ +------------------------------------------------------------------------------- +-- Allows a strobe-validated word of data to be passed safely between +-- two asynchronous clock domains with a handshaking acknowledge strobe. +-- Not a FIFO - so saves on an M10K +-- +-- Clock-crossing considerations: +-- Data will be sampled on source clock and held until transfer is complete +-- Any data arriving in the meantime will be ignored +-- +-- Language build standard requirements: +-- VHDL 2008 +-- +-- author Damian Smith +-- copyright (c) 2019 Global Inkjet Systems +-- date 24 May 2019 +------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity cdc_data_handshake_1 is + generic( + DATA_WIDTH : positive := 8 + ); + port( + arst_n : in std_logic; -- will be synchronised to both domains + -- + src_clk : in std_logic; + src_valid : in std_logic; -- strobe + src_data : in std_logic_vector(DATA_WIDTH - 1 downto 0) := (others => '0'); + src_ack : out std_logic; -- strobe + -- + dest_clk : in std_logic; + dest_valid : out std_logic; -- strobe + dest_data : out std_logic_vector(DATA_WIDTH - 1 downto 0) + + ); +end entity cdc_data_handshake_1; + +architecture rtl of cdc_data_handshake_1 is + signal src_rst_n, dest_rst_n : std_logic; + signal src_data_reg : std_logic_vector(DATA_WIDTH - 1 downto 0); + signal src_valid_reg : std_logic; + signal dest_valid_reg : std_logic; + signal dest_valid_reg_d : std_logic; + signal dest2src_ack : std_logic; + signal dest2src_ack_d : std_logic; + + -- declare false path as src_data_reg is sampled only when safe as validated by dest_valid_reg + attribute altera_attribute : string; + attribute altera_attribute of rtl : architecture is + "-name SDC_STATEMENT ""set_false_path -from [get_keepers *] -to [get_keepers {*cdc_data_handshake_1:*dest_data[*]}]"" "; + +begin + + ----------------------------------------------------------------------------- + -- Synchronize the input reset to the clocks + ----------------------------------------------------------------------------- + iSyncReset_src : entity work.sync_reset port map(async_rstN => arst_n, clk => src_clk, sync_rstN => src_rst_n); + iSyncReset_dest : entity work.sync_reset port map(async_rstN => arst_n, clk => dest_clk, sync_rstN => dest_rst_n); + + src_proc : process(src_clk, src_rst_n) is + begin + if src_rst_n = '0' then + src_ack <= '0'; + src_data_reg <= (others => '0'); + src_valid_reg <= '0'; + dest2src_ack_d <= '0'; + elsif rising_edge(src_clk) then + src_ack <= '0'; + + if src_valid = '1' then + src_data_reg <= src_data; + src_valid_reg <= '1'; + + end if; + + -- stop driving the src2dest signal and give src an ack + dest2src_ack_d <= dest2src_ack; + if dest2src_ack = '1' and dest2src_ack_d = '0' then + src_ack <= '1'; + src_valid_reg <= '0'; + end if; + end if; + end process src_proc; + + --pragma translate_off + assert not (src_valid = '1' and src_valid_reg = '1') report "new valid provided to CDC block before previous had completed" severity error; + --pragma translate_on + + iSyncWire_src2dest : entity work.sync_wire_1 + generic map(rst_val => '0', sync_stages => 2) + port map(rstN => dest_rst_n, clk => dest_clk, async_in => src_valid_reg, sync_out => dest_valid_reg); + + dest_proc : process(dest_clk, dest_rst_n) is + begin + if dest_rst_n = '0' then + dest_valid <= '0'; + dest_data <= (others => '0'); + dest_valid_reg_d <= '0'; + elsif rising_edge(dest_clk) then + dest_valid <= '0'; + dest_valid_reg_d <= dest_valid_reg; + if dest_valid_reg = '1' and dest_valid_reg_d = '0' then + dest_data <= src_data_reg; + dest_valid <= '1'; + end if; + end if; + end process dest_proc; + + iSyncWire_dest2src : entity work.sync_wire_1 + generic map(rst_val => '0', sync_stages => 2) + port map(rstN => src_rst_n, clk => src_clk, async_in => dest_valid_reg, sync_out => dest2src_ack); + + +end architecture rtl; diff --git a/generic_ip/fire_pulse_manager/1/src/fire_pulse_ctrl_1.vhd b/generic_ip/fire_pulse_manager/1/src/fire_pulse_ctrl_1.vhd index 91ed17a..449aabe 100644 --- a/generic_ip/fire_pulse_manager/1/src/fire_pulse_ctrl_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/fire_pulse_ctrl_1.vhd @@ -22,21 +22,23 @@ entity fire_pulse_ctrl_1 is port( reset_n : in std_logic; clk : in std_logic; - src_sel : out std_logic_vector( 1 downto 0); + src_sel : out std_logic_vector(1 downto 0); + + pof_rx_ctrl_valid : out std_logic; uart_regen_bypass : out std_logic; upd_max_pos : out std_logic; upd_min_pos : out std_logic; enable_rx : out std_logic; - uart_bit_div : out std_logic_vector( 3 downto 0); - error_rate_thres : out std_logic_vector( 7 downto 0); + uart_bit_div : out std_logic_vector(3 downto 0); + error_rate_thres : out std_logic_vector(7 downto 0); max_error_flag : in std_logic; rx_watchdog : in std_logic; rx_watchdog_en : out std_logic; rx_watchdog_clr : out std_logic; parity_err_cnt : in std_logic_vector(15 downto 0); skip_pos_cnt : in std_logic_vector(15 downto 0); - mon_point_src : in std_logic_vector(15 downto 0); - mon_points : out std_logic_vector( 3 downto 0); + mon_point_src : in std_logic_vector(15 downto 0); + mon_points : out std_logic_vector(3 downto 0); coarse_time : out std_logic_vector(31 downto 0); fine_time : out std_logic_vector(27 downto 0); one_pps : out std_logic; @@ -45,7 +47,7 @@ entity fire_pulse_ctrl_1 is -- Interrupt Senders ins_fpm_irq_0 : out std_logic; -- Avalon MM Interface - avs_address : in std_logic_vector( 3 downto 0); + avs_address : in std_logic_vector(3 downto 0); avs_write : in std_logic; avs_writedata : in std_logic_vector(31 downto 0); avs_read : in std_logic; @@ -58,41 +60,41 @@ architecture rtl of fire_pulse_ctrl_1 is ----------------------------------------------------------------------------- -- Control & Status Registers Map ----------------------------------------------------------------------------- - constant CSR_IP_ID : std_logic_vector(31 downto 0) := x"0000FF14"; - constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000100"; + constant CSR_IP_ID : std_logic_vector(31 downto 0) := x"0000FF14"; + constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000100"; - constant CSR_IP_ID_REG : std_logic_vector( 3 downto 0) := b"0000"; - constant CSR_IP_VER_REG : std_logic_vector( 3 downto 0) := b"0001"; - constant SRC_SEL_REG : std_logic_vector( 3 downto 0) := b"0010"; - constant POF_RX_CTRL : std_logic_vector( 3 downto 0) := b"0011"; - constant MON_PT_CTRL_REG : std_logic_vector( 3 downto 0) := b"0100"; - constant COARSE_TIME_INIT_REG : std_logic_vector( 3 downto 0) := b"0101"; - constant FINE_TIME_INIT_REG : std_logic_vector( 3 downto 0) := b"0110"; - constant FINE_TIME_REG : std_logic_vector( 3 downto 0) := b"0111"; - constant COARSE_TIME_REG : std_logic_vector( 3 downto 0) := b"1000"; - constant RX_ERROR_STATUS : std_logic_vector( 3 downto 0) := b"1001"; - constant RX_ERROR_CSR : std_logic_vector( 3 downto 0) := b"1010"; - constant IRQ_MNG_REG : std_logic_vector( 3 downto 0) := b"1011"; - constant EXT_FP_CTRL_REG : std_logic_vector( 3 downto 0) := b"1100"; + constant CSR_IP_ID_REG : std_logic_vector(3 downto 0) := b"0000"; + constant CSR_IP_VER_REG : std_logic_vector(3 downto 0) := b"0001"; + constant SRC_SEL_REG : std_logic_vector(3 downto 0) := b"0010"; + constant POF_RX_CTRL : std_logic_vector(3 downto 0) := b"0011"; + constant MON_PT_CTRL_REG : std_logic_vector(3 downto 0) := b"0100"; + constant COARSE_TIME_INIT_REG : std_logic_vector(3 downto 0) := b"0101"; + constant FINE_TIME_INIT_REG : std_logic_vector(3 downto 0) := b"0110"; + constant FINE_TIME_REG : std_logic_vector(3 downto 0) := b"0111"; + constant COARSE_TIME_REG : std_logic_vector(3 downto 0) := b"1000"; + constant RX_ERROR_STATUS : std_logic_vector(3 downto 0) := b"1001"; + constant RX_ERROR_CSR : std_logic_vector(3 downto 0) := b"1010"; + constant IRQ_MNG_REG : std_logic_vector(3 downto 0) := b"1011"; + constant EXT_FP_CTRL_REG : std_logic_vector(3 downto 0) := b"1100"; ----------------------------------------------------------------------------- -- Constants, Signals ----------------------------------------------------------------------------- - constant FINE_TIME_TC : integer := 100000000-1; -- clk must be 100MHz to - -- make it right + constant FINE_TIME_TC : integer := 100000000 - 1; -- clk must be 100MHz to + -- make it right signal enable_rx_i : std_logic; signal fine_time_wrap, time_ld_en : std_logic; signal rx_watchdog_en_i, rx_watchdog_clr_i : std_logic; signal uart_regen_bypass_i : std_logic; signal upd_min_pos_i, upd_max_pos_i : std_logic; - signal irq, irq_src, irq_src_d : std_logic_vector( 0 downto 0); - signal irq_en, irq_mask, irq_val, irq_clr : std_logic_vector( 0 downto 0); - signal src_sel_i : std_logic_vector( 1 downto 0); - signal mp_sel0, mp_sel1, mp_sel2, mp_sel3 : std_logic_vector( 3 downto 0); - signal bit_div : std_logic_vector( 3 downto 0); - signal error_rate_thres_i : std_logic_vector( 7 downto 0); + signal irq, irq_src, irq_src_d : std_logic_vector(0 downto 0); + signal irq_en, irq_mask, irq_val, irq_clr : std_logic_vector(0 downto 0); + signal src_sel_i : std_logic_vector(1 downto 0); + signal mp_sel0, mp_sel1, mp_sel2, mp_sel3 : std_logic_vector(3 downto 0); + signal bit_div : std_logic_vector(3 downto 0); + signal error_rate_thres_i : std_logic_vector(7 downto 0); signal fine_time_init, fine_time_i : std_logic_vector(27 downto 0); signal coarse_time_init, coarse_time_i : std_logic_vector(31 downto 0); signal ext_fp_det_i, ext_fp_gen_i : std_logic_vector(15 downto 0); @@ -100,22 +102,22 @@ architecture rtl of fire_pulse_ctrl_1 is begin pCTRL_REGs : process(reset_n, clk) - begin -- process - if(reset_n = '0') then - fine_time_i <= (others => '0'); - coarse_time_i <= (others => '0'); - elsif(clk = '1' and clk'event) then - if(time_ld_en = '1') then + begin -- process + if (reset_n = '0') then + fine_time_i <= (others => '0'); + coarse_time_i <= (others => '0'); + elsif (clk = '1' and clk'event) then + if (time_ld_en = '1') then fine_time_i <= fine_time_init; - elsif(fine_time_wrap = '1') then + elsif (fine_time_wrap = '1') then fine_time_i <= (others => '0'); else - fine_time_i <= std_logic_vector(unsigned(fine_time_i)+1); + fine_time_i <= std_logic_vector(unsigned(fine_time_i) + 1); end if; - if(time_ld_en = '1') then + if (time_ld_en = '1') then coarse_time_i <= coarse_time_init; - elsif(fine_time_wrap = '1') then - coarse_time_i <= std_logic_vector(unsigned(coarse_time_i)+1); + elsif (fine_time_wrap = '1') then + coarse_time_i <= std_logic_vector(unsigned(coarse_time_i) + 1); end if; one_pps <= fine_time_wrap; end if; @@ -138,19 +140,19 @@ begin pIRQ : process(reset_n, clk) begin - if(reset_n = '0') then - ins_fpm_irq_0 <= '0'; - irq <= "0"; - irq_src_d <= "0"; - elsif(clk = '1' and clk'event) then - irq_src_d <= irq_src; + if (reset_n = '0') then + ins_fpm_irq_0 <= '0'; + irq <= "0"; + irq_src_d <= "0"; + elsif (clk = '1' and clk'event) then + irq_src_d <= irq_src; for n in 0 to irq'left loop - if(irq_clr(n) = '1') then + if (irq_clr(n) = '1') then irq(n) <= '0'; - elsif(irq_en(n) = '1' and irq_src(n) = '1' and irq_src_d(n) = '0') then + elsif (irq_en(n) = '1' and irq_src(n) = '1' and irq_src_d(n) = '0') then irq(n) <= '1'; end if; - end loop; -- n + end loop; -- n ins_fpm_irq_0 <= irq_val(0); end if; end process pIRQ; @@ -174,12 +176,12 @@ begin rx_watchdog_en <= rx_watchdog_en_i; rx_watchdog_clr <= rx_watchdog_clr_i; - ext_fp_det <= ext_fp_det_i; - ext_fp_gen <= ext_fp_gen_i; + ext_fp_det <= ext_fp_det_i; + ext_fp_gen <= ext_fp_gen_i; pCTRL_STATUS : process(reset_n, clk) begin - if(reset_n = '0') then + if (reset_n = '0') then avs_readdatavalid <= '0'; src_sel_i <= "00"; enable_rx_i <= '0'; @@ -199,65 +201,68 @@ begin time_ld_en <= '0'; ext_fp_det_i <= X"0010"; ext_fp_gen_i <= X"0020"; - elsif(clk = '1' and clk'event) then + pof_rx_ctrl_valid <= '0'; + elsif (clk = '1' and clk'event) then -- CTRL registers - if(avs_write = '1') then + pof_rx_ctrl_valid <= '0'; + if (avs_write = '1') then case avs_address is when SRC_SEL_REG => - src_sel_i <= avs_writedata( 1 downto 0); + src_sel_i <= avs_writedata(1 downto 0); when POF_RX_CTRL => enable_rx_i <= avs_writedata(0); uart_regen_bypass_i <= avs_writedata(1); upd_max_pos_i <= avs_writedata(2); upd_min_pos_i <= avs_writedata(3); - bit_div <= avs_writedata( 7 downto 4); + bit_div <= avs_writedata(7 downto 4); + pof_rx_ctrl_valid <= '1'; -- strobe to validate new pof_rx data when MON_PT_CTRL_REG => - mp_sel0 <= avs_writedata( 3 downto 0); - mp_sel1 <= avs_writedata( 7 downto 4); - mp_sel2 <= avs_writedata(11 downto 8); - mp_sel3 <= avs_writedata(15 downto 12); - when COARSE_TIME_INIT_REG => - coarse_time_init <= avs_writedata; + mp_sel0 <= avs_writedata(3 downto 0); + mp_sel1 <= avs_writedata(7 downto 4); + mp_sel2 <= avs_writedata(11 downto 8); + mp_sel3 <= avs_writedata(15 downto 12); + when COARSE_TIME_INIT_REG => + coarse_time_init <= avs_writedata; when FINE_TIME_INIT_REG => - time_ld_en <= avs_writedata(28); - fine_time_init <= avs_writedata(27 downto 0); + time_ld_en <= avs_writedata(28); + fine_time_init <= avs_writedata(27 downto 0); when RX_ERROR_CSR => - error_rate_thres_i <= avs_writedata( 7 downto 0); - rx_watchdog_en_i <= avs_writedata(8); - rx_watchdog_clr_i <= avs_writedata(9); + error_rate_thres_i <= avs_writedata(7 downto 0); + rx_watchdog_en_i <= avs_writedata(8); + rx_watchdog_clr_i <= avs_writedata(9); when IRQ_MNG_REG => - irq_en <= avs_writedata( 0 downto 0); - irq_clr <= avs_writedata( 4 downto 4); - irq_mask <= avs_writedata( 8 downto 8); + irq_en <= avs_writedata(0 downto 0); + irq_clr <= avs_writedata(4 downto 4); + irq_mask <= avs_writedata(8 downto 8); when EXT_FP_CTRL_REG => - ext_fp_det_i <= avs_writedata(15 downto 0); - ext_fp_gen_i <= avs_writedata(31 downto 16); + ext_fp_det_i <= avs_writedata(15 downto 0); + ext_fp_gen_i <= avs_writedata(31 downto 16); when others => null; end case; - end if; + end if; -- Read Ctrl & Status registers avs_readdatavalid <= avs_read; - if(avs_read = '1') then + if (avs_read = '1') then case avs_address is when CSR_IP_ID_REG => avs_readdata <= CSR_IP_ID; when CSR_IP_VER_REG => avs_readdata <= CSR_IP_VER; - when SRC_SEL_REG => + when SRC_SEL_REG => avs_readdata <= (0 => src_sel_i(0), 1 => src_sel_i(1), others => '0'); - when POF_RX_CTRL => + when POF_RX_CTRL => avs_readdata <= X"000000" & bit_div & upd_min_pos_i & upd_max_pos_i & uart_regen_bypass_i & enable_rx_i; when MON_PT_CTRL_REG => avs_readdata <= X"0000" & mp_sel3 & mp_sel2 & mp_sel1 & mp_sel0; when COARSE_TIME_INIT_REG => avs_readdata <= coarse_time_init; - when FINE_TIME_INIT_REG => + when FINE_TIME_INIT_REG => avs_readdata <= b"000" & time_ld_en & fine_time_init; when RX_ERROR_STATUS => avs_readdata <= skip_pos_cnt & parity_err_cnt; - when FINE_TIME_REG => + when FINE_TIME_REG => avs_readdata <= X"0" & fine_time_i; - when COARSE_TIME_REG => + when COARSE_TIME_REG => avs_readdata <= coarse_time_i; when RX_ERROR_CSR => avs_readdata <= X"00000" & max_error_flag & rx_watchdog & rx_watchdog_clr_i & rx_watchdog_en_i & error_rate_thres_i; @@ -271,5 +276,5 @@ begin end if; end if; end process pCTRL_STATUS; - + end architecture rtl; diff --git a/generic_ip/fire_pulse_manager/1/src/fire_pulse_manager_1.vhd b/generic_ip/fire_pulse_manager/1/src/fire_pulse_manager_1.vhd index ba478c3..2c94367 100644 --- a/generic_ip/fire_pulse_manager/1/src/fire_pulse_manager_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/fire_pulse_manager_1.vhd @@ -50,84 +50,90 @@ end entity fire_pulse_manager_1; architecture rtl of fire_pulse_manager_1 is - signal reset_n_i : std_logic; + signal reset_n_i : std_logic; -- reset synchronised to clk (100MHz) -- - signal cs_addr : std_logic_vector(10 downto 0); - signal cs_write_en : std_logic_vector(blk_num - 1 downto 0); - signal cs_write_data : std_logic_vector(31 downto 0); - signal cs_read_en : std_logic_vector(blk_num - 1 downto 0); - signal cs_read_valid : std_logic_vector(blk_num - 1 downto 0); - signal cs_read_data : std_logic_vector(32 * blk_num - 1 downto 0); + signal cs_addr : std_logic_vector(10 downto 0); + signal cs_write_en : std_logic_vector(blk_num - 1 downto 0); + signal cs_write_data : std_logic_vector(31 downto 0); + signal cs_read_en : std_logic_vector(blk_num - 1 downto 0); + signal cs_read_valid : std_logic_vector(blk_num - 1 downto 0); + signal cs_read_data : std_logic_vector(32 * blk_num - 1 downto 0); -- - signal cs_ctrl_write_en : std_logic; - signal cs_ctrl_read_en : std_logic; - signal cs_ctrl_read_valid : std_logic; - signal cs_ctrl_read_data : std_logic_vector(31 downto 0); + signal cs_ctrl_write_en : std_logic; + signal cs_ctrl_read_en : std_logic; + signal cs_ctrl_read_valid : std_logic; + signal cs_ctrl_read_data : std_logic_vector(31 downto 0); -- - signal cs_pg_write_en : std_logic_vector(ch_num - 1 downto 0); - signal cs_pg_read_en : std_logic_vector(ch_num - 1 downto 0); - signal cs_pg_read_valid : std_logic_vector(ch_num - 1 downto 0); - signal cs_pg_read_data : std_logic_vector(32 * ch_num - 1 downto 0); + signal cs_pg_write_en : std_logic_vector(ch_num - 1 downto 0); + signal cs_pg_read_en : std_logic_vector(ch_num - 1 downto 0); + signal cs_pg_read_valid : std_logic_vector(ch_num - 1 downto 0); + signal cs_pg_read_data : std_logic_vector(32 * ch_num - 1 downto 0); -- - signal cs_nsnk_write_en : std_logic; - signal cs_nsnk_read_en : std_logic; - signal cs_nsnk_read_valid : std_logic; - signal cs_nsnk_read_data : std_logic_vector(31 downto 0); + signal cs_nsnk_write_en : std_logic; + signal cs_nsnk_read_en : std_logic; + signal cs_nsnk_read_valid : std_logic; + signal cs_nsnk_read_data : std_logic_vector(31 downto 0); -- - signal cs_log_write_en : std_logic; - signal cs_log_read_en : std_logic; - signal cs_log_read_valid : std_logic; - signal cs_log_read_data : std_logic_vector(31 downto 0); + signal cs_log_write_en : std_logic; + signal cs_log_read_en : std_logic; + signal cs_log_read_valid : std_logic; + signal cs_log_read_data : std_logic_vector(31 downto 0); -- - signal cs_ie_write_en : std_logic; - signal cs_ie_read_en : std_logic; - signal cs_ie_read_valid : std_logic; - signal cs_ie_read_data : std_logic_vector(31 downto 0); + signal cs_ie_write_en : std_logic; + signal cs_ie_read_en : std_logic; + signal cs_ie_read_valid : std_logic; + signal cs_ie_read_data : std_logic_vector(31 downto 0); -- - signal enable_rx : std_logic; - signal uart_regen_bypass : std_logic; - signal upd_max_pos : std_logic; - signal upd_min_pos : std_logic; - signal max_error_flag : std_logic; - signal rx_watchdog : std_logic; - signal rx_watchdog_en : std_logic; - signal rx_watchdog_clr : std_logic; - signal bit_div : std_logic_vector(3 downto 0); - signal error_rate_thres : std_logic_vector(7 downto 0); - signal parity_err_cnt : std_logic_vector(15 downto 0); - signal skip_pos_cnt : std_logic_vector(15 downto 0); - signal mon_point_src : std_logic_vector(15 downto 0); - signal fine_time : std_logic_vector(27 downto 0); - signal coarse_time : std_logic_vector(31 downto 0); + signal enable_rx : std_logic; + signal uart_regen_bypass : std_logic; + signal upd_max_pos : std_logic; + signal upd_min_pos : std_logic; + signal max_error_flag : std_logic; + signal rx_watchdog : std_logic; + signal rx_watchdog_en : std_logic; + signal rx_watchdog_clr : std_logic; + signal bit_div : std_logic_vector(3 downto 0); + signal error_rate_thres : std_logic_vector(7 downto 0); + signal parity_err_cnt : std_logic_vector(15 downto 0); + signal skip_pos_cnt : std_logic_vector(15 downto 0); + signal mon_point_src : std_logic_vector(15 downto 0); + signal fine_time : std_logic_vector(27 downto 0); + signal coarse_time : std_logic_vector(31 downto 0); -- - signal remote_init : std_logic; - signal dp_dir : std_logic_vector(ch_num - 1 downto 0); - signal set_pos_ie : std_logic; - signal enc_pulse : std_logic; - signal enc_pulse_ie : std_logic; - signal enc_pulse_pof : std_logic; - signal pd_pulse : std_logic; - signal pd_pulse_ie : std_logic; - signal pd_pulse_pof : std_logic; - signal inc_pos : std_logic; - signal inc_pos_pof : std_logic; - signal inc_pos_ie : std_logic; - signal dec_pos : std_logic; - signal dec_pos_pof : std_logic; - signal dec_pos_ie : std_logic; - signal abs_pos : std_logic_vector(31 downto 0); - signal abs_pos_pof : std_logic_vector(31 downto 0); - signal abs_pos_ie : std_logic_vector(39 downto 0); + signal remote_init : std_logic; + signal dp_dir : std_logic_vector(ch_num - 1 downto 0); + signal set_pos_ie : std_logic; + signal enc_pulse : std_logic; + signal enc_pulse_ie : std_logic; + signal enc_pulse_pof : std_logic; + signal pd_pulse : std_logic; + signal pd_pulse_ie : std_logic; + signal pd_pulse_pof : std_logic; + signal inc_pos : std_logic; + signal inc_pos_pof : std_logic; + signal inc_pos_ie : std_logic; + signal dec_pos : std_logic; + signal dec_pos_pof : std_logic; + signal dec_pos_ie : std_logic; + signal abs_pos : std_logic_vector(31 downto 0); + signal abs_pos_pof : std_logic_vector(31 downto 0); + signal abs_pos_ie : std_logic_vector(39 downto 0); -- - signal ch_pd, ch_pulse_out : std_logic_vector(ch_num - 1 downto 0); - signal ch_raw_pulse, ch_mask : std_logic_vector(ch_num - 1 downto 0); - signal fire_pulse_i : std_logic_vector(ch_num - 1 downto 0); - signal src_sel : std_logic_vector(1 downto 0); + signal ch_pd, ch_pulse_out : std_logic_vector(ch_num - 1 downto 0); + signal ch_raw_pulse, ch_mask : std_logic_vector(ch_num - 1 downto 0); + signal fire_pulse_i : std_logic_vector(ch_num - 1 downto 0); + signal src_sel : std_logic_vector(1 downto 0); -- - signal one_pps : std_logic; - signal ext_fp_det : std_logic_vector(15 downto 0); - signal ext_fp_gen : std_logic_vector(15 downto 0); - signal pof_rx_regen : std_logic; + signal one_pps : std_logic; + signal ext_fp_det : std_logic_vector(15 downto 0); + signal ext_fp_gen : std_logic_vector(15 downto 0); + signal pof_rx_regen : std_logic; + signal pof_rx_ctrl_valid : std_logic; -- validates uart_regen_bypass, upd_max_pos, upd_min_pos, enable_rx, bit_div + signal bit_div_dest : std_logic_vector(bit_div'range); + signal enable_rx_dest : std_logic; + signal pof_rx_ctrl_data_dest : std_logic_vector(bit_div'high + 2 downto 0); + signal pof_rx_ctrl_data_src : std_logic_vector(bit_div'high + 2 downto 0); + signal uart_regen_bypass_dest : std_logic; begin @@ -170,30 +176,54 @@ begin -- POF Receiver iPOF_RX : entity work.pof_rx_1 port map( - reset_n => reset_n_i, - clk => clk, - init => '0', - rx_clk => rx_clk, - rx_data => pof_rx, - init_out => remote_init, - dp_dir => dp_dir(0), - enc_out => enc_pulse_pof, - pd_out => pd_pulse_pof, - inc_pos => inc_pos_pof, - dec_pos => dec_pos_pof, - abs_pos => abs_pos_pof, - enable => enable_rx, - bit_div => bit_div, - error_rate_thres => error_rate_thres, - one_pps => one_pps, - upd_max_pos => upd_max_pos, - upd_min_pos => upd_min_pos, - max_error_flag => max_error_flag, - rx_watchdog => rx_watchdog, - rx_watchdog_en => rx_watchdog_en, - rx_watchdog_clr => rx_watchdog_clr, - parity_err_cnt => parity_err_cnt, - skip_pos_cnt => skip_pos_cnt); + reset_n => reset_n_i, + clk => clk, + init => '0', + rx_clk => rx_clk, + rx_data => pof_rx, + init_out => remote_init, + dp_dir => dp_dir(0), + enc_out => enc_pulse_pof, + pd_out => pd_pulse_pof, + inc_pos => inc_pos_pof, + dec_pos => dec_pos_pof, + abs_pos => abs_pos_pof, + pof_rx_ctrl_valid => pof_rx_ctrl_valid, + enable => enable_rx, + bit_div => bit_div, + upd_max_pos => upd_max_pos, + upd_min_pos => upd_min_pos, + error_rate_thres => error_rate_thres, + one_pps => one_pps, + max_error_flag => max_error_flag, + rx_watchdog => rx_watchdog, + rx_watchdog_en => rx_watchdog_en, + rx_watchdog_clr => rx_watchdog_clr, + parity_err_cnt => parity_err_cnt, + skip_pos_cnt => skip_pos_cnt); + + -- Synchronise signals to rx_clk + pof_rx_ctrl_data_dest <= enable_rx & uart_regen_bypass & bit_div; + + enable_rx_dest <= pof_rx_ctrl_data_src(5); + uart_regen_bypass_dest <= pof_rx_ctrl_data_src(4); + bit_div_dest <= pof_rx_ctrl_data_src(3 downto 0); + + + iCDC_CTRL : entity work.cdc_data_handshake_1 + generic map( + DATA_WIDTH => pof_rx_ctrl_data_dest'length + ) + port map( + arst_n => reset_n, + src_clk => clk, + src_valid => pof_rx_ctrl_valid, + src_data => pof_rx_ctrl_data_dest, + src_ack => open, + dest_clk => rx_clk, + dest_valid => open, + dest_data => pof_rx_ctrl_data_src + ); -- UART signal regeneration iUART_REGEN : entity work.uart_regen_1 @@ -202,9 +232,9 @@ begin port map( reset_n => reset_n, clk => rx_clk, - bit_div => bit_div, - enable => enable_rx, - bypass_en => uart_regen_bypass, + bit_div => bit_div_dest, -- synchronised to rx_clk + enable => enable_rx_dest, -- synchronised to rx_clk + bypass_en => uart_regen_bypass_dest, -- synchronised to rx_clk uart_rx => pof_rx, uart_tx => pof_tx); @@ -331,6 +361,7 @@ begin reset_n => reset_n_i, clk => clk, src_sel => src_sel, + pof_rx_ctrl_valid => pof_rx_ctrl_valid, uart_regen_bypass => uart_regen_bypass, upd_max_pos => upd_max_pos, upd_min_pos => upd_min_pos, diff --git a/generic_ip/fire_pulse_manager/1/src/pof_rx_1.vhd b/generic_ip/fire_pulse_manager/1/src/pof_rx_1.vhd index 768e0b8..e0f91f9 100644 --- a/generic_ip/fire_pulse_manager/1/src/pof_rx_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/pof_rx_1.vhd @@ -20,32 +20,34 @@ use ieee.numeric_std.all; entity pof_rx_1 is port( - reset_n : in std_logic; - clk : in std_logic; + reset_n : in std_logic; -- synchronised to clk + clk : in std_logic; -- - init : in std_logic; - rx_clk : in std_logic; - rx_data : in std_logic; - init_out : out std_logic; - dp_dir : in std_logic; - enc_out : out std_logic; - pd_out : out std_logic; - inc_pos : out std_logic; - dec_pos : out std_logic; - abs_pos : out std_logic_vector(31 downto 0); + init : in std_logic; + rx_clk : in std_logic; + rx_data : in std_logic; + init_out : out std_logic; + dp_dir : in std_logic; + enc_out : out std_logic; + pd_out : out std_logic; + inc_pos : out std_logic; + dec_pos : out std_logic; + abs_pos : out std_logic_vector(31 downto 0); -- C&S - enable : in std_logic; - bit_div : in std_logic_vector(3 downto 0); - error_rate_thres : in std_logic_vector(7 downto 0); - one_pps : in std_logic; - upd_max_pos : in std_logic; - upd_min_pos : in std_logic; - max_error_flag : out std_logic; - rx_watchdog : out std_logic; - rx_watchdog_en : in std_logic; - rx_watchdog_clr : in std_logic; - parity_err_cnt : out std_logic_vector(15 downto 0); - skip_pos_cnt : out std_logic_vector(15 downto 0)); + pof_rx_ctrl_valid : in std_logic := '1'; -- validates upd_max_pos, upd_min_pos, enable_rx, bit_div + enable : in std_logic; + bit_div : in std_logic_vector(3 downto 0); + upd_max_pos : in std_logic; + upd_min_pos : in std_logic; + -- + error_rate_thres : in std_logic_vector(7 downto 0); + one_pps : in std_logic; + max_error_flag : out std_logic; + rx_watchdog : out std_logic; + rx_watchdog_en : in std_logic; + rx_watchdog_clr : in std_logic; + parity_err_cnt : out std_logic_vector(15 downto 0); + skip_pos_cnt : out std_logic_vector(15 downto 0)); end entity pof_rx_1; architecture rtl of pof_rx_1 is @@ -85,20 +87,17 @@ architecture rtl of pof_rx_1 is signal clk_cnt : std_logic_vector(1 downto 0); signal dist, abs_dist, skip_cnt : std_logic_vector(3 downto 0); signal next_pos_lsb, curr_pos_lsb : std_logic_vector(3 downto 0); - signal pos_corr, max_dist, rx_error_v : std_logic_vector(3 downto 0); - signal gray_pos, rx_symbol_val_v : std_logic_vector(3 downto 0); + signal pos_corr, max_dist : std_logic_vector(3 downto 0); + signal gray_pos : std_logic_vector(3 downto 0); signal symbol_i, rx_symbol : std_logic_vector(7 downto 0); signal rx_wd_cnt : std_logic_vector(9 downto 0); signal parity_err_cnt_i, skip_pos_cnt_i : std_logic_vector(15 downto 0); signal error_rate_cnt, error_rate : std_logic_vector(15 downto 0); signal abs_pos_i, pos_max, pos_min : std_logic_vector(31 downto 0); signal dist_pos, dist_neg : std_logic_vector(31 downto 0); - signal symbol_sample : std_logic; - - -- declare false path as symbol_i is sampled only when safe as validated by symbol_sample - attribute altera_attribute : string; - attribute altera_attribute of rtl : architecture is - "-name SDC_STATEMENT ""set_false_path -from [get_keepers *] -to [get_keepers {*pof_rx_1:*symbol_i\[*\]}]"" "; + signal bit_div_dest : std_logic_vector(bit_div'range); + signal reset_n_rx_clk : std_logic; -- reset synchronised to rx_clk (typically 300 MHz) + begin @@ -108,13 +107,30 @@ begin -- De-serialize symbols (Serial clock at Higher Speed ( Rx Clock probably 300 MHz) ----------------------------------------------------------------------------- + iCDC_CTRL : entity work.cdc_data_handshake_1 + generic map( + DATA_WIDTH => bit_div'length + ) + port map( + arst_n => reset_n, + src_clk => clk, + src_valid => pof_rx_ctrl_valid, + src_data => bit_div, + src_ack => open, + dest_clk => rx_clk, + dest_valid => open, + dest_data => bit_div_dest + ); + + iSyncReset_rxclk : entity work.sync_reset port map(async_rstN => reset_n, clk => rx_clk, sync_rstN => reset_n_rx_clk); + iRX_SYMBOL : entity work.uart_rx_1 generic map( - data_width => 8) + data_width => rx_symbol'length) port map( - reset_n => reset_n, + reset_n => reset_n_rx_clk, -- should be synchronised to rx_clk clk => rx_clk, - bit_div => bit_div, + bit_div => bit_div_dest, -- synchronised init => clear_i, data_out => rx_symbol, data_out_valid => rx_symbol_val, @@ -122,36 +138,42 @@ begin rx_data => rx_data); -- Synchronize to the local clock - pLATCH_RX_DATA : process(rx_clk) - begin - if (rx_clk = '1' and rx_clk'event) then - -- relies on rx_clk <= 3 times clk - if (rx_symbol_val = '1') then - rx_symbol_val_v <= "1111"; - else - rx_symbol_val_v <= '0' & rx_symbol_val_v(3 downto 1); - end if; - if (rx_error = '1') then - rx_error_v <= "1111"; - else - rx_error_v <= '0' & rx_error_v(3 downto 1); - end if; - end if; - end process pLATCH_RX_DATA; - iSYNC_SYMBOL_VAL : entity work.sync_wire_rEdge_1 - generic map(rst_val => '0', sync_stages => 2) - port map(rstN => reset_n, clk => clk, async_in => rx_symbol_val_v(0), sync_out => symbol_sample); -- symbol_sample will become symbol_valid + iCDC_SYMBOL : entity work.cdc_data_handshake_1 + generic map( + DATA_WIDTH => rx_symbol'length + ) + port map( + arst_n => reset_n, + src_clk => rx_clk, + src_valid => rx_symbol_val, + src_data => rx_symbol, + src_ack => open, + dest_clk => clk, + dest_valid => symbol_valid, + dest_data => symbol_i + ); - iSYNC_RX_ERROR : entity work.sync_wire_rEdge_1 - generic map(rst_val => '0', sync_stages => 3) - port map(rstN => reset_n, clk => clk, async_in => rx_error_v(0), sync_out => rx_error_i); -- Caution! Separate metastability path so don't rely on relative timing + iCDC_ERROR : entity work.cdc_data_handshake_1 + generic map( + DATA_WIDTH => 1 -- unused + ) + port map( + arst_n => reset_n, + src_clk => rx_clk, + src_valid => rx_error, + src_data => open, + src_ack => open, + dest_clk => clk, + dest_valid => rx_error_i, + dest_data => open + ); -- synchronize clear to rx_clk iSYNC_CLEAR : entity work.sync_wire_1 generic map(rst_val => '1', sync_stages => 2) port map( - rstN => reset_n, clk => rx_clk, async_in => clear, sync_out => clear_i); + rstN => reset_n_rx_clk, clk => rx_clk, async_in => clear, sync_out => clear_i); ----------------------------------------------------------------------------- -- Toggle-Bits Decoding @@ -185,10 +207,6 @@ begin end if; pd <= pd_confirmed; -- - if symbol_sample = '1' then - symbol_i <= rx_symbol; - end if; - symbol_valid <= symbol_sample; symbol_valid_i <= symbol_valid and symbol_ok; symbol_error <= symbol_valid and not symbol_ok; if (clear = '1') then diff --git a/generic_ip/fire_pulse_manager/1/src/sync_wire_1.vhd b/generic_ip/fire_pulse_manager/1/src/sync_wire_1.vhd index 4f35c29..9d04a39 100644 --- a/generic_ip/fire_pulse_manager/1/src/sync_wire_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/sync_wire_1.vhd @@ -37,7 +37,7 @@ architecture RTL of sync_wire_1 is -- declare false path for the input to the synchroniser attribute altera_attribute : string; attribute altera_attribute of RTL : architecture is - "-name SDC_STATEMENT ""set_false_path -from [get_keepers *] -to [get_keepers {*sync_wire_1:*sync_sig\[0\]}]"" "; + "-name SDC_STATEMENT ""set_false_path -from [get_keepers *] -to [get_keepers {*sync_wire_1:*sync_sig[0]}]"" "; begin pSYNC : process(rstN, clk) diff --git a/generic_ip/fire_pulse_manager/1/src/sync_wire_rEdge_1.vhd b/generic_ip/fire_pulse_manager/1/src/sync_wire_rEdge_1.vhd index 8e76c52..a3d88d1 100644 --- a/generic_ip/fire_pulse_manager/1/src/sync_wire_rEdge_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/sync_wire_rEdge_1.vhd @@ -38,7 +38,7 @@ architecture RTL of sync_wire_rEdge_1 is -- declare false path for the input to the synchroniser attribute altera_attribute : string; attribute altera_attribute of RTL : architecture is - "-name SDC_STATEMENT ""set_false_path -from [get_keepers *] -to [get_keepers {*sync_wire_rEdge_1:*sync_sig\[0\]}]"" "; + "-name SDC_STATEMENT ""set_false_path -from [get_keepers *] -to [get_keepers {*sync_wire_rEdge_1:*sync_sig[0]}]"" "; begin pSYNC : process(rstN, clk) diff --git a/generic_ip/fire_pulse_manager/1/src/test/fire_pulse_manager_1_tb.vhd b/generic_ip/fire_pulse_manager/1/src/test/fire_pulse_manager_1_tb.vhd index 37a7746..13189b4 100644 --- a/generic_ip/fire_pulse_manager/1/src/test/fire_pulse_manager_1_tb.vhd +++ b/generic_ip/fire_pulse_manager/1/src/test/fire_pulse_manager_1_tb.vhd @@ -49,8 +49,8 @@ architecture behav of fire_pulse_manager_1_tb is constant TX_CLK_PERIOD : time := CLK_PERIOD; -- nominally the same as clk_period -- TODO Try different receive oversampling ratios - 300MHz is in the real system - constant RX_CLK_PERIOD : time := 5.0 ns; -- clock period for used by the - -- UART-Rx on the POF + constant RX_CLK_PERIOD : time := CLK_PERIOD / 3; -- 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 @@ -546,8 +546,8 @@ begin -- behav -- Config fire_pulse_manager control registers: -- Enable the POF-Rx addr := std_logic_vector(to_unsigned(3, 32)); - data := X"0000_8041"; - -- Write the data to the register + data := X"0000_8061"; -- set bit_div to 6 to match the 50MBd TX signal to the 300MHz RX_CLK + -- Write the data to the register mm_32b_write(addr, data, avs_s, avs_m); -- Select pulse generator addr := std_logic_vector(to_unsigned(2, 32)); diff --git a/generic_ip/fire_pulse_manager/1/src/uart_regen_1.vhd b/generic_ip/fire_pulse_manager/1/src/uart_regen_1.vhd index dd67a54..40568f1 100644 --- a/generic_ip/fire_pulse_manager/1/src/uart_regen_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/uart_regen_1.vhd @@ -22,15 +22,15 @@ entity uart_regen_1 is generic( data_width : natural range 1 to 31); port( - reset_n : in std_logic; - clk : in std_logic; -- faster clock (2 or 3 times 100MHz) - -- On 100MHz clock - bit_div : in std_logic_vector(3 downto 0); -- number of clock cycles per tx bit - enable : in std_logic; - bypass_en : in std_logic; + reset_n : in std_logic; + clk : in std_logic; + -- must all be synchronous to clk + bit_div : in std_logic_vector(3 downto 0); -- number of clock cycles per tx bit + enable : in std_logic; + bypass_en : in std_logic; -- - uart_rx : in std_logic; - uart_tx : out std_logic); + uart_rx : in std_logic; -- will be on an unrelated, domain - typically one bit is 4 to 6 clk periods long + uart_tx : out std_logic); end entity uart_regen_1; architecture rtl of uart_regen_1 is @@ -62,10 +62,6 @@ begin async_in => uart_rx, sync_out => uart_rx_i); - -- FIXME - don't agree with this statement - metastability can be more subtle. Could put the state vector into an undefined value. - -- NOTE : No NEED TO SYNCHRONIZE TO THE LOCAL CLOCK inputs enable, bypass_en - -- and bit_biv BECAUSE THOSE SIGNALS ARE PREDOMINANTLY STATIC - ----------------------------------------------------------------------------- -- UART registers and sequential logic ----------------------------------------------------------------------------- diff --git a/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd b/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd index bbb7eed..ab8a3c6 100644 --- a/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd @@ -35,17 +35,6 @@ end entity uart_rx_1; architecture rtl of uart_rx_1 is - component sync_wire_1 - generic( - rst_val : std_logic; - sync_stages : positive); - port( - rstN : in std_logic; - clk : in std_logic; - async_in : in std_logic; - sync_out : out std_logic); - end component; - type fsm_state_t is (s_init, s_idle, s_get_start_bit, s_get_data, s_get_stop_bit); signal fsm_state_curr, fsm_state_next : fsm_state_t; @@ -64,7 +53,7 @@ begin -- Input Synchronization ----------------------------------------------------------------------------- - iSYNC_IN : sync_wire_1 + iSYNC_IN : entity work.sync_wire_1 generic map( rst_val => '1', sync_stages => 3) From ef93cc5e0f1fcfbd5a8ad8cd49233adcbc62becf Mon Sep 17 00:00:00 2001 From: Damian Smith Date: Fri, 24 May 2019 16:34:45 +0100 Subject: [PATCH 15/29] HMBFDHV-83 Corrected the header in comms_avalon_unique_id. Minor Bug Fix to generic_sequencer_15 in that an uninitialised signal is now initialised. --- .../src/comms_avalon_unique_id.vhd | 82 ++++++++----------- .../15/src/generic_sequencer_15.vhd | 3 +- 2 files changed, 35 insertions(+), 50 deletions(-) diff --git a/generic_ip/comms_unique_id/src/comms_avalon_unique_id.vhd b/generic_ip/comms_unique_id/src/comms_avalon_unique_id.vhd index c570591..a5f2bc8 100644 --- a/generic_ip/comms_unique_id/src/comms_avalon_unique_id.vhd +++ b/generic_ip/comms_unique_id/src/comms_avalon_unique_id.vhd @@ -1,21 +1,5 @@ ------------------------------------------------------------------------------- --- Title : Command Interpreter --- Project : SAMBA 1200 HIB -------------------------------------------------------------------------------- --- File : command_interpreter.vhd --- Author : Robbie Temple --- Company : Global Inkjet Systems --- Created : 2009-11-01 --- Last update: 2014-12-01 --- Platform : --- Standard : VHDL'93 -------------------------------------------------------------------------------- --- Description: --- SAMBA 1200 HIB test data board command interpreter version --- Interprets the data stream and distributed data to the rest of the FPGA. --- Receives responses and transmits them back to the LVDS parser. --- FIXME - for now, assume that latency is OK and there is no need to back off --- response messages - but test for this! +-- reports the unique FPGA ID ------------------------------------------------------------------------------- -- Copyright (c) 2009 Global Inkjet Systems ------------------------------------------------------------------------------- @@ -25,60 +9,60 @@ use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity comms_avalon_unique_id is - port ( + port( -- Clocks, resets and enables - clk : in std_logic; - rst_n : in std_logic; + clk : in std_logic; + rst_n : in std_logic; ----Avalon MM interface - avs_readdata : out std_logic_vector(31 downto 0); - avs_address : in std_logic_vector(1 downto 0); - avs_read_n : in std_logic - ); + avs_readdata : out std_logic_vector(31 downto 0); + avs_address : in std_logic_vector(1 downto 0); + avs_read_n : in std_logic + ); end comms_avalon_unique_id; architecture rtl of comms_avalon_unique_id is -component unique_chip_ID is - port ( - clkin : in std_logic := '0'; -- clkin.clk - reset : in std_logic := '0'; -- reset.reset - data_valid : out std_logic; -- output.valid - chip_id : out std_logic_vector(63 downto 0) -- .data - ); + component unique_chip_ID is + port( + clkin : in std_logic := '0'; -- clkin.clk + reset : in std_logic := '0'; -- reset.reset + data_valid : out std_logic; -- output.valid + chip_id : out std_logic_vector(63 downto 0) -- .data + ); end component; - signal data_valid : std_logic; - signal chip_id : std_logic_vector (63 downto 0); + signal data_valid : std_logic; + signal chip_id : std_logic_vector(63 downto 0); begin u_chip_ID : unique_chip_ID - port map ( + port map( clkin => clk, reset => not rst_n, - data_valid => data_valid, + data_valid => data_valid, chip_id => chip_id - ); + ); ---------Avalon Process - P_avalon_MM_read : process (clk, rst_n) is - begin -- process P_avalon_MM_read + --------Avalon Process + P_avalon_MM_read : process(clk, rst_n) is + begin -- process P_avalon_MM_read if rst_n = '0' then avs_readdata <= (others => '0'); elsif clk'event and clk = '1' then - avs_readdata <= (others => '0'); + avs_readdata <= (others => '0'); if avs_read_n = '0' then case avs_address is - when "00" => - if data_valid='1' then - avs_readdata <= chip_id(31 downto 0); - end if; + when "00" => + if data_valid = '1' then + avs_readdata <= chip_id(31 downto 0); + end if; when "01" => - if data_valid='1' then - avs_readdata <= chip_id(63 downto 32); - end if; - when "10" => - avs_readdata(0) <=data_valid; + if data_valid = '1' then + avs_readdata <= chip_id(63 downto 32); + end if; + when "10" => + avs_readdata(0) <= data_valid; when others => null; end case; end if; diff --git a/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd b/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd index 6e7048a..60dbe72 100644 --- a/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd +++ b/generic_ip/generic_sequencer/15/src/generic_sequencer_15.vhd @@ -590,7 +590,7 @@ begin ld_jmp_addr <= '1' when decode = '1' and (jump_abs = '1' or jump_rel = '1' or jump_r1 = '1') else '0'; - jump_abs <= '1' when (opcode = CMD_JUMP and (subcode = X"0" or (subcode = X"1" and zero_flag = '1') or (subcode = X"2" and zero_flag = '0'))) or (opcode = CMD_END and subcode = X"1") else '0'; + jump_abs <= '1' when (opcode = CMD_JUMP and (subcode = X"0" or (subcode = X"1" and zero_flag = '1') or (subcode = X"2" and zero_flag = '0'))) or (opcode = CMD_END and subcode = X"1") else '0'; jump_rel <= '1' when (opcode = CMD_BRANCH and (subcode = X"0" or (subcode = X"1" and zero_flag = '1') or (subcode = X"2" and zero_flag = '0'))) or (opcode = CMD_LOOP and loop_done = '0') or (opcode = CMD_END and subcode = X"2") else '0'; jump_r1 <= '1' when opcode = CMD_JUMP and subcode = X"F" else '0'; @@ -635,6 +635,7 @@ begin gRAMP_NOGEN : if VECT_RAMP_EN = false generate ramp_val <= (others => '0'); + ramp_up <= '0'; end generate gRAMP_NOGEN; gBUS_BURST_GEN : if BUS_BURST_EN = true generate From 1ef3a2b16c3fcdcd32a56de209c908ca7c148bca Mon Sep 17 00:00:00 2001 From: Damian Smith Date: Tue, 28 May 2019 11:07:34 +0100 Subject: [PATCH 16/29] Revert "HMBFDHV-83 ELGIP-58 changed comments referring to 200MHz. Improved metastability handling in pof_rx, using synchronisers with attributes included to handle CDC. Corrected sensitivity list in uart_regen_1 and added a note on metastability. Put a note in the testbench as it runs at 200MHz rx_clk, but we recommend 300MHz so it is both specific, and not ideal." This reverts commit e21e804433b0963459517743437a8083a5a29c3e. And also reverts SHA-1: d4f14ab631fe2ab8cc701e3a6a0e90f747db9cdf * HMBFDHV-83 ELGIP-58 New Clock Domain Crossing handshake block to take a register safely across. False Paths declared in sync blocks. bit_div signals synchronised into the blocks using rx_clk to avoid metastability. POF_RX sync/metastability fixed compared to previous mod. Test Bench now has RX_CLK at 300MHz to match expected usage. --- generic_ip/common/0/src/sync_reset.vhd | 8 +- .../fire_pulse_manager/1/sim/sim_fpm.do | 4 +- .../1/src/cdc_data_handshake_1.vhd | 118 -------- .../1/src/fire_pulse_ctrl_1.vhd | 165 +++++----- .../1/src/fire_pulse_manager_1.vhd | 235 ++++++-------- .../fire_pulse_manager/1/src/pof_rx_1.vhd | 286 ++++++++---------- .../fire_pulse_manager/1/src/sync_wire_1.vhd | 38 ++- .../1/src/sync_wire_rEdge_1.vhd | 38 ++- .../1/src/test/fire_pulse_manager_1_tb.vhd | 10 +- .../fire_pulse_manager/1/src/uart_regen_1.vhd | 11 +- .../fire_pulse_manager/1/src/uart_rx_1.vhd | 14 +- .../doc/generic_versioning.json | 2 +- 12 files changed, 373 insertions(+), 556 deletions(-) delete mode 100644 generic_ip/fire_pulse_manager/1/src/cdc_data_handshake_1.vhd diff --git a/generic_ip/common/0/src/sync_reset.vhd b/generic_ip/common/0/src/sync_reset.vhd index 6aeea6b..8b7d37f 100644 --- a/generic_ip/common/0/src/sync_reset.vhd +++ b/generic_ip/common/0/src/sync_reset.vhd @@ -31,18 +31,14 @@ architecture RTL of sync_reset is signal sync_rstN_i : std_logic; - -- declare false path as reset is meant to be applied asynchronously - attribute altera_attribute : string; - attribute altera_attribute of RTL : architecture is - "-name SDC_STATEMENT ""set_false_path -from [get_keepers *] -to [get_keepers {*sync_reset:*sync_rstN*}]"" "; begin pSYNC : process(async_rstN, clk) begin - if (async_rstN = '0') then + if(async_rstN = '0') then sync_rstN_i <= '0'; sync_rstN <= '0'; - elsif (clk = '1' and clk'event) then + elsif(clk = '1' and clk'event) then sync_rstN_i <= '1'; sync_rstN <= sync_rstN_i; end if; diff --git a/generic_ip/fire_pulse_manager/1/sim/sim_fpm.do b/generic_ip/fire_pulse_manager/1/sim/sim_fpm.do index c2dc034..f6ba4aa 100644 --- a/generic_ip/fire_pulse_manager/1/sim/sim_fpm.do +++ b/generic_ip/fire_pulse_manager/1/sim/sim_fpm.do @@ -37,11 +37,11 @@ vcom -2008 -work $WORKLIB $GENERIC_PATH/generic_sequencer/15/src/generic_sequenc vcom -2008 -work $WORKLIB $GENERIC_PATH/generic_sequencer/15/src/generic_sequencer_15.vhd # Pulse Generator -vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/altera/sync_fifo_1.vhd vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/pulse_generator_1_pkg.vhd vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/pulse_conditioning_1.vhd vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/queue_and_delay_1.vhd vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/simple_frac_div_1.vhd +vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/altera/sync_fifo_1.vhd vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/pulse_generator_1.vhd # Enc PD Emul @@ -51,9 +51,9 @@ vcom -2008 -work $WORKLIB $GENERIC_PATH/enc_pd_emul/1/src/enc_pd_emul_1.vhd # Fire-Pulse-Manager vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_1_pkg.vhd vcom -2008 -work $WORKLIB $SRC_PATH/uart_rx_1.vhd -vcom -2008 -work $WORKLIB $SRC_PATH/sync_wire_1.vhd vcom -2008 -work $WORKLIB $SRC_PATH/uart_regen_1.vhd vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_ctrl_1.vhd +vcom -2008 -work $WORKLIB $SRC_PATH/sync_wire_1.vhd vcom -2008 -work $WORKLIB $SRC_PATH/sync_wire_rEdge_1.vhd vcom -2008 -work $WORKLIB $SRC_PATH/pof_rx_1.vhd vcom -2008 -work $WORKLIB $SRC_PATH/cs_bus_itf_1.vhd diff --git a/generic_ip/fire_pulse_manager/1/src/cdc_data_handshake_1.vhd b/generic_ip/fire_pulse_manager/1/src/cdc_data_handshake_1.vhd deleted file mode 100644 index 5bea55c..0000000 --- a/generic_ip/fire_pulse_manager/1/src/cdc_data_handshake_1.vhd +++ /dev/null @@ -1,118 +0,0 @@ -------------------------------------------------------------------------------- --- Allows a strobe-validated word of data to be passed safely between --- two asynchronous clock domains with a handshaking acknowledge strobe. --- Not a FIFO - so saves on an M10K --- --- Clock-crossing considerations: --- Data will be sampled on source clock and held until transfer is complete --- Any data arriving in the meantime will be ignored --- --- Language build standard requirements: --- VHDL 2008 --- --- author Damian Smith --- copyright (c) 2019 Global Inkjet Systems --- date 24 May 2019 -------------------------------------------------------------------------------- --- altera vhdl_input_version vhdl_2008 - -library ieee; -use ieee.std_logic_1164.all; -use ieee.numeric_std.all; - -entity cdc_data_handshake_1 is - generic( - DATA_WIDTH : positive := 8 - ); - port( - arst_n : in std_logic; -- will be synchronised to both domains - -- - src_clk : in std_logic; - src_valid : in std_logic; -- strobe - src_data : in std_logic_vector(DATA_WIDTH - 1 downto 0) := (others => '0'); - src_ack : out std_logic; -- strobe - -- - dest_clk : in std_logic; - dest_valid : out std_logic; -- strobe - dest_data : out std_logic_vector(DATA_WIDTH - 1 downto 0) - - ); -end entity cdc_data_handshake_1; - -architecture rtl of cdc_data_handshake_1 is - signal src_rst_n, dest_rst_n : std_logic; - signal src_data_reg : std_logic_vector(DATA_WIDTH - 1 downto 0); - signal src_valid_reg : std_logic; - signal dest_valid_reg : std_logic; - signal dest_valid_reg_d : std_logic; - signal dest2src_ack : std_logic; - signal dest2src_ack_d : std_logic; - - -- declare false path as src_data_reg is sampled only when safe as validated by dest_valid_reg - attribute altera_attribute : string; - attribute altera_attribute of rtl : architecture is - "-name SDC_STATEMENT ""set_false_path -from [get_keepers *] -to [get_keepers {*cdc_data_handshake_1:*dest_data[*]}]"" "; - -begin - - ----------------------------------------------------------------------------- - -- Synchronize the input reset to the clocks - ----------------------------------------------------------------------------- - iSyncReset_src : entity work.sync_reset port map(async_rstN => arst_n, clk => src_clk, sync_rstN => src_rst_n); - iSyncReset_dest : entity work.sync_reset port map(async_rstN => arst_n, clk => dest_clk, sync_rstN => dest_rst_n); - - src_proc : process(src_clk, src_rst_n) is - begin - if src_rst_n = '0' then - src_ack <= '0'; - src_data_reg <= (others => '0'); - src_valid_reg <= '0'; - dest2src_ack_d <= '0'; - elsif rising_edge(src_clk) then - src_ack <= '0'; - - if src_valid = '1' then - src_data_reg <= src_data; - src_valid_reg <= '1'; - - end if; - - -- stop driving the src2dest signal and give src an ack - dest2src_ack_d <= dest2src_ack; - if dest2src_ack = '1' and dest2src_ack_d = '0' then - src_ack <= '1'; - src_valid_reg <= '0'; - end if; - end if; - end process src_proc; - - --pragma translate_off - assert not (src_valid = '1' and src_valid_reg = '1') report "new valid provided to CDC block before previous had completed" severity error; - --pragma translate_on - - iSyncWire_src2dest : entity work.sync_wire_1 - generic map(rst_val => '0', sync_stages => 2) - port map(rstN => dest_rst_n, clk => dest_clk, async_in => src_valid_reg, sync_out => dest_valid_reg); - - dest_proc : process(dest_clk, dest_rst_n) is - begin - if dest_rst_n = '0' then - dest_valid <= '0'; - dest_data <= (others => '0'); - dest_valid_reg_d <= '0'; - elsif rising_edge(dest_clk) then - dest_valid <= '0'; - dest_valid_reg_d <= dest_valid_reg; - if dest_valid_reg = '1' and dest_valid_reg_d = '0' then - dest_data <= src_data_reg; - dest_valid <= '1'; - end if; - end if; - end process dest_proc; - - iSyncWire_dest2src : entity work.sync_wire_1 - generic map(rst_val => '0', sync_stages => 2) - port map(rstN => src_rst_n, clk => src_clk, async_in => dest_valid_reg, sync_out => dest2src_ack); - - -end architecture rtl; diff --git a/generic_ip/fire_pulse_manager/1/src/fire_pulse_ctrl_1.vhd b/generic_ip/fire_pulse_manager/1/src/fire_pulse_ctrl_1.vhd index 449aabe..91ed17a 100644 --- a/generic_ip/fire_pulse_manager/1/src/fire_pulse_ctrl_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/fire_pulse_ctrl_1.vhd @@ -22,23 +22,21 @@ entity fire_pulse_ctrl_1 is port( reset_n : in std_logic; clk : in std_logic; - src_sel : out std_logic_vector(1 downto 0); - - pof_rx_ctrl_valid : out std_logic; + src_sel : out std_logic_vector( 1 downto 0); uart_regen_bypass : out std_logic; upd_max_pos : out std_logic; upd_min_pos : out std_logic; enable_rx : out std_logic; - uart_bit_div : out std_logic_vector(3 downto 0); - error_rate_thres : out std_logic_vector(7 downto 0); + uart_bit_div : out std_logic_vector( 3 downto 0); + error_rate_thres : out std_logic_vector( 7 downto 0); max_error_flag : in std_logic; rx_watchdog : in std_logic; rx_watchdog_en : out std_logic; rx_watchdog_clr : out std_logic; parity_err_cnt : in std_logic_vector(15 downto 0); skip_pos_cnt : in std_logic_vector(15 downto 0); - mon_point_src : in std_logic_vector(15 downto 0); - mon_points : out std_logic_vector(3 downto 0); + mon_point_src : in std_logic_vector(15 downto 0); + mon_points : out std_logic_vector( 3 downto 0); coarse_time : out std_logic_vector(31 downto 0); fine_time : out std_logic_vector(27 downto 0); one_pps : out std_logic; @@ -47,7 +45,7 @@ entity fire_pulse_ctrl_1 is -- Interrupt Senders ins_fpm_irq_0 : out std_logic; -- Avalon MM Interface - avs_address : in std_logic_vector(3 downto 0); + avs_address : in std_logic_vector( 3 downto 0); avs_write : in std_logic; avs_writedata : in std_logic_vector(31 downto 0); avs_read : in std_logic; @@ -60,41 +58,41 @@ architecture rtl of fire_pulse_ctrl_1 is ----------------------------------------------------------------------------- -- Control & Status Registers Map ----------------------------------------------------------------------------- - constant CSR_IP_ID : std_logic_vector(31 downto 0) := x"0000FF14"; - constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000100"; + constant CSR_IP_ID : std_logic_vector(31 downto 0) := x"0000FF14"; + constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000100"; - constant CSR_IP_ID_REG : std_logic_vector(3 downto 0) := b"0000"; - constant CSR_IP_VER_REG : std_logic_vector(3 downto 0) := b"0001"; - constant SRC_SEL_REG : std_logic_vector(3 downto 0) := b"0010"; - constant POF_RX_CTRL : std_logic_vector(3 downto 0) := b"0011"; - constant MON_PT_CTRL_REG : std_logic_vector(3 downto 0) := b"0100"; - constant COARSE_TIME_INIT_REG : std_logic_vector(3 downto 0) := b"0101"; - constant FINE_TIME_INIT_REG : std_logic_vector(3 downto 0) := b"0110"; - constant FINE_TIME_REG : std_logic_vector(3 downto 0) := b"0111"; - constant COARSE_TIME_REG : std_logic_vector(3 downto 0) := b"1000"; - constant RX_ERROR_STATUS : std_logic_vector(3 downto 0) := b"1001"; - constant RX_ERROR_CSR : std_logic_vector(3 downto 0) := b"1010"; - constant IRQ_MNG_REG : std_logic_vector(3 downto 0) := b"1011"; - constant EXT_FP_CTRL_REG : std_logic_vector(3 downto 0) := b"1100"; + constant CSR_IP_ID_REG : std_logic_vector( 3 downto 0) := b"0000"; + constant CSR_IP_VER_REG : std_logic_vector( 3 downto 0) := b"0001"; + constant SRC_SEL_REG : std_logic_vector( 3 downto 0) := b"0010"; + constant POF_RX_CTRL : std_logic_vector( 3 downto 0) := b"0011"; + constant MON_PT_CTRL_REG : std_logic_vector( 3 downto 0) := b"0100"; + constant COARSE_TIME_INIT_REG : std_logic_vector( 3 downto 0) := b"0101"; + constant FINE_TIME_INIT_REG : std_logic_vector( 3 downto 0) := b"0110"; + constant FINE_TIME_REG : std_logic_vector( 3 downto 0) := b"0111"; + constant COARSE_TIME_REG : std_logic_vector( 3 downto 0) := b"1000"; + constant RX_ERROR_STATUS : std_logic_vector( 3 downto 0) := b"1001"; + constant RX_ERROR_CSR : std_logic_vector( 3 downto 0) := b"1010"; + constant IRQ_MNG_REG : std_logic_vector( 3 downto 0) := b"1011"; + constant EXT_FP_CTRL_REG : std_logic_vector( 3 downto 0) := b"1100"; ----------------------------------------------------------------------------- -- Constants, Signals ----------------------------------------------------------------------------- - constant FINE_TIME_TC : integer := 100000000 - 1; -- clk must be 100MHz to - -- make it right + constant FINE_TIME_TC : integer := 100000000-1; -- clk must be 100MHz to + -- make it right signal enable_rx_i : std_logic; signal fine_time_wrap, time_ld_en : std_logic; signal rx_watchdog_en_i, rx_watchdog_clr_i : std_logic; signal uart_regen_bypass_i : std_logic; signal upd_min_pos_i, upd_max_pos_i : std_logic; - signal irq, irq_src, irq_src_d : std_logic_vector(0 downto 0); - signal irq_en, irq_mask, irq_val, irq_clr : std_logic_vector(0 downto 0); - signal src_sel_i : std_logic_vector(1 downto 0); - signal mp_sel0, mp_sel1, mp_sel2, mp_sel3 : std_logic_vector(3 downto 0); - signal bit_div : std_logic_vector(3 downto 0); - signal error_rate_thres_i : std_logic_vector(7 downto 0); + signal irq, irq_src, irq_src_d : std_logic_vector( 0 downto 0); + signal irq_en, irq_mask, irq_val, irq_clr : std_logic_vector( 0 downto 0); + signal src_sel_i : std_logic_vector( 1 downto 0); + signal mp_sel0, mp_sel1, mp_sel2, mp_sel3 : std_logic_vector( 3 downto 0); + signal bit_div : std_logic_vector( 3 downto 0); + signal error_rate_thres_i : std_logic_vector( 7 downto 0); signal fine_time_init, fine_time_i : std_logic_vector(27 downto 0); signal coarse_time_init, coarse_time_i : std_logic_vector(31 downto 0); signal ext_fp_det_i, ext_fp_gen_i : std_logic_vector(15 downto 0); @@ -102,22 +100,22 @@ architecture rtl of fire_pulse_ctrl_1 is begin pCTRL_REGs : process(reset_n, clk) - begin -- process - if (reset_n = '0') then - fine_time_i <= (others => '0'); - coarse_time_i <= (others => '0'); - elsif (clk = '1' and clk'event) then - if (time_ld_en = '1') then + begin -- process + if(reset_n = '0') then + fine_time_i <= (others => '0'); + coarse_time_i <= (others => '0'); + elsif(clk = '1' and clk'event) then + if(time_ld_en = '1') then fine_time_i <= fine_time_init; - elsif (fine_time_wrap = '1') then + elsif(fine_time_wrap = '1') then fine_time_i <= (others => '0'); else - fine_time_i <= std_logic_vector(unsigned(fine_time_i) + 1); + fine_time_i <= std_logic_vector(unsigned(fine_time_i)+1); end if; - if (time_ld_en = '1') then + if(time_ld_en = '1') then coarse_time_i <= coarse_time_init; - elsif (fine_time_wrap = '1') then - coarse_time_i <= std_logic_vector(unsigned(coarse_time_i) + 1); + elsif(fine_time_wrap = '1') then + coarse_time_i <= std_logic_vector(unsigned(coarse_time_i)+1); end if; one_pps <= fine_time_wrap; end if; @@ -140,19 +138,19 @@ begin pIRQ : process(reset_n, clk) begin - if (reset_n = '0') then - ins_fpm_irq_0 <= '0'; - irq <= "0"; - irq_src_d <= "0"; - elsif (clk = '1' and clk'event) then - irq_src_d <= irq_src; + if(reset_n = '0') then + ins_fpm_irq_0 <= '0'; + irq <= "0"; + irq_src_d <= "0"; + elsif(clk = '1' and clk'event) then + irq_src_d <= irq_src; for n in 0 to irq'left loop - if (irq_clr(n) = '1') then + if(irq_clr(n) = '1') then irq(n) <= '0'; - elsif (irq_en(n) = '1' and irq_src(n) = '1' and irq_src_d(n) = '0') then + elsif(irq_en(n) = '1' and irq_src(n) = '1' and irq_src_d(n) = '0') then irq(n) <= '1'; end if; - end loop; -- n + end loop; -- n ins_fpm_irq_0 <= irq_val(0); end if; end process pIRQ; @@ -176,12 +174,12 @@ begin rx_watchdog_en <= rx_watchdog_en_i; rx_watchdog_clr <= rx_watchdog_clr_i; - ext_fp_det <= ext_fp_det_i; - ext_fp_gen <= ext_fp_gen_i; + ext_fp_det <= ext_fp_det_i; + ext_fp_gen <= ext_fp_gen_i; pCTRL_STATUS : process(reset_n, clk) begin - if (reset_n = '0') then + if(reset_n = '0') then avs_readdatavalid <= '0'; src_sel_i <= "00"; enable_rx_i <= '0'; @@ -201,68 +199,65 @@ begin time_ld_en <= '0'; ext_fp_det_i <= X"0010"; ext_fp_gen_i <= X"0020"; - pof_rx_ctrl_valid <= '0'; - elsif (clk = '1' and clk'event) then + elsif(clk = '1' and clk'event) then -- CTRL registers - pof_rx_ctrl_valid <= '0'; - if (avs_write = '1') then + if(avs_write = '1') then case avs_address is when SRC_SEL_REG => - src_sel_i <= avs_writedata(1 downto 0); + src_sel_i <= avs_writedata( 1 downto 0); when POF_RX_CTRL => enable_rx_i <= avs_writedata(0); uart_regen_bypass_i <= avs_writedata(1); upd_max_pos_i <= avs_writedata(2); upd_min_pos_i <= avs_writedata(3); - bit_div <= avs_writedata(7 downto 4); - pof_rx_ctrl_valid <= '1'; -- strobe to validate new pof_rx data + bit_div <= avs_writedata( 7 downto 4); when MON_PT_CTRL_REG => - mp_sel0 <= avs_writedata(3 downto 0); - mp_sel1 <= avs_writedata(7 downto 4); - mp_sel2 <= avs_writedata(11 downto 8); - mp_sel3 <= avs_writedata(15 downto 12); - when COARSE_TIME_INIT_REG => - coarse_time_init <= avs_writedata; + mp_sel0 <= avs_writedata( 3 downto 0); + mp_sel1 <= avs_writedata( 7 downto 4); + mp_sel2 <= avs_writedata(11 downto 8); + mp_sel3 <= avs_writedata(15 downto 12); + when COARSE_TIME_INIT_REG => + coarse_time_init <= avs_writedata; when FINE_TIME_INIT_REG => - time_ld_en <= avs_writedata(28); - fine_time_init <= avs_writedata(27 downto 0); + time_ld_en <= avs_writedata(28); + fine_time_init <= avs_writedata(27 downto 0); when RX_ERROR_CSR => - error_rate_thres_i <= avs_writedata(7 downto 0); - rx_watchdog_en_i <= avs_writedata(8); - rx_watchdog_clr_i <= avs_writedata(9); + error_rate_thres_i <= avs_writedata( 7 downto 0); + rx_watchdog_en_i <= avs_writedata(8); + rx_watchdog_clr_i <= avs_writedata(9); when IRQ_MNG_REG => - irq_en <= avs_writedata(0 downto 0); - irq_clr <= avs_writedata(4 downto 4); - irq_mask <= avs_writedata(8 downto 8); + irq_en <= avs_writedata( 0 downto 0); + irq_clr <= avs_writedata( 4 downto 4); + irq_mask <= avs_writedata( 8 downto 8); when EXT_FP_CTRL_REG => - ext_fp_det_i <= avs_writedata(15 downto 0); - ext_fp_gen_i <= avs_writedata(31 downto 16); + ext_fp_det_i <= avs_writedata(15 downto 0); + ext_fp_gen_i <= avs_writedata(31 downto 16); when others => null; end case; - end if; + end if; -- Read Ctrl & Status registers avs_readdatavalid <= avs_read; - if (avs_read = '1') then + if(avs_read = '1') then case avs_address is when CSR_IP_ID_REG => avs_readdata <= CSR_IP_ID; when CSR_IP_VER_REG => avs_readdata <= CSR_IP_VER; - when SRC_SEL_REG => + when SRC_SEL_REG => avs_readdata <= (0 => src_sel_i(0), 1 => src_sel_i(1), others => '0'); - when POF_RX_CTRL => + when POF_RX_CTRL => avs_readdata <= X"000000" & bit_div & upd_min_pos_i & upd_max_pos_i & uart_regen_bypass_i & enable_rx_i; when MON_PT_CTRL_REG => avs_readdata <= X"0000" & mp_sel3 & mp_sel2 & mp_sel1 & mp_sel0; when COARSE_TIME_INIT_REG => avs_readdata <= coarse_time_init; - when FINE_TIME_INIT_REG => + when FINE_TIME_INIT_REG => avs_readdata <= b"000" & time_ld_en & fine_time_init; when RX_ERROR_STATUS => avs_readdata <= skip_pos_cnt & parity_err_cnt; - when FINE_TIME_REG => + when FINE_TIME_REG => avs_readdata <= X"0" & fine_time_i; - when COARSE_TIME_REG => + when COARSE_TIME_REG => avs_readdata <= coarse_time_i; when RX_ERROR_CSR => avs_readdata <= X"00000" & max_error_flag & rx_watchdog & rx_watchdog_clr_i & rx_watchdog_en_i & error_rate_thres_i; @@ -276,5 +271,5 @@ begin end if; end if; end process pCTRL_STATUS; - + end architecture rtl; diff --git a/generic_ip/fire_pulse_manager/1/src/fire_pulse_manager_1.vhd b/generic_ip/fire_pulse_manager/1/src/fire_pulse_manager_1.vhd index 2c94367..b7126c5 100644 --- a/generic_ip/fire_pulse_manager/1/src/fire_pulse_manager_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/fire_pulse_manager_1.vhd @@ -25,7 +25,7 @@ entity fire_pulse_manager_1 is port( reset_n : in std_logic; clk : in std_logic; -- 100MHz - rx_clk : in std_logic; -- 300MHz (recommended for 50MBd POF Link) + rx_clk : in std_logic; -- 200MHz -- Datapath I/Os pof_rx : in std_logic; pof_tx : out std_logic; @@ -35,10 +35,9 @@ entity fire_pulse_manager_1 is -- on header J7 -- Interrupt Senders ins_fpm_irq_0 : out std_logic; - -- unused 1 to 3 - ins_fpm_irq_1 : out std_logic; - ins_fpm_irq_2 : out std_logic; - ins_fpm_irq_3 : out std_logic; + ins_fpm_irq_1 : out std_logic; -- @suppress "Unused port: ins_fpm_irq_1 is not used in work.fire_pulse_manager_1(rtl)" + ins_fpm_irq_2 : out std_logic; -- @suppress "Unused port: ins_fpm_irq_2 is not used in work.fire_pulse_manager_1(rtl)" + ins_fpm_irq_3 : out std_logic; -- @suppress "Unused port: ins_fpm_irq_3 is not used in work.fire_pulse_manager_1(rtl)" -- Avalon MM (Slave) Interface avs_address : in std_logic_vector(14 downto 0); avs_write : in std_logic; @@ -50,90 +49,84 @@ end entity fire_pulse_manager_1; architecture rtl of fire_pulse_manager_1 is - signal reset_n_i : std_logic; -- reset synchronised to clk (100MHz) + signal reset_n_i : std_logic; -- - signal cs_addr : std_logic_vector(10 downto 0); - signal cs_write_en : std_logic_vector(blk_num - 1 downto 0); - signal cs_write_data : std_logic_vector(31 downto 0); - signal cs_read_en : std_logic_vector(blk_num - 1 downto 0); - signal cs_read_valid : std_logic_vector(blk_num - 1 downto 0); - signal cs_read_data : std_logic_vector(32 * blk_num - 1 downto 0); + signal cs_addr : std_logic_vector(10 downto 0); + signal cs_write_en : std_logic_vector(blk_num - 1 downto 0); + signal cs_write_data : std_logic_vector(31 downto 0); + signal cs_read_en : std_logic_vector(blk_num - 1 downto 0); + signal cs_read_valid : std_logic_vector(blk_num - 1 downto 0); + signal cs_read_data : std_logic_vector(32 * blk_num - 1 downto 0); -- - signal cs_ctrl_write_en : std_logic; - signal cs_ctrl_read_en : std_logic; - signal cs_ctrl_read_valid : std_logic; - signal cs_ctrl_read_data : std_logic_vector(31 downto 0); + signal cs_ctrl_write_en : std_logic; + signal cs_ctrl_read_en : std_logic; + signal cs_ctrl_read_valid : std_logic; + signal cs_ctrl_read_data : std_logic_vector(31 downto 0); -- - signal cs_pg_write_en : std_logic_vector(ch_num - 1 downto 0); - signal cs_pg_read_en : std_logic_vector(ch_num - 1 downto 0); - signal cs_pg_read_valid : std_logic_vector(ch_num - 1 downto 0); - signal cs_pg_read_data : std_logic_vector(32 * ch_num - 1 downto 0); + signal cs_pg_write_en : std_logic_vector(ch_num - 1 downto 0); + signal cs_pg_read_en : std_logic_vector(ch_num - 1 downto 0); + signal cs_pg_read_valid : std_logic_vector(ch_num - 1 downto 0); + signal cs_pg_read_data : std_logic_vector(32 * ch_num - 1 downto 0); -- - signal cs_nsnk_write_en : std_logic; - signal cs_nsnk_read_en : std_logic; - signal cs_nsnk_read_valid : std_logic; - signal cs_nsnk_read_data : std_logic_vector(31 downto 0); + signal cs_nsnk_write_en : std_logic; + signal cs_nsnk_read_en : std_logic; + signal cs_nsnk_read_valid : std_logic; + signal cs_nsnk_read_data : std_logic_vector(31 downto 0); -- - signal cs_log_write_en : std_logic; - signal cs_log_read_en : std_logic; - signal cs_log_read_valid : std_logic; - signal cs_log_read_data : std_logic_vector(31 downto 0); + signal cs_log_write_en : std_logic; + signal cs_log_read_en : std_logic; + signal cs_log_read_valid : std_logic; + signal cs_log_read_data : std_logic_vector(31 downto 0); -- - signal cs_ie_write_en : std_logic; - signal cs_ie_read_en : std_logic; - signal cs_ie_read_valid : std_logic; - signal cs_ie_read_data : std_logic_vector(31 downto 0); + signal cs_ie_write_en : std_logic; + signal cs_ie_read_en : std_logic; + signal cs_ie_read_valid : std_logic; + signal cs_ie_read_data : std_logic_vector(31 downto 0); -- - signal enable_rx : std_logic; - signal uart_regen_bypass : std_logic; - signal upd_max_pos : std_logic; - signal upd_min_pos : std_logic; - signal max_error_flag : std_logic; - signal rx_watchdog : std_logic; - signal rx_watchdog_en : std_logic; - signal rx_watchdog_clr : std_logic; - signal bit_div : std_logic_vector(3 downto 0); - signal error_rate_thres : std_logic_vector(7 downto 0); - signal parity_err_cnt : std_logic_vector(15 downto 0); - signal skip_pos_cnt : std_logic_vector(15 downto 0); - signal mon_point_src : std_logic_vector(15 downto 0); - signal fine_time : std_logic_vector(27 downto 0); - signal coarse_time : std_logic_vector(31 downto 0); + signal enable_rx : std_logic; + signal uart_regen_bypass : std_logic; + signal upd_max_pos : std_logic; + signal upd_min_pos : std_logic; + signal max_error_flag : std_logic; + signal rx_watchdog : std_logic; + signal rx_watchdog_en : std_logic; + signal rx_watchdog_clr : std_logic; + signal bit_div : std_logic_vector(3 downto 0); + signal error_rate_thres : std_logic_vector(7 downto 0); + signal parity_err_cnt : std_logic_vector(15 downto 0); + signal skip_pos_cnt : std_logic_vector(15 downto 0); + signal mon_point_src : std_logic_vector(15 downto 0); + signal fine_time : std_logic_vector(27 downto 0); + signal coarse_time : std_logic_vector(31 downto 0); -- - signal remote_init : std_logic; - signal dp_dir : std_logic_vector(ch_num - 1 downto 0); - signal set_pos_ie : std_logic; - signal enc_pulse : std_logic; - signal enc_pulse_ie : std_logic; - signal enc_pulse_pof : std_logic; - signal pd_pulse : std_logic; - signal pd_pulse_ie : std_logic; - signal pd_pulse_pof : std_logic; - signal inc_pos : std_logic; - signal inc_pos_pof : std_logic; - signal inc_pos_ie : std_logic; - signal dec_pos : std_logic; - signal dec_pos_pof : std_logic; - signal dec_pos_ie : std_logic; - signal abs_pos : std_logic_vector(31 downto 0); - signal abs_pos_pof : std_logic_vector(31 downto 0); - signal abs_pos_ie : std_logic_vector(39 downto 0); + signal remote_init : std_logic; + signal dp_dir : std_logic_vector(ch_num - 1 downto 0); + signal set_pos_ie : std_logic; + signal enc_pulse : std_logic; + signal enc_pulse_ie : std_logic; + signal enc_pulse_pof : std_logic; + signal pd_pulse : std_logic; + signal pd_pulse_ie : std_logic; + signal pd_pulse_pof : std_logic; + signal inc_pos : std_logic; + signal inc_pos_pof : std_logic; + signal inc_pos_ie : std_logic; + signal dec_pos : std_logic; + signal dec_pos_pof : std_logic; + signal dec_pos_ie : std_logic; + signal abs_pos : std_logic_vector(31 downto 0); + signal abs_pos_pof : std_logic_vector(31 downto 0); + signal abs_pos_ie : std_logic_vector(39 downto 0); -- - signal ch_pd, ch_pulse_out : std_logic_vector(ch_num - 1 downto 0); - signal ch_raw_pulse, ch_mask : std_logic_vector(ch_num - 1 downto 0); - signal fire_pulse_i : std_logic_vector(ch_num - 1 downto 0); - signal src_sel : std_logic_vector(1 downto 0); + signal ch_pd, ch_pulse_out : std_logic_vector(ch_num - 1 downto 0); + signal ch_raw_pulse, ch_mask : std_logic_vector(ch_num - 1 downto 0); + signal fire_pulse_i : std_logic_vector(ch_num - 1 downto 0); + signal src_sel : std_logic_vector(1 downto 0); -- - signal one_pps : std_logic; - signal ext_fp_det : std_logic_vector(15 downto 0); - signal ext_fp_gen : std_logic_vector(15 downto 0); - signal pof_rx_regen : std_logic; - signal pof_rx_ctrl_valid : std_logic; -- validates uart_regen_bypass, upd_max_pos, upd_min_pos, enable_rx, bit_div - signal bit_div_dest : std_logic_vector(bit_div'range); - signal enable_rx_dest : std_logic; - signal pof_rx_ctrl_data_dest : std_logic_vector(bit_div'high + 2 downto 0); - signal pof_rx_ctrl_data_src : std_logic_vector(bit_div'high + 2 downto 0); - signal uart_regen_bypass_dest : std_logic; + signal one_pps : std_logic; + signal ext_fp_det : std_logic_vector(15 downto 0); + signal ext_fp_gen : std_logic_vector(15 downto 0); + signal pof_rx_regen : std_logic; begin @@ -176,54 +169,30 @@ begin -- POF Receiver iPOF_RX : entity work.pof_rx_1 port map( - reset_n => reset_n_i, - clk => clk, - init => '0', - rx_clk => rx_clk, - rx_data => pof_rx, - init_out => remote_init, - dp_dir => dp_dir(0), - enc_out => enc_pulse_pof, - pd_out => pd_pulse_pof, - inc_pos => inc_pos_pof, - dec_pos => dec_pos_pof, - abs_pos => abs_pos_pof, - pof_rx_ctrl_valid => pof_rx_ctrl_valid, - enable => enable_rx, - bit_div => bit_div, - upd_max_pos => upd_max_pos, - upd_min_pos => upd_min_pos, - error_rate_thres => error_rate_thres, - one_pps => one_pps, - max_error_flag => max_error_flag, - rx_watchdog => rx_watchdog, - rx_watchdog_en => rx_watchdog_en, - rx_watchdog_clr => rx_watchdog_clr, - parity_err_cnt => parity_err_cnt, - skip_pos_cnt => skip_pos_cnt); - - -- Synchronise signals to rx_clk - pof_rx_ctrl_data_dest <= enable_rx & uart_regen_bypass & bit_div; - - enable_rx_dest <= pof_rx_ctrl_data_src(5); - uart_regen_bypass_dest <= pof_rx_ctrl_data_src(4); - bit_div_dest <= pof_rx_ctrl_data_src(3 downto 0); - - - iCDC_CTRL : entity work.cdc_data_handshake_1 - generic map( - DATA_WIDTH => pof_rx_ctrl_data_dest'length - ) - port map( - arst_n => reset_n, - src_clk => clk, - src_valid => pof_rx_ctrl_valid, - src_data => pof_rx_ctrl_data_dest, - src_ack => open, - dest_clk => rx_clk, - dest_valid => open, - dest_data => pof_rx_ctrl_data_src - ); + reset_n => reset_n_i, + clk => clk, + init => '0', + rx_clk => rx_clk, + rx_data => pof_rx, + init_out => remote_init, + dp_dir => dp_dir(0), + enc_out => enc_pulse_pof, + pd_out => pd_pulse_pof, + inc_pos => inc_pos_pof, + dec_pos => dec_pos_pof, + abs_pos => abs_pos_pof, + enable => enable_rx, + bit_div => bit_div, + error_rate_thres => error_rate_thres, + one_pps => one_pps, + upd_max_pos => upd_max_pos, + upd_min_pos => upd_min_pos, + max_error_flag => max_error_flag, + rx_watchdog => rx_watchdog, + rx_watchdog_en => rx_watchdog_en, + rx_watchdog_clr => rx_watchdog_clr, + parity_err_cnt => parity_err_cnt, + skip_pos_cnt => skip_pos_cnt); -- UART signal regeneration iUART_REGEN : entity work.uart_regen_1 @@ -232,9 +201,9 @@ begin port map( reset_n => reset_n, clk => rx_clk, - bit_div => bit_div_dest, -- synchronised to rx_clk - enable => enable_rx_dest, -- synchronised to rx_clk - bypass_en => uart_regen_bypass_dest, -- synchronised to rx_clk + bit_div => bit_div, + enable => enable_rx, + bypass_en => uart_regen_bypass, uart_rx => pof_rx, uart_tx => pof_tx); @@ -361,7 +330,6 @@ begin reset_n => reset_n_i, clk => clk, src_sel => src_sel, - pof_rx_ctrl_valid => pof_rx_ctrl_valid, uart_regen_bypass => uart_regen_bypass, upd_max_pos => upd_max_pos, upd_min_pos => upd_min_pos, @@ -393,11 +361,6 @@ begin fire_pulse_i <= ch_pulse_out when src_sel(0) = '1' else (others => pof_rx_regen); fire_pulse <= fire_pulse_i; - -- Unused IRQs - set low until needed to give defined state - ins_fpm_irq_1 <= '0'; - ins_fpm_irq_2 <= '0'; - ins_fpm_irq_3 <= '0'; - pd_pulse <= pd_pulse_pof when src_sel(1) = '0' else pd_pulse_ie; enc_pulse <= enc_pulse_pof when src_sel(1) = '0' else enc_pulse_ie; abs_pos <= abs_pos_pof when src_sel(1) = '0' else abs_pos_ie(31 downto 0); diff --git a/generic_ip/fire_pulse_manager/1/src/pof_rx_1.vhd b/generic_ip/fire_pulse_manager/1/src/pof_rx_1.vhd index e0f91f9..0de5657 100644 --- a/generic_ip/fire_pulse_manager/1/src/pof_rx_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/pof_rx_1.vhd @@ -20,7 +20,7 @@ use ieee.numeric_std.all; entity pof_rx_1 is port( - reset_n : in std_logic; -- synchronised to clk + reset_n : in std_logic; clk : in std_logic; -- init : in std_logic; @@ -34,14 +34,12 @@ entity pof_rx_1 is dec_pos : out std_logic; abs_pos : out std_logic_vector(31 downto 0); -- C&S - pof_rx_ctrl_valid : in std_logic := '1'; -- validates upd_max_pos, upd_min_pos, enable_rx, bit_div enable : in std_logic; - bit_div : in std_logic_vector(3 downto 0); + bit_div : in std_logic_vector( 3 downto 0); + error_rate_thres : in std_logic_vector( 7 downto 0); + one_pps : in std_logic; upd_max_pos : in std_logic; upd_min_pos : in std_logic; - -- - error_rate_thres : in std_logic_vector(7 downto 0); - one_pps : in std_logic; max_error_flag : out std_logic; rx_watchdog : out std_logic; rx_watchdog_en : in std_logic; @@ -56,9 +54,9 @@ architecture rtl of pof_rx_1 is function odd_parity_check(data : std_logic_vector) return std_logic is variable parity_bit : std_logic := '0'; begin - for n in 0 to data'length - 1 loop + for n in 0 to data'length-1 loop parity_bit := parity_bit xor data(n); - end loop; -- n + end loop; -- n return parity_bit; end function odd_parity_check; @@ -66,10 +64,10 @@ architecture rtl of pof_rx_1 is function gray2bin(gray : std_logic_vector) return std_logic_vector is variable bin : std_logic_vector(gray'range); begin - bin(gray'length - 1) := gray(gray'length - 1); - for i in gray'length - 2 downto 0 loop - bin(i) := bin(i + 1) xor gray(i); - end loop; -- n + bin(gray'length-1) := gray(gray'length-1); + for i in gray'length-2 downto 0 loop + bin(i) := bin(i+1) xor gray(i); + end loop; -- n return bin; end function gray2bin; @@ -84,53 +82,33 @@ architecture rtl of pof_rx_1 is signal rx_symbol_val, clear_i, skip_pos_d, pos_recovery : std_logic; signal dp_dir_d, dp_dir_change, max_error_flag_i : std_logic; -- - signal clk_cnt : std_logic_vector(1 downto 0); - signal dist, abs_dist, skip_cnt : std_logic_vector(3 downto 0); - signal next_pos_lsb, curr_pos_lsb : std_logic_vector(3 downto 0); - signal pos_corr, max_dist : std_logic_vector(3 downto 0); - signal gray_pos : std_logic_vector(3 downto 0); - signal symbol_i, rx_symbol : std_logic_vector(7 downto 0); - signal rx_wd_cnt : std_logic_vector(9 downto 0); - signal parity_err_cnt_i, skip_pos_cnt_i : std_logic_vector(15 downto 0); - signal error_rate_cnt, error_rate : std_logic_vector(15 downto 0); - signal abs_pos_i, pos_max, pos_min : std_logic_vector(31 downto 0); - signal dist_pos, dist_neg : std_logic_vector(31 downto 0); - signal bit_div_dest : std_logic_vector(bit_div'range); - signal reset_n_rx_clk : std_logic; -- reset synchronised to rx_clk (typically 300 MHz) + signal clk_cnt : std_logic_vector( 1 downto 0); + signal dist, abs_dist, skip_cnt : std_logic_vector( 3 downto 0); + signal next_pos_lsb, curr_pos_lsb : std_logic_vector( 3 downto 0); + signal pos_corr, max_dist, rx_error_v : std_logic_vector( 3 downto 0); + signal gray_pos, rx_symbol_val_v : std_logic_vector( 3 downto 0); + signal symbol, symbol_i, rx_symbol : std_logic_vector( 7 downto 0); + signal rx_wd_cnt : std_logic_vector( 9 downto 0); + signal parity_err_cnt_i, skip_pos_cnt_i : std_logic_vector(15 downto 0); + signal error_rate_cnt, error_rate : std_logic_vector(15 downto 0); + signal abs_pos_i, pos_max, pos_min : std_logic_vector(31 downto 0); + signal dist_pos, dist_neg : std_logic_vector(31 downto 0); - begin clear <= not enable or init; ----------------------------------------------------------------------------- - -- De-serialize symbols (Serial clock at Higher Speed ( Rx Clock probably 300 MHz) + -- De-serialize symbols (Serial clock at 200 MHz) ----------------------------------------------------------------------------- - - iCDC_CTRL : entity work.cdc_data_handshake_1 - generic map( - DATA_WIDTH => bit_div'length - ) - port map( - arst_n => reset_n, - src_clk => clk, - src_valid => pof_rx_ctrl_valid, - src_data => bit_div, - src_ack => open, - dest_clk => rx_clk, - dest_valid => open, - dest_data => bit_div_dest - ); - - iSyncReset_rxclk : entity work.sync_reset port map(async_rstN => reset_n, clk => rx_clk, sync_rstN => reset_n_rx_clk); - + iRX_SYMBOL : entity work.uart_rx_1 - generic map( - data_width => rx_symbol'length) - port map( - reset_n => reset_n_rx_clk, -- should be synchronised to rx_clk + generic map ( + data_width => 8) + port map ( + reset_n => reset_n, clk => rx_clk, - bit_div => bit_div_dest, -- synchronised + bit_div => bit_div, init => clear_i, data_out => rx_symbol, data_out_valid => rx_symbol_val, @@ -138,42 +116,37 @@ begin rx_data => rx_data); -- Synchronize to the local clock + pLATCH_RX_DATA : process(rx_clk) + begin + if(rx_clk = '1' and rx_clk'event) then + if(rx_symbol_val = '1') then + symbol <= rx_symbol; + end if; + if(rx_symbol_val = '1') then + rx_symbol_val_v <= "1111"; + else + rx_symbol_val_v <= '0' & rx_symbol_val_v(3 downto 1); + end if; + if(rx_error = '1') then + rx_error_v <= "1111"; + else + rx_error_v <= '0' & rx_error_v(3 downto 1); + end if; + end if; + end process pLATCH_RX_DATA; - iCDC_SYMBOL : entity work.cdc_data_handshake_1 - generic map( - DATA_WIDTH => rx_symbol'length - ) - port map( - arst_n => reset_n, - src_clk => rx_clk, - src_valid => rx_symbol_val, - src_data => rx_symbol, - src_ack => open, - dest_clk => clk, - dest_valid => symbol_valid, - dest_data => symbol_i - ); + iSYNC_SYMBOL_VAL : entity work.sync_wire_rEdge_1 + generic map (rst_val => '0', sync_stages => 3) + port map (rstN => reset_n, clk => clk, async_in => rx_symbol_val_v(0), sync_out => symbol_valid); - iCDC_ERROR : entity work.cdc_data_handshake_1 - generic map( - DATA_WIDTH => 1 -- unused - ) - port map( - arst_n => reset_n, - src_clk => rx_clk, - src_valid => rx_error, - src_data => open, - src_ack => open, - dest_clk => clk, - dest_valid => rx_error_i, - dest_data => open - ); - - -- synchronize clear to rx_clk - iSYNC_CLEAR : entity work.sync_wire_1 - generic map(rst_val => '1', sync_stages => 2) - port map( - rstN => reset_n_rx_clk, clk => rx_clk, async_in => clear, sync_out => clear_i); + iSYNC_RX_ERROR : entity work.sync_wire_rEdge_1 + generic map (rst_val => '0', sync_stages => 3) + port map (rstN => reset_n, clk => clk, async_in => rx_error_v(0), sync_out => rx_error_i); + -- synchronize clear to tx_clk + iSYNC_CLEAR: entity work.sync_wire_1 + generic map (rst_val => '1', sync_stages => 2) + port map ( + rstN => reset_n, clk => rx_clk, async_in => clear, sync_out => clear_i); ----------------------------------------------------------------------------- -- Toggle-Bits Decoding @@ -181,54 +154,56 @@ begin pTOGGLE_DEC : process(clk) begin - if (clk = '1' and clk'event) then + if(clk = '1' and clk'event) then -- Toggle Bits - if (clear = '1') then + if(clear = '1') then toggle_sync <= '0'; - elsif (sync_confirmed = '1') then - toggle_sync <= not toggle_sync; + elsif(sync_confirmed = '1') then + toggle_sync <= not toggle_sync; end if; - if (clear = '1' or sync_confirmed = '1' or (symbol_valid_i = '1' and symbol_i(0) = toggle_sync)) then + if(clear = '1' or sync_confirmed = '1' or (symbol_valid_i = '1' and symbol_i(0) = toggle_sync)) then sync_toggle_test <= '0'; - elsif (sync_gen = '1') then + elsif(sync_gen = '1') then sync_toggle_test <= '1'; end if; - sync <= sync_confirmed; - sync_d <= sync; - if (clear = '1') then + sync <= sync_confirmed; + sync_d <= sync; + if(clear = '1') then toggle_pd <= '0'; - elsif (pd_confirmed = '1') then - toggle_pd <= not toggle_pd; + elsif(pd_confirmed = '1') then + toggle_pd <= not toggle_pd; end if; - if (clear = '1' or pd_confirmed = '1' or (symbol_valid_i = '1' and symbol_i(2) = toggle_pd)) then + if(clear = '1' or pd_confirmed = '1' or (symbol_valid_i = '1' and symbol_i(2) = toggle_pd)) then pd_toggle_test <= '0'; - elsif (pd_gen = '1') then + elsif(pd_gen = '1') then pd_toggle_test <= '1'; end if; - pd <= pd_confirmed; + pd <= pd_confirmed; -- symbol_valid_i <= symbol_valid and symbol_ok; symbol_error <= symbol_valid and not symbol_ok; - if (clear = '1') then + if(clear = '1') then parity_err_cnt_i <= (others => '0'); - elsif (symbol_error = '1') then - parity_err_cnt_i <= std_logic_vector(unsigned(parity_err_cnt_i) + 1); + elsif(symbol_error = '1') then + parity_err_cnt_i <= std_logic_vector(unsigned(parity_err_cnt_i)+1); end if; end if; end process pTOGGLE_DEC; + symbol_i <= symbol; + -- The received symbol is assumed to be vaild when there is not parity error -- and when the two bits with the PD-toggle bit are equal - symbol_ok <= '1' when odd_parity_check(symbol_i) = '1' and (symbol_i(1) = symbol_i(2)) else '0'; + symbol_ok <= '1' when odd_parity_check(symbol) = '1' and (symbol(1) = symbol(2)) else '0'; - sync_gen <= '1' when symbol_valid_i = '1' and symbol_i(0) /= toggle_sync else '0'; - pd_gen <= '1' when symbol_valid_i = '1' and symbol_i(2) /= toggle_pd else '0'; + sync_gen <= '1' when symbol_valid_i = '1' and symbol_i(0) /= toggle_sync else '0'; + pd_gen <= '1' when symbol_valid_i = '1' and symbol_i(2) /= toggle_pd else '0'; -- sync_confirmed <= sync_gen and sync_toggle_test; - pd_confirmed <= pd_gen and pd_toggle_test; + pd_confirmed <= pd_gen and pd_toggle_test; -- - init_out <= sync; - pd_out <= pd; + init_out <= sync; + pd_out <= pd; parity_err_cnt <= parity_err_cnt_i; @@ -240,63 +215,64 @@ begin next_pos_lsb <= gray2bin(gray_pos); curr_pos_lsb <= abs_pos_i(3 downto 0); - abs_dist <= dist when dist(3) = '0' else std_logic_vector(unsigned(not dist) + 1); + --dist <= std_logic_vector(signed(next_pos_lsb)-signed(curr_pos_lsb)); + abs_dist <= dist when dist(3) = '0' else std_logic_vector(unsigned(not dist)+1); pPOS_MNG : process(clk) begin - if (clk = '1' and clk'event) then - dist <= std_logic_vector(signed(next_pos_lsb) - signed(curr_pos_lsb)); + if(clk = '1' and clk'event) then + dist <= std_logic_vector(signed(next_pos_lsb)-signed(curr_pos_lsb)); symbol_valid_d <= symbol_valid_i; - if (clear = '1' or (symbol_valid_d = '1' and signed(dist) = 0) or pos_recovery = '1') then + if(clear = '1' or (symbol_valid_d = '1' and signed(dist) = 0) or pos_recovery = '1') then max_dist <= "0001"; - elsif (skip_pos = '1' or rx_error_i = '1') then + elsif(skip_pos = '1' or rx_error_i = '1') then max_dist <= std_logic_vector(unsigned(max_dist) + 1); end if; - if (symbol_valid_d = '1' and valid_pos = '1') then + if(symbol_valid_d = '1' and valid_pos = '1') then pos_corr <= abs_dist; - elsif (apply_corr = '1') then - pos_corr <= std_logic_vector(unsigned(pos_corr) - 1); + elsif(apply_corr = '1') then + pos_corr <= std_logic_vector(unsigned(pos_corr)-1); end if; - if (clear = '1' or corr_done = '1') then + if(clear = '1' or corr_done = '1') then upd_pos <= '0'; - elsif (symbol_valid_d = '1' and valid_pos = '1') then + elsif(symbol_valid_d = '1' and valid_pos = '1') then upd_pos <= '1'; end if; - if (upd_pos = '0' or unsigned(clk_cnt) = 2) then + if(upd_pos = '0' or unsigned(clk_cnt) = 2) then clk_cnt <= (others => '0'); else - clk_cnt <= std_logic_vector(unsigned(clk_cnt) + 1); + clk_cnt <= std_logic_vector(unsigned(clk_cnt)+1); end if; - if (symbol_valid_d = '1' and valid_pos = '1') then + if(symbol_valid_d = '1' and valid_pos = '1') then corr_sign <= dist(3); end if; - inc_pos_i <= inc_pos_ii; - dec_pos_i <= dec_pos_ii; - inc_pos <= inc_pos_i; - dec_pos <= dec_pos_i; - if (clear = '1' or sync = '1') then + inc_pos_i <= inc_pos_ii; + dec_pos_i <= dec_pos_ii; + inc_pos <= inc_pos_i; + dec_pos <= dec_pos_i; + if(clear = '1' or sync = '1') then abs_pos_i <= (others => '0'); - elsif (inc_pos_ii = '1') then - abs_pos_i <= std_logic_vector(signed(abs_pos_i) + 1); - elsif (dec_pos_ii = '1') then - abs_pos_i <= std_logic_vector(signed(abs_pos_i) - 1); + elsif(inc_pos_ii = '1') then + abs_pos_i <= std_logic_vector(signed(abs_pos_i)+1); + elsif(dec_pos_ii = '1') then + abs_pos_i <= std_logic_vector(signed(abs_pos_i)-1); end if; - abs_pos <= abs_pos_i; - skip_pos_d <= skip_pos; - if (clear = '1' or (symbol_valid_d = '1' and valid_pos = '1')) then + abs_pos <= abs_pos_i; + skip_pos_d <= skip_pos; + if(clear = '1' or (symbol_valid_d = '1' and valid_pos = '1')) then skip_cnt <= (others => '0'); - elsif (skip_pos = '1' and skip_pos_d = '0') then - skip_cnt <= std_logic_vector(unsigned(skip_cnt) + 1); + elsif(skip_pos = '1' and skip_pos_d = '0') then + skip_cnt <= std_logic_vector(unsigned(skip_cnt)+1); end if; - if (clear = '1') then + if(clear = '1') then skip_pos_cnt_i <= (others => '0'); - elsif (skip_pos_d = '1') then - skip_pos_cnt_i <= std_logic_vector(unsigned(skip_pos_cnt_i) + 1); + elsif(skip_pos_d = '1') then + skip_pos_cnt_i <= std_logic_vector(unsigned(skip_pos_cnt_i)+1); end if; end if; end process pPOS_MNG; - skip_pos <= '1' when (symbol_valid = '1' and symbol_ok = '0') or (symbol_valid_d = '1' and valid_pos = '0') else '0'; + skip_pos <= '1' when (symbol_valid = '1' and symbol_ok = '0') or (symbol_valid_d = '1' and valid_pos = '0' ) else '0'; pos_recovery <= '1' when unsigned(skip_cnt) >= 3 else '0'; valid_pos <= '1' when unsigned(abs_dist) <= unsigned(max_dist) or pos_recovery = '1' else '0'; @@ -315,26 +291,26 @@ begin pERROR_REPORTING : process(clk) begin - if (clk = '1' and clk'event) then - if (clear = '1' or one_pps = '1') then + if(clk = '1' and clk'event) then + if(clear = '1' or one_pps = '1') then error_rate_cnt <= (others => '0'); - elsif (symbol_error = '1') then - error_rate_cnt <= std_logic_vector(unsigned(error_rate_cnt) + 1); + elsif(symbol_error = '1') then + error_rate_cnt <= std_logic_vector(unsigned(error_rate_cnt)+1); end if; - if (clear = '1') then + if(clear = '1') then error_rate <= (others => '0'); - elsif (one_pps = '1') then + elsif(one_pps = '1') then error_rate <= error_rate_cnt; end if; max_error_flag <= not clear and max_error_flag_i; - if (clear = '1' or symbol_valid_i = '1' or rx_watchdog_clr = '1') then + if(clear = '1' or symbol_valid_i = '1' or rx_watchdog_clr = '1') then rx_wd_cnt <= (others => '0'); else - rx_wd_cnt <= std_logic_vector(unsigned(rx_wd_cnt) + 1); + rx_wd_cnt <= std_logic_vector(unsigned(rx_wd_cnt)+1); end if; - if (clear = '1' or rx_watchdog_clr = '1' or rx_watchdog_en = '0' or sync = '1') then + if(clear = '1' or rx_watchdog_clr = '1' or rx_watchdog_en = '0' or sync = '1') then rx_watchdog <= '0'; - elsif (unsigned(rx_wd_cnt) > 1000) then + elsif(unsigned(rx_wd_cnt) > 1000) then rx_watchdog <= '1'; end if; end if; @@ -358,24 +334,24 @@ begin pENC_MNG : process(clk) begin - if (clk = '1' and clk'event) then + if(clk = '1' and clk'event) then dp_dir_d <= dp_dir; - if (sync_d = '1' or dp_dir_change = '1' or new_max = '1' or upd_max_pos = '1') then + if(sync_d = '1' or dp_dir_change = '1' or new_max = '1' or upd_max_pos = '1') then pos_max <= abs_pos_i; end if; - if (sync_d = '1' or dp_dir_change = '1' or new_min = '1' or upd_min_pos = '1') then + if(sync_d = '1' or dp_dir_change = '1' or new_min = '1' or upd_min_pos = '1') then pos_min <= abs_pos_i; end if; - enc_out <= new_min or new_max; + enc_out <= new_min or new_max; end if; end process pENC_MNG; dp_dir_change <= dp_dir xor dp_dir_d; - dist_pos <= std_logic_vector(signed(abs_pos_i) - signed(pos_max)); - dist_neg <= std_logic_vector(signed(pos_min) - signed(abs_pos_i)); + dist_pos <= std_logic_vector(signed(abs_pos_i)-signed(pos_max)); + dist_neg <= std_logic_vector(signed(pos_min)-signed(abs_pos_i)); new_max <= '1' when inc_pos_i = '1' and dp_dir = '0' and dist_pos(31) = '0' and unsigned(dist_pos(3 downto 0)) /= 0 else '0'; new_min <= '1' when dec_pos_i = '1' and dp_dir = '1' and dist_neg(31) = '0' and unsigned(dist_neg(3 downto 0)) /= 0 else '0'; - + end architecture rtl; diff --git a/generic_ip/fire_pulse_manager/1/src/sync_wire_1.vhd b/generic_ip/fire_pulse_manager/1/src/sync_wire_1.vhd index 9d04a39..52fd605 100644 --- a/generic_ip/fire_pulse_manager/1/src/sync_wire_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/sync_wire_1.vhd @@ -3,18 +3,17 @@ ------------------------------------------------------------------------------- -- File : sync_wire.vhd -- Author : Gianmarco Girau --- Company : GIS +-- Company : On my own -- Target : Generic (simulation), Generic (synthesis) -- Dependency : none ------------------------------------------------------------------------------- -- Description: synchronize a std_logic signal to a clock domain ------------------------------------------------------------------------------- --- Last update: 2019-05-22 +-- Last update: 2015-08-17 ------------------------------------------------------------------------------- -- Revisions : -- Date Version Author Description -- 2010-10-25 1.0 gmg Created --- 2019-05-22 1.1 ds added altera attribute ------------------------------------------------------------------------------- library ieee; @@ -25,39 +24,36 @@ entity sync_wire_1 is rst_val : std_logic := '0'; sync_stages : positive := 2); port( - rstN : in std_logic; - clk : in std_logic; - async_in : in std_logic; - sync_out : out std_logic); + rstN : in std_logic; + clk : in std_logic; + async_in : in std_logic; + sync_out : out std_logic); end sync_wire_1; architecture RTL of sync_wire_1 is - signal sync_sig : std_logic_vector(sync_stages - 1 downto 0); - -- declare false path for the input to the synchroniser - attribute altera_attribute : string; - attribute altera_attribute of RTL : architecture is - "-name SDC_STATEMENT ""set_false_path -from [get_keepers *] -to [get_keepers {*sync_wire_1:*sync_sig[0]}]"" "; + signal sync_sig : std_logic_vector(sync_stages-1 downto 0); + begin pSYNC : process(rstN, clk) begin - if (rstN = '0') then - for n in 0 to sync_stages - 1 loop + if(rstN = '0') then + for n in 0 to sync_stages-1 loop sync_sig(n) <= rst_val; - end loop; -- n - elsif (clk = '1' and clk'event) then - for n in 0 to sync_stages - 1 loop - if (n = 0) then + end loop; -- n + elsif(clk = '1' and clk'event) then + for n in 0 to sync_stages-1 loop + if(n = 0) then sync_sig(0) <= async_in; else - sync_sig(n) <= sync_sig(n - 1); + sync_sig(n) <= sync_sig(n-1); end if; - end loop; -- n + end loop; -- n end if; end process pSYNC; - sync_out <= sync_sig(sync_stages - 1); + sync_out <= sync_sig(sync_stages-1); end RTL; diff --git a/generic_ip/fire_pulse_manager/1/src/sync_wire_rEdge_1.vhd b/generic_ip/fire_pulse_manager/1/src/sync_wire_rEdge_1.vhd index a3d88d1..5d2b1bb 100644 --- a/generic_ip/fire_pulse_manager/1/src/sync_wire_rEdge_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/sync_wire_rEdge_1.vhd @@ -3,18 +3,17 @@ ------------------------------------------------------------------------------- -- File : sync_wire_rEdge.vhd -- Author : Gianmarco Girau --- Company : GIS +-- Company : On my own -- Target : Generic (simulation), Generic (synthesis) -- Dependency : none ------------------------------------------------------------------------------- -- Description: synchronize a std_logic signal to a clock domain with rising edge ------------------------------------------------------------------------------- --- Last update: 2019-05-22 +-- Last update: 2015-08-17 ------------------------------------------------------------------------------- -- Revisions : -- Date Version Author Description -- 2010-12-03 1.0 gmg Created --- 2019-05-22 1.1 ds added altera attribute ------------------------------------------------------------------------------- library ieee; @@ -25,42 +24,39 @@ entity sync_wire_rEdge_1 is rst_val : std_logic := '0'; sync_stages : positive := 2); port( - rstN : in std_logic; - clk : in std_logic; - async_in : in std_logic; - sync_out : out std_logic); + rstN : in std_logic; + clk : in std_logic; + async_in : in std_logic; + sync_out : out std_logic); end sync_wire_rEdge_1; architecture RTL of sync_wire_rEdge_1 is signal sync_out_i, sync_out_d : std_logic; - signal sync_sig : std_logic_vector(sync_stages - 1 downto 0); - -- declare false path for the input to the synchroniser - attribute altera_attribute : string; - attribute altera_attribute of RTL : architecture is - "-name SDC_STATEMENT ""set_false_path -from [get_keepers *] -to [get_keepers {*sync_wire_rEdge_1:*sync_sig[0]}]"" "; + signal sync_sig : std_logic_vector(sync_stages-1 downto 0); + begin pSYNC : process(rstN, clk) begin - if (rstN = '0') then + if(rstN = '0') then sync_out_d <= rst_val; - for n in 0 to sync_stages - 1 loop + for n in 0 to sync_stages-1 loop sync_sig(n) <= rst_val; - end loop; -- n - elsif (clk = '1' and clk'event) then + end loop; -- n + elsif(clk = '1' and clk'event) then sync_out_d <= sync_out_i; - for n in 0 to sync_stages - 1 loop - if (n = 0) then + for n in 0 to sync_stages-1 loop + if(n = 0) then sync_sig(0) <= async_in; else - sync_sig(n) <= sync_sig(n - 1); + sync_sig(n) <= sync_sig(n-1); end if; - end loop; -- n + end loop; -- n end if; end process pSYNC; - sync_out_i <= sync_sig(sync_stages - 1); + sync_out_i <= sync_sig(sync_stages-1); -- rising edge detect sync_out <= sync_out_i and not sync_out_d; diff --git a/generic_ip/fire_pulse_manager/1/src/test/fire_pulse_manager_1_tb.vhd b/generic_ip/fire_pulse_manager/1/src/test/fire_pulse_manager_1_tb.vhd index 13189b4..12eca4f 100644 --- a/generic_ip/fire_pulse_manager/1/src/test/fire_pulse_manager_1_tb.vhd +++ b/generic_ip/fire_pulse_manager/1/src/test/fire_pulse_manager_1_tb.vhd @@ -48,9 +48,9 @@ architecture behav of fire_pulse_manager_1_tb is constant CLK_FREQ : real := 100.0e6; constant TX_CLK_PERIOD : time := CLK_PERIOD; -- nominally the same as clk_period - -- TODO Try different receive oversampling ratios - 300MHz is in the real system - constant RX_CLK_PERIOD : time := CLK_PERIOD / 3; -- clock period for used by the - -- UART-Rx on the POF + + 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 @@ -546,8 +546,8 @@ begin -- behav -- Config fire_pulse_manager control registers: -- Enable the POF-Rx addr := std_logic_vector(to_unsigned(3, 32)); - data := X"0000_8061"; -- set bit_div to 6 to match the 50MBd TX signal to the 300MHz RX_CLK - -- Write the data to the register + data := X"0000_8041"; + -- Write the data to the register mm_32b_write(addr, data, avs_s, avs_m); -- Select pulse generator addr := std_logic_vector(to_unsigned(2, 32)); diff --git a/generic_ip/fire_pulse_manager/1/src/uart_regen_1.vhd b/generic_ip/fire_pulse_manager/1/src/uart_regen_1.vhd index 40568f1..6fd265b 100644 --- a/generic_ip/fire_pulse_manager/1/src/uart_regen_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/uart_regen_1.vhd @@ -24,12 +24,10 @@ entity uart_regen_1 is port( reset_n : in std_logic; clk : in std_logic; - -- must all be synchronous to clk - bit_div : in std_logic_vector(3 downto 0); -- number of clock cycles per tx bit + bit_div : in std_logic_vector(3 downto 0); -- number of clock cycles per tx bit enable : in std_logic; bypass_en : in std_logic; - -- - uart_rx : in std_logic; -- will be on an unrelated, domain - typically one bit is 4 to 6 clk periods long + uart_rx : in std_logic; uart_tx : out std_logic); end entity uart_regen_1; @@ -62,6 +60,9 @@ begin async_in => uart_rx, sync_out => uart_rx_i); + -- NOTE : No NEED TO SYNCHRONIZE TO THE LOCAL CLOCK inputs enable, bypass_en + -- and bit_biv BECAUSE THOSE SIGNALS ARE PREDOMINANTLY STATIC + ----------------------------------------------------------------------------- -- UART registers and sequential logic ----------------------------------------------------------------------------- @@ -116,7 +117,7 @@ begin end process pFSM_SR; -- FSM Combinational Logic - pFSM_CL : process(all) + pFSM_CL : process(fsm_state_curr, uart_rx_i, end_of_bit, end_of_rx, clk_cnt, bit_div) begin --default assignments rst_clk_cnt <= '0'; diff --git a/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd b/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd index ab8a3c6..7980f24 100644 --- a/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd @@ -35,6 +35,17 @@ end entity uart_rx_1; architecture rtl of uart_rx_1 is + component sync_wire_1 + generic( + rst_val : std_logic; + sync_stages : positive); + port( + rstN : in std_logic; + clk : in std_logic; + async_in : in std_logic; + sync_out : out std_logic); + end component; + type fsm_state_t is (s_init, s_idle, s_get_start_bit, s_get_data, s_get_stop_bit); signal fsm_state_curr, fsm_state_next : fsm_state_t; @@ -53,7 +64,7 @@ begin -- Input Synchronization ----------------------------------------------------------------------------- - iSYNC_IN : entity work.sync_wire_1 + iSYNC_IN : sync_wire_1 generic map( rst_val => '1', sync_stages => 3) @@ -170,6 +181,7 @@ begin end if; end if; + when others => null; end case; end process pFSM_CL; diff --git a/generic_ip/generic_versioning/doc/generic_versioning.json b/generic_ip/generic_versioning/doc/generic_versioning.json index a2c191e..d7268ce 100644 --- a/generic_ip/generic_versioning/doc/generic_versioning.json +++ b/generic_ip/generic_versioning/doc/generic_versioning.json @@ -4,7 +4,7 @@ "bus": "csr", "addr_width": "4", "description": "This block is the generic versioning", - "notes": "NB: this block is a key component that is parsed externally, and cannot be renamed with major number tags in order to be processed correctly. Therefore do not modify the source code for this block. If a change is required for a project then a whole new component will be necessary and this signed off in review by the embedded logic line manager.", + "notes" : "NB: this block is a key component that is parsed externally, and cannot be renamed with major number tags in order to be processed correctly. Therefore do not modify the source code for this block. If a change is required for a project then a whole new component will be necessary and this signed off in review by the embedded logic line manager.", "registers": { "ip_id": { "address": "0", From a7c73eba4dcdb569a9fb322178848da74e88e2fa Mon Sep 17 00:00:00 2001 From: Damian Smith Date: Tue, 28 May 2019 11:09:49 +0100 Subject: [PATCH 17/29] HMBFDHV-83 Testbench for fire pulse manager to run at 300MHz for rx_clk as this is the more typical case --- .../1/src/test/fire_pulse_manager_1_tb.vhd | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/generic_ip/fire_pulse_manager/1/src/test/fire_pulse_manager_1_tb.vhd b/generic_ip/fire_pulse_manager/1/src/test/fire_pulse_manager_1_tb.vhd index 12eca4f..13189b4 100644 --- a/generic_ip/fire_pulse_manager/1/src/test/fire_pulse_manager_1_tb.vhd +++ b/generic_ip/fire_pulse_manager/1/src/test/fire_pulse_manager_1_tb.vhd @@ -48,9 +48,9 @@ architecture behav of fire_pulse_manager_1_tb is constant CLK_FREQ : real := 100.0e6; constant TX_CLK_PERIOD : time := CLK_PERIOD; -- nominally the same as clk_period - - constant RX_CLK_PERIOD : time := 5.0 ns; -- clock period for used by the - -- UART-Rx on the POF + -- TODO Try different receive oversampling ratios - 300MHz is in the real system + constant RX_CLK_PERIOD : time := CLK_PERIOD / 3; -- 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 @@ -546,8 +546,8 @@ begin -- behav -- Config fire_pulse_manager control registers: -- Enable the POF-Rx addr := std_logic_vector(to_unsigned(3, 32)); - data := X"0000_8041"; - -- Write the data to the register + data := X"0000_8061"; -- set bit_div to 6 to match the 50MBd TX signal to the 300MHz RX_CLK + -- Write the data to the register mm_32b_write(addr, data, avs_s, avs_m); -- Select pulse generator addr := std_logic_vector(to_unsigned(2, 32)); From a639532f544cc8e5155e548e5bd29688fef62a31 Mon Sep 17 00:00:00 2001 From: Damian Smith Date: Tue, 28 May 2019 13:09:08 +0100 Subject: [PATCH 18/29] HMBFDHV-83 Added a copy of the pof_tx_rx test bench from the SMB repository as it is important to be able to test that the POF receiver works properly. --- .../fire_pulse_manager/1/sim/sim_pof_txrx.do | 70 ++ .../fire_pulse_manager/1/sim/wave_pof_txrx.do | 233 +++++++ .../1/src/test/pof_tx_rx_1_tb.vhd | 623 ++++++++++++++++++ 3 files changed, 926 insertions(+) create mode 100644 generic_ip/fire_pulse_manager/1/sim/sim_pof_txrx.do create mode 100644 generic_ip/fire_pulse_manager/1/sim/wave_pof_txrx.do create mode 100644 generic_ip/fire_pulse_manager/1/src/test/pof_tx_rx_1_tb.vhd diff --git a/generic_ip/fire_pulse_manager/1/sim/sim_pof_txrx.do b/generic_ip/fire_pulse_manager/1/sim/sim_pof_txrx.do new file mode 100644 index 0000000..95c42a4 --- /dev/null +++ b/generic_ip/fire_pulse_manager/1/sim/sim_pof_txrx.do @@ -0,0 +1,70 @@ +# Simulation macro Net-Sync testbench + +.main clear + +set COMP_ONLY 0 + +set TB_PATH ./../src/test +set COMMON_PATH ../../../common/0/src +set OSVVM_PATH $COMMON_PATH/test/OSVVM + +set WORKLIB work + +vlib ./work +vmap work ./work + +if {$COMP_ONLY == 0} { +# Compile the constrained random related packages + vlib OSVVM + vcom -2008 -work OSVVM \ + $OSVVM_PATH/RandomBasePkg.vhd \ + $OSVVM_PATH/SortListPkg_int.vhd \ + $OSVVM_PATH/RandomPkg.vhd \ + $OSVVM_PATH/NamePkg.vhd \ + $OSVVM_PATH/MessagePkg.vhd \ + $OSVVM_PATH/CoveragePkg.vhd +} + +# compile the UUTs: +#vcom -2008 -work $WORKLIB $COMMON_PATH/pkg_functions.vhd +vcom -2008 -work $WORKLIB ../src/sync_wire_1.vhd +vcom -2008 -work $WORKLIB ../src/sync_wire_redge_1.vhd +vcom -2008 -work $WORKLIB ../src/uart_rx_1.vhd +vcom -2008 -work $WORKLIB ../src/pof_rx_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 + # in fire pulse manager, the tx components are part of the testbench + vcom -2008 -work $WORKLIB $TB_PATH/fifo_16x8_1.vhd + vcom -2008 -work $WORKLIB $TB_PATH/pof_tx_1.vhd + vcom -2008 -work $WORKLIB $TB_PATH/uart_tx_1.vhd + vcom -2008 -work $WORKLIB $TB_PATH/pof_tx_rx_1_tb.vhd + + vsim -t ps work.pof_tx_rx_1_tb + + #add wave /pof_tx_rx_tb/* + #add wave /pof_tx_rx_tb/iPOF_TX/* + #add wave /pof_tx_rx_tb/iPOF_RX/* + + # remove warnings from standard numeric/arithmetic packages (speed-up simulation) + set StdArithNoWarnings 1 + set NumericStdNoWarnings 1 + + do wave_pof_txrx.do + + when -label end_of_simulation {test_completed == true} {echo "Simulation Completed"; stop ;} + run -all + + #run 1 ms; +} + + + + diff --git a/generic_ip/fire_pulse_manager/1/sim/wave_pof_txrx.do b/generic_ip/fire_pulse_manager/1/sim/wave_pof_txrx.do new file mode 100644 index 0000000..a0e1081 --- /dev/null +++ b/generic_ip/fire_pulse_manager/1/sim/wave_pof_txrx.do @@ -0,0 +1,233 @@ +onerror {resume} +quietly WaveActivateNextPane {} 0 +add wave -noupdate /pof_tx_rx_1_tb/clk +add wave -noupdate /pof_tx_rx_1_tb/reset_n +add wave -noupdate /pof_tx_rx_1_tb/avs_read +add wave -noupdate /pof_tx_rx_1_tb/avs_write +add wave -noupdate /pof_tx_rx_1_tb/sel_slave_0 +add wave -noupdate /pof_tx_rx_1_tb/sel_slave_1 +add wave -noupdate /pof_tx_rx_1_tb/avs_write_sl0 +add wave -noupdate /pof_tx_rx_1_tb/avs_read_sl0 +add wave -noupdate /pof_tx_rx_1_tb/avs_readdatavalid_sl0 +add wave -noupdate /pof_tx_rx_1_tb/avs_write_sl1 +add wave -noupdate /pof_tx_rx_1_tb/avs_read_sl1 +add wave -noupdate /pof_tx_rx_1_tb/avs_readdatavalid_sl1 +add wave -noupdate /pof_tx_rx_1_tb/init_tx +add wave -noupdate /pof_tx_rx_1_tb/init_rx +add wave -noupdate /pof_tx_rx_1_tb/dir_in +add wave -noupdate /pof_tx_rx_1_tb/pd_in +add wave -noupdate /pof_tx_rx_1_tb/inc_pos +add wave -noupdate /pof_tx_rx_1_tb/dec_pos +add wave -noupdate -radix decimal /pof_tx_rx_1_tb/abs_position +add wave -noupdate /pof_tx_rx_1_tb/tx_data +add wave -noupdate /pof_tx_rx_1_tb/rx_data +add wave -noupdate /pof_tx_rx_1_tb/init_out +add wave -noupdate /pof_tx_rx_1_tb/dir_out +add wave -noupdate /pof_tx_rx_1_tb/enc_out +add wave -noupdate /pof_tx_rx_1_tb/pd_out +add wave -noupdate /pof_tx_rx_1_tb/inc_pos_out +add wave -noupdate /pof_tx_rx_1_tb/dec_pos_out +add wave -noupdate -radix decimal /pof_tx_rx_1_tb/abs_pos_out +add wave -noupdate /pof_tx_rx_1_tb/test_completed +add wave -noupdate /pof_tx_rx_1_tb/running +add wave -noupdate /pof_tx_rx_1_tb/configuring +add wave -noupdate /pof_tx_rx_1_tb/passed +add wave -noupdate /pof_tx_rx_1_tb/failed +add wave -noupdate /pof_tx_rx_1_tb/stimuli_completed +add wave -noupdate /pof_tx_rx_1_tb/avs_address +add wave -noupdate -radix hexadecimal /pof_tx_rx_1_tb/avs_writedata +add wave -noupdate -radix hexadecimal /pof_tx_rx_1_tb/avs_readdata_sl0 +add wave -noupdate -radix hexadecimal /pof_tx_rx_1_tb/avs_readdata_sl1 +add wave -noupdate -radix decimal /pof_tx_rx_1_tb/abs_position_d +add wave -noupdate -radix decimal /pof_tx_rx_1_tb/swathe_pos +add wave -noupdate /pof_tx_rx_1_tb/swathe_cnt +add wave -noupdate -radix hexadecimal /pof_tx_rx_1_tb/avs_m +add wave -noupdate -radix hexadecimal /pof_tx_rx_1_tb/avs_s +add wave -noupdate /pof_tx_rx_1_tb/detected_error +add wave -noupdate /pof_tx_rx_1_tb/dir_discr_cnt +add wave -noupdate /pof_tx_rx_1_tb/pd_discr_cnt +add wave -noupdate /pof_tx_rx_1_tb/pd_in_cnt +add wave -noupdate /pof_tx_rx_1_tb/pd_out_cnt +add wave -noupdate -radix decimal /pof_tx_rx_1_tb/abs_position +add wave -noupdate -radix decimal /pof_tx_rx_1_tb/abs_pos_out +add wave -noupdate /pof_tx_rx_1_tb/pos_discr_cnt +add wave -noupdate /pof_tx_rx_1_tb/end_of_swathe +add wave -noupdate /pof_tx_rx_1_tb/enc_pulse_cnt +add wave -noupdate /pof_tx_rx_1_tb/dir_err +add wave -noupdate /pof_tx_rx_1_tb/pd_err +add wave -noupdate /pof_tx_rx_1_tb/pos_err +add wave -noupdate /pof_tx_rx_1_tb/enc_err +add wave -noupdate /pof_tx_rx_1_tb/ovfl_err +add wave -noupdate /pof_tx_rx_1_tb/injected_errors +add wave -noupdate /pof_tx_rx_1_tb/max_pos +add wave -noupdate /pof_tx_rx_1_tb/min_pos +add wave -noupdate /pof_tx_rx_1_tb/exp_enc_pulse +add wave -noupdate /pof_tx_rx_1_tb/enc_discr +add wave -noupdate /pof_tx_rx_1_tb/exp_enc_cnt +add wave -noupdate /pof_tx_rx_1_tb/error_rate_thres +add wave -noupdate /pof_tx_rx_1_tb/one_pps +add wave -noupdate /pof_tx_rx_1_tb/max_error_flag +add wave -noupdate /pof_tx_rx_1_tb/rx_watchdog +add wave -noupdate /pof_tx_rx_1_tb/rx_watchdog_en +add wave -noupdate /pof_tx_rx_1_tb/rx_watchdog_clr +add wave -noupdate -divider EMB2POF +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/reset_n +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/clk +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/init +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/pd_in +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/inc_pos +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/dec_pos +add wave -noupdate -radix decimal /pof_tx_rx_1_tb/iPOF_TX/abs_position +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/tx_data +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/avs_address +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/avs_write +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/avs_writedata +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/avs_read +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/avs_readdatavalid +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/avs_readdata +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/rd_event +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/wr_event +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/empty +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/full +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/tx_ready +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/rd_event_d +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/wr_event_i +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/enable +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/toggle_sync +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/toggle_pd +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/add_keepalive +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/ovfl_err +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/init_d +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/init_gen +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/init_v +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/init_blocked +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/init_blk_cnt +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/parity_bit +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/inject_error +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/inject_error_req +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/pd_event +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/pd_event_d +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/pd_event_dd +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/gray +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/clear +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/pd_in_d +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/pd_gen +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/clk +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/symbol_valid +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/symbol +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/tx_data +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/event_in_i +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/event_in +add wave -noupdate /pof_tx_rx_1_tb/iPOF_TX/event_out +add wave -noupdate -radix decimal /pof_tx_rx_1_tb/iPOF_TX/keepalive_cnt +add wave -noupdate -divider POF2HMB +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/reset_n +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/clk +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/init +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/rx_clk +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/rx_data +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/init_out +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/enc_out +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/pd_out +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/inc_pos +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/dec_pos +add wave -noupdate -radix decimal /pof_tx_rx_1_tb/iPOF_RX/abs_pos +add wave -noupdate -radix unsigned /pof_tx_rx_1_tb/iPOF_RX/error_rate_thres +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/one_pps +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/max_error_flag +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/rx_watchdog +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/rx_watchdog_en +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/rx_watchdog_clr +add wave -noupdate -radix unsigned /pof_tx_rx_1_tb/iPOF_RX/rx_wd_cnt +add wave -noupdate -radix unsigned /pof_tx_rx_1_tb/iPOF_RX/error_rate_cnt +add wave -noupdate -radix unsigned /pof_tx_rx_1_tb/iPOF_RX/error_rate +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/clear +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/clear_i +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/inc_pos_i +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/dec_pos_i +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/enable +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/sync_gen +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/pd_gen +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/symbol_error +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/rx_symbol_val +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/rx_symbol +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/rx_symbol_val_v +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/symbol_valid_i +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/symbol_valid_d +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/toggle_sync +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/sync_confirmed +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/sync_toggle_test +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/sync +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/toggle_pd +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/pd_confirmed +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/pd_toggle_test +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/pd +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/valid_pos +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/upd_pos +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/corr_done +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/corr_sign +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/skip_cnt +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/skip_pos +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/symbol_valid +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/symbol +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/apply_corr +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/clk_cnt +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/dist +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/abs_dist +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/next_pos_lsb +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/curr_pos_lsb +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/pos_corr +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/max_dist +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/gray_pos +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/symbol_i +add wave -noupdate -radix unsigned /pof_tx_rx_1_tb/iPOF_RX/parity_err_cnt +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/enc_out +add wave -noupdate -radix decimal /pof_tx_rx_1_tb/iPOF_RX/abs_pos_i +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/inc_pos_ii +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/dec_pos_ii +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/new_max +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/new_min +add wave -noupdate -radix decimal /pof_tx_rx_1_tb/iPOF_RX/pos_max +add wave -noupdate -radix decimal /pof_tx_rx_1_tb/iPOF_RX/pos_min +add wave -noupdate -radix decimal /pof_tx_rx_1_tb/iPOF_RX/dist_pos +add wave -noupdate -radix decimal /pof_tx_rx_1_tb/iPOF_RX/dist_neg +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/data_width +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/reset_n +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/clk +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/bit_div +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/init +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/data_out +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/data_out_valid +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/rx_data +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/fsm_state_curr +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/fsm_state_next +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/rx_data_i +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/shf_data +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/rst_bit_cnt +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/inc_bit_cnt +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/rst_clk_cnt +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/end_of_bit +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/end_of_rx +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/data_valid +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/stop_bit +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/data +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/clk_cnt +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/bit_cnt +TreeUpdate [SetDefaultTree] +WaveRestoreCursors {{Cursor 1} {50645000 ps} 0} +quietly wave cursor active 1 +configure wave -namecolwidth 305 +configure wave -valuecolwidth 100 +configure wave -justifyvalue left +configure wave -signalnamewidth 0 +configure wave -snapdistance 10 +configure wave -datasetprefix 0 +configure wave -rowmargin 4 +configure wave -childrowmargin 2 +configure wave -gridoffset 0 +configure wave -gridperiod 1 +configure wave -griddelta 40 +configure wave -timeline 0 +configure wave -timelineunits ps +update +WaveRestoreZoom {28241650818 ps} {29022971010 ps} diff --git a/generic_ip/fire_pulse_manager/1/src/test/pof_tx_rx_1_tb.vhd b/generic_ip/fire_pulse_manager/1/src/test/pof_tx_rx_1_tb.vhd new file mode 100644 index 0000000..38da67b --- /dev/null +++ b/generic_ip/fire_pulse_manager/1/src/test/pof_tx_rx_1_tb.vhd @@ -0,0 +1,623 @@ +------------------------------------------------------------------------------- +-- Title : pof_tx_rx_tb +-- Project : HMB daisy-chaining +------------------------------------------------------------------------------- +-- File : pof_tx_rx_tb.vhd +-- Author : GMG +-- Company : Global Inkjet Systems +-- Created : 2017-08-29 +-- Last update: 2018-07-03 +-- SVN ID : Git +-- Standard : VHDL'2008 +------------------------------------------------------------------------------- +-- Description: +-- Testbench for verifying the transmission over the POF with emb2poftx and +-- pofrx2hmb blocks +------------------------------------------------------------------------------- + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +library OSVVM; +use OSVVM.RandomBasePkg.all; +use OSVVM.RandomPkg.all; + +use work.log_pkg.all; +use work.avalon_verify_pkg.all; + +use work.log_pkg.all; + +entity pof_tx_rx_1_tb is + -- .. +end entity pof_tx_rx_1_tb; + +architecture behav of pof_tx_rx_1_tb is + + constant CLK_PERIOD : time := 10 ns; + constant RX_CLK_PERIOD : time := 5 ns; + + constant NUM_ITERATIONS : natural := 10; + constant SWATHE_LEN : integer := 1000; + constant START_DIR : std_logic := '0'; + constant INJECT_ERROR_PERC : natural := 4; -- percentage of injected errors + constant DISCR_THRES : natural := 1000; + constant TIME_INT : time := 800 ns; + + constant UART_BIT_DIV : std_logic_vector(3 downto 0) := "0100"; + + -- Logging Verbosity Level + constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM; + + signal clk, rx_clk, rx_clk_i, reset_n : std_logic := '0'; + signal avs_read, avs_write, sel_slave_0, sel_slave_1 : std_logic; + signal avs_write_sl0, avs_read_sl0, avs_readdatavalid_sl0 : std_logic; + signal avs_write_sl1, avs_read_sl1, avs_readdatavalid_sl1 : std_logic; + signal init_tx, init_rx, dir_in, pd_in, inc_pos, dec_pos : std_logic; + signal tx_data, rx_data, init_out, dir_out, enc_out : std_logic; + signal pd_out, inc_pos_out, dec_pos_out, end_of_swathe : std_logic; + -- + signal test_completed, running, configuring : boolean; + signal passed, failed, stimuli_completed : boolean; + signal detected_error : boolean := false; + -- + signal avs_address : std_logic_vector(2 downto 0); + signal avs_writedata : std_logic_vector(31 downto 0); + signal avs_readdata_sl0, avs_readdata_sl1 : std_logic_vector(31 downto 0); + signal abs_position, abs_position_d : std_logic_vector(31 downto 0); + signal abs_pos_out : std_logic_vector(31 downto 0); + -- + signal swathe_cnt, swathe_pos : integer; + signal dir_discr_cnt, pd_discr_cnt : integer; + signal pos_discr_cnt : integer; + signal pd_in_cnt, pd_out_cnt : integer; + signal enc_pulse_cnt : integer; + signal dir_err, pd_err, ovfl_err : std_logic; + signal pos_err, enc_err, dir_in_d : std_logic; + signal injected_errors : integer; + signal max_pos, min_pos : integer; + signal max_pos_d, min_pos_d : integer; + signal exp_enc_cnt : integer; + signal exp_enc_pulse, enc_discr : std_logic; + signal enc_out_d : std_logic; + signal error_rate_thres : std_logic_vector(7 downto 0); + signal one_pps : std_logic; + signal max_error_flag : std_logic; + signal rx_watchdog : std_logic; + signal rx_watchdog_en : std_logic; + signal rx_watchdog_clr : std_logic; + -- + signal enable_rx : std_logic; + signal parity_err_cnt : std_logic_vector(15 downto 0); + signal skip_pos_cnt : std_logic_vector(15 downto 0); + -- + signal avs_m : mm_m_rec_t; + signal avs_s : mm_s_rec_t; + + +begin -- architecture behav + + clk <= not clk after 0.5 * CLK_PERIOD; + + rx_clk_i <= not rx_clk_i after 0.5 * RX_CLK_PERIOD; + rx_clk <= rx_clk_i after 1 ns; + + ----------------------------------------------------------------------------- + -- UUTs + ----------------------------------------------------------------------------- + + iPOF_TX : entity work.pof_tx_1 + port map( + reset_n => reset_n, + clk => clk, + init => init_tx, + pd_in => pd_in, + inc_pos => inc_pos, + dec_pos => dec_pos, + abs_position => abs_position, + tx_data => tx_data, + avs_address => avs_address, + avs_write => avs_write_sl0, + avs_writedata => avs_writedata, + avs_read => avs_read_sl0, + avs_readdatavalid => avs_readdatavalid_sl0, + avs_readdata => avs_readdata_sl0); + + iPOF_RX : entity work.pof_rx_1 + port map( + reset_n => reset_n, + clk => clk, + init => init_rx, + rx_clk => rx_clk, + rx_data => rx_data, + init_out => init_out, + dp_dir => dir_in, + enc_out => enc_out, + pd_out => pd_out, + inc_pos => inc_pos_out, + dec_pos => dec_pos_out, + abs_pos => abs_pos_out, + enable => enable_rx, + bit_div => UART_BIT_DIV, + error_rate_thres => error_rate_thres, + one_pps => one_pps, + upd_max_pos => '0', + upd_min_pos => '0', + max_error_flag => max_error_flag, + rx_watchdog => rx_watchdog, + rx_watchdog_en => rx_watchdog_en, + rx_watchdog_clr => rx_watchdog_clr, + parity_err_cnt => parity_err_cnt, + skip_pos_cnt => skip_pos_cnt); + + --rx_data <= tx_data after 40 ns; + rx_data <= transport tx_data after 40 ns; + + ----------------------------------------------------------------------------- + -- UUT configuration and control + ----------------------------------------------------------------------------- + + clk_clk <= clk; + reset_reset_n <= reset_n; + + avs_s.mm_readdata <= avs_readdata_sl0 when sel_slave_0 = '1' else + avs_readdata_sl1 when sel_slave_1 = '1' else (others => '0'); + + avs_readdata_sl1 <= (others => '0'); + + avs_s.mm_readdatavalid <= avs_readdatavalid_sl0 when sel_slave_0 = '1' else + avs_readdatavalid_sl1 when sel_slave_1 = '1' else '0'; + + avs_readdatavalid_sl1 <= '0'; + + avs_s.mm_waitrequest <= '0'; + avs_s.use_readvalid <= true; + + avs_address <= avs_m.mm_address(avs_address'range); + avs_write <= avs_m.mm_write; + avs_writedata <= avs_m.mm_writedata; + avs_read <= avs_m.mm_read; + -- + avs_write_sl0 <= avs_write and sel_slave_0; + --avs_write_sl1 <= avs_write and sel_slave_1; + avs_write_sl1 <= '0'; + -- + avs_read_sl0 <= avs_read and sel_slave_0; + --avs_read_sl1 <= avs_read and sel_slave_1; + avs_read_sl1 <= '0'; + + -- 1-PPS generation: make it faster than 1-PPS for simulation reasons + pEMULATE_1PPS : process + begin + one_pps <= '0'; + for n in 1 to 99999 loop + wait until clk = '1' and clk'event; + end loop; -- 1 to 9999 + one_pps <= '1'; + wait until clk = '1' and clk'event; + end process pEMULATE_1PPS; + + pUUT_CTRL : process + variable addr : std_logic_vector(31 downto 0) := (others => '0'); + variable data : std_logic_vector(31 downto 0) := (others => '0'); + variable init_done : boolean := false; + variable fifo_level : integer; + begin + + enable_rx <= '0'; + -- + rx_watchdog_en <= '0'; + rx_watchdog_clr <= '0'; + error_rate_thres <= X"0A"; + + sel_slave_0 <= '0'; + sel_slave_1 <= '0'; + + configuring <= true; + + -- initilialize the Avalon master-bus + mm_m_init(avs_m); + + if (reset_n = '0') then + wait until reset_n = '1'; + wait for 100 ns; + wait until clk = '1' and clk'event; + end if; + + log("Configuring EMB2POFTX ... ", VLOW, true); + sel_slave_0 <= '1'; + -- Config netfork_rx control registers: + -- disable the block + addr := std_logic_vector(to_unsigned(0, 32)); + data := X"0000_0021"; + mm_32b_write(addr, data, avs_s, avs_m); + + sel_slave_0 <= '0'; + sel_slave_1 <= '1'; + wait until clk = '1' and clk'event; + + log("Configuring POFRX2HMB ... ", VLOW, true); + -- Config netfork_rx control registers: + -- disable the block + addr := std_logic_vector(to_unsigned(0, 32)); + data := X"0000_0001"; + --mm_32b_write(addr, data, avs_s, avs_m); + enable_rx <= '1'; + rx_watchdog_en <= '1'; + + log("Configuration completed.", VLOW, true); + configuring <= false; + + wait; + + end process pUUT_CTRL; + + ----------------------------------------------------------------------------- + -- Stimuli Generation + ----------------------------------------------------------------------------- + + pSTIMULI_REGs : process(clk) + begin + if (clk = '1' and clk'event) then + abs_position_d <= abs_position; + end if; + end process pSTIMULI_REGs; + + inc_pos <= '1' when signed(abs_position) = signed(abs_position_d) + 1 else '0'; + dec_pos <= '1' when signed(abs_position) = signed(abs_position_d) - 1 else '0'; + + pSTIMULI : process + variable rv : RandomPType; + variable tmp_int : integer; + variable rand_time : time; + variable end_of_stimuli : boolean; + variable pd_dist : integer; + begin + + -- initialization + init_rx <= '0'; + -- + init_tx <= '0'; + dir_in <= START_DIR; + pd_in <= '0'; + abs_position <= (others => '0'); + swathe_pos <= 0; + pd_dist := 0; + -- + swathe_cnt <= 0; + stimuli_completed <= false; + end_of_swathe <= '0'; + + -- generating the stimulus + wait until running = true; + wait for 200 ns; + -- Send a Init/Sync pulse + wait until clk = '1' and clk'event; + init_tx <= '1'; + wait until clk = '1' and clk'event; + init_tx <= '0'; + wait for 500 ns; + -- Send a second init pulse and verify that it is ignored (because too + -- close to the previous) + wait until clk = '1' and clk'event; + init_tx <= '1'; + wait until clk = '1' and clk'event; + init_tx <= '0'; + wait for 2500 ns; + -- Send a third pulse (after a bigger interval from the previous). + -- Verify that this time the pulse is accepted + wait until clk = '1' and clk'event; + init_tx <= '1'; + wait until clk = '1' and clk'event; + init_tx <= '0'; + wait for 500 ns; + wait until clk = '1' and clk'event; + -- + -- generate the forward swathe + end_of_stimuli := false; + while end_of_stimuli = false loop + swathe_pos <= 0; + wait until clk = '1' and clk'event; + while swathe_pos /= SWATHE_LEN loop + -- generate a position increment + tmp_int := rv.RandInt(1, 100); + --tmp_int := 100; + if (tmp_int < 20) then + -- generate a position increment opposite to the swathe direction + swathe_pos <= swathe_pos - 1; + if (dir_in = '0') then + abs_position <= std_logic_vector(signed(abs_position) - 1); + else + abs_position <= std_logic_vector(signed(abs_position) + 1); + end if; + else + swathe_pos <= swathe_pos + 1; + if (dir_in = '0') then + abs_position <= std_logic_vector(signed(abs_position) + 1); + else + abs_position <= std_logic_vector(signed(abs_position) - 1); + end if; + end if; + -- + tmp_int := rv.RandInt(1, 100); + if (tmp_int <= 5 and pd_dist >= 10) then + pd_dist := 0; + -- generate a PD increment: the PD might be either concurren or not + -- to the position increment + tmp_int := rv.RandInt(1, 3); + case tmp_int is + when 2 => + -- wait less than the transmission time + wait for 90 ns; + wait until clk = '1' and clk'event; + when 3 => + -- wait more than the transmission time + wait for 290 ns; + wait until clk = '1' and clk'event; + when others => null; + end case; + pd_in <= '1'; + wait until clk = '1' and clk'event; + pd_in <= '0'; + end if; + pd_dist := pd_dist + 1; + rand_time := rv.RandInt(-25, 25) * (10 ns); + wait for TIME_INT + rand_time; + end loop; -- swathe_pos /= SWATHE_LEN + + wait for 25 us; + end_of_swathe <= '1'; + wait until clk = '1' and clk'event; + end_of_swathe <= '0'; + -- reverse direction + if (dir_in /= START_DIR) then + if (swathe_cnt = NUM_ITERATIONS) then + end_of_stimuli := true; + else + swathe_cnt <= swathe_cnt + 1; + end if; + end if; + if (end_of_stimuli = false) then + wait until clk = '1' and clk'event; + dir_in <= not dir_in; + -- Wait some time to make sure the change of direction is transmitted. + -- Note: if the position starts changing before the receiver was able to + -- confirm the change of direction, then some encoder pulses may not be + -- generated + wait for 1 us; + wait until clk = '1' and clk'event; + end if; + end loop; -- end_of_stimuli = false + + stimuli_completed <= true; + wait; + + end process pSTIMULI; + + ----------------------------------------------------------------------------- + -- Error injection + ----------------------------------------------------------------------------- + + -- Randomly change the payload of the data transmitted over the UART. + -- Insert 1, 2 or 3 errors per data word + -- Note: an error on the start bit of the UART will can cause more than 3 + -- errors per data word, therefore this error injection method does not cover + -- all the possible cases + + pERROR_INJECTION : process + -- + alias symbol_valid is <>; + alias symbol is <>; + -- + variable rv : RandomPType; + variable flip_vect : std_logic_vector(7 downto 0); + variable last_flip : std_logic_vector(7 downto 0); + variable bit_flips : integer range 0 to 3; + variable b0, b1, b2 : integer range 0 to 9; + variable exclude_1 : integer_vector(0 downto 0); + variable exclude_2 : integer_vector(1 downto 0); + variable test : std_logic_vector(5 downto 0); + begin + + injected_errors <= 0; + if (running /= true) then + wait until running = true; + end if; + + while running loop + wait until symbol_valid = '1' and symbol_valid'event; + if (rv.RandInt(1, 100) < INJECT_ERROR_PERC) then + -- Inject an error: + -- Number of bits to flip in the tx word + bit_flips := rv.RandInt(1, 3); + --bit_flips := 2; + b0 := rv.RandInt(0, 7); + exclude_1(0) := b0; + b1 := rv.RandInt(min => 0, max => 7, exclude => exclude_1); + exclude_2 := (0 => b0, 1 => b1); + b2 := rv.RandInt(min => 0, max => 7, exclude => exclude_2); + flip_vect := (others => '0'); + flip_vect(b0) := '1'; + if (bit_flips >= 2) then + flip_vect(b1) := '1'; + end if; + if (bit_flips = 3) then + flip_vect(b2) := '1'; + end if; + -- Prevent situations with two consecutive bit flips on bit 0,1 and 2 + if ((flip_vect(0) = '1' and last_flip(0) = '1') or (flip_vect(1) = '1' and last_flip(1) = '1') or (flip_vect(2) = '1' and last_flip(2) = '1')) then + flip_vect := (others => '0'); + end if; + log("bit-flip = " & to_string(bit_flips) & ", flip_vect = " & to_string(flip_vect) & ".", VLOW); + symbol <= force symbol xor flip_vect; + injected_errors <= injected_errors + 1; + wait until clk = '1' and clk'event; + wait until clk = '1' and clk'event; + symbol <= release; + last_flip := flip_vect; + else + last_flip := (others => '0'); + end if; + end loop; + + end process pERROR_INJECTION; + + ----------------------------------------------------------------------------- + -- Output Checking + ----------------------------------------------------------------------------- + + -- No more check on dir_out!!! + dir_out <= dir_in; + + pEVENT_MONITOR : process(clk) + begin + if (clk = '1' and clk'event) then + if (reset_n = '0' or init_tx = '1' or running = false or dir_in = dir_out) then + dir_discr_cnt <= 0; + elsif (dir_in /= dir_out) then + dir_discr_cnt <= dir_discr_cnt + 1; + end if; + if (reset_n = '0' or init_tx = '1' or running = false) then + dir_err <= '0'; + elsif (dir_discr_cnt > DISCR_THRES) then + dir_err <= '1'; + end if; + if (reset_n = '0' or init_tx = '1' or running = false) then + pd_in_cnt <= 0; + elsif (pd_in = '1') then + pd_in_cnt <= pd_in_cnt + 1; + end if; + if (reset_n = '0' or init_tx = '1' or running = false) then + pd_out_cnt <= 0; + elsif (pd_out = '1') then + pd_out_cnt <= pd_out_cnt + 1; + end if; + if (reset_n = '0' or init_tx = '1' or running = false or pd_in_cnt = pd_out_cnt) then + pd_discr_cnt <= 0; + elsif (pd_in_cnt /= pd_out_cnt) then + pd_discr_cnt <= pd_discr_cnt + 1; + end if; + if (reset_n = '0' or init_tx = '1' or running = false) then + pd_err <= '0'; + elsif (pd_discr_cnt > DISCR_THRES) then + pd_err <= '1'; + end if; + if (reset_n = '0' or init_tx = '1' or running = false or signed(abs_position) = signed(abs_pos_out)) then + pos_discr_cnt <= 0; + elsif (signed(abs_position) /= signed(abs_pos_out)) then + pos_discr_cnt <= pos_discr_cnt + 1; + end if; + if (reset_n = '0' or init_tx = '1' or running = false) then + pos_err <= '0'; + elsif (pos_discr_cnt > DISCR_THRES) then + pos_err <= '1'; + end if; + dir_in_d <= dir_in; + if (reset_n = '0' or init_tx = '1' or running = false or dir_in /= dir_in_d) then + enc_pulse_cnt <= 0; + elsif (enc_out = '1') then + enc_pulse_cnt <= enc_pulse_cnt + 1; + end if; + if (reset_n = '0' or init_tx = '1' or running = false) then + enc_err <= '0'; + elsif (end_of_swathe = '1' and enc_pulse_cnt /= SWATHE_LEN) then + enc_err <= '1'; + end if; + max_pos_d <= max_pos; + min_pos_d <= min_pos; + if ((dir_in = '0' and max_pos /= max_pos_d) or (dir_in = '1' and min_pos /= min_pos_d)) then + exp_enc_pulse <= '1'; + else + exp_enc_pulse <= '0'; + end if; + enc_out_d <= enc_out; + end if; + end process pEVENT_MONITOR; + + enc_discr <= enc_out_d xor exp_enc_pulse; + + pMIN_MAX_POS : process(reset_n, end_of_swathe, abs_pos_out) + begin + if (reset_n = '0' or end_of_swathe = '1') then + max_pos <= -SWATHE_LEN; + elsif (signed(abs_pos_out) > max_pos) then + max_pos <= to_integer(signed(abs_pos_out)); + end if; + if (reset_n = '0' or end_of_swathe = '1') then + min_pos <= SWATHE_LEN; + elsif (signed(abs_pos_out) < min_pos) then + min_pos <= to_integer(signed(abs_pos_out)); + end if; + end process pMIN_MAX_POS; + + exp_enc_cnt <= max_pos - min_pos; + + ovfl_err <= <>; + + pERR_DETECT : process(reset_n, clk) + begin + if (reset_n = '0') then + detected_error <= false; + elsif (clk = '1' and clk'event) then + --if(ovfl_err = '1' or dir_err = '1' or pd_err = '1' or pos_err = '1' or enc_err = '1') then + if (ovfl_err = '1' or dir_err = '1' or pd_err = '1' or pos_err = '1') then + detected_error <= true; + end if; + end if; + end process pERR_DETECT; + + + ----------------------------------------------------------------------------- + -- Testbench Control + ----------------------------------------------------------------------------- + + pTB_CTRL : process + begin + + -- Set the verbosity level for logging + set_log_verbosity(VERBOSITY_LEVEL); + set_log_verbosity(VHIGH); + + log_header("POF Transfer Tx/Rx verification:", VLOW); + + test_completed <= false; + running <= false; + passed <= false; + failed <= false; + + -- Reset + reset_n <= '0'; + wait for 100 ns; + wait until clk = '1' and clk'event; + reset_n <= '1'; + + if (configuring /= true) then + wait until configuring = true; + end if; + wait until configuring = false; + running <= true; + + wait until stimuli_completed = true or detected_error = true; + + if (stimuli_completed = true) then + -- wait enough time to make sure that a max length package can be propagated + wait for 20 us; + end if; + + if (detected_error = true) 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; From 381fd49d88f0373b900ae62816db7135f8667d73 Mon Sep 17 00:00:00 2001 From: Damian Smith Date: Fri, 31 May 2019 16:26:26 +0100 Subject: [PATCH 19/29] HMBFDHV-83 Also, corrected version numbers of components and fixed testbench so that it only checks registers which exist. Revert "WH-17 - Added Event-Logger to the Single-Channel FPM to enable enhanced verification/debugging of PD and Fire-Requests" This reverts commit ce8ad8615c979271e90de23a57e9a70df4c7c127. --- .../event_logger/0/doc/event_logger_0.json | 359 ------------------ .../event_logger/0/src/event_logger_0.vhd | 333 ---------------- .../event_logger/0/src/event_logger_0_pkg.vhd | 37 -- .../fire_pulse_manager/0/sim/com_fpm.do | 5 - .../0/src/fire_pulse_manager_0.vhd | 64 +--- .../fire_pulse_manager/1/doc/fpm_ctrl_1.json | 2 +- .../1/src/fire_pulse_ctrl_1.vhd | 160 ++++---- .../1/src/test/fire_pulse_manager_1_tb.vhd | 8 +- .../doc/generic_versioning.json | 2 +- .../1/doc/pulse_generator_1.json | 2 +- .../1/src/pulse_generator_1.vhd | 86 ++--- 11 files changed, 142 insertions(+), 916 deletions(-) delete mode 100644 generic_ip/event_logger/0/doc/event_logger_0.json delete mode 100644 generic_ip/event_logger/0/src/event_logger_0.vhd delete mode 100644 generic_ip/event_logger/0/src/event_logger_0_pkg.vhd diff --git a/generic_ip/event_logger/0/doc/event_logger_0.json b/generic_ip/event_logger/0/doc/event_logger_0.json deleted file mode 100644 index 669c547..0000000 --- a/generic_ip/event_logger/0/doc/event_logger_0.json +++ /dev/null @@ -1,359 +0,0 @@ -[{ - "ip_name": "event_logger_0", - "bus": "csr", - "description": "Event Logger (Slave)", - "registers": { - "ip_id" : { - "address" : "0", - "width" : "32", - "description" : "Unique ID for this IP block", - "fields": { - "ip_number" : { - "type" : "c", - "bit_len" : "8", - "reset" : "0x1B", - "description" : "IP identifier number" - }, - "mfr_number" : { - "type" : "c", - "bit_len" : "8", - "reset" : "0xFF", - "description" : "Manufacturer number" - - }, - "reserved" : { - "type" : "rsv", - "bit_len" : "16", - "description" : "Reserved bits" - } - } - }, - "ip_ver" : { - "address" : "1", - "width" : "32", - "description" : "IP Version", - "fields": { - "minor_number" : { - "type" : "c", - "bit_len" : "8", - "reset" : "0x01", - "description" : "Minor number" - }, - "major_number" : { - "type" : "c", - "bit_len" : "8", - "reset" : "0x00", - "description" : "Major number" - - }, - "reserved" : { - "type" : "rsv", - "bit_len" : "16", - "description" : "Reserved bits" - } - } - }, - "logger_ctrl" : { - "address" : "2", - "width" : "12", - "description" : "Logger control register", - "fields": { - "init" : { - "type" : "w", - "bit_len" : "1", - "reset" : "0x0", - "description" : "Logger init" - }, - "Reserved-0" : { - "type" : "rsv", - "bit_len" : "3", - "description" : "Reserved bits" - }, - "en_1pps_event" : { - "type" : "w", - "bit_len" : "1", - "reset" : "0x0", - "description" : "enable logging of 1-PPS events" - }, - "Reserved-1" : { - "type" : "rsv", - "bit_len" : "3", - "description" : "Reserved bits" - }, - "irq_en" : { - "type" : "w", - "bit_len" : "1", - "reset" : "0x0", - "description" : "IRQ enable" - - }, - "irq_clr" : { - "type" : "w", - "bit_len" : "1", - "reset" : "0x0", - "description" : "IRQ clear" - - }, - "irq_mask" : { - "type" : "w", - "bit_len" : "1", - "reset" : "0x0", - "description" : "IRQ mask" - - }, - "irq_value" : { - "type" : "r", - "bit_len" : "1", - "reset" : "0x0", - "description" : "IRQ value" - - } - } - }, - "src_sel" : { - "address" : "3", - "width" : "29", - "description" : "Source selection", - "fields": { - "src0_sel" : { - "type" : "w", - "bit_len" : "5", - "reset" : "0x0", - "description" : "Source-0 selection" - }, - "Reserved-0" : { - "type" : "rsv", - "bit_len" : "3", - "description" : "Reserved bits" - }, - "src1_sel" : { - "type" : "w", - "bit_len" : "5", - "reset" : "0x0", - "description" : "Source-1 selection" - }, - "Reserved-1" : { - "type" : "rsv", - "bit_len" : "3", - "description" : "Reserved bits" - }, - "src2_sel" : { - "type" : "w", - "bit_len" : "5", - "reset" : "0x0", - "description" : "Source-2 selection" - }, - "Reserved-2" : { - "type" : "rsv", - "bit_len" : "3", - "description" : "Reserved bits" - }, - "src3_sel" : { - "type" : "w", - "bit_len" : "5", - "reset" : "0x0", - "description" : "Source-3 selection" - } - } - }, - "src_cfg" : { - "address" : "4", - "width" : "28", - "description" : "Source configuration", - "fields": { - "ris_en_0" : { - "type" : "w", - "bit_len" : "1", - "reset" : "0x0", - "description" : "Enable rising-edge events on source 0" - }, - "fal_en_0" : { - "type" : "w", - "bit_len" : "1", - "reset" : "0x0", - "description" : "Enable falling-edge events on source 0" - }, - "mask_en_0" : { - "type" : "w", - "bit_len" : "1", - "reset" : "0x0", - "description" : "Mask events on source 0" - }, - "sync_en_0" : { - "type" : "w", - "bit_len" : "1", - "reset" : "0x0", - "description" : "Enable clock synchronization on source 0" - }, - "Reserved-0" : { - "type" : "rsv", - "bit_len" : "4", - "description" : "Reserved bits" - }, - "ris_en_1" : { - "type" : "w", - "bit_len" : "1", - "reset" : "0x0", - "description" : "Enable rising-edge events on source 1" - }, - "fal_en_1" : { - "type" : "w", - "bit_len" : "1", - "reset" : "0x0", - "description" : "Enable falling-edge events on source 1" - }, - "mask_en_1" : { - "type" : "w", - "bit_len" : "1", - "reset" : "0x0", - "description" : "Mask events on source 1" - }, - "sync_en_1" : { - "type" : "w", - "bit_len" : "1", - "reset" : "0x0", - "description" : "Enable clock synchronization on source 1" - }, - "Reserved-1" : { - "type" : "rsv", - "bit_len" : "4", - "description" : "Reserved bits" - }, - "ris_en_2" : { - "type" : "w", - "bit_len" : "1", - "reset" : "0x0", - "description" : "Enable rising-edge events on source 2" - }, - "fal_en_2" : { - "type" : "w", - "bit_len" : "1", - "reset" : "0x0", - "description" : "Enable falling-edge events on source 2" - }, - "mask_en_2" : { - "type" : "w", - "bit_len" : "1", - "reset" : "0x0", - "description" : "Mask events on source 2" - }, - "sync_en_2" : { - "type" : "w", - "bit_len" : "1", - "reset" : "0x0", - "description" : "Enable clock synchronization on source 2" - }, - "Reserved-2" : { - "type" : "rsv", - "bit_len" : "4", - "description" : "Reserved bits" - }, - "ris_en_3" : { - "type" : "w", - "bit_len" : "1", - "reset" : "0x0", - "description" : "Enable rising-edge events on source 3" - }, - "fal_en_3" : { - "type" : "w", - "bit_len" : "1", - "reset" : "0x0", - "description" : "Enable falling-edge events on source 3" - }, - "mask_en_3" : { - "type" : "w", - "bit_len" : "1", - "reset" : "0x0", - "description" : "Mask events on source 3" - }, - "sync_en_3" : { - "type" : "w", - "bit_len" : "1", - "reset" : "0x0", - "description" : "Enable clock synchronization on source 3" - } - } - }, - "log_fifo_mng": { - "address": "5", - "width": "32", - "description": "logger FIFO management", - "fields": { - "irq_gen_thres": { - "type": "w", - "bit_len": "15", - "reset": "0x0", - "description": "FIFO IRQ threshold" - }, - "reserved" : { - "type" : "rsv", - "bit_len" : "1", - "description" : "Reserved bits" - }, - "fifo_level": { - "type": "r", - "bit_len": "15", - "reset": "0x0", - "description": "fifo level" - }, - "fifo_overflow": { - "type": "r", - "bit_len": "1", - "reset": "0x0", - "description": "fifo overflow flag" - } - } - }, - "log_fifo_out-a": { - "type": "r", - "address": "6", - "reset": "0x0", - "width": "32", - "description": "Logger FIFO output-A (time-tag)" - }, - "log_fifo_out-b": { - "type": "r", - "address": "7", - "reset": "0x0", - "width": "32", - "description": "Logger FIFO output-B (position-tag)" - }, - "init_value": { - "type": "r", - "address": "8", - "reset": "0x0", - "width": "4", - "description": "Initial value when logging starts" - }, - "trigger_mng": { - "address": "9", - "width": "13", - "description": "External trigger management", - "fields": { - "ext_trig_en": { - "type": "w", - "bit_len": "1", - "reset": "0x0", - "description": "External trigger enable" - }, - "ext_trig_fal": { - "type": "w", - "bit_len": "1", - "reset": "0x0", - "description": "External triggers happens on the falling edge" - }, - "reserved" : { - "type" : "rsv", - "bit_len" : "6", - "description" : "Reserved bits" - }, - "ext_trig_src": { - "type": "w", - "bit_len": "5", - "reset": "0x0", - "description": "Select the source for the external trigger" - } - } - } - } -}] \ No newline at end of file diff --git a/generic_ip/event_logger/0/src/event_logger_0.vhd b/generic_ip/event_logger/0/src/event_logger_0.vhd deleted file mode 100644 index 2435c9c..0000000 --- a/generic_ip/event_logger/0/src/event_logger_0.vhd +++ /dev/null @@ -1,333 +0,0 @@ -------------------------------------------------------------------------------- --- Title : event_logger_0 --- Project : EMB -------------------------------------------------------------------------------- --- File : event_logger_0.vhd --- Author : Gianmarco Girau --- Company : Global Inkjet Systems --- Created : 2016-07-19 --- Last update: 2019-05-03 --- SVN ID : Git --- Standard : VHDL'93 -------------------------------------------------------------------------------- --- Description: --- The event logger block detects events (rising and/or falling edges) on a --- programmable set of inputs signals, attaches a time and position tag to --- each event, then stores that information on an output FIFO, to be read by the HPS. --- The time-tags use the fine time field of the EMB time counter. -------------------------------------------------------------------------------- - -library ieee; -use ieee.std_logic_1164.all; -use ieee.numeric_std.all; - -library work; -use work.common_pkg.all; -use work.event_logger_0_pkg.all; - -entity event_logger_0 is - generic( - FIFO_SIZE : natural := 1024); - port( - rstN : in std_logic; - clk : in std_logic; - data_src : in std_logic_vector(31 downto 0); - fine_time : in std_logic_vector(27 downto 0); - abs_position : in std_logic_vector(31 downto 0); - -- Interrupt Sender - ins_irq : out std_logic; - -- Avalon MM - avs_address : in std_logic_vector( 3 downto 0); - avs_write : in std_logic; - avs_writedata : in std_logic_vector(31 downto 0); - avs_read : in std_logic; - avs_readdatavalid : out std_logic; - avs_readdata : out std_logic_vector(31 downto 0)); -end event_logger_0; - -architecture RTL of event_logger_0 is - - -- constants - - constant LOG_IP_ID : std_logic_vector(31 downto 0) := x"0000FF1B"; - constant LOG_IP_VER : std_logic_vector(31 downto 0) := x"00000001"; - - -- - signal init, en_1pps_event, pulse_1pps, avs_read_i : std_logic; - signal mp_0, mp_1, mp_2, mp_3 : std_logic; - signal mp_0_i, mp_1_i, mp_2_i, mp_3_i : std_logic; - signal mp_0_d, mp_1_d, mp_2_d, mp_3_d : std_logic; - signal mp_sync_0, mp_sync_1, mp_sync_2, mp_sync_3 : std_logic; - signal mask_mp_0, mask_mp_1, mask_mp_2, mask_mp_3 : std_logic; - signal ris_en_0, ris_en_1, ris_en_2, ris_en_3 : std_logic; - signal fal_en_0, fal_en_1, fal_en_2, fal_en_3 : std_logic; - signal sync_en_0, sync_en_1, sync_en_2, sync_en_3 : std_logic; - signal irq_en, irq_clr, irq_mask, irq_val, irq, irq_d : std_logic; - signal fifo_rd_en, fifo_wr_en, fifo_full, fifo_error : std_logic; - signal time_event, log_event, trigger, trigger_d : std_logic; - signal event_detect_0, event_detect_1 : std_logic; - signal event_detect_2, event_detect_3 : std_logic; - signal ext_trg_en, ext_trg_fal, trigger_set : std_logic; - signal init_value : std_logic_vector( 3 downto 0); - signal ext_trg_src : std_logic_vector( 4 downto 0); - signal src_sel_0, src_sel_1, src_sel_2, src_sel_3 : std_logic_vector( 4 downto 0); - signal fifo_usedw, fifo_thres : std_logic_vector(log2(FIFO_SIZE)-1 downto 0); - signal fine_time_corrected : std_logic_vector(27 downto 0); - signal log_entry, fifo_q_a, fifo_q_b : std_logic_vector(31 downto 0); - -begin -- RTL - - ----------------------------------------------------------------------------- - -- Data source selection and event detection - ----------------------------------------------------------------------------- - - -- input synchronization (in case the input is asynchronous) - iSync_0 : entity work.sync_wire - generic map (rst_val => '0', sync_stages => 2) - port map (rstN => rstN, clk => clk, async_in => mp_0_i, sync_out => mp_sync_0); - - iSync_1 : entity work.sync_wire - generic map (rst_val => '0', sync_stages => 2) - port map (rstN => rstN, clk => clk, async_in => mp_1_i, sync_out => mp_sync_1); - - iSync_2 : entity work.sync_wire - generic map (rst_val => '0', sync_stages => 2) - port map (rstN => rstN, clk => clk, async_in => mp_2_i, sync_out => mp_sync_2); - - iSync_3 : entity work.sync_wire - generic map (rst_val => '0', sync_stages => 2) - port map (rstN => rstN, clk => clk, async_in => mp_3_i, sync_out => mp_sync_3); - - mp_0 <= mp_0_i when sync_en_0 = '0' else mp_sync_0; - mp_1 <= mp_1_i when sync_en_1 = '0' else mp_sync_1; - mp_2 <= mp_2_i when sync_en_2 = '0' else mp_sync_2; - mp_3 <= mp_3_i when sync_en_3 = '0' else mp_sync_3; - - pEventDetect : process(clk) - begin - if(clk = '1' and clk'event) then - mp_0_i <= data_src(to_integer(unsigned(src_sel_0))); - mp_1_i <= data_src(to_integer(unsigned(src_sel_1))); - mp_2_i <= data_src(to_integer(unsigned(src_sel_2))); - mp_3_i <= data_src(to_integer(unsigned(src_sel_3))); - mp_0_d <= mp_0; - mp_1_d <= mp_1; - mp_2_d <= mp_2; - mp_3_d <= mp_3; - trigger <= data_src(to_integer(unsigned(ext_trg_src))); - trigger_d <= trigger; - if(init = '1' or ext_trg_en = '0') then - trigger_set <= '0'; - elsif((ext_trg_fal = '0' and trigger = '1' and trigger_d = '0') or (ext_trg_fal = '1' and trigger = '0' and trigger_d = '1')) then - trigger_set <= '1'; - end if; - if(log_event = '1') then - log_entry <= event_detect_3 & event_detect_2 & event_detect_1 & event_detect_0 & (time_event & fine_time_corrected(26 downto 0)); - end if; - fifo_wr_en <= log_event and ((ext_trg_en and trigger_set) or not ext_trg_en); - if(init = '1') then - fifo_error <= '0'; - elsif(fifo_wr_en = '1' and fifo_full = '1') then - fifo_error <= '1'; - end if; - if(unsigned(fine_time) = 0) then - pulse_1pps <= '1'; - else - pulse_1pps <= '0'; - end if; - if(init = '1') then - init_value <= mp_3 & mp_2 & mp_1 & mp_0; - end if; - end if; - end process pEventDetect; - - event_detect_0 <= not mask_mp_0 and ((ris_en_0 and mp_0 and not mp_0_d) or (fal_en_0 and not mp_0 and mp_0_d)); - event_detect_1 <= not mask_mp_1 and ((ris_en_1 and mp_1 and not mp_1_d) or (fal_en_1 and not mp_1 and mp_1_d)); - event_detect_2 <= not mask_mp_2 and ((ris_en_2 and mp_2 and not mp_2_d) or (fal_en_2 and not mp_2 and mp_2_d)); - event_detect_3 <= not mask_mp_3 and ((ris_en_3 and mp_3 and not mp_3_d) or (fal_en_3 and not mp_3 and mp_3_d)); - time_event <= en_1pps_event and pulse_1pps; - - log_event <= event_detect_0 or event_detect_1 or event_detect_2 or event_detect_3 or time_event; - - - -- correct the fine time to take into account of the detection latency - fine_time_corrected <= std_logic_vector(unsigned(fine_time)-1); - - -- FIFO_A : Event Source and Time-Tag - iFIFO_A : entity work.sync_fifo - generic map( - FIFO_WIDTH => 32, - FIFO_DEPTH => FIFO_SIZE) - port map ( - clock => clk, - data => log_entry, - rdreq => fifo_rd_en, - sclr => init, - wrreq => fifo_wr_en, - empty => open, - full => fifo_full, - q => fifo_q_a, - usedw => fifo_usedw); - - -- FIFO_B: Position-Tag - iFIFO_B : entity work.sync_fifo - generic map( - FIFO_WIDTH => 32, - FIFO_DEPTH => FIFO_SIZE) - port map ( - clock => clk, - data => abs_position, - rdreq => fifo_rd_en, - sclr => init, - wrreq => fifo_wr_en, - empty => open, - full => open, - q => fifo_q_b, - usedw => open); - - fifo_rd_en <= '1' when avs_read = '1' and avs_address = LOG_FIFO_OUT_A_REG else '0'; - - -- IRQ generation and management - pIRQ : process(rstN, clk) - begin - if(rstN = '0') then - irq <= '0'; - irq_d <= '0'; - ins_irq <= '0'; - elsif(clk = '1' and clk'event) then - irq_d <= irq; - if(irq_clr = '1') then - irq <= '0'; - elsif(irq_en = '1' and (unsigned(fifo_usedw) >= unsigned(fifo_thres)) and irq_d = '0') then - irq <= '1'; - end if; - ins_irq <= irq_val; - end if; - end process pIRQ; - - irq_val <= irq and not irq_mask; - - ----------------------------------------------------------------------------- - -- C&S registers (Avalon-MM I/F) - ----------------------------------------------------------------------------- - - pCTRL_STATUS : process(rstN, clk) - begin - if(rstN = '0') then - avs_read_i <= '0'; - avs_readdatavalid <= '0'; - avs_readdata <= (others => '0'); - -- - init <= '0'; - en_1pps_event <= '0'; - mask_mp_0 <= '0'; - mask_mp_1 <= '0'; - mask_mp_2 <= '0'; - mask_mp_3 <= '0'; - ris_en_0 <= '0'; - fal_en_0 <= '0'; - ris_en_1 <= '0'; - fal_en_1 <= '0'; - ris_en_2 <= '0'; - fal_en_2 <= '0'; - ris_en_3 <= '0'; - fal_en_3 <= '0'; - sync_en_0 <= '0'; - sync_en_1 <= '0'; - sync_en_2 <= '0'; - sync_en_3 <= '0'; - src_sel_0 <= (others => '0'); - src_sel_1 <= (others => '0'); - src_sel_2 <= (others => '0'); - src_sel_3 <= (others => '0'); - irq_en <= '0'; - irq_clr <= '0'; - irq_mask <= '0'; - ext_trg_en <= '0'; - ext_trg_fal <= '0'; - ext_trg_src <= (others => '0'); - fifo_thres <= (others => '0'); - elsif(clk = '1' and clk'event) then - -- CTRL registers - if(avs_write = '1') then - case avs_address is - when LOG_CTRL_REG => - init <= avs_writedata( 0); - en_1pps_event <= avs_writedata( 4); - irq_en <= avs_writedata( 8); - irq_clr <= avs_writedata( 9); - irq_mask <= avs_writedata(10); - when LOG_SRC_SEL_REG => - src_sel_0 <= avs_writedata( 4 downto 0); - src_sel_1 <= avs_writedata(12 downto 8); - src_sel_2 <= avs_writedata(20 downto 16); - src_sel_3 <= avs_writedata(28 downto 24); - when LOG_SRC_CFG_REG => - ris_en_0 <= avs_writedata( 0); - fal_en_0 <= avs_writedata( 1); - mask_mp_0 <= avs_writedata( 2); - sync_en_0 <= avs_writedata( 3); - ris_en_1 <= avs_writedata( 8); - fal_en_1 <= avs_writedata( 9); - mask_mp_1 <= avs_writedata(10); - sync_en_1 <= avs_writedata(11); - ris_en_2 <= avs_writedata(16); - fal_en_2 <= avs_writedata(17); - mask_mp_2 <= avs_writedata(18); - sync_en_2 <= avs_writedata(19); - ris_en_3 <= avs_writedata(24); - fal_en_3 <= avs_writedata(25); - mask_mp_3 <= avs_writedata(26); - sync_en_3 <= avs_writedata(27); - when LOG_FIFO_CS_REG => - fifo_thres <= avs_writedata(fifo_thres'range); - when LOG_TRIGGER_CTRL_REG => - ext_trg_en <= avs_writedata( 0); - ext_trg_fal <= avs_writedata( 1); - ext_trg_src <= avs_writedata(12 downto 8); - when others => null; - end case; - end if; - - -- Read Ctrl & Status registers - avs_read_i <= avs_read; - -- Read valid is delayed of an additional clock cycle to take into - -- account for the FIFO latency - avs_readdatavalid <= avs_read_i; - if(avs_read_i = '1') then - case avs_address is - when LOG_IP_ID_ADDR => - avs_readdata <= LOG_IP_ID; - when LOG_IP_VER_ADDR => - avs_readdata <= LOG_IP_VER; - when LOG_CTRL_REG => - avs_readdata <= (0 => init, 4 => en_1pps_event, 8 => irq_en, 9 => irq_clr, 10 => irq_mask, 11 => irq_val, others => '0'); - when LOG_SRC_SEL_REG => - avs_readdata <= b"000" & src_sel_3 & b"000" & src_sel_2 & b"000" & src_sel_1 & b"000" & src_sel_0; - when LOG_SRC_CFG_REG => - avs_readdata( 7 downto 0) <= X"0" & sync_en_0 & mask_mp_0 & fal_en_0 & ris_en_0; - avs_readdata(15 downto 8) <= X"0" & sync_en_1 & mask_mp_1 & fal_en_1 & ris_en_1; - avs_readdata(23 downto 16) <= X"0" & sync_en_2 & mask_mp_2 & fal_en_2 & ris_en_2; - avs_readdata(31 downto 24) <= X"0" & sync_en_3 & mask_mp_3 & fal_en_3 & ris_en_3; - when LOG_FIFO_CS_REG => - avs_readdata(fifo_thres'high downto 0) <= fifo_thres; - avs_readdata(15 downto fifo_thres'high+1) <= (others => '0'); - avs_readdata(fifo_usedw'high+16 downto 16) <= fifo_usedw; - avs_readdata(30 downto fifo_usedw'high+17) <= (others => '0'); - avs_readdata(31) <= fifo_error; - when LOG_FIFO_OUT_A_REG => - avs_readdata <= fifo_q_a; - when LOG_FIFO_OUT_B_REG => - avs_readdata <= fifo_q_b; - when LOG_INIT_VAL_REG => - avs_readdata <= X"0000000" & init_value; - when LOG_TRIGGER_CTRL_REG => - avs_readdata <= X"0000" & b"000" & ext_trg_src & b"000000" & ext_trg_fal & ext_trg_en; - when others => - avs_readdata <= X"BAD1BAD0"; - end case; - end if; - end if; - end process pCTRL_STATUS; - -end RTL; diff --git a/generic_ip/event_logger/0/src/event_logger_0_pkg.vhd b/generic_ip/event_logger/0/src/event_logger_0_pkg.vhd deleted file mode 100644 index 5e2ab79..0000000 --- a/generic_ip/event_logger/0/src/event_logger_0_pkg.vhd +++ /dev/null @@ -1,37 +0,0 @@ -------------------------------------------------------------------------------- --- Title : event_logger_0_pkg --- Project : EMB -------------------------------------------------------------------------------- --- File : event_logger_0_pkg.vhd --- Author : Gianmarco Girau --- Company : Global Inkjet Systems --- Created : 2016-07-19 --- Last update: 2019-05-03 --- SVN ID : Git --- Standard : VHDL'93 -------------------------------------------------------------------------------- --- Description: --- The event logger block detects events (rising and/or falling edges) on a --- programmable set of inputs signals, attaches a time and position tag to --- each event, then stores that information on an output FIFO, to be read by the HPS. --- The time-tags use the fine time field of the EMB time counter. -------------------------------------------------------------------------------- - -library ieee; -use ieee.std_logic_1164.all; -use ieee.numeric_std.all; - -package event_logger_0_pkg is - - constant LOG_IP_ID_ADDR : std_logic_vector( 3 downto 0) := b"0000"; - constant LOG_IP_VER_ADDR : std_logic_vector( 3 downto 0) := b"0001"; - constant LOG_CTRL_REG : std_logic_vector( 3 downto 0) := b"0010"; - constant LOG_SRC_SEL_REG : std_logic_vector( 3 downto 0) := b"0011"; - constant LOG_SRC_CFG_REG : std_logic_vector( 3 downto 0) := b"0100"; - constant LOG_FIFO_CS_REG : std_logic_vector( 3 downto 0) := b"0101"; - constant LOG_FIFO_OUT_A_REG : std_logic_vector( 3 downto 0) := b"0110"; - constant LOG_FIFO_OUT_B_REG : std_logic_vector( 3 downto 0) := b"0111"; - constant LOG_INIT_VAL_REG : std_logic_vector( 3 downto 0) := b"1000"; - constant LOG_TRIGGER_CTRL_REG : std_logic_vector( 3 downto 0) := b"1001"; - -end package event_logger_0_pkg; diff --git a/generic_ip/fire_pulse_manager/0/sim/com_fpm.do b/generic_ip/fire_pulse_manager/0/sim/com_fpm.do index 11c3958..5e9fca5 100644 --- a/generic_ip/fire_pulse_manager/0/sim/com_fpm.do +++ b/generic_ip/fire_pulse_manager/0/sim/com_fpm.do @@ -14,7 +14,6 @@ set COMMON_PATH ../../../common/0/src set SEQUENCER_PATH ../../../generic_sequencer/15/src set PULSE_GEN_PATH ../../../pulse_generator/1/src set EMUL_PATH ../../../enc_pd_emul/1/src -set LOG_PATH ../../../event_logger/0/src set WORKLIB work @@ -45,10 +44,6 @@ vcom -2008 -work $WORKLIB $PULSE_GEN_PATH/pulse_generator_1.vhd vcom -2008 -work $WORKLIB $EMUL_PATH/enc_pd_emul_1_pkg.vhd vcom -2008 -work $WORKLIB $EMUL_PATH/enc_pd_emul_1.vhd -# Event Logger -vcom -2008 -work $WORKLIB $LOG_PATH/event_logger_0_pkg.vhd -vcom -2008 -work $WORKLIB $LOG_PATH/event_logger_0.vhd - # Fire-Pulse-Manager vcom -2008 -work $WORKLIB $COMMON_PATH/cs_bus_itf.vhd vcom -2008 -work $WORKLIB $COMMON_PATH/uart_rx.vhd diff --git a/generic_ip/fire_pulse_manager/0/src/fire_pulse_manager_0.vhd b/generic_ip/fire_pulse_manager/0/src/fire_pulse_manager_0.vhd index 9298412..6c3c78a 100644 --- a/generic_ip/fire_pulse_manager/0/src/fire_pulse_manager_0.vhd +++ b/generic_ip/fire_pulse_manager/0/src/fire_pulse_manager_0.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2017-09-06 --- Last update: 2019-05-13 +-- Last update: 2019-03-22 -- SVN ID : Git -- Standard : VHDL'08 ------------------------------------------------------------------------------- @@ -23,9 +23,6 @@ library work; use work.fire_pulse_0_pkg.all; entity fire_pulse_manager_0 is - generic( - ADD_EVENT_LOGGER : boolean := false; - LOG_FIFO_SIZE : natural range 256 to 4096 := 1024); port( reset_n : in std_logic; clk : in std_logic; -- 100MHz @@ -137,7 +134,6 @@ architecture rtl of fire_pulse_manager_0 is signal src_sel : std_logic_vector( 1 downto 0); -- signal one_pps : std_logic; - signal log_data_src : std_logic_vector(15 downto 0); begin @@ -441,54 +437,14 @@ begin -- Event Logger ----------------------------------------------------------------------------- - gEL0: if ADD_EVENT_LOGGER = false generate - - pLOGGER_RD : process(clk) - begin - if(clk = '1' and clk'event) then - cs_log_read_valid <= cs_log_read_en; - end if; - end process pLOGGER_RD; - - cs_log_read_data <= X"DEAD_BEEF"; - - end generate gEL0; - - gEL1: if ADD_EVENT_LOGGER = false generate - - event_logger_0_1: entity work.event_logger_0 - generic map ( - FIFO_SIZE => LOG_FIFO_SIZE) - port map ( - rstN => reset_n_i, - clk => clk, - data_src => log_data_src, - fine_time => fine_time, - abs_position => abs_pos, - ins_irq => open, - avs_address => cs_addr(3 downto 0), - avs_write => cs_log_write_en, - avs_writedata => cs_write_data, - avs_read => cs_log_read_en, - avs_readdatavalid => cs_log_read_valid, - avs_readdata => cs_log_read_data); - - log_data_src(0) <= init; - log_data_src(1) <= dp_dir; - log_data_src(2) <= pd_pulse; - log_data_src(3) <= enc_pulse; - log_data_src(4) <= ch_pd; - log_data_src(5) <= ch_pulse_out; - log_data_src(6) <= ch_raw_pulse; - log_data_src(7) <= ch_mask; - log_data_src(8) <= pof_rx; - log_data_src(9) <= fire_pulse_i; - log_data_src(10) <= inc_pos; - log_data_src(11) <= dec_pos; - log_data_src(12) <= filtered_pd; - -- - log_data_src(15 downto 13) <= (others => '0'); - - end generate gEL1; + -- Not instantiated yet + pLOGGER_RD : process(clk) + begin + if(clk = '1' and clk'event) then + cs_log_read_valid <= cs_log_read_en; + end if; + end process pLOGGER_RD; + + cs_log_read_data <= X"DEAD_BEEF"; end architecture rtl; diff --git a/generic_ip/fire_pulse_manager/1/doc/fpm_ctrl_1.json b/generic_ip/fire_pulse_manager/1/doc/fpm_ctrl_1.json index ec932f6..0bb3b6b 100644 --- a/generic_ip/fire_pulse_manager/1/doc/fpm_ctrl_1.json +++ b/generic_ip/fire_pulse_manager/1/doc/fpm_ctrl_1.json @@ -36,7 +36,7 @@ "minor_number" : { "type" : "c", "bit_len" : "8", - "reset" : "0x02", + "reset" : "0x01", "description" : "Minor number" }, "major_number" : { diff --git a/generic_ip/fire_pulse_manager/1/src/fire_pulse_ctrl_1.vhd b/generic_ip/fire_pulse_manager/1/src/fire_pulse_ctrl_1.vhd index 91ed17a..494e9b3 100644 --- a/generic_ip/fire_pulse_manager/1/src/fire_pulse_ctrl_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/fire_pulse_ctrl_1.vhd @@ -22,21 +22,21 @@ entity fire_pulse_ctrl_1 is port( reset_n : in std_logic; clk : in std_logic; - src_sel : out std_logic_vector( 1 downto 0); + src_sel : out std_logic_vector(1 downto 0); uart_regen_bypass : out std_logic; upd_max_pos : out std_logic; upd_min_pos : out std_logic; enable_rx : out std_logic; - uart_bit_div : out std_logic_vector( 3 downto 0); - error_rate_thres : out std_logic_vector( 7 downto 0); + uart_bit_div : out std_logic_vector(3 downto 0); + error_rate_thres : out std_logic_vector(7 downto 0); max_error_flag : in std_logic; rx_watchdog : in std_logic; rx_watchdog_en : out std_logic; rx_watchdog_clr : out std_logic; parity_err_cnt : in std_logic_vector(15 downto 0); skip_pos_cnt : in std_logic_vector(15 downto 0); - mon_point_src : in std_logic_vector(15 downto 0); - mon_points : out std_logic_vector( 3 downto 0); + mon_point_src : in std_logic_vector(15 downto 0); + mon_points : out std_logic_vector(3 downto 0); coarse_time : out std_logic_vector(31 downto 0); fine_time : out std_logic_vector(27 downto 0); one_pps : out std_logic; @@ -45,7 +45,7 @@ entity fire_pulse_ctrl_1 is -- Interrupt Senders ins_fpm_irq_0 : out std_logic; -- Avalon MM Interface - avs_address : in std_logic_vector( 3 downto 0); + avs_address : in std_logic_vector(3 downto 0); avs_write : in std_logic; avs_writedata : in std_logic_vector(31 downto 0); avs_read : in std_logic; @@ -58,41 +58,41 @@ architecture rtl of fire_pulse_ctrl_1 is ----------------------------------------------------------------------------- -- Control & Status Registers Map ----------------------------------------------------------------------------- - constant CSR_IP_ID : std_logic_vector(31 downto 0) := x"0000FF14"; - constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000100"; + constant CSR_IP_ID : std_logic_vector(31 downto 0) := x"0000FF14"; + constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000101"; - constant CSR_IP_ID_REG : std_logic_vector( 3 downto 0) := b"0000"; - constant CSR_IP_VER_REG : std_logic_vector( 3 downto 0) := b"0001"; - constant SRC_SEL_REG : std_logic_vector( 3 downto 0) := b"0010"; - constant POF_RX_CTRL : std_logic_vector( 3 downto 0) := b"0011"; - constant MON_PT_CTRL_REG : std_logic_vector( 3 downto 0) := b"0100"; - constant COARSE_TIME_INIT_REG : std_logic_vector( 3 downto 0) := b"0101"; - constant FINE_TIME_INIT_REG : std_logic_vector( 3 downto 0) := b"0110"; - constant FINE_TIME_REG : std_logic_vector( 3 downto 0) := b"0111"; - constant COARSE_TIME_REG : std_logic_vector( 3 downto 0) := b"1000"; - constant RX_ERROR_STATUS : std_logic_vector( 3 downto 0) := b"1001"; - constant RX_ERROR_CSR : std_logic_vector( 3 downto 0) := b"1010"; - constant IRQ_MNG_REG : std_logic_vector( 3 downto 0) := b"1011"; - constant EXT_FP_CTRL_REG : std_logic_vector( 3 downto 0) := b"1100"; + constant CSR_IP_ID_REG : std_logic_vector(3 downto 0) := b"0000"; + constant CSR_IP_VER_REG : std_logic_vector(3 downto 0) := b"0001"; + constant SRC_SEL_REG : std_logic_vector(3 downto 0) := b"0010"; + constant POF_RX_CTRL : std_logic_vector(3 downto 0) := b"0011"; + constant MON_PT_CTRL_REG : std_logic_vector(3 downto 0) := b"0100"; + constant COARSE_TIME_INIT_REG : std_logic_vector(3 downto 0) := b"0101"; + constant FINE_TIME_INIT_REG : std_logic_vector(3 downto 0) := b"0110"; + constant FINE_TIME_REG : std_logic_vector(3 downto 0) := b"0111"; + constant COARSE_TIME_REG : std_logic_vector(3 downto 0) := b"1000"; + constant RX_ERROR_STATUS : std_logic_vector(3 downto 0) := b"1001"; + constant RX_ERROR_CSR : std_logic_vector(3 downto 0) := b"1010"; + constant IRQ_MNG_REG : std_logic_vector(3 downto 0) := b"1011"; + constant EXT_FP_CTRL_REG : std_logic_vector(3 downto 0) := b"1100"; ----------------------------------------------------------------------------- -- Constants, Signals ----------------------------------------------------------------------------- - constant FINE_TIME_TC : integer := 100000000-1; -- clk must be 100MHz to - -- make it right + constant FINE_TIME_TC : integer := 100000000 - 1; -- clk must be 100MHz to + -- make it right signal enable_rx_i : std_logic; signal fine_time_wrap, time_ld_en : std_logic; signal rx_watchdog_en_i, rx_watchdog_clr_i : std_logic; signal uart_regen_bypass_i : std_logic; signal upd_min_pos_i, upd_max_pos_i : std_logic; - signal irq, irq_src, irq_src_d : std_logic_vector( 0 downto 0); - signal irq_en, irq_mask, irq_val, irq_clr : std_logic_vector( 0 downto 0); - signal src_sel_i : std_logic_vector( 1 downto 0); - signal mp_sel0, mp_sel1, mp_sel2, mp_sel3 : std_logic_vector( 3 downto 0); - signal bit_div : std_logic_vector( 3 downto 0); - signal error_rate_thres_i : std_logic_vector( 7 downto 0); + signal irq, irq_src, irq_src_d : std_logic_vector(0 downto 0); + signal irq_en, irq_mask, irq_val, irq_clr : std_logic_vector(0 downto 0); + signal src_sel_i : std_logic_vector(1 downto 0); + signal mp_sel0, mp_sel1, mp_sel2, mp_sel3 : std_logic_vector(3 downto 0); + signal bit_div : std_logic_vector(3 downto 0); + signal error_rate_thres_i : std_logic_vector(7 downto 0); signal fine_time_init, fine_time_i : std_logic_vector(27 downto 0); signal coarse_time_init, coarse_time_i : std_logic_vector(31 downto 0); signal ext_fp_det_i, ext_fp_gen_i : std_logic_vector(15 downto 0); @@ -100,22 +100,22 @@ architecture rtl of fire_pulse_ctrl_1 is begin pCTRL_REGs : process(reset_n, clk) - begin -- process - if(reset_n = '0') then - fine_time_i <= (others => '0'); - coarse_time_i <= (others => '0'); - elsif(clk = '1' and clk'event) then - if(time_ld_en = '1') then + begin -- process + if (reset_n = '0') then + fine_time_i <= (others => '0'); + coarse_time_i <= (others => '0'); + elsif (clk = '1' and clk'event) then + if (time_ld_en = '1') then fine_time_i <= fine_time_init; - elsif(fine_time_wrap = '1') then + elsif (fine_time_wrap = '1') then fine_time_i <= (others => '0'); else - fine_time_i <= std_logic_vector(unsigned(fine_time_i)+1); + fine_time_i <= std_logic_vector(unsigned(fine_time_i) + 1); end if; - if(time_ld_en = '1') then + if (time_ld_en = '1') then coarse_time_i <= coarse_time_init; - elsif(fine_time_wrap = '1') then - coarse_time_i <= std_logic_vector(unsigned(coarse_time_i)+1); + elsif (fine_time_wrap = '1') then + coarse_time_i <= std_logic_vector(unsigned(coarse_time_i) + 1); end if; one_pps <= fine_time_wrap; end if; @@ -138,19 +138,19 @@ begin pIRQ : process(reset_n, clk) begin - if(reset_n = '0') then - ins_fpm_irq_0 <= '0'; - irq <= "0"; - irq_src_d <= "0"; - elsif(clk = '1' and clk'event) then - irq_src_d <= irq_src; + if (reset_n = '0') then + ins_fpm_irq_0 <= '0'; + irq <= "0"; + irq_src_d <= "0"; + elsif (clk = '1' and clk'event) then + irq_src_d <= irq_src; for n in 0 to irq'left loop - if(irq_clr(n) = '1') then + if (irq_clr(n) = '1') then irq(n) <= '0'; - elsif(irq_en(n) = '1' and irq_src(n) = '1' and irq_src_d(n) = '0') then + elsif (irq_en(n) = '1' and irq_src(n) = '1' and irq_src_d(n) = '0') then irq(n) <= '1'; end if; - end loop; -- n + end loop; -- n ins_fpm_irq_0 <= irq_val(0); end if; end process pIRQ; @@ -174,12 +174,12 @@ begin rx_watchdog_en <= rx_watchdog_en_i; rx_watchdog_clr <= rx_watchdog_clr_i; - ext_fp_det <= ext_fp_det_i; - ext_fp_gen <= ext_fp_gen_i; + ext_fp_det <= ext_fp_det_i; + ext_fp_gen <= ext_fp_gen_i; pCTRL_STATUS : process(reset_n, clk) begin - if(reset_n = '0') then + if (reset_n = '0') then avs_readdatavalid <= '0'; src_sel_i <= "00"; enable_rx_i <= '0'; @@ -199,65 +199,65 @@ begin time_ld_en <= '0'; ext_fp_det_i <= X"0010"; ext_fp_gen_i <= X"0020"; - elsif(clk = '1' and clk'event) then + elsif (clk = '1' and clk'event) then -- CTRL registers - if(avs_write = '1') then + if (avs_write = '1') then case avs_address is when SRC_SEL_REG => - src_sel_i <= avs_writedata( 1 downto 0); + src_sel_i <= avs_writedata(1 downto 0); when POF_RX_CTRL => enable_rx_i <= avs_writedata(0); uart_regen_bypass_i <= avs_writedata(1); upd_max_pos_i <= avs_writedata(2); upd_min_pos_i <= avs_writedata(3); - bit_div <= avs_writedata( 7 downto 4); + bit_div <= avs_writedata(7 downto 4); when MON_PT_CTRL_REG => - mp_sel0 <= avs_writedata( 3 downto 0); - mp_sel1 <= avs_writedata( 7 downto 4); - mp_sel2 <= avs_writedata(11 downto 8); - mp_sel3 <= avs_writedata(15 downto 12); - when COARSE_TIME_INIT_REG => - coarse_time_init <= avs_writedata; + mp_sel0 <= avs_writedata(3 downto 0); + mp_sel1 <= avs_writedata(7 downto 4); + mp_sel2 <= avs_writedata(11 downto 8); + mp_sel3 <= avs_writedata(15 downto 12); + when COARSE_TIME_INIT_REG => + coarse_time_init <= avs_writedata; when FINE_TIME_INIT_REG => - time_ld_en <= avs_writedata(28); - fine_time_init <= avs_writedata(27 downto 0); + time_ld_en <= avs_writedata(28); + fine_time_init <= avs_writedata(27 downto 0); when RX_ERROR_CSR => - error_rate_thres_i <= avs_writedata( 7 downto 0); - rx_watchdog_en_i <= avs_writedata(8); - rx_watchdog_clr_i <= avs_writedata(9); + error_rate_thres_i <= avs_writedata(7 downto 0); + rx_watchdog_en_i <= avs_writedata(8); + rx_watchdog_clr_i <= avs_writedata(9); when IRQ_MNG_REG => - irq_en <= avs_writedata( 0 downto 0); - irq_clr <= avs_writedata( 4 downto 4); - irq_mask <= avs_writedata( 8 downto 8); + irq_en <= avs_writedata(0 downto 0); + irq_clr <= avs_writedata(4 downto 4); + irq_mask <= avs_writedata(8 downto 8); when EXT_FP_CTRL_REG => - ext_fp_det_i <= avs_writedata(15 downto 0); - ext_fp_gen_i <= avs_writedata(31 downto 16); + ext_fp_det_i <= avs_writedata(15 downto 0); + ext_fp_gen_i <= avs_writedata(31 downto 16); when others => null; end case; - end if; + end if; -- Read Ctrl & Status registers avs_readdatavalid <= avs_read; - if(avs_read = '1') then + if (avs_read = '1') then case avs_address is when CSR_IP_ID_REG => avs_readdata <= CSR_IP_ID; when CSR_IP_VER_REG => avs_readdata <= CSR_IP_VER; - when SRC_SEL_REG => + when SRC_SEL_REG => avs_readdata <= (0 => src_sel_i(0), 1 => src_sel_i(1), others => '0'); - when POF_RX_CTRL => + when POF_RX_CTRL => avs_readdata <= X"000000" & bit_div & upd_min_pos_i & upd_max_pos_i & uart_regen_bypass_i & enable_rx_i; when MON_PT_CTRL_REG => avs_readdata <= X"0000" & mp_sel3 & mp_sel2 & mp_sel1 & mp_sel0; when COARSE_TIME_INIT_REG => avs_readdata <= coarse_time_init; - when FINE_TIME_INIT_REG => + when FINE_TIME_INIT_REG => avs_readdata <= b"000" & time_ld_en & fine_time_init; when RX_ERROR_STATUS => avs_readdata <= skip_pos_cnt & parity_err_cnt; - when FINE_TIME_REG => + when FINE_TIME_REG => avs_readdata <= X"0" & fine_time_i; - when COARSE_TIME_REG => + when COARSE_TIME_REG => avs_readdata <= coarse_time_i; when RX_ERROR_CSR => avs_readdata <= X"00000" & max_error_flag & rx_watchdog & rx_watchdog_clr_i & rx_watchdog_en_i & error_rate_thres_i; @@ -271,5 +271,5 @@ begin end if; end if; end process pCTRL_STATUS; - + end architecture rtl; diff --git a/generic_ip/fire_pulse_manager/1/src/test/fire_pulse_manager_1_tb.vhd b/generic_ip/fire_pulse_manager/1/src/test/fire_pulse_manager_1_tb.vhd index 13189b4..6719e1f 100644 --- a/generic_ip/fire_pulse_manager/1/src/test/fire_pulse_manager_1_tb.vhd +++ b/generic_ip/fire_pulse_manager/1/src/test/fire_pulse_manager_1_tb.vhd @@ -474,10 +474,14 @@ begin -- behav 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 (i = 0 and (pd_cnt(i) /= (NUM_ITERATIONS) * 2)) or + (i /= 0 and pd_cnt(i) /= 0) then -- fire_pulse_manager now has no registers beyond channel 0 + log("Channel CH" & integer'image(i) & " PD_cnt counter value Incorrect: ", VLOW, true); detected_error <= true; end if; - if (fp_cnt(i) /= (NUM_ITERATIONS) * 2 * 100) then + if (i = 0 and (fp_cnt(i) /= (NUM_ITERATIONS) * 2 * 100)) or + (i /= 0 and fp_cnt(i) /= 0) then + log("Channel CH" & integer'image(i) & " FP_cnt counter value Incorrect: ", VLOW, true); detected_error <= true; end if; end loop; diff --git a/generic_ip/generic_versioning/doc/generic_versioning.json b/generic_ip/generic_versioning/doc/generic_versioning.json index d7268ce..a2c191e 100644 --- a/generic_ip/generic_versioning/doc/generic_versioning.json +++ b/generic_ip/generic_versioning/doc/generic_versioning.json @@ -4,7 +4,7 @@ "bus": "csr", "addr_width": "4", "description": "This block is the generic versioning", - "notes" : "NB: this block is a key component that is parsed externally, and cannot be renamed with major number tags in order to be processed correctly. Therefore do not modify the source code for this block. If a change is required for a project then a whole new component will be necessary and this signed off in review by the embedded logic line manager.", + "notes": "NB: this block is a key component that is parsed externally, and cannot be renamed with major number tags in order to be processed correctly. Therefore do not modify the source code for this block. If a change is required for a project then a whole new component will be necessary and this signed off in review by the embedded logic line manager.", "registers": { "ip_id": { "address": "0", diff --git a/generic_ip/pulse_generator/1/doc/pulse_generator_1.json b/generic_ip/pulse_generator/1/doc/pulse_generator_1.json index 8cef6b2..9507a1b 100644 --- a/generic_ip/pulse_generator/1/doc/pulse_generator_1.json +++ b/generic_ip/pulse_generator/1/doc/pulse_generator_1.json @@ -50,7 +50,7 @@ "minor_number" : { "type" : "c", "bit_len" : "8", - "reset" : "0x05", + "reset" : "0x06", "description" : "Minor number" }, "major_number" : { diff --git a/generic_ip/pulse_generator/1/src/pulse_generator_1.vhd b/generic_ip/pulse_generator/1/src/pulse_generator_1.vhd index d086a64..a20fa65 100644 --- a/generic_ip/pulse_generator/1/src/pulse_generator_1.vhd +++ b/generic_ip/pulse_generator/1/src/pulse_generator_1.vhd @@ -32,27 +32,27 @@ use work.pulse_generator_1_pkg.all; entity pulse_generator_1 is generic( - PD_QUEUE_SIZE : natural range 32 to 1024 := 64; - PULSE_DELAY_EQUAL_EN : boolean := true; - OUT_PULSE_CONDITION : boolean := true; - OVERDRIVE_CHECK : boolean := true; - DIAG_COUNTERS : boolean := true); + PD_QUEUE_SIZE : natural range 32 to 1024 := 64; + PULSE_DELAY_EQUAL_EN : boolean := true; + OUT_PULSE_CONDITION : boolean := true; + OVERDRIVE_CHECK : boolean := true; + DIAG_COUNTERS : boolean := true); port( - clk : in std_logic; - reset_n : in std_logic := '1'; + clk : in std_logic; + reset_n : in std_logic := '1'; -- - init : in std_logic; + init : in std_logic; -- Sequencer I/Os - pd_in : in std_logic; - abs_position : in std_logic_vector(31 downto 0); - dp_dir : out std_logic; - pulse_out : out std_logic; + pd_in : in std_logic; + abs_position : in std_logic_vector(31 downto 0); + dp_dir : out std_logic; + pulse_out : out std_logic; -- diagnostic outputs - filtered_pd : out std_logic; - ch_pd : out std_logic; - ch_mask : out std_logic; - raw_pulse_out : out std_logic; - enc_pulse : out std_logic; + filtered_pd : out std_logic; + ch_pd : out std_logic; + ch_mask : out std_logic; + raw_pulse_out : out std_logic; + enc_pulse : out std_logic; ----------------------------------------------------------------------- -- Avalon MM Interface ----------------------------------------------------------------------- @@ -69,7 +69,7 @@ architecture rtl of pulse_generator_1 is -- constants constant CSR_IP_ID : std_logic_vector(31 downto 0) := x"0000FF13"; - constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000105"; + constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000106"; signal init_de, init_qd, enable, loc_pd, pd_queue_error : std_logic; @@ -463,32 +463,32 @@ begin ----------------------------------------------------------------------------- gODRV_CHK : if OVERDRIVE_CHECK = true generate - + loc_pulse <= enable and (pulse_out_i and not loc_pulse_out_d); pODRV_CHK : process(clk) begin - if(clk = '1' and clk'event) then + if (clk = '1' and clk'event) then loc_pulse_out_d <= pulse_out_i; - if(enable = '0' or overdrive_rst = '1' or unsigned(pulse_interval) = 2**16-1) then + if (enable = '0' or overdrive_rst = '1' or unsigned(pulse_interval) = 2**16 - 1) then first_pulse <= '1'; - elsif(loc_pulse = '1') then + elsif (loc_pulse = '1') then first_pulse <= '0'; end if; - if(loc_pulse = '1') then + if (loc_pulse = '1') then pulse_interval <= (others => '0'); else - pulse_interval <= std_logic_vector(unsigned(pulse_interval)+1); + pulse_interval <= std_logic_vector(unsigned(pulse_interval) + 1); end if; - if(loc_pulse = '1' and first_pulse = '0' and unsigned(pulse_interval) < unsigned(overdrive_thres)) then + if (loc_pulse = '1' and first_pulse = '0' and unsigned(pulse_interval) < unsigned(overdrive_thres)) then overdrv_event <= '1'; else overdrv_event <= '0'; end if; - if(enable = '0' or overdrive_rst = '1') then + if (enable = '0' or overdrive_rst = '1') then overdrive_events <= (others => '0'); - elsif(overdrv_event = '1') then - overdrive_events <= std_logic_vector(unsigned(overdrive_events)+1); + elsif (overdrv_event = '1') then + overdrive_events <= std_logic_vector(unsigned(overdrive_events) + 1); end if; end if; end process pODRV_CHK; @@ -501,10 +501,10 @@ begin first_pulse <= '0'; pulse_interval <= (others => '0'); overdrive_events <= (others => '0'); - overdrv_event <= '0'; + overdrv_event <= '0'; end generate gNOT_ODRV_CHK; - + ----------------------------------------------------------------------------- -- Pulse Width Conditioning ----------------------------------------------------------------------------- @@ -539,33 +539,33 @@ begin ----------------------------------------------------------------------------- - gDIAG_CNT: if DIAG_COUNTERS = true generate + gDIAG_CNT : if DIAG_COUNTERS = true generate pEdgeDetect_Cnt : process(clk) begin - if(clk = '1' and clk'event) then - fire_req_d <= fire_req; - if(init = '1' or enable = '0' or rst_diag_regs = '1') then + if (clk = '1' and clk'event) then + fire_req_d <= fire_req; + if (init = '1' or enable = '0' or rst_diag_regs = '1') then pd_in_cnt <= (others => '0'); - elsif(pd_pulse = '1') then - pd_in_cnt <= std_logic_vector(unsigned(pd_in_cnt)+1); + elsif (pd_pulse = '1') then + pd_in_cnt <= std_logic_vector(unsigned(pd_in_cnt) + 1); end if; - if(init = '1' or enable = '0' or rst_diag_regs = '1') then + if (init = '1' or enable = '0' or rst_diag_regs = '1') then fire_req_cnt <= (others => '0'); - elsif(fire_req_p = '1') then - fire_req_cnt <= std_logic_vector(unsigned(fire_req_cnt)+1); + elsif (fire_req_p = '1') then + fire_req_cnt <= std_logic_vector(unsigned(fire_req_cnt) + 1); end if; end if; end process pEdgeDetect_Cnt; - - fire_req_p <= fire_req and not fire_req_d; + + fire_req_p <= fire_req and not fire_req_d; end generate gDIAG_CNT; - gNOT_DIAG_CNT: if DIAG_COUNTERS = false generate + gNOT_DIAG_CNT : if DIAG_COUNTERS = false generate pd_in_cnt <= (others => '0'); fire_req_cnt <= (others => '0'); - + end generate gNOT_DIAG_CNT; ----------------------------------------------------------------------------- From 711971b3633098d6be28cece274f3a0bceb2514b Mon Sep 17 00:00:00 2001 From: Damian Smith Date: Fri, 31 May 2019 17:57:01 +0100 Subject: [PATCH 20/29] HMBFDHV-83 Changed uart_rx_1 so that it doesn't initialise data or reset data_out as these are not needed: data is only sampled on valid strobe. NOTE this does change the port behaviour of the sub-block, but not in a way that matters, and does not affect the top-level port timing. --- .../fire_pulse_manager/1/sim/wave_fpm.do | 171 ++++++++++++ .../fire_pulse_manager/1/sim/wave_pof_txrx.do | 24 +- .../fire_pulse_manager/1/src/pof_rx_1.vhd | 257 +++++++++--------- .../fire_pulse_manager/1/src/uart_rx_1.vhd | 21 +- 4 files changed, 304 insertions(+), 169 deletions(-) create mode 100644 generic_ip/fire_pulse_manager/1/sim/wave_fpm.do diff --git a/generic_ip/fire_pulse_manager/1/sim/wave_fpm.do b/generic_ip/fire_pulse_manager/1/sim/wave_fpm.do new file mode 100644 index 0000000..95658b7 --- /dev/null +++ b/generic_ip/fire_pulse_manager/1/sim/wave_fpm.do @@ -0,0 +1,171 @@ +onerror {resume} +quietly WaveActivateNextPane {} 0 +add wave -noupdate -group TB /fire_pulse_manager_1_tb/ch_offset +add wave -noupdate -group TB /fire_pulse_manager_1_tb/reset_n +add wave -noupdate -group TB /fire_pulse_manager_1_tb/clk +add wave -noupdate -group TB /fire_pulse_manager_1_tb/rx_clk +add wave -noupdate -group TB /fire_pulse_manager_1_tb/pof_tx +add wave -noupdate -group TB /fire_pulse_manager_1_tb/pof_rx +add wave -noupdate -group TB /fire_pulse_manager_1_tb/ch_pulse_out +add wave -noupdate -group TB /fire_pulse_manager_1_tb/avs_address +add wave -noupdate -group TB /fire_pulse_manager_1_tb/avs_write +add wave -noupdate -group TB /fire_pulse_manager_1_tb/avs_writedata +add wave -noupdate -group TB /fire_pulse_manager_1_tb/avs_read +add wave -noupdate -group TB /fire_pulse_manager_1_tb/avs_readdatavalid +add wave -noupdate -group TB /fire_pulse_manager_1_tb/avs_readdata +add wave -noupdate -group TB /fire_pulse_manager_1_tb/init_tx +add wave -noupdate -group TB /fire_pulse_manager_1_tb/pd_in +add wave -noupdate -group TB /fire_pulse_manager_1_tb/pd_spy +add wave -noupdate -group TB /fire_pulse_manager_1_tb/inc_pos +add wave -noupdate -group TB /fire_pulse_manager_1_tb/dec_pos +add wave -noupdate -group TB /fire_pulse_manager_1_tb/abs_position +add wave -noupdate -group TB /fire_pulse_manager_1_tb/abs_spy +add wave -noupdate -group TB /fire_pulse_manager_1_tb/tx_data +add wave -noupdate -group TB /fire_pulse_manager_1_tb/abs_position_d +add wave -noupdate -group TB /fire_pulse_manager_1_tb/dir_in +add wave -noupdate -group TB /fire_pulse_manager_1_tb/swathe_cnt +add wave -noupdate -group TB /fire_pulse_manager_1_tb/swathe_pos +add wave -noupdate -group TB /fire_pulse_manager_1_tb/end_of_swathe +add wave -noupdate -group TB /fire_pulse_manager_1_tb/test_completed +add wave -noupdate -group TB /fire_pulse_manager_1_tb/running +add wave -noupdate -group TB /fire_pulse_manager_1_tb/configuring +add wave -noupdate -group TB /fire_pulse_manager_1_tb/passed +add wave -noupdate -group TB /fire_pulse_manager_1_tb/failed +add wave -noupdate -group TB /fire_pulse_manager_1_tb/stimuli_completed +add wave -noupdate -group TB /fire_pulse_manager_1_tb/detected_error +add wave -noupdate -group TB /fire_pulse_manager_1_tb/registers_read +add wave -noupdate -group TB /fire_pulse_manager_1_tb/reprogram_offset +add wave -noupdate -group TB /fire_pulse_manager_1_tb/avs_m +add wave -noupdate -group TB /fire_pulse_manager_1_tb/avs_s +add wave -noupdate -group TB /fire_pulse_manager_1_tb/sel_slave_0 +add wave -noupdate -group TB /fire_pulse_manager_1_tb/sel_slave_1 +add wave -noupdate -group TB /fire_pulse_manager_1_tb/pd_cnt +add wave -noupdate -group TB /fire_pulse_manager_1_tb/fp_cnt +add wave -noupdate -group TB /fire_pulse_manager_1_tb/tx_clk +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/reset_n +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/clk +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/init +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/rx_clk +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/rx_data +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/init_out +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/dp_dir +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/enc_out +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/pd_out +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/inc_pos +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/dec_pos +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/abs_pos +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/enable +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/bit_div +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/error_rate_thres +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/one_pps +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/upd_max_pos +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/upd_min_pos +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/max_error_flag +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/rx_watchdog +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/rx_watchdog_en +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/rx_watchdog_clr +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/parity_err_cnt +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/skip_pos_cnt +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/clear +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/symbol_ok +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/inc_pos_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/dec_pos_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/sync_gen +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/pd_gen +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/symbol_error +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/sync_d +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/symbol_valid +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/symbol_valid_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/symbol_valid_d +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/toggle_sync +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/sync_confirmed +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/sync_toggle_test +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/sync +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/toggle_pd +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/pd_confirmed +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/pd_toggle_test +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/pd +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/valid_pos +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/upd_pos +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/corr_done +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/corr_sign +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/skip_pos +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/apply_corr +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/inc_pos_ii +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/dec_pos_ii +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/new_max +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/new_min +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/rx_error +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/rx_error_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/rx_symbol_val +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/clear_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/skip_pos_d +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/pos_recovery +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/dp_dir_d +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/dp_dir_change +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/max_error_flag_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/clk_cnt +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/dist +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/abs_dist +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/skip_cnt +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/next_pos_lsb +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/curr_pos_lsb +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/pos_corr +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/max_dist +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/rx_error_v +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/gray_pos +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/rx_symbol_val_v +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/symbol +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/symbol_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/rx_symbol +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/rx_wd_cnt +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/parity_err_cnt_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/skip_pos_cnt_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/error_rate_cnt +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/error_rate +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/abs_pos_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/pos_max +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/pos_min +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/dist_pos +add wave -noupdate -group {POF RX} /fire_pulse_manager_1_tb/iDUT/iPOF_RX/dist_neg +add wave -noupdate -group UART_RX /fire_pulse_manager_1_tb/iDUT/iPOF_RX/iRX_SYMBOL/reset_n +add wave -noupdate -group UART_RX /fire_pulse_manager_1_tb/iDUT/iPOF_RX/iRX_SYMBOL/clk +add wave -noupdate -group UART_RX /fire_pulse_manager_1_tb/iDUT/iPOF_RX/iRX_SYMBOL/bit_div +add wave -noupdate -group UART_RX /fire_pulse_manager_1_tb/iDUT/iPOF_RX/iRX_SYMBOL/init +add wave -noupdate -group UART_RX /fire_pulse_manager_1_tb/iDUT/iPOF_RX/iRX_SYMBOL/data_out +add wave -noupdate -group UART_RX /fire_pulse_manager_1_tb/iDUT/iPOF_RX/iRX_SYMBOL/data_out_valid +add wave -noupdate -group UART_RX /fire_pulse_manager_1_tb/iDUT/iPOF_RX/iRX_SYMBOL/rx_error +add wave -noupdate -group UART_RX /fire_pulse_manager_1_tb/iDUT/iPOF_RX/iRX_SYMBOL/rx_data +add wave -noupdate -group UART_RX /fire_pulse_manager_1_tb/iDUT/iPOF_RX/iRX_SYMBOL/fsm_state_curr +add wave -noupdate -group UART_RX /fire_pulse_manager_1_tb/iDUT/iPOF_RX/iRX_SYMBOL/fsm_state_next +add wave -noupdate -group UART_RX /fire_pulse_manager_1_tb/iDUT/iPOF_RX/iRX_SYMBOL/rx_data_i +add wave -noupdate -group UART_RX /fire_pulse_manager_1_tb/iDUT/iPOF_RX/iRX_SYMBOL/shf_data +add wave -noupdate -group UART_RX /fire_pulse_manager_1_tb/iDUT/iPOF_RX/iRX_SYMBOL/rst_bit_cnt +add wave -noupdate -group UART_RX /fire_pulse_manager_1_tb/iDUT/iPOF_RX/iRX_SYMBOL/inc_bit_cnt +add wave -noupdate -group UART_RX /fire_pulse_manager_1_tb/iDUT/iPOF_RX/iRX_SYMBOL/rst_clk_cnt +add wave -noupdate -group UART_RX /fire_pulse_manager_1_tb/iDUT/iPOF_RX/iRX_SYMBOL/end_of_bit +add wave -noupdate -group UART_RX /fire_pulse_manager_1_tb/iDUT/iPOF_RX/iRX_SYMBOL/end_of_rx +add wave -noupdate -group UART_RX /fire_pulse_manager_1_tb/iDUT/iPOF_RX/iRX_SYMBOL/data_valid +add wave -noupdate -group UART_RX /fire_pulse_manager_1_tb/iDUT/iPOF_RX/iRX_SYMBOL/stop_bit +add wave -noupdate -group UART_RX /fire_pulse_manager_1_tb/iDUT/iPOF_RX/iRX_SYMBOL/rx_error_i +add wave -noupdate -group UART_RX /fire_pulse_manager_1_tb/iDUT/iPOF_RX/iRX_SYMBOL/data +add wave -noupdate -group UART_RX /fire_pulse_manager_1_tb/iDUT/iPOF_RX/iRX_SYMBOL/clk_cnt +add wave -noupdate -group UART_RX /fire_pulse_manager_1_tb/iDUT/iPOF_RX/iRX_SYMBOL/bit_cnt +TreeUpdate [SetDefaultTree] +WaveRestoreCursors {{Cursor 1} {0 ps} 0} +quietly wave cursor active 0 +configure wave -namecolwidth 150 +configure wave -valuecolwidth 100 +configure wave -justifyvalue left +configure wave -signalnamewidth 1 +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 {64332055 ps} {64335156 ps} diff --git a/generic_ip/fire_pulse_manager/1/sim/wave_pof_txrx.do b/generic_ip/fire_pulse_manager/1/sim/wave_pof_txrx.do index a0e1081..7691baa 100644 --- a/generic_ip/fire_pulse_manager/1/sim/wave_pof_txrx.do +++ b/generic_ip/fire_pulse_manager/1/sim/wave_pof_txrx.do @@ -191,28 +191,6 @@ add wave -noupdate -radix decimal /pof_tx_rx_1_tb/iPOF_RX/pos_max add wave -noupdate -radix decimal /pof_tx_rx_1_tb/iPOF_RX/pos_min add wave -noupdate -radix decimal /pof_tx_rx_1_tb/iPOF_RX/dist_pos add wave -noupdate -radix decimal /pof_tx_rx_1_tb/iPOF_RX/dist_neg -add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/data_width -add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/reset_n -add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/clk -add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/bit_div -add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/init -add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/data_out -add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/data_out_valid -add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/rx_data -add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/fsm_state_curr -add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/fsm_state_next -add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/rx_data_i -add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/shf_data -add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/rst_bit_cnt -add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/inc_bit_cnt -add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/rst_clk_cnt -add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/end_of_bit -add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/end_of_rx -add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/data_valid -add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/stop_bit -add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/data -add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/clk_cnt -add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/bit_cnt TreeUpdate [SetDefaultTree] WaveRestoreCursors {{Cursor 1} {50645000 ps} 0} quietly wave cursor active 1 @@ -230,4 +208,4 @@ configure wave -griddelta 40 configure wave -timeline 0 configure wave -timelineunits ps update -WaveRestoreZoom {28241650818 ps} {29022971010 ps} +WaveRestoreZoom {412239318 ps} {1193559510 ps} diff --git a/generic_ip/fire_pulse_manager/1/src/pof_rx_1.vhd b/generic_ip/fire_pulse_manager/1/src/pof_rx_1.vhd index 0de5657..0ce34e5 100644 --- a/generic_ip/fire_pulse_manager/1/src/pof_rx_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/pof_rx_1.vhd @@ -20,32 +20,32 @@ use ieee.numeric_std.all; entity pof_rx_1 is port( - reset_n : in std_logic; - clk : in std_logic; + reset_n : in std_logic; + clk : in std_logic; -- - init : in std_logic; - rx_clk : in std_logic; - rx_data : in std_logic; - init_out : out std_logic; - dp_dir : in std_logic; - enc_out : out std_logic; - pd_out : out std_logic; - inc_pos : out std_logic; - dec_pos : out std_logic; - abs_pos : out std_logic_vector(31 downto 0); + init : in std_logic; + rx_clk : in std_logic; + rx_data : in std_logic; + init_out : out std_logic; + dp_dir : in std_logic; + enc_out : out std_logic; + pd_out : out std_logic; + inc_pos : out std_logic; + dec_pos : out std_logic; + abs_pos : out std_logic_vector(31 downto 0); -- C&S - enable : in std_logic; - bit_div : in std_logic_vector( 3 downto 0); - error_rate_thres : in std_logic_vector( 7 downto 0); - one_pps : in std_logic; - upd_max_pos : in std_logic; - upd_min_pos : in std_logic; - max_error_flag : out std_logic; - rx_watchdog : out std_logic; - rx_watchdog_en : in std_logic; - rx_watchdog_clr : in std_logic; - parity_err_cnt : out std_logic_vector(15 downto 0); - skip_pos_cnt : out std_logic_vector(15 downto 0)); + enable : in std_logic; + bit_div : in std_logic_vector(3 downto 0); + error_rate_thres : in std_logic_vector(7 downto 0); + one_pps : in std_logic; + upd_max_pos : in std_logic; + upd_min_pos : in std_logic; + max_error_flag : out std_logic; + rx_watchdog : out std_logic; + rx_watchdog_en : in std_logic; + rx_watchdog_clr : in std_logic; + parity_err_cnt : out std_logic_vector(15 downto 0); + skip_pos_cnt : out std_logic_vector(15 downto 0)); end entity pof_rx_1; architecture rtl of pof_rx_1 is @@ -54,9 +54,9 @@ architecture rtl of pof_rx_1 is function odd_parity_check(data : std_logic_vector) return std_logic is variable parity_bit : std_logic := '0'; begin - for n in 0 to data'length-1 loop + for n in 0 to data'length - 1 loop parity_bit := parity_bit xor data(n); - end loop; -- n + end loop; -- n return parity_bit; end function odd_parity_check; @@ -64,10 +64,10 @@ architecture rtl of pof_rx_1 is function gray2bin(gray : std_logic_vector) return std_logic_vector is variable bin : std_logic_vector(gray'range); begin - bin(gray'length-1) := gray(gray'length-1); - for i in gray'length-2 downto 0 loop - bin(i) := bin(i+1) xor gray(i); - end loop; -- n + bin(gray'length - 1) := gray(gray'length - 1); + for i in gray'length - 2 downto 0 loop + bin(i) := bin(i + 1) xor gray(i); + end loop; -- n return bin; end function gray2bin; @@ -82,30 +82,31 @@ architecture rtl of pof_rx_1 is signal rx_symbol_val, clear_i, skip_pos_d, pos_recovery : std_logic; signal dp_dir_d, dp_dir_change, max_error_flag_i : std_logic; -- - signal clk_cnt : std_logic_vector( 1 downto 0); - signal dist, abs_dist, skip_cnt : std_logic_vector( 3 downto 0); - signal next_pos_lsb, curr_pos_lsb : std_logic_vector( 3 downto 0); - signal pos_corr, max_dist, rx_error_v : std_logic_vector( 3 downto 0); - signal gray_pos, rx_symbol_val_v : std_logic_vector( 3 downto 0); - signal symbol, symbol_i, rx_symbol : std_logic_vector( 7 downto 0); - signal rx_wd_cnt : std_logic_vector( 9 downto 0); - signal parity_err_cnt_i, skip_pos_cnt_i : std_logic_vector(15 downto 0); - signal error_rate_cnt, error_rate : std_logic_vector(15 downto 0); - signal abs_pos_i, pos_max, pos_min : std_logic_vector(31 downto 0); - signal dist_pos, dist_neg : std_logic_vector(31 downto 0); - + signal clk_cnt : std_logic_vector(1 downto 0); + signal dist, abs_dist, skip_cnt : std_logic_vector(3 downto 0); + signal next_pos_lsb, curr_pos_lsb : std_logic_vector(3 downto 0); + signal pos_corr, max_dist, rx_error_v : std_logic_vector(3 downto 0); + signal gray_pos, rx_symbol_val_v : std_logic_vector(3 downto 0); + signal symbol, symbol_i, rx_symbol : std_logic_vector(7 downto 0); + signal rx_wd_cnt : std_logic_vector(9 downto 0); + signal parity_err_cnt_i, skip_pos_cnt_i : std_logic_vector(15 downto 0); + signal error_rate_cnt, error_rate : std_logic_vector(15 downto 0); + signal abs_pos_i, pos_max, pos_min : std_logic_vector(31 downto 0); + signal dist_pos, dist_neg : std_logic_vector(31 downto 0); + + begin clear <= not enable or init; ----------------------------------------------------------------------------- - -- De-serialize symbols (Serial clock at 200 MHz) + -- De-serialize symbols (Serial clock at 300 MHz - typical) ----------------------------------------------------------------------------- - + iRX_SYMBOL : entity work.uart_rx_1 - generic map ( + generic map( data_width => 8) - port map ( + port map( reset_n => reset_n, clk => rx_clk, bit_div => bit_div, @@ -118,16 +119,16 @@ begin -- Synchronize to the local clock pLATCH_RX_DATA : process(rx_clk) begin - if(rx_clk = '1' and rx_clk'event) then - if(rx_symbol_val = '1') then + if (rx_clk = '1' and rx_clk'event) then + if (rx_symbol_val = '1') then symbol <= rx_symbol; end if; - if(rx_symbol_val = '1') then + if (rx_symbol_val = '1') then rx_symbol_val_v <= "1111"; else rx_symbol_val_v <= '0' & rx_symbol_val_v(3 downto 1); end if; - if(rx_error = '1') then + if (rx_error = '1') then rx_error_v <= "1111"; else rx_error_v <= '0' & rx_error_v(3 downto 1); @@ -136,17 +137,17 @@ begin end process pLATCH_RX_DATA; iSYNC_SYMBOL_VAL : entity work.sync_wire_rEdge_1 - generic map (rst_val => '0', sync_stages => 3) - port map (rstN => reset_n, clk => clk, async_in => rx_symbol_val_v(0), sync_out => symbol_valid); + generic map(rst_val => '0', sync_stages => 3) + port map(rstN => reset_n, clk => clk, async_in => rx_symbol_val_v(0), sync_out => symbol_valid); iSYNC_RX_ERROR : entity work.sync_wire_rEdge_1 - generic map (rst_val => '0', sync_stages => 3) - port map (rstN => reset_n, clk => clk, async_in => rx_error_v(0), sync_out => rx_error_i); + generic map(rst_val => '0', sync_stages => 3) + port map(rstN => reset_n, clk => clk, async_in => rx_error_v(0), sync_out => rx_error_i); -- synchronize clear to tx_clk - iSYNC_CLEAR: entity work.sync_wire_1 - generic map (rst_val => '1', sync_stages => 2) - port map ( - rstN => reset_n, clk => rx_clk, async_in => clear, sync_out => clear_i); + iSYNC_CLEAR : entity work.sync_wire_1 + generic map(rst_val => '1', sync_stages => 2) + port map( + rstN => reset_n, clk => rx_clk, async_in => clear, sync_out => clear_i); ----------------------------------------------------------------------------- -- Toggle-Bits Decoding @@ -154,38 +155,38 @@ begin pTOGGLE_DEC : process(clk) begin - if(clk = '1' and clk'event) then + if (clk = '1' and clk'event) then -- Toggle Bits - if(clear = '1') then + if (clear = '1') then toggle_sync <= '0'; - elsif(sync_confirmed = '1') then - toggle_sync <= not toggle_sync; + elsif (sync_confirmed = '1') then + toggle_sync <= not toggle_sync; end if; - if(clear = '1' or sync_confirmed = '1' or (symbol_valid_i = '1' and symbol_i(0) = toggle_sync)) then + if (clear = '1' or sync_confirmed = '1' or (symbol_valid_i = '1' and symbol_i(0) = toggle_sync)) then sync_toggle_test <= '0'; - elsif(sync_gen = '1') then + elsif (sync_gen = '1') then sync_toggle_test <= '1'; end if; - sync <= sync_confirmed; - sync_d <= sync; - if(clear = '1') then + sync <= sync_confirmed; + sync_d <= sync; + if (clear = '1') then toggle_pd <= '0'; - elsif(pd_confirmed = '1') then - toggle_pd <= not toggle_pd; + elsif (pd_confirmed = '1') then + toggle_pd <= not toggle_pd; end if; - if(clear = '1' or pd_confirmed = '1' or (symbol_valid_i = '1' and symbol_i(2) = toggle_pd)) then + if (clear = '1' or pd_confirmed = '1' or (symbol_valid_i = '1' and symbol_i(2) = toggle_pd)) then pd_toggle_test <= '0'; - elsif(pd_gen = '1') then + elsif (pd_gen = '1') then pd_toggle_test <= '1'; end if; - pd <= pd_confirmed; + pd <= pd_confirmed; -- symbol_valid_i <= symbol_valid and symbol_ok; symbol_error <= symbol_valid and not symbol_ok; - if(clear = '1') then + if (clear = '1') then parity_err_cnt_i <= (others => '0'); - elsif(symbol_error = '1') then - parity_err_cnt_i <= std_logic_vector(unsigned(parity_err_cnt_i)+1); + elsif (symbol_error = '1') then + parity_err_cnt_i <= std_logic_vector(unsigned(parity_err_cnt_i) + 1); end if; end if; end process pTOGGLE_DEC; @@ -196,14 +197,14 @@ begin -- and when the two bits with the PD-toggle bit are equal symbol_ok <= '1' when odd_parity_check(symbol) = '1' and (symbol(1) = symbol(2)) else '0'; - sync_gen <= '1' when symbol_valid_i = '1' and symbol_i(0) /= toggle_sync else '0'; - pd_gen <= '1' when symbol_valid_i = '1' and symbol_i(2) /= toggle_pd else '0'; + sync_gen <= '1' when symbol_valid_i = '1' and symbol_i(0) /= toggle_sync else '0'; + pd_gen <= '1' when symbol_valid_i = '1' and symbol_i(2) /= toggle_pd else '0'; -- sync_confirmed <= sync_gen and sync_toggle_test; - pd_confirmed <= pd_gen and pd_toggle_test; + pd_confirmed <= pd_gen and pd_toggle_test; -- - init_out <= sync; - pd_out <= pd; + init_out <= sync; + pd_out <= pd; parity_err_cnt <= parity_err_cnt_i; @@ -216,63 +217,63 @@ begin curr_pos_lsb <= abs_pos_i(3 downto 0); --dist <= std_logic_vector(signed(next_pos_lsb)-signed(curr_pos_lsb)); - abs_dist <= dist when dist(3) = '0' else std_logic_vector(unsigned(not dist)+1); + abs_dist <= dist when dist(3) = '0' else std_logic_vector(unsigned(not dist) + 1); pPOS_MNG : process(clk) begin - if(clk = '1' and clk'event) then - dist <= std_logic_vector(signed(next_pos_lsb)-signed(curr_pos_lsb)); + if (clk = '1' and clk'event) then + dist <= std_logic_vector(signed(next_pos_lsb) - signed(curr_pos_lsb)); symbol_valid_d <= symbol_valid_i; - if(clear = '1' or (symbol_valid_d = '1' and signed(dist) = 0) or pos_recovery = '1') then + if (clear = '1' or (symbol_valid_d = '1' and signed(dist) = 0) or pos_recovery = '1') then max_dist <= "0001"; - elsif(skip_pos = '1' or rx_error_i = '1') then + elsif (skip_pos = '1' or rx_error_i = '1') then max_dist <= std_logic_vector(unsigned(max_dist) + 1); end if; - if(symbol_valid_d = '1' and valid_pos = '1') then + if (symbol_valid_d = '1' and valid_pos = '1') then pos_corr <= abs_dist; - elsif(apply_corr = '1') then - pos_corr <= std_logic_vector(unsigned(pos_corr)-1); + elsif (apply_corr = '1') then + pos_corr <= std_logic_vector(unsigned(pos_corr) - 1); end if; - if(clear = '1' or corr_done = '1') then + if (clear = '1' or corr_done = '1') then upd_pos <= '0'; - elsif(symbol_valid_d = '1' and valid_pos = '1') then + elsif (symbol_valid_d = '1' and valid_pos = '1') then upd_pos <= '1'; end if; - if(upd_pos = '0' or unsigned(clk_cnt) = 2) then + if (upd_pos = '0' or unsigned(clk_cnt) = 2) then clk_cnt <= (others => '0'); else - clk_cnt <= std_logic_vector(unsigned(clk_cnt)+1); + clk_cnt <= std_logic_vector(unsigned(clk_cnt) + 1); end if; - if(symbol_valid_d = '1' and valid_pos = '1') then + if (symbol_valid_d = '1' and valid_pos = '1') then corr_sign <= dist(3); end if; - inc_pos_i <= inc_pos_ii; - dec_pos_i <= dec_pos_ii; - inc_pos <= inc_pos_i; - dec_pos <= dec_pos_i; - if(clear = '1' or sync = '1') then + inc_pos_i <= inc_pos_ii; + dec_pos_i <= dec_pos_ii; + inc_pos <= inc_pos_i; + dec_pos <= dec_pos_i; + if (clear = '1' or sync = '1') then abs_pos_i <= (others => '0'); - elsif(inc_pos_ii = '1') then - abs_pos_i <= std_logic_vector(signed(abs_pos_i)+1); - elsif(dec_pos_ii = '1') then - abs_pos_i <= std_logic_vector(signed(abs_pos_i)-1); + elsif (inc_pos_ii = '1') then + abs_pos_i <= std_logic_vector(signed(abs_pos_i) + 1); + elsif (dec_pos_ii = '1') then + abs_pos_i <= std_logic_vector(signed(abs_pos_i) - 1); end if; - abs_pos <= abs_pos_i; - skip_pos_d <= skip_pos; - if(clear = '1' or (symbol_valid_d = '1' and valid_pos = '1')) then + abs_pos <= abs_pos_i; + skip_pos_d <= skip_pos; + if (clear = '1' or (symbol_valid_d = '1' and valid_pos = '1')) then skip_cnt <= (others => '0'); - elsif(skip_pos = '1' and skip_pos_d = '0') then - skip_cnt <= std_logic_vector(unsigned(skip_cnt)+1); + elsif (skip_pos = '1' and skip_pos_d = '0') then + skip_cnt <= std_logic_vector(unsigned(skip_cnt) + 1); end if; - if(clear = '1') then + if (clear = '1') then skip_pos_cnt_i <= (others => '0'); - elsif(skip_pos_d = '1') then - skip_pos_cnt_i <= std_logic_vector(unsigned(skip_pos_cnt_i)+1); + elsif (skip_pos_d = '1') then + skip_pos_cnt_i <= std_logic_vector(unsigned(skip_pos_cnt_i) + 1); end if; end if; end process pPOS_MNG; - skip_pos <= '1' when (symbol_valid = '1' and symbol_ok = '0') or (symbol_valid_d = '1' and valid_pos = '0' ) else '0'; + skip_pos <= '1' when (symbol_valid = '1' and symbol_ok = '0') or (symbol_valid_d = '1' and valid_pos = '0') else '0'; pos_recovery <= '1' when unsigned(skip_cnt) >= 3 else '0'; valid_pos <= '1' when unsigned(abs_dist) <= unsigned(max_dist) or pos_recovery = '1' else '0'; @@ -291,26 +292,26 @@ begin pERROR_REPORTING : process(clk) begin - if(clk = '1' and clk'event) then - if(clear = '1' or one_pps = '1') then + if (clk = '1' and clk'event) then + if (clear = '1' or one_pps = '1') then error_rate_cnt <= (others => '0'); - elsif(symbol_error = '1') then - error_rate_cnt <= std_logic_vector(unsigned(error_rate_cnt)+1); + elsif (symbol_error = '1') then + error_rate_cnt <= std_logic_vector(unsigned(error_rate_cnt) + 1); end if; - if(clear = '1') then + if (clear = '1') then error_rate <= (others => '0'); - elsif(one_pps = '1') then + elsif (one_pps = '1') then error_rate <= error_rate_cnt; end if; max_error_flag <= not clear and max_error_flag_i; - if(clear = '1' or symbol_valid_i = '1' or rx_watchdog_clr = '1') then + if (clear = '1' or symbol_valid_i = '1' or rx_watchdog_clr = '1') then rx_wd_cnt <= (others => '0'); else - rx_wd_cnt <= std_logic_vector(unsigned(rx_wd_cnt)+1); + rx_wd_cnt <= std_logic_vector(unsigned(rx_wd_cnt) + 1); end if; - if(clear = '1' or rx_watchdog_clr = '1' or rx_watchdog_en = '0' or sync = '1') then + if (clear = '1' or rx_watchdog_clr = '1' or rx_watchdog_en = '0' or sync = '1') then rx_watchdog <= '0'; - elsif(unsigned(rx_wd_cnt) > 1000) then + elsif (unsigned(rx_wd_cnt) > 1000) then rx_watchdog <= '1'; end if; end if; @@ -334,24 +335,24 @@ begin pENC_MNG : process(clk) begin - if(clk = '1' and clk'event) then + if (clk = '1' and clk'event) then dp_dir_d <= dp_dir; - if(sync_d = '1' or dp_dir_change = '1' or new_max = '1' or upd_max_pos = '1') then + if (sync_d = '1' or dp_dir_change = '1' or new_max = '1' or upd_max_pos = '1') then pos_max <= abs_pos_i; end if; - if(sync_d = '1' or dp_dir_change = '1' or new_min = '1' or upd_min_pos = '1') then + if (sync_d = '1' or dp_dir_change = '1' or new_min = '1' or upd_min_pos = '1') then pos_min <= abs_pos_i; end if; - enc_out <= new_min or new_max; + enc_out <= new_min or new_max; end if; end process pENC_MNG; dp_dir_change <= dp_dir xor dp_dir_d; - dist_pos <= std_logic_vector(signed(abs_pos_i)-signed(pos_max)); - dist_neg <= std_logic_vector(signed(pos_min)-signed(abs_pos_i)); + dist_pos <= std_logic_vector(signed(abs_pos_i) - signed(pos_max)); + dist_neg <= std_logic_vector(signed(pos_min) - signed(abs_pos_i)); new_max <= '1' when inc_pos_i = '1' and dp_dir = '0' and dist_pos(31) = '0' and unsigned(dist_pos(3 downto 0)) /= 0 else '0'; new_min <= '1' when dec_pos_i = '1' and dp_dir = '1' and dist_neg(31) = '0' and unsigned(dist_neg(3 downto 0)) /= 0 else '0'; - + end architecture rtl; diff --git a/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd b/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd index 7980f24..47212ef 100644 --- a/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd @@ -35,17 +35,6 @@ end entity uart_rx_1; architecture rtl of uart_rx_1 is - component sync_wire_1 - generic( - rst_val : std_logic; - sync_stages : positive); - port( - rstN : in std_logic; - clk : in std_logic; - async_in : in std_logic; - sync_out : out std_logic); - end component; - type fsm_state_t is (s_init, s_idle, s_get_start_bit, s_get_data, s_get_stop_bit); signal fsm_state_curr, fsm_state_next : fsm_state_t; @@ -64,7 +53,7 @@ begin -- Input Synchronization ----------------------------------------------------------------------------- - iSYNC_IN : sync_wire_1 + iSYNC_IN : entity work.sync_wire_1 generic map( rst_val => '1', sync_stages => 3) @@ -95,15 +84,11 @@ begin else clk_cnt <= std_logic_vector(unsigned(clk_cnt) - 1); end if; - if (rst_clk_cnt = '1') then - data <= (others => '0'); - elsif (shf_data = '1') then + if (shf_data = '1') then data <= rx_data_i & data(data'high downto 1); end if; data_out_valid <= data_valid; - if (init = '1') then - data_out <= (others => '0'); - elsif (data_valid = '1') then + if (data_valid = '1') then data_out <= data; end if; rx_error <= rx_error_i; From aca12f3156788122eea6382c3d9e27691435e798 Mon Sep 17 00:00:00 2001 From: Damian Smith Date: Wed, 5 Jun 2019 11:41:42 +0100 Subject: [PATCH 21/29] HMBFDHV-83 Interim commit - speed up the bit clk by making it a shift register instead --- .../fire_pulse_manager/1/sim/wave_pof_txrx.do | 32 ++++- .../fire_pulse_manager/1/src/pof_rx_1.vhd | 1 - .../1/src/test/pof_tx_rx_1_tb.vhd | 135 +++++++++++------- .../fire_pulse_manager/1/src/uart_rx_1.vhd | 59 ++++---- 4 files changed, 144 insertions(+), 83 deletions(-) diff --git a/generic_ip/fire_pulse_manager/1/sim/wave_pof_txrx.do b/generic_ip/fire_pulse_manager/1/sim/wave_pof_txrx.do index 7691baa..6ce1291 100644 --- a/generic_ip/fire_pulse_manager/1/sim/wave_pof_txrx.do +++ b/generic_ip/fire_pulse_manager/1/sim/wave_pof_txrx.do @@ -1,7 +1,8 @@ onerror {resume} quietly WaveActivateNextPane {} 0 -add wave -noupdate /pof_tx_rx_1_tb/clk add wave -noupdate /pof_tx_rx_1_tb/reset_n +add wave -noupdate /pof_tx_rx_1_tb/hmb_clk +add wave -noupdate /pof_tx_rx_1_tb/sm_clk add wave -noupdate /pof_tx_rx_1_tb/avs_read add wave -noupdate /pof_tx_rx_1_tb/avs_write add wave -noupdate /pof_tx_rx_1_tb/sel_slave_0 @@ -191,10 +192,33 @@ add wave -noupdate -radix decimal /pof_tx_rx_1_tb/iPOF_RX/pos_max add wave -noupdate -radix decimal /pof_tx_rx_1_tb/iPOF_RX/pos_min add wave -noupdate -radix decimal /pof_tx_rx_1_tb/iPOF_RX/dist_pos add wave -noupdate -radix decimal /pof_tx_rx_1_tb/iPOF_RX/dist_neg +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/data_width +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/reset_n +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/clk +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/bit_div +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/init +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/data_out +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/data_out_valid +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/rx_data +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/fsm_state_curr +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/fsm_state_next +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/rx_data_i +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/shf_data +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/rst_bit_cnt +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/inc_bit_cnt +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/rst_clk_cnt +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/end_of_bit +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/end_of_rx +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/data_valid +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/stop_bit +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/data +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/clk_cnt +add wave -noupdate /pof_tx_rx_1_tb/iPOF_RX/iRX_SYMBOL/bit_cnt TreeUpdate [SetDefaultTree] -WaveRestoreCursors {{Cursor 1} {50645000 ps} 0} +WaveRestoreCursors {{Cursor 2} {28538165210 ps} 0} {{Cursor 3} {28538185210 ps} 0} {{Cursor 4} {28538205210 ps} 0} {{Cursor 5} {28538225210 ps} 0} +WaveRestoreCursorLinks {1 {2 {20000 ps} 3 {40000 ps} 4 {60000 ps}}} {2 {1 {-20000 ps}}} {3 {1 {-40000 ps}}} {4 {1 {-60000 ps}}} quietly wave cursor active 1 -configure wave -namecolwidth 305 +configure wave -namecolwidth 365 configure wave -valuecolwidth 100 configure wave -justifyvalue left configure wave -signalnamewidth 0 @@ -208,4 +232,4 @@ configure wave -griddelta 40 configure wave -timeline 0 configure wave -timelineunits ps update -WaveRestoreZoom {412239318 ps} {1193559510 ps} +WaveRestoreZoom {28537732626 ps} {28538723476 ps} diff --git a/generic_ip/fire_pulse_manager/1/src/pof_rx_1.vhd b/generic_ip/fire_pulse_manager/1/src/pof_rx_1.vhd index 0ce34e5..2f736e6 100644 --- a/generic_ip/fire_pulse_manager/1/src/pof_rx_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/pof_rx_1.vhd @@ -94,7 +94,6 @@ architecture rtl of pof_rx_1 is signal abs_pos_i, pos_max, pos_min : std_logic_vector(31 downto 0); signal dist_pos, dist_neg : std_logic_vector(31 downto 0); - begin clear <= not enable or init; diff --git a/generic_ip/fire_pulse_manager/1/src/test/pof_tx_rx_1_tb.vhd b/generic_ip/fire_pulse_manager/1/src/test/pof_tx_rx_1_tb.vhd index 38da67b..0357c68 100644 --- a/generic_ip/fire_pulse_manager/1/src/test/pof_tx_rx_1_tb.vhd +++ b/generic_ip/fire_pulse_manager/1/src/test/pof_tx_rx_1_tb.vhd @@ -34,22 +34,24 @@ end entity pof_tx_rx_1_tb; architecture behav of pof_tx_rx_1_tb is - constant CLK_PERIOD : time := 10 ns; - constant RX_CLK_PERIOD : time := 5 ns; + constant SM_CLK_PERIOD : time := 9.9 ns; + constant HMB_CLK_PERIOD : time := 10 ns; + constant RX_CLK_PERIOD : time := 3.333 ns; -- RX CLK will typically be 3 times clk_period - constant NUM_ITERATIONS : natural := 10; - constant SWATHE_LEN : integer := 1000; - constant START_DIR : std_logic := '0'; - constant INJECT_ERROR_PERC : natural := 4; -- percentage of injected errors - constant DISCR_THRES : natural := 1000; - constant TIME_INT : time := 800 ns; - - constant UART_BIT_DIV : std_logic_vector(3 downto 0) := "0100"; + constant NUM_ITERATIONS : natural := 10; + constant SWATHE_LEN : integer := 1000; + constant START_DIR : std_logic := '0'; + constant INJECT_ERROR_PERC : natural := 0; -- percentage of injected errors (normally 4) + constant DISCR_THRES : natural := 1000; + constant TIME_INT : time := 800 ns; + constant POF_EDGE_VARIATION_TYP : natural := 50; -- measured in 100 ps - e.g. 100 here is 10ns variation + constant POF_EDGE_VARIATION_MAX : natural := 100; -- measured in 100 ps - e.g. 100 here is 10ns variation + constant UART_BIT_DIV : std_logic_vector(3 downto 0) := "0110"; -- as rxclk is 6 times bit period -- Logging Verbosity Level constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM; - signal clk, rx_clk, rx_clk_i, reset_n : std_logic := '0'; + signal hmb_clk, rx_clk, rx_clk_i, reset_n : std_logic := '0'; signal avs_read, avs_write, sel_slave_0, sel_slave_1 : std_logic; signal avs_write_sl0, avs_read_sl0, avs_readdatavalid_sl0 : std_logic; signal avs_write_sl1, avs_read_sl1, avs_readdatavalid_sl1 : std_logic; @@ -93,11 +95,15 @@ architecture behav of pof_tx_rx_1_tb is -- signal avs_m : mm_m_rec_t; signal avs_s : mm_s_rec_t; + signal sm_clk : std_logic := '1'; + signal pof_rx_ctrl_valid : std_logic; begin -- architecture behav - clk <= not clk after 0.5 * CLK_PERIOD; + sm_clk <= not sm_clk after 0.5 * SM_CLK_PERIOD; + + hmb_clk <= not hmb_clk after 0.5 * HMB_CLK_PERIOD; rx_clk_i <= not rx_clk_i after 0.5 * RX_CLK_PERIOD; rx_clk <= rx_clk_i after 1 ns; @@ -109,7 +115,7 @@ begin -- architecture behav iPOF_TX : entity work.pof_tx_1 port map( reset_n => reset_n, - clk => clk, + clk => sm_clk, init => init_tx, pd_in => pd_in, inc_pos => inc_pos, @@ -126,7 +132,7 @@ begin -- architecture behav iPOF_RX : entity work.pof_rx_1 port map( reset_n => reset_n, - clk => clk, + clk => hmb_clk, init => init_rx, rx_clk => rx_clk, rx_data => rx_data, @@ -139,10 +145,10 @@ begin -- architecture behav abs_pos => abs_pos_out, enable => enable_rx, bit_div => UART_BIT_DIV, - error_rate_thres => error_rate_thres, - one_pps => one_pps, upd_max_pos => '0', upd_min_pos => '0', + error_rate_thres => error_rate_thres, + one_pps => one_pps, max_error_flag => max_error_flag, rx_watchdog => rx_watchdog, rx_watchdog_en => rx_watchdog_en, @@ -150,14 +156,30 @@ begin -- architecture behav parity_err_cnt => parity_err_cnt, skip_pos_cnt => skip_pos_cnt); - --rx_data <= tx_data after 40 ns; - rx_data <= transport tx_data after 40 ns; + pPOFDELAY : process is + variable RV : RandomPType; + variable edge_delay : time; + begin + if RV.RandInt(0, 9) < 9 then + -- Mostly Force some variability in the edge formation (i.e. narrow the eye) + edge_delay := RV.RandInt(400 + (POF_EDGE_VARIATION_TYP / 4), 400 + POF_EDGE_VARIATION_TYP) * 100 ps; + else + -- Sometimes Force large variability in the edge formation (i.e. narrow the eye a lot - maybe completely) + edge_delay := RV.RandInt(400, 400 + POF_EDGE_VARIATION_MAX) * 100 ps; + end if; + + rx_data <= transport tx_data after edge_delay; + wait until tx_data'event; + + end process pPOFDELAY; + + ----------------------------------------------------------------------------- -- UUT configuration and control ----------------------------------------------------------------------------- - clk_clk <= clk; + clk_clk <= hmb_clk; reset_reset_n <= reset_n; avs_s.mm_readdata <= avs_readdata_sl0 when sel_slave_0 = '1' else @@ -191,10 +213,10 @@ begin -- architecture behav begin one_pps <= '0'; for n in 1 to 99999 loop - wait until clk = '1' and clk'event; + wait until hmb_clk = '1' and hmb_clk'event; end loop; -- 1 to 9999 one_pps <= '1'; - wait until clk = '1' and clk'event; + wait until hmb_clk = '1' and hmb_clk'event; end process pEMULATE_1PPS; pUUT_CTRL : process @@ -204,11 +226,12 @@ begin -- architecture behav variable fifo_level : integer; begin - enable_rx <= '0'; + enable_rx <= '0'; + pof_rx_ctrl_valid <= '0'; -- - rx_watchdog_en <= '0'; - rx_watchdog_clr <= '0'; - error_rate_thres <= X"0A"; + rx_watchdog_en <= '0'; + rx_watchdog_clr <= '0'; + error_rate_thres <= X"0A"; sel_slave_0 <= '0'; sel_slave_1 <= '0'; @@ -221,7 +244,7 @@ begin -- architecture behav if (reset_n = '0') then wait until reset_n = '1'; wait for 100 ns; - wait until clk = '1' and clk'event; + wait until hmb_clk = '1' and hmb_clk'event; end if; log("Configuring EMB2POFTX ... ", VLOW, true); @@ -234,16 +257,20 @@ begin -- architecture behav sel_slave_0 <= '0'; sel_slave_1 <= '1'; - wait until clk = '1' and clk'event; + wait until hmb_clk = '1' and hmb_clk'event; log("Configuring POFRX2HMB ... ", VLOW, true); -- Config netfork_rx control registers: -- disable the block - addr := std_logic_vector(to_unsigned(0, 32)); - data := X"0000_0001"; + addr := std_logic_vector(to_unsigned(0, 32)); + data := X"0000_0001"; --mm_32b_write(addr, data, avs_s, avs_m); - enable_rx <= '1'; - rx_watchdog_en <= '1'; + enable_rx <= '1'; + rx_watchdog_en <= '1'; + pof_rx_ctrl_valid <= '1'; + wait until hmb_clk = '1' and hmb_clk'event; + pof_rx_ctrl_valid <= '0'; + log("Configuration completed.", VLOW, true); configuring <= false; @@ -256,9 +283,9 @@ begin -- architecture behav -- Stimuli Generation ----------------------------------------------------------------------------- - pSTIMULI_REGs : process(clk) + pSTIMULI_REGs : process(hmb_clk) begin - if (clk = '1' and clk'event) then + if (hmb_clk = '1' and hmb_clk'event) then abs_position_d <= abs_position; end if; end process pSTIMULI_REGs; @@ -292,32 +319,32 @@ begin -- architecture behav wait until running = true; wait for 200 ns; -- Send a Init/Sync pulse - wait until clk = '1' and clk'event; + wait until hmb_clk = '1' and hmb_clk'event; init_tx <= '1'; - wait until clk = '1' and clk'event; + wait until hmb_clk = '1' and hmb_clk'event; init_tx <= '0'; wait for 500 ns; -- Send a second init pulse and verify that it is ignored (because too -- close to the previous) - wait until clk = '1' and clk'event; + wait until hmb_clk = '1' and hmb_clk'event; init_tx <= '1'; - wait until clk = '1' and clk'event; + wait until hmb_clk = '1' and hmb_clk'event; init_tx <= '0'; wait for 2500 ns; -- Send a third pulse (after a bigger interval from the previous). -- Verify that this time the pulse is accepted - wait until clk = '1' and clk'event; + wait until hmb_clk = '1' and hmb_clk'event; init_tx <= '1'; - wait until clk = '1' and clk'event; + wait until hmb_clk = '1' and hmb_clk'event; init_tx <= '0'; wait for 500 ns; - wait until clk = '1' and clk'event; + wait until hmb_clk = '1' and hmb_clk'event; -- -- generate the forward swathe end_of_stimuli := false; while end_of_stimuli = false loop swathe_pos <= 0; - wait until clk = '1' and clk'event; + wait until hmb_clk = '1' and hmb_clk'event; while swathe_pos /= SWATHE_LEN loop -- generate a position increment tmp_int := rv.RandInt(1, 100); @@ -349,15 +376,15 @@ begin -- architecture behav when 2 => -- wait less than the transmission time wait for 90 ns; - wait until clk = '1' and clk'event; + wait until hmb_clk = '1' and hmb_clk'event; when 3 => -- wait more than the transmission time wait for 290 ns; - wait until clk = '1' and clk'event; + wait until hmb_clk = '1' and hmb_clk'event; when others => null; end case; pd_in <= '1'; - wait until clk = '1' and clk'event; + wait until hmb_clk = '1' and hmb_clk'event; pd_in <= '0'; end if; pd_dist := pd_dist + 1; @@ -367,7 +394,7 @@ begin -- architecture behav wait for 25 us; end_of_swathe <= '1'; - wait until clk = '1' and clk'event; + wait until hmb_clk = '1' and hmb_clk'event; end_of_swathe <= '0'; -- reverse direction if (dir_in /= START_DIR) then @@ -378,14 +405,14 @@ begin -- architecture behav end if; end if; if (end_of_stimuli = false) then - wait until clk = '1' and clk'event; + wait until hmb_clk = '1' and hmb_clk'event; dir_in <= not dir_in; -- Wait some time to make sure the change of direction is transmitted. -- Note: if the position starts changing before the receiver was able to -- confirm the change of direction, then some encoder pulses may not be -- generated wait for 1 us; - wait until clk = '1' and clk'event; + wait until hmb_clk = '1' and hmb_clk'event; end if; end loop; -- end_of_stimuli = false @@ -451,8 +478,8 @@ begin -- architecture behav log("bit-flip = " & to_string(bit_flips) & ", flip_vect = " & to_string(flip_vect) & ".", VLOW); symbol <= force symbol xor flip_vect; injected_errors <= injected_errors + 1; - wait until clk = '1' and clk'event; - wait until clk = '1' and clk'event; + wait until hmb_clk = '1' and hmb_clk'event; + wait until hmb_clk = '1' and hmb_clk'event; symbol <= release; last_flip := flip_vect; else @@ -469,9 +496,9 @@ begin -- architecture behav -- No more check on dir_out!!! dir_out <= dir_in; - pEVENT_MONITOR : process(clk) + pEVENT_MONITOR : process(hmb_clk) begin - if (clk = '1' and clk'event) then + if (hmb_clk = '1' and hmb_clk'event) then if (reset_n = '0' or init_tx = '1' or running = false or dir_in = dir_out) then dir_discr_cnt <= 0; elsif (dir_in /= dir_out) then @@ -554,11 +581,11 @@ begin -- architecture behav ovfl_err <= <>; - pERR_DETECT : process(reset_n, clk) + pERR_DETECT : process(reset_n, hmb_clk) begin if (reset_n = '0') then detected_error <= false; - elsif (clk = '1' and clk'event) then + elsif (hmb_clk = '1' and hmb_clk'event) then --if(ovfl_err = '1' or dir_err = '1' or pd_err = '1' or pos_err = '1' or enc_err = '1') then if (ovfl_err = '1' or dir_err = '1' or pd_err = '1' or pos_err = '1') then detected_error <= true; @@ -588,7 +615,7 @@ begin -- architecture behav -- Reset reset_n <= '0'; wait for 100 ns; - wait until clk = '1' and clk'event; + wait until hmb_clk = '1' and hmb_clk'event; reset_n <= '1'; if (configuring /= true) then diff --git a/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd b/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd index 47212ef..4bfd73c 100644 --- a/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd @@ -37,15 +37,24 @@ architecture rtl of uart_rx_1 is type fsm_state_t is (s_init, s_idle, s_get_start_bit, s_get_data, s_get_stop_bit); - signal fsm_state_curr, fsm_state_next : fsm_state_t; + signal fsm_state_curr, fsm_state_next : fsm_state_t; -- - signal rx_data_i, shf_data, rst_bit_cnt, inc_bit_cnt : std_logic; - signal rst_clk_cnt, end_of_bit, end_of_rx, data_valid : std_logic; - signal stop_bit, rx_error_i : std_logic; + signal rx_data_i, rst_bit_cnt, inc_bit_cnt : std_logic; + signal rst_clk_cnt, end_of_rx, data_valid : std_logic; + signal stop_bit, rx_error_i : std_logic; -- - signal data : std_logic_vector(data_width - 1 downto 0); - signal clk_cnt : std_logic_vector(3 downto 0); - signal bit_cnt : std_logic_vector(5 downto 0); + signal data : std_logic_vector(data_width - 1 downto 0); + signal bit_cnt : std_logic_vector(5 downto 0); + + -- avoid maths with loadable shift registers + -- bit_div will be used to set an indexed bit of the timer shift register + -- the timers will shift down towards zeroth bit which will indicate timer has completed. + -- this should be faster than using a decrementer and comparators + signal uart_bit_timer, uart_bit_sample_timer : std_logic_vector(2**bit_div'length - 1 downto 0); + signal uart_bit_timer_load_value, uart_bit_sample_timer_load_value : std_logic_vector(2**bit_div'length - 1 downto 0); + + signal end_of_bit_b : std_logic; + signal shf_data_b : std_logic; begin @@ -75,28 +84,31 @@ begin elsif (inc_bit_cnt = '1') then bit_cnt <= std_logic_vector(unsigned(bit_cnt) + 1); end if; - shf_data <= '0'; - if clk_cnt = ('0' & std_logic_vector(unsigned(bit_div(bit_div'high downto 1)) + 1)) and stop_bit = '0' then - shf_data <= '1'; - end if; - if (rst_clk_cnt = '1' or end_of_bit = '1') then - clk_cnt <= std_logic_vector(unsigned(bit_div) - 1); + if (rst_clk_cnt = '1' or end_of_bit_b = '1') then + uart_bit_timer <= uart_bit_timer_load_value; + uart_bit_sample_timer <= uart_bit_sample_timer_load_value; else - clk_cnt <= std_logic_vector(unsigned(clk_cnt) - 1); + uart_bit_timer <= '0' & uart_bit_timer(uart_bit_timer'high downto 1); + uart_bit_sample_timer <= '0' & uart_bit_sample_timer(uart_bit_sample_timer'high downto 1); end if; - if (shf_data = '1') then + if (shf_data_b = '1') then data <= rx_data_i & data(data'high downto 1); end if; - data_out_valid <= data_valid; + data_out_valid <= data_valid; if (data_valid = '1') then data_out <= data; end if; - rx_error <= rx_error_i; + rx_error <= rx_error_i; + uart_bit_timer_load_value <= (others => '0'); + uart_bit_timer_load_value(to_integer(unsigned(bit_div)) - 1) <= '1'; + uart_bit_sample_timer_load_value <= (others => '0'); + uart_bit_sample_timer_load_value(to_integer(unsigned(bit_div(bit_div'high downto 1))) - 1) <= '1'; end if; end process pREGs; - end_of_bit <= '1' when unsigned(clk_cnt) = 0 else '0'; - end_of_rx <= '1' when unsigned(bit_cnt) = data_width else '0'; + shf_data_b <= uart_bit_sample_timer(0) and not stop_bit; + end_of_bit_b <= uart_bit_timer(0); + end_of_rx <= '1' when unsigned(bit_cnt) = data_width else '0'; ----------------------------------------------------------------------------- -- FSM @@ -115,7 +127,7 @@ begin end process pFSM_SR; -- FSM Combinational Logic - pFSM_CL : process(fsm_state_curr, rx_data_i, end_of_bit, end_of_rx) + pFSM_CL : process(all) begin --default assignments rst_clk_cnt <= '0'; @@ -141,13 +153,13 @@ begin end if; when s_get_start_bit => - if (end_of_bit = '1') then + if (end_of_bit_b = '1') then inc_bit_cnt <= '1'; fsm_state_next <= s_get_data; end if; when s_get_data => - if (end_of_bit = '1') then + if (end_of_bit_b = '1') then inc_bit_cnt <= '1'; if (end_of_rx = '1') then fsm_state_next <= s_get_stop_bit; @@ -156,7 +168,7 @@ begin when s_get_stop_bit => stop_bit <= '1'; - if (end_of_bit = '1') then + if (end_of_bit_b = '1') then if (rx_data_i = '1') then data_valid <= '1'; fsm_state_next <= s_idle; @@ -166,7 +178,6 @@ begin end if; end if; - when others => null; end case; end process pFSM_CL; From f45777a36782020af30be040f5f097cbf57dad1d Mon Sep 17 00:00:00 2001 From: Damian Smith Date: Wed, 5 Jun 2019 14:22:10 +0100 Subject: [PATCH 22/29] HMBFDHV-83 tidied signal names and reverted test bench to standard bit-flipping format (but at 300MHz rxclk) --- .../1/src/test/pof_tx_rx_1_tb.vhd | 135 +++++++----------- .../fire_pulse_manager/1/src/uart_rx_1.vhd | 18 +-- 2 files changed, 63 insertions(+), 90 deletions(-) diff --git a/generic_ip/fire_pulse_manager/1/src/test/pof_tx_rx_1_tb.vhd b/generic_ip/fire_pulse_manager/1/src/test/pof_tx_rx_1_tb.vhd index 0357c68..ffb7065 100644 --- a/generic_ip/fire_pulse_manager/1/src/test/pof_tx_rx_1_tb.vhd +++ b/generic_ip/fire_pulse_manager/1/src/test/pof_tx_rx_1_tb.vhd @@ -34,24 +34,22 @@ end entity pof_tx_rx_1_tb; architecture behav of pof_tx_rx_1_tb is - constant SM_CLK_PERIOD : time := 9.9 ns; - constant HMB_CLK_PERIOD : time := 10 ns; - constant RX_CLK_PERIOD : time := 3.333 ns; -- RX CLK will typically be 3 times clk_period + constant CLK_PERIOD : time := 10 ns; -- 100MHz + constant RX_CLK_PERIOD : time := 3.333 ns; -- 300MHz - constant NUM_ITERATIONS : natural := 10; - constant SWATHE_LEN : integer := 1000; - constant START_DIR : std_logic := '0'; - constant INJECT_ERROR_PERC : natural := 0; -- percentage of injected errors (normally 4) - constant DISCR_THRES : natural := 1000; - constant TIME_INT : time := 800 ns; - constant POF_EDGE_VARIATION_TYP : natural := 50; -- measured in 100 ps - e.g. 100 here is 10ns variation - constant POF_EDGE_VARIATION_MAX : natural := 100; -- measured in 100 ps - e.g. 100 here is 10ns variation - constant UART_BIT_DIV : std_logic_vector(3 downto 0) := "0110"; -- as rxclk is 6 times bit period + constant NUM_ITERATIONS : natural := 10; + constant SWATHE_LEN : integer := 1000; + constant START_DIR : std_logic := '0'; + constant INJECT_ERROR_PERC : natural := 4; -- percentage of injected errors + constant DISCR_THRES : natural := 1000; + constant TIME_INT : time := 800 ns; + + constant UART_BIT_DIV : std_logic_vector(3 downto 0) := "0110"; -- divide by 6 -- Logging Verbosity Level constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM; - signal hmb_clk, rx_clk, rx_clk_i, reset_n : std_logic := '0'; + signal clk, rx_clk, rx_clk_i, reset_n : std_logic := '0'; signal avs_read, avs_write, sel_slave_0, sel_slave_1 : std_logic; signal avs_write_sl0, avs_read_sl0, avs_readdatavalid_sl0 : std_logic; signal avs_write_sl1, avs_read_sl1, avs_readdatavalid_sl1 : std_logic; @@ -95,15 +93,11 @@ architecture behav of pof_tx_rx_1_tb is -- signal avs_m : mm_m_rec_t; signal avs_s : mm_s_rec_t; - signal sm_clk : std_logic := '1'; - signal pof_rx_ctrl_valid : std_logic; begin -- architecture behav - sm_clk <= not sm_clk after 0.5 * SM_CLK_PERIOD; - - hmb_clk <= not hmb_clk after 0.5 * HMB_CLK_PERIOD; + clk <= not clk after 0.5 * CLK_PERIOD; rx_clk_i <= not rx_clk_i after 0.5 * RX_CLK_PERIOD; rx_clk <= rx_clk_i after 1 ns; @@ -115,7 +109,7 @@ begin -- architecture behav iPOF_TX : entity work.pof_tx_1 port map( reset_n => reset_n, - clk => sm_clk, + clk => clk, init => init_tx, pd_in => pd_in, inc_pos => inc_pos, @@ -132,7 +126,7 @@ begin -- architecture behav iPOF_RX : entity work.pof_rx_1 port map( reset_n => reset_n, - clk => hmb_clk, + clk => clk, init => init_rx, rx_clk => rx_clk, rx_data => rx_data, @@ -145,10 +139,10 @@ begin -- architecture behav abs_pos => abs_pos_out, enable => enable_rx, bit_div => UART_BIT_DIV, - upd_max_pos => '0', - upd_min_pos => '0', error_rate_thres => error_rate_thres, one_pps => one_pps, + upd_max_pos => '0', + upd_min_pos => '0', max_error_flag => max_error_flag, rx_watchdog => rx_watchdog, rx_watchdog_en => rx_watchdog_en, @@ -156,30 +150,14 @@ begin -- architecture behav parity_err_cnt => parity_err_cnt, skip_pos_cnt => skip_pos_cnt); - pPOFDELAY : process is - variable RV : RandomPType; - variable edge_delay : time; - begin - if RV.RandInt(0, 9) < 9 then - -- Mostly Force some variability in the edge formation (i.e. narrow the eye) - edge_delay := RV.RandInt(400 + (POF_EDGE_VARIATION_TYP / 4), 400 + POF_EDGE_VARIATION_TYP) * 100 ps; - else - -- Sometimes Force large variability in the edge formation (i.e. narrow the eye a lot - maybe completely) - edge_delay := RV.RandInt(400, 400 + POF_EDGE_VARIATION_MAX) * 100 ps; - end if; - - rx_data <= transport tx_data after edge_delay; - wait until tx_data'event; - - end process pPOFDELAY; - - + --rx_data <= tx_data after 40 ns; + rx_data <= transport tx_data after 40 ns; ----------------------------------------------------------------------------- -- UUT configuration and control ----------------------------------------------------------------------------- - clk_clk <= hmb_clk; + clk_clk <= clk; reset_reset_n <= reset_n; avs_s.mm_readdata <= avs_readdata_sl0 when sel_slave_0 = '1' else @@ -213,10 +191,10 @@ begin -- architecture behav begin one_pps <= '0'; for n in 1 to 99999 loop - wait until hmb_clk = '1' and hmb_clk'event; + wait until clk = '1' and clk'event; end loop; -- 1 to 9999 one_pps <= '1'; - wait until hmb_clk = '1' and hmb_clk'event; + wait until clk = '1' and clk'event; end process pEMULATE_1PPS; pUUT_CTRL : process @@ -226,12 +204,11 @@ begin -- architecture behav variable fifo_level : integer; begin - enable_rx <= '0'; - pof_rx_ctrl_valid <= '0'; + enable_rx <= '0'; -- - rx_watchdog_en <= '0'; - rx_watchdog_clr <= '0'; - error_rate_thres <= X"0A"; + rx_watchdog_en <= '0'; + rx_watchdog_clr <= '0'; + error_rate_thres <= X"0A"; sel_slave_0 <= '0'; sel_slave_1 <= '0'; @@ -244,7 +221,7 @@ begin -- architecture behav if (reset_n = '0') then wait until reset_n = '1'; wait for 100 ns; - wait until hmb_clk = '1' and hmb_clk'event; + wait until clk = '1' and clk'event; end if; log("Configuring EMB2POFTX ... ", VLOW, true); @@ -257,20 +234,16 @@ begin -- architecture behav sel_slave_0 <= '0'; sel_slave_1 <= '1'; - wait until hmb_clk = '1' and hmb_clk'event; + wait until clk = '1' and clk'event; log("Configuring POFRX2HMB ... ", VLOW, true); -- Config netfork_rx control registers: -- disable the block - addr := std_logic_vector(to_unsigned(0, 32)); - data := X"0000_0001"; + addr := std_logic_vector(to_unsigned(0, 32)); + data := X"0000_0001"; --mm_32b_write(addr, data, avs_s, avs_m); - enable_rx <= '1'; - rx_watchdog_en <= '1'; - pof_rx_ctrl_valid <= '1'; - wait until hmb_clk = '1' and hmb_clk'event; - pof_rx_ctrl_valid <= '0'; - + enable_rx <= '1'; + rx_watchdog_en <= '1'; log("Configuration completed.", VLOW, true); configuring <= false; @@ -283,9 +256,9 @@ begin -- architecture behav -- Stimuli Generation ----------------------------------------------------------------------------- - pSTIMULI_REGs : process(hmb_clk) + pSTIMULI_REGs : process(clk) begin - if (hmb_clk = '1' and hmb_clk'event) then + if (clk = '1' and clk'event) then abs_position_d <= abs_position; end if; end process pSTIMULI_REGs; @@ -319,32 +292,32 @@ begin -- architecture behav wait until running = true; wait for 200 ns; -- Send a Init/Sync pulse - wait until hmb_clk = '1' and hmb_clk'event; + wait until clk = '1' and clk'event; init_tx <= '1'; - wait until hmb_clk = '1' and hmb_clk'event; + wait until clk = '1' and clk'event; init_tx <= '0'; wait for 500 ns; -- Send a second init pulse and verify that it is ignored (because too -- close to the previous) - wait until hmb_clk = '1' and hmb_clk'event; + wait until clk = '1' and clk'event; init_tx <= '1'; - wait until hmb_clk = '1' and hmb_clk'event; + wait until clk = '1' and clk'event; init_tx <= '0'; wait for 2500 ns; -- Send a third pulse (after a bigger interval from the previous). -- Verify that this time the pulse is accepted - wait until hmb_clk = '1' and hmb_clk'event; + wait until clk = '1' and clk'event; init_tx <= '1'; - wait until hmb_clk = '1' and hmb_clk'event; + wait until clk = '1' and clk'event; init_tx <= '0'; wait for 500 ns; - wait until hmb_clk = '1' and hmb_clk'event; + wait until clk = '1' and clk'event; -- -- generate the forward swathe end_of_stimuli := false; while end_of_stimuli = false loop swathe_pos <= 0; - wait until hmb_clk = '1' and hmb_clk'event; + wait until clk = '1' and clk'event; while swathe_pos /= SWATHE_LEN loop -- generate a position increment tmp_int := rv.RandInt(1, 100); @@ -376,15 +349,15 @@ begin -- architecture behav when 2 => -- wait less than the transmission time wait for 90 ns; - wait until hmb_clk = '1' and hmb_clk'event; + wait until clk = '1' and clk'event; when 3 => -- wait more than the transmission time wait for 290 ns; - wait until hmb_clk = '1' and hmb_clk'event; + wait until clk = '1' and clk'event; when others => null; end case; pd_in <= '1'; - wait until hmb_clk = '1' and hmb_clk'event; + wait until clk = '1' and clk'event; pd_in <= '0'; end if; pd_dist := pd_dist + 1; @@ -394,7 +367,7 @@ begin -- architecture behav wait for 25 us; end_of_swathe <= '1'; - wait until hmb_clk = '1' and hmb_clk'event; + wait until clk = '1' and clk'event; end_of_swathe <= '0'; -- reverse direction if (dir_in /= START_DIR) then @@ -405,14 +378,14 @@ begin -- architecture behav end if; end if; if (end_of_stimuli = false) then - wait until hmb_clk = '1' and hmb_clk'event; + wait until clk = '1' and clk'event; dir_in <= not dir_in; -- Wait some time to make sure the change of direction is transmitted. -- Note: if the position starts changing before the receiver was able to -- confirm the change of direction, then some encoder pulses may not be -- generated wait for 1 us; - wait until hmb_clk = '1' and hmb_clk'event; + wait until clk = '1' and clk'event; end if; end loop; -- end_of_stimuli = false @@ -478,8 +451,8 @@ begin -- architecture behav log("bit-flip = " & to_string(bit_flips) & ", flip_vect = " & to_string(flip_vect) & ".", VLOW); symbol <= force symbol xor flip_vect; injected_errors <= injected_errors + 1; - wait until hmb_clk = '1' and hmb_clk'event; - wait until hmb_clk = '1' and hmb_clk'event; + wait until clk = '1' and clk'event; + wait until clk = '1' and clk'event; symbol <= release; last_flip := flip_vect; else @@ -496,9 +469,9 @@ begin -- architecture behav -- No more check on dir_out!!! dir_out <= dir_in; - pEVENT_MONITOR : process(hmb_clk) + pEVENT_MONITOR : process(clk) begin - if (hmb_clk = '1' and hmb_clk'event) then + if (clk = '1' and clk'event) then if (reset_n = '0' or init_tx = '1' or running = false or dir_in = dir_out) then dir_discr_cnt <= 0; elsif (dir_in /= dir_out) then @@ -581,11 +554,11 @@ begin -- architecture behav ovfl_err <= <>; - pERR_DETECT : process(reset_n, hmb_clk) + pERR_DETECT : process(reset_n, clk) begin if (reset_n = '0') then detected_error <= false; - elsif (hmb_clk = '1' and hmb_clk'event) then + elsif (clk = '1' and clk'event) then --if(ovfl_err = '1' or dir_err = '1' or pd_err = '1' or pos_err = '1' or enc_err = '1') then if (ovfl_err = '1' or dir_err = '1' or pd_err = '1' or pos_err = '1') then detected_error <= true; @@ -615,7 +588,7 @@ begin -- architecture behav -- Reset reset_n <= '0'; wait for 100 ns; - wait until hmb_clk = '1' and hmb_clk'event; + wait until clk = '1' and clk'event; reset_n <= '1'; if (configuring /= true) then diff --git a/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd b/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd index 4bfd73c..ff6b623 100644 --- a/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd @@ -53,8 +53,8 @@ architecture rtl of uart_rx_1 is signal uart_bit_timer, uart_bit_sample_timer : std_logic_vector(2**bit_div'length - 1 downto 0); signal uart_bit_timer_load_value, uart_bit_sample_timer_load_value : std_logic_vector(2**bit_div'length - 1 downto 0); - signal end_of_bit_b : std_logic; - signal shf_data_b : std_logic; + signal end_of_bit : std_logic; + signal shf_data : std_logic; begin @@ -84,14 +84,14 @@ begin elsif (inc_bit_cnt = '1') then bit_cnt <= std_logic_vector(unsigned(bit_cnt) + 1); end if; - if (rst_clk_cnt = '1' or end_of_bit_b = '1') then + if (rst_clk_cnt = '1' or end_of_bit = '1') then uart_bit_timer <= uart_bit_timer_load_value; uart_bit_sample_timer <= uart_bit_sample_timer_load_value; else uart_bit_timer <= '0' & uart_bit_timer(uart_bit_timer'high downto 1); uart_bit_sample_timer <= '0' & uart_bit_sample_timer(uart_bit_sample_timer'high downto 1); end if; - if (shf_data_b = '1') then + if (shf_data = '1') then data <= rx_data_i & data(data'high downto 1); end if; data_out_valid <= data_valid; @@ -106,8 +106,8 @@ begin end if; end process pREGs; - shf_data_b <= uart_bit_sample_timer(0) and not stop_bit; - end_of_bit_b <= uart_bit_timer(0); + shf_data <= uart_bit_sample_timer(0) and not stop_bit; + end_of_bit <= uart_bit_timer(0); end_of_rx <= '1' when unsigned(bit_cnt) = data_width else '0'; ----------------------------------------------------------------------------- @@ -153,13 +153,13 @@ begin end if; when s_get_start_bit => - if (end_of_bit_b = '1') then + if (end_of_bit = '1') then inc_bit_cnt <= '1'; fsm_state_next <= s_get_data; end if; when s_get_data => - if (end_of_bit_b = '1') then + if (end_of_bit = '1') then inc_bit_cnt <= '1'; if (end_of_rx = '1') then fsm_state_next <= s_get_stop_bit; @@ -168,7 +168,7 @@ begin when s_get_stop_bit => stop_bit <= '1'; - if (end_of_bit_b = '1') then + if (end_of_bit = '1') then if (rx_data_i = '1') then data_valid <= '1'; fsm_state_next <= s_idle; From cec09cda6dd313d94705f22122c559e5ce680330 Mon Sep 17 00:00:00 2001 From: Damian Smith Date: Tue, 11 Jun 2019 11:56:50 +0100 Subject: [PATCH 23/29] HMBFDHV-83 Added the altera 2008 vhdl message to allow qsys to work. corrected the indexing of the shift register timers so that uninitialised values don't crash in simulation (no functional change in silicon) --- generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd b/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd index ff6b623..a67b59f 100644 --- a/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/uart_rx_1.vhd @@ -14,6 +14,7 @@ -- Simple UART receiver, used to receive data over the POF, 1 start, 1 stop -- bit, no parity ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; @@ -100,9 +101,9 @@ begin end if; rx_error <= rx_error_i; uart_bit_timer_load_value <= (others => '0'); - uart_bit_timer_load_value(to_integer(unsigned(bit_div)) - 1) <= '1'; + uart_bit_timer_load_value(to_integer(unsigned(bit_div) -1 )) <= '1'; uart_bit_sample_timer_load_value <= (others => '0'); - uart_bit_sample_timer_load_value(to_integer(unsigned(bit_div(bit_div'high downto 1))) - 1) <= '1'; + uart_bit_sample_timer_load_value(to_integer( unsigned(bit_div(bit_div'high downto 1)) -1)) <= '1'; end if; end process pREGs; From 138b0e59d1ce5378ed9580308ad1172263c431d5 Mon Sep 17 00:00:00 2001 From: Simon Southwell Date: Mon, 24 Jun 2019 07:47:01 +0100 Subject: [PATCH 24/29] HMBFDHV-110 Added -- altera vhdl_input_version vhdl_2008 to all EL-GENERIC-IP files for future proofing in light of Damians changes to files that then required this. --- generic_ip/common/0/src/common_pkg.vhd | 1 + generic_ip/common/0/src/cs_bus_itf.vhd | 1 + generic_ip/common/0/src/digital_lpf.vhd | 1 + generic_ip/common/0/src/dpram_sclk.vhd | 1 + generic_ip/common/0/src/markov_edges.vhd | 1 + generic_ip/common/0/src/pkg_functions.vhd | 1 + generic_ip/common/0/src/queue_and_delay.vhd | 1 + generic_ip/common/0/src/stretch_pulse.vhd | 1 + generic_ip/common/0/src/sync_reset.vhd | 1 + generic_ip/common/0/src/sync_wire.vhd | 1 + generic_ip/common/0/src/sync_wire_rEdge.vhd | 1 + generic_ip/common/0/src/uart_rx.vhd | 1 + generic_ip/common/0/src/uart_tx.vhd | 1 + generic_ip/comms_unique_id/src/comms_avalon_unique_id.vhd | 1 + generic_ip/encoder_multiply/0/src/encoder_multiply_0.vhd | 1 + generic_ip/encoder_multiply/0/src/encoder_speed_detect_0.vhd | 1 + generic_ip/encoder_multiply/0/src/lut_divider_0.vhd | 1 + generic_ip/fire_pulse_manager/0/src/fire_pulse_0_pkg.vhd | 1 + generic_ip/fire_pulse_manager/0/src/fire_pulse_ctrl_0.vhd | 1 + generic_ip/fire_pulse_manager/0/src/fire_pulse_manager_0.vhd | 1 + generic_ip/fire_pulse_manager/0/src/pof_rx_0.vhd | 1 + generic_ip/fire_pulse_manager/0/src/smb_diagnostics_0.vhd | 1 + generic_ip/fire_pulse_manager/0/src/uart_regen_0.vhd | 1 + generic_ip/fire_pulse_manager/1/src/cs_bus_itf_1.vhd | 1 + generic_ip/fire_pulse_manager/1/src/fire_pulse_1_pkg.vhd | 1 + generic_ip/fire_pulse_manager/1/src/fire_pulse_ctrl_1.vhd | 1 + generic_ip/fire_pulse_manager/1/src/fire_pulse_ext_1.vhd | 1 + generic_ip/fire_pulse_manager/1/src/fire_pulse_manager_1.vhd | 1 + generic_ip/fire_pulse_manager/1/src/pof_rx_1.vhd | 1 + generic_ip/fire_pulse_manager/1/src/sync_wire_1.vhd | 1 + generic_ip/fire_pulse_manager/1/src/sync_wire_rEdge_1.vhd | 1 + generic_ip/fire_pulse_manager/1/src/uart_regen_1.vhd | 1 + generic_ip/generic_delay_queue/1/src/generic_delay_queue_1.vhd | 2 ++ .../generic_sequencer/15/src/generic_sequencer_15_pkg.vhd | 1 + generic_ip/pulse_generator/1/src/pulse_conditioning_1.vhd | 1 + generic_ip/pulse_generator/1/src/queue_and_delay_1.vhd | 1 + generic_ip/pulse_generator/1/src/simple_frac_div_1.vhd | 1 + generic_ip/som_ctrl/1/src/som_ctrl_1.vhd | 1 + generic_ip/som_ctrl/1/src/som_ctrl_1_pkg.vhd | 1 + 39 files changed, 40 insertions(+) diff --git a/generic_ip/common/0/src/common_pkg.vhd b/generic_ip/common/0/src/common_pkg.vhd index b54c57a..171ddc5 100644 --- a/generic_ip/common/0/src/common_pkg.vhd +++ b/generic_ip/common/0/src/common_pkg.vhd @@ -13,6 +13,7 @@ -- Description: -- Common Package ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/common/0/src/cs_bus_itf.vhd b/generic_ip/common/0/src/cs_bus_itf.vhd index bae3a8d..d83da9e 100644 --- a/generic_ip/common/0/src/cs_bus_itf.vhd +++ b/generic_ip/common/0/src/cs_bus_itf.vhd @@ -16,6 +16,7 @@ -- Date Version Author Description -- 2015-10-19 1.0 gmg Created ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/common/0/src/digital_lpf.vhd b/generic_ip/common/0/src/digital_lpf.vhd index bdad482..af31d08 100644 --- a/generic_ip/common/0/src/digital_lpf.vhd +++ b/generic_ip/common/0/src/digital_lpf.vhd @@ -52,6 +52,7 @@ -- half_per_min = 3 => LPF order=4, hyst=1 -- half_per_min = 2 => LPF order=2, hyst=1 ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/common/0/src/dpram_sclk.vhd b/generic_ip/common/0/src/dpram_sclk.vhd index 0ae1912..3c2bd1d 100644 --- a/generic_ip/common/0/src/dpram_sclk.vhd +++ b/generic_ip/common/0/src/dpram_sclk.vhd @@ -13,6 +13,7 @@ -- Description: -- True Dual-Port, single clock RAM ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/common/0/src/markov_edges.vhd b/generic_ip/common/0/src/markov_edges.vhd index e264fb5..75434c7 100644 --- a/generic_ip/common/0/src/markov_edges.vhd +++ b/generic_ip/common/0/src/markov_edges.vhd @@ -27,6 +27,7 @@ -- Date Version Author Description -- 2008-05-01 1.0 Damian Created ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/common/0/src/pkg_functions.vhd b/generic_ip/common/0/src/pkg_functions.vhd index 2b135da..f5a3776 100644 --- a/generic_ip/common/0/src/pkg_functions.vhd +++ b/generic_ip/common/0/src/pkg_functions.vhd @@ -14,6 +14,7 @@ ------------------------------------------------------------------------------- -- Copyright (c) 2010 Global Inkjet Systems ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/common/0/src/queue_and_delay.vhd b/generic_ip/common/0/src/queue_and_delay.vhd index e5b67e4..ec01c6e 100644 --- a/generic_ip/common/0/src/queue_and_delay.vhd +++ b/generic_ip/common/0/src/queue_and_delay.vhd @@ -19,6 +19,7 @@ -- than 1024 pulses in 2 ms => max pulse rate = 512kHz. The block rises the -- error bit when this condition is violated. ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/common/0/src/stretch_pulse.vhd b/generic_ip/common/0/src/stretch_pulse.vhd index 83089dd..915552e 100644 --- a/generic_ip/common/0/src/stretch_pulse.vhd +++ b/generic_ip/common/0/src/stretch_pulse.vhd @@ -13,6 +13,7 @@ -- Description: -- Stretch pulse to a programmable width ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/common/0/src/sync_reset.vhd b/generic_ip/common/0/src/sync_reset.vhd index 8b7d37f..678bc0b 100644 --- a/generic_ip/common/0/src/sync_reset.vhd +++ b/generic_ip/common/0/src/sync_reset.vhd @@ -16,6 +16,7 @@ -- Date Version Author Description -- 2010-08-06 1.0 gmg Created ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/common/0/src/sync_wire.vhd b/generic_ip/common/0/src/sync_wire.vhd index 83a4ba2..df6f2c8 100644 --- a/generic_ip/common/0/src/sync_wire.vhd +++ b/generic_ip/common/0/src/sync_wire.vhd @@ -15,6 +15,7 @@ -- Date Version Author Description -- 2010-10-25 1.0 gmg Created ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/common/0/src/sync_wire_rEdge.vhd b/generic_ip/common/0/src/sync_wire_rEdge.vhd index de46548..70758c2 100644 --- a/generic_ip/common/0/src/sync_wire_rEdge.vhd +++ b/generic_ip/common/0/src/sync_wire_rEdge.vhd @@ -15,6 +15,7 @@ -- Date Version Author Description -- 2010-12-03 1.0 gmg Created ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/common/0/src/uart_rx.vhd b/generic_ip/common/0/src/uart_rx.vhd index 21af386..cbb1dba 100644 --- a/generic_ip/common/0/src/uart_rx.vhd +++ b/generic_ip/common/0/src/uart_rx.vhd @@ -14,6 +14,7 @@ -- Simple UART receiver, used to receive data over the POF, 1 start, 1 stop -- bit, no parity ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/common/0/src/uart_tx.vhd b/generic_ip/common/0/src/uart_tx.vhd index 44b9b7a..8d7ce49 100644 --- a/generic_ip/common/0/src/uart_tx.vhd +++ b/generic_ip/common/0/src/uart_tx.vhd @@ -14,6 +14,7 @@ -- Simple UART trasmitter, used to trasmit data over the POF, 1 start, 1 stop -- bit, no parity ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/comms_unique_id/src/comms_avalon_unique_id.vhd b/generic_ip/comms_unique_id/src/comms_avalon_unique_id.vhd index a5f2bc8..f081c89 100644 --- a/generic_ip/comms_unique_id/src/comms_avalon_unique_id.vhd +++ b/generic_ip/comms_unique_id/src/comms_avalon_unique_id.vhd @@ -3,6 +3,7 @@ ------------------------------------------------------------------------------- -- Copyright (c) 2009 Global Inkjet Systems ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/encoder_multiply/0/src/encoder_multiply_0.vhd b/generic_ip/encoder_multiply/0/src/encoder_multiply_0.vhd index 2f81fd3..e6ced35 100644 --- a/generic_ip/encoder_multiply/0/src/encoder_multiply_0.vhd +++ b/generic_ip/encoder_multiply/0/src/encoder_multiply_0.vhd @@ -27,6 +27,7 @@ -- step_pos_out : positive encoder step, before multiplication -- step_neg_out : negative encoder step, before multiplication ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/encoder_multiply/0/src/encoder_speed_detect_0.vhd b/generic_ip/encoder_multiply/0/src/encoder_speed_detect_0.vhd index f543753..d70f20b 100644 --- a/generic_ip/encoder_multiply/0/src/encoder_speed_detect_0.vhd +++ b/generic_ip/encoder_multiply/0/src/encoder_speed_detect_0.vhd @@ -26,6 +26,7 @@ -- delta_t : estimated average time between encoder steps -- time_out_flag : time-out flag ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/encoder_multiply/0/src/lut_divider_0.vhd b/generic_ip/encoder_multiply/0/src/lut_divider_0.vhd index 5b03f83..59cb22b 100644 --- a/generic_ip/encoder_multiply/0/src/lut_divider_0.vhd +++ b/generic_ip/encoder_multiply/0/src/lut_divider_0.vhd @@ -18,6 +18,7 @@ -- Using a single M10k block the LUT width is 32 bits, which is more than needed -- for the mantissa. ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/fire_pulse_manager/0/src/fire_pulse_0_pkg.vhd b/generic_ip/fire_pulse_manager/0/src/fire_pulse_0_pkg.vhd index 3857819..bd5f691 100644 --- a/generic_ip/fire_pulse_manager/0/src/fire_pulse_0_pkg.vhd +++ b/generic_ip/fire_pulse_manager/0/src/fire_pulse_0_pkg.vhd @@ -13,6 +13,7 @@ -- Description: -- Package for fire_pulse_manager block ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/fire_pulse_manager/0/src/fire_pulse_ctrl_0.vhd b/generic_ip/fire_pulse_manager/0/src/fire_pulse_ctrl_0.vhd index 1dbfa08..413a37a 100644 --- a/generic_ip/fire_pulse_manager/0/src/fire_pulse_ctrl_0.vhd +++ b/generic_ip/fire_pulse_manager/0/src/fire_pulse_ctrl_0.vhd @@ -13,6 +13,7 @@ -- Description: -- Control service logic for the Fire-Controller-Manager ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/fire_pulse_manager/0/src/fire_pulse_manager_0.vhd b/generic_ip/fire_pulse_manager/0/src/fire_pulse_manager_0.vhd index 6c3c78a..84a2762 100644 --- a/generic_ip/fire_pulse_manager/0/src/fire_pulse_manager_0.vhd +++ b/generic_ip/fire_pulse_manager/0/src/fire_pulse_manager_0.vhd @@ -14,6 +14,7 @@ -- Generates fire request from the EMS output data, transferred either via POF -- or through NetSync ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/fire_pulse_manager/0/src/pof_rx_0.vhd b/generic_ip/fire_pulse_manager/0/src/pof_rx_0.vhd index da76265..a524b8a 100644 --- a/generic_ip/fire_pulse_manager/0/src/pof_rx_0.vhd +++ b/generic_ip/fire_pulse_manager/0/src/pof_rx_0.vhd @@ -13,6 +13,7 @@ -- Description: -- Deserializes and decodes the EMS (SMB) output, received from the POF. ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/fire_pulse_manager/0/src/smb_diagnostics_0.vhd b/generic_ip/fire_pulse_manager/0/src/smb_diagnostics_0.vhd index e9e20f4..ceed873 100644 --- a/generic_ip/fire_pulse_manager/0/src/smb_diagnostics_0.vhd +++ b/generic_ip/fire_pulse_manager/0/src/smb_diagnostics_0.vhd @@ -13,6 +13,7 @@ -- Description: This block includes all the SMB diagnostic functionalities -- except the event logger. ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/fire_pulse_manager/0/src/uart_regen_0.vhd b/generic_ip/fire_pulse_manager/0/src/uart_regen_0.vhd index 6206d00..d4e5bf5 100644 --- a/generic_ip/fire_pulse_manager/0/src/uart_regen_0.vhd +++ b/generic_ip/fire_pulse_manager/0/src/uart_regen_0.vhd @@ -13,6 +13,7 @@ -- Description: -- Regenerate the UART signal ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/fire_pulse_manager/1/src/cs_bus_itf_1.vhd b/generic_ip/fire_pulse_manager/1/src/cs_bus_itf_1.vhd index 00a7deb..25e293b 100644 --- a/generic_ip/fire_pulse_manager/1/src/cs_bus_itf_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/cs_bus_itf_1.vhd @@ -16,6 +16,7 @@ -- Date Version Author Description -- 2015-10-19 1.0 gmg Created ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/fire_pulse_manager/1/src/fire_pulse_1_pkg.vhd b/generic_ip/fire_pulse_manager/1/src/fire_pulse_1_pkg.vhd index 64708ef..c7b1726 100644 --- a/generic_ip/fire_pulse_manager/1/src/fire_pulse_1_pkg.vhd +++ b/generic_ip/fire_pulse_manager/1/src/fire_pulse_1_pkg.vhd @@ -13,6 +13,7 @@ -- Description: -- Package for fire_pulse_manager block ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/fire_pulse_manager/1/src/fire_pulse_ctrl_1.vhd b/generic_ip/fire_pulse_manager/1/src/fire_pulse_ctrl_1.vhd index 494e9b3..e4f1c5a 100644 --- a/generic_ip/fire_pulse_manager/1/src/fire_pulse_ctrl_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/fire_pulse_ctrl_1.vhd @@ -13,6 +13,7 @@ -- Description: -- Control service logic for the Fire-Controller-Manager ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/fire_pulse_manager/1/src/fire_pulse_ext_1.vhd b/generic_ip/fire_pulse_manager/1/src/fire_pulse_ext_1.vhd index 9e4e4bd..62c17de 100644 --- a/generic_ip/fire_pulse_manager/1/src/fire_pulse_ext_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/fire_pulse_ext_1.vhd @@ -13,6 +13,7 @@ -- Description: -- Detects external fire pulse and regenerates it ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/fire_pulse_manager/1/src/fire_pulse_manager_1.vhd b/generic_ip/fire_pulse_manager/1/src/fire_pulse_manager_1.vhd index 3649c93..568b919 100644 --- a/generic_ip/fire_pulse_manager/1/src/fire_pulse_manager_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/fire_pulse_manager_1.vhd @@ -14,6 +14,7 @@ -- Generates fire request from the EMS output data, transferred either via POF -- or through NetSync ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/fire_pulse_manager/1/src/pof_rx_1.vhd b/generic_ip/fire_pulse_manager/1/src/pof_rx_1.vhd index 2f736e6..1c35133 100644 --- a/generic_ip/fire_pulse_manager/1/src/pof_rx_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/pof_rx_1.vhd @@ -13,6 +13,7 @@ -- Description: -- Deserializes and decodes the EMS (SMB) output, received from the POF. ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/fire_pulse_manager/1/src/sync_wire_1.vhd b/generic_ip/fire_pulse_manager/1/src/sync_wire_1.vhd index 52fd605..ed55cf1 100644 --- a/generic_ip/fire_pulse_manager/1/src/sync_wire_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/sync_wire_1.vhd @@ -15,6 +15,7 @@ -- Date Version Author Description -- 2010-10-25 1.0 gmg Created ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/fire_pulse_manager/1/src/sync_wire_rEdge_1.vhd b/generic_ip/fire_pulse_manager/1/src/sync_wire_rEdge_1.vhd index 5d2b1bb..6c53fc2 100644 --- a/generic_ip/fire_pulse_manager/1/src/sync_wire_rEdge_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/sync_wire_rEdge_1.vhd @@ -15,6 +15,7 @@ -- Date Version Author Description -- 2010-12-03 1.0 gmg Created ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/fire_pulse_manager/1/src/uart_regen_1.vhd b/generic_ip/fire_pulse_manager/1/src/uart_regen_1.vhd index 6fd265b..a967275 100644 --- a/generic_ip/fire_pulse_manager/1/src/uart_regen_1.vhd +++ b/generic_ip/fire_pulse_manager/1/src/uart_regen_1.vhd @@ -13,6 +13,7 @@ -- Description: -- Regenerate the UART signal ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/generic_delay_queue/1/src/generic_delay_queue_1.vhd b/generic_ip/generic_delay_queue/1/src/generic_delay_queue_1.vhd index 6131068..c23cd2c 100644 --- a/generic_ip/generic_delay_queue/1/src/generic_delay_queue_1.vhd +++ b/generic_ip/generic_delay_queue/1/src/generic_delay_queue_1.vhd @@ -1,3 +1,5 @@ +-- altera vhdl_input_version vhdl_2008 + library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; diff --git a/generic_ip/generic_sequencer/15/src/generic_sequencer_15_pkg.vhd b/generic_ip/generic_sequencer/15/src/generic_sequencer_15_pkg.vhd index 45007cb..d877c8e 100644 --- a/generic_ip/generic_sequencer/15/src/generic_sequencer_15_pkg.vhd +++ b/generic_ip/generic_sequencer/15/src/generic_sequencer_15_pkg.vhd @@ -14,6 +14,7 @@ -- Package defining common constants for generic_sequencer_15 core, such as -- Control & Status registers offset etc. ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/pulse_generator/1/src/pulse_conditioning_1.vhd b/generic_ip/pulse_generator/1/src/pulse_conditioning_1.vhd index 2698132..d85f961 100644 --- a/generic_ip/pulse_generator/1/src/pulse_conditioning_1.vhd +++ b/generic_ip/pulse_generator/1/src/pulse_conditioning_1.vhd @@ -14,6 +14,7 @@ -- merge input pulses and pd events into a single bit signal, extend the witdth -- to make sure the signal is safely transmitted over the POF ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/pulse_generator/1/src/queue_and_delay_1.vhd b/generic_ip/pulse_generator/1/src/queue_and_delay_1.vhd index c35d3e8..7e08e50 100644 --- a/generic_ip/pulse_generator/1/src/queue_and_delay_1.vhd +++ b/generic_ip/pulse_generator/1/src/queue_and_delay_1.vhd @@ -19,6 +19,7 @@ -- than 1024 pulses in 2 ms => max pulse rate = 512kHz. The block rises the -- error bit when this condition is violated. ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/pulse_generator/1/src/simple_frac_div_1.vhd b/generic_ip/pulse_generator/1/src/simple_frac_div_1.vhd index 3533a42..6625e81 100644 --- a/generic_ip/pulse_generator/1/src/simple_frac_div_1.vhd +++ b/generic_ip/pulse_generator/1/src/simple_frac_div_1.vhd @@ -22,6 +22,7 @@ -- result of the check is positive, the fire request will be issued at the -- current absolute position, otherwise the check is repeated at the next step. ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/som_ctrl/1/src/som_ctrl_1.vhd b/generic_ip/som_ctrl/1/src/som_ctrl_1.vhd index a1f9e96..9eb1356 100644 --- a/generic_ip/som_ctrl/1/src/som_ctrl_1.vhd +++ b/generic_ip/som_ctrl/1/src/som_ctrl_1.vhd @@ -14,6 +14,7 @@ -- som_ctrl block: this block gathers together SOM specific functionalies, such -- as the SWIM interface, power-good input signals, host-power enable signals etc. ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; diff --git a/generic_ip/som_ctrl/1/src/som_ctrl_1_pkg.vhd b/generic_ip/som_ctrl/1/src/som_ctrl_1_pkg.vhd index 5991f89..2e0802b 100644 --- a/generic_ip/som_ctrl/1/src/som_ctrl_1_pkg.vhd +++ b/generic_ip/som_ctrl/1/src/som_ctrl_1_pkg.vhd @@ -13,6 +13,7 @@ -- Description: -- Package defining common constants for the som_ctrl, block ------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 library ieee; use ieee.std_logic_1164.all; From 06d8ad48e9fa6ccb70003376ece4dcf16867a873 Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Fri, 12 Jul 2019 10:09:47 +0100 Subject: [PATCH 25/29] ELGIP-73 HMBXR5601-771 - Removed read-data-valid from Single-Channel FPM Avalon Slave interface and replace it with wait-request signal, which allows variable read latency without having additional pending read/write accesses. This change is classified as minor-version, cause for the single-channel FPM the modification is completely confined within the block Qsys definition file (fire_pulse_manager_0_hw.tcl) --- generic_ip/common/0/sim/sim_cs_bus_itf.do | 68 ++++ generic_ip/common/0/sim/wave_cs_bus_itf.do | 77 ++++ generic_ip/common/0/src/cs_bus_itf.vhd | 83 +++-- .../common/0/src/test/avalon_verify_pkg.vhd | 12 +- .../common/0/src/test/cs_bus_itf_tb.vhd | 332 ++++++++++++++++++ .../0/build/fire_pulse_manager_0_hw.tcl | 23 +- .../0/src/fire_pulse_manager_0.vhd | 6 +- 7 files changed, 557 insertions(+), 44 deletions(-) create mode 100644 generic_ip/common/0/sim/sim_cs_bus_itf.do create mode 100644 generic_ip/common/0/sim/wave_cs_bus_itf.do create mode 100644 generic_ip/common/0/src/test/cs_bus_itf_tb.vhd diff --git a/generic_ip/common/0/sim/sim_cs_bus_itf.do b/generic_ip/common/0/sim/sim_cs_bus_itf.do new file mode 100644 index 0000000..c47a093 --- /dev/null +++ b/generic_ip/common/0/sim/sim_cs_bus_itf.do @@ -0,0 +1,68 @@ +# 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 SRC_PATH ../src +set OSVVM_PATH $TB_PATH/OSVVM + +set WORKLIB work + +vlib ./work +vmap work ./work + +if {$COMP_ONLY == 0} { +# Compile the constrained random related packages + vlib OSVVM + vcom -2008 -work OSVVM \ + $OSVVM_PATH/RandomBasePkg.vhd \ + $OSVVM_PATH/SortListPkg_int.vhd \ + $OSVVM_PATH/RandomPkg.vhd \ + $OSVVM_PATH/NamePkg.vhd \ + $OSVVM_PATH/MessagePkg.vhd \ + $OSVVM_PATH/CoveragePkg.vhd +} + +# compile the UUTs: +vcom -2008 -work $WORKLIB $SRC_PATH/cs_bus_itf.vhd + + +# Compile the testbench and the other components supporting the test +if {$COMP_ONLY == 0} { + # Test support packages + vcom -2008 -work $WORKLIB $TB_PATH/common_test_pkg.vhd + vcom -2008 -work $WORKLIB $TB_PATH/log_pkg.vhd + vcom -2008 -work $WORKLIB $TB_PATH/avalon_verify_pkg.vhd + + # Testbench + vcom -2008 -work $WORKLIB $TB_PATH/cs_bus_itf_tb.vhd + + vsim -t ps work.cs_bus_itf_tb + + + #add wave cs_bus_itf_tb/* + #add wave cs_bus_itf_tb/iUUT/* + + # remove warnings from standard numeric/arithmetic packages (speed-up simulation) + set StdArithNoWarnings 1 + set NumericStdNoWarnings 1 + + do wave_cs_bus_itf.do + + when -label end_of_simulation {test_completed == true} {echo "Simulation Completed"; stop ;} + run -all + + #run 1 ms; +} + + + + diff --git a/generic_ip/common/0/sim/wave_cs_bus_itf.do b/generic_ip/common/0/sim/wave_cs_bus_itf.do new file mode 100644 index 0000000..1edb5e8 --- /dev/null +++ b/generic_ip/common/0/sim/wave_cs_bus_itf.do @@ -0,0 +1,77 @@ +onerror {resume} +quietly WaveActivateNextPane {} 0 +add wave -noupdate /cs_bus_itf_tb/reset_n +add wave -noupdate /cs_bus_itf_tb/clk +add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/avs_address +add wave -noupdate /cs_bus_itf_tb/avs_write +add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/avs_writedata +add wave -noupdate /cs_bus_itf_tb/avs_read +add wave -noupdate /cs_bus_itf_tb/avs_waitrequest +add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/avs_readdata +add wave -noupdate /cs_bus_itf_tb/cs_addr +add wave -noupdate /cs_bus_itf_tb/cs_we +add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/cs_wr_data +add wave -noupdate /cs_bus_itf_tb/cs_re +add wave -noupdate /cs_bus_itf_tb/cs_rv +add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/cs_rd_data +add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/avs_m +add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/avs_s +add wave -noupdate /cs_bus_itf_tb/end_of_stimuli +add wave -noupdate /cs_bus_itf_tb/test_completed +add wave -noupdate /cs_bus_itf_tb/setup +add wave -noupdate /cs_bus_itf_tb/running +add wave -noupdate /cs_bus_itf_tb/passed +add wave -noupdate /cs_bus_itf_tb/failed +add wave -noupdate /cs_bus_itf_tb/blk_0_re +add wave -noupdate /cs_bus_itf_tb/blk_0_we +add wave -noupdate /cs_bus_itf_tb/blk_0_rv +add wave -noupdate /cs_bus_itf_tb/blk_0_re_d +add wave -noupdate /cs_bus_itf_tb/blk_1_re +add wave -noupdate /cs_bus_itf_tb/blk_1_we +add wave -noupdate /cs_bus_itf_tb/blk_1_rv +add wave -noupdate /cs_bus_itf_tb/blk_1_re_d +add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/blk_0_wr_data +add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/blk_0_rd_data +add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/blk_1_wr_data +add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/blk_1_rd_data +add wave -noupdate /cs_bus_itf_tb/iUUT/rstN +add wave -noupdate /cs_bus_itf_tb/iUUT/clk +add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/iUUT/avs_address +add wave -noupdate /cs_bus_itf_tb/iUUT/avs_write +add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/iUUT/avs_writedata +add wave -noupdate /cs_bus_itf_tb/iUUT/avs_read +add wave -noupdate /cs_bus_itf_tb/iUUT/avs_waitrequest +add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/iUUT/avs_readdata +add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/iUUT/cs_addr +add wave -noupdate /cs_bus_itf_tb/iUUT/cs_we +add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/iUUT/cs_wr_data +add wave -noupdate /cs_bus_itf_tb/iUUT/cs_re +add wave -noupdate /cs_bus_itf_tb/iUUT/cs_rv +add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/iUUT/cs_rd_data +add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/iUUT/cs_rd_data_i +add wave -noupdate /cs_bus_itf_tb/iUUT/avs_read_d +add wave -noupdate /cs_bus_itf_tb/iUUT/avs_rd_en +add wave -noupdate /cs_bus_itf_tb/iUUT/read_valid +add wave -noupdate /cs_bus_itf_tb/iUUT/stall_read +add wave -noupdate /cs_bus_itf_tb/iUUT/dummy_rv +add wave -noupdate /cs_bus_itf_tb/iUUT/timeout_flag +add wave -noupdate -radix unsigned /cs_bus_itf_tb/iUUT/read_timeout_cnt +add wave -noupdate /cs_bus_itf_tb/iUUT/avs_address_i +TreeUpdate [SetDefaultTree] +WaveRestoreCursors {{Cursor 1} {1273181 ps} 0} +quietly wave cursor active 1 +configure wave -namecolwidth 273 +configure wave -valuecolwidth 187 +configure wave -justifyvalue left +configure wave -signalnamewidth 0 +configure wave -snapdistance 10 +configure wave -datasetprefix 0 +configure wave -rowmargin 4 +configure wave -childrowmargin 2 +configure wave -gridoffset 0 +configure wave -gridperiod 1 +configure wave -griddelta 40 +configure wave -timeline 0 +configure wave -timelineunits ps +update +WaveRestoreZoom {0 ps} {3540224 ps} diff --git a/generic_ip/common/0/src/cs_bus_itf.vhd b/generic_ip/common/0/src/cs_bus_itf.vhd index d83da9e..3974670 100644 --- a/generic_ip/common/0/src/cs_bus_itf.vhd +++ b/generic_ip/common/0/src/cs_bus_itf.vhd @@ -10,7 +10,7 @@ -- Description: Split the memory space from the Avalon-MM I/F and drive the C&S -- bus for a programmable number of FW processing blocks ------------------------------------------------------------------------------- --- Last update: 2016-10-28 +-- Last update: 2019-07-11 ------------------------------------------------------------------------------- -- Revisions : -- Date Version Author Description @@ -23,7 +23,9 @@ use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity cs_bus_ift is - generic(blk_num : integer range 1 to 16 := 1); + generic( + BLK_NUM : integer range 1 to 16 := 1; + READ_TIMEOUT : integer range 16 to 1023 := 64); port( rstN : in std_logic; clk : in std_logic; @@ -32,32 +34,39 @@ entity cs_bus_ift is avs_write : in std_logic; avs_writedata : in std_logic_vector(31 downto 0); avs_read : in std_logic; - avs_readdatavalid : out std_logic; + avs_waitrequest : out std_logic; avs_readdata : out std_logic_vector(31 downto 0); -- C&S bus cs_addr : out std_logic_vector(10 downto 0); - cs_we : out std_logic_vector(blk_num-1 downto 0); + cs_we : out std_logic_vector(BLK_NUM-1 downto 0); cs_wr_data : out std_logic_vector(31 downto 0); - cs_re : out std_logic_vector(blk_num-1 downto 0); - cs_rv : in std_logic_vector(blk_num-1 downto 0); - cs_rd_data : in std_logic_vector(32*blk_num-1 downto 0)); + cs_re : out std_logic_vector(BLK_NUM-1 downto 0); + cs_rv : in std_logic_vector(BLK_NUM-1 downto 0); + cs_rd_data : in std_logic_vector(32*BLK_NUM-1 downto 0)); end cs_bus_ift; architecture RTL of cs_bus_ift is -- limit to 16 the maximum number of user blocks - type rd_bus_t is array (0 to blk_num-1) of std_logic_vector(31 downto 0); + type rd_bus_t is array (0 to BLK_NUM-1) of std_logic_vector(31 downto 0); - signal cs_rd_data_i : rd_bus_t; - signal avs_read_d : std_logic; - signal avs_rd_en : std_logic; - signal dummy_rv : std_logic; -- Dummy Read valid: asserted when - -- trying to read from not allocated addresses - signal avs_address_i : std_logic_vector(14 downto 0); + signal cs_rd_data_i : rd_bus_t; + signal avs_read_d : std_logic; + signal avs_rd_en : std_logic; + signal avs_write_d : std_logic; + signal avs_wr_en : std_logic; + signal sel_read_valid : std_logic; + signal read_valid : std_logic; + signal stall_read : std_logic; + signal dummy_rv : std_logic; -- Dummy Read valid: asserted when + -- trying to read from not allocated addresses + signal timeout_flag : std_logic; + signal read_timeout_cnt : std_logic_vector( 9 downto 0); + signal avs_address_i : std_logic_vector(14 downto 0); begin - BUS_REMAP: for i in 0 to blk_num-1 generate + BUS_REMAP: for i in 0 to BLK_NUM-1 generate cs_rd_data_i(i) <= cs_rd_data((i+1)*32-1 downto i*32); end generate BUS_REMAP; @@ -68,49 +77,71 @@ begin cs_we <= (others => '0'); cs_wr_data <= (others => '0'); cs_re <= (others => '0'); - avs_readdatavalid <= '0'; avs_readdata <= (others => '0'); avs_read_d <= '0'; + avs_write_d <= '0'; dummy_rv <= '0'; + stall_read <= '0'; elsif(clk = '1' and clk'event) then if(avs_write = '1' or avs_read = '1') then avs_address_i <= avs_address; end if; - avs_read_d <= avs_read; - for i in 0 to blk_num-1 loop + avs_read_d <= avs_read; + avs_write_d <= avs_write; + for i in 0 to BLK_NUM-1 loop -- limit to 16 the maximum number of user blocks - if(avs_write = '1' and to_integer(unsigned(avs_address(avs_address'high downto avs_address'high-3))) = i) then + if(avs_wr_en = '1' and to_integer(unsigned(avs_address(avs_address'high downto avs_address'high-3))) = i) then cs_we(i) <= '1'; else cs_we(i) <= '0'; end if; end loop; -- i - cs_wr_data <= avs_writedata; - for i in 0 to blk_num-1 loop + if(avs_wr_en = '1') then + cs_wr_data <= avs_writedata; + end if; + for i in 0 to BLK_NUM-1 loop if(avs_rd_en = '1' and to_integer(unsigned(avs_address(avs_address'high downto avs_address'high-3))) = i) then cs_re(i) <= '1'; else cs_re(i) <= '0'; end if; end loop; -- i - if(avs_rd_en = '1' and (to_integer(unsigned(avs_address(avs_address'high downto avs_address'high-3))) >= blk_num)) then + if((avs_rd_en = '1' and (to_integer(unsigned(avs_address(avs_address'high downto avs_address'high-3))) >= BLK_NUM)) or timeout_flag = '1') then dummy_rv <= '1'; else dummy_rv <= '0'; end if; - avs_readdatavalid <= dummy_rv or cs_rv(to_integer(unsigned(avs_address_i(avs_address'high downto avs_address'high-3)))); - if(dummy_rv = '0') then + if(sel_read_valid = '1') then avs_readdata <= cs_rd_data_i(to_integer(unsigned(avs_address_i(avs_address'high downto avs_address'high-3)))); - else + elsif(dummy_rv = '1') then avs_readdata <= X"DEAD_BEEF"; end if; + if(avs_rd_en = '1') then + stall_read <= '1'; + elsif(read_valid = '1') then + stall_read <= '0'; + end if; + if(avs_rd_en = '1') then + read_timeout_cnt <= (others => '0'); + elsif(avs_read_d = '1') then + read_timeout_cnt <= std_logic_vector(unsigned(read_timeout_cnt)+1); + end if; end if; end process pLatchIO; - avs_rd_en <= avs_read and not avs_read_d; + sel_read_valid <= cs_rv(to_integer(unsigned(avs_address_i(avs_address'high downto avs_address'high-3)))); + read_valid <= dummy_rv or sel_read_valid; + + + avs_rd_en <= avs_read and not avs_read_d; + avs_wr_en <= avs_write and not avs_write_d; + + avs_waitrequest <= avs_rd_en or avs_wr_en or stall_read; cs_addr <= avs_address_i(10 downto 0); + timeout_flag <= '1' when unsigned(read_timeout_cnt) = READ_TIMEOUT else '0'; + end RTL; diff --git a/generic_ip/common/0/src/test/avalon_verify_pkg.vhd b/generic_ip/common/0/src/test/avalon_verify_pkg.vhd index 81e5a75..099aed9 100644 --- a/generic_ip/common/0/src/test/avalon_verify_pkg.vhd +++ b/generic_ip/common/0/src/test/avalon_verify_pkg.vhd @@ -353,9 +353,9 @@ package body AVALON_VERIFY_PKG is mm_m_rec.mm_writedata <= data; mm_m_rec.mm_write <= '1'; wait until falling_edge(clk_clk); - while(mm_use_waitrequest.is_set = true and mm_s_rec.mm_waitrequest = '1') loop - wait until falling_edge(clk_clk); - end loop; + if(mm_use_waitrequest.is_set = true and mm_s_rec.mm_waitrequest = '1') then + wait until falling_edge(mm_s_rec.mm_waitrequest); + end if; wait until rising_edge(clk_clk); mm_m_rec.mm_byteenable <= "0000"; mm_m_rec.mm_write <= '0'; @@ -425,9 +425,9 @@ package body AVALON_VERIFY_PKG is mm_m_rec.mm_address <= addr or base_addr; mm_m_rec.mm_read <= '1'; wait until falling_edge(clk_clk); - while(mm_use_waitrequest.is_set = true and mm_s_rec.mm_waitrequest = '1') loop - wait until falling_edge(clk_clk); - end loop; + if(mm_use_waitrequest.is_set = true and mm_s_rec.mm_waitrequest = '1') then + wait until falling_edge(mm_s_rec.mm_waitrequest); + end if; wait until rising_edge(clk_clk); mm_m_rec.mm_read <= '0'; if(mm_use_waitrequest.is_set = false) then diff --git a/generic_ip/common/0/src/test/cs_bus_itf_tb.vhd b/generic_ip/common/0/src/test/cs_bus_itf_tb.vhd new file mode 100644 index 0000000..31c0cfe --- /dev/null +++ b/generic_ip/common/0/src/test/cs_bus_itf_tb.vhd @@ -0,0 +1,332 @@ +------------------------------------------------------------------------------- +-- Title : cs_bus_itf_tb +-- Project : Generic +------------------------------------------------------------------------------- +-- File : cs_bus_itf_tb.vhd +-- Author : GMG +-- Company : Global Inkjet Systems +-- Created : 2019-07-10 +-- Last update: 2019-07-10 +-- SVN ID : Git +-- Standard : VHDL'2008 +------------------------------------------------------------------------------- +-- Description: +-- Verifies Time-of-Flight Compensation +------------------------------------------------------------------------------- + +library std; +use std.textio.all; + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +use work.log_pkg.all; +use work.avalon_verify_pkg.all; + +entity cs_bus_itf_tb is + -- .. +end entity cs_bus_itf_tb; + +architecture behav of cs_bus_itf_tb is + + constant CLK_PERIOD : time := 10 ns; + + -- Logging Verbosity Level + constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM; + + constant BLK_NUM : natural := 8; + + ----------------------------------------------------------------------------- + -- Signal declarations + ----------------------------------------------------------------------------- + + signal reset_n : std_logic; + signal clk : std_logic := '0'; + signal avs_address : std_logic_vector(14 downto 0); + signal avs_write : std_logic; + signal avs_writedata : std_logic_vector(31 downto 0); + signal avs_read : std_logic; + signal avs_waitrequest : std_logic; + signal avs_readdata : std_logic_vector(31 downto 0); + signal cs_addr : std_logic_vector(10 downto 0); + signal cs_we : std_logic_vector(BLK_NUM-1 downto 0); + signal cs_wr_data : std_logic_vector(31 downto 0); + signal cs_re : std_logic_vector(BLK_NUM-1 downto 0); + signal cs_rv : std_logic_vector(BLK_NUM-1 downto 0); + signal cs_rd_data : std_logic_vector(32*BLK_NUM-1 downto 0); + -- + signal avs_m : mm_m_rec_t; + signal avs_s : mm_s_rec_t; + -- + signal end_of_stimuli : boolean; + signal test_completed : boolean; + signal setup : boolean; + signal running : boolean; + signal passed : boolean; + signal failed : boolean; + + shared variable error_flag : boolean; + + signal blk_0_re, blk_0_we, blk_0_rv, blk_0_re_d : std_logic; + signal blk_1_re, blk_1_we, blk_1_rv, blk_1_re_d : std_logic; + signal blk_0_wr_data, blk_0_rd_data : std_logic_vector(31 downto 0); + signal blk_1_wr_data, blk_1_rd_data : std_logic_vector(31 downto 0); + + + ----------------------------------------------------------------------------- + -- 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; + ----------------------------------------------------------------------------- + -- End declarative part + ----------------------------------------------------------------------------- + +begin -- architecture behav + + clk <= not clk after 0.5*CLK_PERIOD; + + ----------------------------------------------------------------------------- + -- UUT + ----------------------------------------------------------------------------- + + iUUT: entity work.cs_bus_ift + generic map ( + BLK_NUM => BLK_NUM, + READ_TIMEOUT => 32) + port map ( + rstN => reset_n, + clk => clk, + avs_address => avs_address, + avs_write => avs_write, + avs_writedata => avs_writedata, + avs_read => avs_read, + avs_waitrequest => avs_waitrequest, + avs_readdata => avs_readdata, + cs_addr => cs_addr, + cs_we => cs_we, + cs_wr_data => cs_wr_data, + cs_re => cs_re, + cs_rv => cs_rv, + cs_rd_data => cs_rd_data); + + -- Instantiate only 2 dummy blocks, leave the rest unconnected + blk_0_we <= cs_we(0); + blk_1_we <= cs_we(1); + + blk_0_re <= cs_re(0); + blk_1_re <= cs_re(1); + + cs_rv <= (0 => blk_0_rv, 1 => blk_1_rv, others => '0'); + + cs_rd_data(31 downto 0) <= blk_0_rd_data; + cs_rd_data(63 downto 32) <= blk_1_rd_data; + cs_rd_data(32*BLK_NUM-1 downto 64) <= (others => '1'); + + ----------------------------------------------------------------------------- + -- CS-BUS dummy pripherals + ----------------------------------------------------------------------------- + + pDUMMY_0 : process(clk) + variable rd_val_v : std_logic_vector(3 downto 0) := (others => '0'); + begin + if(clk = '1' and clk'event) then + if(blk_0_we = '1') then + blk_0_wr_data <= cs_wr_data; + end if; + blk_0_re_d <= blk_0_re; + if(blk_0_re = '1' and blk_0_re_d = '0') then + rd_val_v := (0 => '1', others => '0'); + else + rd_val_v := '0' & rd_val_v(rd_val_v'left downto 1); + end if; + if(rd_val_v(0) = '1') then + blk_0_rv <= '1'; + blk_0_rd_data <= X"AAAA0000"; + else + blk_0_rv <= '0'; + blk_0_rd_data <= X"0000BAD0"; + end if; + end if; + end process pDUMMY_0; + + pDUMMY_1 : process(clk) + variable rd_val_v : std_logic_vector(3 downto 0) := (others => '0'); + begin + if(clk = '1' and clk'event) then + if(blk_1_we = '1') then + blk_1_wr_data <= cs_wr_data; + end if; + blk_1_re_d <= blk_1_re; + if(blk_1_re = '1' and blk_1_re_d = '0') then + rd_val_v := (3 => '1', others => '0'); + else + rd_val_v := '0' & rd_val_v(rd_val_v'left downto 1); + end if; + if(rd_val_v(0) = '1') then + blk_1_rv <= '1'; + blk_1_rd_data <= X"BBBB0000"; + else + blk_1_rv <= '0'; + blk_1_rd_data <= X"0000BAD1"; + end if; + end if; + end process pDUMMY_1; + + ----------------------------------------------------------------------------- + -- Avalon interface + ----------------------------------------------------------------------------- + + clk_clk <= clk; + reset_reset_n <= reset_n; + + avs_s.mm_readdata <= avs_readdata; + + avs_s.mm_readdatavalid <= '0'; + + avs_s.mm_waitrequest <= avs_waitrequest; + avs_s.use_readvalid <= false; + + 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; + + ----------------------------------------------------------------------------- + -- Testbench Logic + ----------------------------------------------------------------------------- + + pTB_CTRL : process + + procedure wr_data( + blk : natural; + reg : natural; + data : in std_logic_vector(31 downto 0); + signal avs_s : in mm_s_rec_t; + signal avs_m : out mm_m_rec_t) is + + + variable addr : std_logic_vector(31 downto 0) := (others => '0'); + + begin + + addr := 17x"0" & std_logic_vector(to_unsigned(blk,4)) & std_logic_vector(to_unsigned(reg,11)); + mm_32b_write(addr, data, avs_s, avs_m); + + end procedure wr_data; + + procedure rd_data( + blk : natural; + reg : natural; + data : out std_logic_vector(31 downto 0); + signal avs_s : in mm_s_rec_t; + signal avs_m : out mm_m_rec_t) is + + + variable addr : std_logic_vector(31 downto 0) := (others => '0'); + + begin + + addr := 17x"0" & std_logic_vector(to_unsigned(blk,4)) & std_logic_vector(to_unsigned(reg,11)); + mm_32b_read(addr, data, avs_s, avs_m); + + end procedure rd_data; + + variable data : std_logic_vector(31 downto 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, use_waitrequest => true); + + log_header("verifying CS_BUS_ITF:", VLOW); + + setup <= false; + running <= false; + passed <= false; + error_flag := false; + + -- Reset + reset_n <= '0'; + wait for 100 ns; + wait until clk = '1' and clk'event; + reset_n <= '1'; + + wait for 200 ns; + running <= true; + + --------------------------------------------------------------------------- + -- Write & Read + --------------------------------------------------------------------------- + + wait_latency(clk, 20); + + wr_data(0, 4, X"A0A0B1B1", avs_s, avs_m); + wait_latency(clk, 5); + if(blk_0_wr_data /= X"A0A0B1B1") then + log("ERROR : Expecting written data A0A0B1B1 on block 0", VLOW); + error_flag := true; + end if; + + wait_latency(clk, 20); + wr_data(0, 8, X"C0C0D1D1", avs_s, avs_m); + wait_latency(clk, 5); + if(blk_0_wr_data /= X"C0C0D1D1") then + log("ERROR : Expecting written data C0C0D1D1 on block 1", VLOW); + error_flag := true; + end if; + + wait_latency(clk, 20); + wr_data(2, 0, X"EE00FF11", avs_s, avs_m); + wait_latency(clk, 20); + wr_data(7, 0, X"EE00FF11", avs_s, avs_m); + + + for blk_num in 0 to 7 loop + rd_data(blk_num, 16, data, avs_s, avs_m); + log("Read Data 0x" & to_hstring(data) & " from block " & to_string(blk_num), VLOW); + wait_latency(clk, 50); + end loop; -- blk_num + + wait_latency(clk, 50); + running <= false; + + wait for 5 us; + end_of_stimuli <= true; + if(error_flag = false) then + passed <= true after 100 ns; + end if; + 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; diff --git a/generic_ip/fire_pulse_manager/0/build/fire_pulse_manager_0_hw.tcl b/generic_ip/fire_pulse_manager/0/build/fire_pulse_manager_0_hw.tcl index ce5f8d6..4b8c2c2 100644 --- a/generic_ip/fire_pulse_manager/0/build/fire_pulse_manager_0_hw.tcl +++ b/generic_ip/fire_pulse_manager/0/build/fire_pulse_manager_0_hw.tcl @@ -1,11 +1,11 @@ # TCL File Generated by Component Editor 16.0 -# Wed Oct 25 15:26:07 BST 2017 +# Wed Jul 10 10:00:03 BST 2019 # DO NOT MODIFY # # fire_pulse_manager_0 "fire_pulse_manager_0" v1.0 -# GMG 2017.10.25.15:26:07 +# GMG 2019.07.10.10:00:03 # Fire Pulse Manager # @@ -40,12 +40,11 @@ add_fileset QUARTUS_SYNTH QUARTUS_SYNTH "" "" set_fileset_property QUARTUS_SYNTH TOP_LEVEL fire_pulse_manager_0 set_fileset_property QUARTUS_SYNTH ENABLE_RELATIVE_INCLUDE_PATHS false set_fileset_property QUARTUS_SYNTH ENABLE_FILE_OVERWRITE_MODE false -#add_fileset_file pkg_functions.vhd VHDL PATH ../../../common/0/src/pkg_functions.vhd add_fileset_file common_pkg.vhd VHDL PATH ../../../common/0/src/common_pkg.vhd add_fileset_file sync_reset.vhd VHDL PATH ../../../common/0/src/sync_reset.vhd add_fileset_file sync_wire.vhd VHDL PATH ../../../common/0/src/sync_wire.vhd add_fileset_file sync_wire_rEdge.vhd VHDL PATH ../../../common/0/src/sync_wire_rEdge.vhd -add_fileset_file fifo_1024x32.vhd VHDL PATH ../../../common/0//src/altera/fifo_1024x32.vhd +add_fileset_file fifo_1024x32.vhd VHDL PATH ../../../common/0/src/altera/fifo_1024x32.vhd add_fileset_file fifo_256x32.vhd VHDL PATH ../../../common/0/src/altera/fifo_256x32.vhd add_fileset_file sync_fifo.vhd VHDL PATH ../../../common/0/src/altera/sync_fifo.vhd add_fileset_file cs_bus_itf.vhd VHDL PATH ../../../common/0/src/cs_bus_itf.vhd @@ -72,12 +71,11 @@ add_fileset SIM_VHDL SIM_VHDL "" "" set_fileset_property SIM_VHDL TOP_LEVEL fire_pulse_manager_0 set_fileset_property SIM_VHDL ENABLE_RELATIVE_INCLUDE_PATHS false set_fileset_property SIM_VHDL ENABLE_FILE_OVERWRITE_MODE false -#add_fileset_file pkg_functions.vhd VHDL PATH ../../../common/0/src/pkg_functions.vhd add_fileset_file common_pkg.vhd VHDL PATH ../../../common/0/src/common_pkg.vhd add_fileset_file sync_reset.vhd VHDL PATH ../../../common/0/src/sync_reset.vhd add_fileset_file sync_wire.vhd VHDL PATH ../../../common/0/src/sync_wire.vhd add_fileset_file sync_wire_rEdge.vhd VHDL PATH ../../../common/0/src/sync_wire_rEdge.vhd -add_fileset_file fifo_1024x32.vhd VHDL PATH ../../../common/0//src/altera/fifo_1024x32.vhd +add_fileset_file fifo_1024x32.vhd VHDL PATH ../../../common/0/src/altera/fifo_1024x32.vhd add_fileset_file fifo_256x32.vhd VHDL PATH ../../../common/0/src/altera/fifo_256x32.vhd add_fileset_file sync_fifo.vhd VHDL PATH ../../../common/0/src/altera/sync_fifo.vhd add_fileset_file cs_bus_itf.vhd VHDL PATH ../../../common/0/src/cs_bus_itf.vhd @@ -98,7 +96,7 @@ add_fileset_file smb_diagnostics_0.vhd VHDL PATH ../src/smb_diagnostics_0.vhd add_fileset_file fire_pulse_0_pkg.vhd VHDL PATH ../src/fire_pulse_0_pkg.vhd add_fileset_file uart_regen_0.vhd VHDL PATH ../src/uart_regen_0.vhd add_fileset_file fire_pulse_ctrl_0.vhd VHDL PATH ../src/fire_pulse_ctrl_0.vhd -add_fileset_file fire_pulse_manager_0.vhd VHDL PATH ../src/fire_pulse_manager_0.vhd +add_fileset_file fire_pulse_manager_0.vhd VHDL PATH ../src/fire_pulse_manager_0.vhd # @@ -153,7 +151,7 @@ set_interface_property avs burstcountUnits WORDS set_interface_property avs explicitAddressSpan 0 set_interface_property avs holdTime 0 set_interface_property avs linewrapBursts false -set_interface_property avs maximumPendingReadTransactions 1 +set_interface_property avs maximumPendingReadTransactions 0 set_interface_property avs maximumPendingWriteTransactions 0 set_interface_property avs readLatency 0 set_interface_property avs readWaitTime 1 @@ -170,8 +168,8 @@ add_interface_port avs avs_address address Input 15 add_interface_port avs avs_write write Input 1 add_interface_port avs avs_writedata writedata Input 32 add_interface_port avs avs_read read Input 1 -add_interface_port avs avs_readdatavalid readdatavalid Output 1 add_interface_port avs avs_readdata readdata Output 32 +add_interface_port avs avs_waitrequest waitrequest Output 1 set_interface_assignment avs embeddedsw.configuration.isFlash 0 set_interface_assignment avs embeddedsw.configuration.isMemoryDevice 0 set_interface_assignment avs embeddedsw.configuration.isNonVolatileStorage 0 @@ -217,6 +215,7 @@ add_interface_port rx_clk rx_clk clk Input 1 add_interface irq_0 interrupt end set_interface_property irq_0 associatedAddressablePoint "" set_interface_property irq_0 associatedClock clock +set_interface_property irq_0 associatedReset reset set_interface_property irq_0 bridgedReceiverOffset "" set_interface_property irq_0 bridgesToReceiver "" set_interface_property irq_0 ENABLED true @@ -227,12 +226,14 @@ set_interface_property irq_0 SVD_ADDRESS_GROUP "" add_interface_port irq_0 ins_fpm_irq_0 irq Output 1 + # # connection point irq_1 # add_interface irq_1 interrupt end set_interface_property irq_1 associatedAddressablePoint "" set_interface_property irq_1 associatedClock clock +set_interface_property irq_1 associatedReset reset set_interface_property irq_1 bridgedReceiverOffset "" set_interface_property irq_1 bridgesToReceiver "" set_interface_property irq_1 ENABLED true @@ -243,12 +244,14 @@ set_interface_property irq_1 SVD_ADDRESS_GROUP "" add_interface_port irq_1 ins_fpm_irq_1 irq Output 1 + # # connection point irq_2 # add_interface irq_2 interrupt end set_interface_property irq_2 associatedAddressablePoint "" set_interface_property irq_2 associatedClock clock +set_interface_property irq_2 associatedReset reset set_interface_property irq_2 bridgedReceiverOffset "" set_interface_property irq_2 bridgesToReceiver "" set_interface_property irq_2 ENABLED true @@ -259,12 +262,14 @@ set_interface_property irq_2 SVD_ADDRESS_GROUP "" add_interface_port irq_2 ins_fpm_irq_2 irq Output 1 + # # connection point irq_3 # add_interface irq_3 interrupt end set_interface_property irq_3 associatedAddressablePoint "" set_interface_property irq_3 associatedClock clock +set_interface_property irq_3 associatedReset reset set_interface_property irq_3 bridgedReceiverOffset "" set_interface_property irq_3 bridgesToReceiver "" set_interface_property irq_3 ENABLED true diff --git a/generic_ip/fire_pulse_manager/0/src/fire_pulse_manager_0.vhd b/generic_ip/fire_pulse_manager/0/src/fire_pulse_manager_0.vhd index 84a2762..cc76782 100644 --- a/generic_ip/fire_pulse_manager/0/src/fire_pulse_manager_0.vhd +++ b/generic_ip/fire_pulse_manager/0/src/fire_pulse_manager_0.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2017-09-06 --- Last update: 2019-03-22 +-- Last update: 2019-07-10 -- SVN ID : Git -- Standard : VHDL'08 ------------------------------------------------------------------------------- @@ -45,7 +45,7 @@ entity fire_pulse_manager_0 is avs_write : in std_logic; avs_writedata : in std_logic_vector(31 downto 0); avs_read : in std_logic; - avs_readdatavalid : out std_logic; + avs_waitrequest : out std_logic; avs_readdata : out std_logic_vector(31 downto 0)); end entity fire_pulse_manager_0; @@ -162,7 +162,7 @@ begin avs_write => avs_write, avs_writedata => avs_writedata, avs_read => avs_read, - avs_readdatavalid => avs_readdatavalid, + avs_waitrequest => avs_waitrequest, avs_readdata => avs_readdata, cs_addr => cs_addr, cs_we => cs_write_en, From e41edbfbab2a4cc6b5c962dbe0ad20acc9d067f1 Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Fri, 12 Jul 2019 10:18:48 +0100 Subject: [PATCH 26/29] ELGIP-73 HMBXR5601-771 - avalon waitrequest signal is now asserted by default, which allows the signal to be generated in a sequential wasy, instead of being combinational --- generic_ip/common/0/sim/wave_cs_bus_itf.do | 3 +-- generic_ip/common/0/src/cs_bus_itf.vhd | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/generic_ip/common/0/sim/wave_cs_bus_itf.do b/generic_ip/common/0/sim/wave_cs_bus_itf.do index 1edb5e8..1203a93 100644 --- a/generic_ip/common/0/sim/wave_cs_bus_itf.do +++ b/generic_ip/common/0/sim/wave_cs_bus_itf.do @@ -52,13 +52,12 @@ add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/iUUT/cs_rd_data_i add wave -noupdate /cs_bus_itf_tb/iUUT/avs_read_d add wave -noupdate /cs_bus_itf_tb/iUUT/avs_rd_en add wave -noupdate /cs_bus_itf_tb/iUUT/read_valid -add wave -noupdate /cs_bus_itf_tb/iUUT/stall_read add wave -noupdate /cs_bus_itf_tb/iUUT/dummy_rv add wave -noupdate /cs_bus_itf_tb/iUUT/timeout_flag add wave -noupdate -radix unsigned /cs_bus_itf_tb/iUUT/read_timeout_cnt add wave -noupdate /cs_bus_itf_tb/iUUT/avs_address_i TreeUpdate [SetDefaultTree] -WaveRestoreCursors {{Cursor 1} {1273181 ps} 0} +WaveRestoreCursors {{Cursor 1} {515000 ps} 0} quietly wave cursor active 1 configure wave -namecolwidth 273 configure wave -valuecolwidth 187 diff --git a/generic_ip/common/0/src/cs_bus_itf.vhd b/generic_ip/common/0/src/cs_bus_itf.vhd index 3974670..63147de 100644 --- a/generic_ip/common/0/src/cs_bus_itf.vhd +++ b/generic_ip/common/0/src/cs_bus_itf.vhd @@ -10,7 +10,7 @@ -- Description: Split the memory space from the Avalon-MM I/F and drive the C&S -- bus for a programmable number of FW processing blocks ------------------------------------------------------------------------------- --- Last update: 2019-07-11 +-- Last update: 2019-07-12 ------------------------------------------------------------------------------- -- Revisions : -- Date Version Author Description @@ -57,7 +57,6 @@ architecture RTL of cs_bus_ift is signal avs_wr_en : std_logic; signal sel_read_valid : std_logic; signal read_valid : std_logic; - signal stall_read : std_logic; signal dummy_rv : std_logic; -- Dummy Read valid: asserted when -- trying to read from not allocated addresses signal timeout_flag : std_logic; @@ -78,10 +77,10 @@ begin cs_wr_data <= (others => '0'); cs_re <= (others => '0'); avs_readdata <= (others => '0'); + avs_waitrequest <= '1'; avs_read_d <= '0'; avs_write_d <= '0'; dummy_rv <= '0'; - stall_read <= '0'; elsif(clk = '1' and clk'event) then if(avs_write = '1' or avs_read = '1') then avs_address_i <= avs_address; @@ -116,10 +115,16 @@ begin elsif(dummy_rv = '1') then avs_readdata <= X"DEAD_BEEF"; end if; - if(avs_rd_en = '1') then - stall_read <= '1'; - elsif(read_valid = '1') then - stall_read <= '0'; + -- waitrequest can be decoupled from the read and write request signals. + -- waitrequest may be asserted during idle cycles. An Avalon-MM master may initiate + -- a transaction when waitrequest is asserted and wait for that signal to be + -- deasserted. Decoupling waitrequest from read and write requests may improve + -- system timing. Decoupling eliminates a combinational loop including the read, + -- write, and waitrequest signals. + if(avs_wr_en = '1' or read_valid = '1') then + avs_waitrequest <= '0'; + else + avs_waitrequest <= '1'; end if; if(avs_rd_en = '1') then read_timeout_cnt <= (others => '0'); @@ -136,8 +141,6 @@ begin avs_rd_en <= avs_read and not avs_read_d; avs_wr_en <= avs_write and not avs_write_d; - avs_waitrequest <= avs_rd_en or avs_wr_en or stall_read; - cs_addr <= avs_address_i(10 downto 0); timeout_flag <= '1' when unsigned(read_timeout_cnt) = READ_TIMEOUT else '0'; From fd0c0bb711ee53af504163c33a492aa2688b2f5d Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Fri, 12 Jul 2019 16:20:40 +0100 Subject: [PATCH 27/29] ELGIP-73 HMBXR5601-771 - The interface should now be able to serve contiguous accesses, with no gap between assertion of read/write enable --- generic_ip/common/0/sim/wave_cs_bus_itf.do | 2 + generic_ip/common/0/src/cs_bus_itf.vhd | 22 ++- .../common/0/src/test/cs_bus_itf_tb.vhd | 135 +++++++++++++++--- 3 files changed, 135 insertions(+), 24 deletions(-) diff --git a/generic_ip/common/0/sim/wave_cs_bus_itf.do b/generic_ip/common/0/sim/wave_cs_bus_itf.do index 1203a93..bffc129 100644 --- a/generic_ip/common/0/sim/wave_cs_bus_itf.do +++ b/generic_ip/common/0/sim/wave_cs_bus_itf.do @@ -51,6 +51,8 @@ add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/iUUT/cs_rd_data add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/iUUT/cs_rd_data_i add wave -noupdate /cs_bus_itf_tb/iUUT/avs_read_d add wave -noupdate /cs_bus_itf_tb/iUUT/avs_rd_en +add wave -noupdate /cs_bus_itf_tb/iUUT/avs_wr_en_d +add wave -noupdate /cs_bus_itf_tb/iUUT/busy add wave -noupdate /cs_bus_itf_tb/iUUT/read_valid add wave -noupdate /cs_bus_itf_tb/iUUT/dummy_rv add wave -noupdate /cs_bus_itf_tb/iUUT/timeout_flag diff --git a/generic_ip/common/0/src/cs_bus_itf.vhd b/generic_ip/common/0/src/cs_bus_itf.vhd index 63147de..f844e89 100644 --- a/generic_ip/common/0/src/cs_bus_itf.vhd +++ b/generic_ip/common/0/src/cs_bus_itf.vhd @@ -51,12 +51,14 @@ architecture RTL of cs_bus_ift is type rd_bus_t is array (0 to BLK_NUM-1) of std_logic_vector(31 downto 0); signal cs_rd_data_i : rd_bus_t; + signal busy : std_logic; signal avs_read_d : std_logic; signal avs_rd_en : std_logic; - signal avs_write_d : std_logic; signal avs_wr_en : std_logic; + signal avs_wr_en_d : std_logic; signal sel_read_valid : std_logic; signal read_valid : std_logic; + signal read_valid_d : std_logic; signal dummy_rv : std_logic; -- Dummy Read valid: asserted when -- trying to read from not allocated addresses signal timeout_flag : std_logic; @@ -78,15 +80,18 @@ begin cs_re <= (others => '0'); avs_readdata <= (others => '0'); avs_waitrequest <= '1'; + busy <= '0'; + avs_wr_en_d <= '0'; avs_read_d <= '0'; - avs_write_d <= '0'; + read_valid_d <= '0'; dummy_rv <= '0'; elsif(clk = '1' and clk'event) then if(avs_write = '1' or avs_read = '1') then avs_address_i <= avs_address; end if; - avs_read_d <= avs_read; - avs_write_d <= avs_write; + avs_wr_en_d <= avs_wr_en; + avs_read_d <= avs_read; + read_valid_d <= read_valid; for i in 0 to BLK_NUM-1 loop -- limit to 16 the maximum number of user blocks if(avs_wr_en = '1' and to_integer(unsigned(avs_address(avs_address'high downto avs_address'high-3))) = i) then @@ -126,6 +131,11 @@ begin else avs_waitrequest <= '1'; end if; + if(avs_wr_en = '1' or avs_rd_en = '1') then + busy <= '1'; + elsif(avs_wr_en_d = '1' or read_valid_d = '1') then + busy <= '0'; + end if; if(avs_rd_en = '1') then read_timeout_cnt <= (others => '0'); elsif(avs_read_d = '1') then @@ -138,8 +148,8 @@ begin read_valid <= dummy_rv or sel_read_valid; - avs_rd_en <= avs_read and not avs_read_d; - avs_wr_en <= avs_write and not avs_write_d; + avs_rd_en <= avs_read and not busy; + avs_wr_en <= avs_write and not busy; cs_addr <= avs_address_i(10 downto 0); diff --git a/generic_ip/common/0/src/test/cs_bus_itf_tb.vhd b/generic_ip/common/0/src/test/cs_bus_itf_tb.vhd index 31c0cfe..8b121c5 100644 --- a/generic_ip/common/0/src/test/cs_bus_itf_tb.vhd +++ b/generic_ip/common/0/src/test/cs_bus_itf_tb.vhd @@ -6,7 +6,7 @@ -- Author : GMG -- Company : Global Inkjet Systems -- Created : 2019-07-10 --- Last update: 2019-07-10 +-- Last update: 2019-07-12 -- SVN ID : Git -- Standard : VHDL'2008 ------------------------------------------------------------------------------- @@ -86,6 +86,66 @@ architecture behav of cs_bus_itf_tb is wait until clk = '1' and clk'event; end loop; -- i end procedure wait_latency; + + + procedure mm_32b_write_f( addr : in std_logic_vector(31 downto 0); + data : in std_logic_vector(31 downto 0); + skip_wait_re : in boolean := false; + signal mm_s_rec : in mm_s_rec_t; + signal mm_m_rec : out mm_m_rec_t) is + begin + wait until rising_edge(clk_clk); + mm_m_rec.mm_address <= addr or base_addr; + mm_m_rec.mm_byteenable <= "1111"; + mm_m_rec.mm_writedata <= data; + mm_m_rec.mm_write <= '1'; + wait until falling_edge(clk_clk); + if(mm_use_waitrequest.is_set = true and mm_s_rec.mm_waitrequest = '1') then + wait until falling_edge(mm_s_rec.mm_waitrequest); + end if; + if(skip_wait_re = false) then + wait until rising_edge(clk_clk); + else + wait until falling_edge(clk_clk); + end if; + mm_m_rec.mm_byteenable <= "0000"; + mm_m_rec.mm_write <= '0'; + end mm_32b_write_f; + + procedure mm_32b_read_f( addr : in std_logic_vector(31 downto 0); + data : out std_logic_vector(31 downto 0); + skip_wait_re : in boolean := false; + signal mm_s_rec : in mm_s_rec_t; + signal mm_m_rec : out mm_m_rec_t) is + begin + wait until rising_edge(clk_clk); + mm_m_rec.mm_address <= addr or base_addr; + mm_m_rec.mm_read <= '1'; + wait until falling_edge(clk_clk); + if(mm_use_waitrequest.is_set = true and mm_s_rec.mm_waitrequest = '1') then + wait until falling_edge(mm_s_rec.mm_waitrequest); + end if; + if(skip_wait_re = false) then + wait until rising_edge(clk_clk); + else + wait until falling_edge(clk_clk); + end if; + mm_m_rec.mm_read <= '0'; + if(mm_use_waitrequest.is_set = false) then + for n in 1 to mm_read_latency.get loop + wait until rising_edge(clk_clk); + end loop; -- n + end if; + if(mm_s_rec.use_readvalid = true) then + if(mm_s_rec.mm_readdatavalid = '0') then + wait until mm_s_rec.mm_readdatavalid = '1'; + end if; + end if; + --wait until falling_edge(clk_clk); + data := mm_s_rec.mm_readdata; + end mm_32b_read_f; + + ----------------------------------------------------------------------------- -- End declarative part ----------------------------------------------------------------------------- @@ -207,11 +267,12 @@ begin -- architecture behav pTB_CTRL : process procedure wr_data( - blk : natural; - reg : natural; - data : in std_logic_vector(31 downto 0); - signal avs_s : in mm_s_rec_t; - signal avs_m : out mm_m_rec_t) is + blk : natural; + reg : natural; + data : in std_logic_vector(31 downto 0); + signal avs_s : in mm_s_rec_t; + signal avs_m : out mm_m_rec_t; + skip_wait_re : boolean := false) is variable addr : std_logic_vector(31 downto 0) := (others => '0'); @@ -219,16 +280,17 @@ begin -- architecture behav begin addr := 17x"0" & std_logic_vector(to_unsigned(blk,4)) & std_logic_vector(to_unsigned(reg,11)); - mm_32b_write(addr, data, avs_s, avs_m); + mm_32b_write_f(addr, data, skip_wait_re, avs_s, avs_m); end procedure wr_data; procedure rd_data( - blk : natural; - reg : natural; - data : out std_logic_vector(31 downto 0); - signal avs_s : in mm_s_rec_t; - signal avs_m : out mm_m_rec_t) is + blk : natural; + reg : natural; + data : out std_logic_vector(31 downto 0); + signal avs_s : in mm_s_rec_t; + signal avs_m : out mm_m_rec_t; + skip_wait_re : boolean := false) is variable addr : std_logic_vector(31 downto 0) := (others => '0'); @@ -236,7 +298,7 @@ begin -- architecture behav begin addr := 17x"0" & std_logic_vector(to_unsigned(blk,4)) & std_logic_vector(to_unsigned(reg,11)); - mm_32b_read(addr, data, avs_s, avs_m); + mm_32b_read_f(addr, data, skip_wait_re, avs_s, avs_m); end procedure rd_data; @@ -256,6 +318,7 @@ begin -- architecture behav setup <= false; running <= false; passed <= false; + failed <= false; error_flag := false; -- Reset @@ -268,7 +331,7 @@ begin -- architecture behav running <= true; --------------------------------------------------------------------------- - -- Write & Read + -- Write & Read : pause between operations --------------------------------------------------------------------------- wait_latency(clk, 20); @@ -281,9 +344,9 @@ begin -- architecture behav end if; wait_latency(clk, 20); - wr_data(0, 8, X"C0C0D1D1", avs_s, avs_m); + wr_data(1, 8, X"C0C0D1D1", avs_s, avs_m); wait_latency(clk, 5); - if(blk_0_wr_data /= X"C0C0D1D1") then + if(blk_1_wr_data /= X"C0C0D1D1") then log("ERROR : Expecting written data C0C0D1D1 on block 1", VLOW); error_flag := true; end if; @@ -298,8 +361,42 @@ begin -- architecture behav rd_data(blk_num, 16, data, avs_s, avs_m); log("Read Data 0x" & to_hstring(data) & " from block " & to_string(blk_num), VLOW); wait_latency(clk, 50); - end loop; -- blk_num + end loop; -- blk_num + -- repeat the same test, but without pause between read/write accesses + + --------------------------------------------------------------------------- + -- Write & Read : no pause between operations + --------------------------------------------------------------------------- + + log_header("Repeating the test without pauses between accesses:", VLOW); + + wait_latency(clk, 20); + + wr_data(0, 4, X"A2A2B1B1", avs_s, avs_m, true); + /* + if(blk_0_wr_data /= X"A2A2B1B1") then + log("ERROR : Expecting written data A2A2B1B1 on block 0", VLOW); + error_flag := true; + end if; + */ + + wr_data(1, 8, X"C2C2D1D1", avs_s, avs_m, true); + /* + if(blk_1_wr_data /= X"C2C2D1D1") then + log("ERROR : Expecting written data C2C2D1D1 on block 1", VLOW); + error_flag := true; + end if; + */ + wr_data(2, 0, X"EE00FF11", avs_s, avs_m, true); + wr_data(7, 0, X"EE00FF11", avs_s, avs_m, true); + + + for blk_num in 0 to 7 loop + rd_data(blk_num, 16, data, avs_s, avs_m, true); + log("Read Data 0x" & to_hstring(data) & " from block " & to_string(blk_num), VLOW); + end loop; -- blk_num + wait_latency(clk, 50); running <= false; @@ -307,12 +404,14 @@ begin -- architecture behav end_of_stimuli <= true; if(error_flag = false) then passed <= true after 100 ns; + else + failed <= true; end if; wait; end process pTB_CTRL; - failed <= error_flag after 100 ns; + --failed <= error_flag after 100 ns; pREPORT_RESULT : process begin From 77d2808fd7dda72ad4f72001ab1f17f3e611e6fa Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Mon, 15 Jul 2019 15:01:03 +0100 Subject: [PATCH 28/29] ELGIP-73 - Created Major version 3 of the FPM, to reflect the change in cs_bus_itf.vhd --- generic_ip/fire_pulse_manager/3/Readme.txt | 3 + .../fire_pulse_manager/3/doc/fpm_ctrl_3.json | 310 ++++++++ .../fire_pulse_manager/3/doc/fpm_diags_1.json | 169 +++++ .../3/doc/fpm_event_log_1.json | 57 ++ .../3/doc/fpm_int_encoder_1.json | 1 + .../3/doc/fpm_net_sync_1.json | 57 ++ .../fire_pulse_manager/3/sim/sim_fpm.do | 89 +++ .../fire_pulse_manager/3/sim/sim_pof_txrx.do | 70 ++ .../fire_pulse_manager/3/sim/wave_fpm.do | 171 +++++ .../fire_pulse_manager/3/sim/wave_pof_txrx.do | 235 ++++++ .../3/src/fire_pulse_3_pkg.vhd | 38 + .../3/src/fire_pulse_ctrl_3.vhd | 276 +++++++ .../3/src/fire_pulse_ext_3.vhd | 108 +++ .../3/src/fire_pulse_manager_3.vhd | 421 +++++++++++ .../fire_pulse_manager/3/src/pof_rx_3.vhd | 358 +++++++++ .../3/src/test/fifo_16x8_3.vhd | 201 +++++ .../3/src/test/fire_pulse_manager_3_tb.vhd | 715 ++++++++++++++++++ .../3/src/test/pof_tx_3.vhd | 245 ++++++ .../3/src/test/pof_tx_rx_3_tb.vhd | 623 +++++++++++++++ .../3/src/test/uart_tx_3.vhd | 163 ++++ .../fire_pulse_manager/3/src/uart_regen_3.vhd | 160 ++++ .../fire_pulse_manager/3/src/uart_rx_3.vhd | 186 +++++ 22 files changed, 4656 insertions(+) create mode 100644 generic_ip/fire_pulse_manager/3/Readme.txt create mode 100644 generic_ip/fire_pulse_manager/3/doc/fpm_ctrl_3.json create mode 100644 generic_ip/fire_pulse_manager/3/doc/fpm_diags_1.json create mode 100644 generic_ip/fire_pulse_manager/3/doc/fpm_event_log_1.json create mode 100644 generic_ip/fire_pulse_manager/3/doc/fpm_int_encoder_1.json create mode 100644 generic_ip/fire_pulse_manager/3/doc/fpm_net_sync_1.json create mode 100644 generic_ip/fire_pulse_manager/3/sim/sim_fpm.do create mode 100644 generic_ip/fire_pulse_manager/3/sim/sim_pof_txrx.do create mode 100644 generic_ip/fire_pulse_manager/3/sim/wave_fpm.do create mode 100644 generic_ip/fire_pulse_manager/3/sim/wave_pof_txrx.do create mode 100644 generic_ip/fire_pulse_manager/3/src/fire_pulse_3_pkg.vhd create mode 100644 generic_ip/fire_pulse_manager/3/src/fire_pulse_ctrl_3.vhd create mode 100644 generic_ip/fire_pulse_manager/3/src/fire_pulse_ext_3.vhd create mode 100644 generic_ip/fire_pulse_manager/3/src/fire_pulse_manager_3.vhd create mode 100644 generic_ip/fire_pulse_manager/3/src/pof_rx_3.vhd create mode 100644 generic_ip/fire_pulse_manager/3/src/test/fifo_16x8_3.vhd create mode 100644 generic_ip/fire_pulse_manager/3/src/test/fire_pulse_manager_3_tb.vhd create mode 100644 generic_ip/fire_pulse_manager/3/src/test/pof_tx_3.vhd create mode 100644 generic_ip/fire_pulse_manager/3/src/test/pof_tx_rx_3_tb.vhd create mode 100644 generic_ip/fire_pulse_manager/3/src/test/uart_tx_3.vhd create mode 100644 generic_ip/fire_pulse_manager/3/src/uart_regen_3.vhd create mode 100644 generic_ip/fire_pulse_manager/3/src/uart_rx_3.vhd diff --git a/generic_ip/fire_pulse_manager/3/Readme.txt b/generic_ip/fire_pulse_manager/3/Readme.txt new file mode 100644 index 0000000..5e5e8a0 --- /dev/null +++ b/generic_ip/fire_pulse_manager/3/Readme.txt @@ -0,0 +1,3 @@ +FPM Major version 3: Multi-Channel FPM. The initial version differs from major version 1 +only in the cs_bus_itf block, which uses Avalon waitrequest instead of readdatavalid to +achieve a variable read latency \ No newline at end of file diff --git a/generic_ip/fire_pulse_manager/3/doc/fpm_ctrl_3.json b/generic_ip/fire_pulse_manager/3/doc/fpm_ctrl_3.json new file mode 100644 index 0000000..bbceca8 --- /dev/null +++ b/generic_ip/fire_pulse_manager/3/doc/fpm_ctrl_3.json @@ -0,0 +1,310 @@ +[{ + "ip_name": "fpm_ctrl_3", + "bus": "csr", + "description": "This block is the fire pulse manager control", + "registers": { + "ip_id" : { + "address" : "0", + "width" : "32", + "description" : "Unique ID for this IP block", + "fields": { + "ip_number" : { + "type" : "c", + "bit_len" : "8", + "reset" : "0x14", + "description" : "IP identifier number" + }, + "mfr_number" : { + "type" : "c", + "bit_len" : "8", + "reset" : "0xFF", + "description" : "Manufacturer number" + + }, + "reserved" : { + "type" : "rsv", + "bit_len" : "16", + "description" : "Reserved bits" + } + } + }, + "ip_ver" : { + "address" : "1", + "width" : "32", + "description" : "IP Version", + "fields": { + "minor_number" : { + "type" : "c", + "bit_len" : "8", + "reset" : "0x00", + "description" : "Minor number" + }, + "major_number" : { + "type" : "c", + "bit_len" : "8", + "reset" : "0x03", + "description" : "Major number" + + }, + "reserved" : { + "type" : "rsv", + "bit_len" : "16", + "description" : "Reserved bits" + } + } + }, + "Signal selection": { + "address": "2", + "width": "2", + "description": "Controls signal selection", + "fields": { + "fire_pulse_sel": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "0 => Use External fire pulses, 1 => Use FPM fire pulses" + }, + "enc_pd_emul_en": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "0 => Use POF RX, 1 => Use internal enc/PD emulator" + } + } + }, + "pof_receiver_control": { + "address": "3", + "width": "8", + "description": "Controls POF receiver", + "fields": { + "pof_rx_enable": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "0 => Disable POF RX, 1 => Enable POF RX" + }, + "uart_regeneration_bypass": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "0 => Use UART Regeneration, 1 => Bypass UART Regeneration" + }, + "clear_max": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "0 => Disabled, 1 => Load the current value of Absolute Position as new maximum" + }, + "clear_min": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "0 => Disabled, 1 => Load the current value of Absolute Position as new miniumum" + }, + "uart_rx_div": { + "type": "w", + "bit_len": "4", + "reset": "0x4", + "description": "Defines the number of 200 MHz clock cycles per UART data bit" + } + } + }, + "monitoring_point_selection": { + "address": "4", + "width": "16", + "description": "Selects monitoring points for external header", + "fields": { + "mp0": { + "type": "w", + "bit_len": "4", + "reset": "0x0", + "description": "Selects first monitoring point" + }, + "mp1": { + "type": "w", + "bit_len": "4", + "reset": "0x0", + "description": "Selects second monitoring point" + }, + "mp2": { + "type": "w", + "bit_len": "4", + "reset": "0x0", + "description": "Selects third monitoring point" + }, + "mp3": { + "type": "w", + "bit_len": "4", + "reset": "0x0", + "description": "Selects fourth monitoring point" + } + } + }, + "coarse_time_init": { + "type": "w", + "address": "5", + "reset": "0x00000000", + "width": "32", + "description": "Defines coarse time counter value" + }, + "fine_time_init": { + "address": "6", + "width": "29", + "description": "Fine time counter value/Load counter enable", + "fields": { + "fine_time_init": { + "type" :"w", + "bit_len": "28", + "reset": "0x0000000", + "description": "Defines fine time counter value" + }, + "time_load_en": { + "type" :"w", + "bit_len" : "1", + "reset": "0x0", + "description" : "Writting 1 loads the coarse and fine time counters" + } + } + }, + "fine_time_status": { + "type": "r", + "address": "7", + "reset": "0x0000000", + "width": "28", + "description": "Current fine time counter value" + }, + "coarse_time_status": { + "type": "r", + "address": "8", + "reset": "0x00000000", + "width": "32", + "description": "Current coarse time counter value" + }, + "pof_rx_status": { + "address": "9", + "width": "32", + "description": "Status of POF receiver", + "fields": { + "parity_bit_error_count": { + "type": "r", + "bit_len": "16", + "reset": "0x0000", + "description": "Counts number of parity errors" + }, + "skipped_position_error_count": { + "type": "r", + "bit_len": "16", + "reset": "0x0000", + "description": "Counts position skipped type errors" + } + } + }, + "pof_rx_control": { + "address": "10", + "width": "12", + "description": "POF receiver error control", + "fields": { + "error_rate_thres": { + "type" : "w", + "bit_len": "8", + "reset": "0x0A", + "description": "Defines RX error rate threshold" + }, + "rx_watchdog_en": { + "type": "w", + "bit_len": "1", + "reset": "0x1", + "description": "0 => Disable RX watchdog, 1 => Enable RX Watchdog" + }, + "rx_watchdog_clr": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "0 => RX watchdog counter running, 1 => Clear RX watchdog counter" + }, + "rx_watchdog": { + "type": "r", + "bit_len": "1", + "reset": "0x0", + "description": "0 => RX watchdog not triggered, 1 => RX watchdog triggered" + }, + "rx_error_flag": { + "type": "r", + "bit_len": "1", + "reset": "0x0", + "description": "0 => Error rate below threshold, 1 => Error rate above threshold" + } + } + }, + "fpm_interrupt": { + "address": "11", + "width": "16", + "description": "Interrupt control", + "fields": { + "irq_en": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "0 => Disable IRQ, 1 => Enable IRQ" + }, + "reserved1": { + "type": "rsv", + "bit_len": "3", + "description": "Reserved" + }, + "irq_clr": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "0 => Don't clear pending IRQ, 1 => Clear pending IRQ" + }, + "reserved2": { + "type": "rsv", + "bit_len": "3", + "description": "Reserved" + }, + "irq_mask": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "0 => IRQ not masked, 1 => IRQ masked" + }, + "reserved3": { + "type": "rsv", + "bit_len": "3", + "description": "Reserved" + }, + "irq_status": { + "type": "r", + "bit_len": "1", + "reset": "0x0", + "description": "0 => IRQ not active, 1 => IRQ active" + }, + "reserved4": { + "type": "rsv", + "bit_len": "3", + "description": "Reserved" + } + } + }, + "fpm_ext_ctrl": { + "address": "12", + "width": "32", + "description": "Controls regeneration of external fire pulses", + "fields": { + "ext_fp_det": { + "type": "w", + "bit_len": "16", + "reset": "0x0010", + "description": "Minimum width of external fire pulses" + }, + "ext_fp_gen": { + "type": "w", + "bit_len": "16", + "reset": "0x0020", + "description": "Width of regenerated external fire pulses" + } + } + } + } + }] \ No newline at end of file diff --git a/generic_ip/fire_pulse_manager/3/doc/fpm_diags_1.json b/generic_ip/fire_pulse_manager/3/doc/fpm_diags_1.json new file mode 100644 index 0000000..c5ab54e --- /dev/null +++ b/generic_ip/fire_pulse_manager/3/doc/fpm_diags_1.json @@ -0,0 +1,169 @@ +[{ + "ip_name": "fpm_diags_1", + "bus": "csr", + "description": "This block is the fire pulse manager diagnostics", + "registers": { + "init": { + "type": "w", + "address": "0", + "reset": "0x00", + "width": "32", + "description": "Write 1 then 0 to initialize the diagnostics block" + }, + "input_status": { + "address": "1", + "width": "13", + "description": "Instantaneous status of input signals", + "fields": { + "Rs422Phase0Input": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "" + }, + "Rs422Phase1Input": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "" + }, + "Rs422ZeroPhase": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "" + }, + "Rs422ProductDetect": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "" + }, + "TtlPhase0Input": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "" + }, + "TtlPhase1Input": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "" + }, + "TtlProductDetect": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "" + }, + "FilteredPhase0Input": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "" + }, + "FilteredPhase1Input": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "" + }, + "FilteredZeroPhase": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "" + }, + "FilteredProductDetect": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "" + }, + "EmsEncoderOutput": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "" + }, + "EmsProductDetectOutput": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "" + } + } + }, + "phase0_counter": { + "type": "r", + "address": "2", + "reset": "0x0", + "width": "32", + "description": "" + }, + "phase1_counter": { + "type": "r", + "address": "3", + "reset": "0x0", + "width": "32", + "description": "" + }, + "ems_encoder_output_counter": { + "type": "r", + "address": "6", + "reset": "0x0", + "width": "32", + "description": "" + }, + "ems_pd_output_counter": { + "type": "r", + "address": "7", + "reset": "0x0", + "width": "32", + "description": "" + }, + "fire_request_channel_counter": { + "type": "r", + "address": "8", + "reset": "0x0", + "width": "32", + "description": "" + }, + "delta_time_measurement_interval": { + "type": "w", + "address": "16", + "reset": "0x0", + "width": "32", + "description": "" + }, + "position": { + "type": "r", + "address": "17", + "reset": "0x0", + "width": "32", + "description": "" + }, + "delta_position_measurement_interval": { + "type": "w", + "address": "20", + "reset": "0x0", + "width": "32", + "description": "" + }, + "delta_position_fifo_control": { + "type": "w", + "address": "21", + "reset": "0x0", + "width": "32", + "description": "" + }, + "irq_management": { + "type": "w", + "address": "27", + "reset": "0x0", + "width": "32", + "description": "" + } + } +}] \ No newline at end of file diff --git a/generic_ip/fire_pulse_manager/3/doc/fpm_event_log_1.json b/generic_ip/fire_pulse_manager/3/doc/fpm_event_log_1.json new file mode 100644 index 0000000..c15e178 --- /dev/null +++ b/generic_ip/fire_pulse_manager/3/doc/fpm_event_log_1.json @@ -0,0 +1,57 @@ +[{ + "ip_name" : "fpm_event_log_1", + "bus" : "csr", + "description" : "This block is the fire pulse manager diags", + "registers" : { + "ip_id" : { + "address" : "0", + "width" : "32", + "description" : "Unique ID for this IP block", + "fields": { + "ip_number" : { + "type" : "c", + "bit_len" : "8", + "reset" : "0xFF", + "description" : "IP identifier number (unknown)" + }, + "mfr_number" : { + "type" : "c", + "bit_len" : "8", + "reset" : "0xFF", + "description" : "Manufacturer number" + + }, + "reserved" : { + "type" : "rsv", + "bit_len" : "16", + "description" : "Reserved bits" + } + } + }, + "ip_ver" : { + "address" : "1", + "width" : "32", + "description" : "Bits[7:0] = Minor version number, Bits[15:8] = Major version number, etc.", + "fields": { + "minor_number" : { + "type" : "c", + "bit_len" : "8", + "reset" : "0x01", + "description" : "Minor number" + }, + "major_number" : { + "type" : "c", + "bit_len" : "8", + "reset" : "0x00", + "description" : "Major number" + + }, + "reserved" : { + "type" : "rsv", + "bit_len" : "16", + "description" : "Reserved bits" + } + } + } + } +}] \ No newline at end of file diff --git a/generic_ip/fire_pulse_manager/3/doc/fpm_int_encoder_1.json b/generic_ip/fire_pulse_manager/3/doc/fpm_int_encoder_1.json new file mode 100644 index 0000000..2f57100 --- /dev/null +++ b/generic_ip/fire_pulse_manager/3/doc/fpm_int_encoder_1.json @@ -0,0 +1 @@ +### REPLACED BY THE ENC/PD EMULATOR BLOCK ### diff --git a/generic_ip/fire_pulse_manager/3/doc/fpm_net_sync_1.json b/generic_ip/fire_pulse_manager/3/doc/fpm_net_sync_1.json new file mode 100644 index 0000000..959f62b --- /dev/null +++ b/generic_ip/fire_pulse_manager/3/doc/fpm_net_sync_1.json @@ -0,0 +1,57 @@ +[{ + "ip_name" : "fpm_net_sync_1", + "bus" : "csr", + "description" : "This block is the fire pulse manager net sync", + "registers" : { + "ip_id" : { + "address" : "0", + "width" : "32", + "description" : "Unique ID for this IP block", + "fields": { + "ip_number" : { + "type" : "c", + "bit_len" : "8", + "reset" : "0xFF", + "description" : "IP identifier number (unknown)" + }, + "mfr_number" : { + "type" : "c", + "bit_len" : "8", + "reset" : "0xFF", + "description" : "Manufacturer number" + + }, + "reserved" : { + "type" : "rsv", + "bit_len" : "16", + "description" : "Reserved bits" + } + } + }, + "ip_ver" : { + "address" : "1", + "width" : "32", + "description" : "Bits[7:0] = Minor version number, Bits[15:8] = Major version number, etc.", + "fields": { + "minor_number" : { + "type" : "c", + "bit_len" : "8", + "reset" : "0x01", + "description" : "Minor number" + }, + "major_number" : { + "type" : "c", + "bit_len" : "8", + "reset" : "0x00", + "description" : "Major number" + + }, + "reserved" : { + "type" : "rsv", + "bit_len" : "16", + "description" : "Reserved bits" + } + } + } + } +}] \ No newline at end of file diff --git a/generic_ip/fire_pulse_manager/3/sim/sim_fpm.do b/generic_ip/fire_pulse_manager/3/sim/sim_fpm.do new file mode 100644 index 0000000..feb48d1 --- /dev/null +++ b/generic_ip/fire_pulse_manager/3/sim/sim_fpm.do @@ -0,0 +1,89 @@ +# Multi-channel FPM Simulation macro + +.main clear + +# Path variables +set COMMON_PATH ../../../common/0/src +set GENERIC_PATH ../../../ +set OSVVM_PATH ../../../common/0/src/test/OSVVM +set SRC_PATH ../src +set TB_PATH ../src/test + +set WORKLIB work + +vlib ./work +vmap work ./work + +# Compile OSVVM lib +vlib OSVVM +vcom -2008 -work OSVVM $OSVVM_PATH/RandomBasePkg.vhd +vcom -2008 -work OSVVM $OSVVM_PATH/SortListPkg_int.vhd +vcom -2008 -work OSVVM $OSVVM_PATH/RandomPkg.vhd + +# Compile the testbench support files: + +# Log package and common +vcom -2008 -work $WORKLIB $COMMON_PATH/sync_reset.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/sync_wire.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/sync_wire_redge.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/cs_bus_itf.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/common_pkg.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/test/common_test_pkg.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/test/log_pkg.vhd + +# Compile the VHDL packages that support bus protocols, memory mapped registers and functional procedures +vcom -2008 -work $WORKLIB $COMMON_PATH/test/avalon_verify_pkg.vhd + +# Generic Sequencer +vcom -2008 -work $WORKLIB $GENERIC_PATH/generic_sequencer/15/src/altera/generic_seq_ram_15.vhd +vcom -2008 -work $WORKLIB $GENERIC_PATH/generic_sequencer/15/src/generic_sequencer_15_pkg.vhd +vcom -2008 -work $WORKLIB $GENERIC_PATH/generic_sequencer/15/src/generic_sequencer_15.vhd + +# Pulse Generator +vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/altera/sync_fifo_1.vhd +vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/pulse_generator_1_pkg.vhd +vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/pulse_conditioning_1.vhd +vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/queue_and_delay_1.vhd +vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/simple_frac_div_1.vhd +vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/pulse_generator_1.vhd + +# Enc PD Emul +vcom -2008 -work $WORKLIB $GENERIC_PATH/enc_pd_emul/1/src/enc_pd_emul_1_pkg.vhd +vcom -2008 -work $WORKLIB $GENERIC_PATH/enc_pd_emul/1/src/enc_pd_emul_1.vhd + +# Fire-Pulse-Manager +vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_3_pkg.vhd +vcom -2008 -work $WORKLIB $SRC_PATH/uart_rx_3.vhd +vcom -2008 -work $WORKLIB $SRC_PATH/uart_regen_3.vhd +vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_ctrl_3.vhd +vcom -2008 -work $WORKLIB $SRC_PATH/pof_rx_3.vhd +vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_ext_3.vhd +vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_manager_3.vhd + +# POF TX +vcom -2008 -work $WORKLIB $TB_PATH/fifo_16x8_3.vhd +vcom -2008 -work $WORKLIB $TB_PATH/uart_tx_3.vhd +vcom -2008 -work $WORKLIB $TB_PATH/pof_tx_3.vhd + +# Testbench +vcom -2008 -work $WORKLIB $TB_PATH/fire_pulse_manager_3_tb.vhd + +# Load design +vsim -t ps work.fire_pulse_manager_3_tb + +# Add waves +#add wave -r sim:/fire_pulse_manager_1_tb/* +do wave_fpm.do + +# remove warnings from standard numeric/arithmetic packages (speed-up simulation) +set StdArithNoWarnings 1 +set NumericStdNoWarnings 1 + +when -label end_of_simulation {test_completed == true} {echo "Simulation Completed"; stop ;} +run -all + + + + + + diff --git a/generic_ip/fire_pulse_manager/3/sim/sim_pof_txrx.do b/generic_ip/fire_pulse_manager/3/sim/sim_pof_txrx.do new file mode 100644 index 0000000..8cf642a --- /dev/null +++ b/generic_ip/fire_pulse_manager/3/sim/sim_pof_txrx.do @@ -0,0 +1,70 @@ +# Simulation macro + +.main clear + +set COMP_ONLY 0 + +set TB_PATH ./../src/test +set COMMON_PATH ../../../common/0/src +set OSVVM_PATH $COMMON_PATH/test/OSVVM + +set WORKLIB work + +vlib ./work +vmap work ./work + +if {$COMP_ONLY == 0} { +# Compile the constrained random related packages + vlib OSVVM + vcom -2008 -work OSVVM \ + $OSVVM_PATH/RandomBasePkg.vhd \ + $OSVVM_PATH/SortListPkg_int.vhd \ + $OSVVM_PATH/RandomPkg.vhd \ + $OSVVM_PATH/NamePkg.vhd \ + $OSVVM_PATH/MessagePkg.vhd \ + $OSVVM_PATH/CoveragePkg.vhd +} + +# compile the UUTs: +#vcom -2008 -work $WORKLIB $COMMON_PATH/pkg_functions.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/sync_wire.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/sync_wire_redge.vhd +vcom -2008 -work $WORKLIB ../src/uart_rx_3.vhd +vcom -2008 -work $WORKLIB ../src/pof_rx_3.vhd + + +# Compile the testbench and the other components supporting the test +if {$COMP_ONLY == 0} { + # Test support packages + vcom -2008 -work $WORKLIB $COMMON_PATH/test/common_test_pkg.vhd + vcom -2008 -work $WORKLIB $COMMON_PATH/test/log_pkg.vhd + vcom -2008 -work $WORKLIB $COMMON_PATH/test/avalon_verify_pkg.vhd + + # Testbench + # in fire pulse manager, the tx components are part of the testbench + vcom -2008 -work $WORKLIB $TB_PATH/fifo_16x8_3.vhd + vcom -2008 -work $WORKLIB $TB_PATH/uart_tx_3.vhd + vcom -2008 -work $WORKLIB $TB_PATH/pof_tx_3.vhd + vcom -2008 -work $WORKLIB $TB_PATH/pof_tx_rx_3_tb.vhd + + vsim -t ps work.pof_tx_rx_3_tb + + #add wave /pof_tx_rx_tb/* + #add wave /pof_tx_rx_tb/iPOF_TX/* + #add wave /pof_tx_rx_tb/iPOF_RX/* + + # remove warnings from standard numeric/arithmetic packages (speed-up simulation) + set StdArithNoWarnings 1 + set NumericStdNoWarnings 1 + + do wave_pof_txrx.do + + when -label end_of_simulation {test_completed == true} {echo "Simulation Completed"; stop ;} + run -all + + #run 1 ms; +} + + + + diff --git a/generic_ip/fire_pulse_manager/3/sim/wave_fpm.do b/generic_ip/fire_pulse_manager/3/sim/wave_fpm.do new file mode 100644 index 0000000..a909b1d --- /dev/null +++ b/generic_ip/fire_pulse_manager/3/sim/wave_fpm.do @@ -0,0 +1,171 @@ +onerror {resume} +quietly WaveActivateNextPane {} 0 +add wave -noupdate -group TB /fire_pulse_manager_3_tb/ch_offset +add wave -noupdate -group TB /fire_pulse_manager_3_tb/reset_n +add wave -noupdate -group TB /fire_pulse_manager_3_tb/clk +add wave -noupdate -group TB /fire_pulse_manager_3_tb/rx_clk +add wave -noupdate -group TB /fire_pulse_manager_3_tb/pof_tx +add wave -noupdate -group TB /fire_pulse_manager_3_tb/pof_rx +add wave -noupdate -group TB /fire_pulse_manager_3_tb/ch_pulse_out +add wave -noupdate -group TB /fire_pulse_manager_3_tb/avs_address +add wave -noupdate -group TB /fire_pulse_manager_3_tb/avs_write +add wave -noupdate -group TB /fire_pulse_manager_3_tb/avs_writedata +add wave -noupdate -group TB /fire_pulse_manager_3_tb/avs_read +add wave -noupdate -group TB /fire_pulse_manager_3_tb/avs_waitrequest +add wave -noupdate -group TB /fire_pulse_manager_3_tb/avs_readdata +add wave -noupdate -group TB /fire_pulse_manager_3_tb/init_tx +add wave -noupdate -group TB /fire_pulse_manager_3_tb/pd_in +add wave -noupdate -group TB /fire_pulse_manager_3_tb/pd_spy +add wave -noupdate -group TB /fire_pulse_manager_3_tb/inc_pos +add wave -noupdate -group TB /fire_pulse_manager_3_tb/dec_pos +add wave -noupdate -group TB /fire_pulse_manager_3_tb/abs_position +add wave -noupdate -group TB /fire_pulse_manager_3_tb/abs_spy +add wave -noupdate -group TB /fire_pulse_manager_3_tb/tx_data +add wave -noupdate -group TB /fire_pulse_manager_3_tb/abs_position_d +add wave -noupdate -group TB /fire_pulse_manager_3_tb/dir_in +add wave -noupdate -group TB /fire_pulse_manager_3_tb/swathe_cnt +add wave -noupdate -group TB /fire_pulse_manager_3_tb/swathe_pos +add wave -noupdate -group TB /fire_pulse_manager_3_tb/end_of_swathe +add wave -noupdate -group TB /fire_pulse_manager_3_tb/test_completed +add wave -noupdate -group TB /fire_pulse_manager_3_tb/running +add wave -noupdate -group TB /fire_pulse_manager_3_tb/configuring +add wave -noupdate -group TB /fire_pulse_manager_3_tb/passed +add wave -noupdate -group TB /fire_pulse_manager_3_tb/failed +add wave -noupdate -group TB /fire_pulse_manager_3_tb/stimuli_completed +add wave -noupdate -group TB /fire_pulse_manager_3_tb/detected_error +add wave -noupdate -group TB /fire_pulse_manager_3_tb/registers_read +add wave -noupdate -group TB /fire_pulse_manager_3_tb/reprogram_offset +add wave -noupdate -group TB /fire_pulse_manager_3_tb/avs_m +add wave -noupdate -group TB /fire_pulse_manager_3_tb/avs_s +add wave -noupdate -group TB /fire_pulse_manager_3_tb/sel_slave_0 +add wave -noupdate -group TB /fire_pulse_manager_3_tb/sel_slave_1 +add wave -noupdate -group TB /fire_pulse_manager_3_tb/pd_cnt +add wave -noupdate -group TB /fire_pulse_manager_3_tb/fp_cnt +add wave -noupdate -group TB /fire_pulse_manager_3_tb/tx_clk +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/reset_n +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/clk +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/init +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/rx_clk +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/rx_data +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/init_out +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/dp_dir +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/enc_out +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/pd_out +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/inc_pos +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/dec_pos +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/abs_pos +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/enable +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/bit_div +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/error_rate_thres +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/one_pps +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/upd_max_pos +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/upd_min_pos +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/max_error_flag +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/rx_watchdog +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/rx_watchdog_en +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/rx_watchdog_clr +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/parity_err_cnt +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/skip_pos_cnt +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/clear +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/symbol_ok +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/inc_pos_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/dec_pos_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/sync_gen +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/pd_gen +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/symbol_error +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/sync_d +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/symbol_valid +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/symbol_valid_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/symbol_valid_d +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/toggle_sync +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/sync_confirmed +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/sync_toggle_test +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/sync +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/toggle_pd +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/pd_confirmed +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/pd_toggle_test +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/pd +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/valid_pos +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/upd_pos +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/corr_done +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/corr_sign +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/skip_pos +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/apply_corr +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/inc_pos_ii +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/dec_pos_ii +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/new_max +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/new_min +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/rx_error +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/rx_error_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/rx_symbol_val +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/clear_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/skip_pos_d +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/pos_recovery +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/dp_dir_d +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/dp_dir_change +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/max_error_flag_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/clk_cnt +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/dist +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/abs_dist +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/skip_cnt +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/next_pos_lsb +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/curr_pos_lsb +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/pos_corr +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/max_dist +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/rx_error_v +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/gray_pos +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/rx_symbol_val_v +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/symbol +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/symbol_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/rx_symbol +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/rx_wd_cnt +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/parity_err_cnt_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/skip_pos_cnt_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/error_rate_cnt +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/error_rate +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/abs_pos_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/pos_max +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/pos_min +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/dist_pos +add wave -noupdate -group {POF RX} /fire_pulse_manager_3_tb/iDUT/iPOF_RX/dist_neg +add wave -noupdate -group UART_RX /fire_pulse_manager_3_tb/iDUT/iPOF_RX/iRX_SYMBOL/reset_n +add wave -noupdate -group UART_RX /fire_pulse_manager_3_tb/iDUT/iPOF_RX/iRX_SYMBOL/clk +add wave -noupdate -group UART_RX /fire_pulse_manager_3_tb/iDUT/iPOF_RX/iRX_SYMBOL/bit_div +add wave -noupdate -group UART_RX /fire_pulse_manager_3_tb/iDUT/iPOF_RX/iRX_SYMBOL/init +add wave -noupdate -group UART_RX /fire_pulse_manager_3_tb/iDUT/iPOF_RX/iRX_SYMBOL/data_out +add wave -noupdate -group UART_RX /fire_pulse_manager_3_tb/iDUT/iPOF_RX/iRX_SYMBOL/data_out_valid +add wave -noupdate -group UART_RX /fire_pulse_manager_3_tb/iDUT/iPOF_RX/iRX_SYMBOL/rx_error +add wave -noupdate -group UART_RX /fire_pulse_manager_3_tb/iDUT/iPOF_RX/iRX_SYMBOL/rx_data +add wave -noupdate -group UART_RX /fire_pulse_manager_3_tb/iDUT/iPOF_RX/iRX_SYMBOL/fsm_state_curr +add wave -noupdate -group UART_RX /fire_pulse_manager_3_tb/iDUT/iPOF_RX/iRX_SYMBOL/fsm_state_next +add wave -noupdate -group UART_RX /fire_pulse_manager_3_tb/iDUT/iPOF_RX/iRX_SYMBOL/rx_data_i +add wave -noupdate -group UART_RX /fire_pulse_manager_3_tb/iDUT/iPOF_RX/iRX_SYMBOL/shf_data +add wave -noupdate -group UART_RX /fire_pulse_manager_3_tb/iDUT/iPOF_RX/iRX_SYMBOL/rst_bit_cnt +add wave -noupdate -group UART_RX /fire_pulse_manager_3_tb/iDUT/iPOF_RX/iRX_SYMBOL/inc_bit_cnt +add wave -noupdate -group UART_RX /fire_pulse_manager_3_tb/iDUT/iPOF_RX/iRX_SYMBOL/rst_clk_cnt +add wave -noupdate -group UART_RX /fire_pulse_manager_3_tb/iDUT/iPOF_RX/iRX_SYMBOL/end_of_bit +add wave -noupdate -group UART_RX /fire_pulse_manager_3_tb/iDUT/iPOF_RX/iRX_SYMBOL/end_of_rx +add wave -noupdate -group UART_RX /fire_pulse_manager_3_tb/iDUT/iPOF_RX/iRX_SYMBOL/data_valid +add wave -noupdate -group UART_RX /fire_pulse_manager_3_tb/iDUT/iPOF_RX/iRX_SYMBOL/stop_bit +add wave -noupdate -group UART_RX /fire_pulse_manager_3_tb/iDUT/iPOF_RX/iRX_SYMBOL/rx_error_i +add wave -noupdate -group UART_RX /fire_pulse_manager_3_tb/iDUT/iPOF_RX/iRX_SYMBOL/data +add wave -noupdate -group UART_RX /fire_pulse_manager_3_tb/iDUT/iPOF_RX/iRX_SYMBOL/clk_cnt +add wave -noupdate -group UART_RX /fire_pulse_manager_3_tb/iDUT/iPOF_RX/iRX_SYMBOL/bit_cnt +TreeUpdate [SetDefaultTree] +WaveRestoreCursors {{Cursor 1} {0 ps} 0} +quietly wave cursor active 0 +configure wave -namecolwidth 150 +configure wave -valuecolwidth 100 +configure wave -justifyvalue left +configure wave -signalnamewidth 1 +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 {64332055 ps} {64335156 ps} diff --git a/generic_ip/fire_pulse_manager/3/sim/wave_pof_txrx.do b/generic_ip/fire_pulse_manager/3/sim/wave_pof_txrx.do new file mode 100644 index 0000000..968aa2a --- /dev/null +++ b/generic_ip/fire_pulse_manager/3/sim/wave_pof_txrx.do @@ -0,0 +1,235 @@ +onerror {resume} +quietly WaveActivateNextPane {} 0 +add wave -noupdate /pof_tx_rx_3_tb/reset_n +add wave -noupdate /pof_tx_rx_3_tb/hmb_clk +add wave -noupdate /pof_tx_rx_3_tb/sm_clk +add wave -noupdate /pof_tx_rx_3_tb/avs_read +add wave -noupdate /pof_tx_rx_3_tb/avs_write +add wave -noupdate /pof_tx_rx_3_tb/sel_slave_0 +add wave -noupdate /pof_tx_rx_3_tb/sel_slave_1 +add wave -noupdate /pof_tx_rx_3_tb/avs_write_sl0 +add wave -noupdate /pof_tx_rx_3_tb/avs_read_sl0 +add wave -noupdate /pof_tx_rx_3_tb/avs_readdatavalid_sl0 +add wave -noupdate /pof_tx_rx_3_tb/avs_write_sl1 +add wave -noupdate /pof_tx_rx_3_tb/avs_read_sl1 +add wave -noupdate /pof_tx_rx_3_tb/avs_readdatavalid_sl1 +add wave -noupdate /pof_tx_rx_3_tb/init_tx +add wave -noupdate /pof_tx_rx_3_tb/init_rx +add wave -noupdate /pof_tx_rx_3_tb/dir_in +add wave -noupdate /pof_tx_rx_3_tb/pd_in +add wave -noupdate /pof_tx_rx_3_tb/inc_pos +add wave -noupdate /pof_tx_rx_3_tb/dec_pos +add wave -noupdate -radix decimal /pof_tx_rx_3_tb/abs_position +add wave -noupdate /pof_tx_rx_3_tb/tx_data +add wave -noupdate /pof_tx_rx_3_tb/rx_data +add wave -noupdate /pof_tx_rx_3_tb/init_out +add wave -noupdate /pof_tx_rx_3_tb/dir_out +add wave -noupdate /pof_tx_rx_3_tb/enc_out +add wave -noupdate /pof_tx_rx_3_tb/pd_out +add wave -noupdate /pof_tx_rx_3_tb/inc_pos_out +add wave -noupdate /pof_tx_rx_3_tb/dec_pos_out +add wave -noupdate -radix decimal /pof_tx_rx_3_tb/abs_pos_out +add wave -noupdate /pof_tx_rx_3_tb/test_completed +add wave -noupdate /pof_tx_rx_3_tb/running +add wave -noupdate /pof_tx_rx_3_tb/configuring +add wave -noupdate /pof_tx_rx_3_tb/passed +add wave -noupdate /pof_tx_rx_3_tb/failed +add wave -noupdate /pof_tx_rx_3_tb/stimuli_completed +add wave -noupdate /pof_tx_rx_3_tb/avs_address +add wave -noupdate -radix hexadecimal /pof_tx_rx_3_tb/avs_writedata +add wave -noupdate -radix hexadecimal /pof_tx_rx_3_tb/avs_readdata_sl0 +add wave -noupdate -radix hexadecimal /pof_tx_rx_3_tb/avs_readdata_sl1 +add wave -noupdate -radix decimal /pof_tx_rx_3_tb/abs_position_d +add wave -noupdate -radix decimal /pof_tx_rx_3_tb/swathe_pos +add wave -noupdate /pof_tx_rx_3_tb/swathe_cnt +add wave -noupdate -radix hexadecimal /pof_tx_rx_3_tb/avs_m +add wave -noupdate -radix hexadecimal /pof_tx_rx_3_tb/avs_s +add wave -noupdate /pof_tx_rx_3_tb/detected_error +add wave -noupdate /pof_tx_rx_3_tb/dir_discr_cnt +add wave -noupdate /pof_tx_rx_3_tb/pd_discr_cnt +add wave -noupdate /pof_tx_rx_3_tb/pd_in_cnt +add wave -noupdate /pof_tx_rx_3_tb/pd_out_cnt +add wave -noupdate -radix decimal /pof_tx_rx_3_tb/abs_position +add wave -noupdate -radix decimal /pof_tx_rx_3_tb/abs_pos_out +add wave -noupdate /pof_tx_rx_3_tb/pos_discr_cnt +add wave -noupdate /pof_tx_rx_3_tb/end_of_swathe +add wave -noupdate /pof_tx_rx_3_tb/enc_pulse_cnt +add wave -noupdate /pof_tx_rx_3_tb/dir_err +add wave -noupdate /pof_tx_rx_3_tb/pd_err +add wave -noupdate /pof_tx_rx_3_tb/pos_err +add wave -noupdate /pof_tx_rx_3_tb/enc_err +add wave -noupdate /pof_tx_rx_3_tb/ovfl_err +add wave -noupdate /pof_tx_rx_3_tb/injected_errors +add wave -noupdate /pof_tx_rx_3_tb/max_pos +add wave -noupdate /pof_tx_rx_3_tb/min_pos +add wave -noupdate /pof_tx_rx_3_tb/exp_enc_pulse +add wave -noupdate /pof_tx_rx_3_tb/enc_discr +add wave -noupdate /pof_tx_rx_3_tb/exp_enc_cnt +add wave -noupdate /pof_tx_rx_3_tb/error_rate_thres +add wave -noupdate /pof_tx_rx_3_tb/one_pps +add wave -noupdate /pof_tx_rx_3_tb/max_error_flag +add wave -noupdate /pof_tx_rx_3_tb/rx_watchdog +add wave -noupdate /pof_tx_rx_3_tb/rx_watchdog_en +add wave -noupdate /pof_tx_rx_3_tb/rx_watchdog_clr +add wave -noupdate -divider EMB2POF +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/reset_n +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/clk +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/init +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/pd_in +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/inc_pos +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/dec_pos +add wave -noupdate -radix decimal /pof_tx_rx_3_tb/iPOF_TX/abs_position +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/tx_data +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/avs_address +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/avs_write +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/avs_writedata +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/avs_read +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/avs_readdatavalid +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/avs_readdata +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/rd_event +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/wr_event +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/empty +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/full +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/tx_ready +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/rd_event_d +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/wr_event_i +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/enable +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/toggle_sync +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/toggle_pd +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/add_keepalive +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/ovfl_err +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/init_d +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/init_gen +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/init_v +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/init_blocked +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/init_blk_cnt +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/parity_bit +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/inject_error +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/inject_error_req +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/pd_event +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/pd_event_d +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/pd_event_dd +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/gray +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/clear +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/pd_in_d +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/pd_gen +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/clk +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/symbol_valid +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/symbol +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/tx_data +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/event_in_i +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/event_in +add wave -noupdate /pof_tx_rx_3_tb/iPOF_TX/event_out +add wave -noupdate -radix decimal /pof_tx_rx_3_tb/iPOF_TX/keepalive_cnt +add wave -noupdate -divider POF2HMB +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/reset_n +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/clk +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/init +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/rx_clk +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/rx_data +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/init_out +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/enc_out +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/pd_out +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/inc_pos +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/dec_pos +add wave -noupdate -radix decimal /pof_tx_rx_3_tb/iPOF_RX/abs_pos +add wave -noupdate -radix unsigned /pof_tx_rx_3_tb/iPOF_RX/error_rate_thres +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/one_pps +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/max_error_flag +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/rx_watchdog +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/rx_watchdog_en +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/rx_watchdog_clr +add wave -noupdate -radix unsigned /pof_tx_rx_3_tb/iPOF_RX/rx_wd_cnt +add wave -noupdate -radix unsigned /pof_tx_rx_3_tb/iPOF_RX/error_rate_cnt +add wave -noupdate -radix unsigned /pof_tx_rx_3_tb/iPOF_RX/error_rate +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/clear +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/clear_i +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/inc_pos_i +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/dec_pos_i +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/enable +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/sync_gen +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/pd_gen +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/symbol_error +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/rx_symbol_val +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/rx_symbol +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/rx_symbol_val_v +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/symbol_valid_i +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/symbol_valid_d +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/toggle_sync +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/sync_confirmed +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/sync_toggle_test +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/sync +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/toggle_pd +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/pd_confirmed +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/pd_toggle_test +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/pd +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/valid_pos +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/upd_pos +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/corr_done +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/corr_sign +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/skip_cnt +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/skip_pos +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/symbol_valid +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/symbol +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/apply_corr +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/clk_cnt +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/dist +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/abs_dist +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/next_pos_lsb +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/curr_pos_lsb +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/pos_corr +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/max_dist +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/gray_pos +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/symbol_i +add wave -noupdate -radix unsigned /pof_tx_rx_3_tb/iPOF_RX/parity_err_cnt +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/enc_out +add wave -noupdate -radix decimal /pof_tx_rx_3_tb/iPOF_RX/abs_pos_i +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/inc_pos_ii +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/dec_pos_ii +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/new_max +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/new_min +add wave -noupdate -radix decimal /pof_tx_rx_3_tb/iPOF_RX/pos_max +add wave -noupdate -radix decimal /pof_tx_rx_3_tb/iPOF_RX/pos_min +add wave -noupdate -radix decimal /pof_tx_rx_3_tb/iPOF_RX/dist_pos +add wave -noupdate -radix decimal /pof_tx_rx_3_tb/iPOF_RX/dist_neg +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/iRX_SYMBOL/data_width +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/iRX_SYMBOL/reset_n +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/iRX_SYMBOL/clk +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/iRX_SYMBOL/bit_div +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/iRX_SYMBOL/init +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/iRX_SYMBOL/data_out +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/iRX_SYMBOL/data_out_valid +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/iRX_SYMBOL/rx_data +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/iRX_SYMBOL/fsm_state_curr +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/iRX_SYMBOL/fsm_state_next +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/iRX_SYMBOL/rx_data_i +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/iRX_SYMBOL/shf_data +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/iRX_SYMBOL/rst_bit_cnt +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/iRX_SYMBOL/inc_bit_cnt +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/iRX_SYMBOL/rst_clk_cnt +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/iRX_SYMBOL/end_of_bit +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/iRX_SYMBOL/end_of_rx +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/iRX_SYMBOL/data_valid +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/iRX_SYMBOL/stop_bit +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/iRX_SYMBOL/data +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/iRX_SYMBOL/clk_cnt +add wave -noupdate /pof_tx_rx_3_tb/iPOF_RX/iRX_SYMBOL/bit_cnt +TreeUpdate [SetDefaultTree] +WaveRestoreCursors {{Cursor 2} {28538165210 ps} 0} {{Cursor 3} {28538185210 ps} 0} {{Cursor 4} {28538205210 ps} 0} {{Cursor 5} {28538225210 ps} 0} +WaveRestoreCursorLinks {1 {2 {20000 ps} 3 {40000 ps} 4 {60000 ps}}} {2 {1 {-20000 ps}}} {3 {1 {-40000 ps}}} {4 {1 {-60000 ps}}} +quietly wave cursor active 1 +configure wave -namecolwidth 365 +configure wave -valuecolwidth 100 +configure wave -justifyvalue left +configure wave -signalnamewidth 0 +configure wave -snapdistance 10 +configure wave -datasetprefix 0 +configure wave -rowmargin 4 +configure wave -childrowmargin 2 +configure wave -gridoffset 0 +configure wave -gridperiod 1 +configure wave -griddelta 40 +configure wave -timeline 0 +configure wave -timelineunits ps +update +WaveRestoreZoom {28537732626 ps} {28538723476 ps} diff --git a/generic_ip/fire_pulse_manager/3/src/fire_pulse_3_pkg.vhd b/generic_ip/fire_pulse_manager/3/src/fire_pulse_3_pkg.vhd new file mode 100644 index 0000000..90409a9 --- /dev/null +++ b/generic_ip/fire_pulse_manager/3/src/fire_pulse_3_pkg.vhd @@ -0,0 +1,38 @@ +------------------------------------------------------------------------------- +-- Title : fire_pulse_pkg +-- Project : HMB/EMB/SMB +------------------------------------------------------------------------------- +-- File : fire_pulse_pkg.vhd +-- Author : Gianmarco Girau +-- Company : Global Inkjet Systems +-- Created : 2017-09-08 +-- Last update: 2019-07-15 +-- SVN ID : Git +-- Standard : VHDL'08 +------------------------------------------------------------------------------- +-- Description: +-- Package for fire_pulse_manager block +------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +package fire_pulse_3_pkg is + + ----------------------------------------------------------------------------- + -- Inner block mapping + ----------------------------------------------------------------------------- + + constant blk_num : integer := 8; -- number of sub-blocks with dedicated + -- C&S registers + constant ch_num : integer := 4; -- number of Pulse-Generator blocks + + constant fp_ctrl_id : natural := 0; -- Block ID for the Fire-Pulse-Mang Controller + constant net_snk_id : natural := 1; -- Block ID for Net-Sync Sink + constant log_blk_id : natural := 2; -- Block ID for the Event Logger + constant int_enc_id : natural := 3; -- Block ID for the Internal Encoder Block + constant pg_ch_id : natural := 4; -- Block ID for Pulse-Generator + +end package fire_pulse_3_pkg; diff --git a/generic_ip/fire_pulse_manager/3/src/fire_pulse_ctrl_3.vhd b/generic_ip/fire_pulse_manager/3/src/fire_pulse_ctrl_3.vhd new file mode 100644 index 0000000..5e50935 --- /dev/null +++ b/generic_ip/fire_pulse_manager/3/src/fire_pulse_ctrl_3.vhd @@ -0,0 +1,276 @@ +------------------------------------------------------------------------------- +-- Title : fire_pulse_ctrl +-- Project : HMB/EMB/SMB +------------------------------------------------------------------------------- +-- File : fire_pulse_ctrl.vhd +-- Author : Gianmarco Girau +-- Company : Global Inkjet Systems +-- Created : 2017-09-06 +-- Last update: 2019-07-15 +-- SVN ID : Git +-- Standard : VHDL'08 +------------------------------------------------------------------------------- +-- Description: +-- Control service logic for the Fire-Controller-Manager +------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity fire_pulse_ctrl_3 is + port( + reset_n : in std_logic; + clk : in std_logic; + src_sel : out std_logic_vector(1 downto 0); + uart_regen_bypass : out std_logic; + upd_max_pos : out std_logic; + upd_min_pos : out std_logic; + enable_rx : out std_logic; + uart_bit_div : out std_logic_vector(3 downto 0); + error_rate_thres : out std_logic_vector(7 downto 0); + max_error_flag : in std_logic; + rx_watchdog : in std_logic; + rx_watchdog_en : out std_logic; + rx_watchdog_clr : out std_logic; + parity_err_cnt : in std_logic_vector(15 downto 0); + skip_pos_cnt : in std_logic_vector(15 downto 0); + mon_point_src : in std_logic_vector(15 downto 0); + mon_points : out std_logic_vector(3 downto 0); + coarse_time : out std_logic_vector(31 downto 0); + fine_time : out std_logic_vector(27 downto 0); + one_pps : out std_logic; + ext_fp_det : out std_logic_vector(15 downto 0); + ext_fp_gen : out std_logic_vector(15 downto 0); + -- Interrupt Senders + ins_fpm_irq_0 : out std_logic; + -- Avalon MM Interface + avs_address : in std_logic_vector(3 downto 0); + avs_write : in std_logic; + avs_writedata : in std_logic_vector(31 downto 0); + avs_read : in std_logic; + avs_readdatavalid : out std_logic; + avs_readdata : out std_logic_vector(31 downto 0)); +end entity fire_pulse_ctrl_3; + +architecture rtl of fire_pulse_ctrl_3 is + + ----------------------------------------------------------------------------- + -- Control & Status Registers Map + ----------------------------------------------------------------------------- + constant CSR_IP_ID : std_logic_vector(31 downto 0) := x"0000FF14"; + constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000300"; + + constant CSR_IP_ID_REG : std_logic_vector(3 downto 0) := b"0000"; + constant CSR_IP_VER_REG : std_logic_vector(3 downto 0) := b"0001"; + constant SRC_SEL_REG : std_logic_vector(3 downto 0) := b"0010"; + constant POF_RX_CTRL : std_logic_vector(3 downto 0) := b"0011"; + constant MON_PT_CTRL_REG : std_logic_vector(3 downto 0) := b"0100"; + constant COARSE_TIME_INIT_REG : std_logic_vector(3 downto 0) := b"0101"; + constant FINE_TIME_INIT_REG : std_logic_vector(3 downto 0) := b"0110"; + constant FINE_TIME_REG : std_logic_vector(3 downto 0) := b"0111"; + constant COARSE_TIME_REG : std_logic_vector(3 downto 0) := b"1000"; + constant RX_ERROR_STATUS : std_logic_vector(3 downto 0) := b"1001"; + constant RX_ERROR_CSR : std_logic_vector(3 downto 0) := b"1010"; + constant IRQ_MNG_REG : std_logic_vector(3 downto 0) := b"1011"; + constant EXT_FP_CTRL_REG : std_logic_vector(3 downto 0) := b"1100"; + + ----------------------------------------------------------------------------- + -- Constants, Signals + ----------------------------------------------------------------------------- + + constant FINE_TIME_TC : integer := 100000000 - 1; -- clk must be 100MHz to + -- make it right + + signal enable_rx_i : std_logic; + signal fine_time_wrap, time_ld_en : std_logic; + signal rx_watchdog_en_i, rx_watchdog_clr_i : std_logic; + signal uart_regen_bypass_i : std_logic; + signal upd_min_pos_i, upd_max_pos_i : std_logic; + signal irq, irq_src, irq_src_d : std_logic_vector(0 downto 0); + signal irq_en, irq_mask, irq_val, irq_clr : std_logic_vector(0 downto 0); + signal src_sel_i : std_logic_vector(1 downto 0); + signal mp_sel0, mp_sel1, mp_sel2, mp_sel3 : std_logic_vector(3 downto 0); + signal bit_div : std_logic_vector(3 downto 0); + signal error_rate_thres_i : std_logic_vector(7 downto 0); + signal fine_time_init, fine_time_i : std_logic_vector(27 downto 0); + signal coarse_time_init, coarse_time_i : std_logic_vector(31 downto 0); + signal ext_fp_det_i, ext_fp_gen_i : std_logic_vector(15 downto 0); + +begin + + pCTRL_REGs : process(reset_n, clk) + begin -- process + if (reset_n = '0') then + fine_time_i <= (others => '0'); + coarse_time_i <= (others => '0'); + elsif (clk = '1' and clk'event) then + if (time_ld_en = '1') then + fine_time_i <= fine_time_init; + elsif (fine_time_wrap = '1') then + fine_time_i <= (others => '0'); + else + fine_time_i <= std_logic_vector(unsigned(fine_time_i) + 1); + end if; + if (time_ld_en = '1') then + coarse_time_i <= coarse_time_init; + elsif (fine_time_wrap = '1') then + coarse_time_i <= std_logic_vector(unsigned(coarse_time_i) + 1); + end if; + one_pps <= fine_time_wrap; + end if; + end process pCTRL_REGs; + + fine_time_wrap <= '1' when unsigned(fine_time_i) = FINE_TIME_TC else '0'; + + coarse_time <= coarse_time_i; + fine_time <= fine_time_i; + + -- MOnitoring Point selection + mon_points(0) <= mon_point_src(to_integer(unsigned(mp_sel0))); + mon_points(1) <= mon_point_src(to_integer(unsigned(mp_sel1))); + mon_points(2) <= mon_point_src(to_integer(unsigned(mp_sel2))); + mon_points(3) <= mon_point_src(to_integer(unsigned(mp_sel3))); + + ----------------------------------------------------------------------------- + -- IRQ generation and management + ----------------------------------------------------------------------------- + + pIRQ : process(reset_n, clk) + begin + if (reset_n = '0') then + ins_fpm_irq_0 <= '0'; + irq <= "0"; + irq_src_d <= "0"; + elsif (clk = '1' and clk'event) then + irq_src_d <= irq_src; + for n in 0 to irq'left loop + if (irq_clr(n) = '1') then + irq(n) <= '0'; + elsif (irq_en(n) = '1' and irq_src(n) = '1' and irq_src_d(n) = '0') then + irq(n) <= '1'; + end if; + end loop; -- n + ins_fpm_irq_0 <= irq_val(0); + end if; + end process pIRQ; + + irq_val <= irq and not irq_mask; + irq_src <= "1" when max_error_flag = '1' or rx_watchdog = '1' else "0"; + + ----------------------------------------------------------------------------- + -- C&S registers + ----------------------------------------------------------------------------- + + src_sel <= src_sel_i; + enable_rx <= enable_rx_i; + uart_regen_bypass <= uart_regen_bypass_i; + + uart_bit_div <= bit_div; + upd_max_pos <= upd_max_pos_i; + upd_min_pos <= upd_min_pos_i; + + error_rate_thres <= error_rate_thres_i; + rx_watchdog_en <= rx_watchdog_en_i; + rx_watchdog_clr <= rx_watchdog_clr_i; + + ext_fp_det <= ext_fp_det_i; + ext_fp_gen <= ext_fp_gen_i; + + pCTRL_STATUS : process(reset_n, clk) + begin + if (reset_n = '0') then + avs_readdatavalid <= '0'; + src_sel_i <= "00"; + enable_rx_i <= '0'; + uart_regen_bypass_i <= '0'; + upd_max_pos_i <= '0'; + upd_min_pos_i <= '0'; + bit_div <= "0100"; + error_rate_thres_i <= X"0A"; + rx_watchdog_en_i <= '1'; + rx_watchdog_clr_i <= '0'; + mp_sel0 <= X"0"; + mp_sel1 <= X"0"; + mp_sel2 <= X"0"; + mp_sel3 <= X"0"; + coarse_time_init <= (others => '0'); + fine_time_init <= (others => '0'); + time_ld_en <= '0'; + ext_fp_det_i <= X"0010"; + ext_fp_gen_i <= X"0020"; + elsif (clk = '1' and clk'event) then + -- CTRL registers + if (avs_write = '1') then + case avs_address is + when SRC_SEL_REG => + src_sel_i <= avs_writedata(1 downto 0); + when POF_RX_CTRL => + enable_rx_i <= avs_writedata(0); + uart_regen_bypass_i <= avs_writedata(1); + upd_max_pos_i <= avs_writedata(2); + upd_min_pos_i <= avs_writedata(3); + bit_div <= avs_writedata(7 downto 4); + when MON_PT_CTRL_REG => + mp_sel0 <= avs_writedata(3 downto 0); + mp_sel1 <= avs_writedata(7 downto 4); + mp_sel2 <= avs_writedata(11 downto 8); + mp_sel3 <= avs_writedata(15 downto 12); + when COARSE_TIME_INIT_REG => + coarse_time_init <= avs_writedata; + when FINE_TIME_INIT_REG => + time_ld_en <= avs_writedata(28); + fine_time_init <= avs_writedata(27 downto 0); + when RX_ERROR_CSR => + error_rate_thres_i <= avs_writedata(7 downto 0); + rx_watchdog_en_i <= avs_writedata(8); + rx_watchdog_clr_i <= avs_writedata(9); + when IRQ_MNG_REG => + irq_en <= avs_writedata(0 downto 0); + irq_clr <= avs_writedata(4 downto 4); + irq_mask <= avs_writedata(8 downto 8); + when EXT_FP_CTRL_REG => + ext_fp_det_i <= avs_writedata(15 downto 0); + ext_fp_gen_i <= avs_writedata(31 downto 16); + when others => null; + end case; + end if; + -- Read Ctrl & Status registers + avs_readdatavalid <= avs_read; + if (avs_read = '1') then + case avs_address is + when CSR_IP_ID_REG => + avs_readdata <= CSR_IP_ID; + when CSR_IP_VER_REG => + avs_readdata <= CSR_IP_VER; + when SRC_SEL_REG => + avs_readdata <= (0 => src_sel_i(0), 1 => src_sel_i(1), others => '0'); + when POF_RX_CTRL => + avs_readdata <= X"000000" & bit_div & upd_min_pos_i & upd_max_pos_i & uart_regen_bypass_i & enable_rx_i; + when MON_PT_CTRL_REG => + avs_readdata <= X"0000" & mp_sel3 & mp_sel2 & mp_sel1 & mp_sel0; + when COARSE_TIME_INIT_REG => + avs_readdata <= coarse_time_init; + when FINE_TIME_INIT_REG => + avs_readdata <= b"000" & time_ld_en & fine_time_init; + when RX_ERROR_STATUS => + avs_readdata <= skip_pos_cnt & parity_err_cnt; + when FINE_TIME_REG => + avs_readdata <= X"0" & fine_time_i; + when COARSE_TIME_REG => + avs_readdata <= coarse_time_i; + when RX_ERROR_CSR => + avs_readdata <= X"00000" & max_error_flag & rx_watchdog & rx_watchdog_clr_i & rx_watchdog_en_i & error_rate_thres_i; + when IRQ_MNG_REG => + avs_readdata <= X"0000" & "000" & irq_val & "000" & irq_mask & "000" & irq_clr & "000" & irq_en; + when EXT_FP_CTRL_REG => + avs_readdata <= ext_fp_gen_i & ext_fp_det_i; + when others => + avs_readdata <= X"BAD1BAD0"; + end case; + end if; + end if; + end process pCTRL_STATUS; + +end architecture rtl; diff --git a/generic_ip/fire_pulse_manager/3/src/fire_pulse_ext_3.vhd b/generic_ip/fire_pulse_manager/3/src/fire_pulse_ext_3.vhd new file mode 100644 index 0000000..5ed2f35 --- /dev/null +++ b/generic_ip/fire_pulse_manager/3/src/fire_pulse_ext_3.vhd @@ -0,0 +1,108 @@ +------------------------------------------------------------------------------- +-- Title : fire_pulse_manager +-- Project : GMA +------------------------------------------------------------------------------- +-- File : fire_pulse_ext.vhd +-- Author : Christos Spirotis +-- Company : Global Inkjet Systems +-- Created : 2017-10-03 +-- Last update: 2019-07-15 +-- SVN ID : Git +-- Standard : VHDL'08 +------------------------------------------------------------------------------- +-- Description: +-- Detects external fire pulse and regenerates it +------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +library work; + +entity fire_pulse_ext_3 is + port( + reset_n : in std_logic; + clk : in std_logic; -- 100MHz + + ext_fp_det : in std_logic_vector(15 downto 0); + ext_fp_gen : in std_logic_vector(15 downto 0); + + ext_in : in std_logic; + ext_out : out std_logic + ); +end entity fire_pulse_ext_3; + +architecture rtl of fire_pulse_ext_3 is + +signal ext_in_cnt : unsigned(15 downto 0); +signal ext_out_cnt : unsigned(15 downto 0); +signal ext_in_det : std_logic_vector( 2 downto 0); +signal fp_gen : std_logic; + +begin + + -- Detect pulse + pulse_det : process (clk, reset_n) + begin + if (reset_n = '0') then + ext_in_cnt <= (others => '0'); + ext_in_det <= (others => '0'); + fp_gen <= '0'; + elsif rising_edge(clk) then + fp_gen <= '0'; + ext_in_det <= ext_in_det(1 downto 0) & ext_in; + + -- Detect rising edge while idle + if (ext_in_det(2 downto 1) = "01" and ext_in_cnt = 0) then + -- Start width counter + ext_in_cnt <= X"0001"; + -- Measure width while signal high + elsif ext_in_cnt /= 0 and ext_in_det(1) = '1' then + -- Counter++ + ext_in_cnt <= ext_in_cnt + 1; + -- If reached minimum width + if ext_in_cnt >= unsigned(ext_fp_det) then + -- Regenerate pulse + fp_gen <= '1'; + -- Reset width counter + ext_in_cnt <= (others => '0'); + end if; + -- If signal drops before detection + elsif ext_in_cnt /= 0 and ext_in_det(1) = '0' then + -- Reset width counter + ext_in_cnt <= (others => '0'); + end if; + end if; + end process pulse_det; + + -- Regenerate pulse + pulse_regen : process (clk, reset_n) + begin + if (reset_n = '0') then + ext_out_cnt <= (others => '0'); + ext_out <= '0'; + elsif rising_edge(clk) then + -- Look for pulse detected + if fp_gen = '1' and ext_out_cnt = 0 then + -- Start width counter + ext_out_cnt <= X"0001"; + -- Generate pulse + ext_out <= '1'; + -- If counting + elsif ext_out_cnt /= 0 then + -- Increment width + ext_out_cnt <= ext_out_cnt + 1; + -- If width reached programmed value + if ext_out_cnt >= unsigned(ext_fp_gen) then + -- Reset pulse + ext_out <= '0'; + -- Reset width counter + ext_out_cnt <= (others => '0'); + end if; + end if; + end if; + end process pulse_regen; + +end architecture rtl; diff --git a/generic_ip/fire_pulse_manager/3/src/fire_pulse_manager_3.vhd b/generic_ip/fire_pulse_manager/3/src/fire_pulse_manager_3.vhd new file mode 100644 index 0000000..cdc10c6 --- /dev/null +++ b/generic_ip/fire_pulse_manager/3/src/fire_pulse_manager_3.vhd @@ -0,0 +1,421 @@ +------------------------------------------------------------------------------- +-- Title : fire_pulse_manager +-- Project : HMB/EMB/SMB +------------------------------------------------------------------------------- +-- File : fire_pulse_manager.vhd +-- Author : Gianmarco Girau +-- Company : Global Inkjet Systems +-- Created : 2017-09-06 +-- Last update: 2019-07-15 +-- SVN ID : Git +-- Standard : VHDL'08 +------------------------------------------------------------------------------- +-- Description: +-- Generates fire request from the EMS output data, transferred either via POF +-- or through NetSync +------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +use work.fire_pulse_3_pkg.all; + +entity fire_pulse_manager_3 is + port( + reset_n : in std_logic; + clk : in std_logic; -- 100MHz + rx_clk : in std_logic; -- 300MHz (typical) + -- Datapath I/Os + pof_rx : in std_logic; + pof_tx : out std_logic; + pof_iso_en : out std_logic; + fire_pulse : out std_logic_vector(ch_num - 1 downto 0); + mon_pt : out std_logic_vector(3 downto 0); -- Monitoring Points + -- on header J7 + -- Interrupt Senders + ins_fpm_irq_0 : out std_logic; + ins_fpm_irq_1 : out std_logic; -- @suppress "Unused port: ins_fpm_irq_1 is not used in work.fire_pulse_manager_1(rtl)" + ins_fpm_irq_2 : out std_logic; -- @suppress "Unused port: ins_fpm_irq_2 is not used in work.fire_pulse_manager_1(rtl)" + ins_fpm_irq_3 : out std_logic; -- @suppress "Unused port: ins_fpm_irq_3 is not used in work.fire_pulse_manager_1(rtl)" + -- Avalon MM (Slave) Interface + avs_address : in std_logic_vector(14 downto 0); + avs_write : in std_logic; + avs_writedata : in std_logic_vector(31 downto 0); + avs_read : in std_logic; + avs_waitrequest : out std_logic; + avs_readdata : out std_logic_vector(31 downto 0)); +end entity fire_pulse_manager_3; + +architecture rtl of fire_pulse_manager_3 is + + constant PD_QUEUE_SIZE : natural := 512; + + type diag_cnt_en_t is array (1 to ch_num) of boolean; + constant DIAG_COUNTER_EN : diag_cnt_en_t := (1 => true, others => false); + + signal reset_n_i : std_logic; + -- + signal cs_addr : std_logic_vector(10 downto 0); + signal cs_write_en : std_logic_vector(blk_num - 1 downto 0); + signal cs_write_data : std_logic_vector(31 downto 0); + signal cs_read_en : std_logic_vector(blk_num - 1 downto 0); + signal cs_read_valid : std_logic_vector(blk_num - 1 downto 0); + signal cs_read_data : std_logic_vector(32 * blk_num - 1 downto 0); + -- + signal cs_ctrl_write_en : std_logic; + signal cs_ctrl_read_en : std_logic; + signal cs_ctrl_read_valid : std_logic; + signal cs_ctrl_read_data : std_logic_vector(31 downto 0); + -- + signal cs_pg_write_en : std_logic_vector(ch_num - 1 downto 0); + signal cs_pg_read_en : std_logic_vector(ch_num - 1 downto 0); + signal cs_pg_read_valid : std_logic_vector(ch_num - 1 downto 0); + signal cs_pg_read_data : std_logic_vector(32 * ch_num - 1 downto 0); + -- + signal cs_nsnk_write_en : std_logic; + signal cs_nsnk_read_en : std_logic; + signal cs_nsnk_read_valid : std_logic; + signal cs_nsnk_read_data : std_logic_vector(31 downto 0); + -- + signal cs_log_write_en : std_logic; + signal cs_log_read_en : std_logic; + signal cs_log_read_valid : std_logic; + signal cs_log_read_data : std_logic_vector(31 downto 0); + -- + signal cs_ie_write_en : std_logic; + signal cs_ie_read_en : std_logic; + signal cs_ie_read_valid : std_logic; + signal cs_ie_read_data : std_logic_vector(31 downto 0); + -- + signal enable_rx : std_logic; + signal uart_regen_bypass : std_logic; + signal upd_max_pos : std_logic; + signal upd_min_pos : std_logic; + signal max_error_flag : std_logic; + signal rx_watchdog : std_logic; + signal rx_watchdog_en : std_logic; + signal rx_watchdog_clr : std_logic; + signal bit_div : std_logic_vector(3 downto 0); + signal error_rate_thres : std_logic_vector(7 downto 0); + signal parity_err_cnt : std_logic_vector(15 downto 0); + signal skip_pos_cnt : std_logic_vector(15 downto 0); + signal mon_point_src : std_logic_vector(15 downto 0); + signal fine_time : std_logic_vector(27 downto 0); + signal coarse_time : std_logic_vector(31 downto 0); + -- + signal remote_init : std_logic; + signal dp_dir : std_logic_vector(ch_num - 1 downto 0); + signal set_pos_ie : std_logic; + signal enc_pulse : std_logic; + signal enc_pulse_ie : std_logic; + signal enc_pulse_pof : std_logic; + signal pd_pulse : std_logic; + signal pd_pulse_ie : std_logic; + signal pd_pulse_pof : std_logic; + signal inc_pos : std_logic; + signal inc_pos_pof : std_logic; + signal inc_pos_ie : std_logic; + signal dec_pos : std_logic; + signal dec_pos_pof : std_logic; + signal dec_pos_ie : std_logic; + signal abs_pos : std_logic_vector(31 downto 0); + signal abs_pos_pof : std_logic_vector(31 downto 0); + signal abs_pos_ie : std_logic_vector(39 downto 0); + -- + signal ch_pd, ch_pulse_out : std_logic_vector(ch_num - 1 downto 0); + signal ch_raw_pulse, ch_mask : std_logic_vector(ch_num - 1 downto 0); + signal fire_pulse_i : std_logic_vector(ch_num - 1 downto 0); + signal src_sel : std_logic_vector(1 downto 0); + -- + signal one_pps : std_logic; + signal ext_fp_det : std_logic_vector(15 downto 0); + signal ext_fp_gen : std_logic_vector(15 downto 0); + signal pof_rx_regen : std_logic; + +begin + + ----------------------------------------------------------------------------- + -- Synchronize the input reset (h2f_reset) to the clock (from PLL) + ----------------------------------------------------------------------------- + + iSyncReset : entity work.sync_reset + port map( + async_rstN => reset_n, + clk => clk, + sync_rstN => reset_n_i); + + + ----------------------------------------------------------------------------- + -- C&S Register Interface Splitting + ----------------------------------------------------------------------------- + + iCS_BUS_ITF : entity work.cs_bus_ift + generic map( + blk_num => blk_num) + port map( + rstN => reset_n_i, + clk => clk, + avs_address => avs_address(14 downto 0), + avs_write => avs_write, + avs_writedata => avs_writedata, + avs_read => avs_read, + avs_waitrequest => avs_waitrequest, + avs_readdata => avs_readdata, + cs_addr => cs_addr, + cs_we => cs_write_en, + cs_wr_data => cs_write_data, + cs_re => cs_read_en, + cs_rv => cs_read_valid, + cs_rd_data => cs_read_data); + + cs_ctrl_write_en <= cs_write_en(fp_ctrl_id); + cs_pg_write_en_g : for i in 1 to ch_num generate + cs_pg_write_en(i - 1) <= cs_write_en(pg_ch_id + i - 1); + end generate; + cs_nsnk_write_en <= cs_write_en(net_snk_id); + cs_log_write_en <= cs_write_en(log_blk_id); + cs_ie_write_en <= cs_write_en(int_enc_id); + + cs_ctrl_read_en <= cs_read_en(fp_ctrl_id); + cs_pg_read_en_g : for i in 1 to ch_num generate + cs_pg_read_en(i - 1) <= cs_read_en(pg_ch_id + i - 1); + end generate; + cs_nsnk_read_en <= cs_read_en(net_snk_id); + cs_log_read_en <= cs_read_en(log_blk_id); + cs_ie_read_en <= cs_read_en(int_enc_id); + + cs_read_valid(fp_ctrl_id) <= cs_ctrl_read_valid; + cs_read_valid_pg_g : for i in 1 to ch_num generate + cs_read_valid(pg_ch_id + i - 1) <= cs_pg_read_valid(i - 1); + end generate; + cs_read_valid(net_snk_id) <= cs_nsnk_read_valid; + cs_read_valid(log_blk_id) <= cs_log_read_valid; + cs_read_valid(int_enc_id) <= cs_ie_read_valid; + + cs_read_data(31 + 32 * fp_ctrl_id downto 32 * fp_ctrl_id) <= cs_ctrl_read_data; + cs_read_data_pg_g : for i in 1 to ch_num generate + cs_read_data(31 + 32 * (pg_ch_id + i - 1) downto 32 * (pg_ch_id + i - 1)) <= cs_pg_read_data(31 + 32 * (i - 1) downto 32 * (i - 1)); + end generate; + cs_read_data(31 + 32 * net_snk_id downto 32 * net_snk_id) <= cs_nsnk_read_data; + cs_read_data(31 + 32 * log_blk_id downto 32 * log_blk_id) <= cs_log_read_data; + cs_read_data(31 + 32 * int_enc_id downto 32 * int_enc_id) <= cs_ie_read_data; + + ----------------------------------------------------------------------------- + -- Fire-Pulse-Manager Controller + ----------------------------------------------------------------------------- + + iCTRL : entity work.fire_pulse_ctrl_3 + port map( + reset_n => reset_n_i, + clk => clk, + src_sel => src_sel, + uart_regen_bypass => uart_regen_bypass, + upd_max_pos => upd_max_pos, + upd_min_pos => upd_min_pos, + enable_rx => enable_rx, + uart_bit_div => bit_div, + error_rate_thres => error_rate_thres, + max_error_flag => max_error_flag, + rx_watchdog => rx_watchdog, + rx_watchdog_en => rx_watchdog_en, + rx_watchdog_clr => rx_watchdog_clr, + parity_err_cnt => parity_err_cnt, + skip_pos_cnt => skip_pos_cnt, + mon_point_src => mon_point_src, + mon_points => mon_pt, + coarse_time => coarse_time, + fine_time => fine_time, + one_pps => one_pps, + ext_fp_det => ext_fp_det, + ext_fp_gen => ext_fp_gen, + ins_fpm_irq_0 => ins_fpm_irq_0, + avs_address => cs_addr(3 downto 0), + avs_write => cs_ctrl_write_en, + avs_writedata => cs_write_data, + avs_read => cs_ctrl_read_en, + avs_readdatavalid => cs_ctrl_read_valid, + avs_readdata => cs_ctrl_read_data); + + ins_fpm_irq_1 <= '0'; + ins_fpm_irq_2 <= '0'; + ins_fpm_irq_3 <= '0'; + + -- Output multiplexer + fire_pulse_i <= ch_pulse_out when src_sel(0) = '1' else (others => pof_rx_regen); + fire_pulse <= fire_pulse_i; + + pd_pulse <= pd_pulse_pof when src_sel(1) = '0' else pd_pulse_ie; + enc_pulse <= enc_pulse_pof when src_sel(1) = '0' else enc_pulse_ie; + abs_pos <= abs_pos_pof when src_sel(1) = '0' else abs_pos_ie(31 downto 0); + inc_pos <= inc_pos_pof when src_sel(1) = '0' else inc_pos_ie; + dec_pos <= dec_pos_pof when src_sel(1) = '0' else dec_pos_ie; + + mon_point_src(0) <= remote_init; + mon_point_src(1) <= dp_dir(0); + mon_point_src(2) <= pd_pulse; + mon_point_src(3) <= enc_pulse; + mon_point_src(4) <= ch_pd(0); + mon_point_src(5) <= ch_pulse_out(0); + mon_point_src(6) <= ch_raw_pulse(0); + mon_point_src(7) <= ch_mask(0); + mon_point_src(8) <= pof_rx; + mon_point_src(9) <= fire_pulse_i(0); + -- + mon_point_src(15 downto 10) <= (others => '0'); + + pof_iso_en <= enable_rx; + + ----------------------------------------------------------------------------- + -- Pulse Generator + ----------------------------------------------------------------------------- + + pulse_generator_g : for i in 1 to ch_num generate + iCH_PG : entity work.pulse_generator_1 + generic map( + PD_QUEUE_SIZE => PD_QUEUE_SIZE, + PULSE_DELAY_EQUAL_EN => false, + OUT_PULSE_CONDITION => true, + OVERDRIVE_CHECK => false, + DIAG_COUNTERS => DIAG_COUNTER_EN(i)) + port map( + clk => clk, + reset_n => reset_n_i, + init => remote_init, + pd_in => pd_pulse, + abs_position => abs_pos, + dp_dir => dp_dir(i - 1), + pulse_out => ch_pulse_out(i - 1), + ch_pd => ch_pd(i - 1), + ch_mask => ch_mask(i - 1), + raw_pulse_out => ch_raw_pulse(i - 1), + enc_pulse => open, + avs_address => cs_addr(9 downto 0), + avs_write => cs_pg_write_en(i - 1), + avs_writedata => cs_write_data, + avs_read => cs_pg_read_en(i - 1), + avs_readdatavalid => cs_pg_read_valid(i - 1), + avs_readdata => cs_pg_read_data(31 + 32 * (i - 1) downto 32 * (i - 1))); + end generate; + ----------------------------------------------------------------------------- + -- POF Interface + ----------------------------------------------------------------------------- + + -- POF Receiver + iPOF_RX : entity work.pof_rx_3 + port map( + reset_n => reset_n_i, + clk => clk, + init => '0', + rx_clk => rx_clk, + rx_data => pof_rx, + init_out => remote_init, + dp_dir => dp_dir(0), + enc_out => enc_pulse_pof, + pd_out => pd_pulse_pof, + inc_pos => inc_pos_pof, + dec_pos => dec_pos_pof, + abs_pos => abs_pos_pof, + enable => enable_rx, + bit_div => bit_div, + error_rate_thres => error_rate_thres, + one_pps => one_pps, + upd_max_pos => upd_max_pos, + upd_min_pos => upd_min_pos, + max_error_flag => max_error_flag, + rx_watchdog => rx_watchdog, + rx_watchdog_en => rx_watchdog_en, + rx_watchdog_clr => rx_watchdog_clr, + parity_err_cnt => parity_err_cnt, + skip_pos_cnt => skip_pos_cnt); + + -- UART signal regeneration + iUART_REGEN : entity work.uart_regen_3 + generic map( + data_width => 8) + port map( + reset_n => reset_n, + clk => rx_clk, + bit_div => bit_div, + enable => enable_rx, + bypass_en => uart_regen_bypass, + uart_rx => pof_rx, + uart_tx => pof_tx); + + ----------------------------------------------------------------------------- + -- Ext fire pulse regen + ----------------------------------------------------------------------------- + + fire_pulse_ext_i : entity work.fire_pulse_ext_3 + port map( + reset_n => reset_n_i, + clk => clk, + + ext_fp_det => ext_fp_det, + ext_fp_gen => ext_fp_gen, + + ext_in => pof_rx, + ext_out => pof_rx_regen + ); + + ----------------------------------------------------------------------------- + -- Internal encoder generator + ----------------------------------------------------------------------------- + + iEMUL : entity work.enc_pd_emul_1 + generic map( + SEQ_ENABLE => false) + port map( + clk => clk, + reset_n => reset_n_i, + ttl_pd => open, + ttl_enc_p1 => open, + ttl_enc_p2 => open, + ttl_enc_zp => open, + rs422_pd => pd_pulse_ie, + rs422_enc_p1 => open, + rs422_enc_p2 => open, + rs422_enc_zp => open, + abs_pos_out => abs_pos_ie, + set_pos_out => set_pos_ie, + inc_pos_out => inc_pos_ie, + dec_pos_out => dec_pos_ie, + avs_address => cs_addr(9 downto 0), + avs_write => cs_ie_write_en, + avs_writedata => cs_write_data, + avs_read => cs_ie_read_en, + avs_readdatavalid => cs_ie_read_valid, + avs_readdata => cs_ie_read_data); + + enc_pulse_ie <= inc_pos_ie when dp_dir(0) = '0' else dec_pos_ie; + + ----------------------------------------------------------------------------- + -- NetSync Sink + ----------------------------------------------------------------------------- + + -- Not instantiated yet + pNSNK_RD_VALID : process(clk) + begin + if (clk = '1' and clk'event) then + cs_nsnk_read_valid <= cs_nsnk_read_en; + end if; + end process pNSNK_RD_VALID; + + cs_nsnk_read_data <= X"DEAD_BEEF"; + + ----------------------------------------------------------------------------- + -- Event Logger + ----------------------------------------------------------------------------- + + -- Not instantiated yet + pLOG_RD_VALID : process(clk) + begin + if (clk = '1' and clk'event) then + cs_log_read_valid <= cs_log_read_en; + end if; + end process pLOG_RD_VALID; + + cs_log_read_data <= X"DEAD_BEEF"; + +end architecture rtl; diff --git a/generic_ip/fire_pulse_manager/3/src/pof_rx_3.vhd b/generic_ip/fire_pulse_manager/3/src/pof_rx_3.vhd new file mode 100644 index 0000000..e38c91f --- /dev/null +++ b/generic_ip/fire_pulse_manager/3/src/pof_rx_3.vhd @@ -0,0 +1,358 @@ +------------------------------------------------------------------------------- +-- Title : pof_rx +-- Project : SMB +------------------------------------------------------------------------------- +-- File : pof_rx.vhd +-- Author : Gianmarco Girau +-- Company : Global Inkjet Systems +-- Created : 2017-08-23 +-- Last update: 2019-07-15 +-- SVN ID : Git +-- Standard : VHDL'08 +------------------------------------------------------------------------------- +-- Description: +-- Deserializes and decodes the EMS (SMB) output, received from the POF. +------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity pof_rx_3 is + port( + reset_n : in std_logic; + clk : in std_logic; + -- + init : in std_logic; + rx_clk : in std_logic; + rx_data : in std_logic; + init_out : out std_logic; + dp_dir : in std_logic; + enc_out : out std_logic; + pd_out : out std_logic; + inc_pos : out std_logic; + dec_pos : out std_logic; + abs_pos : out std_logic_vector(31 downto 0); + -- C&S + enable : in std_logic; + bit_div : in std_logic_vector(3 downto 0); + error_rate_thres : in std_logic_vector(7 downto 0); + one_pps : in std_logic; + upd_max_pos : in std_logic; + upd_min_pos : in std_logic; + max_error_flag : out std_logic; + rx_watchdog : out std_logic; + rx_watchdog_en : in std_logic; + rx_watchdog_clr : in std_logic; + parity_err_cnt : out std_logic_vector(15 downto 0); + skip_pos_cnt : out std_logic_vector(15 downto 0)); +end entity pof_rx_3; + +architecture rtl of pof_rx_3 is + + -- check the parity bit (odd parity) + function odd_parity_check(data : std_logic_vector) return std_logic is + variable parity_bit : std_logic := '0'; + begin + for n in 0 to data'length - 1 loop + parity_bit := parity_bit xor data(n); + end loop; -- n + return parity_bit; + end function odd_parity_check; + + -- Gray-to-Binary coding + function gray2bin(gray : std_logic_vector) return std_logic_vector is + variable bin : std_logic_vector(gray'range); + begin + bin(gray'length - 1) := gray(gray'length - 1); + for i in gray'length - 2 downto 0 loop + bin(i) := bin(i + 1) xor gray(i); + end loop; -- n + return bin; + end function gray2bin; + + signal clear, symbol_ok, inc_pos_i, dec_pos_i : std_logic; + signal sync_gen, pd_gen, symbol_error, sync_d : std_logic; + signal symbol_valid, symbol_valid_i, symbol_valid_d : std_logic; + signal toggle_sync, sync_confirmed, sync_toggle_test, sync : std_logic; + signal toggle_pd, pd_confirmed, pd_toggle_test, pd : std_logic; + signal valid_pos, upd_pos, corr_done, corr_sign : std_logic; + signal skip_pos, apply_corr, inc_pos_ii, dec_pos_ii : std_logic; + signal new_max, new_min, rx_error, rx_error_i : std_logic; + signal rx_symbol_val, clear_i, skip_pos_d, pos_recovery : std_logic; + signal dp_dir_d, dp_dir_change, max_error_flag_i : std_logic; + -- + signal clk_cnt : std_logic_vector(1 downto 0); + signal dist, abs_dist, skip_cnt : std_logic_vector(3 downto 0); + signal next_pos_lsb, curr_pos_lsb : std_logic_vector(3 downto 0); + signal pos_corr, max_dist, rx_error_v : std_logic_vector(3 downto 0); + signal gray_pos, rx_symbol_val_v : std_logic_vector(3 downto 0); + signal symbol, symbol_i, rx_symbol : std_logic_vector(7 downto 0); + signal rx_wd_cnt : std_logic_vector(9 downto 0); + signal parity_err_cnt_i, skip_pos_cnt_i : std_logic_vector(15 downto 0); + signal error_rate_cnt, error_rate : std_logic_vector(15 downto 0); + signal abs_pos_i, pos_max, pos_min : std_logic_vector(31 downto 0); + signal dist_pos, dist_neg : std_logic_vector(31 downto 0); + +begin + + clear <= not enable or init; + + ----------------------------------------------------------------------------- + -- De-serialize symbols (Serial clock at 300 MHz - typical) + ----------------------------------------------------------------------------- + + iRX_SYMBOL : entity work.uart_rx_3 + generic map( + data_width => 8) + port map( + reset_n => reset_n, + clk => rx_clk, + bit_div => bit_div, + init => clear_i, + data_out => rx_symbol, + data_out_valid => rx_symbol_val, + rx_error => rx_error, + rx_data => rx_data); + + -- Synchronize to the local clock + pLATCH_RX_DATA : process(rx_clk) + begin + if (rx_clk = '1' and rx_clk'event) then + if (rx_symbol_val = '1') then + symbol <= rx_symbol; + end if; + if (rx_symbol_val = '1') then + rx_symbol_val_v <= "1111"; + else + rx_symbol_val_v <= '0' & rx_symbol_val_v(3 downto 1); + end if; + if (rx_error = '1') then + rx_error_v <= "1111"; + else + rx_error_v <= '0' & rx_error_v(3 downto 1); + end if; + end if; + end process pLATCH_RX_DATA; + + iSYNC_SYMBOL_VAL : entity work.sync_wire_rEdge + generic map(rst_val => '0', sync_stages => 3) + port map(rstN => reset_n, clk => clk, async_in => rx_symbol_val_v(0), sync_out => symbol_valid); + + iSYNC_RX_ERROR : entity work.sync_wire_rEdge + generic map(rst_val => '0', sync_stages => 3) + port map(rstN => reset_n, clk => clk, async_in => rx_error_v(0), sync_out => rx_error_i); + -- synchronize clear to tx_clk + iSYNC_CLEAR : entity work.sync_wire + generic map(rst_val => '1', sync_stages => 2) + port map( + rstN => reset_n, clk => rx_clk, async_in => clear, sync_out => clear_i); + + ----------------------------------------------------------------------------- + -- Toggle-Bits Decoding + ----------------------------------------------------------------------------- + + pTOGGLE_DEC : process(clk) + begin + if (clk = '1' and clk'event) then + -- Toggle Bits + if (clear = '1') then + toggle_sync <= '0'; + elsif (sync_confirmed = '1') then + toggle_sync <= not toggle_sync; + end if; + if (clear = '1' or sync_confirmed = '1' or (symbol_valid_i = '1' and symbol_i(0) = toggle_sync)) then + sync_toggle_test <= '0'; + elsif (sync_gen = '1') then + sync_toggle_test <= '1'; + end if; + sync <= sync_confirmed; + sync_d <= sync; + if (clear = '1') then + toggle_pd <= '0'; + elsif (pd_confirmed = '1') then + toggle_pd <= not toggle_pd; + end if; + if (clear = '1' or pd_confirmed = '1' or (symbol_valid_i = '1' and symbol_i(2) = toggle_pd)) then + pd_toggle_test <= '0'; + elsif (pd_gen = '1') then + pd_toggle_test <= '1'; + end if; + pd <= pd_confirmed; + -- + symbol_valid_i <= symbol_valid and symbol_ok; + symbol_error <= symbol_valid and not symbol_ok; + if (clear = '1') then + parity_err_cnt_i <= (others => '0'); + elsif (symbol_error = '1') then + parity_err_cnt_i <= std_logic_vector(unsigned(parity_err_cnt_i) + 1); + end if; + end if; + end process pTOGGLE_DEC; + + symbol_i <= symbol; + + -- The received symbol is assumed to be vaild when there is not parity error + -- and when the two bits with the PD-toggle bit are equal + symbol_ok <= '1' when odd_parity_check(symbol) = '1' and (symbol(1) = symbol(2)) else '0'; + + sync_gen <= '1' when symbol_valid_i = '1' and symbol_i(0) /= toggle_sync else '0'; + pd_gen <= '1' when symbol_valid_i = '1' and symbol_i(2) /= toggle_pd else '0'; + -- + sync_confirmed <= sync_gen and sync_toggle_test; + pd_confirmed <= pd_gen and pd_toggle_test; + -- + init_out <= sync; + pd_out <= pd; + + parity_err_cnt <= parity_err_cnt_i; + + ----------------------------------------------------------------------------- + -- Position management & Error Recovery + ----------------------------------------------------------------------------- + + gray_pos <= symbol_i(6 downto 3); + next_pos_lsb <= gray2bin(gray_pos); + curr_pos_lsb <= abs_pos_i(3 downto 0); + + --dist <= std_logic_vector(signed(next_pos_lsb)-signed(curr_pos_lsb)); + abs_dist <= dist when dist(3) = '0' else std_logic_vector(unsigned(not dist) + 1); + + pPOS_MNG : process(clk) + begin + if (clk = '1' and clk'event) then + dist <= std_logic_vector(signed(next_pos_lsb) - signed(curr_pos_lsb)); + symbol_valid_d <= symbol_valid_i; + if (clear = '1' or (symbol_valid_d = '1' and signed(dist) = 0) or pos_recovery = '1') then + max_dist <= "0001"; + elsif (skip_pos = '1' or rx_error_i = '1') then + max_dist <= std_logic_vector(unsigned(max_dist) + 1); + end if; + if (symbol_valid_d = '1' and valid_pos = '1') then + pos_corr <= abs_dist; + elsif (apply_corr = '1') then + pos_corr <= std_logic_vector(unsigned(pos_corr) - 1); + end if; + if (clear = '1' or corr_done = '1') then + upd_pos <= '0'; + elsif (symbol_valid_d = '1' and valid_pos = '1') then + upd_pos <= '1'; + end if; + if (upd_pos = '0' or unsigned(clk_cnt) = 2) then + clk_cnt <= (others => '0'); + else + clk_cnt <= std_logic_vector(unsigned(clk_cnt) + 1); + end if; + if (symbol_valid_d = '1' and valid_pos = '1') then + corr_sign <= dist(3); + end if; + inc_pos_i <= inc_pos_ii; + dec_pos_i <= dec_pos_ii; + inc_pos <= inc_pos_i; + dec_pos <= dec_pos_i; + if (clear = '1' or sync = '1') then + abs_pos_i <= (others => '0'); + elsif (inc_pos_ii = '1') then + abs_pos_i <= std_logic_vector(signed(abs_pos_i) + 1); + elsif (dec_pos_ii = '1') then + abs_pos_i <= std_logic_vector(signed(abs_pos_i) - 1); + end if; + abs_pos <= abs_pos_i; + skip_pos_d <= skip_pos; + if (clear = '1' or (symbol_valid_d = '1' and valid_pos = '1')) then + skip_cnt <= (others => '0'); + elsif (skip_pos = '1' and skip_pos_d = '0') then + skip_cnt <= std_logic_vector(unsigned(skip_cnt) + 1); + end if; + if (clear = '1') then + skip_pos_cnt_i <= (others => '0'); + elsif (skip_pos_d = '1') then + skip_pos_cnt_i <= std_logic_vector(unsigned(skip_pos_cnt_i) + 1); + end if; + end if; + end process pPOS_MNG; + + skip_pos <= '1' when (symbol_valid = '1' and symbol_ok = '0') or (symbol_valid_d = '1' and valid_pos = '0') else '0'; + + pos_recovery <= '1' when unsigned(skip_cnt) >= 3 else '0'; + valid_pos <= '1' when unsigned(abs_dist) <= unsigned(max_dist) or pos_recovery = '1' else '0'; + + apply_corr <= '1' when upd_pos = '1' and clk_cnt = "01" else '0'; + corr_done <= '1' when signed(dist) = 0 else '0'; + + inc_pos_ii <= '1' when apply_corr = '1' and corr_sign = '0' else '0'; + dec_pos_ii <= '1' when apply_corr = '1' and corr_sign = '1' else '0'; + + skip_pos_cnt <= skip_pos_cnt_i; + + ----------------------------------------------------------------------------- + -- Additional logic for error reporting + ----------------------------------------------------------------------------- + + pERROR_REPORTING : process(clk) + begin + if (clk = '1' and clk'event) then + if (clear = '1' or one_pps = '1') then + error_rate_cnt <= (others => '0'); + elsif (symbol_error = '1') then + error_rate_cnt <= std_logic_vector(unsigned(error_rate_cnt) + 1); + end if; + if (clear = '1') then + error_rate <= (others => '0'); + elsif (one_pps = '1') then + error_rate <= error_rate_cnt; + end if; + max_error_flag <= not clear and max_error_flag_i; + if (clear = '1' or symbol_valid_i = '1' or rx_watchdog_clr = '1') then + rx_wd_cnt <= (others => '0'); + else + rx_wd_cnt <= std_logic_vector(unsigned(rx_wd_cnt) + 1); + end if; + if (clear = '1' or rx_watchdog_clr = '1' or rx_watchdog_en = '0' or sync = '1') then + rx_watchdog <= '0'; + elsif (unsigned(rx_wd_cnt) > 1000) then + rx_watchdog <= '1'; + end if; + end if; + end process pERROR_REPORTING; + + max_error_flag_i <= '1' when unsigned(error_rate) > unsigned(error_rate_thres) else '0'; + + ----------------------------------------------------------------------------- + -- Encoder Pulse management + ----------------------------------------------------------------------------- + + -- Encoder pulses are generated only when there is an increment of the + -- position in the intended direction, which exceeds the previous maximum. + -- The value of the maximum is reset in the following situations: + -- 1. After a Init/Sync pulse + -- 2. After a direction change + -- 3. When the distance between the current position and the previous maximum + -- exceeds a programmable threshold, where the threshold is a 32 bit signed + -- number. Only the 16 MSBs of this threshold can be configured. The threshold + -- is set to the maximum value by default (e.g.: (2^23 = 8388608) + + pENC_MNG : process(clk) + begin + if (clk = '1' and clk'event) then + dp_dir_d <= dp_dir; + if (sync_d = '1' or dp_dir_change = '1' or new_max = '1' or upd_max_pos = '1') then + pos_max <= abs_pos_i; + end if; + if (sync_d = '1' or dp_dir_change = '1' or new_min = '1' or upd_min_pos = '1') then + pos_min <= abs_pos_i; + end if; + enc_out <= new_min or new_max; + end if; + end process pENC_MNG; + + dp_dir_change <= dp_dir xor dp_dir_d; + + dist_pos <= std_logic_vector(signed(abs_pos_i) - signed(pos_max)); + dist_neg <= std_logic_vector(signed(pos_min) - signed(abs_pos_i)); + + new_max <= '1' when inc_pos_i = '1' and dp_dir = '0' and dist_pos(31) = '0' and unsigned(dist_pos(3 downto 0)) /= 0 else '0'; + new_min <= '1' when dec_pos_i = '1' and dp_dir = '1' and dist_neg(31) = '0' and unsigned(dist_neg(3 downto 0)) /= 0 else '0'; + +end architecture rtl; diff --git a/generic_ip/fire_pulse_manager/3/src/test/fifo_16x8_3.vhd b/generic_ip/fire_pulse_manager/3/src/test/fifo_16x8_3.vhd new file mode 100644 index 0000000..c5e51dc --- /dev/null +++ b/generic_ip/fire_pulse_manager/3/src/test/fifo_16x8_3.vhd @@ -0,0 +1,201 @@ +-- megafunction wizard: %FIFO% +-- GENERATION: STANDARD +-- VERSION: WM1.0 +-- MODULE: scfifo + +-- ============================================================ +-- File Name: fifo_16x8.vhd +-- Megafunction Name(s): +-- scfifo +-- +-- Simulation Library Files(s): +-- altera_mf +-- ============================================================ +-- ************************************************************ +-- THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE! +-- +-- 16.0.2 Build 222 07/20/2016 SJ Lite Edition +-- ************************************************************ + + +--Copyright (C) 1991-2016 Altera Corporation. All rights reserved. +--Your use of Altera Corporation's design tools, logic functions +--and other software and tools, and its AMPP partner logic +--functions, and any output files from any of the foregoing +--(including device programming or simulation files), and any +--associated documentation or information are expressly subject +--to the terms and conditions of the Altera Program License +--Subscription Agreement, the Altera Quartus Prime License Agreement, +--the Altera MegaCore Function License Agreement, or other +--applicable license agreement, including, without limitation, +--that your use is for the sole purpose of programming logic +--devices manufactured by Altera and sold by Altera or its +--authorized distributors. Please refer to the applicable +--agreement for further details. + + +LIBRARY ieee; +USE ieee.std_logic_1164.all; + +LIBRARY altera_mf; +USE altera_mf.all; + +ENTITY fifo_16x8_3 IS + PORT + ( + clock : IN STD_LOGIC ; + data : IN STD_LOGIC_VECTOR (7 DOWNTO 0); + rdreq : IN STD_LOGIC ; + sclr : IN STD_LOGIC ; + wrreq : IN STD_LOGIC ; + empty : OUT STD_LOGIC ; + full : OUT STD_LOGIC ; + q : OUT STD_LOGIC_VECTOR (7 DOWNTO 0); + usedw : OUT STD_LOGIC_VECTOR (3 DOWNTO 0) + ); +END fifo_16x8_3; + + +ARCHITECTURE SYN OF fifo_16x8_3 IS + + SIGNAL sub_wire0 : STD_LOGIC ; + SIGNAL sub_wire1 : STD_LOGIC ; + SIGNAL sub_wire2 : STD_LOGIC_VECTOR (7 DOWNTO 0); + SIGNAL sub_wire3 : STD_LOGIC_VECTOR (3 DOWNTO 0); + + + + COMPONENT scfifo + GENERIC ( + add_ram_output_register : STRING; + intended_device_family : STRING; + lpm_hint : STRING; + lpm_numwords : NATURAL; + lpm_showahead : STRING; + lpm_type : STRING; + lpm_width : NATURAL; + lpm_widthu : NATURAL; + overflow_checking : STRING; + underflow_checking : STRING; + use_eab : STRING + ); + PORT ( + clock : IN STD_LOGIC ; + data : IN STD_LOGIC_VECTOR (7 DOWNTO 0); + rdreq : IN STD_LOGIC ; + sclr : IN STD_LOGIC ; + wrreq : IN STD_LOGIC ; + empty : OUT STD_LOGIC ; + full : OUT STD_LOGIC ; + q : OUT STD_LOGIC_VECTOR (7 DOWNTO 0); + usedw : OUT STD_LOGIC_VECTOR (3 DOWNTO 0) + ); + END COMPONENT; + +BEGIN + empty <= sub_wire0; + full <= sub_wire1; + q <= sub_wire2(7 DOWNTO 0); + usedw <= sub_wire3(3 DOWNTO 0); + + scfifo_component : scfifo + GENERIC MAP ( + add_ram_output_register => "ON", + intended_device_family => "Cyclone V", + lpm_hint => "RAM_BLOCK_TYPE=MLAB", + lpm_numwords => 16, + lpm_showahead => "OFF", + lpm_type => "scfifo", + lpm_width => 8, + lpm_widthu => 4, + overflow_checking => "ON", + underflow_checking => "ON", + use_eab => "ON" + ) + PORT MAP ( + clock => clock, + data => data, + rdreq => rdreq, + sclr => sclr, + wrreq => wrreq, + empty => sub_wire0, + full => sub_wire1, + q => sub_wire2, + usedw => sub_wire3 + ); + + + +END SYN; + +-- ============================================================ +-- CNX file retrieval info +-- ============================================================ +-- Retrieval info: PRIVATE: AlmostEmpty NUMERIC "0" +-- Retrieval info: PRIVATE: AlmostEmptyThr NUMERIC "-1" +-- Retrieval info: PRIVATE: AlmostFull NUMERIC "0" +-- Retrieval info: PRIVATE: AlmostFullThr NUMERIC "-1" +-- Retrieval info: PRIVATE: CLOCKS_ARE_SYNCHRONIZED NUMERIC "0" +-- Retrieval info: PRIVATE: Clock NUMERIC "0" +-- Retrieval info: PRIVATE: Depth NUMERIC "16" +-- Retrieval info: PRIVATE: Empty NUMERIC "1" +-- Retrieval info: PRIVATE: Full NUMERIC "1" +-- Retrieval info: PRIVATE: INTENDED_DEVICE_FAMILY STRING "Cyclone V" +-- Retrieval info: PRIVATE: LE_BasedFIFO NUMERIC "0" +-- Retrieval info: PRIVATE: LegacyRREQ NUMERIC "1" +-- Retrieval info: PRIVATE: MAX_DEPTH_BY_9 NUMERIC "0" +-- Retrieval info: PRIVATE: OVERFLOW_CHECKING NUMERIC "0" +-- Retrieval info: PRIVATE: Optimize NUMERIC "1" +-- Retrieval info: PRIVATE: RAM_BLOCK_TYPE NUMERIC "1" +-- Retrieval info: PRIVATE: SYNTH_WRAPPER_GEN_POSTFIX STRING "0" +-- Retrieval info: PRIVATE: UNDERFLOW_CHECKING NUMERIC "0" +-- Retrieval info: PRIVATE: UsedW NUMERIC "1" +-- Retrieval info: PRIVATE: Width NUMERIC "8" +-- Retrieval info: PRIVATE: dc_aclr NUMERIC "0" +-- Retrieval info: PRIVATE: diff_widths NUMERIC "0" +-- Retrieval info: PRIVATE: msb_usedw NUMERIC "0" +-- Retrieval info: PRIVATE: output_width NUMERIC "8" +-- Retrieval info: PRIVATE: rsEmpty NUMERIC "1" +-- Retrieval info: PRIVATE: rsFull NUMERIC "0" +-- Retrieval info: PRIVATE: rsUsedW NUMERIC "0" +-- Retrieval info: PRIVATE: sc_aclr NUMERIC "0" +-- Retrieval info: PRIVATE: sc_sclr NUMERIC "1" +-- Retrieval info: PRIVATE: wsEmpty NUMERIC "0" +-- Retrieval info: PRIVATE: wsFull NUMERIC "1" +-- Retrieval info: PRIVATE: wsUsedW NUMERIC "0" +-- Retrieval info: LIBRARY: altera_mf altera_mf.altera_mf_components.all +-- Retrieval info: CONSTANT: ADD_RAM_OUTPUT_REGISTER STRING "ON" +-- Retrieval info: CONSTANT: INTENDED_DEVICE_FAMILY STRING "Cyclone V" +-- Retrieval info: CONSTANT: LPM_HINT STRING "RAM_BLOCK_TYPE=MLAB" +-- Retrieval info: CONSTANT: LPM_NUMWORDS NUMERIC "16" +-- Retrieval info: CONSTANT: LPM_SHOWAHEAD STRING "OFF" +-- Retrieval info: CONSTANT: LPM_TYPE STRING "scfifo" +-- Retrieval info: CONSTANT: LPM_WIDTH NUMERIC "8" +-- Retrieval info: CONSTANT: LPM_WIDTHU NUMERIC "4" +-- Retrieval info: CONSTANT: OVERFLOW_CHECKING STRING "ON" +-- Retrieval info: CONSTANT: UNDERFLOW_CHECKING STRING "ON" +-- Retrieval info: CONSTANT: USE_EAB STRING "ON" +-- Retrieval info: USED_PORT: clock 0 0 0 0 INPUT NODEFVAL "clock" +-- Retrieval info: USED_PORT: data 0 0 8 0 INPUT NODEFVAL "data[7..0]" +-- Retrieval info: USED_PORT: empty 0 0 0 0 OUTPUT NODEFVAL "empty" +-- Retrieval info: USED_PORT: full 0 0 0 0 OUTPUT NODEFVAL "full" +-- Retrieval info: USED_PORT: q 0 0 8 0 OUTPUT NODEFVAL "q[7..0]" +-- Retrieval info: USED_PORT: rdreq 0 0 0 0 INPUT NODEFVAL "rdreq" +-- Retrieval info: USED_PORT: sclr 0 0 0 0 INPUT NODEFVAL "sclr" +-- Retrieval info: USED_PORT: usedw 0 0 4 0 OUTPUT NODEFVAL "usedw[3..0]" +-- Retrieval info: USED_PORT: wrreq 0 0 0 0 INPUT NODEFVAL "wrreq" +-- Retrieval info: CONNECT: @clock 0 0 0 0 clock 0 0 0 0 +-- Retrieval info: CONNECT: @data 0 0 8 0 data 0 0 8 0 +-- Retrieval info: CONNECT: @rdreq 0 0 0 0 rdreq 0 0 0 0 +-- Retrieval info: CONNECT: @sclr 0 0 0 0 sclr 0 0 0 0 +-- Retrieval info: CONNECT: @wrreq 0 0 0 0 wrreq 0 0 0 0 +-- Retrieval info: CONNECT: empty 0 0 0 0 @empty 0 0 0 0 +-- Retrieval info: CONNECT: full 0 0 0 0 @full 0 0 0 0 +-- Retrieval info: CONNECT: q 0 0 8 0 @q 0 0 8 0 +-- Retrieval info: CONNECT: usedw 0 0 4 0 @usedw 0 0 4 0 +-- Retrieval info: GEN_FILE: TYPE_NORMAL fifo_16x8.vhd TRUE +-- Retrieval info: GEN_FILE: TYPE_NORMAL fifo_16x8.inc FALSE +-- Retrieval info: GEN_FILE: TYPE_NORMAL fifo_16x8.cmp FALSE +-- Retrieval info: GEN_FILE: TYPE_NORMAL fifo_16x8.bsf FALSE +-- Retrieval info: GEN_FILE: TYPE_NORMAL fifo_16x8_inst.vhd FALSE +-- Retrieval info: LIB_FILE: altera_mf diff --git a/generic_ip/fire_pulse_manager/3/src/test/fire_pulse_manager_3_tb.vhd b/generic_ip/fire_pulse_manager/3/src/test/fire_pulse_manager_3_tb.vhd new file mode 100644 index 0000000..bd8ab48 --- /dev/null +++ b/generic_ip/fire_pulse_manager/3/src/test/fire_pulse_manager_3_tb.vhd @@ -0,0 +1,715 @@ +------------------------------------------------------------------------------- +-- Title : fire_pulse_manager_tb +-- Project : fire_pulse_manager +------------------------------------------------------------------------------- +-- File : fire_pulse_manager_tb.vhd +-- Author : Christos Spirotis +-- Company : Global Inkjet Systems +-- Created : 2018-08-10 +-- Last update: 2019-07-15 +-- SVN ID : Git +-- Standard : VHDL'08 +------------------------------------------------------------------------------- +-- Description: +-- Testbench for fire pulse manager block +------------------------------------------------------------------------------- + +library modelsim_lib; +use modelsim_lib.util.all; +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; +use ieee.math_real.all; +use std.textio.all; +library work; +use work.fire_pulse_3_pkg.all; +use work.log_pkg.all; +use work.avalon_verify_pkg.all; +use work.pulse_generator_1_pkg.all; +use work.enc_pd_emul_1_pkg.CSR_ENC_NCO_INC_ADDR; +use work.enc_pd_emul_1_pkg.CSR_ENC_CTRL_ADDR; +use work.enc_pd_emul_1_pkg.CSR_PD_CTRL_ADDR; +use work.enc_pd_emul_1_pkg.CSR_OUT_ENABLE_ADDR; +use work.enc_pd_emul_1_pkg.CSR_PULSE_NUM_ADDR; + +library osvvm; +use osvvm.RandomPkg.all; + +entity fire_pulse_manager_3_tb is +end fire_pulse_manager_3_tb; + +architecture behav of fire_pulse_manager_3_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; + + -- TODO Try different receive oversampling ratios - 300MHz is in the real system + constant RX_CLK_PERIOD : time := CLK_PERIOD / 3; -- 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); + + signal reset_n : std_logic := '0'; + signal clk : std_logic := '0'; + signal rx_clk : std_logic := '0'; + 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_writedata : std_logic_vector(31 downto 0); + signal avs_read : std_logic_vector(DEV_NUM - 1 downto 0); + signal avs_waitrequest : 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; + signal pd_spy : std_logic; + signal inc_pos : std_logic; + signal dec_pos : std_logic; + signal abs_position : std_logic_vector(31 downto 0); + signal abs_spy : std_logic_vector(31 downto 0); + signal tx_data : std_logic; + signal pof_tx_avs_rv : std_logic; + signal pof_tx_avs_we_d : std_logic; + -- + signal abs_position_d : std_logic_vector(31 downto 0); + signal dir_in : std_logic; + signal swathe_cnt : integer; + signal swathe_pos : integer; + signal end_of_swathe : std_logic; + signal test_completed : boolean; + signal running : 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 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; + + -- generate the NCO increment corresponding to a given output frequency + function freq2NCO_inc( + f_out : real; f_clk : real) return std_logic_vector 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)); + return nco_inc; + + end function freq2NCO_inc; + +begin -- behav + + clk_pr : process + begin + clk <= '0'; + wait for 0.5 * CLK_PERIOD; + clk <= '1'; + wait for 0.5 * CLK_PERIOD; + end process clk_pr; + + rx_clk_pr : process + begin + rx_clk <= '0'; + wait for 0.5 * RX_CLK_PERIOD; + rx_clk <= '1'; + wait for 0.5 * RX_CLK_PERIOD; + end process rx_clk_pr; + + ----------------------------------------------------------------------------- + -- DUTs : Fire Pulse Manager + ----------------------------------------------------------------------------- + + iDUT : entity work.fire_pulse_manager_3 + port map( + reset_n => reset_n, + clk => clk, + rx_clk => rx_clk, + pof_rx => pof_rx, + pof_tx => pof_tx, + fire_pulse => ch_pulse_out, + mon_pt => open, + ins_fpm_irq_0 => open, + ins_fpm_irq_1 => open, + ins_fpm_irq_2 => open, + ins_fpm_irq_3 => open, + avs_address => avs_address, + avs_write => avs_write(0), + avs_writedata => avs_writedata, + avs_read => avs_read(0), + avs_waitrequest => avs_waitrequest(0), + avs_readdata => avs_readdata(0) + ); + + pof_rx <= transport tx_data after POF_DELAY; + + ----------------------------------------------------------------------------- + -- POF Tx + ----------------------------------------------------------------------------- + + iPOF_TX : entity work.pof_tx_3 + port map( + reset_n => reset_n, + clk => clk, + init => init_tx, + pd_in => pd_in, + inc_pos => inc_pos, + dec_pos => dec_pos, + abs_position => abs_position, + tx_data => tx_data, + avs_address => avs_address(2 downto 0), + avs_write => avs_write(1), + avs_writedata => avs_writedata, + avs_read => avs_read(1), + avs_readdatavalid => pof_tx_avs_rv, + avs_readdata => avs_readdata(1)); + + -- Generate a dummy waitrequest for the POF-tx + pPOF_TX_DUMMY_WR : process(clk) + begin + if(clk = '1' and clk'event) then + pof_tx_avs_we_d <= avs_write(1); + end if; + end process pPOF_TX_DUMMY_WR; + + avs_waitrequest(1) <= '0' when pof_tx_avs_we_d = '1' or pof_tx_avs_rv = '1' else '0'; + + ----------------------------------------------------------------------------- + -- Stimuli Generation + ----------------------------------------------------------------------------- + + pSTIMULI_REGs : process(clk) + begin + 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'; + + pSTIMULI : process + 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; + -- + swathe_cnt <= 0; + stimuli_completed <= false; + end_of_swathe <= '0'; + + -- generating the stimulus + wait until running = true; + wait for 200 ns; + -- Send a Init/Sync pulse + wait until clk = '1' and clk'event; + init_tx <= '1'; + wait until clk = '1' and clk'event; + init_tx <= '0'; + wait for 500 ns; + -- + -- 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 + 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); + else + abs_position <= std_logic_vector(signed(abs_position) - 1); + end if; + -- + 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; + 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 + + 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 + end_of_stimuli := true; + else + swathe_cnt <= swathe_cnt + 1; + end if; + end if; + if (end_of_stimuli = false) then + wait until clk = '1' and clk'event; + dir_in <= not dir_in; + -- Wait some time to make sure the change of direction is transmitted. + -- Note: if the position starts changing before the receiver was able to + -- confirm the change of direction, then some encoder pulses may not be + -- generated + wait for 1 us; + wait until clk = '1' and clk'event; + end if; + end loop; -- end_of_stimuli = false + + stimuli_completed <= true; + wait; + + end process pSTIMULI; + + ----------------------------------------------------------------------------- + -- Testbench Control + ----------------------------------------------------------------------------- + + 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; + 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); + + -- Set the verbosity level for logging + set_log_verbosity(VERBOSITY_LEVEL); + set_log_verbosity(VHIGH); + + log_header("Multi-channel FPM verification:", VLOW); + + test_completed <= false; + running <= false; + passed <= false; + failed <= false; + + -- Reset + reset_n <= '0'; + wait for 100 ns; + wait until clk = '1' and clk'event; + reset_n <= '1'; + + if (configuring /= true) then + wait until configuring = true; + end if; + wait until configuring = false; + running <= true; + log("Running test ... ", VLOW, true); + + 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; + fp_arrived_time(i) := 0; + end loop; + 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 + if fp_arrived(i) = true then + fp_arrived_agg := fp_arrived_agg + 1; + end if; + end loop; + + wait until (unsigned(ch_pulse_out) /= 0 or stimuli_completed); + if (stimuli_completed) then + exit; + end if; + + 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)); + 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 + log("Channel CH" & integer'image(i) & " OFFSET INCORRECT !!! ", VLOW, true); + detected_error <= true; + end if; + end if; + end loop; + end loop; + end loop; + + 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; + + 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 + 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 (i = 0 and (pd_cnt(i) /= (NUM_ITERATIONS) * 2)) or + (i /= 0 and pd_cnt(i) /= 0) then -- fire_pulse_manager now has no registers beyond channel 0 + log("Channel CH" & integer'image(i) & " PD_cnt counter value Incorrect: ", VLOW, true); + detected_error <= true; + end if; + if (i = 0 and (fp_cnt(i) /= (NUM_ITERATIONS) * 2 * 100)) or + (i /= 0 and fp_cnt(i) /= 0) then + log("Channel CH" & integer'image(i) & " FP_cnt counter value Incorrect: ", VLOW, true); + detected_error <= true; + end if; + end loop; + + wait until clk = '1' and clk'event; + + if (detected_error = true) 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; + + 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); + + begin + sel_slave_0 <= '0'; + sel_slave_1 <= '0'; + configuring <= true; + + -- initilialize the Avalon master-bus + mm_m_init(avs_m, use_waitrequest => true); + + 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); + sel_slave_1 <= '1'; + -- Config netfork_tx control registers: + -- enable the block + addr := std_logic_vector(to_unsigned(0, 32)); + data := X"0000_0021"; + mm_32b_write(addr, data, avs_s, avs_m); + + sel_slave_1 <= '0'; + sel_slave_0 <= '1'; + wait until clk = '1' and clk'event; + + 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)); + 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)); + data := X"000000FF"; + -- Write the data to the register + 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)); + data := X"0000_8061"; -- set bit_div to 6 to match the 50MBd TX signal to the 300MHz RX_CLK + -- Write the data to the register + mm_32b_write(addr, data, avs_s, avs_m); + -- Select pulse generator + addr := std_logic_vector(to_unsigned(2, 32)); + data := X"0000_0001"; + -- Write the data to the register + mm_32b_write(addr, data, avs_s, avs_m); + -- Config external fire pulses + addr := std_logic_vector(to_unsigned(12, 32)); + data := X"0008_0004"; + -- 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); + 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)); + data := 32X"B"; + -- Write the data to the register + mm_32b_write(addr, data, avs_s, avs_m); + + 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 + 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); + end loop; + configuring <= false; + -- issue PD + 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)); + 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)); + 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)); + 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)); + 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)); + 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)); + 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)); + 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)); + 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_readdata(1) when sel_slave_1 = '1' else (others => '0'); + + avs_s.mm_readdatavalid <= '0'; + + avs_s.mm_waitrequest <= avs_waitrequest(0) when sel_slave_0 = '1' else + avs_waitrequest(1) when sel_slave_1 = '1' else '0'; + + avs_s.use_readvalid <= false; + + avs_address <= avs_m.mm_address(avs_address'range); + avs_write(0) <= avs_m.mm_write and sel_slave_0; + avs_write(1) <= avs_m.mm_write and sel_slave_1; + avs_writedata <= avs_m.mm_writedata; + avs_read(0) <= avs_m.mm_read and sel_slave_0; + avs_read(1) <= avs_m.mm_read and sel_slave_1; + +end behav; + diff --git a/generic_ip/fire_pulse_manager/3/src/test/pof_tx_3.vhd b/generic_ip/fire_pulse_manager/3/src/test/pof_tx_3.vhd new file mode 100644 index 0000000..a6945b4 --- /dev/null +++ b/generic_ip/fire_pulse_manager/3/src/test/pof_tx_3.vhd @@ -0,0 +1,245 @@ +------------------------------------------------------------------------------- +-- Title : pof_tx +-- Project : SMB +------------------------------------------------------------------------------- +-- File : pof_tx.vhd +-- Author : Gianmarco Girau +-- Company : Global Inkjet Systems +-- Created : 2017-08-22 +-- Last update: 2019-07-15 +-- SVN ID : Git +-- Standard : VHDL'08 +------------------------------------------------------------------------------- +-- Description: +-- Encodes the EMS output into a serial format to be distributed over the POF +------------------------------------------------------------------------------- + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity pof_tx_3 is + port( + reset_n : in std_logic; + clk : in std_logic; + init : in std_logic; + pd_in : in std_logic; + inc_pos : in std_logic; + dec_pos : in std_logic; + abs_position : in std_logic_vector(31 downto 0); + tx_data : out std_logic; + -- Avalon MM Interface + avs_address : in std_logic_vector( 2 downto 0); + avs_write : in std_logic; + avs_writedata : in std_logic_vector(31 downto 0); + avs_read : in std_logic; + avs_readdatavalid : out std_logic; + avs_readdata : out std_logic_vector(31 downto 0)); +end entity pof_tx_3; + +architecture rtl of pof_tx_3 is + + constant CSR : std_logic_vector( 2 downto 0) := b"000"; + constant ERROR_INJ_REG : std_logic_vector( 2 downto 0) := b"001"; + + constant KEEPALIVE_PERIOD : integer := 100; + constant INIT_BLOCKED_PERIOD : integer := 200; + + function odd_parity(data : std_logic_vector) return std_logic is + variable parity_bit : std_logic := '1'; + begin + for n in 0 to data'length-1 loop + parity_bit := parity_bit xor data(n); + end loop; -- n + return parity_bit; + end function odd_parity; + + function bin2gray(bin : std_logic_vector) return std_logic_vector is + variable gray : std_logic_vector(bin'range); + begin + gray := bin xor ('0' & bin(bin'length-1 downto 1)); + return gray; + end function bin2gray; + + signal rd_event, wr_event, empty, full, tx_ready : std_logic; + signal rd_event_d, wr_event_i, symbol_valid : std_logic; + signal enable, toggle_sync, toggle_pd : std_logic; + signal add_keepalive, ovfl_err, init_d, init_gen : std_logic; + signal clear, pd_in_d, pd_gen, parity_bit : std_logic; + signal inject_error, inject_error_req : std_logic; + signal pd_event, pd_event_d, pd_event_dd : std_logic; + signal init_blocked, pd_event_ddd, delayed_pos : std_logic; + -- + signal delayed_pos_v : std_logic_vector( 2 downto 0); + signal init_v, gray, bit_div : std_logic_vector( 3 downto 0); + signal latched_pos : std_logic_vector( 3 downto 0); + signal event_in_i : std_logic_vector( 6 downto 0); + signal keepalive_cnt : std_logic_vector( 7 downto 0); + signal event_in, event_out : std_logic_vector( 7 downto 0); + signal symbol : std_logic_vector( 7 downto 0); + signal init_blk_cnt : std_logic_vector( 9 downto 0) := (others => '0'); + + +begin + + clear <= not enable; + + ----------------------------------------------------------------------------- + -- Encode events and queue these in a FIFO + ----------------------------------------------------------------------------- + + pEVENT_GEN : process(clk) + begin + if(clk = '1' and clk'event) then + init_d <= init; + if(init = '1' and init_d = '0' and init_blocked = '0') then + init_v <= "1100"; + else + init_v <= '0' & init_v(3 downto 1); + end if; + if(enable = '0') then + toggle_sync <= '0'; + elsif(init_d = '1' and init_blocked = '0') then + toggle_sync <= not toggle_sync; + end if; + if(init_gen = '1') then + init_blk_cnt <= std_logic_vector(to_unsigned(INIT_BLOCKED_PERIOD, 10)); + elsif(init_blocked = '1') then + init_blk_cnt <= std_logic_vector(unsigned(init_blk_cnt)-1); + end if; + pd_in_d <= pd_in; + pd_event_d <= pd_event; + pd_event_dd <= pd_event_d; + pd_event_ddd <= pd_event_dd; + if(pd_event = '1') then + latched_pos <= abs_position(3 downto 0); + end if; + if((dec_pos = '1' or inc_pos = '1') and pd_gen = '1') then + delayed_pos_v <= "111"; + else + delayed_pos_v <= '0' & delayed_pos_v(2 downto 1); + end if; + if(enable = '0') then + toggle_pd <= '0'; + elsif(pd_event = '1') then + toggle_pd <= not toggle_pd; + end if; + wr_event <= wr_event_i or add_keepalive; + event_in <= parity_bit & event_in_i; + if(enable = '0' or wr_event_i = '1') then + keepalive_cnt <= std_logic_vector(to_unsigned(KEEPALIVE_PERIOD, 8)); + else + keepalive_cnt <= std_logic_vector(unsigned(keepalive_cnt)-1); + end if; + if(enable = '0') then + ovfl_err <= '0'; + elsif(wr_event = '1' and full = '1') then + ovfl_err <= '1'; + end if; + if(clear = '1' or wr_event = '1') then + inject_error <= '0'; + elsif(inject_error_req = '1') then + inject_error <= '1'; + end if; + end if; + end process pEVENT_GEN; + + init_gen <= init_v(0); + + init_blocked <= '1' when unsigned(init_blk_cnt) /= 0 else '0'; + + pd_event <= pd_in and not pd_in_d; + pd_gen <= pd_event or pd_event_d or pd_event_dd; + + delayed_pos <= delayed_pos_v(0) and pd_event_ddd; + + wr_event_i <= enable and (init_gen or pd_gen or dec_pos or inc_pos or delayed_pos); + + add_keepalive <= '1' when wr_event_i = '0' and unsigned(keepalive_cnt) = 0 else '0'; + +gray <= bin2gray(latched_pos) when (pd_event_d = '1' or pd_event_dd = '1') else bin2gray(abs_position(3 downto 0)); + + -- toggle_pd is repeated twice in the tx word, to improve resiliance against + -- double bit-flips errors + event_in_i <= gray & toggle_pd & toggle_pd & toggle_sync; + + parity_bit <= odd_parity(event_in_i) xor inject_error; + + iQUEUE_EVENT : entity work.fifo_16x8_3 + port map ( + clock => clk, + data => event_in, + rdreq => rd_event, + sclr => clear, + wrreq => wr_event, + empty => empty, + full => full, + q => event_out, + usedw => open); + + ----------------------------------------------------------------------------- + -- Transmit symbols over serial link + ----------------------------------------------------------------------------- + + pGET_EVENT : process(clk) + begin + if(clk = '1' and clk'event) then + rd_event_d <= rd_event; + symbol_valid <= rd_event_d; + end if; + end process pGET_EVENT; + + rd_event <= '1' when tx_ready = '1' and empty = '0' and rd_event_d = '0' and symbol_valid = '0' else '0'; + + symbol <= event_out; + + iTX_SYMBOL : entity work.uart_tx_3 + generic map ( + data_width => 8) + port map ( + reset_n => reset_n, + clk => clk, + bit_div => bit_div, + init => clear, + ready => tx_ready, + data_in => symbol, + data_valid => symbol_valid, + tx_data => tx_data); + + ----------------------------------------------------------------------------- + -- C&S registers + ----------------------------------------------------------------------------- + + pCTRL_STATUS : process(reset_n, clk) + begin + if(reset_n = '0') then + avs_readdatavalid <= '0'; + enable <= '0'; + bit_div <= "0010"; + elsif(clk = '1' and clk'event) then + inject_error_req <= '0'; + -- CTRL registers + if(avs_write = '1') then + case avs_address is + when CSR => + enable <= avs_writedata(0); + bit_div <= avs_writedata(7 downto 4); + when ERROR_INJ_REG => + inject_error_req <= avs_writedata(0); + when others => null; + end case; + end if; + -- Read Ctrl & Status registers + avs_readdatavalid <= avs_read; + if(avs_read = '1') then + case avs_address is + when CSR => + avs_readdata <= X"000000" & bit_div & b"00" & ovfl_err & enable; + when others => + avs_readdata <= X"BAD1BAD0"; + end case; + end if; + end if; + end process pCTRL_STATUS; + +end architecture rtl; diff --git a/generic_ip/fire_pulse_manager/3/src/test/pof_tx_rx_3_tb.vhd b/generic_ip/fire_pulse_manager/3/src/test/pof_tx_rx_3_tb.vhd new file mode 100644 index 0000000..5de0c80 --- /dev/null +++ b/generic_ip/fire_pulse_manager/3/src/test/pof_tx_rx_3_tb.vhd @@ -0,0 +1,623 @@ +------------------------------------------------------------------------------- +-- Title : pof_tx_rx_tb +-- Project : HMB daisy-chaining +------------------------------------------------------------------------------- +-- File : pof_tx_rx_tb.vhd +-- Author : GMG +-- Company : Global Inkjet Systems +-- Created : 2017-08-29 +-- Last update: 2019-07-15 +-- SVN ID : Git +-- Standard : VHDL'2008 +------------------------------------------------------------------------------- +-- Description: +-- Testbench for verifying the transmission over the POF with emb2poftx and +-- pofrx2hmb blocks +------------------------------------------------------------------------------- + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +library OSVVM; +use OSVVM.RandomBasePkg.all; +use OSVVM.RandomPkg.all; + +use work.log_pkg.all; +use work.avalon_verify_pkg.all; + +use work.log_pkg.all; + +entity pof_tx_rx_3_tb is + -- .. +end entity pof_tx_rx_3_tb; + +architecture behav of pof_tx_rx_3_tb is + + constant CLK_PERIOD : time := 10 ns; -- 100MHz + constant RX_CLK_PERIOD : time := 3.333 ns; -- 300MHz + + constant NUM_ITERATIONS : natural := 10; + constant SWATHE_LEN : integer := 1000; + constant START_DIR : std_logic := '0'; + constant INJECT_ERROR_PERC : natural := 4; -- percentage of injected errors + constant DISCR_THRES : natural := 1000; + constant TIME_INT : time := 800 ns; + + constant UART_BIT_DIV : std_logic_vector(3 downto 0) := "0110"; -- divide by 6 + + -- Logging Verbosity Level + constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM; + + signal clk, rx_clk, rx_clk_i, reset_n : std_logic := '0'; + signal avs_read, avs_write, sel_slave_0, sel_slave_1 : std_logic; + signal avs_write_sl0, avs_read_sl0, avs_readdatavalid_sl0 : std_logic; + signal avs_write_sl1, avs_read_sl1, avs_readdatavalid_sl1 : std_logic; + signal init_tx, init_rx, dir_in, pd_in, inc_pos, dec_pos : std_logic; + signal tx_data, rx_data, init_out, dir_out, enc_out : std_logic; + signal pd_out, inc_pos_out, dec_pos_out, end_of_swathe : std_logic; + -- + signal test_completed, running, configuring : boolean; + signal passed, failed, stimuli_completed : boolean; + signal detected_error : boolean := false; + -- + signal avs_address : std_logic_vector(2 downto 0); + signal avs_writedata : std_logic_vector(31 downto 0); + signal avs_readdata_sl0, avs_readdata_sl1 : std_logic_vector(31 downto 0); + signal abs_position, abs_position_d : std_logic_vector(31 downto 0); + signal abs_pos_out : std_logic_vector(31 downto 0); + -- + signal swathe_cnt, swathe_pos : integer; + signal dir_discr_cnt, pd_discr_cnt : integer; + signal pos_discr_cnt : integer; + signal pd_in_cnt, pd_out_cnt : integer; + signal enc_pulse_cnt : integer; + signal dir_err, pd_err, ovfl_err : std_logic; + signal pos_err, enc_err, dir_in_d : std_logic; + signal injected_errors : integer; + signal max_pos, min_pos : integer; + signal max_pos_d, min_pos_d : integer; + signal exp_enc_cnt : integer; + signal exp_enc_pulse, enc_discr : std_logic; + signal enc_out_d : std_logic; + signal error_rate_thres : std_logic_vector(7 downto 0); + signal one_pps : std_logic; + signal max_error_flag : std_logic; + signal rx_watchdog : std_logic; + signal rx_watchdog_en : std_logic; + signal rx_watchdog_clr : std_logic; + -- + signal enable_rx : std_logic; + signal parity_err_cnt : std_logic_vector(15 downto 0); + signal skip_pos_cnt : std_logic_vector(15 downto 0); + -- + signal avs_m : mm_m_rec_t; + signal avs_s : mm_s_rec_t; + + +begin -- architecture behav + + clk <= not clk after 0.5 * CLK_PERIOD; + + rx_clk_i <= not rx_clk_i after 0.5 * RX_CLK_PERIOD; + rx_clk <= rx_clk_i after 1 ns; + + ----------------------------------------------------------------------------- + -- UUTs + ----------------------------------------------------------------------------- + + iPOF_TX : entity work.pof_tx_3 + port map( + reset_n => reset_n, + clk => clk, + init => init_tx, + pd_in => pd_in, + inc_pos => inc_pos, + dec_pos => dec_pos, + abs_position => abs_position, + tx_data => tx_data, + avs_address => avs_address, + avs_write => avs_write_sl0, + avs_writedata => avs_writedata, + avs_read => avs_read_sl0, + avs_readdatavalid => avs_readdatavalid_sl0, + avs_readdata => avs_readdata_sl0); + + iPOF_RX : entity work.pof_rx_3 + port map( + reset_n => reset_n, + clk => clk, + init => init_rx, + rx_clk => rx_clk, + rx_data => rx_data, + init_out => init_out, + dp_dir => dir_in, + enc_out => enc_out, + pd_out => pd_out, + inc_pos => inc_pos_out, + dec_pos => dec_pos_out, + abs_pos => abs_pos_out, + enable => enable_rx, + bit_div => UART_BIT_DIV, + error_rate_thres => error_rate_thres, + one_pps => one_pps, + upd_max_pos => '0', + upd_min_pos => '0', + max_error_flag => max_error_flag, + rx_watchdog => rx_watchdog, + rx_watchdog_en => rx_watchdog_en, + rx_watchdog_clr => rx_watchdog_clr, + parity_err_cnt => parity_err_cnt, + skip_pos_cnt => skip_pos_cnt); + + --rx_data <= tx_data after 40 ns; + rx_data <= transport tx_data after 40 ns; + + ----------------------------------------------------------------------------- + -- UUT configuration and control + ----------------------------------------------------------------------------- + + clk_clk <= clk; + reset_reset_n <= reset_n; + + avs_s.mm_readdata <= avs_readdata_sl0 when sel_slave_0 = '1' else + avs_readdata_sl1 when sel_slave_1 = '1' else (others => '0'); + + avs_readdata_sl1 <= (others => '0'); + + avs_s.mm_readdatavalid <= avs_readdatavalid_sl0 when sel_slave_0 = '1' else + avs_readdatavalid_sl1 when sel_slave_1 = '1' else '0'; + + avs_readdatavalid_sl1 <= '0'; + + avs_s.mm_waitrequest <= '0'; + avs_s.use_readvalid <= true; + + avs_address <= avs_m.mm_address(avs_address'range); + avs_write <= avs_m.mm_write; + avs_writedata <= avs_m.mm_writedata; + avs_read <= avs_m.mm_read; + -- + avs_write_sl0 <= avs_write and sel_slave_0; + --avs_write_sl1 <= avs_write and sel_slave_1; + avs_write_sl1 <= '0'; + -- + avs_read_sl0 <= avs_read and sel_slave_0; + --avs_read_sl1 <= avs_read and sel_slave_1; + avs_read_sl1 <= '0'; + + -- 1-PPS generation: make it faster than 1-PPS for simulation reasons + pEMULATE_1PPS : process + begin + one_pps <= '0'; + for n in 1 to 99999 loop + wait until clk = '1' and clk'event; + end loop; -- 1 to 9999 + one_pps <= '1'; + wait until clk = '1' and clk'event; + end process pEMULATE_1PPS; + + pUUT_CTRL : process + variable addr : std_logic_vector(31 downto 0) := (others => '0'); + variable data : std_logic_vector(31 downto 0) := (others => '0'); + variable init_done : boolean := false; + variable fifo_level : integer; + begin + + enable_rx <= '0'; + -- + rx_watchdog_en <= '0'; + rx_watchdog_clr <= '0'; + error_rate_thres <= X"0A"; + + sel_slave_0 <= '0'; + sel_slave_1 <= '0'; + + configuring <= true; + + -- initilialize the Avalon master-bus + mm_m_init(avs_m); + + if (reset_n = '0') then + wait until reset_n = '1'; + wait for 100 ns; + wait until clk = '1' and clk'event; + end if; + + log("Configuring EMB2POFTX ... ", VLOW, true); + sel_slave_0 <= '1'; + -- Config netfork_rx control registers: + -- disable the block + addr := std_logic_vector(to_unsigned(0, 32)); + data := X"0000_0021"; + mm_32b_write(addr, data, avs_s, avs_m); + + sel_slave_0 <= '0'; + sel_slave_1 <= '1'; + wait until clk = '1' and clk'event; + + log("Configuring POFRX2HMB ... ", VLOW, true); + -- Config netfork_rx control registers: + -- disable the block + addr := std_logic_vector(to_unsigned(0, 32)); + data := X"0000_0001"; + --mm_32b_write(addr, data, avs_s, avs_m); + enable_rx <= '1'; + rx_watchdog_en <= '1'; + + log("Configuration completed.", VLOW, true); + configuring <= false; + + wait; + + end process pUUT_CTRL; + + ----------------------------------------------------------------------------- + -- Stimuli Generation + ----------------------------------------------------------------------------- + + pSTIMULI_REGs : process(clk) + begin + if (clk = '1' and clk'event) then + abs_position_d <= abs_position; + end if; + end process pSTIMULI_REGs; + + inc_pos <= '1' when signed(abs_position) = signed(abs_position_d) + 1 else '0'; + dec_pos <= '1' when signed(abs_position) = signed(abs_position_d) - 1 else '0'; + + pSTIMULI : process + variable rv : RandomPType; + variable tmp_int : integer; + variable rand_time : time; + variable end_of_stimuli : boolean; + variable pd_dist : integer; + begin + + -- initialization + init_rx <= '0'; + -- + init_tx <= '0'; + dir_in <= START_DIR; + pd_in <= '0'; + abs_position <= (others => '0'); + swathe_pos <= 0; + pd_dist := 0; + -- + swathe_cnt <= 0; + stimuli_completed <= false; + end_of_swathe <= '0'; + + -- generating the stimulus + wait until running = true; + wait for 200 ns; + -- Send a Init/Sync pulse + wait until clk = '1' and clk'event; + init_tx <= '1'; + wait until clk = '1' and clk'event; + init_tx <= '0'; + wait for 500 ns; + -- Send a second init pulse and verify that it is ignored (because too + -- close to the previous) + wait until clk = '1' and clk'event; + init_tx <= '1'; + wait until clk = '1' and clk'event; + init_tx <= '0'; + wait for 2500 ns; + -- Send a third pulse (after a bigger interval from the previous). + -- Verify that this time the pulse is accepted + wait until clk = '1' and clk'event; + init_tx <= '1'; + wait until clk = '1' and clk'event; + init_tx <= '0'; + wait for 500 ns; + wait until clk = '1' and clk'event; + -- + -- generate the forward swathe + end_of_stimuli := false; + while end_of_stimuli = false loop + swathe_pos <= 0; + wait until clk = '1' and clk'event; + while swathe_pos /= SWATHE_LEN loop + -- generate a position increment + tmp_int := rv.RandInt(1, 100); + --tmp_int := 100; + if (tmp_int < 20) then + -- generate a position increment opposite to the swathe direction + swathe_pos <= swathe_pos - 1; + if (dir_in = '0') then + abs_position <= std_logic_vector(signed(abs_position) - 1); + else + abs_position <= std_logic_vector(signed(abs_position) + 1); + end if; + else + swathe_pos <= swathe_pos + 1; + if (dir_in = '0') then + abs_position <= std_logic_vector(signed(abs_position) + 1); + else + abs_position <= std_logic_vector(signed(abs_position) - 1); + end if; + end if; + -- + tmp_int := rv.RandInt(1, 100); + if (tmp_int <= 5 and pd_dist >= 10) then + pd_dist := 0; + -- generate a PD increment: the PD might be either concurren or not + -- to the position increment + tmp_int := rv.RandInt(1, 3); + case tmp_int is + when 2 => + -- wait less than the transmission time + wait for 90 ns; + wait until clk = '1' and clk'event; + when 3 => + -- wait more than the transmission time + wait for 290 ns; + wait until clk = '1' and clk'event; + when others => null; + end case; + pd_in <= '1'; + wait until clk = '1' and clk'event; + pd_in <= '0'; + end if; + pd_dist := pd_dist + 1; + rand_time := rv.RandInt(-25, 25) * (10 ns); + wait for TIME_INT + rand_time; + end loop; -- swathe_pos /= SWATHE_LEN + + wait for 25 us; + end_of_swathe <= '1'; + wait until clk = '1' and clk'event; + end_of_swathe <= '0'; + -- reverse direction + if (dir_in /= START_DIR) then + if (swathe_cnt = NUM_ITERATIONS) then + end_of_stimuli := true; + else + swathe_cnt <= swathe_cnt + 1; + end if; + end if; + if (end_of_stimuli = false) then + wait until clk = '1' and clk'event; + dir_in <= not dir_in; + -- Wait some time to make sure the change of direction is transmitted. + -- Note: if the position starts changing before the receiver was able to + -- confirm the change of direction, then some encoder pulses may not be + -- generated + wait for 1 us; + wait until clk = '1' and clk'event; + end if; + end loop; -- end_of_stimuli = false + + stimuli_completed <= true; + wait; + + end process pSTIMULI; + + ----------------------------------------------------------------------------- + -- Error injection + ----------------------------------------------------------------------------- + + -- Randomly change the payload of the data transmitted over the UART. + -- Insert 1, 2 or 3 errors per data word + -- Note: an error on the start bit of the UART will can cause more than 3 + -- errors per data word, therefore this error injection method does not cover + -- all the possible cases + + pERROR_INJECTION : process + -- + alias symbol_valid is <>; + alias symbol is <>; + -- + variable rv : RandomPType; + variable flip_vect : std_logic_vector(7 downto 0); + variable last_flip : std_logic_vector(7 downto 0); + variable bit_flips : integer range 0 to 3; + variable b0, b1, b2 : integer range 0 to 9; + variable exclude_1 : integer_vector(0 downto 0); + variable exclude_2 : integer_vector(1 downto 0); + variable test : std_logic_vector(5 downto 0); + begin + + injected_errors <= 0; + if (running /= true) then + wait until running = true; + end if; + + while running loop + wait until symbol_valid = '1' and symbol_valid'event; + if (rv.RandInt(1, 100) < INJECT_ERROR_PERC) then + -- Inject an error: + -- Number of bits to flip in the tx word + bit_flips := rv.RandInt(1, 3); + --bit_flips := 2; + b0 := rv.RandInt(0, 7); + exclude_1(0) := b0; + b1 := rv.RandInt(min => 0, max => 7, exclude => exclude_1); + exclude_2 := (0 => b0, 1 => b1); + b2 := rv.RandInt(min => 0, max => 7, exclude => exclude_2); + flip_vect := (others => '0'); + flip_vect(b0) := '1'; + if (bit_flips >= 2) then + flip_vect(b1) := '1'; + end if; + if (bit_flips = 3) then + flip_vect(b2) := '1'; + end if; + -- Prevent situations with two consecutive bit flips on bit 0,1 and 2 + if ((flip_vect(0) = '1' and last_flip(0) = '1') or (flip_vect(1) = '1' and last_flip(1) = '1') or (flip_vect(2) = '1' and last_flip(2) = '1')) then + flip_vect := (others => '0'); + end if; + log("bit-flip = " & to_string(bit_flips) & ", flip_vect = " & to_string(flip_vect) & ".", VLOW); + symbol <= force symbol xor flip_vect; + injected_errors <= injected_errors + 1; + wait until clk = '1' and clk'event; + wait until clk = '1' and clk'event; + symbol <= release; + last_flip := flip_vect; + else + last_flip := (others => '0'); + end if; + end loop; + + end process pERROR_INJECTION; + + ----------------------------------------------------------------------------- + -- Output Checking + ----------------------------------------------------------------------------- + + -- No more check on dir_out!!! + dir_out <= dir_in; + + pEVENT_MONITOR : process(clk) + begin + if (clk = '1' and clk'event) then + if (reset_n = '0' or init_tx = '1' or running = false or dir_in = dir_out) then + dir_discr_cnt <= 0; + elsif (dir_in /= dir_out) then + dir_discr_cnt <= dir_discr_cnt + 1; + end if; + if (reset_n = '0' or init_tx = '1' or running = false) then + dir_err <= '0'; + elsif (dir_discr_cnt > DISCR_THRES) then + dir_err <= '1'; + end if; + if (reset_n = '0' or init_tx = '1' or running = false) then + pd_in_cnt <= 0; + elsif (pd_in = '1') then + pd_in_cnt <= pd_in_cnt + 1; + end if; + if (reset_n = '0' or init_tx = '1' or running = false) then + pd_out_cnt <= 0; + elsif (pd_out = '1') then + pd_out_cnt <= pd_out_cnt + 1; + end if; + if (reset_n = '0' or init_tx = '1' or running = false or pd_in_cnt = pd_out_cnt) then + pd_discr_cnt <= 0; + elsif (pd_in_cnt /= pd_out_cnt) then + pd_discr_cnt <= pd_discr_cnt + 1; + end if; + if (reset_n = '0' or init_tx = '1' or running = false) then + pd_err <= '0'; + elsif (pd_discr_cnt > DISCR_THRES) then + pd_err <= '1'; + end if; + if (reset_n = '0' or init_tx = '1' or running = false or signed(abs_position) = signed(abs_pos_out)) then + pos_discr_cnt <= 0; + elsif (signed(abs_position) /= signed(abs_pos_out)) then + pos_discr_cnt <= pos_discr_cnt + 1; + end if; + if (reset_n = '0' or init_tx = '1' or running = false) then + pos_err <= '0'; + elsif (pos_discr_cnt > DISCR_THRES) then + pos_err <= '1'; + end if; + dir_in_d <= dir_in; + if (reset_n = '0' or init_tx = '1' or running = false or dir_in /= dir_in_d) then + enc_pulse_cnt <= 0; + elsif (enc_out = '1') then + enc_pulse_cnt <= enc_pulse_cnt + 1; + end if; + if (reset_n = '0' or init_tx = '1' or running = false) then + enc_err <= '0'; + elsif (end_of_swathe = '1' and enc_pulse_cnt /= SWATHE_LEN) then + enc_err <= '1'; + end if; + max_pos_d <= max_pos; + min_pos_d <= min_pos; + if ((dir_in = '0' and max_pos /= max_pos_d) or (dir_in = '1' and min_pos /= min_pos_d)) then + exp_enc_pulse <= '1'; + else + exp_enc_pulse <= '0'; + end if; + enc_out_d <= enc_out; + end if; + end process pEVENT_MONITOR; + + enc_discr <= enc_out_d xor exp_enc_pulse; + + pMIN_MAX_POS : process(reset_n, end_of_swathe, abs_pos_out) + begin + if (reset_n = '0' or end_of_swathe = '1') then + max_pos <= -SWATHE_LEN; + elsif (signed(abs_pos_out) > max_pos) then + max_pos <= to_integer(signed(abs_pos_out)); + end if; + if (reset_n = '0' or end_of_swathe = '1') then + min_pos <= SWATHE_LEN; + elsif (signed(abs_pos_out) < min_pos) then + min_pos <= to_integer(signed(abs_pos_out)); + end if; + end process pMIN_MAX_POS; + + exp_enc_cnt <= max_pos - min_pos; + + ovfl_err <= <>; + + pERR_DETECT : process(reset_n, clk) + begin + if (reset_n = '0') then + detected_error <= false; + elsif (clk = '1' and clk'event) then + --if(ovfl_err = '1' or dir_err = '1' or pd_err = '1' or pos_err = '1' or enc_err = '1') then + if (ovfl_err = '1' or dir_err = '1' or pd_err = '1' or pos_err = '1') then + detected_error <= true; + end if; + end if; + end process pERR_DETECT; + + + ----------------------------------------------------------------------------- + -- Testbench Control + ----------------------------------------------------------------------------- + + pTB_CTRL : process + begin + + -- Set the verbosity level for logging + set_log_verbosity(VERBOSITY_LEVEL); + set_log_verbosity(VHIGH); + + log_header("POF Transfer Tx/Rx verification:", VLOW); + + test_completed <= false; + running <= false; + passed <= false; + failed <= false; + + -- Reset + reset_n <= '0'; + wait for 100 ns; + wait until clk = '1' and clk'event; + reset_n <= '1'; + + if (configuring /= true) then + wait until configuring = true; + end if; + wait until configuring = false; + running <= true; + + wait until stimuli_completed = true or detected_error = true; + + if (stimuli_completed = true) then + -- wait enough time to make sure that a max length package can be propagated + wait for 20 us; + end if; + + if (detected_error = true) 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; diff --git a/generic_ip/fire_pulse_manager/3/src/test/uart_tx_3.vhd b/generic_ip/fire_pulse_manager/3/src/test/uart_tx_3.vhd new file mode 100644 index 0000000..8c84e96 --- /dev/null +++ b/generic_ip/fire_pulse_manager/3/src/test/uart_tx_3.vhd @@ -0,0 +1,163 @@ +------------------------------------------------------------------------------- +-- Title : uart_tx +-- Project : EMB-1 +------------------------------------------------------------------------------- +-- File : uart_tx.vhd +-- Author : Gianmarco Girau +-- Company : Global Inkjet Systems +-- Created : 2016-10-24 +-- Last update: 2019-07-15 +-- SVN ID : Git +-- Standard : VHDL'08 +------------------------------------------------------------------------------- +-- Description: +-- Simple UART trasmitter, used to trasmit data over the POF, 1 start, 1 stop +-- bit, no parity +------------------------------------------------------------------------------- + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity uart_tx_3 is + generic( + data_width : natural range 1 to 31); + port( + reset_n : in std_logic; + clk : in std_logic; + bit_div : in std_logic_vector(3 downto 0); -- number of clock cycles per tx bit + init : in std_logic; + ready : out std_logic; + data_in : in std_logic_vector(data_width-1 downto 0); + data_valid : in std_logic; + tx_data : out std_logic); +end entity uart_tx_3; + +architecture rtl of uart_tx_3 is + + type fsm_state_t is (idle, send_start_bit, send_data, send_stop_bit); + + signal fsm_state_curr, fsm_state_next : fsm_state_t; + -- + signal ld_data, shf_data, rst_bit_cnt, inc_bit_cnt : std_logic; + signal rst_clk_cnt, end_of_bit, end_of_tx : std_logic; + signal rst_tx_data, set_tx_data, ld_tx_data : std_logic; + signal ready_i : std_logic; + -- + signal data : std_logic_vector(data_width-1 downto 0); + signal clk_cnt : std_logic_vector(3 downto 0); + signal bit_cnt : std_logic_vector(5 downto 0); + +begin + + ----------------------------------------------------------------------------- + -- UART registers and sequential logic + ----------------------------------------------------------------------------- + + pREGs : process(clk) + begin + if(clk ='1' and clk'event) then + if(ld_data = '1') then + data <= data_in; + elsif(shf_data = '1') then + data <= '0' & data(data'high downto 1); + end if; + if(rst_bit_cnt = '1') then + bit_cnt <= (others => '0'); + elsif(inc_bit_cnt = '1') then + bit_cnt <= std_logic_vector(unsigned(bit_cnt)+1); + end if; + if(rst_clk_cnt = '1' or end_of_bit = '1') then + clk_cnt <= (others => '0'); + else + clk_cnt <= std_logic_vector(unsigned(clk_cnt)+1); + end if; + if(rst_tx_data = '1') then + tx_data <= '0'; + elsif(set_tx_data = '1') then + tx_data <= '1'; + elsif(ld_tx_data = '1') then + tx_data <= data(0); + end if; + end if; + end process pREGs; + + end_of_bit <= '1' when unsigned(clk_cnt) = (unsigned(bit_div)-1) else '0'; + end_of_tx <= '1' when unsigned(bit_cnt) = data_width else '0'; + + --shf_data <= inc_bit_cnt; + shf_data <= ld_tx_data; + inc_bit_cnt <= ld_tx_data; + + ----------------------------------------------------------------------------- + -- FSM + ----------------------------------------------------------------------------- + + -- FSM state register + pFSM_SR : process(reset_n, clk) + begin + if(reset_n = '0') then + fsm_state_curr <= idle; + elsif(clk = '1' and clk'event) then + fsm_state_curr <= fsm_state_next; + end if; + end process pFSM_SR; + + -- FSM Combinational Logic + pFSM_CL : process(fsm_state_curr, init, data_valid, end_of_bit, end_of_tx) + begin + --default assignments + ready_i <= '0'; + rst_clk_cnt <= '0'; + rst_tx_data <= '0'; + set_tx_data <= '0'; + ld_tx_data <= '0'; + rst_bit_cnt <= '0'; + ld_data <= '0'; + -- + fsm_state_next <= fsm_state_curr; + + if(init = '1') then + set_tx_data <= '1'; + fsm_state_next <= idle; + else + case fsm_state_curr is + when idle => + ready_i <= '1'; + ld_data <= '1'; + rst_clk_cnt <= '1'; + rst_bit_cnt <= '1'; + set_tx_data <= '1'; + if(data_valid = '1') then + rst_tx_data <= '1'; + fsm_state_next <= send_start_bit; + end if; + + when send_start_bit => + if(end_of_bit = '1') then + ld_tx_data <= '1'; + fsm_state_next <= send_data; + end if; + + when send_data => + if(end_of_bit = '1') then + ld_tx_data <= '1'; + if(end_of_tx = '1') then + set_tx_data <= '1'; + fsm_state_next <= send_stop_bit; + end if; + end if; + + when send_stop_bit => + if(end_of_bit = '1') then + fsm_state_next <= idle; + end if; + + when others => null; + end case; + end if; + end process pFSM_CL; + + ready <= ready_i; + +end architecture rtl; diff --git a/generic_ip/fire_pulse_manager/3/src/uart_regen_3.vhd b/generic_ip/fire_pulse_manager/3/src/uart_regen_3.vhd new file mode 100644 index 0000000..3beb82e --- /dev/null +++ b/generic_ip/fire_pulse_manager/3/src/uart_regen_3.vhd @@ -0,0 +1,160 @@ +------------------------------------------------------------------------------- +-- Title : uart_regen +-- Project : EMB-1 +------------------------------------------------------------------------------- +-- File : uart_regen.vhd +-- Author : Gianmarco Girau +-- Company : Global Inkjet Systems +-- Created : 2017-10-31 +-- Last update: 2019-07-15 +-- SVN ID : Git +-- Standard : VHDL'08 +------------------------------------------------------------------------------- +-- Description: +-- Regenerate the UART signal +------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity uart_regen_3 is + generic( + data_width : natural range 1 to 31); + port( + reset_n : in std_logic; + clk : in std_logic; + bit_div : in std_logic_vector(3 downto 0); -- number of clock cycles per tx bit + enable : in std_logic; + bypass_en : in std_logic; + uart_rx : in std_logic; + uart_tx : out std_logic); +end entity uart_regen_3; + +architecture rtl of uart_regen_3 is + + type fsm_state_t is (s_init, s_idle, s_regen); + + signal fsm_state_curr, fsm_state_next : fsm_state_t; + -- + signal uart_rx_i, ld_data, rst_bit_cnt, inc_bit_cnt : std_logic; + signal rst_clk_cnt, end_of_bit, end_of_rx : std_logic; + signal uart_regen, uart_regen_i : std_logic; + -- + signal clk_cnt : std_logic_vector(3 downto 0); + signal bit_cnt : std_logic_vector(5 downto 0); + +begin + + ----------------------------------------------------------------------------- + -- Input Synchronization + ----------------------------------------------------------------------------- + + iSYNC_IN : entity work.sync_wire + generic map( + rst_val => '1', + sync_stages => 3) + port map( + rstN => reset_n, + clk => clk, + async_in => uart_rx, + sync_out => uart_rx_i); + + -- NOTE : No NEED TO SYNCHRONIZE TO THE LOCAL CLOCK inputs enable, bypass_en + -- and bit_biv BECAUSE THOSE SIGNALS ARE PREDOMINANTLY STATIC + + ----------------------------------------------------------------------------- + -- UART registers and sequential logic + ----------------------------------------------------------------------------- + + pREGs : process(clk) + begin + if (clk = '1' and clk'event) then + if (rst_bit_cnt = '1') then + bit_cnt <= (others => '0'); + elsif (inc_bit_cnt = '1') then + bit_cnt <= std_logic_vector(unsigned(bit_cnt) + 1); + end if; + ld_data <= '0'; + if clk_cnt = ('0' & std_logic_vector(unsigned(bit_div(bit_div'high downto 1)) + 1)) then + ld_data <= '1'; + end if; + + if (rst_clk_cnt = '1' or end_of_bit = '1') then + clk_cnt <= std_logic_vector(unsigned(bit_div) - 1); + else + clk_cnt <= std_logic_vector(unsigned(clk_cnt) - 1); + end if; + if (enable = '0') then + uart_regen_i <= '1'; + elsif (ld_data = '1') then + uart_regen_i <= uart_rx_i; + end if; + uart_regen <= uart_regen_i; + end if; + end process pREGs; + + end_of_bit <= '1' when unsigned(clk_cnt) = 0 else '0'; + end_of_rx <= '1' when unsigned(bit_cnt) = data_width + 1 else '0'; + + -- output mux + uart_tx <= uart_rx when bypass_en = '1' else uart_regen; + + ----------------------------------------------------------------------------- + -- FSM + ----------------------------------------------------------------------------- + + -- FSM state register + pFSM_SR : process(clk) + begin + if (clk = '1' and clk'event) then + if (enable = '0' or bypass_en = '1') then + fsm_state_curr <= s_init; + else + fsm_state_curr <= fsm_state_next; + end if; + end if; + end process pFSM_SR; + + -- FSM Combinational Logic + pFSM_CL : process(fsm_state_curr, uart_rx_i, end_of_bit, end_of_rx, clk_cnt, bit_div) + begin + --default assignments + rst_clk_cnt <= '0'; + rst_bit_cnt <= '0'; + inc_bit_cnt <= '0'; + -- + fsm_state_next <= fsm_state_curr; + + case fsm_state_curr is + when s_init => + if (uart_rx_i = '1') then + fsm_state_next <= s_idle; + end if; + + when s_idle => + if (uart_rx_i = '0') then + rst_clk_cnt <= '1'; + rst_bit_cnt <= '1'; + fsm_state_next <= s_regen; + end if; + + when s_regen => + + if (end_of_bit = '1') then + inc_bit_cnt <= '1'; + if (end_of_rx = '1') then + if (uart_rx_i = '1') then + fsm_state_next <= s_idle; + else + fsm_state_next <= s_init; + end if; + end if; + end if; + + end case; + end process pFSM_CL; + + +end architecture rtl; diff --git a/generic_ip/fire_pulse_manager/3/src/uart_rx_3.vhd b/generic_ip/fire_pulse_manager/3/src/uart_rx_3.vhd new file mode 100644 index 0000000..ed26131 --- /dev/null +++ b/generic_ip/fire_pulse_manager/3/src/uart_rx_3.vhd @@ -0,0 +1,186 @@ +------------------------------------------------------------------------------- +-- Title : uart_rx +-- Project : EMB-1 +------------------------------------------------------------------------------- +-- File : uart_rx.vhd +-- Author : Gianmarco Girau +-- Company : Global Inkjet Systems +-- Created : 2016-10-24 +-- Last update: 2019-07-15 +-- SVN ID : Git +-- Standard : VHDL'08 +------------------------------------------------------------------------------- +-- Description: +-- Simple UART receiver, used to receive data over the POF, 1 start, 1 stop +-- bit, no parity +------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity uart_rx_3 is + generic( + data_width : natural range 1 to 31); + port( + reset_n : in std_logic; + clk : in std_logic; + bit_div : in std_logic_vector(3 downto 0); -- number of clock cycles per tx bit + init : in std_logic; + data_out : out std_logic_vector(data_width - 1 downto 0); + data_out_valid : out std_logic; + rx_error : out std_logic; + rx_data : in std_logic); +end entity uart_rx_3; + +architecture rtl of uart_rx_3 is + + type fsm_state_t is (s_init, s_idle, s_get_start_bit, s_get_data, s_get_stop_bit); + + signal fsm_state_curr, fsm_state_next : fsm_state_t; + -- + signal rx_data_i, rst_bit_cnt, inc_bit_cnt : std_logic; + signal rst_clk_cnt, end_of_rx, data_valid : std_logic; + signal stop_bit, rx_error_i : std_logic; + -- + signal data : std_logic_vector(data_width - 1 downto 0); + signal bit_cnt : std_logic_vector(5 downto 0); + + -- avoid maths with loadable shift registers + -- bit_div will be used to set an indexed bit of the timer shift register + -- the timers will shift down towards zeroth bit which will indicate timer has completed. + -- this should be faster than using a decrementer and comparators + signal uart_bit_timer, uart_bit_sample_timer : std_logic_vector(2**bit_div'length - 1 downto 0); + signal uart_bit_timer_load_value, uart_bit_sample_timer_load_value : std_logic_vector(2**bit_div'length - 1 downto 0); + + signal end_of_bit : std_logic; + signal shf_data : std_logic; + +begin + + ----------------------------------------------------------------------------- + -- Input Synchronization + ----------------------------------------------------------------------------- + + iSYNC_IN : entity work.sync_wire + generic map( + rst_val => '1', + sync_stages => 3) + port map( + rstN => reset_n, + clk => clk, + async_in => rx_data, + sync_out => rx_data_i); + + ----------------------------------------------------------------------------- + -- UART registers and sequential logic + ----------------------------------------------------------------------------- + + pREGs : process(clk) + begin + if (clk = '1' and clk'event) then + if (rst_bit_cnt = '1') then + bit_cnt <= (others => '0'); + elsif (inc_bit_cnt = '1') then + bit_cnt <= std_logic_vector(unsigned(bit_cnt) + 1); + end if; + if (rst_clk_cnt = '1' or end_of_bit = '1') then + uart_bit_timer <= uart_bit_timer_load_value; + uart_bit_sample_timer <= uart_bit_sample_timer_load_value; + else + uart_bit_timer <= '0' & uart_bit_timer(uart_bit_timer'high downto 1); + uart_bit_sample_timer <= '0' & uart_bit_sample_timer(uart_bit_sample_timer'high downto 1); + end if; + if (shf_data = '1') then + data <= rx_data_i & data(data'high downto 1); + end if; + data_out_valid <= data_valid; + if (data_valid = '1') then + data_out <= data; + end if; + rx_error <= rx_error_i; + uart_bit_timer_load_value <= (others => '0'); + uart_bit_timer_load_value(to_integer(unsigned(bit_div) -1 )) <= '1'; + uart_bit_sample_timer_load_value <= (others => '0'); + uart_bit_sample_timer_load_value(to_integer( unsigned(bit_div(bit_div'high downto 1)) -1)) <= '1'; + end if; + end process pREGs; + + shf_data <= uart_bit_sample_timer(0) and not stop_bit; + end_of_bit <= uart_bit_timer(0); + end_of_rx <= '1' when unsigned(bit_cnt) = data_width else '0'; + + ----------------------------------------------------------------------------- + -- FSM + ----------------------------------------------------------------------------- + + -- FSM state register + pFSM_SR : process(clk) + begin + if (clk = '1' and clk'event) then + if (init = '1') then + fsm_state_curr <= s_init; + else + fsm_state_curr <= fsm_state_next; + end if; + end if; + end process pFSM_SR; + + -- FSM Combinational Logic + pFSM_CL : process(all) + begin + --default assignments + rst_clk_cnt <= '0'; + rst_bit_cnt <= '0'; + inc_bit_cnt <= '0'; + data_valid <= '0'; + stop_bit <= '0'; + rx_error_i <= '0'; + -- + fsm_state_next <= fsm_state_curr; + + case fsm_state_curr is + when s_init => + if (rx_data_i = '1') then + fsm_state_next <= s_idle; + end if; + + when s_idle => + if (rx_data_i = '0') then + rst_clk_cnt <= '1'; + rst_bit_cnt <= '1'; + fsm_state_next <= s_get_start_bit; + end if; + + when s_get_start_bit => + if (end_of_bit = '1') then + inc_bit_cnt <= '1'; + fsm_state_next <= s_get_data; + end if; + + when s_get_data => + if (end_of_bit = '1') then + inc_bit_cnt <= '1'; + if (end_of_rx = '1') then + fsm_state_next <= s_get_stop_bit; + end if; + end if; + + when s_get_stop_bit => + stop_bit <= '1'; + if (end_of_bit = '1') then + if (rx_data_i = '1') then + data_valid <= '1'; + fsm_state_next <= s_idle; + else + rx_error_i <= '1'; + fsm_state_next <= s_init; + end if; + end if; + + end case; + end process pFSM_CL; + + +end architecture rtl; From 79ecc46cd8bae189e4616b1c34f3c0e11ebe8ffe Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Fri, 19 Jul 2019 16:02:43 +0100 Subject: [PATCH 29/29] ELGIP-73 - Moved queue_and_delay testbench from SMB repository. Improved cs_bus_itf testbench --- generic_ip/common/0/sim/sim_queue_delay.do | 39 ++ generic_ip/common/0/sim/wave_queue_delay.do | 64 ++ .../common/0/src/test/cs_bus_itf_tb.vhd | 126 +++- .../common/0/src/test/queue_and_delay_tb.vhd | 620 ++++++++++++++++++ 4 files changed, 832 insertions(+), 17 deletions(-) create mode 100644 generic_ip/common/0/sim/sim_queue_delay.do create mode 100644 generic_ip/common/0/sim/wave_queue_delay.do create mode 100644 generic_ip/common/0/src/test/queue_and_delay_tb.vhd diff --git a/generic_ip/common/0/sim/sim_queue_delay.do b/generic_ip/common/0/sim/sim_queue_delay.do new file mode 100644 index 0000000..c46d05b --- /dev/null +++ b/generic_ip/common/0/sim/sim_queue_delay.do @@ -0,0 +1,39 @@ +# Simulation macro + +.main clear + +set SRC_PATH ./../src + +vlib ./work +vmap work ./work + + + +# Compile the UUT +vcom -work work $SRC_PATH/common_pkg.vhd +vcom -work work $SRC_PATH/altera/sync_fifo.vhd +vcom -2008 -work work $SRC_PATH/queue_and_delay.vhd + +# Compile the Testbench +vcom -2008 -work work $SRC_PATH/test/queue_and_delay_tb.vhd + +# Simulate +vsim -t ps work.queue_and_delay_tb + +#add wave /queue_and_delay_tb/* +#add wave /queue_and_delay_tb/iUUT/* + +# remove warnings from standard numeric/arithmetic packages (speed-up simulation) +set StdArithNoWarnings 1 +set NumericStdNoWarnings 1 + +do wave_queue_delay.do + +when -label end_of_simulation {completed == true} {echo "Simulation Completed"; stop ;} +run -all + +#run 100 us; + + + + diff --git a/generic_ip/common/0/sim/wave_queue_delay.do b/generic_ip/common/0/sim/wave_queue_delay.do new file mode 100644 index 0000000..63a6e9a --- /dev/null +++ b/generic_ip/common/0/sim/wave_queue_delay.do @@ -0,0 +1,64 @@ +onerror {resume} +quietly WaveActivateNextPane {} 0 +add wave -noupdate /queue_and_delay_tb/rstN +add wave -noupdate /queue_and_delay_tb/clk +add wave -noupdate /queue_and_delay_tb/init +add wave -noupdate /queue_and_delay_tb/cnt_dir +add wave -noupdate /queue_and_delay_tb/pIO_MNG/loc_cnt +add wave -noupdate -radix unsigned /queue_and_delay_tb/delay +add wave -noupdate -radix decimal /queue_and_delay_tb/ext_time +add wave -noupdate /queue_and_delay_tb/kickstart +add wave -noupdate /queue_and_delay_tb/kickstart_ref +add wave -noupdate /queue_and_delay_tb/wave_in +add wave -noupdate /queue_and_delay_tb/wave_delayed +add wave -noupdate /queue_and_delay_tb/wave_out +add wave -noupdate /queue_and_delay_tb/wave_ref +add wave -noupdate /queue_and_delay_tb/wave_error +add wave -noupdate /queue_and_delay_tb/error_detected +add wave -noupdate -radix decimal /queue_and_delay_tb/init_time +add wave -noupdate /queue_and_delay_tb/offset +add wave -noupdate /queue_and_delay_tb/pulse_width +add wave -noupdate /queue_and_delay_tb/passed +add wave -noupdate /queue_and_delay_tb/failed +add wave -noupdate /queue_and_delay_tb/completed +add wave -noupdate /queue_and_delay_tb/ovf_error +add wave -noupdate /queue_and_delay_tb/iUUT/rstN +add wave -noupdate /queue_and_delay_tb/iUUT/clk +add wave -noupdate /queue_and_delay_tb/iUUT/init +add wave -noupdate /queue_and_delay_tb/iUUT/cnt_dir +add wave -noupdate -radix unsigned /queue_and_delay_tb/iUUT/delay +add wave -noupdate -radix decimal /queue_and_delay_tb/iUUT/ext_time +add wave -noupdate /queue_and_delay_tb/iUUT/wave_in +add wave -noupdate /queue_and_delay_tb/iUUT/wave_out +add wave -noupdate /queue_and_delay_tb/iUUT/ovf_error +add wave -noupdate /queue_and_delay_tb/iUUT/toggle_in +add wave -noupdate /queue_and_delay_tb/iUUT/toggle_out +add wave -noupdate /queue_and_delay_tb/iUUT/time_elapsed +add wave -noupdate /queue_and_delay_tb/iUUT/wave_in_d +add wave -noupdate /queue_and_delay_tb/iUUT/wave_out_i +add wave -noupdate /queue_and_delay_tb/iUUT/wave_out_i_d +add wave -noupdate /queue_and_delay_tb/iUUT/new_event +add wave -noupdate /queue_and_delay_tb/iUUT/pending_trans +add wave -noupdate /queue_and_delay_tb/iUUT/fifo_rd_en +add wave -noupdate /queue_and_delay_tb/iUUT/fifo_empty +add wave -noupdate /queue_and_delay_tb/iUUT/fifo_full +add wave -noupdate -radix unsigned /queue_and_delay_tb/iUUT/int_time +add wave -noupdate -radix decimal /queue_and_delay_tb/iUUT/event_time +TreeUpdate [SetDefaultTree] +WaveRestoreCursors {{Cursor 1} {5695000 ps} 0} +quietly wave cursor active 1 +configure wave -namecolwidth 343 +configure wave -valuecolwidth 100 +configure wave -justifyvalue left +configure wave -signalnamewidth 0 +configure wave -snapdistance 10 +configure wave -datasetprefix 0 +configure wave -rowmargin 4 +configure wave -childrowmargin 2 +configure wave -gridoffset 0 +configure wave -gridperiod 1 +configure wave -griddelta 40 +configure wave -timeline 0 +configure wave -timelineunits ps +update +WaveRestoreZoom {814844 ps} {2822428 ps} diff --git a/generic_ip/common/0/src/test/cs_bus_itf_tb.vhd b/generic_ip/common/0/src/test/cs_bus_itf_tb.vhd index 8b121c5..6945793 100644 --- a/generic_ip/common/0/src/test/cs_bus_itf_tb.vhd +++ b/generic_ip/common/0/src/test/cs_bus_itf_tb.vhd @@ -6,7 +6,7 @@ -- Author : GMG -- Company : Global Inkjet Systems -- Created : 2019-07-10 --- Last update: 2019-07-12 +-- Last update: 2019-07-17 -- SVN ID : Git -- Standard : VHDL'2008 ------------------------------------------------------------------------------- @@ -372,30 +372,122 @@ begin -- architecture behav log_header("Repeating the test without pauses between accesses:", VLOW); wait_latency(clk, 20); - + + /* wr_data(0, 4, X"A2A2B1B1", avs_s, avs_m, true); - /* - if(blk_0_wr_data /= X"A2A2B1B1") then - log("ERROR : Expecting written data A2A2B1B1 on block 0", VLOW); - error_flag := true; - end if; - */ - wr_data(1, 8, X"C2C2D1D1", avs_s, avs_m, true); - /* - if(blk_1_wr_data /= X"C2C2D1D1") then - log("ERROR : Expecting written data C2C2D1D1 on block 1", VLOW); - error_flag := true; - end if; - */ wr_data(2, 0, X"EE00FF11", avs_s, avs_m, true); wr_data(7, 0, X"EE00FF11", avs_s, avs_m, true); - for blk_num in 0 to 7 loop rd_data(blk_num, 16, data, avs_s, avs_m, true); log("Read Data 0x" & to_hstring(data) & " from block " & to_string(blk_num), VLOW); - end loop; -- blk_num + end loop; -- blk_num + */ + + -- manually drive the master signals + wait until clk = '1' and clk'event; + avs_m.mm_address <= 17x"0" & std_logic_vector(to_unsigned(0,4)) & std_logic_vector(to_unsigned(4,11)); + avs_m.mm_writedata <= X"A2A2B1B1"; + avs_m.mm_write <= '1'; + wait until clk = '0' and clk'event; + while avs_s.mm_waitrequest = '1' loop + wait until clk = '0' and clk'event; + end loop; + wait until clk = '1' and clk'event; + -- transfer is concluded, but don't de-assert the write enable, just move + -- to the next data + avs_m.mm_address <= 17x"0" & std_logic_vector(to_unsigned(1,4)) & std_logic_vector(to_unsigned(8,11)); + avs_m.mm_writedata <= X"C2C2D1D1"; + avs_m.mm_write <= '1'; + wait until clk = '0' and clk'event; + -- Check first the data written before: + if(blk_0_wr_data /= X"A2A2B1B1") then + log("ERROR : Expecting written data A2A2B1B1 on block 0", VLOW); + error_flag := true; + end if; + while avs_s.mm_waitrequest = '1' loop + wait until clk = '0' and clk'event; + end loop; + wait until clk = '1' and clk'event; + -- transfer is concluded, but don't de-assert the write enable, just move + -- to the next data + avs_m.mm_address <= 17x"0" & std_logic_vector(to_unsigned(2,4)) & std_logic_vector(to_unsigned(0,11)); + avs_m.mm_writedata <= X"EE00FF11"; + avs_m.mm_write <= '1'; + wait until clk = '0' and clk'event; + -- Check first the data written before: + if(blk_1_wr_data /= X"C2C2D1D1") then + log("ERROR : Expecting written data C2C2D1D1 on block 1", VLOW); + error_flag := true; + end if; + while avs_s.mm_waitrequest = '1' loop + wait until clk = '0' and clk'event; + end loop; + wait until clk = '1' and clk'event; + -- transfer is concluded, but don't de-assert the write enable, just move + -- to the next data + avs_m.mm_address <= 17x"0" & std_logic_vector(to_unsigned(7,4)) & std_logic_vector(to_unsigned(0,11)); + avs_m.mm_writedata <= X"FF11EE00"; + avs_m.mm_write <= '1'; + wait until clk = '0' and clk'event; + while avs_s.mm_waitrequest = '1' loop + wait until clk = '0' and clk'event; + end loop; + wait until clk = '1' and clk'event; + -- disable write and start immediately reading + avs_m.mm_write <= '0'; + for n in 0 to 7 loop + avs_m.mm_address <= 17x"0" & std_logic_vector(to_unsigned(n,4)) & std_logic_vector(to_unsigned(16,11)); + avs_m.mm_read <= '1'; + wait until clk = '0' and clk'event; + while avs_s.mm_waitrequest = '1' loop + wait until clk = '0' and clk'event; + end loop; + log("Read Data 0x" & to_hstring(avs_s.mm_readdata) & " from block " & to_string(n), VLOW); + wait until clk = '1' and clk'event; + end loop; -- n + avs_m.mm_read <= '0'; + + wait until clk = '1' and clk'event; + wait until clk = '1' and clk'event; + wait until clk = '1' and clk'event; + wait until clk = '1' and clk'event; + + -- now do a loop with read-write-read without interruption + for n in 0 to 7 loop + avs_m.mm_address <= 17x"0" & std_logic_vector(to_unsigned(n,4)) & std_logic_vector(to_unsigned(16,11)); + avs_m.mm_read <= '1'; + wait until clk = '0' and clk'event; + while avs_s.mm_waitrequest = '1' loop + wait until clk = '0' and clk'event; + end loop; + log("Read Data 0x" & to_hstring(avs_s.mm_readdata) & " from block " & to_string(n), VLOW); + wait until clk = '1' and clk'event; + avs_m.mm_read <= '0'; + avs_m.mm_address <= 17x"0" & std_logic_vector(to_unsigned(0,4)) & std_logic_vector(to_unsigned(4,11)); + avs_m.mm_writedata <= X"A2A2B1B1"; + avs_m.mm_write <= '1'; + wait until clk = '0' and clk'event; + while avs_s.mm_waitrequest = '1' loop + wait until clk = '0' and clk'event; + end loop; + wait until clk = '1' and clk'event; + avs_m.mm_write <= '0'; + avs_m.mm_address <= 17x"0" & std_logic_vector(to_unsigned(7,4)) & std_logic_vector(to_unsigned(8,11)); + avs_m.mm_read <= '1'; + wait until clk = '0' and clk'event; + while avs_s.mm_waitrequest = '1' loop + wait until clk = '0' and clk'event; + end loop; + log("Read Data 0x" & to_hstring(avs_s.mm_readdata) & " from block " & to_string(7), VLOW); + wait until clk = '1' and clk'event; + + + end loop; -- n + avs_m.mm_read <= '0'; + + wait_latency(clk, 50); running <= false; diff --git a/generic_ip/common/0/src/test/queue_and_delay_tb.vhd b/generic_ip/common/0/src/test/queue_and_delay_tb.vhd new file mode 100644 index 0000000..598bb7b --- /dev/null +++ b/generic_ip/common/0/src/test/queue_and_delay_tb.vhd @@ -0,0 +1,620 @@ +------------------------------------------------------------------------------- +-- Title : Testbench for queue_and_delay +-- Project : project independent +------------------------------------------------------------------------------- +-- File : .vhd +-- Author : Gianmarco Girau +-- Company : Global Inkjet Systems +-- Created : 2016-11-01 +-- Last update: 2017-11-06 +-- SVN ID : Git +-- Standard : VHDL'93 +------------------------------------------------------------------------------- +-- Description: +-- Simple Testbench for the queue and delay: Only corner cases of the delay +-- mechanism are checked: wrapping around of the counter, usage of the external +-- reference for the counter, up and down counting. +-- Check also latency issues when using the external counter: what happens if +-- the external counter is not updated every clock cycles. +------------------------------------------------------------------------------- + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity queue_and_delay_tb is + -- ... +end queue_and_delay_tb; + +architecture behav of queue_and_delay_tb is + + ----------------------------------------------------------------------------- + -- Component declarations + ----------------------------------------------------------------------------- + + component queue_and_delay + generic ( + use_ext_time : boolean; + queue_size : natural range 16 to 8192); + port ( + rstN : in std_logic; + clk : in std_logic; + init : in std_logic; + cnt_dir : in std_logic; + delay : in std_logic_vector(31 downto 0); + ext_time : in std_logic_vector(31 downto 0); + wave_in : in std_logic; + wave_out : out std_logic; + ovf_error : out std_logic); + end component; + + + ----------------------------------------------------------------------------- + -- Constant, types and signals + ----------------------------------------------------------------------------- + + constant clk_period : time := 10.0 ns; -- ems clock + + signal rstN : std_logic; + signal clk : std_logic := '0'; + signal init : std_logic; + signal cnt_dir : std_logic; + signal delay : std_logic_vector(31 downto 0); + signal ext_time : std_logic_vector(31 downto 0); + signal wave_in : std_logic; + signal wave_out : std_logic; + signal ovf_error : std_logic; + -- + signal wave_delayed : std_logic; + signal wave_delayed_d : std_logic; + signal wave_ref : std_logic; + signal wave_error : std_logic; + signal init_time : std_logic_vector(31 downto 0); + signal offset : integer; + signal pulse_width : integer; + signal passed : boolean; + signal failed : boolean; + signal completed : boolean; + signal kickstart : std_logic; + signal kickstart_ref : std_logic; + signal error_detected : std_logic; + +begin -- behav + + -- clock generation + clk <= not clk after 0.5*clk_period; + + ----------------------------------------------------------------------------- + -- UUT + ----------------------------------------------------------------------------- + + iUUT: queue_and_delay + generic map ( + use_ext_time => true, + queue_size => 128) + port map ( + rstN => rstN, + clk => clk, + init => init, + cnt_dir => cnt_dir, + delay => delay, + ext_time => ext_time, + wave_in => wave_in, + wave_out => wave_out, + ovf_error => ovf_error); + + ----------------------------------------------------------------------------- + -- Stimuli generator and output checker + ----------------------------------------------------------------------------- + + pIO_MNG: process(rstN, init, clk) + variable loc_cnt : integer; + begin + if(rstN = '0') then + loc_cnt := 0; + ext_time <= (others => '0'); + kickstart <= '0'; + kickstart_ref <= '0'; + wave_error <= '0'; + elsif(init = '1') then + loc_cnt := 0; + ext_time <= init_time; + kickstart <= '0'; + kickstart_ref <= '0'; + wave_error <= '0'; + elsif(clk = '1' and clk'event) then + loc_cnt := loc_cnt+1; + if(cnt_dir = '0') then + ext_time <= std_logic_vector(signed(ext_time)+1); + else + ext_time <= std_logic_vector(signed(ext_time)-1); + end if; + if(loc_cnt = offset) then + kickstart <= '1'; + else + kickstart <= '0'; + end if; + --if(loc_cnt = (offset + to_integer(unsigned(delay))+1)) then + -- wave_delayed <= '1'; + --elsif(loc_cnt = offset + pulse_width + to_integer(unsigned(delay)+1)) then + -- wave_delayed <= '0'; + --end if; + if(loc_cnt = (offset + to_integer(unsigned(delay))+3)) then + kickstart_ref <= '1'; + --elsif(loc_cnt = offset + pulse_width + to_integer(unsigned(delay)+2)) then + else + kickstart_ref <= '0'; + end if; + if(wave_out /= wave_ref) then + wave_error <= '1'; + end if; + end if; + end process pIO_MNG; + + pREP : process(clk) + begin + if(clk = '1' and clk'event) then + wave_delayed_d <= wave_delayed; + if(init = '1') then + error_detected <= '0'; + elsif(wave_error = '1') then + error_detected <= '1'; + end if; + end if; + end process pREP; + + -- Generate the input wave + pWAVE_IN_GEN : process + begin + wave_in <= '0'; + -- wait for the kickstart + wait until kickstart = '1' and kickstart'event; + -- send pulse #1 + wave_in <= '1'; + for n in 1 to pulse_width loop + wait until clk = '1' and clk'event; + end loop; -- n + wave_in <= '0'; + -- send pulse #2 + for n in 1 to 6 loop + wait until ext_time'event; + end loop; -- n + wave_in <= '1'; + for n in 1 to pulse_width loop + wait until clk = '1' and clk'event; + end loop; -- n + wave_in <= '0'; + /* + -- send pulse #3 + for n in 1 to 3 loop + wait until ext_time'event; + end loop; -- n + wave_in <= '1'; + for n in 1 to pulse_width loop + wait until clk = '1' and clk'event; + end loop; -- n + wave_in <= '0'; + */ + end process pWAVE_IN_GEN; + + -- Generate the reference wave + pWAVE_REF_GEN : process + begin + wave_delayed <= '0'; + -- wait for the kickstart + wait until kickstart_ref = '1' and kickstart_ref'event; + -- send pulse #1 + wave_delayed <= '1'; + for n in 1 to pulse_width loop + wait until clk = '1' and clk'event; + end loop; -- n + wave_delayed <= '0'; + -- send pulse #2 + for n in 1 to 6 loop + wait until ext_time'event; + end loop; -- n + wave_delayed <= '1'; + for n in 1 to pulse_width loop + wait until clk = '1' and clk'event; + end loop; -- n + wave_delayed <= '0'; + /* + -- send pulse #3 + for n in 1 to 3 loop + wait until ext_time'event; + end loop; -- n + wave_delayed <= '1'; + for n in 1 to pulse_width loop + wait until clk = '1' and clk'event; + end loop; -- n + wave_delayed <= '0'; + */ + end process pWAVE_REF_GEN; + + wave_ref <= wave_delayed and not wave_delayed_d; + + ----------------------------------------------------------------------------- + -- Test the block via configuration & control through the C&S bus + ----------------------------------------------------------------------------- + + pCFG_and_CTRL : process + begin + + passed <= false; + failed <= false; + completed <= false; + + init <= '0'; + offset <= 0; + pulse_width <= 0; + cnt_dir <= '0'; + delay <= (others => '0'); + init_time <= (others => '0'); + + -- Apply reset + rstN <= '0'; + wait for 20*clk_period; + -- + wait for 10*clk_period; + wait until clk = '1' and clk'event; + rstN <= '1'; + + --------------------------------------------------------------------------- + -- Test-Case #1 + --------------------------------------------------------------------------- + -- Count Up, init count positive, no-wrapping all + + -- Configure + init <= '1'; + -- + offset <= 50; + pulse_width <= 3; + cnt_dir <= '0'; + delay <= std_logic_vector(to_signed(10, 32)); + init_time <= std_logic_vector(to_signed(0, 32)); + + wait for 5*clk_period; + wait until clk = '1' and clk'event; + init <= '0'; + + -- run the test case + wait until wave_ref = '1'; + wait until wave_ref = '0'; + wait until wave_ref = '1'; + wait until wave_ref = '0'; + + -- check the results + wait until clk = '1' and clk'event; + if(error_detected = '1') then + failed <= true; + assert false report "ERROR on TC#1" severity error; + completed <= true; + else + assert false report "TC#1 passed" severity note; + end if; + + passed <= true; + wait for 5*clk_period; + wait until clk = '1' and clk'event; + + --------------------------------------------------------------------------- + -- Test-Case #2 + --------------------------------------------------------------------------- + -- Count Up, init count negative, no-wrapping at all + + -- Configure + init <= '1'; + -- + offset <= 50; + pulse_width <= 3; + cnt_dir <= '0'; + delay <= std_logic_vector(to_signed(10, 32)); + init_time <= std_logic_vector(to_signed(-100, 32)); + + wait for 5*clk_period; + wait until clk = '1' and clk'event; + init <= '0'; + + -- run the test case + wait until wave_ref = '1'; + wait until wave_ref = '0'; + wait until wave_ref = '1'; + wait until wave_ref = '0'; + + -- check the results + wait until clk = '1' and clk'event; + if(error_detected = '1') then + failed <= true; + assert false report "ERROR on TC#2" severity error; + completed <= true; + else + assert false report "TC#2 passed" severity note; + end if; + + passed <= true; + wait for 5*clk_period; + wait until clk = '1' and clk'event; + + --------------------------------------------------------------------------- + -- Test-Case #3 + --------------------------------------------------------------------------- + -- Count Up, init count negative, counter wrapping between the rising and + -- falling edge of the input pulse + + -- Configure + init <= '1'; + -- + offset <= 50; + pulse_width <= 3; + cnt_dir <= '0'; + delay <= std_logic_vector(to_signed(10, 32)); + init_time <= std_logic_vector(to_signed(-52, 32)); + + wait for 5*clk_period; + wait until clk = '1' and clk'event; + init <= '0'; + + -- run the test case + wait until wave_ref = '1'; + wait until wave_ref = '0'; + wait until wave_ref = '1'; + wait until wave_ref = '0'; + + -- check the results + wait until clk = '1' and clk'event; + if(error_detected = '1') then + failed <= true; + assert false report "ERROR on TC#3" severity error; + completed <= true; + else + assert false report "TC#3 passed" severity note; + end if; + + passed <= true; + wait for 5*clk_period; + wait until clk = '1' and clk'event; + + --------------------------------------------------------------------------- + -- Test-Case #4 + --------------------------------------------------------------------------- + -- Count Up, init count negative, counter wrapping between the rising and + -- falling edge of the output pulse + + -- Configure + init <= '1'; + -- + offset <= 50; + pulse_width <= 3; + cnt_dir <= '0'; + delay <= std_logic_vector(to_signed(10, 32)); + init_time <= std_logic_vector(to_signed(-62, 32)); + + wait for 5*clk_period; + wait until clk = '1' and clk'event; + init <= '0'; + + -- run the test case + wait until wave_ref = '1'; + wait until wave_ref = '0'; + wait until wave_ref = '1'; + wait until wave_ref = '0'; + + -- check the results + wait until clk = '1' and clk'event; + if(error_detected = '1') then + failed <= true; + assert false report "ERROR on TC#4" severity error; + completed <= true; + else + assert false report "TC#4 passed" severity note; + end if; + + passed <= true; + wait for 5*clk_period; + wait until clk = '1' and clk'event; + + --------------------------------------------------------------------------- + -- Test-Case #5 + --------------------------------------------------------------------------- + -- Count Down, init count positive, no-wrapping all + + -- Configure + init <= '1'; + -- + offset <= 50; + pulse_width <= 3; + cnt_dir <= '1'; + delay <= std_logic_vector(to_signed(10, 32)); + init_time <= std_logic_vector(to_signed(100, 32)); + + wait for 5*clk_period; + wait until clk = '1' and clk'event; + init <= '0'; + + -- run the test case + wait until wave_ref = '1'; + wait until wave_ref = '0'; + wait until wave_ref = '1'; + wait until wave_ref = '0'; + + -- check the results + wait until clk = '1' and clk'event; + if(error_detected = '1') then + failed <= true; + assert false report "ERROR on TC#5" severity error; + completed <= true; + else + assert false report "TC#5 passed" severity note; + end if; + + passed <= true; + wait for 5*clk_period; + wait until clk = '1' and clk'event; + + --------------------------------------------------------------------------- + -- Test-Case #6 + --------------------------------------------------------------------------- + -- Count Down, init count negative, no-wrapping at all + + -- Configure + init <= '1'; + -- + offset <= 50; + pulse_width <= 3; + cnt_dir <= '1'; + delay <= std_logic_vector(to_signed(10, 32)); + init_time <= std_logic_vector(to_signed(-100, 32)); + + wait for 5*clk_period; + wait until clk = '1' and clk'event; + init <= '0'; + + -- run the test case + wait until wave_ref = '1'; + wait until wave_ref = '0'; + wait until wave_ref = '1'; + wait until wave_ref = '0'; + + -- check the results + wait until clk = '1' and clk'event; + if(error_detected = '1') then + failed <= true; + assert false report "ERROR on TC#6" severity error; + completed <= true; + else + assert false report "TC#6 passed" severity note; + end if; + + passed <= true; + wait for 5*clk_period; + wait until clk = '1' and clk'event; + + --------------------------------------------------------------------------- + -- Test-Case #7 + --------------------------------------------------------------------------- + -- Count Down, init count positive, counter wrapping between the rising and + -- falling edge of the input pulse + + -- Configure + init <= '1'; + -- + offset <= 50; + pulse_width <= 3; + cnt_dir <= '1'; + delay <= std_logic_vector(to_signed(10, 32)); + init_time <= std_logic_vector(to_signed(51, 32)); + + wait for 5*clk_period; + wait until clk = '1' and clk'event; + init <= '0'; + + -- run the test case + wait until wave_ref = '1'; + wait until wave_ref = '0'; + wait until wave_ref = '1'; + wait until wave_ref = '0'; + + -- check the results + wait until clk = '1' and clk'event; + if(error_detected = '1') then + failed <= true; + assert false report "ERROR on TC#7" severity error; + completed <= true; + else + assert false report "TC#7 passed" severity note; + end if; + + passed <= true; + wait for 5*clk_period; + wait until clk = '1' and clk'event; + + --------------------------------------------------------------------------- + -- Test-Case #8 + --------------------------------------------------------------------------- + -- Count Down, init count positive, counter wrapping between the rising and + -- falling edge of the output pulse + + -- Configure + init <= '1'; + -- + offset <= 50; + pulse_width <= 3; + cnt_dir <= '1'; + delay <= std_logic_vector(to_signed(10, 32)); + init_time <= std_logic_vector(to_signed(62, 32)); + + wait for 5*clk_period; + wait until clk = '1' and clk'event; + init <= '0'; + + -- run the test case + wait until wave_ref = '1'; + wait until wave_ref = '0'; + wait until wave_ref = '1'; + wait until wave_ref = '0'; + + -- check the results + wait until clk = '1' and clk'event; + if(error_detected = '1') then + failed <= true; + assert false report "ERROR on TC#8" severity error; + completed <= true; + else + assert false report "TC#8 passed" severity note; + end if; + + passed <= true; + wait for 5*clk_period; + wait until clk = '1' and clk'event; + + --------------------------------------------------------------------------- + -- Test-Case #9 + --------------------------------------------------------------------------- + -- Check the minimum latency + + -- Configure + init <= '1'; + -- + offset <= 50; + pulse_width <= 3; + cnt_dir <= '1'; + delay <= std_logic_vector(to_signed(3, 32)); + init_time <= std_logic_vector(to_signed(62, 32)); + + wait for 5*clk_period; + wait until clk = '1' and clk'event; + init <= '0'; + + -- run the test case + wait until wave_ref = '1'; + wait until wave_ref = '0'; + wait until wave_ref = '1'; + wait until wave_ref = '0'; + + -- check the results + wait until clk = '1' and clk'event; + if(error_detected = '1') then + failed <= true; + assert false report "ERROR on TC#9" severity error; + completed <= true; + else + assert false report "TC#9 passed" severity note; + end if; + + passed <= true; + wait for 5*clk_period; + wait until clk = '1' and clk'event; + + + --------------------------------------------------------------------------- + -- End of Testing + --------------------------------------------------------------------------- + + completed <= true; + + wait for 1 ms; + + end process pCFG_and_CTRL; + +end behav; +