verilog语言请教
总是显示Module contains unmapped components. The output netlist might not be read back into the system.
请问 这个代码有什么问题呢?谢谢
module softdrink(rst,clk,op_start,coin_val,cancel_flag,
hold_ind,charge_ind,drinktk_ind,charge_val);
input clk,rst;
input op_start,cancel_flag;
input [1:0] coin_val;
output hold_ind;
output charge_ind;
output drinktk_ind;
output [2:0]charge_val;
reg hold_ind;
reg charge_ind;
reg drinktk_ind;
reg [2:0]charge_val;
reg[2:0]currentstate,nextstate;
parameter S0=3'b000;
parameter S1=3'b001;
parameter S2=3'b010;
parameter S3=3'b011;
parameter S4=3'b100;
parameter S5=3'b101;
parameter S6=3'b110;
always@(posedge clk or posedge rst)
if(rst)
currentstate<=S0;
else
currentstate<=nextstate;
always@(rst or currentstate or op_start or cancel_flag or coin_val)
if(rst) nextstate=S0;
else case(currentstate)
S0:
if(op_start)
if(coin_val==2'b01) nextstate=S1;
else if (coin_val==2'b10) nextstate=S2;
S1:
if(cancel_flag) nextstate=S0;
else if(coin_val==2'b01) nextstate=S2;
else if (coin_val==2'b10) nextstate=S3;
S2:
if(cancel_flag) nextstate=S0;
else if(coin_val==2'b01) nextstate=S3;
else if (coin_val==2'b10) nextstate=S4;
S3:
if(cancel_flag) nextstate=S0;
else if(coin_val==2'b01) nextstate=S4;
else if (coin_val==2'b10) nextstate=S5;
S4:
if(cancel_flag) nextstate=S0;
else if(coin_val==2'b01) nextstate=S5;
else if (coin_val==2'b10) nextstate=S6;
S5: nextstate=S0;
S6: nextstate=S0;
default:
nextstate=S0;
endcase
always@(currentstate)
if(currentstate==S0)
hold_ind=1'b0;
else
hold_ind=1'b1;
always@(currentstate)
if((currentstate==S5)||(currentstate==S6))
drinktk_ind=1'b1;
else
drinktk_ind=1'b0;
always@(currentstate or cancel_flag)
if(currentstate==S0)
charge_ind=1'b0;
else if(currentstate==S6)
charge_ind=1'b1;
else if(cancel_flag)
charge_ind=1'b1;
else
charge_ind=1'b0;
always@(currentstate or cancel_flag )
if(currentstate==S0) charge_val=3'b000;
else if(currentstate==S6)
charge_val=3'b001;
else if(cancel_flag)
begin
case(currentstate)
S1: charge_val=3'b001;
S2:charge_val=3'b010;
S3:charge_val=3'b011;
S4:charge_val=3'b100;
default:charge_val=3'b000;
endcase
end
else
charge_val=3'b000;
endmodule
第二个always 列表中把rst拿掉。
太感谢了 回头去实验室试试去
还是不太行。
你是怎么拿掉的?后面里和rst 有关的语句也要拿掉的。
你的意思是把
always@(rst or currentstate or op_start or cancel_flag or coin_val)
if(rst) nextstate=S0;
else case(currentstate)
S0:
if(op_start)
if(coin_val==2'b01) nextstate=S1;
else if (coin_val==2'b10) nextstate=S2;
S1:
if(cancel_flag) nextstate=S0;
else if(coin_val==2'b01) nextstate=S2;
else if (coin_val==2'b10) nextstate=S3;
S2:
if(cancel_flag) nextstate=S0;
else if(coin_val==2'b01) nextstate=S3;
else if (coin_val==2'b10) nextstate=S4;
S3:
if(cancel_flag) nextstate=S0;
else if(coin_val==2'b01) nextstate=S4;
else if (coin_val==2'b10) nextstate=S5;
S4:
if(cancel_flag) nextstate=S0;
else if(coin_val==2'b01) nextstate=S5;
else if (coin_val==2'b10) nextstate=S6;
S5: nextstate=S0;
S6: nextstate=S0;
default:
nextstate=S0;
endcase
改成这样? 不好意思 刚接触这东西 不太明白
always@(currentstate or op_start or cancel_flag or coin_val)
S0:
if(op_start)
if(coin_val==2'b01) nextstate=S1;
else if (coin_val==2'b10) nextstate=S2;
S1:
if(cancel_flag) nextstate=S0;
else if(coin_val==2'b01) nextstate=S2;
else if (coin_val==2'b10) nextstate=S3;
S2:
if(cancel_flag) nextstate=S0;
else if(coin_val==2'b01) nextstate=S3;
else if (coin_val==2'b10) nextstate=S4;
S3:
if(cancel_flag) nextstate=S0;
else if(coin_val==2'b01) nextstate=S4;
else if (coin_val==2'b10) nextstate=S5;
S4:
if(cancel_flag) nextstate=S0;
else if(coin_val==2'b01) nextstate=S5;
else if (coin_val==2'b10) nextstate=S6;
S5: nextstate=S0;
S6: nextstate=S0;
default:
nextstate=S0;
endcase
always@(currentstate or op_start or cancel_flag or coin_val)
begin
case(currentstate)
S0:
if(op_start)
if(coin_val==2'b01) nextstate=S1;
else if (coin_val==2'b10) nextstate=S2;
S1:
if(cancel_flag) nextstate=S0;
else if(coin_val==2'b01) nextstate=S2;
else if (coin_val==2'b10) nextstate=S3;
S2:
if(cancel_flag) nextstate=S0;
else if(coin_val==2'b01) nextstate=S3;
else if (coin_val==2'b10) nextstate=S4;
S3:
if(cancel_flag) nextstate=S0;
else if(coin_val==2'b01) nextstate=S4;
else if (coin_val==2'b10) nextstate=S5;
S4:
if(cancel_flag) nextstate=S0;
else if(coin_val==2'b01) nextstate=S5;
else if (coin_val==2'b10) nextstate=S6;
S5: nextstate=S0;
S6: nextstate=S0;
default:
nextstate=S0;
endcase
end
还有你的so状态里是一个if还是两个if语句?
建议你写成这样:
always@(*)
begin
case(currentstate)
S0:
if(op_start) (加上你的语句)
else if(coin_val==2'b01) nextstate=S1;
else if (coin_val==2'b10) nextstate=S2;
S1:
if(cancel_flag) nextstate=S0;
else if(coin_val==2'b01) nextstate=S2;
else if (coin_val==2'b10) nextstate=S3;
S2:
if(cancel_flag) nextstate=S0;
else if(coin_val==2'b01) nextstate=S3;
else if (coin_val==2'b10) nextstate=S4;
S3:
if(cancel_flag) nextstate=S0;
else if(coin_val==2'b01) nextstate=S4;
else if (coin_val==2'b10) nextstate=S5;
S4:
if(cancel_flag) nextstate=S0;
else if(coin_val==2'b01) nextstate=S5;
else if (coin_val==2'b10) nextstate=S6;
S5: nextstate=S0;
S6: nextstate=S0;
default:
nextstate=S0;
endcase
end
这个星号verilog2001是支持的。
太感谢了。好心人。 我们学校用的是个叫synopsys的软件 代码实在不太会改
Always中,if-else语句没写全产生了LATCH!
你先试下吧,不行再找问题。
目前我看到的就是这些问题了。
另外,不知道到你要做到什么程度,后端要做吗。
如果做的话,你这代码风格上要改改。
如果只是拿来玩玩,能跑起来就可以的话,就无所谓了。
还有10楼的回复也是你代码中的一个问题。
时钟周期太短?
没仔细看,但就觉着吧,
always
begin
.....
end
还是写完整好点儿
是不是rst改成~rst,我记得复位信号都是低电平触发?
是不是rst改成~rst,我记得复位信号都是低电平触发?
