From 6ba9051db481c5fb66c2a6cdff80e9d0e6210f3c Mon Sep 17 00:00:00 2001 From: alshapton Date: Sat, 9 Oct 2021 22:12:11 +0100 Subject: [PATCH] More quality improvements Also - all tests now using convert_to_absolute_address --- pyntel4004/src/hardware/instructions/io_ram.py | 2 +- pyntel4004/src/hardware/suboperation.py | 2 +- .../test_0200_225_instruction_wmp-IN-PROGRESS.py | 6 +++--- .../test/06_io_ram/test_0200_233_instruction_rdm.py | 12 ++++++------ 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pyntel4004/src/hardware/instructions/io_ram.py b/pyntel4004/src/hardware/instructions/io_ram.py index 03e1a8b..ed65b4b 100644 --- a/pyntel4004/src/hardware/instructions/io_ram.py +++ b/pyntel4004/src/hardware/instructions/io_ram.py @@ -494,7 +494,7 @@ def sbm(self, register: int): address = self.COMMAND_REGISTER chip = int(bin(int(address)) [2:].zfill(8)[:2], 2) - register = int(bin(int(address))[2:].zfill(8)[2:4], 2) + register = int(bin(int(address))[2:].zfill(8)[2:4], 2) absolute_address = convert_to_absolute_address( self, crb, chip, register, address) value = self.RAM[absolute_address] diff --git a/pyntel4004/src/hardware/suboperation.py b/pyntel4004/src/hardware/suboperation.py index 08ca68f..22820a1 100644 --- a/pyntel4004/src/hardware/suboperation.py +++ b/pyntel4004/src/hardware/suboperation.py @@ -37,7 +37,7 @@ def convert_to_absolute_address(self, rambank, chip, register, address): """ absolute_address = (rambank * self.RAM_BANK_SIZE) + \ (chip * self.RAM_CHIP_SIZE) + \ - - (register * self.RAM_REGISTER_SIZE) + address + (register * self.RAM_REGISTER_SIZE) + address return absolute_address diff --git a/pyntel4004/test/06_io_ram/test_0200_225_instruction_wmp-IN-PROGRESS.py b/pyntel4004/test/06_io_ram/test_0200_225_instruction_wmp-IN-PROGRESS.py index e57ccf3..19ba492 100644 --- a/pyntel4004/test/06_io_ram/test_0200_225_instruction_wmp-IN-PROGRESS.py +++ b/pyntel4004/test/06_io_ram/test_0200_225_instruction_wmp-IN-PROGRESS.py @@ -37,9 +37,9 @@ def test_wrm_scenario1(rambank, chip, register, address): # Perform the instruction under test: chip_test.PROGRAM_COUNTER = 0 chip_test.CURRENT_RAM_BANK = rambank - absolute_address = (rambank * chip_test.RAM_BANK_SIZE) + \ - (chip * chip_test.RAM_CHIP_SIZE) + \ - (register * chip_test.RAM_REGISTER_SIZE) + address + + absolute_address = convert_to_absolute_address( + chip_test, rambank, chip, register, address) chip_test.set_accumulator(value) b_chip = decimal_to_binary(2, chip) b_register = decimal_to_binary(2, register) diff --git a/pyntel4004/test/06_io_ram/test_0200_233_instruction_rdm.py b/pyntel4004/test/06_io_ram/test_0200_233_instruction_rdm.py index 0e83df1..be24991 100644 --- a/pyntel4004/test/06_io_ram/test_0200_233_instruction_rdm.py +++ b/pyntel4004/test/06_io_ram/test_0200_233_instruction_rdm.py @@ -7,6 +7,7 @@ sys.path.insert(1, '../src') from hardware.processor import processor # noqa +from hardware.suboperation import convert_to_absolute_address # noqa def test_validate_rdm_instruction(): @@ -18,9 +19,9 @@ def test_validate_rdm_instruction(): assert op == known -@pytest.mark.parametrize("values", [[0, 1, 0, 7, 3], [1, 3, 1, 6, 4], [2, 5, 2, 5, 5], - [3, 7, 3, 4, 6], [4, 3, 4, 3, 7], [ - 5, 2, 5, 2, 2], +@pytest.mark.parametrize("values", [[0, 1, 0, 7, 3], [1, 3, 1, 6, 4], + [2, 5, 2, 5, 5], [3, 7, 3, 4, 6], + [4, 3, 4, 3, 7], [5, 2, 5, 2, 2], [6, 0, 6, 1, 1], [7, 4, 7, 0, 0]]) def test_rdm_scenario1(values): """Test RDM instruction functionality.""" @@ -35,9 +36,8 @@ def test_rdm_scenario1(values): # Perform the instruction under test: chip_test.CURRENT_RAM_BANK = rambank - absolute_address = (rambank * chip_test.RAM_BANK_SIZE) + \ - (chip * chip_test.RAM_CHIP_SIZE) + \ - (register * chip_test.RAM_REGISTER_SIZE) + address + absolute_address = convert_to_absolute_address( + chip_test, rambank, chip, register, address) chip_test.RAM[absolute_address] = value chip_test.set_accumulator(0) chip_test.COMMAND_REGISTER = absolute_address