Altera_Forum
Honored Contributor
11 years agoCritical Warning (10237) can't infer register isn't issued for certain always blocks
Hello, I am having issues with the warning 10237. I understand its purpose and understand the incorrect code that can generate it. My issue is that I have seen instances where a synchronous code block has been replaced by combinatorial logic without a warning.
This code produces a warning: ""Critical Warning (10237): Verilog HDL warning at warnings.v(8): can't infer register for assignment in edge-triggered always construct because the clock isn't obvious. Generated combinational logic instead"" as it should:
module warnings
(input clk,
input reset,
input data_in,
output reg q );
always @(posedge clk or negedge reset) q <= data_in;
endmodule However this code does not produce a warning (and no registers are shown in the RTL viewer): module warnings
(input clk,
input rst,
input state,
input data,
input i,
input c,
output reg ia,
output reg ca );
always @(posedge clk or posedge rst) begin
case(state)
4'b0010, 4'b1100 : begin
ia <= i + data;
ca <= c + 8'b1;
end
default : begin
ia <= 'b0;
ca <= 'b0;
end
endcase
end
endmodule Whereas this code does produce registers (as seen in gate-level simulations and in the RTL viewer):
module warnings
(input clk,
input rst,
input state,
input data,
input i,
input c,
output reg ia,
output reg ca );
always @(posedge clk or posedge rst) begin
if (rst) begin
ia <= 'b0;
ca <= 'b0;
end
else begin
case(state)
4'b0010, 4'b1100 : begin
ia <= i + data;
ca <= c + 8'b1;
end
default : begin
ia <= 'b0;
ca <= 'b0;
end
endcase
end
end
endmodule