【问题标题】:Chisel: Why do I get a warning when output of Mux is of type SInt?Chisel:为什么当 Mux 的输出是 SInt 类型时我会收到警告?
【发布时间】:2017-02-05 09:27:57
【问题描述】:

代码编译正确,但我收到警告:

[warn] PC_RVI.scala:22: Mux of Bits instantiated, emits SInt in class TOP_pack.PC_RVI

给出警告的代码部分如下所示:

PC_input1 := Mux(io.branch, io.imme, UInt(4))
PC_input2 := Mux(io.PC_or_rs1, io.rs1, PC_reg)

其中immers1 的类型为SInt

【问题讨论】:

    标签: chisel


    【解决方案1】:

    您的所有信号都必须属于同一类型的 SInt。正如我们在给定的代码上看到的那样:

    PC_input1 := Mux(io.branch, io.imme, UInt(4))
    

    io.imme 是一个 SInt() 而 UInt(4) 不是。你的 PC_input1 是 SInt() 吗?

    如果您想避免警告,请对所有变量使用相同的类型。

    【讨论】:

    • 我已经使用 .toUInt 转换为整数,因为 PC_input 应该是 UInt 类型,现在警告消失了。谢谢。
    猜你喜欢
    • 2021-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-25
    • 1970-01-01
    相关资源
    最近更新 更多