Verilog代码将模拟但赢得';不能合成。
这是我的有限状态机的代码Verilog代码将模拟但赢得';不能合成。,verilog,fsm,synthesis,vivado,Verilog,Fsm,Synthesis,Vivado,这是我的有限状态机的代码 // `timescale 1ns / 1ps //Moore Finite State Machine Lab 3 // // WORKING, needs Screen output module moore( input BTNC, //manual clk input SW0, //clr input SW1, input SW2, input SW3, input SW
//
`timescale 1ns / 1ps
//Moore Finite State Machine Lab 3
//
// WORKING, needs Screen output
module moore(
input BTNC, //manual clk
input SW0, //clr
input SW1,
input SW2,
input SW3,
input SW4,
output reg [3:0] LED, //z
reg [2:0] y,Y
);
localparam S_00=3'b000, S_01=3'b001, S_02=3'b010,
S_03=3'b011, S_04=3'b100;
//Define next state
always @(y,SW0,SW1,SW2,SW3,SW4)
begin
case (y)
S_00: if (SW1) Y <= S_01;
else Y <= S_00;
S_01: if (SW1) Y <= S_02;
else if (SW3) Y <= S_03;
else Y <= S_01;
S_02: if (SW1) Y <= S_04;
else Y <= S_02;
S_03: if (SW2) Y <= S_04;
else if (SW3) Y <= S_02;
else Y <= S_03;
S_04: if (SW2) Y <= S_02;
else if (SW4) Y <= S_00;
else Y <= S_04;
default: Y <= 3'bxxx;
endcase
end
//Define state update
always @(SW0, BTNC)
begin
if (!SW0) y <= S_00;
else y <= Y;
end
//Define output
always @(y)
if (y==S_00)
begin
assign LED = 3'b000;
end
else if (y==S_01)
begin
assign LED = 3'b001;
end
else if (y==S_02)
begin
assign LED = 3'b010;
end
else if (y==S_03)
begin
assign LED = 3'b011;
end
else if (y==S_04)
begin
assign LED = 3'b100;
end
else
begin
assign LED = 3'b000; //not used
end
endmodule // lab3ht codename moore
我知道延迟是无法合成的,我试图通过消除延迟来解决这个问题
当然总是@(negedge BTNC),只需按下按钮,但这就是我对verilog的了解。我不知道为什么这不能被合成,所以我可以稍后生成一个比特流并上传到basys3板上,然后在那里使用它
非常感谢您提供的任何见解,代码在模拟过程中运行得非常漂亮参考了警告。您在程序块中使用了
assign
语句,使其成为程序连续赋值
[Synth 8-27] procedural assign not supported
这些类型的作业可以被大多数工具综合,但很容易被误用,因此尽量避免。您的工具似乎不支持这种类型的语句。因此,删除赋值语句,并在每个if..else if..else
条件中使用简单阻塞语句
// Remove assign
else if (y==S_04)
assign LED = 3'b100;
//...
// use simple blocking statements
else if (y==S_04)
LED = 3'b100;
与Y
相关的另一个警告是由于always@(SW0,BTNC)
块的敏感度列表不完整。您正在使用else y=y代码>在此块中。此后,Y
必须出现在灵敏度列表中
[Synth 8-567] referenced signal 'Y' should be on the sensitivity list
对于任何组合始终
块,建议使用始终(*)
或始终梳
。这将消除提供手动灵敏度时出现的任何错误。您可以在此处将所有始终
块的灵敏度(时钟始终
块除外)转换为始终(*)
另外,您的下一状态逻辑始终块是一个组合块。必须在该块中使用分块(=
)赋值
always @(*)
begin
case (y)
S_00: if (SW1) Y = S_01; // blocking assignment
else Y = S_00; // blocking assignment
//...
有关更多信息,请参阅问题。此外,和链接也可能有用
always @(*)
begin
case (y)
S_00: if (SW1) Y = S_01; // blocking assignment
else Y = S_00; // blocking assignment
//...