Allow editing commands

This commit is contained in:
2020-12-25 17:45:30 +01:00
parent de89a7b8fb
commit 0a15d5bef4
5 changed files with 580 additions and 316 deletions

View File

@ -8,10 +8,10 @@
"direct": { "direct": {
"elm/browser": "1.0.2", "elm/browser": "1.0.2",
"elm/core": "1.0.5", "elm/core": "1.0.5",
"elm/html": "1.0.0" "elm/html": "1.0.0",
"elm/json": "1.1.3"
}, },
"indirect": { "indirect": {
"elm/json": "1.1.3",
"elm/time": "1.0.0", "elm/time": "1.0.0",
"elm/url": "1.0.0", "elm/url": "1.0.0",
"elm/virtual-dom": "1.0.2" "elm/virtual-dom": "1.0.2"

View File

@ -73,11 +73,17 @@
--color-table-ram-head-text: var(--color-white); --color-table-ram-head-text: var(--color-white);
--color-table-ram-highlight: var(--color-ram-light2); --color-table-ram-highlight: var(--color-ram-light2);
--color-table-ram-highlight-text: var(--color-black); --color-table-ram-highlight-text: var(--color-black);
--color-table-ram-select: transparent;
--color-table-ram-select-text: inherit;
--color-table-ram-select-border: var(--color-grey-light2);
--color-table-cu-head: var(--color-cu-dark1); --color-table-cu-head: var(--color-cu-dark1);
--color-table-cu-head-text: var(--color-white); --color-table-cu-head-text: var(--color-white);
--color-table-cu-highlight: var(--color-cu-light2); --color-table-cu-highlight: var(--color-cu-light2);
--color-table-cu-highlight-text: var(--color-black); --color-table-cu-highlight-text: var(--color-black);
--color-table-cu-select: transparent;
--color-table-cu-select-text: inherit;
--color-table-cu-select-border: var(--color-grey-light2);
--color-arrow: var(--color-arrow-main); --color-arrow: var(--color-arrow-main);
--color-arrow-text: var(--color-white); --color-arrow-text: var(--color-white);

View File

@ -107,6 +107,7 @@ button {
display: grid; display: grid;
grid-template-columns: auto auto auto; grid-template-columns: auto auto auto;
/* grid-template-columns: max-content auto max-content; */
gap: 9px; gap: 9px;
} }
@ -115,6 +116,7 @@ button {
} }
.pc .section { .pc .section {
min-height: 20em;
max-height: calc(80vh - 8em); max-height: calc(80vh - 8em);
min-width: 20%; min-width: 20%;
@ -274,6 +276,26 @@ th.address {
width: 100%; width: 100%;
} }
.pc .ram input[type=number] {
margin: 0 .5em 0 0;
background-color: var(--color-table-ram-select);
color: var(--color-table-ram-select-text);
border-color: var(--color-table-ram-select-border);
height: max-content;
}
.pc .ram input[type=number].instruction {
width: 5em;
}
.pc .ram input[type=number].address {
width: 7em;
}
.pc .ram table tr td:nth-child(2){
text-align: left;
}
/* CONTROL UNIT */ /* CONTROL UNIT */
@ -285,6 +307,15 @@ th.address {
width: 100%; width: 100%;
} }
.pc .cu select{
margin: 0;
width: 100%;
background-color: var(--color-table-cu-select);
color: var(--color-table-cu-select-text);
border: 1px solid var(--color-table-cu-select-border);
}
/* BUSSES */ /* BUSSES */
.pc .databus, .pc .databus,

View File

@ -5163,63 +5163,13 @@ var $author$project$Main$ActDataBus2Ram = {$: 'ActDataBus2Ram'};
var $author$project$Main$ActInstructionReg2AddressBus = {$: 'ActInstructionReg2AddressBus'}; var $author$project$Main$ActInstructionReg2AddressBus = {$: 'ActInstructionReg2AddressBus'};
var $author$project$Main$ActInstructionReg2ProgrammCounter = {$: 'ActInstructionReg2ProgrammCounter'}; var $author$project$Main$ActInstructionReg2ProgrammCounter = {$: 'ActInstructionReg2ProgrammCounter'};
var $author$project$Main$ActInstructionReg2UCounter = {$: 'ActInstructionReg2UCounter'}; var $author$project$Main$ActInstructionReg2UCounter = {$: 'ActInstructionReg2UCounter'};
var $author$project$Main$ActNothing = {$: 'ActNothing'};
var $author$project$Main$ActProgrammCounter2AddressBus = {$: 'ActProgrammCounter2AddressBus'}; var $author$project$Main$ActProgrammCounter2AddressBus = {$: 'ActProgrammCounter2AddressBus'};
var $author$project$Main$ActProgrammCounterIncrement = {$: 'ActProgrammCounterIncrement'}; var $author$project$Main$ActProgrammCounterIncrement = {$: 'ActProgrammCounterIncrement'};
var $author$project$Main$ActRam2DataBus = {$: 'ActRam2DataBus'}; var $author$project$Main$ActRam2DataBus = {$: 'ActRam2DataBus'};
var $author$project$Main$ActResetUCounter = {$: 'ActResetUCounter'}; var $author$project$Main$ActResetUCounter = {$: 'ActResetUCounter'};
var $author$project$Main$initialUCodes = _List_fromArray( var $author$project$Main$initialUCodes = _List_fromArray(
[ [$author$project$Main$ActProgrammCounter2AddressBus, $author$project$Main$ActRam2DataBus, $author$project$Main$ActDataBus2InstructionReg, $author$project$Main$ActProgrammCounterIncrement, $author$project$Main$ActInstructionReg2UCounter, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActInstructionReg2AddressBus, $author$project$Main$ActRam2DataBus, $author$project$Main$ActDataBus2Accumulator, $author$project$Main$ActResetUCounter, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActAccumulator2DataBus, $author$project$Main$ActInstructionReg2AddressBus, $author$project$Main$ActDataBus2Ram, $author$project$Main$ActResetUCounter, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActAccumulatorIncrement, $author$project$Main$ActResetUCounter, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActInstructionReg2ProgrammCounter, $author$project$Main$ActResetUCounter, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActNothing, $author$project$Main$ActNothing]);
$elm$core$Maybe$Just($author$project$Main$ActProgrammCounter2AddressBus),
$elm$core$Maybe$Just($author$project$Main$ActRam2DataBus),
$elm$core$Maybe$Just($author$project$Main$ActDataBus2InstructionReg),
$elm$core$Maybe$Just($author$project$Main$ActProgrammCounterIncrement),
$elm$core$Maybe$Just($author$project$Main$ActInstructionReg2UCounter),
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Just($author$project$Main$ActInstructionReg2AddressBus),
$elm$core$Maybe$Just($author$project$Main$ActRam2DataBus),
$elm$core$Maybe$Just($author$project$Main$ActDataBus2Accumulator),
$elm$core$Maybe$Just($author$project$Main$ActResetUCounter),
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Just($author$project$Main$ActAccumulator2DataBus),
$elm$core$Maybe$Just($author$project$Main$ActInstructionReg2AddressBus),
$elm$core$Maybe$Just($author$project$Main$ActDataBus2Ram),
$elm$core$Maybe$Just($author$project$Main$ActResetUCounter),
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Just($author$project$Main$ActAccumulatorIncrement),
$elm$core$Maybe$Just($author$project$Main$ActResetUCounter),
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Just($author$project$Main$ActInstructionReg2ProgrammCounter),
$elm$core$Maybe$Just($author$project$Main$ActResetUCounter),
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing,
$elm$core$Maybe$Nothing
]);
var $elm$core$Platform$Cmd$batch = _Platform_batch; var $elm$core$Platform$Cmd$batch = _Platform_batch;
var $elm$core$Platform$Cmd$none = $elm$core$Platform$Cmd$batch(_List_Nil); var $elm$core$Platform$Cmd$none = $elm$core$Platform$Cmd$batch(_List_Nil);
var $author$project$Main$init = function (flags) { var $author$project$Main$init = function (flags) {
@ -5235,52 +5185,6 @@ var $author$project$Main$recieveLocalSession = _Platform_incomingPort('recieveLo
var $author$project$Main$subscriptions = function (model) { var $author$project$Main$subscriptions = function (model) {
return $author$project$Main$recieveLocalSession($author$project$Main$MsgLocalSessionRecieve); return $author$project$Main$recieveLocalSession($author$project$Main$MsgLocalSessionRecieve);
}; };
var $elm$core$List$filter = F2(
function (isGood, list) {
return A3(
$elm$core$List$foldr,
F2(
function (x, xs) {
return isGood(x) ? A2($elm$core$List$cons, x, xs) : xs;
}),
_List_Nil,
list);
});
var $elm$core$List$head = function (list) {
if (list.b) {
var x = list.a;
var xs = list.b;
return $elm$core$Maybe$Just(x);
} else {
return $elm$core$Maybe$Nothing;
}
};
var $author$project$Main$ActAccumulatorDecrement = {$: 'ActAccumulatorDecrement'};
var $author$project$Main$actAccumulator2DataBus = function (pc) {
return _Utils_update(
pc,
{dataBus: pc.accumulator});
};
var $author$project$Main$actAccumulatorDecrement = function (pc) {
return _Utils_update(
pc,
{accumulator: pc.accumulator - 1});
};
var $author$project$Main$actAccumulatorIncrement = function (pc) {
return _Utils_update(
pc,
{accumulator: pc.accumulator + 1});
};
var $author$project$Main$actDataBus2Accumulator = function (pc) {
return _Utils_update(
pc,
{accumulator: pc.dataBus});
};
var $author$project$Main$actDataBus2InstructionReg = function (pc) {
return _Utils_update(
pc,
{instructionReg: pc.dataBus});
};
var $elm$core$List$append = F2( var $elm$core$List$append = F2(
function (xs, ys) { function (xs, ys) {
if (!ys.b) { if (!ys.b) {
@ -5457,8 +5361,8 @@ var $elm$core$List$take = F2(
function (n, list) { function (n, list) {
return A3($elm$core$List$takeFast, 0, n, list); return A3($elm$core$List$takeFast, 0, n, list);
}); });
var $author$project$Main$changeAt = F3( var $author$project$Main$changeAt = F4(
function (pos, newVal, list) { function (pos, newVal, _default, list) {
var len = $elm$core$List$length(list); var len = $elm$core$List$length(list);
var before = A2($elm$core$List$take, pos, list); var before = A2($elm$core$List$take, pos, list);
var after = A2($elm$core$List$drop, pos + 1, list); var after = A2($elm$core$List$drop, pos + 1, list);
@ -5466,7 +5370,7 @@ var $author$project$Main$changeAt = F3(
var before2 = A2( var before2 = A2(
$elm$core$List$append, $elm$core$List$append,
before, before,
A2($elm$core$List$repeat, pos - len, 0)); A2($elm$core$List$repeat, pos - len, _default));
return A2( return A2(
$elm$core$List$append, $elm$core$List$append,
before2, before2,
@ -5478,26 +5382,94 @@ var $author$project$Main$changeAt = F3(
A2($elm$core$List$cons, newVal, after)); A2($elm$core$List$cons, newVal, after));
} }
}); });
var $author$project$Main$changeAtInt = F3(
function (pos, newVal, list) {
return A4($author$project$Main$changeAt, pos, newVal, 0, list);
});
var $author$project$Main$changeAtUCode = F3(
function (pos, newVal, list) {
return A4($author$project$Main$changeAt, pos, newVal, $author$project$Main$ActNothing, list);
});
var $elm$core$List$filter = F2(
function (isGood, list) {
return A3(
$elm$core$List$foldr,
F2(
function (x, xs) {
return isGood(x) ? A2($elm$core$List$cons, x, xs) : xs;
}),
_List_Nil,
list);
});
var $elm$core$List$head = function (list) {
if (list.b) {
var x = list.a;
var xs = list.b;
return $elm$core$Maybe$Just(x);
} else {
return $elm$core$Maybe$Nothing;
}
};
var $author$project$Main$ActAccumulatorDecrement = {$: 'ActAccumulatorDecrement'};
var $author$project$Main$actAccumulator2DataBus = function (pc) {
return _Utils_update(
pc,
{dataBus: pc.accumulator});
};
var $author$project$Main$actAccumulatorDecrement = function (pc) {
return _Utils_update(
pc,
{accumulator: pc.accumulator - 1});
};
var $author$project$Main$actAccumulatorIncrement = function (pc) {
return _Utils_update(
pc,
{accumulator: pc.accumulator + 1});
};
var $author$project$Main$actDataBus2Accumulator = function (pc) {
return _Utils_update(
pc,
{accumulator: pc.dataBus});
};
var $author$project$Main$actDataBus2InstructionReg = function (pc) {
return _Utils_update(
pc,
{instructionReg: pc.dataBus});
};
var $author$project$Main$actDataBus2Ram = function (pc) { var $author$project$Main$actDataBus2Ram = function (pc) {
var newRam = A3($author$project$Main$changeAt, pc.addressBus, pc.dataBus, pc.ram); var newRam = A3($author$project$Main$changeAtInt, pc.addressBus, pc.dataBus, pc.ram);
return _Utils_update( return _Utils_update(
pc, pc,
{ram: newRam}); {ram: newRam});
}; };
var $author$project$Main$seperateInstructionsEntry = function (i) {
var instruction = (i / 100000) | 0;
var address = i - (instruction * 100000);
return _Utils_Tuple2(instruction, address);
};
var $author$project$Main$actInstructionReg2AddressBus = function (pc) { var $author$project$Main$actInstructionReg2AddressBus = function (pc) {
var _v0 = $author$project$Main$seperateInstructionsEntry(pc.instructionReg);
var instruction = _v0.a;
var address = _v0.b;
return _Utils_update( return _Utils_update(
pc, pc,
{addressBus: pc.instructionReg - (((pc.instructionReg / 100000) | 0) * 100000)}); {addressBus: address});
}; };
var $author$project$Main$actInstructionReg2ProgrammCounter = function (pc) { var $author$project$Main$actInstructionReg2ProgrammCounter = function (pc) {
var _v0 = $author$project$Main$seperateInstructionsEntry(pc.instructionReg);
var instruction = _v0.a;
var address = _v0.b;
return _Utils_update( return _Utils_update(
pc, pc,
{programmCounter: pc.instructionReg - (((pc.instructionReg / 100000) | 0) * 100000)}); {programmCounter: address});
}; };
var $author$project$Main$actInstructionReg2UCounter = function (pc) { var $author$project$Main$actInstructionReg2UCounter = function (pc) {
var _v0 = $author$project$Main$seperateInstructionsEntry(pc.instructionReg);
var instruction = _v0.a;
var address = _v0.b;
return _Utils_update( return _Utils_update(
pc, pc,
{uCounter: ((pc.instructionReg / 100000) | 0) * 10}); {uCounter: instruction * 10});
}; };
var $author$project$Main$actProgrammCounter2AddressBus = function (pc) { var $author$project$Main$actProgrammCounter2AddressBus = function (pc) {
return _Utils_update( return _Utils_update(
@ -5550,7 +5522,12 @@ var $author$project$Main$uCodeMaps = _List_fromArray(
_Utils_Tuple2($author$project$Main$ActProgrammCounterIncrement, $author$project$Main$actProgrammCounterIncrement), _Utils_Tuple2($author$project$Main$ActProgrammCounterIncrement, $author$project$Main$actProgrammCounterIncrement),
_Utils_Tuple2($author$project$Main$ActRam2DataBus, $author$project$Main$actRam2DataBus), _Utils_Tuple2($author$project$Main$ActRam2DataBus, $author$project$Main$actRam2DataBus),
_Utils_Tuple2($author$project$Main$ActResetUCounter, $author$project$Main$actResetUCounter), _Utils_Tuple2($author$project$Main$ActResetUCounter, $author$project$Main$actResetUCounter),
_Utils_Tuple2($author$project$Main$ActProgrammCounter2AddressBus, $author$project$Main$actProgrammCounter2AddressBus) _Utils_Tuple2($author$project$Main$ActProgrammCounter2AddressBus, $author$project$Main$actProgrammCounter2AddressBus),
_Utils_Tuple2(
$author$project$Main$ActNothing,
function (s) {
return s;
})
]); ]);
var $author$project$Main$getAction = function (uAction) { var $author$project$Main$getAction = function (uAction) {
var possible_instructions = A2( var possible_instructions = A2(
@ -5574,11 +5551,48 @@ var $author$project$Main$getAction = function (uAction) {
var $elm$core$Basics$not = _Basics_not; var $elm$core$Basics$not = _Basics_not;
var $elm$json$Json$Encode$string = _Json_wrap; var $elm$json$Json$Encode$string = _Json_wrap;
var $author$project$Main$sendUUpdate = _Platform_outgoingPort('sendUUpdate', $elm$json$Json$Encode$string); var $author$project$Main$sendUUpdate = _Platform_outgoingPort('sendUUpdate', $elm$json$Json$Encode$string);
var $elm$core$Tuple$second = function (_v0) {
var y = _v0.b;
return y;
};
var $author$project$Main$uCodeDescriptions = _List_fromArray(
[
_Utils_Tuple2($author$project$Main$ActAccumulator2DataBus, 'Acc -> DataBus'),
_Utils_Tuple2($author$project$Main$ActAccumulatorDecrement, 'Acc --'),
_Utils_Tuple2($author$project$Main$ActAccumulatorIncrement, 'Acc ++'),
_Utils_Tuple2($author$project$Main$ActDataBus2Accumulator, 'DataBus -> Acc'),
_Utils_Tuple2($author$project$Main$ActDataBus2InstructionReg, 'DataBus -> InstReg'),
_Utils_Tuple2($author$project$Main$ActDataBus2Ram, 'DataBus -> Ram'),
_Utils_Tuple2($author$project$Main$ActInstructionReg2AddressBus, 'InstReg -> AddrBus'),
_Utils_Tuple2($author$project$Main$ActInstructionReg2ProgrammCounter, 'InstReg -> ProgCount'),
_Utils_Tuple2($author$project$Main$ActInstructionReg2UCounter, 'InstReg -> µCounter'),
_Utils_Tuple2($author$project$Main$ActProgrammCounterIncrement, 'ProgCounter ++'),
_Utils_Tuple2($author$project$Main$ActRam2DataBus, 'Ram -> DataBus'),
_Utils_Tuple2($author$project$Main$ActResetUCounter, 'µCounter = 0'),
_Utils_Tuple2($author$project$Main$ActProgrammCounter2AddressBus, 'ProgCounter -> AddrBus'),
_Utils_Tuple2($author$project$Main$ActNothing, 'Empty')
]);
var $author$project$Main$string2uAction = function (msg) {
var filtered_list = A2(
$elm$core$List$filter,
function (s) {
return _Utils_eq(s.b, msg);
},
$author$project$Main$uCodeDescriptions);
var _v0 = $elm$core$List$head(filtered_list);
if (_v0.$ === 'Just') {
var _v1 = _v0.a;
var action = _v1.a;
return $elm$core$Maybe$Just(action);
} else {
return $elm$core$Maybe$Nothing;
}
};
var $author$project$Main$uStepPC = function (model) { var $author$project$Main$uStepPC = function (model) {
var uCounter = model.pc.uCounter; var uCounter = model.pc.uCounter;
var may_instruction = A2($author$project$Main$valueAt, uCounter, model.uCode); var may_instruction = A2($author$project$Main$valueAt, uCounter, model.uCode);
if ((may_instruction.$ === 'Just') && (may_instruction.a.$ === 'Just')) { if (may_instruction.$ === 'Just') {
var action = may_instruction.a.a; var action = may_instruction.a;
var possible_instructions = A2( var possible_instructions = A2(
$elm$core$List$filter, $elm$core$List$filter,
function (s) { function (s) {
@ -5644,6 +5658,69 @@ var $author$project$Main$update = F2(
pc: instruction(model.pc) pc: instruction(model.pc)
}), }),
$elm$core$Platform$Cmd$none); $elm$core$Platform$Cmd$none);
case 'MsgRamEditAddress':
var addr = msg.a;
var may_int = msg.b;
var _v1 = $elm$core$String$toInt(may_int);
if (_v1.$ === 'Just') {
var _int = _v1.a;
var old_pc = model.pc;
var _v2 = $author$project$Main$seperateInstructionsEntry(
A2($author$project$Main$valueAtInt, addr, model.pc.ram));
var inst = _v2.a;
var new_val = (inst * 100000) + _int;
var new_pc = _Utils_update(
old_pc,
{
ram: A3($author$project$Main$changeAtInt, addr, new_val, old_pc.ram)
});
return _Utils_Tuple2(
_Utils_update(
model,
{pc: new_pc}),
$elm$core$Platform$Cmd$none);
} else {
return _Utils_Tuple2(model, $elm$core$Platform$Cmd$none);
}
case 'MsgRamEditInstr':
var addr = msg.a;
var may_int = msg.b;
var _v3 = $elm$core$String$toInt(may_int);
if (_v3.$ === 'Just') {
var _int = _v3.a;
var old_pc = model.pc;
var _v4 = $author$project$Main$seperateInstructionsEntry(
A2($author$project$Main$valueAtInt, addr, model.pc.ram));
var address = _v4.b;
var new_val = (_int * 100000) + address;
var new_pc = _Utils_update(
old_pc,
{
ram: A3($author$project$Main$changeAtInt, addr, new_val, old_pc.ram)
});
return _Utils_Tuple2(
_Utils_update(
model,
{pc: new_pc}),
$elm$core$Platform$Cmd$none);
} else {
return _Utils_Tuple2(model, $elm$core$Platform$Cmd$none);
}
case 'MsgCuEditAction':
var addr = msg.a;
var may_action = msg.b;
var _v5 = $author$project$Main$string2uAction(may_action);
if (_v5.$ === 'Just') {
var action = _v5.a;
var newCode = A3($author$project$Main$changeAtUCode, addr, action, model.uCode);
return _Utils_Tuple2(
_Utils_update(
model,
{uCode: newCode}),
$elm$core$Platform$Cmd$none);
} else {
return _Utils_Tuple2(model, $elm$core$Platform$Cmd$none);
}
default: default:
return _Utils_Tuple2( return _Utils_Tuple2(
_Utils_update( _Utils_update(
@ -5676,10 +5753,6 @@ var $elm$html$Html$Attributes$stringProperty = F2(
$elm$json$Json$Encode$string(string)); $elm$json$Json$Encode$string(string));
}); });
var $elm$html$Html$Attributes$class = $elm$html$Html$Attributes$stringProperty('className'); var $elm$html$Html$Attributes$class = $elm$html$Html$Attributes$stringProperty('className');
var $elm$core$Tuple$second = function (_v0) {
var y = _v0.b;
return y;
};
var $elm$html$Html$Attributes$classList = function (classes) { var $elm$html$Html$Attributes$classList = function (classes) {
return $elm$html$Html$Attributes$class( return $elm$html$Html$Attributes$class(
A2( A2(
@ -5831,7 +5904,7 @@ var $author$project$Main$viewAlu = function (model) {
_List_fromArray( _List_fromArray(
[ [
$elm$html$Html$text( $elm$html$Html$text(
'Accumulator: ' + $elm$core$String$fromInt(model.pc.accumulator)) 'Accumulator: ' + A2($author$project$Main$addLeadingZero, model.pc.accumulator, 8))
])), ])),
A2( A2(
$elm$html$Html$div, $elm$html$Html$div,
@ -5907,44 +5980,54 @@ var $elm$core$Tuple$pair = F2(
}); });
var $elm$html$Html$tbody = _VirtualDom_node('tbody'); var $elm$html$Html$tbody = _VirtualDom_node('tbody');
var $elm$html$Html$td = _VirtualDom_node('td'); var $elm$html$Html$td = _VirtualDom_node('td');
var $author$project$Main$uCodeDescriptions = _List_fromArray( var $author$project$Main$MsgCuEditAction = F2(
function (a, b) {
return {$: 'MsgCuEditAction', a: a, b: b};
});
var $elm$html$Html$option = _VirtualDom_node('option');
var $elm$html$Html$select = _VirtualDom_node('select');
var $elm$json$Json$Decode$field = _Json_decodeField;
var $author$project$Main$selectCuValueDecoder = A2(
$elm$json$Json$Decode$field,
'target',
A2($elm$json$Json$Decode$field, 'value', $elm$json$Json$Decode$string));
var $elm$html$Html$Attributes$selected = $elm$html$Html$Attributes$boolProperty('selected');
var $author$project$Main$viewCuInstrSelect = F2(
function (id, current) {
var info2option = function (_v0) {
var action = _v0.a;
var info = _v0.b;
return A2(
$elm$html$Html$option,
_List_fromArray(
[ [
_Utils_Tuple2($author$project$Main$ActAccumulator2DataBus, 'Acc -> DataBus'), $elm$html$Html$Attributes$selected(
_Utils_Tuple2($author$project$Main$ActAccumulatorDecrement, 'Acc --'), _Utils_eq(action, current))
_Utils_Tuple2($author$project$Main$ActAccumulatorIncrement, 'Acc ++'), ]),
_Utils_Tuple2($author$project$Main$ActDataBus2Accumulator, 'DataBus -> Acc'), _List_fromArray(
_Utils_Tuple2($author$project$Main$ActDataBus2InstructionReg, 'DataBus -> InstReg'), [
_Utils_Tuple2($author$project$Main$ActDataBus2Ram, 'DataBus -> Ram'), $elm$html$Html$text(info)
_Utils_Tuple2($author$project$Main$ActInstructionReg2AddressBus, 'InstReg -> AddrBus'), ]));
_Utils_Tuple2($author$project$Main$ActInstructionReg2ProgrammCounter, 'InstReg -> ProgCount'), };
_Utils_Tuple2($author$project$Main$ActInstructionReg2UCounter, 'InstReg -> µCounter'), var listOptions = A2($elm$core$List$map, info2option, $author$project$Main$uCodeDescriptions);
_Utils_Tuple2($author$project$Main$ActProgrammCounterIncrement, 'ProgCounter ++'), return A2(
_Utils_Tuple2($author$project$Main$ActRam2DataBus, 'Ram -> DataBus'), $elm$html$Html$select,
_Utils_Tuple2($author$project$Main$ActResetUCounter, 'µCounter = 0'), _List_fromArray(
_Utils_Tuple2($author$project$Main$ActProgrammCounter2AddressBus, 'ProgCounter -> AddrBus') [
]); A2(
$elm$html$Html$Events$on,
'change',
A2(
$elm$json$Json$Decode$map,
$author$project$Main$MsgCuEditAction(id),
$author$project$Main$selectCuValueDecoder))
]),
listOptions);
});
var $author$project$Main$viewCuUCodeContent = function (model) { var $author$project$Main$viewCuUCodeContent = function (model) {
var list2table = function (may_t) { var list2table = function (t) {
var may_code = may_t.b; var id = t.a;
var id = may_t.a; var code = t.b;
if (may_code.$ === 'Just') {
var code = may_code.a;
var possibleDescriptions = A2(
$elm$core$List$filter,
function (s) {
return _Utils_eq(s.a, code);
},
$author$project$Main$uCodeDescriptions);
var codeDescription = function () {
var _v1 = $elm$core$List$head(possibleDescriptions);
if (_v1.$ === 'Just') {
var _v2 = _v1.a;
var description = _v2.b;
return description;
} else {
return 'Idk what this is';
}
}();
return A2( return A2(
$elm$html$Html$tr, $elm$html$Html$tr,
_List_fromArray( _List_fromArray(
@ -5954,7 +6037,10 @@ var $author$project$Main$viewCuUCodeContent = function (model) {
[ [
_Utils_Tuple2( _Utils_Tuple2(
'current', 'current',
_Utils_eq(id, model.pc.uCounter)) _Utils_eq(id, model.pc.uCounter)),
_Utils_Tuple2(
'empty',
_Utils_eq(code, $author$project$Main$ActNothing))
])) ]))
]), ]),
_List_fromArray( _List_fromArray(
@ -5968,45 +6054,16 @@ var $author$project$Main$viewCuUCodeContent = function (model) {
_List_fromArray( _List_fromArray(
[ [
$elm$html$Html$text( $elm$html$Html$text(
A2($author$project$Main$addLeadingZero, id, 3)) A2($author$project$Main$addLeadingZero, id, 4))
])), ])),
A2( A2(
$elm$html$Html$td, $elm$html$Html$td,
_List_Nil, _List_Nil,
_List_fromArray( _List_fromArray(
[ [
$elm$html$Html$text(codeDescription) A2($author$project$Main$viewCuInstrSelect, id, code)
])) ]))
])); ]));
} else {
return A2(
$elm$html$Html$tr,
_List_fromArray(
[
$elm$html$Html$Attributes$class('empty')
]),
_List_fromArray(
[
A2(
$elm$html$Html$td,
_List_fromArray(
[
$elm$html$Html$Attributes$class('num')
]),
_List_fromArray(
[
$elm$html$Html$text(
A2($author$project$Main$addLeadingZero, id, 3))
])),
A2(
$elm$html$Html$td,
_List_Nil,
_List_fromArray(
[
$elm$html$Html$text('Empty')
]))
]));
}
}; };
var indexedList = A2($elm$core$List$indexedMap, $elm$core$Tuple$pair, model.uCode); var indexedList = A2($elm$core$List$indexedMap, $elm$core$Tuple$pair, model.uCode);
return A2( return A2(
@ -6056,8 +6113,9 @@ var $author$project$Main$viewCuUCode = function (model) {
])); ]));
}; };
var $author$project$Main$viewInstrEntry = function (i) { var $author$project$Main$viewInstrEntry = function (i) {
var instruction = (i / 100000) | 0; var _v0 = $author$project$Main$seperateInstructionsEntry(i);
var address = i - (instruction * 100000); var instruction = _v0.a;
var address = _v0.b;
return $elm$html$Html$text( return $elm$html$Html$text(
A2($author$project$Main$addLeadingZero, instruction, 3) + (' ' + A2($author$project$Main$addLeadingZero, address, 5))); A2($author$project$Main$addLeadingZero, instruction, 3) + (' ' + A2($author$project$Main$addLeadingZero, address, 5)));
}; };
@ -6242,10 +6300,53 @@ var $author$project$Main$viewDataBus = function (model) {
])) ]))
])); ]));
}; };
var $author$project$Main$MsgRamEditAddress = F2(
function (a, b) {
return {$: 'MsgRamEditAddress', a: a, b: b};
});
var $author$project$Main$MsgRamEditInstr = F2(
function (a, b) {
return {$: 'MsgRamEditInstr', a: a, b: b};
});
var $elm$html$Html$Events$alwaysStop = function (x) {
return _Utils_Tuple2(x, true);
};
var $elm$virtual_dom$VirtualDom$MayStopPropagation = function (a) {
return {$: 'MayStopPropagation', a: a};
};
var $elm$html$Html$Events$stopPropagationOn = F2(
function (event, decoder) {
return A2(
$elm$virtual_dom$VirtualDom$on,
event,
$elm$virtual_dom$VirtualDom$MayStopPropagation(decoder));
});
var $elm$json$Json$Decode$at = F2(
function (fields, decoder) {
return A3($elm$core$List$foldr, $elm$json$Json$Decode$field, decoder, fields);
});
var $elm$html$Html$Events$targetValue = A2(
$elm$json$Json$Decode$at,
_List_fromArray(
['target', 'value']),
$elm$json$Json$Decode$string);
var $elm$html$Html$Events$onInput = function (tagger) {
return A2(
$elm$html$Html$Events$stopPropagationOn,
'input',
A2(
$elm$json$Json$Decode$map,
$elm$html$Html$Events$alwaysStop,
A2($elm$json$Json$Decode$map, tagger, $elm$html$Html$Events$targetValue)));
};
var $elm$html$Html$Attributes$value = $elm$html$Html$Attributes$stringProperty('value');
var $author$project$Main$viewRamContent = function (model) { var $author$project$Main$viewRamContent = function (model) {
var ram2table = function (entry) { var ram2table = function (entry) {
var val = entry.b; var val = entry.b;
var id = entry.a; var id = entry.a;
var _v0 = $author$project$Main$seperateInstructionsEntry(val);
var instruction = _v0.a;
var address = _v0.b;
return A2( return A2(
$elm$html$Html$tr, $elm$html$Html$tr,
_List_fromArray( _List_fromArray(
@ -6279,7 +6380,32 @@ var $author$project$Main$viewRamContent = function (model) {
]), ]),
_List_fromArray( _List_fromArray(
[ [
$author$project$Main$viewInstrEntry(val) A2(
$elm$html$Html$input,
_List_fromArray(
[
$elm$html$Html$Attributes$type_('number'),
$elm$html$Html$Attributes$value(
A2($author$project$Main$addLeadingZero, instruction, 3)),
$elm$html$Html$Events$onInput(
$author$project$Main$MsgRamEditInstr(id)),
$elm$html$Html$Attributes$class('ram-entry'),
$elm$html$Html$Attributes$class('instruction')
]),
_List_Nil),
A2(
$elm$html$Html$input,
_List_fromArray(
[
$elm$html$Html$Attributes$type_('number'),
$elm$html$Html$Attributes$value(
A2($author$project$Main$addLeadingZero, address, 5)),
$elm$html$Html$Events$onInput(
$author$project$Main$MsgRamEditAddress(id)),
$elm$html$Html$Attributes$class('ram-entry'),
$elm$html$Html$Attributes$class('address')
]),
_List_Nil)
])) ]))
])); ]));
}; };

View File

@ -6,11 +6,13 @@ port module Main exposing (..)
import Browser import Browser
import Html exposing (Html, button, div, h1, p, text) import Html exposing (Html, button, div, h1, p, text)
import Html.Attributes as HAttr exposing (class, classList, value) import Html.Attributes as HAttr exposing (class, classList, value)
import Html.Events exposing (onClick) import Html.Events as HEvent exposing (onClick, onInput)
import Html.Lazy exposing (lazy) import Html.Lazy exposing (lazy)
import Tuple import Tuple
import Array exposing (get) import Array exposing (get)
import Html exposing (address) import Html exposing (address)
import Json.Decode as JD
import Html.Events exposing (targetValue)
@ -40,7 +42,7 @@ type alias PC =
type alias Model = type alias Model =
{ pc : PC { pc : PC
, uCode : List (Maybe UAction) , uCode : List UAction
, autoscroll : Bool , autoscroll : Bool
} }
@ -59,6 +61,7 @@ type UAction
| ActRam2DataBus | ActRam2DataBus
| ActResetUCounter | ActResetUCounter
| ActProgrammCounter2AddressBus | ActProgrammCounter2AddressBus
| ActNothing
uCodeDescriptions : List ( UAction, String ) uCodeDescriptions : List ( UAction, String )
@ -76,6 +79,7 @@ uCodeDescriptions =
, ( ActRam2DataBus, "Ram -> DataBus" ) , ( ActRam2DataBus, "Ram -> DataBus" )
, ( ActResetUCounter, "µCounter = 0" ) , ( ActResetUCounter, "µCounter = 0" )
, ( ActProgrammCounter2AddressBus, "ProgCounter -> AddrBus" ) , ( ActProgrammCounter2AddressBus, "ProgCounter -> AddrBus" )
, ( ActNothing, "Empty" )
] ]
@ -94,6 +98,7 @@ uCodeMaps =
, ( ActRam2DataBus, actRam2DataBus ) , ( ActRam2DataBus, actRam2DataBus )
, ( ActResetUCounter, actResetUCounter ) , ( ActResetUCounter, actResetUCounter )
, ( ActProgrammCounter2AddressBus, actProgrammCounter2AddressBus ) , ( ActProgrammCounter2AddressBus, actProgrammCounter2AddressBus )
, ( ActNothing, (\s -> s))
] ]
@ -125,66 +130,66 @@ initialPC =
0 0
initialUCodes : List (Maybe UAction) initialUCodes : List UAction
initialUCodes = initialUCodes =
[ Just ActProgrammCounter2AddressBus -- 000 [ ActProgrammCounter2AddressBus -- 000
, Just ActRam2DataBus -- 001 , ActRam2DataBus -- 001
, Just ActDataBus2InstructionReg -- 002 , ActDataBus2InstructionReg -- 002
, Just ActProgrammCounterIncrement -- 003 , ActProgrammCounterIncrement -- 003
, Just ActInstructionReg2UCounter -- 004 , ActInstructionReg2UCounter -- 004
, Nothing -- 005 , ActNothing -- 005
, Nothing , ActNothing
, Nothing , ActNothing
, Nothing , ActNothing
, Nothing -- 009 , ActNothing -- 009
-- 010 LOADA -- 010 LOADA
, Just ActInstructionReg2AddressBus -- 010 , ActInstructionReg2AddressBus -- 010
, Just ActRam2DataBus -- 011 , ActRam2DataBus -- 011
, Just ActDataBus2Accumulator -- 012 , ActDataBus2Accumulator -- 012
, Just ActResetUCounter -- 013 , ActResetUCounter -- 013
, Nothing -- 014 , ActNothing -- 014
, Nothing , ActNothing
, Nothing , ActNothing
, Nothing , ActNothing
, Nothing , ActNothing
, Nothing -- 019 , ActNothing -- 019
-- 020 STOA -- 020 STOA
, Just ActAccumulator2DataBus -- 020 , ActAccumulator2DataBus -- 020
, Just ActInstructionReg2AddressBus -- 021 , ActInstructionReg2AddressBus -- 021
, Just ActDataBus2Ram -- 022 , ActDataBus2Ram -- 022
, Just ActResetUCounter -- 023 , ActResetUCounter -- 023
, Nothing --024 , ActNothing --024
, Nothing , ActNothing
, Nothing , ActNothing
, Nothing , ActNothing
, Nothing , ActNothing
, Nothing -- 029 , ActNothing -- 029
-- 030 INCA -- 030 INCA
, Just ActAccumulatorIncrement -- 030 , ActAccumulatorIncrement -- 030
, Just ActResetUCounter -- 031 , ActResetUCounter -- 031
, Nothing -- 032 , ActNothing -- 032
, Nothing , ActNothing
, Nothing , ActNothing
, Nothing , ActNothing
, Nothing , ActNothing
, Nothing , ActNothing
, Nothing , ActNothing
, Nothing -- 039 , ActNothing -- 039
-- 040 JMP -- 040 JMP
, Just ActInstructionReg2ProgrammCounter -- 040 , ActInstructionReg2ProgrammCounter -- 040
, Just ActResetUCounter -- 041 , ActResetUCounter -- 041
, Nothing -- 042 , ActNothing -- 042
, Nothing , ActNothing
, Nothing , ActNothing
, Nothing , ActNothing
, Nothing , ActNothing
, Nothing , ActNothing
, Nothing , ActNothing
, Nothing -- 049 , ActNothing -- 049
] ]
@ -194,6 +199,9 @@ type Msg
| MsgReset | MsgReset
| MsgAutoscrollUpdate | MsgAutoscrollUpdate
| MsgManualStep UAction | MsgManualStep UAction
| MsgRamEditAddress Int String
| MsgRamEditInstr Int String
| MsgCuEditAction Int String
| MsgLocalSessionRecieve String | MsgLocalSessionRecieve String
@ -223,6 +231,41 @@ update msg model =
( { model | pc = instruction model.pc} ( { model | pc = instruction model.pc}
, Cmd.none ) , Cmd.none )
MsgRamEditAddress addr may_int ->
case String.toInt may_int of
Just int ->
let
(inst,_) = seperateInstructionsEntry ( valueAtInt addr model.pc.ram )
new_val = inst * 100000 + int
old_pc = model.pc
new_pc = { old_pc | ram = (changeAtInt addr new_val old_pc.ram) }
in
({ model | pc = new_pc }
, Cmd.none )
_ -> (model, Cmd.none)
MsgRamEditInstr addr may_int ->
case String.toInt may_int of
Just int ->
let
(_,address) = seperateInstructionsEntry ( valueAtInt addr model.pc.ram )
new_val = int * 100000 + address
old_pc = model.pc
new_pc = { old_pc | ram = (changeAtInt addr new_val old_pc.ram) }
in
({ model | pc = new_pc }
, Cmd.none )
_ -> ( model, Cmd.none )
MsgCuEditAction addr may_action ->
case string2uAction may_action of
Just action ->
let
newCode = changeAtUCode addr action model.uCode
in
({ model | uCode = newCode }, Cmd.none)
_ -> ( model, Cmd.none )
MsgAutoscrollUpdate -> MsgAutoscrollUpdate ->
( { model | autoscroll = not model.autoscroll } ( { model | autoscroll = not model.autoscroll }
, Cmd.none , Cmd.none
@ -250,12 +293,12 @@ uStepPC model =
uCounter = uCounter =
model.pc.uCounter model.pc.uCounter
may_instruction : Maybe (Maybe UAction) may_instruction : Maybe UAction
may_instruction = may_instruction =
valueAt uCounter model.uCode valueAt uCounter model.uCode
in in
case may_instruction of case may_instruction of
Just (Just action) -> Just action ->
let let
possible_instructions = possible_instructions =
List.filter (\s -> Tuple.first s == action) uCodeMaps List.filter (\s -> Tuple.first s == action) uCodeMaps
@ -285,6 +328,7 @@ uStepPC model =
model model
view : Model -> Html Msg view : Model -> Html Msg
view model = view model =
lazy viewPC model lazy viewPC model
@ -368,11 +412,30 @@ viewRamContent model =
val = val =
Tuple.second entry Tuple.second entry
(instruction, address) = seperateInstructionsEntry val
in in
Html.tr Html.tr
[ classList [ ( "current", id == model.pc.addressBus ) ] ] [ classList [ ( "current", id == model.pc.addressBus ) ] ]
[ Html.td [ class "num" ] [ text (addLeadingZero id 3) ] [ Html.td [ class "num" ] [ text (addLeadingZero id 3) ]
, Html.td [ class "num " ] [ viewInstrEntry val ] , Html.td [ class "num " ]
[ Html.input
[ HAttr.type_ "number"
, HAttr.value (addLeadingZero instruction 3)
, onInput (MsgRamEditInstr id)
, class "ram-entry"
, class "instruction"
]
[]
, Html.input
[ HAttr.type_ "number"
, HAttr.value (addLeadingZero address 5)
, onInput (MsgRamEditAddress id)
, class "ram-entry"
, class "address"
]
[]
]
] ]
in in
Html.tbody [] (List.map ram2table indexedRam) Html.tbody [] (List.map ram2table indexedRam)
@ -438,50 +501,41 @@ viewCuUCodeContent model =
indexedList = indexedList =
List.indexedMap Tuple.pair model.uCode List.indexedMap Tuple.pair model.uCode
list2table : ( Int, Maybe UAction ) -> Html Msg list2table : ( Int, UAction ) -> Html Msg
list2table may_t = list2table t =
let let
id = id =
Tuple.first may_t Tuple.first t
may_code = code =
Tuple.second may_t Tuple.second t
in
case may_code of
Just code ->
let
possibleDescriptions : List ( UAction, String )
possibleDescriptions =
List.filter (\s -> Tuple.first s == code) uCodeDescriptions
codeDescription =
case List.head possibleDescriptions of
Just ( _, description ) ->
description
_ ->
"Idk what this is"
in in
Html.tr Html.tr
[ classList [ ( "current", id == model.pc.uCounter ) ] ] [ classList [ ( "current", id == model.pc.uCounter ), ("empty", code == ActNothing) ] ]
[ Html.td [ class "num" ] [ text (addLeadingZero id 3) ] [ Html.td [ class "num" ] [ text (addLeadingZero id 4) ]
, Html.td [] [ text codeDescription ] , Html.td [] [ viewCuInstrSelect id code ]
] ]
Nothing ->
Html.tr [ class "empty" ]
[ Html.td [ class "num" ] [ text (addLeadingZero id 3) ]
, Html.td [] [ text "Empty" ]
]
in in
Html.tbody [] (List.map list2table indexedList) Html.tbody [] (List.map list2table indexedList)
viewCuInstrSelect : Int -> UAction -> Html Msg
viewCuInstrSelect id current =
let
info2option (action, info) =
Html.option [ HAttr.selected (action == current) ] [ text info ]
listOptions = List.map info2option uCodeDescriptions
in
Html.select
[ HEvent.on "change" ( JD.map (MsgCuEditAction id) selectCuValueDecoder) ]
listOptions
viewAlu : Model -> Html Msg viewAlu : Model -> Html Msg
viewAlu model = viewAlu model =
div [ class "section", class "alu" ] div [ class "section", class "alu" ]
[ h1 [ class "header" ] [ text "ALU" ] [ h1 [ class "header" ] [ text "ALU" ]
, p [] [ text ("Accumulator: " ++ String.fromInt model.pc.accumulator) ] , p [] [ text ("Accumulator: " ++ (addLeadingZero model.pc.accumulator 8)) ]
, div [ class "arrow", class "up"] , div [ class "arrow", class "up"]
[ div [ class "button" ] [ div [ class "button" ]
[ Html.a [ onClick (MsgManualStep ActDataBus2Accumulator)] [ text "DB -> ALU" ]] [ Html.a [ onClick (MsgManualStep ActDataBus2Accumulator)] [ text "DB -> ALU" ]]
@ -514,8 +568,7 @@ viewAddressBus model =
viewInstrEntry : Int -> Html Msg viewInstrEntry : Int -> Html Msg
viewInstrEntry i = viewInstrEntry i =
let let
instruction = i // 100000 (instruction, address) = seperateInstructionsEntry i
address = i - instruction*100000
in in
text ( (addLeadingZero instruction 3) ++ " " ++ (addLeadingZero address 5) ) text ( (addLeadingZero instruction 3) ++ " " ++ (addLeadingZero address 5) )
@ -551,21 +604,28 @@ actResetUCounter pc =
actInstructionReg2UCounter : PC -> PC actInstructionReg2UCounter : PC -> PC
actInstructionReg2UCounter pc = actInstructionReg2UCounter pc =
-- Remove last 5 digits as they are address
-- Multiply by ten, because every instruction is 10 uCodes long -- Multiply by ten, because every instruction is 10 uCodes long
{ pc | uCounter = pc.instructionReg // 100000 * 10 } let
(instruction, address) = seperateInstructionsEntry pc.instructionReg
in
{ pc | uCounter = instruction * 10}
actInstructionReg2AddressBus : PC -> PC actInstructionReg2AddressBus : PC -> PC
actInstructionReg2AddressBus pc = actInstructionReg2AddressBus pc =
-- Only bring last 5 digits to AB, because the rest is opcode let
{ pc | addressBus = pc.instructionReg - pc.instructionReg // 100000 * 100000 } (instruction, address) = seperateInstructionsEntry pc.instructionReg
in
{ pc | addressBus = address }
actInstructionReg2ProgrammCounter : PC -> PC actInstructionReg2ProgrammCounter : PC -> PC
actInstructionReg2ProgrammCounter pc = actInstructionReg2ProgrammCounter pc =
-- Only bring last 5 digits to AB, because the rest is opcode let
{ pc | programmCounter = pc.instructionReg - pc.instructionReg // 100000 * 100000 } (instruction, address) = seperateInstructionsEntry pc.instructionReg
in
{ pc | programmCounter = address }
actProgrammCounterIncrement : PC -> PC actProgrammCounterIncrement : PC -> PC
@ -602,7 +662,7 @@ actDataBus2Ram : PC -> PC
actDataBus2Ram pc = actDataBus2Ram pc =
let let
newRam = newRam =
changeAt pc.addressBus pc.dataBus pc.ram changeAtInt pc.addressBus pc.dataBus pc.ram
in in
{ pc | ram = newRam } { pc | ram = newRam }
@ -627,8 +687,17 @@ valueAt n l =
List.head (List.drop n l) List.head (List.drop n l)
changeAt : Int -> Int -> List Int -> List Int changeAtInt : Int -> Int -> List Int -> List Int
changeAt pos newVal list = changeAtInt pos newVal list =
changeAt pos newVal 0 list
changeAtUCode : Int -> UAction -> List UAction -> List UAction
changeAtUCode pos newVal list =
changeAt pos newVal ActNothing list
changeAt : Int -> a -> a ->List a -> List a
changeAt pos newVal default list =
let let
before = before =
List.take pos list List.take pos list
@ -642,7 +711,7 @@ changeAt pos newVal list =
if pos > len then if pos > len then
let let
before2 = before2 =
List.append before (List.repeat (pos - len) 0) List.append before (List.repeat (pos - len) default)
in in
List.append before2 (newVal :: after) List.append before2 (newVal :: after)
@ -674,6 +743,38 @@ addLeadingZero number length =
else else
num_str num_str
seperateInstructionsEntry : Int -> (Int, Int)
seperateInstructionsEntry i =
let
instruction = i // 100000
address = i - instruction*100000
in
(instruction, address)
uAction2String : UAction -> String
uAction2String action =
let
filtered_list = List.filter (\s -> Tuple.first s == action) uCodeDescriptions
in
case List.head filtered_list of
Just (_,info) -> info
Nothing -> "IDK"
string2uAction : String -> Maybe UAction
string2uAction msg =
let
filtered_list = List.filter (\s -> Tuple.second s == msg) uCodeDescriptions
in
case List.head filtered_list of
Just (action,_) -> Just action
_ -> Nothing
selectCuValueDecoder : JD.Decoder String
selectCuValueDecoder =
JD.field "target" ( JD.field "value" JD.string)
-- END HELPERS -- END HELPERS
-- GENERAL -- GENERAL