summaryrefslogtreecommitdiff
path: root/instruction.h
diff options
context:
space:
mode:
authorJacob McDonnell <jacob@jacobmcdonnell.com>2024-07-06 22:49:17 -0400
committerJacob McDonnell <jacob@jacobmcdonnell.com>2024-07-06 22:49:17 -0400
commit14e3f70e7b62d2c5c3b934d4eba214d72e198830 (patch)
treec9da7a92f57882bed3a624eb50eceaa04e21056e /instruction.h
parentaa317d9a7aec97d478bd5f5af3305642a4f258c5 (diff)
Restructured the Project
Diffstat (limited to 'instruction.h')
-rw-r--r--instruction.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/instruction.h b/instruction.h
new file mode 100644
index 0000000..2e10ed6
--- /dev/null
+++ b/instruction.h
@@ -0,0 +1,42 @@
+#ifndef INSTRUCTION_H
+#define INSTRUCTION_H
+
+#include <stdint.h>
+
+typedef struct {
+ unsigned int op: 6;
+ unsigned int rs: 5;
+ unsigned int rt: 5;
+ unsigned int rd: 5;
+ unsigned int shamt: 5;
+ unsigned int func: 6;
+} rtype_t;
+
+typedef struct {
+ unsigned int op: 6;
+ unsigned int rs: 5;
+ unsigned int rt: 5;
+ unsigned int imm: 16;
+} itype_t;
+
+typedef struct {
+ unsigned int op: 6;
+ unsigned int addr: 26;
+} jtype_t;
+
+typedef enum { NOP, RTYPE, ITYPE, JTYPE } type_t;
+
+typedef struct {
+ type_t type;
+ union {
+ rtype_t r;
+ jtype_t j;
+ itype_t i;
+ uint32_t value;
+ };
+} inst_t;
+
+void InstFetch(inst_t *inst);
+void InstExec(const inst_t inst);
+
+#endif