litex/sim/hdl_common/hdl_ncsim.tcl

92 lines
2.6 KiB
Tcl

set HDL_TOOLTYPE SIMULATION
set HDL_TOOLNAME ncsim
set HDL_PUTS puts
set HDL_MSG_FORMAT "********** %s **********"
if {![file exists hdl.var]} {
hdl_note "Creating default hdl.var"
exec echo "DEFINE WORK work" > hdl.var
}
if {![file exists cds.lib]} {
hdl_note "Creating default cds.lib"
exec echo "# This file was created automatically by hdl_ncsim.tcl" > cds.lib
exec echo "# You can edit this file" >> cds.lib
exec echo "# Please add the libraries that are not handled by hdl_ncsim.tcl" >> cds.lib
exec echo "# (for example the Xilinx libraries compiled with compxlib)" >> cds.lib
exec echo {INCLUDE ${CDS_INST_DIR}/tools/inca/files/cds.lib} >> cds.lib
}
proc no_matching_line {pattern file} {
return [catch {exec grep -q $pattern $file}]
}
if {[no_matching_line "^INCLUDE mycds.lib$" cds.lib]} {
hdl_note "Including mycds.lib in cds.lib"
exec echo "INCLUDE mycds.lib" >> cds.lib
}
hdl_note "Clean-up mycds.lib"
exec echo "# This file is written automatically by hdl_ncsim.tcl" > mycds.lib
exec echo "# Do not edit this file" >> mycds.lib
exec echo "# It will be overwritten at each compilation" >> mycds.lib
proc hdl_tool_library {lib} {
set lib [string tolower $lib]
set path [get_lib_path]/${lib}_nc
exec echo "DEFINE $lib $path" >> mycds.lib
exec touch $path
exec rm -r $path
exec mkdir $path
}
proc hdl_tool_compile {format version incdirs library define files behavioral} {
switch $format {
"vhdl" {
set command "ncvhdl"
if {$version != 87} {
lappend command -v93
}
# Less strict VHDL for behavioral modules
if {$behavioral} {
lappend command -relax
}
}
"verilog" {
set command "ncvlog"
if {$version == "sv"} {
lappend command -sv
}
foreach d $define {
lappend command -define $d
}
foreach i $incdirs {
lappend command -incdir $i
}
}
}
lappend command -work [string tolower $library]
lappend command -nocopyright
foreach f $files {
lappend command $f
}
eval $command
}
# Allow launching NC-Sim tools directly in TCL
proc ncvlog { args } {
puts -nonewline [eval exec -keepnewline ncvlog $args]
}
proc ncvhdl { args } {
puts -nonewline [eval exec -keepnewline ncvhdl $args]
}
proc ncelab { args } {
puts -nonewline [eval exec -keepnewline ncelab $args]
}
proc ncsdfc { args } {
puts -nonewline [eval exec -keepnewline ncsdfc $args]
}
proc ncsim { args } {
puts -nonewline [eval exec -keepnewline ncsim $args]
}