双向总线驱动器模块产生其一个单向三态数据收发器(TRI_GATE1)的VHDL语言设计如下
library ieee;
use ieee.std_logic_1164.all;
entity tri_gate1 is
port(a0,al,a2,a3:in std_ logic;
a:in std_logic_vector(15 downto 4);
en:in std_logic;
b0,b1,b2,b3:out std_logic;
b:out std_logic_vector(15 downto 4):
D0,D1,D2,D3:out std_logic);
--向模块2中送数据的4个输出端
end tri_gatel;
architecture behav of tri_gate1 is
begin
process
begin
if en='1' then --EN为高电平时收发器有效
b0<=a0;b1<=a1;b2<=a2;b3<=a3;b<=a;
D0<=a0;D1<=a1;D2<=a2;D3<=a3;
else --EN为低时高阻状态
b0<=一Z;b1<=-Z;b2<=-Z ;b3<='Z';b<="ZZZZZZZZZZZZ";
end if
end process;
end behav;
本模块要实现的功能是产生HS3282的读写信号和发送使能信号及一个送入PC104总线的输入输出16位芯片选择信号/IO16。该模块用VHDL语言输入,其相应的VHDL语言如下
library ieee;
use ieee.std logic_1164.all;
entity gal4243 is
port(MCS,XIOW,XIOR,A1,A2,A3,A4,ENT1,
ENT2,TXR1,TXR2: in std_logic;
WR0,W Rl,WR2,W R3,WR4,W R5,W R6:
out std_logic;
RD0,RD1,RD2,RD3,RD4:out std_logic;
IO16,ENTX1,ENTX2:out std_logic);
end gal4243;
architecture behav of gal4243 is
begin
process
begin
WR6<=XIOW or MCS or A4 or(not A3) or(not A2)or A1;
WR5<=XIOW or MCS or A4 or(not A3) or A2 or(not A1);
WR4<=XIOW or MCS or A4 or(not A3) or A2 or A1;
WR3<=XIOW or MCS or A4 or A3 or(not A2)or(not A1);
WR2<=XIOW or MCS or A4 or A3 or(not A2)or A1;
WR1<=XIOW or MCS or A4 or A3 or A2 or(not A1);
WR0<=XIOW or MCS or A4 orA3 or A2 or A1; --产生写信号
if MCS='0' then
IO16<=MCS;
else
IO16<='Z';
endif;
RD4<=XIOR or MCS or(notA4)orA3 or A2;
RD3<=XIOR or MCS or A4 or(not A3)or(not A2);
RD2<=XIOR or MCS or A4 or(not A3)or A2;
RDI<=XIOR or MCS or A4 or A3 or(not A2)
RD0<=XIOR or MCS or A4 or A3 orA2;--产生读信号
ENTX1<=ENT1 and(not TXR1);
ENTX2<=ENT2 and(not TXR2);--产生发送使能信号
end process;
end behav;
library ieee;
use ieee.std logic_1164.all;
entity U32 is
port(TXR1,DR11,DR12,TXR2,DR21,DR22,RD4:in std_logic;
D0,D1,D2,D3,D4,D5,INT:out std_logic);
end U32;
architecture behav of U32 is
begin
process
begin
if RD4='0' then
D0<=not DR11:
D1<=not DR12;
D2<=not DR21;
D3<=not DR22;
--产生中断时用来判断哪个接收器满
D4<=TXR1;
D5<=TXR2;
--用来判断哪一个发送缓冲区空
else
D0<='Z';D1<'Z';D2<='Z';D3<='Z';D4<='Z';D5<='Z';
endif;
INT<=not(DR11 and DR12 and DR21 and DR22); --有一个接收器满便产生中断
end process;
end behav;