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

[xcelium] updated xcelium flow to a working state #273

Open
wants to merge 2 commits into
base: main
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions doc/edam/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,8 @@ xcelium
================ ===================== ===========
Field Name Type Description
================ ===================== ===========
xmvlog_options List of String Extra options for compilation with `xmvlog`
xmvhdl_options List of String Extra options for compilation with `xmvhdl`
xmsim_options List of String Extra options for running simulation with with `xsim`
xrun_options List of String Extra options for invocation with with `xrun`
elab_options List of String Compilation options for invocation with `xrun -elaborate`
run_options List of String Extra options for invocation with with `xrun -R`
================ ===================== ===========

xsim
Expand Down
101 changes: 49 additions & 52 deletions edalize/xcelium.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import os
import logging
import sys

from edalize.edatool import Edatool

Expand All @@ -16,35 +17,29 @@

XCELIUM_HOME = $(shell xmroot)

CC ?= gcc
CFLAGS := -c -std=c99 -fPIC -fno-stack-protector -g

LD ?= ld
LDFLAGS := -shared -E

#Only 32 bits is currently supported
CFLAGS += -m32
LDFLAGS += -melf_i386

RM ?= rm
INCS := -I$(XCELIUM_HOME)/tools/include

XRUN ?= $(XCELIUM_HOME)/tools/bin/xrun
XRUN_PREFIX ?= {xrun_prefix}

TOPLEVEL := {toplevel}
VPI_MODULES := {modules}
PARAMETERS ?= {parameters}
PLUSARGS ?= {plusargs}
XMSIM_OPTIONS ?= {xmsim_options}
XRUN_OPTIONS ?= {xrun_options}
EXTRA_OPTIONS ?= $(XRUN_OPTIONS) $(if $(XMSIM_OPTIONS),-xmsimargs '$(XMSIM_OPTIONS)',) $(addprefix -defparam ,$(PARAMETERS)) $(addprefix +,$(PLUSARGS))
BUILD_OPTIONS ?= {elab_options}
XRUN_OPTIONS ?= {run_options}

XRUN_CALL = $(XRUN) -q -f edalize_main.f $(addprefix -pli ,$(VPI_MODULES)) $(EXTRA_OPTIONS) -top $(TOPLEVEL)

all: $(VPI_MODULES)

run: $(VPI_MODULES)
$(XRUN_CALL)
build:
$(XRUN_PREFIX) xrun -elaborate $(BUILD_OPTIONS) -top $(TOPLEVEL) -f edalize_main.f
run_nc:
$(XRUN_PREFIX) xrun -R -access rw $(XRUN_OPTIONS)

run: $(VPI_MODULES) build run_nc


run-gui: $(VPI_MODULES)
$(XRUN_CALL) -gui -access rwc
Expand Down Expand Up @@ -76,55 +71,55 @@ def get_doc(cls, api_ver):
if api_ver == 0:
return {'description' : "Xcelium simulator from Cadence Design Systems",
'lists' : [
{'name' : 'xmvhdl_options',
{'name' : 'elab_options',
'type' : 'String',
'desc' : 'Additional options for compilation with xmvhdl'},
{'name' : 'xmvlog_options',
'desc' : 'Additional run options for xrun -elaboration'},
{'name' : 'xrun_prefix',
'type' : 'String',
'desc' : 'Additional options for compilation with xmvlog'},
{'name' : 'xmsim_options',
'desc' : 'prefix for using submission servers like bjob or nc'},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop this and use the EDALIZE_LAUNCHER environment variable instead. There is an upcoming refactoring that, among other things, will standardize this for all the backend flows

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will look into it

{'name' : 'run_options',
'type' : 'String',
'desc' : 'Additional run options for xmsim'},
{'name' : 'xrun_options',
'type' : 'String',
'desc' : 'Additional run options for xrun'},
'desc' : 'Additional run options for xrun -R'},
]}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new options look cleaner, but I'm worried about current users of the xcelium backend because removing the old options will break things for them. Or do you mean that the xcelium backend didn't work at all before? In that case I guess there is less risk anyone will complain

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unless someone would use the generated make as standalone without the generated file list - the previous backend did not work.
so I think it is safe to assume that no one used it.


def _write_build_rtl_f_file(self, tcl_main):
tcl_build_rtl = open(os.path.join(self.work_root, "edalize_build_rtl.f"), 'w')
tcl_build_c = open(os.path.join(self.work_root, "edalize_build_c.f"), 'w')

(src_files, incdirs) = self._get_fileset_files()
vlog_include_dirs = ['+incdir+'+d.replace('\\','/') for d in incdirs]

libs = []

print("\n DEFINES::", file=sys.stderr)
print(self.vlogdefine, file=sys.stderr)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the logger instead of printing to be inline with other backends

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank I will do that.


# add defines to file of files
args = []
for k, v in self.vlogdefine.items():
args += ['+define+{}={}'.format(k,self._param_value_str(v))]

# add inc dirs
args += vlog_include_dirs
line = "{}".format('\n'.join(args))
tcl_build_rtl.write(line + '\n')

# add rtl/c files
for f in src_files:
args = []
if not f.logical_name:
f.logical_name = 'worklib'
if f.file_type.startswith("verilogSource") or \
f.file_type.startswith("systemVerilogSource"):
cmd = 'xmvlog'
args = []

args += self.tool_options.get('xmvlog_options', [])

# Sort dictionary items, to ensure stable output, which makes testing easier
for k, v in self.vlogdefine.items():
args += ['+define+{}={}'.format(k,self._param_value_str(v))]

if f.file_type.startswith("systemVerilogSource"):
args += ['-sv']
args += vlog_include_dirs
cmd = 'elab_opts'
#place holder for any verilog specific per file option
elif f.file_type.startswith("vhdlSource"):
cmd = 'xmvhdl'
if f.file_type.endswith("-93"):
args = ['-v93']
if f.file_type.endswith("-2008"):
args = ['-v200x']
else:
args = []

args += self.tool_options.get('xmvhdl_options', [])

elif f.file_type == 'cSource':
cmd = None
# C files get their own files of files
#lets the user choose between build in or extern c compiler
tcl_build_c.write("{}\n".format(f.name))
elif f.file_type == 'tclSource':
cmd = None
tcl_main.write("-input {}\n".format(f.name))
Expand All @@ -136,7 +131,7 @@ def _write_build_rtl_f_file(self, tcl_main):
cmd = None
if cmd:
args += [f.name.replace('\\','/')]
line = "-makelib {} {} -endlib".format(f.logical_name, ' '.join(args))
line = "{}".format(' '.join(args))
tcl_build_rtl.write(line + '\n')

def _write_makefile(self):
Expand All @@ -150,16 +145,17 @@ def _write_makefile(self):
for key, value in self.plusarg.items():
_plusargs += ['{}={}'.format(key, self._param_value_str(value))]

_xmsim_options = self.tool_options.get('xmsim_options', [])
_xrun_options = self.tool_options.get('xrun_options', [])

_elab_options = self.tool_options.get('elab_options', [])
_xrun_prefix = self.tool_options.get('xrun_prefix', [])
_xrun_options = self.tool_options.get('run_options', [])
_modules = [m['name'] for m in self.vpi_modules]
_clean_targets = ' '.join(["clean_"+m for m in _modules])
_s = MAKE_HEADER.format(toplevel = self.toplevel,
parameters = ' '.join(_parameters),
plusargs = ' '.join(_plusargs),
xmsim_options = ' '.join(_xmsim_options),
xrun_options = ' '.join(_xrun_options),
elab_options = ' '.join(_elab_options),
run_options = ' '.join(_xrun_options),
xrun_prefix = ' '.join(_xrun_prefix),
modules = ' '.join(_modules),
clean_targets = _clean_targets)
vpi_make.write(_s)
Expand All @@ -179,6 +175,7 @@ def _write_makefile(self):

def configure_main(self):
tcl_main = open(os.path.join(self.work_root, "edalize_main.f"), 'w')
tcl_main.write("-f edalize_build_c.f\n")
tcl_main.write("-f edalize_build_rtl.f\n")

self._write_build_rtl_f_file(tcl_main)
Expand Down