-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathVector.scala
36 lines (26 loc) · 948 Bytes
/
Vector.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package Ex0
import chisel3._
class Vector(val elements: Int) extends Module {
val io = IO(
new Bundle {
val idx = Input(UInt(32.W))
val dataIn = Input(UInt(32.W))
val writeEnable = Input(Bool())
val dataOut = Output(UInt(32.W))
}
)
// Creates a vector of zero-initialized registers
val internalVector = RegInit(VecInit(List.fill(elements)(0.U(32.W))))
when(io.writeEnable){
// TODO:
// When writeEnable is true the content of internalVector at the index specified
// by idx should be set to the value of io.dataIn
// If you are unsure how to access a vector element you can look at myVector.scala in .src/test/Examples/
}
// In this case we don't want an otherwise block, in writeEnable is low we don't change
// anything
// TODO:
// io.dataOut should be driven by the contents of internalVector at the index specified
// by idx
io.dataOut := 0.U
}