From f44f9005127b9b6e3137abd1a75a55afd745cee8 Mon Sep 17 00:00:00 2001 From: Damian Smith Date: Thu, 17 Feb 2022 13:32:21 +0000 Subject: [PATCH 1/3] ELGIP-183 Add in the inline merge fix identified by Dave. Test benches still pass --- .../3/doc/pulse_generator_3.json | 2 +- generic_ip/pulse_generator/3/sim/generate.bat | 2 + .../3/src/pulse_generator_3.vhd | 854 +++++++++--------- 3 files changed, 438 insertions(+), 420 deletions(-) create mode 100644 generic_ip/pulse_generator/3/sim/generate.bat diff --git a/generic_ip/pulse_generator/3/doc/pulse_generator_3.json b/generic_ip/pulse_generator/3/doc/pulse_generator_3.json index 63ed887..9db0947 100644 --- a/generic_ip/pulse_generator/3/doc/pulse_generator_3.json +++ b/generic_ip/pulse_generator/3/doc/pulse_generator_3.json @@ -51,7 +51,7 @@ "minor_number" : { "type" : "c", "bit_len" : "8", - "reset" : "0x03", + "reset" : "0x04", "description" : "Minor number" }, "major_number" : { diff --git a/generic_ip/pulse_generator/3/sim/generate.bat b/generic_ip/pulse_generator/3/sim/generate.bat new file mode 100644 index 0000000..6fd7c83 --- /dev/null +++ b/generic_ip/pulse_generator/3/sim/generate.bat @@ -0,0 +1,2 @@ +python.exe ..\..\..\..\..\fw_development_tools\logic_memory_mapper\gen_hdl.py -b csr seq -s "_auto" -j ..\..\..\generic_sequencer\16\doc\generic_sequencer_16.json -o ..\..\..\generic_sequencer\16\src\ +python.exe ..\..\..\..\..\fw_development_tools\logic_memory_mapper\gen_hdl.py -b csr seq -s "_auto" -j ..\doc\pulse_generator_3.json -o ..\src\ diff --git a/generic_ip/pulse_generator/3/src/pulse_generator_3.vhd b/generic_ip/pulse_generator/3/src/pulse_generator_3.vhd index b365a07..5368ec8 100644 --- a/generic_ip/pulse_generator/3/src/pulse_generator_3.vhd +++ b/generic_ip/pulse_generator/3/src/pulse_generator_3.vhd @@ -34,148 +34,148 @@ use work.pulse_generator_3_pkg.all; entity pulse_generator_3 is generic( - PD_QUEUE_SIZE : natural range 32 to 1024 := 64; - PULSE_DELAY_EQUAL_EN : boolean := true; - SPITTING_EN : boolean := true; - BIDIR_CH_OFFSET_EN : boolean := true; - DIAG_COUNTERS : boolean := true; - TOF_COMP_EN : boolean := false; - PIXEL_PITCH_CORR_EN : boolean := false); + PD_QUEUE_SIZE : natural range 32 to 1024 := 64; + PULSE_DELAY_EQUAL_EN : boolean := true; + SPITTING_EN : boolean := true; + BIDIR_CH_OFFSET_EN : boolean := true; + DIAG_COUNTERS : boolean := true; + TOF_COMP_EN : boolean := false; + PIXEL_PITCH_CORR_EN : boolean := false); 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); - 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; - 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'; - stream_busy_b : in std_logic := '0'; + pd_in : in std_logic; + abs_position : in std_logic_vector(31 downto 0); + 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; + 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'; + stream_busy_b : in std_logic := '0'; -- diagnostic outputs - filtered_pd : out std_logic; - ch_pd : out std_logic; - ch_mask : out std_logic; - raw_fire_req : out std_logic; - enc_pulse : out std_logic; + filtered_pd : out std_logic; + ch_pd : out std_logic; + ch_mask : out std_logic; + raw_fire_req : out std_logic; + enc_pulse : out std_logic; ----------------------------------------------------------------------- -- Avalon MM Interface ----------------------------------------------------------------------- - avs_address : in std_logic_vector(10 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(10 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_3; architecture rtl of pulse_generator_3 is component dpram_sclk is - generic ( + generic( DATA_WIDTH : natural; ADDR_WIDTH : natural); - port ( + port( clk : in std_logic; - addr_a : in std_logic_vector(ADDR_WIDTH-1 downto 0); + addr_a : in std_logic_vector(ADDR_WIDTH - 1 downto 0); we_a : in std_logic := '1'; - data_a : in std_logic_vector(DATA_WIDTH-1 downto 0); - q_a : out std_logic_vector(DATA_WIDTH-1 downto 0); - addr_b : in std_logic_vector(ADDR_WIDTH-1 downto 0); + data_a : in std_logic_vector(DATA_WIDTH - 1 downto 0); + q_a : out std_logic_vector(DATA_WIDTH - 1 downto 0); + addr_b : in std_logic_vector(ADDR_WIDTH - 1 downto 0); we_b : in std_logic := '1'; - data_b : in std_logic_vector(DATA_WIDTH-1 downto 0); - q_b : out std_logic_vector(DATA_WIDTH-1 downto 0)); + data_b : in std_logic_vector(DATA_WIDTH - 1 downto 0); + q_b : out std_logic_vector(DATA_WIDTH - 1 downto 0)); end component dpram_sclk; -- 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_ID : std_logic_vector(31 downto 0) := x"0000FF13"; + constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000303"; - signal init_de, init_qd, enable, loc_pd, pd_queue_error : std_logic; - signal ch_ctrl_start_req, pd_pulse, filt_pd, filt_pd_d : std_logic; - signal ch_ctrl_write, ch_ctrl_read, ch_ctrl_busy, enable_i : std_logic; - signal ch_mask_i, bypass_ch_ctrl, bypass_delay_equal : std_logic; - signal div_pulse, gated_pulse, retimed_pulse : std_logic; - signal avs_write_i, avs_read_d, avs_read_i, de_queue_error : std_logic; - signal cnt_dir, dp_dir_i, ch_ctrl_start_req_i : std_logic; - signal set_first_pd : std_logic; - signal dp_dir_d, loc_pd_d, loc_pd_dd : 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; - signal add_img_size, add_img_size_d, abort_fire : std_logic; - signal ch_ctrl_csr_write, ch_ctrl_csr_read, frac_div_en_i : std_logic; - signal upd_max_pos, upd_min_pos, frac_div_en, gen_filt_pd : std_logic; - signal upd_max_pos_i, upd_min_pos_i, dir_change, first_pd : std_logic; - signal pd_in_d, filt_pd_i, abs_pos_lsb, ch_ctrl_start_req_ii : std_logic := '0'; - signal prevent_div_restart, rst_jitter, rst_diag_regs : std_logic; - signal fire_req, start_of_image, new_pixel : std_logic; - signal mid_cross, mid_crossed, zero_cross : std_logic; - signal close_to_zero, close_to_mid : std_logic; - signal div_pulse_i, spitting_enable, spit_pulse : std_logic; - signal seq_bus_valid, spit_nco_msb : std_logic; - signal wh_apply_corr_en, wh_error_meas_avail, wh_corr_ready : std_logic; - signal wh_error_meas_started, init_wh : std_logic; - signal wh_meas_event, wh_img_end, first_img_started : std_logic; - signal tof_lut_wr_en, tof_comp_enable : std_logic; - signal tof_saturation, tof_sat_flag : std_logic; - 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 use_ch_offset_dir1, add_ppc_regs, add_tof_comp_regs : std_logic; - signal add_delay_eq_reg, add_diag_reg : std_logic; + signal init_de, init_qd, enable, loc_pd, pd_queue_error : std_logic; + signal ch_ctrl_start_req, pd_pulse, filt_pd, filt_pd_d : std_logic; + signal ch_ctrl_write, ch_ctrl_read, ch_ctrl_busy, enable_i : std_logic; + signal ch_mask_i, bypass_ch_ctrl, bypass_delay_equal : std_logic; + signal div_pulse, gated_pulse, retimed_pulse : std_logic; + signal avs_write_i, avs_read_d, avs_read_i, de_queue_error : std_logic; + signal cnt_dir, dp_dir_i, ch_ctrl_start_req_i : std_logic; + signal set_first_pd : std_logic; + signal dp_dir_d, loc_pd_d, loc_pd_dd : 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; + signal add_img_size, add_img_size_d, abort_fire : std_logic; + signal ch_ctrl_csr_write, ch_ctrl_csr_read, frac_div_en_i : std_logic; + signal upd_max_pos, upd_min_pos, frac_div_en, gen_filt_pd : std_logic; + signal upd_max_pos_i, upd_min_pos_i, dir_change, first_pd : std_logic; + signal pd_in_d, filt_pd_i, abs_pos_lsb, ch_ctrl_start_req_ii : std_logic := '0'; + signal prevent_div_restart, rst_jitter, rst_diag_regs : std_logic; + signal fire_req, start_of_image, new_pixel : std_logic; + signal mid_cross, mid_crossed, zero_cross : std_logic; + signal close_to_zero, close_to_mid : std_logic; + signal div_pulse_i, spitting_enable, spit_pulse : std_logic; + signal seq_bus_valid, spit_nco_msb : std_logic; + signal wh_apply_corr_en, wh_error_meas_avail, wh_corr_ready : std_logic; + signal wh_error_meas_started, init_wh : std_logic; + signal wh_meas_event, wh_img_end, first_img_started : std_logic; + signal tof_lut_wr_en, tof_comp_enable : std_logic; + signal tof_saturation, tof_sat_flag : std_logic; + 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, 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; -- - signal abs_pos_msb_old : std_logic_vector( 1 downto 0); - signal ch_ctrl_csr_addr : std_logic_vector( 3 downto 0); - 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 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 avs_address_i : std_logic_vector(10 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 abs_pos_msb_old : std_logic_vector(1 downto 0); + signal ch_ctrl_csr_addr : std_logic_vector(3 downto 0); + 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 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 avs_address_i : std_logic_vector(10 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); begin @@ -191,38 +191,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'; @@ -238,11 +238,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; @@ -250,11 +250,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 - generic map ( + iPD_queue : entity work.queue_and_delay + 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, @@ -268,29 +268,29 @@ 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'; else generate - + use_ch_offset_dir1 <= '0'; - + end generate gBYDIR_CH_OFF; -- 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; end if; else ch_offset <= ch_offset_dir0; - end if; + end if; end if; end process pCH_OFF_SEL; @@ -302,9 +302,9 @@ 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); @@ -328,8 +328,8 @@ begin -- - Gating signal (ch_mask) i_channel_control : entity work.generic_sequencer_16 - generic map ( - TRIGGER_WIDTH => 6, + generic map( + TRIGGER_WIDTH => 6, VECTOR_WIDTH => 24, BUS_WIDTH => 32, POS_WIDTH => 24, @@ -341,31 +341,31 @@ begin POS_BUS_EN => true, ALU_EN => false, QUEUE_EN => false) - 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), 4 => (not stream_busy_a), 5 => (not stream_busy_b)); - + ch_mask_i <= fire_enable or ch_ctrl_vector_out(1) or bypass_ch_ctrl; -- output to the monitoring point/event-logger @@ -380,50 +380,66 @@ 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' or new_pixel = '1') then + start_image_flag_early <= '0'; + start_image_flag <= '0'; + if new_pixel = '1' then + start_image_flag <= start_image_flag_early; + end if; + elsif (start_img = '1') then + -- starting a merge so FPM req 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 (stream_busy_a = '1' and stream_busy_b = '1') then + 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'; - + ----------------------------------------------------------------------------- -- Fractional Divider ----------------------------------------------------------------------------- iFracDiv : entity work.simple_frac_div_3 - port map ( + port map( clk => clk, enable => frac_div_en, dir => dp_dir_i, @@ -446,7 +462,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); @@ -461,101 +477,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; @@ -568,26 +584,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'); @@ -605,22 +621,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; @@ -628,14 +644,14 @@ begin spitting_enable <= '0'; spit_pulse <= '0'; - + end generate gSPIT_LOGIC; ----------------------------------------------------------------------------- -- Pulse Gating ----------------------------------------------------------------------------- - gated_pulse <= div_pulse and ch_mask_i and enable_out; + gated_pulse <= div_pulse and ch_mask_i and enable_out; ----------------------------------------------------------------------------- -- Delay Equalization @@ -643,16 +659,16 @@ begin -- compendate for variation in the channel delay when daisy-chaining multiple -- EMBs/HMBs: - gPULSE_DELAY_EQUAL: if PULSE_DELAY_EQUAL_EN = true generate + gPULSE_DELAY_EQUAL : if PULSE_DELAY_EQUAL_EN = true generate add_delay_eq_reg <= '1'; - - iDE: entity work.queue_and_delay - generic map ( + + iDE : entity work.queue_and_delay + generic map( DELAY_WIDTH => 16, USE_EXT_TIME => false, QUEUE_SIZE => 256) - port map ( + port map( rstN => reset_n, clk => clk, init => init_de, @@ -667,7 +683,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'; @@ -679,8 +695,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; @@ -701,27 +717,27 @@ 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; + end if; end if; end process pSUBPIXEL_GEN; @@ -736,35 +752,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'); @@ -772,40 +788,40 @@ 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'; - + ch_delay_i <= ch_delay; tof_sat_flag <= '0'; tof_lut_wr_q <= (others => '0'); - tof_lut_comp <= (others => '0'); - + tof_lut_comp <= (others => '0'); + end generate gTOF_COMP_NOGEN; ----------------------------------------------------------------------------- @@ -813,23 +829,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; @@ -840,11 +856,11 @@ 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'); - + end generate gNOT_DIAG_CNT; ----------------------------------------------------------------------------- @@ -860,15 +876,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; @@ -877,8 +893,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); @@ -892,139 +908,139 @@ 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_delay_equal <= '0'; - sw_ctrl_dp_dir <= '0'; - enable_out <= '0'; - abort_fire <= '0'; - clr_pd_queue <= '0'; + enable_i <= '0'; + bypass_ch_ctrl <= '0'; + bypass_delay_equal <= '0'; + sw_ctrl_dp_dir <= '0'; + enable_out <= '0'; + abort_fire <= '0'; + clr_pd_queue <= '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'; -- - div_ratio <= (others => '0'); - subpixel_phase_num <= (0 => '1', others => '0'); + div_ratio <= (others => '0'); + subpixel_phase_num <= (0 => '1', others => '0'); -- tof_comp_enable <= '0'; - enc_speed_meas_w_i <= std_logic_vector(to_unsigned(50000,20)); - enc_speed_norm_coeff <= std_logic_vector(to_unsigned(256,16)); + enc_speed_meas_w_i <= std_logic_vector(to_unsigned(50000, 20)); + enc_speed_norm_coeff <= std_logic_vector(to_unsigned(256, 16)); -- - wh_apply_corr_en <= '0'; - wh_image_pixel_len <= (others => '0'); - wh_pos_err_2_corr <= (others => '0'); - wh_skip_corr_thres <= (22 => '1', others => '0'); - wh_loop_filt_delta <= std_logic_vector(to_signed(256, 16)); - wh_loop_filt_tot <= std_logic_vector(to_signed(256, 16)); - elsif(clk = '1' and clk'event) then + wh_apply_corr_en <= '0'; + wh_image_pixel_len <= (others => '0'); + wh_pos_err_2_corr <= (others => '0'); + wh_skip_corr_thres <= (22 => '1', others => '0'); + wh_loop_filt_delta <= std_logic_vector(to_signed(256, 16)); + wh_loop_filt_tot <= std_logic_vector(to_signed(256, 16)); + elsif (clk = '1' and clk'event) then clr_pd_queue <= '0'; ch_ctrl_start_req_ii <= '0'; -- CTRL registers - if(avs_write_i = '1' and avs_address(9 downto 5) = "00000") then + if (avs_write_i = '1' and avs_address(9 downto 5) = "00000") then case avs_addr is when PULSE_GEN_CTRL_REG => - enable_i <= avs_writedata(0); - bypass_ch_ctrl <= avs_writedata(1); - bypass_delay_equal <= avs_writedata(3); - sw_ctrl_dp_dir <= avs_writedata(4); - if(add_ppc_regs = '1') then - wh_apply_corr_en <= avs_writedata(11); + enable_i <= avs_writedata(0); + bypass_ch_ctrl <= avs_writedata(1); + bypass_delay_equal <= avs_writedata(3); + sw_ctrl_dp_dir <= avs_writedata(4); + if (add_ppc_regs = '1') then + wh_apply_corr_en <= avs_writedata(11); end if; - if(add_tof_comp_regs = '1') then - tof_comp_enable <= avs_writedata(12); + if (add_tof_comp_regs = '1') then + tof_comp_enable <= avs_writedata(12); end if; - enable_out <= avs_writedata(16); - abort_fire <= avs_writedata(17); - rst_diag_regs <= avs_writedata(18); - clr_pd_queue <= avs_writedata(19); + enable_out <= avs_writedata(16); + abort_fire <= avs_writedata(17); + rst_diag_regs <= avs_writedata(18); + clr_pd_queue <= avs_writedata(19); when CH_OFFSET_D0_REG => - ch_offset_dir0 <= avs_writedata; + ch_offset_dir0 <= avs_writedata; when CH_OFFSET_D1_REG => - if(use_ch_offset_dir1 = '1') then - ch_offset_dir1 <= avs_writedata; + if (use_ch_offset_dir1 = '1') then + ch_offset_dir1 <= avs_writedata; end if; when CH_DELAY_REG => - if(add_delay_eq_reg = '1') then - ch_delay <= avs_writedata(15 downto 0); + if (add_delay_eq_reg = '1') then + ch_delay <= avs_writedata(15 downto 0); end if; 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 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 SUBPIXEL_PHASE_REG => - subpixel_phase_num <= avs_writedata( 5 downto 0); + subpixel_phase_num <= avs_writedata(5 downto 0); when ENC_SPEED_MEAS_W_REG => - if(add_tof_comp_regs = '1') then - enc_speed_meas_w_i <= avs_writedata(19 downto 0); + if (add_tof_comp_regs = '1') then + enc_speed_meas_w_i <= avs_writedata(19 downto 0); end if; when TOF_COMPENSATION_REG => - if(add_tof_comp_regs = '1') then + if (add_tof_comp_regs = '1') then enc_speed_norm_coeff <= avs_writedata(15 downto 0); end if; when WH_PIXEL_NUM => - if(add_ppc_regs = '1') then - wh_image_pixel_len <= avs_writedata(23 downto 0); + if (add_ppc_regs = '1') then + wh_image_pixel_len <= avs_writedata(23 downto 0); end if; when WH_POS_ERR_2_CORR_REG => - if(add_ppc_regs = '1') then - wh_pos_err_2_corr <= avs_writedata; + if (add_ppc_regs = '1') then + wh_pos_err_2_corr <= avs_writedata; end if; when WH_SKIP_CORR_THRES_REG => - if(add_ppc_regs = '1') then - wh_skip_corr_thres <= avs_writedata(23 downto 0); + if (add_ppc_regs = '1') then + wh_skip_corr_thres <= avs_writedata(23 downto 0); end if; when WH_LOOP_FILT_COEFF => - if(add_ppc_regs = '1') then - wh_loop_filt_delta <= avs_writedata(15 downto 0); - wh_loop_filt_tot <= avs_writedata(31 downto 16); + if (add_ppc_regs = '1') then + wh_loop_filt_delta <= avs_writedata(15 downto 0); + wh_loop_filt_tot <= avs_writedata(31 downto 16); end if; 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; when CSR_IP_VER_ADDR => 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, 11 => wh_apply_corr_en, - 12 => tof_comp_enable, 13 => tof_sat_flag, - 16 => enable_out, 17 => abort_fire, 18 => rst_diag_regs, others => '0'); - avs_readdata_i( 7 downto 4) <= '0' & de_queue_error & pd_queue_error & sw_ctrl_dp_dir; - avs_readdata_i( 3 downto 0) <= bypass_delay_equal & '0' & bypass_ch_ctrl & enable_i; - when CH_OFFSET_D0_REG => + avs_readdata_i(31 downto 8) <= (8 => ch_mask_i, 9 => fire_enable, 10 => dp_dir, 11 => wh_apply_corr_en, + 12 => tof_comp_enable, 13 => tof_sat_flag, + 16 => enable_out, 17 => abort_fire, 18 => rst_diag_regs, others => '0'); + avs_readdata_i(7 downto 4) <= '0' & de_queue_error & pd_queue_error & sw_ctrl_dp_dir; + avs_readdata_i(3 downto 0) <= bypass_delay_equal & '0' & bypass_ch_ctrl & enable_i; + when CH_OFFSET_D0_REG => avs_readdata_i <= ch_offset_dir0; when CH_OFFSET_D1_REG => - if(use_ch_offset_dir1 = '1') then + if (use_ch_offset_dir1 = '1') then avs_readdata_i <= ch_offset_dir1; end if; when CH_DELAY_REG => - if(add_delay_eq_reg = '1') then + if (add_delay_eq_reg = '1') then avs_readdata_i <= X"0000" & ch_delay; end if; when CH_CTRL_CTRL_REG => @@ -1044,60 +1060,60 @@ begin when ABS_POS_STAT => avs_readdata_i <= abs_position; when PD_CNT_REG => - if(add_diag_reg = '1') then + if (add_diag_reg = '1') then avs_readdata_i <= X"0000" & pd_cnt; end if; when FIRE_REQ_CNT_REG => - if(add_diag_reg = '1') then + if (add_diag_reg = '1') then avs_readdata_i <= X"00" & fire_req_cnt; end if; when ENC_SPEED_MEAS_W_REG => - if(add_tof_comp_regs = '1') then + if (add_tof_comp_regs = '1') then avs_readdata_i <= X"000" & enc_speed_meas_w_i; end if; when ENC_SPEED_REG => - if(add_tof_comp_regs = '1') then + if (add_tof_comp_regs = '1') then avs_readdata_i <= X"000" & enc_vel; end if; when TOF_COMPENSATION_REG => - if(add_tof_comp_regs = '1') then - avs_readdata_i(15 downto 0) <= enc_speed_norm_coeff; + if (add_tof_comp_regs = '1') then + avs_readdata_i(15 downto 0) <= enc_speed_norm_coeff; avs_readdata_i(31 downto 16) <= tof_lut_comp; end if; when WH_PIXEL_NUM => - if(add_ppc_regs = '1') then + if (add_ppc_regs = '1') then avs_readdata_i <= X"00" & wh_image_pixel_len; end if; when WH_POS_ERR_2_CORR_REG => - if(add_ppc_regs = '1') then + if (add_ppc_regs = '1') then avs_readdata_i <= wh_pos_err_2_corr; end if; when WH_SKIP_CORR_THRES_REG => - if(add_ppc_regs = '1') then + if (add_ppc_regs = '1') then avs_readdata_i <= X"00" & wh_skip_corr_thres; end if; when WH_LOOP_FILT_COEFF => - if(add_ppc_regs = '1') then + if (add_ppc_regs = '1') then avs_readdata_i <= wh_loop_filt_tot & wh_loop_filt_delta; end if; when WH_POS_ERR_CURR_REG => - if(add_ppc_regs = '1') then + if (add_ppc_regs = '1') then avs_readdata_i <= wh_pos_err_curr; end if; when WH_POS_ERR_MAX_REG => - if(add_ppc_regs = '1') then + if (add_ppc_regs = '1') then avs_readdata_i <= wh_pos_err_max; end if; when WH_POS_ERR_MIN_REG => - if(add_ppc_regs = '1') then + if (add_ppc_regs = '1') then avs_readdata_i <= wh_pos_err_min; end if; when WH_DIV_RATIO_CORR_REG => - if(add_ppc_regs = '1') then + if (add_ppc_regs = '1') then avs_readdata_i <= div_ratio_corr(31 downto 0); end if; when WH_CORR_CNT_REG => - if(add_ppc_regs = '1') then + if (add_ppc_regs = '1') then avs_readdata_i <= X"0000" & wh_rotat_cnt; end if; when others => @@ -1106,7 +1122,7 @@ 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 @@ -1121,8 +1137,8 @@ begin avs_readdata <= X"0000" & tof_lut_wr_q; when others => avs_readdata <= X"BAD1BAD0"; - end case?; + end case?; end if; - end process pCTRL_STATUS; + end process pCTRL_STATUS; end architecture rtl; From 577cbdf95c8f5050513a3cad354a137bc9a329cd Mon Sep 17 00:00:00 2001 From: Damian Smith Date: Wed, 23 Feb 2022 11:57:13 +0000 Subject: [PATCH 2/3] ELGIP-183 Corrected the minor version number in logic to version 4 (not autogenerated in this version of product) --- generic_ip/pulse_generator/3/src/pulse_generator_3.vhd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic_ip/pulse_generator/3/src/pulse_generator_3.vhd b/generic_ip/pulse_generator/3/src/pulse_generator_3.vhd index 5368ec8..4b360ba 100644 --- a/generic_ip/pulse_generator/3/src/pulse_generator_3.vhd +++ b/generic_ip/pulse_generator/3/src/pulse_generator_3.vhd @@ -94,7 +94,7 @@ architecture rtl of pulse_generator_3 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"00000304"; signal init_de, init_qd, enable, loc_pd, pd_queue_error : std_logic; signal ch_ctrl_start_req, pd_pulse, filt_pd, filt_pd_d : std_logic; From 82d5a342c22bf1a88642b90e032592e7eedac3b8 Mon Sep 17 00:00:00 2001 From: Damian Smith Date: Wed, 30 Mar 2022 10:59:33 +0100 Subject: [PATCH 3/3] SMB-169 improved description of NCO INC usage --- generic_ip/enc_pd_emul/2/doc/enc_pd_emul_2.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic_ip/enc_pd_emul/2/doc/enc_pd_emul_2.json b/generic_ip/enc_pd_emul/2/doc/enc_pd_emul_2.json index 653db6f..4c36085 100644 --- a/generic_ip/enc_pd_emul/2/doc/enc_pd_emul_2.json +++ b/generic_ip/enc_pd_emul/2/doc/enc_pd_emul_2.json @@ -302,7 +302,7 @@ "address": "6", "reset": "0x0", "width": "32", - "description": "Encoder NCO increment" + "description": "Encoder NCO increment: values in range 0 to 2147483648. Enc period will be 10ns * (2^32)/enc_nco_inc - e.g. increment of d20000 gives period ~2.15ms. increment of x8000000 gives the min period of 20ns (too fast for usage)" }, "enc_pulse_num": { "type": "w",