Home Verilog Digital Design Digital Basics Python RF Basics

Legal Disclaimer

Chip Designing for ASIC/ FPGA Design engineers and Students
FULLCHIPDESIGN
Digital-logic Design...  Dream for many students… start learning front-end…
Custom Search

Feedback ? Send it to admin@fullchipdesign.com or join me at fullchip@gmail.com

Verilog Initial stmts IF-ELSE Case stms Readmemh Function Testbench Binary to Gray Clock Crossing Half-adder Full-adder Tristate buffer Adder tb Counter_enable Blocking Operators Shift LSR Random Nos Sync RAM Verilog Tutorial

Legal Disclaimer

Topics @TYH :- 4G LTE Tutorial, GVIM editor, Smart-Phone, Cloud Computing
Previous Next
Verilog Tutorial.
Digital Basics Tutorial.
Verilog code to Function call and Declaration.  
/*Verilog functions are discussed here.*/
reg [5:0] counter_binary, counter_binary_reg, counter_gray, counter_gray_reg;
integer count, file_wr;
/*Function Declaration: Gray from Binary code*/
function[5:0] binary2gray ;
   input[5:0] value;
   integer i;

   begin
        binary2gray[5] = value[5];
       for (i=5; i>0; i = i - 1)
           binary2gray[i-1] = value[i] ^ value[i - 1];
   end
endfunction
//Function call
always @(*)
begin
counter_binary = counter_binary_reg;
counter_gray = binary2gray(counter_binary_reg);
end .............
endmodule
Check the complete usage of the function in following verilog example
Verilog Function declaration and call.
Interview Questions. Main, FPGA, Digital Fundamentals
LTE - Long Term Evolution topics
Return to Verilog Tutorial
3D draw and render

Verilog functions are used to simplify coding in presence of lengthy, complex and repetitive code. Functions are used to group code segments which can then be used multiple (no limit) times. Terms used in example code below are Function Declaration and Function Call.     

Properties of functions:

(1) Can only be used to pass one argument to/from function.

5 Steps required to build a functional FPGA load (valid for most EDA flows)

How to implement a Integrated Clock Gating (ICG) cell from vendor library.

CMOS Digital Integrated Circuit design for VLSI.

Interview Questions. Main, FPGA, Digital Fundamentals
Interview Questions. Main, FPGA, Digital Fundamentals
Readmemh.
Testbench.

(2) Function code segments with latches will not get interpreted during synthesis. So avoid latches in function code to prevent simulation/synthesis mis-match. (3) A function can only be called from an “always” code block. For test benches its also allowed from within “initial” blocks. (4)  Never use delay, event or timing control in functions. (5) Wires are not allowed in verilog functions.

4G LTE - Long Term Evolution here