问题描述
我仍然在最低的Verilog级别(门级别)玩。 我发现了这篇文章: https://electronics.stackexchange.com/questions/390661/is-it-possible-to-create-a-working-jk-flip-flop-using-gate-level-description-in 通过这种方式,我可以理解这个想法应该行得通,并且我可以解决将Master-Slave JK触发器用作分频器的问题。我使用Icestorm工具链,Yosys没有抱怨,但是Next-PNR给我这个错误:
错误:由于存在组合循环,定时端口规范不完整等原因,导致定时分析失败。
这是我的代码:
module syncRX(clk,signal,detect);
output wire [7:0] detect;
input clk,signal;
reg [6:0] det = 7'b1001010;
assign detect = {det,jk5_out};
jk_flip_flop_edge_triggered jk0(.Q(jk5_out),.Qn(Qn),.C(clk),.J(1),.K(1),.RESETn(0));
endmodule // top
module jk_flip_flop_edge_triggered(Q,Qn,C,J,K,RESETn);
output Q;
output Qn;
input C;
input J;
input K;
input RESETn;
wire Kn; // The complement of the K input.
wire D;
wire D1; // Data input to the D latch.
wire Cn; // Control input to the D latch.
wire Cnn; // Control input to the SR latch.
wire DQ; // Output from the D latch,inputs to the gated SR latch (S).
wire DQn; // Output from the D latch,inputs to the gated SR latch (R).
assign D1 = !RESETn ? 0 : D; // Upon reset force D1 = 0
not(Kn,K);
and(J1,Qn);
and(K1,Kn,Q);
or(D,J1,K1);
not(Cn,C);
not(Cnn,Cn);
d_latch dl(DQ,DQn,Cn,D1);
sr_latch_gated sr(Q,Cnn,DQ,DQn);
endmodule
module d_latch(Q,G,D);
output Q;
output Qn;
input G;
input D;
wire Dn;
wire D1;
wire Dn1;
not(Dn,D);
and(D1,D);
and(Dn1,Dn);
nor(Qn,D1,Q);
nor(Q,Dn1,Qn);
endmodule
module sr_latch_gated(Q,S,R);
output Q;
output Qn;
input G;
input S;
input R;
wire S1;
wire R1;
and(S1,S);
and(R1,R);
nor(Qn,S1,R1,Qn);
endmodule
好吧,如果我问发生了什么,我可以想像答案,我想知道为什么以及如何使它起作用!谢谢大家!
解决方法
环路:
引脚syncRX.jk0.dl.D
->引脚syncRX.jk0.dl.Q/Qn
->
引脚syncRX.jk0.sr.S/R
->引脚syncRX.jk0.sr.Q/Qn
->引脚syncRX.jk0.dl.D
如果您从标准库中实例化闩锁单元,则与时序路径和时序检查有关的问题将由该单元处理。
我当然认为每个知名的实现工具都会报告该循环。但是,既然您说Yosys没有抱怨,我也很困惑(我没有使用过Yosys。)