2017-05-11 10 views
0

以下は私が現在使用しているプロパティです。+/-許容誤差%を持つクロックの周波数をチェックする最良の方法は何ですか?

property freq_chk (time clk_period , bit disable_chk=0); 
    time current_time; 
    disable iff (disable_chk) 
    ('1, current_time = $time) |=> 
    ((($time - current_time) >= (clk_period-1)) && 
    (($time - current_time) <= (clk_period+1))); 
endproperty : freq_chk 

ここで、クロック周期の許容範囲を+/- 1と考えます。 許容範囲のパーセンテージを渡し、それに応じて頻度をチェックする最良の方法は何でしょうか。

私はそのクロックの周波数をチェックするための最良の方法だろう何

property freq_chk_with_tol (time clk_period , bit disable_chk=0, int tolerance=0); 
    time current_time; 
    disable iff (disable_chk) 
    ('1, current_time = $time) |=> 
    ((($time - current_time) >= ((clk_period * (1 - (tolerance/100))) - 1)) && 
    (($time - current_time) <= ((clk_period * (1 + (tolerance/100))) + 1))); 
endproperty : freq_chk_with_tol 

(これはちょうど私が探しています何のデモンストレーションのために、動作しません。)以下のような何かを探しています

+/-トレランス%ですか?

+2

タイプミスのタイトルを確認したい場合があります。 –

+3

はい、それはコックです。 – Bathsheba

+0

ありがとうございます。修正されました:) –

答えて

0

Gregが示唆しているように、整数値を実数に変更すると、私のトリックになりました。

以下は作業コードです。

property freq_chk_tol (time clk_period , bit disable_chk=0, real tolerance=0.00); 
    time current_time; 
    disable iff (disable_chk) 
    ('1, current_time = $time) |=> 
    ((($time - current_time) >= ((clk_period * (1 - (tolerance/100.00))) - 1)) && 
    (($time - current_time) <= ((clk_period * (1 + (tolerance/100.00))) + 1))); 
endproperty : freq_chk_tol 
0

なぜアサーションを使用するのですか?行動コードを使用する方が簡単でしょうか?

time clk_margin = <set it to whatever value you need>; // calculate it once, don't calculate on the fly 
time last_clk_tick; 
always_ff @(posedge clk) begin 
    assert (abs($time - last_clk_tick) < clk_margin); // abs() is a user function return the absolute value 
    last_clk_tick = $time; 
end 
+0

個人的に私は、プロパティアサーションメソッドを使用すると、複数のクロックに対して同じコードを再利用することが容易になり、機能的なカバレッジトラッキングが容易になりました。 –

関連する問題