verilator/test_regress/t/t_clk_2in.cpp

58 lines
1.2 KiB
C++
Raw Normal View History

// -*- mode: C++; c-file-style: "cc-mode" -*-
//
2010-06-22 00:40:34 +00:00
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2010 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
2010-06-22 00:40:34 +00:00
#include <verilated.h>
#include VM_PREFIX_INCLUDE
2010-06-22 00:40:34 +00:00
unsigned int main_time = 0;
2010-06-22 00:40:34 +00:00
double sc_time_stamp() { return main_time; }
2010-06-22 00:40:34 +00:00
VM_PREFIX* topp = nullptr;
2010-06-22 00:40:34 +00:00
void clockit(int clk1, int clk0) {
topp->clks = clk1 << 1 | clk0;
#ifndef T_CLK_2IN_VEC
2010-06-22 00:40:34 +00:00
topp->c1 = clk1;
topp->c0 = clk0;
#endif
#ifdef TEST_VERBOSE
2019-10-25 02:19:46 +00:00
printf("[%u] c1=%d c0=%d\n", main_time, clk1, clk0);
2010-06-22 00:40:34 +00:00
#endif
topp->eval();
main_time++;
}
int main(int argc, char* argv[]) {
Verilated::debug(0);
Verilated::commandArgs(argc, argv);
2010-06-22 00:40:34 +00:00
topp = new VM_PREFIX;
topp->check = 0;
clockit(0, 0);
main_time += 10;
2010-06-22 00:40:34 +00:00
for (int i = 0; i < 2; i++) {
clockit(0, 0);
clockit(0, 1);
clockit(1, 1);
clockit(0, 0);
clockit(1, 1);
clockit(1, 0);
clockit(0, 0);
clockit(0, 1);
clockit(1, 0);
clockit(0, 0);
2010-06-22 00:40:34 +00:00
}
topp->check = 1;
clockit(0, 0);
topp->final();
VL_DO_DANGLING(delete topp, topp);
2010-06-22 00:40:34 +00:00
}