2013-03-29 4 views
0

저는 VHDL의 몇 가지 단점에 익숙해지기 위해 계속 노력하고 있으며 약간의 문제가 있습니다. 먼저 rol, ror, ssl, srl 등과 같은 시프트 연산자는 합성 할 수 없다는 것을 이해합니다. 이 실습의 목적은 황금 모델을 사용하여 테스트 벤치에서 같은 것을 합성 할 수있는 버전을 검사하는 것입니다.VHDL 시프트 연산자는 무엇입니까?

이제이 프로그램의 목적은 온도계 코드를 3 비트 2 진수로 변환하는 것입니다. 즉, 온도계 코드 "00000001"= "001", "00000011"= "010", "00000111"= "011"등입니다. 왼쪽으로. 1의 문자열 사이에 '0'이 삽입 된 경우는 없으므로 벡터 "00011101"은 유효하지 않으며 절대로 발생하지 않습니다.

저는 합성 방법이 아닌 (그리고 지금까지는 컴파일 할 수없는) 알고리즘을 고안하여 작동 방법을 알 수 없었습니다. 기본적으로 온도계 코드를 읽고 온도계 코드가 0이 될 때까지 카운터를 증분 한 다음 카운터 값을 3 비트 std_logic_vector에 할당하는 것이 아이디어입니다. 아래 코드는 제가 지금까지 해본 코드입니다.

library ieee; 
use ieee.std_logic_1164.all; 
use ieee.numeric_std.all; 

entity therm2bin_g is 
    port(therm : inout std_logic_vector(6 downto 0); -- thermometer code 
     bin : out std_logic_vector(2 downto 0); -- binary code 
     i : integer range 0 to 7); 
end therm2bin_g;  

architecture behavioral_g of therm2bin_g is 
begin 

golden : process(therm) 
begin 

    while(therm /= "00000000") loop 
     therm <= therm srl 1; 
     i = i + 1;  
    end loop; 

    bin <= std_logic'(to_unsigned(i,3)); 

end process golden; 
behavioral_g; 
+0

중복 된 http://electronics.stackexchange.com/questions/63734/vhdl-shift-operators –

답변

1

여기는 합성 가능 버전입니다. 루프는 루프의 으로 대체됩니다. SRL 명시 적으로 구현됩니다

entity therm2bin_g is 
port(therm : inout std_logic_vector(6 downto 0); -- thermometer code 
    bin : out std_logic_vector(2 downto 0); -- binary code 
    i : out integer range 0 to 7); 
end therm2bin_g;  

architecture behavioral_g of therm2bin_g is 
begin 

golden : process(therm) 
    variable i_internal: integer range 0 to 7; 
begin 
    i_internal:=0; 
    for idx in 0 to therm'length loop 
     if therm/="0000000" then 
      therm<='0' & therm(therm'left downto 1); 
      i_internal := i_internal + 1;  
     end if; 
    end loop; 

    bin<=std_logic_vector(to_unsigned(i_internal,bin'length)); 
    i<=i_internal; 

end process golden; 
end behavioral_g; 
1

"... 운영자 등 ROL, ROR, SSL, SRL, 같은 통합이 가능하지 ..." 누가 누가 권위의에 있다고? 확인해 봤어? 합성 도구 에서요? 최근 버전입니까, 아니면 1990 년대 초 버전입니까?

일부 도구 은 지원하지 않는다는 점에 유의하십시오. 사실 일부 주방에는 오븐이 없을 수도 있기 때문에 사람들이 케이크 요리법을 작성하는 것을 막지는 못합니다.