| 1 | ----------------------------------------------------------------------------------
|
|---|
| 2 | -- Company: ETH Zurich, Institute for Particle Physics
|
|---|
| 3 | -- Engineer: P. Vogler, Q. Weitzel
|
|---|
| 4 | --
|
|---|
| 5 | -- Create Date: 11:59:40 01/19/2010
|
|---|
| 6 | -- Design Name:
|
|---|
| 7 | -- Module Name: FTU_top - Behavioral
|
|---|
| 8 | -- Project Name:
|
|---|
| 9 | -- Target Devices:
|
|---|
| 10 | -- Tool versions:
|
|---|
| 11 | -- Description: Top level entity of FACT FTU board
|
|---|
| 12 | --
|
|---|
| 13 | -- Dependencies:
|
|---|
| 14 | --
|
|---|
| 15 | -- Revision:
|
|---|
| 16 | -- Revision 0.01 - File Created
|
|---|
| 17 | -- Revision 0.02 - New design of FTU firmware, 12.07.2010, Q. Weitzel
|
|---|
| 18 | -- Additional Comments:
|
|---|
| 19 | --
|
|---|
| 20 | ----------------------------------------------------------------------------------
|
|---|
| 21 |
|
|---|
| 22 | library IEEE;
|
|---|
| 23 | use IEEE.STD_LOGIC_1164.ALL;
|
|---|
| 24 | use IEEE.STD_LOGIC_ARITH.ALL;
|
|---|
| 25 | use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
|---|
| 26 |
|
|---|
| 27 | library ftu_definitions;
|
|---|
| 28 | USE ftu_definitions.ftu_array_types.all;
|
|---|
| 29 |
|
|---|
| 30 | ---- Uncomment the following library declaration if instantiating
|
|---|
| 31 | ---- any Xilinx primitives in this code.
|
|---|
| 32 | --library UNISIM;
|
|---|
| 33 | --use UNISIM.VComponents.all;
|
|---|
| 34 |
|
|---|
| 35 | entity FTU_top is
|
|---|
| 36 | port(
|
|---|
| 37 | -- global control
|
|---|
| 38 | ext_clk : IN STD_LOGIC; -- external clock from FTU board
|
|---|
| 39 | brd_add : IN STD_LOGIC_VECTOR(5 downto 0); -- geographic board/slot address
|
|---|
| 40 | brd_id : IN STD_LOGIC_VECTOR(7 downto 0); -- local solder-programmable board ID
|
|---|
| 41 |
|
|---|
| 42 | -- rate counters LVDS inputs
|
|---|
| 43 | -- use IBUFDS differential input buffer
|
|---|
| 44 | patch_A_p : IN STD_LOGIC; -- logic signal from first trigger patch
|
|---|
| 45 | patch_A_n : IN STD_LOGIC;
|
|---|
| 46 | patch_B_p : IN STD_LOGIC; -- logic signal from second trigger patch
|
|---|
| 47 | patch_B_n : IN STD_LOGIC;
|
|---|
| 48 | patch_C_p : IN STD_LOGIC; -- logic signal from third trigger patch
|
|---|
| 49 | patch_C_n : IN STD_LOGIC;
|
|---|
| 50 | patch_D_p : IN STD_LOGIC; -- logic signal from fourth trigger patch
|
|---|
| 51 | patch_D_n : IN STD_LOGIC;
|
|---|
| 52 | trig_prim_p : IN STD_LOGIC; -- logic signal from n-out-of-4 circuit
|
|---|
| 53 | trig_prim_n : IN STD_LOGIC;
|
|---|
| 54 |
|
|---|
| 55 | -- DAC interface
|
|---|
| 56 | sck : OUT STD_LOGIC; -- serial clock to DAC
|
|---|
| 57 | mosi : OUT STD_LOGIC; -- serial data to DAC, master-out-slave-in
|
|---|
| 58 | clr : OUT STD_LOGIC; -- clear signal to DAC
|
|---|
| 59 | cs_ld : OUT STD_LOGIC; -- chip select or load to DAC
|
|---|
| 60 |
|
|---|
| 61 | -- RS-485 interface to FTM
|
|---|
| 62 | rx : IN STD_LOGIC; -- serial data from FTM
|
|---|
| 63 | tx : OUT STD_LOGIC; -- serial data to FTM
|
|---|
| 64 | rx_en : OUT STD_LOGIC; -- enable RS-485 receiver
|
|---|
| 65 | tx_en : OUT STD_LOGIC; -- enable RS-485 transmitter
|
|---|
| 66 |
|
|---|
| 67 | -- analog buffer enable
|
|---|
| 68 | enables_A : OUT STD_LOGIC_VECTOR(8 downto 0); -- individual enables for analog inputs
|
|---|
| 69 | enables_B : OUT STD_LOGIC_VECTOR(8 downto 0); -- individual enables for analog inputs
|
|---|
| 70 | enables_C : OUT STD_LOGIC_VECTOR(8 downto 0); -- individual enables for analog inputs
|
|---|
| 71 | enables_D : OUT STD_LOGIC_VECTOR(8 downto 0); -- individual enables for analog inputs
|
|---|
| 72 |
|
|---|
| 73 | -- testpoints
|
|---|
| 74 | TP_A : OUT STD_LOGIC_VECTOR(11 downto 0) -- testpoints
|
|---|
| 75 | );
|
|---|
| 76 | end FTU_top;
|
|---|
| 77 |
|
|---|
| 78 | architecture Behavioral of FTU_top is
|
|---|
| 79 |
|
|---|
| 80 | signal reset_sig : STD_LOGIC := '0'; -- initialize reset to 0 at power up
|
|---|
| 81 | signal dac_clr_sig : STD_LOGIC := '1'; -- initialize dac_clr to 1 at power up
|
|---|
| 82 |
|
|---|
| 83 | signal config_start_sig : STD_LOGIC := '0';
|
|---|
| 84 | signal config_ready_sig : STD_LOGIC := '0';
|
|---|
| 85 |
|
|---|
| 86 | signal clk_50M_sig : STD_LOGIC; -- generated by internal DCM
|
|---|
| 87 | signal clk_ready_sig : STD_LOGIC := '0'; -- set high by FTU_clk_gen when DCMs have locked
|
|---|
| 88 |
|
|---|
| 89 | --signal ram_wea_sig : STD_LOGIC_VECTOR(0 downto 0) := "0"; -- RAM write enable for port A
|
|---|
| 90 | --signal ram_web_sig : STD_LOGIC_VECTOR(0 downto 0) := "0"; -- RAM write enable for port B
|
|---|
| 91 | --signal ram_ada_cntr : INTEGER range 0 to 2**5 - 1 := 0;
|
|---|
| 92 | --signal ram_adb_cntr : INTEGER range 0 to 2**4 - 1 := 0;
|
|---|
| 93 | --signal ram_ada_sig : STD_LOGIC_VECTOR(4 downto 0);
|
|---|
| 94 | --signal ram_adb_sig : STD_LOGIC_VECTOR(3 downto 0);
|
|---|
| 95 | --signal ram_dia_sig : STD_LOGIC_VECTOR(7 downto 0);
|
|---|
| 96 | --signal ram_dib_sig : STD_LOGIC_VECTOR(15 downto 0);
|
|---|
| 97 | --signal ram_doa_sig : STD_LOGIC_VECTOR(7 downto 0);
|
|---|
| 98 | --signal ram_dob_sig : STD_LOGIC_VECTOR(15 downto 0);
|
|---|
| 99 |
|
|---|
| 100 | component FTU_clk_gen
|
|---|
| 101 | port(
|
|---|
| 102 | clk : IN STD_LOGIC;
|
|---|
| 103 | rst : IN STD_LOGIC;
|
|---|
| 104 | clk_50 : OUT STD_LOGIC;
|
|---|
| 105 | ready : OUT STD_LOGIC
|
|---|
| 106 | );
|
|---|
| 107 | end component;
|
|---|
| 108 |
|
|---|
| 109 | component FTU_control
|
|---|
| 110 | port(
|
|---|
| 111 | clk_50MHz : IN std_logic;
|
|---|
| 112 | clk_ready : IN std_logic;
|
|---|
| 113 | config_ready : IN std_logic;
|
|---|
| 114 | reset : OUT std_logic;
|
|---|
| 115 | config_start : OUT std_logic
|
|---|
| 116 | );
|
|---|
| 117 | end component;
|
|---|
| 118 |
|
|---|
| 119 | component FTU_spi_interface
|
|---|
| 120 | port(
|
|---|
| 121 | clk_50MHz : IN std_logic;
|
|---|
| 122 | config_start : IN std_logic;
|
|---|
| 123 | dac_array : IN dac_array_type;
|
|---|
| 124 | config_ready : OUT std_logic;
|
|---|
| 125 | config_started : OUT std_logic;
|
|---|
| 126 | dac_cs : OUT std_logic;
|
|---|
| 127 | mosi : OUT std_logic;
|
|---|
| 128 | sclk : OUT std_logic
|
|---|
| 129 | );
|
|---|
| 130 | end component;
|
|---|
| 131 |
|
|---|
| 132 | --component FTU_dual_port_ram
|
|---|
| 133 | -- port(
|
|---|
| 134 | -- clka : IN std_logic;
|
|---|
| 135 | -- ena : IN std_logic;
|
|---|
| 136 | -- wea : IN std_logic_VECTOR(0 downto 0);
|
|---|
| 137 | -- addra : IN std_logic_VECTOR(4 downto 0);
|
|---|
| 138 | -- dina : IN std_logic_VECTOR(7 downto 0);
|
|---|
| 139 | -- douta : OUT std_logic_VECTOR(7 downto 0);
|
|---|
| 140 | -- clkb : IN std_logic;
|
|---|
| 141 | -- enb : IN std_logic;
|
|---|
| 142 | -- web : IN std_logic_VECTOR(0 downto 0);
|
|---|
| 143 | -- addrb : IN std_logic_VECTOR(3 downto 0);
|
|---|
| 144 | -- dinb : IN std_logic_VECTOR(15 downto 0);
|
|---|
| 145 | -- doutb : OUT std_logic_VECTOR(15 downto 0)
|
|---|
| 146 | -- );
|
|---|
| 147 | --end component;
|
|---|
| 148 |
|
|---|
| 149 | -- Synplicity black box declaration
|
|---|
| 150 | --attribute syn_black_box : boolean;
|
|---|
| 151 | --attribute syn_black_box of FTU_dual_port_ram: component is true;
|
|---|
| 152 |
|
|---|
| 153 | begin
|
|---|
| 154 |
|
|---|
| 155 | clr <= dac_clr_sig;
|
|---|
| 156 |
|
|---|
| 157 | Inst_FTU_clk_gen : FTU_clk_gen
|
|---|
| 158 | port map(
|
|---|
| 159 | clk => ext_clk,
|
|---|
| 160 | rst => reset_sig,
|
|---|
| 161 | clk_50 => clk_50M_sig,
|
|---|
| 162 | ready => clk_ready_sig
|
|---|
| 163 | );
|
|---|
| 164 |
|
|---|
| 165 | Inst_FTU_control : FTU_control
|
|---|
| 166 | port map(
|
|---|
| 167 | clk_50MHz => clk_50M_sig,
|
|---|
| 168 | clk_ready => clk_ready_sig,
|
|---|
| 169 | config_ready => config_ready_sig,
|
|---|
| 170 | reset => reset_sig,
|
|---|
| 171 | config_start => config_start_sig
|
|---|
| 172 | );
|
|---|
| 173 |
|
|---|
| 174 | Inst_FTU_spi_interface : FTU_spi_interface
|
|---|
| 175 | port map(
|
|---|
| 176 | clk_50MHz => clk_50M_sig,
|
|---|
| 177 | config_start => config_start_sig,
|
|---|
| 178 | dac_array => DEFAULT_DAC, -- has to come from RAM
|
|---|
| 179 | config_ready => config_ready_sig,
|
|---|
| 180 | config_started => open,
|
|---|
| 181 | dac_cs => cs_ld,
|
|---|
| 182 | mosi => mosi,
|
|---|
| 183 | sclk => sck
|
|---|
| 184 | );
|
|---|
| 185 |
|
|---|
| 186 | --Inst_FTU_dual_port_ram : FTU_dual_port_ram
|
|---|
| 187 | -- port map(
|
|---|
| 188 | -- clka => clk_50M_sig,
|
|---|
| 189 | -- ena => '1',
|
|---|
| 190 | -- wea => ram_wea_sig,
|
|---|
| 191 | -- addra => ram_ada_sig,
|
|---|
| 192 | -- dina => ram_dia_sig,
|
|---|
| 193 | -- douta => ram_doa_sig,
|
|---|
| 194 | -- clkb => clk_50M_sig,
|
|---|
| 195 | -- enb => '1',
|
|---|
| 196 | -- web => ram_web_sig,
|
|---|
| 197 | -- addrb => ram_adb_sig,
|
|---|
| 198 | -- dinb => ram_dib_sig,
|
|---|
| 199 | -- doutb => ram_dob_sig
|
|---|
| 200 | -- );
|
|---|
| 201 |
|
|---|
| 202 | end Behavioral;
|
|---|