Commit 2b615c20 authored by Evangelia Gousiou's avatar Evangelia Gousiou

WIP: added 2 more rx status bits: one activated upon CTRL byte reception and one…

WIP: added 2 more rx status bits: one activated upon CTRL byte reception and one upon detection of more bytes than the max frame size
parent 0c53da28
......@@ -440,7 +440,6 @@ begin
-- counter counting the turnaround time i.e. the time after the end of transmission of a frame
-- (tx_completed_p), or after the end of reception of a frame (rx_frame_ok_p/ rx_crc_wrong_p)
-- and before the transmission of a new frame.
-- Note that the MT is using the turnar_cnt rather than the 1-clk-tick long counter_is_zero pulse
-- turnaround counter
cmp_turnaround_cnt: decr_counter
......@@ -451,7 +450,7 @@ begin
counter_load_i => turnar_load_p,
counter_top_i => reg_from_mt.turnar_lgth_o,
counter_o => reg_to_mt.turnar_time_cnt_i,
counter_is_zero_o => open);
counter_is_zero_o => open); -- too fast to be used by MT
-- -- -- -- -- -- -- -- -- -- --
turnar_load_p <= tx_completed_p or rx_frame_ok_p or rx_crc_wrong_p or reg_from_mt.turnar_start_o;
-- note: turnar_start_o is a monostable, 1-clk-tick-long pulse
......@@ -473,7 +472,7 @@ begin
counter_load_i => silen_load_p,
counter_top_i => reg_from_mt.silen_lgth_o,
counter_o => reg_to_mt.silen_time_cnt_i,
counter_is_zero_o => open);
counter_is_zero_o => open); -- too fast to be used by MT
-- -- -- -- -- -- -- -- -- -- --
silen_load_p <= tx_completed_p or rx_frame_ok_p or rx_crc_wrong_p or reg_from_mt.silen_start_o;
-- note: turnar_start_o is a monostable, 1-clk-tick-long pulse
......@@ -493,10 +492,12 @@ begin
rx_byte_index_o => rx_byte_index, -- current byte index
rx_word_index_o => reg_to_mt.rx_stat_curr_word_indx_i(C_FRAME_WORDS_CNT_LGTH-1 downto 0),
rx_ctrl_byte_o => reg_to_mt.rx_payld_ctrl_i,
rx_ctrl_byte_ok_o => reg_to_mt.rx_stat_ctrl_byte_ok_i,
rx_frame_o => rx_frame,
rx_fss_crc_fes_ok_p_o => rx_frame_ok_p,
rx_fss_received_p_o => rx_fss_received_p,
rx_crc_wrong_p_o => rx_crc_wrong_p,
rx_bytes_num_err_o => reg_to_mt.rx_stat_bytes_num_err_i,
rx_byte_o => rx_byte, -- for debugging
rx_byte_ready_p_o => rx_byte_ready_p);-- for debugging
......
......@@ -59,8 +59,8 @@ package masterFIP_pkg is
-- Array of words with the WorldFIP produced/consumed PAYLOAD bytes --
---------------------------------------------------------------------------------------------------
constant C_BYTE_WIDTH : integer := 8;
constant C_WORD_WIDTH : integer := 32;
constant C_BYTE_WIDTH : integer := 8; -- 8-bit bytes
constant C_WORD_WIDTH : integer := 32; -- 32-bit words
-- Declaration of a structure with 67 words of 32-bit each = 268 bytes which represent the max
-- length of a frame, including
......@@ -74,15 +74,23 @@ package masterFIP_pkg is
-- until the FES detection; therefore the max amount of bytes expected to be counted by the
-- deserializer is 266. Upon the rx_fss_crc_fes_ok_p_o the processor needs to read the rx_ctrl_byte
-- (separate register, not included in the rx_frame structure) and rx_byte_index_o-4 bytes from the
-- rx_frame structure (minus the CTRL, CRC and FES bytes).
-- rx_frame structure (minus the CTRL, 2x CRC and FES bytes).
-- Note that the serializer, is counting one by one the bytes that are serialized, after the FSS and
-- before the CRC; therefore the max amount of bytes expected to be counted by the serializer is
-- 263.
constant C_MAX_FRAME_WORDS : integer := 67;
constant C_FRAME_WORDS_CNT_LGTH : integer := 7; -- ((std_logic_vector(C_MAX_FRAME_WORDS))'left)
constant C_FRAME_BYTES_CNT_LGTH : integer := 9; -- (((std_logic_vector(C_MAX_FRAME_WORDS) srl 2))'left)
constant C_MAX_FRAME_BYTES : integer := 266;
constant C_FRAME_WORDS_CNT_LGTH : integer := 7; -- counter overflows after 128 words = 512 bytes
-- for normal rx operation it should not exceed
-- 67 words; for normal tx operation it should
-- not exceed 66 words
constant C_FRAME_BYTES_CNT_LGTH : integer := 9; -- counter overflows after 128 words = 512 bytes
-- for normal rx operation it should not exceed
-- 266 bytes; for normal tx operation it should
-- not exceed 263 bytes
subtype data_word is std_logic_vector(C_WORD_WIDTH-1 downto 0);
......@@ -177,12 +185,14 @@ package masterFIP_pkg is
rx_byte_index_o : out std_logic_vector(C_FRAME_BYTES_CNT_LGTH-1 downto 0);
rx_word_index_o : out std_logic_vector(C_FRAME_WORDS_CNT_LGTH-1 downto 0);
rx_ctrl_byte_o : out std_logic_vector(C_BYTE_WIDTH-1 downto 0);
rx_ctrl_byte_ok_o : out std_logic;
rx_frame_o : out rx_frame_t;
rx_byte_o : out std_logic_vector(C_BYTE_WIDTH-1 downto 0);
rx_byte_ready_p_o : out std_logic;
rx_fss_crc_fes_ok_p_o : out std_logic;
rx_fss_received_p_o : out std_logic;
rx_crc_wrong_p_o : out std_logic );
rx_crc_wrong_p_o : out std_logic;
rx_bytes_num_err_o : out std_logic);
end component masterfip_rx;
......
......@@ -139,6 +139,9 @@ entity masterfip_rx is port(
rx_ctrl_byte_o : out std_logic_vector(C_BYTE_WIDTH-1 downto 0); -- frame CTRL byte
rx_ctrl_byte_ok_o : out std_logic; -- active after the reception of the CTRL byte (first
-- byte after FSS) and until a rst_i OR rst_rx_i
rx_frame_o : out rx_frame_t; -- frame DATA bytes
-- structure with 67 words of 32-bit each = 268 bytes
-- able to house a frame of max length.
......@@ -153,7 +156,10 @@ entity masterfip_rx is port(
rx_crc_wrong_p_o : out std_logic; -- indication of a frame with wrong CRC; pulse upon FES
rx_fss_received_p_o : out std_logic); -- pulse upon FSS detection (ID/ RP_DAT)
rx_fss_received_p_o : out std_logic; -- pulse upon FSS detection (ID/ RP_DAT)
rx_bytes_num_err_o : out std_logic); -- active after the reception of > C_MAX_FRAME_BYTES bytes
-- and until a rst_i OR rst_rx_i
end entity masterfip_rx;
......@@ -264,27 +270,49 @@ begin
rx_byte_index_o <= rx_byte_index;
---------------------------------------------------------------------------------------------------
-- rx bytes exceeded C_MAX_FRAME_BYTES --
---------------------------------------------------------------------------------------------------
-- indication that the rx counter exceeded the max expected number of bytes
p_rx_bytes_num_err: process (clk_i)
begin
if rising_edge (clk_i) then
if rst_i = '1' or rx_rst_i = '1' then
rx_bytes_num_err_o <= '0';
else
if unsigned(rx_byte_index) > C_MAX_FRAME_BYTES then
rx_bytes_num_err_o <= '1';
end if;
end if;
end if;
end process;
---------------------------------------------------------------------------------------------------
-- combination of four retrieved bytes to a 32-bit word --
---------------------------------------------------------------------------------------------------
-- note: the values of the CTRL byte and all payload regs are kept till a rx_rst_i or a rst_i
p_create_32bit_words: process (clk_i)
begin
if rising_edge (clk_i) then
if rst_i = '1' or rx_rst_i = '1' then
byte0 <= (others => '0');
byte1 <= (others => '0');
byte2 <= (others => '0');
byte3 <= (others => '0');
rx_ctrl_byte_o <= (others => '0');
else
byte0 <= (others => '0');
byte1 <= (others => '0');
byte2 <= (others => '0');
byte3 <= (others => '0');
rx_ctrl_byte_o <= (others => '0');
rx_ctrl_byte_ok_o <= '0';
else
if rx_byte_ready_p = '1' then
if unsigned(rx_byte_index) = resize(unsigned(c_CTRL_BYTE_INDEX),C_FRAME_BYTES_CNT_LGTH) then
rx_ctrl_byte_o <= rx_byte;
rx_ctrl_byte_o <= rx_byte; -- CTRL byte stored in separate word from the rest of the frame
rx_ctrl_byte_ok_o <= '1'; -- value kept till a rst
else
byte0 <= rx_byte;
byte1 <= byte0;
byte2 <= byte1;
byte3 <= byte2;
byte0 <= rx_byte;
byte1 <= byte0;
byte2 <= byte1;
byte3 <= byte2;
end if;
end if;
end if;
......@@ -340,8 +368,14 @@ begin
end if; -- Note: for [CRC|BYTE|BYTE|BYTE], upon
-- rx_fss_crc_fes_ok_p a new word has been created
elsif (rx_byte_ready_p = '1' and unsigned(rx_byte_index_d1) > 0 and unsigned(rx_byte_index_d1) mod 4 = 0) then
-- for the rest of the bytes, i.e. everything before the rx_fss_crc_fes_ok_p, a new word is
-- created after the reception of 4 bytes.
-- note that rx_byte_index is checked to be within the limits [1..262], as:
-- rx_byte_index = 0 refers to the CTRL byte that is written in a separate word, and
-- when rx_byte_index = 262: the one-but-last word (rx_frame_o(66)) of a max-length-frame
-- is written; the last word (rx_frame_o(67)) of a max-length-frame will be written
-- upon rx_fss_crc_fes_ok_p.
elsif (rx_byte_ready_p = '1' and unsigned(rx_byte_index_d1) > 0 and unsigned(rx_byte_index_d1) < 263 and unsigned(rx_byte_index_d1) mod 4 = 0) then
word32_num <= word32_num + 1;
rx_frame_o(word32_num) <= byte0 & byte1 & byte2 & byte3;
end if;
......
......@@ -3,8 +3,8 @@
---------------------------------------------------------------------------------------
-- File : masterfip_wbgen2_csr.vhd
-- Author : auto-generated by wbgen2 from masterfip_csr.wb
-- Created : 06/30/17 14:35:27
-- Version : 0x00010000
-- Created : 07/14/17 20:28:20
-- Version : 0x00020000
-- Standard : VHDL'87
---------------------------------------------------------------------------------------
-- THIS FILE WAS GENERATED BY wbgen2 FROM SOURCE FILE masterfip_csr.wb
......@@ -157,7 +157,7 @@ begin
ack_sreg <= "0000000000";
ack_in_progress <= '0';
rddata_reg <= "00000000000000000000000000000000";
masterfip_ver_id_int <= "00000000000000010000000000000000";
masterfip_ver_id_int <= "00000000000000100000000000000000";
masterfip_rst_core_int <= '0';
masterfip_rst_fd_int <= '0';
masterfip_led_rx_act_int <= '0';
......@@ -663,11 +663,11 @@ begin
if (wb_we_i = '1') then
end if;
rddata_reg(0) <= regs_i.rx_stat_pream_ok_i;
rddata_reg(1) <= regs_i.rx_stat_frame_ok_i;
rddata_reg(2) <= regs_i.rx_stat_frame_crc_err_i;
rddata_reg(1) <= regs_i.rx_stat_ctrl_byte_ok_i;
rddata_reg(2) <= regs_i.rx_stat_frame_ok_i;
rddata_reg(3) <= regs_i.rx_stat_frame_crc_err_i;
rddata_reg(4) <= regs_i.rx_stat_bytes_num_err_i;
rddata_reg(23 downto 8) <= regs_i.rx_stat_bytes_num_i;
rddata_reg(3) <= 'X';
rddata_reg(4) <= 'X';
rddata_reg(5) <= 'X';
rddata_reg(6) <= 'X';
rddata_reg(7) <= 'X';
......@@ -1820,8 +1820,10 @@ begin
-- rx Preamble(FSS) detected
-- rx CTRL byte detected
-- rx frame ok
-- rx frame crc error
-- rx bytes number error
-- rx number of payload bytes
-- current word index
-- rx number of frames with CRC error
......
......@@ -3,8 +3,8 @@
---------------------------------------------------------------------------------------
-- File : masterfip_wbgen2_pkg.vhd
-- Author : auto-generated by wbgen2 from masterfip_csr.wb
-- Created : 06/30/17 14:35:27
-- Version : 0x00010000
-- Created : 07/14/17 20:28:20
-- Version : 0x00020000
-- Standard : VHDL'87
---------------------------------------------------------------------------------------
-- THIS FILE WAS GENERATED BY wbgen2 FROM SOURCE FILE masterfip_csr.wb
......@@ -39,8 +39,10 @@ package masterfip_wbgen2_pkg is
fd_txer_cnt_i : std_logic_vector(31 downto 0);
fd_txer_tstamp_i : std_logic_vector(31 downto 0);
rx_stat_pream_ok_i : std_logic;
rx_stat_ctrl_byte_ok_i : std_logic;
rx_stat_frame_ok_i : std_logic;
rx_stat_frame_crc_err_i : std_logic;
rx_stat_bytes_num_err_i : std_logic;
rx_stat_bytes_num_i : std_logic_vector(15 downto 0);
rx_stat_curr_word_indx_i : std_logic_vector(7 downto 0);
rx_stat_crc_err_cnt_i : std_logic_vector(31 downto 0);
......@@ -133,8 +135,10 @@ package masterfip_wbgen2_pkg is
fd_txer_cnt_i => (others => '0'),
fd_txer_tstamp_i => (others => '0'),
rx_stat_pream_ok_i => '0',
rx_stat_ctrl_byte_ok_i => '0',
rx_stat_frame_ok_i => '0',
rx_stat_frame_crc_err_i => '0',
rx_stat_bytes_num_err_i => '0',
rx_stat_bytes_num_i => (others => '0'),
rx_stat_curr_word_indx_i => (others => '0'),
rx_stat_crc_err_cnt_i => (others => '0'),
......@@ -450,8 +454,10 @@ tmp.fd_wdg_tstamp_i := f_x_to_zero(left.fd_wdg_tstamp_i) or f_x_to_zero(right.fd
tmp.fd_txer_cnt_i := f_x_to_zero(left.fd_txer_cnt_i) or f_x_to_zero(right.fd_txer_cnt_i);
tmp.fd_txer_tstamp_i := f_x_to_zero(left.fd_txer_tstamp_i) or f_x_to_zero(right.fd_txer_tstamp_i);
tmp.rx_stat_pream_ok_i := f_x_to_zero(left.rx_stat_pream_ok_i) or f_x_to_zero(right.rx_stat_pream_ok_i);
tmp.rx_stat_ctrl_byte_ok_i := f_x_to_zero(left.rx_stat_ctrl_byte_ok_i) or f_x_to_zero(right.rx_stat_ctrl_byte_ok_i);
tmp.rx_stat_frame_ok_i := f_x_to_zero(left.rx_stat_frame_ok_i) or f_x_to_zero(right.rx_stat_frame_ok_i);
tmp.rx_stat_frame_crc_err_i := f_x_to_zero(left.rx_stat_frame_crc_err_i) or f_x_to_zero(right.rx_stat_frame_crc_err_i);
tmp.rx_stat_bytes_num_err_i := f_x_to_zero(left.rx_stat_bytes_num_err_i) or f_x_to_zero(right.rx_stat_bytes_num_err_i);
tmp.rx_stat_bytes_num_i := f_x_to_zero(left.rx_stat_bytes_num_i) or f_x_to_zero(right.rx_stat_bytes_num_i);
tmp.rx_stat_curr_word_indx_i := f_x_to_zero(left.rx_stat_curr_word_indx_i) or f_x_to_zero(right.rx_stat_curr_word_indx_i);
tmp.rx_stat_crc_err_cnt_i := f_x_to_zero(left.rx_stat_crc_err_cnt_i) or f_x_to_zero(right.rx_stat_crc_err_cnt_i);
......
......@@ -3,7 +3,7 @@
wbgen2 -V masterfip_wbgen2_csr.vhd -H record -p masterfip_wbgen2_pkg.vhd -s defines -C masterfip_wbgen2_csr.h -D masterfip_wbgen2_csr.html masterfip_csr.wb
echo ""
echo "Moving WB generated files to the following locations..."
echo "Moving wbgen2 generated files to the following locations..."
echo ""
mv -v ./master_wbgen2_csr.vhd ../.
......
......@@ -3,7 +3,7 @@ peripheral {
description = "Wishbone slave for FMC masterFIP core";
hdl_entity = "masterfip_wbgen2_csr";
prefix = "masterfip";
version = 1;
version = 0x020000; -- major: 02 minor: 00 micro: 00
-- Note that for html readability, some of the lines are longer than 100 characters.
......@@ -632,6 +632,19 @@ peripheral {
access_dev = WRITE_ONLY;
};
field {
name = "rx CTRL byte detected";
description = "indication that the deserializer has received the CTRL byte, i.e. the first byte after a Preamble(FSS);\
the bit stays active until a reset of the deserializer (this takes place automatically upon the activation of the serializer,\
OR upon a rx_ctrl_rst OR upon a rst_core).\
Note that the content of the byte is not checked against acceptable CTRL byte codes";
prefix = "ctrl_byte_ok";
type = BIT;
access_bus = READ_ONLY;
access_dev = WRITE_ONLY;
};
field {
name = "rx frame ok";
description = "indication that the deserializer has finished with the reception of a complete frame;\
......@@ -656,6 +669,17 @@ peripheral {
type = BIT;
access_bus = READ_ONLY;
access_dev = WRITE_ONLY;
};
field {
name = "rx bytes number error";
description = "indication that the deserializer has counted the reception of more than 266 bytes;\
The bit stays high until a reset of the deserializer (this takes place automatically upon the activation of the serializer,\
OR upon a rx_ctrl_rst OR upon a rst_core).";
prefix = "bytes_num_err";
type = BIT;
access_bus = READ_ONLY;
access_dev = WRITE_ONLY;
};
field {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment