【问题标题】:Master-slave J-K flip-flop has no output主从J-K触发器无输出
【发布时间】:2021-04-02 18:39:36
【问题描述】:

我已经编写了主从 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("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

Design.sv

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_Latched 触发器模块

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

我已经在 EDA-playground 中编写了整个代码。

生成的图表也很突然。 如果还有其他可以轻松实现的逻辑,请告诉。

【问题讨论】:

    标签: verilog xilinx


    【解决方案1】:

    我在 2 个不同的模拟器上遇到编译错误。您不应在 jk_flip_flop_master_slave 模块中将 qq_bar 声明为 reg。你应该删除这一行:

    reg q,q_bar; // Active low reset signal.
    

    然后它为我编译和模拟。我看到了这个输出:

    100xx1
    110xx0
    010010
    110010
    010010
    110010
    101010
    001010
    101010
    001010
    ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多