2017-01-11 122 views
2

有人能告诉我为什么下面的代码不会在凿子中详细说明吗?看起来我无法分配给UInt中的各个位。这是设计吗?凿子分配给UInt的个别位

我没有看到杰克对类似问题的回应,但以下类型的逻辑跨越位的逻辑是常见的,并且很容易在SV等参数化。我可以看到创建了Bools矢量以及各个位,但还是如何重新进入一个UINT问题...

def ffo(pwidth:Int, in:UInt) : UInt = { 
    val rval = Wire(UInt(width=pwidth)) 
    rval(0) := in(0) 
    for(w <- 1 until pwidth) { 
     rval(w) := in(w) & !(in(w-1,0).orR()) 
    } 
    rval 
    } 

结果:

firrtl.passes.CheckGenders$WrongGender: @[Misc.scala 21:13:@5808.4]: [module IuIrRename] Expression T_1824 is used as a FEMALE but can only be used as a MALE. 
firrtl.passes.CheckGenders$WrongGender: @[Misc.scala 23:15:@5815.4]: [module IuIrRename] Expression T_1826 is used as a FEMALE but can only be used as a MALE. 
firrtl.passes.CheckGenders$WrongGender: @[Misc.scala 23:15:@5822.4]: [module IuIrRename] Expression T_1834 is used as a FEMALE but can only be used as a MALE. 
firrtl.passes.CheckGenders$WrongGender: @[Misc.scala 23:15:@5829.4]: [module IuIrRename] Expression T_1842 is used as a FEMALE but can only be used as a MALE. 
firrtl.passes.CheckGenders$WrongGender: @[Misc.scala 21:13:@5834.4]: [module IuIrRename] Expression T_1851 is used as a FEMALE but can only be used as a MALE. 

回答

1

继续实验(并查看生成的Verilog后)下面的代码就相当于后我在找什么:

def ffo(pwidth:Int, in:UInt) : UInt = { 
    val ary = Wire(Vec(pwidth, Bool())) 
    ary(0) := in(0) 
    for(w <- 1 until pwidth) { 
     ary(w) := in(w) && !(in(w-1,0).orR()) 
    } 
    val rval = Reverse(Cat(ary)) 
    rval 
    }