在VHDL中,如何实现两个三态缓冲区通过上拉驱动同一管脚?
在VHDL中,如何实现两个三态通过上拉驱动同一管脚?我试着在Verilog中做同样的事情,它的合成没有任何问题:在VHDL中,如何实现两个三态缓冲区通过上拉驱动同一管脚?,vhdl,verilog,Vhdl,Verilog,在VHDL中,如何实现两个三态通过上拉驱动同一管脚?我试着在Verilog中做同样的事情,它的合成没有任何问题: `timescale 1ns/10ps module driver( input wire oe, input wire di, output tri1 do ); assign do = oe ? di : 1'bz; endmodule `timescale 1ns/10ps module top( input wire oe1,
`timescale 1ns/10ps
module driver(
input wire oe,
input wire di,
output tri1 do
);
assign do = oe ? di : 1'bz;
endmodule
`timescale 1ns/10ps
module top(
input wire oe1,
input wire di1,
input wire oe2,
input wire di2,
output tri1 do
);
driver driver1(
.oe (oe1),
.di (di1),
.do (do)
);
driver driver2(
.oe (oe2),
.di (di2),
.do (do)
);
endmodule
当我试图用VHDL写这篇文章时,我有点卡住了,因为VHDL我不知道如何将Verilog的tri1“pullup”映射到VHDL
library ieee;
use ieee.std_logic_1164.all;
entity driver is
port(
oe :in std_logic;
di :in std_logic;
do :out std_logic
);
end entity;
architecture rtl of driver is
begin
do <= di when (oe = '1') else 'Z';
end architecture;
library ieee;
use ieee.std_logic_1164.all;
entity top is
port(
oe1 :in std_logic;
di1 :in std_logic;
oe2 :in std_logic;
di2 :in std_logic;
do :out std_logic
);
end entity;
architecture rtl of top is
begin
driver1: entity work.driver
port map(
oe => oe1,
di => di1,
do => do
);
driver2: entity work.driver
port map(
oe => oe2,
di => di2,
do => do
);
-- QUESTION: signal 'do' doesn't pull up to 'H'
---when oe1='0' and oe2='0'..
-- How to fix it in VHDL to do this so that pulls up
-- like 'tri1' signal in the Verilog version of this code.
end architecture;
ieee库;
使用ieee.std_logic_1164.all;
实体驱动程序是
港口(
oe:标准逻辑;
di:标准逻辑中;
do:输出标准逻辑
);
终端实体;
驱动程序rtl的体系结构是
开始
做oe1,
di=>di1,
do=>do
);
驱动程序2:实体工作。驱动程序
港口地图(
oe=>oe2,
di=>di2,
do=>do
);
--问题:信号“do”没有拉到“H”
---当oe1='0'和oe2='0'。。
--如何在VHDL中修复它以实现此目的
--就像这段代码的Verilog版本中的“tri1”信号。
终端架构;
我尝试将driver中的“Z”改为“H”。。。这会导致合成失败,并警告多个驱动程序发出“do”信号
我尝试添加一行“do在顶层架构中添加这行怎么样:
do——实现上拉。。。
--这似乎是合成在vivado没有多个驱动程序错误。。。
-------------------------------------
--模块:上拉
-------------------------------------
图书馆ieee;
使用ieee.std_logic_1164.all;
--拉起
实体上拉是
港口(
di:标准逻辑中;
dz:输出标准逻辑
);
终端实体;
上拉的rtl体系结构是
开始
多兹
);
驱动程序2:实体工作。驱动程序
港口地图(
oe=>oe2,
di=>di2,
do=>doz
);
pullup:实体work.pullup
港口地图(
di=>doz,
dz=>do
);
--do“H”在FPGA内部的数字逻辑中没有任何意义,它只会转换为“1”。这里的问题是一个输出上有多个驱动程序。它实际上应该是inout。这不是问题,因为我只是驱动输出,而不是从中读取。多个驱动程序都可以,只要在用“0”驱动另一个驱动程序之前将一个驱动程序设置为“Z”或者“1”。此外,“H”对FPGA的IO也有意义,它是“弱1”…这就是假设一个上拉值在IO上改变“Z”值的方式,如果它有上拉值的话。(除了VHDL,我不知道如何实现它。)IO上的多个三态驱动程序的另一个问题是,合成工具足够智能,可以优化IOB上的多个三态缓冲区,这样在最终的网络列表中只有一个三态。是的。这是可行的…它不像我希望的那样自动化…例如在Verilog中,我只指定信号为“tri1”当它是“Z”时,公共汽车自动停到“H”。
-- implementing a pullup...
-- this appears to synthesize in vivado without multiple driver error...
-------------------------------------
-- module: pullup
-------------------------------------
library ieee;
use ieee.std_logic_1164.all;
-- pullup
entity pullup is
port(
di: in std_logic;
dz: out std_logic
);
end entity;
architecture rtl of pullup is
begin
dz <= 'H' when (di = 'Z') else di;
end architecture;
-------------------------------------
-- module: driver
-------------------------------------
library ieee;
use ieee.std_logic_1164.all;
entity driver is
port(
oe :in std_logic;
di :in std_logic;
do :out std_logic
);
end entity;
architecture rtl of driver is
begin
process(oe, di)
begin
if (oe = '1') then
do <= di;
else
do <= 'Z';
end if;
end process;
end architecture;
-------------------------------------
-- module: top
-------------------------------------
library ieee;
use ieee.std_logic_1164.all;
entity top is
port(
oe1 :in std_logic;
di1 :in std_logic;
oe2 :in std_logic;
di2 :in std_logic;
do :out std_logic
);
end entity;
architecture rtl of top is
signal doz: std_logic;
begin
driver1: entity work.driver
port map(
oe => oe1,
di => di1,
do => doz
);
driver2: entity work.driver
port map(
oe => oe2,
di => di2,
do => doz
);
pullup: entity work.pullup
port map(
di => doz,
dz => do
);
--do <= 'H' when (doz = 'Z') else doz;
end architecture;