Part 1:
I was always told to use functions in Verilog to avoid code duplication. But can't I do that with a module? If my understanding is correct, all functions can be re-written as modules in Verilog except that modules cannot be instantiated from the inside of an always block. Except, in this case, I can always stick with modules. Am I correct?
Part 2:
If I am correct, why can't the Verilog compiler be written in such a way that the modules get the treatment of a function? I mean, why can't the compiler allow the programmer to instantiate a module inside n block and stop supporting functions?
parametersandgenerateblocks. Check out this 32-bit ALU I wrote for computer architecture using a recursively defined LAC.alwaysblocks, because it doesn't make any sense to have it in the context of sequential logic. I hope that at least answers part of your question.