简体   繁体   English

有没有办法使模块范围内未定义的 Chisel 信号在波形中可见?

[英]Is there a way to make signals in Chisel not defined at module scope visible in waveforms?

If we take for example the following code excerpt (at the top of a module):如果我们以以下代码摘录为例(在模块的顶部):

val write_indices = WireInit(VecInit(Seq.fill(wordsPerBeat)(0.U((log2Ceil(nWays)+log2Ceil(nSets)+log2Ceil(cacheBlockBytes/wordBytes)).W))))
val write_line_indices = WireInit(VecInit(Seq.fill(wordsPerBeat)(0.U(log2Ceil(cacheBlockBytes/wordBytes).W))))
dontTouch(write_indices)
dontTouch(write_line_indices)
// refill logic
when(mem_response_present) {
  for (i <- 0 until wordsPerBeat) {
    val beatIdx = i.U(log2Ceil(wordsPerBeat).W)
    val write_line_index = Cat(d_refill_cnt(log2Ceil(cacheBlockBytes/wordsPerBeat/wordBytes)-1, 0), beatIdx)
    val write_idx = Cat(refill_way, refill_set, write_line_index)
    write_indices(i) := write_idx
    write_line_indices(i) := write_line_index
    cache_line(write_idx) := tl_out.d.bits.data((i + 1) * wordBits - 1, i * wordBits)
  }
}

The only reason for the two top level signals is to get lower signals visible in waveforms.两个顶级信号的唯一原因是让较低的信号在波形中可见。 Is there any way to achieve the same effect without having to manually create those signals?有没有什么方法可以达到相同的效果而不必手动创建这些信号? In this example half the code is used just to get the ability to debug.在这个例子中,一半的代码只是为了获得调试能力。 That seems a bit excessive.这似乎有点过分了。

That seems a bit excessive这似乎有点过分

Completely agreed, fortunately there is a solution.完全同意,幸好有解决办法。 For implementation reasons, Chisel by default is only able to name public fields of the Module class.出于实现原因,默认情况下Chisel 只能命名 Module 类的公共字段。 That is, only the values at the the top-level scope of your Module.也就是说,只有模块顶级范围内的值。 However, there is a nifty macro chisel3.experimental.chiselName that can name these vals inside of the for loop.但是,有一个漂亮的宏chisel3.experimental.chiselName可以for循环内命名这些chisel3.experimental.chiselName Try annotating your Module like so:尝试像这样注释你的模块:

import chisel3._
import chisel3.experimental.chiselName

@chiselName
class MyModule extends Module {
  ...
}

Please check out this earlier answer discussing naming , it has more information than is relevant to answer this question alone, but it has other useful information about how naming works in Chisel.请查看之前讨论命名的答案,它包含的信息比单独回答这个问题的相关信息要多,但它还有其他关于命名如何在 Chisel 中工作的有用信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM