Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

[SOLVED] System Verilog Function Usage

Status
Not open for further replies.

russeree

Newbie level 2
Joined
Jul 14, 2013
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
11
I am very new to functions, I have a parameter to specify the input freq(mhz). Would this return a value I could use to specify a vector width?
Code:
function int _ms_unit_width;
    int freq_mhz = (int_input_freq_mhz/1000);
    _ms_unit_width = ($clog2(freq_mhz)+1);
endfunction
 

ads-ee

Super Moderator
Staff member
Joined
Sep 10, 2013
Messages
7,655
Helped
1,774
Reputation
3,556
Reaction score
1,724
Trophy points
1,393
Location
USA
Activity points
57,836
Using $clog2 is how you do that in Verilog so it should work just as well in SV.
 

russeree

Newbie level 2
Joined
Jul 14, 2013
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
11
I was more concerned about the output type of an int? Is that a legal value to put a 'input wire [x:y] name' declaration?
 

ads-ee

Super Moderator
Staff member
Joined
Sep 10, 2013
Messages
7,655
Helped
1,774
Reputation
3,556
Reaction score
1,724
Trophy points
1,393
Location
USA
Activity points
57,836
Verilog and sv aren't strongly typed languaages like VHDL, so you can assign an integer to a wire vector, though you may end up with truncation depending on the value of the integer and the width of the vector.
 
Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top