문제상황:
실무에서 사용되는 Verilog 코드를 작성하던 중, 아래와 같은 에러 로그가 발생했습니다.
에러가 발생한 코드와 이에 대한 설명:
module counter (
input wire clk,
input wire rst,
output wire [7:0] count
);
always @(posedge clk or posedge rst) begin
if (rst) begin
count <= 8'b0;
end else begin
count <= count + 8'b1;
end
end
endmodule
에러로그 내용:
Error: Procedural assignment to a non-register (count) is not permitted
해결방법:
에러가 수정된 코드+ 수정된 부분에 대한 주석:
module counter (
input wire clk,
input wire rst,
output reg [7:0] count // 수정: output wire를 output reg로 변경
);
always @(posedge clk or posedge rst) begin
if (rst) begin
count <= 8'b0;
end else begin
count <= count + 8'b1;
end
end
endmodule
원인분석:
- 에러 발생 원리: 이 에러는 합성 가능한 프로시져 블록(always 블록) 내에서 비-레지스터 변수(wire)에 대한 프로시져 대입을 시도했기 때문에 발생한 것입니다. 합성 가능한 프로시져 블록 내에서는 오직 레지스터 변수(reg)에 대해서만 프로시져 대입이 가능합니다.
- 해결된 코드의 작동 원리: 해결된 코드에서는 에러가 발생한 count 변수를 output wire에서 output reg로 변경하여 문제를 해결했습니다. 이렇게 함으로써 합성 가능한 프로시져 블록 내에서 레지스터 변수에 대한 프로시져 대입이 가능해지고, 에러가 발생하지 않게 됩니다.
참고링크:
[Error "procedural assignment to a non-register result is not permitted"
I'm getting the error [Synth 8-2576] procedural assignment to a non-register result is not permitted ["lpm_mult.v":29] What am i doing wrong? module lpm_mult ( dataa, datab, //
stackoverflow.com](https://stackoverflow.com/questions/31472546/error-procedural-assignment-to-a-non-register-result-is-not-permitted)
728x90