Does the expression q <= q; is it necessary?
No, this is not the case, and in the case of ASIC, it can actually increase the area and power consumption. Iām not sure how modern FPGAs manage. During synthesis, the instrument will see this operator and will require q updating on each positive edge of the clock signal. Without this final else clause, the tool can only update q
only if the specified conditions are met.
In ASIC, this means that the synthesis tool can insert a clock-clock (if the library has one) instead of a multiplexer. For one DFF, this can be really worse, since the clock is usually much larger than the multiplexer, but if q
is 32 bits, then the savings can be very significant. Modern tools can automatically determine whether the amount of DFF matches the shared resolution with a specific threshold value, and then selects a clock valve or multiplexer accordingly.

In this case, the tool needs 3 multiplexers plus additional routing.
always @(posedge CLK or negedge RESET) if(~RESET) COUNT <= 0; else if(INC) COUNT <= COUNT + 1; else COUNT <= COUNT;

Here the tool uses a single timer for all DFFs.
always @(posedge CLK or negedge RESET) if(~RESET) COUNT <= 0; else if(INC) COUNT <= COUNT + 1;
Images here
user597225
source share