source: FPGA/FTU/test_firmware/FTU_test2/FTU_test2.vhd@ 408

Last change on this file since 408 was 243, checked in by qweitzel, 14 years ago
FTU_test2 is now working
File size: 4.9 KB
Line 
1----------------------------------------------------------------------------------
2-- Company: ETH Zurich, Institute for Particle Physics
3-- Engineer: P. Vogler, Q. Weitzel
4--
5-- Create Date: 05/07/2010
6-- Design Name:
7-- Module Name: FTU_test2 - Behavioral
8-- Project Name:
9-- Target Devices:
10-- Tool versions:
11-- Description: Test firmware for FTU board, set thresholds to some value
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;
24
25---- Uncomment the following library declaration if instantiating
26---- any Xilinx primitives in this code.
27--library UNISIM;
28--use UNISIM.VComponents.all;
29
30
31entity FTU_test2 is
32 port(
33 -- global control
34 ext_clk : IN STD_LOGIC; -- external clock from FTU board
35 brd_add : IN STD_LOGIC_VECTOR(5 downto 0); -- geographic board/slot address
36 brd_id : in STD_LOGIC_VECTOR(7 downto 0); -- local solder-programmable board ID
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 sck : OUT STD_LOGIC; -- serial clock to DAC
53 mosi : OUT STD_LOGIC; -- serial data to DAC, master-out-slave-in
54 clr : OUT STD_LOGIC; -- clear signal to DAC
55 cs_ld : OUT STD_LOGIC; -- chip select or load to DAC
56
57 -- RS-485 interface to FTM
58 rx : IN STD_LOGIC; -- serial data from FTM
59 tx : OUT STD_LOGIC; -- serial data to FTM
60 rx_en : OUT STD_LOGIC; -- enable RS-485 receiver
61 tx_en : OUT STD_LOGIC; -- enable RS-485 transmitter
62
63 -- analog buffer enable
64 enables_A : OUT STD_LOGIC_VECTOR(8 downto 0); -- individual enables for analog inputs
65 enables_B : OUT STD_LOGIC_VECTOR(8 downto 0); -- individual enables for analog inputs
66 enables_C : OUT STD_LOGIC_VECTOR(8 downto 0); -- individual enables for analog inputs
67 enables_D : OUT STD_LOGIC_VECTOR(8 downto 0); -- individual enables for analog inputs
68
69 -- testpoints
70 TP_A : out STD_LOGIC_VECTOR(11 downto 0) -- testpoints
71 );
72end FTU_test2;
73
74
75architecture Behavioral of FTU_test2 is
76
77 component FTU_test2_dac_dcm
78 port(
79 CLKIN_IN : IN STD_LOGIC;
80 RST_IN : IN STD_LOGIC;
81 CLKFX_OUT : OUT STD_LOGIC;
82 CLKIN_IBUFG_OUT : OUT STD_LOGIC;
83 LOCKED_OUT : OUT STD_LOGIC
84 );
85 end component;
86
87 component FTU_test2_dac_control
88 port(
89 clk : IN STD_LOGIC;
90 reset : IN STD_LOGIC;
91 clr : OUT STD_LOGIC;
92 mosi : OUT STD_LOGIC;
93 sck : OUT STD_LOGIC;
94 cs_ld : OUT STD_LOGIC;
95 enable1 : out STD_LOGIC;
96 enable2 : out STD_LOGIC;
97 enable3 : 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 type FTU_test2_StateType is (Running);
105 signal FTU_test2_State, FTU_test2_NextState: FTU_test2_StateType;
106
107begin
108
109 Inst_FTU_test2_dac_dcm : FTU_test2_dac_dcm
110 port map(
111 CLKIN_IN => ext_clk,
112 RST_IN => reset_sig,
113 CLKFX_OUT => clk_50M_sig,
114 CLKIN_IBUFG_OUT => open,
115 LOCKED_OUT => open
116 );
117
118 Inst_FTU_test2_dac_control : FTU_test2_dac_control
119 port map(
120 clk => clk_50M_sig,
121 reset => reset_sig,
122 clr => clr,
123 mosi => mosi,
124 sck => sck,
125 cs_ld => cs_ld,
126 enable1 => enables_A(1),
127 enable2 => enables_A(2),
128 enable3 => enables_A(3)
129 );
130
131 --FTU main state machine (two-process implementation)
132
133 FTU_test2_Registers: process (ext_clk)
134 begin
135 if Rising_edge(ext_clk) then
136 FTU_test2_State <= FTU_test2_NextState;
137 end if;
138 end process FTU_test2_Registers;
139
140 FTU_test2_C_logic: process (FTU_test2_State)
141 begin
142 FTU_test2_NextState <= FTU_test2_State;
143 case FTU_test2_State is
144 when Running =>
145 reset_sig <= '0';
146 enables_A(0) <= '1';
147 end case;
148 end process FTU_test2_C_logic;
149
150end Behavioral;
Note: See TracBrowser for help on using the repository browser.