From 0765d399e56aa387674c3591ec4886cc37d8fccd Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Wed, 13 Mar 2019 13:54:32 +0100 Subject: Allow byte and half-word access to the peripherals. Signed-off-by: Pavel Pisa --- qtmips_machine/peripspiled.cpp | 4 ++-- qtmips_machine/serialport.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/qtmips_machine/peripspiled.cpp b/qtmips_machine/peripspiled.cpp index c4333e7..0404311 100644 --- a/qtmips_machine/peripspiled.cpp +++ b/qtmips_machine/peripspiled.cpp @@ -64,7 +64,7 @@ bool PeripSpiLed::wword(std::uint32_t address, std::uint32_t value) { printf("PeripSpiLed::wword address 0x%08lx data 0x%08lx\n", (unsigned long)address, (unsigned long)value); #endif - switch (address) { + switch (address & ~3) { case SPILED_REG_LED_LINE_o: spiled_reg_led_line = value; emit led_line_changed(value); @@ -90,7 +90,7 @@ std::uint32_t PeripSpiLed::rword(std::uint32_t address, bool debug_access) const (void)debug_access; std::uint32_t value = 0x00000000; - switch (address) { + switch (address & ~3) { case SPILED_REG_LED_LINE_o: value = spiled_reg_led_line; break; diff --git a/qtmips_machine/serialport.cpp b/qtmips_machine/serialport.cpp index 8db5725..f1cb620 100644 --- a/qtmips_machine/serialport.cpp +++ b/qtmips_machine/serialport.cpp @@ -83,7 +83,7 @@ bool SerialPort::wword(std::uint32_t address, std::uint32_t value) { #endif emit write_notification(address, value); - switch (address) { + switch (address & ~3) { case SERP_RX_ST_REG_o: rx_st_reg &= ~SERP_RX_ST_REG_IE_m; rx_st_reg |= value & SERP_RX_ST_REG_IE_m; @@ -110,7 +110,7 @@ std::uint32_t SerialPort::rword(std::uint32_t address, bool debug_access) const printf("SerialPort::rword address 0x%08lx\n", (unsigned long)address); #endif - switch (address) { + switch (address & ~3) { case SERP_RX_ST_REG_o: pool_rx_byte(); value = rx_st_reg; -- cgit v1.2.3