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: dsu
|
20 |
|
|
-- File: dsu.vhd
|
21 |
|
|
-- Author: Jiri Gaisler, Edvin Catovic - Gaisler Research
|
22 |
|
|
-- Description: Combined LEON3 debug support and AHB trace unit
|
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 |
|
|
use grlib.devices.all;
|
31 |
|
|
library gaisler;
|
32 |
|
|
use gaisler.leon3.all;
|
33 |
|
|
use gaisler.libiu.all;
|
34 |
|
|
use gaisler.libcache.all;
|
35 |
|
|
library techmap;
|
36 |
|
|
use techmap.gencomp.all;
|
37 |
|
|
|
38 |
|
|
entity dsu3x is
|
39 |
|
|
generic (
|
40 |
|
|
hindex : integer := 0;
|
41 |
|
|
haddr : integer := 16#900#;
|
42 |
|
|
hmask : integer := 16#f00#;
|
43 |
|
|
ncpu : integer := 1;
|
44 |
|
|
tbits : integer := 30; -- timer bits (instruction trace time tag)
|
45 |
|
|
tech : integer := DEFMEMTECH;
|
46 |
|
|
irq : integer := 0;
|
47 |
|
|
kbytes : integer := 0;
|
48 |
|
|
clk2x : integer range 0 to 1 := 0
|
49 |
|
|
);
|
50 |
|
|
port (
|
51 |
|
|
rst : in std_ulogic;
|
52 |
|
|
hclk : in std_ulogic;
|
53 |
|
|
cpuclk : in std_ulogic;
|
54 |
|
|
ahbmi : in ahb_mst_in_type;
|
55 |
|
|
ahbsi : in ahb_slv_in_type;
|
56 |
|
|
ahbso : out ahb_slv_out_type;
|
57 |
|
|
dbgi : in l3_debug_out_vector(0 to NCPU-1);
|
58 |
|
|
dbgo : out l3_debug_in_vector(0 to NCPU-1);
|
59 |
|
|
dsui : in dsu_in_type;
|
60 |
|
|
dsuo : out dsu_out_type;
|
61 |
|
|
hclken : in std_ulogic
|
62 |
|
|
);
|
63 |
|
|
end;
|
64 |
|
|
|
65 |
|
|
architecture rtl of dsu3x is
|
66 |
|
|
|
67 |
|
|
constant TBUFABITS : integer := log2(kbytes) + 6;
|
68 |
|
|
constant NBITS : integer := log2x(ncpu);
|
69 |
|
|
constant PROC_H : integer := 24+NBITS-1;
|
70 |
|
|
constant PROC_L : integer := 24;
|
71 |
|
|
constant AREA_H : integer := 23;
|
72 |
|
|
constant AREA_L : integer := 20;
|
73 |
|
|
constant HBITS : integer := 28;
|
74 |
|
|
|
75 |
|
|
constant DSU3_VERSION : integer := 1;
|
76 |
|
|
|
77 |
|
|
constant hconfig : ahb_config_type := (
|
78 |
|
|
|
79 |
|
|
4 => ahb_membar(haddr, '0', '0', hmask),
|
80 |
|
|
others => zero32);
|
81 |
|
|
|
82 |
|
|
type slv_reg_type is record
|
83 |
|
|
hsel : std_ulogic;
|
84 |
|
|
haddr : std_logic_vector(PROC_H downto 0);
|
85 |
|
|
hwrite : std_ulogic;
|
86 |
|
|
hwdata : std_logic_vector(31 downto 0);
|
87 |
|
|
hrdata : std_logic_vector(31 downto 0);
|
88 |
|
|
hready : std_ulogic;
|
89 |
|
|
hready2 : std_ulogic;
|
90 |
|
|
end record;
|
91 |
|
|
|
92 |
|
|
type reg_type is record
|
93 |
|
|
slv : slv_reg_type;
|
94 |
|
|
en : std_logic_vector(0 to NCPU-1);
|
95 |
|
|
te : std_logic_vector(0 to NCPU-1);
|
96 |
|
|
be : std_logic_vector(0 to NCPU-1);
|
97 |
|
|
bw : std_logic_vector(0 to NCPU-1);
|
98 |
|
|
bs : std_logic_vector(0 to NCPU-1);
|
99 |
|
|
bx : std_logic_vector(0 to NCPU-1);
|
100 |
|
|
bz : std_logic_vector(0 to NCPU-1);
|
101 |
|
|
halt : std_logic_vector(0 to NCPU-1);
|
102 |
|
|
reset : std_logic_vector(0 to NCPU-1);
|
103 |
|
|
bn : std_logic_vector(NCPU-1 downto 0);
|
104 |
|
|
ss : std_logic_vector(NCPU-1 downto 0);
|
105 |
|
|
bmsk : std_logic_vector(NCPU-1 downto 0);
|
106 |
|
|
dmsk : std_logic_vector(NCPU-1 downto 0);
|
107 |
|
|
cnt : std_logic_vector(2 downto 0);
|
108 |
|
|
dsubre : std_logic_vector(2 downto 0);
|
109 |
|
|
dsuen : std_logic_vector(2 downto 0);
|
110 |
|
|
act : std_ulogic;
|
111 |
|
|
timer : std_logic_vector(tbits-1 downto 0);
|
112 |
|
|
pwd : std_logic_vector(NCPU-1 downto 0);
|
113 |
|
|
tstop : std_ulogic;
|
114 |
|
|
end record;
|
115 |
|
|
|
116 |
|
|
type trace_break_reg is record
|
117 |
|
|
addr : std_logic_vector(31 downto 2);
|
118 |
|
|
mask : std_logic_vector(31 downto 2);
|
119 |
|
|
read : std_logic;
|
120 |
|
|
write : std_logic;
|
121 |
|
|
end record;
|
122 |
|
|
|
123 |
|
|
type tregtype is record
|
124 |
|
|
haddr : std_logic_vector(31 downto 0);
|
125 |
|
|
hwrite : std_logic;
|
126 |
|
|
htrans : std_logic_vector(1 downto 0);
|
127 |
|
|
hsize : std_logic_vector(2 downto 0);
|
128 |
|
|
hburst : std_logic_vector(2 downto 0);
|
129 |
|
|
hwdata : std_logic_vector(31 downto 0);
|
130 |
|
|
hmaster : std_logic_vector(3 downto 0);
|
131 |
|
|
hmastlock : std_logic;
|
132 |
|
|
hsel : std_logic;
|
133 |
|
|
ahbactive : std_logic;
|
134 |
|
|
aindex : std_logic_vector(TBUFABITS - 1 downto 0); -- buffer index
|
135 |
|
|
enable : std_logic; -- trace enable
|
136 |
|
|
bphit : std_logic; -- AHB breakpoint hit
|
137 |
|
|
bphit2 : std_logic; -- delayed bphit
|
138 |
|
|
dcnten : std_logic; -- delay counter enable
|
139 |
|
|
delaycnt : std_logic_vector(TBUFABITS - 1 downto 0); -- delay counter
|
140 |
|
|
tbreg1 : trace_break_reg;
|
141 |
|
|
tbreg2 : trace_break_reg;
|
142 |
|
|
tbwr : std_logic; -- trace buffer write enable
|
143 |
|
|
break : std_logic; -- break CPU when AHB tracing stops
|
144 |
|
|
end record;
|
145 |
|
|
|
146 |
|
|
type hclk_reg_type is record
|
147 |
|
|
irq : std_ulogic;
|
148 |
|
|
oen : std_ulogic;
|
149 |
|
|
end record;
|
150 |
|
|
|
151 |
|
|
constant TRACEN : boolean := (kbytes /= 0);
|
152 |
|
|
signal tbi : tracebuf_in_type;
|
153 |
|
|
signal tbo : tracebuf_out_type;
|
154 |
|
|
|
155 |
|
|
signal tr, trin : tregtype;
|
156 |
|
|
signal r, rin : reg_type;
|
157 |
|
|
|
158 |
|
|
signal rh, rhin : hclk_reg_type;
|
159 |
|
|
signal ahbsi2 : ahb_slv_in_type;
|
160 |
|
|
signal hrdata2x : std_logic_vector(31 downto 0);
|
161 |
|
|
|
162 |
|
|
begin
|
163 |
|
|
|
164 |
|
|
comb: process(rst, r, ahbsi, ahbsi2, dbgi, dsui, ahbmi, tr, tbo, hclken, rh, hrdata2x)
|
165 |
|
|
|
166 |
|
|
variable v : reg_type;
|
167 |
|
|
variable iuacc : std_ulogic;
|
168 |
|
|
variable dbgmode, tstop : std_ulogic;
|
169 |
|
|
variable rawindex : integer range 0 to (2**NBITS)-1;
|
170 |
|
|
variable index : natural range 0 to NCPU-1;
|
171 |
|
|
variable hasel1 : std_logic_vector(AREA_H-1 downto AREA_L);
|
172 |
|
|
variable hasel2 : std_logic_vector(6 downto 2);
|
173 |
|
|
variable tv : tregtype;
|
174 |
|
|
variable vabufi : tracebuf_in_type;
|
175 |
|
|
variable aindex : std_logic_vector(TBUFABITS - 1 downto 0); -- buffer index
|
176 |
|
|
variable hirq : std_logic_vector(NAHBIRQ-1 downto 0);
|
177 |
|
|
variable cpwd : std_logic_vector(15 downto 0);
|
178 |
|
|
variable hrdata : std_logic_vector(31 downto 0);
|
179 |
|
|
variable bphit1, bphit2 : std_ulogic;
|
180 |
|
|
variable vh : hclk_reg_type;
|
181 |
|
|
|
182 |
|
|
begin
|
183 |
|
|
|
184 |
|
|
v := r;
|
185 |
|
|
iuacc := '0'; --v.slv.hready := '0';
|
186 |
|
|
dbgmode := '0'; tstop := '1';
|
187 |
|
|
v.dsubre := r.dsubre(1 downto 0) & dsui.break;
|
188 |
|
|
v.dsuen := r.dsuen(1 downto 0) & dsui.enable;
|
189 |
|
|
hrdata := r.slv.hrdata;
|
190 |
|
|
|
191 |
|
|
tv := tr; vabufi.enable := '0'; tv.bphit := '0'; tv.tbwr := '0';
|
192 |
|
|
if (clk2x /= 0) then tv.bphit2 := tr.bphit; else tv.bphit2 := '0'; end if;
|
193 |
|
|
vabufi.data := (others => '0'); vabufi.addr := (others => '0');
|
194 |
|
|
vabufi.write := (others => '0'); aindex := (others => '0');
|
195 |
|
|
hirq := (others => '0'); v.reset := (others => '0');
|
196 |
|
|
if TRACEN then
|
197 |
|
|
aindex := tr.aindex + 1;
|
198 |
|
|
if (clk2x /= 0) then vh.irq := tr.bphit or tr.bphit2; hirq(irq) := rh.irq;
|
199 |
|
|
else hirq(irq) := tr.bphit; end if;
|
200 |
|
|
end if;
|
201 |
|
|
if hclken = '1' then
|
202 |
|
|
v.slv.hready := '0'; v.act := '0';
|
203 |
|
|
end if;
|
204 |
|
|
|
205 |
|
|
-- check for AHB watchpoints
|
206 |
|
|
bphit1 := '0'; bphit2 := '0';
|
207 |
|
|
if TRACEN and ((ahbsi2.hready and tr.ahbactive) = '1') then
|
208 |
|
|
if ((((tr.tbreg1.addr xor tr.haddr(31 downto 2)) and tr.tbreg1.mask) = zero32(29 downto 0)) and
|
209 |
|
|
(((tr.tbreg1.read and not tr.hwrite) or (tr.tbreg1.write and tr.hwrite)) = '1'))
|
210 |
|
|
then bphit1 := '1'; end if;
|
211 |
|
|
if ((((tr.tbreg2.addr xor tr.haddr(31 downto 2)) and tr.tbreg2.mask) = zero32(29 downto 0)) and
|
212 |
|
|
(((tr.tbreg2.read and not tr.hwrite) or (tr.tbreg2.write and tr.hwrite)) = '1'))
|
213 |
|
|
then bphit2 := '1'; end if;
|
214 |
|
|
if (bphit1 or bphit2) = '1' then
|
215 |
|
|
if ((tr.enable and not r.act) = '1') and (tr.dcnten = '0') and
|
216 |
|
|
(tr.delaycnt /= zero32(TBUFABITS-1 downto 0))
|
217 |
|
|
then tv.dcnten := '1';
|
218 |
|
|
else tv.enable := '0'; tv.bphit := tr.break; end if;
|
219 |
|
|
end if;
|
220 |
|
|
end if;
|
221 |
|
|
|
222 |
|
|
-- generate AHB buffer inputs
|
223 |
|
|
|
224 |
|
|
vabufi.write := "0000";
|
225 |
|
|
if TRACEN then
|
226 |
|
|
if (tr.enable = '1') and (r.act = '0') then
|
227 |
|
|
vabufi.addr(TBUFABITS-1 downto 0) := tr.aindex;
|
228 |
|
|
vabufi.data(127) := bphit1 or bphit2;
|
229 |
|
|
vabufi.data(96+tbits-1 downto 96) := r.timer;
|
230 |
|
|
vabufi.data(94 downto 80) := ahbmi.hirq(15 downto 1);
|
231 |
|
|
vabufi.data(79) := tr.hwrite;
|
232 |
|
|
vabufi.data(78 downto 77) := tr.htrans;
|
233 |
|
|
vabufi.data(76 downto 74) := tr.hsize;
|
234 |
|
|
vabufi.data(73 downto 71) := tr.hburst;
|
235 |
|
|
vabufi.data(70 downto 67) := tr.hmaster;
|
236 |
|
|
vabufi.data(66) := tr.hmastlock;
|
237 |
|
|
vabufi.data(65 downto 64) := ahbmi.hresp;
|
238 |
|
|
if tr.hwrite = '1' then
|
239 |
|
|
vabufi.data(63 downto 32) := ahbsi2.hwdata;
|
240 |
|
|
else
|
241 |
|
|
vabufi.data(63 downto 32) := ahbmi.hrdata;
|
242 |
|
|
end if;
|
243 |
|
|
vabufi.data(31 downto 0) := tr.haddr;
|
244 |
|
|
else
|
245 |
|
|
vabufi.addr(TBUFABITS-1 downto 0) := tr.haddr(TBUFABITS+3 downto 4);
|
246 |
|
|
vabufi.data := ahbsi2.hwdata & ahbsi2.hwdata & ahbsi2.hwdata & ahbsi2.hwdata;
|
247 |
|
|
end if;
|
248 |
|
|
|
249 |
|
|
-- write trace buffer
|
250 |
|
|
|
251 |
|
|
if (tr.enable and not r.act) = '1' then
|
252 |
|
|
if (tr.ahbactive and ahbsi2.hready) = '1' then
|
253 |
|
|
tv.aindex := aindex; tv.tbwr := '1';
|
254 |
|
|
vabufi.enable := '1'; vabufi.write := "1111";
|
255 |
|
|
end if;
|
256 |
|
|
end if;
|
257 |
|
|
|
258 |
|
|
-- trace buffer delay counter handling
|
259 |
|
|
|
260 |
|
|
if (tr.dcnten = '1') then
|
261 |
|
|
if (tr.delaycnt = zero32(TBUFABITS-1 downto 0)) then
|
262 |
|
|
tv.enable := '0'; tv.dcnten := '0'; tv.bphit := tr.break;
|
263 |
|
|
end if;
|
264 |
|
|
if tr.tbwr = '1' then tv.delaycnt := tr.delaycnt - 1; end if;
|
265 |
|
|
end if;
|
266 |
|
|
|
267 |
|
|
-- save AHB transfer parameters
|
268 |
|
|
|
269 |
|
|
if (ahbsi2.hready = '1' ) then
|
270 |
|
|
tv.haddr := ahbsi2.haddr; tv.hwrite := ahbsi2.hwrite; tv.htrans := ahbsi2.htrans;
|
271 |
|
|
tv.hsize := ahbsi2.hsize; tv.hburst := ahbsi2.hburst;
|
272 |
|
|
tv.hmaster := ahbsi2.hmaster; tv.hmastlock := ahbsi2.hmastlock;
|
273 |
|
|
end if;
|
274 |
|
|
if tr.hsel = '1' then tv.hwdata := ahbsi2.hwdata; end if;
|
275 |
|
|
if ahbsi2.hready = '1' then
|
276 |
|
|
tv.hsel := ahbsi2.hsel(hindex);
|
277 |
|
|
tv.ahbactive := ahbsi2.htrans(1);
|
278 |
|
|
end if;
|
279 |
|
|
end if;
|
280 |
|
|
|
281 |
|
|
if r.slv.hsel = '1' then
|
282 |
|
|
if (clk2x = 0) then
|
283 |
|
|
v.cnt := r.cnt - 1;
|
284 |
|
|
else
|
285 |
|
|
if (r.cnt /= "111") or (hclken = '1') then v.cnt := r.cnt - 1; end if;
|
286 |
|
|
end if;
|
287 |
|
|
end if;
|
288 |
|
|
|
289 |
|
|
if (r.slv.hready and hclken) = '1' then
|
290 |
|
|
v.slv.hsel := '0'; --v.slv.act := '0';
|
291 |
|
|
end if;
|
292 |
|
|
|
293 |
|
|
for i in 0 to NCPU-1 loop
|
294 |
|
|
if dbgi(i).dsumode = '1' then
|
295 |
|
|
if r.dmsk(i) = '0' then
|
296 |
|
|
dbgmode := '1';
|
297 |
|
|
if hclken = '1' then v.act := '1'; end if;
|
298 |
|
|
end if;
|
299 |
|
|
v.bn(i) := '1';
|
300 |
|
|
else
|
301 |
|
|
tstop := '0';
|
302 |
|
|
end if;
|
303 |
|
|
end loop;
|
304 |
|
|
|
305 |
|
|
if tstop = '0' then v.timer := r.timer + 1; end if;
|
306 |
|
|
if (clk2x /= 0) then
|
307 |
|
|
if hclken = '1' then v.tstop := tstop; end if;
|
308 |
|
|
tstop := r.tstop;
|
309 |
|
|
end if;
|
310 |
|
|
|
311 |
|
|
cpwd := (others => '0');
|
312 |
|
|
for i in 0 to NCPU-1 loop
|
313 |
|
|
v.bn(i) := v.bn(i) or (dbgmode and r.bmsk(i)) or (r.dsubre(1) and not r.dsubre(2));
|
314 |
|
|
if TRACEN then v.bn(i) := v.bn(i) or (tr.bphit and not r.ss(i) and not r.act); end if;
|
315 |
|
|
v.pwd(i) := dbgi(i).idle and (not dbgi(i).ipend) and not v.bn(i);
|
316 |
|
|
end loop;
|
317 |
|
|
cpwd(NCPU-1 downto 0) := r.pwd;
|
318 |
|
|
|
319 |
|
|
if (ahbsi2.hready and ahbsi2.hsel(hindex)) = '1' then
|
320 |
|
|
if (ahbsi2.htrans(1) = '1') then
|
321 |
|
|
v.slv.hsel := '1';
|
322 |
|
|
v.slv.haddr := ahbsi2.haddr(PROC_H downto 0);
|
323 |
|
|
v.slv.hwrite := ahbsi2.hwrite;
|
324 |
|
|
v.cnt := "111";
|
325 |
|
|
end if;
|
326 |
|
|
end if;
|
327 |
|
|
|
328 |
|
|
|
329 |
|
|
|
330 |
|
|
for i in 0 to NCPU-1 loop
|
331 |
|
|
v.en(i) := r.dsuen(2) and dbgi(i).dsu;
|
332 |
|
|
end loop;
|
333 |
|
|
|
334 |
|
|
rawindex := conv_integer(r.slv.haddr(PROC_H downto PROC_L));
|
335 |
|
|
if ncpu = 1 then index := 0; else
|
336 |
|
|
if rawindex > ncpu then index := ncpu-1; else index := rawindex; end if;
|
337 |
|
|
end if;
|
338 |
|
|
|
339 |
|
|
hasel1 := r.slv.haddr(AREA_H-1 downto AREA_L);
|
340 |
|
|
hasel2 := r.slv.haddr(6 downto 2);
|
341 |
|
|
if r.slv.hsel = '1' then
|
342 |
|
|
case hasel1 is
|
343 |
|
|
|
344 |
|
|
when "000" => -- DSU registers
|
345 |
|
|
if r.cnt(2 downto 0) = "110" then
|
346 |
|
|
if hclken = '1' then v.slv.hready := '1'; else v.slv.hready2 := '1'; end if;
|
347 |
|
|
end if;
|
348 |
|
|
hrdata := (others => '0');
|
349 |
|
|
case hasel2 is
|
350 |
|
|
when "00000" =>
|
351 |
|
|
if (r.slv.hwrite and hclken) = '1' then
|
352 |
|
|
v.te(index) := ahbsi2.hwdata(0);
|
353 |
|
|
v.be(index) := ahbsi2.hwdata(1);
|
354 |
|
|
v.bw(index) := ahbsi2.hwdata(2);
|
355 |
|
|
v.bs(index) := ahbsi2.hwdata(3);
|
356 |
|
|
v.bx(index) := ahbsi2.hwdata(4);
|
357 |
|
|
v.bz(index) := ahbsi2.hwdata(5);
|
358 |
|
|
v.reset(index) := ahbsi2.hwdata(9);
|
359 |
|
|
v.halt(index) := ahbsi2.hwdata(10);
|
360 |
|
|
else
|
361 |
|
|
hrdata(0) := r.te(index);
|
362 |
|
|
hrdata(1) := r.be(index);
|
363 |
|
|
hrdata(2) := r.bw(index);
|
364 |
|
|
hrdata(3) := r.bs(index);
|
365 |
|
|
hrdata(4) := r.bx(index);
|
366 |
|
|
hrdata(5) := r.bz(index);
|
367 |
|
|
hrdata(6) := dbgi(index).dsumode;
|
368 |
|
|
hrdata(7) := r.dsuen(2);
|
369 |
|
|
hrdata(8) := r.dsubre(2);
|
370 |
|
|
hrdata(9) := not dbgi(index).error;
|
371 |
|
|
hrdata(10) := dbgi(index).halt;
|
372 |
|
|
hrdata(11) := dbgi(index).pwd;
|
373 |
|
|
end if;
|
374 |
|
|
when "00010" => -- timer
|
375 |
|
|
if (r.slv.hwrite and hclken) = '1' then
|
376 |
|
|
v.timer := ahbsi2.hwdata(tbits-1 downto 0);
|
377 |
|
|
else
|
378 |
|
|
hrdata(tbits-1 downto 0) := r.timer;
|
379 |
|
|
end if;
|
380 |
|
|
when "01000" =>
|
381 |
|
|
if (r.slv.hwrite and hclken) = '1' then
|
382 |
|
|
v.bn := ahbsi2.hwdata(NCPU-1 downto 0);
|
383 |
|
|
v.ss := ahbsi2.hwdata(16+NCPU-1 downto 16);
|
384 |
|
|
else
|
385 |
|
|
hrdata(NCPU-1 downto 0) := r.bn;
|
386 |
|
|
hrdata(16+NCPU-1 downto 16) := r.ss;
|
387 |
|
|
end if;
|
388 |
|
|
when "01001" =>
|
389 |
|
|
if (r.slv.hwrite and hclken) = '1' then
|
390 |
|
|
v.bmsk(NCPU-1 downto 0) := ahbsi2.hwdata(NCPU-1 downto 0);
|
391 |
|
|
v.dmsk(NCPU-1 downto 0) := ahbsi2.hwdata(NCPU-1+16 downto 16);
|
392 |
|
|
else
|
393 |
|
|
hrdata(NCPU-1 downto 0) := r.bmsk;
|
394 |
|
|
hrdata(NCPU-1+16 downto 16) := r.dmsk;
|
395 |
|
|
end if;
|
396 |
|
|
when "10000" =>
|
397 |
|
|
if TRACEN then
|
398 |
|
|
hrdata((TBUFABITS + 15) downto 16) := tr.delaycnt;
|
399 |
|
|
hrdata(2 downto 0) := tr.break & tr.dcnten & tr.enable;
|
400 |
|
|
if (r.slv.hwrite and hclken) = '1' then
|
401 |
|
|
tv.delaycnt := ahbsi2.hwdata((TBUFABITS+ 15) downto 16);
|
402 |
|
|
tv.break := ahbsi2.hwdata(2);
|
403 |
|
|
tv.dcnten := ahbsi2.hwdata(1);
|
404 |
|
|
tv.enable := ahbsi2.hwdata(0);
|
405 |
|
|
end if;
|
406 |
|
|
end if;
|
407 |
|
|
when "10001" =>
|
408 |
|
|
if TRACEN then
|
409 |
|
|
hrdata((TBUFABITS - 1 + 4) downto 4) := tr.aindex;
|
410 |
|
|
if (r.slv.hwrite and hclken) = '1' then
|
411 |
|
|
tv.aindex := ahbsi2.hwdata((TBUFABITS - 1 + 4) downto 4);
|
412 |
|
|
end if;
|
413 |
|
|
end if;
|
414 |
|
|
when "10100" =>
|
415 |
|
|
if TRACEN then
|
416 |
|
|
hrdata(31 downto 2) := tr.tbreg1.addr;
|
417 |
|
|
if (r.slv.hwrite and hclken) = '1' then
|
418 |
|
|
tv.tbreg1.addr := ahbsi2.hwdata(31 downto 2);
|
419 |
|
|
end if;
|
420 |
|
|
end if;
|
421 |
|
|
when "10101" =>
|
422 |
|
|
if TRACEN then
|
423 |
|
|
hrdata := tr.tbreg1.mask & tr.tbreg1.read & tr.tbreg1.write;
|
424 |
|
|
if (r.slv.hwrite and hclken) = '1' then
|
425 |
|
|
tv.tbreg1.mask := ahbsi2.hwdata(31 downto 2);
|
426 |
|
|
tv.tbreg1.read := ahbsi2.hwdata(1);
|
427 |
|
|
tv.tbreg1.write := ahbsi2.hwdata(0);
|
428 |
|
|
end if;
|
429 |
|
|
end if;
|
430 |
|
|
when "10110" =>
|
431 |
|
|
if TRACEN then
|
432 |
|
|
hrdata(31 downto 2) := tr.tbreg2.addr;
|
433 |
|
|
if (r.slv.hwrite and hclken) = '1' then
|
434 |
|
|
tv.tbreg2.addr := ahbsi2.hwdata(31 downto 2);
|
435 |
|
|
end if;
|
436 |
|
|
end if;
|
437 |
|
|
when "10111" =>
|
438 |
|
|
if TRACEN then
|
439 |
|
|
hrdata := tr.tbreg2.mask & tr.tbreg2.read & tr.tbreg2.write;
|
440 |
|
|
if (r.slv.hwrite and hclken) = '1' then
|
441 |
|
|
tv.tbreg2.mask := ahbsi2.hwdata(31 downto 2);
|
442 |
|
|
tv.tbreg2.read := ahbsi2.hwdata(1);
|
443 |
|
|
tv.tbreg2.write := ahbsi2.hwdata(0);
|
444 |
|
|
end if;
|
445 |
|
|
end if;
|
446 |
|
|
when others =>
|
447 |
|
|
end case;
|
448 |
|
|
|
449 |
|
|
when "010" => -- AHB tbuf
|
450 |
|
|
if TRACEN then
|
451 |
|
|
if r.cnt(2 downto 0) = "101" then
|
452 |
|
|
if hclken = '1' then v.slv.hready := '1'; else v.slv.hready2 := '1'; end if;
|
453 |
|
|
end if;
|
454 |
|
|
vabufi.enable := not (tr.enable and not r.act);
|
455 |
|
|
case tr.haddr(3 downto 2) is
|
456 |
|
|
when "00" =>
|
457 |
|
|
hrdata := tbo.data(127 downto 96);
|
458 |
|
|
if (r.slv.hwrite and hclken) = '1' then
|
459 |
|
|
vabufi.write(3) := vabufi.enable and v.slv.hready;
|
460 |
|
|
end if;
|
461 |
|
|
when "01" =>
|
462 |
|
|
hrdata := tbo.data(95 downto 64);
|
463 |
|
|
if (r.slv.hwrite and hclken) = '1' then
|
464 |
|
|
vabufi.write(2) := vabufi.enable and v.slv.hready;
|
465 |
|
|
end if;
|
466 |
|
|
when "10" =>
|
467 |
|
|
hrdata := tbo.data(63 downto 32);
|
468 |
|
|
if (r.slv.hwrite and hclken) = '1' then
|
469 |
|
|
vabufi.write(1) := vabufi.enable and v.slv.hready;
|
470 |
|
|
end if;
|
471 |
|
|
when others =>
|
472 |
|
|
hrdata := tbo.data(31 downto 0);
|
473 |
|
|
if (r.slv.hwrite and hclken) = '1' then
|
474 |
|
|
vabufi.write(0) := vabufi.enable and v.slv.hready;
|
475 |
|
|
end if;
|
476 |
|
|
end case;
|
477 |
|
|
else
|
478 |
|
|
if hclken = '1' then v.slv.hready := '1'; else v.slv.hready2 := '1'; end if;
|
479 |
|
|
end if;
|
480 |
|
|
when "011" | "001" => -- IU reg file, IU tbuf
|
481 |
|
|
iuacc := '1';
|
482 |
|
|
hrdata := dbgi(index).data;
|
483 |
|
|
if r.cnt(2 downto 0) = "101" then
|
484 |
|
|
if hclken = '1' then v.slv.hready := '1'; else v.slv.hready2 := '1'; end if;
|
485 |
|
|
end if;
|
486 |
|
|
when "100" => -- IU reg access
|
487 |
|
|
iuacc := '1';
|
488 |
|
|
hrdata := dbgi(index).data;
|
489 |
|
|
if r.cnt(1 downto 0) = "11" then
|
490 |
|
|
if hclken = '1' then v.slv.hready := '1'; else v.slv.hready2 := '1'; end if;
|
491 |
|
|
end if;
|
492 |
|
|
when "111" => -- DSU ASI
|
493 |
|
|
if r.cnt(2 downto 1) = "11" then iuacc := '1'; else iuacc := '0'; end if;
|
494 |
|
|
if (dbgi(index).crdy = '1') or (r.cnt = "000") then
|
495 |
|
|
if hclken = '1' then v.slv.hready := '1'; else v.slv.hready2 := '1'; end if;
|
496 |
|
|
end if;
|
497 |
|
|
hrdata := dbgi(index).data;
|
498 |
|
|
when others =>
|
499 |
|
|
if hclken = '1' then v.slv.hready := '1'; else v.slv.hready2 := '1'; end if;
|
500 |
|
|
end case;
|
501 |
|
|
if (r.slv.hready and hclken and not v.slv.hsel) = '1' then v.slv.hready := '0'; end if;
|
502 |
|
|
if (clk2x /= 0) and (r.slv.hready2 and hclken) = '1' then v.slv.hready := '1'; end if;
|
503 |
|
|
end if;
|
504 |
|
|
|
505 |
|
|
if r.slv.hsel = '1' then
|
506 |
|
|
if (r.slv.hwrite and hclken) = '1' then v.slv.hwdata := ahbsi2.hwdata; end if;
|
507 |
|
|
if (clk2x = 0) or ((r.slv.hready or r.slv.hready2) = '0') then
|
508 |
|
|
v.slv.hrdata := hrdata;
|
509 |
|
|
end if;
|
510 |
|
|
end if;
|
511 |
|
|
|
512 |
|
|
if ((ahbsi2.hready and ahbsi2.hsel(hindex)) = '1') and (ahbsi2.htrans(1) = '0') then
|
513 |
|
|
if (clk2x = 0) or (r.slv.hsel = '0') then
|
514 |
|
|
v.slv.hready := '1';
|
515 |
|
|
end if;
|
516 |
|
|
end if;
|
517 |
|
|
|
518 |
|
|
if (clk2x /= 0) and (r.slv.hready = '1') then v.slv.hready2 := '0'; end if;
|
519 |
|
|
if v.slv.hsel = '0' then v.slv.hready := '1'; end if;
|
520 |
|
|
|
521 |
|
|
vh.oen := '0';
|
522 |
|
|
if (clk2x /= 0) then
|
523 |
|
|
if (hclken and r.slv.hsel and (r.slv.hready2 or v.slv.hready)) = '1'
|
524 |
|
|
then vh.oen := '1'; end if;
|
525 |
|
|
if (r.slv.hsel = '1') and (r.cnt = "111") and (hclken = '0') then iuacc := '0'; end if;
|
526 |
|
|
end if;
|
527 |
|
|
|
528 |
|
|
|
529 |
|
|
if rst = '0' then
|
530 |
|
|
v.bn := (others => r.dsubre(2)); v.bmsk := (others => '0');
|
531 |
|
|
v.dmsk := (others => '0');
|
532 |
|
|
v.ss := (others => '0'); v.timer := (others => '0'); v.slv.hsel := '0';
|
533 |
|
|
for i in 0 to NCPU-1 loop
|
534 |
|
|
v.bw(i) := r.dsubre(2); v.be(i) := r.dsubre(2);
|
535 |
|
|
v.bx(i) := r.dsubre(2); v.bz(i) := r.dsubre(2);
|
536 |
|
|
v.bs(i) := '0'; v.te(i) := '0';
|
537 |
|
|
end loop;
|
538 |
|
|
tv.ahbactive := '0'; tv.enable := '0';
|
539 |
|
|
tv.hsel := '0'; tv.dcnten := '0';
|
540 |
|
|
tv.tbreg1.read := '0'; tv.tbreg1.write := '0';
|
541 |
|
|
tv.tbreg2.read := '0'; tv.tbreg2.write := '0';
|
542 |
|
|
v.slv.hready := '1'; v.halt := (others => '0');
|
543 |
|
|
end if;
|
544 |
|
|
vabufi.enable := vabufi.enable and not ahbsi.scanen;
|
545 |
|
|
vabufi.diag := ahbsi.testen & "000";
|
546 |
|
|
rin <= v; trin <= tv; tbi <= vabufi;
|
547 |
|
|
|
548 |
|
|
for i in 0 to NCPU-1 loop
|
549 |
|
|
dbgo(i).tenable <= r.te(i);
|
550 |
|
|
dbgo(i).dsuen <= r.en(i);
|
551 |
|
|
dbgo(i).dbreak <= r.bn(i); -- or (dbgmode and r.bmsk(i));
|
552 |
|
|
if conv_integer(r.slv.haddr(PROC_H downto PROC_L)) = i then
|
553 |
|
|
dbgo(i).denable <= iuacc;
|
554 |
|
|
else
|
555 |
|
|
dbgo(i).denable <= '0';
|
556 |
|
|
end if;
|
557 |
|
|
dbgo(i).step <= r.ss(i);
|
558 |
|
|
dbgo(i).berror <= r.be(i);
|
559 |
|
|
dbgo(i).bsoft <= r.bs(i);
|
560 |
|
|
dbgo(i).bwatch <= r.bw(i);
|
561 |
|
|
dbgo(i).btrapa <= r.bx(i);
|
562 |
|
|
dbgo(i).btrape <= r.bz(i);
|
563 |
|
|
dbgo(i).daddr <= r.slv.haddr(PROC_L-1 downto 2);
|
564 |
|
|
dbgo(i).ddata <= r.slv.hwdata;
|
565 |
|
|
dbgo(i).dwrite <= r.slv.hwrite;
|
566 |
|
|
dbgo(i).halt <= r.halt(i);
|
567 |
|
|
dbgo(i).reset <= r.reset(i);
|
568 |
|
|
dbgo(i).timer(tbits-1 downto 0) <= r.timer;
|
569 |
|
|
dbgo(i).timer(30 downto tbits) <= (others => '0');
|
570 |
|
|
end loop;
|
571 |
|
|
|
572 |
|
|
ahbso.hconfig <= hconfig;
|
573 |
|
|
ahbso.hresp <= HRESP_OKAY;
|
574 |
|
|
ahbso.hready <= r.slv.hready;
|
575 |
|
|
if (clk2x = 0) then
|
576 |
|
|
ahbso.hrdata <= r.slv.hrdata;
|
577 |
|
|
else
|
578 |
|
|
ahbso.hrdata <= hrdata2x;
|
579 |
|
|
end if;
|
580 |
|
|
ahbso.hsplit <= (others => '0');
|
581 |
|
|
ahbso.hcache <= '0';
|
582 |
|
|
ahbso.hirq <= hirq;
|
583 |
|
|
ahbso.hindex <= hindex;
|
584 |
|
|
|
585 |
|
|
dsuo.active <= r.act;
|
586 |
|
|
dsuo.tstop <= tstop;
|
587 |
|
|
dsuo.pwd <= cpwd;
|
588 |
|
|
|
589 |
|
|
rhin <= vh;
|
590 |
|
|
|
591 |
|
|
end process;
|
592 |
|
|
|
593 |
|
|
comb2gen0 : if (clk2x /= 0) generate
|
594 |
|
|
ag0 : clkand generic map (tech => 0, ren => 0) port map (ahbsi.hmastlock, hclken, ahbsi2.hmastlock);
|
595 |
|
|
ag1 : clkand generic map (tech => 0, ren => 0) port map (ahbsi.hwrite, hclken, ahbsi2.hwrite);
|
596 |
|
|
ag2 : clkand generic map (tech => 0, ren => 0) port map (ahbsi.hready, hclken, ahbsi2.hready);
|
597 |
|
|
gen3 : for i in ahbsi.haddr'range generate
|
598 |
|
|
ag3 : clkand generic map (tech => 0, ren => 0) port map (ahbsi.haddr(i), hclken, ahbsi2.haddr(i));
|
599 |
|
|
end generate;
|
600 |
|
|
gen4 : for i in ahbsi.htrans'range generate
|
601 |
|
|
ag4 : clkand generic map (tech => 0, ren => 0) port map (ahbsi.htrans(i), hclken, ahbsi2.htrans(i));
|
602 |
|
|
end generate;
|
603 |
|
|
gen5 : for i in ahbsi.hwdata'range generate
|
604 |
|
|
ag5 : clkand generic map (tech => 0, ren => 0) port map (ahbsi.hwdata(i), hclken, ahbsi2.hwdata(i));
|
605 |
|
|
end generate;
|
606 |
|
|
gen6 : for i in ahbsi.hsize'range generate
|
607 |
|
|
ag6 : clkand generic map (tech => 0, ren => 0) port map (ahbsi.hsize(i), hclken, ahbsi2.hsize(i));
|
608 |
|
|
end generate;
|
609 |
|
|
gen7 : for i in ahbsi.hburst'range generate
|
610 |
|
|
ag7 : clkand generic map (tech => 0, ren => 0) port map (ahbsi.hburst(i), hclken, ahbsi2.hburst(i));
|
611 |
|
|
end generate;
|
612 |
|
|
gen8 : for i in ahbsi.hmaster'range generate
|
613 |
|
|
ag8 : clkand generic map (tech => 0, ren => 0) port map (ahbsi.hmaster(i), hclken, ahbsi2.hmaster(i));
|
614 |
|
|
end generate;
|
615 |
|
|
gen9 : for i in ahbsi.hsel'range generate
|
616 |
|
|
ag9 : clkand generic map (tech => 0, ren => 0) port map (ahbsi.hsel(i), hclken, ahbsi2.hsel(i));
|
617 |
|
|
end generate;
|
618 |
|
|
|
619 |
|
|
gen10 : for i in hrdata2x'range generate
|
620 |
|
|
ag10 : clkand generic map (tech => 0, ren => 0) port map (r.slv.hrdata(i), rh.oen, hrdata2x(i));
|
621 |
|
|
end generate;
|
622 |
|
|
|
623 |
|
|
reg2 : process(hclk)
|
624 |
|
|
begin
|
625 |
|
|
if rising_edge(hclk) then rh <= rhin; end if;
|
626 |
|
|
end process;
|
627 |
|
|
end generate;
|
628 |
|
|
|
629 |
|
|
comb2gen1 : if (clk2x = 0) generate
|
630 |
|
|
ahbsi2 <= ahbsi; rh.irq <= '0'; rh.oen <= '0'; hrdata2x <= (others => '0');
|
631 |
|
|
end generate;
|
632 |
|
|
|
633 |
|
|
reg : process(cpuclk)
|
634 |
|
|
begin
|
635 |
|
|
if rising_edge(cpuclk) then r <= rin; end if;
|
636 |
|
|
end process;
|
637 |
|
|
|
638 |
|
|
|
639 |
|
|
tb0 : if TRACEN generate
|
640 |
|
|
treg : process(cpuclk)
|
641 |
|
|
begin if rising_edge(cpuclk) then tr <= trin; end if; end process;
|
642 |
|
|
mem0 : tbufmem
|
643 |
|
|
generic map (tech => tech, tbuf => kbytes) port map (cpuclk, tbi, tbo);
|
644 |
|
|
-- pragma translate_off
|
645 |
|
|
bootmsg : report_version
|
646 |
|
|
generic map ("dsu3_" & tost(hindex) &
|
647 |
|
|
": LEON3 Debug support unit + AHB Trace Buffer, " & tost(kbytes) & " kbytes");
|
648 |
|
|
-- pragma translate_on
|
649 |
|
|
end generate;
|
650 |
|
|
|
651 |
|
|
notb : if not TRACEN generate
|
652 |
|
|
-- pragma translate_off
|
653 |
|
|
bootmsg : report_version
|
654 |
|
|
generic map ("dsu3_" & tost(hindex) &
|
655 |
|
|
": LEON3 Debug support unit");
|
656 |
|
|
-- pragma translate_on
|
657 |
|
|
end generate;
|
658 |
|
|
|
659 |
|
|
end;
|