diff options
| author | mergify[bot] | 2022-12-08 22:17:33 +0000 |
|---|---|---|
| committer | GitHub | 2022-12-08 22:17:33 +0000 |
| commit | 294bf10510b2dc55312be2e87f9bed556c68afc5 (patch) | |
| tree | 52cc92151e179c2bdb8e2c552ee6a5dbb1d4cd34 /core | |
| parent | 8fe876463e26d1b63e36a7ebf4a2bc62366cce81 (diff) | |
Replay changes on 3.5.x (#2865)
Co-authored-by: Aditya Naik <aditya.naik@sifive.com>
Diffstat (limited to 'core')
| -rw-r--r-- | core/src/main/scala/chisel3/IO.scala | 41 | ||||
| -rw-r--r-- | core/src/main/scala/chisel3/Module.scala | 38 | ||||
| -rw-r--r-- | core/src/main/scala/chisel3/experimental/package.scala | 2 |
3 files changed, 45 insertions, 36 deletions
diff --git a/core/src/main/scala/chisel3/IO.scala b/core/src/main/scala/chisel3/IO.scala new file mode 100644 index 00000000..1a28db1e --- /dev/null +++ b/core/src/main/scala/chisel3/IO.scala @@ -0,0 +1,41 @@ +package chisel3 + +import chisel3.internal.requireIsChiselType // Fix ambiguous import +import chisel3.internal.Builder +import chisel3.internal.sourceinfo.SourceInfo + +object IO { + + /** Constructs a port for the current Module + * + * This must wrap the datatype used to set the io field of any Module. + * i.e. All concrete modules must have defined io in this form: + * [lazy] val io[: io type] = IO(...[: io type]) + * + * Items in [] are optional. + * + * The granted iodef must be a chisel type and not be bound to hardware. + * + * Also registers a Data as a port, also performing bindings. Cannot be called once ports are + * requested (so that all calls to ports will return the same information). + * Internal API. + */ + def apply[T <: Data](iodef: T): T = { + val module = Module.currentModule.get // Impossible to fail + require(!module.isClosed, "Can't add more ports after module close") + requireIsChiselType(iodef, "io type") + + // Clone the IO so we preserve immutability of data types + val iodefClone = + try { + iodef.cloneTypeFull + } catch { + // For now this is going to be just a deprecation so we don't suddenly break everyone's code + case e: AutoClonetypeException => + Builder.deprecated(e.getMessage, Some(s"${iodef.getClass}")) + iodef + } + module.bindIoInPlace(iodefClone) + iodefClone + } +} diff --git a/core/src/main/scala/chisel3/Module.scala b/core/src/main/scala/chisel3/Module.scala index e5c2a848..a2d5cec6 100644 --- a/core/src/main/scala/chisel3/Module.scala +++ b/core/src/main/scala/chisel3/Module.scala @@ -200,42 +200,10 @@ abstract class Module(implicit moduleCompileOptions: CompileOptions) extends Raw } package experimental { - - import chisel3.internal.requireIsChiselType // Fix ambiguous import - object IO { - - /** Constructs a port for the current Module - * - * This must wrap the datatype used to set the io field of any Module. - * i.e. All concrete modules must have defined io in this form: - * [lazy] val io[: io type] = IO(...[: io type]) - * - * Items in [] are optional. - * - * The granted iodef must be a chisel type and not be bound to hardware. - * - * Also registers a Data as a port, also performing bindings. Cannot be called once ports are - * requested (so that all calls to ports will return the same information). - * Internal API. - */ + @deprecated("chisel3.experimental.IO is deprecated, use chisel3.IO instead", "Chisel 3.5") def apply[T <: Data](iodef: T): T = { - val module = Module.currentModule.get // Impossible to fail - require(!module.isClosed, "Can't add more ports after module close") - requireIsChiselType(iodef, "io type") - - // Clone the IO so we preserve immutability of data types - val iodefClone = - try { - iodef.cloneTypeFull - } catch { - // For now this is going to be just a deprecation so we don't suddenly break everyone's code - case e: AutoClonetypeException => - Builder.deprecated(e.getMessage, Some(s"${iodef.getClass}")) - iodef - } - module.bindIoInPlace(iodefClone) - iodefClone + chisel3.IO.apply(iodef) } } } @@ -753,7 +721,7 @@ package experimental { * TODO(twigg): Specifically walk the Data definition to call out which nodes * are problematic. */ - protected def IO[T <: Data](iodef: T): T = chisel3.experimental.IO.apply(iodef) + protected def IO[T <: Data](iodef: T): T = chisel3.IO.apply(iodef) // // Internal Functions diff --git a/core/src/main/scala/chisel3/experimental/package.scala b/core/src/main/scala/chisel3/experimental/package.scala index 39131943..42ec9666 100644 --- a/core/src/main/scala/chisel3/experimental/package.scala +++ b/core/src/main/scala/chisel3/experimental/package.scala @@ -72,7 +72,7 @@ package object experimental { val ports: Seq[Data] = gen.elements.toSeq.reverse.map { case (name, data) => - val p = IO(coerceDirection(chiselTypeClone(data).asInstanceOf[Data])) + val p = chisel3.IO(coerceDirection(chiselTypeClone(data).asInstanceOf[Data])) p.suggestName(name) p |
