Vhdl 测试台中的输入分配和输出值(ghdl和gtkwave)
我将直接讨论细节 我正在使用Ubuntu 14.04LTS、GHDL编译器和GTKWave进行模拟 我有两个文件用于模拟简单的双多路复用器:mux2.vhd和mux2_testbench.vhd 这是mux2.vhd的代码Vhdl 测试台中的输入分配和输出值(ghdl和gtkwave),vhdl,ghdl,gtkwave,Vhdl,Ghdl,Gtkwave,我将直接讨论细节 我正在使用Ubuntu 14.04LTS、GHDL编译器和GTKWave进行模拟 我有两个文件用于模拟简单的双多路复用器:mux2.vhd和mux2_testbench.vhd 这是mux2.vhd的代码 -- Libraries library ieee; use ieee.std_logic_1164.all; -- Entity declaration entity mux2 is port( e0, e1 : in std_logic;
-- Libraries
library ieee;
use ieee.std_logic_1164.all;
-- Entity declaration
entity mux2 is
port(
e0, e1 : in std_logic;
c : in std_logic;
output : out std_logic
);
end mux2;
-- Architecture declaration
architecture mux2_arch of mux2 is
begin
process (e0, e1, c)
begin
if c = '0' then
output <= e0;
else
output <= e1;
end if;
end process;
end mux2_arch;
--库
图书馆ieee;
使用ieee.std_logic_1164.all;
--实体声明
实体mux2是
港口(
e0,e1:标准_逻辑中;
c:标准逻辑;
输出:输出标准逻辑
);
末端mux2;
--架构声明
mux2的建筑mux2_拱为
开始
工艺(e0、e1、c)
开始
如果c='0',则
输出e0,
e1=>e1,
输出=>输出
);
过程
开始
--情况1:控制信号低
c首先,'U'
是类型std\U逻辑的默认值。这意味着未初始化。任何未分配或未驱动的信号将具有值'U'
。我认为很有可能您的输出没有被驱动,因为您已经实例化了一个名为test
的组件,而您正在测试的设备实体
名为mux2
。我建议将组件的名称更改为mux2
,然后默认绑定规则将使实体mux2
能够绑定到组件mux2
:
component mux2 is
port( c : in std_logic;
e0, e1 : in std_logic;
output : out std_logic );
end component;
及
因此,实体
mux2
没有绑定到组件
测试
。将组件
想象成一个IC插座;将一个实体
想象成一个插入插座的IC。如果您的组件
被称为测试
,而您的实体
被称为mux2
,那么模拟器如何知道将两者绑定(即连接)在一起?您可以编写所谓的配置
来执行此绑定,但是将组件
名称更改为mux2
会容易得多,然后这将自动发生
(或者更好的是,为什么要使用组件实例化?为什么要麻烦组件?为什么不改用直接实例化?)
第二,很明显你不是在开e1。肯定是这样的:
e0 <= '0';
e0 <= '1';
e0为了与Brian的评论保持一致,我添加了一个配置规范,以使用mux2代替测试台中的测试:
architecture testbench_arch of mux2_testbench is
component test is
port (
c: in std_logic;
e0, e1: in std_logic;
output: out std_logic
);
end component;
signal c: std_logic;
constant clk: time := 50 ns;
signal e0: std_logic;
signal e1: std_logic;
signal output: std_logic;
for lab: test use entity work.mux2; -- added
begin
lab:
test
port map (
c => c,
e0 => e0,
e1 => e1,
output => output
);
process
begin
--Case 1: Control signal is low
c <= '0';
e0 <= '0';
e1 <= '0';
wait for 100 ns;
e0 <= '0';
e0 <= '1';
wait for 100 ns;
e0 <= '1';
e0 <= '0';
wait for 100 ns;
e0 <= '1';
e0 <= '1';
wait for 100 ns;
--Case 2: Control signal is high
c <= '1';
e0 <= '0';
e1 <= '0';
wait for 100 ns;
e0 <= '0';
e0 <= '1';
wait for 100 ns;
e0 <= '1';
e0 <= '0';
wait for 100 ns;
e0 <= '1';
e0 <= '1';
wait for 100 ns; -- added to terminate the simulation
wait; -- added ""
end process;
end architecture testbench_arch;
mux2测试台的架构测试台是
组件测试是
港口(
c:标准逻辑;
e0,e1:标准_逻辑中;
输出:输出标准逻辑
);
端部元件;
信号c:标准逻辑;
恒定时钟:时间:=50纳秒;
信号e0:std_逻辑;
信号e1:std_逻辑;
信号输出:std_逻辑;
对于实验室:测试使用实体work.mux2;——补充
开始
实验室:
测试
港口地图(
c=>c,
e0=>e0,
e1=>e1,
输出=>输出
);
过程
开始
--情况1:控制信号低
c哪一行将“0”以外的内容写入e1?没有我能看到的。。。是否存在复制/粘贴错误?此外,我没有看到组件“测试”的实体/拱门。请格式化您的代码。
-- this is direct instantiation
lab: entity work.mux2
port map(
c => c,
e0 => e0,
e1 => e1,
output => output
);
e0 <= '0';
e0 <= '1';
e0 <= '0';
e1 <= '1';
-- ^
-- |
architecture testbench_arch of mux2_testbench is
component test is
port (
c: in std_logic;
e0, e1: in std_logic;
output: out std_logic
);
end component;
signal c: std_logic;
constant clk: time := 50 ns;
signal e0: std_logic;
signal e1: std_logic;
signal output: std_logic;
for lab: test use entity work.mux2; -- added
begin
lab:
test
port map (
c => c,
e0 => e0,
e1 => e1,
output => output
);
process
begin
--Case 1: Control signal is low
c <= '0';
e0 <= '0';
e1 <= '0';
wait for 100 ns;
e0 <= '0';
e0 <= '1';
wait for 100 ns;
e0 <= '1';
e0 <= '0';
wait for 100 ns;
e0 <= '1';
e0 <= '1';
wait for 100 ns;
--Case 2: Control signal is high
c <= '1';
e0 <= '0';
e1 <= '0';
wait for 100 ns;
e0 <= '0';
e0 <= '1';
wait for 100 ns;
e0 <= '1';
e0 <= '0';
wait for 100 ns;
e0 <= '1';
e0 <= '1';
wait for 100 ns; -- added to terminate the simulation
wait; -- added ""
end process;
end architecture testbench_arch;