【发布时间】:2017-11-01 04:12:44
【问题描述】:
我正在尝试在 Modelsim 中制作串行加法器的行为模型。
因此,在设计中,我试图在一个时钟周期后将 Carry_out 传递给 Carry_in。
设计是:
一个位,两个 n 位数字中的每个与进位一起进入加法器。
最初进位为 0,但在下一个时钟周期中,前一位相加产生的进位输出再次作为进位输入传递,并且对接下来的两位进行加法,每个数字一个位。
代码如下:
library ieee;
use ieee.std_logic_1164.all;
entity serial_adder is
port (a,b: in std_logic;
s: out std_logic;
cin,cout: inout std_logic);
end serial_adder;
architecture serial_adder_arch of serial_adder is
begin
process(a,b,cin,cout)
begin
if (a='0' and b ='0' and cin ='0')
then s <='0';
cout <='0';
elsif (a='0' and b ='0' and cin ='1')
then s <='1';
cout <='0';
elsif (a='0' and b ='1' and cin ='0')
then s <='1';
cout <='0';
elsif (a='0' and b ='1' and cin ='1')
then s <='0';
cout <='1';
elsif (a='1' and b ='0' and cin ='0')
then s <='1';
cout <='0';
elsif (a='1' and b ='0' and cin ='1')
then s <='0';
cout <='1';
elsif (a='1' and b ='1' and cin ='0')
then s <='0';
cout <='1';
elsif (a='1' and b ='1' and cin ='1')
then s <='1';
cout <='1';
end if;
cin <= cout after 50 ps;
end process;
end serial_adder_arch;
模拟后,我看到我使用“之后”给出的延迟不起作用。我没有延迟,cout 没有被分配给cin
【问题讨论】: