diff --git a/generic_ip/fire_pulse_manager/2/src/fire_pulse_manager_2.vhd b/generic_ip/fire_pulse_manager/2/src/fire_pulse_manager_2.vhd index baf794e..1b95b9d 100644 --- a/generic_ip/fire_pulse_manager/2/src/fire_pulse_manager_2.vhd +++ b/generic_ip/fire_pulse_manager/2/src/fire_pulse_manager_2.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2017-09-06 --- Last update: 2019-07-22 +-- Last update: 2019-08-02 -- SVN ID : Git -- Standard : VHDL'08 ------------------------------------------------------------------------------- @@ -139,7 +139,8 @@ architecture rtl of fire_pulse_manager_2 is signal fire_pulse_i : std_logic; signal fire_req : std_logic; signal src_sel : std_logic_vector( 1 downto 0); - signal vel_meas : std_logic_vector(14 downto 0); + signal vel_meas : std_logic_vector(19 downto 0); + signal vel_sampling_per : std_logic_vector(19 downto 0); -- signal one_pps : std_logic; signal log_data_src : std_logic_vector(31 downto 0); @@ -284,15 +285,14 @@ begin ----------------------------------------------------------------------------- -- Used for Time-of-Flight Compensation - iVEL: entity work.simple_enc_vel_detect - generic map ( - SAMPLING_PERIOD => VEL_MEAS_PERIOD) + iVEL : entity work.simple_enc_vel_detect port map ( - clk => clk, - init => init, - step_pos => inc_pos, - step_neg => dec_pos, - vel_meas => vel_meas); + clk => clk, + init => init, + step_pos => inc_pos, + step_neg => dec_pos, + sampling_period => vel_sampling_per, + vel_meas => vel_meas); ----------------------------------------------------------------------------- -- Pulse Generator @@ -309,6 +309,7 @@ begin pd_in => pd_pulse, abs_position => abs_pos, enc_vel => vel_meas, + enc_speed_meas_w => vel_sampling_per, dp_dir => dp_dir, pulse_out => ch_pulse_out, filtered_pd => filtered_pd, diff --git a/generic_ip/fire_pulse_manager/2/src/simple_enc_vel_detect.vhd b/generic_ip/fire_pulse_manager/2/src/simple_enc_vel_detect.vhd index 7c13686..ce05534 100644 --- a/generic_ip/fire_pulse_manager/2/src/simple_enc_vel_detect.vhd +++ b/generic_ip/fire_pulse_manager/2/src/simple_enc_vel_detect.vhd @@ -6,13 +6,14 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2019-06-18 --- Last update: 2019-07-22 +-- Last update: 2019-08-02 -- SVN ID : Git -- Standard : VHDL'2008 ------------------------------------------------------------------------------- -- Description: -- This block detects encoder velocity by measuring the balance of encoder --- positive and negative steps over consecutive sampling periods. +-- positive and negative steps over consecutive sampling periods. +-- The sampling period is supposed to be less than 2 ms ------------------------------------------------------------------------------- -- altera vhdl_input_version vhdl_2008 @@ -22,24 +23,23 @@ use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity simple_enc_vel_detect is - generic(SAMPLING_PERIOD : natural range 0 to 16383 := 10000); -- 10000 => 10 us @100MHz clock port ( - clk : in std_logic; -- Must be 100 MHz - init : in std_logic; - step_pos : in std_logic; - step_neg : in std_logic; - vel_meas : out std_logic_vector(14 downto 0)); - + clk : in std_logic; -- Must be 100 MHz + init : in std_logic; + step_pos : in std_logic; + step_neg : in std_logic; + sampling_period : in std_logic_vector(19 downto 0); + vel_meas : out std_logic_vector(19 downto 0)); end simple_enc_vel_detect; architecture RTL of simple_enc_vel_detect is signal init_i, sampling_pulse : std_logic; - signal sampling_per_cnt : std_logic_vector(13 downto 0); - signal vel_meas_i : std_logic_vector(14 downto 0); - signal vel_meas_sat_pos : std_logic_vector(14 downto 0); - signal vel_meas_sat_neg : std_logic_vector(14 downto 0); + signal sampling_per_cnt : std_logic_vector(19 downto 0); + signal vel_meas_i : std_logic_vector(19 downto 0); + signal vel_meas_sat_pos : std_logic_vector(19 downto 0); + signal vel_meas_sat_neg : std_logic_vector(19 downto 0); begin -- RTL @@ -67,7 +67,7 @@ begin -- RTL end if; end process pVEL_DETECT; - sampling_pulse <= '1' when unsigned(sampling_per_cnt) = SAMPLING_PERIOD-1 else '0'; + sampling_pulse <= '1' when unsigned(sampling_per_cnt) = unsigned(sampling_period)-1 else '0'; -- define positive and negative saturation thresholds vel_meas_sat_pos <= (vel_meas_i'left => '0', others => '1'); diff --git a/generic_ip/pulse_generator/2/doc/pulse_generator_2.json b/generic_ip/pulse_generator/2/doc/pulse_generator_2.json index fc0a048..fdcc359 100644 --- a/generic_ip/pulse_generator/2/doc/pulse_generator_2.json +++ b/generic_ip/pulse_generator/2/doc/pulse_generator_2.json @@ -142,10 +142,28 @@ "bit_len": "1", "reset": "0x0", "description": "Enable WH wheel correction " + }, + "wh_apply_corr_en": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "Enable WH wheel correction " + }, + "tof_comp_enable": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "Enable Time-of-Flight Compensation" + }, + "tof_sat_flag": { + "type": "r", + "bit_len": "1", + "reset": "0x0", + "description": "Asserted when the current encoder velocity value falls outside of the range covered by the ToF compensation LUT. Velocity saturation is therefore applied." }, "reserved_2": { "type": "rsv", - "bit_len": "4", + "bit_len": "2", "description": "" }, "enable_output": { @@ -367,46 +385,30 @@ "width": "32", "description": "Fire-Request counter" }, - "tof_comp_ctrl": { + "enc_speed_meas_window": { "address": "20", - "width": "32", - "description": "Time-of-Flight Compensation Control", - "fields": { - "tof_comp_enable": { - "type": "w", - "bit_len": "1", - "reset": "0x0", - "description": "Enable Time-of-Flight Compensation" - }, - "tof_sat_flag": { - "type": "r", - "bit_len": "1", - "reset": "0x0", - "description": "Asserted when the current encoder velocity value falls outside of the range covered by the ToF compensation LUT. Velocity saturation is therefore applied." - }, - "reserved0": { - "type": "rsv", - "bit_len": "14", - "description": "" - }, - "enc_speed_norm": { - "type": "w", - "bit_len": "16", - "reset": "0x100", - "description": "Encoder Speed Normalization factor: allow to match the encoder-speed range to the address bus width of the ToF Compensation LUT. With the default value (256), an encoder-speed measurement equal to k selects LUT address k)" - } - } + "width": "20", + "type": "w", + "reset": "0x0C350", + "description": "Encoder speed measurement window length [clock cycles @100MHz]" }, - "tof_comp_status": { + "enc_speed": { "address": "21", + "width": "20", + "type": "r", + "reset": "0x0", + "description": "Encoder Velocity: balance between positive and negative encoder steps over the measurement window" + }, + "tof_compensation": { + "address": "22", "width": "32", - "description": "Time-of-Flight Compensation Status", + "description": "Time-of-Flight Compensation", "fields": { - "enc_vel": { - "type": "r", + "enc_speed_norm": { + "type": "w", "bit_len": "16", - "reset": "0x0", - "description": "Encoder Velocity: balance between positive and negative encoder steps over a sampling window of 100 us" + "reset": "0x0100", + "description": "Encoder Speed Normalization factor: allow to match the encoder-speed range to the address bus width of the ToF Compensation LUT. With the default value (256), an encoder-speed measurement equal to k selects LUT address k)" }, "tof_lut_comp": { "type": "r", @@ -418,20 +420,20 @@ }, "pixel_pitch_corr_stripe_num": { "type": "w", - "address": "22", + "address": "23", "reset": "0x00", "width": "24", "description": "Number of stripes to be considered for pixel pitch correction: corresponds to the number of pixels composing the label, head width included)" }, "pixel_pitch_pos_err_2_corr": { "type": "w", - "address": "23", + "address": "24", "reset": "0x00", "width": "32", "description": "Static value used by the logic to compute pixel-pitch correction: need to be set to the number of 2^32/stripe_num, where stripe_num is the value programmed in pixel_pitch_corr_stripe_num" }, "pixel_pitch_loop_filter_corr": { - "address": "24", + "address": "25", "width": "32", "description": "Loop filter coefficient for pixel-pitch correction", "fields": { @@ -451,35 +453,35 @@ }, "pixel_pitch_pos_err_curr": { "type": "r", - "address": "25", + "address": "26", "reset": "0x00", "width": "24", "description": "Pixel-pitch misalignment measured on the last rotation [encoder steps], represented as signed, fixed point with 16-bits integer part and 8-bits mantissa" }, "pixel_pitch_pos_err_max": { "type": "r", - "address": "26", + "address": "27", "reset": "0x00", "width": "24", "description": "Maximum recorded value of pixel-pitch misalignment [encoder steps], represented as signed, fixed point with 16-bits integer part and 8-bits mantissa" }, "pixel_pitch_pos_err_min": { "type": "r", - "address": "27", + "address": "28", "reset": "0x00", "width": "24", "description": "Minimum recorded value of pixel-pitch misalignment [encoder steps], represented as signed, fixed point with 16-bits integer part and 8-bits mantissa" }, "pixel_pitch_div_ratio_corr": { "type": "r", - "address": "28", + "address": "29", "reset": "0x00", "width": "32", "description": "Division-Ratio Correction (32-LSBs)" }, "pixel_pitch_corr_cnt": { "type": "r", - "address": "29", + "address": "30", "reset": "0x00", "width": "16", "description": "Pixel-pitch corrections count" diff --git a/generic_ip/pulse_generator/2/sim/wave_tof_comp.do b/generic_ip/pulse_generator/2/sim/wave_tof_comp.do index 97435fc..0fd5332 100644 --- a/generic_ip/pulse_generator/2/sim/wave_tof_comp.do +++ b/generic_ip/pulse_generator/2/sim/wave_tof_comp.do @@ -22,6 +22,10 @@ add wave -noupdate /tof_comp_tb/avs_s add wave -noupdate /tof_comp_tb/step_pos add wave -noupdate /tof_comp_tb/step_neg add wave -noupdate -radix decimal /tof_comp_tb/vel_meas +add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/tof_lut_addr +add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/tof_lut_comp +add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/ch_delay +add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/ch_delay_i add wave -noupdate /tof_comp_tb/end_of_stimuli add wave -noupdate /tof_comp_tb/test_completed add wave -noupdate /tof_comp_tb/setup @@ -94,11 +98,9 @@ add wave -noupdate /tof_comp_tb/iUUT/avs_read_i add wave -noupdate /tof_comp_tb/iUUT/de_queue_error add wave -noupdate /tof_comp_tb/iUUT/cnt_dir add wave -noupdate /tof_comp_tb/iUUT/dp_dir_i -add wave -noupdate /tof_comp_tb/iUUT/ch_mask_d add wave -noupdate /tof_comp_tb/iUUT/ch_ctrl_start_req_i add wave -noupdate /tof_comp_tb/iUUT/set_first_pd add wave -noupdate /tof_comp_tb/iUUT/pulse_out_ii -add wave -noupdate /tof_comp_tb/iUUT/loc_pulse_out_d add wave -noupdate /tof_comp_tb/iUUT/loc_pulse add wave -noupdate /tof_comp_tb/iUUT/first_pulse add wave -noupdate /tof_comp_tb/iUUT/dp_dir_d @@ -157,8 +159,6 @@ add wave -noupdate /tof_comp_tb/iUUT/wh_error_meas_started add wave -noupdate /tof_comp_tb/iUUT/init_wh add wave -noupdate /tof_comp_tb/iUUT/loc_pd_d add wave -noupdate /tof_comp_tb/iUUT/wh_meas_event -add wave -noupdate /tof_comp_tb/iUUT/ch_mask_fe -add wave -noupdate /tof_comp_tb/iUUT/first_po_started add wave -noupdate /tof_comp_tb/iUUT/tof_lut_wr_en add wave -noupdate /tof_comp_tb/iUUT/tof_comp_enable add wave -noupdate /tof_comp_tb/iUUT/abs_pos_msb_old @@ -199,7 +199,6 @@ add wave -noupdate /tof_comp_tb/iUUT/wh_pos_err_max add wave -noupdate /tof_comp_tb/iUUT/wh_pos_err_old add wave -noupdate /tof_comp_tb/iUUT/wh_tot_err add wave -noupdate /tof_comp_tb/iUUT/wh_delta_err -add wave -noupdate /tof_comp_tb/iUUT/wh_pos_err_abs add wave -noupdate /tof_comp_tb/iUUT/norm_enc_vel add wave -noupdate /tof_comp_tb/iUUT/ch_offset add wave -noupdate -radix decimal /tof_comp_tb/iVEL/vel_meas @@ -268,8 +267,8 @@ add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/int_ add wave -noupdate /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/local_time_d add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/event_time TreeUpdate [SetDefaultTree] -WaveRestoreCursors {{Cursor 1} {2606443 ps} 0} {{Cursor 2} {121098274 ps} 0} -quietly wave cursor active 2 +WaveRestoreCursors {{Cursor 1} {10895000 ps} 0} {{Cursor 2} {121098274 ps} 0} +quietly wave cursor active 1 configure wave -namecolwidth 394 configure wave -valuecolwidth 100 configure wave -justifyvalue left @@ -284,4 +283,4 @@ configure wave -griddelta 40 configure wave -timeline 0 configure wave -timelineunits ps update -WaveRestoreZoom {117661317 ps} {124543957 ps} +WaveRestoreZoom {0 ps} {220244480 ps} diff --git a/generic_ip/pulse_generator/2/src/pulse_generator_2.vhd b/generic_ip/pulse_generator/2/src/pulse_generator_2.vhd index 6abfd1f..3bfd3f7 100644 --- a/generic_ip/pulse_generator/2/src/pulse_generator_2.vhd +++ b/generic_ip/pulse_generator/2/src/pulse_generator_2.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2016-10-24 --- Last update: 2019-07-26 +-- Last update: 2019-08-05 -- SVN ID : Git -- Standard : VHDL'93 ------------------------------------------------------------------------------- @@ -47,7 +47,8 @@ entity pulse_generator_2 is -- Sequencer I/Os pd_in : in std_logic; abs_position : in std_logic_vector(31 downto 0); - enc_vel : in std_logic_vector(14 downto 0) := (others => '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; pulse_out : out std_logic; -- diagnostic outputs @@ -115,7 +116,6 @@ architecture rtl of pulse_generator_2 is 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 enc_vel_i : std_logic_vector(14 downto 0); signal wh_rotat_cnt : std_logic_vector(15 downto 0); signal overdrive_events, overdrive_thres : std_logic_vector(15 downto 0); signal pulse_interval, basic_pos_error : std_logic_vector(15 downto 0); @@ -124,13 +124,14 @@ architecture rtl of pulse_generator_2 is 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 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_pos_err : std_logic_vector(23 downto 0); signal wh_pos_err_max, wh_pos_err_min : std_logic_vector(23 downto 0); signal wh_pos_err_old, wh_tot_err, wh_delta_err : std_logic_vector(23 downto 0); signal wh_img_pixel_cnt, wh_image_pixel_len : std_logic_vector(23 downto 0); - signal norm_enc_vel : std_logic_vector(30 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); @@ -641,7 +642,7 @@ begin if(tof_saturation = '1') then tof_lut_addr <= (others => '1'); else - tof_lut_addr <= norm_enc_vel(norm_enc_vel'left-14 downto (norm_enc_vel'left-14-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 tof_sat_flag <= '0'; @@ -785,6 +786,8 @@ begin enable <= enable_i and not init_v(4); + enc_speed_meas_w <= enc_speed_meas_w_i; + pCTRL_STATUS : process(reset_n, clk) begin if(reset_n = '0') then @@ -821,6 +824,7 @@ begin div_ratio <= (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)); -- wh_apply_corr_en <= '0'; @@ -839,6 +843,7 @@ begin bypass_delay_equal <= avs_writedata(3); sw_ctrl_dp_dir <= avs_writedata(4); wh_apply_corr_en <= avs_writedata(11); + tof_comp_enable <= avs_writedata(12); enable_out <= avs_writedata(16); abort_fire <= avs_writedata(17); rst_diag_regs <= avs_writedata(18); @@ -869,9 +874,10 @@ begin div_offset(33 downto 24) <= avs_writedata( 9 downto 0); when SP_OFFSET_FRAC => div_offset(23 downto 0) <= avs_writedata(23 downto 0); - when TOF_COMP_CTRL_REG => - tof_comp_enable <= avs_writedata(0); - enc_speed_norm_coeff <= avs_writedata(31 downto 16); + when ENC_SPEED_MEAS_W_REG => + enc_speed_meas_w_i <= avs_writedata(19 downto 0); + when TOF_COMPENSATION_REG => + enc_speed_norm_coeff <= avs_writedata(15 downto 0); when WH_PIXEL_NUM => wh_image_pixel_len <= avs_writedata(23 downto 0); when WH_POS_ERR_2_CORR_REG => @@ -894,6 +900,7 @@ begin avs_readdata_i <= CSR_IP_VER; when PULSE_GEN_CTRL_REG => avs_readdata_i(31 downto 8) <= (8 => ch_mask_i, 9 => fire_enable, 10 => dp_dir, 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 & bypass_pulse_cond & bypass_ch_ctrl & enable_i; @@ -932,10 +939,12 @@ begin avs_readdata_i <= pd_in_cnt; when FIRE_REQ_CNT_REG => avs_readdata_i <= fire_req_cnt; - when TOF_COMP_CTRL_REG => - avs_readdata_i <= enc_speed_norm_coeff & 14x"0" & tof_sat_flag & tof_comp_enable; - when TOF_COMP_STATUS_REG => - avs_readdata_i(15 downto 0) <= std_logic_vector(resize(signed(enc_vel),16)); + when ENC_SPEED_MEAS_W_REG => + avs_readdata_i <= X"000" & enc_speed_meas_w_i; + when ENC_SPEED_REG => + avs_readdata_i <= X"000" & enc_vel; + when TOF_COMPENSATION_REG => + avs_readdata_i(15 downto 0) <= enc_speed_norm_coeff; avs_readdata_i(31 downto 16) <= tof_lut_comp; when WH_PIXEL_NUM => avs_readdata_i <= X"00" & wh_image_pixel_len; diff --git a/generic_ip/pulse_generator/2/src/pulse_generator_2_pkg.vhd b/generic_ip/pulse_generator/2/src/pulse_generator_2_pkg.vhd index a03b64d..2a0941f 100644 --- a/generic_ip/pulse_generator/2/src/pulse_generator_2_pkg.vhd +++ b/generic_ip/pulse_generator/2/src/pulse_generator_2_pkg.vhd @@ -6,7 +6,7 @@ -- Author : GMG -- Company : Global Inkjet Systems -- Created : 2018-08-22 --- Last update: 2019-07-26 +-- Last update: 2019-08-02 -- SVN ID : Git -- Standard : VHDL'2008 ------------------------------------------------------------------------------- @@ -41,16 +41,17 @@ package pulse_generator_2_pkg is constant ABS_POS_STAT : std_logic_vector(4 downto 0) := 5x"11"; constant PD_IN_CNT_REG : std_logic_vector(4 downto 0) := 5x"12"; constant FIRE_REQ_CNT_REG : std_logic_vector(4 downto 0) := 5x"13"; - constant TOF_COMP_CTRL_REG : std_logic_vector(4 downto 0) := 5x"14"; - constant TOF_COMP_STATUS_REG : std_logic_vector(4 downto 0) := 5x"15"; - constant WH_PIXEL_NUM : std_logic_vector(4 downto 0) := 5x"16"; - constant WH_POS_ERR_2_CORR_REG : std_logic_vector(4 downto 0) := 5x"17"; - constant WH_LOOP_FILT_COEFF : std_logic_vector(4 downto 0) := 5x"18"; - constant WH_POS_ERR_CURR_REG : std_logic_vector(4 downto 0) := 5x"19"; - constant WH_POS_ERR_MAX_REG : std_logic_vector(4 downto 0) := 5x"1A"; - constant WH_POS_ERR_MIN_REG : std_logic_vector(4 downto 0) := 5x"1B"; - constant WH_DIV_RATIO_CORR_REG : std_logic_vector(4 downto 0) := 5x"1C"; - constant WH_CORR_CNT_REG : std_logic_vector(4 downto 0) := 5x"1D"; + constant ENC_SPEED_MEAS_W_REG : std_logic_vector(4 downto 0) := 5x"14"; + constant ENC_SPEED_REG : std_logic_vector(4 downto 0) := 5x"15"; + constant TOF_COMPENSATION_REG : std_logic_vector(4 downto 0) := 5x"16"; + constant WH_PIXEL_NUM : std_logic_vector(4 downto 0) := 5x"17"; + constant WH_POS_ERR_2_CORR_REG : std_logic_vector(4 downto 0) := 5x"18"; + constant WH_LOOP_FILT_COEFF : std_logic_vector(4 downto 0) := 5x"19"; + constant WH_POS_ERR_CURR_REG : std_logic_vector(4 downto 0) := 5x"1A"; + constant WH_POS_ERR_MAX_REG : std_logic_vector(4 downto 0) := 5x"1B"; + constant WH_POS_ERR_MIN_REG : std_logic_vector(4 downto 0) := 5x"1C"; + constant WH_DIV_RATIO_CORR_REG : std_logic_vector(4 downto 0) := 5x"1D"; + constant WH_CORR_CNT_REG : std_logic_vector(4 downto 0) := 5x"1E"; constant SEQ_CSR_OFFSET : std_logic_vector(10 downto 0) := 11x"20"; constant SEQ_RAM_OFFSET : std_logic_vector(10 downto 0) := 11x"200"; diff --git a/generic_ip/pulse_generator/2/src/test/tof_comp/tof_table_1.cfg b/generic_ip/pulse_generator/2/src/test/tof_comp/tof_table_1.cfg index 8185557..5898407 100644 --- a/generic_ip/pulse_generator/2/src/test/tof_comp/tof_table_1.cfg +++ b/generic_ip/pulse_generator/2/src/test/tof_comp/tof_table_1.cfg @@ -7,6 +7,8 @@ 00000064 00000064 00000064 +00000009 +0000000A 00000064 00000064 00000064 @@ -15,6 +17,8 @@ 00000064 00000064 00000064 +00000013 +00000014 00000064 00000064 00000064 @@ -23,6 +27,8 @@ 00000064 00000064 00000064 +0000001D +0000001E 00000064 00000064 00000064 @@ -31,6 +37,8 @@ 00000064 00000064 00000064 +00000027 +00000028 00000064 00000064 00000064 @@ -39,6 +47,8 @@ 00000064 00000064 00000064 +00000031 +00000032 00000064 00000064 00000064 @@ -47,23 +57,7 @@ 00000064 00000064 00000064 -00000064 -00000064 -00000064 -00000064 -00000064 -00000064 -00000064 -00000064 -00000064 -00000064 -00000064 -00000064 -00000064 -00000064 -00000064 -00000064 -00000064 +0000003C 00000064 00000064 00000064 @@ -510,3 +504,9 @@ 00000064 00000064 00000014 +00000064 +00000064 +00000064 +00000064 +00000064 +00000064 diff --git a/generic_ip/pulse_generator/2/src/test/tof_comp_tb.vhd b/generic_ip/pulse_generator/2/src/test/tof_comp_tb.vhd index 272aca8..6ddb314 100644 --- a/generic_ip/pulse_generator/2/src/test/tof_comp_tb.vhd +++ b/generic_ip/pulse_generator/2/src/test/tof_comp_tb.vhd @@ -6,7 +6,7 @@ -- Author : GMG -- Company : Global Inkjet Systems -- Created : 2019-06-20 --- Last update: 2019-07-03 +-- Last update: 2019-08-05 -- SVN ID : Git -- Standard : VHDL'2008 ------------------------------------------------------------------------------- @@ -82,7 +82,8 @@ architecture behav of tof_comp_tb is -- signal step_pos : std_logic; signal step_neg : std_logic; - signal vel_meas : std_logic_vector(14 downto 0); + signal vel_meas : std_logic_vector(19 downto 0); + signal vel_sampling_per : std_logic_vector(19 downto 0); -- signal end_of_stimuli : boolean; signal test_completed : boolean; @@ -205,9 +206,9 @@ architecture behav of tof_comp_tb is end procedure config_tof_comp_lut; - procedure apply_tof_comp( - tof_enable : std_logic; + procedure setup_tof_comp( enc_speed_norm : natural; + vel_sampl_win : natural := SAMPLING_PERIOD; signal mm_s_rec : in mm_s_rec_t; signal mm_m_rec : out mm_m_rec_t) is @@ -216,18 +217,15 @@ architecture behav of tof_comp_tb is begin - data := (0 => tof_enable, others => '0'); - data(31 downto 16) := std_logic_vector(to_unsigned(enc_speed_norm,16)); - addr := std_logic_vector(resize(unsigned(TOF_COMP_CTRL_REG), 32)); + addr := std_logic_vector(resize(unsigned(ENC_SPEED_MEAS_W_REG), 32)); + data := std_logic_vector(to_unsigned(vel_sampl_win, 32)); mm_32b_write(addr, data, mm_s_rec, mm_m_rec); - if(tof_enable = '0') then - log("ToF Compensation Disabled.", VMEDIUM); - else - log("ToF Compensation Enabled.", VMEDIUM); - end if; + addr := std_logic_vector(resize(unsigned(TOF_COMPENSATION_REG), 32)); + data := x"0000" & std_logic_vector(to_unsigned(enc_speed_norm,16)); + mm_32b_write(addr, data, mm_s_rec, mm_m_rec); - end procedure apply_tof_comp; + end procedure setup_tof_comp; procedure apply_pg_cfg( div_ratio : real; @@ -301,13 +299,19 @@ architecture behav of tof_comp_tb is config_tof_comp_lut(tof_table, mm_s_rec, mm_m_rec); -- apply tof compensation - apply_tof_comp(tof_enable, enc_speed_norm, mm_s_rec, mm_m_rec); + setup_tof_comp(enc_speed_norm, SAMPLING_PERIOD, mm_s_rec, mm_m_rec); -- enable the pulse-generator: bypass_ch_ctrl = '1', addr := std_logic_vector(resize(unsigned(PULSE_GEN_CTRL_REG), 32)); - data := (0 => '1', 1 => '1', 4 => dir, 16 => '1', others => '0'); + data := (0 => '1', 1 => '1', 4 => dir, 12 => tof_enable, 16 => '1', others => '0'); mm_32b_write(addr, data, mm_s_rec, mm_m_rec); + if(tof_enable = '0') then + log("ToF Compensation Disabled.", VMEDIUM); + else + log("ToF Compensation Enabled.", VMEDIUM); + end if; + if(dir = '0') then log("Ch-Ctrl disabled, direction = DIR-0", VMEDIUM); else @@ -341,6 +345,7 @@ begin -- architecture behav pd_in => pd_in, abs_position => abs_position, enc_vel => vel_meas, + enc_speed_meas_w => vel_sampling_per, dp_dir => dp_dir, pulse_out => pulse_out, filtered_pd => filtered_pd, @@ -354,15 +359,14 @@ begin -- architecture behav avs_readdatavalid => avs_readdatavalid, avs_readdata => avs_readdata); - iVEL: entity work.simple_enc_vel_detect - generic map ( - SAMPLING_PERIOD => SAMPLING_PERIOD) + iVEL : entity work.simple_enc_vel_detect port map ( - clk => clk, - init => init, - step_pos => step_pos, - step_neg => step_neg, - vel_meas => vel_meas); + clk => clk, + init => init, + step_pos => step_pos, + step_neg => step_neg, + sampling_period => vel_sampling_per, + vel_meas => vel_meas); ----------------------------------------------------------------------------- -- Avalon interface @@ -607,7 +611,7 @@ begin -- architecture behav delay => 100, dir => '0', tof_enable => '1', - enc_speed_norm => 1024, + enc_speed_norm => 256, mm_s_rec => avs_s, mm_m_rec => avs_m);