赞
踩
添加文件;
选择第二项;add or create design sources;
设计代码jk_ff.v:
module jk_ff ( input j,
input k,
input clk,
output q);
reg q;
always @ (posedge clk)
case ({j,k})
2'b00 : q <= q;
2'b01 : q <= 0;
2'b10 : q <= 1;
2'b11 : q <= ~q;
endcase
endmodule
将仿真文件设置为顶层模块,编写顶层模块,运行仿真:
仿真代码tb_jk.v:
module tb_jk; reg j; reg k; reg clk; always #5 clk = ~clk; jk_ff jk0 ( .j(j), .k(k), .clk(clk), .q(q)); initial begin j <= 0; k <= 0; #5 j <= 0; k <= 1; #20 j <= 1; k <= 0; #20 j <= 1; k <= 1; #20 $finish; end initial $monitor ("j=%0d k=%0d q=%0d", j, k, q); endmodule
输出:
打开硬件原理图:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。