2017-03-02 99 views
0

请帮助了解一些模拟器行为与时间刻度连接。 这是我最模块: 问题与模拟计时

module top; 

//timeunit 1ns; 
//timeprecision 1ps; 

bit clk_62p5; // PCI write clock 

always 
    #8 clk_62p5++; 

DPSRAM_64X4096 u_MEM (
    .clka(clk_62p5), 
    …. 
); 

… 

endmodule 

`timescale 1 ns/1 ps 

module DPSRAM_64X4096 (…); 
… 
endmodule 

这是我的模拟脚本:

irun \ 
… 
    -timescale 1ns/1ps \ 
    … 

所以,当我运行仿真我看到clk_62p5时钟周期为16ps,而不是为16ns。 你能解释为什么我有这样的行为?

第2个问题,timeunit,timeprecision和timecale之间的区别是什么?

感谢 Hayk酒店

+0

要不回答您的第一个问题:我无法重现您的问题。这是[我的尝试](https://www.edaplayground.com/x/aP_)。请你可以发布[MCVE](http://stackoverflow.com/help/mcve)。不过,我注意到你已经写了'时间刻度1 ns/1 ps。这应该是'timescale 1ns/1ps。也许这是你的问题? –

+0

这些术语在免费的IEEE Std 1800-2012中有完整描述。 – toolic

+0

是的,我想你应该删除'时间刻度'中的空格并再次检查 –

回答

1

要回答你的第二个问题:

'的时间表是编译器指令。使用编译器指令可能导致编译顺序相关,这是不同的行为,或者由实际顺序编译你的文件引起的问题假设你有三个文件:

fileA.v `timescale 1ns/1ps 
fileB.v `timescale 10ns/10ps 
fileC.v // no timescale directive 

如果按此顺序

编译
fileA.v fileB.v fileC.v 

则精度会1PS - 最小发现编译 - 每个文件的TIMEUNIT将是:

fileA.v 1ns because of the `timescale directive 
fileB.v 10ns because of the `timescale directive 
fileC.v 10ns because the `timescale directive from fileB.v continues to have an effect 

如果在此为了

fileA.v fileC.v fileB.v 

则精度会1ps的编译 - 最小发现编译 - 的TIMEUNIT每个文件将是:

fileA.v 1ns because of the `timescale directive 
fileB.v 10ns because of the `timescale directive 
fileC.v 1ns because the `timescale directive from fileA.v continues to have an effect 

如果按此顺序编译

fileC.v fileA.v fileB.v 

然后你会得到一个错误,因为它没有timescale directive appearing before any file with a timescale指令是非法的。 (尽管如果没有文件具有`timescale指令),那就没问题了。

timeunittimeprecision是较新的System-Verilog实现相同的方法。由于它们不是编译器指令,它们不会遇到相关问题。它们只适用于它们用于的范围($ unit/package/module/program/interface)(并且必须在该范围内首先出现)。

如果您使用timeunittimeprecision以及timescale directive then时间单元and timeprecision`优先。