Added gpio input buffer to remove unknown data bits.
diff --git a/verilog/rtl/Peripherals/IOMultiplexer/GenerateGPIOAssigns.py b/verilog/rtl/Peripherals/IOMultiplexer/GenerateGPIOAssigns.py
index dff217c..299ba63 100644
--- a/verilog/rtl/Peripherals/IOMultiplexer/GenerateGPIOAssigns.py
+++ b/verilog/rtl/Peripherals/IOMultiplexer/GenerateGPIOAssigns.py
@@ -194,31 +194,31 @@
 		outputLines.append(f"	assign gpio_input[PIN_{pinName}] = 1'b0;\n")
 		outputLines.append(f"	assign io_out[PIN_{pinName}] = 1'b0;\n")
 		outputLines.append(f"	assign io_oeb[PIN_{pinName}] = {IO_INPUT};\n")
-		outputLines.append(f"	assign {pinName.lower()} = io_in[PIN_{pinName}];\n")
+		outputLines.append(f"	assign {pinName.lower()} = inputBuffer[PIN_{pinName}];\n")
 
 def writeIRQPin(outputLines:list[str], pinName:str, allowGPIO:bool):
 	if allowGPIO:
-		outputLines.append(f"	assign gpio_input[PIN_{pinName}] = irq_en ? 1'b0 : io_in[PIN_{pinName}];\n")
+		outputLines.append(f"	assign gpio_input[PIN_{pinName}] = irq_en ? 1'b0 : gpio_oe[PIN_{pinName}] ? inputBuffer[PIN_{pinName}] : 1'b0;\n")
 		outputLines.append(f"	assign io_out[PIN_{pinName}] = irq_en ? 1'b0 : gpio_output[PIN_{pinName}];\n")
 		outputLines.append(f"	assign io_oeb[PIN_{pinName}] = irq_en ? {IO_INPUT} : gpio_oe[PIN_{pinName}];\n")
-		outputLines.append(f"	assign irq_in = irq_en ? io_in[PIN_{pinName}] : 1'b0;\n")
+		outputLines.append(f"	assign irq_in = irq_en ? inputBuffer[PIN_{pinName}] : 1'b0;\n")
 	else:
 		outputLines.append(f"	assign gpio_input[PIN_{pinName}] = 1'b0;\n")
 		outputLines.append(f"	assign io_out[PIN_{pinName}] = 1'b0;\n")
 		outputLines.append(f"	assign io_oeb[PIN_{pinName}] = {IO_INPUT};\n")
-		outputLines.append(f"	assign irq_in = io_in[PIN_{pinName}];\n")
+		outputLines.append(f"	assign irq_in = inputBuffer[PIN_{pinName}];\n")
 
 def writeFlashPin(outputLines:list[str], pinName:str, isOutput:bool, pinType:str, allowGPIO:bool):
 	if allowGPIO:
 		if isOutput:
-			outputLines.append(f"	assign gpio_input[PIN_{pinName}] = flash_en ? 1'b0 : io_in[PIN_{pinName}];\n")
+			outputLines.append(f"	assign gpio_input[PIN_{pinName}] = flash_en ? 1'b0 : gpio_oe[PIN_{pinName}] ? inputBuffer[PIN_{pinName}] : 1'b0;\n")
 			outputLines.append(f"	assign io_out[PIN_{pinName}] = flash_en ? flash_{pinType.lower()} : gpio_output[PIN_{pinName}];\n")
 			outputLines.append(f"	assign io_oeb[PIN_{pinName}] = flash_en ? {IO_OUTPUT} : gpio_oe[PIN_{pinName}];\n")
 		else:
-			outputLines.append(f"	assign gpio_input[PIN_{pinName}] = flash_en ? 1'b0 : io_in[PIN_{pinName}];\n")
+			outputLines.append(f"	assign gpio_input[PIN_{pinName}] = flash_en ? 1'b0 : gpio_oe[PIN_{pinName}] ? inputBuffer[PIN_{pinName}] : 1'b0;\n")
 			outputLines.append(f"	assign io_out[PIN_{pinName}] = flash_en ? flash_{pinType.lower()}_write : gpio_output[PIN_{pinName}];\n")
 			outputLines.append(f"	assign io_oeb[PIN_{pinName}] = flash_en ? !flash_{pinType.lower()}_we : gpio_oe[PIN_{pinName}];\n")
-			outputLines.append(f"	assign flash_{pinType.lower()}_read = flash_en && !flash_{pinType.lower()}_we ? io_in[PIN_{pinName}] : 1'b0;\n")
+			outputLines.append(f"	assign flash_{pinType.lower()}_read = flash_en && !flash_{pinType.lower()}_we ? inputBuffer[PIN_{pinName}] : 1'b0;\n")
 	else:
 		if isOutput:
 			outputLines.append(f"	assign gpio_input[PIN_{pinName}] = 1'b0;\n")
@@ -228,19 +228,19 @@
 			outputLines.append(f"	assign gpio_input[PIN_{pinName}] = 1'b0;\n")
 			outputLines.append(f"	assign io_out[PIN_{pinName}] = flash_{pinType.lower()}_write;\n")
 			outputLines.append(f"	assign io_oeb[PIN_{pinName}] = !flash_{pinType.lower()}_we;\n")
-			outputLines.append(f"	assign flash_{pinType.lower()}_read = !flash_{pinType.lower()}_we ? io_in[PIN_{pinName}] : 1'b0;\n")
+			outputLines.append(f"	assign flash_{pinType.lower()}_read = !flash_{pinType.lower()}_we ? inputBuffer[PIN_{pinName}] : 1'b0;\n")
 
 def writeUARTPin(outputLines:list[str], pinName:str, uartIndex:int, isOutput:bool, allowGPIO:bool):
 	if allowGPIO:
 		if isOutput:
-			outputLines.append(f"	assign gpio_input[PIN_{pinName}] = uart_en[{uartIndex}] ? 1'b0 : io_in[PIN_{pinName}];\n")
+			outputLines.append(f"	assign gpio_input[PIN_{pinName}] = uart_en[{uartIndex}] ? 1'b0 : gpio_oe[PIN_{pinName}] ? inputBuffer[PIN_{pinName}] : 1'b0;\n")
 			outputLines.append(f"	assign io_out[PIN_{pinName}] = uart_en[{uartIndex}] ? uart_tx[{uartIndex}] : gpio_output[PIN_{pinName}];\n")
 			outputLines.append(f"	assign io_oeb[PIN_{pinName}] = uart_en[{uartIndex}] ? {IO_OUTPUT} : gpio_oe[PIN_{pinName}];\n")
 		else:
-			outputLines.append(f"	assign gpio_input[PIN_{pinName}] = uart_en[{uartIndex}] ? 1'b0 : io_in[PIN_{pinName}];\n")
+			outputLines.append(f"	assign gpio_input[PIN_{pinName}] = uart_en[{uartIndex}] ? 1'b0 : gpio_oe[PIN_{pinName}] ? inputBuffer[PIN_{pinName}] : 1'b0;\n")
 			outputLines.append(f"	assign io_out[PIN_{pinName}] = uart_en[{uartIndex}] ? 1'b0 : gpio_output[PIN_{pinName}];\n")
 			outputLines.append(f"	assign io_oeb[PIN_{pinName}] = uart_en[{uartIndex}] ? {IO_INPUT} : gpio_oe[PIN_{pinName}];\n")
-			outputLines.append(f"	assign uart_rx[{uartIndex}] = uart_en[{uartIndex}] ? io_in[PIN_{pinName}] : 1'b1;\n") # UART Rx defaults to high when not in use
+			outputLines.append(f"	assign uart_rx[{uartIndex}] = uart_en[{uartIndex}] ? inputBuffer[PIN_{pinName}] : 1'b1;\n") # UART Rx defaults to high when not in use
 	else:
 		if isOutput:
 			outputLines.append(f"	assign gpio_input[PIN_{pinName}] = 1'b0;\n")
@@ -250,11 +250,11 @@
 			outputLines.append(f"	assign gpio_input[PIN_{pinName}] = 1'b0;\n")
 			outputLines.append(f"	assign io_out[PIN_{pinName}] = 1'b0;\n")
 			outputLines.append(f"	assign io_oeb[PIN_{pinName}] = {IO_INPUT};\n")
-			outputLines.append(f"	assign uart_rx[{uartIndex}] = io_in[PIN_{pinName}];\n")
+			outputLines.append(f"	assign uart_rx[{uartIndex}] = inputBuffer[PIN_{pinName}];\n")
 
 def writePWMPin(outputLines:list[str], pinName:str, pwmIndex:int, allowGPIO:bool):
 	if allowGPIO:
-		outputLines.append(f"	assign gpio_input[PIN_{pinName}] = pwm_en[{pwmIndex}] ? 1'b0 : io_in[PIN_{pinName}];\n")
+		outputLines.append(f"	assign gpio_input[PIN_{pinName}] = pwm_en[{pwmIndex}] ? 1'b0 : gpio_oe[PIN_{pinName}] ? inputBuffer[PIN_{pinName}] : 1'b0;\n")
 		outputLines.append(f"	assign io_out[PIN_{pinName}] = pwm_en[{pwmIndex}] ? pwm_out[{pwmIndex}] : gpio_output[PIN_{pinName}];\n")
 		outputLines.append(f"	assign io_oeb[PIN_{pinName}] = pwm_en[{pwmIndex}] ? {IO_OUTPUT} : gpio_oe[PIN_{pinName}];\n")
 	else:
@@ -265,14 +265,14 @@
 def writeSPIPin(outputLines:list[str], pinName:str, spiIndex:int, isOutput:bool, pinType:str, allowGPIO:bool):
 	if allowGPIO:
 		if isOutput:
-			outputLines.append(f"	assign gpio_input[PIN_{pinName}] = spi_en[{spiIndex}] ? 1'b0 : io_in[PIN_{pinName}];\n")
+			outputLines.append(f"	assign gpio_input[PIN_{pinName}] = spi_en[{spiIndex}] ? 1'b0 : gpio_oe[PIN_{pinName}] ? inputBuffer[PIN_{pinName}] : 1'b0;\n")
 			outputLines.append(f"	assign io_out[PIN_{pinName}] = spi_en[{spiIndex}] ? spi_{pinType.lower()}[{spiIndex}] : gpio_output[PIN_{pinName}];\n")
 			outputLines.append(f"	assign io_oeb[PIN_{pinName}] = spi_en[{spiIndex}] ? {IO_OUTPUT} : gpio_oe[PIN_{pinName}];\n")
 		else:
-			outputLines.append(f"	assign gpio_input[PIN_{pinName}] = spi_en[{spiIndex}] ? 1'b0 : io_in[PIN_{pinName}];\n")
+			outputLines.append(f"	assign gpio_input[PIN_{pinName}] = spi_en[{spiIndex}] ? 1'b0 : gpio_oe[PIN_{pinName}] ? inputBuffer[PIN_{pinName}] : 1'b0;\n")
 			outputLines.append(f"	assign io_out[PIN_{pinName}] = spi_en[{spiIndex}] ? 1'b0 : gpio_output[PIN_{pinName}];\n")
 			outputLines.append(f"	assign io_oeb[PIN_{pinName}] = spi_en[{spiIndex}] ? {IO_INPUT} : gpio_oe[PIN_{pinName}];\n")
-			outputLines.append(f"	assign spi_{pinType.lower()}[{spiIndex}] = spi_en[{spiIndex}] ? io_in[PIN_{pinName}] : 1'b0;\n")
+			outputLines.append(f"	assign spi_{pinType.lower()}[{spiIndex}] = spi_en[{spiIndex}] ? inputBuffer[PIN_{pinName}] : 1'b0;\n")
 	else:
 		if isOutput:
 			outputLines.append(f"	assign gpio_input[PIN_{pinName}] = 1'b0;\n")
@@ -282,16 +282,16 @@
 			outputLines.append(f"	assign gpio_input[PIN_{pinName}] = 1'b0;\n")
 			outputLines.append(f"	assign io_out[PIN_{pinName}] = 1'b0;\n")
 			outputLines.append(f"	assign io_oeb[PIN_{pinName}] = {IO_INPUT};\n")
-			outputLines.append(f"	assign spi_{pinType.lower()}[{spiIndex}] = io_in[PIN_{pinName}];\n")
+			outputLines.append(f"	assign spi_{pinType.lower()}[{spiIndex}] = inputBuffer[PIN_{pinName}];\n")
 
 def writeVGAPin(outputLines:list[str], pinName:str, pinType:str, pinIndex:int, allowGPIO:bool):
 	if allowGPIO:
 		if pinIndex >= 0:
-			outputLines.append(f"	assign gpio_input[PIN_{pinName}] = vgaEnable ? 1'b0 : io_in[PIN_{pinName}];\n")
+			outputLines.append(f"	assign gpio_input[PIN_{pinName}] = vgaEnable ? 1'b0 : gpio_oe[PIN_{pinName}] ? inputBuffer[PIN_{pinName}] : 1'b0;\n")
 			outputLines.append(f"	assign io_out[PIN_{pinName}] = vgaEnable ? vga_{pinType.lower()}[{pinIndex}] : gpio_output[PIN_{pinName}];\n")
 			outputLines.append(f"	assign io_oeb[PIN_{pinName}] = vgaEnable ?{IO_OUTPUT} : gpio_oe[PIN_{pinName}];\n")
 		else:
-			outputLines.append(f"	assign gpio_input[PIN_{pinName}] = vgaEnable ? 1'b0 : io_in[PIN_{pinName}];\n")
+			outputLines.append(f"	assign gpio_input[PIN_{pinName}] = vgaEnable ? 1'b0 : gpio_oe[PIN_{pinName}] ? inputBuffer[PIN_{pinName}] : 1'b0;\n")
 			outputLines.append(f"	assign io_out[PIN_{pinName}] = vgaEnable ? vga_{pinType.lower()} : gpio_output[PIN_{pinName}];\n")
 			outputLines.append(f"	assign io_oeb[PIN_{pinName}] = vgaEnable ?{IO_OUTPUT} : gpio_oe[PIN_{pinName}];\n")
 	else:
@@ -306,7 +306,7 @@
 
 def writeBlinkPin(outputLines:list[str], pinName:str, blinkIndex:int, allowGPIO:bool):
 	if allowGPIO:
-		outputLines.append(f"	assign gpio_input[PIN_{pinName}] = blinkEnabled ? 1'b0 : io_in[PIN_{pinName}];\n")
+		outputLines.append(f"	assign gpio_input[PIN_{pinName}] = blinkEnabled ? 1'b0 : gpio_oe[PIN_{pinName}] ? inputBuffer[PIN_{pinName}] : 1'b0;\n")
 		outputLines.append(f"	assign io_out[PIN_{pinName}] = blinkEnabled ? blink[{blinkIndex}] : gpio_output[PIN_{pinName}];\n")
 		outputLines.append(f"	assign io_oeb[PIN_{pinName}] = blinkEnabled ? {IO_OUTPUT} : gpio_oe[PIN_{pinName}];\n")
 	else:
@@ -317,11 +317,11 @@
 def writeUndefinedPin(outputLines:list[str], pinName:str, isOutput:bool, allowGPIO:bool):
 	if allowGPIO:
 		if isOutput:
-			outputLines.append(f"	assign gpio_input[PIN_{pinName}] = io_in[PIN_{pinName}];\n")
+			outputLines.append(f"	assign gpio_input[PIN_{pinName}] = gpio_oe[PIN_{pinName}] ? inputBuffer[PIN_{pinName}] : 1'b0;\n")
 			outputLines.append(f"	assign io_out[PIN_{pinName}] = gpio_output[PIN_{pinName}];\n")
 			outputLines.append(f"	assign io_oeb[PIN_{pinName}] = gpio_oe[PIN_{pinName}];\n")
 		else:
-			outputLines.append(f"	assign gpio_input[PIN_{pinName}] = io_in[PIN_{pinName}];\n")
+			outputLines.append(f"	assign gpio_input[PIN_{pinName}] = gpio_oe[PIN_{pinName}] ? inputBuffer[PIN_{pinName}] : 1'b0;\n")
 			outputLines.append(f"	assign io_out[PIN_{pinName}] = gpio_output[PIN_{pinName}];\n")
 			outputLines.append(f"	assign io_oeb[PIN_{pinName}] = gpio_oe[PIN_{pinName}];\n")
 	else:
diff --git a/verilog/rtl/Peripherals/IOMultiplexer/IOMultiplexer_top.v b/verilog/rtl/Peripherals/IOMultiplexer/IOMultiplexer_top.v
index bbb555c..b2c20ea 100644
--- a/verilog/rtl/Peripherals/IOMultiplexer/IOMultiplexer_top.v
+++ b/verilog/rtl/Peripherals/IOMultiplexer/IOMultiplexer_top.v
@@ -64,6 +64,14 @@
 		output wire[1:0] probe_blink
 	);
 
+	// Buffer inputs
+	wire[`MPRJ_IO_PADS-1:0] inputBuffer;
+
+	genvar i;
+	generate
+		for (i = 0; i < `MPRJ_IO_PADS; i = i + 1) assign inputBuffer[i] = (io_in[i] === 1'dx) ? 1'b0 : io_in[i];
+	endgenerate
+
 	// Test blink
 	localparam BLINK_CLOCK_DIV = 26;
 	reg blinkEnabled = 1'b1;
@@ -140,7 +148,7 @@
 	assign gpio_input[PIN_JTAG] = 1'b0;
 	assign io_out[PIN_JTAG] = 1'b0;
 	assign io_oeb[PIN_JTAG] = 1'b1;
-	assign jtag = io_in[PIN_JTAG];
+	assign jtag = inputBuffer[PIN_JTAG];
 	
 	// IO01-PIN_SDO: Output
 	localparam PIN_SDO = 1;
@@ -153,28 +161,28 @@
 	assign gpio_input[PIN_SDI] = 1'b0;
 	assign io_out[PIN_SDI] = 1'b0;
 	assign io_oeb[PIN_SDI] = 1'b1;
-	assign sdi = io_in[PIN_SDI];
+	assign sdi = inputBuffer[PIN_SDI];
 	
 	// IO03-PIN_CSB: Input
 	localparam PIN_CSB = 3;
 	assign gpio_input[PIN_CSB] = 1'b0;
 	assign io_out[PIN_CSB] = 1'b0;
 	assign io_oeb[PIN_CSB] = 1'b1;
-	assign csb = io_in[PIN_CSB];
+	assign csb = inputBuffer[PIN_CSB];
 	
 	// IO04-PIN_SCK: Input
 	localparam PIN_SCK = 4;
 	assign gpio_input[PIN_SCK] = 1'b0;
 	assign io_out[PIN_SCK] = 1'b0;
 	assign io_oeb[PIN_SCK] = 1'b1;
-	assign sck = io_in[PIN_SCK];
+	assign sck = inputBuffer[PIN_SCK];
 	
 	// IO05-PIN_UART1_RX: Input
 	localparam PIN_UART1_RX = 5;
 	assign gpio_input[PIN_UART1_RX] = 1'b0;
 	assign io_out[PIN_UART1_RX] = 1'b0;
 	assign io_oeb[PIN_UART1_RX] = 1'b1;
-	assign uart_rx[1] = io_in[PIN_UART1_RX];
+	assign uart_rx[1] = inputBuffer[PIN_UART1_RX];
 	
 	// IO06-PIN_UART1_TX: Output
 	localparam PIN_UART1_TX = 6;
@@ -184,10 +192,10 @@
 	
 	// IO07-PIN_IRQ: Input
 	localparam PIN_IRQ = 7;
-	assign gpio_input[PIN_IRQ] = irq_en ? 1'b0 : io_in[PIN_IRQ];
+	assign gpio_input[PIN_IRQ] = irq_en ? 1'b0 : gpio_oe[PIN_IRQ] ? inputBuffer[PIN_IRQ] : 1'b0;
 	assign io_out[PIN_IRQ] = irq_en ? 1'b0 : gpio_output[PIN_IRQ];
 	assign io_oeb[PIN_IRQ] = irq_en ? 1'b1 : gpio_oe[PIN_IRQ];
-	assign irq_in = irq_en ? io_in[PIN_IRQ] : 1'b0;
+	assign irq_in = irq_en ? inputBuffer[PIN_IRQ] : 1'b0;
 	
 	// IO08-PIN_FLASH_CSB: Output
 	localparam PIN_FLASH_CSB = 8;
@@ -206,123 +214,123 @@
 	assign gpio_input[PIN_FLASH_IO0] = 1'b0;
 	assign io_out[PIN_FLASH_IO0] = flash_io0_write;
 	assign io_oeb[PIN_FLASH_IO0] = !flash_io0_we;
-	assign flash_io0_read = !flash_io0_we ? io_in[PIN_FLASH_IO0] : 1'b0;
+	assign flash_io0_read = !flash_io0_we ? inputBuffer[PIN_FLASH_IO0] : 1'b0;
 	
 	// IO11-PIN_FLASH_IO1: InOut
 	localparam PIN_FLASH_IO1 = 11;
 	assign gpio_input[PIN_FLASH_IO1] = 1'b0;
 	assign io_out[PIN_FLASH_IO1] = flash_io1_write;
 	assign io_oeb[PIN_FLASH_IO1] = !flash_io1_we;
-	assign flash_io1_read = !flash_io1_we ? io_in[PIN_FLASH_IO1] : 1'b0;
+	assign flash_io1_read = !flash_io1_we ? inputBuffer[PIN_FLASH_IO1] : 1'b0;
 	
 	// IO12-PIN_PWM0: Output
 	localparam PIN_PWM0 = 12;
-	assign gpio_input[PIN_PWM0] = pwm_en[0] ? 1'b0 : io_in[PIN_PWM0];
+	assign gpio_input[PIN_PWM0] = pwm_en[0] ? 1'b0 : gpio_oe[PIN_PWM0] ? inputBuffer[PIN_PWM0] : 1'b0;
 	assign io_out[PIN_PWM0] = pwm_en[0] ? pwm_out[0] : gpio_output[PIN_PWM0];
 	assign io_oeb[PIN_PWM0] = pwm_en[0] ? 1'b0 : gpio_oe[PIN_PWM0];
 	
 	// IO13-PIN_PWM1: Output
 	localparam PIN_PWM1 = 13;
-	assign gpio_input[PIN_PWM1] = pwm_en[1] ? 1'b0 : io_in[PIN_PWM1];
+	assign gpio_input[PIN_PWM1] = pwm_en[1] ? 1'b0 : gpio_oe[PIN_PWM1] ? inputBuffer[PIN_PWM1] : 1'b0;
 	assign io_out[PIN_PWM1] = pwm_en[1] ? pwm_out[1] : gpio_output[PIN_PWM1];
 	assign io_oeb[PIN_PWM1] = pwm_en[1] ? 1'b0 : gpio_oe[PIN_PWM1];
 	
 	// IO14-PIN_PWM2: Output
 	localparam PIN_PWM2 = 14;
-	assign gpio_input[PIN_PWM2] = pwm_en[2] ? 1'b0 : io_in[PIN_PWM2];
+	assign gpio_input[PIN_PWM2] = pwm_en[2] ? 1'b0 : gpio_oe[PIN_PWM2] ? inputBuffer[PIN_PWM2] : 1'b0;
 	assign io_out[PIN_PWM2] = pwm_en[2] ? pwm_out[2] : gpio_output[PIN_PWM2];
 	assign io_oeb[PIN_PWM2] = pwm_en[2] ? 1'b0 : gpio_oe[PIN_PWM2];
 	
 	// IO15-PIN_PWM3: Output
 	localparam PIN_PWM3 = 15;
-	assign gpio_input[PIN_PWM3] = pwm_en[3] ? 1'b0 : io_in[PIN_PWM3];
+	assign gpio_input[PIN_PWM3] = pwm_en[3] ? 1'b0 : gpio_oe[PIN_PWM3] ? inputBuffer[PIN_PWM3] : 1'b0;
 	assign io_out[PIN_PWM3] = pwm_en[3] ? pwm_out[3] : gpio_output[PIN_PWM3];
 	assign io_oeb[PIN_PWM3] = pwm_en[3] ? 1'b0 : gpio_oe[PIN_PWM3];
 	
 	// IO16-PIN_PWM4: Output
 	localparam PIN_PWM4 = 16;
-	assign gpio_input[PIN_PWM4] = pwm_en[4] ? 1'b0 : io_in[PIN_PWM4];
+	assign gpio_input[PIN_PWM4] = pwm_en[4] ? 1'b0 : gpio_oe[PIN_PWM4] ? inputBuffer[PIN_PWM4] : 1'b0;
 	assign io_out[PIN_PWM4] = pwm_en[4] ? pwm_out[4] : gpio_output[PIN_PWM4];
 	assign io_oeb[PIN_PWM4] = pwm_en[4] ? 1'b0 : gpio_oe[PIN_PWM4];
 	
 	// IO17-PIN_PWM5: Output
 	localparam PIN_PWM5 = 17;
-	assign gpio_input[PIN_PWM5] = pwm_en[5] ? 1'b0 : io_in[PIN_PWM5];
+	assign gpio_input[PIN_PWM5] = pwm_en[5] ? 1'b0 : gpio_oe[PIN_PWM5] ? inputBuffer[PIN_PWM5] : 1'b0;
 	assign io_out[PIN_PWM5] = pwm_en[5] ? pwm_out[5] : gpio_output[PIN_PWM5];
 	assign io_oeb[PIN_PWM5] = pwm_en[5] ? 1'b0 : gpio_oe[PIN_PWM5];
 	
 	// IO18-PIN_PWM6: Output
 	localparam PIN_PWM6 = 18;
-	assign gpio_input[PIN_PWM6] = pwm_en[6] ? 1'b0 : io_in[PIN_PWM6];
+	assign gpio_input[PIN_PWM6] = pwm_en[6] ? 1'b0 : gpio_oe[PIN_PWM6] ? inputBuffer[PIN_PWM6] : 1'b0;
 	assign io_out[PIN_PWM6] = pwm_en[6] ? pwm_out[6] : gpio_output[PIN_PWM6];
 	assign io_oeb[PIN_PWM6] = pwm_en[6] ? 1'b0 : gpio_oe[PIN_PWM6];
 	
 	// IO19-PIN_UART2_RX: Input
 	localparam PIN_UART2_RX = 19;
-	assign gpio_input[PIN_UART2_RX] = uart_en[2] ? 1'b0 : io_in[PIN_UART2_RX];
+	assign gpio_input[PIN_UART2_RX] = uart_en[2] ? 1'b0 : gpio_oe[PIN_UART2_RX] ? inputBuffer[PIN_UART2_RX] : 1'b0;
 	assign io_out[PIN_UART2_RX] = uart_en[2] ? 1'b0 : gpio_output[PIN_UART2_RX];
 	assign io_oeb[PIN_UART2_RX] = uart_en[2] ? 1'b1 : gpio_oe[PIN_UART2_RX];
-	assign uart_rx[2] = uart_en[2] ? io_in[PIN_UART2_RX] : 1'b1;
+	assign uart_rx[2] = uart_en[2] ? inputBuffer[PIN_UART2_RX] : 1'b1;
 	
 	// IO20-PIN_UART2_TX: Output
 	localparam PIN_UART2_TX = 20;
-	assign gpio_input[PIN_UART2_TX] = uart_en[2] ? 1'b0 : io_in[PIN_UART2_TX];
+	assign gpio_input[PIN_UART2_TX] = uart_en[2] ? 1'b0 : gpio_oe[PIN_UART2_TX] ? inputBuffer[PIN_UART2_TX] : 1'b0;
 	assign io_out[PIN_UART2_TX] = uart_en[2] ? uart_tx[2] : gpio_output[PIN_UART2_TX];
 	assign io_oeb[PIN_UART2_TX] = uart_en[2] ? 1'b0 : gpio_oe[PIN_UART2_TX];
 	
 	// IO21-PIN_PWM7: Output
 	localparam PIN_PWM7 = 21;
-	assign gpio_input[PIN_PWM7] = pwm_en[7] ? 1'b0 : io_in[PIN_PWM7];
+	assign gpio_input[PIN_PWM7] = pwm_en[7] ? 1'b0 : gpio_oe[PIN_PWM7] ? inputBuffer[PIN_PWM7] : 1'b0;
 	assign io_out[PIN_PWM7] = pwm_en[7] ? pwm_out[7] : gpio_output[PIN_PWM7];
 	assign io_oeb[PIN_PWM7] = pwm_en[7] ? 1'b0 : gpio_oe[PIN_PWM7];
 	
 	// IO22-PIN_SPI0_CLK: Output
 	localparam PIN_SPI0_CLK = 22;
-	assign gpio_input[PIN_SPI0_CLK] = spi_en[0] ? 1'b0 : io_in[PIN_SPI0_CLK];
+	assign gpio_input[PIN_SPI0_CLK] = spi_en[0] ? 1'b0 : gpio_oe[PIN_SPI0_CLK] ? inputBuffer[PIN_SPI0_CLK] : 1'b0;
 	assign io_out[PIN_SPI0_CLK] = spi_en[0] ? spi_clk[0] : gpio_output[PIN_SPI0_CLK];
 	assign io_oeb[PIN_SPI0_CLK] = spi_en[0] ? 1'b0 : gpio_oe[PIN_SPI0_CLK];
 	
 	// IO23-PIN_SPI0_MOSI: Output
 	localparam PIN_SPI0_MOSI = 23;
-	assign gpio_input[PIN_SPI0_MOSI] = spi_en[0] ? 1'b0 : io_in[PIN_SPI0_MOSI];
+	assign gpio_input[PIN_SPI0_MOSI] = spi_en[0] ? 1'b0 : gpio_oe[PIN_SPI0_MOSI] ? inputBuffer[PIN_SPI0_MOSI] : 1'b0;
 	assign io_out[PIN_SPI0_MOSI] = spi_en[0] ? spi_mosi[0] : gpio_output[PIN_SPI0_MOSI];
 	assign io_oeb[PIN_SPI0_MOSI] = spi_en[0] ? 1'b0 : gpio_oe[PIN_SPI0_MOSI];
 	
 	// IO24-PIN_SPI0_MISO: Input
 	localparam PIN_SPI0_MISO = 24;
-	assign gpio_input[PIN_SPI0_MISO] = spi_en[0] ? 1'b0 : io_in[PIN_SPI0_MISO];
+	assign gpio_input[PIN_SPI0_MISO] = spi_en[0] ? 1'b0 : gpio_oe[PIN_SPI0_MISO] ? inputBuffer[PIN_SPI0_MISO] : 1'b0;
 	assign io_out[PIN_SPI0_MISO] = spi_en[0] ? 1'b0 : gpio_output[PIN_SPI0_MISO];
 	assign io_oeb[PIN_SPI0_MISO] = spi_en[0] ? 1'b1 : gpio_oe[PIN_SPI0_MISO];
-	assign spi_miso[0] = spi_en[0] ? io_in[PIN_SPI0_MISO] : 1'b0;
+	assign spi_miso[0] = spi_en[0] ? inputBuffer[PIN_SPI0_MISO] : 1'b0;
 	
 	// IO25-PIN_SPI0_CS: Output
 	localparam PIN_SPI0_CS = 25;
-	assign gpio_input[PIN_SPI0_CS] = spi_en[0] ? 1'b0 : io_in[PIN_SPI0_CS];
+	assign gpio_input[PIN_SPI0_CS] = spi_en[0] ? 1'b0 : gpio_oe[PIN_SPI0_CS] ? inputBuffer[PIN_SPI0_CS] : 1'b0;
 	assign io_out[PIN_SPI0_CS] = spi_en[0] ? spi_cs[0] : gpio_output[PIN_SPI0_CS];
 	assign io_oeb[PIN_SPI0_CS] = spi_en[0] ? 1'b0 : gpio_oe[PIN_SPI0_CS];
 	
 	// IO26-PIN_UART3_RX: Input
 	localparam PIN_UART3_RX = 26;
-	assign gpio_input[PIN_UART3_RX] = uart_en[3] ? 1'b0 : io_in[PIN_UART3_RX];
+	assign gpio_input[PIN_UART3_RX] = uart_en[3] ? 1'b0 : gpio_oe[PIN_UART3_RX] ? inputBuffer[PIN_UART3_RX] : 1'b0;
 	assign io_out[PIN_UART3_RX] = uart_en[3] ? 1'b0 : gpio_output[PIN_UART3_RX];
 	assign io_oeb[PIN_UART3_RX] = uart_en[3] ? 1'b1 : gpio_oe[PIN_UART3_RX];
-	assign uart_rx[3] = uart_en[3] ? io_in[PIN_UART3_RX] : 1'b1;
+	assign uart_rx[3] = uart_en[3] ? inputBuffer[PIN_UART3_RX] : 1'b1;
 	
 	// IO27-PIN_UART3_TX: Output
 	localparam PIN_UART3_TX = 27;
-	assign gpio_input[PIN_UART3_TX] = uart_en[3] ? 1'b0 : io_in[PIN_UART3_TX];
+	assign gpio_input[PIN_UART3_TX] = uart_en[3] ? 1'b0 : gpio_oe[PIN_UART3_TX] ? inputBuffer[PIN_UART3_TX] : 1'b0;
 	assign io_out[PIN_UART3_TX] = uart_en[3] ? uart_tx[3] : gpio_output[PIN_UART3_TX];
 	assign io_oeb[PIN_UART3_TX] = uart_en[3] ? 1'b0 : gpio_oe[PIN_UART3_TX];
 	
 	// IO28-PIN_BLINK0: Output
 	localparam PIN_BLINK0 = 28;
-	assign gpio_input[PIN_BLINK0] = blinkEnabled ? 1'b0 : io_in[PIN_BLINK0];
+	assign gpio_input[PIN_BLINK0] = blinkEnabled ? 1'b0 : gpio_oe[PIN_BLINK0] ? inputBuffer[PIN_BLINK0] : 1'b0;
 	assign io_out[PIN_BLINK0] = blinkEnabled ? blink[0] : gpio_output[PIN_BLINK0];
 	assign io_oeb[PIN_BLINK0] = blinkEnabled ? 1'b0 : gpio_oe[PIN_BLINK0];
 	
 	// IO29-PIN_BLINK1: Output
 	localparam PIN_BLINK1 = 29;
-	assign gpio_input[PIN_BLINK1] = blinkEnabled ? 1'b0 : io_in[PIN_BLINK1];
+	assign gpio_input[PIN_BLINK1] = blinkEnabled ? 1'b0 : gpio_oe[PIN_BLINK1] ? inputBuffer[PIN_BLINK1] : 1'b0;
 	assign io_out[PIN_BLINK1] = blinkEnabled ? blink[1] : gpio_output[PIN_BLINK1];
 	assign io_oeb[PIN_BLINK1] = blinkEnabled ? 1'b0 : gpio_oe[PIN_BLINK1];