-
-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev' # Conflicts: # project/Version.sc # project/Version.sc~HEAD
- Loading branch information
Showing
36 changed files
with
1,197 additions
and
162 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 @@ | ||
0.11.6 |
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,71 @@ | ||
package spinal.core | ||
|
||
import spinal.idslplugin.Location | ||
|
||
import scala.collection.mutable | ||
import scala.collection.mutable.ArrayBuffer | ||
|
||
object HardMap{ | ||
def apply(content : Seq[NamedType[_ <: Data]]) : HardMap = { | ||
val ret = new HardMap() | ||
content.foreach(e => ret.add(e)) | ||
ret | ||
} | ||
} | ||
|
||
class HardMap extends MultiData { | ||
val storage = mutable.LinkedHashMap[NamedType[Data], Data]() | ||
var elementsCache : ArrayBuffer[(String, Data)] = null | ||
|
||
def keyToName(key : Any) = key match { | ||
case n: Nameable if n.isNamed => n.getName() | ||
} | ||
|
||
def update[T <: Data](key : NamedType[T], value : T): Unit = { | ||
assert(elementsCache == null) | ||
assert(!storage.contains(key.asInstanceOf[NamedType[Data]])) | ||
storage(key.asInstanceOf[NamedType[Data]]) = value | ||
if(OwnableRef.proposal(value, this)) value.setPartialName(keyToName(key), Nameable.DATAMODEL_WEAK) | ||
} | ||
|
||
def add[T <: Data](key: NamedType[T]) : Unit = { | ||
this(key) = key() | ||
} | ||
|
||
def apply[T <: Data](key: NamedType[T]): T = { | ||
storage(key.asInstanceOf[NamedType[Data]]).asInstanceOf[T] | ||
} | ||
|
||
override def elements: ArrayBuffer[(String, Data)] = { | ||
if(elementsCache == null) { | ||
elementsCache = ArrayBuffer[(String, Data)]() | ||
for ((k, d) <- storage) { | ||
val name = keyToName(k) | ||
elementsCache += name -> d | ||
} | ||
} | ||
elementsCache | ||
} | ||
|
||
def hardMapAssign(that: HardMap)(f: (Data, Data) => Unit): Unit = { | ||
for ((name, element) <- elements) { | ||
val other = that.find(name) | ||
if (other == null) { | ||
LocatedPendingError(s"Bundle assignment is not complete. $this need '$name' but $that doesn't provide it.") | ||
} | ||
else { | ||
f(element, other) | ||
} | ||
} | ||
} | ||
|
||
protected override def assignFromImpl(that: AnyRef, target: AnyRef, kind: AnyRef)(implicit loc: Location): Unit = { | ||
that match { | ||
case that: HardMap => | ||
if (!this.getClass.isAssignableFrom(that.getClass)) SpinalError("HardMap must have the same final class to" + | ||
" be assigned. Either use assignByName or assignSomeByName at \n" + ScalaLocated.long) | ||
hardMapAssign(that)((to, from) => to.compositAssignFrom(from, to, kind)) | ||
case _ => throw new Exception("Undefined assignment") | ||
} | ||
} | ||
} |
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
Oops, something went wrong.