- // Allow SW Override for invalid inputs.
- iof0Ctrl(pin) <> swPinCtrl(pin)
- when (io.port.iof_0(pin).o.valid) {
- iof0Ctrl(pin) <> io.port.iof_0(pin).o
+ val pre_xor = Wire(new GPIOPinCtrl())
+
+ if (c.includeIOF) {
+ // Allow SW Override for invalid inputs.
+ iof0Ctrl(pin) <> swPinCtrl(pin)
+ when (io.port.iof_0.get(pin).o.valid) {
+ iof0Ctrl(pin) <> io.port.iof_0.get(pin).o
+ }
+
+ iof1Ctrl(pin) <> swPinCtrl(pin)
+ when (io.port.iof_1.get(pin).o.valid) {
+ iof1Ctrl(pin) <> io.port.iof_1.get(pin).o
+ }
+
+ // Select IOF 0 vs. IOF 1.
+ iofCtrl(pin) <> Mux(iofSelReg(pin), iof1Ctrl(pin), iof0Ctrl(pin))
+
+ // Allow SW Override for things IOF doesn't control.
+ iofPlusSwPinCtrl(pin) <> swPinCtrl(pin)
+ iofPlusSwPinCtrl(pin) <> iofCtrl(pin)
+
+ // Final XOR & Pin Control
+ pre_xor := Mux(iofEnReg.io.q(pin), iofPlusSwPinCtrl(pin), swPinCtrl(pin))
+ } else {
+ pre_xor := swPinCtrl(pin)