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

Last change on this file since 236 was 236, checked in by qweitzel, 16 years ago
second test for FTU added
File size: 2.8 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 7 := 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 < 7) then
70 if (dac_id_cnt = 3) then
71 dac_id_cnt <= 7;
72 else
73 dac_id_cnt <= dac_id_cnt + 1;
74 end if;
75 dac_config_start <= '1';
76 spi_distr_state <= CONFIG_DAC;
77 else
78 dac_id_cnt <= 0;
79 config_started <= '0';
80 config_ready <= '1';
81 spi_distr_state <= IDLE;
82 end if;
83 end if;
84 end case;
85 end if;
86
87 end process spi_distribute_proc;
88
89END ARCHITECTURE beha;
90
Note: See TracBrowser for help on using the repository browser.