当前位置:网站首页>关于verilog的时延研究
关于verilog的时延研究
2022-07-30 09:49:00 【贱贱的剑】
时延赋值
疑问: 网页Verilog时延一章,有关assign #20 so_lose = ai & bi到底是先延时20个时间单位再采样还是先采样再时延20个时间单位。做了以下的实验
1、原代码
- time_delay_module模型
module time_delay_module(
input ai, bi,
output so_lose, so_get, so_normal);
assign #20 so_lose = ai & bi ;
assign #5 so_get = ai & bi ;
assign so_normal = ai & bi ;
endmodule
- testbench
`timescale 1ns/1ns
module test ;
reg ai, bi ;
wire so_lose, so_get, so_normal ;
initial begin
ai = 0 ;
#25 ; ai = 1 ;
#35 ; ai = 0 ; //60ns
#40 ; ai = 1 ; //100ns
#10 ; ai = 0 ; //110ns
end
initial begin
bi = 1 ;
#70 ; bi = 0 ;
#20 ; bi = 1 ;
end
time_delay_module u_wire_delay(
.ai (ai),
.bi (bi),
.so_lose (so_lose),
.so_get (so_get),
.so_normal (so_normal));
initial begin
forever begin
#100;
//$display("---gyc---%d", $time);
if ($time >= 1000) begin
$finish ;
end
end
end
endmodule
把这个的代码的波形加载后观看
由于延后时的ai和bi的电平值相同,因此无法判断是先采样后延时赋值还是先延时后采样赋值,因此需要对原代码进行修改。
2、修改
将test模型的第一个initial的时间稍做修改,其余的保持不变,结果如下,即把第一个25个时间单位的时延改成3
initial begin
ai = 0;
#3 ai = 1;
#35 ai = 0;
#40 ai = 1;
#10 ai = 0;
end
下载波形查看
由波形可以看出
- so_normal是没有时延的直接赋值,因此为ai&bi,结果为低电平。
- so_lose和so_get分别时延20和5个时间单位,但是刚开始的ai低平时钟只有3个单位,因此被忽略了,当ai到第3个时间单位时才重新计时。此时还是无法分清楚到底先采样后延时赋值还是先延时后采样赋值。
3.再修改
代码继续做如下改动,即将刚刚修改的3个延时的时间单位改成5
initial begin
ai = 0;
#5 ai = 1;
#35 ai = 0;
#40 ai = 1;
#10 ai = 0;
end
再拉取波形如下
- 这次
so_get在5个单位前后拥有不同的电平值,可以很清楚的看到:ai的第5个单位是高电平而开始是低电平,so_get第5个单位是低电平,因此是先执行ai&bi为低电平,然后时延5个单位再赋值给so_get - 因此结论正如原文中所说
先采样,后延时赋值.
边栏推荐
- Re17:读论文 Challenges for Information Extraction from Dialogue in Criminal Law
- nacos实战项目中的配置
- Flask's routing (app.route) detailed
- Matplotlib--plot markers
- 【HMS core】【FAQ】HMS Toolkit典型问题合集1
- Detailed explanation of JVM memory layout, class loading mechanism and garbage collection mechanism
- Baidu promotion assistant encounters duplicate keywords, verification errors, how to delete redundant ones with one click
- Meikle Studio - see the actual combat notes of Hongmeng equipment development five - drive subsystem development
- flowable工作流所有业务概念
- 系统设计精选 | 基于FPGA的CAN总线控制器的设计(附代码)
猜你喜欢

Alibaba Cloud OSS Object Storage

PyQt5-在窗口上绘制文本

Redis Desktop Manager 2022.4.2 released

Re20:读论文 What About the Precedent: An Information-Theoretic Analysis of Common Law

EViews 12.0软件安装包下载及安装教程

Baidu promotion assistant encounters duplicate keywords, verification errors, how to delete redundant ones with one click

Re17:读论文 Challenges for Information Extraction from Dialogue in Criminal Law

(C language) file operation

STM32CubeMX配置生成FreeRTOS项目

梅科尔工作室-看鸿蒙设备开发实战笔记五——驱动子系统开发
随机推荐
分页 paging
BERT预训练模型系列总结
Baidu promotion assistant encounters duplicate keywords, verification errors, how to delete redundant ones with one click
flowable workflow all business concepts
【HMS core】【FAQ】HMS Toolkit典型问题合集1
线上靶机prompt.ml
你真的懂Redis的5种基本数据结构吗?
shell脚本
唯物辩证法-条件论
shell script
BERT pre-training model series summary
SST-Calib: A lidar-visual extrinsic parameter calibration method combining semantics and VO for spatiotemporal synchronization calibration (ITSC 2022)
Re18:读论文 GCI Everything Has a Cause: Leveraging Causal Inference in Legal Text Analysis
105. Construct binary tree from preorder and inorder traversal sequence (video explanation!!)
[100 Solidity Skills] 1. Contract reentrancy attack
PyQt5-用像素点绘制正弦曲线
判断一颗树是否为完全二叉树——视频讲解!!!
Do you really understand the 5 basic data structures of Redis?
梅科尔工作室-看鸿蒙设备开发实战笔记四——内核开发
GNOME 新功能:安全启动被禁用时警告用户