Using map and zipWithIndex methods in Vec class

255 views
Skip to first unread message

Arka Maity

unread,
Aug 3, 2015, 6:35:16 AM8/3/15
to chisel-users
Hi all,
          I have defined a val of Vec class as follows

           val addrOutVirtual = Vec.fill(4){Valid(UInt(width = 13))}

          Further into the code I try to assign values to it using two approaches

        addrOutVirtual.zipWithIndex.map(i => i._1.bits := io.addrIn.bits + UInt(i._2))          
        addrOutVirtual.zipWithIndex.map(i => i._1.valid := Bool(true))
 
         Alternatively I also used the following lines to achieve a similar result

         addrOutVirtual.map(i => i.bits := io.addrIn.bits + UInt(i))                             
         addrOutVirtual.map(i => i.valid := Bool(true))

         The methods looks the same to me, both of them compiles but the peek(c.addrOutVirtual) gives me different results, First one is the expected value while
          latter is an unexpected value. Can anyone explain the difference between the above two approaches ?

Sincerely yours
Arka

Nick Bandurin

unread,
Aug 3, 2015, 9:16:39 AM8/3/15
to chisel-users, arka.m...@gmail.com

addrOutVirtual.map(i => i.bits := io.addrIn.bits + UInt(i))

It is
the same as
: addrOutVirtual.map(i => i.bits := io.addrIn.bits + UInt(Cat(i.bits, i.valid, i.ready)))




понедельник, 3 августа 2015 г., 13:35:16 UTC+3 пользователь Arka Maity написал:

Nick Bandurin

unread,
Aug 3, 2015, 9:22:09 AM8/3/15
to chisel-users, arka.m...@gmail.com
I would have written differently:

addOutVirtual.zipWithIndex.foreach({ case(x,i) =>
  x.bits  := io.addrln.btis + UInt(i)
  x.valid :=Bool(true)
})

понедельник, 3 августа 2015 г., 13:35:16 UTC+3 пользователь Arka Maity написал:
Hi all,
Reply all
Reply to author
Forward
0 new messages