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 37

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 37 budinero
--| File: ctrl_memory_writer.vhd
6 32 budinero
--| 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 37 budinero
entity ctrl_memory_writer is
40 32 budinero
  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 37 budinero
    -- reset memory address to 0
71 32 budinero
    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
    final_address_I:    in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
75
    -- it is set when communication ends and remains until next restart or actual address change
76
    finished_O:         out std_logic;
77 37 budinero
    -- when counter finishes, restart
78 32 budinero
    continuous_I:       in  std_logic;
79
  );
80 37 budinero
end entity ctrl_memory_writer;
81 32 budinero
 
82
 
83
----------------------------------------------------------------------------------------------------
84
----------------------------------------------------------------------------------------------------
85 37 budinero
architecture ARCH11 of ctrl_output_manager is
86 32 budinero
 
87
  type DataStatusType is (
88
          INIT,
89
          WORKING
90
          );
91
 
92
  signal data_status: DataStatusType; -- comunicates status between both ports
93
 
94
 
95
  signal count: std_logic_vector(MEM_ADD_WIDTH-1  downto 0);
96
  signal enable_count:std_logic;
97
  signal reset_count: std_logic;
98
  signal data: std_logic_vector(15 downto 0);
99
 
100
  signal address_counter: std_logic_vector(MEM_ADD_WIDTH - 1  downto 0);
101
  signal s_finished, s_STB_adc, s_STB_mem: std_logic; -- previous to outputs
102
 
103
begin
104
  --------------------------------------------------------------------------------------------------
105 37 budinero
  -- Instances
106 32 budinero
  U_COUNTER0: generic_counter
107
  generic map(
108
    OUTPUT_WIDTH => MEM_ADD_WIDTH -- Output width for counter.
109
  )
110
  port map(
111
    clk_I => CLK_I,
112
    count_O => count,
113
    reset_I => reset_count,
114
    enable_I => enable_count
115
  );
116
 
117
 
118
  --------------------------------------------------------------------------------------------------
119
  -- Combinational
120
 
121
  -- counter
122
  s_finished <= '1' when count >= final_address_I;
123
  enable_count <= '1' when enable_I = '1' and
124
                           data_status = WORKING  and
125
                           s_STB_mem = '1' and
126
                           ACK_I_mem = '1' and
127
                           s_finished = '0'
128
                      else
129
                  '0';
130
  reset_count <= '1' when reset_I = '1' or (s_finished = '1' and continuous_I = '1') else
131
                 '0';
132
 
133
  -- outputs
134
  finished_O <= s_finished;
135
  STB_O_adc <= s_STB_adc;
136
  STB_O_mem <= s_STB_mem;
137
  DAT_O_mem <= data;
138
  ADR_O_mem <= count;
139
 
140
  --------------------------------------------------------------------------------------------------
141
  -- Clocked
142
 
143
 
144
  -- Lock interface when working
145
  P_cyc_signals: process (clk_I, enable_count, ACK_I_adc, ACK_I_mem)
146
  begin
147
    if CLK_I'event and CLK_I = '1' then
148 37 budinero
      if enable_I = '0' or reset_I = '1' then
149 32 budinero
        CYC_O_adc <= '0';   CYC_O_mem <= '0';
150
      else
151
        CYC_O_adc <= '1';  CYC_O_mem <= '1';
152
      end if;
153
    end if;
154
  end process;
155
 
156
 
157
 
158
 
159
  P_stb_signals: process (CLK_I, reset_I, data_status, s_STB_adc, s_STB_mem, ACK_I_adc, ACK_I_mem)
160
  begin
161
 
162
    if CLK_I'event and CLK_I = '1' then
163
      if reset_I = '1' then
164
        data_status <= INIT;
165
        s_STB_adc <= '0';
166
        s_STB_mem <= '0';
167
        data <= (others => '0');
168
      elsif enable_I = '1' then
169
        if data_status = INIT and s_STB_adc = '0' or s_STB_mem = '0' then
170
          -- this state is only necessary when there are adc convertions in every clock
171
          -- (for the first convertion)
172
          s_STB_adc <= '1';
173
          s_STB_mem <= '1';
174
        else
175
          data_status <= WORKING;
176
 
177
          if s_STB_adc = '1' and ACK_I_adc = '1' then
178
            s_STB_mem <= '1'; -- strobe when adc ack
179
            data <= DAT_I_adc; -- save data
180
          elsif s_STB_mem = '1' and ACK_I_mem = '1' then
181
            s_STB_mem <= '0';
182
          end if;
183
 
184
          if s_STB_mem = '1' and ACK_I_mem = '1' then
185
            s_STB_adc <= '1'; -- strobe when mem ack
186
          elsif s_STB_adc = '1' and ACK_I_adc = '1' then
187
            s_STB_adc <= '0';
188
          end if;
189
 
190
        end if;
191
      else
192
        s_STB_adc <= '0';
193
        s_STB_mem <= '0';
194
      end if;
195
    end if;
196
 
197
  end process;
198
 
199
 
200
end architecture;

powered by: WebSVN 2.1.0

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