From f28e864d8674ed3184a8050f6f4686b4f585224e Mon Sep 17 00:00:00 2001 From: David Steele Date: Fri, 10 Feb 2023 13:44:04 +0000 Subject: [PATCH] HMBSED3000-354. Fix library components to work with D3000 Zero gap Implement inline merge / zero gap in D3000 Logic --- .../7/src/fire_pulse_manager_7.vhd | 4 + .../8/src/fire_pulse_manager_8.vhd | 16 +- .../18/src/generic_sequencer_18.vhd | 82 +-- .../pixel_buffer/2/src/pixel_buffer_2.vhd | 16 +- .../2/src/pixel_buffer_zero_gap_2.vhd | 144 ++--- .../5/src/pulse_generator_5.vhd | 133 +++-- .../6/src/pulse_generator_6.vhd | 521 +++++++++--------- 7 files changed, 509 insertions(+), 407 deletions(-) diff --git a/generic_ip/fire_pulse_manager/7/src/fire_pulse_manager_7.vhd b/generic_ip/fire_pulse_manager/7/src/fire_pulse_manager_7.vhd index b7df9b3..f06bb09 100644 --- a/generic_ip/fire_pulse_manager/7/src/fire_pulse_manager_7.vhd +++ b/generic_ip/fire_pulse_manager/7/src/fire_pulse_manager_7.vhd @@ -50,6 +50,8 @@ entity fire_pulse_manager_7 is stream_busy_a : in std_logic_vector(CH_NUM - 1 downto 0) := (others => '0'); stream_busy_b : in std_logic_vector(CH_NUM - 1 downto 0) := (others => '0'); dp_dir_out : out std_logic_vector(CH_NUM - 1 downto 0); + hd_leadng_edge_rev: out std_logic_vector(CH_NUM - 1 downto 0); -- Head will print with rear nozzles first (e.g. dcba cs abcd) + pg_vecb_spare : out std_logic_vector(32*CH_NUM - 1 downto 0); -- spare bits output from the pg sequencer vector B abs_pos_out : out std_logic_vector(31 downto 0); print_start : out std_logic; mon_pt : out std_logic_vector(3 downto 0); -- Monitoring Points @@ -505,6 +507,8 @@ begin enc_vel => vel_meas, enc_speed_meas_w => vel_sampling_per(i), dp_dir => dp_dir(i), + hd_leadng_edge_rev => hd_leadng_edge_rev(i), + pg_vecb_spare => pg_vecb_spare(i*7+6 downto i*7), fire_req_vec => ch_fire_pulse(i), start_of_image_vec => ch_start_of_image(i), stream_busy_a => stream_busy_a(i), diff --git a/generic_ip/fire_pulse_manager/8/src/fire_pulse_manager_8.vhd b/generic_ip/fire_pulse_manager/8/src/fire_pulse_manager_8.vhd index 3ca2984..2d026ef 100644 --- a/generic_ip/fire_pulse_manager/8/src/fire_pulse_manager_8.vhd +++ b/generic_ip/fire_pulse_manager/8/src/fire_pulse_manager_8.vhd @@ -50,6 +50,8 @@ entity fire_pulse_manager_8 is stream_busy_a : in std_logic_vector(CH_NUM - 1 downto 0) := (others => '0'); stream_busy_b : in std_logic_vector(CH_NUM - 1 downto 0) := (others => '0'); dp_dir_out : out std_logic_vector(CH_NUM - 1 downto 0); + hd_leadng_edge_rev: out std_logic_vector(CH_NUM - 1 downto 0); -- Head will print with rear nozzles first (e.g. dcba cs abcd) + pg_vecb_spare : out std_logic_vector(32*CH_NUM - 1 downto 0); -- spare bits output from the pg sequencer vector B abs_pos_out : out std_logic_vector(31 downto 0); print_start : out std_logic; mon_pt : out std_logic_vector(3 downto 0); -- Monitoring Points @@ -231,7 +233,7 @@ begin ----------------------------------------------------------------------------- - -- C&S Register Interface Splitting + -- C&S Register Interface Splitting ----------------------------------------------------------------------------- iCS_BUS_ITF : entity work.cs_bus_ift_no_wait @@ -328,8 +330,8 @@ begin fpm_generic_status(7) <= '1' when PULSE_DELAY_EQUAL_EN = true else '0'; fpm_generic_status(8) <= '1' when TOF_COMP_EN = true else '0'; fpm_generic_status(9) <= '1' when PIXEL_PITCH_CORR_EN = true else '0'; - - + + ----------------------------------------------------------------------------- -- I/Os selection ----------------------------------------------------------------------------- @@ -411,12 +413,12 @@ begin begin if (clk = '1' and clk'Event) then init <= '0'; - if fire_pulse_ctrl_init = '1' then -- signal from control registers + if fire_pulse_ctrl_init = '1' then -- signal from control registers init <= '1'; elsif src_sel(SRC_SEL_ENC_PD_EMUL_EN) = '1' then -- setting the internal encoder position also re-initialises init <= set_pos_ie; -- fpm_init_done should be polled by ESW before any further actions to ensure init is complete elsif src_sel(SRC_SEL_SEB_EPD_EN) = '0' and remote_init = '1' then - -- source is not SEB-EPD (i.e. it's the SEB-PDW RX link) and we received an init signal over the POF RX link (it's a strobe) + -- source is not SEB-EPD (i.e. it's the SEB-PDW RX link) and we received an init signal over the POF RX link (it's a strobe) init <= '1'; elsif src_sel(SRC_SEL_SEB_EPD_EN) = '0' and enable_rx = '0' then -- source is not enc_pd_emul and is not SEB-EPD (i.e. it's the SEB-PDW RX link) but the RX link has been disabled @@ -507,6 +509,8 @@ begin enc_vel => vel_meas, enc_speed_meas_w => vel_sampling_per(i), dp_dir => dp_dir(i), + hd_leadng_edge_rev => hd_leadng_edge_rev(i), + pg_vecb_spare => pg_vecb_spare(i*7+6 downto i*7), fire_req_vec => ch_fire_pulse(i), start_of_image_vec => ch_start_of_image(i), stream_busy_a => stream_busy_a(i), @@ -584,7 +588,7 @@ begin ----------------------------------------------------------------------------- - -- EMS + -- EMS ----------------------------------------------------------------------------- gEMS : if SEB_EPD_MODE = true generate diff --git a/generic_ip/generic_sequencer/18/src/generic_sequencer_18.vhd b/generic_ip/generic_sequencer/18/src/generic_sequencer_18.vhd index 2ed4786..0620c5f 100644 --- a/generic_ip/generic_sequencer/18/src/generic_sequencer_18.vhd +++ b/generic_ip/generic_sequencer/18/src/generic_sequencer_18.vhd @@ -25,6 +25,7 @@ entity generic_sequencer_18 is generic( TRIGGER_WIDTH : natural range 1 to 16 := 16; VECTOR_WIDTH : natural range 1 to 24 := 24; + VECTOR_WIDTHB : natural range 1 to 24 := 1; RAMP_WIDTH : natural range 1 to 16 := 16; -- Must be less than or equal to VECTOR_WIDTH BUS_WIDTH : natural range 1 to 32 := 32; POS_WIDTH : natural range 1 to 32 := 32; @@ -39,32 +40,33 @@ entity generic_sequencer_18 is DEVICE_FAMILY : string := "Cyclone V" -- "Cyclone 10 LP" ); port( - -- + -- clk : in std_logic; reset_n : in std_logic; - -- + -- avs_csr_address : in std_logic_vector(3 downto 0); avs_csr_write : in std_logic; avs_csr_writedata : in std_logic_vector(31 downto 0); 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_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); - -- + -- 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 := '1'; - -- + -- vector_out : out std_logic_vector(VECTOR_WIDTH - 1 downto 0); - -- + vector_out_b : out std_logic_vector(VECTOR_WIDTHB - 1 downto 0); + -- bus_data : out std_logic_vector(BUS_WIDTH - 1 downto 0); bus_valid : out std_logic; bus_ack : in std_logic); @@ -123,6 +125,7 @@ architecture rtl of generic_sequencer_18 is signal trig_int : std_logic; signal vector_out_i : std_logic_vector(23 downto 0) := (others => '0'); + signal vector_out_b_i : std_logic_vector(VECTOR_WIDTHB - 1 downto 0); signal ramp_curr : std_logic_vector(RAMP_WIDTH - 1 downto 0); signal ramp_next : std_logic_vector(RAMP_WIDTH - 1 downto 0); signal ramp_final : std_logic_vector(RAMP_WIDTH - 1 downto 0); @@ -137,14 +140,14 @@ architecture rtl of generic_sequencer_18 is 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 decode, clr_vec_all, ld_vec : std_logic; signal bus_valid_i : std_logic; signal busy_i : std_logic := '1'; signal ld_start_addr, inc_ram_addr : std_logic; signal ld_trig_mask, ld_trig_sel : std_logic; signal ld_pos, ld_ramp : std_logic; signal zero_flag, alu_upd : std_logic; - signal clr_vec_i, clr_vec_ii : std_logic; + signal clr_vec_a_i, clr_vec_b_i : std_logic; signal fetch_op, ramp_up : std_logic; signal op_cnt_done, inc_op_cnt : std_logic; signal bus_pause, ld_jmp_addr : std_logic; @@ -203,7 +206,7 @@ begin -- Clock and reset clk => clk, rst_n => reset_n, - + -- auto-generated -- Internal signal ports @@ -242,7 +245,7 @@ begin pos_store => pos_store_csr, seq_queue_r_queue_left => queue_left, seq_queue_r_queue_exec => queue_exec, - + -- end auto-generated -- Slave bus port @@ -296,7 +299,7 @@ begin end if; if fsm = s_pos_wait and subcode = x"4" then - -- capture the comparator top bits + -- capture the comparator top bits pos_comp_msbs <= operand_1(pos_comp_msbs'range); end if; @@ -336,7 +339,7 @@ begin --pragma translate_off assert (to_integer(unsigned(trig_sel)) < TRIGGER_WIDTH) report "ERROR: trig_sel out of selectable trigger mask" severity failure; assert (VECT_RAMP_EN = false or RAMP_WIDTH <= VECTOR_WIDTH) report "ERROR: Ramp Width must be <= Vector Width" severity failure; - --pragma translate_on + --pragma translate_on ----------------------------------------------------------------------------- -- Dual-Port Memory buffer @@ -365,7 +368,7 @@ begin ----------------------------------------------------------------------------- -- Sequencer Logic - ----------------------------------------------------------------------------- + ----------------------------------------------------------------------------- start_req_i <= start_req and not start_req_d; @@ -388,7 +391,7 @@ begin fsm_nxt <= fsm; -- decode <= '0'; - clr_vec_i <= '0'; + clr_vec_all <= '0'; ld_vec <= '0'; ld_ramp <= '0'; busy_i <= '1'; @@ -414,7 +417,7 @@ begin if (seq_enable = '0') then busy_i <= '0'; if (rst_vector_out = '1') then - clr_vec_i <= '1'; + clr_vec_all <= '1'; end if; fsm_nxt <= s_idle; elsif (start_req_i = '1') then @@ -433,7 +436,7 @@ begin when s_init => if (rst_vector_out = '1') then - clr_vec_i <= '1'; + clr_vec_all <= '1'; end if; fsm_nxt <= s_fetch; @@ -452,7 +455,7 @@ begin case opcode is -- when CMD_NOP => fsm_nxt <= s_fetch; - -- + -- when CMD_TRIG_MASK => fsm_nxt <= s_trig_mask; when CMD_TRIG_WAIT => fsm_nxt <= s_trig_wait; when CMD_VEC_SET => fsm_nxt <= s_vec_set; @@ -563,11 +566,12 @@ begin ld_trig_sel <= '1' when decode = '1' and (opcode = CMD_TRIG_WAIT or opcode = CMD_VEC_RAMP_UP or opcode = CMD_VEC_RAMP_DN or opcode = CMD_VEC_RAMP) else '0'; - -- + -- pSEQ_REGs : process(reset_n, clk) begin if (reset_n = '0') then vector_out_i <= (others => '0'); + vector_out_b_i <= (others => '0'); start_req_d <= '0'; fetch_enable <= '0'; pc_value <= (others => '0'); @@ -577,12 +581,15 @@ begin busy <= '1'; trig_mask <= (others => '0'); trig_sel <= (others => '0'); - clr_vec_ii <= '0'; + clr_vec_a_i <= '0'; + clr_vec_b_i <= '0'; ramp_to_val <= '0'; return_addr <= (others => '0'); op_cnt <= (others => '0'); loop_active <= '0'; elsif (clk = '1' and clk'event) then + clr_vec_a_i <= '0'; + clr_vec_b_i <= '0'; start_req_d <= start_req; fetch_enable <= (not debug_mode) or (debug_mode and step_req); if (fetch_op = '1') then @@ -608,15 +615,26 @@ begin if (ld_trig_sel = '1') then trig_sel <= subcode; end if; - if (ld_vec = '1' and subcode = "0001") then - clr_vec_ii <= '1'; - else - clr_vec_ii <= '0'; + if (ld_vec = '1' and subcode(2 downto 0) = "001") then + if subcode(3) = '0' then + clr_vec_a_i <= '1'; + else + clr_vec_b_i <= '1'; + end if; end if; - if (clr_vec = '1') then - vector_out_i <= (others => '0'); + if clr_vec_all = '1' or clr_vec_a_i = '1' or clr_vec_b_i = '1' then + if clr_vec_all = '1' or clr_vec_a_i = '1' then + vector_out_i <= (others => '0'); + end if; + if clr_vec_all = '1' or clr_vec_b_i = '1' then + vector_out_b_i <= (others => '0'); + end if; elsif (ld_vec = '1') then - vector_out_i(VECTOR_WIDTH - 1 downto 0) <= operand_comp(VECTOR_WIDTH - 1 downto 0); + if subcode(3) = '0' then + vector_out_i(VECTOR_WIDTH - 1 downto 0) <= operand_comp(VECTOR_WIDTH - 1 downto 0); + else + vector_out_b_i <= operand_comp(VECTOR_WIDTHB - 1 downto 0); + end if; elsif (VECT_RAMP_EN = true and ld_ramp = '1') then if (ramp_up = '1' and ramp_next(ramp_next'high) = '0' and vector_out_i(ramp_next'high) = '1') then vector_out_i(RAMP_WIDTH - 1 downto 0) <= (others => '1'); @@ -663,8 +681,6 @@ begin 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 @@ -687,14 +703,16 @@ begin ----------------------------------------------------------------------------- gVECT_NO_PIPE : if ADD_VEC_PIPE = false generate - vector_out <= vector_out_i(vector_out'range); + vector_out <= vector_out_i(vector_out'range); + vector_out_b <= vector_out_b_i; end generate gVECT_NO_PIPE; gVECT_PIPE : if ADD_VEC_PIPE = true generate pVECT_PIPE : process(clk) begin if (clk = '1' and clk'event) then - vector_out <= vector_out_i(vector_out'range); + vector_out <= vector_out_i(vector_out'range); + vector_out_b <= vector_out_b_i; end if; end process pVECT_PIPE; end generate gVECT_PIPE; diff --git a/generic_ip/pixel_buffer/2/src/pixel_buffer_2.vhd b/generic_ip/pixel_buffer/2/src/pixel_buffer_2.vhd index 46201f8..526511a 100644 --- a/generic_ip/pixel_buffer/2/src/pixel_buffer_2.vhd +++ b/generic_ip/pixel_buffer/2/src/pixel_buffer_2.vhd @@ -199,6 +199,8 @@ architecture rtl of pixel_buffer_2 is signal diag_peek_wren : std_logic_vector(MAX_OP_WIDTH-1 downto 0); signal is_en_peek : std_logic; + signal is_not_last_wave : std_logic; + signal rdreq_vec_int : std_logic_vector(MAX_OP_WIDTH-1 downto 0); signal rd_data_stripe_id : std_logic_vector(MAX_OP_WIDTH*STRIPE_ID_WIDTH-1 downto 0); @@ -378,6 +380,7 @@ begin pixel_buf_wr_shft(0) <= '1'; word_count <= (others => '0'); is_last_wave <= '0'; + is_not_last_wave <= '0'; overrun <= '0'; underrun <= '0'; pend_drop_detect <= '0'; @@ -419,6 +422,7 @@ begin pixel_buf_wr_shft(0) <= '1'; word_count <= (others => '0'); is_last_wave <= '0'; + is_not_last_wave <= '0'; overrun <= '0'; underrun <= '0'; pend_drop_detect <= '0'; @@ -490,6 +494,14 @@ begin else is_last_wave <= '0'; end if; + + -- Only set when there are multiple playouts of the same address in the pixel buffer + -- This stops drop_stripe altering the rd_ptr until the previous stripe has finished + if start_req_first = '1' and start_req_last = '0' then + is_not_last_wave <= '1'; + else + is_not_last_wave <= '0'; + end if; end if; -- If pixel buffer peeking diags enabled, export the read and write pointers, @@ -626,9 +638,9 @@ begin -- If a 'droppy' situation is outstanding, wait for the data path to go idle -- and clear the contents of the next stripe -- sequencers_busy = '0' covers the case where rd_req_vec reads at different times - -- is_last_wave and rd_ptr_all_equal ensures that we complete the stripe before completely before deleting this one + -- is_not_last_wave = 0 and rd_ptr_all_equal ensures that we complete the stripe before completely before deleting this one stripe_dropped <= '0'; - if pend_drop_detect = '1' and sequencers_busy = '0' and unsigned(wren) = 0 and word_count >= drop_adjust and unsigned(rdreq_vec_int) = 0 and is_last_wave = '1' and rd_ptr_all_equal = '1' then + if pend_drop_detect = '1' and sequencers_busy = '0' and unsigned(wren) = 0 and word_count >= drop_adjust and unsigned(rdreq_vec_int) = 0 and is_not_last_wave = '0' and rd_ptr_all_equal = '1' then pend_drop_detect <= '0'; for i in 0 to MAX_OP_WIDTH-1 loop rd_ptr(i) <= std_logic_vector(unsigned(rd_ptr(i)) + unsigned(drop_adjust)); diff --git a/generic_ip/pixel_buffer/2/src/pixel_buffer_zero_gap_2.vhd b/generic_ip/pixel_buffer/2/src/pixel_buffer_zero_gap_2.vhd index bf2e7e5..1d16188 100644 --- a/generic_ip/pixel_buffer/2/src/pixel_buffer_zero_gap_2.vhd +++ b/generic_ip/pixel_buffer/2/src/pixel_buffer_zero_gap_2.vhd @@ -86,7 +86,7 @@ entity pixel_buffer_zero_gap_2 IS rdreq : in std_logic; rdreq_vec : in std_logic_vector(MAX_OP_WIDTH-1 downto 0) := (others => '0'); rdreq_rdy : out std_logic; - q : out data_array_t(NUM_CHANS-1 downto 0)(MAX_OP_WIDTH*32-1 downto 0); + q : out std_logic_vector(MAX_OP_WIDTH*32-1 downto 0); empty : out std_logic; full : out std_logic; @@ -137,6 +137,7 @@ architecture rtl of pixel_buffer_zero_gap_2 is constant TOTAL_DEPTH_LOG2 : integer := log2(PX_DEPTH + RSVD_DEPTH); constant NUM_CHANS_LOG2 : integer := log2(NUM_CHANS); + signal q_int : data_array_t(NUM_CHANS-1 downto 0)(MAX_OP_WIDTH*32-1 downto 0); signal rd_req_int : std_logic_vector(NUM_CHANS-1 downto 0); type rdreq_vec_t is array (natural range <> ) of std_logic_vector; signal rdreq_vec_int : rdreq_vec_t(NUM_CHANS-1 downto 0)(MAX_OP_WIDTH-1 downto 0); @@ -243,7 +244,7 @@ begin clr_buf_active_rdreq(NUM_CHANS-1 downto 1)<= (others => '0'); GEN_TIE_OFF_Q : for i in 1 to NUM_CHANS-1 generate - q(i) <= (others => '0'); + q_int(i) <= (others => '0'); end generate; end generate; @@ -257,6 +258,10 @@ begin -- Instantiate the pixel buffers, both normal and -- (if enabled) auxiliary -- ----------------------------------------------- + GEN_Q_COMB : for j in 0 to (MAX_OP_WIDTH*32/4)-1 generate + q(j*4+3 downto j*4) <= q_int(0)(j*4+3 downto j*4) when (unsigned(q_int(0)(j*4+3 downto j*4)) > unsigned(q_int(1)(j*4+3 downto j*4))) + else q_int(1)(j*4+3 downto j*4); + end generate; GEN_PX_BUF : for i in 0 to NUM_CHANS-1 generate @@ -264,89 +269,90 @@ begin start_req_int(i) <= buf_active_int(0)(i) and seq_1st_start_req; - GEN_Q : for j in 0 to MAX_OP_WIDTH-1 generate - q(i)(j*32+31 downto j*32) <= rd_data(i)(j*32+31 downto j*32) when pb_data_enable(j)(i) else (others => '0'); + GEN_Q : for j in 0 to MAX_OP_WIDTH-1 generate + q_int(i)(j*32+31 downto j*32) <= rd_data(i)(j*32+31 downto j*32) when pb_data_enable(j)(i) else (others => '0'); - GEN_EN : if SUB_HEADS >= 4 and (MAX_OP_WIDTH/2) = SUB_HEADS generate - pb_data_enable(j)(i) <= buf_active_late_int(j/2)(i); -- 1536 must zero sub head data so merge works correctly - else generate - pb_data_enable(j)(i) <= buf_active_late_int(0)(i); -- Any Heads without Sub Heads - disable whole pixel buffer output - end generate; + GEN_EN : if SUB_HEADS >= 4 and (MAX_OP_WIDTH/2) = SUB_HEADS generate + pb_data_enable(j)(i) <= buf_active_late_int(j/2)(i); -- 1536 must zero sub head data so merge works correctly + else generate + pb_data_enable(j)(i) <= buf_active_late_int(0)(i); -- Any Heads without Sub Heads - disable whole pixel buffer output end generate; + end generate; - clr_buf_active_rdreq(i) <= (last_stripe(i)(MAX_OP_WIDTH-1) and is_last_wave(i) and rd_req_int(i)) - or last_stripe_dropped(i); -- if the last stripe of the image is dropped, the above case never happens + clr_buf_active_rdreq(i) <= (last_stripe(i)(MAX_OP_WIDTH-1) and is_last_wave(i) and rd_req_int(i)) + or last_stripe_dropped(i); -- if the last stripe of the image is dropped, the above case never happens - GEN_SH: for j in 0 to SUB_HEADS-1 generate - clr_buf_active_rdvec(j)(i) <= (last_stripe(i)(j*2) and is_last_wave(i) and rdreq_vec_int(i)(j*2)) - or last_stripe_dropped(i); -- if the last stripe of the image is dropped, the above case never happens + GEN_SH: for j in 0 to SUB_HEADS-1 generate + clr_buf_active_rdvec(j)(i) <= (last_stripe(i)(j*2) and is_last_wave(i) and rdreq_vec_int(i)(j*2)) + or last_stripe_dropped(i); -- if the last stripe of the image is dropped, the above case never happens - clr_buf_active(j)(i) <= clr_buf_active_rdvec(j)(i) when VECTORED_RDREQ else clr_buf_active_rdreq(i); - end generate; - pixel_buf_inst : entity work.pixel_buffer_2 - generic map ( - MAX_OP_WIDTH => MAX_OP_WIDTH, - SHIFT_DEPTH => SHIFT_DEPTH, - PX_DEPTH => PX_DEPTH, - RSVD_DEPTH => RSVD_DEPTH, - FULL_MARGIN => FULL_MARGIN, - EN_PEEK => EN_PEEK, - VECTORED_RDREQ => VECTORED_RDREQ, - DEVICE_FAMILY => DEVICE_FAMILY, - ADD_PADDING => ADD_PADDING - ) - port map - ( - clk => clk, - rst_n => rst_n, + clr_buf_active(j)(i) <= clr_buf_active_rdvec(j)(i) when VECTORED_RDREQ else clr_buf_active_rdreq(i); + end generate; - pixel_buf_rdy => pixel_buf_rdy(i), + pixel_buf_inst : entity work.pixel_buffer_2 + generic map ( + MAX_OP_WIDTH => MAX_OP_WIDTH, + SHIFT_DEPTH => SHIFT_DEPTH, + PX_DEPTH => PX_DEPTH, + RSVD_DEPTH => RSVD_DEPTH, + FULL_MARGIN => FULL_MARGIN, + EN_PEEK => EN_PEEK, + VECTORED_RDREQ => VECTORED_RDREQ, + DEVICE_FAMILY => DEVICE_FAMILY, + ADD_PADDING => ADD_PADDING + ) + port map + ( + clk => clk, + rst_n => rst_n, - last_word => last_word(i), - data => data(i), - wrreq => wrreq(i), + pixel_buf_rdy => pixel_buf_rdy(i), - rdreq => rd_req_int(i), - rdreq_vec => rdreq_vec_int(i), - rdreq_rdy => rd_req_rdy_int(i), - q => rd_data(i), - last_word_op => last_stripe(i), + last_word => last_word(i), + data => data(i), + wrreq => wrreq(i), - empty => empty_int(i), - full => full_int(i), - overrun => overrun_int(i), - underrun => underrun_int(i), - dbl_drop => dbl_drop_int(i), - fp_drop => fp_drop_int(i), + rdreq => rd_req_int(i), + rdreq_vec => rdreq_vec_int(i), + rdreq_rdy => rd_req_rdy_int(i), + q => rd_data(i), + last_word_op => last_stripe(i), - print_data_width => print_data_width, - clear_buffer => clear_buffer, + empty => empty_int(i), + full => full_int(i), + overrun => overrun_int(i), + underrun => underrun_int(i), + dbl_drop => dbl_drop_int(i), + fp_drop => fp_drop_int(i), - start_req => start_req_int(i), - start_req_first => start_req_first, - start_req_last => start_req_last, - is_last_wave => is_last_wave(i), + print_data_width => print_data_width, + clear_buffer => clear_buffer, - all_on => all_on, + start_req => start_req_int(i), + start_req_first => start_req_first, + start_req_last => start_req_last, + is_last_wave => is_last_wave(i), - diag_peek_sel => diag_peek_sel, - diag_peek_addr => diag_peek_addr, - diag_peek_data => diag_peek_data_int(i), - diag_peek_rdptr => diag_peek_rdptr_int(i), - diag_peek_wrptr => diag_peek_wrptr_int(i), - diag_peek_wdata => diag_peek_wdata, - diag_peek_wr => diag_peek_wr, + all_on => all_on, - fire_req => fire_req, -- Was used for drop detect, but drop now signalled explicitly - drop_stripe => buf_active_int(0)(i) and drop_stripe_d, -- 1 clock delayed so that buf_active is already valid when pulsed - sequencers_busy => sequencers_busy_int(i), - last_stripe_dropped => last_stripe_dropped(i), - fp_holdoff_update => fp_holdoff_update, - wave_seq_len => wave_seq_len, + diag_peek_sel => diag_peek_sel, + diag_peek_addr => diag_peek_addr, + diag_peek_data => diag_peek_data_int(i), + diag_peek_rdptr => diag_peek_rdptr_int(i), + diag_peek_wrptr => diag_peek_wrptr_int(i), + diag_peek_wdata => diag_peek_wdata, + diag_peek_wr => diag_peek_wr, - diag_word_count => diag_word_count_int(i) - ); + fire_req => fire_req, -- Was used for drop detect, but drop now signalled explicitly + drop_stripe => buf_active_int(0)(i) and drop_stripe_d, -- 1 clock delayed so that buf_active is already valid when pulsed + sequencers_busy => sequencers_busy_int(i), + last_stripe_dropped => last_stripe_dropped(i), + fp_holdoff_update => fp_holdoff_update, + wave_seq_len => wave_seq_len, + + diag_word_count => diag_word_count_int(i) + ); end generate; end generate; diff --git a/generic_ip/pulse_generator/5/src/pulse_generator_5.vhd b/generic_ip/pulse_generator/5/src/pulse_generator_5.vhd index 6969cab..f69ac22 100644 --- a/generic_ip/pulse_generator/5/src/pulse_generator_5.vhd +++ b/generic_ip/pulse_generator/5/src/pulse_generator_5.vhd @@ -6,8 +6,8 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2016-10-24 --- Last update: 2021-04-12 --- SVN ID : Git +-- Last update: 2023-01-30 +-- SVN ID : Git -- Standard : VHDL'93 ------------------------------------------------------------------------------- -- Description: @@ -51,6 +51,8 @@ entity pulse_generator_5 is enc_vel : in std_logic_vector(19 downto 0) := (others => '0'); enc_speed_meas_w : out std_logic_vector(19 downto 0); dp_dir : out std_logic; + hd_leadng_edge_rev : out std_logic; -- Head will print with rear nozzles first (e.g. dcba cs abcd) + pg_vecb_spare : out std_logic_vector(7 downto 1); -- spare bits output from the pg sequencer vector B fire_req_vec : out std_logic_vector(31 downto 0); start_of_image_vec : out std_logic_vector(31 downto 0); stream_busy_a : in std_logic := '0'; @@ -92,7 +94,7 @@ architecture rtl of pulse_generator_5 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"00000303"; + constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000501"; constant TOF_COMP_LUT_DEPTH : natural := 512; constant TOF_COMP_LUT_WIDTH : natural := 16; @@ -128,7 +130,7 @@ architecture rtl of pulse_generator_5 is signal wh_apply_corr_en_d, wh_corr_start, wh_skip_corr : std_logic; signal wh_img_2nd_half, wh_img_2nd_half_d : std_logic; signal selected_pulse, selected_pulse_d, clr_pd_queue : std_logic; - signal zero_gap_mode, start_image_flag : std_logic; + signal zero_gap_mode, start_image_flag, start_image_flag_early : std_logic; signal use_ch_offset_dir1, add_ppc_regs, add_tof_comp_regs : std_logic; signal add_delay_eq_reg, add_diag_reg : std_logic; -- @@ -137,45 +139,47 @@ architecture rtl of pulse_generator_5 is signal wh_corr_ready_v, ch_ctrl_trigger_in : std_logic_vector(5 downto 0); signal avs_addr : std_logic_vector(4 downto 0); signal subpix_phase_cnt, subpixel_phase_num : std_logic_vector(5 downto 0); + signal has_subpix_phases : std_logic; signal init_v : std_logic_vector(7 downto 0); signal ch_ctrl_start_addr, bpe_top : std_logic_vector(7 downto 0); signal ch_ctrl_address : std_logic_vector(7 downto 0); signal tof_lut_wr_addr, tof_lut_addr : std_logic_vector(8 downto 0); - signal wh_rotat_cnt, gnd_16 : std_logic_vector(15 downto 0); - signal wh_loop_filt_tot, wh_loop_filt_delta : std_logic_vector(15 downto 0); - signal ch_delay, ch_delay_i : std_logic_vector(15 downto 0); - signal enc_speed_norm_coeff, tof_lut_wr_data : std_logic_vector(15 downto 0); - signal tof_lut_wr_q, tof_lut_comp : std_logic_vector(15 downto 0); - signal tof_lut_comp_i : std_logic_vector(15 downto 0); - signal pd_cnt : std_logic_vector(15 downto 0); - signal enc_speed_meas_w_i, enc_vel_i : std_logic_vector(19 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 wh_skip_corr_thres : std_logic_vector(23 downto 0); - signal wh_img_pixel_cnt, wh_image_pixel_len : std_logic_vector(23 downto 0); - signal basic_pos_error_sat : std_logic_vector(23 downto 0); - signal fire_req_cnt : std_logic_vector(23 downto 0); - signal norm_enc_vel : std_logic_vector(35 downto 0); - signal ch_offset, 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, basic_pos_error : std_logic_vector(31 downto 0); - signal seq_bus_data, spit_nco, spit_nco_inc : std_logic_vector(31 downto 0); - signal start_pos, abs_pos_d : std_logic_vector(31 downto 0); - signal subpix_phase : std_logic_vector(31 downto 0); - signal wh_pos_err_2_corr : std_logic_vector(31 downto 0); - signal wh_pos_err_max, wh_pos_err_min : std_logic_vector(31 downto 0); - signal wh_pos_err, wh_pos_err_curr : std_logic_vector(31 downto 0); - signal wh_pos_err_old, wh_pos_err_abs : std_logic_vector(31 downto 0); - signal wh_tot_err, wh_delta_err : std_logic_vector(31 downto 0); - signal div_ratio, div_ratio_i : std_logic_vector(33 downto 0); - signal div_ratio_corr, div_ratio_corr_new : std_logic_vector(33 downto 0); - signal wh_loop_err_delta, wh_loop_err_tot : std_logic_vector(47 downto 0); - signal pos_error, wh_loop_err : std_logic_vector(47 downto 0); - signal div_ratio_corr_ext : std_logic_vector(63 downto 0); + signal wh_rotat_cnt, gnd_16 : std_logic_vector(15 downto 0); + signal wh_loop_filt_tot, wh_loop_filt_delta : std_logic_vector(15 downto 0); + signal ch_delay, ch_delay_i : std_logic_vector(15 downto 0); + signal enc_speed_norm_coeff, tof_lut_wr_data : std_logic_vector(15 downto 0); + signal tof_lut_wr_q, tof_lut_comp : std_logic_vector(15 downto 0); + signal tof_lut_comp_i : std_logic_vector(15 downto 0); + signal pd_cnt : std_logic_vector(15 downto 0); + signal enc_speed_meas_w_i, enc_vel_i : std_logic_vector(19 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_ctrl_vector_b_out : std_logic_vector(7 downto 0); + signal wh_skip_corr_thres : std_logic_vector(23 downto 0); + signal wh_img_pixel_cnt, wh_image_pixel_len : std_logic_vector(23 downto 0); + signal basic_pos_error_sat : std_logic_vector(23 downto 0); + signal fire_req_cnt : std_logic_vector(23 downto 0); + signal norm_enc_vel : std_logic_vector(35 downto 0); + signal ch_offset, 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, basic_pos_error : std_logic_vector(31 downto 0); + signal seq_bus_data, spit_nco, spit_nco_inc : std_logic_vector(31 downto 0); + signal start_pos, abs_pos_d : std_logic_vector(31 downto 0); + signal subpix_phase : std_logic_vector(31 downto 0); + signal wh_pos_err_2_corr : std_logic_vector(31 downto 0); + signal wh_pos_err_max, wh_pos_err_min : std_logic_vector(31 downto 0); + signal wh_pos_err, wh_pos_err_curr : std_logic_vector(31 downto 0); + signal wh_pos_err_old, wh_pos_err_abs : std_logic_vector(31 downto 0); + signal wh_tot_err, wh_delta_err : std_logic_vector(31 downto 0); + signal div_ratio, div_ratio_i : std_logic_vector(33 downto 0); + signal div_ratio_corr, div_ratio_corr_new : std_logic_vector(33 downto 0); + signal wh_loop_err_delta, wh_loop_err_tot : std_logic_vector(47 downto 0); + signal pos_error, wh_loop_err : std_logic_vector(47 downto 0); + signal div_ratio_corr_ext : std_logic_vector(63 downto 0); begin @@ -192,7 +196,7 @@ 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 = '1' and close_to_zero = '1' and signed(abs_position) < signed(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'; close_to_zero <= '1' when abs_position(31 downto 30) = "00" or abs_position(31 downto 30) = "11" else '0'; @@ -310,6 +314,8 @@ begin dp_dir_i <= ch_ctrl_vector_out(0); end if; dp_dir_d <= dp_dir_i; + hd_leadng_edge_rev <= ch_ctrl_vector_b_out(0); + pg_vecb_spare <= ch_ctrl_vector_b_out(7 downto 1); end if; end process pDIR_CHG; @@ -331,6 +337,7 @@ begin generic map( -- @suppress "Generic map uses default values. Missing optional actuals: RAMP_WIDTH, DEVICE_FAMILY" TRIGGER_WIDTH => 6, VECTOR_WIDTH => 24, + VECTOR_WIDTHB => 8, BUS_WIDTH => 32, POS_WIDTH => 32, SEQ_DEPTH => 256, @@ -360,6 +367,7 @@ begin pos_in => abs_position, busy => ch_ctrl_busy, vector_out => ch_ctrl_vector_out, + vector_out_b => ch_ctrl_vector_b_out, bus_data => seq_bus_data, bus_valid => seq_bus_valid, bus_ack => '1'); @@ -403,12 +411,28 @@ begin if (start_img = '1' and (fire_enable = '0' or zero_gap_mode = '1')) then pixel_cnt <= (others => '0'); elsif (fire_enable = '1' and new_pixel = '1') then - pixel_cnt <= std_logic_vector(unsigned(pixel_cnt) + 1); + if (start_image_flag_early = '1') then + pixel_cnt <= (others => '0'); + else + pixel_cnt <= std_logic_vector(unsigned(pixel_cnt) + 1); + end if; end if; - if (init = '1' or enable = '0' or new_pixel = '1') then - start_image_flag <= '0'; + if (init = '1' or enable = '0') then + start_image_flag_early <= '0'; + start_image_flag <= '0'; + elsif new_pixel = '1' then + start_image_flag <= start_image_flag_early or start_img; + start_image_flag_early <= '0'; elsif (start_img = '1') then - start_image_flag <= '1'; + -- starting a merge so FPM req vector will not line up with pd. So delay pd till next full sequence + -- The second pd could come in when the fire pulse phase is non zero. e.g. Fire pulse phases + -- 15->32 could be associated with start of second image. But 0->14 would never be signalled + -- as start of image. delay start image flag until just before fire pulse phase 0. + if fire_enable = '1' and has_subpix_phases = '1' then -- already running, make sure to wait for next sub pixel cycle + start_image_flag_early <= '1'; + else + start_image_flag <= '1'; + end if; end if; end if; end process pGEN_IMAGE; @@ -599,7 +623,7 @@ begin end generate gNOT_PP_CORR_GEN; - + ----------------------------------------------------------------------------- -- Spitting logic @@ -632,7 +656,7 @@ begin end generate gSPIT_LOGIC; ----------------------------------------------------------------------------- - -- Pulse Gating + -- Pulse Gating ----------------------------------------------------------------------------- gated_pulse <= div_pulse and ch_mask_i and enable_out; @@ -722,12 +746,17 @@ begin else start_of_image_vec <= (others => '0'); end if; + if unsigned(subpixel_phase_num) > 1 then + has_subpix_phases <= '1'; + else + has_subpix_phases <= '0'; + end if; end if; end process pSUBPIXEL_GEN; - -- new pixel flag is asserted on the last phase of the pixel. + -- new pixel flag is asserted on the last phase of the pixel. new_pixel <= '1' when subpix_phase_cnt = subpixel_phase_num else '0'; - + --fire_req_vec <= (0 => fire_req, others => '0'); --start_of_image_vec <= (0 => start_of_image, others => '0'); @@ -747,7 +776,7 @@ begin -- waste resources with the 2's complement). -- Note: you don't really care to know whether the encoder speed -- matches the direction used for generating fire-request, because - -- fire-request are not generated in the wrong direction + -- fire-request are not generated in the wrong direction if (enc_vel(enc_vel'left) = '1') then enc_vel_i <= not enc_vel; else @@ -873,7 +902,7 @@ begin ch_ctrl_writedata <= avs_writedata; ch_ctrl_csr_writedata <= avs_writedata; tof_lut_wr_data <= avs_writedata(tof_lut_wr_data'range); - + pINIT : process(clk) begin @@ -898,7 +927,7 @@ begin -- Clock and reset clk => clk, rst_n => reset_n, - + -- auto-generated -- Internal signal ports @@ -950,7 +979,7 @@ begin pixel_pitch_pos_err_min => wh_pos_err_min, pixel_pitch_div_ratio_corr => div_ratio_corr(31 downto 0), pixel_pitch_corr_cnt => wh_rotat_cnt, - + -- end auto-generated -- Slave bus port diff --git a/generic_ip/pulse_generator/6/src/pulse_generator_6.vhd b/generic_ip/pulse_generator/6/src/pulse_generator_6.vhd index 82d51d2..2b4fcd6 100644 --- a/generic_ip/pulse_generator/6/src/pulse_generator_6.vhd +++ b/generic_ip/pulse_generator/6/src/pulse_generator_6.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2016-10-24 --- Last update: 2021-04-12 +-- Last update: 2023-01-30 -- SVN ID : Git -- Standard : VHDL'93 ------------------------------------------------------------------------------- @@ -53,6 +53,8 @@ entity pulse_generator_6 is enc_vel : in std_logic_vector(19 downto 0) := (others => '0'); enc_speed_meas_w : out std_logic_vector(19 downto 0); dp_dir : out std_logic; + hd_leadng_edge_rev : out std_logic; -- Head will print with rear nozzles first (e.g. dcba cs abcd) + pg_vecb_spare : out std_logic_vector(7 downto 1); -- spare bits output from the pg sequencer vector B fire_req_vec : out std_logic_vector(31 downto 0); start_of_image_vec : out std_logic_vector(31 downto 0); stream_busy_a : in std_logic := '0'; @@ -94,7 +96,7 @@ architecture rtl of pulse_generator_6 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"00000303"; + constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000601"; constant TOF_COMP_LUT_DEPTH : natural := 512; constant TOF_COMP_LUT_WIDTH : natural := 16; @@ -130,7 +132,7 @@ architecture rtl of pulse_generator_6 is signal wh_apply_corr_en_d, wh_corr_start, wh_skip_corr : std_logic; signal wh_img_2nd_half, wh_img_2nd_half_d : std_logic; signal selected_pulse, selected_pulse_d, clr_pd_queue : std_logic; - signal zero_gap_mode, start_image_flag : std_logic; + signal zero_gap_mode, start_image_flag, start_image_flag_early : std_logic; signal use_ch_offset_dir1, add_ppc_regs, add_tof_comp_regs : std_logic; signal add_delay_eq_reg, add_diag_reg : std_logic; -- @@ -139,6 +141,7 @@ architecture rtl of pulse_generator_6 is signal wh_corr_ready_v, ch_ctrl_trigger_in : std_logic_vector( 5 downto 0); signal avs_addr : std_logic_vector( 4 downto 0); signal subpix_phase_cnt, subpixel_phase_num : std_logic_vector( 5 downto 0); + signal has_subpix_phases : std_logic; signal init_v : std_logic_vector( 7 downto 0); signal ch_ctrl_start_addr, bpe_top : std_logic_vector( 7 downto 0); signal ch_ctrl_address : std_logic_vector( 7 downto 0); @@ -153,6 +156,7 @@ architecture rtl of pulse_generator_6 is signal enc_speed_meas_w_i, enc_vel_i : std_logic_vector(19 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_ctrl_vector_b_out : std_logic_vector(7 downto 0); signal wh_skip_corr_thres : std_logic_vector(23 downto 0); signal wh_img_pixel_cnt, wh_image_pixel_len : std_logic_vector(23 downto 0); signal basic_pos_error_sat : std_logic_vector(23 downto 0); @@ -193,33 +197,33 @@ 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 + 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; @@ -240,11 +244,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; @@ -258,7 +262,7 @@ begin QUEUE_SIZE => 2*PD_QUEUE_SIZE, DEVICE_FAMILY => DEVICE_FAMILY ) - port map ( + port map( rstN => reset_n, clk => clk, init => init_qd, @@ -272,7 +276,7 @@ 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; - gBYDIR_CH_OFF: if BIDIR_CH_OFFSET_EN = true generate + gBYDIR_CH_OFF : if BIDIR_CH_OFFSET_EN = true generate use_ch_offset_dir1 <= '1'; @@ -285,9 +289,9 @@ begin -- channel offset selection pCH_OFF_SEL : process(clk) begin - if(clk = '1' and clk'event) then - if(use_ch_offset_dir1 = '1') then - if(dp_dir_i = '0') then + if (clk = '1' and clk'event) then + if (use_ch_offset_dir1 = '1') then + if (dp_dir_i = '0') then ch_offset <= ch_offset_dir0; else ch_offset <= ch_offset_dir1; @@ -306,14 +310,16 @@ begin pDIR_CHG : process(clk) begin - if(clk = '1' and clk'event) then - init_qd <= not enable or init or dir_change or clr_pd_queue or wh_corr_start; - if(bypass_ch_ctrl = '1') then + if (clk = '1' and clk'event) then + init_qd <= not enable or init or dir_change or clr_pd_queue or wh_corr_start; + if (bypass_ch_ctrl = '1') then dp_dir_i <= sw_ctrl_dp_dir; else dp_dir_i <= ch_ctrl_vector_out(0); end if; dp_dir_d <= dp_dir_i; + hd_leadng_edge_rev <= ch_ctrl_vector_b_out(0); + pg_vecb_spare <= ch_ctrl_vector_b_out(7 downto 1); end if; end process pDIR_CHG; @@ -335,8 +341,9 @@ begin generic map ( TRIGGER_WIDTH => 6, VECTOR_WIDTH => 24, + VECTOR_WIDTHB => 8, BUS_WIDTH => 32, - POS_WIDTH => 24, + POS_WIDTH => 32, SEQ_DEPTH => 256, ADD_VEC_PIPE => false, VECT_CPU_EN => false, @@ -347,28 +354,29 @@ begin QUEUE_EN => false, DEVICE_FAMILY => DEVICE_FAMILY ) - 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, + busy => ch_ctrl_busy, + vector_out => ch_ctrl_vector_out, + vector_out_b => ch_ctrl_vector_b_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), 4 => (not stream_busy_a), 5 => (not stream_busy_b)); @@ -386,42 +394,58 @@ begin zero_gap_mode <= ch_ctrl_vector_out(7); 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' or zero_gap_mode = '1')) then - pixel_cnt <= (others => '0'); - elsif(fire_enable = '1' and new_pixel = '1') then - pixel_cnt <= std_logic_vector(unsigned(pixel_cnt)+1); + pixel_cnt <= (others => '0'); + elsif (fire_enable = '1' and new_pixel = '1') then + if (start_image_flag_early = '1') then + pixel_cnt <= (others => '0'); + else + pixel_cnt <= std_logic_vector(unsigned(pixel_cnt) + 1); + end if; end if; - if(init = '1' or enable = '0' or new_pixel = '1') then - start_image_flag <= '0'; - elsif(start_img = '1') then - start_image_flag <= '1'; + if (init = '1' or enable = '0') then + start_image_flag_early <= '0'; + start_image_flag <= '0'; + elsif new_pixel = '1' then + start_image_flag <= start_image_flag_early or start_img; + start_image_flag_early <= '0'; + elsif (start_img = '1') then + -- starting a merge so FPM req vector will not line up with pd. So delay pd till next full sequence + -- The second pd could come in when the fire pulse phase is non zero. e.g. Fire pulse phases + -- 15->32 could be associated with start of second image. But 0->14 would never be signalled + -- as start of image. delay start image flag until just before fire pulse phase 0. + if fire_enable = '1' and has_subpix_phases = '1' then -- already running, make sure to wait for next sub pixel cycle + start_image_flag_early <= '1'; + else + start_image_flag <= '1'; + end if; end if; end if; end process pGEN_IMAGE; start_of_image <= start_image_flag and fire_req; - 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'; ----------------------------------------------------------------------------- @@ -452,7 +476,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); @@ -467,101 +491,101 @@ begin -- W&H Div-Ratio Correction for Flexo/CI cylinders ----------------------------------------------------------------------------- - gPP_CORR_GEN: if PIXEL_PITCH_CORR_EN = true generate + gPP_CORR_GEN : if PIXEL_PITCH_CORR_EN = true generate add_ppc_regs <= '1'; pDIV_RATIO_CORR : process(clk) begin - if(clk = '1' and clk'event) then + if (clk = '1' and clk'event) then -- latch the absolute-position to prevent excessive degradation of timing - abs_pos_d <= abs_position; - if(init_wh = '1' or wh_img_end = '1') then + abs_pos_d <= abs_position; + if (init_wh = '1' or wh_img_end = '1') then wh_img_pixel_cnt <= (others => '0'); - elsif(fire_enable = '1' and div_pulse = '1') then - wh_img_pixel_cnt <= std_logic_vector(unsigned(wh_img_pixel_cnt)+1); + elsif (fire_enable = '1' and div_pulse = '1') then + wh_img_pixel_cnt <= std_logic_vector(unsigned(wh_img_pixel_cnt) + 1); end if; - loc_pd_d <= loc_pd; + loc_pd_d <= loc_pd; wh_apply_corr_en_d <= wh_apply_corr_en; - init_wh <= init or (not enable) or (not wh_apply_corr_en); - if(init_wh = '1') then + init_wh <= init or (not enable) or (not wh_apply_corr_en); + if (init_wh = '1') then div_ratio_corr <= (others => '0'); - elsif(wh_corr_ready = '1' and wh_skip_corr = '0') then - div_ratio_corr <= std_logic_vector(signed(div_ratio_corr)+signed(div_ratio_corr_new)); + elsif (wh_corr_ready = '1' and wh_skip_corr = '0') then + div_ratio_corr <= std_logic_vector(signed(div_ratio_corr) + signed(div_ratio_corr_new)); end if; - div_ratio_i <= std_logic_vector(signed(div_ratio)+signed(div_ratio_corr)); - wh_img_2nd_half_d <= wh_img_2nd_half; - if(init_wh = '1' or wh_skip_corr = '1') then + div_ratio_i <= std_logic_vector(signed(div_ratio) + signed(div_ratio_corr)); + wh_img_2nd_half_d <= wh_img_2nd_half; + if (init_wh = '1' or wh_skip_corr = '1') then first_img_started <= '0'; - elsif(wh_img_2nd_half = '1' and wh_img_2nd_half_d = '0') then + elsif (wh_img_2nd_half = '1' and wh_img_2nd_half_d = '0') then first_img_started <= '1'; end if; - if(init_wh = '1' or wh_skip_corr = '1') then + if (init_wh = '1' or wh_skip_corr = '1') then wh_error_meas_started <= '0'; - elsif(wh_meas_event = '1' and first_img_started = '1') then + elsif (wh_meas_event = '1' and first_img_started = '1') then wh_error_meas_started <= not wh_error_meas_started; end if; - if(wh_meas_event = '1' and wh_error_meas_started = '0') then + if (wh_meas_event = '1' and wh_error_meas_started = '0') then start_pos <= abs_pos_d; end if; - if((loc_pd_d and wh_img_end) = '1' or wh_skip_corr = '1') then + if ((loc_pd_d and wh_img_end) = '1' or wh_skip_corr = '1') then basic_pos_error <= (others => '0'); - elsif(wh_meas_event = '1' and wh_error_meas_started = '1') then - if(loc_pd_d = '1') then - basic_pos_error <= std_logic_vector(resize(signed(abs_pos_d)-signed(start_pos), basic_pos_error'length)); + elsif (wh_meas_event = '1' and wh_error_meas_started = '1') then + if (loc_pd_d = '1') then + basic_pos_error <= std_logic_vector(resize(signed(abs_pos_d) - signed(start_pos), basic_pos_error'length)); else - basic_pos_error <= std_logic_vector(resize(signed(start_pos)-signed(abs_pos_d), basic_pos_error'length)); + basic_pos_error <= std_logic_vector(resize(signed(start_pos) - signed(abs_pos_d), basic_pos_error'length)); end if; end if; - if(wh_error_meas_started = '1' and (loc_pd_d or wh_img_end) = '1') then + if (wh_error_meas_started = '1' and (loc_pd_d or wh_img_end) = '1') then wh_error_meas_avail <= '1'; else wh_error_meas_avail <= '0'; end if; - wh_corr_ready_v <= wh_corr_ready_v(wh_corr_ready_v'left-1 downto 0) & wh_error_meas_avail; - pos_error <= std_logic_vector(signed(basic_pos_error_sat & 24x"0") - signed(div_ratio)); - if(init_wh = '1' or wh_skip_corr = '1') then + wh_corr_ready_v <= wh_corr_ready_v(wh_corr_ready_v'left - 1 downto 0) & wh_error_meas_avail; + pos_error <= std_logic_vector(signed(basic_pos_error_sat & 24x"0") - signed(div_ratio)); + if (init_wh = '1' or wh_skip_corr = '1') then wh_pos_err_old <= (others => '0'); - elsif(wh_corr_ready_v(0) = '1') then + elsif (wh_corr_ready_v(0) = '1') then wh_pos_err_old <= wh_pos_err; end if; - wh_loop_err_delta <= std_logic_vector(signed(wh_delta_err)*signed(wh_loop_filt_delta)); - wh_loop_err_tot <= std_logic_vector(signed(wh_tot_err)*signed(wh_loop_filt_tot)); - wh_loop_err <= std_logic_vector(signed(wh_loop_err_delta)+signed(wh_loop_err_tot)); - if(wh_corr_ready_v(2) = '1') then - div_ratio_corr_ext <= std_logic_vector(signed(wh_loop_err(wh_loop_err'left-8 downto 8))*signed(wh_pos_err_2_corr)); + wh_loop_err_delta <= std_logic_vector(signed(wh_delta_err) * signed(wh_loop_filt_delta)); + wh_loop_err_tot <= std_logic_vector(signed(wh_tot_err) * signed(wh_loop_filt_tot)); + wh_loop_err <= std_logic_vector(signed(wh_loop_err_delta) + signed(wh_loop_err_tot)); + if (wh_corr_ready_v(2) = '1') then + div_ratio_corr_ext <= std_logic_vector(signed(wh_loop_err(wh_loop_err'left - 8 downto 8)) * signed(wh_pos_err_2_corr)); end if; -- Compute the absolute value of the position-error. Use a simple 1's -- complement if you need to do sign inversion - if(wh_pos_err(wh_pos_err'left) = '1') then + if (wh_pos_err(wh_pos_err'left) = '1') then wh_pos_err_abs <= not wh_pos_err; else wh_pos_err_abs <= wh_pos_err; end if; - if(init_wh = '1') then + if (init_wh = '1') then wh_pos_err_curr <= (others => '0'); - elsif(wh_corr_ready_v(0) = '1') then + elsif (wh_corr_ready_v(0) = '1') then wh_pos_err_curr <= wh_pos_err; end if; - if(wh_corr_ready_v(1) = '1' and unsigned(wh_pos_err_abs) > unsigned(wh_skip_corr_thres & X"00") and first_img_started = '1') then + if (wh_corr_ready_v(1) = '1' and unsigned(wh_pos_err_abs) > unsigned(wh_skip_corr_thres & X"00") and first_img_started = '1') then wh_skip_corr <= '1'; - elsif(loc_pd = '1') then + elsif (loc_pd = '1') then wh_skip_corr <= '0'; end if; - if(init_wh = '1') then + if (init_wh = '1') then wh_pos_err_max <= (others => '0'); - elsif(wh_corr_ready = '1' and signed(wh_pos_err) > signed(wh_pos_err_max)) then + elsif (wh_corr_ready = '1' and signed(wh_pos_err) > signed(wh_pos_err_max)) then wh_pos_err_max <= wh_pos_err; end if; - if(init_wh = '1') then + if (init_wh = '1') then wh_pos_err_min <= (others => '0'); - elsif(wh_corr_ready = '1' and signed(wh_pos_err) < signed(wh_pos_err_min)) then + elsif (wh_corr_ready = '1' and signed(wh_pos_err) < signed(wh_pos_err_min)) then wh_pos_err_min <= wh_pos_err; end if; - if(init_wh = '1') then + if (init_wh = '1') then wh_rotat_cnt <= (others => '0'); - elsif(wh_corr_ready = '1') then - wh_rotat_cnt <= std_logic_vector(unsigned(wh_rotat_cnt)+1); + elsif (wh_corr_ready = '1') then + wh_rotat_cnt <= std_logic_vector(unsigned(wh_rotat_cnt) + 1); end if; end if; end process pDIV_RATIO_CORR; @@ -574,26 +598,26 @@ begin wh_meas_event <= loc_pd_d xor wh_img_end; - div_ratio_corr_new <= std_logic_vector(resize(signed(div_ratio_corr_ext(div_ratio_corr_ext'left downto 16)),div_ratio'length)); + div_ratio_corr_new <= std_logic_vector(resize(signed(div_ratio_corr_ext(div_ratio_corr_ext'left downto 16)), div_ratio'length)); wh_corr_ready <= wh_corr_ready_v(wh_corr_ready_v'left); -- saturate the basic position error when exceeding the size of a 24-bits -- signed number - bpe_top <= basic_pos_error(31 downto 24); + bpe_top <= basic_pos_error(31 downto 24); basic_pos_error_sat <= basic_pos_error(23 downto 0) when (signed(bpe_top) = 0 or signed(bpe_top) = -1) else X"7FFFFF" when signed(bpe_top) > 0 else X"800000"; -- No need to use 24 bits mantissa for pos_error, 8 bits are plenty wh_pos_err <= pos_error(pos_error'left downto 16); - wh_tot_err <= wh_pos_err; - wh_delta_err <= std_logic_vector(signed(wh_pos_err)-signed(wh_pos_err_old)); + wh_tot_err <= wh_pos_err; + wh_delta_err <= std_logic_vector(signed(wh_pos_err) - signed(wh_pos_err_old)); end generate gPP_CORR_GEN; - gNOT_PP_CORR_GEN: if PIXEL_PITCH_CORR_EN = false generate + gNOT_PP_CORR_GEN : if PIXEL_PITCH_CORR_EN = false generate - add_ppc_regs <= '0'; + add_ppc_regs <= '0'; -- div_ratio_i <= div_ratio; div_ratio_corr <= (others => '0'); @@ -611,22 +635,22 @@ begin -- Spitting logic ----------------------------------------------------------------------------- - gSPIT_LOGIC: if SPITTING_EN generate + gSPIT_LOGIC : if SPITTING_EN generate 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; @@ -675,7 +699,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 add_delay_eq_reg <= '0'; @@ -687,8 +711,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 selected_pulse <= gated_pulse; else selected_pulse <= retimed_pulse; @@ -709,27 +733,32 @@ begin pSUBPIXEL_GEN : process(clk) variable first_pixel : std_logic; begin - if(clk = '1' and clk'event) then - if(fire_enable = '0' or new_pixel = '1') then + if (clk = '1' and clk'event) then + if (fire_enable = '0' or new_pixel = '1') then subpix_phase_cnt <= (others => '0'); - elsif(fire_req = '1') then - subpix_phase_cnt <= std_logic_vector(unsigned(subpix_phase_cnt)+1); + elsif (fire_req = '1') then + subpix_phase_cnt <= std_logic_vector(unsigned(subpix_phase_cnt) + 1); end if; - if(fire_enable = '0' or new_pixel = '1') then + if (fire_enable = '0' or new_pixel = '1') then subpix_phase <= (0 => '1', others => '0'); - elsif(fire_req = '1') then + elsif (fire_req = '1') then subpix_phase <= subpix_phase(30 downto 0) & subpix_phase(31); end if; - if(fire_req = '1') then + if (fire_req = '1') then fire_req_vec <= subpix_phase; else fire_req_vec <= (others => '0'); end if; - if(fire_req = '1' and start_image_flag = '1') then + if (fire_req = '1' and start_image_flag = '1') then start_of_image_vec <= subpix_phase; else start_of_image_vec <= (others => '0'); end if; + if unsigned(subpixel_phase_num) > 1 then + has_subpix_phases <= '1'; + else + has_subpix_phases <= '0'; + end if; end if; end process pSUBPIXEL_GEN; @@ -744,35 +773,35 @@ begin -- Time-of-Flight Compensation ----------------------------------------------------------------------------- - gTOF_COMP_GEN: if TOF_COMP_EN = true and PULSE_DELAY_EQUAL_EN = true generate + gTOF_COMP_GEN : if TOF_COMP_EN = true and PULSE_DELAY_EQUAL_EN = true generate add_tof_comp_regs <= '1'; pTOF_COMP : process(clk) begin - if(clk = '1' and clk'event) then + if (clk = '1' and clk'event) then -- if the encoder speed is negative, do a 1's complement (no need to -- waste resources with the 2's complement). -- Note: you don't really care to know whether the encoder speed -- matches the direction used for generating fire-request, because -- fire-request are not generated in the wrong direction - if(enc_vel(enc_vel'left) = '1') then + if (enc_vel(enc_vel'left) = '1') then enc_vel_i <= not enc_vel; else enc_vel_i <= enc_vel; end if; - if(tof_saturation = '1') then + if (tof_saturation = '1') then tof_lut_addr <= (others => '1'); else - tof_lut_addr <= norm_enc_vel(norm_enc_vel'left-19 downto (norm_enc_vel'left-19-tof_lut_addr'left)); + tof_lut_addr <= norm_enc_vel(norm_enc_vel'left - 19 downto (norm_enc_vel'left - 19 - tof_lut_addr'left)); end if; - if(init or (not enable) or (not tof_comp_enable)) then + if (init or (not enable) or (not tof_comp_enable)) then tof_sat_flag <= '0'; - elsif(tof_saturation = '1') then + elsif (tof_saturation = '1') then tof_sat_flag <= '1'; end if; - ch_delay_i <= std_logic_vector(unsigned(ch_delay)+unsigned(tof_lut_comp)); - if(tof_comp_enable = '1') then + ch_delay_i <= std_logic_vector(unsigned(ch_delay) + unsigned(tof_lut_comp)); + if (tof_comp_enable = '1') then tof_lut_comp <= tof_lut_comp_i; else tof_lut_comp <= (others => '0'); @@ -780,31 +809,31 @@ begin end if; end process pTOF_COMP; - norm_enc_vel <= std_logic_vector(unsigned(enc_vel_i)*unsigned(enc_speed_norm_coeff)); + norm_enc_vel <= std_logic_vector(unsigned(enc_vel_i) * unsigned(enc_speed_norm_coeff)); - tof_saturation <= '1' when unsigned(norm_enc_vel(norm_enc_vel'left downto norm_enc_vel'left-18)) /= 0 else '0'; + tof_saturation <= '1' when unsigned(norm_enc_vel(norm_enc_vel'left downto norm_enc_vel'left - 18)) /= 0 else '0'; --iTOF_COMP_LUT : entity work.dpram_sclk iTOF_COMP_LUT : dpram_sclk - generic map ( - DATA_WIDTH => TOF_COMP_LUT_WIDTH, - ADDR_WIDTH => log2(TOF_COMP_LUT_DEPTH)) - port map ( - clk => clk, - addr_a => tof_lut_wr_addr, - we_a => tof_lut_wr_en, - data_a => tof_lut_wr_data, - q_a => tof_lut_wr_q, - addr_b => tof_lut_addr, - we_b => '0', - data_b => gnd_16, - q_b => tof_lut_comp_i); + generic map( + DATA_WIDTH => TOF_COMP_LUT_WIDTH, + ADDR_WIDTH => log2(TOF_COMP_LUT_DEPTH)) + port map( + clk => clk, + addr_a => tof_lut_wr_addr, + we_a => tof_lut_wr_en, + data_a => tof_lut_wr_data, + q_a => tof_lut_wr_q, + addr_b => tof_lut_addr, + we_b => '0', + data_b => gnd_16, + q_b => tof_lut_comp_i); gnd_16 <= (others => '0'); end generate gTOF_COMP_GEN; - gTOF_COMP_NOGEN: if TOF_COMP_EN = false or PULSE_DELAY_EQUAL_EN = false generate + gTOF_COMP_NOGEN : if TOF_COMP_EN = false or PULSE_DELAY_EQUAL_EN = false generate add_tof_comp_regs <= '0'; @@ -821,23 +850,23 @@ begin ----------------------------------------------------------------------------- - gDIAG_CNT: if DIAG_COUNTERS = true generate + gDIAG_CNT : if DIAG_COUNTERS = true generate add_diag_reg <= '1'; pEdgeDetect_Cnt : process(clk) begin - if(clk = '1' and clk'event) then + if (clk = '1' and clk'event) then loc_pd_dd <= loc_pd; - if(init = '1' or enable = '0' or rst_diag_regs = '1') then + if (init = '1' or enable = '0' or rst_diag_regs = '1') then pd_cnt <= (others => '0'); - elsif(loc_pd = '1' and loc_pd_dd = '0') then - pd_cnt <= std_logic_vector(unsigned(pd_cnt)+1); + elsif (loc_pd = '1' and loc_pd_dd = '0') then + pd_cnt <= std_logic_vector(unsigned(pd_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(new_pixel = '1') then - fire_req_cnt <= std_logic_vector(unsigned(fire_req_cnt)+1); + elsif (new_pixel = '1') then + fire_req_cnt <= std_logic_vector(unsigned(fire_req_cnt) + 1); end if; end if; end process pEdgeDetect_Cnt; @@ -848,7 +877,7 @@ begin end generate gDIAG_CNT; - gNOT_DIAG_CNT: if DIAG_COUNTERS = false generate + gNOT_DIAG_CNT : if DIAG_COUNTERS = false generate pd_cnt <= (others => '0'); fire_req_cnt <= (others => '0'); @@ -868,15 +897,15 @@ begin ch_ctrl_csr_write <= '1' when avs_write = '1' and avs_address(10 downto 5) = "000001" else '0'; tof_lut_wr_en <= '1' when avs_write = '1' and avs_address(10 downto 9) = "10" else '0'; - avs_read_i <= '1' when avs_read = '1' and avs_address(10 downto 9) = "00" else '0'; - ch_ctrl_read <= '1' when avs_read = '1' and avs_address(10 downto 9) = "01" else '0'; - ch_ctrl_csr_read <= '1' when avs_read = '1' and avs_address(10 downto 5) = "000001" else '0'; + avs_read_i <= '1' when avs_read = '1' and avs_address(10 downto 9) = "00" else '0'; + ch_ctrl_read <= '1' when avs_read = '1' and avs_address(10 downto 9) = "01" else '0'; + ch_ctrl_csr_read <= '1' when avs_read = '1' and avs_address(10 downto 5) = "000001" 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); - tof_lut_wr_addr <= avs_address(tof_lut_wr_addr'range); + tof_lut_wr_addr <= avs_address(tof_lut_wr_addr'range); ch_ctrl_writedata <= avs_writedata; ch_ctrl_csr_writedata <= avs_writedata; @@ -885,8 +914,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); @@ -899,75 +928,75 @@ begin enc_speed_meas_w <= enc_speed_meas_w_i; pulse_generator_csr_regs_i : entity work.pulse_generator_6_csr_regs - generic map ( - ADDR_DECODE_WIDTH => 5 - ) - port map ( - -- Clock and reset - clk => clk, - rst_n => reset_n, + generic map( + ADDR_DECODE_WIDTH => 5 + ) + port map( + -- Clock and reset + clk => clk, + rst_n => reset_n, - -- auto-generated + -- auto-generated - -- Internal signal ports - pulse_gen_control_w_enable => enable_i, - pulse_gen_control_w_bypass_channel_controller => bypass_ch_ctrl, - pulse_gen_control_w_bypass_delay_equalizer => bypass_delay_equal, - pulse_gen_control_w_sw_control_dp_dir => sw_ctrl_dp_dir, - pulse_gen_control_w_wh_apply_corr_en => wh_apply_corr_en, - pulse_gen_control_w_pp_apply_corr_en => open, - pulse_gen_control_w_tof_comp_enable => tof_comp_enable, - pulse_gen_control_w_enable_output => enable_out, - pulse_gen_control_w_trigger_abort_fire => abort_fire, - pulse_gen_control_w_reset_diag_regs => rst_diag_regs, - pd_offset_dir_0 => ch_offset_dir0, - pd_offset_dir_1 => ch_offset_dir1, - channel_delay => ch_delay, - channel_controller_control_w_sequencer_start_address => ch_ctrl_start_addr, - fractional_divider_control_enable => frac_div_en_i, - fractional_divider_control_udp_max_pos => upd_max_pos_i, - fractional_divider_control_udp_min_pos => upd_min_pos_i, - divider_ratio_int => div_ratio(33 downto 24), - divider_ratio_fraction => div_ratio(23 downto 0), - subpixel_phase_num => subpixel_phase_num, - enc_speed_meas_window => enc_speed_meas_w_i, - tof_compensation_w_enc_speed_norm => enc_speed_norm_coeff, - pixel_pitch_corr_stripe_num => wh_image_pixel_len, - pixel_pitch_pos_err_2_corr => wh_pos_err_2_corr, - pixel_pitch_skip_corr_thres => wh_skip_corr_thres, - pixel_pitch_loop_filter_corr_delta_error_coeff => wh_loop_filt_delta, - pixel_pitch_loop_filter_corr_tot_error_coeff => wh_loop_filt_tot, - pulse_gen_control_w_clr_pd_queue => clr_pd_queue, - channel_controller_control_w_start_seq_trigger => ch_ctrl_start_req_ii, - pulse_gen_control_r_pd_queue_error_flag => pd_queue_error, - pulse_gen_control_r_delay_equalizer_error_flag => de_queue_error, - pulse_gen_control_r_ch_mask_status => ch_mask_i, - pulse_gen_control_r_fire_enable_status => fire_enable, - pulse_gen_control_r_dual_phase_directionality_select_status => dp_dir_i, - pulse_gen_control_r_tof_sat_flag => tof_sat_flag, - channel_controller_control_r_busy => ch_ctrl_busy, - abs_position_max => abs_pos_max, - abs_position_min => abs_pos_min, - abs_position => abs_position, - pd_counter => pd_cnt, - fire_req_counter => fire_req_cnt, - enc_speed => enc_vel, - tof_compensation_r_tof_lut_comp => tof_lut_comp, - pixel_pitch_pos_err_curr => wh_pos_err_curr, - pixel_pitch_pos_err_max => wh_pos_err_max, - pixel_pitch_pos_err_min => wh_pos_err_min, - pixel_pitch_div_ratio_corr => div_ratio_corr(31 downto 0), - pixel_pitch_corr_cnt => wh_rotat_cnt, + -- Internal signal ports + pulse_gen_control_w_enable => enable_i, + pulse_gen_control_w_bypass_channel_controller => bypass_ch_ctrl, + pulse_gen_control_w_bypass_delay_equalizer => bypass_delay_equal, + pulse_gen_control_w_sw_control_dp_dir => sw_ctrl_dp_dir, + pulse_gen_control_w_wh_apply_corr_en => wh_apply_corr_en, + pulse_gen_control_w_pp_apply_corr_en => open, + pulse_gen_control_w_tof_comp_enable => tof_comp_enable, + pulse_gen_control_w_enable_output => enable_out, + pulse_gen_control_w_trigger_abort_fire => abort_fire, + pulse_gen_control_w_reset_diag_regs => rst_diag_regs, + pd_offset_dir_0 => ch_offset_dir0, + pd_offset_dir_1 => ch_offset_dir1, + channel_delay => ch_delay, + channel_controller_control_w_sequencer_start_address => ch_ctrl_start_addr, + fractional_divider_control_enable => frac_div_en_i, + fractional_divider_control_udp_max_pos => upd_max_pos_i, + fractional_divider_control_udp_min_pos => upd_min_pos_i, + divider_ratio_int => div_ratio(33 downto 24), + divider_ratio_fraction => div_ratio(23 downto 0), + subpixel_phase_num => subpixel_phase_num, + enc_speed_meas_window => enc_speed_meas_w_i, + tof_compensation_w_enc_speed_norm => enc_speed_norm_coeff, + pixel_pitch_corr_stripe_num => wh_image_pixel_len, + pixel_pitch_pos_err_2_corr => wh_pos_err_2_corr, + pixel_pitch_skip_corr_thres => wh_skip_corr_thres, + pixel_pitch_loop_filter_corr_delta_error_coeff => wh_loop_filt_delta, + pixel_pitch_loop_filter_corr_tot_error_coeff => wh_loop_filt_tot, + pulse_gen_control_w_clr_pd_queue => clr_pd_queue, + channel_controller_control_w_start_seq_trigger => ch_ctrl_start_req_ii, + pulse_gen_control_r_pd_queue_error_flag => pd_queue_error, + pulse_gen_control_r_delay_equalizer_error_flag => de_queue_error, + pulse_gen_control_r_ch_mask_status => ch_mask_i, + pulse_gen_control_r_fire_enable_status => fire_enable, + pulse_gen_control_r_dual_phase_directionality_select_status => dp_dir_i, + pulse_gen_control_r_tof_sat_flag => tof_sat_flag, + channel_controller_control_r_busy => ch_ctrl_busy, + abs_position_max => abs_pos_max, + abs_position_min => abs_pos_min, + abs_position => abs_position, + pd_counter => pd_cnt, + fire_req_counter => fire_req_cnt, + enc_speed => enc_vel, + tof_compensation_r_tof_lut_comp => tof_lut_comp, + pixel_pitch_pos_err_curr => wh_pos_err_curr, + pixel_pitch_pos_err_max => wh_pos_err_max, + pixel_pitch_pos_err_min => wh_pos_err_min, + pixel_pitch_div_ratio_corr => div_ratio_corr(31 downto 0), + pixel_pitch_corr_cnt => wh_rotat_cnt, - -- end auto-generated + -- end auto-generated - -- Slave bus port - avs_address => avs_addr(4 downto 0), - avs_write => avs_write_i, - avs_writedata => avs_writedata, - avs_read => avs_read_i, - avs_readdata => avs_readdata_i - ); + -- Slave bus port + avs_address => avs_addr(4 downto 0), + avs_write => avs_write_i, + avs_writedata => avs_writedata, + avs_read => avs_read_i, + avs_readdata => avs_readdata_i + ); avs_readdata <= avs_readdata_i when avs_address(10 downto 5) = "000000" else ch_ctrl_csr_readdata when avs_address(10 downto 5) = "000001" else