VHDL端口映射问题
我对 VHDL 还比较陌生。 我正在尝试编写代码来使用全加器的组合进行无符号乘法。 编译时它会传递到端口映射。 我已经解决了第一张地图中的错误,但所有其他地图都给我带来了问题。
我对每个错误都得到相同的错误:“端口映射方面的表达式实际值必须是静态的”
这是我的代码。 任何帮助表示赞赏。 此外,如果您根据查看我的代码获得一般提示,我将不胜感激。
谢谢, 布兹基
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;
I'm relatively new to VHDL. I'm attempting to write code to do unsigned multiplication using a combination of full adders. When compiling it passes up to the port mapping. I've resolved the errors in the first map, but all of the others give me problems.
I get the same error for each: "Expression actuals in port map aspect must be static"
Here's my code. Any help is appreciated. In addition, if you have general tips based on looking at my code I would be thankful.
Thanks,
Buzkie
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;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我很生疏,但您可能需要为
a(_) 和 b(_)
条目提供显式的 和 门。 我听说过线或,但没有听说过线与(至少在正逻辑中)。至少,尝试仅用
a(_)
部分替换其中的每一个,并查看错误是否消失。 它不会是正确的电路,但它会确认我对于导致编译问题的原因是否正确。I'm rusty, but you might need to have explicit and gates for the
a(_) and b(_)
entries. I've heard of wire-ORs, but not wire-ANDs (in positive logic at least).At the very least, try replacing each of these with just the
a(_)
portion, and see if the errors go away. It won't be the right circuit, but it will confirm if I'm right as to what's causing the compilation problem.如果我没记错的话,你不能将逻辑表达式(例如 a(0) 和 b(0))映射到端口(但我认为常量是可以的)。 如果这是正确的,您必须为所有输入和输出创建显式信号。
还:
1)我不认为全加器架构是行为性的,所以我会给它起一个别的名字。 我为这些架构使用了(无论正确与否)名称 rtl。
2) 应该可以在不声明组件的情况下实例化全加器。 使用像
我也发现通常总是指定正式端口名称的语法(cout => c1(0),对箭头的方向等进行一些保留)
3)我想你知道任何最近新的合成器将能够综合乘法,并且您这样做只是为了学习它是如何工作的,否则我只是告诉您:)
If I remember things correctly, you can't map a logic expression (e.g. a(0) and b(0)) to a port (but I think constants are OK). If this is correct, you have to create explicit signals for all inputs and outputs.
Also:
1) I don't think the fulladder architecture is behavioral, so I would name it something else. I have used (correctly or not) the name rtl for these architectures.
2) It should be possible to instantiate the full adders without declaring the component. Use a syntax like
I also find it usual to always specify the formal port names (cout => c1(0), with some reservation for the direction of the arrow, etc.)
3) I suppose you know that any recently new synthesizer will be able to synthisize a multiplication and that you are just doing this for learning how it works, otherwise I just told you :)
某些合成器在端口映射不是静态表达式时存在问题。
无论合成器有什么抱怨,您可能都必须用信号替换端口映射中的表达式。 例如:
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);
...
code>Fand00: fulladder 端口映射('0',t,'0',pro(0),c1(0));
如果可能,请更换为不同的合成器软件。 不要折磨自己。
Some synthesizers have problems with port maps that are not static expressions.
You may have to replace the expression in the port map with a signal, wherever the synthesizer complains. For example:
Fand00: fulladder port map('0',(a(0) and b(0)),'0',pro(0),c1(0));
With:
signal t: std_logic;
...
t <= a(0) and b(0);
...
Fand00: fulladder port map('0',t,'0',pro(0),c1(0));
If at all possible, change to a different synthesizer software. Don't torture yourself.