| 1 | ----------------------------------------------------------------------------------
|
|---|
| 2 | -- Company: ETH Zurich, Institute for Particle Physics
|
|---|
| 3 | -- Engineer: P. Vogler, Q. Weitzel
|
|---|
| 4 | --
|
|---|
| 5 | -- Create Date: 04/05/2010
|
|---|
| 6 | -- Design Name:
|
|---|
| 7 | -- Module Name: FTU_test1 - Behavioral
|
|---|
| 8 | -- Project Name:
|
|---|
| 9 | -- Target Devices:
|
|---|
| 10 | -- Tool versions:
|
|---|
| 11 | -- Description: Test firmware for FTU board, switch on/off enable signals
|
|---|
| 12 | --
|
|---|
| 13 | -- Dependencies:
|
|---|
| 14 | --
|
|---|
| 15 | -- Revision:
|
|---|
| 16 | -- Revision 0.01 - File Created
|
|---|
| 17 | -- Additional Comments:
|
|---|
| 18 | --
|
|---|
| 19 | ----------------------------------------------------------------------------------
|
|---|
| 20 |
|
|---|
| 21 | library IEEE;
|
|---|
| 22 | use IEEE.STD_LOGIC_1164.ALL;
|
|---|
| 23 | use IEEE.STD_LOGIC_ARITH.ALL;
|
|---|
| 24 | use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
|---|
| 25 |
|
|---|
| 26 | ---- Uncomment the following library declaration if instantiating
|
|---|
| 27 | ---- any Xilinx primitives in this code.
|
|---|
| 28 | --library UNISIM;
|
|---|
| 29 | --use UNISIM.VComponents.all;
|
|---|
| 30 |
|
|---|
| 31 | entity FTU_test1 is
|
|---|
| 32 | port(
|
|---|
| 33 | -- global control
|
|---|
| 34 | ext_clk : IN STD_LOGIC; -- external clock from FTU board
|
|---|
| 35 | --reset : in STD_LOGIC; -- reset
|
|---|
| 36 | brd_add : IN STD_LOGIC_VECTOR(5 downto 0); -- global board address (not local)
|
|---|
| 37 |
|
|---|
| 38 | -- rate counters LVDS inputs
|
|---|
| 39 | -- use IBUFDS differential input buffer
|
|---|
| 40 | patch_A_p : IN STD_LOGIC; -- logic signal from first trigger patch
|
|---|
| 41 | patch_A_n : IN STD_LOGIC;
|
|---|
| 42 | patch_B_p : IN STD_LOGIC; -- logic signal from second trigger patch
|
|---|
| 43 | patch_B_n : IN STD_LOGIC;
|
|---|
| 44 | patch_C_p : IN STD_LOGIC; -- logic signal from third trigger patch
|
|---|
| 45 | patch_C_n : IN STD_LOGIC;
|
|---|
| 46 | patch_D_p : IN STD_LOGIC; -- logic signal from fourth trigger patch
|
|---|
| 47 | patch_D_n : IN STD_LOGIC;
|
|---|
| 48 | trig_prim_p : IN STD_LOGIC; -- logic signal from n-out-of-4 circuit
|
|---|
| 49 | trig_prim_n : IN STD_LOGIC;
|
|---|
| 50 |
|
|---|
| 51 | -- DAC interface
|
|---|
| 52 | -- miso : IN STD_LOGIC; -- master-in-slave-out
|
|---|
| 53 | sck : OUT STD_LOGIC; -- serial clock to DAC
|
|---|
| 54 | mosi : OUT STD_LOGIC; -- serial data to DAC, master-out-slave-in
|
|---|
| 55 | clr : OUT STD_LOGIC; -- clear signal to DAC
|
|---|
| 56 | cs_ld : OUT STD_LOGIC; -- chip select or load to DAC
|
|---|
| 57 |
|
|---|
| 58 | -- RS-485 interface to FTM
|
|---|
| 59 | rx : IN STD_LOGIC; -- serial data from FTM
|
|---|
| 60 | tx : OUT STD_LOGIC; -- serial data to FTM
|
|---|
| 61 | rx_en : OUT STD_LOGIC; -- enable RS-485 receiver
|
|---|
| 62 | tx_en : OUT STD_LOGIC; -- enable RS-485 transmitter
|
|---|
| 63 |
|
|---|
| 64 | -- analog buffer enable
|
|---|
| 65 | enables_A : OUT STD_LOGIC_VECTOR(8 downto 0); -- individual enables for analog inputs
|
|---|
| 66 | enables_B : OUT STD_LOGIC_VECTOR(8 downto 0); -- individual enables for analog inputs
|
|---|
| 67 | enables_C : OUT STD_LOGIC_VECTOR(8 downto 0); -- individual enables for analog inputs
|
|---|
| 68 | enables_D : OUT STD_LOGIC_VECTOR(8 downto 0); -- individual enables for analog inputs
|
|---|
| 69 |
|
|---|
| 70 | -- testpoints
|
|---|
| 71 | TP_A : out STD_LOGIC_VECTOR(11 downto 0) -- testpoints
|
|---|
| 72 | );
|
|---|
| 73 | end FTU_test1;
|
|---|
| 74 |
|
|---|
| 75 | architecture Behavioral of FTU_test1 is
|
|---|
| 76 |
|
|---|
| 77 | component FTU_test1_dcm
|
|---|
| 78 | port(
|
|---|
| 79 | CLKIN_IN : IN STD_LOGIC;
|
|---|
| 80 | CLKFX_OUT : OUT STD_LOGIC;
|
|---|
| 81 | CLKIN_IBUFG_OUT : OUT STD_LOGIC
|
|---|
| 82 | );
|
|---|
| 83 | end component;
|
|---|
| 84 |
|
|---|
| 85 | component Clock_Divider
|
|---|
| 86 | port(
|
|---|
| 87 | clock : IN STD_LOGIC;
|
|---|
| 88 | enable_out : OUT STD_LOGIC
|
|---|
| 89 | );
|
|---|
| 90 | end component;
|
|---|
| 91 |
|
|---|
| 92 | signal clk_5M_sig : STD_LOGIC;
|
|---|
| 93 | signal enable_sig : STD_LOGIC;
|
|---|
| 94 |
|
|---|
| 95 | begin
|
|---|
| 96 |
|
|---|
| 97 | Inst_FTU_test1_dcm : FTU_test1_dcm
|
|---|
| 98 | port map(
|
|---|
| 99 | CLKIN_IN => ext_clk,
|
|---|
| 100 | CLKFX_OUT => clk_5M_sig,
|
|---|
| 101 | CLKIN_IBUFG_OUT => open
|
|---|
| 102 | );
|
|---|
| 103 |
|
|---|
| 104 | Inst_Clock_Divider : Clock_Divider
|
|---|
| 105 | port map (
|
|---|
| 106 | clock => clk_5M_sig,
|
|---|
| 107 | enable_out => enable_sig
|
|---|
| 108 | );
|
|---|
| 109 |
|
|---|
| 110 | enables_A(8) <= enable_sig;
|
|---|
| 111 | enables_B(8) <= enable_sig;
|
|---|
| 112 | enables_C(8) <= enable_sig;
|
|---|
| 113 | enables_D(8) <= enable_sig;
|
|---|
| 114 |
|
|---|
| 115 | end Behavioral;
|
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 | library IEEE;
|
|---|
| 119 | use IEEE.STD_LOGIC_1164.ALL;
|
|---|
| 120 | use IEEE.STD_LOGIC_ARITH.ALL;
|
|---|
| 121 | use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
|---|
| 122 |
|
|---|
| 123 | entity Clock_Divider is
|
|---|
| 124 | port(
|
|---|
| 125 | clock : in std_logic;
|
|---|
| 126 | enable_out: out std_logic
|
|---|
| 127 | );
|
|---|
| 128 | end entity Clock_Divider;
|
|---|
| 129 |
|
|---|
| 130 | architecture RTL of Clock_Divider is
|
|---|
| 131 |
|
|---|
| 132 | constant max_count : integer := 5000000/1000000; -- for simulation
|
|---|
| 133 | --constant max_count : integer := 5000000/1; -- for implementation
|
|---|
| 134 | constant final_count : integer := 3;
|
|---|
| 135 |
|
|---|
| 136 | begin
|
|---|
| 137 |
|
|---|
| 138 | process(clock)
|
|---|
| 139 | variable count : integer range 0 to max_count;
|
|---|
| 140 | variable count2 : integer range 0 to final_count;
|
|---|
| 141 | begin
|
|---|
| 142 | if rising_edge(clock) then
|
|---|
| 143 | --enable_out <= '0';
|
|---|
| 144 | if count2 = final_count then
|
|---|
| 145 | enable_out <= '0';
|
|---|
| 146 | else
|
|---|
| 147 | if count < max_count/2 then
|
|---|
| 148 | enable_out <= '0';
|
|---|
| 149 | count := count + 1;
|
|---|
| 150 | elsif count < max_count then
|
|---|
| 151 | enable_out <= '1';
|
|---|
| 152 | count := count + 1;
|
|---|
| 153 | else
|
|---|
| 154 | count := 0;
|
|---|
| 155 | enable_out <= '0';
|
|---|
| 156 | count2 := count2 + 1;
|
|---|
| 157 | end if;
|
|---|
| 158 | end if;
|
|---|
| 159 | end if;
|
|---|
| 160 | end process;
|
|---|
| 161 |
|
|---|
| 162 | end architecture RTL;
|
|---|