1d7c51068SXuan Hupackage utils 2d7c51068SXuan Hu 3d7c51068SXuan Huimport chisel3._ 4d7c51068SXuan Hu 5d7c51068SXuan Hu/** 6d7c51068SXuan Hu * Produce named UInt(x.W) 7d7c51068SXuan Hu * 8d7c51068SXuan Hu * @example {{{ 9d7c51068SXuan Hu * object Fflags extends NamedUInt(5) 10d7c51068SXuan Hu * val fflags = Fflags() 11d7c51068SXuan Hu * }}} 12d7c51068SXuan Hu */ 13d7c51068SXuan Huabstract class NamedUInt(int : Int) { 14d7c51068SXuan Hu def apply(): UInt = UInt(width.W) 15d7c51068SXuan Hu 16d7c51068SXuan Hu def width: Int = int 17*92c61038SXuan Hu 18*92c61038SXuan Hu protected def checkInputWidth(uint: UInt): Unit = { 19*92c61038SXuan Hu require( 20*92c61038SXuan Hu uint.getWidth == this.width, 21*92c61038SXuan Hu s"the input UInt width(${uint.getWidth}) should be ${this.width}" 22*92c61038SXuan Hu ) 23*92c61038SXuan Hu } 24d7c51068SXuan Hu} 25