⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mmu_dcache.vhd

📁 ARM7的源代码
💻 VHD
📖 第 1 页 / 共 4 页
字号:
          and (dcramov.dtramoutsn(i).tag = rs.addr(TAG_HIGH downto TAG_LOW))        then          if DSNOOP_FAST then-- pragma translate_off            if not is_x(rs.addr(OFFSET_HIGH downto OFFSET_LOW)) then-- pragma translate_on            vh.hit(conv_integer(rs.addr(OFFSET_HIGH downto OFFSET_LOW)))(i) := '1';--             vh.set := std_logic_vector(conv_unsigned(i, SETBITS));-- pragma translate_off            end if;-- pragma translate_on          else            snoopaddr := rs.addr(OFFSET_HIGH downto OFFSET_LOW);            snoopwe := '1'; snoopset := i;                  end if;        end if;      -- bypass tag data on read/write contention        if (not DSNOOP_FAST) and (rs.writebp(i) = '1') then           dcramov.dtramout(i).tag   := rs.addr(TAG_HIGH downto TAG_LOW);          dcramov.dtramout(i).valid := (others => '0');        end if;      end loop;    end if;-- generate access parameters during pipeline stall    if ((r.holdn) = '0') or (DEBUG_UNIT and (dci.dsuen = '1')) then      taddr := r.xaddress(OFFSET_HIGH downto LINE_LOW);      --if r.dsuwren = '0' then v.dsuwren := '1'; end if;    elsif ((dci.enaddr and not dci.read) = '1') or (eholdn = '0')    then      taddr := dci.maddress(OFFSET_HIGH downto LINE_LOW);    else      taddr := dci.eaddress(OFFSET_HIGH downto LINE_LOW);    end if;    if (dci.write or not r.holdn) = '1' then      maddress := r.xaddress(31 downto 0); signed := r.signed;       read := r.read; size := r.size; edata := dci.maddress;      mmudci_su := r.su; mmudci_read := r.read;    else      maddress := dci.maddress(31 downto 0); signed := dci.signed;       read := dci.read; size := dci.size; edata := dci.edata;      mmudci_su := dci.msu; mmudci_read := dci.read;    end if;    newtag := dci.maddress(TAG_HIGH downto TAG_LOW);    vl.waddr := maddress(OFFSET_HIGH downto OFFSET_LOW);  -- lru write address-- generate cache hit and valid bits    forcemiss := not dci.asi(3); hit := '0'; set := 0;     snoophit := (others => '0'); snoopval := '1';    for i in DSETS-1 downto 0 loop      if DSNOOP and DSNOOP_FAST then-- pragma translate_off        if not is_x(rh.taddr) then-- pragma translate_on                  snoophit(i) := rh.hit(conv_integer(rh.taddr))(i);-- pragma translate_off        end if;-- pragma translate_on      end if;      if (dcramov.dtramout(i).tag = dci.maddress(TAG_HIGH downto TAG_LOW)) and (tparerr(i) = '0') and        (((dcramov.dtramout(i).ctx = r.mmctrl1.ctx) or (r.mmctrl1.e = '0')) or (not M_EN))        then hitv(i) := '1'; end if; -- not r.flush; set := i; end if;      validrawv(i) := hitv(i) and (not r.flush) and (not snoophit(i)) and	genmux(dci.maddress(LINE_HIGH downto LINE_LOW), dcramov.dtramout(i).valid);      validv(i) :=  validrawv(i) and not dparerr(i);      if (hitv(i) and not snoophit(i)) = '1' then ivalid := ivalid or dcramov.dtramout(i).valid; end if;      snoopval := snoopval and not snoophit(i);    end loop;                  hit := orv(hitv) and not r.flush;    -- cache hit disabled if mmu-enabled but off or BYPASS    if (M_EN) and (dci.asi(4 downto 0) = ASI_MMU_BP) then  -- or (r.mmctrl1.e = '0')      hit := '0';    end if;        validraw := orv(validrawv);    valid := orv(validv);    if DSETS > 1 then       for i in DSETS-1 downto 0 loop         if hitv(i) = '1' then	  vset := vset or std_logic_vector(conv_unsigned(i, SETBITS));        end if;      end loop;      set := conv_integer(vset);    else set := 0; end if;    if (dci.dsuen and (not r.holdn)) = '1' then diagset := r.xaddress(TAG_LOW+SETBITS-1 downto TAG_LOW);    else diagset := maddress(TAG_LOW + SETBITS - 1 downto TAG_LOW); end if;-- pragma translate_off    if not is_x(diagset) then-- pragma translate_on      case DSETS is      when 1 => ddset := 0;      when 3 => if conv_integer(diagset) < 3 then ddset := conv_integer(diagset); end if;      when others => ddset := conv_integer(diagset);       end case;-- pragma translate_off    end if;--pragma translate_on        if ((r.holdn and dci.enaddr) = '1')  and (r.dstate = idle) then        v.hit := hit; v.xaddress := dci.maddress;	v.read := dci.read; v.size := dci.size;	v.asi := dci.asi(4 downto 0);  	v.signed := dci.signed; v.su := dci.msu;    end if;-- Store buffer--    wdata := r.wb.data1;    if mcdo.ready = '1' then      v.wb.addr(2) := r.wb.addr(2) or (r.wb.size(0) and r.wb.size(1));      if r.stpend = '1' then        v.stpend := r.req; v.wb.data1 := r.wb.data2; 	v.wb.lock := r.wb.lock and r.req;      end if;    end if;    if mcdo.grant = '1' then v.req := r.burst; v.burst := '0'; end if;-- main Dcache state machine    case r.dstate is    when idle =>			-- Idle state      if (snoopval = '1') then v.valid := dcramov.dtramout(set).valid;      else v.valid := (others => '0'); end if;      v.nomds := r.nomds and not eholdn; v.valid := dcramov.dtramout(set).valid;      if (r.stpend  = '0') or ((mcdo.ready and not r.req)= '1') then -- wait for store queue	v.wb.addr := dci.maddress; v.wb.size := dci.size; 	v.wb.read := dci.read; v.wb.data1 := dci.edata; v.wb.lock := dci.lock;	v.wb.asi := dci.asi(3 downto 0);       end if;      if (eholdn and (not r.nomds)) = '1' then -- avoid false path through nullify	if dci.asi(4 downto 0) = ASI_DTAG then rdatasel := dtag; end if;	if dci.asi(4 downto 0) = ASI_DDATA then rdatasel := dddata; end if;	if dci.asi(4 downto 0) = ASI_DCTX then rdatasel := dctx; end if;      end if;      if (dci.enaddr and eholdn and (not r.nomds) and not dci.nullify) = '1' then	case dci.asi(4 downto 0) is	when ASI_ITAG | ASI_IDATA | ASI_ICTX =>		-- Read/write Icache tags          -- CTX write has to be done through ctxnr & ASI_ITAG	  if (ico.flush = '1') or (dci.asi(4) = '1') then mexc := '1'; 	 else v.dstate := asi_idtag; v.holdn := '0'; end if; 	when ASI_IFLUSH =>		-- flush instruction cache	  if dci.read = '0' then iflush := '1'; end if; 	when ASI_DFLUSH =>		-- flush data cache	  if dci.read = '0' then flush := '1'; end if; 	when ASI_DDATA =>		-- Read/write Dcache data 	  if (dci.size /= "10") or (r.flush = '1') then -- only word access is allowed 	    mexc := '1'; 	  elsif (dci.read = '0') then 	    dwrite := '1'; ddiagwrite := '1'; 	  end if; 	when ASI_DTAG =>		-- Read/write Dcache tags 	  if (dci.size /= "10") or (r.flush = '1') then -- allow only word access 	    mexc := '1'; 	  elsif (dci.read = '0') then 	    twrite := '1'; tdiagwrite := '1'; 	  end if;        when ASI_DCTX =>          -- write has to be done through ctxnr & ASI_DTAG          if (dci.size /= "10") or (r.flush = '1') or (dci.read = '0') then -- allow only word access 	    mexc := '1'; 	  end if;        when ASI_FLUSH_PAGE => -- i/dcache flush page          if M_EN then            if dci.read = '0' then              flush := '1'; iflush := '1'; pflush := '1'; pflushtyp := PFLUSH_PAGE;            end if; 	  end if;        when ASI_FLUSH_CTX => -- i/dcache flush ctx          if M_EN then            if dci.read = '0' then              flush := '1'; iflush := '1'; pflush := '1'; pflushtyp := PFLUSH_CTX;            end if;          end if;        when ASI_MMUFLUSHPROBE =>          if M_EN then            if dci.read = '0' then      -- flush              mmudci_flush_op := '1';              v.flush_op := not mmudco.grant;              v.dstate := wflush;              v.vaddr := dci.maddress; v.holdn := '0'; flush := '1'; iflush := '1';            end if;          end if;        when ASI_MMU_DIAG =>          -- ASI_MMU_DIAG is not needed,          if M_EN and M_EN_DIAG then            if dci.read = '0' then      -- diag access              mmudci_diag_op := '1';              v.diag_op := not mmudco.grant;              v.vaddr := dci.maddress;            end if;          end if;          when ASI_MMU_DSU =>        when ASI_MMUREGS =>          if M_EN then            rdatasel := misc; mmuregw := not dci.read;            -- clean fault valid bit            if dci.read = '1' then              case dci.maddress(CNR_U downto CNR_D) is                when CNR_F =>                  mmudci_fsread := '1';                when others => null;              end case;            end if;          end if;	when others =>--          setrepl := std_logic_vector(conv_unsigned(set, SETBITS));	  if dci.read = '1' then	-- read access	    if (not ((mcdo.dcs(0) = '1') 	       and ((hit and valid and not forcemiss) = '1')))	    then	-- read miss	      v.holdn := '0'; v.dstate := wread; v.ready := '0'; v.cache := '1';              if (not M_EN) or                ((dci.asi(4 downto 0) = ASI_MMU_BP) or (r.mmctrl1.e = '0'))              then                -- cache disabled if mmu-enabled but off or BYPASS                if (M_EN) then v.cache := '0'; end if;                                if ((r.stpend  = '0') or ((mcdo.ready and not r.req) = '1'))                then	-- wait for store queue                                    v.req := '1';                  v.burst := dci.size(1) and dci.size(0) and not dci.maddress(2);                end if;              else                -- ## mmu case >                if (r.stpend  = '0') or ((mcdo.ready and not r.req)= '1')                then                  v.wbinit := '1';     -- wb init in idle                  v.burst := dci.size(1) and dci.size(0) and not dci.maddress(2);                else                  v.wbinit := '0';                end if;                                mmudci_trans_op := '1';  -- start translation                v.trans_op := not mmudco.grant;                v.vaddr := dci.maddress;                 v.dstate := rtrans;                -- ## < mmu case               end if;                          else       -- read hit              if (DSETS > 1) and (DCREPLACE = lru) then vl.write := '1'; end if;            end if;            	  else			-- write access            v.ready := '0';            if (not M_EN) or              ((dci.asi(4 downto 0) = ASI_MMU_BP) or (r.mmctrl1.e = '0')) then                                          if (r.stpend  = '0') or ((mcdo.ready and not r.req)= '1') then                v.req := '1'; v.stpend := '1';                 v.burst := dci.size(1) and dci.size(0);                if (dci.size = "11") then v.dstate := dblwrite; end if; -- double store	                    else		-- wait for store queue                v.dstate := wwrite; v.holdn := '0';              end if;            else              -- ## mmu case >              if (r.stpend  = '0') or ((mcdo.ready and not r.req)= '1')              then                v.wbinit := '1';     -- wb init in idle                v.burst := dci.size(1) and dci.size(0);                            else                v.wbinit := '0';              end if;                mmudci_trans_op := '1';  -- start translation              v.trans_op := not mmudco.grant;               v.vaddr := dci.maddress; v.holdn := '0';              v.dstate := wtrans;              v.dblwdata := dci.size(0) or dci.size(1);  -- "11"              -- ## < mmu case             end if;            -- note: cache hit disabled if BYPASS            if (mcdo.dcs(0) = '1') and ((hit and (dci.size(1) or validraw)) = '1')             then  -- write hit                            twrite := '1'; dwrite := '1';              if (DSETS > 1) and (DCREPLACE = lru) then vl.write := '1'; end if;              setrepl := std_logic_vector(conv_unsigned(set, SETBITS));            end if;	    if (dci.size = "11") then v.xaddress(2) := '1'; end if;	  end if;          if (DSETS > 1) then    	    vl.set := std_logic_vector(conv_unsigned(set, SETBITS));            v.setrepl := std_logic_vector(conv_unsigned(set, SETBITS));            if ((not hit) and (not dparerr(set)) and (not r.flush)) = '1' then              case DCREPLACE is              when rnd =>                if DCLOCK_BIT = 1 then                   if lock(conv_integer(r.rndcnt)) = '0' then v.setrepl := r.rndcnt;                  else                    v.setrepl := std_logic_vector(conv_unsigned(DSETS-1, SETBITS));                    for i in DSETS-1 downto 0 loop                      if (lock(i) = '0') and (i>conv_integer(r.rndcnt)) then                        v.setrepl := std_logic_vector(conv_unsigned(i, SETBITS));                      end if;                    end loop;                  end if;                else                  v.setrepl := r.rndcnt;                end if;              when lru =>-- pragma translate_off      		if not is_x(dci.maddress(OFFSET_HIGH downto OFFSET_LOW)) then-- pragma translate_on                          v.setrepl := lru_set(rl.lru(conv_integer(dci.maddress(OFFSET_HIGH downto OFFSET_LOW))), lock(0 to DSETS-1));-- pragma translate_off      		end if;-- pragma translate_on                      when lrr =>                v.setrepl := (others => '0');                if DCLOCK_BIT = 1 then                   if lock(0) = '1' then v.setrepl(0) := '1';                  else                    v.setrepl(0) := dcramov.dtramout(0).lrr xor dcramov.dtramout(1).lrr;                  end if;                else                  v.setrepl(0) := dcramov.dtramout(0).lrr xor dcramov.dtramout(1).lrr;                end if;                if v.setrepl(0) = '0' then                  v.lrr := not dcramov.dtramout(0).lrr;                else                  v.lrr := dcramov.dtramout(0).lrr;                end if;              end case;            end if;            if (DCLOCK_BIT = 1) then              if (hit and (not dparerr(set)) and lock(set)) = '1' then v.lock := '1';              else v.lock := '0'; end if;            end if;                        end if;        end case;      end if;    when rtrans =>      if M_EN then        if r.stpend = '1' then          if ((mcdo.ready and not r.req) = '1') then	            v.ready := '1';       -- buffer store finish          end if;        end if;                v.holdn := '0';        if mmudco.transdata.finish = '1' then          -- translation error, i.e. page fault          if (mmudco.transdata.accexc) = '1' then            v.holdn := '1'; v.dstate := idle;            mds := '0'; mexc := not r.mmctrl1.nf;          else            v.dstate := wread;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -