2)f语句的二选择控制 格式: if条件then 顺序处理语句 else 顶序处理语句 end if 用条件来选择两条不同程序执行的路径。 16
16 2)if 语句的二选择控制 格式: 用条件来选择两条不同程序执行的路径。 if 条件 then 顺序处理语句; else 顺序处理语句; end if ;
此描述的典型电路是二选一电路 architecture rtl of mux2 is begin process(a, b, sel) begin if (sel =1)then imux y<=a; else y <=b end if end process MULTIPLEXER end rtl
17 此描述的典型电路是二选一电路: architecture rtl of mux2 is begin process(a, b, sel) begin if (sel = ‘ 1 ’) then y <= a ; else y <= b ; end if ; end process ; end rtl ;
3)近语句的多选择控制 计f语句的多选择控制又称为讦语句的嵌套。 格式 if条件then 顺序处理语句 lif条件then 顺序处理语句; elsif条件then 顺序处理语句 else 顺序处理语句; end if:
18 3)if 语句的多选择控制 if 语句的多选择控制又称为 if 语句的嵌套。 格式: if 条件 then 顺序处理语句; elsif 条件 then 顺序处理语句; ┇ elsif 条件 then 顺序处理语句; else 顺序处理语句; end if;
典型电路是多选一(四选一)电路。 library ieee use ieee std logic 1164.alli enti ty mux i port (input: in std logic vector(3 downto 0 sel: in std logic vector(l downto 0)i y: out std logic)i end mux 4i architecture rtl of mux 4 is MUX begin process(input, sel) inputt,. 01 yi begin seI[1.0] if (sel="00")then y<=input(0) elsif (sel=01)then y<=input(1) elsif (sel=10")then y<=input(2) else y<=input(3)i end ifi end processi end rtl
19 典型电路是多选一(四选一)电路
if then elsi语句中隐含了优先级别的判断, 最先出现的条件优先级最高,可用于设计具有优 先级的电路。如8-3优先级编码器。 library ieee use ieee std_logic_1164.all entity coder is port(input: in std_logic_vector(7 downto O) output: out std_logic_vector(2 downto O)) end coder
20 if_then_elsif 语句中隐含了优先级别的判断, 最先出现的条件优先级最高,可用于设计具有优 先级的电路。如8-3优先级编码器。 library ieee; use ieee.std_logic_1164.all; entity coder is port(input: in std_logic_vector(7 downto 0); output: out std_logic_vector(2 downto 0)); end coder;