diff options
| author | mergify[bot] | 2022-08-05 00:59:23 +0000 |
|---|---|---|
| committer | GitHub | 2022-08-05 00:59:23 +0000 |
| commit | db18ae16a26dab5231ca83172c88b9735a977582 (patch) | |
| tree | 484c0d45240f9db07437f15d0fe15cac1e04db67 /core/src/main/scala/chisel3/Data.scala | |
| parent | 945416c628656498be7a98dcd4899f2b9e830c00 (diff) | |
Replace some options with nullable vars (backport #2658) (#2659)
* Replace some options with nullable vars (#2658)
Co-authored-by: Jack Koenig <koenig@sifive.com>
(cherry picked from commit ac460bfeb16c8e7d0dc00975bb03f73c0fea2103)
# Conflicts:
# core/src/main/scala/chisel3/internal/Builder.scala
* Fix backport conflicts (#2661)
Co-authored-by: Zachary Yedidia <zyedidia@gmail.com>
Diffstat (limited to 'core/src/main/scala/chisel3/Data.scala')
| -rw-r--r-- | core/src/main/scala/chisel3/Data.scala | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/core/src/main/scala/chisel3/Data.scala b/core/src/main/scala/chisel3/Data.scala index 592ebe25..956c7996 100644 --- a/core/src/main/scala/chisel3/Data.scala +++ b/core/src/main/scala/chisel3/Data.scala @@ -501,14 +501,15 @@ abstract class Data extends HasId with NamedComponent with SourceInfoDoc { // Binding stores information about this node's position in the hardware graph. // This information is supplemental (more than is necessary to generate FIRRTL) and is used to // perform checks in Chisel, where more informative error messages are possible. - private var _binding: Option[Binding] = None + private var _bindingVar: Binding = null // using nullable var for better memory usage + private def _binding: Option[Binding] = Option(_bindingVar) // Only valid after node is bound (synthesizable), crashes otherwise protected[chisel3] def binding: Option[Binding] = _binding protected def binding_=(target: Binding) { if (_binding.isDefined) { throw RebindingException(s"Attempted reassignment of binding to $this, from: ${target}") } - _binding = Some(target) + _bindingVar = target } // Similar to topBindingOpt except it explicitly excludes SampleElements which are bound but not @@ -540,14 +541,15 @@ abstract class Data extends HasId with NamedComponent with SourceInfoDoc { // Both are only valid after binding is set. // Direction of this node, accounting for parents (force Input / Output) and children. - private var _direction: Option[ActualDirection] = None + private var _directionVar: ActualDirection = null // using nullable var for better memory usage + private def _direction: Option[ActualDirection] = Option(_directionVar) private[chisel3] def direction: ActualDirection = _direction.get private[chisel3] def direction_=(actualDirection: ActualDirection) { if (_direction.isDefined) { throw RebindingException(s"Attempted reassignment of resolved direction to $this") } - _direction = Some(actualDirection) + _directionVar = actualDirection } private[chisel3] def stringAccessor(chiselType: String): String = { |
