Re: [sv-bc] FW: interpretation of priority if-else or case statement

From: Brad Pierce <Brad.Pierce_at_.....>
Date: Wed Mar 30 2005 - 14:29:31 PST
Cliff,

Why would we want a case for this example?  Why not just --

   module decode4
   (output reg [3:0] y,
    input      [1:0] a,
    input            en);

   always_comb begin
     y = '0;
     y[a] = en ? '1 : '0;
   end

   endmodule

or

  // Using new generate
  module decode4
   (output reg [3:0] y,
    input      [1:0] a,
    input            en);

  for (genvar I = 3; I >= 0; I--) begin
    assign y[I] = (a == I) ? en : '0 ;
  end

  endmodule

or 

  //Using old generate
  module decode4
   (output reg [3:0] y,
    input      [1:0] a,
    input            en);

  genvar I;

  generate for (I = 3; I >= 0; I--) begin:GEN
    assign y[I] = (a == I) ? en : '0 ;
  end endgenerate

  endmodule

-- Brad
Received on Wed Mar 30 14:29:33 2005

This archive was generated by hypermail 2.1.8 : Wed Mar 30 2005 - 14:29:38 PST