📄 iu3.vhd
字号:
begin err := not r.w.s.et; if (((dbgi.dbreak = '1') and (tt = ("00" & TT_WATCH))) or ((dbgi.bsoft = '1') and (tt = ("10000001")))) then err := '0'; end if; return(err); end; procedure diagwr(r : in registers; dsur : in dsu_registers; ir : in irestart_register; dbg : in l3_debug_in_type; wpr : in watchpoint_registers; s : out special_register_type; vwpr : out watchpoint_registers; asi : out std_logic_vector(7 downto 0); pc, npc : out pctype; tbufcnt : out std_logic_vector(TBUFBITS-1 downto 0); wr : out std_ulogic; addr : out std_logic_vector(9 downto 0); data : out word; fpcwr : out std_ulogic) is variable i : integer range 0 to 3; begin s := r.w.s; pc := r.f.pc; npc := ir.addr; wr := '0'; vwpr := wpr; asi := dsur.asi; addr := (others => '0'); data := dbg.ddata; tbufcnt := dsur.tbufcnt; fpcwr := '0'; if (dbg.dsuen and dbg.denable and dbg.dwrite) = '1' then case dbg.daddr(23 downto 20) is when "0001" => if (dbg.daddr(16) = '1') and TRACEBUF then -- trace buffer control reg tbufcnt := dbg.ddata(TBUFBITS-1 downto 0); end if; when "0011" => -- IU reg file if dbg.daddr(12) = '0' then wr := '1'; addr := (others => '0'); addr(RFBITS-1 downto 0) := dbg.daddr(RFBITS+1 downto 2); else -- FPC fpcwr := '1'; end if; when "0100" => -- IU special registers case dbg.daddr(7 downto 6) is when "00" => -- IU regs Y - TBUF ctrl reg case dbg.daddr(5 downto 2) is when "0000" => -- Y s.y := dbg.ddata; when "0001" => -- PSR s.cwp := dbg.ddata(NWINLOG2-1 downto 0); s.icc := dbg.ddata(23 downto 20); s.ec := dbg.ddata(13); if FPEN then s.ef := dbg.ddata(12); end if; s.pil := dbg.ddata(11 downto 8); s.s := dbg.ddata(7); s.ps := dbg.ddata(6); s.et := dbg.ddata(5); when "0010" => -- WIM s.wim := dbg.ddata(NWIN-1 downto 0); when "0011" => -- TBR s.tba := dbg.ddata(31 downto 12); s.tt := dbg.ddata(11 downto 4); when "0100" => -- PC pc := dbg.ddata(31 downto PCLOW); when "0101" => -- NPC npc := dbg.ddata(31 downto PCLOW); when "0110" => --FSR fpcwr := '1'; when "0111" => --CFSR when "1001" => -- ASI reg asi := dbg.ddata(7 downto 0); --when "1001" => -- TBUF ctrl reg -- tbufcnt := dbg.ddata(TBUFBITS-1 downto 0); when others => end case; when "01" => -- ASR16 - ASR31 case dbg.daddr(5 downto 2) is when "0001" => -- %ASR17 s.dwt := dbg.ddata(14); s.svt := dbg.ddata(13); when "0010" => -- %ASR18 if MACEN then s.asr18 := dbg.ddata; end if; when "1000" => -- %ASR24 - %ASR31 vwpr(0).addr := dbg.ddata(31 downto 2); vwpr(0).exec := dbg.ddata(0); when "1001" => vwpr(0).mask := dbg.ddata(31 downto 2); vwpr(0).load := dbg.ddata(1); vwpr(0).store := dbg.ddata(0); when "1010" => vwpr(1).addr := dbg.ddata(31 downto 2); vwpr(1).exec := dbg.ddata(0); when "1011" => vwpr(1).mask := dbg.ddata(31 downto 2); vwpr(1).load := dbg.ddata(1); vwpr(1).store := dbg.ddata(0); when "1100" => vwpr(2).addr := dbg.ddata(31 downto 2); vwpr(2).exec := dbg.ddata(0); when "1101" => vwpr(2).mask := dbg.ddata(31 downto 2); vwpr(2).load := dbg.ddata(1); vwpr(2).store := dbg.ddata(0); when "1110" => vwpr(3).addr := dbg.ddata(31 downto 2); vwpr(3).exec := dbg.ddata(0); when "1111" => -- vwpr(3).mask := dbg.ddata(31 downto 2); vwpr(3).load := dbg.ddata(1); vwpr(3).store := dbg.ddata(0); when others => -- end case;-- disabled due to bug in XST-- i := conv_integer(dbg.daddr(4 downto 3)); -- if dbg.daddr(2) = '0' then-- vwpr(i).addr := dbg.ddata(31 downto 2);-- vwpr(i).exec := dbg.ddata(0); -- else-- vwpr(i).mask := dbg.ddata(31 downto 2);-- vwpr(i).load := dbg.ddata(1);-- vwpr(i).store := dbg.ddata(0); -- end if; when others => end case; when others => end case; end if; end; function asr17_gen ( r : in registers) return word is variable asr17 : word; variable fpu2 : integer range 0 to 3; begin asr17 := zero32; asr17(31 downto 28) := conv_std_logic_vector(index, 4); if (clk2x > 8) then asr17(16 downto 15) := conv_std_logic_vector(clk2x-8, 2); asr17(17) := '1'; elsif (clk2x > 0) then asr17(16 downto 15) := conv_std_logic_vector(clk2x, 2); end if; asr17(14) := r.w.s.dwt; if svt = 1 then asr17(13) := r.w.s.svt; end if; if lddel = 2 then asr17(12) := '1'; end if; if (fpu > 0) and (fpu < 8) then fpu2 := 1; elsif (fpu >= 8) and (fpu < 15) then fpu2 := 3; elsif fpu = 15 then fpu2 := 2; else fpu2 := 0; end if; asr17(11 downto 10) := conv_std_logic_vector(fpu2, 2); if mac = 1 then asr17(9) := '1'; end if; if v8 /= 0 then asr17(8) := '1'; end if; asr17(7 downto 5) := conv_std_logic_vector(nwp, 3); asr17(4 downto 0) := conv_std_logic_vector(nwin-1, 5); return(asr17); end; procedure diagread(dbgi : in l3_debug_in_type; r : in registers; dsur : in dsu_registers; ir : in irestart_register; wpr : in watchpoint_registers; dco : in dcache_out_type; tbufo : in tracebuf_out_type; data : out word) is variable cwp : std_logic_vector(4 downto 0); variable rd : std_logic_vector(4 downto 0); variable i : integer range 0 to 3; begin data := (others => '0'); cwp := (others => '0'); cwp(NWINLOG2-1 downto 0) := r.w.s.cwp; case dbgi.daddr(22 downto 20) is when "001" => -- trace buffer if TRACEBUF then if dbgi.daddr(16) = '1' then -- trace buffer control reg if TRACEBUF then data(TBUFBITS-1 downto 0) := dsur.tbufcnt; end if; else case dbgi.daddr(3 downto 2) is when "00" => data := tbufo.data(127 downto 96); when "01" => data := tbufo.data(95 downto 64); when "10" => data := tbufo.data(63 downto 32); when others => data := tbufo.data(31 downto 0); end case; end if; end if; when "011" => -- IU reg file if dbgi.daddr(12) = '0' then data := rfo.data1(31 downto 0); if (dbgi.daddr(11) = '1') and (is_fpga(fabtech) = 0) then data := rfo.data2(31 downto 0); end if; else data := fpo.dbg.data; end if; when "100" => -- IU regs case dbgi.daddr(7 downto 6) is when "00" => -- IU regs Y - TBUF ctrl reg case dbgi.daddr(5 downto 2) is when "0000" => data := r.w.s.y; when "0001" => data := conv_std_logic_vector(IMPL, 4) & conv_std_logic_vector(VER, 4) & r.w.s.icc & "000000" & r.w.s.ec & r.w.s.ef & r.w.s.pil & r.w.s.s & r.w.s.ps & r.w.s.et & cwp; when "0010" => data(NWIN-1 downto 0) := r.w.s.wim; when "0011" => data := r.w.s.tba & r.w.s.tt & "0000"; when "0100" => data(31 downto PCLOW) := r.f.pc; when "0101" => data(31 downto PCLOW) := ir.addr; when "0110" => -- FSR data := fpo.dbg.data; when "0111" => -- CPSR when "1000" => -- TT reg data(12 downto 4) := dsur.err & dsur.tt; when "1001" => -- ASI reg data(7 downto 0) := dsur.asi; when others => end case; when "01" => if dbgi.daddr(5) = '0' then -- %ASR17 if dbgi.daddr(4 downto 2) = "001" then -- %ASR17 data := asr17_gen(r); elsif MACEN and dbgi.daddr(4 downto 2) = "010" then -- %ASR18 data := r.w.s.asr18; end if; else -- %ASR24 - %ASR31 i := conv_integer(dbgi.daddr(4 downto 3)); -- if dbgi.daddr(2) = '0' then data(31 downto 2) := wpr(i).addr; data(0) := wpr(i).exec; else data(31 downto 2) := wpr(i).mask; data(1) := wpr(i).load; data(0) := wpr(i).store; end if; end if; when others => end case; when "111" => data := r.x.data(conv_integer(r.x.set)); when others => end case; end; procedure itrace(r : in registers; dsur : in dsu_registers; vdsu : in dsu_registers; res : in word; exc : in std_ulogic; dbgi : in l3_debug_in_type; error : in std_ulogic; trap : in std_ulogic; tbufcnt : out std_logic_vector(TBUFBITS-1 downto 0); di : out tracebuf_in_type) is variable meminst : std_ulogic; begin di.addr := (others => '0'); di.data := (others => '0'); di.enable := '0'; di.write := (others => '0'); tbufcnt := vdsu.tbufcnt; meminst := r.x.ctrl.inst(31) and r.x.ctrl.inst(30); if TRACEBUF then di.addr(TBUFBITS-1 downto 0) := dsur.tbufcnt; di.data(127) := '0'; di.data(126) := not r.x.ctrl.pv; di.data(125 downto 96) := dbgi.timer(29 downto 0); di.data(95 downto 64) := res; di.data(63 downto 34) := r.x.ctrl.pc(31 downto 2); di.data(33) := trap; di.data(32) := error; di.data(31 downto 0) := r.x.ctrl.inst; if (dbgi.tenable = '0') or (r.x.rstate = dsu2) then if ((dbgi.dsuen and dbgi.denable) = '1') and (dbgi.daddr(23 downto 20) & dbgi.daddr(16) = "00010") then di.enable := '1'; di.addr(TBUFBITS-1 downto 0) := dbgi.daddr(TBUFBITS-1+4 downto 4); if dbgi.dwrite = '1' then case dbgi.daddr(3 downto 2) is when "00" => di.write(3) := '1'; when "01" => di.write(2) := '1'; when "10" => di.write(1) := '1'; when others => di.write(0) := '1'; end case; di.data := dbgi.ddata & dbgi.ddata & dbgi.ddata & dbgi.ddata; end if; end if; elsif (not r.x.ctrl.annul and (r.x.ctrl.pv or meminst) and not r.x.debug) = '1' then di.enable := '1'; di.write := (others => '1'); tbufcnt := dsur.tbufcnt + 1; end if; di.diag := dco.testen & "000"; if dco.scanen = '1' then di.enable := '0'; end if; end if; end; procedure dbg_cache(holdn : in std_ulogic; dbgi : in l3_debug_in_type; r : in registers; dsur : in dsu_registers; mresult : in word; dci : in dc_in_type; mresult2 : out word; dci2 : out dc_in_type ) is begin mresult2 := mresult; dci2 := dci; dci2.dsuen := '0'; if DBGUNIT then if r.x.rstate = dsu2 then dci2.asi := dsur.asi; if (dbgi.daddr(22 downto 20) = "111") and (dbgi.dsuen = '1') then dci2.dsuen := (dbgi.denable or r.m.dci.dsuen) and not dsur.crdy(2); dci2.enaddr := dbgi.denable; dci2.size := "10"; dci2.read := '1'; dci2.write := '0'; if (dbgi.denable and not r.m.dci.enaddr) = '1' then mresult2 := (others => '0'); mresult2(19 downto 2) := dbgi.daddr(19 downto 2); else mresult2 := dbgi.ddata; end if; if dbgi.dwrite = '1' then dci2.read := '0'; dci2.write := '1'; end if; end if; end if; end if; end; procedure fpexack(r : in registers; fpexc : out std_ulogic) is begin fpexc := '0'; if FPEN then if r.x.ctrl.tt = TT_FPEXC then fpexc := '1'; end if; end if; end; procedure diagrdy(denable : in std_ulogic; dsur : in dsu_registers; dci : in dc_in_type; mds : in std_ulogic; ico : in icache_out_type; crdy : out std_logic_vector(2 downto 1)) is begin crdy := dsur.crdy(1) & '0'; if dci.dsuen = '1' then case dsur.asi(4 downto 0) is when ASI_ITAG | ASI_IDATA | ASI_UINST | ASI_SINST => crdy(2) := ico.diagrdy and not dsur.crdy(2); when ASI_DTAG | ASI_MMUSNOOP_DTAG | ASI_DDATA | ASI_UDATA | ASI_SDATA => crdy(1) := not denable and dci.enaddr and not dsur.crdy(1); when others => crdy(2) := dci.enaddr and denable; end case; end if;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -