associative_array(連想配列)
associative_array(連想配列)の例題です。
連想配列は、インデックスに文字列を使う配列です。
連想配列は、クラスなのでつぎのような関数が使えます。
・ exists
・ first
・ prev
・ next
・ last
・ num
・ delete
添付ファイル(associative_array.sv)をModelSim AE 6.4a Starter Editionでシミュレーションした結果は、次のようになります。
# vsim -c assoc
# Loading sv_std.std
# Loading work.assoc
run -all
# map[ hello ] = 1
# map[ sad ] = 2
# map[ world ] = 3
# map.exists( world ) = 1
# map.exists( and ) = 0
# map.first = 1, hello
# map.prev = 0, hello
# map.next = 1, sad
# map.last = 1, world
# map.next = 0, world
# map.prev = 1, sad
# map.num = 3
# map.num = 2
# map.num = 2
# map.num = 0
quit