2

I have a function f(), defined in a Verilog module, M1. I would like to reuse this same function in a different module, M2.

Is there anyway of doing this without redefining the function in M2?

  --- M1.v ---
  module M1();
     function f;
        //do stuff
     endfunction
  endmodule

  --- M2.v -----
  module M2();
  // Use f() here
  endmodule

1 Answer 1

3

You can place the function into a separate file and use the `include compiler directive to include the function inside both modules:

  --- M1.v ---
  module M1();
     `include "functions.v"
  endmodule

  --- M2.v -----
  module M2();
     `include "functions.v"
     // Use f() here
  endmodule
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.