source: FPGA/FAD/FACT_FAD_lib/hdl/control_manager_beha.vhd@ 228

Last change on this file since 228 was 215, checked in by dneise, 14 years ago
initial commit (2nd part): only VHDL and UCF files were commited.
  • Property svn:executable set to *
File size: 4.9 KB
Line 
1--
2-- VHDL Architecture FACT_FAD_lib.controlRAM_manager.beha
3--
4-- Created:
5-- by - Benjamin Krumm.UNKNOWN (EEPC8)
6-- at - 14:35:46 14.04.2010
7--
8-- using Mentor Graphics HDL Designer(TM) 2009.1 (Build 12)
9--
10LIBRARY ieee;
11USE ieee.std_logic_1164.ALL;
12USE ieee.std_logic_arith.ALL;
13USE ieee.std_logic_unsigned.ALL;
14LIBRARY FACT_FAD_LIB;
15USE FACT_FAD_LIB.fad_definitions.ALL;
16
17ENTITY control_manager IS
18 GENERIC(
19 NO_OF_ROI : integer := 36;
20 NO_OF_DAC : integer := 8;
21 ADDR_WIDTH : integer := 8
22 );
23 PORT(
24 clk : IN std_logic;
25 ram_data_out : IN std_logic_vector (15 DOWNTO 0);
26 config_ready, config_started : OUT std_logic := '0';
27 config_start : IN std_logic;
28 config_data : INOUT std_logic_vector (15 DOWNTO 0) := (others => 'Z');
29 config_addr : IN std_logic_vector (ADDR_WIDTH - 1 DOWNTO 0);
30 config_wr_en : IN std_logic;
31 config_rd_en : IN std_logic;
32 config_data_valid : OUT std_logic := '0';
33 config_busy : OUT std_logic := '0';
34 ram_addr : OUT std_logic_vector (ADDR_WIDTH - 1 DOWNTO 0);
35 ram_data_in : OUT std_logic_vector (15 DOWNTO 0);
36 ram_write_en : OUT std_logic_vector (0 DOWNTO 0);
37 dac_array : OUT dac_array_type;
38 roi_array : OUT roi_array_type
39 );
40
41-- Declarations
42
43END control_manager ;
44
45ARCHITECTURE beha OF control_manager IS
46
47 type TYPE_CTRL_STATE is (CTRL_INIT, CTRL_IDLE, CTRL_WAIT_IDLE, CTRL_WRITE,
48 CTRL_LOAD_ADDR, CTRL_LOAD_WAIT, CTRL_LOAD_DATA,
49 CTRL_READ_ADDR, CTRL_READ_WAIT, CTRL_READ_DATA);
50
51 signal ctrl_state : TYPE_CTRL_STATE := CTRL_INIT;
52 signal addr_cntr : integer range 0 to 2**ADDR_WIDTH - 1 := 0;
53 signal int_dac_array : dac_array_type := DEFAULT_DAC;
54 signal int_roi_array : roi_array_type := DEFAULT_ROI;
55
56BEGIN
57
58 control_fsm_proc: process (clk)
59 begin
60
61 if rising_edge(clk) then
62
63 config_busy <= '1'; -- is always busy except in idle mode
64
65 case ctrl_state is
66
67 when CTRL_INIT =>
68 addr_cntr <= addr_cntr + 1;
69 ram_addr <= conv_std_logic_vector(addr_cntr, ADDR_WIDTH);
70 config_data_valid <= '0';
71 config_ready <= '0';
72 ctrl_state <= CTRL_INIT;
73 ram_write_en <= "1";
74 if (addr_cntr < NO_OF_ROI) then
75 ram_data_in <= conv_std_logic_vector(int_roi_array(addr_cntr ), 16);
76 elsif (addr_cntr < NO_OF_ROI + NO_OF_DAC) then
77 ram_data_in <= conv_std_logic_vector(int_dac_array(addr_cntr - NO_OF_ROI), 16);
78 else
79 ram_write_en <= "0";
80 ctrl_state <= CTRL_IDLE;
81 end if;
82
83 when CTRL_IDLE =>
84 addr_cntr <= 0;
85 ram_write_en <= "0";
86 config_busy <= '0';
87 if (config_start = '1') then
88 config_started <= '1';
89 config_ready <= '0';
90 config_data_valid <= '0';
91 ctrl_state <= CTRL_LOAD_ADDR;
92 end if;
93 if (config_wr_en = '1') then
94 config_busy <= '1';
95 config_data <= (others => 'Z');
96 ctrl_state <= CTRL_WRITE;
97 end if;
98 if (config_rd_en = '1') then
99 ram_addr <= config_addr;
100 config_data_valid <= '0';
101-- ctrl_state <= CTRL_READ_ADDR;
102 ctrl_state <= CTRL_READ_WAIT;
103 end if;
104
105 when CTRL_WAIT_IDLE =>
106 ctrl_state <= CTRL_IDLE;
107
108 when CTRL_LOAD_ADDR =>
109 ram_addr <= conv_std_logic_vector(addr_cntr, ADDR_WIDTH);
110 ctrl_state <= CTRL_LOAD_WAIT;
111 when CTRL_LOAD_WAIT =>
112 ctrl_state <= CTRL_LOAD_DATA;
113 when CTRL_LOAD_DATA =>
114 addr_cntr <= addr_cntr + 1;
115 if (addr_cntr < NO_OF_ROI) then
116 roi_array(addr_cntr) <= conv_integer(ram_data_out);
117 ctrl_state <= CTRL_LOAD_ADDR;
118 elsif (addr_cntr < NO_OF_ROI + NO_OF_DAC) then
119 dac_array(addr_cntr - NO_OF_ROI) <= conv_integer(ram_data_out);
120 ctrl_state <= CTRL_LOAD_ADDR;
121 else
122 addr_cntr <= 0;
123 config_started <= '0';
124 config_ready <= '1';
125 ctrl_state <= CTRL_WAIT_IDLE;
126 end if;
127
128 when CTRL_WRITE =>
129 ram_data_in <= config_data;
130 ram_addr <= config_addr;
131 ram_write_en <= "1";
132 ctrl_state <= CTRL_IDLE;
133
134 -- *** IMPORTANT ***
135 -- read address must remain two clock cycles
136 when CTRL_READ_ADDR =>
137 ctrl_state <= CTRL_READ_WAIT;
138 when CTRL_READ_WAIT =>
139 ctrl_state <= CTRL_READ_DATA;
140 when CTRL_READ_DATA =>
141 config_data <= ram_data_out;
142 config_data_valid <= '1';
143 ctrl_state <= CTRL_IDLE;
144
145 end case;
146
147 end if;
148
149 end process control_fsm_proc;
150
151END ARCHITECTURE beha;
152
Note: See TracBrowser for help on using the repository browser.