Strategy to concat Vec objects

491 views
Skip to first unread message

edm...@edmondcote.com

unread,
Sep 6, 2018, 2:44:57 PM9/6/18
to chisel-users
Believe that this question was asked before, but to no avail: https://stackoverflow.com/questions/51437942/chisel-concatenation-error

Can anyone think of a better strategy to concatenate two Vec objects?  Other than using generators that is, e.g.:

val storeTableWalkerRequest: Vec[Bool] = Wire(Vec(NumStorePorts, Bool()))

val loadTableWalkerRequest: Vec[Bool] = Wire(Vec(NumLoadPorts, Bool()))

// Concatenate all request vectors

val tableWalkerRequests: Vec[Bool] = Wire(Vec(NumStorePorts + NumLoadPorts, Bool()))

for (i <- 0 until NumStorePorts) {
  tableWalkerRequests(i) := storeTableWalkerRequest(i)
}

for (i <- NumStorePorts until NumStorePorts + NumLoadPorts) {
  tableWalkerRequests(i) := loadTableWalkerRequest(i - NumStorePorts)
}

Andrew Waterman

unread,
Sep 6, 2018, 2:47:50 PM9/6/18
to chisel...@googlegroups.com
Perhaps something like: VecInit((storeTableWalkerRequest ++ loadTableWalkerRequest):_*)

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to chisel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/chisel-users/34f45830-9f55-4cbf-8ddc-908c632c477f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Edmond Cote

unread,
Sep 7, 2018, 12:19:45 PM9/7/18
to chisel...@googlegroups.com
Thanks, Andrew!  I appreciate the tip, but "no dice" :(

val tableWalkerRequests: Vec[Bool] = Wire(VecInit((storerTableWalkerRequest ++ loaderTableWalkerRequest):_*))
// no `: _*' annotation allowed here (such annotations are only allowed in arguments to *-parameters)

val tableWalkerRequests: Vec[Bool] = Wire(VecInit(storerTableWalkerRequest ++ loaderTableWalkerRequest))
// wire type 'Vec(chisel3.core.Bool@2311, chisel3.core.Bool@2313, [..])' must be a Chisel type, not hardware


On Thu, Sep 6, 2018 at 11:47 AM Andrew Waterman <wate...@eecs.berkeley.edu> wrote:
Perhaps something like: VecInit((storeTableWalkerRequest ++ loadTableWalkerRequest):_*)
On Thu, Sep 6, 2018 at 11:44 AM, <edm...@edmondcote.com> wrote:
Believe that this question was asked before, but to no avail: https://stackoverflow.com/questions/51437942/chisel-concatenation-error

Can anyone think of a better strategy to concatenate two Vec objects?  Other than using generators that is, e.g.:

val storeTableWalkerRequest: Vec[Bool] = Wire(Vec(NumStorePorts, Bool()))

val loadTableWalkerRequest: Vec[Bool] = Wire(Vec(NumLoadPorts, Bool()))

// Concatenate all request vectors

val tableWalkerRequests: Vec[Bool] = Wire(Vec(NumStorePorts + NumLoadPorts, Bool()))

for (i <- 0 until NumStorePorts) {
  tableWalkerRequests(i) := storeTableWalkerRequest(i)
}

for (i <- NumStorePorts until NumStorePorts + NumLoadPorts) {
  tableWalkerRequests(i) := loadTableWalkerRequest(i - NumStorePorts)
}

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/chisel-users/34f45830-9f55-4cbf-8ddc-908c632c477f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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.

Steve Burns

unread,
Sep 7, 2018, 6:41:32 PM9/7/18
to chisel...@googlegroups.com
How about this slight modification:
VecInit(IndexedSeq((storeTableWalkerRequest ++ loadTableWalkerRequest):_*) )


Steve Burns

unread,
Sep 7, 2018, 7:03:29 PM9/7/18
to chisel...@googlegroups.com
Seems to work:

package vec_append

import chisel3._
import chisel3.util._
import chisel3.iotesters._
import org.scalatest.{Matchers, FlatSpec}

class Tl extends Module {
  val io = IO(new Bundle {
    val a = Input(Vec(2,UInt(4.W)))
    val b = Input(Vec(3,UInt(4.W)))
    val z = Output(Vec(5,UInt(4.W)))
  })

  io.z := VecInit( IndexedSeq( (io.a ++ io.b):_*))

}

class Tester(c: Tl) extends PeekPokeTester(c) {

    poke( c.io.a(0), 0)
    poke( c.io.a(1), 1)
    poke( c.io.b(0), 10)
    poke( c.io.b(1), 11)
    poke( c.io.b(2), 12)
    step(1)
    expect( c.io.z(0), 0)
    expect( c.io.z(1), 1)
    expect( c.io.z(2), 10)
    expect( c.io.z(3), 11)
    expect( c.io.z(4), 12)

}


class Test extends FlatSpec with Matchers {
  behavior of "Test"

  it should "work" in {
    chisel3.iotesters.Driver( () => new Tl, "firrtl") { c =>
      new Tester(c)
    } should be (true)
  }
}

Edmond Cote

unread,
Sep 12, 2018, 7:37:43 PM9/12/18
to chisel-users
Hi Steve,

Simply wanted to confirm that I have it working as well.

In the second case where I highlighted a "must be a Chisel type, not hardware" error, I made the mistake of making the assignment of a Bool() to a DecoupledIO() interface.  This works great!

val reqs = io.load.map(_.read) ++ io.store.map(_.write)

arbiter.io.in.zipWithIndex.foreach {
  case (in, index) =>
    in.valid := reqs(index)
    in.bits := 0.U // don't care
}


To unsubscribe from this group and stop receiving emails from it, send an email to chisel-users+unsubscribe@googlegroups.com.

To post to this group, send email to chisel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/chisel-users/34f45830-9f55-4cbf-8ddc-908c632c477f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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+unsubscribe@googlegroups.com.

--
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+unsubscribe@googlegroups.com.

--
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+unsubscribe@googlegroups.com.

To post to this group, send email to chisel...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages