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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_1_0/] [rtl/] [vhdl/] [pmem_ctrl.vhd] - Blame information for rev 174

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 174 arniml
-- $Id: pmem_ctrl.vhd,v 1.4 2005-06-08 19:13:53 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 174 arniml
  -- implemented counter width of Program Counter
94
  -- the upper bit is only altered by JMP, CALL and RET(R)
95
  subtype pc_count_range_t is natural range pmem_addr_width_c-2 downto 0;
96
 
97 4 arniml
  -- the Program Counter
98
  signal program_counter_q : unsigned(pmem_addr_t'range);
99
 
100 174 arniml
 
101 4 arniml
  -- the Program Memory address
102
  signal pmem_addr_s,
103
         pmem_addr_q       : std_logic_vector(pmem_addr_t'range);
104
 
105
begin
106
 
107
  -----------------------------------------------------------------------------
108
  -- Process program_counter
109
  --
110
  -- Purpose:
111
  --   Implements the Program Counter.
112
  --
113
  program_counter: process (res_i, clk_i)
114
  begin
115
    if res_i = res_active_c then
116
      program_counter_q <= (others => '0');
117
      pmem_addr_q       <= (others => '0');
118
 
119
    elsif clk_i'event and clk_i = clk_active_c then
120
      if en_clk_i then
121
 
122
        -- parallel load mode
123
        if write_pcl_i then
124
          program_counter_q(data_i'range) <= UNSIGNED(data_i);
125
        elsif write_pch_i then
126
          program_counter_q(pmem_addr_width_c-1 downto data_i'high+1) <=
127
            UNSIGNED(data_i(pmem_addr_width_c - dmem_addr_width_c - 1 downto 0));
128
        elsif inc_pc_i then
129
          -- increment mode
130 174 arniml
          -- the MSB is not modified by linear increments
131
          -- it can only be altered by JMP, CALL or RET(R)
132
          program_counter_q(pc_count_range_t) <=
133
            program_counter_q(pc_count_range_t) + 1;
134 4 arniml
        end if;
135
 
136
        -- set pmem address
137
        if write_pmem_addr_i then
138
          pmem_addr_q <= pmem_addr_s;
139
        end if;
140
 
141
      end if;
142
 
143
    end if;
144
 
145
  end process program_counter;
146
  --
147
  -----------------------------------------------------------------------------
148
 
149
 
150
  -----------------------------------------------------------------------------
151
  -- Process pmem_addr
152
  --
153
  -- Purpose:
154
  --   Multiplex the Program Memory address.
155
  --
156
  pmem_addr: process (program_counter_q,
157
                      addr_type_i,
158
                      pmem_addr_q,
159
                      data_i)
160
  begin
161
    -- default assignment
162 77 arniml
    pmem_addr_s <= STD_LOGIC_VECTOR(program_counter_q);
163 4 arniml
 
164
    case addr_type_i is
165
      when PM_PC =>
166
        -- default is ok
167
        null;
168
 
169
      when PM_PAGE =>
170
        pmem_addr_s(word_t'range) <= data_i;
171
        -- take page address from program counter
172
        --   => important for JMPP, MOVP!
173
        --      they must wrap to next page when at FF!
174
 
175
      when PM_PAGE3 =>
176
        pmem_addr_s(word_t'range) <= data_i;
177
        -- page address is explicitely specified
178
        pmem_addr_s(page_t'range) <= "0011";
179
 
180
      when others =>
181
        null;
182
 
183
    end case;
184
 
185
  end process pmem_addr;
186
  --
187
  -----------------------------------------------------------------------------
188
 
189
 
190
  -----------------------------------------------------------------------------
191
  -- Process data_output
192
  --
193
  -- Purpose:
194
  --   Multiplex the data bus output.
195
  --
196
  data_output: process (read_pmem_i,
197
                        read_pcl_i,
198
                        read_pch_i,
199
                        pmem_data_i,
200
                        program_counter_q)
201
  begin
202
    data_o <= (others => bus_idle_level_c);
203
 
204
    if read_pmem_i then
205
      data_o <= pmem_data_i;
206
    elsif read_pcl_i then
207 77 arniml
      data_o <= STD_LOGIC_VECTOR(program_counter_q(data_o'range));
208 4 arniml
    elsif read_pch_i then
209 77 arniml
      data_o(3 downto 0) <= STD_LOGIC_VECTOR(program_counter_q(pmem_addr_width_c-1 downto data_o'high+1));
210 4 arniml
    end if;
211
 
212
  end process data_output;
213
  --
214
  -----------------------------------------------------------------------------
215
 
216
 
217
  -----------------------------------------------------------------------------
218
  -- Output Mapping.
219
  -----------------------------------------------------------------------------
220
  pmem_addr_o <= pmem_addr_q;
221
 
222
end rtl;
223
 
224
 
225
-------------------------------------------------------------------------------
226
-- File History:
227
--
228
-- $Log: not supported by cvs2svn $
229 174 arniml
-- Revision 1.3  2004/07/11 16:51:33  arniml
230
-- cleanup copyright notice
231
--
232 129 arniml
-- Revision 1.2  2004/04/24 23:44:25  arniml
233
-- move from std_logic_arith to numeric_std
234
--
235 77 arniml
-- Revision 1.1  2004/03/23 21:31:53  arniml
236
-- initial check-in
237 4 arniml
--
238
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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