File: t_mem_multi_io2.cpp

package info (click to toggle)
verilator 3.833-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 10,196 kB
  • sloc: cpp: 49,566; perl: 7,111; yacc: 2,221; lex: 1,702; makefile: 651; sh: 175
file content (91 lines) | stat: -rw-r--r-- 1,901 bytes parent folder | download | duplicates (3)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// -*- mode: C++; c-file-style: "cc-mode" -*-
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2008 by Lane Brooks

#if defined(T_MEM_MULTI_IO2_CC)
# include "Vt_mem_multi_io2_cc.h"
#elif defined(T_MEM_MULTI_IO2_SC)
# include "Vt_mem_multi_io2_sc.h"
#else
# error "Unknown test"
#endif

VM_PREFIX* tb = NULL;
bool pass = true;

double sc_time_stamp() {
    return 0;
}

void check(const char* bus, int got, int exp) {
    if (got != exp) {
	VL_PRINTF("%%Error: Data mismatch on '%s', got=%x, exp=%x\n", bus, got, exp);
	pass = false;
    }
}

int main() {
    Verilated::debug(0);
    tb = new VM_PREFIX ("tb");

#ifdef SYSTEMC_VERSION
    sc_signal<vluint32_t>	i3;
    sc_signal<vluint32_t>	o3;
    sc_signal<vluint32_t>	i34[4];
    sc_signal<vluint32_t>	o34[4];
    sc_signal<vluint32_t>	i345[4][5];
    sc_signal<vluint32_t>	o345[4][5];

    tb->i3(i3);
    tb->o3(o3);
    for (int i=0; i<4; i++) {
	tb->i34[i](i34[i]);
	tb->o34[i](o34[i]);
	for (int j=0; j<5; j++) {
	    tb->i345[i][j](i345[i][j]);
	    tb->o345[i][j](o345[i][j]);
	}
    }
#endif

    // loop through every possibility and check the result
#ifdef SYSTEMC_VERSION
    sc_start(1,SC_NS);
#  define ASSIGN(s,v) s.write(v)
#  define READ(s) s.read()
#else
    tb->eval();
#  define ASSIGN(s,v) tb->s = (v)
#  define READ(s) tb->s
#endif

    ASSIGN(i3, 13);
    for (int i=0; i<4; i++) {
	ASSIGN(i34[i], i);
	for (int j=0; j<5; j++) {
	    ASSIGN(i345[i][j], i*8 + j);
	}
    }

#ifdef SYSTEMC_VERSION
    sc_start(1,SC_NS);
#else
    tb->eval();
#endif

    check("o3", READ(o3), 13);
    for (int i=0; i<4; i++) {
	check("o34", READ(o34[i]), i);
	for (int j=0; j<5; j++) {
	    check("o345", READ(o345[i][j]), i*8 + j);
	}
    }

    if (pass) {
	VL_PRINTF("*-* All Finished *-*\n");
    } else {
	vl_fatal(__FILE__,__LINE__,"top", "Unexpected results from test\n");
    }
    return 0;
}