source: FPGA/FTU/test_firmware/FTU_test5/FTU_test5_dac_control.vhd@ 813

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