|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity XC2S151 is
Port (
CLK : IN STD_LOGIC ; --CLK
A : IN STD_LOGIC_VECTOR(10 DOWNTO 0); --A0-A10 ADD
IOR1 : IN STD_LOGIC ; --Read Signal
IOW1 : IN STD_LOGIC ; --Writ Signal
AEN1 : IN STD_LOGIC ; --Add Free
Y1 : OUT STD_LOGIC; --74F245
Y2 : OUT STD_LOGIC; --74F273
Y3 : OUT STD_LOGIC; --74F244
Y4 : OUT STD_LOGIC; --74F244
Y5 : OUT STD_LOGIC; --74F244
IO16 : OUT STD_LOGIC; --16IO
CP5,CP6:OUT STD_LOGIC;--
DIRX,DIRY,DIRZ,DIRA,DIRB,PLUSEY,PLUSEZ,PLUSEA,PLUSEB : OUT STD_LOGIC;
PLUSEX: OUT STD_LOGIC;
I: INOUT STD_LOGIC_VECTOR(13 DOWNTO 0) --D0-D15
);
end XC2S151;
architecture Behavioral of XC2S151 is
SIGNAL BUF2:STD_LOGIC_VECTOR (13 DOWNTO 0);
SIGNAL BUFY1,BUFY2 :STD_LOGIC_VECTOR (13 DOWNTO 0);-- unsigned (15 DOWNTO 0)
SIGNAL Y10,Y11,Y12,Y13:STD_LOGIC;
SIGNAL ADD : STD_LOGIC_VECTOR (13 DOWNTO 0); --ADD+IOR+IOW+AED
SIGNAL OUTPUT : STD_LOGIC_VECTOR (10 DOWNTO 0); --OUTPUT CONECL
SIGNAL BUF1:STD_LOGIC; --sign
SIGNAL STAGESBUF1:STD_LOGIC_VECTOR (13 DOWNTO 0);
SIGNAL ORDER1:STD_LOGIC_VECTOR (13 DOWNTO 0);
SIGNAL QN :STD_LOGIC_VECTOR (3 DOWNTO 0);
SIGNAL CLK1,CLK2,RST:STD_LOGIC;
SIGNAL COUNTER :STD_LOGIC_VECTOR (15 DOWNTO 0);
SIGNAL DLY :STD_LOGIC;
SIGNAL XBUF,YBUF,XBUF1,YBUF1,XBUF2,YBUF2:STD_LOGIC;
SIGNAL XAXA2:STD_LOGIC;
begin
ADD(13)<=A(10); -- \
ADD(12)<=A(9); -- |
ADD(11)<=A(8); -- |
ADD(10)<=A(7); -- |
ADD(9)<=A(6); -- |
ADD(8)<=A(5); -- |
ADD(7)<=A(4); -- > ADD
ADD(6)<=A(3); -- |
ADD(5)<=A(2); -- |
ADD(4)<=A(1); -- |
ADD(3)<=A(0); -- |
ADD(2)<=IOR1; -- |
ADD(1)<=IOW1; -- |
ADD(0)<=AEN1; -- /
OUTPUT<="00010111100" WHEN ADD="01100000000010" ELSE --300 --read BUFX status
"01001111100" WHEN ADD="01100000010100" ELSE --302 --write stages
"00101111100" WHEN ADD="01100001010100" ELSE --30A --Y
"10001111100" WHEN ADD="01100001110010" ELSE --30E --Y
"00000111111" ;
Y13<=OUTPUT(10);
Y12<=OUTPUT(9);
Y11<=OUTPUT(8);
Y10<=OUTPUT(7);
Y5<=OUTPUT(5); --74F273
Y4<=OUTPUT(4); -- \
Y3<=OUTPUT(3); -- > OUTPUT
Y2<=OUTPUT(2);
Y1<=OUTPUT(1); --74F245
IO16<=OUTPUT(0); -- /
---Y10,Y11,Y12 为译码出来的片选。I为ISA数据总线
PROCESS(Y10)
BEGIN
IF Y10='1' THEN --0X300读标志0XEAAA表示记数器BUFY2为空,0XC000表示满。
I<=BUF2; --BUFY2都为偶数
ELSE
I<="ZZZZZZZZZZZZZZ";
END IF;
END PROCESS;
PROCESS(Y12)
BEGIN
IF Y12='1' THEN --写分频数
STAGESBUF1<=I
END IF;
END PROCESS;
PROCESS(CLK2,Y11,BUF2)
BEGIN
IF Y11='1' THEN
BUFY2<=I;
ELSIF BUF2="00000000000000" THEN
IF CLK2' EVENT AND CLK2='1' THEN
BUFY2<=BUFY2-1; --减一记数,到0停止。
XAXA2<=NOT XAXA2; --减两次输出一个脉冲。
END IF;
END IF;
END PROCESS;
BUF2<="10101010101010" WHEN BUFY2="00000000000000" ELSE
"00000000000000";
PROCESS(CP,RST)
BEGIN
IF RST='1'THEN
QN<="0000";
ELSIF CP' EVENT AND CP='1' THEN
QN<=QN+1;
END IF;
END PROCESS;
RST<='1' WHEN QN=10 ELSE
'0';
CP1<=QN(2);
PROCESS(CLK1) --分频
BEGIN
IF CLK1' EVENT AND CLK1='1' THEN
DLY<=COUNTER(15);
COUNTER<=COUNTER+STAGESBUF1;
END IF;
CLK2<=(COUNTER(15) XOR DLY) AND NOT CP1;
CP5<=CLK1;
END PROCESS;
PLUSEY<=XAXA2; --输出脉冲
end Behavioral;
0。5MS我读一次标志,为0XEAAA把分频数,记数器初值送入。送几万次都是正确的,但时间长了就会多或少几个。不知道是为什么??? |
|