这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » 软件与操作系统 » case语句和if 语句有什么区别吗?

共1条 1/1 1 跳转至

case语句和if 语句有什么区别吗?

助工
2007-10-22 20:25:09     打赏

process(row_t,col,he)
begin
 he<=col&row_t;
  case he is
   when "0111101111"=>bcd_8_t<="00000001"; --01  
   when "1011101111"=>bcd_8_t<="00000010"; --02 
   when "1101101111"=>bcd_8_T<="00000011"; --03
   when "1110101111"=>bcd_8_T<="00000100"; --04
   when "1111001111"=>bcd_8_T<="00000101"; --05
  end case;
end process;

这段程序用if语句写的话,编译就会报错,为什么呢?

process(row_t,col,he)
begin
 he<=col&row_t;
   if he= "0111101111" then  bcd_8_t<="00000001"; --01  
   elsif  he= "1011101111" then  bcd_8_t<="00000010"; --02  
   elsif   he= "1101101111"   then  bcd_8_T<="00000011"; --03
   elsif   he= "1110101111"    then bcd_8_T<="00000100"; --04
   elsif   he= "1111001111"    then bcd_8_T<="00000101"; --05
  end if;

end process;




关键词: 语句     什么     区别    

共1条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]