Skip to content

Commit

Permalink
[test] optimize test code
Browse files Browse the repository at this point in the history
  • Loading branch information
midnighter95 committed Nov 6, 2023
1 parent 5dd8a91 commit ef841e9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 24 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ project/project
project/target
target/
# test
test_run_dir/
run/
verdiLog

.bsp/
Expand Down
1 change: 0 additions & 1 deletion emulator/src/dpi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,5 @@ void dpiCheck(
svBit valid,
const svBitVecVal *result,
const svBitVecVal *fflags) {

testharness_instance.dpiCheck(valid, *result, *fflags);
}
5 changes: 1 addition & 4 deletions emulator/src/testharness.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@

TestHarness::TestHarness() : terminate(false) {}

uint64_t TestHarness::get_t() { return getCycle(); }

int TestHarness::report() {
if (terminate == true) {
LOG(INFO) << fmt::format("ran {} cases, cycles = {}", cnt - 1, get_t());
LOG(INFO) << fmt::format("ran {} cases, cycles = {}", cnt - 1, getCycle());
dpiFinish();
}
return 0;
Expand Down Expand Up @@ -71,7 +69,6 @@ void TestHarness::dpiInitCosim() {
}

void TestHarness::dpiPeek(svBit ready) {

if (ready == 1) {
setAvailable();
}
Expand Down
20 changes: 9 additions & 11 deletions emulator/src/testharness.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,34 +41,32 @@ class TestHarness {
public:
explicit TestHarness();

void dpiDumpWave();
std::queue<testdata> test_queue;

void dpiInitCosim();
testdata testcase;

uint64_t get_t();
void initTestCases();

int report();
void dpiDumpWave();

uint64_t getCycle() { return ctx->time(); }
void dpiInitCosim();

void dpiPoke(const DutInterface &toDut);

void dpiPeek(svBit ready);

std::queue<testdata> test_queue;

testdata testcase;

void initTestCases();

void dpiCheck(svBit valid, svBitVecVal result, svBitVecVal fflags);

uint64_t getCycle() { return ctx->time(); }

void setAvailable();

void clrAvailable();

void reloadCase();

int report();

private:
VerilatedContext *ctx;
VerilatedFstC tfp;
Expand Down
6 changes: 0 additions & 6 deletions emulator/src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@

#include <cstdint>


inline char *get_env_arg(const char *name) {
char *val = std::getenv(name);
CHECK(val != nullptr) << fmt::format("cannot find environment of name '{}'", name);
return val;
}

inline char *get_env_arg_default(const char *name, char *default_val) {
char *val = std::getenv(name);
return val == nullptr ? default_val : val;
}

0 comments on commit ef841e9

Please sign in to comment.