signal soft_gbe_reset, soft_rst, dhcp_done : std_logic;
signal rst_ctr : std_logic_vector(24 downto 0);
signal mac_reset : std_logic;
-signal global_reset : std_logic;
+signal global_reset, rst_n, ff : std_logic;
begin
stage_ctrl_regs <= STAGE_CTRL_REGS_IN;
-global_reset <= not GSR_N;
+reset_sync : process(GSR_N, CLK)
+begin
+ if (GSR_N = '0') then
+ ff <= '0';
+ rst_n <= '0';
+ elsif rising_edge(CLK) then
+ ff <= '1';
+ rst_n <= ff;
+ end if;
+end process reset_sync;
+
+global_reset <= not rst_n;
-- gk 23.04.10
LED_PACKET_SENT_OUT <= '0'; --timeout_noticed; --pc_ready;
port map(
CLK => CLK,
CLK_125 => serdes_clk_125,
- RESET => global_reset, --RESET,
- RESET_FOR_DHCP => global_reset, --'0', --soft_gbe_reset, --'0', --reset_dhcp,
+ RESET => RESET,
MC_LINK_OK_OUT => link_ok,
- MC_RESET_LINK_IN => '0',
+ MC_RESET_LINK_IN => global_reset,
MC_IDLE_TOO_LONG_OUT => idle_too_long,
MC_DHCP_DONE_OUT => dhcp_done,
TC_SRC_UDP_IN => mc_src_udp,
TC_TRANSMISSION_DONE_OUT => mc_transmit_done,
TC_IDENT_IN => mc_ident,
+ TC_MAX_FRAME_IN => pc_max_frame_size,
-- signal to/from frame constructor
FC_DATA_OUT => fc_data,
end if;
end process SHF_Q_PROC;
-SAVE_SUB_HDR_MACHINE_PROC : process(CLK)
+SAVE_SUB_HDR_MACHINE_PROC : process(RESET, CLK)
begin
if RESET = '1' then
save_sub_hdr_current_state <= IDLE;
-- LOADING PART
--*******
-LOAD_MACHINE_PROC : process(CLK) is
+LOAD_MACHINE_PROC : process(RESET, CLK) is
begin
if RESET = '1' then
load_current_state <= IDLE;
end if;
end process LOAD_MACHINE_PROC;
-LOAD_MACHINE : process(load_current_state, qsf_empty, header_ctr, load_eod, term_ctr, insert_padding)
+LOAD_MACHINE : process(load_current_state, qsf_empty, header_ctr, load_eod_q, term_ctr, insert_padding)
begin
case (load_current_state) is
ipCsProc : process(CLK)\r
begin\r
if rising_edge(CLK) then\r
- if (RESET = '1') or (constructCurrentState = IDLE) then\r
+ if (constructCurrentState = IDLE) then\r
ip_checksum <= x"00000000";\r
else\r
case constructCurrentState is\r
delayCtrProc : process(CLK)\r
begin\r
if rising_edge(CLK) then\r
- if (RESET = '1') or (constructCurrentState = IDLE) or (constructCurrentState = CLEANUP) then\r
+ if (constructCurrentState = IDLE) or (constructCurrentState = CLEANUP) then\r
delay_ctr <= (others => '0');\r
elsif (constructCurrentState = DELAY) then\r
delay_ctr <= delay_ctr + x"1";\r
headersIntProc : process(CLK)\r
begin\r
if rising_edge(CLK) then\r
- if (RESET = '1') or (constructCurrentState = IDLE) then\r
+ if (constructCurrentState = IDLE) then\r
headers_int_counter <= 0;\r
else\r
if (headers_int_counter = cur_max) then\r
putUdpHeadersProc : process(CLK)\r
begin\r
if rising_edge(CLK) then\r
- if (RESET = '1') or (FLAGS_OFFSET_IN(12 downto 0) = "0000000000000") then\r
+ if (FLAGS_OFFSET_IN(12 downto 0) = "0000000000000") then\r
put_udp_headers <= '1';\r
else\r
put_udp_headers <= '0';\r
\r
fpfWrEnProc : process(constructCurrentState, WR_EN_IN, RESET, LINK_OK_IN)\r
begin\r
- if (RESET = '1') or (LINK_OK_IN = '0') then -- gk 01.10.10\r
+ if (LINK_OK_IN = '0') then -- gk 01.10.10\r
fpf_wr_en <= '0';\r
elsif (constructCurrentState /= IDLE) and (constructCurrentState /= CLEANUP) and (constructCurrentState /= SAVE_DATA) and (constructCurrentState /= DELAY) then\r
fpf_wr_en <= '1';\r
readyFramesCtrProc: process( CLK )\r
begin\r
if rising_edge(CLK) then\r
- if (RESET = '1') or (LINK_OK_IN = '0') then -- gk 01.10.10\r
+ if (LINK_OK_IN = '0') then -- gk 01.10.10\r
ready_frames_ctr <= (others => '0');\r
elsif (constructCurrentState = CLEANUP) then\r
ready_frames_ctr <= ready_frames_ctr + 1;\r
+ else\r
+ ready_frames_ctr <= ready_frames_ctr;\r
end if;\r
end if;\r
end process readyFramesCtrProc;\r
fpfResetProc : process(CLK)\r
begin\r
if rising_edge(CLK) then\r
- if (RESET = '1' or LINK_OK_IN = '0') then\r
+ if (LINK_OK_IN = '0') then\r
fpf_reset <= '1';\r
else\r
fpf_reset <= '0';\r
sopProc: process( RD_CLK )\r
begin\r
if rising_edge(RD_CLK) then\r
- if ( RESET = '1' ) or (link_ok_125 = '0') then -- gk 01.10.10\r
+ if (link_ok_125 = '0') then -- gk 01.10.10\r
ft_sop <= '0';\r
elsif ((transmitCurrentState = T_IDLE) and (sent_frames_ctr /= ready_frames_ctr_q)) then\r
ft_sop <= '1';\r
sentFramesCtrProc: process( RD_CLK )\r
begin\r
if rising_edge(RD_CLK) then\r
- if ( RESET = '1' ) or (LINK_OK_IN = '0') then -- gk 01.10.10\r
+ if (LINK_OK_IN = '0') then -- gk 01.10.10\r
sent_frames_ctr <= (others => '0');\r
mon_sent_frames <= (others => '0');\r
elsif( FT_TX_DONE_IN = '1' ) or (FT_TX_DISCFRM_IN = '1') then\r
process(RD_CLK)\r
begin\r
if rising_edge(RD_CLK) then\r
- if (RESET = '1') or (LINK_OK_IN = '0') then\r
+ if (LINK_OK_IN = '0') then\r
mon_sent_bytes <= (others => '0');\r
elsif (fpf_rd_en = '1') then\r
mon_sent_bytes <= mon_sent_bytes + x"1";\r
REMOVE_CTR_PROC : process(RX_MAC_CLK)
begin
if rising_edge(RX_MAC_CLK) then
- if (RESET = '1') or (filter_current_state = IDLE) or
+ if (filter_current_state = IDLE) or
(filter_current_state = REMOVE_VTYPE and remove_ctr = x"0f") or
(filter_current_state = REMOVE_TYPE and remove_ctr = x"0b") then
remove_ctr <= (others => '1');
elsif (MAC_RX_EN_IN = '1') and (filter_current_state /= IDLE) then --and (filter_current_state /= CLEANUP) then
remove_ctr <= remove_ctr + x"1";
+ else
+ remove_ctr <= remove_ctr;
end if;
end if;
end process REMOVE_CTR_PROC;
SAVED_PROTO_PROC : process(RX_MAC_CLK)
begin
if rising_edge(RX_MAC_CLK) then
- if (RESET = '1') or (filter_current_state = CLEANUP) then
+ if (filter_current_state = CLEANUP) then
saved_proto <= (others => '0');
elsif (filter_current_state = REMOVE_IP) and (remove_ctr = x"07") then
saved_proto <= MAC_RXD_IN;
+ else
+ saved_proto <= saved_proto;
end if;
end if;
end process SAVED_PROTO_PROC;
SAVED_SRC_IP_PROC : process(RX_MAC_CLK)
begin
if rising_edge(RX_MAC_CLK) then
- if (RESET = '1') or (filter_current_state = CLEANUP) then
+ if (filter_current_state = CLEANUP) then
saved_src_ip <= (others => '0');
elsif (filter_current_state = REMOVE_IP) and (remove_ctr = x"0a") then
saved_src_ip(7 downto 0) <= MAC_RXD_IN;
saved_src_ip(23 downto 16) <= MAC_RXD_IN;
elsif (filter_current_state = REMOVE_IP) and (remove_ctr = x"0d") then
saved_src_ip(31 downto 24) <= MAC_RXD_IN;
+ else
+ saved_src_ip <= saved_src_ip;
end if;
end if;
end process SAVED_SRC_IP_PROC;
SAVED_DEST_IP_PROC : process(RX_MAC_CLK)
begin
if rising_edge(RX_MAC_CLK) then
- if (RESET = '1') or (filter_current_state = CLEANUP) then
+ if (filter_current_state = CLEANUP) then
saved_dest_ip <= (others => '0');
elsif (filter_current_state = REMOVE_IP) and (remove_ctr = x"0e") then
saved_dest_ip(7 downto 0) <= MAC_RXD_IN;
saved_dest_ip(23 downto 16) <= MAC_RXD_IN;
elsif (filter_current_state = REMOVE_IP) and (remove_ctr = x"11") then
saved_dest_ip(31 downto 24) <= MAC_RXD_IN;
+ else
+ saved_dest_ip <= saved_dest_ip;
end if;
end if;
end process SAVED_DEST_IP_PROC;
SAVED_SRC_UDP_PROC : process(RX_MAC_CLK)
begin
if rising_edge(RX_MAC_CLK) then
- if (RESET = '1') or (filter_current_state = CLEANUP) then
+ if (filter_current_state = CLEANUP) then
saved_src_udp <= (others => '0');
elsif (filter_current_state = REMOVE_UDP) and (remove_ctr = x"12") then
saved_src_udp(15 downto 8) <= MAC_RXD_IN;
elsif (filter_current_state = REMOVE_UDP) and (remove_ctr = x"13") then
saved_src_udp(7 downto 0) <= MAC_RXD_IN;
+ else
+ saved_src_udp <= saved_src_udp;
end if;
end if;
end process SAVED_SRC_UDP_PROC;
SAVED_DEST_UDP_PROC : process(RX_MAC_CLK)
begin
if rising_edge(RX_MAC_CLK) then
- if (RESET = '1') or (filter_current_state = CLEANUP) then
+ if (filter_current_state = CLEANUP) then
saved_dest_udp <= (others => '0');
elsif (filter_current_state = REMOVE_UDP) and (remove_ctr = x"14") then
saved_dest_udp(15 downto 8) <= MAC_RXD_IN;
elsif (filter_current_state = REMOVE_UDP) and (remove_ctr = x"15") then
saved_dest_udp(7 downto 0) <= MAC_RXD_IN;
+ else
+ saved_dest_udp <= saved_dest_udp;
end if;
end if;
end process SAVED_DEST_UDP_PROC;
SAVED_DEST_MAC_PROC : process(RX_MAC_CLK)
begin
if rising_edge(RX_MAC_CLK) then
- if (RESET = '1') or (filter_current_state = CLEANUP) then
+ if (filter_current_state = CLEANUP) then
saved_dest_mac <= (others => '0');
elsif (filter_current_state = IDLE) and (MAC_RX_EN_IN = '1') and (new_frame = '0') then
saved_dest_mac(7 downto 0) <= MAC_RXD_IN;
saved_dest_mac(39 downto 32) <= MAC_RXD_IN;
elsif (filter_current_state = REMOVE_DEST) and (remove_ctr = x"02") then
saved_dest_mac(47 downto 40) <= MAC_RXD_IN;
+ else
+ saved_dest_mac <= saved_dest_mac;
end if;
end if;
end process SAVED_DEST_MAC_PROC;
SAVED_SRC_MAC_PROC : process(RX_MAC_CLK)
begin
if rising_edge(RX_MAC_CLK) then
- if (RESET = '1') or (filter_current_state = CLEANUP) then
+ if (filter_current_state = CLEANUP) then
saved_src_mac <= (others => '0');
elsif (filter_current_state = REMOVE_DEST) and (remove_ctr = x"03") then
saved_src_mac(7 downto 0) <= MAC_RXD_IN;
saved_src_mac(39 downto 32) <= MAC_RXD_IN;
elsif (filter_current_state = REMOVE_SRC) and (remove_ctr = x"08") then
saved_src_mac(47 downto 40) <= MAC_RXD_IN;
+ else
+ saved_src_mac <= saved_src_mac;
end if;
end if;
end process SAVED_SRC_MAC_PROC;
SAVED_FRAME_TYPE_PROC : process(RX_MAC_CLK)
begin
if rising_edge(RX_MAC_CLK) then
- if (RESET = '1') or (filter_current_state = CLEANUP) then
+ if (filter_current_state = CLEANUP) then
saved_frame_type <= (others => '0');
elsif (filter_current_state = REMOVE_SRC) and (remove_ctr = x"09") then
saved_frame_type(15 downto 8) <= MAC_RXD_IN;
saved_frame_type(15 downto 8) <= MAC_RXD_IN;
elsif (filter_current_state = REMOVE_VTYPE) and (remove_ctr = x"0e") then
saved_frame_type(7 downto 0) <= MAC_RXD_IN;
+ else
+ saved_frame_type <= saved_frame_type;
end if;
end if;
end process SAVED_FRAME_TYPE_PROC;
SAVED_VID_PROC : process(RX_MAC_CLK)
begin
if rising_edge(RX_MAC_CLK) then
- if (RESET = '1') or (filter_current_state = CLEANUP) then
+ if (filter_current_state = CLEANUP) then
saved_vid <= (others => '0');
elsif (filter_current_state = REMOVE_TYPE and remove_ctr = x"0b" and saved_frame_type = x"8100") then
saved_vid(15 downto 8) <= MAC_RXD_IN;
elsif (filter_current_state = REMOVE_VID and remove_ctr = x"0c") then
saved_vid(7 downto 0) <= MAC_RXD_IN;
+ else
+ saved_vid <= saved_vid;
end if;
end if;
end process SAVED_VID_PROC;
FifoAvailProc : process (TX_MAC_CLK)\r
begin\r
if rising_edge(TX_MAC_CLK) then\r
- if (RESET = '1') or (LINK_OK_IN = '0') then -- gk 01.10.10\r
+ if (LINK_OK_IN = '0') then -- gk 01.10.10\r
tx_fifoavail_i <= '0';\r
elsif (transmitCurrentState = T_TRANSMIT) then\r
tx_fifoavail_i <= '1';\r
\r
FifoEmptyProc : process(transmitCurrentState, START_OF_PACKET_IN, TX_EMPTY_IN, RESET)\r
begin\r
- if (RESET = '1') or (LINK_OK_IN = '0') then -- gk 01.10.10\r
+ if (LINK_OK_IN = '0') then -- gk 01.10.10\r
FifoEmpty <= '1';\r
elsif (transmitCurrentState = T_WAITFORFIFO) then\r
FifoEmpty <= '1';\r
\r
SENT_CTR_PROC : process(TX_MAC_CLK)\r
begin\r
- if rising_edge(TX_MAC_CLK) then\r
- if (RESET = '1') then\r
+ if (RESET = '1') then\r
sent_ctr <= (others => '0');\r
- elsif (TX_DONE_IN = '1') and (TX_STAT_EN_IN = '1') and (TX_STATVEC_IN(0) = '1') then\r
+ elsif rising_edge(TX_MAC_CLK) then\r
+ if (TX_DONE_IN = '1') and (TX_STAT_EN_IN = '1') and (TX_STATVEC_IN(0) = '1') then\r
sent_ctr <= sent_ctr + x"1";\r
+ else\r
+ sent_ctr <= sent_ctr;\r
end if;\r
end if;\r
end process SENT_CTR_PROC;\r
-- RECEIVING PART
--*********
-SAVE_MACHINE_PROC : process(CLK_IPU)
+SAVE_MACHINE_PROC : process(RESET, CLK_IPU)
begin
if RESET = '1' then
save_current_state <= IDLE;
end if;
end process SF_DATA_EOD_PROC;
-SAVED_EVENTS_CTR_PROC : process(CLK_IPU)
+SAVED_EVENTS_CTR_PROC : process(RESET, CLK_IPU)
begin
- if rising_edge(CLK_IPU) then
- if (RESET = '1') then
- saved_events_ctr <= (others => '0');
- elsif (save_current_state = ADD_SUBSUB4) then
+ if (RESET = '1') then
+ saved_events_ctr <= (others => '0');
+ elsif rising_edge(CLK_IPU) then
+ if (save_current_state = ADD_SUBSUB4) then
saved_events_ctr <= saved_events_ctr + x"1";
else
saved_events_ctr <= saved_events_ctr;
Reset => sf_reset,
RPReset => sf_reset,
AmEmptyThresh => b"0000_0000_0000_0010", --b"0000_0000_0000_0010", -- one byte ahead
- AmFullThresh => b"111_1111_1110_1111", --b"001_0011_1000_1000", --b"111_1111_1110_1111", -- 0x7fef = 32751
+ AmFullThresh => b"001_0011_1000_1000", --b"111_1111_1110_1111", -- 0x7fef = 32751
Q(7 downto 0) => sf_q,
Q(8) => sf_eod,
--WCNT => open,
end if;
end process PC_DATA_PROC;
-LOAD_MACHINE_PROC : process(CLK_GBE)
+LOAD_MACHINE_PROC : process(RESET, CLK_GBE)
begin
if RESET = '1' then
load_current_state <= IDLE;
end if;
end process LOAD_MACHINE_PROC;
-LOAD_MACHINE : process(load_current_state, saved_events_ctr_gbe, loaded_events_ctr, loaded_bytes_ctr, PC_READY_IN, sf_eod, MULT_EVT_ENABLE_IN)
+LOAD_MACHINE : process(load_current_state, saved_events_ctr_gbe, loaded_events_ctr, loaded_bytes_ctr, PC_READY_IN, sf_eod)
begin
case (load_current_state) is
when IDLE =>
load_state <= x"1";
- if (saved_events_ctr /= loaded_events_ctr) then
+ if (saved_events_ctr_gbe /= loaded_events_ctr) then
load_next_state <= REMOVE;
else
load_next_state <= IDLE;
--*****
-- counters
-LOADED_EVENTS_CTR_PROC : process(CLK_GBE)
+LOADED_EVENTS_CTR_PROC : process(RESET, CLK_GBE)
begin
- if rising_edge(CLK_GBE) then
- if (RESET = '1') then
- loaded_events_ctr <= (others => '0');
- elsif (load_current_state = CLOSE) then
+ if (RESET = '1') then
+ loaded_events_ctr <= (others => '0');
+ elsif rising_edge(CLK_GBE) then
+ if (load_current_state = CLOSE) then
loaded_events_ctr <= loaded_events_ctr + x"1";
else
loaded_events_ctr <= loaded_events_ctr;
READOUT_CTR_PROC : process(CLK_GBE)
begin
if rising_edge(CLK_GBE) then
- if (RESET = '1' or READOUT_CTR_VALID_IN = '1') then
+ if (READOUT_CTR_VALID_IN = '1') then
readout_ctr <= READOUT_CTR_IN;
elsif (load_current_state = DECIDE) then
readout_ctr <= readout_ctr + x"1";
CLK : in std_logic; -- system clock
CLK_125 : in std_logic;
RESET : in std_logic;
- RESET_FOR_DHCP : in std_logic;
MC_LINK_OK_OUT : out std_logic;
MC_RESET_LINK_IN : in std_logic;
protocol_selector : trb_net16_gbe_protocol_selector
port map(
CLK => CLK,
- RESET => RESET,
- RESET_FOR_DHCP => RESET_FOR_DHCP,
+ RESET => RESET,
+ RESET_FOR_DHCP => MC_RESET_LINK_IN,
PS_DATA_IN => rc_data_local, -- RC_DATA_IN,
PS_WR_EN_IN => ps_wr_en_qq, --ps_wr_en,
end if;
end process SYNC_PROC;
-REDIRECT_MACHINE_PROC : process(CLK)
+REDIRECT_MACHINE_PROC : process(RESET, CLK)
begin
if RESET = '1' then
redirect_current_state <= IDLE;
end if;
end process REDIRECT_MACHINE_PROC;
-REDIRECT_MACHINE : process(redirect_current_state, link_current_state, RC_FRAME_WAITING_IN, RC_DATA_IN, ps_busy, RC_FRAME_PROTO_IN, ps_wr_en, loaded_bytes_ctr, RC_FRAME_SIZE_IN)
+REDIRECT_MACHINE : process(redirect_current_state, link_current_state, RC_FRAME_WAITING_IN, ps_busy, RC_FRAME_PROTO_IN, loaded_bytes_ctr, RC_FRAME_SIZE_IN)
begin
case redirect_current_state is
LOADING_DONE_PROC : process(CLK)
begin
if rising_edge(CLK) then
- if (RESET = '1') then
- RC_LOADING_DONE_OUT <= '0';
- elsif (RC_DATA_IN(8) = '1' and ps_wr_en_q = '1') then
+ if (RC_DATA_IN(8) = '1' and ps_wr_en_q = '1') then
RC_LOADING_DONE_OUT <= '1';
else
RC_LOADING_DONE_OUT <= '0';
LOADED_BYTES_CTR_PROC : process(CLK)
begin
if rising_edge(CLK) then
- if (RESET = '1') or (redirect_current_state = IDLE) then
+ if (redirect_current_state = IDLE) then
loaded_bytes_ctr <= (others => '0');
elsif (redirect_current_state = LOAD or redirect_current_state = DROP) and (rc_rd_en = '1') then
loaded_bytes_ctr <= loaded_bytes_ctr + x"1";
first_byte_q <= first_byte;
first_byte_qq <= first_byte_q;
- if (RESET = '1') then
- first_byte <= '0';
- elsif (redirect_current_state = IDLE) then
+ if (redirect_current_state = IDLE) then
first_byte <= '1';
else
first_byte <= '0';
--*********************
-- DATA FLOW CONTROL
-FLOW_MACHINE_PROC : process(CLK)
+FLOW_MACHINE_PROC : process(RESET, CLK)
begin
if RESET = '1' then
flow_current_state <= IDLE;
--***********************
-- LINK STATE CONTROL
-LINK_STATE_MACHINE_PROC : process(CLK)
+LINK_STATE_MACHINE_PROC : process(MC_RESET_LINK_IN, CLK)
begin
- if RESET = '1' then
+ if MC_RESET_LINK_IN = '1' then
link_current_state <= INACTIVE;
elsif rising_edge(CLK) then
-- --if (RESET = '1') then
begin
if rising_edge(CLK) then
--if (RESET = '1') or (link_current_state /= TIMEOUT) then
- if (RESET_FOR_DHCP = '1') or (link_current_state /= TIMEOUT) then
+ if (link_current_state /= TIMEOUT) then
link_ok_timeout_ctr <= (others => '0');
elsif (link_current_state = TIMEOUT) then
link_ok_timeout_ctr <= link_ok_timeout_ctr + x"1";
WAIT_CTR_PROC : process(CLK)
begin
if rising_edge(CLK) then
- --if (RESET = '1') or (link_current_state = INACTIVE) then
- if (RESET_FOR_DHCP = '1') or (link_current_state = INACTIVE) then
- wait_ctr <= (others => '0');
- elsif (link_current_state = WAIT_FOR_BOOT) then
+ if (link_current_state = WAIT_FOR_BOOT) then
wait_ctr <= wait_ctr + x"1";
+ else
+ wait_ctr <= (others => '0');
end if;
end if;
end process WAIT_CTR_PROC;
-- GENERATE MAC_ADDRESS
g_MY_MAC <= unique_id(31 downto 8) & x"be0002";
---g_MAX_FRAME_SIZE <= x"0578";
-
---g_MAX_PACKET_SIZE <= x"fa00" when g_SIMULATE = 0 else x"0600";
---
--*************
--****************
TSMAC_CONTROLLER : trb_net16_gbe_mac_control
port map(
CLK => CLK,
- RESET => RESET_FOR_DHCP, --RESET,
-
+ RESET => MC_RESET_LINK_IN,
+
-- signals to/from main controller
MC_TSMAC_READY_OUT => tsm_ready,
MC_RECONF_IN => tsm_reconf,
THE_EVT_INFO_STORE_PROC: process( CLK )
begin
if( rising_edge(CLK) ) then
- if (RESET = '1') then -- gk 31.05.10
- pc_sub_size <= (others => '0');
- pc_trig_nr <= (others => '0');
- elsif( PC_START_OF_SUB_IN = '1' ) then
+ if( PC_START_OF_SUB_IN = '1' ) then
pc_sub_size <= PC_SUB_SIZE_IN;
pc_trig_nr <= PC_TRIG_NR_IN;
+ else
+ pc_sub_size <= pc_sub_size;
+ pc_trig_nr <= pc_trig_nr;
end if;
end if;
end process;
LOAD_EOD_PROC : process(CLK)
begin
if rising_edge(CLK) then
- if (RESET = '1') then
- load_eod_q <= '0';
- else
- load_eod_q <= load_eod;
- end if;
+ load_eod_q <= load_eod;
end if;
end process LOAD_EOD_PROC;
-- gk 29.03.10 no changes here because the queue size should contain the padding bytes of subevents
queueSizeProc : process(CLK)
begin
- if rising_edge(CLK) then
+ if (RESET = '1') then
+ queue_size <= x"00000028"; -- + 8B for queue headers and 32B for termination
+ elsif rising_edge(CLK) then
--if (RESET = '1') or (loadCurrentState = PUT_Q_DEC) then -- gk 07.10.10 -- (loadCurrentState = CLEANUP) then
- if (RESET = '1') or (loadCurrentState = CLEANUP) then
+ if (loadCurrentState = CLEANUP) then
queue_size <= x"00000028"; -- + 8B for queue headers and 32B for termination
elsif (saveSubCurrentState = SAVE_SIZE) and (sub_int_ctr = 3) then
queue_size <= queue_size + pc_sub_size + x"10"; -- + 16B for each subevent headers
+ else
+ queue_size <= queue_size;
end if;
end if;
end process queueSizeProc;
-- gk 04.12.10
firstSubInMultiProc : process(CLK)
begin
- if rising_edge(CLK) then
- if (RESET = '1') or (loadCurrentState = LOAD_TERM) then
+ if (RESET = '1') then
+ first_sub_in_multi <= '1';
+ elsif rising_edge(CLK) then
+ if (loadCurrentState = LOAD_TERM) then
first_sub_in_multi <= '1';
elsif (loadCurrentState = LOAD_DATA) then
first_sub_in_multi <= '0';
+ else
+ first_sub_in_multi <= first_sub_in_multi;
end if;
end if;
end process;
-- gk 04.12.10
fromDivideStateProc : process(CLK)
begin
- if rising_edge(CLK) then
- if (RESET = '1') then
- from_divide_state <= '0';
- elsif (loadCurrentState = DIVIDE) then
+ if (RESET = '1') then
+ from_divide_state <= '0';
+ elsif rising_edge(CLK) then
+ if (loadCurrentState = DIVIDE) then
from_divide_state <= '1';
elsif (loadCurrentState = PREP_DATA) then
from_divide_state <= '0';
+ else
+ from_divide_state <= from_divide_state;
end if;
end if;
end process fromDivideStateProc;
dividePositionProc : process(CLK)
begin
- if rising_edge(CLK) then
- if (RESET = '1') then
- divide_position <= "00";
- elsif (bytes_loaded = max_frame_size - 1) then
+ if (RESET = '1') then
+ divide_position <= "00";
+ disable_prep <= '0';
+ elsif rising_edge(CLK) then
+ if (bytes_loaded = max_frame_size - 1) then
if (loadCurrentState = LIDLE) then
divide_position <= "00";
disable_prep <= '0'; -- gk 05.12.10
elsif (loadCurrentState = LOAD_TERM) then
divide_position <= "11";
disable_prep <= '0'; -- gk 05.12.10
+ else
+ divide_position <= divide_position;
+ disable_prep <= disable_prep;
end if;
elsif (loadCurrentState = PREP_DATA) then -- gk 06.12.10 reset disable_prep
disable_prep <= '0';
+ divide_position <= divide_position;
+ else
+ divide_position <= divide_position;
+ disable_prep <= disable_prep;
end if;
end if;
allIntCtrProc : process(CLK)
begin
- if rising_edge(CLK) then
- if (RESET = '1') then -- gk 31.05.10
- all_int_ctr <= 0;
- else
+ if (RESET = '1') then -- gk 31.05.10
+ all_int_ctr <= 0;
+ elsif rising_edge(CLK) then
case loadCurrentState is
when LIDLE => all_int_ctr <= 0;
when DELAY => all_int_ctr <= 0;
end case;
- end if;
end if;
end process allIntCtrProc;
dfRdEnProc : process(loadCurrentState, bytes_loaded, max_frame_size, sub_bytes_loaded,
sub_size_loaded, all_int_ctr, RESET, size_left, load_eod_q)
begin
- if (RESET = '1') then
- df_rd_en <= '0';
- elsif (loadCurrentState = LOAD_DATA) then
+ if (loadCurrentState = LOAD_DATA) then
-- if (bytes_loaded = max_frame_size - x"1") then
-- df_rd_en <= '0';
-- -- gk 07.10.10
shfRdEnProc : process(loadCurrentState, all_int_ctr, RESET)
begin
- if (RESET = '1') then -- gk 31.05.10
- shf_rd_en <= '0';
- elsif (loadCurrentState = LOAD_SUB) then
+ if (loadCurrentState = LOAD_SUB) then
shf_rd_en <= '1';
elsif (loadCurrentState = LOAD_TERM) and (all_int_ctr < 31) then
shf_rd_en <= '1';
fcWrEnProc : process(loadCurrentState, RESET, first_sub_in_multi, from_divide_state, MULT_EVT_ENABLE_IN, divide_position, disable_prep)
begin
- if (RESET = '1') then -- gk 31.05.10
- fc_wr_en <= '0';
- elsif (loadCurrentState = PUT_Q_LEN) or (loadCurrentState = PUT_Q_DEC) then
+ if (loadCurrentState = PUT_Q_LEN) or (loadCurrentState = PUT_Q_DEC) then
fc_wr_en <= '1';
elsif (loadCurrentState = LOAD_SUB) or (loadCurrentState = LOAD_DATA) or (loadCurrentState = LOAD_TERM) then
fc_wr_en <= '1';
DELAY_CTR_PROC : process(CLK)
begin
if rising_edge(CLK) then
- if ((RESET = '1') or (loadCurrentState = LIDLE)) then
+ if (loadCurrentState = LIDLE) then
delay_ctr <= PC_DELAY_IN;
elsif ((loadCurrentState = DELAY) and (ticks_ctr(7) = '1')) then
delay_ctr <= delay_ctr - x"1";
+ else
+ delay_ctr <= delay_ctr;
end if;
end if;
end process DELAY_CTR_PROC;
TICKS_CTR_PROC : process(CLK)
begin
if rising_edge(CLK) then
- if ((RESET = '1') or (loadCurrentState = LIDLE) or (ticks_ctr(7) = '1')) then
+ if ((loadCurrentState = LIDLE) or (ticks_ctr(7) = '1')) then
ticks_ctr <= x"00";
elsif (loadCurrentState = DELAY) then
ticks_ctr <= ticks_ctr + x"1";
+ else
+ ticks_ctr <= ticks_ctr;
end if;
end if;
end process TICKS_CTR_PROC;
RST_AFTER_SUB_PROC : process(CLK)
begin
if(rising_edge(CLK)) then
- if(RESET = '1') then
- rst_after_sub <= '0';
- else
- rst_after_sub <= rst_after_sub_comb;
- end if;
+ rst_after_sub <= rst_after_sub_comb;
end if;
end process RST_AFTER_SUB_PROC;
bytesLoadedProc : process(CLK)
begin
if rising_edge(CLK) then
- if (RESET = '1') or (loadCurrentState = LIDLE) or (loadCurrentState = DIVIDE) or (loadCurrentState = CLEANUP) then
+ if (loadCurrentState = LIDLE) or (loadCurrentState = DIVIDE) or (loadCurrentState = CLEANUP) then
bytes_loaded <= x"0000";
elsif (loadCurrentState = PUT_Q_LEN) or (loadCurrentState = PUT_Q_DEC) or (loadCurrentState = LOAD_DATA) or (loadCurrentState = LOAD_SUB) or (loadCurrentState = LOAD_TERM) then
bytes_loaded <= bytes_loaded + x"1";
bytes_loaded <= bytes_loaded + x"1";
elsif (MULT_EVT_ENABLE_IN = '1') and (loadCurrentState = PREP_DATA) and (from_divide_state = '1') and ((divide_position = "00") or (divide_position = "01")) and (disable_prep = '0') then
bytes_loaded <= bytes_loaded + x"1";
+ else
+ bytes_loaded <= bytes_loaded;
end if;
end if;
end process bytesLoadedProc;
subSizeLoadedProc : process(CLK)
begin
if rising_edge(CLK) then
- if (RESET = '1') or (loadCurrentState = LIDLE) or (loadCurrentState = CLEANUP) or (rst_after_sub = '1') then -- gk 08.04.10
+ if (loadCurrentState = LIDLE) or (loadCurrentState = CLEANUP) or (rst_after_sub = '1') then -- gk 08.04.10
sub_size_loaded <= x"00000000";
elsif (loadCurrentState = LOAD_SUB) and (all_int_ctr < 4) then
-- was all_int_ctr
-- gk 29.03.10 here the padding bytes have to be added to the loadedSize in order to load the correct amount of bytes from fifo
elsif (loadCurrentState = LOAD_SUB) and (all_int_ctr = 5) and (sub_size_loaded(2) = '1') then
sub_size_loaded <= sub_size_loaded + x"4";
+ else
+ sub_size_loaded <= sub_size_loaded;
end if;
end if;
end process subSizeLoadedProc;
subBytesLoadedProc : process(CLK)
begin
if rising_edge(CLK) then
- if (RESET = '1') or (loadCurrentState = LIDLE) or (loadCurrentState = CLEANUP) or (rst_after_sub = '1') then -- gk 26.07.10 --or (sub_bytes_loaded = sub_size_loaded) -- gk 08.04.10
+ if (loadCurrentState = LIDLE) or (loadCurrentState = CLEANUP) or (rst_after_sub = '1') then -- gk 26.07.10 --or (sub_bytes_loaded = sub_size_loaded) -- gk 08.04.10
sub_bytes_loaded <= x"00000011"; -- subevent headers doesnt count
elsif (loadCurrentState = LOAD_DATA) then
sub_bytes_loaded <= sub_bytes_loaded + x"1";
+ else
+ sub_bytes_loaded <= sub_bytes_loaded;
end if;
end if;
end process subBytesLoadedProc;
actualPacketProc : process(CLK)
begin
if rising_edge(CLK) then
- if (RESET = '1') or (loadCurrentState = LIDLE) or (loadCurrentState = CLEANUP) then
+ if (loadCurrentState = LIDLE) or (loadCurrentState = CLEANUP) then
actual_packet_size <= x"0008";
elsif (fc_wr_en = '1') then
actual_packet_size <= actual_packet_size + x"1";
+ else
+ actual_packet_size <= actual_packet_size;
end if;
end if;
end process actualPacketProc;
actualQueueSizeProc : process(CLK)
begin
- if rising_edge(CLK) then
- if (RESET = '1') or (loadCurrentState = CLEANUP) then
+ if RESET = '1' then
+ actual_queue_size <= (others => '0');
+ elsif rising_edge(CLK) then
+ if (loadCurrentState = CLEANUP) then
actual_queue_size <= (others => '0');
elsif (loadCurrentState = LIDLE) then
actual_queue_size <= queue_size;
+ else
+ actual_queue_size <= actual_queue_size;
end if;
end if;
end process actualQueueSizeProc;
-- amount of bytes left to send in current packet
sizeLeftProc : process(CLK)
begin
- if rising_edge(CLK) then
- if (RESET = '1') or (loadCurrentState = CLEANUP) then
+ if (RESET = '1') then
+ size_left <= (others => '0');
+ elsif rising_edge(CLK) then
+ if (loadCurrentState = CLEANUP) then
size_left <= (others => '0');
elsif (loadCurrentState = LIDLE) then
size_left <= queue_size;
elsif (fc_wr_en = '1') then
size_left <= size_left - 1;
+ else
+ size_left <= size_left;
end if;
end if;
end process sizeLeftProc;
-- In this case, we increment the fragmented packet ID with EOD from ipu2gbe.
THE_FC_IDENT_COUNTER_PROC: process(CLK)
begin
- if rising_edge(CLK) then
- if (RESET = '1') then
- fc_ident <= (others => '0');
- elsif (PC_END_OF_DATA_IN = '1') then
+ if (RESET = '1') then
+ fc_ident <= (others => '0');
+ elsif rising_edge(CLK) then
+ if (PC_END_OF_DATA_IN = '1') then
fc_ident <= fc_ident + 1;
+ else
+ fc_ident <= fc_ident;
end if;
end if;
end process THE_FC_IDENT_COUNTER_PROC;
moreFragmentsProc : process(CLK)
begin
if rising_edge(CLK) then
- if (RESET = '1') or (loadCurrentState = LIDLE) or (loadCurrentState = CLEANUP) then
+ if (loadCurrentState = LIDLE) or (loadCurrentState = CLEANUP) then
fc_flags_offset(13) <= '0';
elsif ((loadCurrentState = DIVIDE) and (TC_READY_IN = '1')) or ((loadCurrentState = WAIT_FOR_FC) and (TC_READY_IN = '1')) then
if ((actual_queue_size - actual_packet_size) < max_frame_size) then
else
fc_flags_offset(13) <= '1'; -- more fragments
end if;
+ else
+ fc_flags_offset(13) <= fc_flags_offset(13);
end if;
end if;
end process moreFragmentsProc;
eodProc : process(CLK)
begin
if rising_edge(CLK) then
- if (RESET = '1') then
- fc_eod <= '0';
- elsif (loadCurrentState = LOAD_DATA) and (bytes_loaded = max_frame_size - 2) then
+ if (loadCurrentState = LOAD_DATA) and (bytes_loaded = max_frame_size - 2) then
fc_eod <= '1';
elsif (loadCurrentState = LOAD_SUB) and (bytes_loaded = max_frame_size - 2) then
fc_eod <= '1';
sodProc : process(CLK)
begin
if rising_edge(CLK) then
- if (RESET = '1') then
- fc_sod <= '0';
- elsif (loadCurrentState = WAIT_FOR_FC) and (TC_READY_IN = '1') then
+ if (loadCurrentState = WAIT_FOR_FC) and (TC_READY_IN = '1') then
fc_sod <= '1';
elsif (loadCurrentState = DIVIDE) and (TC_READY_IN = '1') then
fc_sod <= '1';
offsetProc : process(CLK)
begin
if rising_edge(CLK) then
- if (RESET = '1') or (loadCurrentState = LIDLE) or (loadCurrentState = CLEANUP) then
+ if (loadCurrentState = LIDLE) or (loadCurrentState = CLEANUP) then
fc_flags_offset(12 downto 0) <= (others => '0');
elsif ((loadCurrentState = DIVIDE) and (TC_READY_IN = '1')) then
fc_flags_offset(12 downto 0) <= actual_packet_size(15 downto 3);
+ else
+ fc_flags_offset(12 downto 0) <= fc_flags_offset(12 downto 0);
end if;
end if;
end process offsetProc;
fcIPSizeProc : process(CLK)
begin
if rising_edge(CLK) then
- if (RESET= '1') then
- fc_ip_size <= (others => '0');
- elsif ((loadCurrentState = DIVIDE) and (TC_READY_IN = '1')) or ((loadCurrentState = WAIT_FOR_FC) and (TC_READY_IN = '1')) then
+ if ((loadCurrentState = DIVIDE) and (TC_READY_IN = '1')) or ((loadCurrentState = WAIT_FOR_FC) and (TC_READY_IN = '1')) then
if (size_left >= max_frame_size) then
fc_ip_size <= max_frame_size;
else
fc_ip_size <= size_left(15 downto 0);
end if;
+ else
+ fc_ip_size <= fc_ip_size;
end if;
end if;
end process fcIPSizeProc;
fcUDPSizeProc : process(CLK)
- begin
+begin
if rising_edge(CLK) then
- if (RESET = '1') then
- fc_udp_size <= (others => '0');
- elsif (loadCurrentState = WAIT_FOR_FC) and (TC_READY_IN = '1') then
+ if (loadCurrentState = WAIT_FOR_FC) and (TC_READY_IN = '1') then
fc_udp_size <= queue_size(15 downto 0);
+ else
+ fc_udp_size <= fc_udp_size;
end if;
end if;
end process fcUDPSizeProc;
subIntProc: process( CLK )
begin
if rising_edge(CLK) then
- if (RESET = '1') or (saveSubCurrentState = SIDLE) then
+ if (saveSubCurrentState = SIDLE) then
sub_int_ctr <= 0;
elsif (sub_int_ctr = 3) and (saveSubCurrentState /= SAVE_TERM) then
sub_int_ctr <= 0;
sub_int_ctr <= 0;
elsif (saveSubCurrentState /= SIDLE) and (loadCurrentState /= PREP_DATA) then
sub_int_ctr <= sub_int_ctr + 1;
+ else
+ sub_int_ctr <= sub_int_ctr;
end if;
end if;
end process subIntProc;
PRIORITIZE : process(CLK, FRAME_TYPE_IN, PROTOCOL_CODE_IN)
begin
-
- if rising_edge(CLK) then
+ if RESET = '1' then
+ CODE_OUT <= (others => '0');
+ elsif rising_edge(CLK) then
CODE_OUT <= (others => '0');
-
- if (RESET = '0') then
--**** HERE ADD YOU PROTOCOL RECOGNITION AT WANTED PRIORITY LEVEL
-- priority level is the bit position in the CODE_OUT vector
end case;
- end if;
-
end if;
end process PRIORITIZE;
PS_BUSY_OUT <= busy;
-SELECT_MACHINE_PROC : process(CLK)
+SELECT_MACHINE_PROC : process(RESET, CLK)
begin
if RESET = '1' then
select_current_state <= IDLE;
INDEX_PROC : process(CLK)
begin
if rising_edge(CLK) then
- if (RESET = '1') or (select_current_state = IDLE) then
+ if (select_current_state = IDLE) then
index <= 0;
elsif (select_current_state = LOOP_OVER and resp_ready(index) = '0') then
index <= index + 1;
SELECTOR_PROC : process(CLK)
begin
if rising_edge(CLK) then
- if (RESET = '1') then
- TC_DATA_OUT <= (others => '0');
- TC_FRAME_SIZE_OUT <= (others => '0');
- TC_FRAME_TYPE_OUT <= (others => '0');
- TC_DEST_MAC_OUT <= (others => '0');
- TC_DEST_IP_OUT <= (others => '0');
- TC_DEST_UDP_OUT <= (others => '0');
- TC_SRC_MAC_OUT <= (others => '0');
- TC_SRC_IP_OUT <= (others => '0');
- TC_SRC_UDP_OUT <= (others => '0');
- TC_IP_PROTOCOL_OUT <= (others => '0');
- TC_IDENT_OUT <= (others => '0');
- PS_RESPONSE_READY_OUT <= '0';
- selected <= (others => '0');
- elsif (select_current_state = SELECT_ONE or select_current_state = PROCESS_REQUEST) then
+ if (select_current_state = SELECT_ONE or select_current_state = PROCESS_REQUEST) then
TC_DATA_OUT <= tc_data((index + 1) * 9 - 1 downto index * 9);
TC_FRAME_SIZE_OUT <= tc_size((index + 1) * 16 - 1 downto index * 16);
TC_FRAME_TYPE_OUT <= tc_type((index + 1) * 16 - 1 downto index * 16);
FRAMES_REC_CTR_PROC : process(CLK)
begin
- if rising_edge(CLK) then
- if (RESET = '1') then
+ if (RESET = '1') then
frames_received_ctr <= (others => '0');
- elsif (FR_FRAME_VALID_IN = '1') then
- frames_received_ctr <= frames_received_ctr + x"1";
+ elsif rising_edge(CLK) then
+ if (FR_FRAME_VALID_IN = '1') then
+ frames_received_ctr <= frames_received_ctr + x"1";
+ else
+ frames_received_ctr <= frames_received_ctr;
end if;
end if;
end process FRAMES_REC_CTR_PROC;
FRAMES_READOUT_CTR_PROC : process(CLK)
begin
- if rising_edge(CLK) then
- if (RESET = '1') then
+ if (RESET = '1') then
frames_readout_ctr <= (others => '0');
- elsif (RC_LOADING_DONE_IN = '1') then
- frames_readout_ctr <= frames_readout_ctr + x"1";
+ elsif rising_edge(CLK) then
+ if (RC_LOADING_DONE_IN = '1') then
+ frames_readout_ctr <= frames_readout_ctr + x"1";
+ else
+ frames_readout_ctr <= frames_readout_ctr;
end if;
end if;
end process FRAMES_READOUT_CTR_PROC;
-- debug only
BYTES_REC_CTR_PROC : process(CLK)
begin
- if rising_edge(CLK) then
if (RESET = '1') then
bytes_rec_ctr <= (others => '0');
- elsif (FR_FRAME_VALID_IN = '1') then
- bytes_rec_ctr <= bytes_rec_ctr + FR_FRAME_SIZE_IN;
+ elsif rising_edge(CLK) then
+ if (FR_FRAME_VALID_IN = '1') then
+ bytes_rec_ctr <= bytes_rec_ctr + FR_FRAME_SIZE_IN;
+ else
+ bytes_rec_ctr <= bytes_rec_ctr;
end if;
end if;
end process BYTES_REC_CTR_PROC;
SAVED_PROTO_PROC : process(CLK)
begin
if rising_edge(CLK) then
- if (RESET = '1') then
- saved_proto <= (others => '0');
- elsif (load_current_state = READY) then
+ if (load_current_state = READY) then
if (and_all(proto_code) = '0') then
saved_proto <= proto_code;
else
saved_proto <= (others => '0');
end if;
+ else
+ saved_proto <= saved_proto;
end if;
end if;
end process SAVED_PROTO_PROC;
attribute syn_encoding : string;
-type main_states is (BOOTING, SENDING_DISCOVER, WAITING_FOR_OFFER, SENDING_REQUEST, WAITING_FOR_ACK, ESTABLISHED);
+type main_states is (BOOTING, DELAY, SENDING_DISCOVER, WAITING_FOR_OFFER, SENDING_REQUEST, WAITING_FOR_ACK, ESTABLISHED);
signal main_current_state, main_next_state : main_states;
attribute syn_encoding of main_current_state: signal is "onehot";
SAVE_SERVER_ADDR_PROC : process(CLK)
begin
if rising_edge(CLK) then
- if (RESET = '1') or (main_current_state = BOOTING) then
+ if (main_current_state = BOOTING) then
saved_server_mac <= (others => '0');
saved_server_ip <= (others => '0');
elsif (main_current_state = WAITING_FOR_OFFER) and (receive_current_state = SAVE_VALUES and save_ctr = 1) then
saved_server_mac <= PS_SRC_MAC_ADDRESS_IN;
saved_server_ip <= PS_SRC_IP_ADDRESS_IN;
+ else
+ saved_server_mac <= saved_server_mac;
+ saved_server_ip <= saved_server_ip;
end if;
end if;
end process SAVE_SERVER_ADDR_PROC;
-- **** MAIN MACHINE PART
-MAIN_MACHINE_PROC : process(CLK)
+MAIN_MACHINE_PROC : process(RESET, CLK)
begin
if RESET = '1' then
main_current_state <= BOOTING;
end if;
end process MAIN_MACHINE_PROC;
-MAIN_MACHINE : process(main_current_state, DHCP_START_IN, construct_current_state, wait_ctr, receive_current_state, PS_DATA_IN)
+MAIN_MACHINE : process(main_current_state, DHCP_START_IN, construct_current_state, saved_true_ip, saved_proposed_ip, wait_ctr, receive_current_state, PS_DATA_IN)
begin
case (main_current_state) is
when BOOTING =>
state2 <= x"1";
if (DHCP_START_IN = '1') then
- main_next_state <= SENDING_DISCOVER;
+ main_next_state <= DELAY; --SENDING_DISCOVER;
else
main_next_state <= BOOTING;
end if;
+
+ when DELAY =>
+ if (wait_ctr = x"2000_0000") then
+ main_next_state <= SENDING_DISCOVER;
+ else
+ main_next_state <= DELAY;
+ end if;
when SENDING_DISCOVER =>
state2 <= x"2";
state2 <= x"3";
if (receive_current_state = SAVE_VALUES) and (PS_DATA_IN(8) = '1') then
main_next_state <= SENDING_REQUEST;
- elsif (wait_ctr = x"1000_0000") then
+ elsif (wait_ctr = x"2000_0000") then
main_next_state <= BOOTING;
else
main_next_state <= WAITING_FOR_OFFER;
state2 <= x"5";
if (receive_current_state = SAVE_VALUES) and (PS_DATA_IN(8) = '1') then
main_next_state <= ESTABLISHED;
- elsif (wait_ctr = x"1000_0000") then
+ elsif (wait_ctr = x"2000_0000") then
main_next_state <= BOOTING;
else
main_next_state <= WAITING_FOR_ACK;
when ESTABLISHED =>
state2 <= x"6";
- if (saved_proposed_ip = saved_true_ip) then
+-- if (saved_proposed_ip = saved_true_ip) then
main_next_state <= ESTABLISHED;
- else
- main_next_state <= BOOTING;
- end if;
+-- else
+-- main_next_state <= BOOTING;
+-- end if;
end case;
WAIT_CTR_PROC : process(CLK)
begin
if rising_edge(CLK) then
- if (RESET = '1') or (main_current_state = BOOTING or main_current_state = SENDING_DISCOVER or main_current_state = SENDING_REQUEST) then
+ if (main_current_state = SENDING_DISCOVER or main_current_state = SENDING_REQUEST or main_current_state = BOOTING) then
wait_ctr <= (others => '0');
- elsif (main_current_state = WAITING_FOR_ACK or main_current_state = WAITING_FOR_OFFER) then
+ elsif (main_current_state = WAITING_FOR_ACK or main_current_state = WAITING_FOR_OFFER or main_current_state = DELAY) then
wait_ctr <= wait_ctr + x"1";
+ else
+ wait_ctr <= wait_ctr;
end if;
end if;
end process WAIT_CTR_PROC;
-- **** MESSAGES RECEIVING PART
-RECEIVE_MACHINE_PROC : process(CLK)
+RECEIVE_MACHINE_PROC : process(RESET, CLK)
begin
- if rising_edge(CLK) then
- if (RESET = '1') or (main_current_state = BOOTING) then
- receive_current_state <= IDLE;
- else
+ if RESET = '1' then
+ receive_current_state <= IDLE;
+ elsif rising_edge(CLK) then
+ --if (main_current_state = BOOTING) then
+ -- receive_current_state <= IDLE;
+ --else
receive_current_state <= receive_next_state;
- end if;
+ --end if;
end if;
end process RECEIVE_MACHINE_PROC;
-RECEIVE_MACHINE : process(receive_current_state, main_current_state, PS_DATA_IN, PS_DEST_MAC_ADDRESS_IN, g_MY_MAC, PS_ACTIVATE_IN, PS_WR_EN_IN, save_ctr)
+RECEIVE_MACHINE : process(receive_current_state, main_current_state, bootp_hdr, saved_dhcp_type, saved_transaction_id, PS_DATA_IN, PS_DEST_MAC_ADDRESS_IN, g_MY_MAC, PS_ACTIVATE_IN, PS_WR_EN_IN, save_ctr)
begin
case receive_current_state is
SAVE_CTR_PROC : process(CLK)
begin
if rising_edge(CLK) then
- if (RESET = '1') or (receive_current_state = IDLE) then
+ if (receive_current_state = IDLE) then
save_ctr <= 0;
elsif (receive_current_state = SAVE_VALUES and PS_WR_EN_IN = '1' and PS_ACTIVATE_IN = '1') then
save_ctr <= save_ctr + 1;
+ else
+ save_ctr <= save_ctr;
end if;
end if;
end process SAVE_CTR_PROC;
SAVE_VALUES_PROC : process(CLK)
begin
if rising_edge(CLK) then
- if (RESET = '1') or (main_current_state = BOOTING) then
+ if (main_current_state = BOOTING) then
saved_transaction_id <= (others => '0');
saved_proposed_ip <= (others => '0');
+ saved_true_ip <= (others => '0');
saved_dhcp_type <= (others => '0');
-- dissection of DHCP Offer message
elsif (main_current_state = WAITING_FOR_OFFER and receive_current_state = SAVE_VALUES) then
+ saved_true_ip <= saved_true_ip;
+
case save_ctr is
when 3 =>
-- dissection on DHCP Ack message
elsif (main_current_state = WAITING_FOR_ACK and receive_current_state = SAVE_VALUES) then
+ saved_proposed_ip <= saved_proposed_ip;
+
case save_ctr is
when 3 =>
when others => null;
end case;
-
+ else
+ saved_transaction_id <= saved_transaction_id;
+ saved_proposed_ip <= saved_proposed_ip;
+ saved_true_ip <= saved_true_ip;
+ saved_dhcp_type <= saved_dhcp_type;
end if;
end if;
end process SAVE_VALUES_PROC;
-- **** MESSAGES CONSTRUCTING PART
-CONSTRUCT_MACHINE_PROC : process(CLK)
+CONSTRUCT_MACHINE_PROC : process(RESET, CLK)
begin
if RESET = '1' then
construct_current_state <= IDLE;
LOAD_CTR_PROC : process(CLK)
begin
if rising_edge(CLK) then
- if (RESET = '1') or (construct_current_state = IDLE) then
+ if (construct_current_state = IDLE) then
load_ctr <= 0;
elsif (TC_RD_EN_IN = '1') and (PS_SELECTED_IN = '1') then
-- elsif (construct_current_state /= IDLE and construct_current_state /= CLEANUP and PS_SELECTED_IN = '1') then
-- end if;
--end process TC_WR_PROC;
-TC_DATA_PROC : process(CLK, construct_current_state, load_ctr, bootp_hdr, g_MY_MAC, main_current_state)
+TC_DATA_PROC : process(CLK)
begin
if rising_edge(CLK) then
case (construct_current_state) is
PACKET_NUM_PROC : process(CLK)
begin
if rising_edge(CLK) then
- if (RESET = '1') or (dissect_current_state = IDLE) then
+ if (dissect_current_state = IDLE) then
packet_num <= "100";
elsif (GSC_INIT_READ_IN = '1' and rx_fifo_rd = '1' and packet_num = "100") then
packet_num <= "000";
TX_DATA_CTR_PROC : process(CLK)
begin
if rising_edge(CLK) then
- if (RESET = '1' or dissect_current_state = IDLE) then
+ if (dissect_current_state = IDLE) then
tx_data_ctr <= (others => '0');
elsif (tx_fifo_wr = '1') then
tx_data_ctr <= tx_data_ctr + x"2";
TOO_MUCH_DATA_PROC : process(CLK)
begin
if rising_edge(CLK) then
- if (RESET = '1') or (dissect_current_state = IDLE) then
+ if (dissect_current_state = IDLE) then
too_much_data <= '0';
elsif (dissect_current_state = SAVE_RESPONSE) and (tx_data_ctr = x"fa00") then
too_much_data <= '1';
TX_LOADED_CTR_PROC : process(CLK)
begin
if rising_edge(CLK) then
- if (RESET = '1' or dissect_current_state = IDLE) then
+ if (dissect_current_state = IDLE) then
tx_loaded_ctr <= x"0000";
elsif (dissect_current_state = LOAD_FRAME and PS_SELECTED_IN = '1' and TC_RD_EN_IN = '1') then
tx_loaded_ctr <= tx_loaded_ctr + x"1";
TC_FRAME_SIZE_OUT <= tx_data_ctr;
-DISSECT_MACHINE_PROC : process(CLK)
+DISSECT_MACHINE_PROC : process(RESET, CLK)
begin
if RESET = '1' then
dissect_current_state <= IDLE;
end if;
end process DISSECT_MACHINE_PROC;
-DISSECT_MACHINE : process(dissect_current_state, reset_detected, too_much_data, PS_WR_EN_IN, PS_ACTIVATE_IN, PS_DATA_IN, data_ctr, PS_SELECTED_IN, GSC_INIT_READ_IN, GSC_REPLY_DATAREADY_IN, tx_loaded_ctr, tx_data_ctr, rx_fifo_q, GSC_BUSY_IN, tx_frame_loaded, g_MAX_FRAME_SIZE)
+DISSECT_MACHINE : process(dissect_current_state, reset_detected, too_much_data, PS_WR_EN_IN, PS_ACTIVATE_IN, PS_DATA_IN, PS_SELECTED_IN, GSC_INIT_READ_IN, GSC_REPLY_DATAREADY_IN, tx_loaded_ctr, tx_data_ctr, rx_fifo_q, GSC_BUSY_IN)
begin
case dissect_current_state is
RESET_DETECTED_PROC : process(CLK)
begin
if rising_edge(CLK) then
- if (RESET = '1' or dissect_current_state = CLEANUP) then
+ if (dissect_current_state = IDLE) then
reset_detected <= '0';
- elsif (PS_DATA_IN(7 downto 0) = x"80" and PS_WR_EN_IN = '1' and PS_ACTIVATE_IN = '1' and saved_hdr_ctr = "0100") then--and dissect_current_state = IDLE and PS_WR_EN_IN = '1' and PS_ACTIVATE_IN = '1') then -- first byte as 0x80
+ elsif (PS_DATA_IN(7 downto 0) = x"80" and PS_WR_EN_IN = '1' and PS_ACTIVATE_IN = '1' and saved_hdr_ctr = "0100") then
reset_detected <= '1';
+ else
+ reset_detected <= reset_detected;
end if;
end if;
end process RESET_DETECTED_PROC;
MAKE_RESET_PROC : process(CLK)
begin
if rising_edge(CLK) then
- if (RESET = '1') then
+ if (dissect_current_state = IDLE) then
make_reset <= '0';
elsif (dissect_current_state = CLEANUP and reset_detected = '1') then
make_reset <= '1';
+ else
+ make_reset <= make_reset;
end if;
end if;
end process MAKE_RESET_PROC;
PC_TRIG_NR_IN => pc_trig_nr,
PC_TRIGGER_TYPE_IN => pc_trig_type,
PC_QUEUE_DEC_IN => CFG_QUEUE_DEC_IN, --x"0003_0062", --pc_queue_dec,
- PC_MAX_FRAME_SIZE_IN => g_MAX_FRAME_SIZE,
+ PC_MAX_FRAME_SIZE_IN => (others => '0'), -- not used anymore
PC_MAX_QUEUE_SIZE_IN => x"0000_0fd0", -- not used for the moment
PC_DELAY_IN => (others => '0'),
PC_INSERT_TTYPE_IN => CFG_INSERT_TTYPE_IN,
when x"04" =>
max_frame <= BUS_DATA_IN(15 downto 0);
- g_MAX_FRAME_SIZE <= BUS_DATA_IN(15 downto 0);
when x"05" =>
if (BUS_DATA_IN = x"0000_0000") then
TC_SRC_UDP_IN : in std_logic_vector(15 downto 0);
TC_TRANSMISSION_DONE_OUT : out std_logic;
TC_IDENT_IN : in std_logic_vector(15 downto 0);
+ TC_MAX_FRAME_IN : in std_logic_vector(15 downto 0);
-- signal to/from frame constructor
FC_DATA_OUT : out std_logic_vector(7 downto 0);
begin
-TRANSMIT_MACHINE_PROC : process(CLK)
+TRANSMIT_MACHINE_PROC : process(RESET, CLK)
begin
if RESET = '1' then
transmit_current_state <= IDLE;
end if;
end process TRANSMIT_MACHINE_PROC;
-TRANSMIT_MACHINE : process(transmit_current_state, FC_H_READY_IN, TC_DATAREADY_IN, FC_READY_IN, local_end, g_MAX_FRAME_SIZE, actual_frame_bytes, go_to_divide)
+TRANSMIT_MACHINE : process(transmit_current_state, FC_H_READY_IN, TC_DATAREADY_IN, FC_READY_IN, local_end, TC_MAX_FRAME_IN, actual_frame_bytes, go_to_divide)
begin
case transmit_current_state is
if (local_end = x"0000") then
transmit_next_state <= SEND_ONE;
else
- if (actual_frame_bytes = g_MAX_FRAME_SIZE - x"1") then
+ if (actual_frame_bytes = TC_MAX_FRAME_IN - x"1") then
transmit_next_state <= SEND_ONE;
else
transmit_next_state <= TRANSMIT;
if rising_edge(CLK) then
if (transmit_current_state = IDLE or transmit_current_state = DIVIDE) then
go_to_divide <= '0';
- elsif (transmit_current_state = TRANSMIT and actual_frame_bytes = g_MAX_FRAME_SIZE - x"1") then
+ elsif (transmit_current_state = TRANSMIT and actual_frame_bytes = TC_MAX_FRAME_IN - x"1") then
go_to_divide <= '1';
-- elsif (transmit_current_state = SEND_ONE and full_packet_size < packet_loaded_bytes - x"1") then
-- go_to_divide <= '1';
begin
if rising_edge(CLK) then
if (transmit_current_state = PREPARE_HEADERS) then
- if (local_end >= g_MAX_FRAME_SIZE) then
- ip_size <= g_MAX_FRAME_SIZE;
+ if (local_end >= TC_MAX_FRAME_IN) then
+ ip_size <= TC_MAX_FRAME_IN;
else
ip_size <= local_end + x"1";
end if;
begin
if rising_edge(CLK) then
if (transmit_current_state = PREPARE_HEADERS) then
- if (local_end >= g_MAX_FRAME_SIZE) then
+ if (local_end >= TC_MAX_FRAME_IN) then
more_fragments <= '1';
else
more_fragments <= '0';
TC_SRC_UDP_IN : in std_logic_vector(15 downto 0);
TC_IDENT_IN : in std_logic_vector(15 downto 0);
TC_TRANSMISSION_DONE_OUT : out std_logic;
+ TC_MAX_FRAME_IN : in std_logic_vector(15 downto 0);
-- signal to/from frame constructor
FC_DATA_OUT : out std_logic_vector(7 downto 0);
CLK : in std_logic; -- system clock
CLK_125 : in std_logic;
RESET : in std_logic;
- RESET_FOR_DHCP : in std_logic;
MC_LINK_OK_OUT : out std_logic;
MC_RESET_LINK_IN : in std_logic;
-- g_MY_MAC is being set by Main Controller
signal g_MY_MAC : std_logic_vector(47 downto 0);
--- size of ethernet frame use for fragmentation of outgoing packets
-signal g_MAX_FRAME_SIZE : std_logic_vector(15 downto 0) := x"0578"; --x"0200"; -- set up in main controller
-
---signal g_MAX_PACKET_SIZE : std_logic_vector(15 downto 0);
-
constant c_MAX_FRAME_TYPES : integer range 1 to 16 := 2;
constant c_MAX_PROTOCOLS : integer range 1 to 16 := 5; --5; --4; --5;
constant c_MAX_IP_PROTOCOLS : integer range 1 to 16 := 2;