Skip to content

Commit

Permalink
add default field for DecodeField for DecodeTable non X case
Browse files Browse the repository at this point in the history
  • Loading branch information
sequencer committed Oct 2, 2023
1 parent 3b39bd8 commit a80c2e5
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ trait DecodeField[T <: DecodePattern, D <: Data] {

def chiselType: D

def default: BitPat = dc

final def width: Int = chiselType.getWidth

def dc: BitPat = BitPat.dontCare(width)

def genTable(op: T): BitPat

require(width == default.width)
}

/**
Expand Down Expand Up @@ -79,7 +83,11 @@ class DecodeTable[I <: DecodePattern](patterns: Seq[I], fields: Seq[DecodeField[
private val _table = patterns.map { op =>
op.bitPat -> fields.reverse.map(field => field.genTable(op)).reduce(_ ## _)
}
val table: TruthTable = TruthTable(_table, BitPat.dontCare(_table.head._2.getWidth))

val table: TruthTable = TruthTable(
patterns.map { op => op.bitPat -> fields.reverse.map(field => field.genTable(op)).reduce(_ ## _) },
fields.reverse.map(_.default).reduce(_ ## _)
)

def decode(input: UInt): DecodeBundle = chisel3.util.experimental.decode.decoder(input, table).asTypeOf(bundle)
}

0 comments on commit a80c2e5

Please sign in to comment.