항상 if로만 코딩했었는데, 공부해보니 동시처리문 이라는 것을 알게 되었습니다.

이후 코딩할 때 더 편할 것 같아서 공부해보았습니다.

순차처리문((process)문의 경우 Verilog의 always와 같은 기능입니다. HW언어의 장점인 병렬처리에는 동시처리문이 더 적합하다 생각해서 공부해 보았습니다.

순차, 동시 처리문 차이.jpg

  1. with~select~when 문을 이용한 선택적 동시처리문

MUX의 DUT

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity mux is
    Port ( X : in std_logic_vector(1 downto 0);
        S : in std_logic;
        Y   : out std_logic );
end mux;

architecture Behavioral of mux is

begin

with S select
    y <= X(1) when '1',
         X(0) when '0',
         '0' when others;

end Behavioral;

testbench

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity tb_mux is
end tb_mux;

architecture Behavioral of tb_mux is
    signal X0, X1 : std_logic;
    signal S : std_logic;
    signal Y : std_logic;

begin
UUT : entity work.mux port map(
x(0) => x0, x(1) => x1, s => s, y => y);

process
    begin
    X0 <= '0';
    x1 <= '1';
    
    S <= '0';
    wait for 10ns;
    
    S <= '1';
    wait for 10ns;

    
    report "종료" severity failure;
end process;

end Behavioral;

waveform

image.png