Skip to content

Commit

Permalink
add reset and finish
Browse files Browse the repository at this point in the history
  • Loading branch information
Dragon-Git committed Nov 16, 2024
1 parent 85750a2 commit 97ba6c2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
7 changes: 1 addition & 6 deletions src/svuvm/python_bridge_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,9 @@ package python_bridge_pkg;
`ifndef VERILATOR
#n;
`endif //VERILATOR
$display("inside sv task in %d", $time);
$display("=== time: %d ===", $time);
endtask:wait_unit

task stop();
$stop;
endtask:stop

task run_test_wrap(string test_name="");
`ifndef VERILATOR
run_test(test_name);
Expand Down Expand Up @@ -491,7 +487,6 @@ package python_bridge_pkg;
// utils
export "DPI-C" task run_test_wrap;
export "DPI-C" task wait_unit;
export "DPI-C" task stop;

import "DPI-C" pure function string dirname(string file_path);
`ifndef VERILATOR
Expand Down
15 changes: 10 additions & 5 deletions src/svuvm/svuvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#endif

#ifndef NO_VPI
#include "vpi_user.h"
#include "sv_vpi_user.h"
#include "vpi_user.h"
#endif

extern "C" {
Expand Down Expand Up @@ -94,7 +94,6 @@ void read_reg(const char *name, int *data);
void check_reg(const char *name, int data = 0, unsigned char predict = 0);
void run_test_wrap(const char *test_name = "");
void wait_unit(int n);
void stop();

int wrap_read_reg(const char *name) {
int data;
Expand Down Expand Up @@ -1258,8 +1257,7 @@ PYBIND11_MODULE(svuvm, m) {
} else {
scope = nullptr;
}
vpiHandle handle =
vpi_handle_by_name((char *)"top.test_wire", scope);
vpiHandle handle = vpi_handle_by_name((char *)"top.test_wire", scope);
if (handle == nullptr) {
vpi_printf((PLI_BYTE8 *)"VPI Error: unable to locate vpiHandle (%s), "
"Either the name is incorrect, or you may "
Expand Down Expand Up @@ -1538,7 +1536,14 @@ PYBIND11_MODULE(svuvm, m) {
py::arg("sqr_name"), py::arg("rand_en") = 1, py::arg("background") = 0);
m.def("run_test", &run_test_wrap, "uvm run test", py::arg("test_name"));
m.def("wait_unit", &wait_unit, "wait unit time");
m.def("stop", &stop, "suspend the simulation");
m.def(
"reset", []() { return vpi_control(vpiReset); },
"Reset the simulation");
m.def(
"stop", []() { return vpi_control(vpiStop); }, "Suspend the simulation");
m.def(
"finish", []() { return vpi_control(vpiFinish); },
"Finished the simulation");
}

void py_func(const char *mod_name, const char *func_name,
Expand Down

0 comments on commit 97ba6c2

Please sign in to comment.