1 |
2 |
dimamali |
------------------------------------------------------------------------------
|
2 |
|
|
-- This file is a part of the GRLIB VHDL IP LIBRARY
|
3 |
|
|
-- Copyright (C) 2003, Gaisler Research
|
4 |
|
|
--
|
5 |
|
|
-- This program is free software; you can redistribute it and/or modify
|
6 |
|
|
-- it under the terms of the GNU General Public License as published by
|
7 |
|
|
-- the Free Software Foundation; either version 2 of the License, or
|
8 |
|
|
-- (at your option) any later version.
|
9 |
|
|
--
|
10 |
|
|
-- This program is distributed in the hope that it will be useful,
|
11 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
|
|
-- GNU General Public License for more details.
|
14 |
|
|
--
|
15 |
|
|
-- You should have received a copy of the GNU General Public License
|
16 |
|
|
-- along with this program; if not, write to the Free Software
|
17 |
|
|
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
18 |
|
|
-----------------------------------------------------------------------------
|
19 |
|
|
-- Entity: leon3sh
|
20 |
|
|
-- File: leon3sh.vhd
|
21 |
|
|
-- Author: Jiri Gaisler, Edvin Catovic, Gaisler Research
|
22 |
|
|
-- Description: Top-level LEON3 component
|
23 |
|
|
------------------------------------------------------------------------------
|
24 |
|
|
|
25 |
|
|
library ieee;
|
26 |
|
|
use ieee.std_logic_1164.all;
|
27 |
|
|
library grlib;
|
28 |
|
|
use grlib.amba.all;
|
29 |
|
|
use grlib.stdlib.all;
|
30 |
|
|
library gaisler;
|
31 |
|
|
library techmap;
|
32 |
|
|
use techmap.gencomp.all;
|
33 |
|
|
use gaisler.leon3.all;
|
34 |
|
|
use gaisler.libiu.all;
|
35 |
|
|
use gaisler.libcache.all;
|
36 |
|
|
use gaisler.libproc3.all;
|
37 |
|
|
use gaisler.arith.all;
|
38 |
|
|
--library fpu;
|
39 |
|
|
--use fpu.libfpu.all;
|
40 |
|
|
|
41 |
|
|
entity leon3sh is
|
42 |
|
|
generic (
|
43 |
|
|
hindex : integer := 0;
|
44 |
|
|
fabtech : integer range 0 to NTECH := DEFFABTECH;
|
45 |
|
|
memtech : integer range 0 to NTECH := DEFMEMTECH;
|
46 |
|
|
nwindows : integer range 2 to 32 := 8;
|
47 |
|
|
dsu : integer range 0 to 1 := 0;
|
48 |
|
|
fpu : integer range 0 to 31 := 0;
|
49 |
|
|
v8 : integer range 0 to 63 := 0;
|
50 |
|
|
cp : integer range 0 to 1 := 0;
|
51 |
|
|
mac : integer range 0 to 1 := 0;
|
52 |
|
|
pclow : integer range 0 to 2 := 2;
|
53 |
|
|
notag : integer range 0 to 1 := 0;
|
54 |
|
|
nwp : integer range 0 to 4 := 0;
|
55 |
|
|
icen : integer range 0 to 1 := 0;
|
56 |
|
|
irepl : integer range 0 to 2 := 2;
|
57 |
|
|
isets : integer range 1 to 4 := 1;
|
58 |
|
|
ilinesize : integer range 4 to 8 := 4;
|
59 |
|
|
isetsize : integer range 1 to 256 := 1;
|
60 |
|
|
isetlock : integer range 0 to 1 := 0;
|
61 |
|
|
dcen : integer range 0 to 1 := 0;
|
62 |
|
|
drepl : integer range 0 to 2 := 2;
|
63 |
|
|
dsets : integer range 1 to 4 := 1;
|
64 |
|
|
dlinesize : integer range 4 to 8 := 4;
|
65 |
|
|
dsetsize : integer range 1 to 256 := 1;
|
66 |
|
|
dsetlock : integer range 0 to 1 := 0;
|
67 |
|
|
dsnoop : integer range 0 to 6 := 0;
|
68 |
|
|
ilram : integer range 0 to 1 := 0;
|
69 |
|
|
ilramsize : integer range 1 to 512 := 1;
|
70 |
|
|
ilramstart : integer range 0 to 255 := 16#8e#;
|
71 |
|
|
dlram : integer range 0 to 1 := 0;
|
72 |
|
|
dlramsize : integer range 1 to 512 := 1;
|
73 |
|
|
dlramstart : integer range 0 to 255 := 16#8f#;
|
74 |
|
|
mmuen : integer range 0 to 1 := 0;
|
75 |
|
|
itlbnum : integer range 2 to 64 := 8;
|
76 |
|
|
dtlbnum : integer range 2 to 64 := 8;
|
77 |
|
|
tlb_type : integer range 0 to 3 := 1;
|
78 |
|
|
tlb_rep : integer range 0 to 1 := 0;
|
79 |
|
|
lddel : integer range 1 to 2 := 2;
|
80 |
|
|
disas : integer range 0 to 2 := 0;
|
81 |
|
|
tbuf : integer range 0 to 64 := 0;
|
82 |
|
|
pwd : integer range 0 to 2 := 2; -- power-down
|
83 |
|
|
svt : integer range 0 to 1 := 1; -- single vector trapping
|
84 |
|
|
rstaddr : integer := 0;
|
85 |
|
|
smp : integer range 0 to 15 := 0; -- support SMP systems
|
86 |
|
|
cached : integer := 0; -- cacheability table
|
87 |
|
|
scantest : integer := 0
|
88 |
|
|
);
|
89 |
|
|
port (
|
90 |
|
|
clk : in std_ulogic;
|
91 |
|
|
rstn : in std_ulogic;
|
92 |
|
|
ahbi : in ahb_mst_in_type;
|
93 |
|
|
ahbo : out ahb_mst_out_type;
|
94 |
|
|
ahbsi : in ahb_slv_in_type;
|
95 |
|
|
ahbso : in ahb_slv_out_vector;
|
96 |
|
|
irqi : in l3_irq_in_type;
|
97 |
|
|
irqo : out l3_irq_out_type;
|
98 |
|
|
dbgi : in l3_debug_in_type;
|
99 |
|
|
dbgo : out l3_debug_out_type;
|
100 |
|
|
fpui : out grfpu_in_type;
|
101 |
|
|
fpuo : in grfpu_out_type
|
102 |
|
|
);
|
103 |
|
|
end;
|
104 |
|
|
|
105 |
|
|
architecture rtl of leon3sh is
|
106 |
|
|
|
107 |
|
|
constant IRFBITS : integer range 6 to 10 := log2(NWINDOWS+1) + 4;
|
108 |
|
|
constant IREGNUM : integer := NWINDOWS * 16 + 8;
|
109 |
|
|
|
110 |
|
|
signal holdn : std_logic;
|
111 |
|
|
signal rfi : iregfile_in_type;
|
112 |
|
|
signal rfo : iregfile_out_type;
|
113 |
|
|
signal crami : cram_in_type;
|
114 |
|
|
signal cramo : cram_out_type;
|
115 |
|
|
signal tbi : tracebuf_in_type;
|
116 |
|
|
signal tbo : tracebuf_out_type;
|
117 |
|
|
signal rst : std_ulogic;
|
118 |
|
|
signal fpi : fpc_in_type;
|
119 |
|
|
signal fpo : fpc_out_type;
|
120 |
|
|
signal cpi : fpc_in_type;
|
121 |
|
|
signal cpo : fpc_out_type;
|
122 |
|
|
|
123 |
|
|
signal rd1, rd2, wd : std_logic_vector(35 downto 0);
|
124 |
|
|
signal gnd, vcc : std_logic;
|
125 |
|
|
|
126 |
|
|
constant FPURFHARD : integer := 1; --1-is_fpga(memtech);
|
127 |
|
|
constant fpuarch : integer := fpu mod 16;
|
128 |
|
|
constant fpunet : integer := fpu / 16;
|
129 |
|
|
|
130 |
|
|
begin
|
131 |
|
|
|
132 |
|
|
gnd <= '0'; vcc <= '1';
|
133 |
|
|
|
134 |
|
|
-- leon3 processor core (iu, caches & mul/div)
|
135 |
|
|
|
136 |
|
|
p0 : proc3
|
137 |
|
|
generic map (hindex, fabtech, memtech, nwindows, dsu, fpu, v8, cp, mac,
|
138 |
|
|
pclow, notag, nwp, icen, irepl, isets, ilinesize, isetsize, isetlock,
|
139 |
|
|
dcen, drepl, dsets, dlinesize, dsetsize, dsetlock, dsnoop, ilram,
|
140 |
|
|
ilramsize, ilramstart, dlram, dlramsize, dlramstart, mmuen, itlbnum, dtlbnum,
|
141 |
|
|
tlb_type, tlb_rep, lddel, disas, tbuf, pwd, svt, rstaddr, smp, cached, 0, scantest)
|
142 |
|
|
port map (clk, rst, holdn, ahbi, ahbo, ahbsi, ahbso, rfi, rfo, crami, cramo,
|
143 |
|
|
tbi, tbo, fpi, fpo, cpi, cpo, irqi, irqo, dbgi, dbgo, gnd, clk, vcc);
|
144 |
|
|
|
145 |
|
|
-- IU register file
|
146 |
|
|
|
147 |
|
|
rf0 : regfile_3p generic map (memtech, IRFBITS, 32, 1, IREGNUM)
|
148 |
|
|
port map (clk, rfi.waddr(IRFBITS-1 downto 0), rfi.wdata, rfi.wren,
|
149 |
|
|
clk, rfi.raddr1(IRFBITS-1 downto 0), rfi.ren1, rfo.data1,
|
150 |
|
|
rfi.raddr2(IRFBITS-1 downto 0), rfi.ren2, rfo.data2, rfi.diag);
|
151 |
|
|
|
152 |
|
|
-- cache memory
|
153 |
|
|
|
154 |
|
|
cmem0 : cachemem
|
155 |
|
|
generic map (memtech, icen, irepl, isets, ilinesize, isetsize, isetlock, dcen,
|
156 |
|
|
drepl, dsets, dlinesize, dsetsize, dsetlock, dsnoop, ilram,
|
157 |
|
|
ilramsize, dlram, dlramsize, mmuen)
|
158 |
|
|
port map (clk, crami, cramo, clk);
|
159 |
|
|
|
160 |
|
|
-- instruction trace buffer memory
|
161 |
|
|
|
162 |
|
|
tbmem_gen : if (tbuf /= 0) generate
|
163 |
|
|
tbmem0 : tbufmem
|
164 |
|
|
generic map (tech => memtech, tbuf => tbuf)
|
165 |
|
|
port map (clk, tbi, tbo);
|
166 |
|
|
end generate;
|
167 |
|
|
|
168 |
|
|
-- FPU
|
169 |
|
|
|
170 |
|
|
fpu0 : if not ((fpuarch > 0) and (fpuarch < 8)) generate fpo.ldlock <= '0'; fpo.ccv <= '1'; fpo.holdn <= '1'; end generate;
|
171 |
|
|
|
172 |
|
|
grfpw0gen : if (fpuarch > 0) and (fpuarch < 8) generate
|
173 |
|
|
fpu0: grfpwxsh
|
174 |
|
|
generic map (FPURFHARD*memtech, pclow, dsu, disas, hindex)
|
175 |
|
|
port map (rst, clk, holdn, fpi, fpo, fpui, fpuo);
|
176 |
|
|
end generate;
|
177 |
|
|
|
178 |
|
|
-- 1-clock reset delay
|
179 |
|
|
|
180 |
|
|
rstreg : process(clk)
|
181 |
|
|
begin if rising_edge(clk) then rst <= rstn; end if; end process;
|
182 |
|
|
|
183 |
|
|
-- pragma translate_off
|
184 |
|
|
bootmsg : report_version
|
185 |
|
|
generic map (
|
186 |
|
|
"leon3_" & tost(hindex) & ": LEON3 SPARC V8 processor rev " & tost(LEON3_VERSION),
|
187 |
|
|
"leon3_" & tost(hindex) & ": icache " & tost(isets*icen) & "*" & tost(isetsize*icen) &
|
188 |
|
|
" kbyte, dcache " & tost(dsets*dcen) & "*" & tost(dsetsize*dcen) & " kbyte"
|
189 |
|
|
);
|
190 |
|
|
-- pragma translate_on
|
191 |
|
|
|
192 |
|
|
|
193 |
|
|
end;
|