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

Subversion Repositories modular_oscilloscope

[/] [modular_oscilloscope/] [trunk/] [hdl/] [ctrl/] [output_manager.vhd] - Blame information for rev 33

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 28 budinero
-------------------------------------------------------------------------------------------------100
2
--| Modular Oscilloscope
3
--| UNSL - Argentine
4
--|
5
--| File: output_manager.vhd
6 33 budinero
--| Version: 0.31
7 28 budinero
--| Tested in: Actel A3PE1500
8
--|-------------------------------------------------------------------------------------------------
9
--| Description:
10
--|   CONTROL - Output manager
11
--|   This is a pseudo buffer, wich reads a memory incrementaly under certain parameters.
12
--|   
13
--|-------------------------------------------------------------------------------------------------
14
--| File history:
15
--|   0.1   | jun-2009 | First testing
16
--|   0.2   | jul-2009 | Two levels internal buffer
17
--|   0.3   | jul-2009 | One level internal buffer and only one clock
18 33 budinero
--|   0.31  | jul-2009 | Internal WE signals
19 28 budinero
----------------------------------------------------------------------------------------------------
20 33 budinero
--| Copyright © 2009, Facundo Aguilera.
21 28 budinero
--|
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
----------------------------------------------------------------------------------------------------
25
 
26 33 budinero
 
27
--==================================================================================================
28 28 budinero
-- TODO
29 33 budinero
-- · Spped up address_counter (with Actel SmartGen).
30
--==================================================================================================
31 28 budinero
 
32
 
33
library ieee;
34
use ieee.std_logic_1164.all;
35
use IEEE.STD_LOGIC_UNSIGNED.ALL;
36
use IEEE.NUMERIC_STD.ALL;
37
 
38
 
39
 
40
----------------------------------------------------------------------------------------------------
41
----------------------------------------------------------------------------------------------------
42
entity output_manager is
43
  generic(
44 33 budinero
    MEM_ADD_WIDTH: integer :=  14
45 28 budinero
  );
46
  port(
47
    ------------------------------------------------------------------------------------------------
48
    -- MASTER (to memory) 
49
    DAT_I_mem: in std_logic_vector (15 downto 0);
50
    --DAT_O_mem: out std_logic_vector (15 downto 0);
51
    ADR_O_mem: out std_logic_vector (MEM_ADD_WIDTH - 1  downto 0);
52
    CYC_O_mem: out std_logic;
53
    STB_O_mem: out std_logic;
54
    ACK_I_mem: in std_logic ;
55
    WE_O_mem:  out std_logic;
56
 
57
    ------------------------------------------------------------------------------------------------
58
    -- SLAVE (to I/O ports) 
59
    --DAT_I_port: in std_logic_vector (15 downto 0);
60
    DAT_O_port: out std_logic_vector (15 downto 0);
61
    --ADR_I_port: in std_logic_vector (7 downto 0); 
62
    CYC_I_port: in std_logic;
63
    STB_I_port: in std_logic;
64
    ACK_O_port: out std_logic ;
65
    WE_I_port:  in std_logic;
66
 
67
 
68
    ------------------------------------------------------------------------------------------------
69
    -- Common signals 
70
    RST_I: in std_logic;
71
    CLK_I: in std_logic;
72
 
73
    ------------------------------------------------------------------------------------------------
74
    -- Internal
75
    -- reset counter to initial address, or load it
76
    load:             in std_logic;
77
    -- start count from the actual address ('0' means pause, '1' means continue)
78
    enable:           in std_logic;
79
    -- buffer starts and ends here 
80
    initial_address:  in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
81
    -- when the buffer arrives here, address is changed to 0  (buffer size)
82
    final_address:    in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
83
    -- address wich is being writed by control
84 33 budinero
    stop_address:     in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
85 28 budinero
    -- it is set when communication ends and remains until next restart or actual address change
86
    finish:           out std_logic
87
 
88
 
89
        );
90
end entity output_manager;
91
 
92
----------------------------------------------------------------------------------------------------
93
----------------------------------------------------------------------------------------------------
94
architecture ARCH11 of output_manager is
95
 
96 33 budinero
 
97 28 budinero
 
98 33 budinero
 
99 28 budinero
  type DataStatusType is (
100
          RESET,
101
          INIT,     -- when restartet
102
          READY,     -- data available to be read
103
          READ      -- data was read from port, read next from memory 
104
          );
105
 
106
  signal data_status: DataStatusType; -- comunicates status between both ports
107
 
108
  signal address_counter: std_logic_vector(MEM_ADD_WIDTH - 1  downto 0);
109
  signal data: std_logic_vector(15 downto 0);
110
  signal enable_read: std_logic;
111
  signal s_finish: std_logic;
112
 
113
 
114
begin
115
 
116
  --------------------------------------------------------------------------------------------------
117
  -- Data status resolution 
118
 
119
  P_status: process(CLK_I, RST_I, load, WE_I_port)
120
  begin
121
 
122
    if (CLK_I'event and CLK_I = '1') then
123
      if RST_I = '1' or load = '1' then
124
        data_status <= RESET;
125
      else
126
        case data_status is
127
        when RESET =>
128
 
129
          data_status <= INIT;
130
 
131
        when INIT =>
132
 
133
          if ACK_I_mem = '1' and enable_read = '1' then
134
            data_status <= READY;
135
          end if;
136
 
137
 
138
        when READ =>
139
 
140
          if ACK_I_mem = '1' and enable_read = '1' and (STB_I_port /= '1' or CYC_I_port /= '1' or
141
          WE_I_port /= '0')
142
          then
143
            data_status <= READY;
144
          end if;
145
          -- STB_I_port /= '1' or CYC_I_port /= '1': forwarding
146
 
147
        when others => -- (when READY)
148
 
149
          if STB_I_port = '1' and CYC_I_port = '1' and WE_I_port = '0' then
150
            data_status <= READ;
151
          end if;
152
 
153
        end case;
154
      end if;
155
    end if;
156
 
157
  end process;
158
 
159
 
160
  --------------------------------------------------------------------------------------------------
161
  -- Data read 
162
  ADR_O_mem <= address_counter;
163
  s_finish <= '1' when address_counter = initial_address and data_status /= INIT else
164
            '0';
165 33 budinero
  enable_read <= '1' when  enable = '1' and s_finish = '0' and address_counter /= stop_address
166
            else '0';
167
 
168 28 budinero
  finish <= s_finish;
169
  WE_O_mem <= '0' ;
170
 
171 33 budinero
 
172
 
173 28 budinero
  P_read: process(CLK_I, data_status, initial_address, address_counter, data, enable_read,
174
  ACK_I_mem, WE_I_port)
175
  begin
176
 
177
 
178
    -- Clocked signals
179
    if (CLK_I'event and CLK_I = '1') then
180
      case data_status is
181
 
182
      when RESET =>
183 33 budinero
 
184 28 budinero
        data <= (others => '0');
185
        address_counter <= initial_address;
186
 
187
      when READY =>
188
 
189
        if enable_read = '1' and ACK_I_mem = '1' and  CYC_I_port = '1' and STB_I_port = '1' then
190
        -- (forwarding)
191
          data <= DAT_I_mem;
192
          if address_counter < final_address then
193
            address_counter <= address_counter + 1;
194
          else
195
            address_counter <= (others => '0');
196
          end if;
197
        else
198
          data <= data;
199
          address_counter <= address_counter;
200
        end if;
201
 
202
      when others => -- (when INIT or READ)
203
 
204
        if enable_read = '1' and ACK_I_mem = '1' then
205
          data <= DAT_I_mem;
206
          if address_counter < final_address then
207
            address_counter <= address_counter + 1;
208
          else
209
            address_counter <= (others => '0');
210
          end if;
211
        end if;
212
 
213
      end case;
214
     end if;
215
 
216
    -- Cominational signals
217
 
218
    case data_status is
219
    when RESET =>
220
 
221
      STB_O_mem <= '0';
222
      CYC_O_mem <= '0';
223
 
224
    when READY =>
225
 
226
      if enable_read = '1' and CYC_I_port = '1' and STB_I_port = '1' and WE_I_port = '0' then
227
      -- (forwarding)
228
        STB_O_mem <= '1';
229
        CYC_O_mem <= '1';
230
      else
231
        STB_O_mem <= '0';
232
        CYC_O_mem <= '0';
233
      end if;
234
 
235
    when others => -- (when INIT or READ)
236
 
237
      if enable_read = '1' then
238
        STB_O_mem <= '1';
239
        CYC_O_mem <= '1';
240
      else
241
        STB_O_mem <= '0';
242
        CYC_O_mem <= '0';
243
      end if;
244
 
245
    end case;
246
 
247
 
248
  end process;
249
 
250
 
251
 
252
  --------------------------------------------------------------------------------------------------
253
  -- Read from port interface
254
  ACK_O_port <= '1' when  (CYC_I_port = '1' and STB_I_port = '1' and WE_I_port = '0') and
255
                          (data_status = READY or
256
                          (data_status = READ and ACK_I_mem = '1' and enable_read = '1' )) else
257
                '0';
258
                -- data_status = READ and ACK_I_mem = '1' and enable_read = '1': forwarding
259
 
260
  DAT_O_port <= data;
261
 
262
 
263
 
264
 
265
end architecture;

powered by: WebSVN 2.1.0

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