1 |
2 |
arniml |
-------------------------------------------------------------------------------
|
2 |
|
|
--
|
3 |
|
|
-- The stack unit.
|
4 |
|
|
--
|
5 |
|
|
-- $Id: t400_stack.vhd,v 1.1.1.1 2006-05-06 01:56:45 arniml Exp $
|
6 |
|
|
--
|
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_stack 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 |
|
|
-- Stack Control Interface ------------------------------------------------
|
63 |
|
|
op_i : in stack_op_t;
|
64 |
|
|
-- Program Counter Interface ----------------------------------------------
|
65 |
|
|
pc_i : in pc_t;
|
66 |
|
|
pc_o : out pc_t
|
67 |
|
|
);
|
68 |
|
|
|
69 |
|
|
end t400_stack;
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
architecture rtl of t400_stack is
|
73 |
|
|
|
74 |
|
|
signal sa_q,
|
75 |
|
|
sb_q,
|
76 |
|
|
sc_q : pc_t;
|
77 |
|
|
|
78 |
|
|
begin
|
79 |
|
|
|
80 |
|
|
-----------------------------------------------------------------------------
|
81 |
|
|
-- Process stack
|
82 |
|
|
--
|
83 |
|
|
-- Purpose:
|
84 |
|
|
-- Implements the stack consisting of SA, SB, SC.
|
85 |
|
|
-- SC is skipped when it's a 41xL.
|
86 |
|
|
--
|
87 |
|
|
stack: process (ck_i, por_i)
|
88 |
|
|
variable t41x_type_v : boolean;
|
89 |
|
|
begin
|
90 |
|
|
if por_i then
|
91 |
|
|
sa_q <= (others => '0');
|
92 |
|
|
sb_q <= (others => '0');
|
93 |
|
|
sc_q <= (others => '0');
|
94 |
|
|
|
95 |
|
|
elsif ck_i'event and ck_i = '1' then
|
96 |
|
|
-- determine type
|
97 |
|
|
t41x_type_v := opt_type_g = t400_opt_type_410_c;
|
98 |
|
|
|
99 |
|
|
if ck_en_i then
|
100 |
|
|
case op_i is
|
101 |
|
|
when STACK_PUSH =>
|
102 |
|
|
sa_q <= pc_i;
|
103 |
|
|
sb_q <= sa_q;
|
104 |
|
|
if not t41x_type_v then
|
105 |
|
|
sc_q <= sb_q;
|
106 |
|
|
end if;
|
107 |
|
|
|
108 |
|
|
when STACK_POP =>
|
109 |
|
|
sa_q <= sb_q;
|
110 |
|
|
if not t41x_type_v then
|
111 |
|
|
sb_q <= sc_q;
|
112 |
|
|
end if;
|
113 |
|
|
|
114 |
|
|
when others =>
|
115 |
|
|
null;
|
116 |
|
|
|
117 |
|
|
end case;
|
118 |
|
|
end if;
|
119 |
|
|
end if;
|
120 |
|
|
end process stack;
|
121 |
|
|
--
|
122 |
|
|
-----------------------------------------------------------------------------
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
-----------------------------------------------------------------------------
|
126 |
|
|
-- Output mapping
|
127 |
|
|
-----------------------------------------------------------------------------
|
128 |
|
|
pc_o <= sa_q;
|
129 |
|
|
|
130 |
|
|
end rtl;
|
131 |
|
|
|
132 |
|
|
|
133 |
|
|
-------------------------------------------------------------------------------
|
134 |
|
|
-- File History:
|
135 |
|
|
--
|
136 |
|
|
-- $Log: not supported by cvs2svn $
|
137 |
|
|
-------------------------------------------------------------------------------
|