summaryrefslogtreecommitdiff
path: root/core/src/main/scala/chisel3/internal/Warning.scala
blob: 5ac506c91777a4dc1431ef67cb3da57f214e3151 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// SPDX-License-Identifier: Apache-2.0

package chisel3.internal

///////////////////////////////////////////////////
// Never remove IDs and only ever add to the end //
///////////////////////////////////////////////////

// TODO should deprecations be included here?
private[chisel3] object WarningID extends Enumeration {
  type WarningID = Value

  val NoID = Value(0) // Reserved
  val UnsafeUIntCastToEnum = Value(1)
  val DynamicBitSelectTooWide = Value(2)
  val DynamicBitSelectTooNarrow = Value(3)
  val DynamicIndexTooWide = Value(4)
  val DynamicIndexTooNarrow = Value(5)
  val ExtractFromVecSizeZero = Value(6)
  val BundleLiteralValueTooWide = Value(7)
  val AsTypeOfReadOnly = Value(8)
}
import WarningID.WarningID

// Argument order differs from apply below to avoid type signature collision with apply method below
private[chisel3] case class Warning(id: WarningID, msg: String)
private[chisel3] object Warning {
  def apply(id: WarningID, msg: String): Warning = {
    val num = f"[W${id.id}%03d] "
    new Warning(info, id, num + msg)
  }
  def noInfo(id: WarningID, msg: String): Warning = {
    implicit val info = SourceInfo.materializeFromStacktrace
    Warning(id, msg)
  }
}