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.

equivalent function in Verilog for VHDL 'LENGTH function?

Status
Not open for further replies.

korgull

Junior Member level 1
Joined
Jun 5, 2008
Messages
18
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
MN, United States
Activity points
1,418
verilog log function

Hi,
Is there a way or an equivalent command in Verilog which does the same thing as the 'LENGTH function in VHDL? If I am correct, the syntax of

Code:
Data'LENGTH
will return the bit size of the signal "Data", which is what I would like to do.

thanks
 

equivalent of (others => 0) in verilog

No, Verilog-2001 doesn't have any equivalents for many VHDL attributes ('size, 'left, 'right, 'high, 'low, etc.)

...but that's where Systemverilog 1800-2005 comes in...
Code:
$size(Data)

Systemverilog has a direct-equivalent for most of the VHDL-attributes/properties (including 'length). SV is still missing some, but it's a vast vast improvement over legacy Verilog.
 

    korgull

    Points: 2
    Helpful Answer Positive Rating
length in vhdl

boardlanguage said:
No, Verilog-2001 doesn't have any equivalents for many VHDL attributes ('size, 'left, 'right, 'high, 'low, etc.)

...but that's where Systemverilog 1800-2005 comes in...
Code:
$size(Data)

Systemverilog has a direct-equivalent for most of the VHDL-attributes/properties (including 'length). SV is still missing some, but it's a vast vast improvement over legacy Verilog.

thanks!

Can you recommend a good book for learning more about System Verilog commands?

However.. I did a quick check at Amazon, and from that I gather that System Verilog is for testbenches ? I need this to create a functional/behavioral model. Will this still be synthesizable?
 

length vhdl

Because it's new, Systemverilog is not as widely supported as VHDL or Verilog-2001.

You're right -- at the moment, it's mostly used for testbench/verification. But there is a synthesizeable subset of Systemverilog, so it can be used for new designs. Altera Quartus-II 8.0, Synopsys Design Compiler, Cadence RTL Compiler can synthesize Systemverilog RTL. (I think other tools like Synplicity can do it, too, but Design Compiler is probably the best at the moment.)

An older PDF version of the Systemverilog standard (3.1a) is available from:
**broken link removed**

As for books, there have been books posted in this forum and others -- just do a search and they'll come up.

Anyway ... if you must stay with Verilog, then unfortunately there's no direct equivalent for 'LENGTH. You can sort of work around that by using a parameter (it works just like a VHDL generic)
Code:
parameter integer DATA_W = 16;

reg [DATA_W-1:0] Data;

// $size(Data) --> DATA_W
 

    korgull

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top