This repository has been archived by the owner on Jun 16, 2024. It is now read-only.
-
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
Showing
20 changed files
with
119 additions
and
61 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
11 changes: 6 additions & 5 deletions
11
...hrzn/chryse/platform/BoardResources.scala → ...yse/platform/PlatformBoardResources.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,23 +1,24 @@ | ||
package ee.hrzn.chryse.platform | ||
|
||
import chisel3._ | ||
import ee.hrzn.chryse.platform.resource.DataResource | ||
import ee.hrzn.chryse.platform.resource.Base | ||
import ee.hrzn.chryse.platform.resource.ResourceBase | ||
import ee.hrzn.chryse.platform.resource.ResourceData | ||
|
||
import scala.collection.mutable.ArrayBuffer | ||
|
||
abstract class BoardResources { | ||
abstract class PlatformBoardResources { | ||
private[chryse] def setNames() = | ||
for { f <- this.getClass().getDeclaredFields() } { | ||
f.setAccessible(true) | ||
f.get(this) match { | ||
case res: Base => | ||
case res: ResourceBase => | ||
res.setName(f.getName()) | ||
case _ => | ||
} | ||
} | ||
|
||
val clock: resource.ClockSource | ||
|
||
def all: Seq[DataResource[_ <: Data]] = Base.allFromBoardResources(this) | ||
def all: Seq[ResourceData[_ <: Data]] = | ||
ResourceBase.allFromBoardResources(this) | ||
} |
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
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
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
16 changes: 8 additions & 8 deletions
16
.../hrzn/chryse/platform/resource/Base.scala → ...ryse/platform/resource/ResourceBase.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: 1 addition & 1 deletion
2
...platform/resource/SinglePinResource.scala → ...platform/resource/ResourceSinglePin.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,5 +1,5 @@ | ||
package ee.hrzn.chryse.platform.resource | ||
|
||
trait SinglePinResource extends Base { | ||
trait ResourceSinglePin extends ResourceBase { | ||
def onPin(id: Pin): this.type | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/scala/ee/hrzn/chryse/platform/resource/SPIFlash.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,46 @@ | ||
package ee.hrzn.chryse.platform.resource | ||
|
||
import chisel3._ | ||
|
||
class SPIFlash extends ResourceBase { | ||
// TODO NEXT: refactoring out inversion (and other interposed) logic here should be fruitful. | ||
val cs = new ResourceData[Bool](Output(Bool())) {} // TODO: invert | ||
val clock = new ResourceData[Clock](Output(Clock())) {} // XXX: Clock here OK? | ||
val copi = new ResourceData[Bool](Output(Bool())) {} | ||
val cipo = new ResourceData[Bool](Input(Bool())) {} | ||
val wp = new ResourceData[Bool](Output(Bool())) {} // TODO: invert | ||
val hold = new ResourceData[Bool](Output(Bool())) {} // TODO: invert | ||
|
||
def setName(name: String): Unit = { | ||
cs.setName(s"${name}_cs") | ||
clock.setName(s"${name}_clock") | ||
copi.setName(s"${name}_copi") | ||
cipo.setName(s"${name}_cipo") | ||
wp.setName(s"${name}_wp") | ||
hold.setName(s"${name}_hold") | ||
} | ||
|
||
def onPins( | ||
csN: Pin, | ||
clock: Pin, | ||
copi: Pin, | ||
cipo: Pin, | ||
wpN: Pin, | ||
holdN: Pin, | ||
): this.type = { | ||
this.cs.onPin(csN) | ||
this.clock.onPin(clock) | ||
this.copi.onPin(copi) | ||
this.cipo.onPin(cipo) | ||
this.wp.onPin(wpN) | ||
this.hold.onPin(holdN) | ||
this | ||
} | ||
|
||
def data: Seq[ResourceData[_ <: Data]] = | ||
Seq(cs, clock, copi, cipo, wp, hold) | ||
} | ||
|
||
object SPIFlash { | ||
def apply() = new SPIFlash | ||
} |
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
Oops, something went wrong.