source: firmware/FTU/dac_spi/FTU_spi_distributor.vhd@ 19157

Last change on this file since 19157 was 9939, checked in by weitzel, 14 years ago
FTU RS485 interface is now connected to main control
File size: 2.7 KB
Line 
1--
2-- VHDL Architecture FACT_FAD_lib.spi_distributor.beha
3--
4-- Created:
5-- by - Benjamin Krumm.UNKNOWN (EEPC8)
6-- at - 09:24:21 23.04.2010
7--
8-- using Mentor Graphics HDL Designer(TM) 2009.1 (Build 12)
9--
10-- modified by Q. Weitzel
11--
12
13LIBRARY ieee;
14USE ieee.std_logic_1164.all;
15USE ieee.std_logic_arith.all;
16USE ieee.std_logic_unsigned.all;
17library ftu_definitions;
18USE ftu_definitions.ftu_array_types.all;
19
20ENTITY FTU_spi_distributor IS
21 PORT(
22 clk : IN std_logic; -- 50MHz
23 config_start : IN std_logic;
24 config_ready : OUT std_logic := '0';
25 config_started : OUT std_logic := '0';
26 dac_array : IN dac_array_type;
27 dac_config_start : OUT std_logic := '0';
28 dac_config_ready : IN std_logic;
29 dac_id : OUT std_logic_vector(2 downto 0) := (others => '0');
30 data : OUT std_logic_vector(15 downto 0) := (others => '0')
31 );
32END ENTITY FTU_spi_distributor;
33
34ARCHITECTURE beha OF FTU_spi_distributor IS
35
36 type TYPE_SPI_DISTRIBUTION_STATE is (INIT, IDLE, CONFIG_DAC);
37
38 signal spi_distr_state : TYPE_SPI_DISTRIBUTION_STATE := INIT;
39 signal dac_id_cnt : integer range 0 to 7 := 0;
40
41BEGIN
42
43 spi_distribute_proc: process (clk)
44 begin
45
46 if rising_edge(clk) then
47 data <= (others => '0');
48 case spi_distr_state is
49 when INIT =>
50 data <= (others => '0');
51 spi_distr_state <= IDLE;
52 when IDLE =>
53 config_ready <= '0';
54 data <= (others => '0');
55 -- start DAC configuration
56 if (config_start = '1') then
57 config_started <= '1';
58 config_ready <= '0';
59 dac_config_start <= '1';
60 dac_id <= conv_std_logic_vector(dac_id_cnt, dac_id'length);
61 data <= conv_std_logic_vector(dac_array(dac_id_cnt),data'length);
62 spi_distr_state <= CONFIG_DAC;
63 end if;
64
65 -- DAC configuration
66 when CONFIG_DAC =>
67 dac_config_start <= '1';
68 dac_id <= conv_std_logic_vector(dac_id_cnt, dac_id'length);
69 data <= conv_std_logic_vector(dac_array(dac_id_cnt),data'length);
70 if (dac_config_ready = '1') then
71 dac_config_start <= '0';
72 if (dac_id_cnt < 7) then
73 dac_id_cnt <= dac_id_cnt + 1;
74 dac_config_start <= '1';
75 spi_distr_state <= CONFIG_DAC;
76 else
77 dac_id_cnt <= 0;
78 config_started <= '0';
79 config_ready <= '1';
80 spi_distr_state <= IDLE;
81 end if;
82 end if;
83 end case;
84 end if;
85
86 end process spi_distribute_proc;
87
88END ARCHITECTURE beha;
89
Note: See TracBrowser for help on using the repository browser.