3.4 VHDL中的描述语句
if 语句执行一序列的语句,其次序依赖于一个或多个条件的值。 3 种类型: (1) if 语句的门闩控制 if 条件 then 顺序处理语句; end if ; 例: if (ena = ‘1’) then q <= d; end if; 综合后生成锁存器(latch)
上述条件改为时钟沿,则生成 D触发器:
(2) if 语句的二选择控制 格式: if 条件 then 顺序处理语句; else 顺序处理语句; end if ; 用条件来选择两条不同程序执行的路径。 此描述的典型电路是二选一电路: 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) if 语句的多选择控制 if 语句的多选择控制又称为 if 语句的嵌套。 格式: if 条件 then 顺序处理语句; elsif 条件 then 顺序处理语句; ┇ elsif 条件 then 顺序处理语句; else 顺序处理语句; end if; 典型电路是多选一电路。如四选一电路:
|
|||