2.用 verilog 编程,语法要符合 FPGA 设计的要求
3.设计工程中可使用的工具及设计大致过程?
设计过程:
1、首先确定输入输出,A=1 表示投入 10 分,B=1 表示投入 5 分,Y=1 表示弹出饮料,
Z=1 表示找零。
2、确定电路的状态,S0 表示没有进行投币,S1 表示已经有 5 分硬币。
3、画出状态转移图。
module sell(clk,rst,a,b,y,z);
input clk,rst,a,b;
output y,z;
parameter s0=0,s1=1;
reg state,next_state;
always@(posedge clk)
begin
if(!rst)
state<=s0;
else
state<=next_state;
end
always@(a or b or cstate)
begin
y=0;z=0;
case(state)
s0: if(a==1&&b==0) next_state=s1;
else if(a==0&&b==1)
begin
next_state=s0; y=1;
end
else
next_state=s0;
s1: if(a==1&&b==0)
begin
next_state=s0;y=1;
end
else if(a==0&&b==1)
begin
next_state=s0; y=1;z=1;
end
else
next_state=s0;
default: next_state=s0;
endcase
end
endmodule