Revert "HMBFDHV-83 ELGIP-58 changed comments referring to 200MHz. Improved metastability handling in pof_rx, using synchronisers with attributes included to handle CDC. Corrected sensitivity list in uart_regen_1 and added a note on metastability. Put a note in the testbench as it runs at 200MHz rx_clk, but we recommend 300MHz so it is both specific, and not ideal."
This reverts commite21e804433. And also reverts SHA-1:d4f14ab631* HMBFDHV-83 ELGIP-58 New Clock Domain Crossing handshake block to take a register safely across. False Paths declared in sync blocks. bit_div signals synchronised into the blocks using rx_clk to avoid metastability. POF_RX sync/metastability fixed compared to previous mod. Test Bench now has RX_CLK at 300MHz to match expected usage.
This commit is contained in:
parent
ef93cc5e0f
commit
1ef3a2b16c
12 changed files with 374 additions and 557 deletions
|
|
@ -31,18 +31,14 @@ architecture RTL of sync_reset is
|
|||
|
||||
signal sync_rstN_i : std_logic;
|
||||
|
||||
-- declare false path as reset is meant to be applied asynchronously
|
||||
attribute altera_attribute : string;
|
||||
attribute altera_attribute of RTL : architecture is
|
||||
"-name SDC_STATEMENT ""set_false_path -from [get_keepers *] -to [get_keepers {*sync_reset:*sync_rstN*}]"" ";
|
||||
begin
|
||||
|
||||
pSYNC : process(async_rstN, clk)
|
||||
begin
|
||||
if (async_rstN = '0') then
|
||||
if(async_rstN = '0') then
|
||||
sync_rstN_i <= '0';
|
||||
sync_rstN <= '0';
|
||||
elsif (clk = '1' and clk'event) then
|
||||
elsif(clk = '1' and clk'event) then
|
||||
sync_rstN_i <= '1';
|
||||
sync_rstN <= sync_rstN_i;
|
||||
end if;
|
||||
|
|
|
|||
|
|
@ -37,11 +37,11 @@ vcom -2008 -work $WORKLIB $GENERIC_PATH/generic_sequencer/15/src/generic_sequenc
|
|||
vcom -2008 -work $WORKLIB $GENERIC_PATH/generic_sequencer/15/src/generic_sequencer_15.vhd
|
||||
|
||||
# Pulse Generator
|
||||
vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/altera/sync_fifo_1.vhd
|
||||
vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/pulse_generator_1_pkg.vhd
|
||||
vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/pulse_conditioning_1.vhd
|
||||
vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/queue_and_delay_1.vhd
|
||||
vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/simple_frac_div_1.vhd
|
||||
vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/altera/sync_fifo_1.vhd
|
||||
vcom -2008 -work $WORKLIB $GENERIC_PATH/pulse_generator/1/src/pulse_generator_1.vhd
|
||||
|
||||
# Enc PD Emul
|
||||
|
|
@ -51,9 +51,9 @@ vcom -2008 -work $WORKLIB $GENERIC_PATH/enc_pd_emul/1/src/enc_pd_emul_1.vhd
|
|||
# Fire-Pulse-Manager
|
||||
vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_1_pkg.vhd
|
||||
vcom -2008 -work $WORKLIB $SRC_PATH/uart_rx_1.vhd
|
||||
vcom -2008 -work $WORKLIB $SRC_PATH/sync_wire_1.vhd
|
||||
vcom -2008 -work $WORKLIB $SRC_PATH/uart_regen_1.vhd
|
||||
vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_ctrl_1.vhd
|
||||
vcom -2008 -work $WORKLIB $SRC_PATH/sync_wire_1.vhd
|
||||
vcom -2008 -work $WORKLIB $SRC_PATH/sync_wire_rEdge_1.vhd
|
||||
vcom -2008 -work $WORKLIB $SRC_PATH/pof_rx_1.vhd
|
||||
vcom -2008 -work $WORKLIB $SRC_PATH/cs_bus_itf_1.vhd
|
||||
|
|
|
|||
|
|
@ -1,118 +0,0 @@
|
|||
-------------------------------------------------------------------------------
|
||||
-- Allows a strobe-validated word of data to be passed safely between
|
||||
-- two asynchronous clock domains with a handshaking acknowledge strobe.
|
||||
-- Not a FIFO - so saves on an M10K
|
||||
--
|
||||
-- Clock-crossing considerations:
|
||||
-- Data will be sampled on source clock and held until transfer is complete
|
||||
-- Any data arriving in the meantime will be ignored
|
||||
--
|
||||
-- Language build standard requirements:
|
||||
-- VHDL 2008
|
||||
--
|
||||
-- author Damian Smith
|
||||
-- copyright (c) 2019 Global Inkjet Systems
|
||||
-- date 24 May 2019
|
||||
-------------------------------------------------------------------------------
|
||||
-- altera vhdl_input_version vhdl_2008
|
||||
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
|
||||
entity cdc_data_handshake_1 is
|
||||
generic(
|
||||
DATA_WIDTH : positive := 8
|
||||
);
|
||||
port(
|
||||
arst_n : in std_logic; -- will be synchronised to both domains
|
||||
--
|
||||
src_clk : in std_logic;
|
||||
src_valid : in std_logic; -- strobe
|
||||
src_data : in std_logic_vector(DATA_WIDTH - 1 downto 0) := (others => '0');
|
||||
src_ack : out std_logic; -- strobe
|
||||
--
|
||||
dest_clk : in std_logic;
|
||||
dest_valid : out std_logic; -- strobe
|
||||
dest_data : out std_logic_vector(DATA_WIDTH - 1 downto 0)
|
||||
|
||||
);
|
||||
end entity cdc_data_handshake_1;
|
||||
|
||||
architecture rtl of cdc_data_handshake_1 is
|
||||
signal src_rst_n, dest_rst_n : std_logic;
|
||||
signal src_data_reg : std_logic_vector(DATA_WIDTH - 1 downto 0);
|
||||
signal src_valid_reg : std_logic;
|
||||
signal dest_valid_reg : std_logic;
|
||||
signal dest_valid_reg_d : std_logic;
|
||||
signal dest2src_ack : std_logic;
|
||||
signal dest2src_ack_d : std_logic;
|
||||
|
||||
-- declare false path as src_data_reg is sampled only when safe as validated by dest_valid_reg
|
||||
attribute altera_attribute : string;
|
||||
attribute altera_attribute of rtl : architecture is
|
||||
"-name SDC_STATEMENT ""set_false_path -from [get_keepers *] -to [get_keepers {*cdc_data_handshake_1:*dest_data[*]}]"" ";
|
||||
|
||||
begin
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Synchronize the input reset to the clocks
|
||||
-----------------------------------------------------------------------------
|
||||
iSyncReset_src : entity work.sync_reset port map(async_rstN => arst_n, clk => src_clk, sync_rstN => src_rst_n);
|
||||
iSyncReset_dest : entity work.sync_reset port map(async_rstN => arst_n, clk => dest_clk, sync_rstN => dest_rst_n);
|
||||
|
||||
src_proc : process(src_clk, src_rst_n) is
|
||||
begin
|
||||
if src_rst_n = '0' then
|
||||
src_ack <= '0';
|
||||
src_data_reg <= (others => '0');
|
||||
src_valid_reg <= '0';
|
||||
dest2src_ack_d <= '0';
|
||||
elsif rising_edge(src_clk) then
|
||||
src_ack <= '0';
|
||||
|
||||
if src_valid = '1' then
|
||||
src_data_reg <= src_data;
|
||||
src_valid_reg <= '1';
|
||||
|
||||
end if;
|
||||
|
||||
-- stop driving the src2dest signal and give src an ack
|
||||
dest2src_ack_d <= dest2src_ack;
|
||||
if dest2src_ack = '1' and dest2src_ack_d = '0' then
|
||||
src_ack <= '1';
|
||||
src_valid_reg <= '0';
|
||||
end if;
|
||||
end if;
|
||||
end process src_proc;
|
||||
|
||||
--pragma translate_off
|
||||
assert not (src_valid = '1' and src_valid_reg = '1') report "new valid provided to CDC block before previous had completed" severity error;
|
||||
--pragma translate_on
|
||||
|
||||
iSyncWire_src2dest : entity work.sync_wire_1
|
||||
generic map(rst_val => '0', sync_stages => 2)
|
||||
port map(rstN => dest_rst_n, clk => dest_clk, async_in => src_valid_reg, sync_out => dest_valid_reg);
|
||||
|
||||
dest_proc : process(dest_clk, dest_rst_n) is
|
||||
begin
|
||||
if dest_rst_n = '0' then
|
||||
dest_valid <= '0';
|
||||
dest_data <= (others => '0');
|
||||
dest_valid_reg_d <= '0';
|
||||
elsif rising_edge(dest_clk) then
|
||||
dest_valid <= '0';
|
||||
dest_valid_reg_d <= dest_valid_reg;
|
||||
if dest_valid_reg = '1' and dest_valid_reg_d = '0' then
|
||||
dest_data <= src_data_reg;
|
||||
dest_valid <= '1';
|
||||
end if;
|
||||
end if;
|
||||
end process dest_proc;
|
||||
|
||||
iSyncWire_dest2src : entity work.sync_wire_1
|
||||
generic map(rst_val => '0', sync_stages => 2)
|
||||
port map(rstN => src_rst_n, clk => src_clk, async_in => dest_valid_reg, sync_out => dest2src_ack);
|
||||
|
||||
|
||||
end architecture rtl;
|
||||
|
|
@ -22,23 +22,21 @@ entity fire_pulse_ctrl_1 is
|
|||
port(
|
||||
reset_n : in std_logic;
|
||||
clk : in std_logic;
|
||||
src_sel : out std_logic_vector(1 downto 0);
|
||||
|
||||
pof_rx_ctrl_valid : out std_logic;
|
||||
src_sel : out std_logic_vector( 1 downto 0);
|
||||
uart_regen_bypass : out std_logic;
|
||||
upd_max_pos : out std_logic;
|
||||
upd_min_pos : out std_logic;
|
||||
enable_rx : out std_logic;
|
||||
uart_bit_div : out std_logic_vector(3 downto 0);
|
||||
error_rate_thres : out std_logic_vector(7 downto 0);
|
||||
uart_bit_div : out std_logic_vector( 3 downto 0);
|
||||
error_rate_thres : out std_logic_vector( 7 downto 0);
|
||||
max_error_flag : in std_logic;
|
||||
rx_watchdog : in std_logic;
|
||||
rx_watchdog_en : out std_logic;
|
||||
rx_watchdog_clr : out std_logic;
|
||||
parity_err_cnt : in std_logic_vector(15 downto 0);
|
||||
skip_pos_cnt : in std_logic_vector(15 downto 0);
|
||||
mon_point_src : in std_logic_vector(15 downto 0);
|
||||
mon_points : out std_logic_vector(3 downto 0);
|
||||
mon_point_src : in std_logic_vector(15 downto 0);
|
||||
mon_points : out std_logic_vector( 3 downto 0);
|
||||
coarse_time : out std_logic_vector(31 downto 0);
|
||||
fine_time : out std_logic_vector(27 downto 0);
|
||||
one_pps : out std_logic;
|
||||
|
|
@ -47,7 +45,7 @@ entity fire_pulse_ctrl_1 is
|
|||
-- Interrupt Senders
|
||||
ins_fpm_irq_0 : out std_logic;
|
||||
-- Avalon MM Interface
|
||||
avs_address : in std_logic_vector(3 downto 0);
|
||||
avs_address : in std_logic_vector( 3 downto 0);
|
||||
avs_write : in std_logic;
|
||||
avs_writedata : in std_logic_vector(31 downto 0);
|
||||
avs_read : in std_logic;
|
||||
|
|
@ -60,41 +58,41 @@ architecture rtl of fire_pulse_ctrl_1 is
|
|||
-----------------------------------------------------------------------------
|
||||
-- Control & Status Registers Map
|
||||
-----------------------------------------------------------------------------
|
||||
constant CSR_IP_ID : std_logic_vector(31 downto 0) := x"0000FF14";
|
||||
constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000100";
|
||||
constant CSR_IP_ID : std_logic_vector(31 downto 0) := x"0000FF14";
|
||||
constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000100";
|
||||
|
||||
constant CSR_IP_ID_REG : std_logic_vector(3 downto 0) := b"0000";
|
||||
constant CSR_IP_VER_REG : std_logic_vector(3 downto 0) := b"0001";
|
||||
constant SRC_SEL_REG : std_logic_vector(3 downto 0) := b"0010";
|
||||
constant POF_RX_CTRL : std_logic_vector(3 downto 0) := b"0011";
|
||||
constant MON_PT_CTRL_REG : std_logic_vector(3 downto 0) := b"0100";
|
||||
constant COARSE_TIME_INIT_REG : std_logic_vector(3 downto 0) := b"0101";
|
||||
constant FINE_TIME_INIT_REG : std_logic_vector(3 downto 0) := b"0110";
|
||||
constant FINE_TIME_REG : std_logic_vector(3 downto 0) := b"0111";
|
||||
constant COARSE_TIME_REG : std_logic_vector(3 downto 0) := b"1000";
|
||||
constant RX_ERROR_STATUS : std_logic_vector(3 downto 0) := b"1001";
|
||||
constant RX_ERROR_CSR : std_logic_vector(3 downto 0) := b"1010";
|
||||
constant IRQ_MNG_REG : std_logic_vector(3 downto 0) := b"1011";
|
||||
constant EXT_FP_CTRL_REG : std_logic_vector(3 downto 0) := b"1100";
|
||||
constant CSR_IP_ID_REG : std_logic_vector( 3 downto 0) := b"0000";
|
||||
constant CSR_IP_VER_REG : std_logic_vector( 3 downto 0) := b"0001";
|
||||
constant SRC_SEL_REG : std_logic_vector( 3 downto 0) := b"0010";
|
||||
constant POF_RX_CTRL : std_logic_vector( 3 downto 0) := b"0011";
|
||||
constant MON_PT_CTRL_REG : std_logic_vector( 3 downto 0) := b"0100";
|
||||
constant COARSE_TIME_INIT_REG : std_logic_vector( 3 downto 0) := b"0101";
|
||||
constant FINE_TIME_INIT_REG : std_logic_vector( 3 downto 0) := b"0110";
|
||||
constant FINE_TIME_REG : std_logic_vector( 3 downto 0) := b"0111";
|
||||
constant COARSE_TIME_REG : std_logic_vector( 3 downto 0) := b"1000";
|
||||
constant RX_ERROR_STATUS : std_logic_vector( 3 downto 0) := b"1001";
|
||||
constant RX_ERROR_CSR : std_logic_vector( 3 downto 0) := b"1010";
|
||||
constant IRQ_MNG_REG : std_logic_vector( 3 downto 0) := b"1011";
|
||||
constant EXT_FP_CTRL_REG : std_logic_vector( 3 downto 0) := b"1100";
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Constants, Signals
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
constant FINE_TIME_TC : integer := 100000000 - 1; -- clk must be 100MHz to
|
||||
-- make it right
|
||||
constant FINE_TIME_TC : integer := 100000000-1; -- clk must be 100MHz to
|
||||
-- make it right
|
||||
|
||||
signal enable_rx_i : std_logic;
|
||||
signal fine_time_wrap, time_ld_en : std_logic;
|
||||
signal rx_watchdog_en_i, rx_watchdog_clr_i : std_logic;
|
||||
signal uart_regen_bypass_i : std_logic;
|
||||
signal upd_min_pos_i, upd_max_pos_i : std_logic;
|
||||
signal irq, irq_src, irq_src_d : std_logic_vector(0 downto 0);
|
||||
signal irq_en, irq_mask, irq_val, irq_clr : std_logic_vector(0 downto 0);
|
||||
signal src_sel_i : std_logic_vector(1 downto 0);
|
||||
signal mp_sel0, mp_sel1, mp_sel2, mp_sel3 : std_logic_vector(3 downto 0);
|
||||
signal bit_div : std_logic_vector(3 downto 0);
|
||||
signal error_rate_thres_i : std_logic_vector(7 downto 0);
|
||||
signal irq, irq_src, irq_src_d : std_logic_vector( 0 downto 0);
|
||||
signal irq_en, irq_mask, irq_val, irq_clr : std_logic_vector( 0 downto 0);
|
||||
signal src_sel_i : std_logic_vector( 1 downto 0);
|
||||
signal mp_sel0, mp_sel1, mp_sel2, mp_sel3 : std_logic_vector( 3 downto 0);
|
||||
signal bit_div : std_logic_vector( 3 downto 0);
|
||||
signal error_rate_thres_i : std_logic_vector( 7 downto 0);
|
||||
signal fine_time_init, fine_time_i : std_logic_vector(27 downto 0);
|
||||
signal coarse_time_init, coarse_time_i : std_logic_vector(31 downto 0);
|
||||
signal ext_fp_det_i, ext_fp_gen_i : std_logic_vector(15 downto 0);
|
||||
|
|
@ -102,22 +100,22 @@ architecture rtl of fire_pulse_ctrl_1 is
|
|||
begin
|
||||
|
||||
pCTRL_REGs : process(reset_n, clk)
|
||||
begin -- process
|
||||
if (reset_n = '0') then
|
||||
fine_time_i <= (others => '0');
|
||||
coarse_time_i <= (others => '0');
|
||||
elsif (clk = '1' and clk'event) then
|
||||
if (time_ld_en = '1') then
|
||||
begin -- process
|
||||
if(reset_n = '0') then
|
||||
fine_time_i <= (others => '0');
|
||||
coarse_time_i <= (others => '0');
|
||||
elsif(clk = '1' and clk'event) then
|
||||
if(time_ld_en = '1') then
|
||||
fine_time_i <= fine_time_init;
|
||||
elsif (fine_time_wrap = '1') then
|
||||
elsif(fine_time_wrap = '1') then
|
||||
fine_time_i <= (others => '0');
|
||||
else
|
||||
fine_time_i <= std_logic_vector(unsigned(fine_time_i) + 1);
|
||||
fine_time_i <= std_logic_vector(unsigned(fine_time_i)+1);
|
||||
end if;
|
||||
if (time_ld_en = '1') then
|
||||
if(time_ld_en = '1') then
|
||||
coarse_time_i <= coarse_time_init;
|
||||
elsif (fine_time_wrap = '1') then
|
||||
coarse_time_i <= std_logic_vector(unsigned(coarse_time_i) + 1);
|
||||
elsif(fine_time_wrap = '1') then
|
||||
coarse_time_i <= std_logic_vector(unsigned(coarse_time_i)+1);
|
||||
end if;
|
||||
one_pps <= fine_time_wrap;
|
||||
end if;
|
||||
|
|
@ -140,19 +138,19 @@ begin
|
|||
|
||||
pIRQ : process(reset_n, clk)
|
||||
begin
|
||||
if (reset_n = '0') then
|
||||
ins_fpm_irq_0 <= '0';
|
||||
irq <= "0";
|
||||
irq_src_d <= "0";
|
||||
elsif (clk = '1' and clk'event) then
|
||||
irq_src_d <= irq_src;
|
||||
if(reset_n = '0') then
|
||||
ins_fpm_irq_0 <= '0';
|
||||
irq <= "0";
|
||||
irq_src_d <= "0";
|
||||
elsif(clk = '1' and clk'event) then
|
||||
irq_src_d <= irq_src;
|
||||
for n in 0 to irq'left loop
|
||||
if (irq_clr(n) = '1') then
|
||||
if(irq_clr(n) = '1') then
|
||||
irq(n) <= '0';
|
||||
elsif (irq_en(n) = '1' and irq_src(n) = '1' and irq_src_d(n) = '0') then
|
||||
elsif(irq_en(n) = '1' and irq_src(n) = '1' and irq_src_d(n) = '0') then
|
||||
irq(n) <= '1';
|
||||
end if;
|
||||
end loop; -- n
|
||||
end loop; -- n
|
||||
ins_fpm_irq_0 <= irq_val(0);
|
||||
end if;
|
||||
end process pIRQ;
|
||||
|
|
@ -176,12 +174,12 @@ begin
|
|||
rx_watchdog_en <= rx_watchdog_en_i;
|
||||
rx_watchdog_clr <= rx_watchdog_clr_i;
|
||||
|
||||
ext_fp_det <= ext_fp_det_i;
|
||||
ext_fp_gen <= ext_fp_gen_i;
|
||||
ext_fp_det <= ext_fp_det_i;
|
||||
ext_fp_gen <= ext_fp_gen_i;
|
||||
|
||||
pCTRL_STATUS : process(reset_n, clk)
|
||||
begin
|
||||
if (reset_n = '0') then
|
||||
if(reset_n = '0') then
|
||||
avs_readdatavalid <= '0';
|
||||
src_sel_i <= "00";
|
||||
enable_rx_i <= '0';
|
||||
|
|
@ -201,68 +199,65 @@ begin
|
|||
time_ld_en <= '0';
|
||||
ext_fp_det_i <= X"0010";
|
||||
ext_fp_gen_i <= X"0020";
|
||||
pof_rx_ctrl_valid <= '0';
|
||||
elsif (clk = '1' and clk'event) then
|
||||
elsif(clk = '1' and clk'event) then
|
||||
-- CTRL registers
|
||||
pof_rx_ctrl_valid <= '0';
|
||||
if (avs_write = '1') then
|
||||
if(avs_write = '1') then
|
||||
case avs_address is
|
||||
when SRC_SEL_REG =>
|
||||
src_sel_i <= avs_writedata(1 downto 0);
|
||||
src_sel_i <= avs_writedata( 1 downto 0);
|
||||
when POF_RX_CTRL =>
|
||||
enable_rx_i <= avs_writedata(0);
|
||||
uart_regen_bypass_i <= avs_writedata(1);
|
||||
upd_max_pos_i <= avs_writedata(2);
|
||||
upd_min_pos_i <= avs_writedata(3);
|
||||
bit_div <= avs_writedata(7 downto 4);
|
||||
pof_rx_ctrl_valid <= '1'; -- strobe to validate new pof_rx data
|
||||
bit_div <= avs_writedata( 7 downto 4);
|
||||
when MON_PT_CTRL_REG =>
|
||||
mp_sel0 <= avs_writedata(3 downto 0);
|
||||
mp_sel1 <= avs_writedata(7 downto 4);
|
||||
mp_sel2 <= avs_writedata(11 downto 8);
|
||||
mp_sel3 <= avs_writedata(15 downto 12);
|
||||
when COARSE_TIME_INIT_REG =>
|
||||
coarse_time_init <= avs_writedata;
|
||||
mp_sel0 <= avs_writedata( 3 downto 0);
|
||||
mp_sel1 <= avs_writedata( 7 downto 4);
|
||||
mp_sel2 <= avs_writedata(11 downto 8);
|
||||
mp_sel3 <= avs_writedata(15 downto 12);
|
||||
when COARSE_TIME_INIT_REG =>
|
||||
coarse_time_init <= avs_writedata;
|
||||
when FINE_TIME_INIT_REG =>
|
||||
time_ld_en <= avs_writedata(28);
|
||||
fine_time_init <= avs_writedata(27 downto 0);
|
||||
time_ld_en <= avs_writedata(28);
|
||||
fine_time_init <= avs_writedata(27 downto 0);
|
||||
when RX_ERROR_CSR =>
|
||||
error_rate_thres_i <= avs_writedata(7 downto 0);
|
||||
rx_watchdog_en_i <= avs_writedata(8);
|
||||
rx_watchdog_clr_i <= avs_writedata(9);
|
||||
error_rate_thres_i <= avs_writedata( 7 downto 0);
|
||||
rx_watchdog_en_i <= avs_writedata(8);
|
||||
rx_watchdog_clr_i <= avs_writedata(9);
|
||||
when IRQ_MNG_REG =>
|
||||
irq_en <= avs_writedata(0 downto 0);
|
||||
irq_clr <= avs_writedata(4 downto 4);
|
||||
irq_mask <= avs_writedata(8 downto 8);
|
||||
irq_en <= avs_writedata( 0 downto 0);
|
||||
irq_clr <= avs_writedata( 4 downto 4);
|
||||
irq_mask <= avs_writedata( 8 downto 8);
|
||||
when EXT_FP_CTRL_REG =>
|
||||
ext_fp_det_i <= avs_writedata(15 downto 0);
|
||||
ext_fp_gen_i <= avs_writedata(31 downto 16);
|
||||
ext_fp_det_i <= avs_writedata(15 downto 0);
|
||||
ext_fp_gen_i <= avs_writedata(31 downto 16);
|
||||
when others => null;
|
||||
end case;
|
||||
end if;
|
||||
end if;
|
||||
-- Read Ctrl & Status registers
|
||||
avs_readdatavalid <= avs_read;
|
||||
if (avs_read = '1') then
|
||||
if(avs_read = '1') then
|
||||
case avs_address is
|
||||
when CSR_IP_ID_REG =>
|
||||
avs_readdata <= CSR_IP_ID;
|
||||
when CSR_IP_VER_REG =>
|
||||
avs_readdata <= CSR_IP_VER;
|
||||
when SRC_SEL_REG =>
|
||||
when SRC_SEL_REG =>
|
||||
avs_readdata <= (0 => src_sel_i(0), 1 => src_sel_i(1), others => '0');
|
||||
when POF_RX_CTRL =>
|
||||
when POF_RX_CTRL =>
|
||||
avs_readdata <= X"000000" & bit_div & upd_min_pos_i & upd_max_pos_i & uart_regen_bypass_i & enable_rx_i;
|
||||
when MON_PT_CTRL_REG =>
|
||||
avs_readdata <= X"0000" & mp_sel3 & mp_sel2 & mp_sel1 & mp_sel0;
|
||||
when COARSE_TIME_INIT_REG =>
|
||||
avs_readdata <= coarse_time_init;
|
||||
when FINE_TIME_INIT_REG =>
|
||||
when FINE_TIME_INIT_REG =>
|
||||
avs_readdata <= b"000" & time_ld_en & fine_time_init;
|
||||
when RX_ERROR_STATUS =>
|
||||
avs_readdata <= skip_pos_cnt & parity_err_cnt;
|
||||
when FINE_TIME_REG =>
|
||||
when FINE_TIME_REG =>
|
||||
avs_readdata <= X"0" & fine_time_i;
|
||||
when COARSE_TIME_REG =>
|
||||
when COARSE_TIME_REG =>
|
||||
avs_readdata <= coarse_time_i;
|
||||
when RX_ERROR_CSR =>
|
||||
avs_readdata <= X"00000" & max_error_flag & rx_watchdog & rx_watchdog_clr_i & rx_watchdog_en_i & error_rate_thres_i;
|
||||
|
|
@ -276,5 +271,5 @@ begin
|
|||
end if;
|
||||
end if;
|
||||
end process pCTRL_STATUS;
|
||||
|
||||
|
||||
end architecture rtl;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ entity fire_pulse_manager_1 is
|
|||
port(
|
||||
reset_n : in std_logic;
|
||||
clk : in std_logic; -- 100MHz
|
||||
rx_clk : in std_logic; -- 300MHz (recommended for 50MBd POF Link)
|
||||
rx_clk : in std_logic; -- 200MHz
|
||||
-- Datapath I/Os
|
||||
pof_rx : in std_logic;
|
||||
pof_tx : out std_logic;
|
||||
|
|
@ -35,10 +35,9 @@ entity fire_pulse_manager_1 is
|
|||
-- on header J7
|
||||
-- Interrupt Senders
|
||||
ins_fpm_irq_0 : out std_logic;
|
||||
-- unused 1 to 3
|
||||
ins_fpm_irq_1 : out std_logic;
|
||||
ins_fpm_irq_2 : out std_logic;
|
||||
ins_fpm_irq_3 : out std_logic;
|
||||
ins_fpm_irq_1 : out std_logic; -- @suppress "Unused port: ins_fpm_irq_1 is not used in work.fire_pulse_manager_1(rtl)"
|
||||
ins_fpm_irq_2 : out std_logic; -- @suppress "Unused port: ins_fpm_irq_2 is not used in work.fire_pulse_manager_1(rtl)"
|
||||
ins_fpm_irq_3 : out std_logic; -- @suppress "Unused port: ins_fpm_irq_3 is not used in work.fire_pulse_manager_1(rtl)"
|
||||
-- Avalon MM (Slave) Interface
|
||||
avs_address : in std_logic_vector(14 downto 0);
|
||||
avs_write : in std_logic;
|
||||
|
|
@ -50,90 +49,84 @@ end entity fire_pulse_manager_1;
|
|||
|
||||
architecture rtl of fire_pulse_manager_1 is
|
||||
|
||||
signal reset_n_i : std_logic; -- reset synchronised to clk (100MHz)
|
||||
signal reset_n_i : std_logic;
|
||||
--
|
||||
signal cs_addr : std_logic_vector(10 downto 0);
|
||||
signal cs_write_en : std_logic_vector(blk_num - 1 downto 0);
|
||||
signal cs_write_data : std_logic_vector(31 downto 0);
|
||||
signal cs_read_en : std_logic_vector(blk_num - 1 downto 0);
|
||||
signal cs_read_valid : std_logic_vector(blk_num - 1 downto 0);
|
||||
signal cs_read_data : std_logic_vector(32 * blk_num - 1 downto 0);
|
||||
signal cs_addr : std_logic_vector(10 downto 0);
|
||||
signal cs_write_en : std_logic_vector(blk_num - 1 downto 0);
|
||||
signal cs_write_data : std_logic_vector(31 downto 0);
|
||||
signal cs_read_en : std_logic_vector(blk_num - 1 downto 0);
|
||||
signal cs_read_valid : std_logic_vector(blk_num - 1 downto 0);
|
||||
signal cs_read_data : std_logic_vector(32 * blk_num - 1 downto 0);
|
||||
--
|
||||
signal cs_ctrl_write_en : std_logic;
|
||||
signal cs_ctrl_read_en : std_logic;
|
||||
signal cs_ctrl_read_valid : std_logic;
|
||||
signal cs_ctrl_read_data : std_logic_vector(31 downto 0);
|
||||
signal cs_ctrl_write_en : std_logic;
|
||||
signal cs_ctrl_read_en : std_logic;
|
||||
signal cs_ctrl_read_valid : std_logic;
|
||||
signal cs_ctrl_read_data : std_logic_vector(31 downto 0);
|
||||
--
|
||||
signal cs_pg_write_en : std_logic_vector(ch_num - 1 downto 0);
|
||||
signal cs_pg_read_en : std_logic_vector(ch_num - 1 downto 0);
|
||||
signal cs_pg_read_valid : std_logic_vector(ch_num - 1 downto 0);
|
||||
signal cs_pg_read_data : std_logic_vector(32 * ch_num - 1 downto 0);
|
||||
signal cs_pg_write_en : std_logic_vector(ch_num - 1 downto 0);
|
||||
signal cs_pg_read_en : std_logic_vector(ch_num - 1 downto 0);
|
||||
signal cs_pg_read_valid : std_logic_vector(ch_num - 1 downto 0);
|
||||
signal cs_pg_read_data : std_logic_vector(32 * ch_num - 1 downto 0);
|
||||
--
|
||||
signal cs_nsnk_write_en : std_logic;
|
||||
signal cs_nsnk_read_en : std_logic;
|
||||
signal cs_nsnk_read_valid : std_logic;
|
||||
signal cs_nsnk_read_data : std_logic_vector(31 downto 0);
|
||||
signal cs_nsnk_write_en : std_logic;
|
||||
signal cs_nsnk_read_en : std_logic;
|
||||
signal cs_nsnk_read_valid : std_logic;
|
||||
signal cs_nsnk_read_data : std_logic_vector(31 downto 0);
|
||||
--
|
||||
signal cs_log_write_en : std_logic;
|
||||
signal cs_log_read_en : std_logic;
|
||||
signal cs_log_read_valid : std_logic;
|
||||
signal cs_log_read_data : std_logic_vector(31 downto 0);
|
||||
signal cs_log_write_en : std_logic;
|
||||
signal cs_log_read_en : std_logic;
|
||||
signal cs_log_read_valid : std_logic;
|
||||
signal cs_log_read_data : std_logic_vector(31 downto 0);
|
||||
--
|
||||
signal cs_ie_write_en : std_logic;
|
||||
signal cs_ie_read_en : std_logic;
|
||||
signal cs_ie_read_valid : std_logic;
|
||||
signal cs_ie_read_data : std_logic_vector(31 downto 0);
|
||||
signal cs_ie_write_en : std_logic;
|
||||
signal cs_ie_read_en : std_logic;
|
||||
signal cs_ie_read_valid : std_logic;
|
||||
signal cs_ie_read_data : std_logic_vector(31 downto 0);
|
||||
--
|
||||
signal enable_rx : std_logic;
|
||||
signal uart_regen_bypass : std_logic;
|
||||
signal upd_max_pos : std_logic;
|
||||
signal upd_min_pos : std_logic;
|
||||
signal max_error_flag : std_logic;
|
||||
signal rx_watchdog : std_logic;
|
||||
signal rx_watchdog_en : std_logic;
|
||||
signal rx_watchdog_clr : std_logic;
|
||||
signal bit_div : std_logic_vector(3 downto 0);
|
||||
signal error_rate_thres : std_logic_vector(7 downto 0);
|
||||
signal parity_err_cnt : std_logic_vector(15 downto 0);
|
||||
signal skip_pos_cnt : std_logic_vector(15 downto 0);
|
||||
signal mon_point_src : std_logic_vector(15 downto 0);
|
||||
signal fine_time : std_logic_vector(27 downto 0);
|
||||
signal coarse_time : std_logic_vector(31 downto 0);
|
||||
signal enable_rx : std_logic;
|
||||
signal uart_regen_bypass : std_logic;
|
||||
signal upd_max_pos : std_logic;
|
||||
signal upd_min_pos : std_logic;
|
||||
signal max_error_flag : std_logic;
|
||||
signal rx_watchdog : std_logic;
|
||||
signal rx_watchdog_en : std_logic;
|
||||
signal rx_watchdog_clr : std_logic;
|
||||
signal bit_div : std_logic_vector(3 downto 0);
|
||||
signal error_rate_thres : std_logic_vector(7 downto 0);
|
||||
signal parity_err_cnt : std_logic_vector(15 downto 0);
|
||||
signal skip_pos_cnt : std_logic_vector(15 downto 0);
|
||||
signal mon_point_src : std_logic_vector(15 downto 0);
|
||||
signal fine_time : std_logic_vector(27 downto 0);
|
||||
signal coarse_time : std_logic_vector(31 downto 0);
|
||||
--
|
||||
signal remote_init : std_logic;
|
||||
signal dp_dir : std_logic_vector(ch_num - 1 downto 0);
|
||||
signal set_pos_ie : std_logic;
|
||||
signal enc_pulse : std_logic;
|
||||
signal enc_pulse_ie : std_logic;
|
||||
signal enc_pulse_pof : std_logic;
|
||||
signal pd_pulse : std_logic;
|
||||
signal pd_pulse_ie : std_logic;
|
||||
signal pd_pulse_pof : std_logic;
|
||||
signal inc_pos : std_logic;
|
||||
signal inc_pos_pof : std_logic;
|
||||
signal inc_pos_ie : std_logic;
|
||||
signal dec_pos : std_logic;
|
||||
signal dec_pos_pof : std_logic;
|
||||
signal dec_pos_ie : std_logic;
|
||||
signal abs_pos : std_logic_vector(31 downto 0);
|
||||
signal abs_pos_pof : std_logic_vector(31 downto 0);
|
||||
signal abs_pos_ie : std_logic_vector(39 downto 0);
|
||||
signal remote_init : std_logic;
|
||||
signal dp_dir : std_logic_vector(ch_num - 1 downto 0);
|
||||
signal set_pos_ie : std_logic;
|
||||
signal enc_pulse : std_logic;
|
||||
signal enc_pulse_ie : std_logic;
|
||||
signal enc_pulse_pof : std_logic;
|
||||
signal pd_pulse : std_logic;
|
||||
signal pd_pulse_ie : std_logic;
|
||||
signal pd_pulse_pof : std_logic;
|
||||
signal inc_pos : std_logic;
|
||||
signal inc_pos_pof : std_logic;
|
||||
signal inc_pos_ie : std_logic;
|
||||
signal dec_pos : std_logic;
|
||||
signal dec_pos_pof : std_logic;
|
||||
signal dec_pos_ie : std_logic;
|
||||
signal abs_pos : std_logic_vector(31 downto 0);
|
||||
signal abs_pos_pof : std_logic_vector(31 downto 0);
|
||||
signal abs_pos_ie : std_logic_vector(39 downto 0);
|
||||
--
|
||||
signal ch_pd, ch_pulse_out : std_logic_vector(ch_num - 1 downto 0);
|
||||
signal ch_raw_pulse, ch_mask : std_logic_vector(ch_num - 1 downto 0);
|
||||
signal fire_pulse_i : std_logic_vector(ch_num - 1 downto 0);
|
||||
signal src_sel : std_logic_vector(1 downto 0);
|
||||
signal ch_pd, ch_pulse_out : std_logic_vector(ch_num - 1 downto 0);
|
||||
signal ch_raw_pulse, ch_mask : std_logic_vector(ch_num - 1 downto 0);
|
||||
signal fire_pulse_i : std_logic_vector(ch_num - 1 downto 0);
|
||||
signal src_sel : std_logic_vector(1 downto 0);
|
||||
--
|
||||
signal one_pps : std_logic;
|
||||
signal ext_fp_det : std_logic_vector(15 downto 0);
|
||||
signal ext_fp_gen : std_logic_vector(15 downto 0);
|
||||
signal pof_rx_regen : std_logic;
|
||||
signal pof_rx_ctrl_valid : std_logic; -- validates uart_regen_bypass, upd_max_pos, upd_min_pos, enable_rx, bit_div
|
||||
signal bit_div_dest : std_logic_vector(bit_div'range);
|
||||
signal enable_rx_dest : std_logic;
|
||||
signal pof_rx_ctrl_data_dest : std_logic_vector(bit_div'high + 2 downto 0);
|
||||
signal pof_rx_ctrl_data_src : std_logic_vector(bit_div'high + 2 downto 0);
|
||||
signal uart_regen_bypass_dest : std_logic;
|
||||
signal one_pps : std_logic;
|
||||
signal ext_fp_det : std_logic_vector(15 downto 0);
|
||||
signal ext_fp_gen : std_logic_vector(15 downto 0);
|
||||
signal pof_rx_regen : std_logic;
|
||||
|
||||
begin
|
||||
|
||||
|
|
@ -176,54 +169,30 @@ begin
|
|||
-- POF Receiver
|
||||
iPOF_RX : entity work.pof_rx_1
|
||||
port map(
|
||||
reset_n => reset_n_i,
|
||||
clk => clk,
|
||||
init => '0',
|
||||
rx_clk => rx_clk,
|
||||
rx_data => pof_rx,
|
||||
init_out => remote_init,
|
||||
dp_dir => dp_dir(0),
|
||||
enc_out => enc_pulse_pof,
|
||||
pd_out => pd_pulse_pof,
|
||||
inc_pos => inc_pos_pof,
|
||||
dec_pos => dec_pos_pof,
|
||||
abs_pos => abs_pos_pof,
|
||||
pof_rx_ctrl_valid => pof_rx_ctrl_valid,
|
||||
enable => enable_rx,
|
||||
bit_div => bit_div,
|
||||
upd_max_pos => upd_max_pos,
|
||||
upd_min_pos => upd_min_pos,
|
||||
error_rate_thres => error_rate_thres,
|
||||
one_pps => one_pps,
|
||||
max_error_flag => max_error_flag,
|
||||
rx_watchdog => rx_watchdog,
|
||||
rx_watchdog_en => rx_watchdog_en,
|
||||
rx_watchdog_clr => rx_watchdog_clr,
|
||||
parity_err_cnt => parity_err_cnt,
|
||||
skip_pos_cnt => skip_pos_cnt);
|
||||
|
||||
-- Synchronise signals to rx_clk
|
||||
pof_rx_ctrl_data_dest <= enable_rx & uart_regen_bypass & bit_div;
|
||||
|
||||
enable_rx_dest <= pof_rx_ctrl_data_src(5);
|
||||
uart_regen_bypass_dest <= pof_rx_ctrl_data_src(4);
|
||||
bit_div_dest <= pof_rx_ctrl_data_src(3 downto 0);
|
||||
|
||||
|
||||
iCDC_CTRL : entity work.cdc_data_handshake_1
|
||||
generic map(
|
||||
DATA_WIDTH => pof_rx_ctrl_data_dest'length
|
||||
)
|
||||
port map(
|
||||
arst_n => reset_n,
|
||||
src_clk => clk,
|
||||
src_valid => pof_rx_ctrl_valid,
|
||||
src_data => pof_rx_ctrl_data_dest,
|
||||
src_ack => open,
|
||||
dest_clk => rx_clk,
|
||||
dest_valid => open,
|
||||
dest_data => pof_rx_ctrl_data_src
|
||||
);
|
||||
reset_n => reset_n_i,
|
||||
clk => clk,
|
||||
init => '0',
|
||||
rx_clk => rx_clk,
|
||||
rx_data => pof_rx,
|
||||
init_out => remote_init,
|
||||
dp_dir => dp_dir(0),
|
||||
enc_out => enc_pulse_pof,
|
||||
pd_out => pd_pulse_pof,
|
||||
inc_pos => inc_pos_pof,
|
||||
dec_pos => dec_pos_pof,
|
||||
abs_pos => abs_pos_pof,
|
||||
enable => enable_rx,
|
||||
bit_div => bit_div,
|
||||
error_rate_thres => error_rate_thres,
|
||||
one_pps => one_pps,
|
||||
upd_max_pos => upd_max_pos,
|
||||
upd_min_pos => upd_min_pos,
|
||||
max_error_flag => max_error_flag,
|
||||
rx_watchdog => rx_watchdog,
|
||||
rx_watchdog_en => rx_watchdog_en,
|
||||
rx_watchdog_clr => rx_watchdog_clr,
|
||||
parity_err_cnt => parity_err_cnt,
|
||||
skip_pos_cnt => skip_pos_cnt);
|
||||
|
||||
-- UART signal regeneration
|
||||
iUART_REGEN : entity work.uart_regen_1
|
||||
|
|
@ -232,9 +201,9 @@ begin
|
|||
port map(
|
||||
reset_n => reset_n,
|
||||
clk => rx_clk,
|
||||
bit_div => bit_div_dest, -- synchronised to rx_clk
|
||||
enable => enable_rx_dest, -- synchronised to rx_clk
|
||||
bypass_en => uart_regen_bypass_dest, -- synchronised to rx_clk
|
||||
bit_div => bit_div,
|
||||
enable => enable_rx,
|
||||
bypass_en => uart_regen_bypass,
|
||||
uart_rx => pof_rx,
|
||||
uart_tx => pof_tx);
|
||||
|
||||
|
|
@ -361,7 +330,6 @@ begin
|
|||
reset_n => reset_n_i,
|
||||
clk => clk,
|
||||
src_sel => src_sel,
|
||||
pof_rx_ctrl_valid => pof_rx_ctrl_valid,
|
||||
uart_regen_bypass => uart_regen_bypass,
|
||||
upd_max_pos => upd_max_pos,
|
||||
upd_min_pos => upd_min_pos,
|
||||
|
|
@ -393,11 +361,6 @@ begin
|
|||
fire_pulse_i <= ch_pulse_out when src_sel(0) = '1' else (others => pof_rx_regen);
|
||||
fire_pulse <= fire_pulse_i;
|
||||
|
||||
-- Unused IRQs - set low until needed to give defined state
|
||||
ins_fpm_irq_1 <= '0';
|
||||
ins_fpm_irq_2 <= '0';
|
||||
ins_fpm_irq_3 <= '0';
|
||||
|
||||
pd_pulse <= pd_pulse_pof when src_sel(1) = '0' else pd_pulse_ie;
|
||||
enc_pulse <= enc_pulse_pof when src_sel(1) = '0' else enc_pulse_ie;
|
||||
abs_pos <= abs_pos_pof when src_sel(1) = '0' else abs_pos_ie(31 downto 0);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use ieee.numeric_std.all;
|
|||
|
||||
entity pof_rx_1 is
|
||||
port(
|
||||
reset_n : in std_logic; -- synchronised to clk
|
||||
reset_n : in std_logic;
|
||||
clk : in std_logic;
|
||||
--
|
||||
init : in std_logic;
|
||||
|
|
@ -34,14 +34,12 @@ entity pof_rx_1 is
|
|||
dec_pos : out std_logic;
|
||||
abs_pos : out std_logic_vector(31 downto 0);
|
||||
-- C&S
|
||||
pof_rx_ctrl_valid : in std_logic := '1'; -- validates upd_max_pos, upd_min_pos, enable_rx, bit_div
|
||||
enable : in std_logic;
|
||||
bit_div : in std_logic_vector(3 downto 0);
|
||||
bit_div : in std_logic_vector( 3 downto 0);
|
||||
error_rate_thres : in std_logic_vector( 7 downto 0);
|
||||
one_pps : in std_logic;
|
||||
upd_max_pos : in std_logic;
|
||||
upd_min_pos : in std_logic;
|
||||
--
|
||||
error_rate_thres : in std_logic_vector(7 downto 0);
|
||||
one_pps : in std_logic;
|
||||
max_error_flag : out std_logic;
|
||||
rx_watchdog : out std_logic;
|
||||
rx_watchdog_en : in std_logic;
|
||||
|
|
@ -56,9 +54,9 @@ architecture rtl of pof_rx_1 is
|
|||
function odd_parity_check(data : std_logic_vector) return std_logic is
|
||||
variable parity_bit : std_logic := '0';
|
||||
begin
|
||||
for n in 0 to data'length - 1 loop
|
||||
for n in 0 to data'length-1 loop
|
||||
parity_bit := parity_bit xor data(n);
|
||||
end loop; -- n
|
||||
end loop; -- n
|
||||
return parity_bit;
|
||||
end function odd_parity_check;
|
||||
|
||||
|
|
@ -66,10 +64,10 @@ architecture rtl of pof_rx_1 is
|
|||
function gray2bin(gray : std_logic_vector) return std_logic_vector is
|
||||
variable bin : std_logic_vector(gray'range);
|
||||
begin
|
||||
bin(gray'length - 1) := gray(gray'length - 1);
|
||||
for i in gray'length - 2 downto 0 loop
|
||||
bin(i) := bin(i + 1) xor gray(i);
|
||||
end loop; -- n
|
||||
bin(gray'length-1) := gray(gray'length-1);
|
||||
for i in gray'length-2 downto 0 loop
|
||||
bin(i) := bin(i+1) xor gray(i);
|
||||
end loop; -- n
|
||||
return bin;
|
||||
end function gray2bin;
|
||||
|
||||
|
|
@ -84,53 +82,33 @@ architecture rtl of pof_rx_1 is
|
|||
signal rx_symbol_val, clear_i, skip_pos_d, pos_recovery : std_logic;
|
||||
signal dp_dir_d, dp_dir_change, max_error_flag_i : std_logic;
|
||||
--
|
||||
signal clk_cnt : std_logic_vector(1 downto 0);
|
||||
signal dist, abs_dist, skip_cnt : std_logic_vector(3 downto 0);
|
||||
signal next_pos_lsb, curr_pos_lsb : std_logic_vector(3 downto 0);
|
||||
signal pos_corr, max_dist : std_logic_vector(3 downto 0);
|
||||
signal gray_pos : std_logic_vector(3 downto 0);
|
||||
signal symbol_i, rx_symbol : std_logic_vector(7 downto 0);
|
||||
signal rx_wd_cnt : std_logic_vector(9 downto 0);
|
||||
signal parity_err_cnt_i, skip_pos_cnt_i : std_logic_vector(15 downto 0);
|
||||
signal error_rate_cnt, error_rate : std_logic_vector(15 downto 0);
|
||||
signal abs_pos_i, pos_max, pos_min : std_logic_vector(31 downto 0);
|
||||
signal dist_pos, dist_neg : std_logic_vector(31 downto 0);
|
||||
signal bit_div_dest : std_logic_vector(bit_div'range);
|
||||
signal reset_n_rx_clk : std_logic; -- reset synchronised to rx_clk (typically 300 MHz)
|
||||
signal clk_cnt : std_logic_vector( 1 downto 0);
|
||||
signal dist, abs_dist, skip_cnt : std_logic_vector( 3 downto 0);
|
||||
signal next_pos_lsb, curr_pos_lsb : std_logic_vector( 3 downto 0);
|
||||
signal pos_corr, max_dist, rx_error_v : std_logic_vector( 3 downto 0);
|
||||
signal gray_pos, rx_symbol_val_v : std_logic_vector( 3 downto 0);
|
||||
signal symbol, symbol_i, rx_symbol : std_logic_vector( 7 downto 0);
|
||||
signal rx_wd_cnt : std_logic_vector( 9 downto 0);
|
||||
signal parity_err_cnt_i, skip_pos_cnt_i : std_logic_vector(15 downto 0);
|
||||
signal error_rate_cnt, error_rate : std_logic_vector(15 downto 0);
|
||||
signal abs_pos_i, pos_max, pos_min : std_logic_vector(31 downto 0);
|
||||
signal dist_pos, dist_neg : std_logic_vector(31 downto 0);
|
||||
|
||||
|
||||
begin
|
||||
|
||||
clear <= not enable or init;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- De-serialize symbols (Serial clock at Higher Speed ( Rx Clock probably 300 MHz)
|
||||
-- De-serialize symbols (Serial clock at 200 MHz)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
iCDC_CTRL : entity work.cdc_data_handshake_1
|
||||
generic map(
|
||||
DATA_WIDTH => bit_div'length
|
||||
)
|
||||
port map(
|
||||
arst_n => reset_n,
|
||||
src_clk => clk,
|
||||
src_valid => pof_rx_ctrl_valid,
|
||||
src_data => bit_div,
|
||||
src_ack => open,
|
||||
dest_clk => rx_clk,
|
||||
dest_valid => open,
|
||||
dest_data => bit_div_dest
|
||||
);
|
||||
|
||||
iSyncReset_rxclk : entity work.sync_reset port map(async_rstN => reset_n, clk => rx_clk, sync_rstN => reset_n_rx_clk);
|
||||
|
||||
|
||||
iRX_SYMBOL : entity work.uart_rx_1
|
||||
generic map(
|
||||
data_width => rx_symbol'length)
|
||||
port map(
|
||||
reset_n => reset_n_rx_clk, -- should be synchronised to rx_clk
|
||||
generic map (
|
||||
data_width => 8)
|
||||
port map (
|
||||
reset_n => reset_n,
|
||||
clk => rx_clk,
|
||||
bit_div => bit_div_dest, -- synchronised
|
||||
bit_div => bit_div,
|
||||
init => clear_i,
|
||||
data_out => rx_symbol,
|
||||
data_out_valid => rx_symbol_val,
|
||||
|
|
@ -138,42 +116,37 @@ begin
|
|||
rx_data => rx_data);
|
||||
|
||||
-- Synchronize to the local clock
|
||||
pLATCH_RX_DATA : process(rx_clk)
|
||||
begin
|
||||
if(rx_clk = '1' and rx_clk'event) then
|
||||
if(rx_symbol_val = '1') then
|
||||
symbol <= rx_symbol;
|
||||
end if;
|
||||
if(rx_symbol_val = '1') then
|
||||
rx_symbol_val_v <= "1111";
|
||||
else
|
||||
rx_symbol_val_v <= '0' & rx_symbol_val_v(3 downto 1);
|
||||
end if;
|
||||
if(rx_error = '1') then
|
||||
rx_error_v <= "1111";
|
||||
else
|
||||
rx_error_v <= '0' & rx_error_v(3 downto 1);
|
||||
end if;
|
||||
end if;
|
||||
end process pLATCH_RX_DATA;
|
||||
|
||||
iCDC_SYMBOL : entity work.cdc_data_handshake_1
|
||||
generic map(
|
||||
DATA_WIDTH => rx_symbol'length
|
||||
)
|
||||
port map(
|
||||
arst_n => reset_n,
|
||||
src_clk => rx_clk,
|
||||
src_valid => rx_symbol_val,
|
||||
src_data => rx_symbol,
|
||||
src_ack => open,
|
||||
dest_clk => clk,
|
||||
dest_valid => symbol_valid,
|
||||
dest_data => symbol_i
|
||||
);
|
||||
iSYNC_SYMBOL_VAL : entity work.sync_wire_rEdge_1
|
||||
generic map (rst_val => '0', sync_stages => 3)
|
||||
port map (rstN => reset_n, clk => clk, async_in => rx_symbol_val_v(0), sync_out => symbol_valid);
|
||||
|
||||
iCDC_ERROR : entity work.cdc_data_handshake_1
|
||||
generic map(
|
||||
DATA_WIDTH => 1 -- unused
|
||||
)
|
||||
port map(
|
||||
arst_n => reset_n,
|
||||
src_clk => rx_clk,
|
||||
src_valid => rx_error,
|
||||
src_data => open,
|
||||
src_ack => open,
|
||||
dest_clk => clk,
|
||||
dest_valid => rx_error_i,
|
||||
dest_data => open
|
||||
);
|
||||
|
||||
-- synchronize clear to rx_clk
|
||||
iSYNC_CLEAR : entity work.sync_wire_1
|
||||
generic map(rst_val => '1', sync_stages => 2)
|
||||
port map(
|
||||
rstN => reset_n_rx_clk, clk => rx_clk, async_in => clear, sync_out => clear_i);
|
||||
iSYNC_RX_ERROR : entity work.sync_wire_rEdge_1
|
||||
generic map (rst_val => '0', sync_stages => 3)
|
||||
port map (rstN => reset_n, clk => clk, async_in => rx_error_v(0), sync_out => rx_error_i);
|
||||
-- synchronize clear to tx_clk
|
||||
iSYNC_CLEAR: entity work.sync_wire_1
|
||||
generic map (rst_val => '1', sync_stages => 2)
|
||||
port map (
|
||||
rstN => reset_n, clk => rx_clk, async_in => clear, sync_out => clear_i);
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Toggle-Bits Decoding
|
||||
|
|
@ -181,54 +154,56 @@ begin
|
|||
|
||||
pTOGGLE_DEC : process(clk)
|
||||
begin
|
||||
if (clk = '1' and clk'event) then
|
||||
if(clk = '1' and clk'event) then
|
||||
-- Toggle Bits
|
||||
if (clear = '1') then
|
||||
if(clear = '1') then
|
||||
toggle_sync <= '0';
|
||||
elsif (sync_confirmed = '1') then
|
||||
toggle_sync <= not toggle_sync;
|
||||
elsif(sync_confirmed = '1') then
|
||||
toggle_sync <= not toggle_sync;
|
||||
end if;
|
||||
if (clear = '1' or sync_confirmed = '1' or (symbol_valid_i = '1' and symbol_i(0) = toggle_sync)) then
|
||||
if(clear = '1' or sync_confirmed = '1' or (symbol_valid_i = '1' and symbol_i(0) = toggle_sync)) then
|
||||
sync_toggle_test <= '0';
|
||||
elsif (sync_gen = '1') then
|
||||
elsif(sync_gen = '1') then
|
||||
sync_toggle_test <= '1';
|
||||
end if;
|
||||
sync <= sync_confirmed;
|
||||
sync_d <= sync;
|
||||
if (clear = '1') then
|
||||
sync <= sync_confirmed;
|
||||
sync_d <= sync;
|
||||
if(clear = '1') then
|
||||
toggle_pd <= '0';
|
||||
elsif (pd_confirmed = '1') then
|
||||
toggle_pd <= not toggle_pd;
|
||||
elsif(pd_confirmed = '1') then
|
||||
toggle_pd <= not toggle_pd;
|
||||
end if;
|
||||
if (clear = '1' or pd_confirmed = '1' or (symbol_valid_i = '1' and symbol_i(2) = toggle_pd)) then
|
||||
if(clear = '1' or pd_confirmed = '1' or (symbol_valid_i = '1' and symbol_i(2) = toggle_pd)) then
|
||||
pd_toggle_test <= '0';
|
||||
elsif (pd_gen = '1') then
|
||||
elsif(pd_gen = '1') then
|
||||
pd_toggle_test <= '1';
|
||||
end if;
|
||||
pd <= pd_confirmed;
|
||||
pd <= pd_confirmed;
|
||||
--
|
||||
symbol_valid_i <= symbol_valid and symbol_ok;
|
||||
symbol_error <= symbol_valid and not symbol_ok;
|
||||
if (clear = '1') then
|
||||
if(clear = '1') then
|
||||
parity_err_cnt_i <= (others => '0');
|
||||
elsif (symbol_error = '1') then
|
||||
parity_err_cnt_i <= std_logic_vector(unsigned(parity_err_cnt_i) + 1);
|
||||
elsif(symbol_error = '1') then
|
||||
parity_err_cnt_i <= std_logic_vector(unsigned(parity_err_cnt_i)+1);
|
||||
end if;
|
||||
end if;
|
||||
end process pTOGGLE_DEC;
|
||||
|
||||
symbol_i <= symbol;
|
||||
|
||||
-- The received symbol is assumed to be vaild when there is not parity error
|
||||
-- and when the two bits with the PD-toggle bit are equal
|
||||
symbol_ok <= '1' when odd_parity_check(symbol_i) = '1' and (symbol_i(1) = symbol_i(2)) else '0';
|
||||
symbol_ok <= '1' when odd_parity_check(symbol) = '1' and (symbol(1) = symbol(2)) else '0';
|
||||
|
||||
sync_gen <= '1' when symbol_valid_i = '1' and symbol_i(0) /= toggle_sync else '0';
|
||||
pd_gen <= '1' when symbol_valid_i = '1' and symbol_i(2) /= toggle_pd else '0';
|
||||
sync_gen <= '1' when symbol_valid_i = '1' and symbol_i(0) /= toggle_sync else '0';
|
||||
pd_gen <= '1' when symbol_valid_i = '1' and symbol_i(2) /= toggle_pd else '0';
|
||||
--
|
||||
sync_confirmed <= sync_gen and sync_toggle_test;
|
||||
pd_confirmed <= pd_gen and pd_toggle_test;
|
||||
pd_confirmed <= pd_gen and pd_toggle_test;
|
||||
--
|
||||
init_out <= sync;
|
||||
pd_out <= pd;
|
||||
init_out <= sync;
|
||||
pd_out <= pd;
|
||||
|
||||
parity_err_cnt <= parity_err_cnt_i;
|
||||
|
||||
|
|
@ -240,63 +215,64 @@ begin
|
|||
next_pos_lsb <= gray2bin(gray_pos);
|
||||
curr_pos_lsb <= abs_pos_i(3 downto 0);
|
||||
|
||||
abs_dist <= dist when dist(3) = '0' else std_logic_vector(unsigned(not dist) + 1);
|
||||
--dist <= std_logic_vector(signed(next_pos_lsb)-signed(curr_pos_lsb));
|
||||
abs_dist <= dist when dist(3) = '0' else std_logic_vector(unsigned(not dist)+1);
|
||||
|
||||
pPOS_MNG : process(clk)
|
||||
begin
|
||||
if (clk = '1' and clk'event) then
|
||||
dist <= std_logic_vector(signed(next_pos_lsb) - signed(curr_pos_lsb));
|
||||
if(clk = '1' and clk'event) then
|
||||
dist <= std_logic_vector(signed(next_pos_lsb)-signed(curr_pos_lsb));
|
||||
symbol_valid_d <= symbol_valid_i;
|
||||
if (clear = '1' or (symbol_valid_d = '1' and signed(dist) = 0) or pos_recovery = '1') then
|
||||
if(clear = '1' or (symbol_valid_d = '1' and signed(dist) = 0) or pos_recovery = '1') then
|
||||
max_dist <= "0001";
|
||||
elsif (skip_pos = '1' or rx_error_i = '1') then
|
||||
elsif(skip_pos = '1' or rx_error_i = '1') then
|
||||
max_dist <= std_logic_vector(unsigned(max_dist) + 1);
|
||||
end if;
|
||||
if (symbol_valid_d = '1' and valid_pos = '1') then
|
||||
if(symbol_valid_d = '1' and valid_pos = '1') then
|
||||
pos_corr <= abs_dist;
|
||||
elsif (apply_corr = '1') then
|
||||
pos_corr <= std_logic_vector(unsigned(pos_corr) - 1);
|
||||
elsif(apply_corr = '1') then
|
||||
pos_corr <= std_logic_vector(unsigned(pos_corr)-1);
|
||||
end if;
|
||||
if (clear = '1' or corr_done = '1') then
|
||||
if(clear = '1' or corr_done = '1') then
|
||||
upd_pos <= '0';
|
||||
elsif (symbol_valid_d = '1' and valid_pos = '1') then
|
||||
elsif(symbol_valid_d = '1' and valid_pos = '1') then
|
||||
upd_pos <= '1';
|
||||
end if;
|
||||
if (upd_pos = '0' or unsigned(clk_cnt) = 2) then
|
||||
if(upd_pos = '0' or unsigned(clk_cnt) = 2) then
|
||||
clk_cnt <= (others => '0');
|
||||
else
|
||||
clk_cnt <= std_logic_vector(unsigned(clk_cnt) + 1);
|
||||
clk_cnt <= std_logic_vector(unsigned(clk_cnt)+1);
|
||||
end if;
|
||||
if (symbol_valid_d = '1' and valid_pos = '1') then
|
||||
if(symbol_valid_d = '1' and valid_pos = '1') then
|
||||
corr_sign <= dist(3);
|
||||
end if;
|
||||
inc_pos_i <= inc_pos_ii;
|
||||
dec_pos_i <= dec_pos_ii;
|
||||
inc_pos <= inc_pos_i;
|
||||
dec_pos <= dec_pos_i;
|
||||
if (clear = '1' or sync = '1') then
|
||||
inc_pos_i <= inc_pos_ii;
|
||||
dec_pos_i <= dec_pos_ii;
|
||||
inc_pos <= inc_pos_i;
|
||||
dec_pos <= dec_pos_i;
|
||||
if(clear = '1' or sync = '1') then
|
||||
abs_pos_i <= (others => '0');
|
||||
elsif (inc_pos_ii = '1') then
|
||||
abs_pos_i <= std_logic_vector(signed(abs_pos_i) + 1);
|
||||
elsif (dec_pos_ii = '1') then
|
||||
abs_pos_i <= std_logic_vector(signed(abs_pos_i) - 1);
|
||||
elsif(inc_pos_ii = '1') then
|
||||
abs_pos_i <= std_logic_vector(signed(abs_pos_i)+1);
|
||||
elsif(dec_pos_ii = '1') then
|
||||
abs_pos_i <= std_logic_vector(signed(abs_pos_i)-1);
|
||||
end if;
|
||||
abs_pos <= abs_pos_i;
|
||||
skip_pos_d <= skip_pos;
|
||||
if (clear = '1' or (symbol_valid_d = '1' and valid_pos = '1')) then
|
||||
abs_pos <= abs_pos_i;
|
||||
skip_pos_d <= skip_pos;
|
||||
if(clear = '1' or (symbol_valid_d = '1' and valid_pos = '1')) then
|
||||
skip_cnt <= (others => '0');
|
||||
elsif (skip_pos = '1' and skip_pos_d = '0') then
|
||||
skip_cnt <= std_logic_vector(unsigned(skip_cnt) + 1);
|
||||
elsif(skip_pos = '1' and skip_pos_d = '0') then
|
||||
skip_cnt <= std_logic_vector(unsigned(skip_cnt)+1);
|
||||
end if;
|
||||
if (clear = '1') then
|
||||
if(clear = '1') then
|
||||
skip_pos_cnt_i <= (others => '0');
|
||||
elsif (skip_pos_d = '1') then
|
||||
skip_pos_cnt_i <= std_logic_vector(unsigned(skip_pos_cnt_i) + 1);
|
||||
elsif(skip_pos_d = '1') then
|
||||
skip_pos_cnt_i <= std_logic_vector(unsigned(skip_pos_cnt_i)+1);
|
||||
end if;
|
||||
end if;
|
||||
end process pPOS_MNG;
|
||||
|
||||
skip_pos <= '1' when (symbol_valid = '1' and symbol_ok = '0') or (symbol_valid_d = '1' and valid_pos = '0') else '0';
|
||||
skip_pos <= '1' when (symbol_valid = '1' and symbol_ok = '0') or (symbol_valid_d = '1' and valid_pos = '0' ) else '0';
|
||||
|
||||
pos_recovery <= '1' when unsigned(skip_cnt) >= 3 else '0';
|
||||
valid_pos <= '1' when unsigned(abs_dist) <= unsigned(max_dist) or pos_recovery = '1' else '0';
|
||||
|
|
@ -315,26 +291,26 @@ begin
|
|||
|
||||
pERROR_REPORTING : process(clk)
|
||||
begin
|
||||
if (clk = '1' and clk'event) then
|
||||
if (clear = '1' or one_pps = '1') then
|
||||
if(clk = '1' and clk'event) then
|
||||
if(clear = '1' or one_pps = '1') then
|
||||
error_rate_cnt <= (others => '0');
|
||||
elsif (symbol_error = '1') then
|
||||
error_rate_cnt <= std_logic_vector(unsigned(error_rate_cnt) + 1);
|
||||
elsif(symbol_error = '1') then
|
||||
error_rate_cnt <= std_logic_vector(unsigned(error_rate_cnt)+1);
|
||||
end if;
|
||||
if (clear = '1') then
|
||||
if(clear = '1') then
|
||||
error_rate <= (others => '0');
|
||||
elsif (one_pps = '1') then
|
||||
elsif(one_pps = '1') then
|
||||
error_rate <= error_rate_cnt;
|
||||
end if;
|
||||
max_error_flag <= not clear and max_error_flag_i;
|
||||
if (clear = '1' or symbol_valid_i = '1' or rx_watchdog_clr = '1') then
|
||||
if(clear = '1' or symbol_valid_i = '1' or rx_watchdog_clr = '1') then
|
||||
rx_wd_cnt <= (others => '0');
|
||||
else
|
||||
rx_wd_cnt <= std_logic_vector(unsigned(rx_wd_cnt) + 1);
|
||||
rx_wd_cnt <= std_logic_vector(unsigned(rx_wd_cnt)+1);
|
||||
end if;
|
||||
if (clear = '1' or rx_watchdog_clr = '1' or rx_watchdog_en = '0' or sync = '1') then
|
||||
if(clear = '1' or rx_watchdog_clr = '1' or rx_watchdog_en = '0' or sync = '1') then
|
||||
rx_watchdog <= '0';
|
||||
elsif (unsigned(rx_wd_cnt) > 1000) then
|
||||
elsif(unsigned(rx_wd_cnt) > 1000) then
|
||||
rx_watchdog <= '1';
|
||||
end if;
|
||||
end if;
|
||||
|
|
@ -358,24 +334,24 @@ begin
|
|||
|
||||
pENC_MNG : process(clk)
|
||||
begin
|
||||
if (clk = '1' and clk'event) then
|
||||
if(clk = '1' and clk'event) then
|
||||
dp_dir_d <= dp_dir;
|
||||
if (sync_d = '1' or dp_dir_change = '1' or new_max = '1' or upd_max_pos = '1') then
|
||||
if(sync_d = '1' or dp_dir_change = '1' or new_max = '1' or upd_max_pos = '1') then
|
||||
pos_max <= abs_pos_i;
|
||||
end if;
|
||||
if (sync_d = '1' or dp_dir_change = '1' or new_min = '1' or upd_min_pos = '1') then
|
||||
if(sync_d = '1' or dp_dir_change = '1' or new_min = '1' or upd_min_pos = '1') then
|
||||
pos_min <= abs_pos_i;
|
||||
end if;
|
||||
enc_out <= new_min or new_max;
|
||||
enc_out <= new_min or new_max;
|
||||
end if;
|
||||
end process pENC_MNG;
|
||||
|
||||
dp_dir_change <= dp_dir xor dp_dir_d;
|
||||
|
||||
dist_pos <= std_logic_vector(signed(abs_pos_i) - signed(pos_max));
|
||||
dist_neg <= std_logic_vector(signed(pos_min) - signed(abs_pos_i));
|
||||
dist_pos <= std_logic_vector(signed(abs_pos_i)-signed(pos_max));
|
||||
dist_neg <= std_logic_vector(signed(pos_min)-signed(abs_pos_i));
|
||||
|
||||
new_max <= '1' when inc_pos_i = '1' and dp_dir = '0' and dist_pos(31) = '0' and unsigned(dist_pos(3 downto 0)) /= 0 else '0';
|
||||
new_min <= '1' when dec_pos_i = '1' and dp_dir = '1' and dist_neg(31) = '0' and unsigned(dist_neg(3 downto 0)) /= 0 else '0';
|
||||
|
||||
|
||||
end architecture rtl;
|
||||
|
|
|
|||
|
|
@ -3,18 +3,17 @@
|
|||
-------------------------------------------------------------------------------
|
||||
-- File : sync_wire.vhd
|
||||
-- Author : Gianmarco Girau <ggianmarco.girau@gmail.com>
|
||||
-- Company : GIS
|
||||
-- Company : On my own
|
||||
-- Target : Generic (simulation), Generic (synthesis)
|
||||
-- Dependency : none
|
||||
-------------------------------------------------------------------------------
|
||||
-- Description: synchronize a std_logic signal to a clock domain
|
||||
-------------------------------------------------------------------------------
|
||||
-- Last update: 2019-05-22
|
||||
-- Last update: 2015-08-17
|
||||
-------------------------------------------------------------------------------
|
||||
-- Revisions :
|
||||
-- Date Version Author Description
|
||||
-- 2010-10-25 1.0 gmg Created
|
||||
-- 2019-05-22 1.1 ds added altera attribute
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
library ieee;
|
||||
|
|
@ -25,39 +24,36 @@ entity sync_wire_1 is
|
|||
rst_val : std_logic := '0';
|
||||
sync_stages : positive := 2);
|
||||
port(
|
||||
rstN : in std_logic;
|
||||
clk : in std_logic;
|
||||
async_in : in std_logic;
|
||||
sync_out : out std_logic);
|
||||
rstN : in std_logic;
|
||||
clk : in std_logic;
|
||||
async_in : in std_logic;
|
||||
sync_out : out std_logic);
|
||||
end sync_wire_1;
|
||||
|
||||
architecture RTL of sync_wire_1 is
|
||||
|
||||
signal sync_sig : std_logic_vector(sync_stages - 1 downto 0);
|
||||
-- declare false path for the input to the synchroniser
|
||||
attribute altera_attribute : string;
|
||||
attribute altera_attribute of RTL : architecture is
|
||||
"-name SDC_STATEMENT ""set_false_path -from [get_keepers *] -to [get_keepers {*sync_wire_1:*sync_sig[0]}]"" ";
|
||||
signal sync_sig : std_logic_vector(sync_stages-1 downto 0);
|
||||
|
||||
begin
|
||||
|
||||
pSYNC : process(rstN, clk)
|
||||
begin
|
||||
if (rstN = '0') then
|
||||
for n in 0 to sync_stages - 1 loop
|
||||
if(rstN = '0') then
|
||||
for n in 0 to sync_stages-1 loop
|
||||
sync_sig(n) <= rst_val;
|
||||
end loop; -- n
|
||||
elsif (clk = '1' and clk'event) then
|
||||
for n in 0 to sync_stages - 1 loop
|
||||
if (n = 0) then
|
||||
end loop; -- n
|
||||
elsif(clk = '1' and clk'event) then
|
||||
for n in 0 to sync_stages-1 loop
|
||||
if(n = 0) then
|
||||
sync_sig(0) <= async_in;
|
||||
else
|
||||
sync_sig(n) <= sync_sig(n - 1);
|
||||
sync_sig(n) <= sync_sig(n-1);
|
||||
end if;
|
||||
end loop; -- n
|
||||
end loop; -- n
|
||||
end if;
|
||||
end process pSYNC;
|
||||
|
||||
sync_out <= sync_sig(sync_stages - 1);
|
||||
sync_out <= sync_sig(sync_stages-1);
|
||||
|
||||
end RTL;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,18 +3,17 @@
|
|||
-------------------------------------------------------------------------------
|
||||
-- File : sync_wire_rEdge.vhd
|
||||
-- Author : Gianmarco Girau <ggianmarco.girau@gmail.com>
|
||||
-- Company : GIS
|
||||
-- Company : On my own
|
||||
-- Target : Generic (simulation), Generic (synthesis)
|
||||
-- Dependency : none
|
||||
-------------------------------------------------------------------------------
|
||||
-- Description: synchronize a std_logic signal to a clock domain with rising edge
|
||||
-------------------------------------------------------------------------------
|
||||
-- Last update: 2019-05-22
|
||||
-- Last update: 2015-08-17
|
||||
-------------------------------------------------------------------------------
|
||||
-- Revisions :
|
||||
-- Date Version Author Description
|
||||
-- 2010-12-03 1.0 gmg Created
|
||||
-- 2019-05-22 1.1 ds added altera attribute
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
library ieee;
|
||||
|
|
@ -25,42 +24,39 @@ entity sync_wire_rEdge_1 is
|
|||
rst_val : std_logic := '0';
|
||||
sync_stages : positive := 2);
|
||||
port(
|
||||
rstN : in std_logic;
|
||||
clk : in std_logic;
|
||||
async_in : in std_logic;
|
||||
sync_out : out std_logic);
|
||||
rstN : in std_logic;
|
||||
clk : in std_logic;
|
||||
async_in : in std_logic;
|
||||
sync_out : out std_logic);
|
||||
end sync_wire_rEdge_1;
|
||||
|
||||
architecture RTL of sync_wire_rEdge_1 is
|
||||
|
||||
signal sync_out_i, sync_out_d : std_logic;
|
||||
signal sync_sig : std_logic_vector(sync_stages - 1 downto 0);
|
||||
-- declare false path for the input to the synchroniser
|
||||
attribute altera_attribute : string;
|
||||
attribute altera_attribute of RTL : architecture is
|
||||
"-name SDC_STATEMENT ""set_false_path -from [get_keepers *] -to [get_keepers {*sync_wire_rEdge_1:*sync_sig[0]}]"" ";
|
||||
signal sync_sig : std_logic_vector(sync_stages-1 downto 0);
|
||||
|
||||
begin
|
||||
|
||||
pSYNC : process(rstN, clk)
|
||||
begin
|
||||
if (rstN = '0') then
|
||||
if(rstN = '0') then
|
||||
sync_out_d <= rst_val;
|
||||
for n in 0 to sync_stages - 1 loop
|
||||
for n in 0 to sync_stages-1 loop
|
||||
sync_sig(n) <= rst_val;
|
||||
end loop; -- n
|
||||
elsif (clk = '1' and clk'event) then
|
||||
end loop; -- n
|
||||
elsif(clk = '1' and clk'event) then
|
||||
sync_out_d <= sync_out_i;
|
||||
for n in 0 to sync_stages - 1 loop
|
||||
if (n = 0) then
|
||||
for n in 0 to sync_stages-1 loop
|
||||
if(n = 0) then
|
||||
sync_sig(0) <= async_in;
|
||||
else
|
||||
sync_sig(n) <= sync_sig(n - 1);
|
||||
sync_sig(n) <= sync_sig(n-1);
|
||||
end if;
|
||||
end loop; -- n
|
||||
end loop; -- n
|
||||
end if;
|
||||
end process pSYNC;
|
||||
|
||||
sync_out_i <= sync_sig(sync_stages - 1);
|
||||
sync_out_i <= sync_sig(sync_stages-1);
|
||||
-- rising edge detect
|
||||
sync_out <= sync_out_i and not sync_out_d;
|
||||
|
||||
|
|
|
|||
|
|
@ -48,9 +48,9 @@ architecture behav of fire_pulse_manager_1_tb is
|
|||
constant CLK_FREQ : real := 100.0e6;
|
||||
|
||||
constant TX_CLK_PERIOD : time := CLK_PERIOD; -- nominally the same as clk_period
|
||||
-- TODO Try different receive oversampling ratios - 300MHz is in the real system
|
||||
constant RX_CLK_PERIOD : time := CLK_PERIOD / 3; -- clock period for used by the
|
||||
-- UART-Rx on the POF
|
||||
|
||||
constant RX_CLK_PERIOD : time := 5.0 ns; -- clock period for used by the
|
||||
-- UART-Rx on the POF
|
||||
|
||||
constant POF_DELAY : time := 30 ns; -- Total delay from POF-Tx input to POF-Rx output
|
||||
|
||||
|
|
@ -546,8 +546,8 @@ begin -- behav
|
|||
-- Config fire_pulse_manager control registers:
|
||||
-- Enable the POF-Rx
|
||||
addr := std_logic_vector(to_unsigned(3, 32));
|
||||
data := X"0000_8061"; -- set bit_div to 6 to match the 50MBd TX signal to the 300MHz RX_CLK
|
||||
-- Write the data to the register
|
||||
data := X"0000_8041";
|
||||
-- Write the data to the register
|
||||
mm_32b_write(addr, data, avs_s, avs_m);
|
||||
-- Select pulse generator
|
||||
addr := std_logic_vector(to_unsigned(2, 32));
|
||||
|
|
|
|||
|
|
@ -24,12 +24,10 @@ entity uart_regen_1 is
|
|||
port(
|
||||
reset_n : in std_logic;
|
||||
clk : in std_logic;
|
||||
-- must all be synchronous to clk
|
||||
bit_div : in std_logic_vector(3 downto 0); -- number of clock cycles per tx bit
|
||||
bit_div : in std_logic_vector(3 downto 0); -- number of clock cycles per tx bit
|
||||
enable : in std_logic;
|
||||
bypass_en : in std_logic;
|
||||
--
|
||||
uart_rx : in std_logic; -- will be on an unrelated, domain - typically one bit is 4 to 6 clk periods long
|
||||
uart_rx : in std_logic;
|
||||
uart_tx : out std_logic);
|
||||
end entity uart_regen_1;
|
||||
|
||||
|
|
@ -62,6 +60,9 @@ begin
|
|||
async_in => uart_rx,
|
||||
sync_out => uart_rx_i);
|
||||
|
||||
-- NOTE : No NEED TO SYNCHRONIZE TO THE LOCAL CLOCK inputs enable, bypass_en
|
||||
-- and bit_biv BECAUSE THOSE SIGNALS ARE PREDOMINANTLY STATIC
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- UART registers and sequential logic
|
||||
-----------------------------------------------------------------------------
|
||||
|
|
@ -116,7 +117,7 @@ begin
|
|||
end process pFSM_SR;
|
||||
|
||||
-- FSM Combinational Logic
|
||||
pFSM_CL : process(all)
|
||||
pFSM_CL : process(fsm_state_curr, uart_rx_i, end_of_bit, end_of_rx, clk_cnt, bit_div)
|
||||
begin
|
||||
--default assignments
|
||||
rst_clk_cnt <= '0';
|
||||
|
|
|
|||
|
|
@ -35,6 +35,17 @@ end entity uart_rx_1;
|
|||
|
||||
architecture rtl of uart_rx_1 is
|
||||
|
||||
component sync_wire_1
|
||||
generic(
|
||||
rst_val : std_logic;
|
||||
sync_stages : positive);
|
||||
port(
|
||||
rstN : in std_logic;
|
||||
clk : in std_logic;
|
||||
async_in : in std_logic;
|
||||
sync_out : out std_logic);
|
||||
end component;
|
||||
|
||||
type fsm_state_t is (s_init, s_idle, s_get_start_bit, s_get_data, s_get_stop_bit);
|
||||
|
||||
signal fsm_state_curr, fsm_state_next : fsm_state_t;
|
||||
|
|
@ -53,7 +64,7 @@ begin
|
|||
-- Input Synchronization
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
iSYNC_IN : entity work.sync_wire_1
|
||||
iSYNC_IN : sync_wire_1
|
||||
generic map(
|
||||
rst_val => '1',
|
||||
sync_stages => 3)
|
||||
|
|
@ -170,6 +181,7 @@ begin
|
|||
end if;
|
||||
end if;
|
||||
|
||||
when others => null;
|
||||
end case;
|
||||
end process pFSM_CL;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
"bus": "csr",
|
||||
"addr_width": "4",
|
||||
"description": "This block is the generic versioning",
|
||||
"notes": "NB: this block is a key component that is parsed externally, and cannot be renamed with major number tags in order to be processed correctly. Therefore do not modify the source code for this block. If a change is required for a project then a whole new component will be necessary and this signed off in review by the embedded logic line manager.",
|
||||
"notes" : "NB: this block is a key component that is parsed externally, and cannot be renamed with major number tags in order to be processed correctly. Therefore do not modify the source code for this block. If a change is required for a project then a whole new component will be necessary and this signed off in review by the embedded logic line manager.",
|
||||
"registers": {
|
||||
"ip_id": {
|
||||
"address": "0",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue