版主: 51FPGA |
xilinx论坛
最后登陆时间:2015-03-19 10:58:07 |
代码:
reg [1:0] state_now=2'b00; // 表示系统当前状态 reg [1:0] state_next=2'b00; // 表示系统下一个状态 parameter Wait = 2'b00, // 等待状态 Send = 2'b01; // 产生发送 always @(posedge clk or posedge rst) begin if(rst) begin state_now <= Wait; end else begin state_now <= state_next; end end always @(state_now or start or type) begin case(state_now) Wait: if(start) begin state_next = Send; case(type) 2'b00: duty<=1; 2'b01: duty<=5; 2'b10: duty<=9; 2'b11: duty<=0; endcase end Send: if(!start) begin state_next = Wait; duty<=0; end endcase end always @(posedge clk or posedge rst) begin if(rst) dout <= 1'b0; else case(state_next) Wait:; Send:; default:; endcase end 为什么编译后总是有warning: WARNING:Xst:737 - Found 2-bit latch for signal <state_next>. Latches may be generated from incomplete case or if statements. We do not recommend the use of latches in FPGA/CPLD designs, as they may lead to timing problems. |
共1条 1/1 1 |