2017-11-01 11 views
0

Modelsim에서 직렬 덧셈기의 행동 모델을 만들려고합니다."after"가 Modelsim에서 작동하지 않습니다.

그래서 디자인에서 Carry_out을 Carry_in으로 1 클럭주기 후 전달하려고합니다.

디자인은 다음과 같습니다

1 비트, 2 개의 n 비트 수에서 각각 캐리와 함께 가산기를 입력합니다.

처음에는 캐리가 0이지만 다음 클럭 사이클에서 이전 비트의 추가로 인한 carry_out이 carry_in으로 다시 전달되고 각 번호에서 하나씩 다음 2 비트로 덧셈이 수행됩니다.

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; 

시뮬레이션 후, 내가보고하고 그 I가 작동하지 않는 '후'를 사용하여 제공하고 지연 : 여기

는 코드입니다. 지연이없고 cout이 할당되지 않습니다 cin

답변

0

시뮬레이션에서이 코드가 작동하더라도 wait for 문 때문에 합성되지 않습니다.

아래의 직렬 덧셈기 코드를 참조하십시오.

library ieee; 
use ieee.std_logic_1164.all; 

--serial adder for N bits. Note that we dont have to mention N here. 
entity serial_adder is 
    port(Clk,reset : in std_logic; --clock and reset signal 
      a,b,cin : in std_logic; --note that cin is used for only first iteration. 
      s,cout : out std_logic --note that s comes out at every clock cycle and cout is valid only for last clock cycle. 
      ); 
end serial_adder; 

architecture behav of serial_adder is 

--intermediate signals. 
signal c,flag : std_logic := '0'; 

begin 

process(clk,reset) 
--we use variable, so that we need the carry value to be updated immediately. 
variable c : std_logic := '0'; 
begin 
if(reset = '1') then --active high reset 
    s <= '0'; 
    cout <= c; 
    flag <= '0'; 
elsif(rising_edge(clk)) then 
    if(flag = '0') then 
     c := cin; --on first iteration after reset, assign cin to c. 
     flag <= '1'; --then make flag 1, so that this if statement isnt executed any more. 
    end if; 
    s <= a xor b xor c; --SUM 
    c := (a and b) or (c and b) or (a and c); --CARRY 
end if; 
end process; 

end behav; 

당신이 그것을 좋아한다면,이 link에 테스트 벤치 코드와 설명이 있습니다.

+0

음, 실제로'cin '에'cout'의 값을 직접 할당하려했기 때문에 오류가있었습니다. 귀하의 접근 방식이 효과적이었습니다. 고마워. :) – Siladittya

0

시뮬레이터 시간 해상도는 무엇입니까? 기본값은 1ns이며, 시간 지연은 해상도로 반올림됩니다.

vsim -t 50ps을 사용해 해상도를 50ps로 변경하십시오.

+0

이 질문에 대한 답변을 제공하지 않습니다. 비평하거나 저자의 설명을 요청하려면 게시물 아래에 의견을 남겨 둡니다. - [리뷰에서] (리뷰/저품절 포스트/17833420) – Brick

+0

@ 브릭 - 질문과 대답을 잘못 이해했습니다. 'after'는 기본 시뮬레이터 시간 분해능이 1ns이고'after'가 50ps의 지연을 지정하기 때문에 * 작동하지 않습니다. * 반올림됩니다. 이것은 FAQ이며 누구에게나 알려줍니다 살아있는 이런 종류의 일. OP는 완전히 무의미한 대답을 받아 들였기 때문에 분명히 혼란 스럽습니다. – EML