Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Parameter as bit width in verilog CONSTANT

Status
Not open for further replies.

imbichie

Full Member level 6
Full Member level 6
Joined
Jul 30, 2010
Messages
381
Helped
55
Reputation
110
Reaction score
54
Trophy points
1,308
Location
Cochin/ Kerala/ India or Bangalore/ Karnataka/ Ind
sites.google.com
Activity points
3,580
Hi all,

How we can use the parameter as bit width in verilog for a CONSTANT value representation.
For example :
Code:
parameter VAL = 11;
always @ ( posedge CLK or negedge RESETn )
  begin
    if ( !RESETn )
      begin
        count <= {VAL{1'b0}};
      end
    else
      begin
        if ( count == [B][COLOR="#FF0000"]11'h5FF[/COLOR][/B] )
          begin
            count <= {VAL{1'b0}};
          end
        else 
          begin
            count <= count + [B][COLOR="#FF0000"]11'h1[/COLOR][/B];
          end
      end
  end

So here instead of 11'h5FF and 11'h1, how I can replace this with parameter VAL.
 

11'h5FF can be replaced with {VAL{1'b1}}. {n{M}} means concatenate the replication of M, n times.

There is no need to size operands to get 0's extended, Verilog does this automatically

Code:
parameter VAL = 11;
always @ ( posedge CLK or negedge RESETn )
  begin
    if ( !RESETn )
      begin
        count <= 0;
      end
    else
      begin
        if ( count == {VAL{1'b1}} )
          begin
            count <= 0;
          end
        else 
          begin
            count <= count + 1;
          end
      end
  end
 

11'h5FF can be replaced with {VAL{1'b1}}. {n{M}} means concatenate the replication of M, n times.

Hi Dave thank you for your reply.

But i think 11'h5FF -> 11'b101_1111_1111
so it cannot be {11{1'b1}} -> 11'b111_1111_1111
so here {VAL{1'b1}} means its 11'h7FF not 11'h5FF.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top