source: FPGA/FTU/test_firmware/FTU_test2/FTU_test2_dac_control.vhd@ 8080

Last change on this file since 8080 was 243, checked in by qweitzel, 14 years ago
FTU_test2 is now working
File size: 3.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_dac_control - Behavioral
8-- Project Name:
9-- Target Devices:
10-- Tool versions:
11-- Description: test2 for control DAC on FTU board to set trigger thresholds
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;
25USE ftu_definitions.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
32entity FTU_test2_dac_control is
33 port(
34 clk : IN STD_LOGIC;
35 reset : IN STD_LOGIC;
36 clr : OUT STD_LOGIC;
37 mosi : OUT STD_LOGIC;
38 sck : OUT STD_LOGIC;
39 cs_ld : out STD_LOGIC;
40 enable1 : out STD_LOGIC;
41 enable2 : out STD_LOGIC;
42 enable3 : out STD_LOGIC
43 );
44end FTU_test2_dac_control;
45
46architecture Behavioral of FTU_test2_dac_control is
47
48 component FTU_test2_spi_interface
49 port(
50 clk_50MHz : IN std_logic;
51 config_start : IN std_logic;
52 dac_array : IN dac_array_type;
53 config_ready : OUT std_logic;
54 config_started : OUT std_logic;
55 dac_cs : OUT std_logic;
56 mosi : OUT std_logic;
57 sclk : OUT std_logic;
58 miso : INOUT std_logic
59 );
60 end component;
61
62 signal clk_sig : std_logic;
63 signal reset_sig : std_logic;
64
65 signal clr_sig : std_logic;
66 signal mosi_sig : std_logic := '0';
67 signal serial_clock_sig : std_logic;
68 signal dac_cs_sig : std_logic;
69
70 signal config_start_sig : std_logic := '0';
71 signal config_ready_sig : std_logic;
72 signal config_started_sig : std_logic := '0';
73 signal dac_array_sig : dac_array_type := (100,200,300,400,500);
74
75 -- Build an enumerated type for the state machine
76 type state_type is (START, WAITING, STOP);
77
78 -- Register to hold the current state
79 signal state, next_state : state_type;
80
81begin
82
83 reset_sig <= reset;
84 clk_sig <= clk;
85 mosi <= mosi_sig;
86 sck <= serial_clock_sig;
87 cs_ld <= dac_cs_sig;
88
89 -- FSM for dac control: first process
90 FSM_Registers: process(clk_sig, reset_sig)
91 begin
92 if reset_sig = '1' then
93 state <= START;
94 elsif Rising_edge(clk_sig) then
95 state <= next_state;
96 end if;
97 end process;
98
99 -- FSM for dac control: second process
100 FSM_logic: process(state, config_ready_sig)
101 begin
102 next_state <= state;
103 case state is
104 when START =>
105 config_start_sig <= '1';
106 enable1 <= '1';
107 enable2 <= '0';
108 enable3 <= '0';
109 next_state <= WAITING;
110 when WAITING =>
111 config_start_sig <= '1';
112 enable1 <= '0';
113 enable2 <= '1';
114 enable3 <= '0';
115 if (config_ready_sig = '1') then
116 next_state <= STOP;
117 else
118 next_state <= WAITING;
119 end if;
120 when STOP =>
121 enable1 <= '0';
122 enable2 <= '0';
123 enable3 <= '1';
124 config_start_sig <= '0';
125 end case;
126 end process;
127
128 Inst_FTU_test2_spi_interface : FTU_test2_spi_interface
129 port map(
130 clk_50MHz => clk_sig,
131 config_start => config_start_sig,
132 dac_array => dac_array_sig,
133 config_ready => config_ready_sig,
134 config_started => config_started_sig,
135 dac_cs => dac_cs_sig,
136 mosi => mosi_sig,
137 sclk => serial_clock_sig,
138 miso => open
139 );
140
141end Behavioral;
142
Note: See TracBrowser for help on using the repository browser.