Read in EN

combinational switch

일반적인 조건문은 priority가 존재하게 된다. 아래 문장은 selection 값에 따라 output이 결정되는 mux를 구현한 것이다. 다만 아래의 문장은 synthesis 될 때 selection이 0이 아니면 그 다음에 1을 check하고, 1도 아니면 2 check하는 식으로 우선 순위가 들어가게 된다.

o <= (in0, sel==0, in1, sel==1, in2, sel==2, in3)

이러한 priority가 생기면 부가 로직이 생기게 되고, system 성능에 영향을 끼칠 수가 있는데, switch 문장을 사용하여 priority 없는 조건문을 생성하면 된다.

with switch(sel):
    with case(0) : o <= in0
    with case(1) : o <= in1
    with case(2) : o <= in2
    with others() : o <= in3

위의 문장은 아래와 같이 process 문장으로 변환된다.

process(sel,in0,in1,in2,in3)
begin
    case sel is
        when "00" => o <= in0;
        when "01" => o <= in1;
        when "10" => o <= in2;
        when others => o <= in3;
    end case;
end process;
← All posts