From 7a3c18fd9777f940aff972ee2a8fa9a761050332 Mon Sep 17 00:00:00 2001 From: Daniel Kirschten Date: Wed, 30 Oct 2019 16:49:50 +0100 Subject: [PATCH] Am2900Machine now resets registers in strict mode too --- .../model/am2900/machine/Am2900Machine.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/machine/Am2900Machine.java b/plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/machine/Am2900Machine.java index 9cd8adcc..cb57ab89 100644 --- a/plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/machine/Am2900Machine.java +++ b/plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/machine/Am2900Machine.java @@ -88,27 +88,25 @@ public class Am2900Machine implements Machine defaultParams[19] = paramClassifications[19].parse("JZ"); MicroInstruction jzMI = MicroInstruction.create(defaultParams); am2900.setHighLevelState("muir_2.q", jzMI.toBitVector()); - if (!machineDefinition.strict) - { - setRegistersToZero(machineDefinition.getUnsortedRegisters()); - setRegisterGroupToZero(machineDefinition.getRegisterGroups()); - // TODO reset latches? - } + Bit regsValue = machineDefinition.strict ? Bit.U : Bit.ZERO; + setRegistersTo(machineDefinition.getUnsortedRegisters(), regsValue); + setRegisterGroupTo(machineDefinition.getRegisterGroups(), regsValue); + // TODO reset latches? } - private void setRegistersToZero(List registers) + private void setRegistersTo(List registers, Bit value) { for (Register r : registers) if (r != muInstrRegister.instance)// don't reset; sometimes causes a glitch - setRegister(r, BitVector.of(Bit.ZERO, r.getWidth())); + setRegister(r, BitVector.of(value, r.getWidth())); } - private void setRegisterGroupToZero(List registerGroups) + private void setRegisterGroupTo(List registerGroups, Bit value) { for (RegisterGroup rg : registerGroups) { - setRegistersToZero(rg.getRegisters()); - setRegisterGroupToZero(rg.getSubGroups()); + setRegistersTo(rg.getRegisters(), value); + setRegisterGroupTo(rg.getSubGroups(), value); } } -- 2.17.1