gen_xaction.py
# -*- coding: UTF-8 -*-
import string
xaction_file_template = open("./transaction.sv", "r")
xaction_txt = xaction_file_template.read()
item = string.Template(xaction_txt)
l2f_item_file_str = item.substitute(xaction="l2f_item")
l2f_item_file = open("./l2f_item.sv", "w")
l2f_item_file.write(l2f_item_file_str)
xaction_file_template.close()
l2f_item_file.close()
transaction.txt 模板文件
class $xaction extends uvm_sequence_item;
typedef $xaction this_type;
`uvm_object_param_utils_begin(this_type)
`uvm_object_utils_end
function new(string name = "$xaction");
super.new(name);
endfunction
endclass