source: firmware/FTM/test_firmware/FTM_test3/#FTM_test3_microwire_controller.vhd#@ 13449

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