Verilog 错误"continuous assignment output must be a net"



我正在做一项任务,我必须合成我的Verilog代码。我编写了代码,进行了编译和模拟,一切都很顺利。当我去合成时,设计编译器在我的一个模块中给了我一个错误。该模块表示一个带有数据缓冲器的简单8位移位寄存器。当我合成时,它会给我一个错误:

连续分配输出缓冲区必须是净

我不知道这条消息在说什么。

module shiftReg(output shift_out,
output reg [7:0] data_buff,
input shift_write, clk, shift_in,
input [7:0] data);
reg [7:0] buffer;
assign shift_out = buffer[7];
assign buffer[0] = shift_in; //This is where it states an error.
always@(posedge clk) begin
if(shift_write == 1) begin
buffer <= {buffer[6:0],shift_in};
end
end
always@(shift_write) begin
if(shift_write == 0) begin
data_buff <= buffer;
buffer <= data;
end
end
endmodule 

消息告诉您,通过连续赋值(使用assign关键字(分配给的信号必须是网络类型变量,例如wire。但是,您将buffer声明为reg类型的变量。这是非法的,在你进行合成之前,你的模拟器至少应该警告你这一点。我使用的模拟器给了我编译错误。

你可以简单地删除这一行:

assign buffer[0] = shift_in; //This is where it states an error.

在第一个always块中,您已经在以下行中隐式地将buffer[0]分配给shift_in

buffer <= {buffer[6:0],shift_in};

修复后,您仍然有问题。由于多种原因,第二always块是奇数。语法是合法的,但它不符合良好的合成编码实践。也许您打算将2个always块合并为1:

module shiftReg (
output shift_out,
output reg [7:0] data_buff,
input shift_write, clk, shift_in,
input [7:0] data
);
reg [7:0] buffer;
assign shift_out = buffer[7];
always @(posedge clk) begin
if (shift_write) begin
buffer <= {buffer[6:0], shift_in};
end else begin
data_buff <= buffer;
buffer <= data;
end
end
endmodule 

相关内容

最新更新