Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CTG] Add new cli param '--filter' #571

Merged
merged 2 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions riscv-ctg/riscv_ctg/ctg.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def gen_test(op_node, opcode):
logger.info('Writing tests for csr_comb')
csr_comb_gen.write_test(fprefix, node, usage_str, label, csr_comb_instr_dict)

def ctg(verbose, out, random ,xlen_arg,flen_arg, cgf_file,num_procs,base_isa, max_inst,inxFlag):
def ctg(verbose, out, random ,xlen_arg,flen_arg, cgf_file,num_procs,base_isa, max_inst,inxFlag,filter):
logger.level(verbose)
logger.info('****** RISC-V Compliance Test Generator {0} *******'.format(__version__ ))
logger.info('Copyright (c) 2020, InCore Semiconductors Pvt. Ltd.')
Expand Down Expand Up @@ -134,6 +134,12 @@ def ctg(verbose, out, random ,xlen_arg,flen_arg, cgf_file,num_procs,base_isa, ma
op_template = utils.load_yaml(const.template_files)
cgf = expand_cgf(cgf_file,xlen,flen)
pool = mp.Pool(num_procs)
results = pool.starmap(create_test, [(usage_str, node,label,base_isa,max_inst, op_template,
randomize, out_dir, xlen, flen, inxFlag) for label,node in cgf.items()])

args_list = []
for label,node in cgf.items():
if filter is not None and re.search(filter, label) is None:
continue
args_list.append((usage_str, node,label,base_isa,max_inst, op_template,
randomize, out_dir, xlen, flen, inxFlag))
results = pool.starmap(create_test, args_list)
pool.close()
5 changes: 3 additions & 2 deletions riscv-ctg/riscv_ctg/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
hardware.",default='32')
@click.option("--inst",type=int,help="Maximum number of Macro Instances per test.")
@click.option("--z-inx", '-ix', type=bool, default='False', help="If the extension is Z*inx then pass True otherwise defaulted to False")
def cli(verbose, out_dir, randomize , cgf,procs,base_isa, flen,inst,z_inx):
@click.option("--filter", type=str, help="Filtering tests to be generated with regex")
def cli(verbose, out_dir, randomize , cgf,procs,base_isa, flen,inst,z_inx,filter):
if not os.path.exists(out_dir):
os.mkdir(out_dir)
if '32' in base_isa:
xlen = 32
elif '64' in base_isa:
xlen = 64
ctg(verbose, out_dir, randomize ,xlen, int(flen), cgf,procs,base_isa,inst,z_inx)
ctg(verbose, out_dir, randomize ,xlen, int(flen), cgf,procs,base_isa,inst,z_inx,filter)