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

Axi Back to Back example with good headers #2559

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
17 changes: 17 additions & 0 deletions lib/cv_dv_utils/python/sim_cmd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!---
// Copyright 2024 CEA
// SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
--->

# SIM CMD
MikeOpenHWGroup marked this conversation as resolved.
Show resolved Hide resolved
## Introduction
These are python scripts, they allow to compile and run a test.

# Usage
To compile a code in system verilog
python3 compile.py --yaml simulator_vcs.yaml --outdir out

To run a test
python3 run_test.py --yaml simulator_vcs.yaml --test_name bursty_test_c

The templates of yaml files are provided with the script, which can be used to compile and run the test
136 changes: 136 additions & 0 deletions lib/cv_dv_utils/python/sim_cmd/compile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
## ----------------------------------------------------------------------------
MikeOpenHWGroup marked this conversation as resolved.
Show resolved Hide resolved
##Copyright 2023 CEA*
##*Commissariat a l'Energie Atomique et aux Energies Alternatives (CEA)
##
##Licensed under the Apache License, Version 2.0 (the "License");
##you may not use this file except in compliance with the License.
##You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
##Unless required by applicable law or agreed to in writing, software
##distributed under the License is distributed on an "AS IS" BASIS,
##WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
##See the License for the specific language governing permissions and
##limitations under the License.
##[END OF HEADER]
## ----------------------------------------------------------------------------


import argparse
import os
import yaml

#import compile_cmd as cmp

parser = argparse.ArgumentParser(description='compile options')
parser.add_argument('--yaml' ,dest='yaml_file', type=str, help='Top YAML with compile and simulation options')
parser.add_argument('--outdir' ,dest='outdir', type=str, help='Logs are directed to outdir: default output')
args = parser.parse_args()


def get_cmd(yaml_file, outdir, opt, vopt_option, work):
with open(yaml_file, 'r') as yaml_top:
sim_yaml = yaml.safe_load(yaml_top)


for entry in sim_yaml:
if entry['tool'] == "questa":
cmd = "vlog -sv"
vopt_cmd = "vopt"
tool = "questa"
elif entry['tool'] == "vcs":
cmd = "vcs -sverilog"
vopt_cmd = ""
tool = "vcs"
if 'compile' in entry:
comp = entry['compile']
else:
comp = ""
########################
## get compile options ##
########################
if 'work_lib' in comp:
work_lib = comp['work_lib']
elif work != '':
work_lib = work
else:
work_lib = "work"
########################
## get SV log options ##
########################
if 'svlog_option' in comp:
opt += " "
opt += comp["svlog_option"]
else:
opt += " "
########################
## get SV log sources ##
## *.sv ##
########################
if 'svlog_source' in comp:
src_list = comp["svlog_source"]
srcs = src_list.split()
else:
src_list = ""
########################
## get file list ##
########################
if 'svlog_flist' in comp:
file_list = comp["svlog_flist"]
files = file_list.split()
else:
file_list = ""
files = ""
########################
## get vopt options ##
########################
if 'top_entity' in entry:
top_entity = comp['top_entity']
else:
top_entity = "top"
if 'vopt_option' in comp:
vopt_option += " "
vopt_option += comp['vopt_option']
else:
vopt_option += " "
########################
## run other YAML ####
########################
if 'yaml_lists' in comp:
yaml_list = comp["yaml_lists"]
yamls = yaml_list.split()
for y in yamls:
get_cmd(y, outdir, opt, vopt_option, work_lib)


file_cmd = ""
for f in files:
file_cmd += " -f " + f

if tool == "questa":
compile_cmd = "{} {} {} {} -work {} -l {}/{}.log".format(cmd, opt, file_cmd, src_list, work_lib, outdir, yaml_file)
vopt_cmd = "{} {} -work {} {} -o opt".format(vopt_cmd, vopt_option, work_lib, top_entity)
elif tool == "vcs":
compile_cmd = "{} {} {} {} -l {}/{}.log".format(cmd, opt, file_cmd, src_list, outdir, yaml_file)
vopt_cmd = ""

print(compile_cmd)
os.system(compile_cmd)
return vopt_cmd
## get_cmd

if args.outdir==None:
outdir = "output"
else:
outdir = args.outdir


if args.yaml_file == None:
print("Please provide a Top YAML file")
else:
if os.path.isdir("{}".format(outdir)) == False:
os.system("mkdir {}".format(outdir))
vopt_cmd = get_cmd(args.yaml_file, outdir, '', '', '')
if vopt_cmd != "":
os.system(vopt_cmd)
26 changes: 26 additions & 0 deletions lib/cv_dv_utils/python/sim_cmd/module1_template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## ----------------------------------------------------------------------------
##Copyright 2023 CEA*
##*Commissariat a l'Energie Atomique et aux Energies Alternatives (CEA)
##
##Licensed under the Apache License, Version 2.0 (the "License");
##you may not use this file except in compliance with the License.
##You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
##Unless required by applicable law or agreed to in writing, software
##distributed under the License is distributed on an "AS IS" BASIS,
##WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
##See the License for the specific language governing permissions and
##limitations under the License.
##[END OF HEADER]
## ----------------------------------------------------------------------------




- tool: questa
compile:
work_lib : "module1 lib name"
svlog_option: "local svlog options"
svlog_flist : "file lists (ex module1_pkg.Flist)"
24 changes: 24 additions & 0 deletions lib/cv_dv_utils/python/sim_cmd/module2_template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## ----------------------------------------------------------------------------
##Copyright 2023 CEA*
##*Commissariat a l'Energie Atomique et aux Energies Alternatives (CEA)
##
##Licensed under the Apache License, Version 2.0 (the "License");
##you may not use this file except in compliance with the License.
##You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
##Unless required by applicable law or agreed to in writing, software
##distributed under the License is distributed on an "AS IS" BASIS,
##WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
##See the License for the specific language governing permissions and
##limitations under the License.
##[END OF HEADER]
## ----------------------------------------------------------------------------


- tool: questa
compile:
work_lib : "module1 lib name"
svlog_option: "local svlog options"
svlog_flist : "file lists (ex module2_pkg.Flist)"
133 changes: 133 additions & 0 deletions lib/cv_dv_utils/python/sim_cmd/run_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
## ----------------------------------------------------------------------------
##Copyright 2023 CEA*
##*Commissariat a l'Energie Atomique et aux Energies Alternatives (CEA)
##
##Licensed under the Apache License, Version 2.0 (the "License");
##you may not use this file except in compliance with the License.
##You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
##Unless required by applicable law or agreed to in writing, software
##distributed under the License is distributed on an "AS IS" BASIS,
##WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
##See the License for the specific language governing permissions and
##limitations under the License.
##[END OF HEADER]
## ----------------------------------------------------------------------------



import argparse
import os
import yaml

parser = argparse.ArgumentParser(description='compile and simulation options')
parser.add_argument('--yaml' ,dest='yaml_file', type=str, help='Top YAML with compile and simulation options')
parser.add_argument('--test_name',dest='test_name', type=str, help='Name of the test, default: test_hpdcache_multiple_random_requests')
parser.add_argument('--seed' , dest='seed', type=int, help='random seed ex: 3452363, default 1')
parser.add_argument('--debug' , dest='debug', type=str, help='UVM_LOW/MEDIUM/HIGH/FULL/DEBUG, default LOW')
parser.add_argument('--batch' , dest='batch', type=int, help='1: batch mode, 0:gui default, 1')
parser.add_argument('--stdout' , dest='stdout', type=int, help='1: stdout 0: nostdout')
parser.add_argument('--outdir' , dest='outdir', type=str, help='output dirctory de fault "output"')
##
args = parser.parse_args()

def run_test(cmd, test_name, seed, debug, batch, stdout, outdir, work_lib, opt, tool):
## get arguments
if outdir == None:
outdir = "output"


if seed == None:
seed = 1

if debug == None:
debug = "UVM_LOW"

if batch == None:
batch = 1

if batch == 1:
if tool == "questa":
batchstr = "-c"
else:
batchstr = ""
else:
if tool == "vcs":
batchstr = "-gui"
else:
batchstr = ""

if stdout == None:
stdout = 1

if stdout == 0:
stdoutstr = ">"
else:
stdoutstr = "-l"

if os.path.isdir("{}".format(outdir)) == False:
os.system("mkdir {}".format(outdir))

if test_name == None:
print("ERROR: Please provide a valid test name")
else:
if tool == "questa":
run_cmd = "{} {} -sv_seed {} +UVM_VERBOSITY={} -wlf {}/{}_{}.wlf +UVM_TESTNAME={} {} -lib {} opt {} {}/{}_{}.log".format(cmd, batchstr, seed, debug, outdir, test_name, seed, test_name, opt, work_lib, stdoutstr, outdir, test_name, seed )
elif tool == "vcs":
run_cmd = "{} {} +ntb_random_seed={} +UVM_VERBOSITY={} -grw {}/{}_{}.wlf +UVM_TESTNAME={} {} {}/{}_{}.log".format(cmd, batchstr, seed, debug, outdir, test_name, seed, test_name, stdoutstr, outdir, test_name, seed )

print(run_cmd)
os.system("{}".format(run_cmd))

def get_cmd(yaml_file, opt):
with open(yaml_file, 'r') as yaml_top:
sim_yaml = yaml.safe_load(yaml_top)


for entry in sim_yaml:
if entry['tool'] == "questa":
cmd = "vsim"
tool = "questa"
if 'sim' in entry:
sim = entry['sim']
else:
sim = ""
elif entry['tool'] == "vcs":
cmd = "./simv"
tool = "vcs"
if 'sim' in entry:
sim = entry['sim']
else:
sim = ""
########################
## get compile options ##
########################
if tool == "questa":
if 'work_lib' in sim:
work_lib = sim['work_lib']
elif work != '':
work_lib = work
else:
work_lib = "work"
else:
work_lib = ""
########################
## get SV log options ##
########################
if 'sim_option' in sim:
opt += " "
opt += sim["sim_option"]
else:
opt += " "
return cmd, work_lib, opt, tool

if args.yaml_file == None:
print("Please provide a Top YAML file")
else:
cmd, work_lib, opt, tool = get_cmd(args.yaml_file, '')
run_test(cmd, args.test_name, args.seed, args.debug, args.batch, args.stdout, args.outdir, work_lib, opt, tool )



30 changes: 30 additions & 0 deletions lib/cv_dv_utils/python/sim_cmd/top_questa_template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## ----------------------------------------------------------------------------
##Copyright 2023 CEA*
##*Commissariat a l'Energie Atomique et aux Energies Alternatives (CEA)
##
##Licensed under the Apache License, Version 2.0 (the "License");
##you may not use this file except in compliance with the License.
##You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
##Unless required by applicable law or agreed to in writing, software
##distributed under the License is distributed on an "AS IS" BASIS,
##WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
##See the License for the specific language governing permissions and
##limitations under the License.
##[END OF HEADER]
## ----------------------------------------------------------------------------


- tool: questa
compile:
work_lib : "<name>"
svlog_option: "<vlog options to propgate>"
svlog_source: "list of sv sources (ex module.sv top.sv)"
yaml_lists : "list of yaml of other modules (ex module1_template.yaml, module2_template.yaml"
vopt_option : "<vopt options>"
top_entity : "<top>"
sim:
work_lib : "<name>"
sim_option : "sim options"
26 changes: 26 additions & 0 deletions lib/cv_dv_utils/python/sim_cmd/top_vcs_template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## ----------------------------------------------------------------------------
##Copyright 2023 CEA*
##*Commissariat a l'Energie Atomique et aux Energies Alternatives (CEA)
##
##Licensed under the Apache License, Version 2.0 (the "License");
##you may not use this file except in compliance with the License.
##You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
##Unless required by applicable law or agreed to in writing, software
##distributed under the License is distributed on an "AS IS" BASIS,
##WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
##See the License for the specific language governing permissions and
##limitations under the License.
##[END OF HEADER]
## ----------------------------------------------------------------------------

- tool: vcs
compile:
svlog_option: "<svlog options>"
svlog_option: "<vlog options to propgate>"
svlog_flist : "file list (example $MODULE/module_pkg.Flit)"
top_entity : "<name>"
sim:
sim_option : "sim option"
Loading