1package utils 2 3import chisel3._ 4import chisel3.util._ 5import freechips.rocketchip.tilelink.TLMessages._ 6import freechips.rocketchip.tilelink.TLPermissions._ 7import freechips.rocketchip.tilelink.{TLBundle, TLBundleA, TLBundleB, TLBundleC, TLBundleD, TLBundleE, TLChannel} 8 9trait HasTLDump { 10 11 implicit class TLDump(channel: TLChannel) { 12 def dump = channel match { 13 case a: TLBundleA => 14 printChannelA(a) 15 case b: TLBundleB => 16 printChannelB(b) 17 case c: TLBundleC => 18 printChannelC(c) 19 case d: TLBundleD => 20 printChannelD(d) 21 case e: TLBundleE => 22 printChannelE(e) 23 } 24 } 25 26 def printChannelA(a: TLBundleA): Unit = { 27 switch(a.opcode) { 28 is(PutFullData) { 29 XSDebug(false, true.B, 30 a.channelName + " PutFullData param: %x size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 31 a.param, a.size, a.source, a.address, a.mask, a.data, a.corrupt 32 ) 33 } 34 35 is(PutPartialData) { 36 XSDebug(false, true.B, 37 a.channelName + " PutPartialData param: %x size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 38 a.param, a.size, a.source, a.address, a.mask, a.data, a.corrupt 39 ) 40 } 41 42 is(ArithmeticData) { 43 XSDebug(false, true.B, 44 a.channelName + " ArithmeticData param: %x size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 45 a.param, a.size, a.source, a.address, a.mask, a.data, a.corrupt 46 ) 47 } 48 49 is(LogicalData) { 50 XSDebug(false, true.B, 51 a.channelName + " LogicalData param: %x size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 52 a.param, a.size, a.source, a.address, a.mask, a.data, a.corrupt 53 ) 54 } 55 56 is(Get) { 57 XSDebug(false, true.B, 58 a.channelName + " Get param: %x size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 59 a.param, a.size, a.source, a.address, a.mask, a.data, a.corrupt 60 ) 61 } 62 63 is(Hint) { 64 XSDebug(false, true.B, 65 a.channelName + " Intent param: %x size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 66 a.param, a.size, a.source, a.address, a.mask, a.data, a.corrupt 67 ) 68 } 69 70 is(AcquireBlock) { 71 switch(a.param) { 72 is(NtoB) { 73 XSDebug(false, true.B, 74 a.channelName + " AcquireBlock NtoB size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 75 a.size, a.source, a.address, a.mask, a.data, a.corrupt 76 ) 77 } 78 is(NtoT) { 79 XSDebug(false, true.B, 80 a.channelName + " AcquireBlock NtoT size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 81 a.size, a.source, a.address, a.mask, a.data, a.corrupt 82 ) 83 } 84 is(BtoT) { 85 XSDebug(false, true.B, 86 a.channelName + " AcquireBlock BtoT size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 87 a.size, a.source, a.address, a.mask, a.data, a.corrupt 88 ) 89 } 90 } 91 } 92 93 is(AcquirePerm) { 94 switch(a.param) { 95 is(NtoB) { 96 XSDebug(false, true.B, 97 a.channelName + " AcquirePerm NtoB size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 98 a.size, a.source, a.address, a.mask, a.data, a.corrupt 99 ) 100 } 101 is(NtoT) { 102 XSDebug(false, true.B, 103 a.channelName + " AcquirePerm NtoT size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 104 a.size, a.source, a.address, a.mask, a.data, a.corrupt 105 ) 106 } 107 is(BtoT) { 108 XSDebug(false, true.B, 109 a.channelName + " AcquirePerm BtoT size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 110 a.size, a.source, a.address, a.mask, a.data, a.corrupt 111 ) 112 } 113 } 114 } 115 116 } 117 } 118 119 def printChannelB(b: TLBundleB): Unit = { 120 switch(b.opcode) { 121 is(PutFullData) { 122 XSDebug(false, true.B, 123 b.channelName + " PutFullData param: %x size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 124 b.param, b.size, b.source, b.address, b.mask, b.data, b.corrupt 125 ) 126 } 127 128 is(PutPartialData) { 129 XSDebug(false, true.B, 130 b.channelName + " PutPartialData param: %x size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 131 b.param, b.size, b.source, b.address, b.mask, b.data, b.corrupt 132 ) 133 } 134 135 is(ArithmeticData) { 136 XSDebug(false, true.B, 137 b.channelName + " ArithmeticData param: %x size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 138 b.param, b.size, b.source, b.address, b.mask, b.data, b.corrupt 139 ) 140 } 141 142 is(LogicalData) { 143 XSDebug(false, true.B, 144 b.channelName + " LogicalData param: %x size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 145 b.param, b.size, b.source, b.address, b.mask, b.data, b.corrupt 146 ) 147 } 148 149 is(Get) { 150 XSDebug(false, true.B, 151 b.channelName + " Get param: %x size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 152 b.param, b.size, b.source, b.address, b.mask, b.data, b.corrupt 153 ) 154 } 155 156 is(Hint) { 157 XSDebug(false, true.B, 158 b.channelName + " Intent param: %x size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 159 b.param, b.size, b.source, b.address, b.mask, b.data, b.corrupt 160 ) 161 } 162 163 is(Probe) { 164 switch(b.param) { 165 is(toN) { 166 XSDebug(false, true.B, 167 b.channelName + " Probe toN size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 168 b.size, b.source, b.address, b.mask, b.data, b.corrupt 169 ) 170 } 171 is(toB) { 172 XSDebug(false, true.B, 173 b.channelName + " Probe toB size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 174 b.size, b.source, b.address, b.mask, b.data, b.corrupt 175 ) 176 } 177 is(toT) { 178 XSDebug(false, true.B, 179 b.channelName + " Probe toT size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 180 b.size, b.source, b.address, b.mask, b.data, b.corrupt 181 ) 182 } 183 } 184 } 185 186 } 187 } 188 189 def printChannelC(c: TLBundleC): Unit = { 190 switch(c.opcode) { 191 is(AccessAck) { 192 XSDebug(false, true.B, 193 c.channelName + " AccessAck param: %x size: %x source: %d address: %x data: %x corrupt: %b\n", 194 c.param, c.size, c.source, c.address, c.data, c.corrupt 195 ) 196 } 197 198 is(AccessAckData) { 199 XSDebug(false, true.B, 200 c.channelName + " AccessAckData param: %x size: %x source: %d address: %x data: %x corrupt: %b\n", 201 c.param, c.size, c.source, c.address, c.data, c.corrupt 202 ) 203 } 204 205 is(HintAck) { 206 XSDebug(false, true.B, 207 c.channelName + " HintAck param: %x size: %x source: %d address: %x data: %x corrupt: %b\n", 208 c.param, c.size, c.source, c.address, c.data, c.corrupt 209 ) 210 } 211 212 is(ProbeAck) { 213 switch(c.param) { 214 is(TtoB) { 215 XSDebug(false, true.B, 216 c.channelName + " ProbeAck TtoB size: %x source: %d address: %x data: %x corrupt: %b\n", 217 c.size, c.source, c.address, c.data, c.corrupt 218 ) 219 } 220 is(TtoN) { 221 XSDebug(false, true.B, 222 c.channelName + " ProbeAck TtoN size: %x source: %d address: %x data: %x corrupt: %b\n", 223 c.size, c.source, c.address, c.data, c.corrupt 224 ) 225 } 226 is(BtoN) { 227 XSDebug(false, true.B, 228 c.channelName + " ProbeAck BtoN size: %x source: %d address: %x data: %x corrupt: %b\n", 229 c.size, c.source, c.address, c.data, c.corrupt 230 ) 231 } 232 is(TtoT) { 233 XSDebug(false, true.B, 234 c.channelName + " ProbeAck TtoT size: %x source: %d address: %x data: %x corrupt: %b\n", 235 c.size, c.source, c.address, c.data, c.corrupt 236 ) 237 } 238 is(BtoB) { 239 XSDebug(false, true.B, 240 c.channelName + " ProbeAck BtoB size: %x source: %d address: %x data: %x corrupt: %b\n", 241 c.size, c.source, c.address, c.data, c.corrupt 242 ) 243 } 244 is(NtoN) { 245 XSDebug(false, true.B, 246 c.channelName + " ProbeAck NtoN size: %x source: %d address: %x data: %x corrupt: %b\n", 247 c.size, c.source, c.address, c.data, c.corrupt 248 ) 249 } 250 } 251 } 252 253 is(ProbeAckData) { 254 switch(c.param) { 255 is(TtoB) { 256 XSDebug(false, true.B, 257 c.channelName + " ProbeAckData TtoB size: %x source: %d address: %x data: %x corrupt: %b\n", 258 c.size, c.source, c.address, c.data, c.corrupt 259 ) 260 } 261 is(TtoN) { 262 XSDebug(false, true.B, 263 c.channelName + " ProbeAckData TtoN size: %x source: %d address: %x data: %x corrupt: %b\n", 264 c.size, c.source, c.address, c.data, c.corrupt 265 ) 266 } 267 is(BtoN) { 268 XSDebug(false, true.B, 269 c.channelName + " ProbeAckData BtoN size: %x source: %d address: %x data: %x corrupt: %b\n", 270 c.size, c.source, c.address, c.data, c.corrupt 271 ) 272 } 273 is(TtoT) { 274 XSDebug(false, true.B, 275 c.channelName + " ProbeAckData TtoT size: %x source: %d address: %x data: %x corrupt: %b\n", 276 c.size, c.source, c.address, c.data, c.corrupt 277 ) 278 } 279 is(BtoB) { 280 XSDebug(false, true.B, 281 c.channelName + " ProbeAckData BtoB size: %x source: %d address: %x data: %x corrupt: %b\n", 282 c.size, c.source, c.address, c.data, c.corrupt 283 ) 284 } 285 is(NtoN) { 286 XSDebug(false, true.B, 287 c.channelName + " ProbeAckData NtoN size: %x source: %d address: %x data: %x corrupt: %b\n", 288 c.size, c.source, c.address, c.data, c.corrupt 289 ) 290 } 291 } 292 } 293 294 is(Release) { 295 switch(c.param) { 296 is(TtoB) { 297 XSDebug(false, true.B, 298 c.channelName + " Release TtoB size: %x source: %d address: %x data: %x corrupt: %b\n", 299 c.size, c.source, c.address, c.data, c.corrupt 300 ) 301 } 302 is(TtoN) { 303 XSDebug(false, true.B, 304 c.channelName + " Release TtoN size: %x source: %d address: %x data: %x corrupt: %b\n", 305 c.size, c.source, c.address, c.data, c.corrupt 306 ) 307 } 308 is(BtoN) { 309 XSDebug(false, true.B, 310 c.channelName + " Release BtoN size: %x source: %d address: %x data: %x corrupt: %b\n", 311 c.size, c.source, c.address, c.data, c.corrupt 312 ) 313 } 314 is(TtoT) { 315 XSDebug(false, true.B, 316 c.channelName + " Release TtoT size: %x source: %d address: %x data: %x corrupt: %b\n", 317 c.size, c.source, c.address, c.data, c.corrupt 318 ) 319 } 320 is(BtoB) { 321 XSDebug(false, true.B, 322 c.channelName + " Release BtoB size: %x source: %d address: %x data: %x corrupt: %b\n", 323 c.size, c.source, c.address, c.data, c.corrupt 324 ) 325 } 326 is(NtoN) { 327 XSDebug(false, true.B, 328 c.channelName + " Release NtoN size: %x source: %d address: %x data: %x corrupt: %b\n", 329 c.size, c.source, c.address, c.data, c.corrupt 330 ) 331 } 332 } 333 } 334 335 is(ReleaseData) { 336 switch(c.param) { 337 is(TtoB) { 338 XSDebug(false, true.B, 339 c.channelName + " ReleaseData TtoB size: %x source: %d address: %x data: %x corrupt: %b\n", 340 c.size, c.source, c.address, c.data, c.corrupt 341 ) 342 } 343 is(TtoN) { 344 XSDebug(false, true.B, 345 c.channelName + " ReleaseData TtoN size: %x source: %d address: %x data: %x corrupt: %b\n", 346 c.size, c.source, c.address, c.data, c.corrupt 347 ) 348 } 349 is(BtoN) { 350 XSDebug(false, true.B, 351 c.channelName + " ReleaseData BtoN size: %x source: %d address: %x data: %x corrupt: %b\n", 352 c.size, c.source, c.address, c.data, c.corrupt 353 ) 354 } 355 is(TtoT) { 356 XSDebug(false, true.B, 357 c.channelName + " ReleaseData TtoT size: %x source: %d address: %x data: %x corrupt: %b\n", 358 c.size, c.source, c.address, c.data, c.corrupt 359 ) 360 } 361 is(BtoB) { 362 XSDebug(false, true.B, 363 c.channelName + " ReleaseData BtoB size: %x source: %d address: %x data: %x corrupt: %b\n", 364 c.size, c.source, c.address, c.data, c.corrupt 365 ) 366 } 367 is(NtoN) { 368 XSDebug(false, true.B, 369 c.channelName + " ReleaseData NtoN size: %x source: %d address: %x data: %x corrupt: %b\n", 370 c.size, c.source, c.address, c.data, c.corrupt 371 ) 372 } 373 } 374 } 375 376 } 377 } 378 379 def printChannelD(d: TLBundleD): Unit = { 380 switch(d.opcode) { 381 is(AccessAck) { 382 XSDebug(false, true.B, 383 d.channelName + " AccessAck param: %x size: %x source: %d sink: %d denied: %b data: %x corrupt: %b\n", 384 d.param, d.size, d.source, d.sink, d.denied, d.data, d.corrupt 385 ) 386 } 387 388 is(AccessAckData) { 389 XSDebug(false, true.B, 390 d.channelName + " AccessAckData param: %x size: %x source: %d sink: %d denied: %b data: %x corrupt: %b\n", 391 d.param, d.size, d.source, d.sink, d.denied, d.data, d.corrupt 392 ) 393 } 394 395 is(HintAck) { 396 XSDebug(false, true.B, 397 d.channelName + " HintAck param: %x size: %x source: %d sink: %d denied: %b data: %x corrupt: %b\n", 398 d.param, d.size, d.source, d.sink, d.denied, d.data, d.corrupt 399 ) 400 } 401 402 is(Grant) { 403 switch(d.param) { 404 is(toT) { 405 XSDebug(false, true.B, 406 d.channelName + " Grant toT size: %x source: %d sink: %d denied: %b data: %x corrupt: %b\n", 407 d.size, d.source, d.sink, d.denied, d.data, d.corrupt 408 ) 409 } 410 is(toB) { 411 XSDebug(false, true.B, 412 d.channelName + " Grant toB size: %x source: %d sink: %d denied: %b data: %x corrupt: %b\n", 413 d.size, d.source, d.sink, d.denied, d.data, d.corrupt 414 ) 415 } 416 is(toN) { 417 XSDebug(false, true.B, 418 d.channelName + " Grant toN size: %x source: %d sink: %d denied: %b data: %x corrupt: %b\n", 419 d.size, d.source, d.sink, d.denied, d.data, d.corrupt 420 ) 421 } 422 } 423 } 424 425 is(GrantData) { 426 switch(d.param) { 427 is(toT) { 428 XSDebug(false, true.B, 429 d.channelName + " GrantData toT size: %x source: %d sink: %d denied: %b data: %x corrupt: %b\n", 430 d.size, d.source, d.sink, d.denied, d.data, d.corrupt 431 ) 432 } 433 is(toB) { 434 XSDebug(false, true.B, 435 d.channelName + " GrantData toB size: %x source: %d sink: %d denied: %b data: %x corrupt: %b\n", 436 d.size, d.source, d.sink, d.denied, d.data, d.corrupt 437 ) 438 } 439 is(toN) { 440 XSDebug(false, true.B, 441 d.channelName + " GrantData toN size: %x source: %d sink: %d denied: %b data: %x corrupt: %b\n", 442 d.size, d.source, d.sink, d.denied, d.data, d.corrupt 443 ) 444 } 445 } 446 } 447 448 is(ReleaseAck) { 449 XSDebug(false, true.B, 450 d.channelName + " ReleaseAck param: %x size: %x source: %d sink: %d denied: %b data: %x corrupt: %b\n", 451 d.param, d.size, d.source, d.sink, d.denied, d.data, d.corrupt 452 ) 453 } 454 455 } 456 } 457 458 def printChannelE(e: TLBundleE): Unit = { 459 XSDebug(false, true.B, e.channelName + "GrantAck sink: %d\n", e.sink) 460 } 461 462} 463