VHDL全加器测试台输出U.

时间:2013-10-28 03:57:14

标签: output simulation vhdl

我是一名vhdl newbie.i为只使用AND和OR门的全加器编写了编码。我创建了一个测试平台来测试我的代码,并将其配置为激活A,B和Cin的所有八种逻辑组合。当我运行模拟波形时,输入是正确的,但输出总和(在我的情况下为H)只显示“U”。请提出任何想法。

library ieee;
use ieee.std_logic_1164.all;

--This program describes behaviour of a full adder constructed using
-- AND and OR gates. It employs component method which describes behaviour of
--AND,OR and NOT gates and use them to build the final object


--Entity description of the full adder
  entity full_add is
  port (a,b,c:IN BIT; h:OUT BIT);
  end entity full_add;

--Description the 3 input And Gate

  entity And2 is
  port (j,k,l:in BIT; m:out BIT);
  end entity And2;

  architecture ex1 of And2 is
  begin
  m <= (j AND k AND l);
  end architecture ex1;

  --Description of the four input OR gate

   entity Or2 is
   port (d,e,f,g:IN BIT; h:OUT BIT);
   end entity Or2;

  architecture ex1 of Or2 is
  begin
  h <= (d or e or f or g);
  end architecture ex1;

--Description of the NOT gate

 entity Not1 is
 port(x:in BIT; y:out BIT);
 end entity Not1;

 architecture ex1 of Not1 is
 begin
 y <= not x;
 end architecture ex1;

--Components and wiring description

 architecture netlist of full_add is
 signal s,u,v,s2,u2,v2,w2:BIT;
 begin
 g1:entity WORK.Not1(ex1) port map(a,s);
 g2:entity WORK.Not1(ex1) port map(b,u);
 g3:entity WORK.Not1(ex1) port map(c,v);
 g4:entity WORK.And2(ex1) port map(s,u,c,s2);
 g5:entity WORK.And2(ex1) port map(s,b,v,u2);
 g6:entity WORK.And2(ex1) port map(a,u,v,v2);
 g7:entity WORK.And2(ex1) port map(a,b,v,w2);
 g8:entity WORK.Or2(ex1) port map (s2,u2,v2,w2,h);

end architecture netlist;

1 个答案:

答案 0 :(得分:1)

您将不得不调试实现:这将是使用模拟器的一个很好的练习!

你看到“H”的值为'U',但你还不知道为什么。跟踪H的所有驱动程序:在发布的代码中,我只能看到一个,它来自输入S2,U2,V2,W2。

在模拟器中,将这些信号添加到Wave窗口并重新运行模拟:其中一个卡在'U'处?如果是这样,追溯该信号以找出原因。如果它们都具有有效值,则指向将“U”驱动到信号H上的其他内容。

了解模拟器的“驱动程序”命令(即查找和阅读手册!),以识别驱动H的所有信号及其在给定时间的值。 (我们隐藏)测试平台中可能有一个驱动程序。如果是这样,请更改其驱动值(可能使用H <= 'Z';"分配)并重新运行模拟。

基本上:学习和练习基本的模拟调试技巧:其中一项技能可能会解决问题。并根据您从中学到的内容编辑问题:如果问题仍然存在,这些结果将更接近它。

相关问题