1,$time

The $time system function returns an integer that is a 64-bit time, scaled to the timescale unit of the module that invoked it.

 1 `timescale 10 ns / 1 ns
2 module test;
3 reg set;
4 parameter p = 1.55;
5 initial begin
6 $monitor($time,,"set=",set);
7 #p set = 0;
8 #p set = 1;
9 end
10 endmodule

结果:

                   0 set=x
2 set=0
3 set=1
V C S S i m u l a t i o n R e p o r t
Time: 32 ns

分析:

a) The simulation times 16 ns and 32 ns are scaled to 1.6 and 3.2 because the time unit for the module is 10 ns; therefore, time values reported by this module are multiples of 10 ns.
b) The value 1.6 is rounded to 2, and 3.2 is rounded to 3 because the $time system function returns an integer. The time precision does not cause rounding of these values

因为精度是1ns,1.55*10=15.5ns,四舍五入,取16ns

假如将精度设置为

`timescale 10 ns / 1ps  那么,结果将是15.5和31

2,$stime

The $stime system function returns an unsigned integer that is a 32-bit time, scaled to the timescale unit of the module that invoked it. If the actual simulation time does not fit in 32 bits, the low order 32 bits of the current simulation time are returned.

对于$time的example,$stime和$time是一样的。

3,$realtime

The $realtime system function returns a real number time that, like $time, is scaled to the time unit of the module that invoked it.

将上述example改为$realtime之后,结果如下所示:

0 set=x
1.6 set=0
3.2 set=1
V C S S i m u l a t i o n R e p o r t
Time: 32 ns

其他运行结果相同

随机推荐

  1. 《挑战程序设计竞赛》——DFS

    DFS(深度优先搜索) 简介 深度优先搜索(DFS,Depth-First Search)是搜索的手段之一.它从某个状态开始,不断的转移状态直到无法转移.然后退回到前一步的状态,继续转移到其他状态,如 ...

  2. python中字典按键、值进行排序

    看到排序,就不禁想起python中的sort和sorted sort是列表中的方法,用于对列表进行排序(改变的是原列表,不返回新列表) 用法: list.sort(key=None,reverse=T ...

  3. 【简单数据结构】并查集--洛谷 P1111

    题目背景 AA地区在地震过后,连接所有村庄的公路都造成了损坏而无法通车.政府派人修复这些公路. 题目描述 给出A地区的村庄数NN,和公路数MM,公路是双向的.并告诉你每条公路的连着哪两个村庄,并告诉你 ...

  4. Shell系列(21)- 字符截取命令printf

    作用 printf是标准格式输出命令,控制输出格式,不会自动加入换行符.awk会用到该条命令 命令 printf '输出类型输出格式' 输出内容 #''双引号不能少,输出类型和输出格式之间没有空格 输 ...

  5. ci框架 查询构造器类

    $this->db->get() 该方法执行 SELECT 语句并返回查询结果,可以得到一个表的所有数据: $query = $this->db->get('mytable') ...

  6. 判断javaScript变量是Ojbect类型还是Array类型

      JavaScript是弱类型的语言,所以对变量的类型并没有强制控制类型.所以声明的变量可能会成为其他类型的变量, 所以在使用中经常会去判断变量的实际类型. 对于一般的变量我们会使用typeof来判 ...

  7. P5012-水の数列【并查集,RMQ】

    正题 题目链接:https://www.luogu.com.cn/problem/P5012 题目大意 \(n\)个数字的一个序列,\(T\)次询问给出\([l,r]\)要求 找出一个最大的\(x\) ...

  8. 测试用例 setup 和 和 teardown

    前言 学过unittest的都知道里面用前置和后置setup呾teardown非常好用,在每次用例开始前呾结束后都去执行一次.当然迓有更高级一点的 setupClass 呾 teardownClass ...

  9. isnull与ifnull适用数据库

    根据业务流程去查询某个数据表的某个字段的最大值: 直接用的select max(code) from base_area; 大多数情况没有问题,有个特殊点:如果数据表里边没有数据,且返回类型时int时 ...

  10. Kubernetes-Service介绍(一)-基本概念

    前言 本篇是Kubernetes第八篇,大家一定要把环境搭建起来,看是解决不了问题的,必须实战.Pod篇暂时应该还缺少两篇,等Service和存储相关内容介绍以后,补充剩下的两篇,有状态的Pod会涉及 ...