バッチ モードでの Force コマンドの使用 - 2023.2 日本語

Vivado Design Suite ユーザー ガイド: ロジック シミュレーション (UG900)

Document ID
UG900
Release Date
2023-10-18
Version
2023.2 日本語

次のコード例に、add_force コマンドを使用して信号を指定の値に強制する方法を示します。簡単な Verilog 回路が提供されています。最初の例は、add_force コマンドをインタラクティブに使用する例を、2 番目はスクリプトを使用した例を示しています。

例 1: force の追加

次のコード例は Verilog 回路です。

module bot(input in1, in2,output out1);
reg sel;
assign out1 = sel? in1: in2;
endmodule
module top;
reg in1, in2;
wire out1;
bot I1(in1, in2, out1);
initial
begin
    #10 in1 = 1'b1; in2 = 1'b0;
    #10 in1 = 1'b0; in2 = 1'b1;
end
initial
    $monitor("out1 = %b\n", out1);
endmodule

add_force の効果を観察するには、次のコマンドを入力します。

xelab -vlog tmp.v -debug all
xsim work.top

コマンド プロンプトに次を入力します。

add_force /top/I1/sel 1
run 10
add_force /top/I1/sel 0
run all

add_force コマンドを使用すると、信号、ワイヤ、またはレジスタを指定値に設定できます。

add_force [-radix <arg>] [-repeat_every <arg>] [-cancel_after <arg>] [-quiet] 
[-verbose] <hdl_object> <values>...

この Tcl コマンドおよびその他の Tcl コマンドの詳細は、 『Vivado Design Suite Tcl コマンド リファレンス ガイド』 (UG835) を参照してください。

例 2: スクリプトでの add_force と remove_forces の使用

次は、カウンターをインスタンシエートする Verilog ファイル top.v の例です。このファイルは、次のコマンド例で使用できます。

module counter(input clk,reset,updown,output [4:0] out1);
reg [4:0] r1;
always@(posedge clk)
begin
    if(reset)
        r1 <= 0;
    else
        if(updown)
            r1 <= r1 + 1;
        else
            r1 <= r1 - 1;
end
assign out1 = r1;
endmodule
module top;
reg clk;
reg reset;
reg updown;
wire [4:0] out1;
counter I1(clk, reset, updown, out1);
initial
begin
    reset = 1;
    #20 reset = 0;
end
initial
begin
    updown = 1; clk = 0;
end
initial
    #500 $finish;
initial
    $monitor("out1 = %b\n", out1);
endmodule

コマンド例

  1. 次のコマンドを含む add_force.tcl というファイルを作成します。
    create_project add_force -force
    add_files top.v
    set_property top top [get_filesets sim_1]
    set_property -name xelab.more_options -value {-debug all} -objects [get_filesets 
    sim_1]
    set_property runtime {0} [get_filesets sim_1]
    launch_simulation -simset sim_1 -mode behavioral
    add_wave /top/*
  2. Vivado Design Suite を Tcl モードで起動して、add_force.tcl ファイルを読み込みます。
  3. [Tcl Console] ウィンドウに次を入力します。
    set force1 [add_force clk {0 1} {1 2} -repeat_every 3 -cancel_after 500]
    set force2 [add_force updown {0 10} {1 20} -repeat_every 30]
    run 100

    out1 の値の増減を波形ウィンドウで確認します。start_gui コマンドを使用して、Vivado IDE で波形を確認します。

    updown 信号の値を波形ウィンドウで確認します。

  4. [Tcl Console] ウィンドウに次を入力します。
    remove_forces $force2
    run 100

    out1 の値だけが増加したことを確認します。

  5. [Tcl Console] ウィンドウに次を入力します。
    remove_forces $force1
    run 100

    out1 信号はトグルしないので、clk の値が変化していないことを確認します。