1

I used the code below as a function in ModelSim, and it raised the error of 'Global declarations are illegal in Verilog 2001 syntax'. could anyone help me with this?

function [24:0] shiftright(input [24:0] in);
integer i;
begin
if (in)
for (i=0; i<25; i=i+1) begin
    if (i == 24) shiftright[i]<= 0;
    else shiftright[i] <= in[i+1];
end
end
endfunction

1 Answer 1

0

You have written your function outside of a module declaration. All declarations must be inside a module in Verilog. SystemVerilog does allow variables, functions and a number of other things outside of a module.

Also, you cannot use a non-blocking assignment to the return value of a function.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.