0
該有限狀態機用作數據路徑的控制器,該數據路徑包含計算兩個4位數的GCD所需的運算符。我對這種語言相當陌生,我意識到這個問題可能是一個缺失的分號,或者可能與我的聲明有關,但我無法弄清楚問題所在。我不斷收到錯誤:Verilog FSM和模塊實例化
錯誤:HDLCompiler:806 - 「D:/ Xilinx Stuff/GCD/GCD FSM.v」第44行:「if」附近出現語法錯誤。 錯誤:HDLCompiler:806 - 「D:/ Xilinx Stuff/GCD/GCD FSM.v」第60行:在「=」附近出現語法錯誤。 錯誤:HDLCompiler:806 - 「D:/ Xilinx Stuff/GCD/GCD FSM.v」行64:在「=」附近出現語法錯誤。 錯誤:HDLCompiler:806 - 「D:/ Xilinx Stuff/GCD/GCD FSM.v」行68:在「;」附近出現語法錯誤。
我也開到關於一般的邏輯任何提示,爲FSM的代碼如下所示:我注意到
module GCD_FSM(clk,data_in,reset,data_out,x_in,y_in,gcd_out,xgty,xlty,xequaly,go_in,xnew,ynew);
input clk, data_in, reset,go_in;
input reg[3:0] x_in,y_in,gcd_out;
output reg [1:0] data_out;
reg [3:0] x,y;
output reg[3:0] xnew,ynew;
output reg xgty,xlty,xequaly,cleango;
// Declare state register
reg [1:0]state;
// Declare states
parameter S0 = 0, S1 = 1, S2 = 2, S3 = 3, S4 =4;
/* Output depends only on the state
always @ (state) begin
case (state)
S0:
data_out = 2'b01;
S1:
data_out = 2'b10;
S2:
data_out = 2'b11;
S3:
data_out = 2'b00;
default:
data_out = 2'b00;
endcase
end
*/
// Determine the next state
always @ (posedge clk or posedge reset) begin
if (reset)
state <= S0;
else
case (state)
S0:
debounce start(.clock(clk),.noisy(go_in),.clean(cleango));
if (cleango)
state <= S1;
else
state <= S0;
S1:
state <= S2;
S2:
if (xlty)
state <= S3;
else if(xgty)
state <= S4;
else if(xequaly)
state <= S5;
S3:
ripple_carry_adder_subtractor ysubx(.S(ynew),.C(carry),.V(overflow),.A(y),.B(x),.Op(1));
y = ynew;
state <= S2;
S4:
ripple_carry_adder_subtractor xsuby(.S(xnew),.C(carry),.V(overflow),.A(x),.B(y),.Op(1));
x = xnew;
state <= S2;
S5:
gcd_out = x;
state <= S0;
endcase
end
endmodule
感謝您的糾正!儘管如此,仍然收到相同的錯誤代碼 – Antoninus 2015-02-18 19:21:22
您可以在此處或在http://www.edaplayground.com/ – Ari 2015-02-18 22:11:08
上發佈您的修改後的代碼我編輯了我的原始文章以反映更改,同時debounce位於單獨的模塊中。 – Antoninus 2015-02-18 22:35:46