Add bitwise operations to ALU
This commit is contained in:
parent
90dae6963b
commit
ad1fddf495
@ -211,6 +211,22 @@ Instr Argument
|
||||
<td><code>Acc / DataBus</code></td>
|
||||
<td>Dividiere den Akkumulator durch den Datenbus</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Acc AND DataBus</code></td>
|
||||
<td>Führe bitweise UND auf Akkumulator mit Datenbus aus</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Acc OR DataBus</code></td>
|
||||
<td>Führe bitweise ODER auf Akkumulator mit Datenbus aus</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Acc XOR DataBus</code></td>
|
||||
<td>Führe bitweise XOR auf Akkumulator mit Datenbus aus</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Acc NOT DataBus</code></td>
|
||||
<td>Führe bitweise NOT auf Akkumulator mit Datenbus aus</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>InstReg -> µCounter</code></td>
|
||||
<td>Nehme das Argument des Befehls im Instruktionsregister, füge am Ende eine 0 an und Lade ihn in den µCounter</td>
|
||||
@ -409,6 +425,22 @@ Instr Argument
|
||||
<td><code>Acc / DataBus</code></td>
|
||||
<td>Divide the accumulator by the value of the databus</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Acc AND DataBus</code></td>
|
||||
<td>Do a bitwise AND to accumulator with the value of the databus</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Acc OR DataBus</code></td>
|
||||
<td>Do a bitwise OR to accumulator with the value of the databus</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Acc XOR DataBus</code></td>
|
||||
<td>Do a bitwise XOR to accumulator with the value of the databus</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Acc NOT DataBus</code></td>
|
||||
<td>Do a bitwise NOT to accumulator with the value of the databus</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>InstReg -> µCounter</code></td>
|
||||
<td>Take the instruction from instruction register, add a 0 at the tail and write it to µCounter</td>
|
||||
|
@ -37,6 +37,10 @@ type UAction
|
||||
| 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
|
||||
|
@ -5,6 +5,7 @@ module PC.UActions exposing ( uCodes
|
||||
|
||||
import Array exposing (Array)
|
||||
import Tuple
|
||||
import Bitwise
|
||||
|
||||
import PC.Types exposing (..)
|
||||
import PC.Helpers exposing (..)
|
||||
@ -21,6 +22,10 @@ uCodes =
|
||||
, UCode UA_ALU_AccumulatorSubtractByDataBus "accSub" actAccumulatorSub "Acc - DataBus"
|
||||
, UCode UA_ALU_AccumulatorMultiplyByDataBus "accMul" actAccumulatorMultiply "Acc * DataBus"
|
||||
, UCode UA_ALU_AccumulatorDivideByDataBus "accDiv" actAccumulatorDivide "Acc / DataBus"
|
||||
, UCode UA_ALU_AccumulatorANDDataBus "accAND" actAccumulatorAND "Acc AND DataBus"
|
||||
, UCode UA_ALU_AccumulatorORDataBus "accOR" actAccumulatorOR "Acc OR DataBus"
|
||||
, UCode UA_ALU_AccumulatorXORDataBus "accXOR" actAccumulatorXOR "Acc XOR DataBus"
|
||||
, UCode UA_ALU_AccumulatorNOT "accNOT" actAccumulatorNOT "Acc NOT"
|
||||
, UCode UA_CU_InstructionReg2AddressBus "ir2ab" actInstructionReg2AddressBus "InstReg -> AddrBus"
|
||||
, UCode UA_CU_InstructionReg2DataBus "ir2db" actInstructionReg2DataBus "InstReg -> DataBus"
|
||||
, UCode UA_CU_InstructionReg2ProgrammCounter "ir2pc" actInstructionReg2ProgrammCounter "InstReg -> ProgCount"
|
||||
@ -158,6 +163,22 @@ actAccumulatorDivide : PC -> PC
|
||||
actAccumulatorDivide pc =
|
||||
{ pc | accumulator = pc.accumulator // pc.dataBus }
|
||||
|
||||
actAccumulatorAND : PC -> PC
|
||||
actAccumulatorAND pc =
|
||||
{ pc | accumulator = Bitwise.and pc.accumulator pc.dataBus }
|
||||
|
||||
actAccumulatorOR : PC -> PC
|
||||
actAccumulatorOR pc =
|
||||
{ pc | accumulator = Bitwise.or pc.accumulator pc.dataBus }
|
||||
|
||||
actAccumulatorXOR : PC -> PC
|
||||
actAccumulatorXOR pc =
|
||||
{ pc | accumulator = Bitwise.xor pc.accumulator pc.dataBus }
|
||||
|
||||
actAccumulatorNOT : PC -> PC
|
||||
actAccumulatorNOT pc =
|
||||
{ pc | accumulator = Bitwise.complement pc.accumulator }
|
||||
|
||||
|
||||
|
||||
actDataBus2Ram : PC -> PC
|
||||
|
@ -292,6 +292,13 @@ viewAlu model =
|
||||
, button [ onClick <| PM_ManualStep UA_ALU_AccumulatorMultiplyByDataBus ] [ text "*" ]
|
||||
, button [ onClick <| PM_ManualStep UA_ALU_AccumulatorDivideByDataBus ] [ text "/" ]
|
||||
]
|
||||
, Html.span [] [ text "Bitwise operations"]
|
||||
, div [ class "button-group-alu__4-elements" ]
|
||||
[ button [ onClick <| PM_ManualStep UA_ALU_AccumulatorANDDataBus ] [ text "AND" ]
|
||||
, button [ onClick <| PM_ManualStep UA_ALU_AccumulatorORDataBus ] [ text "OR" ]
|
||||
, button [ onClick <| PM_ManualStep UA_ALU_AccumulatorXORDataBus ] [ text "XOR" ]
|
||||
, button [ onClick <| PM_ManualStep UA_ALU_AccumulatorNOT ] [ text "NOT" ]
|
||||
]
|
||||
]
|
||||
, div [ class "arrow-line", class "bottom" ]
|
||||
[ drawArrow Up UA_DataBus2Accumulator "DB -> ALU"
|
||||
|
Loading…
x
Reference in New Issue
Block a user