MatchLib
Toggle main menu visibility
Main Page
Namespaces
Namespace List
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
Functions
Files
File List
File Members
All
Macros
•
All
Classes
Namespaces
Files
Functions
Modules
Pages
Loading...
Searching...
No Matches
cmod
include
nvhls_array.h
1
/*
2
* Copyright (c) 2016-2024, NVIDIA CORPORATION. All rights reserved.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License")
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
#ifndef NVHLS_ARRAY
17
#define NVHLS_ARRAY
18
19
20
#include <cstddef>
21
#include <ac_assert.h>
22
#include <list>
23
#include "systemc.h"
24
25
namespace
nvhls {
26
27
template
<
size_t
W>
28
struct
nv_array_pow2;
29
30
template
<>
31
struct
nv_array_pow2
<1>
32
{
33
static
const
size_t
P = 1;
34
};
31
struct
nv_array_pow2
<1> {
…
};
35
36
template
<
size_t
W>
37
struct
nv_array_pow2
38
{
39
typedef
nv_array_pow2
<(W>>1)>
SUB
;
40
static
const
size_t
P = SUB::P << 1;
41
};
37
struct
nv_array_pow2
{
…
};
42
43
44
static
const
char
* make_permanent(
const
char
*
nm
) {
45
#ifdef __SYNTHESIS__
46
return
nm
;
47
#else
48
static
std::list<std::string>
nm_str
;
49
nm_str
.push_back(std::string(
nm
));
50
return
nm_str
.back().c_str();
51
#endif
52
}
53
54
// nv_array_bank_array_no_assert_base is the base class for banked arrays,
55
// and typically is not directly used in user models.
56
57
template
<
typename
B,
size_t
C>
58
class
nv_array_bank_array_no_assert_base;
59
60
template
<
typename
B>
61
class
nv_array_bank_array_no_assert_base
<B, 1>
62
{
63
B a;
64
65
public
:
66
67
nv_array_bank_array_no_assert_base
() : a() {}
68
69
nv_array_bank_array_no_assert_base
(
const
char
*
prefix
)
70
: a(make_permanent(
sc_gen_unique_name
(
prefix
)))
71
{}
72
73
B &operator[](
size_t
idx
) {
return
a; }
74
const
B &operator[](
size_t
idx
)
const
{
return
a; }
75
};
61
class
nv_array_bank_array_no_assert_base
<B, 1> {
…
};
76
77
78
template
<
typename
B,
size_t
C>
79
class
nv_array_bank_array_no_assert_base
80
{
81
static
const
size_t
W =
nv_array_pow2
<
C
-1>::P;
82
nv_array_bank_array_no_assert_base<B, W >
a0;
83
nv_array_bank_array_no_assert_base
<B,
C
-W> a1;
84
public
:
85
86
nv_array_bank_array_no_assert_base
() : a0(), a1() {}
87
88
nv_array_bank_array_no_assert_base
(
const
char
*
prefix
)
89
: a0(make_permanent(
sc_gen_unique_name
(
prefix
)))
90
, a1(make_permanent(
sc_gen_unique_name
(
prefix
)))
91
{}
92
93
B &operator[](
size_t
idx
) {
94
#ifndef __SYNTHESIS__
95
assert
(
idx
<
C
);
96
#endif
97
size_t
aidx
=
idx
& (W-1);
return
idx
&W ? a1[
aidx
] : a0[
aidx
];
98
}
99
100
const
B &operator[](
size_t
idx
)
const
{
101
#ifndef __SYNTHESIS__
102
assert
(
idx
<
C
);
103
#endif
104
size_t
aidx
=
idx
& (W-1);
return
idx
&W ? a1[
aidx
] : a0[
aidx
];
105
}
106
};
79
class
nv_array_bank_array_no_assert_base
{
…
};
107
108
109
144
template
<
typename
Type,
unsigned
int
VectorLength>
145
class
nv_array
:
public
nv_array_bank_array_no_assert_base
<Type, VectorLength>
146
{
147
public
:
148
typedef
nv_array_bank_array_no_assert_base<Type,VectorLength>
base_t
;
149
nv_array
() {}
150
nv_array
(
const
char
*
prefix
) :
base_t
(
prefix
) {}
151
nv_array
(
sc_module_name
prefix
) :
base_t
(
prefix
) {}
152
nv_array
(
sc_module_name
prefix
,
const
unsigned
int
&
id
) :
base_t
(
prefix
) {}
153
};
145
class
nv_array
:
public
nv_array_bank_array_no_assert_base
<Type, VectorLength> {
…
};
154
155
};
156
157
#endif
nvhls::nv_array_bank_array_no_assert_base
Definition
nvhls_array.h:80
nvhls::nv_array
An implementation of array that declares VectorLength variables for array of size VectorLength.
Definition
nvhls_array.h:146
nvhls::get_slc
nvhls_t< W >::nvuint_t get_slc(type X, const unsigned int i)
Function that returns slice of bits.
Definition
nvhls_int.h:437
nvhls::nv_array_pow2
Definition
nvhls_array.h:38
Generated on Thu Apr 24 2025 16:48:01 for MatchLib by
1.9.8