Commit c664d602 authored by Paolo Baesso's avatar Paolo Baesso

Merge branch 'master' into PythonScripts

parents b965ec88 9958f8e7
......@@ -28,8 +28,8 @@ set_property PACKAGE_PIN F6 [get_ports gpio]
## Crystal clock
set_property IOSTANDARD LVDS_25 [get_ports sysclk_40_i_p]
set_property PACKAGE_PIN T4 [get_ports sysclk_40_i_n]
set_property PACKAGE_PIN T5 [get_ports sysclk_40_i_p]
set_property PACKAGE_PIN T4 [get_ports sysclk_40_i_n]
## Output clock (currently not working so set to 0)
set_property IOSTANDARD LVCMOS33 [get_ports sysclk_50_o_p]
......@@ -106,3 +106,35 @@ set_property PACKAGE_PIN G3 [get_ports {dut_clk_i[3]}]
set_property BITSTREAM.CONFIG.SPI_BUSWIDTH 4 [current_design]
create_debug_core u_ila_0 ila
set_property ALL_PROBE_SAME_MU true [get_debug_cores u_ila_0]
set_property ALL_PROBE_SAME_MU_CNT 4 [get_debug_cores u_ila_0]
set_property C_ADV_TRIGGER true [get_debug_cores u_ila_0]
set_property C_DATA_DEPTH 8192 [get_debug_cores u_ila_0]
set_property C_EN_STRG_QUAL true [get_debug_cores u_ila_0]
set_property C_INPUT_PIPE_STAGES 0 [get_debug_cores u_ila_0]
set_property C_TRIGIN_EN false [get_debug_cores u_ila_0]
set_property C_TRIGOUT_EN false [get_debug_cores u_ila_0]
set_property port_width 1 [get_debug_ports u_ila_0/clk]
connect_debug_port u_ila_0/clk [get_nets [list sysclk_40_BUFG]]
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe0]
set_property port_width 32 [get_debug_ports u_ila_0/probe0]
connect_debug_port u_ila_0/probe0 [get_nets [list {TrigNArray[0][0]} {TrigNArray[0][1]} {TrigNArray[0][2]} {TrigNArray[0][3]} {TrigNArray[0][4]} {TrigNArray[0][5]} {TrigNArray[0][6]} {TrigNArray[0][7]} {TrigNArray[0][8]} {TrigNArray[0][9]} {TrigNArray[0][10]} {TrigNArray[0][11]} {TrigNArray[0][12]} {TrigNArray[0][13]} {TrigNArray[0][14]} {TrigNArray[0][15]} {TrigNArray[0][16]} {TrigNArray[0][17]} {TrigNArray[0][18]} {TrigNArray[0][19]} {TrigNArray[0][20]} {TrigNArray[0][21]} {TrigNArray[0][22]} {TrigNArray[0][23]} {TrigNArray[0][24]} {TrigNArray[0][25]} {TrigNArray[0][26]} {TrigNArray[0][27]} {TrigNArray[0][28]} {TrigNArray[0][29]} {TrigNArray[0][30]} {TrigNArray[0][31]}]]
create_debug_port u_ila_0 probe
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe1]
set_property port_width 1 [get_debug_ports u_ila_0/probe1]
connect_debug_port u_ila_0/probe1 [get_nets [list {busy_o_OBUF[0]}]]
create_debug_port u_ila_0 probe
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe2]
set_property port_width 1 [get_debug_ports u_ila_0/probe2]
connect_debug_port u_ila_0/probe2 [get_nets [list {dut_clk_o_OBUF[0]}]]
create_debug_port u_ila_0 probe
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe3]
set_property port_width 1 [get_debug_ports u_ila_0/probe3]
connect_debug_port u_ila_0/probe3 [get_nets [list TriggerNumberStrobe6_out]]
set_property C_CLK_INPUT_FREQ_HZ 300000000 [get_debug_cores dbg_hub]
set_property C_ENABLE_CLK_DIVIDER false [get_debug_cores dbg_hub]
set_property C_USER_SCAN_CHAIN 1 [get_debug_cores dbg_hub]
connect_debug_port dbg_hub/clk [get_nets sysclk_40_BUFG]
......@@ -39,9 +39,10 @@ entity Dummy_DUT is
CLK : in STD_LOGIC; --! this is the USB clock.
RST : in STD_LOGIC; --! Synchronous clock
Trigger : in STD_LOGIC; --! Trigger from TLU
stretchBusy: in STD_LOGIC; -- flag: if 1, then we want to extend the BUSY signal
Busy : out STD_LOGIC; --! Busy to TLU
DUTClk : out STD_LOGIC; --! clock from DUT
TriggerNumber : out STD_LOGIC_VECTOR(15 downto 0);
TriggerNumber : out STD_LOGIC_VECTOR(31 downto 0);
TriggerNumberStrobe : out STD_LOGIC;
FSM_Error : out STD_LOGIC
);
......@@ -63,12 +64,12 @@ architecture RTL of Dummy_DUT is
signal Registered_Trigger , Registered_RST : std_logic; -- trigger and reset signals after being registered to suppress meta-stability.
signal TriggerShiftRegister : STD_LOGIC_VECTOR (15 downto 0); --! register
signal TriggerShiftRegister : STD_LOGIC_VECTOR (31 downto 0); --! register
--to accept
--incoming
--trigger number
type state_type is (IDLE , WAIT_FOR_TRIGGER_LOW , CLOCKING , OUTPUT_TRIGGER_NUMBER);
type state_type is (IDLE , WAIT_FOR_TRIGGER_LOW , CLOCKING , OUTPUT_TRIGGER_NUMBER, BUSYDELAY);
signal state : state_type := IDLE;
signal next_state : state_type := IDLE;
......@@ -81,6 +82,8 @@ architecture RTL of Dummy_DUT is
constant TriggerBitCounterLimit : unsigned(4 downto 0) := to_unsigned(16,5);
signal DUTClockCounter : unsigned(4 downto 0) := ( others => '0');
signal s_busySR : unsigned( 14 downto 0) := ( others => '0' ); -- --! Shift register to generate stretch
begin
......@@ -111,6 +114,30 @@ begin
end if;
end if;
end process busy_control;
-- busy_control: process (clk , state)
-- begin -- process busy_control
-- if rising_edge(clk) then
-- if (stretchBusy ='1') then
-- if ((state = IDLE) and (s_busySR=0)) then
-- busy <= '0';
-- s_busySR <= ( others => '1' );
-- elsif ( (state = IDLE) and (s_busySR /= 0) ) then
-- busy <= '1';
-- s_busySR <= s_busySR -1;
-- else
-- busy <= '1';
-- s_busySR <= s_busySR -1;
-- end if;
-- else
-- if state = IDLE then
-- busy <= '0';
-- else
-- busy <= '1';
-- end if;
-- end if;
-- end if;
-- end process busy_control;
clock_control: process (clk , state , TriggerBitCounter )
begin -- process busy_control
......@@ -153,7 +180,7 @@ begin
elsif state = CLOCKING then
if (InternalDUTClk = '1') and (DUTClockCounter=to_unsigned(1,4 )) then
-- if (InternalDUTClk = '1') and (DUTClockCounter=to_unsigned(1,DUTClockCounter'length )) then
TriggerShiftRegister <= trigger & TriggerShiftRegister( 15 downto 1) ;
TriggerShiftRegister <= trigger & TriggerShiftRegister( 31 downto 1) ;
-- TriggerShiftRegister <= trigger & TriggerShiftRegister( TriggerShiftRegister'high downto 1) ;
else
TriggerShiftRegister <= TriggerShiftRegister;
......@@ -174,11 +201,22 @@ begin
end if;
end process strobe_control;
busy_delay_control: process(clk, state)
begin
if rising_edge(clk) then
if state= BUSYDELAY then
s_busySR <= s_busySR -1;
elsif state= WAIT_FOR_TRIGGER_LOW then
s_busySR <= ( others => '1' );
end if;
end if;
end process busy_delay_control;
--! @brief controls the next state in the state machine
-- type : combinational
-- inputs : pattern_we, mask_we , beam_state_counter
-- outputs: state , beam_state_counter
state_logic: process (state, TriggerBitCounter , registered_trigger ,InternalDUTClk )
state_logic: process (state, TriggerBitCounter , registered_trigger ,InternalDUTClk, stretchBusy, s_busySR )
begin -- process state_logic
case state is
......@@ -187,7 +225,7 @@ begin
next_state <= WAIT_FOR_TRIGGER_LOW;
else
next_state <= IDLE;
end if;
end if;
when WAIT_FOR_TRIGGER_LOW =>
if ( registered_trigger = '0' ) then
......@@ -204,7 +242,18 @@ begin
end if;
when OUTPUT_TRIGGER_NUMBER =>
next_state <= IDLE;
if (stretchBusy ='1') then
next_state <= BUSYDELAY;
else
next_state <= IDLE;
end if;
when BUSYDELAY =>
if (s_busySR /= 0) then
next_state <= BUSYDELAY;
else
next_state <= IDLE;
end if;
when others =>
next_state <= IDLE;
......
--=============================================================================
--! @file eventBuffer_rtl.vhd
--=============================================================================
--
-------------------------------------------------------------------------------
-- --
-- University of Bristol, High Energy Physics Group.
-- --
------------------------------------------------------------------------------- --
-- VHDL Architecture fmc_mTLU_lib.eventBuffer.rtl
--
--
-- Created using using Mentor Graphics HDL Designer(TM) 2010.3 (Build 21)
--
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.numeric_std.all;
USE work.ipbus.all;
--! @brief Stores input words (64bits) for readout over IPBus.
--! Uses a FIFO ( 64bits at input, 32 bits at output )
--
--
--! @author David Cussans , David.Cussans@bristol.ac.uk
--
--! @date 15:24:50 11/13/12
--
--! @version v0.1
--
--! @details
--! \n\nIPBus Address map:
--! \li 0x0000 - FIFO data
--! \li 0x0001 - FIFO fill level
--! \li 0x0010 - FIFO status/control: (Writing Bit-0 resets pointers, Reading bit-1 returns "prog_full" flag)
--!
--! <b>Modified by: Alvaro Dosil , alvaro.dosil@usc.es </b>\n
--------------------------------------------------------------------------------
ENTITY eventBuffer IS
GENERIC(
g_EVENT_DATA_WIDTH : positive := 32;
g_IPBUS_WIDTH : positive := 32;
g_READ_COUNTER_WIDTH : positive := 13
);
PORT(
clk_4x_logic_i : IN std_logic;
data_strobe_i : IN std_logic; -- Indicates data to transfer
event_data_i : IN std_logic_vector (g_EVENT_DATA_WIDTH-1 DOWNTO 0);
ipbus_clk_i : IN std_logic;
ipbus_i : IN ipb_wbus;
ipbus_reset_i : IN std_logic;
strobe_4x_logic_i : IN std_logic;
--trigger_count_i : IN std_logic_vector (g_IPBUS_WIDTH-1 DOWNTO 0); --! Not used yet.
rst_fifo_o : OUT std_logic; --! rst signal to first level fifos
buffer_full_o : OUT std_logic; --! Goes high when event buffer almost full
ipbus_o : OUT ipb_rbus;
logic_reset_i : IN std_logic -- reset buffers when high. Synch withclk_4x_logic
);
-- Declarations
END ENTITY eventBuffer ;
--
ARCHITECTURE rtl OF eventBuffer IS
signal s_rd_data_count : std_logic_vector(g_READ_COUNTER_WIDTH-1 downto 0) := (others =>'0');
signal s_fifo_fill_level : std_logic_vector(g_IPBUS_WIDTH-1 downto 0) := (others =>'0'); -- read-counter - 2*write_count
signal s_write_strobe : std_logic := '0';
signal s_rst_fifo, s_rst_fifo_ipb : std_logic := '0'; -- ! Take high to reset FIFO pointers.
signal s_fifo_prog_full : std_logic := '0'; -- ! Controlled by programmable-full flag of FIFO core
signal s_fifo_rd_en : std_logic := '0'; -- ! Take high to clock data out of FIFO
signal s_fifo_dout : std_logic_vector(g_IPBUS_WIDTH-1 downto 0); -- ! Output from FIFO ( fall-through mode)
signal s_fifo_valid : std_logic := '1'; -- ! High when data in FIFO
signal s_fifo_full, s_fifo_almost_full, s_fifo_empty, s_fifo_almost_empty : std_logic := '0'; -- ! full and empty FIFO flags
signal s_fifo_status_ipb , s_fifo_fill_level_d1 : std_logic_vector(ipbus_o.ipb_rdata'range) := (others => '0'); -- data registered onto IPBus clock
signal s_ack : std_logic := '0'; -- -- IPBus ACK signal
COMPONENT dummy_event_fifo
PORT (
rst : IN STD_LOGIC;
wr_clk : IN STD_LOGIC;
rd_clk : IN STD_LOGIC;
din : IN STD_LOGIC_VECTOR(g_EVENT_DATA_WIDTH-1 DOWNTO 0);
wr_en : IN STD_LOGIC;
rd_en : IN STD_LOGIC;
dout : OUT STD_LOGIC_VECTOR(g_EVENT_DATA_WIDTH-1 DOWNTO 0);
full : OUT STD_LOGIC;
almost_full : OUT STD_LOGIC;
empty : OUT STD_LOGIC;
almost_empty : OUT STD_LOGIC;
rd_data_count : OUT STD_LOGIC_VECTOR(12 DOWNTO 0);
prog_full : OUT STD_LOGIC
);
END COMPONENT;
BEGIN
-----------------------------------------------------------------------------
-- IPBus IO
-----------------------------------------------------------------------------
--! Generate IPBus ACK
ipbus_ack: process(ipbus_clk_i)
begin
if rising_edge(ipbus_clk_i) then
s_ack <= ipbus_i.ipb_strobe and not s_ack;
end if;
end process ipbus_ack;
ipbus_o.ipb_ack <= s_ack;
--! Generate FIFO read enable
--! take high for one cycle ( when ipb_strobe goes high but before ACK goes
--high to follow it
s_fifo_rd_en <= '1' when
ipbus_i.ipb_strobe = '1' and ipbus_i.ipb_write = '0' and ipbus_i.ipb_addr(1 downto 0) = "00" and s_ack = '0'
else '0';
ipbus_o.ipb_err <= '0';
--! Multiplex output data.
with ipbus_i.ipb_addr(1 downto 0) select ipbus_o.ipb_rdata <=
s_fifo_dout when "00",
s_fifo_fill_level when "01",
s_fifo_status_ipb when "10",
(others => '1') when others;
ipbus_write: process (ipbus_clk_i)
begin -- process ipbus_write
if rising_edge(ipbus_clk_i) then
s_rst_fifo_ipb <= '0';
if ipbus_i.ipb_strobe = '1' and ipbus_i.ipb_addr(1 downto 0) = "10" and ipbus_i.ipb_write = '1' then
s_rst_fifo_ipb <= '1';
end if;
-- Register data onto IPBus clock domain to ease timing closure.
s_fifo_status_ipb <= X"000000" & "000" & s_fifo_prog_full & s_fifo_full & s_fifo_almost_full & s_fifo_almost_empty & s_fifo_empty;
s_fifo_fill_level <= X"0000" & "000" & s_rd_data_count;
end if;
end process ipbus_write;
rst_fifo_o <= s_rst_fifo_ipb;
s_rst_fifo <= s_rst_fifo_ipb or logic_reset_i;
-----------------------------------------------------------------------------
-- FIFO and fill-level calculation
-----------------------------------------------------------------------------
-- Instantiate a buffer to store the data. 64-bit on input, 32-bit on output.
--event_fifo : entity work.tlu_event_fifo
event_fifo : dummy_event_fifo
PORT MAP (
rst => s_rst_fifo,
wr_clk => clk_4x_logic_i,
rd_clk => ipbus_clk_i,
--din => event_data_i,
din => event_data_i,
wr_en => data_strobe_i,
rd_en => s_fifo_rd_en,
dout => s_fifo_dout,
full => s_fifo_full,
almost_full => s_fifo_almost_full,
empty => s_fifo_empty,
almost_empty => s_fifo_almost_empty,
rd_data_count => s_rd_data_count,
prog_full => s_fifo_prog_full
);
buffer_full_o <= s_fifo_prog_full;
END ARCHITECTURE rtl;
......@@ -23,12 +23,12 @@ use work.ipbus.ALL;
entity top_EUDET_dummy is
generic(
constant FW_VERSION : unsigned(31 downto 0):= X"ffff0001"; -- Firmware revision. Remember to change this as needed.
constant FW_VERSION : unsigned(31 downto 0):= X"ffff0006"; -- Firmware revision. Remember to change this as needed.
g_NUM_DUTS : positive := 4; -- <- was 3
g_NUM_TRIG_INPUTS :positive := 6;-- <- was 4
g_NUM_EDGE_INPUTS :positive := 6;-- <-- was 4
g_NUM_EXT_SLAVES :positive :=8;-- <-- ??
g_EVENT_DATA_WIDTH :positive := 64;-- <-- ??
g_EVENT_DATA_WIDTH :positive := 32;-- <-- ??
g_IPBUS_WIDTH :positive := 32;-- <-- was 32
g_SPILL_COUNTER_WIDTH :positive := 12;-- <-- ??
g_BUILD_SIMULATED_MAC :integer := 0
......@@ -71,18 +71,13 @@ entity top_EUDET_dummy is
triggers_o: out std_logic_vector(g_NUM_DUTS-1 downto 0); --Trigger lines to DUTs
dut_clk_i: in std_logic_vector(g_NUM_DUTS-1 downto 0); --Clock from DUTs
dut_clk_o: out std_logic_vector(g_NUM_DUTS-1 downto 0) --Clock to DUTs
--reset_or_clk_n_o: out std_logic_vector(g_NUM_DUTS-1 downto 0); --T0 synchronization signal
--reset_or_clk_p_o: out std_logic_vector(g_NUM_DUTS-1 downto 0);
--shutter_to_dut_n_o: out std_logic_vector(g_NUM_DUTS-1 downto 0); --Shutter output
--shutter_to_dut_p_o: out std_logic_vector(g_NUM_DUTS-1 downto 0);
--TLU trigger inputs
--threshold_discr_n_i: in std_logic_vector(g_NUM_TRIG_INPUTS-1 downto 0);
--threshold_discr_p_i: in std_logic_vector(g_NUM_TRIG_INPUTS-1 downto 0)
--gpio_hdr: out std_logic_vector(3 downto 0);
--extclk_n_b: inout std_logic; --External clock in or clock output
--extclk_p_b: inout std_logic
--shutter_to_dut_p_o: out std_logic_vector(g_NUM_DUTS-1 downto 0);
);
end top_EUDET_dummy;
......@@ -137,6 +132,12 @@ architecture rtl of top_EUDET_dummy is
SIGNAL strobe_8x_logic : std_logic; --! Pulses one cycle every 4 of 16x clock.
SIGNAL strobe_4x_logic : std_logic; -- one pulse every 4 cycles of clk_4x
SIGNAL trigger_count : std_logic_vector(g_IPBUS_WIDTH-1 DOWNTO 0);
type myTrigArray is array (g_NUM_DUTS-1 downto 0) of std_logic_vector(g_IPBUS_WIDTH-1 DOWNTO 0);
signal TrigNArray : myTrigArray;
SIGNAL TriggerNumber : std_logic_vector(g_EVENT_DATA_WIDTH-1 DOWNTO 0);
SIGNAL TriggerNumberStrobe : std_logic_vector(g_NUM_DUTS-1 downto 0);
SIGNAL stretchFlags : std_logic_vector(g_NUM_DUTS-1 downto 0) := "0011"; -- ! define which dummyDUT have their busy line stretched
SIGNAL trigger_times : t_triggerTimeArray(g_NUM_TRIG_INPUTS-1 DOWNTO 0); -- ! trigger arrival time ( w.r.t. logic_strobe)
SIGNAL triggers : std_logic_vector(g_NUM_TRIG_INPUTS-1 DOWNTO 0);
SIGNAL veto_o : std_logic; --! goes high when one or more DUT are busy
......@@ -154,7 +155,7 @@ architecture rtl of top_EUDET_dummy is
port (
clk_4x_logic_i : IN std_logic ;
strobe_4x_logic_i : IN std_logic ; --! goes high every 4th clock cycle
trigger_counter_i : IN std_logic_vector (g_IPBUS_WIDTH-1 DOWNTO 0); --! Number of trigger events since last reset
trigger_counter_i : IN std_logic_vector (g_EVENT_DATA_WIDTH-1 DOWNTO 0); --! Number of trigger events since last reset
trigger_i : IN std_logic ; --! goes high when trigger logic issues a trigger
reset_or_clk_to_dut_i : IN std_logic ; --! Synchronization signal. Passed TO DUT pins
shutter_to_dut_i : IN std_logic ; --! Goes high TO indicate data-taking active. DUTs report busy unless ignoreShutterVeto IPBus flag is set high
......@@ -181,9 +182,10 @@ architecture rtl of top_EUDET_dummy is
CLK : in STD_LOGIC; --! this is the USB clock.
RST : in STD_LOGIC; --! Synchronous clock
Trigger : in STD_LOGIC; --! Trigger from TLU
stretchBusy: in STD_LOGIC; --! flag: if 1 extend the BUSY signal
Busy : out STD_LOGIC; --! Busy to TLU
DUTClk : out STD_LOGIC; --! clock from DUT
TriggerNumber : out STD_LOGIC_VECTOR(15 downto 0);
TriggerNumber : out STD_LOGIC_VECTOR(31 downto 0);
TriggerNumberStrobe : out STD_LOGIC;
FSM_Error : out STD_LOGIC
);
......@@ -191,41 +193,27 @@ end component;
----------------------------------------------
----------------------------------------------
-- COMPONENT T0_Shutter_Iface
-- PORT (
-- clk_4x_i : IN std_logic;
-- clk_4x_strobe : IN std_logic;
-- ipbus_clk_i : IN std_logic;
-- ipbus_i : IN ipb_wbus;
-- T0_o : OUT std_logic;
-- ipbus_o : OUT ipb_rbus;
-- shutter_o : OUT std_logic
-- );
-- END COMPONENT T0_Shutter_Iface;
----------------------------------------------
----------------------------------------------
-- COMPONENT eventBuffer
-- GENERIC (
-- g_EVENT_DATA_WIDTH : positive := 64;
-- g_IPBUS_WIDTH : positive := 32;
-- g_READ_COUNTER_WIDTH : positive := 16
-- );
-- PORT (
-- clk_4x_logic_i : IN std_logic ;
-- data_strobe_i : IN std_logic ; -- Indicates data TO transfer
-- event_data_i : IN std_logic_vector (g_EVENT_DATA_WIDTH-1 DOWNTO 0);
-- ipbus_clk_i : IN std_logic ;
-- ipbus_i : IN ipb_wbus ;
-- ipbus_reset_i : IN std_logic ;
-- strobe_4x_logic_i : IN std_logic ;
-- --trigger_count_i : IN std_logic_vector (g_IPBUS_WIDTH-1 DOWNTO 0); --! Not used yet.
-- rst_fifo_o : OUT std_logic ; --! rst signal TO first level fifos
-- buffer_full_o : OUT std_logic ; --! Goes high when event buffer almost full
-- ipbus_o : OUT ipb_rbus ;
-- logic_reset_i : IN std_logic -- reset buffers when high. Synch withclk_4x_logic
-- );
-- END COMPONENT eventBuffer;
COMPONENT eventBuffer
GENERIC (
g_EVENT_DATA_WIDTH : positive := 32;
g_IPBUS_WIDTH : positive := 32;
g_READ_COUNTER_WIDTH : positive := 16
);
PORT (
clk_4x_logic_i : IN std_logic ;
data_strobe_i : IN std_logic ; -- Indicates data TO transfer
event_data_i : IN std_logic_vector (g_EVENT_DATA_WIDTH-1 DOWNTO 0);
ipbus_clk_i : IN std_logic ;
ipbus_i : IN ipb_wbus ;
ipbus_reset_i : IN std_logic ;
strobe_4x_logic_i : IN std_logic ;
--trigger_count_i : IN std_logic_vector (g_IPBUS_WIDTH-1 DOWNTO 0); --! Not used yet.
rst_fifo_o : OUT std_logic ; --! rst signal TO first level fifos
buffer_full_o : OUT std_logic ; --! Goes high when event buffer almost full
ipbus_o : OUT ipb_rbus ;
logic_reset_i : IN std_logic -- reset buffers when high. Synch withclk_4x_logic
);
END COMPONENT eventBuffer;
----------------------------------------------
----------------------------------------------
-- COMPONENT eventFormatter
......@@ -291,63 +279,8 @@ end component;
);
END COMPONENT logic_clocks;
----------------------------------------------
----------------------------------------------
-- COMPONENT triggerInputs_newTLU
-- GENERIC (
-- g_NUM_INPUTS : natural := 1;
-- g_IPBUS_WIDTH : positive := 32
-- );
-- PORT (
-- --cfd_discr_p_i : IN std_logic_vector (g_NUM_INPUTS-1 DOWNTO 0); --! Inputs from constant-fraction discriminators
-- --cfd_discr_n_i : IN std_logic_vector (g_NUM_INPUTS-1 DOWNTO 0); --! Input from CFD
-- clk_4x_logic : IN std_logic ; --! Rising edge active. By default = 4*40MHz = 160MHz
-- clk_200_i : IN std_logic ;
-- strobe_4x_logic_i : IN std_logic ; --! Pulses high once every 4 cycles of clk_4x_logic
-- threshold_discr_p_i : IN std_logic_vector (g_NUM_INPUTS-1 DOWNTO 0); --! inputs from threshold comparators
-- threshold_discr_n_i : IN std_logic_vector (g_NUM_INPUTS-1 DOWNTO 0); --! inputs from threshold comparators
-- reset_i : IN std_logic ;
-- trigger_times_o : OUT t_triggerTimeArray (g_NUM_INPUTS-1 DOWNTO 0); --! trigger arrival time ( w.r.t. logic_strobe)
-- trigger_o : OUT std_logic_vector (g_NUM_INPUTS-1 DOWNTO 0); --! Goes high on leading edge of trigger, in sync with clk_4x_logic_i
-- --trigger_debug_o : OUT std_logic_vector ( ((2*g_NUM_INPUTS)-1) DOWNTO 0); --! Copy of input trigger level. High bits CFD, Low threshold
-- edge_rising_times_o : OUT t_triggerTimeArray (g_NUM_INPUTS-1 DOWNTO 0); --! edge arrival time ( w.r.t. logic_strobe)
-- edge_falling_times_o : OUT t_triggerTimeArray (g_NUM_INPUTS-1 DOWNTO 0); --! edge arrival time ( w.r.t. logic_strobe)
-- edge_rising_o : OUT std_logic_vector (g_NUM_INPUTS-1 DOWNTO 0); --! High when rising edge. Syncronous with clk_4x_logic_i
-- edge_falling_o : OUT std_logic_vector (g_NUM_INPUTS-1 DOWNTO 0); --! High when falling edge
-- ipbus_clk_i : IN std_logic ;
-- ipbus_reset_i : IN std_logic ;
-- ipbus_i : IN ipb_wbus ; --! Signals from IPBus core TO slave
-- ipbus_o : OUT ipb_rbus ; --! signals from slave TO IPBus core
-- clk_8x_logic_i : IN std_logic ; --! 640MHz clock ( 16x 40MHz )
-- strobe_8x_logic_i : IN std_logic --! Pulses one cycle every 4 of 8x clock.
-- );
-- END COMPONENT triggerInputs_newTLU;
----------------------------------------------
----------------------------------------------
-- COMPONENT triggerLogic
-- GENERIC (
-- g_NUM_INPUTS : positive := 4;
-- g_IPBUS_WIDTH : positive := 32
-- );
-- PORT (
-- clk_4x_logic_i : IN std_logic ; -- ! Rising edge active
-- ipbus_clk_i : IN std_logic ;
-- ipbus_i : IN ipb_wbus ; -- Signals from IPBus core TO slave
-- ipbus_reset_i : IN std_logic ;
-- logic_reset_i : IN std_logic ; -- active high. Synchronous with clk_4x_logic
-- logic_strobe_i : IN std_logic ; -- ! Pulses high once every 4 cycles of clk_4x_logic
-- trigger_i : IN std_logic_vector (g_NUM_INPUTS-1 DOWNTO 0); -- ! High when trigger from input connector active
-- trigger_times_i : IN t_triggerTimeArray (g_NUM_INPUTS-1 DOWNTO 0); --! trigger arrival time
-- veto_i : IN std_logic ; -- ! Halts triggers when high
-- trigger_o : OUT std_logic_vector (g_NUM_INPUTS-1 DOWNTO 0); -- ! High when trigger from input connector active and enabled
-- trigger_times_o : OUT t_triggerTimeArray (g_NUM_INPUTS-1 DOWNTO 0); --! trigger arrival time
-- event_number_o : OUT std_logic_vector (g_IPBUS_WIDTH-1 DOWNTO 0); -- starts at one. Increments for each post_veto_trigger
-- ipbus_o : OUT ipb_rbus ; -- signals from slave TO IPBus core
-- post_veto_trigger_o : OUT std_logic ; -- ! goes high when trigger passes
-- pre_veto_trigger_o : OUT std_logic ;
-- trigger_active_o : OUT std_logic --! Goes high when triggers are active ( ie. not veoted)
-- );
-- END COMPONENT triggerLogic;
COMPONENT i2c_master
PORT (
i2c_scl_i : IN std_logic;
......@@ -520,33 +453,7 @@ begin
logic_reset_o => logic_reset
);
----------------------------------------------
-- I5 : triggerInputs_newTLU
-- GENERIC MAP (
-- g_NUM_INPUTS => g_NUM_TRIG_INPUTS,
-- g_IPBUS_WIDTH => 32
-- )
-- PORT MAP (
-- clk_4x_logic => clk_4x_logic,
-- clk_200_i => clk_200,
-- strobe_4x_logic_i => strobe_4x_logic,
-- threshold_discr_p_i => threshold_discr_p_i,
-- threshold_discr_n_i => threshold_discr_n_i,
-- reset_i => logic_reset,
-- trigger_times_o => trigger_times,
-- trigger_o => triggers,
-- --trigger_debug_o => OPEN,
-- edge_rising_times_o => s_edge_rise_times,
-- edge_falling_times_o => s_edge_fall_times,
-- edge_rising_o => s_edge_rising,
-- edge_falling_o => s_edge_falling,
-- ipbus_clk_i => clk_ipb,
-- ipbus_reset_i => rst_ipb,
-- ipbus_i => ipbww(N_SLV_TRGIN),
-- ipbus_o => ipbrr(N_SLV_TRGIN),
-- clk_8x_logic_i => clk_8x_logic,
-- strobe_8x_logic_i => strobe_8x_logic
-- );
------------------------------------------
-- I6 : eventFormatter
......@@ -588,38 +495,28 @@ begin
-- );
------------------------------------------
-- I7 : eventBuffer
-- GENERIC MAP (
-- g_EVENT_DATA_WIDTH => g_EVENT_DATA_WIDTH,
-- g_IPBUS_WIDTH => g_IPBUS_WIDTH,
-- g_READ_COUNTER_WIDTH => 14
I7 : eventBuffer
GENERIC MAP (
g_EVENT_DATA_WIDTH => 32,
g_IPBUS_WIDTH => g_IPBUS_WIDTH,
g_READ_COUNTER_WIDTH => 13
-- )
-- PORT MAP (
-- clk_4x_logic_i => clk_4x_logic,
-- data_strobe_i => data_strobe,
-- event_data_i => event_data,
-- ipbus_clk_i => clk_ipb,
-- ipbus_i => ipbww(N_SLV_EVBUF),
-- ipbus_reset_i => rst_ipb,
-- strobe_4x_logic_i => strobe_4x_logic,
-- rst_fifo_o => rst_fifo_o,
-- buffer_full_o => buffer_full_o,
-- ipbus_o => ipbrr(N_SLV_EVBUF),
-- logic_reset_i => logic_reset
-- );
)
PORT MAP (
clk_4x_logic_i => clk_4x_logic,
--clk_4x_logic_i => sysclk_40,
data_strobe_i => TriggerNumberStrobe(0),
event_data_i => TrigNArray(0),
ipbus_clk_i => clk_ipb,
ipbus_i => ipbww(N_SLV_EVBUF),
ipbus_reset_i => rst_ipb,
strobe_4x_logic_i => strobe_4x_logic,
rst_fifo_o => rst_fifo_o,
buffer_full_o => buffer_full_o,
ipbus_o => ipbrr(N_SLV_EVBUF),
logic_reset_i => logic_reset
);
--------------------------------------------
-- I8 : T0_Shutter_Iface
-- PORT MAP (
-- clk_4x_i => clk_4x_logic,
-- clk_4x_strobe => strobe_4x_logic,
-- T0_o => T0_o,
-- shutter_o => s_shutter,
-- ipbus_clk_i => clk_ipb,
-- ipbus_i => ipbww(N_SLV_SHUT),
-- ipbus_o => ipbrr(N_SLV_SHUT)
-- );
------------------------------------------
-- I9 : DUTInterfaces
......@@ -652,30 +549,7 @@ begin
-- veto_o => veto_o
-- );
------------------------------------------
-- I10 : triggerLogic
-- GENERIC MAP (
-- g_NUM_INPUTS => g_NUM_TRIG_INPUTS,
-- g_IPBUS_WIDTH => g_IPBUS_WIDTH
-- )
-- PORT MAP (
-- clk_4x_logic_i => clk_4x_logic,
-- ipbus_clk_i => clk_ipb,
-- ipbus_i => ipbww(N_SLV_TRGLGC),
-- ipbus_reset_i => rst_ipb,
-- logic_reset_i => s_triggerLogic_reset,
-- logic_strobe_i => strobe_4x_logic,
-- trigger_i => triggers,
-- trigger_times_i => trigger_times,
-- veto_i => overall_veto,
-- trigger_o => postVetotrigger,
-- trigger_times_o => postVetoTrigger_times,
-- event_number_o => trigger_count,
-- ipbus_o => ipbrr(N_SLV_TRGLGC),
-- post_veto_trigger_o => overall_trigger,
-- pre_veto_trigger_o => OPEN,
-- trigger_active_o => leds(2)
-- );
-------------TEST AREA------------
-- test0: entity work.test_inToOut
......@@ -728,10 +602,11 @@ begin
CLK => sysclk_40,
RST => cont_i(iDUT),-- coming from HDMI pin
Trigger => triggers_i(iDUT), --coming from HDMI pin
stretchBusy => stretchFlags(iDUT),
Busy => busy_o(iDUT), --going out on HDMI pin
DUTClk => dut_clk_o(iDUT), --going out on HDMI pin
--TriggerNumber => TriggerNumber(DUT),
--TriggerNumberStrobe => TriggerNumberStrobe(DUT),
TriggerNumber => TrigNArray(iDUT),
TriggerNumberStrobe => TriggerNumberStrobe(iDUT),
FSM_Error => open
);
......@@ -763,19 +638,7 @@ begin
I => clk_enclustra--sysclk
);
------------------------------------------
-- Do not use this: we need differential 3.3 V, not available.
-- OBUFDS_inst : OBUFDS
-- generic map (
-- SLEW => "FAST") -- Specify the output slew rate
-- port map (
-- O => sysclk_50_o_p, -- Diff_p output (connect directly to top-level port)
-- OB => sysclk_50_o_n, -- Diff_n output (connect directly to top-level port)
-- I => encl_clock50 -- Buffer input
-- );
-- This might not work: these are just two single ended. If we remove R coupling maybe?
--sysclk_50_o_p <= encl_clock50;
--sysclk_50_o_n <= not encl_clock50;
......
......@@ -46,11 +46,11 @@ class EUDETdummy:
self.IC6=PCA9539PW(self.TLU_I2C, 0x74)
self.IC6.setInvertReg(0, 0x00)# 0= normal, 1= inverted
self.IC6.setIOReg(0, 0x00)# 0= output, 1= input
self.IC6.setOutputs(0, 0xAA)# If output, set to XX
self.IC6.setOutputs(0, 0x88)# If output, set to XX
self.IC6.setInvertReg(1, 0x00)# 0= normal, 1= inverted
self.IC6.setIOReg(1, 0x00)# 0= output, 1= input
self.IC6.setOutputs(1, 0xAA)# If output, set to XX
self.IC6.setOutputs(1, 0x88)# If output, set to XX
self.IC7=PCA9539PW(self.TLU_I2C, 0x75)
self.IC7.setInvertReg(0, 0x00)# 0= normal, 1= inverted
......
......@@ -32,14 +32,14 @@
<node id="i2c_cmdstatus" address="0x4" mask="0x000000ff" permission="rw" description="" />
</node>
<!-- Not sure about the FillLevelFlags register -->
<!--
<node id="eventBuffer" address="0x4000" description="Event buffer">
<node id="EventFifoData" address="0x0" mode="non-incremental" size="32000" permission="r" description="" />
<node id="EventFifoFillLevel" address="0x1" permission="r" description="" />
<node id="EventFifoCSR" address="0x2" permission="rw" description="" />
<node id="EventFifoFillLevelFlags" address="0x3" permission="r" description="" />
</node>
-->
<!-- Event formatter registers. Should be ok -->
<!--
<node id="Event_Formatter" address="0x5000" description="Event formatter configuration">
......
......@@ -66,6 +66,12 @@ if __name__ == "__main__":
logdata= True
EUDummy.start(logdata)
time.sleep(0.2)
nwords= int( EUDummy.getFifoLevel() )
print nwords
myarray= EUDummy.getFifoData(nwords)
for iel in myarray:
print iel >> 16
EUDummy.stop()
# prompt = MyPrompt()
# prompt.prompt = '>> '
......
......@@ -105,5 +105,18 @@ set_property PACKAGE_PIN G3 [get_ports {dut_clk_i[3]}]
set_input_delay -clock [get_clocks [get_clocks -of_objects [get_pins I4/pll_base_inst/CLKOUT0]]] -rise -min 0.300 [get_ports -regexp -filter { NAME =~ ".*thresh.*" && DIRECTION == "IN" }]
set_input_delay -clock [get_clocks [get_clocks -of_objects [get_pins I4/pll_base_inst/CLKOUT0]]] -rise -max 0.400 [get_ports -regexp -filter { NAME =~ ".*thresh.*" && DIRECTION == "IN" }]
# Input timing ignored
create_clock -name virtualclk -period 10.000 -waveform {0.000 5.00}
set_clock_groups -name async_clk -asynchronous -group [get_clocks -include_generated_clocks s_clk320] -group {virtualclk}
set input_list "[get_ports {threshold_discr_n_i[*]}] [get_ports {threshold_discr_p_i[*]}]"
set_input_delay -clock virtualclk -rise -2 $input_list
set_input_delay -clock virtualclk -fall 2 $input_list
set_input_delay -clock virtualclk -rise -2 $input_list -clock_fall -add_delay
set_input_delay -clock virtualclk -fall 2 $input_list -clock_fall -add_delay
#set_input_delay 1.6ns -clock [get_clocks s_clk320][get_ports threshold_discr_p_i[2]]
#set_false_path -from [get_ports threshold_discr_p_i[2]] -to [get_pins I5/trigger_input_loop[2]/thresholdDeserializer/ISERDES2_Delayed/DDLY]
set_property BITSTREAM.CONFIG.SPI_BUSWIDTH 4 [current_design]
......@@ -39,7 +39,7 @@ ENTITY DUTInterface_AIDA IS
shutter_to_dut_i : IN std_logic; --! Goes high to indicate data-taking active. DUTs report busy unless ignore_shutter_veto flag is set high
ignore_shutter_veto_i : in std_logic;
ignore_dut_busy_i : in std_logic;
dut_mask_i : in std_logic; --! Set high if DUT is active.
--dut_mask_i : in std_logic; --! Set high if DUT is active. Moved one level up
busy_o : OUT std_logic; --! goes high when DUT is busy or vetoed by shutter
-- Signals to/from DUT
......@@ -138,11 +138,12 @@ BEGIN
--busy_o <= ((not ignore_shutter_veto_i ) and (not shutter_to_dut_i)) or
-- ((dut_busy_i and DUT_mask_i ) and (not ignore_dut_busy_i) );
busy_o <= ((not ignore_shutter_veto_i ) and (not shutter_to_dut_i)) or
( (dut_busy_i and DUT_mask_i ) );
--busy_o <= ((not ignore_shutter_veto_i ) and (not shutter_to_dut_i)) or ( (dut_busy_i and DUT_mask_i ) );
busy_o <= ((not ignore_shutter_veto_i ) and (not shutter_to_dut_i)) or ( dut_busy_i );
dut_clk_o <= s_dut_clk ;
dut_trigger_o <= DUT_mask_i and s_trigger_out;
--dut_trigger_o <= DUT_mask_i and s_trigger_out;
dut_trigger_o <= s_trigger_out;
end if;
end process register_signals;
......
......@@ -132,9 +132,13 @@ end process;
elsif (state = WAIT_FOR_BUSY_HIGH ) then
-- only clock out bottom 15 bits of data.
-- (replace fixed width with a mask at some stage ?)
trig_shift_reg <= "00000000000000000" & trigger_counter_copy(14 downto 0);
trig_shift_reg <= "00000000000000000" & trigger_counter_copy(14 downto 0);
serial_trig_data <= '0';
end if;
if ( state = IDLE ) and ( trigger_i = '1') then
trigger_counter_copy <= trigger_counter_i; -- register the trigger number to shift it out
end if;
end if;
......@@ -151,7 +155,7 @@ end process;
when IDLE =>
if ( trigger_i = '1') then -- respond to trigger going high
next_state <= WAIT_FOR_BUSY_HIGH; -- wait for DUT to respond to busy
trigger_counter_copy <= trigger_counter_i; -- register the trigger number to shift it out
--trigger_counter_copy <= trigger_counter_i; -- register the trigger number to shift it out
elsif ( (dut_clk_r2 = '1') and (enable_dut_veto_i = '1') ) then -- If DUT asserts DUT_CLK_I then veto triggers
next_state <= DUT_INITIATED_VETO;
......
......@@ -291,7 +291,7 @@ BEGIN
shutter_to_dut_i => shutter_to_dut_i ,
ignore_shutter_veto_i => s_IgnoreShutterVeto ,
ignore_dut_busy_i => s_DUT_ignore_busy(dut),
dut_mask_i => s_DUT_mask(dut),
--dut_mask_i => s_DUT_mask(dut),
busy_o => s_dut_veto_aida(dut),
-- Signals to/from DUT
......@@ -346,8 +346,8 @@ BEGIN
p_signal_mux: process (clk_4x_logic_i ) is
begin -- process p_signal_mux
if rising_edge(clk_4x_logic_i) then
s_trigger_to_dut <= ( s_trigger_to_dut_eudet and (not s_DUT_aida_eudet_mode)) or ( s_trigger_to_dut_aida and s_DUT_aida_eudet_mode) ;
s_dut_veto <= ( s_dut_veto_eudet and (not s_DUT_aida_eudet_mode)) or ( s_dut_veto_aida and s_DUT_aida_eudet_mode) ;
s_trigger_to_dut <= (( s_trigger_to_dut_eudet and (not s_DUT_aida_eudet_mode)) or ( s_trigger_to_dut_aida and s_DUT_aida_eudet_mode)) and s_DUT_mask ; -- move DutMask one level up to affect both AIDA and EUDET modes
s_dut_veto <= (( s_dut_veto_eudet and (not s_DUT_aida_eudet_mode)) or ( s_dut_veto_aida and s_DUT_aida_eudet_mode)) and s_DUT_mask ; -- move DutMask one level up to affect both AIDA and EUDET modes
s_shutter_to_dut <= ( s_shutter_to_dut_eudet and (not s_DUT_aida_eudet_mode)) or ( s_shutter_to_dut_aida and s_DUT_aida_eudet_mode) ;
s_reset_or_clk_to_dut <= ( s_reset_or_clk_to_dut_aida and s_DUT_aida_eudet_mode) ; --! reset_or_clk line stays low if in EUDET mode
......
......@@ -23,7 +23,7 @@ use work.ipbus.ALL;
entity top_tlu_v1e is
generic(
constant FW_VERSION : unsigned(31 downto 0):= X"1e000008"; -- Firmware revision. Remember to change this as needed.
constant FW_VERSION : unsigned(31 downto 0):= X"1e00000a"; -- Firmware revision. Remember to change this as needed.
g_NUM_DUTS : positive := 4; -- <- was 3
g_NUM_TRIG_INPUTS :positive := 6;-- <- was 4
g_NUM_EDGE_INPUTS :positive := 6;-- <-- was 4
......
......@@ -45,10 +45,10 @@ DACThreshold4 = -0.12
DACThreshold5 = -0.12
# Define which DUTs are ON
DutMask = 0
DUTMask = 1
# Define mode of DUT (00 EUDET, 11 AIDA)
DUTMaskMode= 0xFF
DUTMaskMode= 0xFC
# Allow asynchronous veto
DUTMaskModeModifier= 0x0
......
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