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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_0_4_beta/] [rtl/] [vhdl/] [pmem_ctrl.vhd] - Blame information for rev 303

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

Line No. Rev Author Line
1 4 arniml
-------------------------------------------------------------------------------
2
--
3
-- The Program Memory control unit.
4
-- All operations related to the Program Memory are managed here.
5
--
6 129 arniml
-- $Id: pmem_ctrl.vhd,v 1.3 2004-07-11 16:51:33 arniml Exp $
7 4 arniml
--
8 129 arniml
-- Copyright (c) 2004, Arnim Laeuger (arniml@opencores.org)
9
--
10 4 arniml
-- 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.pmem_addr_t;
51
use work.t48_pack.word_t;
52
use work.pmem_ctrl_pack.pmem_addr_ident_t;
53
 
54
entity pmem_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
    -- T48 Bus Interface ------------------------------------------------------
62
    data_i            : in  word_t;
63
    data_o            : out word_t;
64
    write_pcl_i       : in  boolean;
65
    read_pcl_i        : in  boolean;
66
    write_pch_i       : in  boolean;
67
    read_pch_i        : in  boolean;
68
    inc_pc_i          : in  boolean;
69
    write_pmem_addr_i : in  boolean;
70
    addr_type_i       : in  pmem_addr_ident_t;
71
    read_pmem_i       : in  boolean;
72
    -- Porgram Memroy Interface -----------------------------------------------
73
    pmem_addr_o       : out pmem_addr_t;
74
    pmem_data_i       : in  word_t
75
  );
76
 
77
end pmem_ctrl;
78
 
79
 
80
library ieee;
81 77 arniml
use ieee.numeric_std.all;
82 4 arniml
 
83
use work.pmem_ctrl_pack.all;
84
use work.t48_pack.res_active_c;
85
use work.t48_pack.clk_active_c;
86
use work.t48_pack.bus_idle_level_c;
87
use work.t48_pack.pmem_addr_width_c;
88
use work.t48_pack.dmem_addr_width_c;
89
use work.t48_pack.page_t;
90
 
91
architecture rtl of pmem_ctrl is
92
 
93
  -- the Program Counter
94
  signal program_counter_q : unsigned(pmem_addr_t'range);
95
 
96
  -- the Program Memory address
97
  signal pmem_addr_s,
98
         pmem_addr_q       : std_logic_vector(pmem_addr_t'range);
99
 
100
begin
101
 
102
  -----------------------------------------------------------------------------
103
  -- Process program_counter
104
  --
105
  -- Purpose:
106
  --   Implements the Program Counter.
107
  --
108
  program_counter: process (res_i, clk_i)
109
  begin
110
    if res_i = res_active_c then
111
      program_counter_q <= (others => '0');
112
      pmem_addr_q       <= (others => '0');
113
 
114
    elsif clk_i'event and clk_i = clk_active_c then
115
      if en_clk_i then
116
 
117
        -- parallel load mode
118
        if write_pcl_i then
119
          program_counter_q(data_i'range) <= UNSIGNED(data_i);
120
        elsif write_pch_i then
121
          program_counter_q(pmem_addr_width_c-1 downto data_i'high+1) <=
122
            UNSIGNED(data_i(pmem_addr_width_c - dmem_addr_width_c - 1 downto 0));
123
        elsif inc_pc_i then
124
          -- increment mode
125
          program_counter_q <= program_counter_q + 1;
126
        end if;
127
 
128
        -- set pmem address
129
        if write_pmem_addr_i then
130
          pmem_addr_q <= pmem_addr_s;
131
        end if;
132
 
133
      end if;
134
 
135
    end if;
136
 
137
  end process program_counter;
138
  --
139
  -----------------------------------------------------------------------------
140
 
141
 
142
  -----------------------------------------------------------------------------
143
  -- Process pmem_addr
144
  --
145
  -- Purpose:
146
  --   Multiplex the Program Memory address.
147
  --
148
  pmem_addr: process (program_counter_q,
149
                      addr_type_i,
150
                      pmem_addr_q,
151
                      data_i)
152
  begin
153
    -- default assignment
154 77 arniml
    pmem_addr_s <= STD_LOGIC_VECTOR(program_counter_q);
155 4 arniml
 
156
    case addr_type_i is
157
      when PM_PC =>
158
        -- default is ok
159
        null;
160
 
161
      when PM_PAGE =>
162
        pmem_addr_s(word_t'range) <= data_i;
163
        -- take page address from program counter
164
        --   => important for JMPP, MOVP!
165
        --      they must wrap to next page when at FF!
166
 
167
      when PM_PAGE3 =>
168
        pmem_addr_s(word_t'range) <= data_i;
169
        -- page address is explicitely specified
170
        pmem_addr_s(page_t'range) <= "0011";
171
 
172
      when others =>
173
        null;
174
 
175
    end case;
176
 
177
  end process pmem_addr;
178
  --
179
  -----------------------------------------------------------------------------
180
 
181
 
182
  -----------------------------------------------------------------------------
183
  -- Process data_output
184
  --
185
  -- Purpose:
186
  --   Multiplex the data bus output.
187
  --
188
  data_output: process (read_pmem_i,
189
                        read_pcl_i,
190
                        read_pch_i,
191
                        pmem_data_i,
192
                        program_counter_q)
193
  begin
194
    data_o <= (others => bus_idle_level_c);
195
 
196
    if read_pmem_i then
197
      data_o <= pmem_data_i;
198
    elsif read_pcl_i then
199 77 arniml
      data_o <= STD_LOGIC_VECTOR(program_counter_q(data_o'range));
200 4 arniml
    elsif read_pch_i then
201 77 arniml
      data_o(3 downto 0) <= STD_LOGIC_VECTOR(program_counter_q(pmem_addr_width_c-1 downto data_o'high+1));
202 4 arniml
    end if;
203
 
204
  end process data_output;
205
  --
206
  -----------------------------------------------------------------------------
207
 
208
 
209
  -----------------------------------------------------------------------------
210
  -- Output Mapping.
211
  -----------------------------------------------------------------------------
212
  pmem_addr_o <= pmem_addr_q;
213
 
214
end rtl;
215
 
216
 
217
-------------------------------------------------------------------------------
218
-- File History:
219
--
220
-- $Log: not supported by cvs2svn $
221 129 arniml
-- Revision 1.2  2004/04/24 23:44:25  arniml
222
-- move from std_logic_arith to numeric_std
223
--
224 77 arniml
-- Revision 1.1  2004/03/23 21:31:53  arniml
225
-- initial check-in
226 4 arniml
--
227 77 arniml
--
228 4 arniml
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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