source: FPGA/FTU/test_firmware/FTU_test2/FTU_test2_spi_distributor.vhd@ 241

Last change on this file since 241 was 238, checked in by qweitzel, 15 years ago
some bug fixes for FTU_test2
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
11LIBRARY ieee;
12USE ieee.std_logic_1164.all;
13USE ieee.std_logic_arith.all;
14USE ieee.std_logic_unsigned.all;
15library ftu_definitions;
16USE ftu_definitions.ftu_array_types.all;
17
18ENTITY FTU_test2_spi_distributor IS
19 PORT(
20 clk : IN std_logic; -- 50MHz
21 config_start : IN std_logic;
22 config_ready : OUT std_logic := '0';
23 config_started : OUT std_logic := '0';
24 dac_array : IN dac_array_type;
25 dac_config_start : OUT std_logic := '0';
26 dac_config_ready : IN std_logic;
27 dac_id : OUT std_logic_vector(2 downto 0) := (others => '0');
28 data : INOUT std_logic_vector(15 downto 0) := (others => 'Z')
29 );
30END ENTITY FTU_test2_spi_distributor;
31
32ARCHITECTURE beha OF FTU_test2_spi_distributor IS
33
34 type TYPE_SPI_DISTRIBUTION_STATE is (INIT, IDLE, CONFIG_DAC);
35
36 signal spi_distr_state : TYPE_SPI_DISTRIBUTION_STATE := INIT;
37 signal dac_id_cnt : integer range 0 to 4 := 0;
38
39BEGIN
40
41 spi_distribute_proc: process (clk)
42 begin
43
44 if rising_edge(clk) then
45 data <= (others => 'Z');
46 case spi_distr_state is
47 when INIT =>
48 data <= (others => 'Z');
49 spi_distr_state <= IDLE;
50 when IDLE =>
51 data <= (others => 'Z');
52 -- start DAC configuration
53 if (config_start = '1') then
54 config_started <= '1';
55 config_ready <= '0';
56 dac_config_start <= '1';
57 dac_id <= conv_std_logic_vector(dac_id_cnt, dac_id'length);
58 data <= conv_std_logic_vector(dac_array(dac_id_cnt),data'length);
59 spi_distr_state <= CONFIG_DAC;
60 end if;
61
62 -- DAC configuration
63 when CONFIG_DAC =>
64 dac_config_start <= '1';
65 dac_id <= conv_std_logic_vector(dac_id_cnt, dac_id'length);
66 data <= conv_std_logic_vector(dac_array(dac_id_cnt),data'length);
67 if (dac_config_ready = '1') then
68 dac_config_start <= '0';
69 if (dac_id_cnt < 4) then
70 dac_id_cnt <= dac_id_cnt + 1;
71 dac_config_start <= '1';
72 spi_distr_state <= CONFIG_DAC;
73 else
74 dac_id_cnt <= 0;
75 config_started <= '0';
76 config_ready <= '1';
77 spi_distr_state <= IDLE;
78 end if;
79 end if;
80 end case;
81 end if;
82
83 end process spi_distribute_proc;
84
85END ARCHITECTURE beha;
86
Note: See TracBrowser for help on using the repository browser.