anhnha
Full Member level 6

Hi all,
I have read this function in verilog:
I understand every code line but the problem is that I really don't know where the code is used?
What is the purpose of the function?
I have read this function in verilog:
Code:
module word_aligner (word_out, word_in);
output [7: 0] word_out;
input [7: 0] word_in;
assign word_out = aligned_word(word_in); // invoke function
function [7: 0] aligned_word; // function declaration
input [7: 0] word;
begin
aligned_word = word;
if (aligned_word != 0)
while (aligned_word[7] == 0) aligned_word = aligned_word << 1;
end
endfunction
endmodule
What is the purpose of the function?