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 31

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

powered by: WebSVN 2.1.0

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