-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathtest_base_record1.cpp
60 lines (48 loc) · 1.34 KB
/
test_base_record1.cpp
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
/******************************************************************************
* Copyright (c) 2020, Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception.
*
*****************************************************************************/
#include "sct_assert.h"
#include "systemc.h"
// Template record with base template class, which has methods and fields
class A : public sc_module {
public:
sc_signal<int> sig{"sig"};
SC_CTOR(A) {
SC_METHOD(base_record1);
sensitive << sig;
}
template <unsigned BitSize>
struct Base {
static const unsigned SIZE = BitSize;
typedef sc_uint<SIZE> Bits_t;
Base(const int& par) : b(par) {
}
bool a;
Bits_t b;
sc_uint<1> getB(unsigned offset) {
return (sc_uint<1>)b[offset];
}
};
template <unsigned BitSize>
struct Simple : Base<BitSize> {
using BaseT = Base<BitSize>;
sc_uint<4> c;
Simple(const int& par) : BaseT(par) {}
auto getB() {
return BaseT::getB(4);
}
};
void base_record1()
{
Simple<8> s(sig.read());
int l = s.getB();
}
};
int sc_main(int argc, char *argv[]) {
A a_mod{"a_mod"};
sc_start();
return 0;
}