source: FPGA/FTU/test_firmware/FTU_test5/FTU_test5.vhd@ 9321

Last change on this file since 9321 was 268, checked in by qweitzel, 14 years ago
FTU_test5 added
File size: 6.8 KB
Line 
1----------------------------------------------------------------------------------
2-- Company: ETH Zurich, Institute for Particle Physics
3-- Engineer: P. Vogler, Q. Weitzel
4--
5-- Create Date: 07/14/2010
6-- Design Name:
7-- Module Name: FTU_test5 - Behavioral
8-- Project Name:
9-- Target Devices:
10-- Tool versions:
11-- Description: Test firmware for FTU board, set thresholds and enables
12--
13-- Dependencies:
14--
15-- Revision:
16-- Revision 0.01 - File Created
17-- Additional Comments:
18--
19----------------------------------------------------------------------------------
20library IEEE;
21use IEEE.STD_LOGIC_1164.ALL;
22use IEEE.STD_LOGIC_ARITH.ALL;
23use IEEE.STD_LOGIC_UNSIGNED.ALL;
24library ftu_definitions_test5;
25USE ftu_definitions_test5.ftu_array_types.all;
26
27---- Uncomment the following library declaration if instantiating
28---- any Xilinx primitives in this code.
29--library UNISIM;
30--use UNISIM.VComponents.all;
31
32
33entity FTU_test5 is
34 port(
35 -- global control
36 ext_clk : IN STD_LOGIC; -- external clock from FTU board
37 brd_add : IN STD_LOGIC_VECTOR(5 downto 0); -- geographic board/slot address
38 brd_id : in STD_LOGIC_VECTOR(7 downto 0); -- local solder-programmable board ID
39
40 -- rate counters LVDS inputs
41 -- use IBUFDS differential input buffer
42 patch_A_p : IN STD_LOGIC; -- logic signal from first trigger patch
43 patch_A_n : IN STD_LOGIC;
44 patch_B_p : IN STD_LOGIC; -- logic signal from second trigger patch
45 patch_B_n : IN STD_LOGIC;
46 patch_C_p : IN STD_LOGIC; -- logic signal from third trigger patch
47 patch_C_n : IN STD_LOGIC;
48 patch_D_p : IN STD_LOGIC; -- logic signal from fourth trigger patch
49 patch_D_n : IN STD_LOGIC;
50 trig_prim_p : IN STD_LOGIC; -- logic signal from n-out-of-4 circuit
51 trig_prim_n : IN STD_LOGIC;
52
53 -- DAC interface
54 sck : OUT STD_LOGIC; -- serial clock to DAC
55 mosi : OUT STD_LOGIC; -- serial data to DAC, master-out-slave-in
56 clr : OUT STD_LOGIC; -- clear signal to DAC
57 cs_ld : OUT STD_LOGIC; -- chip select or load to DAC
58
59 -- RS-485 interface to FTM
60 rx : IN STD_LOGIC; -- serial data from FTM
61 tx : OUT STD_LOGIC; -- serial data to FTM
62 rx_en : OUT STD_LOGIC; -- enable RS-485 receiver
63 tx_en : OUT STD_LOGIC; -- enable RS-485 transmitter
64
65 -- analog buffer enable
66 enables_A : OUT STD_LOGIC_VECTOR(8 downto 0); -- individual enables for analog inputs
67 enables_B : OUT STD_LOGIC_VECTOR(8 downto 0); -- individual enables for analog inputs
68 enables_C : OUT STD_LOGIC_VECTOR(8 downto 0); -- individual enables for analog inputs
69 enables_D : OUT STD_LOGIC_VECTOR(8 downto 0); -- individual enables for analog inputs
70
71 -- testpoints
72 TP_A : out STD_LOGIC_VECTOR(11 downto 0) -- testpoints
73 );
74end FTU_test5;
75
76
77architecture Behavioral of FTU_test5 is
78
79 component FTU_test5_dac_dcm
80 port(
81 CLKIN_IN : IN STD_LOGIC;
82 RST_IN : IN STD_LOGIC;
83 CLKFX_OUT : OUT STD_LOGIC;
84 CLKIN_IBUFG_OUT : OUT STD_LOGIC;
85 LOCKED_OUT : OUT STD_LOGIC
86 );
87 end component;
88
89 component FTU_test5_dac_control
90 port(
91 clk : IN STD_LOGIC;
92 reset : IN STD_LOGIC;
93 dacs : IN dac_array_type;
94 clr : OUT STD_LOGIC;
95 mosi : OUT STD_LOGIC;
96 sck : OUT STD_LOGIC;
97 cs_ld : OUT STD_LOGIC
98 );
99 end component;
100
101 signal reset_sig : STD_LOGIC := '0'; -- initialize reset to 0 at power up
102 signal clk_50M_sig : STD_LOGIC;
103
104 --signal enable_sig : enable_array_type := DEFAULT_ENABLE;
105 signal enable_sig : enable_array_type;
106 signal dac_array_sig : dac_array_type;
107
108 type FTU_test5_StateType is (Running);
109 signal FTU_test5_State, FTU_test5_NextState: FTU_test5_StateType;
110
111begin
112
113 Inst_FTU_test5_dac_dcm : FTU_test5_dac_dcm
114 port map(
115 CLKIN_IN => ext_clk,
116 RST_IN => reset_sig,
117 CLKFX_OUT => clk_50M_sig,
118 CLKIN_IBUFG_OUT => open,
119 LOCKED_OUT => open
120 );
121
122 Inst_FTU_test5_dac_control : FTU_test5_dac_control
123 port map(
124 clk => clk_50M_sig,
125 reset => reset_sig,
126 dacs => dac_array_sig,
127 clr => clr,
128 mosi => mosi,
129 sck => sck,
130 cs_ld => cs_ld
131 );
132
133 enable_sig <= ("0000000000000000","0000000000000000","0000000000000000","0000000000000000") when (brd_add(3 downto 0) = "0000") else
134 ("0000000101010101","0000000101010101","0000000101010101","0000000101010101") when (brd_add(3 downto 0) = "0001") else
135 ("0000000010101010","0000000010101010","0000000010101010","0000000010101010") when (brd_add(3 downto 0) = "0010") else
136 ("0000000000000001","0000000000000001","0000000000000001","0000000000000001") when (brd_add(3 downto 0) = "0011") else
137 ("0000000000000011","0000000000000011","0000000000000011","0000000000000011") when (brd_add(3 downto 0) = "0100") else
138 ("0000000000001111","0000000000001111","0000000000001111","0000000000001111") when (brd_add(3 downto 0) = "0101") else
139 ("0000000000111111","0000000000111111","0000000000111111","0000000000111111") when (brd_add(3 downto 0) = "0110") else
140 ("0000000111111111","0000000111111111","0000000111111111","0000000111111111") when (brd_add(3 downto 0) = "0111") else
141 ("0000000111110000","0000000111110000","0000000111110000","0000000111110000") when (brd_add(3 downto 0) = "1000") else
142 ("0000000000011111","0000000000011111","0000000000011111","0000000000011111") when (brd_add(3 downto 0) = "1001") else
143 DEFAULT_ENABLE;
144
145 dac_array_sig <= (100,100,100,100,0,0,0,100) when (brd_add(5 downto 4) = "00") else
146 (200,200,200,200,0,0,0,100) when (brd_add(5 downto 4) = "01") else
147 (300,300,300,300,0,0,0,100) when (brd_add(5 downto 4) = "10") else
148 DEFAULT_DAC;
149
150 enables_A <= enable_sig(0)(8 downto 0);
151 enables_B <= enable_sig(1)(8 downto 0);
152 enables_C <= enable_sig(2)(8 downto 0);
153 enables_D <= enable_sig(3)(8 downto 0);
154
155 --FTU main state machine (two-process implementation)
156
157 FTU_test5_Registers: process (ext_clk)
158 begin
159 if Rising_edge(ext_clk) then
160 FTU_test5_State <= FTU_test5_NextState;
161 end if;
162 end process FTU_test5_Registers;
163
164 FTU_test5_C_logic: process (FTU_test5_State)
165 begin
166 FTU_test5_NextState <= FTU_test5_State;
167 case FTU_test5_State is
168 when Running =>
169 reset_sig <= '0';
170 end case;
171 end process FTU_test5_C_logic;
172
173end Behavioral;
Note: See TracBrowser for help on using the repository browser.