Home.Verilog.Digital Design.Digital Basics.Python.RF Basics.
Previous.
Next.
Custom Search

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

Legal Disclaimer

Chip Designing for ASIC/ FPGA Design engineers and Students
FULLCHIPDESIGN
Digital-logic Design...  Dream for many students… start learning front-end…
Try navigation bar on top to explore the contents @ fullchipdesign

Legal Disclaimer

Custom Search

/*Function declaration and calling a function is discussed in this section.*/

reg [5:0] counter_binary, counter_binary_reg, counter_gray, counter_gray_reg;
integer count, file_wr;

/*Function to get Gray code 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

//Calling a function
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
Function declaration and use in Verilog.