1 |
62 |
budinero |
-------------------------------------------------------------------------------------------------100
|
2 |
|
|
--| Modular Oscilloscope
|
3 |
|
|
--| UNSL - Argentine
|
4 |
|
|
--|
|
5 |
|
|
--| File: ctrl_pkg.vhd
|
6 |
|
|
--| Version: 0.1
|
7 |
|
|
--| Tested in: Actel A3PE1500
|
8 |
|
|
--|-------------------------------------------------------------------------------------------------
|
9 |
|
|
--| Description:
|
10 |
|
|
--| CONTROL - Package
|
11 |
|
|
--| Package for instantiate Control modules.
|
12 |
|
|
--|
|
13 |
|
|
--|-------------------------------------------------------------------------------------------------
|
14 |
|
|
--| File history:
|
15 |
|
|
--| 0.11 | aug-2009 | First release
|
16 |
|
|
----------------------------------------------------------------------------------------------------
|
17 |
|
|
--| Copyright (R) 2009, Facundo Aguilera.
|
18 |
|
|
--|
|
19 |
|
|
--| This VHDL design file is an open design; you can redistribute it and/or
|
20 |
|
|
--| modify it and/or implement it after contacting the author.
|
21 |
|
|
----------------------------------------------------------------------------------------------------
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
-- Bloque completo
|
26 |
|
|
library IEEE;
|
27 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
28 |
|
|
use ieee.math_real.all;
|
29 |
|
|
|
30 |
|
|
package ctrl_pkg is
|
31 |
|
|
--------------------------------------------------------------------------------------------------
|
32 |
|
|
-- Componentes
|
33 |
|
|
|
34 |
|
|
component generic_decoder is
|
35 |
|
|
generic(
|
36 |
|
|
INPUT_WIDTH: integer := 5 -- Input with for decoder (decodes INPUT_WIDTH to 2^INPUT_WIDTH)
|
37 |
|
|
);
|
38 |
|
|
Port(
|
39 |
|
|
enable_I: in std_logic;
|
40 |
|
|
data_I: in std_logic_vector(INPUT_WIDTH-1 downto 0);
|
41 |
|
|
decoded_O: out std_logic_vector( integer(2**real(INPUT_WIDTH))-1 downto 0)
|
42 |
|
|
);
|
43 |
|
|
end component generic_decoder;
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
component generic_counter is
|
47 |
|
|
generic(
|
48 |
|
|
OUTPUT_WIDTH: integer := 32 -- Output width for counter.
|
49 |
|
|
);
|
50 |
|
|
port(
|
51 |
|
|
clk_I: in std_logic;
|
52 |
|
|
count_O: out std_logic_vector( OUTPUT_WIDTH downto 0);
|
53 |
|
|
reset_I: in std_logic;
|
54 |
|
|
enable_I: in std_logic
|
55 |
|
|
);
|
56 |
|
|
end component generic_counter;
|
57 |
|
|
|
58 |
|
|
component ctrl_output_manager is
|
59 |
|
|
generic(
|
60 |
|
|
MEM_ADD_WIDTH: integer := 14
|
61 |
|
|
);
|
62 |
|
|
port(
|
63 |
|
|
------------------------------------------------------------------------------------------------
|
64 |
|
|
-- MASTER (to memory)
|
65 |
|
|
DAT_I_mem: in std_logic_vector (15 downto 0);
|
66 |
|
|
--DAT_O_mem: out std_logic_vector (15 downto 0);
|
67 |
|
|
ADR_O_mem: out std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
68 |
|
|
CYC_O_mem: out std_logic;
|
69 |
|
|
STB_O_mem: out std_logic;
|
70 |
|
|
ACK_I_mem: in std_logic ;
|
71 |
|
|
WE_O_mem: out std_logic;
|
72 |
|
|
------------------------------------------------------------------------------------------------
|
73 |
|
|
-- SLAVE (to I/O ports)
|
74 |
|
|
--DAT_I_port: in std_logic_vector (15 downto 0);
|
75 |
|
|
DAT_O_port: out std_logic_vector (15 downto 0);
|
76 |
|
|
--ADR_I_port: in std_logic_vector (7 downto 0);
|
77 |
|
|
CYC_I_port: in std_logic;
|
78 |
|
|
STB_I_port: in std_logic;
|
79 |
|
|
ACK_O_port: out std_logic ;
|
80 |
|
|
WE_I_port: in std_logic;
|
81 |
|
|
------------------------------------------------------------------------------------------------
|
82 |
|
|
-- Common signals
|
83 |
|
|
RST_I: in std_logic;
|
84 |
|
|
CLK_I: in std_logic;
|
85 |
|
|
------------------------------------------------------------------------------------------------
|
86 |
|
|
-- Internal
|
87 |
|
|
load_I: in std_logic;
|
88 |
|
|
-- load initial address
|
89 |
|
|
enable_I: in std_logic;
|
90 |
|
|
-- continue reading from the actual address ('0' means pause, '1' means continue)
|
91 |
|
|
initial_address_I: in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
92 |
|
|
-- buffer starts and ends here
|
93 |
|
|
biggest_address_I: in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
94 |
|
|
-- when the buffer arrives here, address is changed to 0 (buffer size)
|
95 |
|
|
pause_address_I: in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
96 |
|
|
-- address wich is being writed by control
|
97 |
|
|
finish_O: out std_logic
|
98 |
|
|
-- this is set when communication ends and remains until next restart or actual address change
|
99 |
|
|
);
|
100 |
|
|
end component ctrl_output_manager;
|
101 |
|
|
|
102 |
|
|
component ctrl_memory_writer is
|
103 |
|
|
generic(
|
104 |
|
|
MEM_ADD_WIDTH: integer := 14
|
105 |
|
|
);
|
106 |
|
|
port(
|
107 |
|
|
----------------------------------------------------------------------------------------------
|
108 |
|
|
-- to memory
|
109 |
|
|
DAT_O_mem: out std_logic_vector (15 downto 0);
|
110 |
|
|
ADR_O_mem: out std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
111 |
|
|
CYC_O_mem: out std_logic;
|
112 |
|
|
STB_O_mem: out std_logic;
|
113 |
|
|
ACK_I_mem: in std_logic ;
|
114 |
|
|
WE_O_mem: out std_logic;
|
115 |
|
|
----------------------------------------------------------------------------------------------
|
116 |
|
|
-- to acquistion module
|
117 |
|
|
DAT_I_adc: in std_logic_vector (15 downto 0);
|
118 |
|
|
-- Using an address generator, commented
|
119 |
|
|
-- ADR_O_adc: out std_logic_vector (ADC_ADD_WIDTH - 1 downto 0);
|
120 |
|
|
CYC_O_adc: out std_logic;
|
121 |
|
|
STB_O_adc: out std_logic;
|
122 |
|
|
ACK_I_adc: in std_logic ;
|
123 |
|
|
--WE_O_adc: out std_logic;
|
124 |
|
|
----------------------------------------------------------------------------------------------
|
125 |
|
|
-- Common signals
|
126 |
|
|
RST_I: in std_logic;
|
127 |
|
|
CLK_I: in std_logic;
|
128 |
|
|
----------------------------------------------------------------------------------------------
|
129 |
|
|
-- Internal
|
130 |
|
|
-- reset memory address to 0
|
131 |
|
|
reset_I: in std_logic;
|
132 |
|
|
-- read in clk edge from the actual address ('0' means pause, '1' means continue)
|
133 |
|
|
enable_I: in std_logic;
|
134 |
|
|
final_address_I: in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
135 |
|
|
-- it is set when communication ends and remains until next restart or actual address change
|
136 |
|
|
finished_O: out std_logic;
|
137 |
|
|
-- when counter finishes, restart
|
138 |
|
|
continuous_I: in std_logic
|
139 |
|
|
);
|
140 |
|
|
end component ctrl_memory_writer;
|
141 |
|
|
|
142 |
|
|
|
143 |
|
|
component ctrl_data_skipper is
|
144 |
|
|
generic(
|
145 |
|
|
-- max losses = 2**(2**SELECTOR_WIDTH). (i.e., if SELECTOR_WIDTH = 5: 4.2950e+09)
|
146 |
|
|
SELECTOR_WIDTH: integer := 5
|
147 |
|
|
);
|
148 |
|
|
port(
|
149 |
|
|
-- enable output signal
|
150 |
|
|
ack_O: out std_logic;
|
151 |
|
|
-- sinal from wishbone interface
|
152 |
|
|
ack_I, stb_I: in std_logic;
|
153 |
|
|
-- selector from register, equation: losses = 2**(selector_I + 1) * enable_skipper_I
|
154 |
|
|
selector_I: in std_logic_vector(SELECTOR_WIDTH-1 downto 0);
|
155 |
|
|
-- enable from register
|
156 |
|
|
enable_skipper_I: in std_logic;
|
157 |
|
|
-- common signals
|
158 |
|
|
reset_I, clk_I: in std_logic;
|
159 |
|
|
-- set when returns to the first channel
|
160 |
|
|
first_channel_I: in std_logic
|
161 |
|
|
);
|
162 |
|
|
end component ctrl_data_skipper;
|
163 |
|
|
|
164 |
|
|
|
165 |
|
|
component ctrl_channel_selector is
|
166 |
|
|
generic(
|
167 |
|
|
CHANNEL_WIDTH: integer := 4 -- number of channels 2**CHANNEL_WIDTH, max. 4
|
168 |
|
|
);
|
169 |
|
|
port(
|
170 |
|
|
channels_I: in std_logic_vector(integer(2**real(CHANNEL_WIDTH))-1 downto 0);
|
171 |
|
|
channel_number_O: out std_logic_vector(CHANNEL_WIDTH - 1 downto 0);
|
172 |
|
|
first_channel_O: out std_logic;
|
173 |
|
|
clk_I: in std_logic;
|
174 |
|
|
enable_I: in std_logic;
|
175 |
|
|
reset_I: in std_logic
|
176 |
|
|
);
|
177 |
|
|
end component ctrl_channel_selector;
|
178 |
|
|
|
179 |
|
|
|
180 |
|
|
component ctrl_trigger_manager is
|
181 |
|
|
generic (
|
182 |
|
|
MEM_ADD_WIDTH: integer := 14;
|
183 |
|
|
DATA_WIDTH: integer := 10;
|
184 |
|
|
CHANNELS_WIDTH: integer := 4
|
185 |
|
|
);
|
186 |
|
|
port (
|
187 |
|
|
data_I: in std_logic_vector (DATA_WIDTH - 1 downto 0);
|
188 |
|
|
channel_I: in std_logic_vector (CHANNELS_WIDTH -1 downto 0);
|
189 |
|
|
trig_channel_I: in std_logic_vector (CHANNELS_WIDTH -1 downto 0);
|
190 |
|
|
address_I: in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
191 |
|
|
final_address_I: in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
192 |
|
|
-- offset from trigger address (signed). MUST BE:
|
193 |
|
|
-- -final_address_I < offset_I < final_address_I
|
194 |
|
|
offset_I: in std_logic_vector (MEM_ADD_WIDTH downto 0);
|
195 |
|
|
-- trigger level (from max to min, not signed)
|
196 |
|
|
level_I: in std_logic_vector (DATA_WIDTH - 1 downto 0);
|
197 |
|
|
-- use falling edge when falling_I = '1', else rising edge
|
198 |
|
|
falling_I: in std_logic;
|
199 |
|
|
clk_I: in std_logic;
|
200 |
|
|
reset_I: in std_logic;
|
201 |
|
|
enable_I: in std_logic;
|
202 |
|
|
-- it is set when trigger condition occurs
|
203 |
|
|
trigger_O: out std_logic;
|
204 |
|
|
-- address when trigger plus offset
|
205 |
|
|
address_O: out std_logic_vector (MEM_ADD_WIDTH - 1 downto 0)
|
206 |
|
|
);
|
207 |
|
|
end component ctrl_trigger_manager;
|
208 |
|
|
|
209 |
|
|
|
210 |
|
|
component ctrl_address_allocation is
|
211 |
|
|
port(
|
212 |
|
|
----------------------------------------------------------------------------------------------
|
213 |
|
|
-- From port
|
214 |
|
|
DAT_I_port: in std_logic_vector (15 downto 0);
|
215 |
|
|
DAT_O_port: out std_logic_vector (15 downto 0);
|
216 |
|
|
ADR_I_port: in std_logic_vector (3 downto 0);
|
217 |
|
|
CYC_I_port: in std_logic;
|
218 |
|
|
STB_I_port: in std_logic;
|
219 |
|
|
ACK_O_port: out std_logic ;
|
220 |
|
|
WE_I_port: in std_logic;
|
221 |
|
|
RST_I: in std_logic;
|
222 |
|
|
CLK_I: in std_logic;
|
223 |
|
|
----------------------------------------------------------------------------------------------
|
224 |
|
|
-- To internal
|
225 |
|
|
CYC_O_int: out std_logic;
|
226 |
|
|
STB_O_int: out std_logic;
|
227 |
|
|
ACK_I_int: in std_logic ;
|
228 |
|
|
DAT_I_int: in std_logic_vector(15 downto 0);
|
229 |
|
|
----------------------------------------------------------------------------------------------
|
230 |
|
|
-- Internal
|
231 |
|
|
start_O: out std_logic;
|
232 |
|
|
continuous_O: out std_logic;
|
233 |
|
|
trigger_en_O: out std_logic;
|
234 |
|
|
trigger_edge_O: out std_logic;
|
235 |
|
|
trigger_channel_O:out std_logic_vector(0 downto 0);
|
236 |
|
|
time_scale_O: out std_logic_vector(4 downto 0);
|
237 |
|
|
time_scale_en_O: out std_logic;
|
238 |
|
|
channels_sel_O: out std_logic_vector(1 downto 0);
|
239 |
|
|
buffer_size_O: out std_logic_vector(13 downto 0);
|
240 |
|
|
trigger_level_O: out std_logic_vector(9 downto 0);
|
241 |
|
|
trigger_offset_O: out std_logic_vector(14 downto 0);
|
242 |
|
|
|
243 |
|
|
adc_conf_O: out std_logic_vector(15 downto 0);
|
244 |
|
|
|
245 |
|
|
error_number_I: in std_logic_vector (2 downto 0);
|
246 |
|
|
status_I: in std_logic_vector(1 downto 0);
|
247 |
|
|
|
248 |
|
|
write_in_adc_O: out std_logic;
|
249 |
|
|
stop_O: out std_logic
|
250 |
|
|
);
|
251 |
|
|
end component ctrl_address_allocation;
|
252 |
|
|
|
253 |
|
|
|
254 |
|
|
component ctrl is
|
255 |
|
|
port(
|
256 |
|
|
------------------------------------------------------------------------------------------------
|
257 |
|
|
-- (TEMPORAL) to monitors
|
258 |
|
|
ctrl_status_monitor: out std_logic_vector(3 downto 0);
|
259 |
|
|
|
260 |
|
|
------------------------------------------------------------------------------------------------
|
261 |
|
|
-- From port
|
262 |
|
|
DAT_I_port: in std_logic_vector (15 downto 0);
|
263 |
|
|
DAT_O_port: out std_logic_vector (15 downto 0);
|
264 |
|
|
ADR_I_port: in std_logic_vector (3 downto 0);
|
265 |
|
|
CYC_I_port: in std_logic;
|
266 |
|
|
STB_I_port: in std_logic;
|
267 |
|
|
ACK_O_port: out std_logic ;
|
268 |
|
|
WE_I_port: in std_logic;
|
269 |
|
|
CLK_I_port: in std_logic;
|
270 |
|
|
RST_I_port: in std_logic;
|
271 |
|
|
|
272 |
|
|
------------------------------------------------------------------------------------------------
|
273 |
|
|
-- To ADC
|
274 |
|
|
DAT_I_daq: in std_logic_vector (15 downto 0);
|
275 |
|
|
DAT_O_daq: out std_logic_vector (15 downto 0);
|
276 |
|
|
ADR_O_daq: out std_logic_vector (1 downto 0);
|
277 |
|
|
CYC_O_daq: out std_logic;
|
278 |
|
|
STB_O_daq: out std_logic;
|
279 |
|
|
ACK_I_daq: in std_logic ;
|
280 |
|
|
WE_O_daq: out std_logic;
|
281 |
|
|
|
282 |
|
|
CLK_I_daq: in std_logic;
|
283 |
|
|
RST_I_daq: in std_logic;
|
284 |
|
|
|
285 |
|
|
------------------------------------------------------------------------------------------------
|
286 |
|
|
-- To memory, A (writing) interface (Higer prioriry)
|
287 |
|
|
--DAT_I_memw: in std_logic_vector (15 downto 0);
|
288 |
|
|
DAT_O_memw: out std_logic_vector (15 downto 0);
|
289 |
|
|
ADR_O_memw: out std_logic_vector (13 downto 0);
|
290 |
|
|
CYC_O_memw: out std_logic;
|
291 |
|
|
STB_O_memw: out std_logic;
|
292 |
|
|
ACK_I_memw: in std_logic ;
|
293 |
|
|
WE_O_memw: out std_logic;
|
294 |
|
|
|
295 |
|
|
------------------------------------------------------------------------------------------------
|
296 |
|
|
-- To memory, B (reading) interface
|
297 |
|
|
DAT_I_memr: in std_logic_vector (15 downto 0);
|
298 |
|
|
--DAT_O_memr: out std_logic_vector (15 downto 0);
|
299 |
|
|
ADR_O_memr: out std_logic_vector (13 downto 0);
|
300 |
|
|
CYC_O_memr: out std_logic;
|
301 |
|
|
STB_O_memr: out std_logic;
|
302 |
|
|
ACK_I_memr: in std_logic ;
|
303 |
|
|
WE_O_memr: out std_logic
|
304 |
|
|
|
305 |
|
|
);
|
306 |
|
|
end component ctrl;
|
307 |
|
|
|
308 |
|
|
end package ctrl_pkg;
|
309 |
|
|
|