MatchLib
ArbitratedScratchpadTypes.h
1 /*
2  * Copyright (c) 2016-2022, 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 ARBITRATED_SCRATCHPAD_TYPES_H
17 #define ARBITRATED_SCRATCHPAD_TYPES_H
18 
19 #include <nvhls_int.h>
20 #include <nvhls_types.h>
21 #include <nvhls_message.h>
22 #include <comptrees.h>
23 
24 // Declare client input and output interfaces as structs
25 class CLITYPE_T : public nvhls_message {
26  public:
27  enum { LOAD, STORE };
28  sc_uint<1> val;
29  static const int width = 1;
30 
31  template <unsigned int Size>
32  void Marshall(Marshaller<Size>& m) {
33  m& val;
34  }
35 };
36 
37 template <typename T, unsigned int AddrWidth, unsigned int N>
38 class cli_req_t : public nvhls_message {
39  public:
40  CLITYPE_T type;
41  bool valids[N];
42  NVUINTW(AddrWidth) addr[N];
43  T data[N];
44  static const unsigned int type_width = Wrapped<T>::width;
45  static const int width = 1 + N + N * (AddrWidth + type_width);
46 
47  template <unsigned int Size>
48  void Marshall(Marshaller<Size>& m) {
49  m& type;
50  for(unsigned i=0; i<N; i++) {
51  m& valids[i];
52  }
53  for(unsigned i=0; i<N; i++) {
54  m& addr[i];
55  }
56  for(unsigned i=0; i<N; i++) {
57  m& data[i];
58  }
59  }
60 };
61 
62 template <typename T, unsigned int N>
63 class cli_rsp_t : public nvhls_message {
64  public:
65  bool valids[N];
66  T data[N];
67  static const unsigned int type_width = Wrapped<T>::width;
68  static const int width = N + type_width * N;
69 
70  template <unsigned int Size>
71  void Marshall(Marshaller<Size>& m) {
72  for(unsigned i=0; i<N; i++) {
73  m& valids[i];
74  }
75  for(unsigned i=0; i<N; i++) {
76  m& data[i];
77  }
78  }
79 };
80 
81 #endif