-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DPI-C support for XCelium and Verilator (not possible with MAIN a…
…rgument)
- Loading branch information
Showing
9 changed files
with
100 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
cmake_minimum_required(VERSION 3.25) | ||
project(dpi_example NONE) | ||
|
||
include("../../SoCMakeConfig.cmake") | ||
|
||
option_enum(SIMULATOR "Which simulator to use" "questa;modelsim;xcelium;verilator" "modelsim") | ||
|
||
add_ip(tb | ||
DESCRIPTION "Simple verilog testbench" | ||
) | ||
|
||
ip_sources(${IP} SYSTEMVERILOG | ||
${PROJECT_SOURCE_DIR}/tb.sv | ||
) | ||
|
||
add_subdirectory(hello) | ||
|
||
ip_link(${IP} hello_dpi) | ||
|
||
if(SIMULATOR STREQUAL "questa" OR SIMULATOR STREQUAL "modelsim") | ||
modelsim(${IP}) | ||
|
||
elseif(SIMULATOR STREQUAL "xcelium") | ||
xcelium(${IP}) | ||
|
||
elseif(SIMULATOR STREQUAL "verilator") | ||
enable_language(CXX) | ||
verilator(${IP}) | ||
add_executable(main Vtb__main.cpp) | ||
target_link_libraries(main tb__vlt) | ||
endif() | ||
|
||
help() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Verilated -*- C++ -*- | ||
// DESCRIPTION: main() calling loop, created with Verilator --main | ||
|
||
#include "verilated.h" | ||
#include "Vtb.h" | ||
|
||
//====================== | ||
|
||
int main(int argc, char** argv, char**) { | ||
// Setup context, defaults, and parse command line | ||
Verilated::debug(0); | ||
const std::unique_ptr<VerilatedContext> contextp{new VerilatedContext}; | ||
contextp->commandArgs(argc, argv); | ||
|
||
// Construct the Verilated model, from Vtop.h generated from Verilating | ||
const std::unique_ptr<Vtb> topp{new Vtb{contextp.get()}}; | ||
|
||
// Simulate until $finish | ||
while (!contextp->gotFinish()) { | ||
// Evaluate model | ||
topp->eval(); | ||
// Advance time | ||
contextp->timeInc(1); | ||
} | ||
|
||
if (!contextp->gotFinish()) { | ||
VL_DEBUG_IF(VL_PRINTF("+ Exiting without $finish; no events left\n");); | ||
} | ||
|
||
// Final model cleanup | ||
topp->final(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
cmake_minimum_required(VERSION 3.25) | ||
project(hello_dpi CXX) | ||
|
||
add_library(hello_dpi SHARED | ||
./hello.cpp | ||
) | ||
|
||
if(NOT SIMULATOR STREQUAL "verilator") | ||
target_compile_options(hello_dpi PRIVATE -m32) | ||
target_link_options(hello_dpi PRIVATE -m32) | ||
endif() |
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.