17 #ifndef _BUS_TILELINK_SIGNAL_IF_H_
18 #define _BUS_TILELINK_SIGNAL_IF_H_
20 #include <scc/signal_opt_ports.h>
25 const sc_core::sc_time CLK_DELAY = 1_ps;
28 template <
typename T>
using m2s_t = sc_core::sc_out<T>;
29 template <
typename T>
using s2m_t = sc_core::sc_in<T>;
30 template <
typename T>
using m2s_full_t = sc_core::sc_out<T>;
31 template <
typename T>
using s2m_full_t = sc_core::sc_in<T>;
37 template <
typename T>
using m2s_t = sc_core::sc_in<T>;
38 template <
typename T>
using s2m_t = sc_core::sc_out<T>;
39 template <
typename T>
using m2s_full_t = sc_core::sc_in<T>;
40 template <
typename T>
using s2m_full_t = sc_core::sc_out<T>;
46 template <
typename T>
using m2s_t = sc_core::sc_signal<T>;
47 template <
typename T>
using s2m_t = sc_core::sc_signal<T>;
48 template <
typename T>
using m2s_full_t = sc_core::sc_signal<T>;
49 template <
typename T>
using s2m_full_t = sc_core::sc_signal<T>;
50 template <
typename T>
using m2s_opt_t = sc_core::sc_signal<T>;
51 template <
typename T>
using s2m_opt_t = sc_core::sc_signal<T>;
54 template <
bool Cond,
class T,
class S>
struct select_if {
typedef S type; };
56 template <
class T,
class S>
struct select_if<true, T, S> {
typedef T type; };
68 template <
unsigned int W = 32,
unsigned int A = 32,
unsigned int Z = 32,
unsigned int O = 1,
unsigned int I = 3>
struct tl_cfg {
70 static_assert(W > 0,
"W shall be larger than 0");
71 static_assert(W <= 4096,
"W shall be less than or equal 4096");
73 static_assert(A >= 0,
"A shall be larger than or equal 0");
74 static_assert(A <= 128,
"A shall be less than or equal 128");
75 static_assert(Z > 0,
"Z shall be larger than 0");
76 static_assert(Z < 5,
"Z shall be less than or equal 4");
77 static_assert(O >= 0,
"O shall be larger than or equal 0");
78 static_assert(O <= 64,
"O shall be less than or equal 64");
79 static_assert(I >= 0,
"I shall be larger than or equal 0");
80 static_assert(I <= 64,
"I shall be less than or equal 64");
81 constexpr
static unsigned int BUSWIDTH = 8 * W;
82 constexpr
static unsigned int MASKWIDTH = W;
83 constexpr
static unsigned int ADDRWIDTH = A;
84 constexpr
static unsigned int SZWIDTH = Z;
85 constexpr
static unsigned int MIDWIDTH = O;
86 constexpr
static unsigned int SIDWIDTH = I;
89 using data_t =
typename select_if<(8 * W) <= 64, sc_dt::sc_uint<BUSWIDTH>, sc_dt::sc_biguint<BUSWIDTH>>::type;
94 inline std::string concat(
const char* prefix,
const char* name) {
return std::string(prefix) + name; }
97 template <
typename CFG,
typename TYPES = master_types>
struct ch_a {
98 typename TYPES::template m2s_t<sc_dt::sc_uint<3>> code{
"code"};
99 typename TYPES::template m2s_t<sc_dt::sc_uint<3>> param{
"param"};
100 typename TYPES::template m2s_t<sc_dt::sc_uint<CFG::SZWIDTH>> size{
"size"};
101 typename TYPES::template m2s_t<sc_dt::sc_uint<CFG::MIDWIDTH>> source{
"source"};
102 typename TYPES::template m2s_t<CFG::addr_t> address{
"address"};
103 typename TYPES::template m2s_t<CFG::mask_t> mask{
"mask"};
104 typename TYPES::template m2s_t<CFG::data_t> data{
"data"};
105 typename TYPES::template s2m_t<bool> corrupt{
"corrupt"};
106 typename TYPES::template m2s_t<bool> valid{
"valid"};
107 typename TYPES::template s2m_t<bool> ready{
"ready"};
110 ch_a(
const char* prefix)
111 : code{concat(prefix,
"_code").c_str()}
112 , param{concat(prefix,
"_param").c_str()}
113 , size{concat(prefix,
"_size").c_str()}
114 , source{concat(prefix,
"_source").c_str()}
115 , address{concat(prefix,
"_address").c_str()}
116 , mask{concat(prefix,
"_mask").c_str()}
117 , data{concat(prefix,
"_data").c_str()}
118 , corrupt{concat(prefix,
"_corrupt").c_str()}
119 , valid{concat(prefix,
"_valid").c_str()}
120 , ready{concat(prefix,
"_ready").c_str()} {}
126 source.bind(o.source);
127 address.bind(o.address);
130 corrupt.bind(o.corrupt);
137 template <
typename CFG,
typename TYPES = master_types>
struct ch_b {
138 typename TYPES::template s2m_t<sc_dt::sc_uint<3>> code{
"code"};
139 typename TYPES::template s2m_t<sc_dt::sc_uint<3>> param{
"param"};
140 typename TYPES::template s2m_t<sc_dt::sc_uint<CFG::SZWIDTH>> size{
"size"};
141 typename TYPES::template s2m_t<sc_dt::sc_uint<CFG::MIDWIDTH>> source{
"source"};
142 typename TYPES::template s2m_t<CFG::addr_t> address{
"address"};
143 typename TYPES::template s2m_t<CFG::mask_t> mask{
"mask"};
144 typename TYPES::template s2m_t<CFG::data_t> data{
"data"};
145 typename TYPES::template m2s_t<bool> corrupt{
"corrupt"};
146 typename TYPES::template s2m_t<bool> valid{
"valid"};
147 typename TYPES::template m2s_t<bool> ready{
"ready"};
150 ch_b(
const char* prefix)
151 : code{concat(prefix,
"_code").c_str()}
152 , param{concat(prefix,
"_param").c_str()}
153 , size{concat(prefix,
"_size").c_str()}
154 , source{concat(prefix,
"_source").c_str()}
155 , address{concat(prefix,
"_address").c_str()}
156 , mask{concat(prefix,
"_mask").c_str()}
157 , data{concat(prefix,
"_data").c_str()}
158 , corrupt{concat(prefix,
"_corrupt").c_str()}
159 , valid{concat(prefix,
"_valid").c_str()}
160 , ready{concat(prefix,
"_ready").c_str()} {}
166 source.bind(o.source);
167 address.bind(o.address);
170 corrupt.bind(o.corrupt);
177 template <
typename CFG,
typename TYPES = master_types>
struct ch_c {
178 typename TYPES::template m2s_t<sc_dt::sc_uint<3>> code{
"code"};
179 typename TYPES::template m2s_t<sc_dt::sc_uint<3>> param{
"param"};
180 typename TYPES::template m2s_t<sc_dt::sc_uint<CFG::SZWIDTH>> size{
"size"};
181 typename TYPES::template m2s_t<sc_dt::sc_uint<CFG::MIDWIDTH>> source{
"source"};
182 typename TYPES::template m2s_t<CFG::addr_t> address{
"address"};
183 typename TYPES::template m2s_t<CFG::data_t> data{
"data"};
184 typename TYPES::template s2m_t<bool> corrupt{
"corrupt"};
185 typename TYPES::template m2s_t<bool> valid{
"valid"};
186 typename TYPES::template s2m_t<bool> ready{
"ready"};
189 ch_c(
const char* prefix)
190 : code{concat(prefix,
"_code").c_str()}
191 , param{concat(prefix,
"_param").c_str()}
192 , size{concat(prefix,
"_size").c_str()}
193 , source{concat(prefix,
"_source").c_str()}
194 , address{concat(prefix,
"_address").c_str()}
195 , data{concat(prefix,
"_data").c_str()}
196 , corrupt{concat(prefix,
"_corrupt").c_str()}
197 , valid{concat(prefix,
"_valid").c_str()}
198 , ready{concat(prefix,
"_ready").c_str()} {}
204 source.bind(o.source);
205 address.bind(o.address);
207 corrupt.bind(o.corrupt);
214 template <
typename CFG,
typename TYPES = master_types>
struct ch_d {
215 typename TYPES::template s2m_t<sc_dt::sc_uint<3>> code{
"code"};
216 typename TYPES::template s2m_t<sc_dt::sc_uint<2>> param{
"param"};
217 typename TYPES::template s2m_t<sc_dt::sc_uint<CFG::SZWIDTH>> size{
"size"};
218 typename TYPES::template s2m_t<sc_dt::sc_uint<CFG::MIDWIDTH>> source{
"source"};
219 typename TYPES::template s2m_t<sc_dt::sc_uint<CFG::SIDWIDTH>> sink{
"sink"};
220 typename TYPES::template m2s_t<bool> denied{
"denied"};
221 typename TYPES::template s2m_t<CFG::data_t> data{
"data"};
222 typename TYPES::template m2s_t<bool> corrupt{
"corrupt"};
223 typename TYPES::template s2m_t<bool> valid{
"valid"};
224 typename TYPES::template m2s_t<bool> ready{
"ready"};
227 ch_d(
const char* prefix)
228 : code{concat(prefix,
"_code").c_str()}
229 , param{concat(prefix,
"_param").c_str()}
230 , size{concat(prefix,
"_size").c_str()}
231 , source{concat(prefix,
"_source").c_str()}
232 , sink{concat(prefix,
"_sink").c_str()}
233 , denied{concat(prefix,
"_denied").c_str()}
234 , data{concat(prefix,
"_data").c_str()}
235 , corrupt{concat(prefix,
"_corrupt").c_str()}
236 , valid{concat(prefix,
"_valid").c_str()}
237 , ready{concat(prefix,
"_ready").c_str()} {}
243 source.bind(o.source);
245 denied.bind(o.denied);
247 corrupt.bind(o.corrupt);
254 template <
typename CFG,
typename TYPES = master_types>
struct ch_e {
255 typename TYPES::template m2s_t<sc_dt::sc_uint<CFG::SIDWIDTH>> sink{
"sink"};
256 typename TYPES::template m2s_t<bool> valid{
"valid"};
257 typename TYPES::template s2m_t<bool> ready{
"ready"};
260 ch_e(
const char* prefix)
261 : sink{concat(prefix,
"_sink").c_str()}
262 , valid{concat(prefix,
"_valid").c_str()}
263 , ready{concat(prefix,
"_ready").c_str()} {}
272 template <
typename CFG,
typename TYPES = master_types>
struct tl_ul :
public ch_a<CFG, TYPES>,
public ch_d<CFG, TYPES> {
276 tl_ul(
const char* prefix)
287 template <
typename CFG,
typename TYPES = master_types>
288 struct tl_c :
public ch_a<CFG, TYPES>,
public ch_b<CFG, TYPES>,
public ch_c<CFG, TYPES>,
public ch_d<CFG, TYPES>,
public ch_e<CFG, TYPES> {
295 tl_c(
const char* prefix)
TLM2.0 components modeling APB.