forked from SpinalHDL/SpinalDoc-RTD
-
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.
- Loading branch information
1 parent
74dda33
commit f410407
Showing
6 changed files
with
128 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
*.class | ||
*.log | ||
*.bak | ||
|
||
# sbt specific | ||
.cache/ | ||
.history/ | ||
.lib/ | ||
dist/* | ||
target | ||
lib_managed/ | ||
src_managed/ | ||
project/boot/ | ||
project/plugins/project/ | ||
|
||
# Scala-IDE specific | ||
.scala_dependencies | ||
.worksheet | ||
|
||
.idea | ||
out | ||
|
||
# Metals | ||
.metals | ||
|
||
# Eclipse | ||
bin/ | ||
.classpath | ||
.project | ||
.settings | ||
.cache-main | ||
|
||
#User | ||
/*.vhd | ||
/*.v | ||
*.cf | ||
*.json | ||
*.vcd | ||
!tester/src/test/resources/*.vhd | ||
|
||
|
||
simWorkspace/ | ||
tmp/ |
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,16 @@ | ||
ThisBuild / version := "1.0" | ||
ThisBuild / scalaVersion := "2.12.16" | ||
ThisBuild / organization := "org.example" | ||
|
||
val spinalVersion = "1.7.3" | ||
val spinalCore = "com.github.spinalhdl" %% "spinalhdl-core" % spinalVersion | ||
val spinalLib = "com.github.spinalhdl" %% "spinalhdl-lib" % spinalVersion | ||
val spinalIdslPlugin = compilerPlugin("com.github.spinalhdl" %% "spinalhdl-idsl-plugin" % spinalVersion) | ||
|
||
lazy val mylib = (project in file(".")) | ||
.settings( | ||
name := "SpinalDoc-RTD-examples", | ||
libraryDependencies ++= Seq(spinalCore, spinalLib, spinalIdslPlugin) | ||
) | ||
|
||
fork := true |
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 @@ | ||
sbt.version=1.6.0 |
Empty file.
60 changes: 60 additions & 0 deletions
60
examples/src/main/scala/spinaldoc/examples/advanced/MemoryMappedUart.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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package spinaldoc.examples.advanced | ||
|
||
import spinal.core._ | ||
import spinal.lib._ | ||
import spinal.lib.bus.amba3.apb.{Apb3, Apb3Config, Apb3SlaveFactory} | ||
import spinal.lib.com.uart.{Uart, UartCtrl, UartCtrlGenerics} | ||
|
||
object Apb3UartCtrl { | ||
def getApb3Config = Apb3Config( | ||
addressWidth = 4, | ||
dataWidth = 32 | ||
) | ||
} | ||
// end object Apb3UartCtrl | ||
|
||
<<<<<<< HEAD | ||
// start impl | ||
class Apb3UartCtrl(uartCtrlConfig : UartCtrlGenerics, rxFifoDepth : Int) extends Component{ | ||
val io = new Bundle { | ||
======= | ||
case class Apb3UartCtrl(uartCtrlConfig: UartCtrlGenerics, rxFifoDepth: Int) extends Component { | ||
val io = new Bundle{ | ||
>>>>>>> 4dcc6d368 (fixup! Convert Memory Mapped UART Example) | ||
val bus = slave(Apb3(Apb3UartCtrl.getApb3Config)) | ||
val uart = master(Uart()) | ||
} | ||
|
||
// Instanciate an simple uart controller | ||
val uartCtrl = new UartCtrl(uartCtrlConfig) | ||
io.uart <> uartCtrl.io.uart | ||
|
||
// Create an instance of the Apb3SlaveFactory that will then be used as a slave factory drived by io.bus | ||
val busCtrl = Apb3SlaveFactory(io.bus) | ||
|
||
// Ask the busCtrl to create a readable/writable register at the address 0 | ||
// and drive uartCtrl.io.config.clockDivider with this register | ||
busCtrl.driveAndRead(uartCtrl.io.config.clockDivider,address = 0) | ||
|
||
// Do the same thing than above but for uartCtrl.io.config.frame at the address 4 | ||
busCtrl.driveAndRead(uartCtrl.io.config.frame,address = 4) | ||
|
||
// Ask the busCtrl to create a writable Flow[Bits] (valid/payload) at the address 8. | ||
// Then convert it into a stream and connect it to the uartCtrl.io.write by using an register stage (>->) | ||
busCtrl.createAndDriveFlow(Bits(uartCtrlConfig.dataWidthMax bits),address = 8).toStream >-> uartCtrl.io.write | ||
|
||
// To avoid losing writes commands between the Flow to Stream transformation just above, | ||
// make the occupancy of the uartCtrl.io.write readable at address 8 | ||
busCtrl.read(uartCtrl.io.write.valid,address = 8) | ||
|
||
// Take uartCtrl.io.read, convert it into a Stream, then connect it to the input of a FIFO of 64 elements | ||
// Then make the output of the FIFO readable at the address 12 by using a non blocking protocol | ||
// (Bit 7 downto 0 => read data <br> Bit 31 => read data valid ) | ||
busCtrl.readStreamNonBlocking(uartCtrl.io.read.queue(rxFifoDepth), | ||
address = 12, validBitOffset = 31, payloadBitOffset = 0) | ||
} | ||
// end case class Apb3UartCtrl | ||
|
||
object MemoryMappedUart extends App { | ||
SpinalVerilog(Apb3UartCtrl(UartCtrlGenerics(), rxFifoDepth=16)) | ||
} |
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