【发布时间】:2018-04-04 12:22:06
【问题描述】:
我正在尝试模拟 t-flipflop 的工作。
`timescale 1ns / 1ps
module t_flipflop(
input t,
input clk,
input clear,
output q,
output qbar
);
wire sbar, rbar;
assign sbar= ~(t & clk & qbar & clear);
assign rbar= ~(t & clk & q);
assign q= ~(sbar & qbar);
assign qbar= ~(rbar & q & clear);
endmodule
现在在输出中 q 的值在 t=1 时切换,但 qbar 的值始终为 1
同样当 t=1 时,q 始终为 0,qbar 为 1。
我做错了什么?
测试夹具 -
`timescale 1ns / 1ps
module test_t_flipflop;
// Inputs
reg t;
reg clk;
reg clear;
// Outputs
wire q;
wire qbar;
// Instantiate the Unit Under Test (UUT)
t_flipflop uut (
.t(t),
.clk(clk),
.clear(clear),
.q(q),
.qbar(qbar)
);
initial begin
clear=1'b0;
#34 clear=1'b1;
end
initial begin
t=1'b0;
clk=1'b0;
forever #15 clk=~clk;
end
initial begin
#10 t=1;
#95 t=0;
#40 t=1;
end
编辑:添加了完整的测试夹具代码。
我想用数据流模型来实现这个,理解清楚
【问题讨论】: