【问题标题】:VHDL Full adder test bench output UVHDL 全加器测试台输出 U
【发布时间】:2013-10-28 03:57:13
【问题描述】:

我是一个 vhdl 新手。我只使用 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;

【问题讨论】:

  • 如何才能拥有一个只有一个输出的全加器?我以为全加器既有求和又有进位?
  • 请同时发布测试平台,因为这样可以重现您的问题,从而更容易调试。顺便提一句。你不需要为了获得not operation而制作一个模块;所以 g1 可以写成 s &lt;= not a 等。
  • Morten 关于“not”的观点是有效的,但同样适用于“and”和“or”;我认为这里的重点是学习结构化编码而不是优化解决方案。

标签: output simulation vhdl


【解决方案1】:

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

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

在模拟器中,将这些信号添加到 Wave 窗口并重新运行模拟:其中一个是否停留在“U”?如果是这样,请追溯该信号以找出原因。如果它们都具有有效值,则表明将“U”驱动到信号 H 上的其他东西。

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

本质上:学习和练习基本的模拟调试技能:这些技能之一很可能解决问题。并用你从他们那里学到的东西编辑问题:如果问题仍然存在,这些结果将更接近它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-05
    • 1970-01-01
    • 2019-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多