Skip to content

Commit 96141dd

Browse files
committed
Merge branch 'master' of github.com:leros-dev/leros
2 parents c3a686b + 9b1e58e commit 96141dd

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

src/main/scala/leros/DataMem.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import chisel3._
44
import leros.util.Assembler
55

66

7-
class DataMemIO(memAddrWidth: Int) extends Bundle {
7+
class DataMemIO(val memAddrWidth: Int) extends Bundle {
88
val rdAddr = Input(UInt(memAddrWidth.W))
99
val rdData = Output(UInt(32.W))
1010
val wrAddr = Input(UInt(memAddrWidth.W))

src/main/scala/leros/InstrMem.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import chisel3._
44
import chisel3.util._
55
import leros.util.Assembler
66

7+
class InstrMemIO(memAddrWidth: Int) extends Bundle {
8+
val addr = Input(UInt(memAddrWidth.W))
9+
val instr = Output(UInt(16.W))
10+
}
711

812
/**
913
* Instruction memory.
@@ -13,10 +17,7 @@ import leros.util.Assembler
1317
* FIXME: Verilog generation from Chisel results in logic, not in a ROM.
1418
*/
1519
class InstrMem(memAddrWidth: Int, prog: String) extends Module {
16-
val io = IO(new Bundle {
17-
val addr = Input(UInt(memAddrWidth.W))
18-
val instr = Output(UInt(16.W))
19-
})
20+
val io = IO(new InstrMemIO(memAddrWidth))
2021
val code = Assembler.getProgram(prog)
2122
assert(scala.math.pow(2, memAddrWidth) >= code.length, "Program too large")
2223
val progMem = VecInit(code.toIndexedSeq.map(_.asUInt(16.W)))

src/main/scala/leros/Leros.scala

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@ import leros.State._
1010
*
1111
* Sequential implementation with two states.
1212
*/
13-
class Leros(prog: String, size: Int = 32, memAddrWidth: Int = 8) extends Module {
13+
class Leros(size: Int = 32, memAddrWidth: Int = 8) extends Module {
1414

15-
val imemIO = IO(new Bundle {
16-
val addr = Output(UInt(memAddrWidth.W))
17-
val instr = Input(UInt(16.W))
18-
})
15+
val imemIO = IO(Flipped(new InstrMemIO(memAddrWidth)))
1916
val dmemIO = IO(Flipped(new DataMemIO(16)))
2017

2118
val alu = Module(new AluAccu(size))
@@ -151,5 +148,5 @@ class Leros(prog: String, size: Int = 32, memAddrWidth: Int = 8) extends Module
151148
}
152149

153150
object Leros extends App {
154-
emitVerilog(new Leros(args(0)), Array("--target-dir", "generated"))
151+
emitVerilog(new Leros, Array("--target-dir", "generated"))
155152
}

src/main/scala/leros/LerosTop.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class LerosTop(prog: String, size: Int = 32, memAddrWidth: Int = 8) extends Modu
1818
val led = Output(UInt(8.W))
1919
})
2020

21-
val leros = Module(new Leros(prog))
21+
val leros = Module(new Leros)
2222
// Fetch from instruction memory with an address register that is reset to 0
2323
val instrMem = Module(new InstrMem(memAddrWidth, prog))
2424
// Data memory, including the register memory

0 commit comments

Comments
 (0)