[logo] 
 
Home
News
Activity
About/Contact
Major Tools
  Dinotrace
  Verilator
  Verilog-mode
  Verilog-Perl
Other Tools
  BugVise
  CovVise
  Force-Gate-Sim
  Gspice
  IPC::Locker
  Rsvn
  Schedule::Load
  SVN::S4
  Synopsys-modes
  SystemPerl
  Verilog-Pli
  Voneline
  Vregs
General Info
  Papers

Parsing Verilog widths correctly

Added by Ritesh Patel over 1 year ago

Hi,

I'm having the same issue as a previous user who had filed a bug (about 3 years ago: Here is a link to the fixed bug bug153)

My signal is declared like this:

input logic [32-1:0] dpr1_us_delay

I'm getting this issue:

Argument "32-1" isn't numeric in subtraction (-)

When I try to get the width of this signal it gives me 33 bits instead of 32 bits. Is this because I am using SV ports? I noticed the previous user was declaring Verilog ports.

Thanks for the support, Ritesh


Replies (4)

RE: Parsing Verilog widths correctly - Added by Wilson Snyder over 1 year ago

Strangely bug153 didn't indicate that the resolution was that it's the user's job to evaluate. I fixed that.

Doing better is a long term goal....

RE: Parsing Verilog widths correctly - Added by Nicky Ayoub 8 months ago

I am experiencing a similar issue. But in this case the expression is more complicated like: WIDTH-1

where width is a parameter. If the parameter is defined in the module declaration then I can look it up. I used the dump tests to figure this out:

module v_v2k
  1. ( input clk, input rst, input [WIDTH:0] sig1, output reg [WIDTH:0] sig2 );

But if I change the syntax a little I can't figure out how to reference the top level parameter (net) and I loose it:

parameter WIDTH = 16;
module v_v2k_mchp
 (
  input clk,
  input rst,
  input [WIDTH:0]      sig1,
  output reg [WIDTH:0] sig2
 );
~/src/perl/verilog/Verilog-Perl$ diff -c test_dir/42_v2k.dmp t/42_dumpcheck_v2k.out
  • test_dir/42_v2k.dmp 2011-09-16 16:09:56.144532000 -0700 --- t/42_dumpcheck_v2k.out 2011-09-16 15:15:45.348560000 -0700 *******
  • 3,8 ** --- 3,9 ---- Port:rst Dir:in DataT: Array: Port:sig1 Dir:in DataT:[WIDTH:0] Array: Port:sig2 Dir:out DataT:reg [WIDTH:0] Array: + Net:WIDTH DeclT:parameter NetT: DataT: Array: Value:16 Net:clk O DeclT:port NetT: DataT: Array: Net:rst O DeclT:port NetT: DataT: Array: Net:sig1 O DeclT:port NetT: DataT:[WIDTH:0] Array: WIDTH:0 nicky@hoser:~/src/perl/verilog/Verilog-Perl$

RE: Parsing Verilog widths correctly - Added by Wilson Snyder 8 months ago

Do you really mean you put WIDTH above the module declaration? That's legal SystemVerilog, but unusual and not what's normal.

Assuming not, you can $module->find_net("WIDTH") and use the found $net->value.

RE: Parsing Verilog widths correctly - Added by Nicky Ayoub 8 months ago

Yes, the parameter is declared above the module declaration and as you state is legal in SV but is not normal... So, I am assuming that WIDTH is not available as a net at the top level. I can see if we can change the source verilog and move on.

Thanks

(1-4/4)