1/*************************************************************************************** 2* Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences 3* Copyright (c) 2020-2021 Peng Cheng Laboratory 4* 5* XiangShan is licensed under Mulan PSL v2. 6* You can use this software according to the terms and conditions of the Mulan PSL v2. 7* You may obtain a copy of Mulan PSL v2 at: 8* http://license.coscl.org.cn/MulanPSL2 9* 10* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 11* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 12* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 13* 14* See the Mulan PSL v2 for more details. 15***************************************************************************************/ 16 17package utils 18 19import org.chipsalliance.cde.config.Parameters 20import chisel3._ 21import chisel3.util._ 22import freechips.rocketchip.tilelink.TLMessages._ 23import freechips.rocketchip.tilelink.TLPermissions._ 24import freechips.rocketchip.tilelink.{TLBundle, TLBundleA, TLBundleB, TLBundleC, TLBundleD, TLBundleE, TLChannel} 25import utility.XSDebug 26 27trait HasTLDump { 28 29 implicit val p: Parameters 30 31 implicit class TLDump(channel: TLChannel) { 32 def dump = channel match { 33 case a: TLBundleA => 34 printChannelA(a) 35 case b: TLBundleB => 36 printChannelB(b) 37 case c: TLBundleC => 38 printChannelC(c) 39 case d: TLBundleD => 40 printChannelD(d) 41 case e: TLBundleE => 42 printChannelE(e) 43 } 44 } 45 46 def printChannelA(a: TLBundleA): Unit = { 47 switch(a.opcode) { 48 is(PutFullData) { 49 XSDebug(false, true.B, 50 a.channelName + " PutFullData param: %x size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 51 a.param, a.size, a.source, a.address, a.mask, a.data, a.corrupt 52 ) 53 } 54 55 is(PutPartialData) { 56 XSDebug(false, true.B, 57 a.channelName + " PutPartialData param: %x size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 58 a.param, a.size, a.source, a.address, a.mask, a.data, a.corrupt 59 ) 60 } 61 62 is(ArithmeticData) { 63 XSDebug(false, true.B, 64 a.channelName + " ArithmeticData param: %x size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 65 a.param, a.size, a.source, a.address, a.mask, a.data, a.corrupt 66 ) 67 } 68 69 is(LogicalData) { 70 XSDebug(false, true.B, 71 a.channelName + " LogicalData param: %x size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 72 a.param, a.size, a.source, a.address, a.mask, a.data, a.corrupt 73 ) 74 } 75 76 is(Get) { 77 XSDebug(false, true.B, 78 a.channelName + " Get param: %x size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 79 a.param, a.size, a.source, a.address, a.mask, a.data, a.corrupt 80 ) 81 } 82 83 is(Hint) { 84 XSDebug(false, true.B, 85 a.channelName + " Intent param: %x size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 86 a.param, a.size, a.source, a.address, a.mask, a.data, a.corrupt 87 ) 88 } 89 90 is(AcquireBlock) { 91 switch(a.param) { 92 is(NtoB) { 93 XSDebug(false, true.B, 94 a.channelName + " AcquireBlock NtoB size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 95 a.size, a.source, a.address, a.mask, a.data, a.corrupt 96 ) 97 } 98 is(NtoT) { 99 XSDebug(false, true.B, 100 a.channelName + " AcquireBlock NtoT size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 101 a.size, a.source, a.address, a.mask, a.data, a.corrupt 102 ) 103 } 104 is(BtoT) { 105 XSDebug(false, true.B, 106 a.channelName + " AcquireBlock BtoT size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 107 a.size, a.source, a.address, a.mask, a.data, a.corrupt 108 ) 109 } 110 } 111 } 112 113 is(AcquirePerm) { 114 switch(a.param) { 115 is(NtoB) { 116 XSDebug(false, true.B, 117 a.channelName + " AcquirePerm NtoB size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 118 a.size, a.source, a.address, a.mask, a.data, a.corrupt 119 ) 120 } 121 is(NtoT) { 122 XSDebug(false, true.B, 123 a.channelName + " AcquirePerm NtoT size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 124 a.size, a.source, a.address, a.mask, a.data, a.corrupt 125 ) 126 } 127 is(BtoT) { 128 XSDebug(false, true.B, 129 a.channelName + " AcquirePerm BtoT size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 130 a.size, a.source, a.address, a.mask, a.data, a.corrupt 131 ) 132 } 133 } 134 } 135 136 } 137 } 138 139 def printChannelB(b: TLBundleB): Unit = { 140 switch(b.opcode) { 141 is(PutFullData) { 142 XSDebug(false, true.B, 143 b.channelName + " PutFullData param: %x size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 144 b.param, b.size, b.source, b.address, b.mask, b.data, b.corrupt 145 ) 146 } 147 148 is(PutPartialData) { 149 XSDebug(false, true.B, 150 b.channelName + " PutPartialData param: %x size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 151 b.param, b.size, b.source, b.address, b.mask, b.data, b.corrupt 152 ) 153 } 154 155 is(ArithmeticData) { 156 XSDebug(false, true.B, 157 b.channelName + " ArithmeticData param: %x size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 158 b.param, b.size, b.source, b.address, b.mask, b.data, b.corrupt 159 ) 160 } 161 162 is(LogicalData) { 163 XSDebug(false, true.B, 164 b.channelName + " LogicalData param: %x size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 165 b.param, b.size, b.source, b.address, b.mask, b.data, b.corrupt 166 ) 167 } 168 169 is(Get) { 170 XSDebug(false, true.B, 171 b.channelName + " Get param: %x size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 172 b.param, b.size, b.source, b.address, b.mask, b.data, b.corrupt 173 ) 174 } 175 176 is(Hint) { 177 XSDebug(false, true.B, 178 b.channelName + " Intent param: %x size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 179 b.param, b.size, b.source, b.address, b.mask, b.data, b.corrupt 180 ) 181 } 182 183 is(Probe) { 184 switch(b.param) { 185 is(toN) { 186 XSDebug(false, true.B, 187 b.channelName + " Probe toN size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 188 b.size, b.source, b.address, b.mask, b.data, b.corrupt 189 ) 190 } 191 is(toB) { 192 XSDebug(false, true.B, 193 b.channelName + " Probe toB size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 194 b.size, b.source, b.address, b.mask, b.data, b.corrupt 195 ) 196 } 197 is(toT) { 198 XSDebug(false, true.B, 199 b.channelName + " Probe toT size: %x source: %d address: %x mask: %x data: %x corrupt: %b\n", 200 b.size, b.source, b.address, b.mask, b.data, b.corrupt 201 ) 202 } 203 } 204 } 205 206 } 207 } 208 209 def printChannelC(c: TLBundleC): Unit = { 210 switch(c.opcode) { 211 is(AccessAck) { 212 XSDebug(false, true.B, 213 c.channelName + " AccessAck param: %x size: %x source: %d address: %x data: %x corrupt: %b\n", 214 c.param, c.size, c.source, c.address, c.data, c.corrupt 215 ) 216 } 217 218 is(AccessAckData) { 219 XSDebug(false, true.B, 220 c.channelName + " AccessAckData param: %x size: %x source: %d address: %x data: %x corrupt: %b\n", 221 c.param, c.size, c.source, c.address, c.data, c.corrupt 222 ) 223 } 224 225 is(HintAck) { 226 XSDebug(false, true.B, 227 c.channelName + " HintAck param: %x size: %x source: %d address: %x data: %x corrupt: %b\n", 228 c.param, c.size, c.source, c.address, c.data, c.corrupt 229 ) 230 } 231 232 is(ProbeAck) { 233 switch(c.param) { 234 is(TtoB) { 235 XSDebug(false, true.B, 236 c.channelName + " ProbeAck TtoB 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(TtoN) { 241 XSDebug(false, true.B, 242 c.channelName + " ProbeAck TtoN 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(BtoN) { 247 XSDebug(false, true.B, 248 c.channelName + " ProbeAck BtoN 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 is(TtoT) { 253 XSDebug(false, true.B, 254 c.channelName + " ProbeAck TtoT size: %x source: %d address: %x data: %x corrupt: %b\n", 255 c.size, c.source, c.address, c.data, c.corrupt 256 ) 257 } 258 is(BtoB) { 259 XSDebug(false, true.B, 260 c.channelName + " ProbeAck BtoB size: %x source: %d address: %x data: %x corrupt: %b\n", 261 c.size, c.source, c.address, c.data, c.corrupt 262 ) 263 } 264 is(NtoN) { 265 XSDebug(false, true.B, 266 c.channelName + " ProbeAck NtoN size: %x source: %d address: %x data: %x corrupt: %b\n", 267 c.size, c.source, c.address, c.data, c.corrupt 268 ) 269 } 270 } 271 } 272 273 is(ProbeAckData) { 274 switch(c.param) { 275 is(TtoB) { 276 XSDebug(false, true.B, 277 c.channelName + " ProbeAckData TtoB 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(TtoN) { 282 XSDebug(false, true.B, 283 c.channelName + " ProbeAckData TtoN 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(BtoN) { 288 XSDebug(false, true.B, 289 c.channelName + " ProbeAckData BtoN 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 is(TtoT) { 294 XSDebug(false, true.B, 295 c.channelName + " ProbeAckData TtoT size: %x source: %d address: %x data: %x corrupt: %b\n", 296 c.size, c.source, c.address, c.data, c.corrupt 297 ) 298 } 299 is(BtoB) { 300 XSDebug(false, true.B, 301 c.channelName + " ProbeAckData BtoB size: %x source: %d address: %x data: %x corrupt: %b\n", 302 c.size, c.source, c.address, c.data, c.corrupt 303 ) 304 } 305 is(NtoN) { 306 XSDebug(false, true.B, 307 c.channelName + " ProbeAckData NtoN size: %x source: %d address: %x data: %x corrupt: %b\n", 308 c.size, c.source, c.address, c.data, c.corrupt 309 ) 310 } 311 } 312 } 313 314 is(Release) { 315 switch(c.param) { 316 is(TtoB) { 317 XSDebug(false, true.B, 318 c.channelName + " Release TtoB 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(TtoN) { 323 XSDebug(false, true.B, 324 c.channelName + " Release TtoN 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(BtoN) { 329 XSDebug(false, true.B, 330 c.channelName + " Release BtoN 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 is(TtoT) { 335 XSDebug(false, true.B, 336 c.channelName + " Release TtoT size: %x source: %d address: %x data: %x corrupt: %b\n", 337 c.size, c.source, c.address, c.data, c.corrupt 338 ) 339 } 340 is(BtoB) { 341 XSDebug(false, true.B, 342 c.channelName + " Release BtoB size: %x source: %d address: %x data: %x corrupt: %b\n", 343 c.size, c.source, c.address, c.data, c.corrupt 344 ) 345 } 346 is(NtoN) { 347 XSDebug(false, true.B, 348 c.channelName + " Release NtoN size: %x source: %d address: %x data: %x corrupt: %b\n", 349 c.size, c.source, c.address, c.data, c.corrupt 350 ) 351 } 352 } 353 } 354 355 is(ReleaseData) { 356 switch(c.param) { 357 is(TtoB) { 358 XSDebug(false, true.B, 359 c.channelName + " ReleaseData TtoB 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(TtoN) { 364 XSDebug(false, true.B, 365 c.channelName + " ReleaseData TtoN 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(BtoN) { 370 XSDebug(false, true.B, 371 c.channelName + " ReleaseData BtoN 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 is(TtoT) { 376 XSDebug(false, true.B, 377 c.channelName + " ReleaseData TtoT size: %x source: %d address: %x data: %x corrupt: %b\n", 378 c.size, c.source, c.address, c.data, c.corrupt 379 ) 380 } 381 is(BtoB) { 382 XSDebug(false, true.B, 383 c.channelName + " ReleaseData BtoB size: %x source: %d address: %x data: %x corrupt: %b\n", 384 c.size, c.source, c.address, c.data, c.corrupt 385 ) 386 } 387 is(NtoN) { 388 XSDebug(false, true.B, 389 c.channelName + " ReleaseData NtoN size: %x source: %d address: %x data: %x corrupt: %b\n", 390 c.size, c.source, c.address, c.data, c.corrupt 391 ) 392 } 393 } 394 } 395 396 } 397 } 398 399 def printChannelD(d: TLBundleD): Unit = { 400 switch(d.opcode) { 401 is(AccessAck) { 402 XSDebug(false, true.B, 403 d.channelName + " AccessAck param: %x size: %x source: %d sink: %d denied: %b data: %x corrupt: %b\n", 404 d.param, d.size, d.source, d.sink, d.denied, d.data, d.corrupt 405 ) 406 } 407 408 is(AccessAckData) { 409 XSDebug(false, true.B, 410 d.channelName + " AccessAckData param: %x size: %x source: %d sink: %d denied: %b data: %x corrupt: %b\n", 411 d.param, d.size, d.source, d.sink, d.denied, d.data, d.corrupt 412 ) 413 } 414 415 is(HintAck) { 416 XSDebug(false, true.B, 417 d.channelName + " HintAck param: %x size: %x source: %d sink: %d denied: %b data: %x corrupt: %b\n", 418 d.param, d.size, d.source, d.sink, d.denied, d.data, d.corrupt 419 ) 420 } 421 422 is(Grant) { 423 switch(d.param) { 424 is(toT) { 425 XSDebug(false, true.B, 426 d.channelName + " Grant toT size: %x source: %d sink: %d denied: %b data: %x corrupt: %b\n", 427 d.size, d.source, d.sink, d.denied, d.data, d.corrupt 428 ) 429 } 430 is(toB) { 431 XSDebug(false, true.B, 432 d.channelName + " Grant toB size: %x source: %d sink: %d denied: %b data: %x corrupt: %b\n", 433 d.size, d.source, d.sink, d.denied, d.data, d.corrupt 434 ) 435 } 436 is(toN) { 437 XSDebug(false, true.B, 438 d.channelName + " Grant toN size: %x source: %d sink: %d denied: %b data: %x corrupt: %b\n", 439 d.size, d.source, d.sink, d.denied, d.data, d.corrupt 440 ) 441 } 442 } 443 } 444 445 is(GrantData) { 446 switch(d.param) { 447 is(toT) { 448 XSDebug(false, true.B, 449 d.channelName + " GrantData toT size: %x source: %d sink: %d denied: %b data: %x corrupt: %b\n", 450 d.size, d.source, d.sink, d.denied, d.data, d.corrupt 451 ) 452 } 453 is(toB) { 454 XSDebug(false, true.B, 455 d.channelName + " GrantData toB size: %x source: %d sink: %d denied: %b data: %x corrupt: %b\n", 456 d.size, d.source, d.sink, d.denied, d.data, d.corrupt 457 ) 458 } 459 is(toN) { 460 XSDebug(false, true.B, 461 d.channelName + " GrantData toN size: %x source: %d sink: %d denied: %b data: %x corrupt: %b\n", 462 d.size, d.source, d.sink, d.denied, d.data, d.corrupt 463 ) 464 } 465 } 466 } 467 468 is(ReleaseAck) { 469 XSDebug(false, true.B, 470 d.channelName + " ReleaseAck param: %x size: %x source: %d sink: %d denied: %b data: %x corrupt: %b\n", 471 d.param, d.size, d.source, d.sink, d.denied, d.data, d.corrupt 472 ) 473 } 474 475 } 476 } 477 478 def printChannelE(e: TLBundleE): Unit = { 479 XSDebug(false, true.B, e.channelName + "GrantAck sink: %d\n", e.sink) 480 } 481 482} 483