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

📄 mctrl.vhd

📁 core_arm_latest.tar.gz源代码
💻 VHD
📖 第 1 页 / 共 2 页
字号:
	  v.hresp := HRESP_ERROR; v.bstate := berr; v.bdrive := (others => '1');	elsif r.read = '0' then 	  if (r.busw = "00") and (r.area /= io) and CFG_PERIMEM_BUS8EN then 	    v.bstate := bwrite8;	  elsif (r.busw = "01") and (r.area /= io) and CFG_PERIMEM_BUS16EN then 	    v.bstate := bwrite16;   	  else v.bstate := bwrite; end if;	  v.wrn := wrn; v.writen := '0'; v.bdrive := not bdrive;	else 	  if r.oen = '1' then v.ramoen := r.ramsn; v.oen := '0';	  else	    if (r.busw = "00") and (r.area /= io) and CFG_PERIMEM_BUS8EN then v.bstate := bread8;	    elsif (r.busw = "01") and (r.area /= io) and CFG_PERIMEM_BUS16EN then v.bstate := bread16;	    else v.bstate := bread; end if;	  end if;	end if;      end if;    when berr =>      v.bstate := idle; ready := '1';      v.hresp := HRESP_ERROR;      v.ramsn := (others => '1'); v.romsn := (others => '1'); v.psel(0) := '1';      v.ramoen := (others => '1'); v.oen := '1'; v.iosn := "11"; v.bdrive := (others => '1');    when bread =>       if ((r.ws = "0000") and (r.ready = '0') and (bready = '1'))      then 	if r.brmw = '0' then	  ready := '1'; v.address := ahbsi.haddr; v.echeck := '1';	end if;        if (((ahbsi.hsel = '0') or (ahbsi.htrans /= HTRANS_SEQ)) or (r.hburst = HBURST_SINGLE))        then  	  v.ramoen := (others => '1'); v.oen := '1'; v.iosn := "11";   	  v.bstate := idle; v.read := not r.hwrite;	  if r.brmw = '0' then  	    v.ramsn := (others => '1'); v.romsn := (others => '1'); 	    v.psel(0) := '1';	  else 	    v.echeck := '1'; 	  end if;	end if;      end if;      if r.ready = '1' then	v.ws := rws;      else	if r.ws /= "0000" then v.ws := r.ws - 1; end if;      end if;    when bwrite =>      if (r.ws = "0000") and (bready = '1') then	ready := '1'; v.wrn := (others => '1'); v.writen := '1'; v.echeck := '1';	v.ramsn := (others => '1'); v.romsn := (others => '1'); v.iosn := "11";	v.bdrive := (others => '1'); v.bstate := idle;	v.psel(0) := '1';      end if;      if r.ws /= "0000" then v.ws := r.ws - 1; end if;    when bread8 =>       if CFG_PERIMEM_BUS8EN then        if (r.ws = "0000") and (r.ready8 = '0') then	  v.ready8 := '1'; v.ws := rws; 	  v.address(1 downto 0) := r.address(1 downto 0) + 1;          if (r.address(1 downto 0) = "11") then	    ready := '1'; v.address := ahbsi.haddr; v.echeck := '1';            if (((ahbsi.hsel = '0') or (ahbsi.htrans /= HTRANS_SEQ)) or 	        (r.hburst = HBURST_SINGLE))            then  	      v.ramoen := (others => '1'); v.oen := '1'; v.iosn := "11";   	      v.bstate := idle;  	      v.ramsn := (others => '1'); v.romsn := (others => '1');	      v.psel(0) := '1';	    end if;          end if;        end if;        if (r.ready8 = '1') then v.ws := rws;        elsif r.ws /= "0000" then v.ws := r.ws - 1; end if;      else	v.bstate := idle;      end if;    when bwrite8 =>      if CFG_PERIMEM_BUS8EN then        if (r.ws = "0000") and (r.ready8 = '0') then 	  v.ready8 := '1'; v.wrn := (others => '1'); v.writen := '1';        end if;        if (r.ws = "0000") and            ((r.address(1 downto 0) = "11") or             ((r.address(1 downto 0) = "01") and (r.size = "01")) or	    (r.size = "00"))         then	  ready := '1'; v.wrn := (others => '1'); v.writen := '1'; v.echeck := '1';	  v.ramsn := (others => '1'); v.romsn := (others => '1'); v.iosn := "11";	  v.bdrive := (others => '1'); v.bstate := idle;	  v.psel(0) := '1';        end if;        if (r.ready8 = '1') then	  v.address(1 downto 0) := r.address(1 downto 0) + 1; v.ws := rws; --	  v.writedata(31 downto 8) := r.writedata(23 downto 0);	  v.writedata(31 downto 16) := r.writedata(23 downto 16) & r.writedata8(15 downto 8);	  v.writedata8(15 downto 8) := r.writedata8(7 downto 0);	  v.bstate := idle;         end if;        if r.ws /= "0000" then v.ws := r.ws - 1; end if;      else	v.bstate := idle;      end if;    when bread16 =>       if CFG_PERIMEM_BUS16EN then        if (r.ws = "0000") and ((r.address(1) or r.brmw) = '1') and 	   (r.ready8 = '0')         then	  if r.brmw = '0' then	    ready := '1'; v.address := ahbsi.haddr; v.echeck := '1';	  end if;          if (((ahbsi.hsel = '0') or (ahbsi.htrans /= HTRANS_SEQ)) or 	      (r.hburst = HBURST_SINGLE))          then	    if r.brmw = '0' then  	      v.ramsn := (others => '1'); v.romsn := (others => '1');	      v.psel(0) := '1';	    end if;  	    v.ramoen := (others => '1'); v.oen := '1'; v.iosn := "11";   	    v.bstate := idle; v.read := not r.hwrite;	  end if;        end if;        if (r.ws = "0000") and (r.ready8 = '0') then 	  v.ready8 := '1'; v.ws := rws; 	  if r.brmw = '0' then v.address(1) := not r.address(1); end if;        end if;        if r.ws /= "0000" then v.ws := r.ws - 1; end if;      else	v.bstate := idle;      end if;    when bwrite16 =>      if CFG_PERIMEM_BUS16EN then        if (r.ws = "0000") and            ((r.address(1 downto 0) = "10") or (r.size(1) = '0'))         then	  ready := '1'; v.wrn := (others => '1'); v.writen := '1'; v.echeck := '1';	  v.ramsn := (others => '1'); v.romsn := (others => '1'); v.iosn := "11";	  v.bdrive := (others => '1'); v.bstate := idle;	  v.psel(0) := '1';        end if;        if (r.ws = "0000") and (r.ready8 = '0') then 	  v.ready8 := '1'; v.wrn := (others => '1'); v.writen := '1';        end if;        if (r.ready8 = '1') then	  v.address(1) := not r.address(1); v.ws := rws; 	  v.writedata(31 downto 16) := r.writedata8(15 downto 0);	  v.bstate := idle;         end if;        if r.ws /= "0000" then v.ws := r.ws - 1; end if;      else	v.bstate := idle;      end if;    when others =>    end case;-- if BUSY or IDLE cycle seen, or if de-selected, return to idle state    if (ahbsi.hready = '1') then      if ((ahbsi.hsel = '0') or (ahbsi.htrans = HTRANS_BUSY) or 	(ahbsi.htrans = HTRANS_IDLE))      then        v.bstate := idle;        v.ramsn := (others => '1'); v.romsn := (others => '1');        v.ramoen := (others => '1'); v.oen := '1'; v.iosn := "11";        v.bdrive := (others => '1'); v.wrn := (others => '1');        v.writen := '1'; v.hsel := '0'; ready := ahbsi.hsel; v.srhsel := '0';	v.psel(0) := '1';      elsif srhsel = '1' then        v.romsn := romsn; v.ramsn(4 downto 0) := ramsn(4 downto 0); v.iosn := iosn & '1';        v.psel(0) := psel;        if v.read = '1' then v.ramoen(4 downto 0) := ramsn(4 downto 0); v.oen := leadin; end if;      end if;    end if;-- error checking and reporting    noerror := '1';    if ((r.echeck and r.mcfg1.bexcen and not r.bexcn) = '1') then      noerror := '0'; v.bstate := berr; v.hresp := HRESP_ERROR; v.bdrive := (others => '1');    end if;-- APB register access    case apbi.paddr(3 downto 2) is    when "00" =>       regsd(28 downto 0) := r.mcfg1.iowidth & 	r.mcfg1.brdyen & r.mcfg1.bexcen & "0" & r.mcfg1.iows & r.mcfg1.ioen &	'0' & 	"000000" & r.mcfg1.romwrite & 	'0' & r.mcfg1.romwidth & r.mcfg1.romwws & r.mcfg1.romrws;    when "01" =>       if CFG_PERIMEM_SDRAMEN then	regsd(31 downto 19) := sdapbo.prdata(31 downto 19);        regsd(14 downto 13) := r.mcfg2.sdren & r.mcfg2.srdis;      end if;      regsd(12 downto 9) := r.mcfg2.rambanksz;      if CFG_PERIMEM_RAMSEL5 then regsd(7) := r.mcfg2.brdyen; end if;      regsd(6 downto 0) := r.mcfg2.rmw & r.mcfg2.ramwidth & 	r.mcfg2.ramwws & r.mcfg2.ramrws;    when "10" =>       if CFG_PERIMEM_SDRAMEN then	regsd(26 downto 12) := sdapbo.prdata(26 downto 12);      end if;    when others => regsd := (others => '0');    end case;    apbo.prdata <= regsd;    if (apbi.psel and apbi.penable and apbi.pwrite) = '1' then      case apbi.paddr(5 downto 2) is      when "0000" =>         v.mcfg1.romrws      :=  apbi.pwdata(3 downto 0);         v.mcfg1.romwws      :=  apbi.pwdata(7 downto 4);        v.mcfg1.romwidth    :=  apbi.pwdata(9 downto 8);        v.mcfg1.romwrite    :=  apbi.pwdata(11);        v.mcfg1.ioen        :=  apbi.pwdata(19);        v.mcfg1.iows        :=  apbi.pwdata(23 downto 20);        v.mcfg1.bexcen      :=  apbi.pwdata(25);        v.mcfg1.brdyen      :=  apbi.pwdata(26);        v.mcfg1.iowidth     :=  apbi.pwdata(28 downto 27);      when "0001" =>         v.mcfg2.ramrws      := apbi.pwdata(1 downto 0);        v.mcfg2.ramwws      := apbi.pwdata(3 downto 2);        v.mcfg2.ramwidth    := apbi.pwdata(5 downto 4);        v.mcfg2.rmw         := apbi.pwdata(6);        v.mcfg2.brdyen      := apbi.pwdata(7);        v.mcfg2.rambanksz   := apbi.pwdata(12 downto 9);	if CFG_PERIMEM_SDRAMEN then          v.mcfg2.srdis       := apbi.pwdata(13);          v.mcfg2.sdren       := apbi.pwdata(14);	end if;      when others => null;      end case;    end if;-- select appropriate data during reads    case r.area is    when rom | ram =>       dataout := memdata;      if (r.area = rom) and (CFG_PERIMEM_BOOT /= perimem_memory) then	if (r.psel(0) = '0') then v.readdata := promdata; end if;        if r.psel(1) = '0' then dataout := r.readdata; end if;      end if;    when others =>      if CFG_PERIMEM_BUS8EN and (r.busw = "00") then        dataout := r.data(31 downto 24) & r.data(31 downto 24) 		 & r.data(31 downto 24) & r.data(31 downto 24);      elsif CFG_PERIMEM_BUS16EN and (r.busw = "01") then        dataout := r.data(31 downto 16) & r.data(31 downto 16);       else dataout := r.data; end if;    end case;    v.ready := ready;    v.srhsel := r.srhsel and not ready;    if ahbsi.hready = '1' then v.hsel := ahbsi.hsel; end if;    if ((ahbsi.hready and ahbsi.hsel) = '1') then      v.size := ahbsi.hsize(1 downto 0); v.hwrite := ahbsi.hwrite;      v.hburst := ahbsi.hburst; v.htrans := ahbsi.htrans;      if ahbsi.htrans(1) = '1' then v.hsel := '1'; v.srhsel := srhsel; end if;      if CFG_PERIMEM_SDRAMEN then 	v.haddr := ahbsi.haddr;      end if;    end if;-- sdram synchronisation    if CFG_PERIMEM_SDRAMEN then      if (r.bstate /= idle) then bidle := '0';      else        bidle := '1';        if (sdmo.busy and not sdmo.aload) = '1' then 	  v.address(16 downto 2) := sdmo.address;	  v.romsn := (others => '1'); v.ramsn(4 downto 0) := (others => '1'); 	  v.iosn := (others =>'1'); v.ramoen(4 downto 0) := (others => '1'); 	  v.oen := '1';          v.bdrive := not (sdmo.bdrive & sdmo.bdrive & sdmo.bdrive & sdmo.bdrive);	  v.hresp := sdmo.hresp;        end if;      end if;      if (sdmo.aload and r.srhsel) = '1' then        v.romsn := romsn; v.ramsn(4 downto 0) := ramsn(4 downto 0); v.iosn := iosn & '1';        v.psel(0) := psel;        if v.read = '1' then v.ramoen(4 downto 0) := ramsn(4 downto 0); v.oen := leadin; end if;      end if;      if sdmo.hsel = '1' then 	v.writedata := writedata;	hready := sdmo.hready and noerror and not r.brmw;      else hready := r.ready and noerror; end if;    else      hready := r.ready and noerror;    end if;-- use d(15:0) as I/O ports (only usefull in 8/16-bit mode)    if (CFG_PERIMEM_BUS8EN or CFG_PERIMEM_BUS16EN) then       mctrlo.pioh <= r.data(15 downto 0);      if ((r.mcfg1.romwidth(1) or r.mcfg1.iowidth(1) or r.mcfg2.ramwidth(1)) = '0')	 and ((r.mcfg2.sdren = '0') or not CFG_PERIMEM_SDRAMEN)      then        v.writedata(15 downto 0) := r.writedata(15 downto 0);        if pioo.wrio = '1' then 	  v.writedata(15 downto 0) := pioo.piol(31 downto 16);        end if;        v.wrn(3 downto 2) := "11";	v.bdrive(3 downto 2) := pioo.piodir(17 downto 16);      end if;    else mctrlo.pioh <= (others => '0'); end if;-- reset    if rst = '0' then      v.bstate 	 	   := idle;       v.read 		   := '1';       v.wrn                := "1111";      v.writen		   := '1';       v.mcfg1.romwrite     := '0';      v.mcfg1.ioen         := '0';      v.mcfg1.brdyen       := '0';      v.mcfg1.bexcen       := '0';      v.hsel		   := '0';      v.srhsel		   := '0';      if ((CFG_PERIMEM_BOOT = perimem_memory) or ((CFG_PERIMEM_BOOT = perimem_dual) and (pioo.io8lsb(4) = '0')))       then        v.mcfg1.romrws     := "1111";        v.mcfg1.romwws     := "1111";        v.mcfg1.romwidth   := pioo.io8lsb(1 downto 0);      else	v.mcfg2.ramrws	   := std_logic_vector(CFG_PERIMEM_BRAMRWS(1 downto 0));	v.mcfg2.ramwws	   := std_logic_vector(CFG_PERIMEM_BRAMWWS(1 downto 0));        v.mcfg1.romrws     := "0001";        v.mcfg1.romwws     := "0001";        v.mcfg1.romwidth   := "11";      end if;      v.mcfg2.srdis        := '0';      v.mcfg2.sdren        := '0';    end if;-- optional feeb-back from write stobe to data bus drivers    if CFG_PERIMEM_WENDFB then bdrive := r.bdrive and memi.wrn;    else bdrive := r.bdrive; end if;-- pragma translate_off    for i in dataout'range loop --'      if is_x(dataout(i)) then dataout(i) := '1'; end if;    end loop;-- pragma translate_on-- drive various register inputs and external outputs    ri <= v;     memo.address(27 downto 0) <= r.address(27 downto 0);    memo.ramsn(4 downto 0)  <= r.ramsn;    memo.ramoen(4 downto 0) <= r.ramoen;    memo.romsn       	<= r.romsn;    memo.oen  		<= r.oen;    memo.iosn  		<= r.iosn(0);    memo.read  		<= r.read;    memo.wrn 		<= r.wrn;     memo.writen 	<= r.writen;    memo.bdrive  	<= bdrive;    memo.data		<= r.writedata;    sdi.idle 		<= bidle;    sdi.haddr		<= haddr;    sdi.rhaddr		<= r.haddr;    sdi.nhtrans		<= htrans;    sdi.rhtrans		<= r.htrans;    sdi.htrans		<= ahbsi.htrans;    sdi.hready		<= ahbsi.hready;    sdi.hsize		<= r.size;    sdi.hwrite		<= r.hwrite;    sdi.hsel		<= sdhsel;    sdi.enable		<= r.mcfg2.sdren;    ahbso.hrdata <= dataout;    ahbso.hready <= hready;    ahbso.hresp  <= r.hresp;    ahbso.hsplit <= (others => '0');  end process;  stdregs : process(clk,rst)  begin     if rising_edge(clk) then r <= ri; end if;    if rst = '0' then      r.ramsn <= (others => '1'); r.romsn <= (others => '1');      r.oen <= '1'; r.bdrive <= (others => '1');      r.iosn <= "11"; r.ramoen <= (others => '1');    end if;  end process;-- optional boot-prom promgen : if (CFG_PERIMEM_BOOT /= perimem_memory) generate    bprom0 : bprom port map      (clk => clk, cs => r.psel(0), addr => r.address, data => promdata);  end generate;-- optional sdram controller  sd0 : if CFG_PERIMEM_SDRAMEN generate    sdctrl : sdmctrl port map ( rst => rst, clk => clk, sdi => sdi, 	sdo => sdo, apbi => apbi, apbo => sdapbo, wpo => wpo, sdmo => sdmo);  end generate;end;

⌨️ 快捷键说明

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