在VHDL中的Ripple进位中添加延迟



我已经连续三天为这个问题头疼了。。也就是说,我不能向3位RCA的全加法器插入延迟。不幸的是,我试图将它们添加到全加法器代码中,但只有一个全加法器考虑延迟,而其他两个则不考虑。所以我想知道是否有可能在端口映射部分为3位RCA代码添加延迟。

帮我摆脱它。

谢谢

这是我的密码。。。

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity RCA_3 is
Port (
A : in STD_LOGIC_VECTOR (2 downto 0);
B : in STD_LOGIC_VECTOR (2 downto 0);
Cin : in STD_LOGIC;
S : out STD_LOGIC_VECTOR ( 2 downto 0);
Cout : out STD_LOGIC);
end RCA_3;

architecture Behavioral of RCA_3 is
component full_adder
Port ( 
a : in STD_LOGIC;
b : in STD_LOGIC;
cin : in STD_LOGIC;
sum : out STD_LOGIC;
cout : out STD_LOGIC);
end component;
signal c1,c2: STD_LOGIC; 
begin
--here i have a trouble
process is
begin 
wait for 10 ns;
FA1: full_adder port map( a => A(0), b => B(0), cin => Cin, sum => S(0), cout => c1);
wait for 10 ns;
FA2: full_adder port map( a => A(1), b => B(1), cin => c1, sum => S(1), cout => c2);
wait for 10 ns;
FA3: full_adder port map( a => A(2), b => B(2), cin => c2, sum => S(2), cout => Cout);
wait for 10 ns;
end process;
end Behavioral;

我不知道你的FullAdder代码,但我认为它是这样的:

entity full_adder is
Port (
a    : in  STD_LOGIC;
b    : in  STD_LOGIC;
cin  : in  STD_LOGIC;
s    : out STD_LOGIC;
cout : out STD_LOGIC);
end full_adder;
architecture bhv of full_adder is
begin
s <= a XOR b XOR cin;
cout <= (a AND b) OR (cin AND a) OR (cin AND b);
end bhv;

你现在可以写这样的东西:

s <= a XOR b XOR cin after 10 ns;
cout <= (a AND b) OR (cin AND a) OR (cin AND b) after 10 ns;

当您实例化全加法器时,不需要任何进一步的延迟。

仅供参考:您可以使用for generate语句来对Full Adder进行更通用的实现。

我建议您使用STD_ULOGIC而不是STD_LOGIC,因为在大多数情况下,您不希望信号具有多个驱动程序。尤其是在为FPGA或ASIC编写代码时,你必须避免此类信号,直到你不知道自己在做什么或如何处理它们。

最新更新