2012-05-17 3 views
0

이 코드에서는 16 비트 숫자를 곱하고 32 비트 출력을 얻으려고합니다. 코드에 오류가 있습니다. 줄에16 비트 숫자 곱하기

c<=c+a; 

컴파일러가 오류를 제공합니다.?. "캔트 모드 아웃 포트 'C'를 읽고 무엇을 내 실수 해 주셔서 감사합니다

library ieee; 
    use ieee.std_logic_1164.all; 
    use ieee.std_logic_arith.all; 
    use ieee.std_logic_unsigned.all; 

    entity circ is 
    port ( a :in std_logic_vector (15 downto 0); 
    b :in std_logic_vector (15 downto 0); 
    c :out std_logic_vector (31 downto 0) 
     ); 

    end entity; 

    architecture data of circ is 
    begin 
process(a,b) 
begin 
c<= '0'; 
for i in 15 to 0 loop 
if (b(i) = '1') then 
c<=c+a; 
end if; 
END LOOP; 

end process; 
    end data; 

답변

1

오류는 컴파일러가 당신에게 무엇을 정확하게

cant read port 'c' of mode out

당신은 출력을 읽을 수 없습니다. 당신은 c을 읽고있는 당신이 c이 과제의 오른쪽에 나타납니다 c <= c + a 때문에 쓸 때. 당신은 재해야 할 것 다음과 같은 코드를 작성하십시오 :

signal s : std_logic_vector(31 downto 0); 

process(a,b) 
begin 
    s <= (others => '0'); 
    for i in 15 to 0 loop 
    if (b(i) = '1') then 
     s <= s + a; -- Use a local signal that we can read and write 
    end if; 
    end loop; 
    c <= s; -- Assign the output to the local signal. 
end process; 
+0

c <= '0'; 컴파일러에서 오류가 발생합니다 :'웨이브 폼 요소 유형이 "std_logic_vector"이어야합니다.' – redlogic

+0

'c <='0 ''은 'c <=(others =>'0 '이어야합니다.'std_logic_vector가 아니고 std_logic_vector이므로 –

+0

눈치 채지 못했습니다. 그것은 OP의 코드에서 잘라내어 붙여 넣기 만 한 것입니다. 나는 고칠 것이다. –