From: Daniel Kirschten Date: Wed, 30 Oct 2019 15:49:50 +0000 (+0100) Subject: Am2900Machine now resets registers in strict mode too X-Git-Url: https://mograsim.net/gitweb/?a=commitdiff_plain;h=7a3c18fd9777f940aff972ee2a8fa9a761050332;p=Mograsim.git Am2900Machine now resets registers in strict mode too --- 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); } }