WH-17 - Added a VHDL generic for enabling/disabling the instantiation of Pixel-Pitch-Correction logic
This commit is contained in:
parent
f62293b1eb
commit
a3117fea99
2 changed files with 138 additions and 112 deletions
|
|
@ -6,7 +6,7 @@
|
|||
-- Author : Gianmarco Girau
|
||||
-- Company : Global Inkjet Systems
|
||||
-- Created : 2017-09-06
|
||||
-- Last update: 2019-09-27
|
||||
-- Last update: 2019-10-01
|
||||
-- SVN ID : Git
|
||||
-- Standard : VHDL'08
|
||||
-------------------------------------------------------------------------------
|
||||
|
|
@ -300,8 +300,11 @@ begin
|
|||
|
||||
iCH_PG : entity work.pulse_generator_2
|
||||
generic map(
|
||||
pd_queue_size => PD_QUEUE_SIZE,
|
||||
out_pulse_condition => true)
|
||||
PD_QUEUE_SIZE => PD_QUEUE_SIZE,
|
||||
OUT_PULSE_CONDITION => true,
|
||||
OVERDRIVE_CHECK => false,
|
||||
TOF_COMP_EN => true,
|
||||
PIXEL_PITCH_CORR_EN => true)
|
||||
port map(
|
||||
clk => clk,
|
||||
reset_n => reset_n_i,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
-- Author : Gianmarco Girau
|
||||
-- Company : Global Inkjet Systems
|
||||
-- Created : 2016-10-24
|
||||
-- Last update: 2019-09-05
|
||||
-- Last update: 2019-10-01
|
||||
-- SVN ID : Git
|
||||
-- Standard : VHDL'93
|
||||
-------------------------------------------------------------------------------
|
||||
|
|
@ -36,9 +36,10 @@ entity pulse_generator_2 is
|
|||
PD_QUEUE_SIZE : natural range 32 to 1024 := 64;
|
||||
PULSE_DELAY_EQUAL_EN : boolean := true;
|
||||
OUT_PULSE_CONDITION : boolean := true;
|
||||
OVERDRIVE_CHECK : boolean := true;
|
||||
OVERDRIVE_CHECK : boolean := false;
|
||||
DIAG_COUNTERS : boolean := true;
|
||||
TOF_COMP_EN : boolean := true);
|
||||
TOF_COMP_EN : boolean := false;
|
||||
PIXEL_PITCH_CORR_EN : boolean := false);
|
||||
port(
|
||||
clk : in std_logic;
|
||||
reset_n : in std_logic := '1';
|
||||
|
|
@ -73,7 +74,7 @@ architecture rtl of pulse_generator_2 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"00000201";
|
||||
constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000202";
|
||||
|
||||
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;
|
||||
|
|
@ -414,123 +415,141 @@ begin
|
|||
-- W&H Div-Ratio Correction for Flexo/CI cylinders
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
pDIV_RATIO_CORR : process(clk)
|
||||
begin
|
||||
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
|
||||
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);
|
||||
end if;
|
||||
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
|
||||
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));
|
||||
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
|
||||
first_img_started <= '0';
|
||||
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
|
||||
wh_error_meas_started <= '0';
|
||||
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
|
||||
start_pos <= abs_pos_d;
|
||||
end if;
|
||||
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));
|
||||
gPP_CORR_GEN: if PIXEL_PITCH_CORR_EN = true generate
|
||||
|
||||
pDIV_RATIO_CORR : process(clk)
|
||||
begin
|
||||
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
|
||||
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);
|
||||
end if;
|
||||
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
|
||||
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));
|
||||
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
|
||||
first_img_started <= '0';
|
||||
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
|
||||
wh_error_meas_started <= '0';
|
||||
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
|
||||
start_pos <= abs_pos_d;
|
||||
end if;
|
||||
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));
|
||||
else
|
||||
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
|
||||
wh_error_meas_avail <= '1';
|
||||
else
|
||||
basic_pos_error <= std_logic_vector(resize(signed(start_pos)-signed(abs_pos_d), basic_pos_error'length));
|
||||
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_pos_err_old <= (others => '0');
|
||||
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));
|
||||
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
|
||||
wh_pos_err_abs <= not wh_pos_err;
|
||||
else
|
||||
wh_pos_err_abs <= wh_pos_err;
|
||||
end if;
|
||||
if(init_wh = '1') then
|
||||
wh_pos_err_curr <= (others => '0');
|
||||
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
|
||||
wh_skip_corr <= '1';
|
||||
elsif(loc_pd = '1') then
|
||||
wh_skip_corr <= '0';
|
||||
end if;
|
||||
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
|
||||
wh_pos_err_max <= wh_pos_err;
|
||||
end if;
|
||||
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
|
||||
wh_pos_err_min <= wh_pos_err;
|
||||
end if;
|
||||
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);
|
||||
end if;
|
||||
end if;
|
||||
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_pos_err_old <= (others => '0');
|
||||
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));
|
||||
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
|
||||
wh_pos_err_abs <= not wh_pos_err;
|
||||
else
|
||||
wh_pos_err_abs <= wh_pos_err;
|
||||
end if;
|
||||
if(init_wh = '1') then
|
||||
wh_pos_err_curr <= (others => '0');
|
||||
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
|
||||
wh_skip_corr <= '1';
|
||||
elsif(loc_pd = '1') then
|
||||
wh_skip_corr <= '0';
|
||||
end if;
|
||||
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
|
||||
wh_pos_err_max <= wh_pos_err;
|
||||
end if;
|
||||
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
|
||||
wh_pos_err_min <= wh_pos_err;
|
||||
end if;
|
||||
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);
|
||||
end if;
|
||||
end if;
|
||||
end process pDIV_RATIO_CORR;
|
||||
end process pDIV_RATIO_CORR;
|
||||
|
||||
wh_img_end <= '1' when unsigned(wh_img_pixel_cnt) = unsigned(wh_image_pixel_len) else '0';
|
||||
wh_img_end <= '1' when unsigned(wh_img_pixel_cnt) = unsigned(wh_image_pixel_len) else '0';
|
||||
|
||||
wh_img_2nd_half <= '1' when unsigned(wh_img_pixel_cnt) >= unsigned(wh_image_pixel_len(wh_image_pixel_len'left downto 1)) else '0';
|
||||
wh_img_2nd_half <= '1' when unsigned(wh_img_pixel_cnt) >= unsigned(wh_image_pixel_len(wh_image_pixel_len'left downto 1)) else '0';
|
||||
|
||||
wh_corr_start <= wh_apply_corr_en and not wh_apply_corr_en_d;
|
||||
wh_corr_start <= wh_apply_corr_en and not wh_apply_corr_en_d;
|
||||
|
||||
wh_meas_event <= loc_pd_d xor wh_img_end;
|
||||
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);
|
||||
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);
|
||||
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";
|
||||
-- saturate the basic position error when exceeding the size of a 24-bits
|
||||
-- signed number
|
||||
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);
|
||||
-- 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
|
||||
|
||||
div_ratio_i <= div_ratio;
|
||||
div_ratio_corr <= (others => '0');
|
||||
wh_corr_start <= '0';
|
||||
wh_rotat_cnt <= (others => '0');
|
||||
wh_pos_err_curr <= (others => '0');
|
||||
wh_pos_err_min <= (others => '0');
|
||||
wh_pos_err_max <= (others => '0');
|
||||
|
||||
end generate gNOT_PP_CORR_GEN;
|
||||
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Spitting logic
|
||||
|
|
@ -714,6 +733,10 @@ begin
|
|||
gTOF_COMP_NOGEN: if TOF_COMP_EN = false or PULSE_DELAY_EQUAL_EN = false generate
|
||||
|
||||
ch_delay_i <= ch_delay;
|
||||
|
||||
tof_sat_flag <= '0';
|
||||
tof_lut_wr_q <= (others => '0');
|
||||
tof_lut_comp <= (others => '0');
|
||||
|
||||
end generate gTOF_COMP_NOGEN;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue