0

我是一个 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;
4

1 回答 1

1

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

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

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

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

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

于 2013-10-28T21:28:02.570 回答