-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add memory mapped UART + GPIOs and instruction memory programmable ov…
…er APB
- Loading branch information
1 parent
a307144
commit 72f9d8a
Showing
12 changed files
with
283 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,30 @@ | ||
# Just remember commands, for now. | ||
|
||
PROG_DIR ?= leros/asm/test | ||
ROM ?= base.s | ||
APB_BASE_ADDR ?= 01050000 | ||
BUILD_DIR ?= src/sv/ | ||
|
||
init: | ||
git submodule update --init --recursive | ||
|
||
generate: | ||
sbt run | ||
|
||
generate_dtu: | ||
sbt "runMain DtuTop $(APB_BASE_ADDR) $(PROG_DIR)/$(ROM) $(BUILD_DIR)" | ||
|
||
clean: | ||
rm -rf $(BUILD_DIR)/*.sv | ||
rm -rf $(BUILD_DIR)/*.json | ||
rm -rf $(BUILD_DIR)/*.f | ||
rm -rf $(BUILD_DIR)/*.fir | ||
|
||
test: | ||
sbt test | ||
cd leros; make init | ||
cd leros; sbt test | ||
cd hello-morse; sbt test | ||
|
||
test_dtu: | ||
sbt "testOnly DtuTopTester" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
object Register_Map_Index { | ||
val COUNT = 9 | ||
|
||
val UART_RX_DATA = 0 | ||
val UART_RX_VALID = 1 | ||
val UART_RX_READY = 2 | ||
|
||
val UART_TX_DATA = 3 | ||
val UART_TX_VALID = 4 | ||
val UART_TX_READY = 5 | ||
|
||
val PMOD_OE = 6 | ||
val PMOD_GPO = 7 | ||
val PMOD_GPI = 8 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package io | ||
|
||
import chisel3._ | ||
import chisel3.util._ | ||
|
||
class ApbLoader(apbAddrWidth:Int, apbDataWidth:Int, apbBaseAddr:Int, lerosCtrlRegAddr:Int, lerosMemAddrWidth:Int, lerosMemDataWidth:Int) extends Module { | ||
val io = IO(new Bundle{ | ||
val apb = new ApbTargetPort(apbAddrWidth, apbDataWidth) | ||
|
||
val req = Output(Bool()) | ||
val wrAddr = Output(UInt(lerosMemAddrWidth.W)) | ||
val wrData = Output(UInt(lerosMemDataWidth.W)) | ||
val wr = Output(Bool()) | ||
val wrMask = Output(UInt((lerosMemDataWidth/8).W)) | ||
|
||
val lerosReset = Output(Bool()) | ||
}) | ||
|
||
val idle :: write :: read :: Nil = Enum(3) | ||
val state = RegInit(idle) | ||
|
||
val lerosResetReg = RegInit(false.B) | ||
|
||
io.apb.pready := false.B | ||
io.apb.prdata := 0.U | ||
io.apb.pslverr := false.B | ||
|
||
io.req := false.B | ||
io.wrAddr := 0.U | ||
io.wrData := 0.U | ||
io.wrMask := 0.U | ||
io.wr := false.B | ||
|
||
io.lerosReset := lerosResetReg | ||
|
||
switch(state) { | ||
is(idle) { | ||
io.apb.pready := false.B | ||
io.apb.prdata := 0.U | ||
io.apb.pslverr := false.B | ||
|
||
io.req := false.B | ||
io.wrAddr := 0.U | ||
io.wrData := 0.U | ||
io.wrMask := 0.U | ||
io.wr := false.B | ||
|
||
when(io.apb.psel && io.apb.pwrite) { | ||
state := write | ||
} | ||
. elsewhen(io.apb.psel && !io.apb.pwrite) { | ||
state := read | ||
} | ||
} | ||
is(write) { | ||
when(io.apb.paddr === lerosCtrlRegAddr.U) { | ||
lerosResetReg := Mux(io.apb.pwdata === 0.U, false.B, true.B) | ||
} | ||
.otherwise { | ||
io.req := true.B | ||
io.wrAddr := io.apb.paddr - apbBaseAddr.U | ||
io.wrData := io.apb.pwdata | ||
io.wrMask := "b11".U | ||
io.wr := true.B | ||
} | ||
|
||
io.apb.pslverr := (apbBaseAddr.U > io.apb.paddr) | ||
io.apb.pready := true.B | ||
|
||
when(~io.apb.psel) { | ||
state := idle | ||
} | ||
} | ||
// Read not supported therefore raise error | ||
is(read) { | ||
io.apb.prdata := 0.U | ||
|
||
io.req := false.B | ||
io.wrAddr := 0.U | ||
io.wrData := 0.U | ||
io.wrMask := 0.U | ||
io.wr := false.B | ||
|
||
io.apb.pready := true.B | ||
io.apb.pslverr := true.B | ||
|
||
when(~io.apb.psel) { | ||
state := idle | ||
} | ||
} | ||
} | ||
|
||
} |
4 changes: 3 additions & 1 deletion
4
src/main/scala/ApbPort.scala → src/main/scala/io/ApbPort.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/main/scala/PmodGpioPort.scala → src/main/scala/io/PmodGpioPort.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
package io | ||
|
||
import chisel3._ | ||
import chisel3.util._ | ||
|
||
|
Oops, something went wrong.