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 49

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
----------------------------------------------------------------------------------------------------
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
  ACK_O_port <= CYC_I_port and STB_I_port and (not(ADR_I_port(3)) or ACK_I_int or not(running_I));
194
 
195
 
196
  --------------------------------------------------------------------------------------------------
197
  -- Internal wishbone allocation
198
  STB_O_int <= STB_I_port and ADR_I_port(3);
199
  CYC_O_int <= CYC_I_port and ADR_I_port(3);
200
 
201
  --------------------------------------------------------------------------------------------------
202
  -- Stop signal
203
  stop_O <= CYC_I_port and STB_I_port and WE_I_port;
204
 
205
  --------------------------------------------------------------------------------------------------
206
  -- DAT_I 
207
  data <= DAT_I_int(9 downto 0);
208
  data_channel <= DAT_I_int(10);
209
 
210
 
211
  --------------------------------------------------------------------------------------------------
212
  -- Writing allocation
213
  P_wr: process(CLK_I, CYC_I_port, DAT_I_port, ADR_I_port, STB_I_port, WE_I_port, RST_I)
214
  begin
215
  if CLK_I'event and CLK_I = '1' then
216
    -- Defaul values
217
    if RST_I = '1' then
218
      start_R <= '0';
219
      continuous_R <= '0';
220
      trigger_on_R <= '0';
221
      trigger_edge_R <= '0';
222
      time_scale_en_R <= '0';
223
      time_scale_R <= (others => '0');
224
      channels_sel_R <= (others => '0');
225
      buffer_size_R <= (others => '0');
226
      trigger_level_R <= (others => '0');
227
      trigger_offset_R <= (others => '0');
228
 
229
    -- Assignments
230
    elsif CYC_I_port = '1' and STB_I_port = '1' and WE_I_port = '1' and ADR_I_port(3) = '0' then
231
 
232
      case ADR_I_port(2 downto 0) is
233
        when O"0" =>
234
          start_R <=           DAT_I_port(0);
235
          continuous_R <=      DAT_I_port(1);
236
          trigger_on_R <=      DAT_I_port(2);
237
          trigger_edge_R <=    DAT_I_port(3);
238
          trigger_channel_R <= DAT_I_port(4 downto 4);
239
          time_scale_en_R <=   DAT_I_port(5);
240
          time_scale_R <=      DAT_I_port(10 downto 6);
241
 
242
        when O"1" =>
243
          channels_sel_R <=   DAT_I_port(1 downto 0);
244
 
245
        when O"2" =>
246
          buffer_size_R <=    DAT_I_port(13 downto 0);
247
 
248
        when O"3" =>
249
          trigger_level_R <=  DAT_I_port(9 downto 0);
250
 
251
        when O"4" =>
252
          trigger_offset_R <= DAT_I_port(14 downto 0);
253
 
254
        when O"5" =>
255
          adc_conf_R   <=     DAT_I_port;
256
          write_in_adc_R <=     '1';
257
 
258
        when others =>
259
 
260
      end case;
261
 
262
    -- Auto restart signals 
263
    else
264
      start_R <= '0';
265
      write_in_adc_R <= '0';
266
 
267
    end if;
268
  end if;
269
 
270
  end process;
271
 
272
  start_O <= start_R;
273
  continuous_O <= continuous_R;
274
  trigger_en_O <= trigger_on_R;
275
  trigger_edge_O <= trigger_edge_R;
276
  time_scale_en_O <= time_scale_en_R;
277
  time_scale_O <= time_scale_R;
278
  channels_sel_O <= channels_sel_R;
279
  buffer_size_O <= buffer_size_R;
280
  trigger_level_O <= trigger_level_R;
281
  trigger_offset_O <= trigger_offset_R;
282
  trigger_channel_O <= trigger_channel_R;
283
  write_in_adc_O <= write_in_adc_R;
284
  adc_conf_O <= adc_conf_R;
285
 
286
 
287
end architecture;

powered by: WebSVN 2.1.0

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