1 |
49 |
budinero |
-------------------------------------------------------------------------------------------------100
|
2 |
|
|
--| Modular Oscilloscope
|
3 |
|
|
--| UNSL - Argentine
|
4 |
|
|
--|
|
5 |
|
|
--| File: ctrl_address_allocation.vhd
|
6 |
|
|
--| Version: 0.1
|
7 |
|
|
--| Tested in: Actel A3PE1500
|
8 |
|
|
--| Board: RVI Prototype Board + LP Data Conversion Daughter Board
|
9 |
|
|
--|-------------------------------------------------------------------------------------------------
|
10 |
|
|
--| Description:
|
11 |
|
|
--| CONTROL - Address allocations
|
12 |
|
|
--|
|
13 |
|
|
--|
|
14 |
|
|
--|-------------------------------------------------------------------------------------------------
|
15 |
|
|
--| File history:
|
16 |
|
|
--| 0.1 | jul-2009 | First testing
|
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 |
|
|
-- TO DO
|
27 |
|
|
-- · Finish ADC conf write
|
28 |
|
|
--==================================================================================================
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
--==================================================================================================
|
32 |
|
|
-- Allocations
|
33 |
|
|
-- ADR NAME MODE [ 15| 14| 13| 12| 11| 10| 9| 8|
|
34 |
|
|
-- 7| 6| 5| 4| 3| 2| 1| 0] bits
|
35 |
|
|
--
|
36 |
|
|
-- 00 RunConf_R RW [ | | | | |TScal04|TScal03|TScal02|
|
37 |
|
|
-- TScal01|TScal00|TScalEn| TrCh| TrEdg| TrOn| Cont| Start]
|
38 |
|
|
--
|
39 |
|
|
-- 01 Channels_R RW [ | | | | | | | |
|
40 |
|
|
-- | | | | | | RCh01| RCh00]
|
41 |
|
|
--
|
42 |
|
|
-- 02 BuffSize_R RW [ | |BuffS13|BuffS12|BuffS11|BuffS10|BuffS09|BuffS08|
|
43 |
|
|
-- BuffS07|BuffS06|BuffS05|BuffS04|BuffS03|BuffS02|BuffS01|BuffS00]
|
44 |
|
|
--
|
45 |
|
|
-- 03 TrigLvl_R RW [ | | | | | |TrLvl09|TrLvl08|
|
46 |
|
|
-- TrLvl07|TrLvl06|TrLvl05|TrLvl04|TrLvl03|TrLvl02|TrLvl01|TrLvl00]
|
47 |
|
|
--
|
48 |
|
|
-- 04 TrigOff_R RW [ |TrOff14|TrOff13|TrOff12|TrOff11|TrOff10|TrOff09|TrOff08|
|
49 |
|
|
-- TrOff07|TrOff06|TrOff00|TrOff00|TrOff00|TrOff00|TrOff00|TrOff00]
|
50 |
|
|
--
|
51 |
|
|
-- 05 ADCConf RW [ | | | | ADCS|ADSleep| ADPSEn| ADPS08|
|
52 |
|
|
-- ADPS07| ADPS06| ADPS05| ADPS04| ADPS03| ADPS02| ADPS01| ADPS00]
|
53 |
|
|
--
|
54 |
|
|
-- 08 Data_O R [ErrFlag|RunFlag| | | | DCh00| Dat09| Dat08|
|
55 |
|
|
-- Dat07| Dat06| Dat05| Dat04| Dat03| Dat02| Dat01| Dat00]
|
56 |
|
|
--
|
57 |
|
|
-- 09 Error_O R [ | | | | | | | |
|
58 |
|
|
-- | | | | | ErrN02| ErrN01| ErrN00]
|
59 |
|
|
--
|
60 |
|
|
--
|
61 |
|
|
--
|
62 |
|
|
-- Description
|
63 |
|
|
--
|
64 |
|
|
--==================================================================================================
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
library ieee;
|
69 |
|
|
use ieee.std_logic_1164.all;
|
70 |
|
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
71 |
|
|
--use IEEE.NUMERIC_STD.ALL;
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
----------------------------------------------------------------------------------------------------
|
76 |
|
|
----------------------------------------------------------------------------------------------------
|
77 |
|
|
entity ctrl_address_allocation is
|
78 |
|
|
-- generic(
|
79 |
|
|
-- MEM_ADD_WIDTH: integer := 14
|
80 |
|
|
-- );
|
81 |
|
|
port(
|
82 |
|
|
------------------------------------------------------------------------------------------------
|
83 |
|
|
-- From port
|
84 |
|
|
DAT_I_port: in std_logic_vector (15 downto 0);
|
85 |
|
|
DAT_O_port: out std_logic_vector (15 downto 0);
|
86 |
|
|
ADR_I_port: in std_logic_vector (3 downto 0);
|
87 |
|
|
CYC_I_port: in std_logic;
|
88 |
|
|
STB_I_port: in std_logic;
|
89 |
|
|
ACK_O_port: out std_logic ;
|
90 |
|
|
WE_I_port: in std_logic;
|
91 |
|
|
RST_I: in std_logic;
|
92 |
|
|
CLK_I: in std_logic;
|
93 |
|
|
|
94 |
|
|
------------------------------------------------------------------------------------------------
|
95 |
|
|
-- To internal
|
96 |
|
|
--DAT_I_int: in std_logic_vector (15 downto 0);
|
97 |
|
|
--DAT_O_int: out std_logic_vector (15 downto 0);
|
98 |
|
|
--ADR_O_int: in std_logic_vector (3 downto 0);
|
99 |
|
|
CYC_O_int: out std_logic;
|
100 |
|
|
STB_O_int: out std_logic;
|
101 |
|
|
ACK_I_int: in std_logic ;
|
102 |
|
|
DAT_I_int: in std_logic_vector(15 downto 0);
|
103 |
|
|
--DAT_O_int: out std_logic_vector(15 downto 0);
|
104 |
|
|
-- WE_O_int: out std_logic;
|
105 |
|
|
|
106 |
|
|
------------------------------------------------------------------------------------------------
|
107 |
|
|
-- Internal
|
108 |
|
|
start_O: out std_logic;
|
109 |
|
|
continuous_O: out std_logic;
|
110 |
|
|
trigger_en_O: out std_logic;
|
111 |
|
|
trigger_edge_O: out std_logic;
|
112 |
|
|
trigger_channel_O:out std_logic_vector(0 downto 0);
|
113 |
|
|
time_scale_O: out std_logic_vector(4 downto 0);
|
114 |
|
|
time_scale_en_O: out std_logic;
|
115 |
|
|
channels_sel_O: out std_logic_vector(1 downto 0);
|
116 |
|
|
buffer_size_O: out std_logic_vector(13 downto 0);
|
117 |
|
|
trigger_level_O: out std_logic_vector(9 downto 0);
|
118 |
|
|
trigger_offset_O: out std_logic_vector(14 downto 0);
|
119 |
|
|
|
120 |
|
|
adc_conf_O: out std_logic_vector(15 downto 0);
|
121 |
|
|
|
122 |
|
|
error_number_I: in std_logic_vector (2 downto 0);
|
123 |
|
|
--data_channel_I: in std_logic;
|
124 |
|
|
running_I: in std_logic;
|
125 |
|
|
error_flag_I: in std_logic;
|
126 |
|
|
|
127 |
|
|
write_in_adc_O: out std_logic;
|
128 |
|
|
stop_O: out std_logic
|
129 |
|
|
-- Stop the current conversion when reading
|
130 |
|
|
);
|
131 |
|
|
end entity ctrl_address_allocation;
|
132 |
|
|
|
133 |
|
|
----------------------------------------------------------------------------------------------------
|
134 |
|
|
----------------------------------------------------------------------------------------------------
|
135 |
|
|
architecture ARCH01 of ctrl_address_allocation is
|
136 |
|
|
|
137 |
|
|
-- Tipos
|
138 |
|
|
type data_array is array(0 to 9) of std_logic_vector(15 downto 0);
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
-- type arr is array(0 to 3) of std_logic_vector(15 downto 0);
|
142 |
|
|
--
|
143 |
|
|
-- signal arr_a : arr;
|
144 |
|
|
-- signal vec_0, vec_1, vec_2, vec_3 : std_logic vector(15 downto 0);
|
145 |
|
|
-- ....
|
146 |
|
|
-- arr_a(0) <= vec_0;
|
147 |
|
|
-- arr_a(1) <= vec_1;
|
148 |
|
|
signal o_selector: data_array;
|
149 |
|
|
|
150 |
|
|
signal start_R: std_logic;
|
151 |
|
|
signal continuous_R: std_logic;
|
152 |
|
|
signal trigger_on_R: std_logic;
|
153 |
|
|
signal trigger_edge_R: std_logic;
|
154 |
|
|
signal time_scale_en_R: std_logic;
|
155 |
|
|
signal time_scale_R: std_logic_vector(4 downto 0);
|
156 |
|
|
signal channels_sel_R: std_logic_vector(1 downto 0);
|
157 |
|
|
signal buffer_size_R: std_logic_vector(13 downto 0);
|
158 |
|
|
signal trigger_level_R: std_logic_vector(9 downto 0);
|
159 |
|
|
signal trigger_offset_R: std_logic_vector(14 downto 0);
|
160 |
|
|
signal trigger_channel_R: std_logic_vector(0 downto 0);
|
161 |
|
|
|
162 |
|
|
signal adc_conf_R: std_logic_vector(15 downto 0);
|
163 |
|
|
signal write_in_adc_R: std_logic;
|
164 |
|
|
|
165 |
|
|
signal data: std_logic_vector(9 downto 0);
|
166 |
|
|
signal data_channel: std_logic;
|
167 |
|
|
|
168 |
|
|
begin
|
169 |
|
|
|
170 |
|
|
|
171 |
|
|
--------------------------------------------------------------------------------------------------
|
172 |
|
|
-- Reading allocation
|
173 |
|
|
o_selector(0) <= (15 downto 11 => '0') & time_scale_R & time_scale_en_R & trigger_channel_R &
|
174 |
|
|
trigger_edge_R & trigger_on_R & continuous_R & start_R;
|
175 |
|
|
o_selector(1) <= (15 downto 2 => '0') & channels_sel_R;
|
176 |
|
|
o_selector(2) <= (15 downto 14 => '0') & buffer_size_R;
|
177 |
|
|
o_selector(3) <= (15 downto 10 => '0') & trigger_level_R;
|
178 |
|
|
o_selector(4) <= (15 downto 15 => '0') & trigger_offset_R;
|
179 |
|
|
o_selector(5) <= adc_conf_R;
|
180 |
|
|
o_selector(6) <= (others => '0');
|
181 |
|
|
o_selector(7) <= (others => '0');
|
182 |
|
|
|
183 |
|
|
|
184 |
|
|
o_selector(8) <= error_flag_I & running_I & (13 downto 11 => '0') & data_channel & data;
|
185 |
|
|
o_selector(9) <= (15 downto 3 => '0') & error_number_I;
|
186 |
|
|
|
187 |
|
|
DAT_O_port <= o_selector(conv_integer(ADR_I_port));
|
188 |
|
|
|
189 |
|
|
|
190 |
|
|
--------------------------------------------------------------------------------------------------
|
191 |
|
|
-- Read asignments
|
192 |
|
|
-- if reading registers, do ack, else use internal ack
|
193 |
54 |
budinero |
ACK_O_port <= (CYC_I_port and STB_I_port) and
|
194 |
|
|
((not(ADR_I_port(3)) or ACK_I_int or not(running_I)));
|
195 |
49 |
budinero |
|
196 |
|
|
|
197 |
|
|
--------------------------------------------------------------------------------------------------
|
198 |
|
|
-- Internal wishbone allocation
|
199 |
|
|
STB_O_int <= STB_I_port and ADR_I_port(3);
|
200 |
|
|
CYC_O_int <= CYC_I_port and ADR_I_port(3);
|
201 |
|
|
|
202 |
|
|
--------------------------------------------------------------------------------------------------
|
203 |
|
|
-- Stop signal
|
204 |
|
|
stop_O <= CYC_I_port and STB_I_port and WE_I_port;
|
205 |
|
|
|
206 |
|
|
--------------------------------------------------------------------------------------------------
|
207 |
|
|
-- DAT_I
|
208 |
|
|
data <= DAT_I_int(9 downto 0);
|
209 |
|
|
data_channel <= DAT_I_int(10);
|
210 |
|
|
|
211 |
|
|
|
212 |
|
|
--------------------------------------------------------------------------------------------------
|
213 |
|
|
-- Writing allocation
|
214 |
|
|
P_wr: process(CLK_I, CYC_I_port, DAT_I_port, ADR_I_port, STB_I_port, WE_I_port, RST_I)
|
215 |
|
|
begin
|
216 |
|
|
if CLK_I'event and CLK_I = '1' then
|
217 |
|
|
-- Defaul values
|
218 |
|
|
if RST_I = '1' then
|
219 |
|
|
start_R <= '0';
|
220 |
|
|
continuous_R <= '0';
|
221 |
|
|
trigger_on_R <= '0';
|
222 |
|
|
trigger_edge_R <= '0';
|
223 |
|
|
time_scale_en_R <= '0';
|
224 |
|
|
time_scale_R <= (others => '0');
|
225 |
|
|
channels_sel_R <= (others => '0');
|
226 |
|
|
buffer_size_R <= (others => '0');
|
227 |
|
|
trigger_level_R <= (others => '0');
|
228 |
|
|
trigger_offset_R <= (others => '0');
|
229 |
54 |
budinero |
trigger_channel_R <= (others => '0');
|
230 |
|
|
write_in_adc_R <= '0';
|
231 |
|
|
adc_conf_R <= (others => '0');
|
232 |
49 |
budinero |
|
233 |
54 |
budinero |
|
234 |
|
|
|
235 |
49 |
budinero |
-- Assignments
|
236 |
|
|
elsif CYC_I_port = '1' and STB_I_port = '1' and WE_I_port = '1' and ADR_I_port(3) = '0' then
|
237 |
|
|
|
238 |
|
|
case ADR_I_port(2 downto 0) is
|
239 |
|
|
when O"0" =>
|
240 |
|
|
start_R <= DAT_I_port(0);
|
241 |
|
|
continuous_R <= DAT_I_port(1);
|
242 |
|
|
trigger_on_R <= DAT_I_port(2);
|
243 |
|
|
trigger_edge_R <= DAT_I_port(3);
|
244 |
|
|
trigger_channel_R <= DAT_I_port(4 downto 4);
|
245 |
|
|
time_scale_en_R <= DAT_I_port(5);
|
246 |
|
|
time_scale_R <= DAT_I_port(10 downto 6);
|
247 |
|
|
|
248 |
|
|
when O"1" =>
|
249 |
|
|
channels_sel_R <= DAT_I_port(1 downto 0);
|
250 |
|
|
|
251 |
|
|
when O"2" =>
|
252 |
|
|
buffer_size_R <= DAT_I_port(13 downto 0);
|
253 |
|
|
|
254 |
|
|
when O"3" =>
|
255 |
|
|
trigger_level_R <= DAT_I_port(9 downto 0);
|
256 |
|
|
|
257 |
|
|
when O"4" =>
|
258 |
|
|
trigger_offset_R <= DAT_I_port(14 downto 0);
|
259 |
|
|
|
260 |
|
|
when O"5" =>
|
261 |
|
|
adc_conf_R <= DAT_I_port;
|
262 |
|
|
write_in_adc_R <= '1';
|
263 |
|
|
|
264 |
|
|
when others =>
|
265 |
|
|
|
266 |
|
|
end case;
|
267 |
|
|
|
268 |
|
|
-- Auto restart signals
|
269 |
|
|
else
|
270 |
|
|
start_R <= '0';
|
271 |
|
|
write_in_adc_R <= '0';
|
272 |
|
|
|
273 |
|
|
end if;
|
274 |
|
|
end if;
|
275 |
|
|
|
276 |
|
|
end process;
|
277 |
|
|
|
278 |
|
|
start_O <= start_R;
|
279 |
|
|
continuous_O <= continuous_R;
|
280 |
|
|
trigger_en_O <= trigger_on_R;
|
281 |
|
|
trigger_edge_O <= trigger_edge_R;
|
282 |
|
|
time_scale_en_O <= time_scale_en_R;
|
283 |
|
|
time_scale_O <= time_scale_R;
|
284 |
|
|
channels_sel_O <= channels_sel_R;
|
285 |
|
|
buffer_size_O <= buffer_size_R;
|
286 |
|
|
trigger_level_O <= trigger_level_R;
|
287 |
|
|
trigger_offset_O <= trigger_offset_R;
|
288 |
|
|
trigger_channel_O <= trigger_channel_R;
|
289 |
|
|
write_in_adc_O <= write_in_adc_R;
|
290 |
|
|
adc_conf_O <= adc_conf_R;
|
291 |
|
|
|
292 |
|
|
|
293 |
|
|
end architecture;
|