92 lines
2.7 KiB
Elm
92 lines
2.7 KiB
Elm
module PC.Types exposing (..)
|
|
|
|
import Array exposing (Array)
|
|
|
|
pcModelVersion = "4"
|
|
|
|
type alias PC_Model =
|
|
{ pc : PC
|
|
, uCodes : Array UAction
|
|
}
|
|
|
|
type alias PC =
|
|
{ ram : Array (Int, String)
|
|
, dataBus : Int
|
|
, addressBus : Int
|
|
, instructionReg : Int
|
|
, programmCounter : Int
|
|
, uCounter : Int
|
|
, accumulator : Int
|
|
}
|
|
|
|
type alias UCode =
|
|
{ variant : UAction
|
|
, id : String
|
|
, action : PC -> PC
|
|
, label : String
|
|
}
|
|
|
|
-- UActions that can be used in µCode
|
|
type UAction
|
|
= UA_ALU_Accumulator2DataBus
|
|
| UA_ALU_AccumulatorDecrement
|
|
| UA_ALU_AccumulatorIncrement
|
|
| UA_ALU_AccumulatorShiftLeftByDataBus
|
|
| UA_ALU_AccumulatorShiftRightByDataBus
|
|
| UA_ALU_AccumulatorAddByDataBus
|
|
| UA_ALU_AccumulatorSubtractByDataBus
|
|
| UA_ALU_AccumulatorMultiplyByDataBus
|
|
| UA_ALU_AccumulatorDivideByDataBus
|
|
| UA_ALU_AccumulatorANDDataBus
|
|
| UA_ALU_AccumulatorORDataBus
|
|
| UA_ALU_AccumulatorXORDataBus
|
|
| UA_ALU_AccumulatorNOT
|
|
| UA_CU_InstructionReg2AddressBus
|
|
| UA_CU_InstructionReg2DataBus
|
|
| UA_CU_InstructionReg2ProgrammCounter
|
|
| UA_CU_InstructionReg2UCounter
|
|
| UA_CU_ProgrammCounterIncrement
|
|
| UA_CU_InstructionReg2ProgrammCounterIfAccEq0
|
|
| UA_CU_ProgrammCounter2AddressBus
|
|
| UA_CU_ResetUCounter
|
|
| UA_DataBus2Accumulator
|
|
| UA_DataBus2InstructionReg
|
|
| UA_DataBus2Ram
|
|
| UA_Ram2DataBus
|
|
| UA_AlertUser
|
|
| UA_Nothing
|
|
|
|
|
|
-- To make it easier to understand everything has name convention
|
|
-- PM_ -> PC_Msg in general
|
|
-- PM_B_ -> for a Button
|
|
-- PM_C_ -> for a Checkbox
|
|
-- PM_F_ -> for a TextField
|
|
type PC_Msg
|
|
= PM_B_UCycleStep
|
|
| PM_B_InstructionStep
|
|
| PM_B_Reset
|
|
| PM_B_RamAddBelow
|
|
| PM_B_CuAddBelow
|
|
| PM_F_RamEditInstr Int String
|
|
| PM_F_RamEditAddress Int String
|
|
| PM_F_RamEditComment Int String
|
|
| PM_F_CuEditAction Int String
|
|
| PM_F_CuInstrRegEditAddr String
|
|
| PM_F_CuInstrRegEditInstr String
|
|
| PM_F_CuProgCounterEdit String
|
|
| PM_F_CuUCounterEdit String
|
|
| PM_F_EditAddressBus String
|
|
| PM_F_EditDataBus String
|
|
| PM_F_AluEdit String
|
|
| PM_ManualStep UAction
|
|
|
|
|
|
-- Tells main what is supposed
|
|
-- to happen after a update
|
|
type PC_AfterUpdateAction
|
|
= PUA_Nothing -- Do nothing
|
|
| PUA_Alert -- Alert the user
|
|
| PUA_Storage -- Update localStorage
|
|
| PUA_Scroller -- Scroll to value
|
|
| PUA_Storage_And_Scroller -- Update localStorage and scroll to values |