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

Subversion Repositories zpu

[/] [zpu/] [trunk/] [zpu/] [zpu4/] [core/] [zpupkg.vhd] - Blame information for rev 95

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

Line No. Rev Author Line
1 93 oharboe
-- ZPU
2
--
3
-- Copyright 2004-2008 oharboe - Øyvind Harboe - oyvind.harboe@zylin.com
4
-- 
5
-- The FreeBSD license
6
-- 
7
-- Redistribution and use in source and binary forms, with or without
8
-- modification, are permitted provided that the following conditions
9
-- are met:
10
-- 
11
-- 1. Redistributions of source code must retain the above copyright
12
--    notice, this list of conditions and the following disclaimer.
13
-- 2. Redistributions in binary form must reproduce the above
14
--    copyright notice, this list of conditions and the following
15
--    disclaimer in the documentation and/or other materials
16
--    provided with the distribution.
17
-- 
18
-- THIS SOFTWARE IS PROVIDED BY THE ZPU PROJECT ``AS IS'' AND ANY
19
-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20
-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
-- ZPU PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
-- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25
-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26
-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27
-- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29
-- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
-- 
31
-- The views and conclusions contained in the software and documentation
32
-- are those of the authors and should not be interpreted as representing
33
-- official policies, either expressed or implied, of the ZPU Project.
34
 
35
library IEEE;
36
use IEEE.STD_LOGIC_1164.all;
37
use ieee.numeric_std.all;
38
 
39
library work;
40
use work.zpu_config.all;
41
 
42
package zpupkg is
43
 
44
        -- This bit is set for read/writes to IO
45
        -- FIX!!! eventually this should be set to wordSize-1 so as to
46
        -- to make the address of IO independent of amount of memory
47
        -- reserved for CPU. Requires trivial tweaks in toolchain/runtime
48
        -- libraries.
49
 
50
        constant byteBits                       : integer := wordPower-3; -- # of bits in a word that addresses bytes
51
        constant maxAddrBit                     : integer := maxAddrBitIncIO-1;
52
        constant ioBit                          : integer := maxAddrBit+1;
53
        constant wordSize                       : integer := 2**wordPower;
54
        constant wordBytes                      : integer := wordSize/8;
55
        constant minAddrBit                     : integer := byteBits;
56
        -- configurable internal stack size. Probably going to be 16 after toolchain is done
57
        constant        stack_bits              : integer := 5;
58
        constant        stack_size              : integer := 2**stack_bits;
59
 
60
 
61
        component dualport_ram is
62
        port (clk : in std_logic;
63
                memAWriteEnable : in std_logic;
64
                memAAddr : in std_logic_vector(maxAddrBitBRAM downto minAddrBit);
65
                memAWrite : in std_logic_vector(wordSize-1 downto 0);
66
                memARead : out std_logic_vector(wordSize-1 downto 0);
67
                memBWriteEnable : in std_logic;
68
                memBAddr : in std_logic_vector(maxAddrBitBRAM downto minAddrBit);
69
                memBWrite : in std_logic_vector(wordSize-1 downto 0);
70
                memBRead : out std_logic_vector(wordSize-1 downto 0));
71
        end component;
72
 
73
 
74
        component dram is
75
                port (clk : in std_logic;
76
                        areset : in std_logic;
77
                        mem_writeEnable : in std_logic;
78
                        mem_readEnable : in std_logic;
79
                        mem_addr : in std_logic_vector(maxAddrBit downto 0);
80
                        mem_write : in std_logic_vector(wordSize-1 downto 0);
81
                        mem_read : out std_logic_vector(wordSize-1 downto 0);
82
                        mem_busy : out std_logic;
83
                        mem_writeMask : in std_logic_vector(wordBytes-1 downto 0));
84
        end component;
85
 
86
 
87
        component trace is
88
          port(
89
                clk         : in std_logic;
90
                begin_inst  : in std_logic;
91
                pc          : in std_logic_vector(maxAddrBitIncIO downto 0);
92
                        opcode          : in std_logic_vector(7 downto 0);
93
                        sp                      : in std_logic_vector(maxAddrBitIncIO downto minAddrBit);
94
                        memA            : in std_logic_vector(wordSize-1 downto 0);
95
                        memB            : in std_logic_vector(wordSize-1 downto 0);
96
                        busy         : in std_logic;
97
                        intSp           : in std_logic_vector(stack_bits-1 downto 0)
98
                        );
99
        end component;
100
 
101
        component zpu_core is
102
    port ( clk : in std_logic;
103
                          areset : in std_logic;
104
                          enable : in std_logic;
105
                          in_mem_busy : in std_logic;
106
                          mem_read : in std_logic_vector(wordSize-1 downto 0);
107
                          mem_write : out std_logic_vector(wordSize-1 downto 0);
108
                          out_mem_addr : out std_logic_vector(maxAddrBitIncIO downto 0);
109
                          out_mem_writeEnable : out std_logic;
110
                          out_mem_readEnable : out std_logic;
111
                          mem_writeMask: out std_logic_vector(wordBytes-1 downto 0);
112
                          interrupt : in std_logic;
113
                          break : out std_logic);
114
        end component;
115
 
116
 
117
 
118
        component timer is
119
          port(
120
               clk              : in std_logic;
121
                         areset                         : in std_logic;
122
                         we                                     : in std_logic;
123
                         din                                    : in std_logic_vector(7 downto 0);
124
                         adr                                    : in std_logic_vector(2 downto 0);
125
                         dout                                   : out std_logic_vector(7 downto 0));
126
        end component;
127
 
128
        component  zpuio is
129
                port (  areset                  : in std_logic;
130
                                cpu_clk                 : in std_logic;
131
                                clk_status              : in std_logic_vector(2 downto 0);
132
                                cpu_din                 : in std_logic_vector(15 downto 0);
133
                                cpu_a                   : in std_logic_vector(20 downto 0);
134
                                cpu_we                  : in std_logic_vector(1 downto 0);
135
                                cpu_re                  : in std_logic;
136
                                cpu_dout                : inout std_logic_vector(15 downto 0));
137
        end component;
138
 
139
 
140
 
141
 
142
        -- opcode decode constants
143
        constant        OpCode_Im               : std_logic_vector(7 downto 7) := "1";
144
        constant        OpCode_StoreSP  : std_logic_vector(7 downto 5) := "010";
145
        constant        OpCode_LoadSP   : std_logic_vector(7 downto 5) := "011";
146
        constant        OpCode_Emulate  : std_logic_vector(7 downto 5) := "001";
147
        constant        OpCode_AddSP    : std_logic_vector(7 downto 4) := "0001";
148
        constant        OpCode_Short    : std_logic_vector(7 downto 4) := "0000";
149
 
150
        constant        OpCode_Break    : std_logic_vector(3 downto 0) := "0000";
151
        constant        OpCode_NA4      : std_logic_vector(3 downto 0) := "0001";
152
        constant        OpCode_PushSP   : std_logic_vector(3 downto 0) := "0010";
153
        constant        OpCode_NA3              : std_logic_vector(3 downto 0) := "0011";
154
 
155
        constant        OpCode_PopPC    : std_logic_vector(3 downto 0) := "0100";
156
        constant        OpCode_Add              : std_logic_vector(3 downto 0) := "0101";
157
        constant        OpCode_And              : std_logic_vector(3 downto 0) := "0110";
158
        constant        OpCode_Or               : std_logic_vector(3 downto 0) := "0111";
159
 
160
        constant        OpCode_Load             : std_logic_vector(3 downto 0) := "1000";
161
        constant        OpCode_Not              : std_logic_vector(3 downto 0) := "1001";
162
        constant        OpCode_Flip             : std_logic_vector(3 downto 0) := "1010";
163
        constant        OpCode_Nop              : std_logic_vector(3 downto 0) := "1011";
164
 
165
        constant        OpCode_Store    : std_logic_vector(3 downto 0) := "1100";
166
        constant        OpCode_PopSP    : std_logic_vector(3 downto 0) := "1101";
167
        constant        OpCode_NA2              : std_logic_vector(3 downto 0) := "1110";
168
        constant        OpCode_NA               : std_logic_vector(3 downto 0) := "1111";
169
 
170
        constant        OpCode_Lessthan                         : std_logic_vector(5 downto 0) := std_logic_vector(to_unsigned(36, 6));
171
        constant        OpCode_Lessthanorequal          : std_logic_vector(5 downto 0) := std_logic_vector(to_unsigned(37, 6));
172
        constant        OpCode_Ulessthan                        : std_logic_vector(5 downto 0) := std_logic_vector(to_unsigned(38, 6));
173
        constant        OpCode_Ulessthanorequal         : std_logic_vector(5 downto 0) := std_logic_vector(to_unsigned(39, 6));
174
 
175
        constant        OpCode_Swap                                     : std_logic_vector(5 downto 0) := std_logic_vector(to_unsigned(40, 6));
176
        constant        OpCode_Mult                                     : std_logic_vector(5 downto 0) := std_logic_vector(to_unsigned(41, 6));
177
 
178
        constant        OpCode_Lshiftright                      : std_logic_vector(5 downto 0) := std_logic_vector(to_unsigned(42, 6));
179
        constant        OpCode_Ashiftleft                       : std_logic_vector(5 downto 0) := std_logic_vector(to_unsigned(43, 6));
180
        constant        OpCode_Ashiftright                      : std_logic_vector(5 downto 0) := std_logic_vector(to_unsigned(44, 6));
181
        constant        OpCode_Call                                     : std_logic_vector(5 downto 0) := std_logic_vector(to_unsigned(45, 6));
182
 
183
        constant        OpCode_Eq                                       : std_logic_vector(5 downto 0) := std_logic_vector(to_unsigned(46, 6));
184
        constant        OpCode_Neq                                      : std_logic_vector(5 downto 0) := std_logic_vector(to_unsigned(47, 6));
185
 
186
        constant        OpCode_Sub                                      : std_logic_vector(5 downto 0) := std_logic_vector(to_unsigned(49, 6));
187
        constant        OpCode_Loadb                            : std_logic_vector(5 downto 0) := std_logic_vector(to_unsigned(51, 6));
188
        constant        OpCode_Storeb                           : std_logic_vector(5 downto 0) := std_logic_vector(to_unsigned(52, 6));
189
 
190
        constant        OpCode_Eqbranch                         : std_logic_vector(5 downto 0) := std_logic_vector(to_unsigned(55, 6));
191
        constant        OpCode_Neqbranch                        : std_logic_vector(5 downto 0) := std_logic_vector(to_unsigned(56, 6));
192
        constant        OpCode_Poppcrel                         : std_logic_vector(5 downto 0) := std_logic_vector(to_unsigned(57, 6));
193
 
194
        constant        OpCode_Pushspadd                        : std_logic_vector(5 downto 0) := std_logic_vector(to_unsigned(61, 6));
195
        constant        OpCode_Mult16x16                        : std_logic_vector(5 downto 0) := std_logic_vector(to_unsigned(62, 6));
196
        constant        OpCode_Callpcrel                        : std_logic_vector(5 downto 0) := std_logic_vector(to_unsigned(63, 6));
197
 
198
 
199
 
200
        constant OpCode_Size            : integer := 8;
201
 
202
 
203
 
204
end zpupkg;

powered by: WebSVN 2.1.0

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