From 7556dca4f6cf682e3c76ed3c2b9adcb3e44a4398 Mon Sep 17 00:00:00 2001 From: TQ Hirsch Date: Wed, 20 Sep 2023 09:25:49 +0200 Subject: [PATCH] Successfully runs EKBA --- .../com/thequux/mcpdp/ext/bit/formatting.kt | 5 ++++ .../com/thequux/mcpdp/peripheral/DL11.kt | 6 +++-- .../com/thequux/mcpdp/peripheral/Unibus.kt | 23 +++++++++++++++---- 3 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 src/main/kotlin/com/thequux/mcpdp/ext/bit/formatting.kt diff --git a/src/main/kotlin/com/thequux/mcpdp/ext/bit/formatting.kt b/src/main/kotlin/com/thequux/mcpdp/ext/bit/formatting.kt new file mode 100644 index 0000000..6db9c09 --- /dev/null +++ b/src/main/kotlin/com/thequux/mcpdp/ext/bit/formatting.kt @@ -0,0 +1,5 @@ +package com.thequux.mcpdp.ext.bit + +fun UShort.toOctal(): String = this.toString(8).padStart(6,'0') +fun UByte.toOctal(): String = this.toString(8).padStart(3, '0') +fun UInt.toOctal(): String = this.toString(8).padStart(11, '0') diff --git a/src/main/kotlin/com/thequux/mcpdp/peripheral/DL11.kt b/src/main/kotlin/com/thequux/mcpdp/peripheral/DL11.kt index 37eb143..194f410 100644 --- a/src/main/kotlin/com/thequux/mcpdp/peripheral/DL11.kt +++ b/src/main/kotlin/com/thequux/mcpdp/peripheral/DL11.kt @@ -8,6 +8,7 @@ import com.thequux.mcpdp.ext.bit.bic import com.thequux.mcpdp.ext.bit.bis import com.thequux.mcpdp.ext.bit.bit import com.thequux.mcpdp.ext.bit.maskSet +import org.slf4j.LoggerFactory import java.io.InputStream import java.io.OutputStream import java.io.InterruptedIOException @@ -18,6 +19,7 @@ import kotlin.concurrent.thread class DL11(private var istr: InputStream, private val ostr: OutputStream, val reg_base: UInt, val vector: UShort, val unibus: Unibus): PAddressSpace, Peripheral { + private val logger = LoggerFactory.getLogger(this.javaClass) private var reader: Thread? = null private var rcsr: UShort = 0x0u set(value) { @@ -78,9 +80,9 @@ class DL11(private var istr: InputStream, private val ostr: OutputStream, val re } override fun setb(addr: UInt, value: UByte) { - when (addr.toInt() and 7) { - 0 -> setw(0u, value.toUShort()) // high bits are unaffected + if (!(addr bit 0)) { + setw(addr, value.toUShort()) } } diff --git a/src/main/kotlin/com/thequux/mcpdp/peripheral/Unibus.kt b/src/main/kotlin/com/thequux/mcpdp/peripheral/Unibus.kt index f40ff27..277cbec 100644 --- a/src/main/kotlin/com/thequux/mcpdp/peripheral/Unibus.kt +++ b/src/main/kotlin/com/thequux/mcpdp/peripheral/Unibus.kt @@ -4,8 +4,10 @@ import com.thequux.mcpdp.core.BusTimeoutError import com.thequux.mcpdp.core.MemoryError import com.thequux.mcpdp.core.MemoryErrorType import com.thequux.mcpdp.core.PAddressSpace +import com.thequux.mcpdp.ext.bit.toOctal import com.thequux.mcpdp.util.ConfigurationError import com.thequux.mcpdp.util.ProgrammerError +import org.slf4j.LoggerFactory import java.lang.Integer.min import java.util.Collections import java.util.LinkedList @@ -72,15 +74,28 @@ class Unibus: PAddressSpace, Subregion(12, 6) { /// The view of the unibus from a device var deviceView: PAddressSpace = this internal set + private val logger = LoggerFactory.getLogger(this.javaClass) private val queue: Array> = Array(8) { Vector(4) } override fun map(address: UInt): PAddressSpace = super.map(address) ?: throw BusTimeoutError(address) - override fun getw(addr: UInt): UShort = map(addr).getw(addr) - override fun getb(addr: UInt): UByte = map(addr).getb(addr) - override fun setw(addr: UInt, value: UShort) = map(addr).setw(addr, value) - override fun setb(addr: UInt, value: UByte) = map(addr).setb(addr, value) + override fun getw(addr: UInt): UShort { + if (logger.isTraceEnabled) logger.trace("DATIW ${addr.toOctal()}") + return map(addr).getw(addr) + } + override fun getb(addr: UInt): UByte { + if (logger.isTraceEnabled) logger.trace("DATIB ${addr.toOctal()}") + return map(addr).getb(addr) + } + override fun setw(addr: UInt, value: UShort) { + if (logger.isTraceEnabled) logger.trace("DATOW ${addr.toOctal()} <- ${value.toOctal()}") + map(addr).setw(addr, value) + } + override fun setb(addr: UInt, value: UByte) { + if (logger.isTraceEnabled) logger.trace("DATOB ${addr.toOctal()} <- ${value.toOctal()}") + map(addr).setb(addr, value) + } /// Request that the processor service an interrupt. When the interrupt is handled, calls getVector() on the device /// to fetch the currently desired interrupt vector