source: FPGA/FTU/FTU_top.vhd@ 215

Last change on this file since 215 was 207, checked in by qweitzel, 14 years ago
updated FTU_top entity
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: 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-- 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_top 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); -- global board address
36
37 -- rate counters LVDS inputs
38 -- use IBUFDS differential input buffer
39 patch_A_p : IN STD_LOGIC; -- logic signal from first trigger patch
40 patch_A_n : IN STD_LOGIC;
41 patch_B_p : IN STD_LOGIC; -- logic signal from second trigger patch
42 patch_B_n : IN STD_LOGIC;
43 patch_C_p : IN STD_LOGIC; -- logic signal from third trigger patch
44 patch_C_n : IN STD_LOGIC;
45 patch_D_p : IN STD_LOGIC; -- logic signal from fourth trigger patch
46 patch_D_n : IN STD_LOGIC;
47 trig_prim_p : IN STD_LOGIC; -- logic signal from n-out-of-4 circuit
48 trig_prim_n : IN STD_LOGIC;
49
50 -- DAC interface
51 sck : OUT STD_LOGIC; -- serial clock to DAC
52 mosi : OUT STD_LOGIC; -- serial data to DAC, master-out-slave-in
53 clr : OUT STD_LOGIC; -- clear signal to DAC
54 cs_ld : OUT STD_LOGIC; -- chip select or load to DAC
55
56 -- RS-485 interface to FTM
57 rx : IN STD_LOGIC; -- serial data from FTM
58 tx : OUT STD_LOGIC; -- serial data to FTM
59 rx_en : OUT STD_LOGIC; -- enable RS-485 receiver
60 tx_en : OUT STD_LOGIC; -- enable RS-485 transmitter
61
62 -- analog buffer enable
63 enables_A : OUT STD_LOGIC_VECTOR(8 downto 0); -- individual enables for analog inputs
64 enables_B : OUT STD_LOGIC_VECTOR(8 downto 0); -- individual enables for analog inputs
65 enables_C : OUT STD_LOGIC_VECTOR(8 downto 0); -- individual enables for analog inputs
66 enables_D : OUT STD_LOGIC_VECTOR(8 downto 0); -- individual enables for analog inputs
67
68 -- testpoints
69 TP_A : out STD_LOGIC_VECTOR(11 downto 0) -- testpoints
70 );
71end FTU_top;
72
73
74architecture Behavioral of FTU_top is
75
76 component FTU_dac_dcm
77 port(
78 CLKIN_IN : IN STD_LOGIC;
79 RST_IN : IN STD_LOGIC;
80 CLKFX_OUT : OUT STD_LOGIC;
81 CLKIN_IBUFG_OUT : OUT STD_LOGIC;
82 LOCKED_OUT : OUT STD_LOGIC
83 );
84 end component;
85
86 component FTU_dac_control
87 port(
88 clk : IN STD_LOGIC;
89 reset : IN STD_LOGIC;
90 miso : 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 );
96 end component;
97
98 signal reset_sig : STD_LOGIC := '0'; -- initialize reset to 0 at power up
99 signal clk_5M_sig : STD_LOGIC;
100
101 type FTU_top_StateType is (Init, Running, Reset);
102 signal FTU_top_State, FTU_top_NextState: FTU_top_StateType;
103
104begin
105
106 Inst_FTU_dac_dcm : FTU_dac_dcm
107 port map(
108 CLKIN_IN => ext_clk,
109 RST_IN => reset_sig,
110 CLKFX_OUT => clk_5M_sig,
111 CLKIN_IBUFG_OUT => open,
112 LOCKED_OUT => open
113 );
114
115 Inst_FTU_dac_control : FTU_dac_control
116 port map(
117 clk => clk_5M_sig,
118 reset => reset_sig,
119 miso => '0',
120 clr => clr,
121 mosi => mosi,
122 sck => sck,
123 cs_ld => cs_ld
124 );
125
126 --FTU main state machine (two-process implementation)
127
128 FTU_top_Registers: process (ext_clk)
129 begin
130 if Rising_edge(ext_clk) then
131 FTU_top_State <= FTU_top_NextState;
132 end if;
133 end process FTU_top_Registers;
134
135 FTU_top_C_logic: process (FTU_top_State)
136 begin
137 FTU_top_NextState <= FTU_top_State;
138 case FTU_top_State is
139 when Init =>
140 reset_sig <= '0';
141 FTU_top_NextState <= Running;
142 when Running =>
143 when Reset =>
144 reset_sig <= '1';
145 FTU_top_NextState <= Init;
146 end case;
147 end process FTU_top_C_logic;
148
149end Behavioral;
150
151--What is missing?
152--UART
153--registers (enables, DAC values etc.)
154--rate counters
155--main state machine for FTU: talks to DAC, reads counters, listens to UART
156
Note: See TracBrowser for help on using the repository browser.