laforest / FPGADesignElements

A self-contained online book containing a library of FPGA design modules and related coding/design guides.
MIT License
387 stars 40 forks source link

Constant.v:24: warning: @* found no sensitivities so it will never trigger. #7

Closed rodrigomelo9 closed 4 years ago

rodrigomelo9 commented 4 years ago

It is a complaint from iVerilog. The problem is here (because nothing is changed inside of the always):

    always @(*) begin
        constant_out = VALUE;
    end

What about to use an assign instead? Something like:

module Constant
#(
    parameter WORD_WIDTH    = 0,
    parameter VALUE         = 0
)
(
    output wire [WORD_WIDTH-1:0] constant_out
);

    assign constant_out = VALUE;

endmodule

Let me know if you agree with the suggested change to create a PR.

PS: is only a warning, which could have not a negative effect, but in this form is simpler and the warning removed.

laforest commented 4 years ago

I didn't test with iverilog, so you are finding corner cases I missed. Good! For code quality and organization reasons, I completely avoid the use of assign except when it must be used. You've just found a third such exception. :) Yes, please go ahead with the PR. I will be editing my coding standard to match. Thanks!

laforest commented 4 years ago

Thanks!