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

Subversion Repositories modular_oscilloscope

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

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

Line No. Rev Author Line
1 32 budinero
-------------------------------------------------------------------------------------------------100
2
--| Modular Oscilloscope
3
--| UNSL - Argentine
4
--|
5
--| File: memory_writer.vhd
6
--| Version: 0.1
7
--| Tested in: Actel A3PE1500
8
--|-------------------------------------------------------------------------------------------------
9
--| Description:
10
--|   CONTROL - Memory writer
11
--|   Read data and write it in a memory (it's a simple wishbone bridge)
12
--|   
13
--|-------------------------------------------------------------------------------------------------
14
--| File history:
15
--|   0.1   | jul-2009 | First release
16
----------------------------------------------------------------------------------------------------
17 33 budinero
--| Copyright © 2009, Facundo Aguilera.
18 32 budinero
--|
19
--| This VHDL design file is an open design; you can redistribute it and/or
20
--| modify it and/or implement it after contacting the author.
21
----------------------------------------------------------------------------------------------------
22
 
23
 
24
--==================================================================================================
25
-- TODO
26
-- · ...
27
--==================================================================================================
28
 
29
 
30
library ieee;
31
use ieee.std_logic_1164.all;
32
use IEEE.STD_LOGIC_UNSIGNED.ALL;
33
use IEEE.NUMERIC_STD.ALL;
34
 
35
 
36
 
37
----------------------------------------------------------------------------------------------------
38
----------------------------------------------------------------------------------------------------
39
entity memory_writer is
40
  generic(
41
    MEM_ADD_WIDTH: integer :=  14
42
  );
43
  port(
44
    ------------------------------------------------------------------------------------------------
45
    -- to memory
46
    DAT_O_mem: out std_logic_vector (15 downto 0);
47
    ADR_O_mem: out std_logic_vector (MEM_ADD_WIDTH - 1  downto 0);
48
    CYC_O_mem: out std_logic;
49
    STB_O_mem: out std_logic;
50
    ACK_I_mem: in std_logic ;
51
    WE_O_mem:  out std_logic;
52
 
53
    ------------------------------------------------------------------------------------------------
54
    -- to acquistion module
55
    DAT_I_adc: in std_logic_vector (15 downto 0);
56
    -- Using an address generator, commented
57
    -- ADR_O_adc: out std_logic_vector (ADC_ADD_WIDTH - 1  downto 0); 
58
    CYC_O_adc: out std_logic;
59
    STB_O_adc: out std_logic;
60
    ACK_I_adc: in std_logic ;
61
    WE_O_adc:  out std_logic;
62
 
63
    ------------------------------------------------------------------------------------------------
64
    -- Common signals 
65
    RST_I: in std_logic;
66
    CLK_I: in std_logic;
67
 
68
    ------------------------------------------------------------------------------------------------
69
    -- Internal
70
    -- reset counter(memory address) to 0
71
    reset_I:            in std_logic;
72
    -- read in clk edge from the actual address ('0' means pause, '1' means continue)
73
    enable_I:           in std_logic;
74
    -- buffer starts and ends here 
75
    -- when the buffer arrives here, address is changed to 0  (buffer size)
76
    final_address_I:    in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
77
    -- address wich is being writed by control
78
    -- stop_address:     in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
79
    -- it is set when communication ends and remains until next restart or actual address change
80
    finished_O:         out std_logic;
81
    -- When counter finishes, restart
82
    continuous_I:       in  std_logic;
83
 
84
 
85
  );
86
end entity memory_writer;
87
 
88
 
89
 
90
 
91
----------------------------------------------------------------------------------------------------
92
----------------------------------------------------------------------------------------------------
93
architecture ARCH11 of output_manager is
94
 
95
  type DataStatusType is (
96
          INIT,
97
          WORKING
98
          );
99
 
100
  signal data_status: DataStatusType; -- comunicates status between both ports
101
 
102
 
103
  signal count: std_logic_vector(MEM_ADD_WIDTH-1  downto 0);
104
  signal enable_count:std_logic;
105
  signal reset_count: std_logic;
106
  signal data: std_logic_vector(15 downto 0);
107
 
108
  signal address_counter: std_logic_vector(MEM_ADD_WIDTH - 1  downto 0);
109
  signal s_finished, s_STB_adc, s_STB_mem: std_logic; -- previous to outputs
110
 
111
begin
112
  --------------------------------------------------------------------------------------------------
113
  -- Instantiations
114
  U_COUNTER0: generic_counter
115
  generic map(
116
    OUTPUT_WIDTH => MEM_ADD_WIDTH -- Output width for counter.
117
  )
118
  port map(
119
    clk_I => CLK_I,
120
    count_O => count,
121
    reset_I => reset_count,
122
    enable_I => enable_count
123
  );
124
 
125
 
126
  --------------------------------------------------------------------------------------------------
127
  -- Combinational
128
 
129
  -- counter
130
  s_finished <= '1' when count >= final_address_I;
131
  enable_count <= '1' when enable_I = '1' and
132
                           data_status = WORKING  and
133
                           s_STB_mem = '1' and
134
                           ACK_I_mem = '1' and
135
                           s_finished = '0'
136
                      else
137
                  '0';
138
  reset_count <= '1' when reset_I = '1' or (s_finished = '1' and continuous_I = '1') else
139
                 '0';
140
 
141
  -- outputs
142
  finished_O <= s_finished;
143
  STB_O_adc <= s_STB_adc;
144
  STB_O_mem <= s_STB_mem;
145
  DAT_O_mem <= data;
146
  ADR_O_mem <= count;
147
 
148
  --------------------------------------------------------------------------------------------------
149
  -- Clocked
150
 
151
 
152
  -- Lock interface when working
153
  P_cyc_signals: process (clk_I, enable_count, ACK_I_adc, ACK_I_mem)
154
  begin
155
    if CLK_I'event and CLK_I = '1' then
156
      if enable_I /= '1' or reset_I = '1' then
157
        CYC_O_adc <= '0';   CYC_O_mem <= '0';
158
      else
159
        CYC_O_adc <= '1';  CYC_O_mem <= '1';
160
      end if;
161
    end if;
162
  end process;
163
 
164
 
165
 
166
 
167
  P_stb_signals: process (CLK_I, reset_I, data_status, s_STB_adc, s_STB_mem, ACK_I_adc, ACK_I_mem)
168
  begin
169
 
170
    if CLK_I'event and CLK_I = '1' then
171
      if reset_I = '1' then
172
        data_status <= INIT;
173
        s_STB_adc <= '0';
174
        s_STB_mem <= '0';
175
        data <= (others => '0');
176
      elsif enable_I = '1' then
177
        if data_status = INIT and s_STB_adc = '0' or s_STB_mem = '0' then
178
          -- this state is only necessary when there are adc convertions in every clock
179
          -- (for the first convertion)
180
          s_STB_adc <= '1';
181
          s_STB_mem <= '1';
182
        else
183
          data_status <= WORKING;
184
 
185
          if s_STB_adc = '1' and ACK_I_adc = '1' then
186
            s_STB_mem <= '1'; -- strobe when adc ack
187
            data <= DAT_I_adc; -- save data
188
          elsif s_STB_mem = '1' and ACK_I_mem = '1' then
189
            s_STB_mem <= '0';
190
          end if;
191
 
192
          if s_STB_mem = '1' and ACK_I_mem = '1' then
193
            s_STB_adc <= '1'; -- strobe when mem ack
194
          elsif s_STB_adc = '1' and ACK_I_adc = '1' then
195
            s_STB_adc <= '0';
196
          end if;
197
 
198
        end if;
199
      else
200
        s_STB_adc <= '0';
201
        s_STB_mem <= '0';
202
      end if;
203
    end if;
204
 
205
  end process;
206
 
207
 
208
end architecture;

powered by: WebSVN 2.1.0

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