Enable on a 'complex' register

50 views
Skip to first unread message

Martin Schoeberl

unread,
Feb 25, 2013, 9:09:43 PM2/25/13
to chisel...@googlegroups.com
Hi all,

maybe this question is of general interest, so opting to the group.

I'm using a register, that has as input a Bundle (complex data structure).

val decReg = Reg(io.fedec)

Works fine. Now I would like to add an enable for this register and don't know
how to tell decReg what type it is. I don't care about the reset value and therefore
want to avoid defining that value for the 'complex' data structure io.fedec.

First try:

val decReg = Reg()
when (io.ena) {
decReg := io.fedec
}

complains about the missing argument for the contractor:
"missing arguments for method apply in object Reg;
follow this method with `_' if you want to treat it as a partially applied function"

Now doing some for me wild version (as I'm not really familiar with Scala):

val decReg = Reg()_
when (io.ena) {
decReg := io.fedec
}

That goes ok for the constructor, but I get a "reassignment to val
[error] decReg := io.fedec"

A naive try:

val decReg = Reg(io.fedec)
when (io.ena) {
decReg := io.fedec
}

does not work either. (Scala/Chisel compiles, but the generated C code not).

Cheers,
Martin

Martin Schoeberl

unread,
Feb 25, 2013, 9:24:14 PM2/25/13
to chisel...@googlegroups.com
After some more tinkering around I'm replying myself…
Should have found this out earlier.

One solution is:

val decReg = Reg(new FeDec())
when (io.ena) {
decReg := io.fedec
}

FeDec() is the data type (Bundle) of io.fedec.

Using the some trick with reset value works as well:

val decReg = Reg(resetVal = new FeDec())
when (io.ena) {
decReg := io.fedec
}

Cheers,
Martin
> --
> You received this message because you are subscribed to the Google Groups "chisel-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to chisel-users...@googlegroups.com.
> To post to this group, send email to chisel...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

Reply all
Reply to author
Forward
0 new messages