summaryrefslogtreecommitdiff
path: root/src/main/scala/chisel/package.scala
blob: f7ed6b13941cf0a869feaba966012a84f01ad6cc (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package object chisel {
  import scala.language.experimental.macros

  import internal.firrtl.Width
  import internal.sourceinfo.{SourceInfo, SourceInfoTransform}
  import util.BitPat


  type Direction = chisel.core.Direction
  val INPUT = chisel.core.INPUT
  val OUTPUT = chisel.core.OUTPUT
  val NO_DIR = chisel.core.NO_DIR
  type Flipped = chisel.core.Flipped
  type Data = chisel.core.Data
  val Wire = chisel.core.Wire
  val Clock = chisel.core.Clock
  type Clock = chisel.core.Clock

  type Aggregate = chisel.core.Aggregate
  val Vec = chisel.core.Vec
  type Vec[T <: Data] = chisel.core.Vec[T]
  type VecLike[T <: Data] = chisel.core.VecLike[T]
  type Bundle = chisel.core.Bundle

  val assert = chisel.core.assert

  type Element = chisel.core.Element
  type Bits = chisel.core.Bits
  val Bits = chisel.core.Bits
  type Num[T <: Data] = chisel.core.Num[T]
  type UInt = chisel.core.UInt
  val UInt = chisel.core.UInt
  type SInt = chisel.core.SInt
  val SInt = chisel.core.SInt
  type Bool = chisel.core.Bool
  val Bool = chisel.core.Bool
  val Mux = chisel.core.Mux

  type BlackBox = chisel.core.BlackBox

  val Mem = chisel.core.Mem
  type MemBase[T <: Data] = chisel.core.MemBase[T]
  type Mem[T <: Data] = chisel.core.Mem[T]
  val SeqMem = chisel.core.SeqMem
  type SeqMem[T <: Data] = chisel.core.SeqMem[T]

  val Module = chisel.core.Module
  type Module = chisel.core.Module

  val printf = chisel.core.printf

  val Reg = chisel.core.Reg

  val when = chisel.core.when
  type WhenContext = chisel.core.WhenContext


  implicit class fromBigIntToLiteral(val x: BigInt) extends AnyVal {
    def U: UInt = UInt(x, Width())
    def S: SInt = SInt(x, Width())
  }
  implicit class fromIntToLiteral(val x: Int) extends AnyVal {
    def U: UInt = UInt(BigInt(x), Width())
    def S: SInt = SInt(BigInt(x), Width())
  }
  implicit class fromStringToLiteral(val x: String) extends AnyVal {
    def U: UInt = UInt(x)
  }
  implicit class fromBooleanToLiteral(val x: Boolean) extends AnyVal {
    def B: Bool = Bool(x)
  }

  implicit class fromUIntToBitPatComparable(val x: UInt) extends AnyVal {
    final def === (that: BitPat): Bool = macro SourceInfoTransform.thatArg
    final def != (that: BitPat): Bool = macro SourceInfoTransform.thatArg
    final def =/= (that: BitPat): Bool = macro SourceInfoTransform.thatArg

    def do_=== (that: BitPat)(implicit sourceInfo: SourceInfo): Bool = that === x
    def do_!= (that: BitPat)(implicit sourceInfo: SourceInfo): Bool = that != x
    def do_=/= (that: BitPat)(implicit sourceInfo: SourceInfo): Bool = that =/= x
  }
}