I'm seeing some where differences in circuit simulation when changing what should be an unrelated module. I'm trying to understand what optimizations are going on here to cause this:
// Multiplicand Load Register
module mc (input clkIn,
input rstIn,
input [7:0]multicIn,
input ldMIn,
output reg [7:0]multicOut);
always @ (posedge clkIn)
begin
if (rstIn)
multicOut <= 8'b00000000;
else if (ldMIn)
multicOut <= multicIn;
end
endmodule //mc
// Multiplier Shift Register
module mp (input clkIn,
input rstIn,
input [7:0]multipIn,
input ldMIn,
input srPIn,
input irIn,
output reg [7:0]prodLowOut);
always @ (posedge clkIn)
begin
if (rstIn)
prodLowOut <= 8'b00000000;
else if (ldMIn)
prodLowOut <= multipIn;
else if (srPIn)
prodLowOut <= {irIn, prodLowOut[7:1]};
end
endmodule //mp
If I simulate this as it is, the mc module loads a clock cycle early (seeming to infer a latch):
But if I comment out the shift register, else if srPIn, line in mp (effectively making them the same), then mc loads at the correct time:
My question is, why are changes in one module seeming to affect changes in another? Am I hitting some weird optimization area? Why am I inferring a latch where I shouldn't be? This seems to follow the correct rules for writing a register.