当前位置:网站首页>【Verilog】HDLBits题解——Verification: Writing Testbenches
【Verilog】HDLBits题解——Verification: Writing Testbenches
2022-08-03 12:03:00 【wjh776a68】
Clock
module top_module ( );
reg clk;
initial begin
clk = 0;
forever #5 clk = ~clk;
end
dut dut_inst(.clk(clk)) ;
endmodule
Testbench1
module top_module ( output reg A, output reg B );//
// generate input patterns here
initial begin
A = 0;
B = 0;
#10
A = 1;
#5
B = 1;
#5
A = 0;
#20
B = 0;
end
endmodule
AND gate
module top_module();
reg [1:0] in;
wire out;
initial begin
in = 'b0;
#10;
in = 'b01;
#10;
in = 'b10;
#10;
in = 'b11;
#10;
//$finish;
end
andgate andgate_inst (
.in(in),
.out(out)
);
endmodule
Testbench2
module top_module();
reg clk;
reg in;
reg [2:0] s;
reg [5:0] STAT;
wire out;
initial begin
STAT = 0;
clk = 0;
in = 0;
s = 'h2;
forever #5 clk = ~clk;
end
always @ (negedge clk) begin
case (STAT)
0: begin
s <= 'h6;
end
1: begin
s <= 'h2;
in <= 1;
end
2: begin
s <= 'h7;
in <= 0;
end
3: begin
s <= 'h0;
in <= 1;
end
6: begin
s <= 'h0;
in <= 0;
end
default: begin
end
endcase
if (STAT < 6) begin
STAT <= STAT + 1;
end
end
q7 q7_inst(
.clk(clk),
.in(in),
.s(s),
.out(out)
);
endmodule
T flip-flop
module top_module ();
reg clk, reset, t;
reg [5:0] STAT;
wire q;
initial begin
clk = 0;
reset = 0;
t = 0;
STAT = 0;
forever #1 clk = ~clk;
end
always @ (posedge clk) begin
case (STAT)
0: begin
reset <= 1;
STAT <= 1;
end
1: begin
reset <= 0;
t <= 1;
STAT <= 2;
end
2: begin
t <= 0;
end
endcase
end
tff tff_inst(
.clk(clk),
.reset(reset), // active-high synchronous reset
.t(t), // toggle
.q(q)
);
endmodule
边栏推荐
猜你喜欢

项目概述、推送和存储平台准备

【MySQL功法】第5话 · SQL单表查询

利用ChangeStream实现Amazon DocumentDB表级别容灾复制

肝完Alibaba这份面试通关宝典,我成功拿下今年第15个Offer

第四周学习 HybridSN,MobileNet V1,V2,V3,SENet

How to do App Automation Testing?Practical sharing of the whole process of App automation testing

Go 语言快速入门指南: 介绍及安装

Knowledge Graph Question Answering System Based on League of Legends

mysql进阶(二十四)防御SQL注入的方法总结

字节最爱问的智力题,你会几道?
随机推荐
c语言进阶篇:内存函数
面试突击71:GET 和 POST 有什么区别?
深度学习中数据到底要不要归一化?实测数据来说明!
数据库系统原理与应用教程(076)—— MySQL 练习题:操作题 160-167(二十):综合练习
【一起学Rust】Rust学习前准备——注释和格式化输出
bash while循环和until循环
App自动化测试怎么做?实战分享App自动化测试全流程
学习软件测试需要掌握哪些知识点呢?
fastposter v2.9.0 程序员必备海报生成器
opencv学习—VideoCapture 类基础知识「建议收藏」
flink流批一体有啥条件,数据源是从mysql批量分片读取,为啥设置成批量模式就不行
LeetCode 899 Ordered queue [lexicographical order] HERODING's LeetCode road
从零开始Blazor Server(6)--基于策略的权限验证
流式编程使用场景
第四周学习 HybridSN,MobileNet V1,V2,V3,SENet
pandas连接oracle数据库并拉取表中数据到dataframe中、生成当前时间的时间戳数据、格式化为指定的格式(“%Y-%m-%d-%H-%M-%S“)并添加到csv文件名称中
3年软件测试经验,不懂自动化基础...不知道我这种测试人员是不是要被淘汰了?
为什么越来越多的开发者放弃使用Postman,而选择Eolink?
广州番禺:暑期防溺水,安全不放假
R语言拟合ARIMA模型并使用拟合模型进行预测推理、使用autoplot函数可视化ARIMA模型预测结果、可视化包含置信区间的预测结果