MatchLib
All Classes Namespaces Files Functions Modules Pages
UIntOrEmpty.h
1/*
2 * Copyright (c) 2017-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
17#ifndef _UINTOREMPTY_H_
18#define _UINTOREMPTY_H_
19
20#include <systemc>
21#include <nvhls_int.h>
22#include <nvhls_types.h>
23#include <nvhls_assert.h>
24#include <nvhls_message.h>
25
27// Provides an NVUINT field that can also be of width = 0
28// May eventually integrate this more into Connections marshaller
29
30namespace nvhls {
31
35struct EmptyField : public nvhls_message {
36 template <typename T>
37 EmptyField operator=(T const &) {
38#ifndef __SYNTHESIS__
39 NVHLS_ASSERT_MSG(true,"EmptyField should never be assigned or accessed"); // If an assignment actually occurs during runtime
40 // you've done something wrong
41#endif
42 return EmptyField();
43 }
44 uint64 to_uint64() { return 0; }
45 const sc_bit operator[](std::size_t idx) const { return static_cast<sc_bit>(0); }
46 bool and_reduce() { return 0; }
47 bool or_reduce() { return 0; }
48};
49
50/* Operator << for EmptyField. */
51inline std::ostream &operator<<(ostream &os, const EmptyField &empty) {
52 return os << "EMPTYFIELD";
53}
54
55/* Operator & for Marshaller and EmptyField. */
56template <unsigned int Size>
57Marshaller<Size> &operator&(Marshaller<Size> &m, EmptyField &rhs) {
58 return m; // just do nothing
59}
60
61/* Operator != for EmptyField and int. */
62inline bool operator!=(const EmptyField lhs, const int rhs) {
63 return true; // EmptyField never equals anything
64}
65
69template <bool, int W>
71
75template <int W>
77 public:
78 typedef NVUINTW(W) T;
79};
80
84template <int W>
86 public:
87 typedef EmptyField T;
88};
89
101template <int W>
103 public:
104 typedef typename UIntOrEmptywCheck<(W > 0), W>::T T;
105};
106
107};
108
110
111#endif
112
The UIntOrEmpty class is used to define a bitvector that can have a bitwidth of 0.
A class to determine whether to instantiate an NVUINT or an EmptyField.
Definition UIntOrEmpty.h:70
#define NVHLS_ASSERT_MSG(X, MSG)
#define NVUINTW(width)
Definition nvhls_types.h:35
nvhls_t< W >::nvuint_t get_slc(type X, const unsigned int i)
Function that returns slice of bits.
Definition nvhls_int.h:437
The EmptyField class is used for rudimentary support for members of a struct that can be configured t...
Definition UIntOrEmpty.h:35