Fixed instrGen and added large test

Also added a note about the OR instruction. Either to fix later or leave as is.
This commit is contained in:
Kacper 2020-06-07 17:41:37 +01:00
parent 0b1ffea9ce
commit 24e22f13ec
3 changed files with 147 additions and 4 deletions

View file

@ -17,6 +17,11 @@
STA R6 909
*/
/*
IMPORTANT NOTE: For the OR instruction, enter it as "_OR", otherwise the code breaks :(
-Kacper
*/
#include <iostream>
#include <string>
#include <vector>
@ -190,7 +195,7 @@ string getInstructionHex(string instruction){
rs2="R0";
}else if(opcode=="AND"){
binary+="001100";
}else if(opcode=="OR"){
}else if(opcode=="_OR"){
binary+="001101";
}else if(opcode=="XOR"){
binary+="001110";
@ -215,7 +220,7 @@ string getInstructionHex(string instruction){
rs1="R0";
rs2="R0";
}else if(opcode=="SUB"){
binary+"011000";
binary+="011000";
}else if(opcode=="SBC"){
binary+="011001";
}else if(opcode=="SBO"){
@ -278,10 +283,12 @@ void generateMIF(vector<string> instructions){
cout << "DATA_RADIX = HEX;" << endl;
cout << "CONTENT" << endl;
cout << "BEGIN" << endl;
cout << "[0..2047]: 0;" << endl;
for (int i = 0; i < instructions.size(); i++){
int i=0;
for (i; i < instructions.size(); i++){
cout << i << " : " << instructions.at(i) << ";" << endl;
}
cout << "[" << i << "..2047]: 0;" << endl;
cout << "END;" << endl;
}
int main(){

72
all_instr_test.mif Normal file
View file

@ -0,0 +1,72 @@
DEPTH = 2048;
WIDTH = 16;
ADDRESS_RADIX = DEC;
DATA_RADIX = HEX;
CONTENT
BEGIN
0 : 8800;
1 : 9001;
2 : 26D0;
3 : 291A;
4 : 2D00;
5 : 3161;
6 : 3440;
7 : 3993;
8 : 3AA5;
9 : D003;
10 : 3CE2;
11 : A003;
12 : 9804;
13 : 38A5;
14 : 3FC0;
15 : 419F;
16 : 304F;
17 : 5008;
18 : 5028;
19 : 284F;
20 : 43F7;
21 : 3540;
22 : 47F5;
23 : 484D;
24 : 8806;
25 : 0040;
26 : B800;
27 : 8807;
28 : 085A;
29 : B800;
30 : 8808;
31 : 0A7D;
32 : B800;
33 : 8809;
34 : 0C53;
35 : B801;
36 : 880A;
37 : B00B;
38 : 0E70;
39 : B800;
40 : 880C;
41 : 1063;
42 : B800;
43 : 880D;
44 : 126D;
45 : B800;
46 : 880E;
47 : 147A;
48 : B800;
49 : 880F;
50 : 5340;
51 : 53C0;
52 : 1678;
53 : B800;
54 : 1863;
55 : 1A5A;
56 : 1FB8;
57 : 7C00;
58 : 1C77;
59 : 204C;
60 : A810;
61 : 226D;
62 : 246D;
63 : 7E00;
[64..2047]: 0;
END;

64
all_instr_test.txt Normal file
View file

@ -0,0 +1,64 @@
LDA R1 0
LDA R2 1
MOV R3 R2
ADD R4 R3 R2
ADO R4
SUB R5 R4 R1
SBO R1
MUL R6 R2 R3
MLA R2 R4 R5
STA R2 3
MLS R3 R4 R2
LDA R4 3
LDA R3 4
MUL R2 R4 R5
MRT R7
LSL R6 R3 R7
SUB R1 R1 R7
PSH R1
PSH R5
ADD R1 R1 R7
LSR R7 R6 R7
SBO R5
ASR R7 R6 R5
ROR R1 R1 R5
LDA R1 6
JMP R1
LDA R7 0
LDA R1 7
JC1 R1 R3 R2
LDA R7 0
LDA R1 8
JC2 R1 R7 R5
LDA R7 0
LDA R1 9
JC3 R1 R2 R3
LDA R7 1
LDA R1 10
LDA R6 11
JC4 R1 R6
LDA R7 0
LDA R1 12
JC5 R1 R4 R3
LDA R7 0
LDA R1 13
JC6 R1 R5 R5
LDA R7 0
LDA R1 14
JC7 R1 R7 R2
LDA R7 0
LDA R1 15
POP R5
POP R7
JC8 R1 R7
LDA R7 0
AND R1 R4 R3
_OR R1 R3 R2
NOT R6 R7
NOP
XOR R1 R6 R7
NND R1 R1 R4
LDA R5 16
NOR R1 R5 R5
XNR R1 R5 R5
STP