MatchLib
All Classes Namespaces Files Functions Modules Pages
AxiAddWriteResponse.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#ifndef __AXIADDWRITERESPONSE_H__
17#define __AXIADDWRITERESPONSE_H__
18
19#include <systemc.h>
20#include <nvhls_connections.h>
21#include <nvhls_marshaller.h>
22#include <axi/axi4.h>
23#include <TypeToBits.h>
24
50template <typename CfgManager, typename CfgSubordinate>
51class AxiAddWriteResponse : public sc_module {
52 SC_HAS_PROCESS(AxiAddWriteResponse);
53 // Local typedefs and derived constants
56
57 public:
58 // External interface
59 sc_in_clk clk;
60 sc_in<bool> rst;
61
62 typename axiM::read::template subordinate<> axiM_read;
63 typename axiM::write::template subordinate<> axiM_write;
64 typename axiS::read::template manager<> axiS_read;
65 typename axiS::write::template manager<> axiS_write;
66
67 private:
68 // Local state and submodules
69 typename axiM::AddrPayload AW;
70 typename axiM::WritePayload W;
71 typename axiM::AddrPayload AR;
72 typename axiS::ReadPayload R;
74 // Ideally we'd remove the B field entirely, but a stub of it still exists,
75 // so we need to connect it to something
77
78 public:
79 // Constructor
80 AxiAddWriteResponse(sc_module_name name)
81 : sc_module(name),
82 clk("clk"),
83 rst("rst"),
84 axiM_read("axiM_read"),
85 axiM_write("axiM_write"),
86 axiS_read("axiS_read"),
87 axiS_write("axiS_write"),
88 B("B"),
89 dummyB("dummyB")
90 {
91
92 B.clk(clk);
93 B.rst(rst);
94 B.in(axiS_write.b);
95
96 dummyB.clk(clk);
97 dummyB.rst(rst);
98 dummyB.out(axiM_write.b);
99
100 SC_THREAD(axi_read_ar);
101 sensitive << clk.pos();
103
104 SC_THREAD(axi_read_r);
105 sensitive << clk.pos();
107
108 SC_THREAD(axi_write_aw);
109 sensitive << clk.pos();
111
112 SC_THREAD(axi_write_w);
113 sensitive << clk.pos();
115 }
116
117 private:
118 void axi_read_ar() {
119 axiM_read.ar.Reset();
120 axiS_read.ar.Reset();
121 #pragma hls_pipeline_init_interval 1
122 #pragma pipeline_stall_mode flush
123 while(1) {
124 wait();
125 if (axiM_read.ar.PopNB(AR)) {
126 axiS_read.ar.Push(BitsToType<typename axiS::AddrPayload>(TypeToBits(AR)));
127 }
128 }
129 }
130
131 void axi_read_r() {
132 axiM_read.r.Reset();
133 axiS_read.r.Reset();
134 #pragma hls_pipeline_init_interval 1
135 #pragma pipeline_stall_mode flush
136 while(1) {
137 wait();
138 if (axiS_read.r.PopNB(R)) {
139 axiM_read.r.Push(BitsToType<typename axiM::ReadPayload>(TypeToBits(R)));
140 }
141 }
142 }
143
144 void axi_write_aw() {
145 axiM_write.aw.Reset();
146 axiS_write.aw.Reset();
147 #pragma hls_pipeline_init_interval 1
148 #pragma pipeline_stall_mode flush
149 while(1) {
150 wait();
151 if (axiM_write.aw.PopNB(AW)) {
152 axiS_write.aw.Push(BitsToType<typename axiS::AddrPayload>(TypeToBits(AW)));
153 }
154 }
155 }
156
157 void axi_write_w() {
158 axiM_write.w.Reset();
159 axiS_write.w.Reset();
160 #pragma hls_pipeline_init_interval 1
161 #pragma pipeline_stall_mode flush
162 while(1) {
163 wait();
164 if (axiM_write.w.PopNB(W)) {
165 axiS_write.w.Push(BitsToType<typename axiS::WritePayload>(TypeToBits(W)));
166 }
167 }
168 }
169};
170
171
172#endif
A simple shim that converts between two AXI configs by adding write responses.
The base axi4 class parameterized according a valid config.
Definition axi4.h:64
sc_lv< Wrapped< T >::width > TypeToBits(T in)
Convert Type to logic vector.
Definition TypeToBits.h:48
#define NVHLS_NEG_RESET_SIGNAL_IS(port)
ENABLE_SYNC_RESET define: Select synchronous or asynchronous reset.
A struct composed of the signals associated with AXI read and write requests.
Definition axi4.h:114
A struct composed of the signals associated with an AXI read response.
Definition axi4.h:157
A struct composed of the signals associated with AXI write data.
Definition axi4.h:215