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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_0_5_beta/] [rtl/] [vhdl/] [dmem_ctrl.vhd] - Blame information for rev 292

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 arniml
-------------------------------------------------------------------------------
2
--
3
-- The Data Memory control unit.
4
-- All accesses to the Data Memory are managed here.
5
--
6 77 arniml
-- $Id: dmem_ctrl.vhd,v 1.3 2004-04-24 23:44:25 arniml Exp $
7 4 arniml
--
8
-- Copyright (c) 2004, Arnim Laeuger (arniml@opencores.org)
9
--
10
-- All rights reserved
11
--
12
-- Redistribution and use in source and synthezised forms, with or without
13
-- modification, are permitted provided that the following conditions are met:
14
--
15
-- Redistributions of source code must retain the above copyright notice,
16
-- this list of conditions and the following disclaimer.
17
--
18
-- Redistributions in synthesized form must reproduce the above copyright
19
-- notice, this list of conditions and the following disclaimer in the
20
-- documentation and/or other materials provided with the distribution.
21
--
22
-- Neither the name of the author nor the names of other contributors may
23
-- be used to endorse or promote products derived from this software without
24
-- specific prior written permission.
25
--
26
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
28
-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29
-- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
30
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36
-- POSSIBILITY OF SUCH DAMAGE.
37
--
38
-- Please report bugs to the author, but before you do so, please
39
-- make sure that this is not a derivative work and that
40
-- you have the latest version of this file.
41
--
42
-- The latest version of this file can be found at:
43
--      http://www.opencores.org/cvsweb.shtml/t48/
44
--
45
-------------------------------------------------------------------------------
46
 
47
library ieee;
48
use ieee.std_logic_1164.all;
49
 
50
use work.t48_pack.dmem_addr_t;
51
use work.t48_pack.word_t;
52
use work.dmem_ctrl_pack.dmem_addr_ident_t;
53
 
54
entity dmem_ctrl is
55
 
56
  port (
57
    -- Global Interface -------------------------------------------------------
58
    clk_i             : in  std_logic;
59
    res_i             : in  std_logic;
60
    en_clk_i          : in  boolean;
61
    -- Control Interface ------------------------------------------------------
62
    data_i            : in  word_t;
63
    write_dmem_addr_i : in  boolean;
64
    write_dmem_i      : in  boolean;
65
    read_dmem_i       : in  boolean;
66
    addr_type_i       : in  dmem_addr_ident_t;
67
    bank_select_i     : in  std_logic;
68
    data_o            : out word_t;
69
    -- Data Memory Interface --------------------------------------------------
70
    dmem_data_i       : in  word_t;
71
    dmem_addr_o       : out dmem_addr_t;
72
    dmem_we_o         : out std_logic;
73
    dmem_data_o       : out word_t
74
  );
75
 
76
end dmem_ctrl;
77
 
78
 
79
library ieee;
80 77 arniml
use ieee.numeric_std.all;
81 4 arniml
 
82
use work.t48_pack.clk_active_c;
83
use work.t48_pack.res_active_c;
84
use work.t48_pack.bus_idle_level_c;
85
use work.t48_pack.to_stdLogic;
86
 
87
use work.dmem_ctrl_pack.all;
88
 
89
architecture rtl of dmem_ctrl is
90
 
91
  signal dmem_addr_s,
92
         dmem_addr_q  : dmem_addr_t;
93
begin
94
 
95
  -----------------------------------------------------------------------------
96
  -- Process addr_decode
97
  --
98
  -- Purpose:
99
  --   Decode/multiplex the address information for the Data Memory.
100
  --
101
  addr_decode: process (data_i,
102
                        addr_type_i,
103
                        bank_select_i,
104 65 arniml
                        dmem_addr_q)
105 4 arniml
    variable stack_addr_v : unsigned(5 downto 0);
106
  begin
107
    -- default assignment
108 77 arniml
    dmem_addr_s  <= dmem_addr_q;
109
    stack_addr_v := (others => '0');
110 4 arniml
 
111
    case addr_type_i is
112
      when DM_PLAIN =>
113
        dmem_addr_s <= data_i;
114
 
115
      when DM_REG =>
116
        dmem_addr_s               <= (others => '0');
117
        dmem_addr_s(2 downto 0)   <= data_i(2 downto 0);
118
        -- implement bank switching
119
        if bank_select_i = '1' then
120
          -- dmem address 24 - 31: access proper set
121
          dmem_addr_s(4 downto 3) <= "11";
122
        end if;
123
 
124
      when DM_STACK =>
125
        -- build address from stack pointer
126
        stack_addr_v(3 downto 1)  := unsigned(data_i(2 downto 0));
127
        -- dmem address 8 - 23
128
        stack_addr_v              := stack_addr_v + 8;
129
 
130
        dmem_addr_s <= (others => '0');
131 77 arniml
        dmem_addr_s(5 downto 0) <= std_logic_vector(stack_addr_v);
132 4 arniml
 
133
      when DM_STACK_HIGH =>
134
        dmem_addr_s(0) <= '1';
135
 
136
      when others =>
137
        -- do nothing
138
 
139
        -- pragma translate_off
140
        assert false
141
          report "Unknown address type identification for Data Memory controller!"
142
          severity error;
143
        -- pragma translate_on
144
 
145
    end case;
146
 
147
  end process addr_decode;
148
  --
149
  -----------------------------------------------------------------------------
150
 
151
 
152
  -----------------------------------------------------------------------------
153
  -- Process dmem_addr_reg
154
  --
155
  -- Purpose:
156
  --   Implements the Data Memory Address Register.
157
  --   This register is necessary to hold the address during a write operation
158
  --   as we cannot hold the address in the input register of the
159
  --   synchronous RAM (no clock suppression/gating).
160
  --
161
  dmem_addr_reg: process (res_i, clk_i)
162
  begin
163
    if res_i = res_active_c then
164
      dmem_addr_q <= (others => '0');
165
 
166
    elsif clk_i'event and clk_i = clk_active_c then
167
      if en_clk_i then
168
 
169
        if write_dmem_addr_i then
170
          dmem_addr_q <= dmem_addr_s;
171
        end if;
172
 
173
      end if;
174
 
175
    end if;
176
 
177
  end process dmem_addr_reg;
178
  --
179
  -----------------------------------------------------------------------------
180
 
181
 
182
  -----------------------------------------------------------------------------
183
  -- Output mapping.
184
  -----------------------------------------------------------------------------
185
  dmem_addr_o <=   dmem_addr_s
186
                 when write_dmem_addr_i and en_clk_i else
187
                   dmem_addr_q;
188
 
189
  -- data from bus is fed through
190
  dmem_data_o <= data_i;
191
 
192
  -- data to bus is enabled upon read request
193
  data_o      <=   dmem_data_i
194
                 when read_dmem_i else
195
                   (others => bus_idle_level_c);
196
 
197
  -- write enable to Data Memory is fed through
198
  dmem_we_o   <= to_stdLogic(write_dmem_i);
199
 
200
end rtl;
201
 
202
 
203
-------------------------------------------------------------------------------
204
-- File History:
205
--
206
-- $Log: not supported by cvs2svn $
207 77 arniml
-- Revision 1.2  2004/04/18 18:58:29  arniml
208
-- clean up sensitivity list
209
--
210 65 arniml
-- Revision 1.1  2004/03/23 21:31:52  arniml
211
-- initial check-in
212 4 arniml
--
213 65 arniml
--
214 4 arniml
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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