case statement

Let’s always start by code:


case sel is 
  when choice_1 =>
     sequential statements;
  when choice_2 =>
     sequential statements;
  ...
  when others =>
     sequential statements;
end case;

the previous statement:


with sel select
 r <= a + b + c when "00",
      a - b  when "10",
      c + 1 when others;

can be rewritten as:


process(a,b,c,sel)
begin
  case sel is 
     when "00" =>  
      r <= a + b + c;
     when "10" =>  
      r <= a - b;
     when others =>  
      r <= c + 1;
  end case
end; 

Can you rewrite the priority encoder using a case statement?

News Reporter
Dr. Lu

发表评论

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

跳至工具栏