1 |
46 |
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.01 | jul-2009 | First incomplete
|
16 |
|
|
--| 0.1 | aug-2009 | First incomplete
|
17 |
|
|
----------------------------------------------------------------------------------------------------
|
18 |
|
|
--| Copyright © 2009, Facundo Aguilera.
|
19 |
|
|
--|
|
20 |
|
|
--| This VHDL design file is an open design; you can redistribute it and/or
|
21 |
|
|
--| modify it and/or implement it after contacting the author.
|
22 |
|
|
----------------------------------------------------------------------------------------------------
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
-- Bloque completo
|
27 |
|
|
library IEEE;
|
28 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
29 |
|
|
use ieee.math_real.all;
|
30 |
|
|
|
31 |
|
|
package ctrl_pkg is
|
32 |
|
|
--------------------------------------------------------------------------------------------------
|
33 |
|
|
-- Componentes
|
34 |
|
|
|
35 |
|
|
component generic_decoder is
|
36 |
|
|
generic(
|
37 |
|
|
INPUT_WIDTH: integer := 5 -- Input with for decoder (decodes INPUT_WIDTH to 2^INPUT_WIDTH)
|
38 |
|
|
);
|
39 |
|
|
Port(
|
40 |
|
|
enable_I: in std_logic;
|
41 |
|
|
data_I: in std_logic_vector(INPUT_WIDTH-1 downto 0);
|
42 |
|
|
decoded_O: out std_logic_vector( integer(2**real(INPUT_WIDTH))-1 downto 0)
|
43 |
|
|
);
|
44 |
|
|
end component generic_decoder;
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
component generic_counter is
|
48 |
|
|
generic(
|
49 |
|
|
OUTPUT_WIDTH: integer := 32 -- Output width for counter.
|
50 |
|
|
);
|
51 |
|
|
port(
|
52 |
|
|
clk_I: in std_logic;
|
53 |
|
|
count_O: out std_logic_vector( OUTPUT_WIDTH downto 0);
|
54 |
|
|
reset_I: in std_logic;
|
55 |
|
|
enable_I: in std_logic
|
56 |
|
|
);
|
57 |
|
|
end component generic_counter;
|
58 |
|
|
|
59 |
|
|
component ctrl_output_manager is
|
60 |
|
|
generic(
|
61 |
|
|
MEM_ADD_WIDTH: integer := 14
|
62 |
|
|
);
|
63 |
|
|
port(
|
64 |
|
|
------------------------------------------------------------------------------------------------
|
65 |
|
|
-- MASTER (to memory)
|
66 |
|
|
DAT_I_mem: in std_logic_vector (15 downto 0);
|
67 |
|
|
--DAT_O_mem: out std_logic_vector (15 downto 0);
|
68 |
|
|
ADR_O_mem: out std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
69 |
|
|
CYC_O_mem: out std_logic;
|
70 |
|
|
STB_O_mem: out std_logic;
|
71 |
|
|
ACK_I_mem: in std_logic ;
|
72 |
|
|
WE_O_mem: out std_logic;
|
73 |
|
|
------------------------------------------------------------------------------------------------
|
74 |
|
|
-- SLAVE (to I/O ports)
|
75 |
|
|
--DAT_I_port: in std_logic_vector (15 downto 0);
|
76 |
|
|
DAT_O_port: out std_logic_vector (15 downto 0);
|
77 |
|
|
--ADR_I_port: in std_logic_vector (7 downto 0);
|
78 |
|
|
CYC_I_port: in std_logic;
|
79 |
|
|
STB_I_port: in std_logic;
|
80 |
|
|
ACK_O_port: out std_logic ;
|
81 |
|
|
WE_I_port: in std_logic;
|
82 |
|
|
------------------------------------------------------------------------------------------------
|
83 |
|
|
-- Common signals
|
84 |
|
|
RST_I: in std_logic;
|
85 |
|
|
CLK_I: in std_logic;
|
86 |
|
|
------------------------------------------------------------------------------------------------
|
87 |
|
|
-- Internal
|
88 |
|
|
load_I: in std_logic;
|
89 |
|
|
-- load initial address
|
90 |
|
|
enable_I: in std_logic;
|
91 |
|
|
-- continue reading from the actual address ('0' means pause, '1' means continue)
|
92 |
|
|
initial_address_I: in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
93 |
|
|
-- buffer starts and ends here
|
94 |
|
|
biggest_address_I: in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
95 |
|
|
-- when the buffer arrives here, address is changed to 0 (buffer size)
|
96 |
|
|
pause_address_I: in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
97 |
|
|
-- address wich is being writed by control
|
98 |
|
|
finish_O: out std_logic
|
99 |
|
|
-- this is set when communication ends and remains until next restart or actual address change
|
100 |
|
|
);
|
101 |
|
|
end component ctrl_output_manager;
|
102 |
|
|
|
103 |
|
|
component ctrl_memory_writer is
|
104 |
|
|
generic(
|
105 |
|
|
MEM_ADD_WIDTH: integer := 14
|
106 |
|
|
);
|
107 |
|
|
port(
|
108 |
|
|
----------------------------------------------------------------------------------------------
|
109 |
|
|
-- to memory
|
110 |
|
|
DAT_O_mem: out std_logic_vector (15 downto 0);
|
111 |
|
|
ADR_O_mem: out std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
112 |
|
|
CYC_O_mem: out std_logic;
|
113 |
|
|
STB_O_mem: out std_logic;
|
114 |
|
|
ACK_I_mem: in std_logic ;
|
115 |
|
|
WE_O_mem: out std_logic;
|
116 |
|
|
----------------------------------------------------------------------------------------------
|
117 |
|
|
-- to acquistion module
|
118 |
|
|
DAT_I_adc: in std_logic_vector (15 downto 0);
|
119 |
|
|
-- Using an address generator, commented
|
120 |
|
|
-- ADR_O_adc: out std_logic_vector (ADC_ADD_WIDTH - 1 downto 0);
|
121 |
|
|
CYC_O_adc: out std_logic;
|
122 |
|
|
STB_O_adc: out std_logic;
|
123 |
|
|
ACK_I_adc: in std_logic ;
|
124 |
|
|
WE_O_adc: out std_logic;
|
125 |
|
|
----------------------------------------------------------------------------------------------
|
126 |
|
|
-- Common signals
|
127 |
|
|
RST_I: in std_logic;
|
128 |
|
|
CLK_I: in std_logic;
|
129 |
|
|
----------------------------------------------------------------------------------------------
|
130 |
|
|
-- Internal
|
131 |
|
|
-- reset memory address to 0
|
132 |
|
|
reset_I: in std_logic;
|
133 |
|
|
-- read in clk edge from the actual address ('0' means pause, '1' means continue)
|
134 |
|
|
enable_I: in std_logic;
|
135 |
|
|
final_address_I: in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
136 |
|
|
-- it is set when communication ends and remains until next restart or actual address change
|
137 |
|
|
finished_O: out std_logic;
|
138 |
|
|
-- when counter finishes, restart
|
139 |
|
|
continuous_I: in std_logic;
|
140 |
|
|
);
|
141 |
|
|
end component ctrl_memory_writer;
|
142 |
|
|
|
143 |
|
|
|
144 |
|
|
component ctrl_data_skipper is
|
145 |
|
|
generic(
|
146 |
|
|
-- max losses = 2**(2**SELECTOR_WIDTH). (i.e., if SELECTOR_WIDTH = 5: 4.2950e+09)
|
147 |
|
|
SELECTOR_WIDTH: integer := 5
|
148 |
|
|
);
|
149 |
|
|
port(
|
150 |
|
|
-- enable output signal
|
151 |
|
|
ack_O: out std_logic;
|
152 |
|
|
-- sinal from wishbone interface
|
153 |
|
|
ack_I, stb_I: in std_logic;
|
154 |
|
|
-- selector from register, equation: losses = 2**(selector_I + 1) * enable_skipper_I
|
155 |
|
|
selector_I: in std_logic_vector(SELECTOR_WIDTH-1 downto 0);
|
156 |
|
|
-- enable from register
|
157 |
|
|
enable_skipper_I: in std_logic;
|
158 |
|
|
-- common signals
|
159 |
|
|
reset_I, clk_I: in std_logic;
|
160 |
|
|
-- set when returns to the first channel
|
161 |
|
|
first_channel_I: in std_logic
|
162 |
|
|
);
|
163 |
|
|
end component ctrl_data_skipper;
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
component ctrl_channel_selector is
|
167 |
|
|
generic(
|
168 |
|
|
CHANNEL_WIDTH: integer := 4 -- number of channels 2**CHANNEL_WIDTH, max. 4
|
169 |
|
|
);
|
170 |
|
|
port(
|
171 |
|
|
channels_I: in std_logic_vector(integer(2**real(CHANNEL_WIDTH))-1 downto 0);
|
172 |
|
|
channel_number_O: out std_logic_vector(3 downto 0);
|
173 |
|
|
first_channel_O: out std_logic;
|
174 |
|
|
clk_I: in std_logic;
|
175 |
|
|
enable_I: in std_logic;
|
176 |
|
|
reset_I: in std_logic
|
177 |
|
|
);
|
178 |
|
|
end component ctrl_channel_selector;
|
179 |
|
|
|
180 |
|
|
|
181 |
|
|
component ctrl_trigger_manager is
|
182 |
|
|
generic (
|
183 |
|
|
MEM_ADD_WIDTH: integer := 14;
|
184 |
|
|
DATA_WIDTH: integer := 10;
|
185 |
|
|
CHANNELS_WIDTH: integer := 4
|
186 |
|
|
);
|
187 |
|
|
port (
|
188 |
|
|
data_I: in std_logic_vector (DATA_WIDTH - 1 downto 0);
|
189 |
|
|
channel_I: in std_logic_vector (CHANNELS_WIDTH -1 downto 0);
|
190 |
|
|
trig_channel_I: in std_logic_vector (CHANNELS_WIDTH -1 downto 0);
|
191 |
|
|
address_I: in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
192 |
|
|
final_address_I: in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
193 |
|
|
-- offset from trigger address (signed). MUST BE:
|
194 |
|
|
-- -final_address_I < offset_I < final_address_I
|
195 |
|
|
offset_I: in std_logic_vector (MEM_ADD_WIDTH downto 0);
|
196 |
|
|
-- trigger level (from max to min, not signed)
|
197 |
|
|
level_I: in std_logic_vector (DATA_WIDTH - 1 downto 0);
|
198 |
|
|
-- use falling edge when falling_I = '1', else rising edge
|
199 |
|
|
falling_I: in std_logic;
|
200 |
|
|
clk_I: in std_logic;
|
201 |
|
|
reset_I: in std_logic;
|
202 |
|
|
enable_I: in std_logic;
|
203 |
|
|
-- it is set when trigger condition occurs
|
204 |
|
|
trigger_O: out std_logic;
|
205 |
|
|
-- address when trigger plus offset
|
206 |
|
|
address_O: out std_logic_vector (MEM_ADD_WIDTH - 1 downto 0)
|
207 |
|
|
);
|
208 |
|
|
end component ctrl_trigger_manager;
|
209 |
|
|
|
210 |
|
|
|
211 |
|
|
component ctrl_address_assignments is
|
212 |
|
|
port(
|
213 |
|
|
----------------------------------------------------------------------------------------------
|
214 |
|
|
-- From port
|
215 |
|
|
DAT_I_port: in std_logic_vector (15 downto 0);
|
216 |
|
|
DAT_O_port: out std_logic_vector (15 downto 0);
|
217 |
|
|
ADR_I_port: in std_logic_vector (3 downto 0);
|
218 |
|
|
CYC_I_port: in std_logic;
|
219 |
|
|
STB_I_port: in std_logic;
|
220 |
|
|
ACK_O_port: out std_logic ;
|
221 |
|
|
WE_I_port: in std_logic;
|
222 |
|
|
RST_I: in std_logic;
|
223 |
|
|
CLK_I: in std_logic;
|
224 |
|
|
----------------------------------------------------------------------------------------------
|
225 |
|
|
-- To internal
|
226 |
|
|
CYC_O_int: out std_logic;
|
227 |
|
|
STB_O_int: out std_logic;
|
228 |
|
|
ACK_I_int: in std_logic ;
|
229 |
|
|
DAT_I_int: in std_logic_vector(15 downto 0);
|
230 |
|
|
----------------------------------------------------------------------------------------------
|
231 |
|
|
-- Internal
|
232 |
|
|
start_O: out std_logic;
|
233 |
|
|
continuous_O: out std_logic;
|
234 |
|
|
trigger_en_O: out std_losugic;
|
235 |
|
|
trigger_edge_O: out std_logic;
|
236 |
|
|
trigger_channel_O:out std_logic;
|
237 |
|
|
time_scale_O: out std_logic_vector(4 downto 0);
|
238 |
|
|
time_scale_en_O: out std_logic;
|
239 |
|
|
channels_sel_O: out std_logic_vector(1 downto 0);
|
240 |
|
|
buffer_size_O: out std_logic_vector(13 downto 0);
|
241 |
|
|
trigger_level_O: out std_logic_vector(9 downto 0);
|
242 |
|
|
trigger_offset_O: out std_logic_vector(14 downto 0);
|
243 |
|
|
|
244 |
|
|
error_number_I: in std_logic_vector (2 downto 0);
|
245 |
|
|
data_channel_I: in std_logic;
|
246 |
|
|
running_I: in std_logic;
|
247 |
|
|
error_flag_I: in std_logic;
|
248 |
|
|
|
249 |
|
|
stop_O: out std_logic
|
250 |
|
|
);
|
251 |
|
|
end component ctrl_address_assignments;
|
252 |
|
|
|
253 |
|
|
|
254 |
|
|
end package ctrl_pkg;
|
255 |
|
|
|