File: t_clk_inp_init.cpp

package info (click to toggle)
verilator 4.038-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 29,596 kB
  • sloc: cpp: 90,585; perl: 15,101; ansic: 8,573; yacc: 3,626; lex: 1,616; makefile: 1,101; sh: 175; python: 145
file content (67 lines) | stat: -rw-r--r-- 1,368 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2020 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0

// Test defines
// Generated header
#include "Vt_clk_inp_init.h"
// General headers
#include "verilated.h"

Vt_clk_inp_init* topp;

vluint64_t main_time;
double sc_time_stamp() { return main_time; }

void oneTest(int seed) {
    double sim_time = 1000;

#ifdef TEST_VERBOSE
    VL_PRINTF("== Seed=%d\n", seed);
#endif

    // Randomise initial state
    srand48(seed);
    srand48(5);
    Verilated::randReset(123);

    topp = new Vt_clk_inp_init("top");

    // Start not in reset
    topp->rst_n = 1;
    topp->clk = 0;
    topp->eval();

    // Tick for a little bit
    while (sc_time_stamp() < sim_time && !Verilated::gotFinish()) {
        topp->clk = 0;
        topp->eval();

        main_time += 5;

        topp->clk = 1;
        topp->eval();

        main_time += 5;
    }

    if (!Verilated::gotFinish()) {
        vl_fatal(__FILE__, __LINE__, "main", "%Error: Timeout; never got a $finish");
    }

    topp->final();
    VL_DO_DANGLING(delete topp, topp);
}

int main(int argc, char** argv, char** env) {
    Verilated::commandArgs(argc, argv);
#if VL_DEBUG
    // Verilated::debug(1);
#endif

    for (int seed = 123; seed < 133; ++seed) {
        oneTest(seed);
    }

    return 0;
}