From e1fc4b5d61c779a7b189da83a86524e52f3b1081 Mon Sep 17 00:00:00 2001 From: Peter Lemmens Date: Wed, 18 Mar 2015 17:18:04 +0100 Subject: [PATCH] Slow-control interface update; added soda-enable bit and soda-reset bit Details in SODA_addressmap.odt --- SODA_addressmap | 45 ++- code/med_ecp3_sfp_sync_down.vhd | 12 +- code/soda_components.vhd | 6 +- code/soda_packet_builder.vhd | 84 ++++-- code/soda_source.vhd | 100 ++++--- code/soda_superburst_gen.vhd | 4 +- soda_hub_probe.rvl | 197 ++++++++++++-- soda_source.ldf | 4 +- soda_source_groningen.lpf | 2 +- soda_source_probe.rvl | 469 ++++++++++++++++++++++++-------- trb3_soda_hub.xcf | 17 +- trb3_soda_source.xcf | 11 +- 12 files changed, 684 insertions(+), 267 deletions(-) diff --git a/SODA_addressmap b/SODA_addressmap index b37255d..46f3c7e 100644 --- a/SODA_addressmap +++ b/SODA_addressmap @@ -1,9 +1,12 @@ -SODA_SOURCE (0xF355) -++++++++++++++++++++ +SODA_SOURCE (0xF355) + + WRITE_REG: BE00 soda_cmd_word_S -BE01 LEDregister_i +BE01 -- +BE02 -- +BE03 CTRL_STATUS_register_i READ_REG: @@ -12,10 +15,20 @@ BE01 super_burst_nr_S BE02 calib_register_S BE03 CTRL_STATUS_register_i -c +CONTROL(r/w): +CTRL_STATUS_register_i[31] : soda_reset_S +CTRL_STATUS_register_i[30] : soda_enable_S +CTRL_STATUS_register_i[29] : dead_channel_S +CTRL_STATUS_register_i[28:16] : -- +STATUS(read-only): +CTRL_STATUS_register_i[15] : report_error_S +CTRL_STATUS_register_i[14:2] : -- +CTRL_STATUS_register_i[1] : downstream_error_S +CTRL_STATUS_register_i[0] : channel_timeout_status_S + SODA_CLIENT (0xF356) -++++++++++++++++++++ + WRITE_REG: BE00 LEDregister_i @@ -31,9 +44,8 @@ BE05 Debug_TX_count BE06 Debug_SOS_count BE07 Debug_CMD_count - Cu_TRB_SODA_HUB (0xF35B) -++++++++++++++++++++++++++ + WRITE_REG: BE00 soda_cmd_word_S @@ -55,13 +67,16 @@ BE09 calib_register_S channel2 BE10 calib_register_S channel3 BE11 calib_register_S channel4 -control(read & write): -CTRL_STATUS_register_i[8] : dead_channel -CTRL_STATUS_register_i[15] : reset errors -status(read-only): -CTRL_STATUS_register_i[17] : timeout-error -CTRL_STATUS_register_i[18] : downstream-error -CTRL_STATUS_register_i[31] : report error +CONTROL(r/w): +CTRL_STATUS_register_i[31] : soda_reset_S +CTRL_STATUS_register_i[30] : soda_enable_S +CTRL_STATUS_register_i[29] : dead_channel_S +CTRL_STATUS_register_i[28:16] : -- +STATUS(read-only): +CTRL_STATUS_register_i[15] : report_error_S +CTRL_STATUS_register_i[14:2] : -- +CTRL_STATUS_register_i[1] : downstream_error_S +CTRL_STATUS_register_i[0] : channel_timeout_status_S DEBUG_STATUS(31) <= send_link_reset_i when rising_edge(SYSCLK); DEBUG_STATUS(30) <= '0'; @@ -77,7 +92,7 @@ DEBUG_STATUS(2) <= CLK_EN; DEBUG_STATUS(1) <= CLEAR; DEBUG_STATUS(0) <= RESET; -------------------------------------------------------------------- + constant K_IDLE : std_logic_vector(7 downto 0) := x"BC"; constant D_IDLE0 : std_logic_vector(7 downto 0) := x"C5"; constant D_IDLE1 : std_logic_vector(7 downto 0) := x"50"; diff --git a/code/med_ecp3_sfp_sync_down.vhd b/code/med_ecp3_sfp_sync_down.vhd index 4f4584d..3a496ff 100644 --- a/code/med_ecp3_sfp_sync_down.vhd +++ b/code/med_ecp3_sfp_sync_down.vhd @@ -190,18 +190,18 @@ signal rx_fsm_state : std_logic_vector(3 downto 0); signal tx_fsm_state : std_logic_vector(3 downto 0); signal debug_reg : std_logic_vector(63 downto 0); -signal led_dlm, last_led_dlm : std_logic; -signal led_ok : std_logic; -signal led_tx, last_led_tx : std_logic; -signal led_rx, last_led_rx : std_logic; -signal timer : unsigned(20 downto 0); - type sci_ctrl is (IDLE, SCTRL, SCTRL_WAIT, SCTRL_WAIT2, SCTRL_FINISH, GET_WA, GET_WA_WAIT, GET_WA_WAIT2, GET_WA_FINISH); signal sci_state : sci_ctrl; signal sci_timer : unsigned(12 downto 0) := (others => '0'); signal start_timer : unsigned(18 downto 0) := (others => '0'); --signal watchdog_timer : unsigned(20 downto 0) := (others => '0'); --signal watchdog_trigger : std_logic :='0'; + +signal led_dlm, last_led_dlm : std_logic; +signal led_ok : std_logic; +signal led_tx, last_led_tx : std_logic; +signal led_rx, last_led_rx : std_logic; +signal timer : unsigned(20 downto 0); begin diff --git a/code/soda_components.vhd b/code/soda_components.vhd index 594b699..515cb6b 100644 --- a/code/soda_components.vhd +++ b/code/soda_components.vhd @@ -65,7 +65,7 @@ package soda_components is port( SODACLK : in std_logic; -- fabric clock RESET : in std_logic; -- synchronous reset - --Internal Connection + ENABLE : in std_logic; -- synchronous reset SODA_BURST_PULSE_IN : in std_logic := '0'; -- START_OF_SUPERBURST_OUT : out std_logic := '0'; SUPER_BURST_NR_OUT : out std_logic_vector(30 downto 0) := (others => '0'); @@ -80,8 +80,8 @@ package soda_components is --Internal Connection LINK_PHASE_IN : in std_logic := '0'; SODA_CYCLE_IN : in std_logic := '0'; - SODA_CMD_WINDOW_IN : in std_logic := '0'; - SODA_CMD_STROBE_IN : in std_logic := '0'; -- + SODA_CMD_WINDOW_IN : in std_logic := '0'; + SODA_CMD_STROBE_IN : in std_logic := '0'; START_OF_SUPERBURST : in std_logic := '0'; SUPER_BURST_NR_IN : in std_logic_vector(30 downto 0) := (others => '0'); SODA_CMD_WORD_IN : in std_logic_vector(30 downto 0) := (others => '0'); --REGIO_CTRL_REG in trbnet handler is 32 bit diff --git a/code/soda_packet_builder.vhd b/code/soda_packet_builder.vhd index 1b7de86..be45e14 100644 --- a/code/soda_packet_builder.vhd +++ b/code/soda_packet_builder.vhd @@ -16,7 +16,7 @@ entity soda_packet_builder is --Internal Connection LINK_PHASE_IN : in std_logic := '0'; -- even/odd fase needed to match 16-bit link stuff in trb SODA_CYCLE_IN : in std_logic := '0'; -- 40MHz cycle for soda transmissions - SODA_CMD_WINDOW_IN : in std_logic := '0'; + SODA_CMD_WINDOW_IN : in std_logic := '0'; SODA_CMD_STROBE_IN : in std_logic := '0'; START_OF_SUPERBURST : in std_logic := '0'; SUPER_BURST_NR_IN : in std_logic_vector(30 downto 0) := (others => '0'); @@ -52,9 +52,13 @@ architecture Behavioral of soda_packet_builder is c_WAIT4CYCLE_B, c_BST1, c_BST2, c_BST3, c_BST4, c_BST5, c_BST6, c_BST7, c_BST8, c_WAIT4CYCLE_C, c_CMD1, c_CMD2, c_CMD3, c_CMD4, c_CMD5, c_CMD6, c_CMD7, c_CMD8 ); -- c_WAIT4BST1, c_WAIT4CMD1, - signal build_packet_state_S : build_packet_state_type := c_IDLE; + signal build_packet_state_S : build_packet_state_type := c_IDLE; signal build_packet_bits_S : std_logic_vector(7 downto 0) := (others => '0'); + type cmd_window_state_type is ( c_WINDOW_IDLE, c_WAIT4WINDOW, c_START_CMD); + signal cmd_window_state_S : cmd_window_state_type := c_WINDOW_IDLE; + + signal soda_dlm_preview_S : std_logic; begin @@ -82,33 +86,65 @@ begin TX_DLM_WORD_OUT <= soda_pkt_word_S; - strobe_delay_proc : process(SODACLK) - begin - if rising_edge(SODACLK) then - if (RESET='1') then - soda_cmd_pending_S <= '0'; - elsif (SODA_CMD_STROBE_IN='1') then - soda_cmd_pending_S <= '1'; - elsif (soda_cmd_strobe_S='1') then - soda_cmd_pending_S <= '0'; - end if; - end if; - end process; +-- strobe_delay_proc : process(SODACLK) +-- begin +-- if rising_edge(SODACLK) then +-- if (RESET='1') then +-- soda_cmd_pending_S <= '0'; +-- elsif (SODA_CMD_STROBE_IN='1') then +-- soda_cmd_pending_S <= '1'; +-- elsif (soda_cmd_strobe_S='1') then +-- soda_cmd_pending_S <= '0'; +-- end if; +-- end if; +-- end process; - strobe_delivery_proc : process(SODACLK) +-- strobe_delivery_proc : process(SODACLK) +-- begin +-- if rising_edge(SODACLK) then +-- if (RESET='1') then +-- soda_cmd_strobe_S <= '0'; +-- elsif ((SODA_CMD_STROBE_IN='1') and (soda_cmd_pending_S='1')) then +-- soda_cmd_strobe_S <= '1'; +-- else +-- soda_cmd_strobe_S <= '0'; +-- end if; +-- end if; +-- end process; + + SODA_CMD_FLOWCTRL : process(SODACLK) begin - if rising_edge(SODACLK) then - if (RESET='1') then - soda_cmd_strobe_S <= '0'; - elsif ((SODA_CMD_STROBE_IN='1') and (soda_cmd_pending_S='1')) then - soda_cmd_strobe_S <= '1'; + if( rising_edge(SODACLK) ) then + if( RESET = '1' ) then + cmd_window_state_S <= c_WINDOW_IDLE; + soda_cmd_pending_S <= '0'; + soda_cmd_strobe_S <= '0'; else - soda_cmd_strobe_S <= '0'; + case cmd_window_state_S is + when c_WINDOW_IDLE => + if (SODA_CMD_STROBE_IN='1') then + cmd_window_state_S <= c_WAIT4WINDOW; + soda_cmd_pending_S <= '1'; + end if; + when c_WAIT4WINDOW => + if ((SODA_CMD_WINDOW_IN ='1') and (soda_cmd_pending_S ='1')) then + cmd_window_state_S <= c_START_CMD; + soda_cmd_strobe_S <= '1'; + soda_cmd_pending_S <= '0'; + end if; + when c_START_CMD => + cmd_window_state_S <= c_WINDOW_IDLE; + soda_cmd_strobe_S <= '0'; + soda_cmd_pending_S <= '0'; + when others => + cmd_window_state_S <= c_WINDOW_IDLE; + soda_cmd_strobe_S <= '0'; + soda_cmd_pending_S <= '0'; + end case; end if; end if; - end process; - + end process SODA_CMD_FLOWCTRL; packet_fsm_proc : process(SODACLK) begin @@ -239,7 +275,7 @@ begin soda_dlm_preview_S <= '0'; reg1_soda_pkt_valid_S <= '0'; when c_BST8 => - if (SODA_CMD_STROBE_IN='0') then + if (soda_cmd_strobe_S='0') then soda_dlm_preview_S <= '0'; build_packet_bits_S <= x"00"; build_packet_state_S <= c_IDLE; diff --git a/code/soda_source.vhd b/code/soda_source.vhd index 4b259c2..ae227fb 100644 --- a/code/soda_source.vhd +++ b/code/soda_source.vhd @@ -62,7 +62,8 @@ architecture Behavioral of soda_source is signal store_rd : std_logic; signal buf_bus_data_out : std_logic_vector(31 downto 0); - signal CTRL_STATUS_register_i : std_logic_vector(31 downto 0); + signal CTRL_STATUS_register_S : std_logic_vector(31 downto 0); +-- signal SODA_CMD_register_i : std_logic_vector(31 downto 0); signal test_line_i : std_logic_vector(31 downto 0); signal reply_data_valid_S : std_logic; @@ -77,18 +78,21 @@ architecture Behavioral of soda_source is signal reply_timeout_error_S : std_logic; signal channel_timeout_status_S : std_logic; signal downstream_error_S : std_logic; + signal report_error_S : std_logic; signal dead_channel_S : std_logic; + signal soda_reset_S : std_logic; + signal soda_enable_S : std_logic; -begin - +begin + superburst_gen : soda_superburst_generator generic map(BURST_COUNT => 16) port map( SODACLK => SODACLK, - RESET => RESET, - --Internal Connection + RESET => soda_reset_S, + ENABLE => soda_enable_S, SODA_BURST_PULSE_IN => SODA_BURST_PULSE_IN, START_OF_SUPERBURST_OUT => start_of_superburst_S, SUPER_BURST_NR_OUT => super_burst_nr_S, @@ -103,7 +107,7 @@ begin LINK_PHASE_IN => LINK_PHASE_IN, --link_phase_S, PL! SODA_CYCLE_IN => SODA_CYCLE_IN, SODA_CMD_WINDOW_IN => soda_cmd_window_S, - SODA_CMD_STROBE_IN => soda_send_cmd_S, + SODA_CMD_STROBE_IN => soda_cmd_strobe_sodaclk_S, --soda_send_cmd_S, goes with removal of SODA_CMD_FLOWCTRL START_OF_SUPERBURST => start_of_superburst_S, SUPER_BURST_NR_IN => super_burst_nr_S, SODA_CMD_WORD_IN => soda_cmd_word_S, @@ -146,38 +150,34 @@ begin begin if rising_edge(SYSCLK) then if( RESET = '1' ) then - calib_register_S <= (others => '0'); - channel_timeout_status_S <= '0'; - downstream_error_S <= '0'; - CTRL_STATUS_register_i(16) <= '0'; -- reset DOWNSTREAM_ERROR status-bit - CTRL_STATUS_register_i(17) <= '0'; -- reset DOWNSTREAM_ERROR status-bit - CTRL_STATUS_register_i(31) <= '0'; -- reset REPORT_ERROR status-bit + calib_register_S <= (others => '0'); + channel_timeout_status_S <= '0'; + downstream_error_S <= '0'; + channel_timeout_status_S <= '0'; + report_error_S <= '0'; elsif (calib_data_valid_S = '1') then -- calibration finished in time - calib_register_S(15 downto 0) <= calibration_time_S; - channel_timeout_status_S <= '0'; + calib_register_S(15 downto 0) <= calibration_time_S; + channel_timeout_status_S <= '0'; elsif (reply_data_valid_S = '1') then -- the reply was correct - channel_timeout_status_S <= '0'; + channel_timeout_status_S <= '0'; if (reply_OK_S = '1') then - downstream_error_S <= '0'; + downstream_error_S <= '0'; elsif (dead_channel_S = '0') then - downstream_error_S <= '1'; - CTRL_STATUS_register_i(16) <= '1'; -- set DOWNSTREAM_ERROR status-bit - CTRL_STATUS_register_i(31) <= '1'; -- set REPORT_ERROR status-bit + downstream_error_S <= '1'; + report_error_S <= '1'; -- set REPORT_ERROR status-bit end if; elsif ((reply_timeout_error_S = '1') and (reply_OK_S = '1')) then - channel_timeout_status_S <= '1'; - CTRL_STATUS_register_i(17) <= '1'; -- set CALIBRATION_TIMEOUT_ERROR status-bit - CTRL_STATUS_register_i(31) <= '1'; -- set REPORT_ERROR status-bit - elsif (CTRL_STATUS_register_i(15) = '1') then -- check if slowcontrol wants to reset errors - CTRL_STATUS_register_i(16) <= '0'; -- reset DOWNSTREAM_ERROR status-bit - CTRL_STATUS_register_i(17) <= '0'; -- reset DOWNSTREAM_ERROR status-bit - CTRL_STATUS_register_i(31) <= '0'; -- reset REPORT_ERROR status-bit + channel_timeout_status_S <= '1'; + downstream_error_S <= '1'; -- set CALIBRATION_TIMEOUT_ERROR status-bit + report_error_S <= '1'; -- set REPORT_ERROR status-bit + elsif (report_error_S = '1') then -- check if slowcontrol wants to reset errors + channel_timeout_status_S <= '0'; + downstream_error_S <= '0'; -- set CALIBRATION_TIMEOUT_ERROR status-bit + report_error_S <= '0'; -- set REPORT_ERROR status-bit end if; end if; end process; - - --------------------------------------------------------- -- RegIO Statemachine --------------------------------------------------------- @@ -252,23 +252,21 @@ soda_cmd_strobe_posedge_to_pulse: posedge_to_pulse PULSE_OUT => soda_cmd_strobe_sodaclk_S ); -SODA_CMD_FLOWCTRL : process(SODACLK) - begin - if( rising_edge(SODACLK) ) then - if( RESET = '1' ) then - soda_cmd_pending_S <= '0'; - soda_send_cmd_S <= '0'; - elsif soda_cmd_strobe_sodaclk_S = '1' then - soda_cmd_pending_S <= '1'; - elsif soda_cmd_window_S = '1' and soda_cmd_pending_S = '1' then - soda_send_cmd_S <= '1'; - soda_cmd_pending_S <= '0'; - else - soda_cmd_pending_S <= '0'; - soda_send_cmd_S <= '0'; - end if; - end if; - end process SODA_CMD_FLOWCTRL; + +--------------------------------------------------------- +-- Control bits -- +--------------------------------------------------------- + soda_reset_S <= (RESET or CTRL_STATUS_register_S(31)); + soda_enable_S <= CTRL_STATUS_register_S(30); + dead_channel_S <= CTRL_STATUS_register_S(29); -- slow-control can declare a channel dead +--------------------------------------------------------- +-- Status bits -- +--------------------------------------------------------- + CTRL_STATUS_register_S(15) <= report_error_S; + CTRL_STATUS_register_S(14 downto 2) <= (others => '0'); + CTRL_STATUS_register_S(1) <= downstream_error_S; + CTRL_STATUS_register_S(0) <= channel_timeout_status_S; + --------------------------------------------------------- -- data handling -- --------------------------------------------------------- @@ -280,21 +278,19 @@ SODA_CMD_FLOWCTRL : process(SODACLK) if ( RESET = '1' ) then soda_cmd_strobe_S <= '0'; soda_cmd_word_S <= (others => '0'); - CTRL_STATUS_register_i(15 downto 0) <= (others => '0'); + CTRL_STATUS_register_S(31 downto 16) <= (30 => '1', others => '0'); -- enable soda by default elsif( (store_wr = '1') and (SODA_ADDR_IN = "0000") ) then soda_cmd_strobe_S <= '1'; soda_cmd_word_S <= SODA_DATA_IN(30 downto 0); - elsif( (store_wr = '1') and (SODA_ADDR_IN = "0001") ) then + elsif( (store_wr = '1') and (SODA_ADDR_IN = "0011") ) then soda_cmd_strobe_S <= '0'; - CTRL_STATUS_register_i(15 downto 0) <= SODA_DATA_IN(15 downto 0); -- use only the 16 lower bits for control + CTRL_STATUS_register_S(31 downto 16) <= SODA_DATA_IN(31 downto 16); -- use only the 16 upper bits for control else soda_cmd_strobe_S <= '0'; end if; end if; end process THE_WRITE_REG_PROC; - dead_channel_S <= CTRL_STATUS_register_i(8); -- slow-control can declare a channel dead - -- register read THE_READ_REG_PROC: process( SYSCLK ) @@ -309,13 +305,13 @@ SODA_CMD_FLOWCTRL : process(SODACLK) elsif( (store_rd = '1') and (SODA_ADDR_IN = "0010") ) then buf_bus_data_out <= calib_register_S; elsif( (store_rd = '1') and (SODA_ADDR_IN = "0011") ) then - buf_bus_data_out <= CTRL_STATUS_register_i; + buf_bus_data_out <= CTRL_STATUS_register_S; end if; end if; end process THE_READ_REG_PROC; -- output signals - LEDS_OUT <= CTRL_STATUS_register_i(3 downto 0); + LEDS_OUT <= CTRL_STATUS_register_S(3 downto 0); SODA_DATA_OUT <= buf_bus_data_out; SODA_ACK_OUT <= bus_ack; diff --git a/code/soda_superburst_gen.vhd b/code/soda_superburst_gen.vhd index 0c7b925..55f8a32 100644 --- a/code/soda_superburst_gen.vhd +++ b/code/soda_superburst_gen.vhd @@ -17,7 +17,7 @@ entity soda_superburst_generator is port( SODACLK : in std_logic; -- fabric clock RESET : in std_logic; -- synchronous reset - --Internal Connection + ENABLE : in std_logic := '1'; SODA_BURST_PULSE_IN : in std_logic := '0'; -- START_OF_SUPERBURST_OUT : out std_logic := '0'; SUPER_BURST_NR_OUT : out std_logic_vector(30 downto 0) := (others => '0'); @@ -46,7 +46,7 @@ begin burst_counter_S <= cBURST_COUNT; START_OF_SUPERBURST_OUT <= '0'; super_burst_nr_S <= (others => '0'); - elsif ((SODA_BURST_PULSE_IN = '1') and (soda_burst_pulse_S = '0')) then + elsif ((SODA_BURST_PULSE_IN = '1') and (soda_burst_pulse_S = '0') and (ENABLE='1')) then if (burst_counter_S = x"00") then START_OF_SUPERBURST_OUT <= '1'; super_burst_nr_S <= super_burst_nr_S + 1; diff --git a/soda_hub_probe.rvl b/soda_hub_probe.rvl index c6f73dc..644a0ea 100644 --- a/soda_hub_probe.rvl +++ b/soda_hub_probe.rvl @@ -1,7 +1,7 @@ - + - + @@ -118,34 +118,173 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/soda_source.ldf b/soda_source.ldf index d78233a..02e2c21 100644 --- a/soda_source.ldf +++ b/soda_source.ldf @@ -4,7 +4,7 @@ - + 2 Lattice LatticeECP3 @@ -45,8 +45,8 @@ 1 0 - /local/lemmens/lattice/soda/trb3_periph_sodahub_20150304.bit - 03/04/15 14:53:50 + /local/lemmens/lattice/soda/trb3_periph_sodahub_20150317.bit + 03/17/15 15:09:57 Fast Program - + 5 Lattice LatticeECP3 @@ -132,8 +131,8 @@ 1 0 - /local/lemmens/lattice/soda/trb3_periph_sodasource_20150303.bit - 03/03/15 17:13:40 + /local/lemmens/lattice/soda/trb3_periph_sodasource_20150318.bit + 03/18/15 13:53:16 N/A Fast Program