How to Initialize a Register of Vectors?

481 views
Skip to first unread message

Mahdi Nazemi

unread,
Apr 26, 2017, 7:57:19 PM4/26/17
to chisel-users
I have defined a register of vectors like this

    val my_reg = Reg(Vec(n, Bits(32.W)))

and I access the elements of this register in a for loop using `my_reg(i)`.

Now, I like to initialize this register to zero, so I change the variable definition to this

    val my_reg = Reg(Vec(n, Bits(32.W)), init = UInt(0))

However, I get the following compilation error when I want to access the elements of this register

    chisel3.core.Data does not take parameters
    my_reg(i) := io.a(i)

How can I define a register of vectors and properly initialize them synchronously?

ch...@berkeley.edu

unread,
Apr 27, 2017, 12:56:36 PM4/27/17
to chisel-users
Try 
val my_reg = RegInit(Vec(Seq.fill(n)(0.U(32.W)))
Reply all
Reply to author
Forward
0 new messages