1 //See LICENSE for license details
3 package sifive.blocks.devices.pinctrl
7 // This is the base class of things you "always"
8 // want to control from a HW block.
9 class PinCtrl extends Bundle {
15 // Package up the inputs and outputs
17 abstract class Pin extends Bundle {
19 val ival = Bool(INPUT)
23 // Must be defined by the subclasses
24 def inputPin(pue: Bool = Bool(false)): Bool
25 def outputPin(signal: Bool,
26 pue: Bool = Bool(false),
27 ds: Bool = Bool(false),
28 ie: Bool = Bool(false)
31 def inputPin(pins: Vec[this.type], pue: Bool): Vec[Bool] = {
32 val signals = Wire(Vec(pins.length, new Bool()))
33 for ((signal, pin) <- (signals zip pins)) {
34 signal := pin.inputPin(pue)
41 ////////////////////////////////////////////////////////////////////////////////////
43 class BasePin extends Pin() {
44 val o = new PinCtrl().asOutput
46 def inputPin(pue: Bool = Bool(false) /*ignored*/): Bool = {
47 this.o.oval := Bool(false)
48 this.o.oe := Bool(false)
49 this.o.ie := Bool(true)
53 def outputPin(signal: Bool,
54 pue: Bool = Bool(false), /*ignored*/
55 ds: Bool = Bool(false), /*ignored*/
56 ie: Bool = Bool(false)
59 this.o.oe := Bool(true)
65 /////////////////////////////////////////////////////////////////////////
66 class EnhancedPinCtrl extends PinCtrl {
71 class EnhancedPin extends Pin() {
73 val o = new EnhancedPinCtrl().asOutput
75 def inputPin(pue: Bool = Bool(false)): Bool = {
76 this.o.oval := Bool(false)
77 this.o.oe := Bool(false)
79 this.o.ds := Bool(false)
80 this.o.ie := Bool(true)
85 def outputPin(signal: Bool,
86 pue: Bool = Bool(false),
87 ds: Bool = Bool(false),
88 ie: Bool = Bool(false)
91 this.o.oe := Bool(true)