Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Connectable operators: :<=, :>=, :<>=, and :#= #2806

Merged
merged 97 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from 70 commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
4ae61c1
Added :<>=, :<=, :>=, :#=
azidar Aug 30, 2022
ba3168d
Fix imports, one test, dataview still broken
azidar Aug 30, 2022
4eef0eb
Fixed view bug
azidar Aug 30, 2022
82b9eee
Ran scalafmt
azidar Aug 30, 2022
c779ddb
Added Defaulting type to experimental
azidar Sep 23, 2022
f39dc11
Added support for Defaulting in bulk connect ops
azidar Sep 23, 2022
abcff93
Address reviewer feedback from #2747
azidar Sep 26, 2022
e09bf57
Ran formatte
azidar Sep 26, 2022
149f804
Added @group connection
azidar Sep 27, 2022
5025083
Added @group connection data.scala
azidar Sep 27, 2022
b0e5b10
Rewrote connection algorithm to use a Trie, works much better
azidar Sep 30, 2022
51527c1
Changed defaulting to a type property, turns out tries are super usef…
azidar Oct 1, 2022
e6b8c18
Added more tests, fixed a few bugs
azidar Oct 3, 2022
f53cdcb
Started add :#= tests, unexpected behavior for Output..
azidar Oct 4, 2022
a4b5875
All tests pass
azidar Oct 7, 2022
b682184
Bugfix: Output on Vec of bundle with mixed field orientations
azidar Oct 7, 2022
1e064bc
Add recursive iterators without path
azidar Oct 7, 2022
e210cc1
Improved defaulting syntax
azidar Oct 11, 2022
2d7743d
Rewrote connection algorithm to be recursive, for Waivables, tests pass
azidar Oct 13, 2022
3d5ff10
Added waivable use case, bugfix for opaque type emission
azidar Oct 14, 2022
2408df0
Added motivating use cases to tests
azidar Oct 14, 2022
88eae68
WIP: begin supporting dontcares, made :<= more strict (may revert tha…
azidar Oct 18, 2022
6323929
Added :<>=, :<=, :>=, :#=
azidar Aug 30, 2022
aa4aed5
Fix imports, one test, dataview still broken
azidar Aug 30, 2022
24d92e2
Fixed view bug
azidar Aug 30, 2022
342724d
Ran scalafmt
azidar Aug 30, 2022
a15e0d7
Added Defaulting type to experimental
azidar Sep 23, 2022
0fa4bb3
Added support for Defaulting in bulk connect ops
azidar Sep 23, 2022
da7b382
Address reviewer feedback from #2747
azidar Sep 26, 2022
3ff26b6
Ran formatte
azidar Sep 26, 2022
71d0465
Added @group connection
azidar Sep 27, 2022
6410468
Added @group connection data.scala
azidar Sep 27, 2022
3938d79
Rewrote connection algorithm to use a Trie, works much better
azidar Sep 30, 2022
a5cc424
Changed defaulting to a type property, turns out tries are super usef…
azidar Oct 1, 2022
417f366
Added more tests, fixed a few bugs
azidar Oct 3, 2022
f7bf004
Started add :#= tests, unexpected behavior for Output..
azidar Oct 4, 2022
01110cb
All tests pass
azidar Oct 7, 2022
b706d89
Bugfix: Output on Vec of bundle with mixed field orientations
azidar Oct 7, 2022
adefd42
Add recursive iterators without path
azidar Oct 7, 2022
3998402
Improved defaulting syntax
azidar Oct 11, 2022
4ca6596
Rewrote connection algorithm to be recursive, for Waivables, tests pass
azidar Oct 13, 2022
b1fdd1d
Added waivable use case, bugfix for opaque type emission
azidar Oct 14, 2022
f5b2da9
Added motivating use cases to tests
azidar Oct 14, 2022
6acbe54
WIP: begin supporting dontcares, made :<= more strict (may revert tha…
azidar Oct 18, 2022
f66accb
Started adding fixes to tests with := erroring aggressively
azidar Oct 18, 2022
cbf165b
WIP fixing up CompatibiliityInteropSpec
azidar Oct 19, 2022
a4d906b
Added more waivable mechanism to think about
azidar Oct 22, 2022
312dd28
Merge branch 'turkducken-try-2' of github.com:chipsalliance/chisel3 i…
azidar Oct 22, 2022
550f610
Fixed missed merge conflicts, added DataMirror programmatic iterators
azidar Oct 24, 2022
40754ce
Added WaivedData, pattern looks very promising
azidar Oct 25, 2022
731bad4
Removed old prototypes (Defaultling, Waivable, etc)
azidar Oct 25, 2022
8a238a2
Fixed deriveOrientation
azidar Oct 27, 2022
b3c3a7a
Added tests on compatibility bundles
azidar Oct 27, 2022
9863ede
Forgot to add WaivedData, refactored stuff to put more logic in Relat…
azidar Oct 28, 2022
4a27fa5
Made operators more strict because now you can waive things
azidar Oct 28, 2022
e67ad58
Use macros for scaladoc, reduces copypasta
azidar Oct 31, 2022
0c6f2d7
Generate scaladoc correctly for implicits for 2.13, (2.12 breaks grap…
azidar Nov 1, 2022
493b7fc
Started writing md docs
azidar Nov 1, 2022
17ab57f
Wrote mdoc with basic operator descriptions and examples
azidar Nov 1, 2022
ea2339a
WIP: writing docs
azidar Nov 1, 2022
2c0ad15
Added collectAlignedDeep and collectFlippedDeep
azidar Nov 2, 2022
fb27fbd
WIP
azidar Nov 2, 2022
eb652a4
Removed multiple-elaboration of producer in :<>=
azidar Nov 2, 2022
7d6bf50
Added Input/Output discussion and port-direction vs connection-direct…
azidar Nov 3, 2022
f0f5a1f
Apply suggestions from code review
azidar Nov 3, 2022
ec0840f
MOre reviewer feedback
azidar Nov 3, 2022
bb396a3
More docs updates from reviewer feedback
azidar Nov 3, 2022
119c9c4
More documentation updates
azidar Nov 4, 2022
81517c0
Comment out broken autoclonetype example
azidar Nov 4, 2022
04dab40
Added some of megan's feedback on docs
azidar Nov 7, 2022
43bf875
Added description of :,=,<,>,#
azidar Nov 7, 2022
41b20c9
Added to toc, made autoclonetype example work
azidar Nov 8, 2022
f0d3b83
Apply suggestions from code review
azidar Nov 8, 2022
463fedb
Added S =:= T restriction, clarified docs
azidar Nov 8, 2022
1cdcbf3
Added DontCare producer connections
azidar Nov 8, 2022
2e2b0d8
Updated doc with discussion of dataview
azidar Nov 8, 2022
6487623
Reorganized code into a connectable package, added scaladoc
azidar Nov 9, 2022
c9bb6e8
Revert turning migrate on changes to tests
azidar Nov 9, 2022
3511522
Updated doc
azidar Nov 9, 2022
c239655
Ran formatter
azidar Nov 10, 2022
21a2b86
Removed commented code
azidar Nov 10, 2022
e02e928
Changed migration flag, renamed test spec
azidar Nov 10, 2022
6fe5263
Cleaned up tests
azidar Nov 10, 2022
8f984ec
Added squeezed, renamed WaivedData -> ConnectableData
azidar Nov 11, 2022
5d5fc38
Addressed feedback
azidar Nov 15, 2022
352b1a6
Moved DataMirror
azidar Nov 15, 2022
73429bc
Renamed things to keep vocab consistent, wrote squeeze tests
azidar Nov 15, 2022
e7faa62
Ran formatter
azidar Nov 15, 2022
0154691
Fix broken mdoc links
azidar Nov 15, 2022
17bd7ad
Made connectable not a case class
azidar Nov 15, 2022
4f35579
Addressed reviewer feedback
azidar Nov 29, 2022
efb9658
Merge branch 'master' of github.com:chipsalliance/chisel3 into turkdu…
azidar Nov 29, 2022
6f1339c
Fixed tests
azidar Nov 29, 2022
876ad5a
Reverted changes to ChiselStage
azidar Nov 29, 2022
68eb540
Ran formatter
azidar Nov 29, 2022
a197a62
Revert hasBindings change, requires match for classtag
azidar Nov 29, 2022
09984f4
Fix docs
azidar Nov 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@ lazy val chisel = (project in file("."))
// This is probably fundamental to how ScalaDoc works so there may be no solution other than this workaround.
// See https://github.com/sbt/sbt-unidoc/issues/107
(core / Compile / sources).value.map("-P:chiselplugin:INTERNALskipFile:" + _)
++ {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, n)) if n >= 13 => "-implicits" :: Nil
case _ => Nil
}
}
)

// tests elaborating and executing/formally verifying a Chisel circuit with chiseltest
Expand Down
77 changes: 64 additions & 13 deletions core/src/main/scala/chisel3/Aggregate.scala
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,24 @@ sealed abstract class Aggregate extends Data {

private[chisel3] def width: Width = getElements.map(_.width).foldLeft(0.W)(_ + _)

private[chisel3] def legacyConnect(that: Data)(implicit sourceInfo: SourceInfo): Unit = {
// Emits the FIRRTL `this <= that`, or `this is invalid` if that == DontCare
private[chisel3] def firrtlConnect(that: Data)(implicit sourceInfo: SourceInfo): Unit = {
// If the source is a DontCare, generate a DefInvalid for the sink, otherwise, issue a Connect.
if (that == DontCare) {
pushCommand(DefInvalid(sourceInfo, lref))
} else {
pushCommand(Connect(sourceInfo, lref, Node(that)))
}
}

// Emits the FIRRTL `this <- that`, or `this is invalid` if that == DontCare
private[chisel3] def firrtlPartialConnect(that: Data)(implicit sourceInfo: SourceInfo): Unit = {
// If the source is a DontCare, generate a DefInvalid for the sink,
// otherwise, issue a Connect.
// otherwise, issue a Partial Connect.
if (that == DontCare) {
pushCommand(DefInvalid(sourceInfo, Node(this)))
pushCommand(DefInvalid(sourceInfo, lref))
} else {
pushCommand(BulkConnect(sourceInfo, Node(this), Node(that)))
pushCommand(PartialConnect(sourceInfo, lref, Node(that)))
}
}

Expand Down Expand Up @@ -258,25 +269,54 @@ sealed class Vec[T <: Data] private[chisel3] (gen: => T, val length: Int) extend
private[chisel3] final override def allElements: Seq[Element] =
(sample_element +: self).flatMap(_.allElements)

/** Strong bulk connect, assigning elements in this Vec from elements in a Seq.
/** The "bulk connect operator", assigning elements in this Vec from elements in a Seq.
*
* @note the length of this Vec must match the length of the input Seq
* For chisel3._, uses the [[BiConnect]] algorithm; sub-elements of `that` may end up driving sub-elements of `this`
* - Complicated semantics, will likely be deprecated in the future
azidar marked this conversation as resolved.
Show resolved Hide resolved
mwachs5 marked this conversation as resolved.
Show resolved Hide resolved
*
* For Chisel._, emits the FIRRTL.<- operator
* - Equivalent to `this :<>= that` without the restrictions that bundle field names and vector sizes must match
*
* @note the length of this Vec and that Seq must match
* @param that the Seq to connect from
* @group connection
*/
def <>(that: Seq[T])(implicit sourceInfo: SourceInfo, moduleCompileOptions: CompileOptions): Unit = {
if (this.length != that.length) {
Builder.error("Vec and Seq being bulk connected have different lengths!")
}
for ((a, b) <- this.zip(that))
if (this.length != that.length)
Builder.error(
s"Vec (size ${this.length}) and Seq (size ${that.length}) being bulk connected have different lengths!"
)
for ((a, b) <- this.zip(that)) {
a <> b
}
}

// TODO: eliminate once assign(Seq) isn't ambiguous with assign(Data) since Vec extends Seq and Data
/** The "bulk connect operator", assigning elements in this Vec from elements in a Vec.
*
* For chisel3._, uses the [[BiConnect]] algorithm; sub-elements of `that` may end up driving sub-elements of `this`
* - Complicated semantics, hard to write quickly, will likely be deprecated in the future
*
* For Chisel._, emits the FIRRTL.<- operator
* - Equivalent to `this :<>= that` without the restrictions that bundle field names and vector sizes must match
*
* @note This is necessary in [[Aggregate]], rather than relying on [[Data.<>]], due to supporting the Seq
* @note the length of this Vec and that Vec must match
* @param that the Vec to connect from
* @group connection
*/
def <>(that: Vec[T])(implicit sourceInfo: SourceInfo, moduleCompileOptions: CompileOptions): Unit =
this.bulkConnect(that.asInstanceOf[Data])

/** Strong bulk connect, assigning elements in this Vec from elements in a Seq.
/** "The strong connect operator", assigning elements in this Vec from elements in a Seq.
*
* For chisel3._, this operator is mono-directioned; all sub-elements of `this` will be driven by sub-elements of `that`.
* - Equivalent to `this :#= that`
*
* For Chisel._, this operator connections bi-directionally via emitting the FIRRTL.<=
* - Equivalent to `this :<>= that`, with the additional restriction that the relative bundle field flips must match
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the above true about the flips needing to match? Actually i need to go read up on whether turkducken requires that

*
* @note the length of this Vec must match the length of the input Seq
* @group connection
*/
def :=(that: Seq[T])(implicit sourceInfo: SourceInfo, moduleCompileOptions: CompileOptions): Unit = {
require(
Expand All @@ -287,7 +327,18 @@ sealed class Vec[T <: Data] private[chisel3] (gen: => T, val length: Int) extend
a := b
}

// TODO: eliminate once assign(Seq) isn't ambiguous with assign(Data) since Vec extends Seq and Data
/** "The strong connect operator", assigning elements in this Vec from elements in a Vec.
*
* For chisel3._, this operator is mono-directioned; all sub-elements of `this` will be driven by sub-elements of `that`.
* - Equivalent to `this :#= that`
*
* For Chisel._, this operator connections bi-directionally via emitting the FIRRTL.<=
* - Equivalent to `this :<>= that`, with the additional restriction that the relative bundle field flips must match
*
* @note This is necessary in [[Aggregate]], rather than relying on [[Data.:=]], due to supporting the Seq
* @note the length of this Vec must match the length of the input Vec
* @group connection
*/
def :=(that: Vec[T])(implicit sourceInfo: SourceInfo, moduleCompileOptions: CompileOptions): Unit = this.connect(that)

/** Creates a dynamically indexed read or write accessor into the array.
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/scala/chisel3/CompileOptions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ trait CompileOptions {
/** If marked true, then any Module which consumes `inferModuleReset=false` must also mix in [[RequireSyncReset]] */
def migrateInferModuleReset: Boolean = false

/** If marked true, then any <> or := operation using legacy connection semantics will error and suggest using [[Connectable]] ops */
def migrateConnections: Boolean = false

/** Should connects emit as firrtl <= instead of <- */
def emitStrictConnects: Boolean = true
}
Expand Down
Loading