Did some renaming and added some more functionality to ALU
This commit is contained in:
@ -43,11 +43,11 @@ initialRam = Array.fromList
|
|||||||
|
|
||||||
initialUCodes : Array UAction
|
initialUCodes : Array UAction
|
||||||
initialUCodes = Array.fromList
|
initialUCodes = Array.fromList
|
||||||
[ UA_ProgrammCounter2AddressBus -- 000
|
[ UA_CU_ProgrammCounter2AddressBus -- 000
|
||||||
, UA_Ram2DataBus -- 001
|
, UA_Ram2DataBus -- 001
|
||||||
, UA_DataBus2InstructionReg -- 002
|
, UA_DataBus2InstructionReg -- 002
|
||||||
, UA_ProgrammCounterIncrement -- 003
|
, UA_CU_ProgrammCounterIncrement -- 003
|
||||||
, UA_InstructionReg2UCounter -- 004
|
, UA_CU_InstructionReg2UCounter -- 004
|
||||||
, UA_Nothing -- 005
|
, UA_Nothing -- 005
|
||||||
, UA_Nothing
|
, UA_Nothing
|
||||||
, UA_Nothing
|
, UA_Nothing
|
||||||
@ -55,10 +55,10 @@ initialUCodes = Array.fromList
|
|||||||
, UA_Nothing -- 009
|
, UA_Nothing -- 009
|
||||||
|
|
||||||
-- 010 LOADA
|
-- 010 LOADA
|
||||||
, UA_InstructionReg2AddressBus -- 010
|
, UA_CU_InstructionReg2AddressBus -- 010
|
||||||
, UA_Ram2DataBus -- 011
|
, UA_Ram2DataBus -- 011
|
||||||
, UA_DataBus2Accumulator -- 012
|
, UA_DataBus2Accumulator -- 012
|
||||||
, UA_ResetUCounter -- 013
|
, UA_CU_ResetUCounter -- 013
|
||||||
, UA_Nothing -- 014
|
, UA_Nothing -- 014
|
||||||
, UA_Nothing
|
, UA_Nothing
|
||||||
, UA_Nothing
|
, UA_Nothing
|
||||||
@ -67,10 +67,10 @@ initialUCodes = Array.fromList
|
|||||||
, UA_Nothing -- 019
|
, UA_Nothing -- 019
|
||||||
|
|
||||||
-- 020 STOA
|
-- 020 STOA
|
||||||
, UA_Accumulator2DataBus -- 020
|
, UA_ALU_Accumulator2DataBus -- 020
|
||||||
, UA_InstructionReg2AddressBus -- 021
|
, UA_CU_InstructionReg2AddressBus -- 021
|
||||||
, UA_DataBus2Ram -- 022
|
, UA_DataBus2Ram -- 022
|
||||||
, UA_ResetUCounter -- 023
|
, UA_CU_ResetUCounter -- 023
|
||||||
, UA_Nothing --024
|
, UA_Nothing --024
|
||||||
, UA_Nothing
|
, UA_Nothing
|
||||||
, UA_Nothing
|
, UA_Nothing
|
||||||
@ -79,8 +79,8 @@ initialUCodes = Array.fromList
|
|||||||
, UA_Nothing -- 029
|
, UA_Nothing -- 029
|
||||||
|
|
||||||
-- 030 INCA
|
-- 030 INCA
|
||||||
, UA_AccumulatorIncrement -- 030
|
, UA_ALU_AccumulatorIncrement -- 030
|
||||||
, UA_ResetUCounter -- 031
|
, UA_CU_ResetUCounter -- 031
|
||||||
, UA_Nothing -- 032
|
, UA_Nothing -- 032
|
||||||
, UA_Nothing
|
, UA_Nothing
|
||||||
, UA_Nothing
|
, UA_Nothing
|
||||||
@ -91,8 +91,8 @@ initialUCodes = Array.fromList
|
|||||||
, UA_Nothing -- 039
|
, UA_Nothing -- 039
|
||||||
|
|
||||||
-- 040 JMP
|
-- 040 JMP
|
||||||
, UA_InstructionReg2ProgrammCounter -- 040
|
, UA_CU_InstructionReg2ProgrammCounter -- 040
|
||||||
, UA_ResetUCounter -- 041
|
, UA_CU_ResetUCounter -- 041
|
||||||
, UA_Nothing -- 042
|
, UA_Nothing -- 042
|
||||||
, UA_Nothing
|
, UA_Nothing
|
||||||
, UA_Nothing
|
, UA_Nothing
|
||||||
|
@ -2,7 +2,7 @@ module PC.Types exposing (..)
|
|||||||
|
|
||||||
import Array exposing (Array)
|
import Array exposing (Array)
|
||||||
|
|
||||||
pcModelVersion = "3"
|
pcModelVersion = "4"
|
||||||
|
|
||||||
type alias PC_Model =
|
type alias PC_Model =
|
||||||
{ pc : PC
|
{ pc : PC
|
||||||
@ -26,21 +26,29 @@ type alias UCode =
|
|||||||
, label : String
|
, label : String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- UActions that can be used in µCode
|
||||||
type UAction
|
type UAction
|
||||||
= UA_Accumulator2DataBus
|
= UA_ALU_Accumulator2DataBus
|
||||||
| UA_AccumulatorDecrement
|
| UA_ALU_AccumulatorDecrement
|
||||||
| UA_AccumulatorIncrement
|
| UA_ALU_AccumulatorIncrement
|
||||||
|
| UA_ALU_AccumulatorShiftLeftByDataBus
|
||||||
|
| UA_ALU_AccumulatorShiftRightByDataBus
|
||||||
|
| UA_ALU_AccumulatorAddByDataBus
|
||||||
|
| UA_ALU_AccumulatorSubtractByDataBus
|
||||||
|
| UA_ALU_AccumulatorMultiplyByDataBus
|
||||||
|
| UA_ALU_AccumulatorDivideByDataBus
|
||||||
|
| 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_DataBus2Accumulator
|
||||||
| UA_DataBus2InstructionReg
|
| UA_DataBus2InstructionReg
|
||||||
| UA_DataBus2Ram
|
| UA_DataBus2Ram
|
||||||
| UA_InstructionReg2AddressBus
|
|
||||||
| UA_InstructionReg2ProgrammCounter
|
|
||||||
| UA_InstructionReg2UCounter
|
|
||||||
| UA_ProgrammCounterIncrement
|
|
||||||
| UA_InstructionReg2ProgrammCounterIfAccEq0
|
|
||||||
| UA_Ram2DataBus
|
| UA_Ram2DataBus
|
||||||
| UA_ResetUCounter
|
|
||||||
| UA_ProgrammCounter2AddressBus
|
|
||||||
| UA_AlertUser
|
| UA_AlertUser
|
||||||
| UA_Nothing
|
| UA_Nothing
|
||||||
|
|
||||||
|
@ -11,23 +11,30 @@ import PC.Helpers exposing (..)
|
|||||||
|
|
||||||
uCodes : List UCode
|
uCodes : List UCode
|
||||||
uCodes =
|
uCodes =
|
||||||
[ UCode UA_Nothing "n" (\s -> s) "Empty"
|
[ UCode UA_Nothing "n" (\s -> s) "Empty"
|
||||||
, UCode UA_Accumulator2DataBus "acc2db" actAccumulator2DataBus "Acc -> DataBus"
|
, UCode UA_ALU_Accumulator2DataBus "acc2db" actAccumulator2DataBus "Acc -> DataBus"
|
||||||
, UCode UA_AccumulatorDecrement "accDec" actAccumulatorDecrement "Acc --"
|
, UCode UA_ALU_AccumulatorDecrement "accDec" actAccumulatorDecrement "Acc --"
|
||||||
, UCode UA_AccumulatorIncrement "accInc" actAccumulatorIncrement "Acc ++"
|
, UCode UA_ALU_AccumulatorIncrement "accInc" actAccumulatorIncrement "Acc ++"
|
||||||
, UCode UA_DataBus2Accumulator "db2acc" actDataBus2Accumulator "DataBus -> Acc"
|
, UCode UA_ALU_AccumulatorShiftLeftByDataBus "accLsN" actAccumulatorShiftLeft "Acc << DataBus"
|
||||||
, UCode UA_DataBus2InstructionReg "db2ir" actDataBus2InstructionReg "DataBus -> InstReg"
|
, UCode UA_ALU_AccumulatorShiftRightByDataBus "accRsN" actAccumulatorShiftRight "Acc >> DataBus"
|
||||||
, UCode UA_DataBus2Ram "db2ram" actDataBus2Ram "DataBus -> Ram"
|
, UCode UA_ALU_AccumulatorAddByDataBus "accAdd" actAccumulatorAdd "Acc + DataBus"
|
||||||
, UCode UA_InstructionReg2AddressBus "ir2ab" actInstructionReg2AddressBus "InstReg -> AddrBus"
|
, UCode UA_ALU_AccumulatorSubtractByDataBus "accSub" actAccumulatorSub "Acc - DataBus"
|
||||||
, UCode UA_InstructionReg2ProgrammCounter "ir2pc" actInstructionReg2ProgrammCounter "InstReg -> ProgCount"
|
, UCode UA_ALU_AccumulatorMultiplyByDataBus "accMul" actAccumulatorMultiply "Acc * DataBus"
|
||||||
, UCode UA_InstructionReg2UCounter "ir2uc" actInstructionReg2UCounter "InstReg -> µCounter"
|
, UCode UA_ALU_AccumulatorDivideByDataBus "accDiv" actAccumulatorDivide "Acc / DataBus"
|
||||||
, UCode UA_ProgrammCounterIncrement "pcInc" actProgrammCounterIncrement "ProgCounter ++"
|
, UCode UA_CU_InstructionReg2AddressBus "ir2ab" actInstructionReg2AddressBus "InstReg -> AddrBus"
|
||||||
, UCode UA_Ram2DataBus "ram2db" actRam2DataBus "Ram -> DataBus"
|
, UCode UA_CU_InstructionReg2DataBus "ir2db" actInstructionReg2DataBus "InstReg -> DataBus"
|
||||||
, UCode UA_ResetUCounter "ucReset" actResetUCounter "µCounter = 0"
|
, UCode UA_CU_InstructionReg2ProgrammCounter "ir2pc" actInstructionReg2ProgrammCounter "InstReg -> ProgCount"
|
||||||
, UCode UA_ProgrammCounter2AddressBus "pc2ab" actProgrammCounter2AddressBus "ProgCounter -> AddrBus"
|
, UCode UA_CU_InstructionReg2UCounter "ir2uc" actInstructionReg2UCounter "InstReg -> µCounter"
|
||||||
, UCode UA_InstructionReg2ProgrammCounterIfAccEq0
|
, UCode UA_CU_ProgrammCounterIncrement "pcInc" actProgrammCounterIncrement "ProgCounter ++"
|
||||||
|
, UCode UA_CU_ProgrammCounter2AddressBus "pc2ab" actProgrammCounter2AddressBus "ProgCounter -> AddrBus"
|
||||||
|
, UCode UA_CU_ResetUCounter "ucReset" actResetUCounter "µCounter = 0"
|
||||||
|
, UCode UA_CU_InstructionReg2ProgrammCounterIfAccEq0
|
||||||
"ir2pciacceq0" actInstructionReg2ProgrammCounterIfAccEq0 "Acc == 0 => InstReg -> ProgCounter"
|
"ir2pciacceq0" actInstructionReg2ProgrammCounterIfAccEq0 "Acc == 0 => InstReg -> ProgCounter"
|
||||||
, UCode UA_AlertUser "alert" actDoAlert "Signal End of Programm"
|
, UCode UA_DataBus2Accumulator "db2acc" actDataBus2Accumulator "DataBus -> Acc"
|
||||||
|
, UCode UA_DataBus2InstructionReg "db2ir" actDataBus2InstructionReg "DataBus -> InstReg"
|
||||||
|
, UCode UA_DataBus2Ram "db2ram" actDataBus2Ram "DataBus -> Ram"
|
||||||
|
, UCode UA_Ram2DataBus "ram2db" actRam2DataBus "Ram -> DataBus"
|
||||||
|
, UCode UA_AlertUser "alert" actDoAlert "Signal End of Programm"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -73,6 +80,12 @@ actInstructionReg2AddressBus pc =
|
|||||||
in
|
in
|
||||||
{ pc | addressBus = address }
|
{ pc | addressBus = address }
|
||||||
|
|
||||||
|
actInstructionReg2DataBus : PC -> PC
|
||||||
|
actInstructionReg2DataBus pc =
|
||||||
|
let
|
||||||
|
(_, data) = seperateInstructionsEntry pc.instructionReg
|
||||||
|
in
|
||||||
|
{ pc | dataBus = data }
|
||||||
|
|
||||||
actInstructionReg2ProgrammCounter : PC -> PC
|
actInstructionReg2ProgrammCounter : PC -> PC
|
||||||
actInstructionReg2ProgrammCounter pc =
|
actInstructionReg2ProgrammCounter pc =
|
||||||
@ -121,6 +134,31 @@ actAccumulatorDecrement : PC -> PC
|
|||||||
actAccumulatorDecrement pc =
|
actAccumulatorDecrement pc =
|
||||||
{ pc | accumulator = pc.accumulator - 1 }
|
{ pc | accumulator = pc.accumulator - 1 }
|
||||||
|
|
||||||
|
actAccumulatorShiftLeft : PC -> PC
|
||||||
|
actAccumulatorShiftLeft pc =
|
||||||
|
{ pc | accumulator = pc.accumulator * (2 ^ pc.dataBus) }
|
||||||
|
|
||||||
|
actAccumulatorShiftRight : PC -> PC
|
||||||
|
actAccumulatorShiftRight pc =
|
||||||
|
{ pc | accumulator = pc.accumulator // (2 ^ pc.dataBus) }
|
||||||
|
|
||||||
|
actAccumulatorAdd : PC -> PC
|
||||||
|
actAccumulatorAdd pc =
|
||||||
|
{ pc | accumulator = pc.accumulator + pc.dataBus }
|
||||||
|
|
||||||
|
actAccumulatorSub : PC -> PC
|
||||||
|
actAccumulatorSub pc =
|
||||||
|
{ pc | accumulator = pc.accumulator - pc.dataBus }
|
||||||
|
|
||||||
|
actAccumulatorMultiply : PC -> PC
|
||||||
|
actAccumulatorMultiply pc =
|
||||||
|
{ pc | accumulator = pc.accumulator * pc.dataBus }
|
||||||
|
|
||||||
|
actAccumulatorDivide : PC -> PC
|
||||||
|
actAccumulatorDivide pc =
|
||||||
|
{ pc | accumulator = pc.accumulator // pc.dataBus }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
actDataBus2Ram : PC -> PC
|
actDataBus2Ram : PC -> PC
|
||||||
actDataBus2Ram pc =
|
actDataBus2Ram pc =
|
||||||
|
Reference in New Issue
Block a user