|
发表于 2010-3-16 21:16:31
|
显示全部楼层
我太笨,找了个VHD转不成功,代码是我六年前写的EPP接口500K的采集
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity controler is
port(clock:in std_logic;
reset:in std_logic;
inclk:buffer std_logic;
--OE:buffer std_logic;--------------
--SEL:buffer std_logic;-------------
ndata:in std_logic;
din:in std_logic_vector(7 downto 0);
outclk:buffer std_logic;
dout:out std_logic_vector(7 downto 0);
ramwr:buffer std_logic;
waitout:buffer std_logic;
addressbus:out std_logic_vector(12 downto 0);
ramoe:buffer std_logic);
end;
architecture work of controler is
signal count:std_logic_vector(4 downto 0);
signal sel: std_logic;
signal oe: std_logic;
signal wpointer:std_logic_vector(12 downto 0);
signal rpointer:std_logic_vector(12 downto 0);
signal ready:std_logic;
signal eppcount:std_logic_vector(1 downto 0);
begin
readdata:process(reset,clock,OUTCLK,RAMOE)
begin
if reset='1' then
count<="11101";
oe<='1';
--SEL<='0';
ramwr<='1';
ramoe<='1';
inclk<='0';
--sel<='1';
else
if rising_edge(clock) then
if count="11101" then
count<="00000";
inclk<='1';
RAMOE<='1';
oe<='0';
-- sel<='1';
else
count<=count+1;
end if;
if count="11100" then
oe<='0';
RAMOE<='1';
end if;
if count="00000" then
ramwr<='0';
end if;
if count="00001" then
ramwr<='1';
oe<='1';
inclk<='0';
RAMOE<='0';
end if;
IF COUNT>"00001" THEN
IF RPOINTER=WPOINTER THEN
OE<='0';
--SEL<='1';
RAMOE<='1';
ELSE
--IF COUNT/="11100" THEN
--RAMOE<='0';????????????????????????????(要修)
--END IF;
END IF;
END IF;
end if;
end if;
end process readdata;
outctrl:process(INCLK,din)
begin
--IF OE='0' THEN
-- if sel='0' AND INCLK='0' then
-- dout<="00000000";
-- elsE
-- IF INCLK/='1' THEN
-- dout<=din;
-- END IF;
-- END IF;
--ELSIF OE='1' THEN
-- dout<="ZZZZZZZZ";
--end if;
if inclk='1' then
if din="00000000" then
dout<="00000001";
else
dout<=din;
end if;
else
if ramoe='1' then
dout<="00000000";
else
dout<="ZZZZZZZZ";
end if;
end if;
--if inclk='0' then
-- if ramoe='0' then
-- dout<="ZZZZZZZZ";
-- else
-- dout<="00000000";
-- end if;
--end if;
end process outctrl;
waddress:process(ramwr,reset)
begin
if reset='1' then
wpointer<="0000000000000";
else
if rising_edge(ramwr) then
wpointer<=wpointer+1;
end if;
end if;
end process waddress;
raddress:process(reset,outclk,ramoe)
begin
if reset='1' then
rpointer<="0000000000000";
else
if FALLING_edge(OUTCLK) then
if ramoe='0' then
rpointer<=rpointer+1;
end if;
end if;
end if;
end process raddress;
addresscom:process(wpointer,rpointer)
begin
if wpointer=rpointer then
SEL<='0';
else
SEL<='1';
end if;
end process addresscom;
addressout:process(wpointer,rpointer,inclk)
begin
if inclk='1' then
addressbus<=wpointer;
else
addressbus<=rpointer;
end if;
end process addressout;
eppread:process(clock,ndata,inclk,eppcount)
begin
if inclk='0' then
if ndata='0' then
if rising_edge(clock) then
if ready='1' then
if eppcount="00" then
IF (COUNT>"00001" and count<"11100") THEN
outclk<='1';
eppcount<=eppcount+1;
END IF;
end if;
if eppcount="01" then
outclk<='0';
waitout<='1';
eppcount<=eppcount+1;
end if;
else
ready<='1';
eppcount<="00";
end if;
end if;
else
if ndata='1' then
--if rising_edge(clock) then
waitout<='0';
ready<='0';
--end if;
end if;
end if;
end if;
end process eppread;
end work; |
|