source: firmware/FTM/test_firmware/FTM_test3/FTM_test3_microwire_controller.vhd@ 10891

Last change on this file since 10891 was 10046, checked in by vogler, 14 years ago
Test firmware for FTM hardware testing
File size: 3.2 KB
Line 
1--
2-- VHDL Architecture FACT_FAD_lib.spi_controller.beha
3--
4-- Created:
5-- by - Benjamin Krumm.UNKNOWN (EEPC8)
6-- at - 10:37:20 12.04.2010
7--
8-- using Mentor Graphics HDL Designer(TM) 2009.1 (Build 12)
9--
10-- modified by Q. Weitzel
11--
12-------------------------------------------------------------------------------
13--
14-- modified by Patrick Vogler
15-- September 17 2010
16--
17-- modified to be used as a Microwire interface to control the clock
18-- conditioner LMK03000 on the FTM board
19-------------------------------------------------------------------------------
20
21LIBRARY ieee;
22USE ieee.std_logic_1164.all;
23USE ieee.std_logic_arith.all;
24USE ieee.std_logic_unsigned.all;
25
26library FTM_definitions_test3;
27USE FTM_definitions_test3.ftm_array_types.all;
28
29
30
31ENTITY FTM_test3_microwire_controller IS
32 PORT(
33 -- clk : IN std_logic; -- 250MHz
34 clk_uwire : IN std_logic; -- sclk
35 data_uwire : OUT std_logic := '0'; -- mosi
36 le_uwire : OUT std_logic := '1'; -- Latch Enable = chip select
37 clk_cond_array : IN clk_cond_array_type; -- data to be loaded
38 -- into the clock conditioner
39 config_start : IN std_logic;
40 config_ready : OUT std_logic := '0';
41 config_started : OUT std_logic := '0'
42 );
43END FTM_test3_microwire_controller ;
44
45
46ARCHITECTURE beha OF FTM_test3_microwire_controller IS
47
48 type TYPE_uWire_STATE is (IDLE, LOAD_SHIFT_REG, SHIFT);
49 signal uwire_state : TYPE_uWire_STATE := IDLE;
50 signal register_count : integer range 0 to 9 := 0;
51 signal bit_count : integer range 0 to 32 := 0;
52 signal shift_reg : std_logic_vector (31 downto 0) := (others => '0');
53
54
55BEGIN
56
57 uwire_write_proc: process (clk_uwire)
58 begin
59
60 if falling_edge(clk_uwire) then
61
62 case uwire_state is
63
64 when IDLE =>
65
66 le_uwire <= '1';
67 config_ready <= '1';
68 config_started <= '0';
69 bit_count <= 0;
70 register_count <= 0;
71 data_uwire <= '0';
72
73 if (config_start = '1') then
74 config_ready <= '0';
75 uwire_state <= LOAD_SHIFT_REG;
76 end if;
77
78
79 when LOAD_SHIFT_REG =>
80 bit_count <= 0;
81 config_started <= '1';
82 shift_reg <= clk_cond_array(register_count)(31 downto 0);
83 register_count <= register_count + 1;
84-- le_uwire <= '0';
85 uwire_state <= SHIFT;
86
87
88 when SHIFT =>
89 data_uwire <= shift_reg(31);
90 le_uwire <= '0';
91 shift_reg <= shift_reg(30 downto 0) & shift_reg(31);
92 bit_count <= bit_count + 1;
93 if ((bit_count = 32)AND(register_count = 9)) then
94 le_uwire <= '1';
95 uwire_state <= IDLE;
96 elsif ((bit_count = 32)AND(NOT(register_count = 9))) then
97 le_uwire <= '1';
98 uwire_state <= LOAD_SHIFT_REG;
99 else
100 uwire_state <= SHIFT;
101 end if;
102
103 end case;
104 end if;
105
106 end process uwire_write_proc;
107
108END ARCHITECTURE beha;
Note: See TracBrowser for help on using the repository browser.