VHDL 3xor门在一个使用结构
我想实现3xor门,前两个异或门的输出应该是最后一个异或门的输入VHDL 3xor门在一个使用结构,vhdl,xor,Vhdl,Xor,我想实现3xor门,前两个异或门的输出应该是最后一个异或门的输入 xor1---> xor3----> final output xor2---> 这是我的代码,我不确定到目前为止我所做的是否正确,我想我必须声明arch。当我做mod的时候。什么?为帮助干杯 library IEEE; use IEEE.STD_LOGIC_1164.ALL; architecture struct of triplexor is comp
xor1--->
xor3----> final output
xor2--->
这是我的代码,我不确定到目前为止我所做的是否正确,我想我必须声明arch。当我做mod的时候。什么?为帮助干杯
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
architecture struct of triplexor is
component unit10
port (a0, a1: in bit; o1: out bit); --xor1
end component;
architecture func of unit10 is
begin
o1 <= a0 xor a1;
end func;
component unit11
port (a2, a3: in bit; o2: out bit); --xor2
end component;
architecture func of unit11 is
begin
o2 <= a2 xor a3;
end func;
component unit2
port (i1, i2: in bit; yi: out bit); --xor3
end component;
architecture func of unit2 is
begin
yi <= i1 xor i2;
end func;
signal ya, yb, yout: bit;
begin
mod_unit10: unit10 port map (a, b, ya);
mod_unit11: unit11 port map (a, b, yb);
mod_unit2 : unit2 port map (ya, yb, yout);
output: y<=yout;
end architecture struct;
IEEE库;
使用IEEE.STD_LOGIC_1164.ALL;
triplexor的体系结构是
组件单元10
端口(a0,a1:输入位;o1:输出位)--xor1
端部元件;
单元10的建筑功能是
开始
o1这是您的代码,其中只包含同一组件的3个实例:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity triplexor ...
end entity;
architecture struct of triplexor is
component myXor
port (
i0, i0: in bit;
o: out bit
);
end component;
architecture rtl of myXor is
begin
o <= i0 xor i1;
end rtl;
signal ya, yb, yout: bit;
begin
-- using port mapping by position
inst_xor1: myXor
port map (
a, b,
ya
);
inst_xor2: myXor
port map (
a, b,
yb
);
-- using port mapping by name (I prefer this style - it's safer if someone changes a port list)
inst_xor3: myXor
port map (
i0 => ya,
i1 => yb,
o => yout
);
y <= yout;
end architecture struct;
IEEE库;
使用IEEE.STD_LOGIC_1164.ALL;
实体三色体。。。
终端实体;
triplexor的体系结构是
组分粘液菌
港口(
i0,i0:以位为单位;
o:出位了
);
端部元件;
myXor的rtl体系结构是
开始
o在组件中隐藏XOR有什么原因吗?为什么有3个组件填充一个xor?您可以只使用一个组件并创建3个实例。您的示例将始终计算为“0”(y:=xor x->y:=0)。你的结构在哪里?组件的使用是强制性的吗?如果必须使用组件,则可以删除两个组件声明并实例化其余组件三次。@paepbels您可以只使用一个组件并创建三个实例。我该怎么做?我的结构不是begin modunit吗,,,,?对不起,我是新来的@没有唯一功能的pablo组件不需要是唯一的——它们只描述组件实例如何工作。如果将它与C++进行比较,则组件将是一个类,实例将是该类的对象——对类声明的数字对象没有限制。在mod_unit10:unit10端口图中(a、b、ya)代码>,左边的名称是必须唯一的实例名称,右边的名称表示三个组件可以相同的组件。当然,如果我想将4个值异或在一起,我会按照grorel的建议去做,而忽略结构设计。谢谢,我想我现在明白了!