在 chisel3 阐述中显示组件 ID 的机制是什么
What mechanism works to show component ID in chisel3 elaboration
Chisel 抛出异常并显示详细错误消息。下面以我的代码为例
chisel3.core.Binding$ExpectedHardwareException: data to be connected 'chisel3.core.Bool@81' must be hardware, not a bare Chisel type. Perhaps you forgot to wrap it in Wire(_) or IO(_)?
这个异常消息很有趣,因为 chisel3.core.Bool@
后面的 81
看起来像 ID,而不是哈希码。
实际上,数据类型扩展了具有 _id
字段的 HasId
特征,并且
_id
字段似乎为每个组件生成一个唯一的 ID。
我认为数据类型会覆盖 toString
以生成具有 type@ID
的字符串,但它不会覆盖。这就是下面代码中的 $node
不能使用 ID 的原因。
throw Binding.ExpectedHardwareException(s"$prefix'$node' must be hardware, " +
"not a bare Chisel type. Perhaps you forgot to wrap it in Wire(_) or IO(_)?")
数据中存在 toNamed
方法,而不是 toString
。不过调用这个方法好像是为了生成firrtl代码,而不是将component转成string。
为什么数据类型可以显示其ID?
如果不是ID,而是hashcode,这个问题是我的误会。
我觉得你应该看看 Chisel PR #985。它改变了 Data 的 toString 方法的实现方式。我不确定它是否直接回答了您的问题,但这可能会使错误的含义和位置更加清晰。如果不是,您应该对此发表评论。
Scala 类 带有默认的 toString 方法,其形式为 className@hashCode
.
如您所述,chisel3.core.Bool@81
确实看起来像是在使用 _id
而不是 hashCode
。那是因为在最近发布的 Chisel 版本 (3.1.6
) 中,哈希码就是 id!如果您检查该版本标记处的源文件,您可以看到这一点:https://github.com/freechipsproject/chisel3/blob/dc4200f8b622e637ec170dc0728c7887a7dbc566/chiselFrontend/src/main/scala/chisel3/internal/Builder.scala#L81
在 master
上不再是这种情况,这可能是任何混淆的根源!正如 Chick 指出的那样,我们刚刚更改了 .toString
方法,使其比默认方法提供更多信息;期待在 3.2.0
!
中提供更多信息
Chisel 抛出异常并显示详细错误消息。下面以我的代码为例
chisel3.core.Binding$ExpectedHardwareException: data to be connected 'chisel3.core.Bool@81' must be hardware, not a bare Chisel type. Perhaps you forgot to wrap it in Wire(_) or IO(_)?
这个异常消息很有趣,因为 chisel3.core.Bool@
后面的 81
看起来像 ID,而不是哈希码。
实际上,数据类型扩展了具有 _id
字段的 HasId
特征,并且
_id
字段似乎为每个组件生成一个唯一的 ID。
我认为数据类型会覆盖 toString
以生成具有 type@ID
的字符串,但它不会覆盖。这就是下面代码中的 $node
不能使用 ID 的原因。
throw Binding.ExpectedHardwareException(s"$prefix'$node' must be hardware, " +
"not a bare Chisel type. Perhaps you forgot to wrap it in Wire(_) or IO(_)?")
数据中存在 toNamed
方法,而不是 toString
。不过调用这个方法好像是为了生成firrtl代码,而不是将component转成string。
为什么数据类型可以显示其ID?
如果不是ID,而是hashcode,这个问题是我的误会。
我觉得你应该看看 Chisel PR #985。它改变了 Data 的 toString 方法的实现方式。我不确定它是否直接回答了您的问题,但这可能会使错误的含义和位置更加清晰。如果不是,您应该对此发表评论。
Scala 类 带有默认的 toString 方法,其形式为 className@hashCode
.
如您所述,chisel3.core.Bool@81
确实看起来像是在使用 _id
而不是 hashCode
。那是因为在最近发布的 Chisel 版本 (3.1.6
) 中,哈希码就是 id!如果您检查该版本标记处的源文件,您可以看到这一点:https://github.com/freechipsproject/chisel3/blob/dc4200f8b622e637ec170dc0728c7887a7dbc566/chiselFrontend/src/main/scala/chisel3/internal/Builder.scala#L81
在 master
上不再是这种情况,这可能是任何混淆的根源!正如 Chick 指出的那样,我们刚刚更改了 .toString
方法,使其比默认方法提供更多信息;期待在 3.2.0
!