Skip to content

Commit

Permalink
BlackBox mapClockDomain now support reset/enable polarity adaptation
Browse files Browse the repository at this point in the history
  • Loading branch information
Dolu1990 committed Feb 10, 2020
1 parent 1a35e41 commit 48c73a7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions core/src/main/scala/spinal/core/BlackBox.scala
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,21 @@ abstract class BlackBox extends Component{
/**
* Map clock domain signals (clock, reset, enable) to a clockDomain
*/
def mapClockDomain(clockDomain: ClockDomain = ClockDomain.current, clock: Bool = null, reset: Bool = null, enable: Bool = null): Unit = {
def mapClockDomain(clockDomain: ClockDomain = ClockDomain.current, clock: Bool = null, reset: Bool = null, enable: Bool = null, resetActiveLevel: Polarity = HIGH, enableActiveLevel: Polarity = HIGH): Unit = {

Component.push(parent)

if (clockDomain.hasClockEnableSignal && enable == null) SpinalError(s"Clock domain has clock enable, but blackbox is not compatible $this")

if (enable != null) {
pulledDataCache += (clockDomain.clockEnable -> enable)
enable := clockDomain.readClockEnableWire
enable := (if(enableActiveLevel != clockDomain.config.clockEnableActiveLevel) !clockDomain.readClockEnableWire else clockDomain.readClockEnableWire)
}

if (reset != null) {
if (!clockDomain.hasResetSignal) SpinalError(s"Clock domain has no reset, but blackbox need it $this")
pulledDataCache += (clockDomain.reset -> reset)
reset := clockDomain.readResetWire
reset := (if(resetActiveLevel != clockDomain.config.resetActiveLevel) !clockDomain.readResetWire else clockDomain.readResetWire)
}

pulledDataCache += (clockDomain.clock -> clock)
Expand All @@ -138,8 +138,8 @@ abstract class BlackBox extends Component{


/** Map clock domains signal to the current ClockDomain */
def mapCurrentClockDomain(clock: Bool, reset: Bool = null, enable: Bool = null): Unit = {
mapClockDomain(ClockDomain.current, clock, reset, enable)
def mapCurrentClockDomain(clock: Bool, reset: Bool = null, enable: Bool = null, resetActiveLevel: Polarity = HIGH, enableActiveLevel: Polarity = HIGH): Unit = {
mapClockDomain(ClockDomain.current, clock, reset, enable, resetActiveLevel, enableActiveLevel)
}

override def isInBlackBoxTree: Boolean = isBlackBox || parent.isInBlackBoxTree
Expand Down

0 comments on commit 48c73a7

Please sign in to comment.