没看懂什么原理,求大神指点!
moduleFSK2_JT( clk, rstn, in, out );
inputclk; inputrstn; inputin; outputout;
regout; integeri; integerj; reg[3:0]i_tmp; reg[3:0]cnt; regyt,y0,y1,y2,y3; always@(posedge clk or negedge rstn) begin if(!rstn)cnt<=0; elsebegin if(cnt==4'b1111)cnt<=0; else cnt<=cnt+1'b1; end end
always@(posedgeclk or negedge rstn) begin if(!rstn)i<=0; elsebegin if(in==1)i<=i+1; else if(in==0)begin i<=0;end end end
always@(posedge clk or negedge rstn) begin if(!rstn)begin y3<=0;i_tmp<=0;end else begin if(i==4) i_tmp<=i; else i_tmp<=0; if(i_tmp>=1) begin i_tmp<=i_tmp-1'b1; y3<=1; end else y3<=0; end end
always@(posedge clk or negedge rstn) begin if(!rstn)begin y0<=0;end elsebegin y2<=y3; y1<=y2; y0<=y1; yt<=y0; end end always@(posedge clk or negedge rstn) begin if(!rstn)begin out<=0;end elsebegin if(y3==1|yt==0) out<=0; if(y3==0|yt==1) out<=0; if(y3==0|yt==0) out<=1; if(y3==1|yt==1) out<=0; end end endmodule
|