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

Subversion Repositories t400

[/] [t400/] [trunk/] [rtl/] [vhdl/] [t400_pmem_ctrl.vhd] - Blame information for rev 179

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 arniml
------------------------------------------------------------------------------
2
--
3
-- The Program memory controller.
4
--
5 179 arniml
-- $Id: t400_pmem_ctrl.vhd 179 2009-04-01 19:48:38Z arniml $
6 2 arniml
--
7
-- Copyright (c) 2006 Arnim Laeuger (arniml@opencores.org)
8
--
9
-- All rights reserved
10
--
11
-- Redistribution and use in source and synthezised forms, with or without
12
-- modification, are permitted provided that the following conditions are met:
13
--
14
-- Redistributions of source code must retain the above copyright notice,
15
-- this list of conditions and the following disclaimer.
16
--
17
-- Redistributions in synthesized form must reproduce the above copyright
18
-- notice, this list of conditions and the following disclaimer in the
19
-- documentation and/or other materials provided with the distribution.
20
--
21
-- Neither the name of the author nor the names of other contributors may
22
-- be used to endorse or promote products derived from this software without
23
-- specific prior written permission.
24
--
25
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
27
-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28
-- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
29
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35
-- POSSIBILITY OF SUCH DAMAGE.
36
--
37
-- Please report bugs to the author, but before you do so, please
38
-- make sure that this is not a derivative work and that
39
-- you have the latest version of this file.
40
--
41
-- The latest version of this file can be found at:
42
--      http://www.opencores.org/cvsweb.shtml/t400/
43
--
44
-------------------------------------------------------------------------------
45
 
46
library ieee;
47
use ieee.std_logic_1164.all;
48
 
49
use work.t400_opt_pack.all;
50
use work.t400_pack.all;
51
 
52
entity t400_pmem_ctrl is
53
 
54
  generic (
55
    opt_type_g : integer := t400_opt_type_420_c
56
  );
57
  port (
58
    -- System Interface -------------------------------------------------------
59
    ck_i       : in  std_logic;
60
    ck_en_i    : in  boolean;
61
    por_i      : in  boolean;
62
    res_i      : in  boolean;
63
    a_i        : in  dw_t;
64
    m_i        : in  dw_t;
65
    -- Control Interface ------------------------------------------------------
66
    op_i       : in  pc_op_t;
67
    dec_data_i : in  dec_data_t;
68
    -- Stack Interface --------------------------------------------------------
69
    pc_o       : out pc_t;
70
    pc_i       : in  pc_t;
71
    -- Program Memory Interface -----------------------------------------------
72
    pm_addr_o  : out pc_t
73
  );
74
 
75
end t400_pmem_ctrl;
76
 
77
 
78
library ieee;
79
use ieee.numeric_std.all;
80
 
81 70 arniml
-- pragma translate_off
82
use work.tb_pack.tb_pc_s;
83
-- pragma translate_on
84
 
85 2 arniml
architecture rtl of t400_pmem_ctrl is
86
 
87
  signal pc_q      : pc_t;
88
  signal last_pc_s : pc_t;
89
 
90
begin
91
 
92
  -----------------------------------------------------------------------------
93
  -- Determine last program counter address
94
  -----------------------------------------------------------------------------
95
  last_pc_s <=   to_unsigned(16#1ff#, pc_t'length)
96
               when opt_type_g = t400_opt_type_410_c else
97
                 to_unsigned(16#3ff#, pc_t'length);
98
 
99
 
100
  -----------------------------------------------------------------------------
101
  -- Process pc
102
  --
103
  -- Purpose:
104
  --   Implements the program counter.
105
  --
106
  pc: process (ck_i, por_i)
107
  begin
108
    if por_i then
109
      pc_q <= (others => '0');
110
 
111
    elsif ck_i'event and ck_i = '1' then
112
      if    res_i then
113
        -- synchronous reset upon external reset event
114
        pc_q                 <= (others => '0');
115
 
116
      elsif ck_en_i then
117
        -- determine PC update mode
118
        case op_i is
119
          -- increment program counter ----------------------------------------
120
          when PC_INC_PC =>
121
            if pc_q = last_pc_s then
122
              -- roll over
123
              pc_q           <= (others => '0');
124
            else
125
              pc_q           <= pc_q + 1;
126
            end if;
127
 
128
          -- Load lower 6 bits from program memory data -----------------------
129
          when PC_LOAD_6 =>
130
            pc_q(5 downto 0) <= unsigned(dec_data_i(5 downto 0));
131
 
132
          -- Load lower 7 bits from program memory data -----------------------
133
          when PC_LOAD_7 =>
134
            pc_q(6 downto 0) <= unsigned(dec_data_i(6 downto 0));
135
 
136
          -- Load lower 8 bits from program memory data -----------------------
137
          when PC_LOAD_8 =>
138
            pc_q(7 downto 0) <= unsigned(dec_data_i(7 downto 0));
139
 
140
          -- Load all bits from program memory data ---------------------------
141
          when PC_LOAD =>
142
            pc_q             <= unsigned(dec_data_i);
143
 
144
          -- pop program counter from stack -----------------------------------
145
          when PC_POP =>
146
            pc_q             <= pc_i;
147
 
148
          -- update program counter for LQID instruction ----------------------
149
          when PC_LOAD_A_M =>
150
            pc_q(7 downto 4) <= unsigned(a_i);
151
            pc_q(3 downto 0) <= unsigned(m_i);
152
 
153 70 arniml
          -- load interrupt vector --------------------------------------------
154
          when PC_INT =>
155
            if opt_type_g = t400_opt_type_420_c then
156 89 arniml
              -- load address 0x100, i.e. skip first instruction at
157
              -- vector address 0x0ff which has to be a NOP :-)
158
              pc_q <= (8 => '1', others => '0');
159 70 arniml
            end if;
160
 
161 2 arniml
          when others =>
162
            null;
163
        end case;
164
      end if;
165
    end if;
166
  end process pc;
167
  --
168
  -----------------------------------------------------------------------------
169
 
170
 
171 70 arniml
  -- pragma translate_off
172
  -- instrument interrupt testbench
173
  tb_pc_s <= pc_q;
174
  -- pragma translate_on
175
 
176
 
177 2 arniml
  -----------------------------------------------------------------------------
178
  -- Output mapping
179
  -----------------------------------------------------------------------------
180
  pc_o      <= pc_q;
181
  pm_addr_o <= pc_q;
182
 
183
end rtl;

powered by: WebSVN 2.1.0

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