2007年07月13日

ModelSim TIPS 「Utilパッケージ(ファンクション使用例)」

今度は、ModelSim標準Utilパッケージのファンクション使用例を書いてみた。
ソースコードは次のようになる。


library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

library modelsim_lib;
use modelsim_lib.util.all;

library c;
use c.stdio_h.all;

entity mti_func_test is
end mti_func_test;


architecture behavior of mti_func_test is
begin

    process
        variable    resolution      : real;
        variable    alignment_time  : time;
        variable    current_time    : real;
        variable    wait_time       : real;
    begin
        -- シミュレーションレゾリューションの取得
        resolution := get_resolution;
        printf( "Resolution    = %f\n", resolution );

        -- 半端なウエイト
        wait for 12345678 fs;

        -- 半端なウエイトをアライメント
        wait_time := to_real(12345678 fs);
        -- 現シミュレーション時間の取得
        current_time := to_real(now);

        printf( "Current Time  = %f\n", current_time );
        printf( "Wait Time     = %f\n", wait_time );

        -- 半端なウエイトをアラインメント
        alignment_time := to_time(12345.678);
        wait for alignment_time;

        -- 現シミュレーション時間の取得
        current_time := to_real(now);

        printf( "Current Time  = %f\n", current_time );

        wait;
    end process;

end behavior;


これをModelSimでシミュレーションするとTranscriptウィンドウに次のように表示される。

シミュレーションレゾリューションが1nsの場合


# Resolution    = 1.000000e-009
# Current Time  = 1.200000e+001
# Wait Time     = 1.200000e+001
# Current Time  = 1.235800e+004

シミュレーションレゾリューションが1psの場合


# Resolution    = 1.000000e-012
# Current Time  = 1.234600e+004
# Wait Time     = 1.234600e+004
# Current Time  = 2.469200e+004

シミュレーションレゾリューションが1fsの場合


# Resolution    = 1.000000e-015
# Current Time  = 1.234568e+007
# Wait Time     = 1.234568e+007
# Current Time  = 1.235802e+007

2回目の「Current Time」は「alignment_time := to_time(12345.678);」の単位がシミュレーションレゾリューションによって変化するため、このような結果になる。

投稿時刻(12:38)│コメント(0)ModelSim 

この記事にコメントする

名前:
URL:
  情報を記憶: 評価: 顔   
 
 
 
最新コメント
カテゴリ別表示
月別表示