Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

36 lines
838B

  1. package Ex0
  2. import chisel3._
  3. class Vector(val elements: Int) extends Module {
  4. val io = IO(
  5. new Bundle {
  6. val idx = Input(UInt(32.W))
  7. val dataIn = Input(UInt(32.W))
  8. val writeEnable = Input(Bool())
  9. val dataOut = Output(UInt(32.W))
  10. }
  11. )
  12. // Creates a vector of zero-initialized registers
  13. val internalVector = RegInit(VecInit(List.fill(elements)(0.U(32.W))))
  14. when(io.writeEnable){
  15. // TODO:
  16. // When writeEnable is true the content of internalVector at the index specified
  17. // by idx should be set to the value of io.dataIn
  18. }
  19. // In this case we don't want an otherwise block, in writeEnable is low we don't change
  20. // anything
  21. // TODO:
  22. // io.dataOut should be driven by the contents of internalVector at the index specified
  23. // by idx
  24. io.dataOut := 0.U
  25. }