source: FPGA/FTU/dac_spi/FTU_spi_distributor.vhd@ 2785

Last change on this file since 2785 was 273, checked in by qweitzel, 14 years ago
new structure for FTU firmware, not yet finished
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 data <= (others => '0');
54 -- start DAC configuration
55 if (config_start = '1') then
56 config_started <= '1';
57 config_ready <= '0';
58 dac_config_start <= '1';
59 dac_id <= conv_std_logic_vector(dac_id_cnt, dac_id'length);
60 data <= conv_std_logic_vector(dac_array(dac_id_cnt),data'length);
61 spi_distr_state <= CONFIG_DAC;
62 end if;
63
64 -- DAC configuration
65 when CONFIG_DAC =>
66 dac_config_start <= '1';
67 dac_id <= conv_std_logic_vector(dac_id_cnt, dac_id'length);
68 data <= conv_std_logic_vector(dac_array(dac_id_cnt),data'length);
69 if (dac_config_ready = '1') then
70 dac_config_start <= '0';
71 if (dac_id_cnt < 7) then
72 dac_id_cnt <= dac_id_cnt + 1;
73 dac_config_start <= '1';
74 spi_distr_state <= CONFIG_DAC;
75 else
76 dac_id_cnt <= 0;
77 config_started <= '0';
78 config_ready <= '1';
79 spi_distr_state <= IDLE;
80 end if;
81 end if;
82 end case;
83 end if;
84
85 end process spi_distribute_proc;
86
87END ARCHITECTURE beha;
88
Note: See TracBrowser for help on using the repository browser.