2017-03-02 48 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`優先。