53 #include <boost/algorithm/string.hpp> 58 #define XSIM_VLOG "xvlog" 59 #define XSIM_VHDL "xvhdl" 60 #define XSIM_XELAB "xelab" 61 #define XSIM_XSC "xsc" 65 const std::string& _top_fname,
const std::string& _inc_dirs)
80 const std::list<std::string>& file_list)
82 std::ofstream prj_file(project_filename);
83 for(
auto const&
file : file_list)
89 std::filesystem::path file_path(
file);
90 const auto extension = file_path.extension().string();
91 if(extension ==
".vhd" || extension ==
".vhdl" || extension ==
".VHD" || extension ==
".VHDL")
95 else if(extension ==
".v" || extension ==
".V" || extension ==
".sv" || extension ==
".SV")
101 THROW_ERROR(
"Extension not recognized! " + extension);
103 prj_file <<
" work ";
104 const auto filename = file_path.string();
107 prj_file << std::filesystem::path(
GetCurrentPath()).string() <<
"/";
112 return project_filename;
116 const std::list<std::string>& file_list)
118 script <<
"#configuration" << std::endl;
119 const auto setupscr =
120 Param->isOption(OPT_xilinx_vivado_settings) ?
Param->getOption<std::string>(OPT_xilinx_vivado_settings) :
"";
121 if(!setupscr.empty())
123 script <<
". " << setupscr <<
" >& /dev/null;" << std::endl << std::endl;
125 script <<
"BEH_DIR=\"" <<
XSIM_SUBDIR <<
suffix <<
"\"" << std::endl <<
"BEH_CC=\"${CC}\"" << std::endl << std::endl;
126 log_file =
"${BEH_DIR}/" + top_filename +
"_xsim.log";
127 const auto xilinx_root =
Param->isOption(OPT_xilinx_root) ?
Param->getOption<std::string>(OPT_xilinx_root) :
"";
128 std::string beh_cflags =
129 "-DXILINX_SIMULATOR " + (xilinx_root.size() ? (
"-isystem " + xilinx_root +
"/data/xsim/include") :
"");
131 const auto vflags = [&]() {
133 if(cflags.find(
"-m32") != std::string::npos)
135 flags +=
" -define __M32";
137 else if(cflags.find(
"-mx32") != std::string::npos)
139 flags +=
" -define __MX32";
141 else if(cflags.find(
"-m64") != std::string::npos)
143 flags +=
" -define __M64";
145 if(
Param->isOption(OPT_generate_vcd) &&
Param->getOption<
bool>(OPT_generate_vcd))
147 flags +=
" -define GENERATE_VCD";
149 if(
Param->isOption(OPT_discrepancy) &&
Param->getOption<
bool>(OPT_discrepancy))
151 flags +=
" -define GENERATE_VCD_DISCREPANCY";
153 const auto inc_dir_list = string_to_container<std::vector<std::string>>(
inc_dirs,
",");
154 for(
const auto& inc : inc_dir_list)
156 flags +=
" -i " + inc;
162 std::string sim_cmd =
163 "rm -rf xsim.* xelab.*; " XSIM_XELAB " -sv_root ${BEH_DIR} -sv_lib libmdpi " + vflags +
" -prj " + prj_file;
164 if(
Param->isOption(OPT_assert_debug) &&
Param->getOption<
bool>(OPT_assert_debug))
166 sim_cmd +=
" --debug all --rangecheck -O2";
170 sim_cmd +=
" --debug off -O3";
172 sim_cmd +=
" -L work -L unifast_ver -L unisims_ver -L unimacro_ver -L secureip --snapshot " + top_filename +
173 "tb_behav work.clocked_bambu_testbench -nolog -stat -R";
174 sim_cmd +=
" 2>&1 | tee " +
log_file;
static const std::string & create_project_file(const std::string &project_filename, const std::list< std::string > &file_list)
File containing functions and utilities to support the printing of debug messagges.
#define PRINT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
#define DEBUG_LEVEL_PEDANTIC
very verbose debugging print is performed.
~VIVADO_xsim_wrapper() override
Destructor.
std::string GenerateScript(std::ostream &script, const std::string &top_filename, const std::list< std::string > &file_list) override
Generates the proper simulation script.
void CheckExecution() override
Checks if the current specification can be executed or not.
VIVADO_xsim_wrapper(const ParameterConstRef &Param, const std::string &suffix, const std::string &top_fname, const std::string &inc_dirs)
Constructor.
utility function used to read files.
bool ends_with(const std::string &str, const std::string &pattern)
This file collects some utility functions and macros.
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Wrapper to XSIM by XILINX VIVADO.
this class is used to manage the command-line or XML options.
void Clean() const override
Remove files created during simulation.
std::string GetCurrentPath()
std::string suffix
suffix added to the XSIM dir