Generic definitions for registers.
define a register read function.
case class RegReadFn private(combinational: Boolean, fn: (Bool, Bool) => (Bool, Bool, UInt))
- combinational
Boolean
whether to allowin.ready
depending onout.ready
- fn
(in.valid:Bool, out.ready:Bool) => (in.ready:Bool, out.valid:Bool, data:UInt)
the read function.
RegReadFn generator.
- apply
((Bool, Bool) => (Bool, Bool, UInt)) => RegReadFn
(implicit) direct function definition. - apply
((out.ready) => (out.valid, data:UInt)) => RegReadFn
(implicit) simplified function definition. - apply
(RegisterReadIO[UInt]) => RegReadFn
(implicit) convert aRegisterReadIO
to a read function. - apply
(ReadyValidIO[UInt]) => RegReadFn
(implicit) convert aReadyValidIO
to a read function. - apply
(UInt) => RegReadFn
(implicit) read from a register. - apply
(Unit) => RegReadFn
(implicit) get always 0 read function.
define a register write function.
case class RegWriteFn private(combinational: Boolean, fn: (Bool, Bool, UInt) => (Bool, Bool))
- combinational
Boolean
whether to allowin.ready
depending onout.ready
- fn
(in.valid:Bool, out.ready:Bool, data:UInt) => (in.ready:Bool, out.valid:Bool)
the write function.
RegWriteFn generator.
- apply
((Bool, Bool, UInt) => (Bool, Bool)) => RegWriteFn
(implicit) direct function definition. - apply
((out.ready, data:UInt) => (out.valid)) => RegWriteFn
(implicit) simplified function definition. - apply
(RegisterWriteIO[UInt]) => RegWriteFn
(implicit) convert aRegisterWriteIO
to a write function. - apply
(DecoupledIO[UInt]) => RegWriteFn
(implicit) convert aDecoupledIO
to a write function. - apply
(UInt) => RegWriteFn
(implicit) write to a register. - apply
(Unit) => RegWriteFn
(implicit) get always ready write function but actually write nothing.
A generic register.
case class RegField(width: Int, read: RegReadFn, write: RegWriteFn, name: String, description: String)
- width
Int
the bit width of the register. - read
RegReadFn
the read function. - write
RegWriteFn
the write function. - name
String
the name of the register. - description
String
the description of the register. - pipelined
() => Boolean
in.ready
does not depend onout.ready
for either read or write or both. - readOnly
() => RegField
get a read only version of this register.
Register generator
- Map
(Int -> Seq[RegField])
(type) Register field definition: byte address -> sequence of bit fields - apply
(n:Int) => RegField
get a dummy n bit wide register. - apply
(Int, RegReadFn, RegWriteFn) => RegField
get an annonymas register. - apply
(Int, rw: UInt) => RegField
get a plain register (setrw
to aReg
). - apply
(Int, UInt, String, String) => RegField
get a named register. - apply
(Int, RegReadFn, String, String) => RegField
get a named readonly register. - apply
(Int, RegWriteFn, String, String) => RegField
get a named writeonly register. - w1ToClear
(Int, UInt, String, set: UInt) => RegField
get a register that has a always 1 set of bits defined byset
and when writing 1 to an unset bit clears it. - rwReg
(Int, SimpleRegIO) => RegField
wrap a blackbox register into a RW register. - bytes
(reg: UInt, numBytes: Int) => Seq[RegField]
Create byte-sized read-write RegFields out of a large UInt register. It is updated when any of the bytes are written. Because the RegFields are all byte-sized, this is also suitable when a register is larger than the intended bus width of the device (atomic updates are impossible).
A trait extended by Module implementations to define the register file and the interrupts.
- regmap
(mapping: RegField.Map*) => Unit
- interrupts
Vec[Bool]
Last updated: 26/09/2017
CC BY-NC-SA 4.0, © (2017) Wei Song
Apache 2.0, © (2016-2017) SiFive, Inc
BSD, © (2012-2014, 2016) The Regents of the University of California (Regents)