92
92
#define P9 16
93
93
#define P10 20
94
94
#define P11 21
95
- #define CLKPIN 17
95
+ #define CLKPIN 5
96
96
97
97
98
98
//Main loop modes
@@ -105,112 +105,119 @@ typedef struct _nibble{
105
105
uint8_t data : 4 ;
106
106
} nibble ;
107
107
108
- // Global Variables
108
+ // Global Variables
109
109
110
- extern uint16_t regPC ;
111
- extern nibble regA ;
112
- extern uint16_t regMEM ;
113
- extern nibble regSTAT ;
110
+ extern uint16_t regPC ;
111
+ extern nibble regA ;
112
+ extern uint16_t regMEM ;
113
+ extern nibble regSTAT ;
114
114
115
- extern nibble * MAINMEM ;
115
+ extern nibble * MAINMEM ;
116
116
117
- extern int mem_fd ;
118
- extern void * gpio_map ;
119
- // I/O access
120
- extern volatile unsigned * gpio ;
117
+ extern int mem_fd ;
118
+ extern void * gpio_map ;
119
+ // I/O access
120
+ extern volatile unsigned * gpio ;
121
121
122
122
123
- //--------------------Prototypes----------------------//
123
+ //--------------------Prototypes----------------------//
124
124
125
125
126
- // inst.c Prototypes
127
- // ------------------------------------------------//
126
+ // inst.c Prototypes
127
+ // ------------------------------------------------//
128
128
129
129
130
- //Decodes the OP code and Calls the appropriate instruction
131
- int decode (const char * op_code , uint16_t address );
130
+ //Decodes the OP code and Calls the appropriate instruction
131
+ int decode (const char * op_code , uint16_t address );
132
132
133
- //Halt Instruction
134
- void hlt (void );
133
+ //Halt Instruction
134
+ void hlt (void );
135
135
136
- //Load Instruction
137
- void lod (uint16_t );
136
+ //Load Instruction
137
+ void lod (uint16_t );
138
138
139
- //Store Instruction
140
- void str (uint16_t );
139
+ //Store Instruction
140
+ void str (uint16_t );
141
141
142
- //Add Instruction
143
- void add (uint16_t );
142
+ //Add Instruction
143
+ void add (uint16_t );
144
144
145
- //No Operation Instruction
146
- void nop (void );
145
+ //No Operation Instruction
146
+ void nop (void );
147
147
148
- //NAND Instruction
149
- void nnd (uint16_t );
148
+ //NAND Instruction
149
+ void nnd (uint16_t );
150
150
151
- //Carry XOR into Accumulator
152
- void cxa (void );
151
+ //Carry XOR into Accumulator
152
+ void cxa (void );
153
153
154
- //Jump Instruction
155
- void jmp (uint16_t );
154
+ //Jump Instruction
155
+ void jmp (uint16_t );
156
156
157
- //Prints registers to screen
158
- void printReg (void );
157
+ //Prints registers to screen
158
+ void printReg (void );
159
159
160
+ //Sets the IO fields in MEM to the GPIOs
161
+ void setIOMem (int mode );
160
162
161
- // mem.c Prototypes
162
- // ------------------------------------------------//
163
+ //Inits all GPIOs to outputs
164
+ void initGPIOs ( void );
163
165
164
- //Initialize Memory
165
- int initMem (void );
166
166
167
167
168
- nibble readMem (uint16_t );
168
+ // mem.c Prototypes
169
+ // ------------------------------------------------//
169
170
170
- //Stores data into memory
171
- void writeMem ( nibble data , uint16_t address );
171
+ //Initialize Memory
172
+ int initMem ( void );
172
173
173
- //Prints all of Memory
174
- void printMem (uint16_t , uint16_t );
175
174
176
- //Frees Memory allocation
177
- void freeMem (void );
175
+ nibble readMem (uint16_t );
178
176
179
- //Sets data table values for 1 to 15
180
- void setBoot ( void );
177
+ //Stores data into memory
178
+ void writeMem ( nibble data , uint16_t address );
181
179
180
+ //Prints all of Memory
181
+ void printMem (uint16_t , uint16_t );
182
182
183
+ //Frees Memory allocation
184
+ void freeMem (void );
183
185
184
- //main.c Prototypes
185
- // ------------------------------------------------//
186
+ //Sets data table values for 1 to 15
187
+ void setBoot ( void );
186
188
187
- //Superloop
188
- int mainloop (void );
189
189
190
- //Shuts down the virtual machine
191
- int shutdown (int );
192
190
191
+ //main.c Prototypes
192
+ // ------------------------------------------------//
193
193
194
- void waitForPeriod (long firstTime ,struct timespec gettime_now ,long period );
194
+ //Superloop
195
+ int mainloop (void );
195
196
196
- //util.c Prototypes
197
- //-------------------------------------------------//
197
+ //Shuts down the virtual machine
198
+ int shutdown ( int );
198
199
199
200
200
- char * tobitstr ( size_t , uint64_t , char );
201
+ void waitForPeriod ( long firstTime , struct timespec gettime_now , long period );
201
202
203
+ //util.c Prototypes
204
+ //-------------------------------------------------//
202
205
203
- //fileIO.c Prototypes
204
- //------------------------------------------------//
205
206
206
- //Reads file into memory
207
- int readBin (const char * , uint16_t );
207
+ char * tobitstr (size_t ,uint64_t ,char );
208
208
209
209
210
- //GPIO .c Prototypes
211
- // -----------------------------------------------//
210
+ //fileIO .c Prototypes
211
+ //- -----------------------------------------------//
212
212
213
- void setup_io (void );
213
+ //Reads file into memory
214
+ int readBin (const char * , uint16_t );
215
+
216
+
217
+ //GPIO.c Prototypes
218
+ //-----------------------------------------------//
219
+
220
+ void setup_io (void );
214
221
215
222
216
223
#endif
0 commit comments