// Copyright (C) 2024 Ethan Uppal. All rights reserved. #ifdef PULSAR_VERILATOR_TEST #include void PulsarMain::cycle() { mod->clk = 0; mod->eval(); mod->clk = 1; mod->eval(); } void PulsarMain::pump() { for (int i = 0; i < 10; i++) { cycle(); } } void PulsarMain::reset() { mod->reset = 1; pump(); mod->reset = 0; pump(); } void PulsarMain::go() { mod->go = 1; while (!mod->done) { cycle(); } mod->go = 0; cycle(); } #ifdef __linux__ // linux hack for CI? // https://veripool.org/guide/latest/faq.html#why-do-i-get-undefined-reference-to-sc-time-stamp // likely not sustainable double sc_time_stamp() { return 0; } #endif int test(PulsarMain main); int main(int argc, char** argv) { Verilated::commandArgs(argc, argv); VPULSAR_MAIN_MODULE* mod = new VPULSAR_MAIN_MODULE; PulsarMain main; main.mod = mod; int exit_code = test(main); if (exit_code == 0) { std::cout << "test passed!" << '\n'; } delete mod; exit(exit_code); } #endif