麻烦大家看看这个为什么在DC编译中会报错呢?
时间:10-02
整理:3721RD
点击:
下面是code
module seqdet(clk,reset,x,z);
input clk;
input reset;
input [4:0] x;
output z;
reg [3:0] state;
reg [3:0] next_state;
reg z;
parameter IDLE = 4'd0;
parameter A = 4'd1;
parameter B = 4'd2;
parameter C = 4'd3;
parameter D = 4'd4;
parameter E = 4'd5;
parameter F = 4'd6;
parameter G = 4'd7;
parameter H = 4'd8;
always @ (posedge clk or posedge reset)
if (reset == 1'b1)
state <= IDLE;
else
state <= next_state;
always @ (state or x)
begin
next_state = 4'bxxxx;
case(state)
IDLE: if (x == 5'b11111)
next_state = A;
else if (x == 5'b00000)
next_state = D;
else next_state = IDLE;
A: if (x == 5'b11111)
next_state = B;
else if (x == 5'b00000)
next_state = G;
else next_state = IDLE;
B: if (x == 5'b11111)
next_state = C;
else if (x == 5'b00000)
next_state = G;
else next_state = IDLE;
C: if (x == 5'b00000)
next_state = G;
else
next_state =IDLE;
D: if (x == 5'b00000)
next_state = E;
else if (x == 5'b11111)
next_state = H;
else next_state = IDLE;
E: if (x == 5'b00000)
next_state = F;
else if (x == 5'b11111)
next_state = H;
else state = IDLE;
F: if (x == 5'b11111)
next_state = H;
else
next_state = IDLE;
G: if (x == 5'b00000)
next_state = E;
else if (x == 5'b11111)
next_state = A;
else
next_state = IDLE;
H: if (x == 5'b11111)
next_state = B;
else if (x == 5'b00000)
next_state = D;
else
next_state = IDLE;
default: next_state = IDLE;
endcase
end
always @ (state or x)
begin
case(state)
IDLE: z <= 1'b0;
A: z <= 1'b0;
B: z <= 1'b0;
C: if (x == 5'b11111)
z <= 1'b1;
else z<= 1'b0;
D: z <= 1'b0;
E: z <= 1'b0;
F: if (x == 5 'b00000)
z <= 1'b1;
else z <= 1'b0;
G: z <= 1'b0;
H: z <= 1'b0;
default: z <= 1'b0;
endcase
end
endmodule
就是一个三段式的检测电路,在DC2008中read的时候报错
Error: /home/wqy1985/Desktop/filter/seqdet.v:24: Net 'state[0]' or a directly connected net is driven by more than one source, and not all drivers are three-state. (ELAB-366)
应该是说的我的state被多个驱动了吧?但是我找不出是错在哪里?新人,希望高人指教
module seqdet(clk,reset,x,z);
input clk;
input reset;
input [4:0] x;
output z;
reg [3:0] state;
reg [3:0] next_state;
reg z;
parameter IDLE = 4'd0;
parameter A = 4'd1;
parameter B = 4'd2;
parameter C = 4'd3;
parameter D = 4'd4;
parameter E = 4'd5;
parameter F = 4'd6;
parameter G = 4'd7;
parameter H = 4'd8;
always @ (posedge clk or posedge reset)
if (reset == 1'b1)
state <= IDLE;
else
state <= next_state;
always @ (state or x)
begin
next_state = 4'bxxxx;
case(state)
IDLE: if (x == 5'b11111)
next_state = A;
else if (x == 5'b00000)
next_state = D;
else next_state = IDLE;
A: if (x == 5'b11111)
next_state = B;
else if (x == 5'b00000)
next_state = G;
else next_state = IDLE;
B: if (x == 5'b11111)
next_state = C;
else if (x == 5'b00000)
next_state = G;
else next_state = IDLE;
C: if (x == 5'b00000)
next_state = G;
else
next_state =IDLE;
D: if (x == 5'b00000)
next_state = E;
else if (x == 5'b11111)
next_state = H;
else next_state = IDLE;
E: if (x == 5'b00000)
next_state = F;
else if (x == 5'b11111)
next_state = H;
else state = IDLE;
F: if (x == 5'b11111)
next_state = H;
else
next_state = IDLE;
G: if (x == 5'b00000)
next_state = E;
else if (x == 5'b11111)
next_state = A;
else
next_state = IDLE;
H: if (x == 5'b11111)
next_state = B;
else if (x == 5'b00000)
next_state = D;
else
next_state = IDLE;
default: next_state = IDLE;
endcase
end
always @ (state or x)
begin
case(state)
IDLE: z <= 1'b0;
A: z <= 1'b0;
B: z <= 1'b0;
C: if (x == 5'b11111)
z <= 1'b1;
else z<= 1'b0;
D: z <= 1'b0;
E: z <= 1'b0;
F: if (x == 5 'b00000)
z <= 1'b1;
else z <= 1'b0;
G: z <= 1'b0;
H: z <= 1'b0;
default: z <= 1'b0;
endcase
end
endmodule
就是一个三段式的检测电路,在DC2008中read的时候报错
Error: /home/wqy1985/Desktop/filter/seqdet.v:24: Net 'state[0]' or a directly connected net is driven by more than one source, and not all drivers are three-state. (ELAB-366)
应该是说的我的state被多个驱动了吧?但是我找不出是错在哪里?新人,希望高人指教
等待高人解惑哦
希望今天会有结果
E: if (x == 5'b00000)
next_state = F;
else if (x == 5'b11111)
next_state = H;
else state = IDLE; //《--- 错误所在!
看来是个typo
楼上正解~
你在两个always block中对state进行了赋值,这样就不是同步状态机了,不能综合。
这个应该属于笔误,不小心造成的。
在2处赋值了,
应该是笔误,
lways @ (state or x)
begin
case(state)
IDLE: z <= 1'b0;
A: z <= 1'b0;
B: z <= 1'b0;
C: if (x == 5'b11111)
z <= 1'b1;
else z<= 1'b0;
D: z <= 1'b0;
E: z <= 1'b0;
F: if (x == 5 'b00000)
z <= 1'b1;
else z <= 1'b0;
G: z <= 1'b0;
H: z <= 1'b0;
default: z <= 1'b0;
endcase
end
endmodule
这个地方有问题,明显的错误啊
还有我个人认为三段式的状态机写法不怎么好,可以试图学习一下新思的写法。
三段式怎么不好了?
三段式至少比一段式的要合理