|
本帖最后由 fpgaw 于 2010-11-19 06:37 编辑
--状态转换---
process(LCLK1)
begin
if LCLK1'event and LCLK1='1' then
sdram_current<=sdram_next;
end if;
end process;
----状态机逻辑---
process(ADS,LHOLD,LWDRD,ADDR_MSB,LBE)
begin
case sdram_current is
----------
when st0=> ready<='1';sdram_en<='0';
if (ADS='0' and LHOLD='1') then
ADDR_MSB(11 downto 0)<=LA(21 downto 10);
sdram_next<=st1;
else
sdram_next<=st0;
end if;
----------
when st1=> sdram_en<='0';
if (ADS='1') then
ready<='0';
sdram_next<=st2;
else
ready<='1';
sdram_next<=st1;--ADS=0
end if;
-----------
when st2=> sdram_en<='0';
if (ADDR_MSB(11 downto 0)="000000000011" and LBE(3 downto 0)="1111") then
sdram_addr(7 downto 0)<=LA(9 downto 2);
sdram_next<=st3;--valid address
else
sdram_addr(7 downto 0)<=sdram_addr(7 downto 0);
sdram_next<=st0;--invalid address
end if;
-----------
when st3=> ready<='0';
if(LWDRD='1') then
sdram_we<='1';--write data
elsif(LWDRD='0') then
sdram_we<='0';--read data
end if;
sdram_next<=st4;
------------
when st4=> ready<='0';
sdram_en<='1'; ---enable sdram chip select
sdram_next<=st5;
------------
when st5=> ready<='1';
sdram_en<='0';
sdram_next<=st0;--finish one time operation
------------
when others=> ready<='1';
sdram_en<='0';
sdram_next<=st0;
------------
end case;
end process; |
|