MatchLib
ArbitratedScratchpadTypes.h
1 /*
2  * Copyright (c) 2016-2019, 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  for(unsigned i=0; i<N; i++) {
50  m& data[i];
51  m& addr[i];
52  m& valids[i];
53  }
54  m& type;
55  }
56 };
57 
58 template <typename T, unsigned int N>
59 class cli_rsp_t : public nvhls_message {
60  public:
61  bool valids[N];
62  T data[N];
63  static const unsigned int type_width = Wrapped<T>::width;
64  static const int width = N + type_width * N;
65 
66  template <unsigned int Size>
67  void Marshall(Marshaller<Size>& m) {
68  for(unsigned i=0; i<N; i++) {
69  m& data[i];
70  m& valids[i];
71  }
72  }
73 };
74 
75 #endif
NVUINTW(Wrapped< T >::width) TypeToNVUINT(T in)
Convert Type to NVUINT.
Definition: TypeToBits.h:115