Skip to content

Commit a087921

Browse files
committed
Update vm4.h
1 parent 3e69e1c commit a087921

File tree

1 file changed

+71
-64
lines changed

1 file changed

+71
-64
lines changed

vm4.h

+71-64
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
#define P9 16
9393
#define P10 20
9494
#define P11 21
95-
#define CLKPIN 17
95+
#define CLKPIN 5
9696

9797

9898
//Main loop modes
@@ -105,112 +105,119 @@ typedef struct _nibble{
105105
uint8_t data : 4;
106106
} nibble;
107107

108-
// Global Variables
108+
// Global Variables
109109

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;
114114

115-
extern nibble* MAINMEM;
115+
extern nibble* MAINMEM;
116116

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;
121121

122122

123-
//--------------------Prototypes----------------------//
123+
//--------------------Prototypes----------------------//
124124

125125

126-
// inst.c Prototypes
127-
// ------------------------------------------------//
126+
// inst.c Prototypes
127+
// ------------------------------------------------//
128128

129129

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);
132132

133-
//Halt Instruction
134-
void hlt(void);
133+
//Halt Instruction
134+
void hlt(void);
135135

136-
//Load Instruction
137-
void lod(uint16_t);
136+
//Load Instruction
137+
void lod(uint16_t);
138138

139-
//Store Instruction
140-
void str(uint16_t);
139+
//Store Instruction
140+
void str(uint16_t);
141141

142-
//Add Instruction
143-
void add(uint16_t);
142+
//Add Instruction
143+
void add(uint16_t);
144144

145-
//No Operation Instruction
146-
void nop(void);
145+
//No Operation Instruction
146+
void nop(void);
147147

148-
//NAND Instruction
149-
void nnd(uint16_t);
148+
//NAND Instruction
149+
void nnd(uint16_t);
150150

151-
//Carry XOR into Accumulator
152-
void cxa(void);
151+
//Carry XOR into Accumulator
152+
void cxa(void);
153153

154-
//Jump Instruction
155-
void jmp(uint16_t);
154+
//Jump Instruction
155+
void jmp(uint16_t);
156156

157-
//Prints registers to screen
158-
void printReg(void);
157+
//Prints registers to screen
158+
void printReg(void);
159159

160+
//Sets the IO fields in MEM to the GPIOs
161+
void setIOMem(int mode);
160162

161-
// mem.c Prototypes
162-
// ------------------------------------------------//
163+
//Inits all GPIOs to outputs
164+
void initGPIOs(void);
163165

164-
//Initialize Memory
165-
int initMem(void);
166166

167167

168-
nibble readMem(uint16_t);
168+
// mem.c Prototypes
169+
// ------------------------------------------------//
169170

170-
//Stores data into memory
171-
void writeMem(nibble data, uint16_t address);
171+
//Initialize Memory
172+
int initMem(void);
172173

173-
//Prints all of Memory
174-
void printMem(uint16_t, uint16_t);
175174

176-
//Frees Memory allocation
177-
void freeMem(void);
175+
nibble readMem(uint16_t);
178176

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);
181179

180+
//Prints all of Memory
181+
void printMem(uint16_t, uint16_t);
182182

183+
//Frees Memory allocation
184+
void freeMem(void);
183185

184-
//main.c Prototypes
185-
// ------------------------------------------------//
186+
//Sets data table values for 1 to 15
187+
void setBoot(void);
186188

187-
//Superloop
188-
int mainloop(void);
189189

190-
//Shuts down the virtual machine
191-
int shutdown(int);
192190

191+
//main.c Prototypes
192+
// ------------------------------------------------//
193193

194-
void waitForPeriod(long firstTime,struct timespec gettime_now,long period );
194+
//Superloop
195+
int mainloop(void);
195196

196-
//util.c Prototypes
197-
//-------------------------------------------------//
197+
//Shuts down the virtual machine
198+
int shutdown(int);
198199

199200

200-
char *tobitstr(size_t,uint64_t,char);
201+
void waitForPeriod(long firstTime,struct timespec gettime_now,long period );
201202

203+
//util.c Prototypes
204+
//-------------------------------------------------//
202205

203-
//fileIO.c Prototypes
204-
//------------------------------------------------//
205206

206-
//Reads file into memory
207-
int readBin(const char*, uint16_t);
207+
char *tobitstr(size_t,uint64_t,char);
208208

209209

210-
//GPIO.c Prototypes
211-
//-----------------------------------------------//
210+
//fileIO.c Prototypes
211+
//------------------------------------------------//
212212

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);
214221

215222

216223
#endif

0 commit comments

Comments
 (0)