source: firmware/FTU/test_firmware/FTU_test8/FTU_test8.vhd@ 9939

Last change on this file since 9939 was 9622, checked in by weitzel, 14 years ago
FTU_test8 added (threshold ramping)
File size: 5.0 KB
Line 
1----------------------------------------------------------------------------------
2-- Company: ETH Zurich, Institute for Particle Physics
3-- Engineer: P. Vogler, Q. Weitzel
4--
5-- Create Date: 08/04/2010
6-- Design Name:
7-- Module Name: FTU_test8 - Behavioral
8-- Project Name:
9-- Target Devices:
10-- Tool versions:
11-- Description: Test firmware for FTU board, ramp thresholds up (and down)
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_test8 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_test8;
73
74
75architecture Behavioral of FTU_test8 is
76
77 component FTU_test8_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_test8_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_test8_StateType is (Running);
105 signal FTU_test8_State, FTU_test8_NextState: FTU_test8_StateType;
106
107begin
108
109 enables_B <= "111111111";
110 enables_C <= "111111111";
111 enables_D <= "111111111";
112
113 Inst_FTU_test8_dac_dcm : FTU_test8_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_test8_dac_control : FTU_test8_dac_control
123 port map(
124 clk => clk_50M_sig,
125 reset => reset_sig,
126 clr => clr,
127 mosi => mosi,
128 sck => sck,
129 cs_ld => cs_ld,
130 enable1 => enables_A(1),
131 enable2 => enables_A(2),
132 enable3 => enables_A(3)
133 );
134
135 --FTU main state machine (two-process implementation)
136
137 FTU_test8_Registers: process (ext_clk)
138 begin
139 if Rising_edge(ext_clk) then
140 FTU_test8_State <= FTU_test8_NextState;
141 end if;
142 end process FTU_test8_Registers;
143
144 FTU_test8_C_logic: process (FTU_test8_State)
145 begin
146 FTU_test8_NextState <= FTU_test8_State;
147 case FTU_test8_State is
148 when Running =>
149 reset_sig <= '0';
150 enables_A(8 downto 4) <= "11111";
151 enables_A(0) <= '0';
152 end case;
153 end process FTU_test8_C_logic;
154
155end Behavioral;
Note: See TracBrowser for help on using the repository browser.