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