forked from virtualagc/virtualagc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathALU.cpp
136 lines (134 loc) · 3.22 KB
/
ALU.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/****************************************************************************
* ALU - ARITHMETIC UNIT subsystem
*
* AUTHOR: John Pultorak
* DATE: 9/22/01
* FILE: ALU.cpp
*
* NOTES: see header file.
*
*****************************************************************************
*/
#include "ALU.h"
#include "SEQ.h"
#include "BUS.h"
regB ALU::register_B; // next instruction
regCI ALU::register_CI; // ALU carry-in flip flop
regX ALU::register_X; // ALU X register
regY ALU::register_Y; // ALU Y register
regU ALU::register_U; // ALU sum
unsigned ALU::glbl_BUS = 0;
unsigned whereGo = 02030;
//************************************************************
void
ALU::execRP_ALU_RB()
{
BUS::glbl_READ_BUS = register_B.read();
}
// Performs an inclusive OR or register U and register C;
// in the MASK instruction, the RC and RU control pulses
// are activated simultaneously. This causes both to be
// gated onto the AGC bus which performs the logical OR.
void
ALU::execRP_ALU_RC()
{
ALU::glbl_BUS |= register_B.outmask() & (~register_B.read());
BUS::glbl_READ_BUS = ALU::glbl_BUS;
}
// Performs an inclusive OR or register U and register C;
// in the MASK instruction, the RC and RU control pulses
// are activated simultaneously. This causes both to be
// gated onto the AGC bus which performs the logical OR.
void
ALU::execRP_ALU_RU()
{
ALU::glbl_BUS |= register_U.read();
BUS::glbl_READ_BUS = ALU::glbl_BUS;
}
//************************************************************
//************************************************************
// This is the interface between the read and write busses
void
ALU::execRP_ALU_OR_RB14()
{
BUS::glbl_WRITE_BUS |= 0020000 | BUS::glbl_READ_BUS;
}
void
ALU::execRP_ALU_OR_R1()
{
BUS::glbl_WRITE_BUS |= 0000001 | BUS::glbl_READ_BUS;
}
void
ALU::execRP_ALU_OR_R1C()
{
BUS::glbl_WRITE_BUS |= 0177776 | BUS::glbl_READ_BUS;
}
void
ALU::execRP_ALU_OR_R2()
{
BUS::glbl_WRITE_BUS |= 0000002 | BUS::glbl_READ_BUS;
}
void
ALU::execRP_ALU_OR_RSB()
{
BUS::glbl_WRITE_BUS |= 0100000 | BUS::glbl_READ_BUS;
}
void
ALU::execRP_ALU_OR_R22()
{
BUS::glbl_WRITE_BUS |= 0000022 | BUS::glbl_READ_BUS;
}
void
ALU::execRP_ALU_OR_R24()
{
BUS::glbl_WRITE_BUS |= 0000024 | BUS::glbl_READ_BUS;
}
void
ALU::execRP_ALU_OR_R2000()
{
BUS::glbl_WRITE_BUS |= whereGo | BUS::glbl_READ_BUS; // TC GOPROG instruction
}
//************************************************************
void
ALU::execWP_GENRST()
{
}
void
ALU::execWP_CI()
{
register_CI.writeField(1, 1, 1);
}
void
ALU::execWP_WX()
{
register_X.write(BUS::glbl_WRITE_BUS);
}
void
ALU::execWP_WB()
{
register_B.write(BUS::glbl_WRITE_BUS);
}
void
ALU::execWP_WYx()
{
register_Y.write(BUS::glbl_WRITE_BUS);
}
void
ALU::execWP_WY()
{
if (!SEQ::isAsserted(CI))
register_CI.writeField(1, 1, 0);
register_X.write(0);
register_Y.write(BUS::glbl_WRITE_BUS);
}
unsigned
regU::read()
{
unsigned carry = (outmask() + 1)
& (ALU::register_X.read() + ALU::register_Y.read()); // end-around carry
if (carry || ALU::register_CI.read())
carry = 1;
else
carry = 0;
return outmask() & (ALU::register_X.read() + ALU::register_Y.read() + carry);
}