CORE-662 added comments. Used constants for src_sel indices to improve readability. Rewrote init generation code for better readability.

This commit is contained in:
Damian Smith 2022-04-25 13:55:42 +01:00
commit 981ed17021

View file

@ -126,9 +126,10 @@ architecture rtl of fire_pulse_manager_7 is
signal fine_time : std_logic_vector(27 downto 0);
signal coarse_time : std_logic_vector(31 downto 0);
--
signal init, remote_init : std_logic;
signal init : std_logic; -- strobing this sends init signal over pof_tx. it is also a sort of reset to pd_cnt, simple_enc_vel_detect, pulse_generator, ems, seb_led_gen, smb_diagnostics, dw_pulse
signal remote_init : std_logic;
signal dp_dir : std_logic_vector(CH_NUM - 1 downto 0);
signal set_pos_ie : std_logic;
signal set_pos_ie : std_logic; -- set for internal encoder / encoder emulator
signal enc_pulse : std_logic_vector(CH_NUM - 1 downto 0);
signal pd_pulse : std_logic;
signal pd_pulse_ie : std_logic;
@ -175,8 +176,14 @@ architecture rtl of fire_pulse_manager_7 is
signal ch_start_of_image : fire_pulse_t;
signal ch_pd : std_logic_vector(CH_NUM - 1 downto 0);
signal ch_raw_pulse, ch_mask : std_logic_vector(CH_NUM - 1 downto 0);
signal src_sel : std_logic_vector(3 downto 0);
signal fpm_init : std_logic; -- init signal driven by control register
--
constant SRC_SEL_SEB_EPD_LINKOUT_SEL : integer := 3;
constant SRC_SEL_SEB_EPD_EN : integer := 2;
constant SRC_SEL_ENC_PD_EMUL_EN : integer := 1;
constant SRC_SEL_FIRE_PULSE_SEL : integer := 0;
signal src_sel : std_logic_vector(3 downto 0); -- seb_epd_linkout_sel, seb_epd_en, enc_pd_emul_en, fire_pulse_sel
--
signal fire_pulse_ctrl_init : std_logic; -- init signal driven by control register
--
signal ext_fp_in_sync : std_logic;
signal ext_fp_in : std_logic;
@ -281,7 +288,7 @@ begin
reset_n => reset_n_i,
clk => clk,
fpm_config => fpm_generic_status,
fpm_init => fpm_init,
fpm_init => fire_pulse_ctrl_init,
fpm_init_done => iPOF_TX_init_done,
src_sel => src_sel,
uart_regen_bypass => uart_regen_bypass,
@ -327,14 +334,14 @@ begin
begin
if (clk = '1' and clk'event) then
-- Abs-Pos and PD source selection
if (src_sel(2) = '1') then
if (src_sel(SRC_SEL_SEB_EPD_EN) = '1') then
-- Use SEB-EPD inputs
pd_pulse <= pd_ems;
abs_pos <= abs_pos_ems;
inc_pos <= inc_pos_ems;
dec_pos <= dec_pos_ems;
else
if (src_sel(1) = '0') then
if (src_sel(SRC_SEL_ENC_PD_EMUL_EN) = '0') then
pd_pulse <= pd_pulse_pof;
abs_pos <= abs_pos_pof;
inc_pos <= inc_pos_pof;
@ -351,14 +358,14 @@ begin
gPOF_TX_OUT : if SEB_EPD_MODE = true generate
pof_tx <= dw_pulse when src_sel(3) = '1' else
pof_tx_regen when src_sel(2) = '0' else
pof_tx <= dw_pulse when src_sel(SRC_SEL_SEB_EPD_LINKOUT_SEL) = '1' else
pof_tx_regen when src_sel(SRC_SEL_SEB_EPD_EN) = '0' else
pof_tx_data;
pBUF_SEB_EPD_MODE : process(clk)
begin
if (clk = '1' and clk'event) then
seb_epd_mode_en <= src_sel(2);
seb_epd_mode_en <= src_sel(SRC_SEL_SEB_EPD_EN);
end if;
end process pBUF_SEB_EPD_MODE;
@ -376,7 +383,7 @@ begin
abs_pos_out <= abs_pos;
dp_dir_out <= dp_dir;
for i in 0 to CH_NUM - 1 loop
if (src_sel(0) = '1') then
if (src_sel(SRC_SEL_FIRE_PULSE_SEL) = '1') then
fire_pulse(i * 32 + 31 downto i * 32) <= ch_fire_pulse(i);
start_of_image(i * 32 + 31 downto i * 32) <= ch_start_of_image(i);
else
@ -391,10 +398,18 @@ begin
pINIT_GEN : process(clk)
begin
if (clk = '1' and clk'Event) then
if (src_sel(1) = '0') then
init <= fpm_init or (not src_sel(2) and (not enable_rx or remote_init));
else
init <= fpm_init or set_pos_ie;
init <= '0';
if fire_pulse_ctrl_init = '1' then -- signal from control registers
init <= '1';
elsif src_sel(SRC_SEL_ENC_PD_EMUL_EN) = '1' then -- setting the internal encoder position also re-initialises
init <= set_pos_ie; -- fpm_init_done should be polled by ESW before any further actions to ensure init is complete
elsif src_sel(SRC_SEL_SEB_EPD_EN) = '0' and remote_init = '1' then
-- source is not SEB-EPD (i.e. it's the SEB-PDW RX link) and we received an init signal over the POF RX link (it's a strobe)
init <= '1';
elsif src_sel(SRC_SEL_SEB_EPD_EN) = '0' and enable_rx = '0' then
-- source is not enc_pd_emul and is not SEB-EPD (i.e. it's the SEB-PDW RX link) but the RX link has been disabled
-- FIXME - will this condition hold several systems in reset, but not begin the pof_tx init process?
init <= '1';
end if;
end if;
end process pINIT_GEN;
@ -594,9 +609,9 @@ begin
filt_zp => open,
filt_pd => ems_filt_pd);
pd_pulse_mux <= seb_epd_pd when src_sel(1) = '0' else pd_pulse_ie;
enc_p1_mux <= seb_epd_enc_p1 when src_sel(1) = '0' else enc_p1_ie;
enc_p2_mux <= seb_epd_enc_p2 when src_sel(1) = '0' else enc_p2_ie;
pd_pulse_mux <= seb_epd_pd when src_sel(SRC_SEL_ENC_PD_EMUL_EN) = '0' else pd_pulse_ie;
enc_p1_mux <= seb_epd_enc_p1 when src_sel(SRC_SEL_ENC_PD_EMUL_EN) = '0' else enc_p1_ie;
enc_p2_mux <= seb_epd_enc_p2 when src_sel(SRC_SEL_ENC_PD_EMUL_EN) = '0' else enc_p2_ie;
else generate