2016-11-17 3 views
0

나는 사전 인터뷰 질문 으로이 질문을 받았다 "다이어그램 그리기 및 다음과 같은 요구 사항을 충족하는 모듈에 대한 VHDL 코드를 작성 : 완전 동점. b. Muxes 각 버스가 8 비트 너비 인 11 개의 버스 사이 c. 대기 시간이 2 사이클임 d. 최대 클럭 주파수에 최적화 됨. "VHDL : 11 버스 8 비트 출력 사이의 muxes

ive 내가 대학에서 한 내 오래된 노트와 과제를 읽으려고했는데, 나는 이것으로 올바른 길을 가고 있다고 생각하지 않는다. 내가 코드 한혜진까지 아래 게시 한 :

library IEEE; 
use IEEE.STD_LOGIC_1164.all; 

entity Mux is 
port(

A: in STD_LOGIC_vector(7 downto 0); 
    B: in STD_LOGIC_vector(7 downto 0); 
    C: in STD_LOGIC_vector(7 downto 0); 
    D: in STD_LOGIC_vector(7 downto 0); 
    E: in STD_LOGIC_vector(7 downto 0); 
    F: in STD_LOGIC_vector(7 downto 0); 
    G: in STD_LOGIC_vector(7 downto 0); 
    H: in STD_LOGIC_vector(7 downto 0); 
    I: in STD_LOGIC_vector(7 downto 0); 
    J: in STD_LOGIC_vector(7 downto 0); 
    K: in STD_LOGIC_vector(7 downto 0); 
S0: in std_LOGIC_vector(3 downto 0); 

Z: out STD_LOGIC_vector(7 downto 0) 
); 
end Mux; 
architecture func of Mux is 
begin 
process (A,B,C,D,E,F,G,H,I,J,K,S0) 
begin 

    if S0="0001" then 
     Z<= A; 
    elsif S0="0010" then 
     Z<= B; 
    elsif S0="0011" then 
     Z<= C; 
    elsif S0="0100" then 
     Z<= D; 
    elsif S0="0101" then 
     Z<= E; 
    elsif S0="0110" then 
     Z<= F; 
    elsif S0="0111" then 
     Z<= G; 
    elsif S0="1000" then 
     Z<= H; 
    elsif S0="1001" then 
     Z<= I; 
    elsif S0="1010" then 
     Z<= J; 
    elsif S0="1011" then 
     Z<= K; 
    else 
     Z<=A; 
    end if; 


end process; 
end func; 

이 내가 나의 두 번째 파일에 대해 가지고있는 코드 :

LIBRARY ieee; 
USE ieee.std_logic_1164.ALL; 
use IEEE.std_logic_arith.all; 
entity mux11test is 
end entity mux11test; 
architecture test of mux11test is 
    signal T_A: STD_LOGIC_vector(7 downto 0):="00000001"; 
    signal T_B: STD_LOGIC_vector(7 downto 0):="00000010"; 
    signal T_C: STD_LOGIC_vector(7 downto 0):="00000011"; 
    signal T_D: STD_LOGIC_vector(7 downto 0):="00000100"; 
    signal T_E: STD_LOGIC_vector(7 downto 0):="00000101"; 
    signal T_F: STD_LOGIC_vector(7 downto 0):="00000110"; 
    signal T_G: STD_LOGIC_vector(7 downto 0):="00000111"; 
    signal T_H: STD_LOGIC_vector(7 downto 0):="00001000"; 
    signal T_I: STD_LOGIC_vector(7 downto 0):="00001001"; 
    signal T_J: STD_LOGIC_vector(7 downto 0):="00001010"; 
    signal T_K: STD_LOGIC_vector(7 downto 0):="00001011"; 

    signal T_S: STD_LOGIC_vector(3 downto 0); 
signal T_Z: STD_LOGIC_vector(7 downto 0); 

component mux11 IS 
port(

A: in STD_LOGIC_vector(7 downto 0); 
    B: in STD_LOGIC_vector(7 downto 0); 
    C: in STD_LOGIC_vector(7 downto 0); 
    D: in STD_LOGIC_vector(7 downto 0); 
    E: in STD_LOGIC_vector(7 downto 0); 
    F: in STD_LOGIC_vector(7 downto 0); 
    G: in STD_LOGIC_vector(7 downto 0); 
    H: in STD_LOGIC_vector(7 downto 0); 
    I: in STD_LOGIC_vector(7 downto 0); 
    J: in STD_LOGIC_vector(7 downto 0); 
    K: in STD_LOGIC_vector(7 downto 0); 
S0: in std_LOGIC_vector(3 downto 0); 

Z: out STD_LOGIC_vector(7 downto 0) 
); 
END COMPONENT ; 
signal clk : std_LOGIC; 
constant clk_period: time:=100ns; 
begin 

umux: Mux11 port map(T_A,T_B,T_C,T_D,T_E,T_F,T_G,T_H,T_I,T_J,T_K,T_S,T_Z); 
clk_process:process 
begin 
clk<='0'; 
wait for clk_period/2; 
clk <='1'; 
wait for clk_period/2; 
end process; 
PROCESS 
begin 
if T_S="0001" then 
    T_Z <= T_A ; 
elsif T_S="0010" then 
T_Z <= T_B ; wait for 100 ns; 
elsif T_S="0011" then 
T_Z <= T_C ; wait for 100 ns; 
elsif T_S="0100" then 
T_Z <= T_D ; wait for 100 ns; 
elsif T_S="0101" then 
T_Z <=T_E ; wait for 100 ns; 
elsif T_S="0110" then 
T_Z <= T_F ; wait for 100 ns; 
    elsif T_S="0111" then 
T_Z <= T_G ; wait for 100 ns; 
    elsif T_S="1000" then 
T_Z <= T_H ; wait for 100 ns; 
elsif T_S="1001" then 
T_Z <= T_I ; wait for 100 ns; 
elsif T_S="1010" then 
T_Z <= T_J ; wait for 100 ns; 
elsif T_S="1011" then 
T_Z <= T_K ; wait for 100 ns; 


wait; 

end if; 
end PROCESS; 

end architecture test; 

옳은 길과 경우 메신저 경우 말해 줄 수있는 사람이있다 이것은 완전히 동기식이며 어떻게 구현을 시작하거나 2 사이클의 대기 시간을 결정합니까?

+0

엔티티에서 시계를 정의하지 않았기 때문에 프로세스가 전혀 동기화되지 않았습니다. 먼저 시계를 정의해야합니다. –

+0

u 제안 된 기사가 있다면 시계를 정의하는 방법을 볼 수 있습니다. –

+1

* 올바른 경로의 메신저가 있으면 알려주는 사람이 있습니까? 이것이 완전히 동기화되어 있고 구현을 시작하거나 레이턴시 2주기를 결정하는 방법은 무엇입니까? * 이것은 복제물입니다. * 올바른 경로의 메신저가 있으면 알려주고, 이것이 완전히 동기이면 어떻게 구현하거나 대기 시간을 2 주기로 결정할 수 있습니까? * [VHDL 코드로 어려움을 겪고있는]에서 발견되었습니다. 이 전체 동기식 및 대기 시간의 얼마나 많은 사이클을 알고 있습니까?] (https://stackoverflow.com/questions/40643703/im-struggling-with-my-vhdl-code-is-this-full-synchronous- and-how-do-know-how-m) – user1155120

답변

0

나는 당신을 도울 명확한 답변을 쓰려고합니다.

먼저 디자인에 시계가 필요합니다. clk으로 전화하십시오.

entity Mux is 
port(

    clk: in std_logic; 
    A: in STD_LOGIC_vector(7 downto 0); 
    B: in STD_LOGIC_vector(7 downto 0); 
    C: in STD_LOGIC_vector(7 downto 0); 
    D: in STD_LOGIC_vector(7 downto 0); 
    E: in STD_LOGIC_vector(7 downto 0); 
    F: in STD_LOGIC_vector(7 downto 0); 
    G: in STD_LOGIC_vector(7 downto 0); 
    H: in STD_LOGIC_vector(7 downto 0); 
    I: in STD_LOGIC_vector(7 downto 0); 
    J: in STD_LOGIC_vector(7 downto 0); 
    K: in STD_LOGIC_vector(7 downto 0); 
    S0: in std_LOGIC_vector(3 downto 0); 

    Z: out STD_LOGIC_vector(7 downto 0)); 

end Mux; 

동기식 프로세스를 사용할 때 아이디어는 항상 시계 가장자리에서 값을 업데이트하는 것입니다. 상승 에지라고합시다. 따라서 귀하의 프로세스는 귀하의 입력에만 민감해야합니다 clk.

P : PROCESS (clk) 
BEGIN 
    IF (rising_edge(clk)) THEN 
    ... 
    END IF; 
END PROCESS; 

멀티플렉서와 ​​관련하여 귀하의 생각은 좋았습니다. 그러나 케이스 진술을 사용하는 것이 좋습니다. IFELSIF보다 읽기 쉽기 때문입니다.

CASE S0 IS 
    WHEN "0001" => Z <= A; 
    WHEN "0010" => Z <= B; 
    ... 
    WHEN "1011" => Z <= K; 
END CASE; 

편집 : 2주기 지연에 대해 이야기하는 것을 잊어 버렸기 때문에 두 단어를 말할 것입니다. 거기에 두 개의 중간 신호 (즉, Z_i와 Z_ii)가 필요합니다. Z_ii는 한 클럭 사이클 후에 Z_i를 취하고 Z는 한 클럭 사이클 후에 Z_ii를 취합니다.

Z_ii <= Z_i; 
Z <= Z_ii; 

물론 Z_i (및 Z가 아닌)를 처리해야합니다.

+0

if 문을 case 문으로 변경하면 case 문을 "if (rising_edge (clk))"에 넣을 수 있습니다. –

+0

예, 동기화할 수 있습니다. –

+0

도움을 주셔서 대단히 감사합니다 :) 이제는이 모든 것을 함께 넣고 잘못 수행 할 것입니다. –