Code improvement; define IOCell name as Option and place in trait to reduce code modifications
This commit is contained in:
@@ -60,7 +60,17 @@ class DigitalInIOCellBundle extends Bundle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
trait IOCell extends BaseModule {
|
trait IOCell extends BaseModule {
|
||||||
var i_name: String
|
var iocell_name : Option[String] = None
|
||||||
|
|
||||||
|
/** Set IOCell name
|
||||||
|
* @param s Proposed name for the IOCell
|
||||||
|
*
|
||||||
|
* @return An inherited IOCell with given the proposed name
|
||||||
|
*/
|
||||||
|
def suggestName(s: String) : this.type = {
|
||||||
|
iocell_name = Some(s)
|
||||||
|
super.suggestName(s)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trait AnalogIOCell extends IOCell {
|
trait AnalogIOCell extends IOCell {
|
||||||
@@ -89,19 +99,15 @@ abstract class GenericIOCell extends BlackBox with HasBlackBoxResource {
|
|||||||
|
|
||||||
class GenericAnalogIOCell extends GenericIOCell with AnalogIOCell {
|
class GenericAnalogIOCell extends GenericIOCell with AnalogIOCell {
|
||||||
val io = IO(new AnalogIOCellBundle)
|
val io = IO(new AnalogIOCellBundle)
|
||||||
var i_name = "NoNameAssigned"
|
|
||||||
}
|
}
|
||||||
class GenericDigitalGPIOCell extends GenericIOCell with DigitalGPIOCell {
|
class GenericDigitalGPIOCell extends GenericIOCell with DigitalGPIOCell {
|
||||||
val io = IO(new DigitalGPIOCellBundle)
|
val io = IO(new DigitalGPIOCellBundle)
|
||||||
var i_name = "NoNameAssigned"
|
|
||||||
}
|
}
|
||||||
class GenericDigitalInIOCell extends GenericIOCell with DigitalInIOCell {
|
class GenericDigitalInIOCell extends GenericIOCell with DigitalInIOCell {
|
||||||
val io = IO(new DigitalInIOCellBundle)
|
val io = IO(new DigitalInIOCellBundle)
|
||||||
var i_name = "NoNameAssigned"
|
|
||||||
}
|
}
|
||||||
class GenericDigitalOutIOCell extends GenericIOCell with DigitalOutIOCell {
|
class GenericDigitalOutIOCell extends GenericIOCell with DigitalOutIOCell {
|
||||||
val io = IO(new DigitalOutIOCellBundle)
|
val io = IO(new DigitalOutIOCellBundle)
|
||||||
var i_name = "NoNameAssigned"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
trait IOCellTypeParams {
|
trait IOCellTypeParams {
|
||||||
@@ -118,11 +124,9 @@ case class GenericIOCellParams() extends IOCellTypeParams {
|
|||||||
def output() = Module(new GenericDigitalOutIOCell)
|
def output() = Module(new GenericDigitalOutIOCell)
|
||||||
}
|
}
|
||||||
|
|
||||||
trait IOCellName {
|
|
||||||
var i_name: String
|
|
||||||
}
|
|
||||||
|
|
||||||
object IOCell extends IOCellName {
|
|
||||||
|
object IOCell {
|
||||||
|
|
||||||
/** From within a RawModule or MultiIOModule context, generate new module IOs from a given
|
/** From within a RawModule or MultiIOModule context, generate new module IOs from a given
|
||||||
* signal and return the new IO and a Seq containing all generated IO cells.
|
* signal and return the new IO and a Seq containing all generated IO cells.
|
||||||
@@ -144,8 +148,6 @@ object IOCell extends IOCellName {
|
|||||||
(padSignal, iocells)
|
(padSignal, iocells)
|
||||||
}
|
}
|
||||||
|
|
||||||
var i_name = "NoNameAssigned"
|
|
||||||
|
|
||||||
/** Connect two identical signals together by adding IO cells between them and return a Seq
|
/** Connect two identical signals together by adding IO cells between them and return a Seq
|
||||||
* containing all generated IO cells.
|
* containing all generated IO cells.
|
||||||
* @param coreSignal The core-side (internal) signal onto which to connect/add IO cells
|
* @param coreSignal The core-side (internal) signal onto which to connect/add IO cells
|
||||||
@@ -168,13 +170,11 @@ object IOCell extends IOCellName {
|
|||||||
)(coreSignal: T,
|
)(coreSignal: T,
|
||||||
padSignal: T
|
padSignal: T
|
||||||
): Seq[IOCell] = {
|
): Seq[IOCell] = {
|
||||||
print("Suggested names: " + name + " ")
|
|
||||||
DataMirror.directionOf(coreSignal) match {
|
DataMirror.directionOf(coreSignal) match {
|
||||||
case ActualDirection.Input => {
|
case ActualDirection.Input => {
|
||||||
val iocell = typeParams.input()
|
val iocell = typeParams.input()
|
||||||
name.foreach(n => {
|
name.foreach(n => {
|
||||||
iocell.suggestName(n)
|
iocell.suggestName(n)
|
||||||
iocell.i_name = n
|
|
||||||
})
|
})
|
||||||
coreSignal := castFromBool(iocell.io.i)
|
coreSignal := castFromBool(iocell.io.i)
|
||||||
iocell.io.ie := true.B
|
iocell.io.ie := true.B
|
||||||
@@ -185,7 +185,6 @@ object IOCell extends IOCellName {
|
|||||||
val iocell = typeParams.output()
|
val iocell = typeParams.output()
|
||||||
name.foreach(n => {
|
name.foreach(n => {
|
||||||
iocell.suggestName(n)
|
iocell.suggestName(n)
|
||||||
iocell.i_name = n
|
|
||||||
})
|
})
|
||||||
iocell.io.o := castToBool(coreSignal)
|
iocell.io.o := castToBool(coreSignal)
|
||||||
iocell.io.oe := true.B
|
iocell.io.oe := true.B
|
||||||
@@ -236,7 +235,6 @@ object IOCell extends IOCellName {
|
|||||||
// An alternative solution would be to suggestName(n + "_" + i)
|
// An alternative solution would be to suggestName(n + "_" + i)
|
||||||
name.foreach(n => {
|
name.foreach(n => {
|
||||||
iocell.suggestName(n)
|
iocell.suggestName(n)
|
||||||
iocell.i_name = n
|
|
||||||
})
|
})
|
||||||
iocell.io.pad := sig
|
iocell.io.pad := sig
|
||||||
iocell.io.ie := true.B
|
iocell.io.ie := true.B
|
||||||
@@ -254,7 +252,6 @@ object IOCell extends IOCellName {
|
|||||||
// An alternative solution would be to suggestName(n + "_" + i)
|
// An alternative solution would be to suggestName(n + "_" + i)
|
||||||
name.foreach(n => {
|
name.foreach(n => {
|
||||||
iocell.suggestName(n)
|
iocell.suggestName(n)
|
||||||
iocell.i_name = n
|
|
||||||
})
|
})
|
||||||
iocell.io.o := sig
|
iocell.io.o := sig
|
||||||
iocell.io.oe := true.B
|
iocell.io.oe := true.B
|
||||||
|
|||||||
Reference in New Issue
Block a user