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