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 56

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

powered by: WebSVN 2.1.0

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