2017-01-11 48 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 
    }