Verilog 主从J-K触发器没有输出
我已经为主从式JK触发器编写了测试台代码和设计代码,但是没有输出。 请指出错误 试验台.svVerilog 主从J-K触发器没有输出,verilog,xilinx,edaplayground,Verilog,Xilinx,Edaplayground,我已经为主从式JK触发器编写了测试台代码和设计代码,但是没有输出。 请指出错误 试验台.sv module JK_ff_tb; reg clk; reg reset; reg j,k; wire q; wire qb; jk_flip_flop_master_slave jkflipflop( .clk(clk), .reset(reset), .j(j), .k(k), .q(q), .q_bar(qb) ); initial begin $dumpfile("d
module JK_ff_tb;
reg clk;
reg reset;
reg j,k;
wire q;
wire qb;
jk_flip_flop_master_slave jkflipflop( .clk(clk), .reset(reset), .j(j), .k(k), .q(q), .q_bar(qb) );
initial begin
$dumpfile("dump.vcd"); $dumpvars;
$monitor(clk,j,k,q,qb,reset);
j = 1'b0;
k = 1'b0;
reset = 1;
clk=1;
#10
reset=0;
j=1'b1;
k=1'b0;
#100
reset=0;
j=1'b0;
k=1'b1;
#100
reset=0;
j=1'b1;
k=1'b1;
#100
reset=0;
j=1'b0;
k=1'b0;
#100
reset=1;
j=1'b1;
k=1'b0;
end
always #25 clk <= ~clk;
endmodule
// Code your design here
module jk_flip_flop_master_slave(j,k,clk,reset,q,q_bar);
input j,k,clk,reset;
output q,q_bar;
reg q,q_bar; // Active low reset signal.
wire MQ; // The master's Q output.
wire MQn; // The master's Qn output.
wire Cn; // The clock input to the slave shall be the complement of the master's.
wire J1;
wire K1;
wire J2; // The actual input to the first SR latch (S).
wire K2; // The actual input to the first SR latch (R).
assign J2 = !reset ? 0 : J1; // Upon reset force J2 = 0
assign K2 = !reset ? 1 : K1; // Upon reset force K2 = 1
and(J1, j, q_bar);
and(K1, k, q);
not(Cn, clk);
sr_latch_gated master(MQ, MQn, clk, J2, K2);
sr_latch_gated slave(q, q_bar, Cn, MQ, MQn);
endmodule // jk_flip_flop_master_slave
Sr_锁存触发器模块
module sr_latch_gated(Q, Qn, G, S, R);
output Q;
output Qn;
input G;
input S;
input R;
wire S1;
wire R1;
and(S1, G, S);
and(R1, G, R);
nor(Qn, S1, Q);
nor(Q, R1, Qn);
endmodule // sr_latch_gated
我在操场上把整件事都编好了
生成的图表也非常突然。
如果有另一种逻辑可以很容易地实现,请告诉我。我在两个不同的模拟器上遇到编译错误。您不应在
jk\u触发器\u主从
模块中将q
和q\u条
声明为reg
。您应该删除此行:
reg q,q_bar; // Active low reset signal.
然后它为我编译和模拟。我看到这个输出:
100xx1
110xx0
010010
110010
010010
110010
101010
001010
101010
001010
...