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.

[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
 

Using $clog2 is how you do that in Verilog so it should work just as well in SV.
 
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?
 

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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top