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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_0_1_beta/] [rtl/] [vhdl/] [dmem_ctrl.vhd] - Blame information for rev 4

Go to most recent revision | 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
-- $Id: dmem_ctrl.vhd,v 1.1 2004-03-23 21:31:52 arniml Exp $
7
--
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
use ieee.std_logic_arith.all;
81
 
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
                        dmem_addr_q,
105
                        write_dmem_addr_i)
106
    variable stack_addr_v : unsigned(5 downto 0);
107
  begin
108
    -- default assignment
109
    dmem_addr_s <= dmem_addr_q;
110
 
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
        stack_addr_v              := (others => '0');
126
        -- build address from stack pointer
127
        stack_addr_v(3 downto 1)  := unsigned(data_i(2 downto 0));
128
        -- dmem address 8 - 23
129
        stack_addr_v              := stack_addr_v + 8;
130
 
131
        dmem_addr_s <= (others => '0');
132
        dmem_addr_s(5 downto 0) <= conv_std_logic_vector(stack_addr_v, 6);
133
 
134
      when DM_STACK_HIGH =>
135
        dmem_addr_s(0) <= '1';
136
 
137
      when others =>
138
        -- do nothing
139
 
140
        -- pragma translate_off
141
        assert false
142
          report "Unknown address type identification for Data Memory controller!"
143
          severity error;
144
        -- pragma translate_on
145
 
146
    end case;
147
 
148
  end process addr_decode;
149
  --
150
  -----------------------------------------------------------------------------
151
 
152
 
153
  -----------------------------------------------------------------------------
154
  -- Process dmem_addr_reg
155
  --
156
  -- Purpose:
157
  --   Implements the Data Memory Address Register.
158
  --   This register is necessary to hold the address during a write operation
159
  --   as we cannot hold the address in the input register of the
160
  --   synchronous RAM (no clock suppression/gating).
161
  --
162
  dmem_addr_reg: process (res_i, clk_i)
163
  begin
164
    if res_i = res_active_c then
165
      dmem_addr_q <= (others => '0');
166
 
167
    elsif clk_i'event and clk_i = clk_active_c then
168
      if en_clk_i then
169
 
170
        if write_dmem_addr_i then
171
          dmem_addr_q <= dmem_addr_s;
172
        end if;
173
 
174
      end if;
175
 
176
    end if;
177
 
178
  end process dmem_addr_reg;
179
  --
180
  -----------------------------------------------------------------------------
181
 
182
 
183
  -----------------------------------------------------------------------------
184
  -- Output mapping.
185
  -----------------------------------------------------------------------------
186
  dmem_addr_o <=   dmem_addr_s
187
                 when write_dmem_addr_i and en_clk_i else
188
                   dmem_addr_q;
189
 
190
  -- data from bus is fed through
191
  dmem_data_o <= data_i;
192
 
193
  -- data to bus is enabled upon read request
194
  data_o      <=   dmem_data_i
195
                 when read_dmem_i else
196
                   (others => bus_idle_level_c);
197
 
198
  -- write enable to Data Memory is fed through
199
  dmem_we_o   <= to_stdLogic(write_dmem_i);
200
 
201
end rtl;
202
 
203
 
204
-------------------------------------------------------------------------------
205
-- File History:
206
--
207
-- $Log: not supported by cvs2svn $
208
--
209
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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