commit 838a10427f9e50c04da128efbd0c729ff8f81424 Author: Wouter Horlings Date: Wed Sep 18 16:49:13 2019 +0200 snelle beun commit diff --git a/ACE1/.~lock.registersheet.ods# b/ACE1/.~lock.registersheet.ods# new file mode 100755 index 0000000..ed532d1 --- /dev/null +++ b/ACE1/.~lock.registersheet.ods# @@ -0,0 +1 @@ +,wouter,doofensmirtz,17.09.2019 13:32,file:///home/wouter/.config/libreoffice/4; \ No newline at end of file diff --git a/ACE1/ATmega48A-PA-88A-PA-168A-PA-328-P-DS-DS40002061A.pdf b/ACE1/ATmega48A-PA-88A-PA-168A-PA-328-P-DS-DS40002061A.pdf new file mode 100755 index 0000000..ac201a2 Binary files /dev/null and b/ACE1/ATmega48A-PA-88A-PA-168A-PA-328-P-DS-DS40002061A.pdf differ diff --git a/ACE1/ass1/.vscode/arduino.json b/ACE1/ass1/.vscode/arduino.json new file mode 100755 index 0000000..bf32d10 --- /dev/null +++ b/ACE1/ass1/.vscode/arduino.json @@ -0,0 +1,6 @@ +{ + "programmer": "AVR ISP", + "port": "/dev/ttyACM0", + "board": "arduino:avr:uno", + "sketch": "code/code.ino" +} \ No newline at end of file diff --git a/ACE1/ass1/.vscode/c_cpp_properties.json b/ACE1/ass1/.vscode/c_cpp_properties.json new file mode 100755 index 0000000..7fc7f21 --- /dev/null +++ b/ACE1/ass1/.vscode/c_cpp_properties.json @@ -0,0 +1,19 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "/home/wouter/.arduino15/packages/arduino/tools/**", + "/home/wouter/.arduino15/packages/arduino/hardware/avr/1.6.22/**" + ], + "forcedInclude": [ + "/home/wouter/.arduino15/packages/arduino/hardware/avr/1.6.22/cores/arduino/Arduino.h" + ], + "intelliSenseMode": "gcc-x64", + "compilerPath": "/usr/bin/clang", + "cStandard": "c11", + "cppStandard": "c++17" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/ACE1/ass1/A.csv b/ACE1/ass1/A.csv new file mode 100755 index 0000000..b754765 --- /dev/null +++ b/ACE1/ass1/A.csv @@ -0,0 +1,13 @@ +{{28,122,80,42,54,122,98,42,99,58,124,29,21}, +{113,85,30,35,41,98,103,68,15,50,31,80,54}, +{47,37,23,96,59,47,84,26,84,72,51,118,119}, +{38,121,45,21,87,91,20,69,98,119,15,89,47}, +{40,71,105,76,31,65,109,30,127,110,17,64,64}, +{45,20,113,86,86,51,104,115,61,103,60,113,44}, +{101,107,33,63,39,47,120,20,41,64,102,59,86}, +{9,42,118,26,83,123,10,82,47,108,127,4,66}, +{75,26,117,80,47,111,38,22,98,101,92,100,48}, +{90,9,71,36,90,95,4,94,72,29,77,118,78}, +{81,75,97,127,22,8,96,80,100,88,69,114,16}, +{25,109,74,3,126,56,99,15,69,73,76,19,97}, +{59,84,102,53,30,34,33,105,75,102,60,121,93}} diff --git a/ACE1/ass1/B.csv b/ACE1/ass1/B.csv new file mode 100755 index 0000000..4cd51b3 --- /dev/null +++ b/ACE1/ass1/B.csv @@ -0,0 +1,13 @@ +{{102,61,111,79,99,3,25,50,33,48,5,94,28}, +{106,89,35,37,112,51,13,70,3,110,31,7,99}, +{65,115,94,68,95,114,34,34,64,1,11,66,126}, +{114,37,42,3,88,35,124,50,74,95,25,34,24}, +{25,111,4,116,54,90,11,32,121,20,26,62,60}, +{45,41,20,33,89,75,89,2,28,19,96,46,119}, +{39,68,87,59,33,82,94,14,115,0,0,92,85}, +{58,62,122,106,93,39,86,80,75,23,57,89,7}, +{119,75,20,42,1,120,83,24,62,78,20,25,126}, +{121,42,78,45,8,17,52,38,44,13,104,57,62}, +{29,96,0,64,47,50,22,17,88,63,108,78,101}, +{70,108,69,12,0,80,115,107,71,54,5,57,3}, +{123,72,56,5,30,45,2,11,124,84,63,47,104}} diff --git a/ACE1/ass1/B.csv~ b/ACE1/ass1/B.csv~ new file mode 100755 index 0000000..bc2074e --- /dev/null +++ b/ACE1/ass1/B.csv~ @@ -0,0 +1,13 @@ +102,61,111,79,99,3,25,50,33,48,5,94,28 +106,89,35,37,112,51,13,70,3,110,31,7,99 +65,115,94,68,95,114,34,34,64,1,11,66,126 +114,37,42,3,88,35,124,50,74,95,25,34,24 +25,111,4,116,54,90,11,32,121,20,26,62,60 +45,41,20,33,89,75,89,2,28,19,96,46,119 +39,68,87,59,33,82,94,14,115,0,0,92,85 +58,62,122,106,93,39,86,80,75,23,57,89,7 +119,75,20,42,1,120,83,24,62,78,20,25,126 +121,42,78,45,8,17,52,38,44,13,104,57,62 +29,96,0,64,47,50,22,17,88,63,108,78,101 +70,108,69,12,0,80,115,107,71,54,5,57,3 +123,72,56,5,30,45,2,11,124,84,63,47,104 diff --git a/ACE1/ass1/C.txt b/ACE1/ass1/C.txt new file mode 100755 index 0000000..3632602 --- /dev/null +++ b/ACE1/ass1/C.txt @@ -0,0 +1,13 @@ +{{0,0,0,0,0,0,0,0,0,0,0,0,0}, +{0,0,0,0,0,0,0,0,0,0,0,0,0}, +{0,0,0,0,0,0,0,0,0,0,0,0,0}, +{0,0,0,0,0,0,0,0,0,0,0,0,0}, +{0,0,0,0,0,0,0,0,0,0,0,0,0}, +{0,0,0,0,0,0,0,0,0,0,0,0,0}, +{0,0,0,0,0,0,0,0,0,0,0,0,0}, +{0,0,0,0,0,0,0,0,0,0,0,0,0}, +{0,0,0,0,0,0,0,0,0,0,0,0,0}, +{0,0,0,0,0,0,0,0,0,0,0,0,0}, +{0,0,0,0,0,0,0,0,0,0,0,0,0}, +{0,0,0,0,0,0,0,0,0,0,0,0,0}, +{0,0,0,0,0,0,0,0,0,0,0,0,0}} diff --git a/ACE1/ass1/Matrix.xlsx b/ACE1/ass1/Matrix.xlsx new file mode 100755 index 0000000..c048cb9 Binary files /dev/null and b/ACE1/ass1/Matrix.xlsx differ diff --git a/ACE1/ass1/code/.vscode/arduino.json b/ACE1/ass1/code/.vscode/arduino.json new file mode 100755 index 0000000..4bbb32d --- /dev/null +++ b/ACE1/ass1/code/.vscode/arduino.json @@ -0,0 +1,6 @@ +{ + "programmer": "AVRISP mkII", + "board": "arduino:avr:uno", + "port": "/dev/ttyACM1", + "sketch": "code.ino" +} \ No newline at end of file diff --git a/ACE1/ass1/code/.vscode/c_cpp_properties.json b/ACE1/ass1/code/.vscode/c_cpp_properties.json new file mode 100755 index 0000000..e04683f --- /dev/null +++ b/ACE1/ass1/code/.vscode/c_cpp_properties.json @@ -0,0 +1,16 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "/home/wouter/.arduino15/packages/arduino/tools/**", + "/home/wouter/.arduino15/packages/arduino/hardware/avr/1.8.1/**" + ], + "forcedInclude": [ + "/home/wouter/.arduino15/packages/arduino/hardware/avr/1.8.1/cores/arduino/Arduino.h" + ], + "intelliSenseMode": "gcc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/ACE1/ass1/code/code.ino b/ACE1/ass1/code/code.ino new file mode 100755 index 0000000..9c30b67 --- /dev/null +++ b/ACE1/ass1/code/code.ino @@ -0,0 +1,174 @@ +uint8_t A[13][13] = {{28, 122, 80, 42, 54, 122, 98, 42, 99, 58, 124, 29, 21}, + {113, 85, 30, 35, 41, 98, 103, 68, 15, 50, 31, 80, 54}, + {47, 37, 23, 96, 59, 47, 84, 26, 84, 72, 51, 118, 119}, + {38, 121, 45, 21, 87, 91, 20, 69, 98, 119, 15, 89, 47}, + {40, 71, 105, 76, 31, 65, 109, 30, 127, 110, 17, 64, 64}, + {45, 20, 113, 86, 86, 51, 104, 115, 61, 103, 60, 113, 44}, + {101, 107, 33, 63, 39, 47, 120, 20, 41, 64, 102, 59, 86}, + {9, 42, 118, 26, 83, 123, 10, 82, 47, 108, 127, 4, 66}, + {75, 26, 117, 80, 47, 111, 38, 22, 98, 101, 92, 100, 48}, + {90, 9, 71, 36, 90, 95, 4, 94, 72, 29, 77, 118, 78}, + {81, 75, 97, 127, 22, 8, 96, 80, 100, 88, 69, 114, 16}, + {25, 109, 74, 3, 126, 56, 99, 15, 69, 73, 76, 19, 97}, + {59, 84, 102, 53, 30, 34, 33, 105, 75, 102, 60, 121, 93}}; + +uint8_t B[13][13] = {{102, 61, 111, 79, 99, 3, 25, 50, 33, 48, 5, 94, 28}, + {106, 89, 35, 37, 112, 51, 13, 70, 3, 110, 31, 7, 99}, + {65, 115, 94, 68, 95, 114, 34, 34, 64, 1, 11, 66, 126}, + {114, 37, 42, 3, 88, 35, 124, 50, 74, 95, 25, 34, 24}, + {25, 111, 4, 116, 54, 90, 11, 32, 121, 20, 26, 62, 60}, + {45, 41, 20, 33, 89, 75, 89, 2, 28, 19, 96, 46, 119}, + {39, 68, 87, 59, 33, 82, 94, 14, 115, 0, 0, 92, 85}, + {58, 62, 122, 106, 93, 39, 86, 80, 75, 23, 57, 89, 7}, + {119, 75, 20, 42, 1, 120, 83, 24, 62, 78, 20, 25, 126}, + {121, 42, 78, 45, 8, 17, 52, 38, 44, 13, 104, 57, 62}, + {29, 96, 0, 64, 47, 50, 22, 17, 88, 63, 108, 78, 101}, + {70, 108, 69, 12, 0, 80, 115, 107, 71, 54, 5, 57, 3}, + {123, 72, 56, 5, 30, 45, 2, 11, 124, 84, 63, 47, 104}}; +uint32_t C[13][13] ={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; + +#define LOADCOLUMN \ +"ld r13,Y+;\n"\ +"out 0x0A,r28; write to IOregister \n"\ +"out 0x0B,r29; write to IOregister \n"\ +"ldd r14,Y+(12);\n"\ +"ldd r15,Y+25;\n"\ +"ldd r16,Y+38;\n"\ +"adiw Y,(51);\n"\ +"ld r17, Y;\n"\ +"ldd r18,Y+13;\n"\ +"ldd r19,Y+26;\n"\ +"ldd r20,Y+39;\n"\ +"adiw Y,52;\n"\ +"ld r21,Y;\n"\ +"ldd r22,Y+13;\n"\ +"ldd r23,Y+26;\n"\ +"ldd r24,Y+39;\n"\ +"ldd r25,Y+52;\n"\ +"in r28,0x0A; read from IOregister \n"\ +"in r29,0x0B; read from IOregister \n" + +#define MULROW \ +"ld r12,X+; eerste\n"\ +"mul r13,r12;\n"\ +"movw r2,r0; copy naar sum1\n"\ +"ld r12,X+; tweede\n"\ +"mul r14,r12;\n"\ +"add r2,r0;\n"\ +"adc r3,r1;\n"\ +"ld r12,X+; drie\n"\ +"mul r15,r12; \n"\ +"add r2,r0;\n"\ +"adc r3,r1;\n"\ +"ld r12,X+; vier\n"\ +"mul r16,r12;\n"\ +"add r2,r0;\n"\ +"adc r3,r1;\n"\ +"ld r12,X+; vijf\n"\ +"mul r17,r12;\n"\ +"movw r4,r0; copy naar sum2\n"\ +"ld r12,X+; zes\n"\ +"mul r18,r12;\n"\ +"add r4,r0;\n"\ +"adc r5,r1;\n"\ +"ld r12,X+; load 7\n"\ +"mul r19,r12;\n"\ +"add r4,r0;\n"\ +"adc r5,r1;\n"\ +"ld r12,X+; load 8\n"\ +"mul r20,r12;\n"\ +"add r2,r0;\n"\ +"adc r3,r1;\n"\ +"ld r12,X+; load9\n"\ +"mul r21,r12; \n"\ +"movw r6,r0; copy naar sum3\n"\ +"ld r12,X+; load 10\n"\ +"mul r22,r12;\n"\ +"add r6,r0;\n"\ +"adc r7,r1;\n"\ +"ld r12,X+;load 11\n"\ +"mul r23,r12; \n"\ +"add r6,r0;\n"\ +"adc r7,r1;\n"\ +"ld r12,X+; load 12\n"\ +"mul r24,r12;\n"\ +"add r6,r0;\n"\ +"adc r7,r1;\n"\ +"ld r12,X+; load 13\n"\ +"mul r25,r12;\n"\ +"movw r8,r0; copy naar sum4\n" + +#define SUBSUM \ +"add r2,r4;\n"\ +"adc r3,r5;\n"\ +"clr r4;\n"\ +"clr r5;\n"\ +"adc r4,r4;\n"\ +"add r2,r6;\n"\ +"adc r3,r7;\n"\ +"adc r4,r5;\n"\ +"add r2,r8;\n"\ +"adc r3,r9;\n"\ +"adc r4,r5;\n" + + +#define DOROW \ +LOADCOLUMN \ +MULROW \ +SUBSUM + +void print_mat(uint32_t mat[13][13]) { + int i, j; + for (i = 0; i < 13; i++) + { + for (j = 0; j < 13; j++) + { + Serial.print(mat[i][j]); + Serial.print(" "); + } + Serial.println(""); + } +} + + + +void setup() { + Serial.begin(115200); + uint8_t *B_ptr = &B[0][0]; + uint8_t out = 0; + //print_mat(C); + // Serial.println(B_ptr); + asm volatile( //"ld r2,Y+;\n" + //"ld r1,Y+;\n" + //"mov %0,r4;\n" + DOROW + "st Z, r2;\n" + "std Z+1,r3;\n" + "std Z+2,r4;\n" + : + : "z"(&(C[0][0])),"y" (&(B[0][0])), "x"(&(A[0][0])) + : "memory","r0","r1","r2","r3","r4","r5","r6","r7","r8","r9","r11","r12","r13","r14","r15","r16","r17","r18","r19","r20","r21","r22","r23","r24","r25"); + + Serial.println(out); + Serial.println("test\n"); + Serial.println(out); + Serial.println("dit werkt:\n"); + print_mat(C); + Serial.println("\n\n"); + Serial.println(out,HEX); + Serial.println(out,DEC); +} + +void loop() {} diff --git a/ACE1/ass1/matrixequation.m b/ACE1/ass1/matrixequation.m new file mode 100755 index 0000000..b77298e --- /dev/null +++ b/ACE1/ass1/matrixequation.m @@ -0,0 +1 @@ +sum(sum((A*B)+(2*A+3*B)-answer)) diff --git a/ACE1/ass1/solution.txt b/ACE1/ass1/solution.txt new file mode 100755 index 0000000..53fd28b --- /dev/null +++ b/ACE1/ass1/solution.txt @@ -0,0 +1,13 @@ +66244,70420,43142,48294,56072,63164,52099,31720,58450,43076,44497,50341,81323 +61392,58158,52098,41767,51206,44836,48073,35047,51417,35434,31560,49887,53934 +72902,64108,46792,35480,39019,53832,55222,35468,66661,45356,34461,48256,60181 +71998,65202,46122,43976,46914,55191,48920,39173,51798,41643,39359,43629,64011 +78209,66796,53896,41467,46371,62504,58243,34613,61540,41119,34492,49122,73968 +74039,76737,64172,55106,53772,65043,66339,44511,74839,37915,40082,63182,65908 +70509,66003,49706,42217,50875,49420,46916,33925,61377,45763,36835,52391,66348 +59694,64546,42257,49046,51783,54723,41040,27253,58315,32639,52426,49676,73417 +76021,71977,51711,45047,50976,63037,59302,36664,62826,42353,43768,54762,74417 +63693,68287,49155,47424,48487,55476,50218,37915,62107,38433,37970,53375,58379 +81035,73450,62248,47581,54030,60095,66698,46914,65116,47888,33516,57153,63321 +62426,68906,39911,46746,45814,57976,36013,27449,63340,38079,37453,46595,74875 +80654,74061,61169,46161,51754,57797,55117,45747,63964,46628,40736,54493,65845 diff --git a/ACE1/ass1/test b/ACE1/ass1/test new file mode 100755 index 0000000..e69de29 diff --git a/ACE1/registersheet.ods b/ACE1/registersheet.ods new file mode 100755 index 0000000..37d995f Binary files /dev/null and b/ACE1/registersheet.ods differ