cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
rlb.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2016 -- 2021 IBM Corporation
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 
30 #include "rlb.hpp"
31 
32 using namespace hls;
33 
34 #undef USE_DEPRECATED_DIRECTIVES
35 
36 
40 #ifndef __SYNTHESIS__
41  extern bool gTraceEvent;
42 #endif
43 #define THIS_NAME "RLB"
44 
45 #define TRACE_OFF 0x0000
46 #define TRACE_TODO 1 << 1
47 #define TRACE_ALL 0xFFFF
48 
49 #define DEBUG_LEVEL (TRACE_OFF)
50 
51 
62 void rlb(
63 
64  //------------------------------------------------------
65  //-- MMIO Interface
66  //------------------------------------------------------
67  StsBit *poMMIO_Ready,
68 
69  //------------------------------------------------------
70  //-- UOE / Data Stream Interface
71  //------------------------------------------------------
72  stream<StsBool> &siUOE_Ready,
73 
74  //------------------------------------------------------
75  //-- TOE / Data Stream Interface
76  //------------------------------------------------------
77  stream<StsBool> &siTOE_Ready)
78 {
79  #if HLS_VERSION == 2017
80  //-- DIRECTIVES FOR THE INTERFACES ----------------------------------------
81  #pragma HLS INTERFACE ap_ctrl_none port=return
82 
83 
84 
85 
86 
87  #pragma HLS INTERFACE ap_none register port=poMMIO_Ready name=poMMIO_Ready
88  #pragma HLS RESOURCE core=AXI4Stream variable=siUOE_Ready metadata="-bus_bundle siUOE_Ready"
89  #pragma HLS RESOURCE core=AXI4Stream variable=siTOE_Ready metadata="-bus_bundle siTOE_Ready"
90 
91  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
92  #pragma HLS pipeline II=1
93 #else
94  //-- DIRECTIVES FOR THE INTERFACES -----------------------------------------
95  #pragma HLS INTERFACE ap_ctrl_none port=return
96 
97  #pragma HLS INTERFACE ap_none register port=poMMIO_Ready name=poMMIO_Ready
98  #pragma HLS INTERFACE axis register both port=siUOE_Ready name=siUOE_Ready
99  #pragma HLS INTERFACE axis register both port=siTOE_Ready name=siTOE_Ready
100 
101  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
102  #pragma HLS PIPELINE II=1 enable_flush
103  #pragma HLS INLINE off
104 #endif
105 
106  const char *myName = concat2(THIS_NAME, "RLB");
107 
108  //-- STATIC CONTROL VARIABLES (with RESET) --------------------------------
109  static enum FsmStates { BARRIER=0, SYNC } rlb_fsmState;
110  #pragma HLS RESET variable=rlb_fsmState
111  static StsBool rlb_uoeReady;
112  #pragma HSL RESET variable=rlb_uoeReady
113  static StsBool rlb_toeReady;
114  #pragma HSL RESET variable=rlb_toeReady
115 
116  switch(rlb_fsmState) {
117  case BARRIER:
118  *poMMIO_Ready = 0;
119  if(!siUOE_Ready.empty()) {
120  siUOE_Ready.read(rlb_uoeReady);
121  }
122  if(!siTOE_Ready.empty()) {
123  siTOE_Ready.read(rlb_toeReady);
124  }
125  if (rlb_uoeReady and rlb_toeReady) {
126  rlb_fsmState = SYNC;
127  }
128  break;
129  case SYNC:
130  *poMMIO_Ready = 1;
131  break;
132  }
133 }
134 
bool StsBool
Definition: nal.hpp:246
bool gTraceEvent
Definition: tb_nal.cpp:151
#define THIS_NAME
Definition: rlb.cpp:43
void rlb(StsBit *poMMIO_Ready, stream< StsBool > &siUOE_Ready, stream< StsBool > &siTOE_Ready)
Main process of the Ready Logic Barrier (RLB).
Definition: rlb.cpp:62
ap_uint< 1 > StsBit
Definition: nts_types.hpp:116
#define concat2(firstCharConst, secondCharConst)
Definition: nts_utils.hpp:159
: Defines and prototypes related to the Ready Logic Barrier.