OpenCores
URL https://opencores.org/ocsvn/modular_oscilloscope/modular_oscilloscope/trunk

Subversion Repositories modular_oscilloscope

[/] [modular_oscilloscope/] [trunk/] [hdl/] [ctrl/] [address_allocation.vhd] - Blame information for rev 57

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.