architecture art of coder is begin process(input begin if input(7=0 then output<=000 elsif input(6)=then output<=001 elsif input(5)=then output<=“010 elsif input(4)=0 then output<=011
21 architecture art of coder is begin process(input) begin if input(7)=‘0’ then output<=“000”; elsif input(6)=‘0’ then output<=“001”; elsif input(5)=‘0’ then output<=“010”; elsif input(4)=‘0’ then output<=“011”;
elsif input( 3=0 then output<=100 elsif input(2)=0 then output<=101 elsif input(1)=then output<=110 else output<s end if end process end art
22 elsif input(3)=‘0’ then output<=“100”; elsif input(2)=‘0’ then output<=“101”; elsif input(1)=‘0’ then output<=“110”’; else output<=“111”; end if; end process; end art;
2、case语句 case语句常用来描述总线或编码、译码行为 可读性比计语句强。 格式如下: case表达式is when分支条件→>顺序处理语句 When分支条件→>顺序处理语句; When分支条件→>顺序处理语句; end case 23
23 2、 case 语句 case 语句常用来描述总线或编码、译码行为。 可读性比if 语句强。 格式如下: case 表达式 is when 分支条件 => 顺序处理语句; when 分支条件 => 顺序处理语句; when 分支条件 => 顺序处理语句; end case; ┇
其中的分支条件可有以下的形式 When值=>顺序处理语句 When值to值=>顺序处理语句; when值值值-.值=>顺序处理语句 以上三种方式的混合 When others=>顺序处理语句;
24 其中的分支条件可有以下的形式: when 值 => 顺序处理语句; when 值 to 值 => 顺序处理语句; when 值|值|值|…|值 => 顺序处理语句; 以上三种方式的混合; when others => 顺序处理语句;
Case语句使用注 1)分支条件的值必须在表达式的取值范围内 2)两个分支条件不能重叠。 3)CASE语句执行时必须选中,且只能选中 个分支条件 4)如果没有 others'分支条件存在,则分支条 件必须覆盖表达式所有可能的值。 对 std_logo, std_logic_vector数据类型要特 别注意使用 others分支条件
25 Case 语句使用注意: 1)分支条件的值必须在表达式的取值范围内。 2)两个分支条件不能重叠。 3)CASE语句执行时必须选中,且只能选中一 个分支条件。 4)如果没有others分支条件存在,则分支条 件必须覆盖表达式所有可能的值。 对std_logc, std_logic_vector数据类型要特 别注意使用others分支条件