我对VHDL比较陌生。我正在尝试编写代码,使用全加法器的组合来进行无符号乘法。在编译时,它会向上传递到端口映射。我已经解决了第一个map中的错误,但所有其他map都给我带来了问题。
我得到了相同的错误:“端口映射方面中的表达式实数必须是静态的”
这是我的代码。任何帮助都是非常感谢的。此外,如果您有基于查看我的代码的一般提示,我将不胜感激。
谢谢,巴斯基
library ieee;
use ieee.std_logic_1164.all;
entity fulladder is
port (a, b, c: in std_logic;
sout, cout: out std_logic);
end fulladder;
architecture behav of fulladder is
begin
sout <= (a xor b) xor c ;
cout <= (a and b) or (c and (a xor b));
end behav;
library ieee;
use ieee.std_logic_1164.all;
entity unsignedmult is
port (a,b: in std_logic_vector (3 downto 0);
pro: out std_logic_vector (7 downto 0));
end unsignedmult;
architecture synth of unsignedmult is
--Declarations
signal c1,c2,c3,c4,c5: std_logic_vector (3 downto 0);
signal s1,s2,s3,s4: std_logic_vector (2 downto 0);
component fulladder
port (a,b,c:in std_logic;
sout,cout:out std_logic);
end component;
begin
--Row 0 ----Sin-----A&B-------Cin--Sout---Cout
Fand00: fulladder port map('0',(a(0) and b(0)),'0',pro(0),c1(0));
Fand01: fulladder port map('0',(a(1) and b(0)),'0',s1(0),c1(1));
Fand02: fulladder port map('0',(a(2) and b(0)),'0',s1(1),c1(2));
Fand03: fulladder port map('0',(a(3) and b(0)),'0',s1(2),c1(3));
--Row 1
Fand10: fulladder port map(s1(0),(a(0) and b(1)),c1(0),pro(1),c2(0));
Fand11: fulladder port map(s1(1),(a(1) and b(1)),c1(1),s2(0),c2(1));
Fand12: fulladder port map(s1(2),(a(2) and b(1)),c1(2),s2(1),c2(2));
Fand13: fulladder port map('0',(a(3) and b(1)),c1(3),s2(2),c2(3));
--Row 2
Fand20: fulladder
----Sin------A&B------Cin-Sout-Cout
port map(s2(0),(a(0) and b(2)),c2(0),pro(2),c3(0));
Fand21: fulladder
----Sin--A&B------Cin-Sout-Cout
port map(s2(1),(a(1) and b(2)),c2(1),s3(0),c3(1));
Fand22: fulladder
----Sin--A&B------Cin-Sout-Cout
port map(s2(2),(a(2) and b(2)),c2(2),s3(1),c3(2));
Fand23: fulladder
----Sin--A&B------Cin-Sout-Cout
port map('0',(a(3) and b(2)),c2(3),s3(2),c3(3));
--Row 3
Fand30: fulladder
----Sin------A&B------Cin-Sout-Cout
port map(s3(0),(a(0) and b(3)),c3(0),pro(3),c4(0));
Fand31: fulladder
----Sin--A&B------Cin-Sout-Cout
port map(s3(1),(a(1) and b(3)),c3(1),s4(0),c4(1));
Fand32: fulladder
----Sin--A&B------Cin-Sout-Cout
port map(s3(2),(a(2) and b(3)),c3(2),s4(1),c4(2));
Fand33: fulladder
----Sin--A&B------Cin-Sout-Cout
port map('0',(a(3) and b(3)),c3(3),s4(2),c4(3));
--Row 4
F40: fulladder
port map(s4(0),c4(0),'0',pro(4),c5(0));
F41: fulladder
port map(s4(1),c4(1),c5(0),pro(5),c5(1));
F42: fulladder
port map(s4(2),c4(2),c5(1),pro(6),c5(2));
F43: fulladder
port map('0',c4(3),c5(2),pro(7),c5(3));
end synth;发布于 2009-03-10 22:44:40
我有点生疏了,但是您可能需要为a(_) and b(_)条目显式地使用and门。我听说过wire- of,但没有听说过wire-AND(至少在正逻辑中)。
至少,尝试用a(_)部分替换其中的每一个,看看错误是否消失了。它不会是正确的电路,但它将确认我是否正确,是什么导致了编译问题。
发布于 2009-03-10 23:07:43
如果我没记错,您不能将逻辑表达式(例如a(0)和b(0))映射到端口(但我认为常量可以)。如果这是正确的,您必须为所有输入和输出创建显式信号。
另外: 1)我不认为fulladder架构是行为的,所以我会给它起其他的名字。我已经(无论正确与否)为这些架构使用了rtl这个名称。
2)应该可以在不声明组件的情况下实例化全加法器。使用如下语法
Fand00: entity fulladder port map(...)我还发现通常总是指定正式的端口名称(cout => c1(0),保留一些箭头的方向,等等)
3)我想你知道任何新的合成器都能合成乘法,你这样做只是为了学习它是如何工作的,否则我就告诉你:)
发布于 2009-05-05 09:29:46
一些合成器在端口映射不是静态表达式的情况下存在问题。
在合成器出现问题的地方,您可能必须将端口映射中的表达式替换为信号。例如:
Fand00: fulladder port map('0',(a(0) and b(0)),'0',pro(0),c1(0));
通过以下方式:
signal t: std_logic;
...
t <= a(0) and b(0);
...
Fand00: fulladder port map('0',t,'0',pro(0),c1(0));
如果可能的话,换成不同的合成器软件。不要折磨你自己。
https://stackoverflow.com/questions/632422
复制相似问题