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

📄 smc_mctrl.vhd

📁 ahb sdram interface.arm cpu series,include controller
💻 VHD
📖 第 1 页 / 共 3 页
字号:
    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 SDRAMEN then	regsd(31 downto 19) := sdapbo.prdata(31 downto 19);	if BUS64 then regsd(18) := '1'; end if;        regsd(14 downto 13) := r.mcfg2.sdren & r.mcfg2.srdis;      end if;      regsd(12 downto 9) := r.mcfg2.rambanksz;      if 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 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(pindex) 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 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    if (r.area(rom) or r.area(ram)) = '1' then dataout := memdata;    else      if 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 BUS16EN and (r.busw = "01") then        dataout := r.data(31 downto 16) & r.data(31 downto 16);       else dataout := r.data; end if;    end if;    v.ready := ready;    v.srhsel := r.srhsel and not ready;    if ahbsi.hready = '1' then v.hsel := ahbsi.hsel(hindex); end if;    if ((ahbsi.hready and ahbsi.hsel(hindex)) = '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 SDRAMEN then	v.haddr := ahbsi.haddr;      end if;    end if;-- sdram synchronisation    if SDRAMEN then      v.sa := sdmo.address; v.sd := memi.sd;      if (r.bstate /= idle) then bidle := '0';      else        bidle := '1';        if (sdmo.busy and not sdmo.aload) = '1' then          if not SDSEPBUS then            v.address(sdlsb + 14 downto sdlsb) := sdmo.address;          end if;	  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';        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;        v.sdwritedata(31 downto 0) := writedata;        if BUS64 and sdmo.bsel = '1' then          v.sdwritedata(63 downto 32) := writedata;        end if;         hready := sdmo.hready and noerror and not r.brmw;	if SDSEPBUS then	  if BUS64 and sdmo.bsel = '1' then dataout := r.sd(63 downto 32);	  else dataout := r.sd(31 downto 0); end if;	end if;      else hready := r.ready and noerror; end if;    else      hready := r.ready and noerror;    end if;        if v.read = '1' then v.mben := "0000"; else v.mben := v.wrn; end if;    v.nbdrive := not v.bdrive;    if oepol = 0 then      bdrive_sel := r.bdrive;      vbdrive(31 downto 24) := (others => v.bdrive(0));      vbdrive(23 downto 16) := (others => v.bdrive(1));      vbdrive(15 downto 8) := (others => v.bdrive(2));      vbdrive(7 downto 0) := (others => v.bdrive(3));      vsbdrive(31 downto 24) := (others => v.bdrive(0));      vsbdrive(23 downto 16) := (others => v.bdrive(1));      vsbdrive(15 downto 8) := (others => v.bdrive(2));      vsbdrive(7 downto 0) := (others => v.bdrive(3));            vsbdrive(63 downto 56) := (others => v.bdrive(0));      vsbdrive(55 downto 48) := (others => v.bdrive(1));      vsbdrive(47 downto 40) := (others => v.bdrive(2));      vsbdrive(39 downto 32) := (others => v.bdrive(3));    else      bdrive_sel := r.nbdrive;      vbdrive(31 downto 24) := (others => v.nbdrive(0));      vbdrive(23 downto 16) := (others => v.nbdrive(1));      vbdrive(15 downto 8) := (others => v.nbdrive(2));      vbdrive(7 downto 0) := (others => v.nbdrive(3));      vsbdrive(31 downto 24) := (others => v.nbdrive(0));      vsbdrive(23 downto 16) := (others => v.nbdrive(1));      vsbdrive(15 downto 8) := (others => v.nbdrive(2));      vsbdrive(7 downto 0) := (others => v.nbdrive(3));            vsbdrive(63 downto 56) := (others => v.nbdrive(0));      vsbdrive(55 downto 48) := (others => v.nbdrive(1));      vsbdrive(47 downto 40) := (others => v.nbdrive(2));      vsbdrive(39 downto 32) := (others => v.nbdrive(3));    end if;         -- for smc lan chip ********************************************    if (r.iosn(0) = '1' and v.iosn(0) = '0') then       v.eth_aen := '0';       v.eth_nbe := v.wrn and not (r.read&r.read&r.read&r.read);    elsif (r.iosn(0) = '1' and r.eth_aen = '0') then        v.eth_aen := '1';       v.eth_nbe := v.wrn;    end if;        if (r.eth_aen = '0' and v.iosn(0) = '0' and r.read = '1') then       v.eth_readn := '0';    else       v.eth_readn := '1';    end if;    if (r.eth_aen = '0' and v.iosn(0) = '0' and r.writen = '0') then       v.eth_writen := '0';    else       v.eth_writen := '1';    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';      v.ready		 := '1';      v.mcfg1.iows       := "0000";      v.mcfg2.ramrws     := "00";      v.mcfg2.ramwws     := "00";      v.mcfg1.romrws     := "1111";      v.mcfg1.romwws     := "1111";      v.mcfg1.romwidth   := memi.bwidth;      v.mcfg2.srdis      := '0';      v.mcfg2.sdren      := '0';      v.eth_aen      := '1'; -- for smsc eth      v.eth_readn    := '1'; -- for smsc eth      v.eth_writen   := '1'; -- for smsc eth      v.eth_nbe      := (others => '1'); -- for smsc eth      if syncrst = 1 then        v.ramsn := (others => '1'); v.romsn := (others => '1');        v.oen := '1'; v.iosn := "11"; v.ramoen := (others => '1');        v.bdrive := (others => '1'); v.nbdrive := (others => '0');        if oepol = 0 then vbdrive := (others => '1'); vsbdrive := (others => '1');        else vbdrive := (others => '0'); vsbdrive := (others => '0'); end if;       end if;    end if;-- optional feeb-back from write stobe to data bus drivers    if 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;    ribdrive <= vbdrive;    risbdrive <= vsbdrive;         ahbso.hcache <= not r.area(io);    memo.address <= r.address;    memo.sa <= r.sa;    memo.ramsn          <= "111" & r.ramsn;    memo.ramoen         <= "111" & r.ramoen;    memo.romsn       	<= "111111" & 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;    memo.sddata(31 downto 0)  <= r.sdwritedata(31 downto 0);    memo.sddata(63 downto 32) <= r.sdwritedata(63 downto 32);    memo.mben		<= r.mben;    memo.vbdrive        <= rbdrive;    memo.svbdrive       <= rsbdrive;    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;    sdi.srdis 		<= r.mcfg2.srdis;    ahbso.hrdata <= dataout;    ahbso.hready <= hready;    ahbso.hresp  <= r.hresp;    -- for smsc eth    eth_aen    <= r.eth_aen;    eth_readn  <= r.eth_readn;    eth_writen <= r.eth_writen;    eth_nbe    <= r.eth_nbe;   end process;  stdregs : process(clk,rst)  begin    if rising_edge(clk) then      r <= ri; rbdrive <= ribdrive; rsbdrive <= risbdrive;      if rst = '0' then r.ws <= (others => '0'); end if;     end if;    if (syncrst = 0) and (rst = '0') then      r.ramsn <= (others => '1'); r.romsn <= (others => '1');      r.oen <= '1'; r.iosn <= "11"; r.ramoen <= (others => '1');      r.bdrive <= (others => '1'); r.nbdrive <= (others => '0');      if oepol = 0 then rbdrive <= (others => '1'); rsbdrive <= (others => '1');      else rbdrive <= (others => '0'); rsbdrive <= (others => '0'); end if;     end if;  end process;  ahbso.hsplit <= (others => '0');  ahbso.hconfig <= hconfig;  ahbso.hirq    <= (others => '0');  ahbso.hindex <= hindex;  apbo.pconfig  <= pconfig;  apbo.pirq     <= (others => '0');  apbo.pindex   <= pindex;-- optional sdram controller  sd0 : if SDRAMEN generate    sdctrl : sdmctrl generic map (pindex, invclk, fast, wprot, sdbits)	port map ( rst => rst, clk => clk, sdi => sdi,	sdo => sdo, apbi => apbi, apbo => sdapbo, wpo => wpo, sdmo => sdmo);  end generate;  sd1 : if not SDRAMEN generate	sdo <= ("00", "11", '1', '1', '1', "11111111");        sdapbo <= apb_none;        --sdmo <= ((others => '0'), '0', '0', '0', '1', '0', "11");        sdmo.address <= (others => '0'); sdmo.busy <= '0';        sdmo.aload <= '0'; sdmo.bdrive <= '0'; sdmo.hready <= '1';        sdmo.hresp <= "11";  end generate;end;

⌨️ 快捷键说明

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