From 40373170ac269f6d699a7a5f8d32a1bb2a9d350b Mon Sep 17 00:00:00 2001 From: mpabi Date: Fri, 24 May 2024 10:20:44 +0000 Subject: [PATCH 01/10] :( --- cpp/_rvmain.cpp | 81 ++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/cpp/_rvmain.cpp b/cpp/_rvmain.cpp index ebf205d..e1c570a 100644 --- a/cpp/_rvmain.cpp +++ b/cpp/_rvmain.cpp @@ -7,7 +7,6 @@ int strlen(char *s) { return p - s; } - void strcpy(char *s, char *t) { while (*s++ = *t++); @@ -38,7 +37,7 @@ char *alloc(int n) #define LEN (8+2)*10 struct model { - char * str; + char * ptr; uint32_t len ; }; @@ -73,7 +72,6 @@ char *simple_strtok(char *str, const char *delims) { // " .,mpabi" // ^ - // Pomiń początkowe delimitery while (*static_str && is_delim(*static_str, delims)) { static_str++; @@ -87,6 +85,8 @@ char *simple_strtok(char *str, const char *delims) { // Zapisz początek tokenu char *token_start = static_str; + + //,. mpabi pabi // Znajdź koniec tokenu while (*static_str && !is_delim(*static_str, delims)) { static_str++; @@ -102,62 +102,61 @@ char *simple_strtok(char *str, const char *delims) { return token_start; } -char buf[100]; + +char buf[1000]; struct model * p = (struct model *) buf; //p[1] + // + + ////func alg //in: ptr to date //return: count of words -int alg (const char * ptr) { - - char bufer[ALLOCSIZE]; - strcpy(bufer, (char *)ptr); +int alg (char * ptr) { const char *delims = " ,.!?:;\n\t"; - int8_t count = 0; + int pos = 0; - char *token = simple_strtok(bufer, delims); + while (char *token = simple_strtok(ptr, delims)) { - while (token != (char *)NULL) { + if (token == (char *)NULL) + break; - p[count].str = token; - p[count].len = strlen(token); - - token = simple_strtok((char *)NULL, delims); - count++; - } + p[pos].ptr = token; + //p[pos].len = strlen(token); + p[pos].len = pos; + ++pos; + } - return count; + return pos; } +/* +struct model { + char * str; + uint32_t len ; +} tab [10] ; +*/ + int main() { +// Seccess is often +// ^ + char *str = " Success is often defined as the ability to reach your goals in life, whatever those goals may be. In some ways, a better word for success might be attainment, accomplishment, or progress. It is not necessarily a destination but a journey that helps develop the skills and resources you need to thrive."; - char *str = "If wantered relation no surprise of all"; +/* + struct model *ptr = (struct model *) alloc(LEN); + if (ptr != (struct model *)NULL) { + ptr->str = alloc(strlen((char *)str) + 1); + if (ptr->str != (char *)NULL) { + strcpy (ptr->str, (char *)str); + ptr->len = strlen(ptr->str); + int8_t count = alg(ptr->str); + } + } + */ alg(str); asm ("nop"); return 1; } - -// wynik tego kodu: -// p[0].str = If -// p[0].len = 2 - -// p[1].str = wantered -// p[1].len = 8 - -// p[2].str = relation -// p[2].len = 8 - -// p[3].str = no -// p[3].len = 2 - -// p[4].str = surprise -// p[4].len = 8 - -// p[5].str = of -// p[5].len = 2 - -// p[6].str = all -// p[6].len = 3 From bd1371a2145efaae63f860eed2ab276b49eb6a42 Mon Sep 17 00:00:00 2001 From: mpabi Date: Fri, 24 May 2024 10:26:04 +0000 Subject: [PATCH 02/10] ref --- cpp/_rvmain.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/cpp/_rvmain.cpp b/cpp/_rvmain.cpp index e1c570a..375bdbd 100644 --- a/cpp/_rvmain.cpp +++ b/cpp/_rvmain.cpp @@ -119,9 +119,6 @@ int alg (char * ptr) { while (char *token = simple_strtok(ptr, delims)) { - if (token == (char *)NULL) - break; - p[pos].ptr = token; //p[pos].len = strlen(token); p[pos].len = pos; From 809f1e4004d480e7cc1d05f4eeacc2b38fbe0782 Mon Sep 17 00:00:00 2001 From: mpabi Date: Fri, 24 May 2024 16:12:13 +0000 Subject: [PATCH 03/10] alg need be fixed !!! --- cpp/_rvmain.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cpp/_rvmain.cpp b/cpp/_rvmain.cpp index 375bdbd..20795b1 100644 --- a/cpp/_rvmain.cpp +++ b/cpp/_rvmain.cpp @@ -62,7 +62,7 @@ bool is_delim(char c, const char *delims) { // Najprostsza implementacja funkcji strtok char *simple_strtok(char *str, const char *delims) { - static char *static_str = (char *) NULL; // Przechowuje wskaźnik do bieżącej pozycji w ciągu + char *static_str = (char *) NULL; // Przechowuje wskaźnik do bieżącej pozycji w ciągu // Jeśli przekazano nowy ciąg, zaktualizuj static_str if (str == NULL) { @@ -117,7 +117,7 @@ int alg (char * ptr) { int pos = 0; - while (char *token = simple_strtok(ptr, delims)) { + while (char *token = simple_strtok(ptr+strlen(ptr), delims)) { p[pos].ptr = token; //p[pos].len = strlen(token); @@ -152,7 +152,7 @@ int main() { } } */ - alg(str); + int w = alg(str); asm ("nop"); return 1; From 8190fc9684cec488e53f19280141f0002a38758b Mon Sep 17 00:00:00 2001 From: mpabi Date: Sat, 25 May 2024 08:38:43 +0000 Subject: [PATCH 04/10] update --- cpp/_rvmain.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cpp/_rvmain.cpp b/cpp/_rvmain.cpp index 20795b1..bca60c5 100644 --- a/cpp/_rvmain.cpp +++ b/cpp/_rvmain.cpp @@ -117,11 +117,13 @@ int alg (char * ptr) { int pos = 0; - while (char *token = simple_strtok(ptr+strlen(ptr), delims)) { + while (char *token = simple_strtok(ptr, delims)) { p[pos].ptr = token; //p[pos].len = strlen(token); p[pos].len = pos; + + token = token + strlen(token) + 1; ++pos; } From f8380b5835824c2989ed0a02e1769cf207b027d3 Mon Sep 17 00:00:00 2001 From: borysr Date: Sat, 25 May 2024 17:54:58 +0200 Subject: [PATCH 05/10] =?UTF-8?q?funkcja=20alg=20dzia=C5=82a=20poprawnie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cpp/._rvmain.cpp.swl | Bin 12288 -> 0 bytes cpp/._rvmain.cpp.swm | Bin 12288 -> 0 bytes cpp/._rvmain.cpp.swo | Bin 12288 -> 0 bytes cpp/{._rvmain.cpp.swn => ._rvmain.cpp.swp} | Bin 12288 -> 12288 bytes cpp/Make.rules-kopia | 81 --- cpp/Murax.scala | 543 --------------------- cpp/_crt0.S-k0 | 42 -- cpp/_crt0.S-k1 | 39 -- cpp/_rvmain.cpp | 90 +--- cpp/murax_128k_ram-sp.ld | 43 -- cpp/murax_128k_ram.ld | 67 --- cpp/murax_128k_ram.ld-kopia | 13 - 12 files changed, 24 insertions(+), 894 deletions(-) delete mode 100644 cpp/._rvmain.cpp.swl delete mode 100644 cpp/._rvmain.cpp.swm delete mode 100644 cpp/._rvmain.cpp.swo rename cpp/{._rvmain.cpp.swn => ._rvmain.cpp.swp} (74%) delete mode 100644 cpp/Make.rules-kopia delete mode 100644 cpp/Murax.scala delete mode 100644 cpp/_crt0.S-k0 delete mode 100644 cpp/_crt0.S-k1 delete mode 100644 cpp/murax_128k_ram-sp.ld delete mode 100644 cpp/murax_128k_ram.ld delete mode 100644 cpp/murax_128k_ram.ld-kopia diff --git a/cpp/._rvmain.cpp.swl b/cpp/._rvmain.cpp.swl deleted file mode 100644 index 1080c395311c7737c4867a39fcbc7f858bcef4c9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2U2Ggz8HP{zcYi2Qgs4Q(@dlc;*X(YbgrspDgrXD$Od1JVq{P9DXUFmE&dv-o zvsrd6LoXT?@l&p71u3W!2!R9=kPD)Ms6_3HqM}HF3UUS9Py|K2fZT9Xp6{HQ?An9` zDOZIV>se>coS*l+-#6zRE4$o$=;%lFz4fNzdW%w*+YhX?(?zxGR;7BWmq_uAuKlx~ zGu!m`+`D&q-}UN#Ryu6-qomVtO0@|;LUeg_E0)dI#4=LI#4=LI#4=LI#4=LI`FD-Ad7dX&!P4;x#F+pzjti=o!^$f zN(V{@N(V{@N(V{@N(V{@N(V{@N(V{@N(V{@UWE=gEv0_UAOG)uJ>vQQ|Kjiem+nyN zukZqFzz^UlcnrP-UxWyj;6rc(4nrN@0dI#p;mVtp`a4{P-@-HSb9fTgU||bfZt3oZ@2*G zVGS1H5FCL0@J{&0o0NJPF2UpQFbrV;Rd_30d81Olhs*FgxBySVH{l!bBzzf8!ErbM zcY}gg-oSj|m+%~X8@>f!fycmsPr-dK2Y12CP zSueS9#sA?N;=%g5x~UoFK8AYt9C^&;q+MODgi&0XnzIGL>1vuK+?iW<)k*X;1$tgr zj;`pw6J}oGwRGYIPUc6U4kMlRk~r~GPe&`-34#i3{V>z=O{nUWUeijgUme(udSOO| z35q7nO|51}7CBke@j`}5{caq1ON>iNwQ5yN9eZ$LVMe#S!0)CAoR}~YrJY>yNz>h_ zdSJWA68=#&J?3+>^~P%2d6_EteEX|@;Az`RPtNP{p_vN0t(I#GUGA-T$(TYlfe#0k zGOdj?Cf1axyHS{C+ID1TBkt;%`s4==&Mk(EnK(FsI5!?t^F9k9v5AdUVIH0Q;KITK zhd*}o#F10965pNRG`h#e(9#I;jfQ!P!h;xL1rad5zt&25M%fmbtVOzDZxX}30?)}1KyJ-4t$rlI6xEGw<07%*~UF|d3<`F7#PRomTO)K@h^?6KaZfPq@hk?I&t~=1J2-Ta9xQ=%HjkBkF7@LP#`Ze;+ z$MwQ{ZTJ3L^NvSdpE%}O)rtDvSe(t+6~O5sj7*b?x!7x)G-+~Y&lXiIXP+imNb=Wcq+#HyQgt7^l0snreV|{SUV+6|8quK zy?J_U5x+IKBJnugyQ@)O)QQZ^r$fIZ(Oc#%_}Ru;*K1?paNxFm-Opob-|^|K>$Ocr zrZU4avwf+PX))L_ryVCznx#WWo5jBCg_+~F9nEsnks)Z$D!XmbSaE{X+itpDL&sNw zQ9v|TvEU@Vyr~q5+pc&$ZJQT%7nwFHU5=taUrjYLIrlm9>fT@6dKQkTs{n%ECs_-#o{v*BYhdv*-I*q}0xqx8jGM$p&4mo{9X{^ptK+arAG9 zhsMCI_W5F;Th~K^wj9(ku_Yf#)S)(`_6VQf)B1Fr?Wymh6Is{s*jn0S``9xp`<2$R zi`r5fPAQXxmz3vYwC1mkbS@k@rmF{Pvs2T2DU&@Q@kFBQrD?<$uMy0A>iPCT>JQx2 zBDzJ0*dEO=>)IpEc4;e~ak7ZqSiet)bNPe3q&82HZ6`rBrR+Mormt>|w8|?VqB5c8 zOk!G$5+&61vzLn1P`_92&5sPyp}CjCK+`r{%ah*pSd|@@9y#Wl%_o1=^3mq)ux3-- zQlStzzI)S05%H05w$5fV-#B%Vn`y1a@-v;)YRFtuk{A*hIWFYy9yw-CZW+m9=hz>} z+bp|+oQqg#>MsT9alKtE3 zZr$xAaA_VTLL3)wYcZu*43;f>%EZMAkP`-t#9}MEn4Y|>YNsE%L9gZM`^a+Y)K?Fw Fe*yJzWu*WB diff --git a/cpp/._rvmain.cpp.swm b/cpp/._rvmain.cpp.swm deleted file mode 100644 index ee08e76f78961876ed0fed3da5cfdf4038170c34..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2zfTlF6vqcEe<4II)L0Bh47<1d*gfDP;*k(SL4vU$U=)QcdwXHw*xT&x0p|s+ zETr&nFn0bZv`|WkwT-d#M}x7^!a`%Bg??vljynj!f{OSy`LMTdXWqQ`ncd=Y%$O4+ zmv~>N#c(t;Hq@HTrB}b5Y(B_XF>*r@{?}od*`99Kae7U+cek;(M8dA6LO9>$1c78a zTwJg{zZ2KH&7^x|fDG*2K;w9K$}&Zs)fDDiUGVuQySYaGT z=*Gp+=T<+Hmm;JkgE$=1J4+cJ#bMs{xfWQup)Rx_rPmF%qXjMD7lH(WVzM~I^p1g2 z##~OB+oQ{fT6IyZP;_D*6g)rX$;w=w;o8=?&h31@;AoL|(=FsQIa=5Id9CP`+CriP zWV6!KF)!^LUap0=EL5%~+^I2)b%GLfq}oN3LWEdM9L}sA%KB5NUKK0lX>#C}T6axt z$<)?PsjVGSTNMq$p7@t(P3Ig7 zUXE)rI#bMXgAb05ULG17xi*YhYVZIC>%5HpkTcZsNau6p>A^tF=jV8j>PjS(*Ssae z&C0|wt0 zFRVvOabOtgQ#ErS+_YUc+jJ(IsH6+98s?Ol5QK&Bc2*Zc{>_IF&n5;Y<_k-9KAQKu iM1TD~@f;=QY~P(noV9wslP_jneld!(NZUC(!2SZ9@K1IC diff --git a/cpp/._rvmain.cpp.swo b/cpp/._rvmain.cpp.swo deleted file mode 100644 index afb7b4f5d5178c0e319ad1b35eda4e5ab73a16e9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2&u`mg7{}jo07mHwlt18U3agWBNt{w>6;d&+MHGg1n8tx_4A*g}6UR2TQ#Xyu zkk~Y7hm8p|Y2pBvapJ}#*mhipgtT2a@FyU|&vN6yf$wWORR~=Z6$xq5^GcuEexDzH z{Cyr*t&-)!8;h^gY_1@%o)F^4`Be36YwPJhzj|0SeZ!O6{nopFpy~B~UP8Pl6Xrw5 ztLJq!ue)xYZmnRX7>{Zp_9E5HiuMS*5eJv1|NVydV{ulhu4oW`Cyv6oC7!wRqh ztN<&(3a|pK04u->umTUL0)aau&Y<>(lKP)Zjzc}iumY?AE5Hh{0;~Wl zzzVPetN<(U04ktWgiwa@(f{Kp9-ser{{R1FREVF!H{f${4O|A7zy>hD5_ko?3>Ls7 zcoqzUec(~>2>5-!5Wj)zU=4)eB`^p68WG|runDe#E8t`B5jY3Vf)Bu3U>3}PNw9@_ ze*m9>3*c=~1{v@S7zbnENg$u?J3QmJ;1;+Ez5t(s%iu%sKB$3tkOJf2*T;mo0lo&8 zz(w#HcomF-KlY&x@IAN(?gCz{04u->umY?AE5Hi;zY1&!BF_k#qI2Teq?Yj4n8@d8 zIyWt=xvz<^cDMSW=AL!~kCX$AwS#n^(Mp$OW-LGKlX=%z%_T)<96ZP1o?Vsh<>>~v z(O_wJ_Uhg3yf?g~me^2V*8^sz|uklq#dQZG{rH z3h~wk8J2HQK10i%R;Pw()O=l|OkPlNHg=I?iHw?MIl4=S$Sz5Dd~?_{$c;T`V$Z}S zTZRwfUx;_jDk+g=xml$w9X@*W*pcIlZ!REJ5-^8=G__?~6maJg-6Y@Kyc*|z9tJF- zuV@}+q6o#b0~rDT_0ZE$Z|K*xJ2!2!P8El2TDP_O?JvV90nt*Zz2m^97EcyV34vsB zE^>=hj%y&r4?N4TNx@4}OsBh@)E%8vI0+#Ok>7z<(nRgJ6G)#ZCUur;7mcO4zrNDz zpW4cu|D8V!Z diff --git a/cpp/._rvmain.cpp.swn b/cpp/._rvmain.cpp.swp similarity index 74% rename from cpp/._rvmain.cpp.swn rename to cpp/._rvmain.cpp.swp index d0b40fbbb6019a04fa7498f224d80ed3cebe972b..788113abba50fcdda36d365405919176912ef935 100644 GIT binary patch literal 12288 zcmeI2&u>&!6vr=UR8*7zaicM(CBjUnPNyx3PzFK_nkEIJ4K8eJd3|%IbM2e=Uf#RY zrc@xtouC`zLKnuL3ynV#7XAe++_-Ro8-FAk6Mvx#O*AAB{hoX8bfy%m2^&f7OFo%- z=iPhmIp1^dc_qwD<%!Wlw7XmpxHbv#&W6Y9$CoC>#hZm_CR-Yz6DVrQ3!03H$)Q2WLS5j)4PU2j~F=F5ZS%!RO#S z_!uk!38ukQU_a;u_kg>>pSKF}2RIL20ndRG;29vnC>RFY!42T@2E+uu1K)ygz-QnM za2h-hTHp}a3r4_3@Z&8)dbHh7*~)tsn8oIX>W1F8lu@kt}}NRHiC@$a8Fh0rSVo6 z$~-5PQ&QJ5rkbp)Sk~Z$bVE`wqavjjNhg%aAZ*ZL(#mKy2_npiDN=RWPYaDe%Xyh$ zMv_bSv>7bYj4ab=OnK6jv=A)j{S?5aHHP9xY&EJU8Rag5rkZVNJf%Qu{GhEVV~ycq zm^9N!4a?IAI+n-+fl@<8 zX^uhjGD=dDWIm@NqjV&YUafe8W^B)sVPNmuqZ#I07YS4 zCDm1yYYKxX;)h`pBgdAs3#j8Np0%k2kQ%Gt-h{?6lu9Nt{>oQ6f!nEaWaH8qz7$ND zZi94<;Yg}>3A>dR8Y+@xhf`0Lx)XsSg6G=YuAVp?cJj5`l@&!mSf^swKx&+**``(+ zvs3%aJ^S~JOvaPil_9{kwxi&c7dNYO1S>89HCiF6mcSYHQ3`K-9J*{pY?C_6pH2); z3F8xniNQ*xGKGq+D6+{5bqq4Ss@Sk<6>^bz4I7)Ou}$m*$q2{8s>CsN#+OQV2wQPB zyWH%Utn9GQRGkW4&z3XpY_`tCwm(;|u4%M=JN2l1+9=!YZ@Dh*I$}3IqHrX5^GSRr zb@SB-V70axb}53iJ29-1#~qW^!d#IVRjb5lUqgofHNo*Ym7PH35hJ6zw+q8nZpLP?%3tt*=OxA`Y{Sx`nngJT$F21nz{^YE@tx z+N4HpR`dyUn6}@sgNLc`P-&>xhaZEYZ)B3+OZ*Z_@Pluh9IRhcRlLs-&4c>>rP!n${ zGow?BnBZq81{Pwvk9NAY&koH!_w|aMxa9VV@mSza4UYnJA?p z(HX`m#H$=kps_QSMP0x#%_g9t; z+Zn<6emiN743L3?8|Y=1vU*13NhbRFnbY?Uo{}<<0Wv@a$N(8217v^0i(=V-*LvS^q_eB z{y!mm_;r%8pWrii2i}60;01UJ>c9naU=}<81uzEszy)v~oC8NdH~4;nu@B%qcnw~G z=U@wXU=f(01hRmGW8iNuY608e2lxuUfH&Y7*aRD328@CMkOV#85BmBBK7o(m38;a2 za2wnLQ{X1J3Pyo&kq0!$02v?yWPl8i0Wv@a$N(9L4XiVc;ag$Nceq{wVjZs;=R1cmECcb8`Y|7DuMmj zaw|%-T2%|YRmXbkLZS?0)AREouXhfwwZgkD)MzE_)EL&9UY#pmc1SdtZR^=wF#M?g zEUK5qhJMv@lxX3uTK7$@N2&Ersr3%2^;mR zi%RwQFn3@xnvfB#h)^7{D_n`9rCNn+{QC6t-5WDgvy<2*7ms7H${X^2q|(toSpO$O|EV{4IJt!~>RCa#xLN iuw*9+?Nj0bNh}%;qAY1UX0=wf__ZJ`Bj?D%IQs_$gEi&= diff --git a/cpp/Make.rules-kopia b/cpp/Make.rules-kopia deleted file mode 100644 index 2bd12e9..0000000 --- a/cpp/Make.rules-kopia +++ /dev/null @@ -1,81 +0,0 @@ - -ARCH=riscv64-unknown-elf -GNU_DIR=$(HOME)/riscv/riscv/ -GNU_BIN=$(GNU_DIR)/bin - - -CC=$(GNU_BIN)/$(ARCH)-gcc -CXX=$(GNU_BIN)/$(ARCH)-g++ -AS=$(GNU_BIN)/$(ARCH)-as -LD=$(GNU_BIN)/$(ARCH)-ld -OBJCOPY=$(GNU_BIN)/$(ARCH)-objcopy -OBJDUMP=$(GNU_BIN)/$(ARCH)-objdump -SIZE=$(GNU_BIN)/$(ARCH)-size -AR=$(GNU_BIN)/$(ARCH)-ar -RANLIB=$(GNU_BIN)/$(ARCH)-ranlib - - -CFLAGS+=-ffreestanding -CFLAGS+=-fno-pic -CFLAGS+=-march=rv32i -mabi=ilp32 -CFLAGS+= -g - - -LDFLAGS+=-nostdlib -LDFLAGS+=-Wl,-Ttext=0x00000000 - -# see: https://github.com/riscv/riscv-gcc/issues/120 -#LDFLAGS+=-Wl,--no-relax - - - -ASFLAGS+=$(CFLAGS) -CXXFLAGS+=$(CFLAGS) - -CLEAN_DIRS=$(SUBDIRS:%=clean-%) -ALL_DIRS=$(SUBDIRS:%=all-%) - -OBJDUMPFLAGS+=-Mnumeric,no-aliases - -.PHONY: all clean world $(CLEAN_DIRS) $(ALL_DIRS) - - -%.bin : % - $(OBJCOPY) $< -O binary $@ - -%.lst : % - $(OBJDUMP) $(OBJDUMPFLAGS) -dr --disassemble-all $< > $<.lst - -% : %.o - $(LINK.cc) $(LDFLAGS) -o $@ $^ $(LDLIBS) - $(SIZE) -x -A $@ - -%.s: %.c - $(COMPILE.c) -S -o $@ $< - -%.s: %.cc - $(COMPILE.cc) -S -o $@ $< - -%.o: %.c - $(COMPILE.c) -o $@ $< - -%.o: %.cc - $(COMPILE.cc) -o $@ $< - -%.srec: % - $(OBJCOPY) $< -O srec $@ - - - - -all:: $(ALL_DIRS) - -clean:: $(CLEAN_DIRS) - -$(ALL_DIRS):: - $(MAKE) -C $(@:all-%=%) all - -$(CLEAN_DIRS):: - $(MAKE) -C $(@:clean-%=%) clean - -world:: clean all diff --git a/cpp/Murax.scala b/cpp/Murax.scala deleted file mode 100644 index 2260833..0000000 --- a/cpp/Murax.scala +++ /dev/null @@ -1,543 +0,0 @@ -package vexriscv.demo - -import spinal.core._ -import spinal.lib._ -import spinal.lib.bus.amba3.apb._ -import spinal.lib.bus.misc.SizeMapping -import spinal.lib.bus.simple.PipelinedMemoryBus -import spinal.lib.com.jtag.Jtag -import spinal.lib.com.spi.ddr.SpiXdrMaster -import spinal.lib.com.uart._ -import spinal.lib.io.{InOutWrapper, TriStateArray} -import spinal.lib.misc.{InterruptCtrl, Prescaler, Timer} -import spinal.lib.soc.pinsec.{PinsecTimerCtrl, PinsecTimerCtrlExternal} -import vexriscv.plugin._ -import vexriscv.{VexRiscv, VexRiscvConfig, plugin} -import spinal.lib.com.spi.ddr._ -import spinal.lib.bus.simple._ -import scala.collection.mutable.ArrayBuffer -import scala.collection.Seq - -/** - * Created by PIC32F_USER on 28/07/2017. - * - * Murax is a very light SoC which could work without any external component. - * - ICE40-hx8k + icestorm => 53 Mhz, 2142 LC - * - 0.37 DMIPS/Mhz - * - 8 kB of on-chip ram - * - JTAG debugger (eclipse/GDB/openocd ready) - * - Interrupt support - * - APB bus for peripherals - * - 32 GPIO pin - * - one 16 bits prescaler, two 16 bits timers - * - one UART with tx/rx fifo - */ - - -case class MuraxConfig(coreFrequency : HertzNumber, - onChipRamSize : BigInt, - onChipRamHexFile : String, - pipelineDBus : Boolean, - pipelineMainBus : Boolean, - pipelineApbBridge : Boolean, - gpioWidth : Int, - uartCtrlConfig : UartCtrlMemoryMappedConfig, - xipConfig : SpiXdrMasterCtrl.MemoryMappingParameters, - hardwareBreakpointCount : Int, - cpuPlugins : ArrayBuffer[Plugin[VexRiscv]]){ - require(pipelineApbBridge || pipelineMainBus, "At least pipelineMainBus or pipelineApbBridge should be enable to avoid wipe transactions") - val genXip = xipConfig != null - -} - - - -object MuraxConfig{ - def default : MuraxConfig = default(false, false) - def default(withXip : Boolean = false, bigEndian : Boolean = false) = MuraxConfig( - coreFrequency = 12 MHz, - onChipRamSize = 128 kB, - onChipRamHexFile = null, - pipelineDBus = true, - pipelineMainBus = false, - pipelineApbBridge = true, - gpioWidth = 32, - xipConfig = ifGen(withXip) (SpiXdrMasterCtrl.MemoryMappingParameters( - SpiXdrMasterCtrl.Parameters(8, 12, SpiXdrParameter(2, 2, 1)).addFullDuplex(0,1,false), - cmdFifoDepth = 32, - rspFifoDepth = 32, - xip = SpiXdrMasterCtrl.XipBusParameters(addressWidth = 24, lengthWidth = 2) - )), - hardwareBreakpointCount = if(withXip) 3 else 0, - cpuPlugins = ArrayBuffer( //DebugPlugin added by the toplevel - new IBusSimplePlugin( - resetVector = if(withXip) 0xF001E000l else 0x00000000l, - cmdForkOnSecondStage = true, - cmdForkPersistence = withXip, //Required by the Xip controller - prediction = NONE, - catchAccessFault = false, - compressedGen = false, - bigEndian = bigEndian - ), - new DBusSimplePlugin( - catchAddressMisaligned = false, - catchAccessFault = false, - earlyInjection = false, - bigEndian = bigEndian - ), - new CsrPlugin(CsrPluginConfig.smallest(mtvecInit = if(withXip) 0xE0040020l else 0x00000020l)), - new DecoderSimplePlugin( - catchIllegalInstruction = false - ), - new RegFilePlugin( - regFileReadyKind = plugin.SYNC, - zeroBoot = false - ), - new IntAluPlugin, - new SrcPlugin( - separatedAddSub = false, - executeInsertion = false - ), - new LightShifterPlugin, - new HazardSimplePlugin( - bypassExecute = false, - bypassMemory = false, - bypassWriteBack = false, - bypassWriteBackBuffer = false, - pessimisticUseSrc = false, - pessimisticWriteRegFile = false, - pessimisticAddressMatch = false - ), - new BranchPlugin( - earlyBranch = false, - catchAddressMisaligned = false - ), - new YamlPlugin("cpu0.yaml") - ), - uartCtrlConfig = UartCtrlMemoryMappedConfig( - uartCtrlConfig = UartCtrlGenerics( - dataWidthMax = 8, - clockDividerWidth = 20, - preSamplingSize = 1, - samplingSize = 3, - postSamplingSize = 1 - ), - initConfig = UartCtrlInitConfig( - baudrate = 115200, - dataLength = 7, //7 => 8 bits - parity = UartParityType.NONE, - stop = UartStopType.ONE - ), - busCanWriteClockDividerConfig = false, - busCanWriteFrameConfig = false, - txFifoDepth = 16, - rxFifoDepth = 16 - ) - - ) - - def fast = { - val config = default - - //Replace HazardSimplePlugin to get datapath bypass - config.cpuPlugins(config.cpuPlugins.indexWhere(_.isInstanceOf[HazardSimplePlugin])) = new HazardSimplePlugin( - bypassExecute = true, - bypassMemory = true, - bypassWriteBack = true, - bypassWriteBackBuffer = true - ) -// config.cpuPlugins(config.cpuPlugins.indexWhere(_.isInstanceOf[LightShifterPlugin])) = new FullBarrelShifterPlugin() - - config - } -} - - -case class Murax(config : MuraxConfig) extends Component{ - import config._ - - val io = new Bundle { - //Clocks / reset - val asyncReset = in Bool() - val mainClk = in Bool() - - //Main components IO - val jtag = slave(Jtag()) - - //Peripherals IO - val gpioA = master(TriStateArray(gpioWidth bits)) - val uart = master(Uart()) - - val xip = ifGen(genXip)(master(SpiXdrMaster(xipConfig.ctrl.spi))) - } - - - val resetCtrlClockDomain = ClockDomain( - clock = io.mainClk, - config = ClockDomainConfig( - resetKind = BOOT - ) - ) - - val resetCtrl = new ClockingArea(resetCtrlClockDomain) { - val mainClkResetUnbuffered = False - - //Implement an counter to keep the reset axiResetOrder high 64 cycles - // Also this counter will automatically do a reset when the system boot. - val systemClkResetCounter = Reg(UInt(6 bits)) init(0) - when(systemClkResetCounter =/= U(systemClkResetCounter.range -> true)){ - systemClkResetCounter := systemClkResetCounter + 1 - mainClkResetUnbuffered := True - } - when(BufferCC(io.asyncReset)){ - systemClkResetCounter := 0 - } - - //Create all reset used later in the design - val mainClkReset = RegNext(mainClkResetUnbuffered) - val systemReset = RegNext(mainClkResetUnbuffered) - } - - - val systemClockDomain = ClockDomain( - clock = io.mainClk, - reset = resetCtrl.systemReset, - frequency = FixedFrequency(coreFrequency) - ) - - val debugClockDomain = ClockDomain( - clock = io.mainClk, - reset = resetCtrl.mainClkReset, - frequency = FixedFrequency(coreFrequency) - ) - - val system = new ClockingArea(systemClockDomain) { - val pipelinedMemoryBusConfig = PipelinedMemoryBusConfig( - addressWidth = 32, - dataWidth = 32 - ) - - val bigEndianDBus = config.cpuPlugins.exists(_ match{ case plugin : DBusSimplePlugin => plugin.bigEndian case _ => false}) - - //Arbiter of the cpu dBus/iBus to drive the mainBus - //Priority to dBus, !! cmd transactions can change on the fly !! - val mainBusArbiter = new MuraxMasterArbiter(pipelinedMemoryBusConfig, bigEndianDBus) - - //Instanciate the CPU - val cpu = new VexRiscv( - config = VexRiscvConfig( - plugins = cpuPlugins += new DebugPlugin(debugClockDomain, hardwareBreakpointCount) - ) - ) - - //Checkout plugins used to instanciate the CPU to connect them to the SoC - val timerInterrupt = False - val externalInterrupt = False - for(plugin <- cpu.plugins) plugin match{ - case plugin : IBusSimplePlugin => - mainBusArbiter.io.iBus.cmd <> plugin.iBus.cmd - mainBusArbiter.io.iBus.rsp <> plugin.iBus.rsp - case plugin : DBusSimplePlugin => { - if(!pipelineDBus) - mainBusArbiter.io.dBus <> plugin.dBus - else { - mainBusArbiter.io.dBus.cmd << plugin.dBus.cmd.halfPipe() - mainBusArbiter.io.dBus.rsp <> plugin.dBus.rsp - } - } - case plugin : CsrPlugin => { - plugin.externalInterrupt := externalInterrupt - plugin.timerInterrupt := timerInterrupt - } - case plugin : DebugPlugin => plugin.debugClockDomain{ - resetCtrl.systemReset setWhen(RegNext(plugin.io.resetOut)) - io.jtag <> plugin.io.bus.fromJtag() - } - case _ => - } - - - - //****** MainBus slaves ******** - val mainBusMapping = ArrayBuffer[(PipelinedMemoryBus,SizeMapping)]() - val ram = new MuraxPipelinedMemoryBusRam( - onChipRamSize = onChipRamSize, - onChipRamHexFile = onChipRamHexFile, - pipelinedMemoryBusConfig = pipelinedMemoryBusConfig, - bigEndian = bigEndianDBus - ) - mainBusMapping += ram.io.bus -> (0x00000000l, onChipRamSize) - - val apbBridge = new PipelinedMemoryBusToApbBridge( - apb3Config = Apb3Config( - addressWidth = 20, - dataWidth = 32 - ), - pipelineBridge = pipelineApbBridge, - pipelinedMemoryBusConfig = pipelinedMemoryBusConfig - ) - mainBusMapping += apbBridge.io.pipelinedMemoryBus -> (0xF0000000l, 1 MB) - - - - //******** APB peripherals ********* - val apbMapping = ArrayBuffer[(Apb3, SizeMapping)]() - val gpioACtrl = Apb3Gpio(gpioWidth = gpioWidth, withReadSync = true) - io.gpioA <> gpioACtrl.io.gpio - apbMapping += gpioACtrl.io.apb -> (0x00000, 4 kB) - - val uartCtrl = Apb3UartCtrl(uartCtrlConfig) - uartCtrl.io.uart <> io.uart - externalInterrupt setWhen(uartCtrl.io.interrupt) - apbMapping += uartCtrl.io.apb -> (0x10000, 4 kB) - - val timer = new MuraxApb3Timer() - timerInterrupt setWhen(timer.io.interrupt) - apbMapping += timer.io.apb -> (0x20000, 4 kB) - - val xip = ifGen(genXip)(new Area{ - val ctrl = Apb3SpiXdrMasterCtrl(xipConfig) - ctrl.io.spi <> io.xip - externalInterrupt setWhen(ctrl.io.interrupt) - apbMapping += ctrl.io.apb -> (0x1F000, 4 kB) - - val accessBus = new PipelinedMemoryBus(PipelinedMemoryBusConfig(24,32)) - mainBusMapping += accessBus -> (0xE0000000l, 16 MB) - - ctrl.io.xip.fromPipelinedMemoryBus() << accessBus - val bootloader = Apb3Rom("src/main/c/murax/xipBootloader/crt.bin") - apbMapping += bootloader.io.apb -> (0x1E000, 4 kB) - }) - - - - //******** Memory mappings ********* - val apbDecoder = Apb3Decoder( - master = apbBridge.io.apb, - slaves = apbMapping.toSeq - ) - - val mainBusDecoder = new Area { - val logic = new MuraxPipelinedMemoryBusDecoder( - master = mainBusArbiter.io.masterBus, - specification = mainBusMapping.toSeq, - pipelineMaster = pipelineMainBus - ) - } - } -} - - - -object Murax{ - def main(args: Array[String]) { - SpinalVerilog(Murax(MuraxConfig.default)) - } -} - -object MuraxCfu{ - def main(args: Array[String]) { - SpinalVerilog{ - val config = MuraxConfig.default - config.cpuPlugins += new CfuPlugin( - stageCount = 1, - allowZeroLatency = true, - encodings = List( - CfuPluginEncoding ( - instruction = M"-------------------------0001011", - functionId = List(14 downto 12), - input2Kind = CfuPlugin.Input2Kind.RS - ) - ), - busParameter = CfuBusParameter( - CFU_VERSION = 0, - CFU_INTERFACE_ID_W = 0, - CFU_FUNCTION_ID_W = 3, - CFU_REORDER_ID_W = 0, - CFU_REQ_RESP_ID_W = 0, - CFU_INPUTS = 2, - CFU_INPUT_DATA_W = 32, - CFU_OUTPUTS = 1, - CFU_OUTPUT_DATA_W = 32, - CFU_FLOW_REQ_READY_ALWAYS = false, - CFU_FLOW_RESP_READY_ALWAYS = false, - CFU_WITH_STATUS = true, - CFU_RAW_INSN_W = 32, - CFU_CFU_ID_W = 4, - CFU_STATE_INDEX_NUM = 5 - ) - ) - - val toplevel = Murax(config) - - toplevel.rework { - for (plugin <- toplevel.system.cpu.plugins) plugin match { - case plugin: CfuPlugin => plugin.bus.toIo().setName("miaou") - case _ => - } - } - - toplevel - } - } -} - - -object Murax_iCE40_hx8k_breakout_board_xip{ - - case class SB_GB() extends BlackBox{ - val USER_SIGNAL_TO_GLOBAL_BUFFER = in Bool() - val GLOBAL_BUFFER_OUTPUT = out Bool() - } - - case class SB_IO_SCLK() extends BlackBox{ - addGeneric("PIN_TYPE", B"010000") - val PACKAGE_PIN = out Bool() - val OUTPUT_CLK = in Bool() - val CLOCK_ENABLE = in Bool() - val D_OUT_0 = in Bool() - val D_OUT_1 = in Bool() - setDefinitionName("SB_IO") - } - - case class SB_IO_DATA() extends BlackBox{ - addGeneric("PIN_TYPE", B"110000") - val PACKAGE_PIN = inout(Analog(Bool)) - val CLOCK_ENABLE = in Bool() - val INPUT_CLK = in Bool() - val OUTPUT_CLK = in Bool() - val OUTPUT_ENABLE = in Bool() - val D_OUT_0 = in Bool() - val D_OUT_1 = in Bool() - val D_IN_0 = out Bool() - val D_IN_1 = out Bool() - setDefinitionName("SB_IO") - } - - case class Murax_iCE40_hx8k_breakout_board_xip() extends Component{ - val io = new Bundle { - val mainClk = in Bool() - val jtag_tck = in Bool() - val jtag_tdi = in Bool() - val jtag_tdo = out Bool() - val jtag_tms = in Bool() - val uart_txd = out Bool() - val uart_rxd = in Bool() - - val mosi = inout(Analog(Bool)) - val miso = inout(Analog(Bool)) - val sclk = out Bool() - val spis = out Bool() - - val led = out Bits(8 bits) - } - val murax = Murax(MuraxConfig.default(withXip = true).copy(onChipRamSize = 8 kB)) - murax.io.asyncReset := False - - val mainClkBuffer = SB_GB() - mainClkBuffer.USER_SIGNAL_TO_GLOBAL_BUFFER <> io.mainClk - mainClkBuffer.GLOBAL_BUFFER_OUTPUT <> murax.io.mainClk - - val jtagClkBuffer = SB_GB() - jtagClkBuffer.USER_SIGNAL_TO_GLOBAL_BUFFER <> io.jtag_tck - jtagClkBuffer.GLOBAL_BUFFER_OUTPUT <> murax.io.jtag.tck - - io.led <> murax.io.gpioA.write(7 downto 0) - - murax.io.jtag.tdi <> io.jtag_tdi - murax.io.jtag.tdo <> io.jtag_tdo - murax.io.jtag.tms <> io.jtag_tms - murax.io.gpioA.read <> 0 - murax.io.uart.txd <> io.uart_txd - murax.io.uart.rxd <> io.uart_rxd - - - - val xip = new ClockingArea(murax.systemClockDomain) { - RegNext(murax.io.xip.ss.asBool) <> io.spis - - val sclkIo = SB_IO_SCLK() - sclkIo.PACKAGE_PIN <> io.sclk - sclkIo.CLOCK_ENABLE := True - - sclkIo.OUTPUT_CLK := ClockDomain.current.readClockWire - sclkIo.D_OUT_0 <> murax.io.xip.sclk.write(0) - sclkIo.D_OUT_1 <> RegNext(murax.io.xip.sclk.write(1)) - - val datas = for ((data, pin) <- (murax.io.xip.data, List(io.mosi, io.miso)).zipped) yield new Area { - val dataIo = SB_IO_DATA() - dataIo.PACKAGE_PIN := pin - dataIo.CLOCK_ENABLE := True - - dataIo.OUTPUT_CLK := ClockDomain.current.readClockWire - dataIo.OUTPUT_ENABLE <> data.writeEnable - dataIo.D_OUT_0 <> data.write(0) - dataIo.D_OUT_1 <> RegNext(data.write(1)) - - dataIo.INPUT_CLK := ClockDomain.current.readClockWire - data.read(0) := dataIo.D_IN_0 - data.read(1) := RegNext(dataIo.D_IN_1) - } - } - - } - - def main(args: Array[String]) { - SpinalVerilog(Murax_iCE40_hx8k_breakout_board_xip()) - } -} - -object MuraxDhrystoneReady{ - def main(args: Array[String]) { - SpinalVerilog(Murax(MuraxConfig.fast.copy(onChipRamSize = 256 kB))) - } -} - -object MuraxDhrystoneReadyMulDivStatic{ - def main(args: Array[String]) { - SpinalVerilog({ - val config = MuraxConfig.fast.copy(onChipRamSize = 256 kB) - config.cpuPlugins += new MulPlugin - config.cpuPlugins += new DivPlugin - config.cpuPlugins.remove(config.cpuPlugins.indexWhere(_.isInstanceOf[BranchPlugin])) - config.cpuPlugins +=new BranchPlugin( - earlyBranch = false, - catchAddressMisaligned = false - ) - config.cpuPlugins += new IBusSimplePlugin( - resetVector = 0x00000000l, - cmdForkOnSecondStage = true, - cmdForkPersistence = false, - prediction = STATIC, - catchAccessFault = false, - compressedGen = false - ) - config.cpuPlugins.remove(config.cpuPlugins.indexWhere(_.isInstanceOf[LightShifterPlugin])) - config.cpuPlugins += new FullBarrelShifterPlugin - Murax(config) - }) - } -} - -//Will blink led and echo UART RX to UART TX (in the verilator sim, type some text and press enter to send UART frame to the Murax RX pin) -object MuraxWithRamInit{ - def main(args: Array[String]) { - SpinalVerilog(Murax(MuraxConfig.default.copy(onChipRamSize = 4 kB, onChipRamHexFile = "src/main/ressource/hex/muraxDemo.hex"))) - } -} - -object Murax_arty{ - def main(args: Array[String]) { - val hex = "src/main/c/murax/hello_world/build/hello_world.hex" - SpinalVerilog(Murax(MuraxConfig.default(false).copy(coreFrequency = 100 MHz,onChipRamSize = 32 kB, onChipRamHexFile = hex))) - } -} - - -object MuraxAsicBlackBox extends App{ - println("Warning this soc do not has any rom to boot on.") - val config = SpinalConfig() - config.addStandardMemBlackboxing(blackboxAll) - config.generateVerilog(Murax(MuraxConfig.default())) -} - diff --git a/cpp/_crt0.S-k0 b/cpp/_crt0.S-k0 deleted file mode 100644 index dbe07d9..0000000 --- a/cpp/_crt0.S-k0 +++ /dev/null @@ -1,42 +0,0 @@ - .text - .global _start - .type _start, @function - -_start: - # Initialize global pointer - .option push - .option norelax - la gp, __global_pointer$ - .option pop - - li sp, 0x1fff0 - - # Clear the bss segment - la a0, __bss_start - la a1, __BSS_END__ - -clear_bss: - bgeu a0, a1, finish_bss - sb x0, 0(a0) - addi a0, a0, 1 - beq x0, x0, clear_bss -finish_bss: - - nop //! - - call main - - nop //! - - # abort execution here - ebreak - - .section .rodata -alfabet: - .string "abcdefghijklmnopqrstuwxyz" -slowo: - - .section .data -wynik: - .string "mpabi" - .space 26 # rezerwuje 26 bajtów dla wyniku, zainicjowane na 0 \ No newline at end of file diff --git a/cpp/_crt0.S-k1 b/cpp/_crt0.S-k1 deleted file mode 100644 index 09af34b..0000000 --- a/cpp/_crt0.S-k1 +++ /dev/null @@ -1,39 +0,0 @@ - .text - .global _start - .type _start, @function - -_start: - # Initialize global pointer - .option push - .option norelax - la gp, __global_pointer$ - .option pop - - # Initialize stack pointer from linker script symbol - la sp, __stack_top - - # Clear the BSS segment - la a0, __bss_start - la a1, __bss_end - -clear_bss: - bgeu a0, a1, finish_bss - sb x0, 0(a0) - addi a0, a0, 1 - j clear_bss -finish_bss: - - call main - - ebreak - -.section .rodata - -alfabet: - .string "abcdefghijklmnopqrstuwxyz" -slowo: - - .section .data -wynik: - .string "mpabi" - .space 26 # rezerwuje 26 bajtów dla wyniku, zainicjowane na 0 diff --git a/cpp/_rvmain.cpp b/cpp/_rvmain.cpp index 375bdbd..6f0d40f 100644 --- a/cpp/_rvmain.cpp +++ b/cpp/_rvmain.cpp @@ -41,15 +41,7 @@ struct model { uint32_t len ; }; - -//alg -// prosta implementacji func. z bibl. std. strok przy uzyciu gpt3.5 -// - #define NULL ((void*) 0) - -// -// Funkcja pomocnicza do sprawdzania, czy znak jest wśród delimiterów bool is_delim(char c, const char *delims) { while (*delims) { if (c == *delims) { @@ -60,98 +52,64 @@ bool is_delim(char c, const char *delims) { return false; } -// Najprostsza implementacja funkcji strtok char *simple_strtok(char *str, const char *delims) { - static char *static_str = (char *) NULL; // Przechowuje wskaźnik do bieżącej pozycji w ciągu + static char *static_str =(char *) NULL; // Stores the position in the string - // Jeśli przekazano nowy ciąg, zaktualizuj static_str - if (str == NULL) { - return (char *) NULL; // str nie wskazuje na zdanie !!! + if (str !=(char *) NULL) { + static_str = str; } - static_str = str; - - // " .,mpabi" - // ^ - // Pomiń początkowe delimitery + + if (static_str == (char *) NULL) { + return (char *)NULL; + } + + // Skip initial delimiters while (*static_str && is_delim(*static_str, delims)) { static_str++; } - - // Jeśli doszliśmy do końca ciągu, zwróć NULL + if (*static_str == '\0') { - return (char *) NULL; + return (char *)NULL; } - // Zapisz początek tokenu char *token_start = static_str; - - //,. mpabi pabi - // Znajdź koniec tokenu + // Find the end of the token while (*static_str && !is_delim(*static_str, delims)) { static_str++; } - // Jeśli znaleziono delimitery, zamień je na '\0' i zaktualizuj static_str if (*static_str) { *static_str = '\0'; static_str++; + } else { + static_str = (char *)NULL; } - // Zwróć początek tokenu return token_start; } - char buf[1000]; struct model * p = (struct model *) buf; //p[1] - // + +int alg(char *ptr) { + const char *delims = " ,.!?:;\n\t"; + int pos = 0; -////func alg -//in: ptr to date -//return: count of words -int alg (char * ptr) { - - const char *delims = " ,.!?:;\n\t"; - - int pos = 0; - - while (char *token = simple_strtok(ptr, delims)) { - + char *token = simple_strtok(ptr, delims); + while (token != (char *)NULL) { p[pos].ptr = token; - //p[pos].len = strlen(token); - p[pos].len = pos; - ++pos; + p[pos].len = strlen(token); + ++pos; + token = simple_strtok((char *)NULL, delims); // Set ptr to NULL after the first call to continue tokenizing the same string } - return pos; + return pos; } -/* -struct model { - char * str; - uint32_t len ; -} tab [10] ; -*/ - int main() { -// Seccess is often -// ^ char *str = " Success is often defined as the ability to reach your goals in life, whatever those goals may be. In some ways, a better word for success might be attainment, accomplishment, or progress. It is not necessarily a destination but a journey that helps develop the skills and resources you need to thrive."; - -/* - struct model *ptr = (struct model *) alloc(LEN); - if (ptr != (struct model *)NULL) { - ptr->str = alloc(strlen((char *)str) + 1); - if (ptr->str != (char *)NULL) { - strcpy (ptr->str, (char *)str); - ptr->len = strlen(ptr->str); - - int8_t count = alg(ptr->str); - } - } - */ alg(str); asm ("nop"); diff --git a/cpp/murax_128k_ram-sp.ld b/cpp/murax_128k_ram-sp.ld deleted file mode 100644 index b3ac278..0000000 --- a/cpp/murax_128k_ram-sp.ld +++ /dev/null @@ -1,43 +0,0 @@ -MEMORY -{ - RAM (wx) : ORIGIN = 0x0, LENGTH = 128K -} - -SECTIONS -{ - .text : - { - *(.text*) - *(.rodata*) - } > RAM - - .data : - { - *(.data*) - } > RAM - - .bss : - { - *(.bss*) - *(COMMON) - } > RAM - - /* Add stack at the end of RAM */ - . = ALIGN(4); - _end = .; - PROVIDE(end = .); - - /* Define stack size and location */ - _stack_size = 0x4000; /* Example stack size: 16KB */ - _stack_end = ORIGIN(RAM) + LENGTH(RAM); /* End of RAM */ - _stack_start = _stack_end - _stack_size; /* Calculate start of the stack */ - .stack (NOLOAD) : - { - . = ALIGN(4); - . = . + _stack_size; - . = ALIGN(4); - _sp = .; - } > RAM - - PROVIDE(__stack = _sp); -} diff --git a/cpp/murax_128k_ram.ld b/cpp/murax_128k_ram.ld deleted file mode 100644 index 244668e..0000000 --- a/cpp/murax_128k_ram.ld +++ /dev/null @@ -1,67 +0,0 @@ -/* Linker script for a system with 128KB RAM starting at 0x10000 */ -MEMORY -{ - RAM (wx) : ORIGIN = 0x0000, LENGTH = 128K -} - -SECTIONS -{ - /* Place code and readonly data at the beginning of RAM */ - .text : - { - *(.text*) - *(.rodata*) - } > RAM - - /* Place initialized data right after the .text section */ - .data : - { - . = ALIGN(4); - *(.data*) - } > RAM - - /* Uninitialized data (BSS) follows initialized data */ - .bss : - { - . = ALIGN(4); - __bss_start = .; - *(.bss*) - *(COMMON) - . = ALIGN(4); - __bss_end = .; - } > RAM - - /* Define heap start right after bss */ - . = ALIGN(4); - __heap_start = .; - PROVIDE(heap_start = __heap_start); - - /* Leave space for the heap by not explicitly defining its end */ - /* The heap grows towards the stack */ - - /* Reserve space for the stack at the end of RAM */ - /* Let's say we want a 16KB stack */ - . = ALIGN(4); - __stack_size = 16K; /* Size of the stack */ - __stack_top = ORIGIN(RAM) + LENGTH(RAM); /* Top of the stack */ - __stack_start = __stack_top - __stack_size; /* Start of the stack */ - .stack (NOLOAD) : - { - . = __stack_start; - . += __stack_size; /* Allocate space for the stack */ - . = ALIGN(4); - } > RAM - - PROVIDE(__stack = __stack_top); - PROVIDE(stack_top = __stack_top); - PROVIDE(stack_start = __stack_start); - - /* Heap end is dynamically located at the start of the stack */ - __heap_end = __stack_start; - PROVIDE(heap_end = __heap_end); - - /* End of RAM usage */ - . = ALIGN(4); - _end = .; - PROVIDE(end = _end); -} diff --git a/cpp/murax_128k_ram.ld-kopia b/cpp/murax_128k_ram.ld-kopia deleted file mode 100644 index 6488ff3..0000000 --- a/cpp/murax_128k_ram.ld-kopia +++ /dev/null @@ -1,13 +0,0 @@ -MEMORY -{ - RAM (wx) : ORIGIN = 0x10000, LENGTH = 128K -} - -SECTIONS -{ - .text : { *(.text*) } > RAM - .rodata : { *(.rodata*) } > RAM - .data : { *(.data*) } > RAM - .bss : { *(.bss*) } > RAM - _end = .; /* Definiuje koniec sekcji danych, może być używane do określenia rozmiaru sterty */ -} From a7089d248ff6e5d791e5bcfd1924ea6ef1ceb708 Mon Sep 17 00:00:00 2001 From: mpabi Date: Sat, 25 May 2024 16:39:06 +0000 Subject: [PATCH 06/10] retire #define, first step :) c++ approach --- cpp/_rvmain.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cpp/_rvmain.cpp b/cpp/_rvmain.cpp index bca60c5..bd83114 100644 --- a/cpp/_rvmain.cpp +++ b/cpp/_rvmain.cpp @@ -11,6 +11,16 @@ void strcpy(char *s, char *t) { while (*s++ = *t++); } + +class GamePlayer { + + private: + + static const int NUM_TURNS = 5; + int scores[NUM_TURNS]; + +} c; + #define ALLOCSIZE 10000 static char allocbuf[ALLOCSIZE]; @@ -105,7 +115,6 @@ char *simple_strtok(char *str, const char *delims) { char buf[1000]; struct model * p = (struct model *) buf; //p[1] - // ////func alg From 10c1866b333b0316b4bdba439674607d1ab7d3bf Mon Sep 17 00:00:00 2001 From: mpabi Date: Sat, 25 May 2024 16:50:41 +0000 Subject: [PATCH 07/10] remove extra files from 'tracked files' --- conf.json | 16 ------ cpp/._rvmain.cpp.swl | Bin 12288 -> 0 bytes cpp/._rvmain.cpp.swm | Bin 12288 -> 0 bytes cpp/._rvmain.cpp.swn | Bin 12288 -> 0 bytes cpp/._rvmain.cpp.swo | Bin 12288 -> 0 bytes cpp/Make.rules-kopia | 81 -------------------------- cpp/_crt0.S-k0 | 42 -------------- cpp/_crt0.S-k1 | 39 ------------- cpp/murax_128k_ram-sp.ld | 43 -------------- cpp/murax_128k_ram.ld | 67 ---------------------- cpp/murax_128k_ram.ld-kopia | 13 ----- igit-borys.py | 111 ------------------------------------ 12 files changed, 412 deletions(-) delete mode 100644 conf.json delete mode 100644 cpp/._rvmain.cpp.swl delete mode 100644 cpp/._rvmain.cpp.swm delete mode 100644 cpp/._rvmain.cpp.swn delete mode 100644 cpp/._rvmain.cpp.swo delete mode 100644 cpp/Make.rules-kopia delete mode 100644 cpp/_crt0.S-k0 delete mode 100644 cpp/_crt0.S-k1 delete mode 100644 cpp/murax_128k_ram-sp.ld delete mode 100644 cpp/murax_128k_ram.ld delete mode 100644 cpp/murax_128k_ram.ld-kopia delete mode 100644 igit-borys.py diff --git a/conf.json b/conf.json deleted file mode 100644 index a059d03..0000000 --- a/conf.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "user": "borysr", - "email": "borysr@gmail.com", - "remotes": [ - { - "name": "r", - "protocol": "http", - "domain": "qstack.pl", - "port": "3000", - "token_name": "t", - "token": "8ee3f1b7980197aeceadee3cf4d980f817d44f06", - "group": "1i-2023", - "project": "homework" - } - ] -} \ No newline at end of file diff --git a/cpp/._rvmain.cpp.swl b/cpp/._rvmain.cpp.swl deleted file mode 100644 index 1080c395311c7737c4867a39fcbc7f858bcef4c9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2U2Ggz8HP{zcYi2Qgs4Q(@dlc;*X(YbgrspDgrXD$Od1JVq{P9DXUFmE&dv-o zvsrd6LoXT?@l&p71u3W!2!R9=kPD)Ms6_3HqM}HF3UUS9Py|K2fZT9Xp6{HQ?An9` zDOZIV>se>coS*l+-#6zRE4$o$=;%lFz4fNzdW%w*+YhX?(?zxGR;7BWmq_uAuKlx~ zGu!m`+`D&q-}UN#Ryu6-qomVtO0@|;LUeg_E0)dI#4=LI#4=LI#4=LI#4=LI`FD-Ad7dX&!P4;x#F+pzjti=o!^$f zN(V{@N(V{@N(V{@N(V{@N(V{@N(V{@N(V{@UWE=gEv0_UAOG)uJ>vQQ|Kjiem+nyN zukZqFzz^UlcnrP-UxWyj;6rc(4nrN@0dI#p;mVtp`a4{P-@-HSb9fTgU||bfZt3oZ@2*G zVGS1H5FCL0@J{&0o0NJPF2UpQFbrV;Rd_30d81Olhs*FgxBySVH{l!bBzzf8!ErbM zcY}gg-oSj|m+%~X8@>f!fycmsPr-dK2Y12CP zSueS9#sA?N;=%g5x~UoFK8AYt9C^&;q+MODgi&0XnzIGL>1vuK+?iW<)k*X;1$tgr zj;`pw6J}oGwRGYIPUc6U4kMlRk~r~GPe&`-34#i3{V>z=O{nUWUeijgUme(udSOO| z35q7nO|51}7CBke@j`}5{caq1ON>iNwQ5yN9eZ$LVMe#S!0)CAoR}~YrJY>yNz>h_ zdSJWA68=#&J?3+>^~P%2d6_EteEX|@;Az`RPtNP{p_vN0t(I#GUGA-T$(TYlfe#0k zGOdj?Cf1axyHS{C+ID1TBkt;%`s4==&Mk(EnK(FsI5!?t^F9k9v5AdUVIH0Q;KITK zhd*}o#F10965pNRG`h#e(9#I;jfQ!P!h;xL1rad5zt&25M%fmbtVOzDZxX}30?)}1KyJ-4t$rlI6xEGw<07%*~UF|d3<`F7#PRomTO)K@h^?6KaZfPq@hk?I&t~=1J2-Ta9xQ=%HjkBkF7@LP#`Ze;+ z$MwQ{ZTJ3L^NvSdpE%}O)rtDvSe(t+6~O5sj7*b?x!7x)G-+~Y&lXiIXP+imNb=Wcq+#HyQgt7^l0snreV|{SUV+6|8quK zy?J_U5x+IKBJnugyQ@)O)QQZ^r$fIZ(Oc#%_}Ru;*K1?paNxFm-Opob-|^|K>$Ocr zrZU4avwf+PX))L_ryVCznx#WWo5jBCg_+~F9nEsnks)Z$D!XmbSaE{X+itpDL&sNw zQ9v|TvEU@Vyr~q5+pc&$ZJQT%7nwFHU5=taUrjYLIrlm9>fT@6dKQkTs{n%ECs_-#o{v*BYhdv*-I*q}0xqx8jGM$p&4mo{9X{^ptK+arAG9 zhsMCI_W5F;Th~K^wj9(ku_Yf#)S)(`_6VQf)B1Fr?Wymh6Is{s*jn0S``9xp`<2$R zi`r5fPAQXxmz3vYwC1mkbS@k@rmF{Pvs2T2DU&@Q@kFBQrD?<$uMy0A>iPCT>JQx2 zBDzJ0*dEO=>)IpEc4;e~ak7ZqSiet)bNPe3q&82HZ6`rBrR+Mormt>|w8|?VqB5c8 zOk!G$5+&61vzLn1P`_92&5sPyp}CjCK+`r{%ah*pSd|@@9y#Wl%_o1=^3mq)ux3-- zQlStzzI)S05%H05w$5fV-#B%Vn`y1a@-v;)YRFtuk{A*hIWFYy9yw-CZW+m9=hz>} z+bp|+oQqg#>MsT9alKtE3 zZr$xAaA_VTLL3)wYcZu*43;f>%EZMAkP`-t#9}MEn4Y|>YNsE%L9gZM`^a+Y)K?Fw Fe*yJzWu*WB diff --git a/cpp/._rvmain.cpp.swm b/cpp/._rvmain.cpp.swm deleted file mode 100644 index ee08e76f78961876ed0fed3da5cfdf4038170c34..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2zfTlF6vqcEe<4II)L0Bh47<1d*gfDP;*k(SL4vU$U=)QcdwXHw*xT&x0p|s+ zETr&nFn0bZv`|WkwT-d#M}x7^!a`%Bg??vljynj!f{OSy`LMTdXWqQ`ncd=Y%$O4+ zmv~>N#c(t;Hq@HTrB}b5Y(B_XF>*r@{?}od*`99Kae7U+cek;(M8dA6LO9>$1c78a zTwJg{zZ2KH&7^x|fDG*2K;w9K$}&Zs)fDDiUGVuQySYaGT z=*Gp+=T<+Hmm;JkgE$=1J4+cJ#bMs{xfWQup)Rx_rPmF%qXjMD7lH(WVzM~I^p1g2 z##~OB+oQ{fT6IyZP;_D*6g)rX$;w=w;o8=?&h31@;AoL|(=FsQIa=5Id9CP`+CriP zWV6!KF)!^LUap0=EL5%~+^I2)b%GLfq}oN3LWEdM9L}sA%KB5NUKK0lX>#C}T6axt z$<)?PsjVGSTNMq$p7@t(P3Ig7 zUXE)rI#bMXgAb05ULG17xi*YhYVZIC>%5HpkTcZsNau6p>A^tF=jV8j>PjS(*Ssae z&C0|wt0 zFRVvOabOtgQ#ErS+_YUc+jJ(IsH6+98s?Ol5QK&Bc2*Zc{>_IF&n5;Y<_k-9KAQKu iM1TD~@f;=QY~P(noV9wslP_jneld!(NZUC(!2SZ9@K1IC diff --git a/cpp/._rvmain.cpp.swn b/cpp/._rvmain.cpp.swn deleted file mode 100644 index d0b40fbbb6019a04fa7498f224d80ed3cebe972b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2!B5jr9LFD+=s{4U-qi5eFtjVMbJA?p z(HX`m#H$=kps_QSMP0x#%_g9t; z+Zn<6emiN743L3?8|Y=1vU*13NhbRFnbY?Uo{}<<0Wv@a$N(8217v^0i(=V-*LvS^q_eB z{y!mm_;r%8pWrii2i}60;01UJ>c9naU=}<81uzEszy)v~oC8NdH~4;nu@B%qcnw~G z=U@wXU=f(01hRmGW8iNuY608e2lxuUfH&Y7*aRD328@CMkOV#85BmBBK7o(m38;a2 za2wnLQ{X1J3Pyo&kq0!$02v?yWPl8i0Wv@a$N(9L4XiVc;ag$Nceq{wVjZs;=R1cmECcb8`Y|7DuMmj zaw|%-T2%|YRmXbkLZS?0)AREouXhfwwZgkD)MzE_)EL&9UY#pmc1SdtZR^=wF#M?g zEUK5qhJMv@lxX3uTK7$@N2&Ersr3%2^;mR zi%RwQFn3@xnvfB#h)^7{D_n`9rCNn+{QC6t-5WDgvy<2*7ms7H${X^2q|(toSpO$O|EV{4IJt!~>RCa#xLN iuw*9+?Nj0bNh}%;qAY1UX0=wf__ZJ`Bj?D%IQs_$gEi&= diff --git a/cpp/._rvmain.cpp.swo b/cpp/._rvmain.cpp.swo deleted file mode 100644 index afb7b4f5d5178c0e319ad1b35eda4e5ab73a16e9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2&u`mg7{}jo07mHwlt18U3agWBNt{w>6;d&+MHGg1n8tx_4A*g}6UR2TQ#Xyu zkk~Y7hm8p|Y2pBvapJ}#*mhipgtT2a@FyU|&vN6yf$wWORR~=Z6$xq5^GcuEexDzH z{Cyr*t&-)!8;h^gY_1@%o)F^4`Be36YwPJhzj|0SeZ!O6{nopFpy~B~UP8Pl6Xrw5 ztLJq!ue)xYZmnRX7>{Zp_9E5HiuMS*5eJv1|NVydV{ulhu4oW`Cyv6oC7!wRqh ztN<&(3a|pK04u->umTUL0)aau&Y<>(lKP)Zjzc}iumY?AE5Hh{0;~Wl zzzVPetN<(U04ktWgiwa@(f{Kp9-ser{{R1FREVF!H{f${4O|A7zy>hD5_ko?3>Ls7 zcoqzUec(~>2>5-!5Wj)zU=4)eB`^p68WG|runDe#E8t`B5jY3Vf)Bu3U>3}PNw9@_ ze*m9>3*c=~1{v@S7zbnENg$u?J3QmJ;1;+Ez5t(s%iu%sKB$3tkOJf2*T;mo0lo&8 zz(w#HcomF-KlY&x@IAN(?gCz{04u->umY?AE5Hi;zY1&!BF_k#qI2Teq?Yj4n8@d8 zIyWt=xvz<^cDMSW=AL!~kCX$AwS#n^(Mp$OW-LGKlX=%z%_T)<96ZP1o?Vsh<>>~v z(O_wJ_Uhg3yf?g~me^2V*8^sz|uklq#dQZG{rH z3h~wk8J2HQK10i%R;Pw()O=l|OkPlNHg=I?iHw?MIl4=S$Sz5Dd~?_{$c;T`V$Z}S zTZRwfUx;_jDk+g=xml$w9X@*W*pcIlZ!REJ5-^8=G__?~6maJg-6Y@Kyc*|z9tJF- zuV@}+q6o#b0~rDT_0ZE$Z|K*xJ2!2!P8El2TDP_O?JvV90nt*Zz2m^97EcyV34vsB zE^>=hj%y&r4?N4TNx@4}OsBh@)E%8vI0+#Ok>7z<(nRgJ6G)#ZCUur;7mcO4zrNDz zpW4cu|D8V!Z diff --git a/cpp/Make.rules-kopia b/cpp/Make.rules-kopia deleted file mode 100644 index 2bd12e9..0000000 --- a/cpp/Make.rules-kopia +++ /dev/null @@ -1,81 +0,0 @@ - -ARCH=riscv64-unknown-elf -GNU_DIR=$(HOME)/riscv/riscv/ -GNU_BIN=$(GNU_DIR)/bin - - -CC=$(GNU_BIN)/$(ARCH)-gcc -CXX=$(GNU_BIN)/$(ARCH)-g++ -AS=$(GNU_BIN)/$(ARCH)-as -LD=$(GNU_BIN)/$(ARCH)-ld -OBJCOPY=$(GNU_BIN)/$(ARCH)-objcopy -OBJDUMP=$(GNU_BIN)/$(ARCH)-objdump -SIZE=$(GNU_BIN)/$(ARCH)-size -AR=$(GNU_BIN)/$(ARCH)-ar -RANLIB=$(GNU_BIN)/$(ARCH)-ranlib - - -CFLAGS+=-ffreestanding -CFLAGS+=-fno-pic -CFLAGS+=-march=rv32i -mabi=ilp32 -CFLAGS+= -g - - -LDFLAGS+=-nostdlib -LDFLAGS+=-Wl,-Ttext=0x00000000 - -# see: https://github.com/riscv/riscv-gcc/issues/120 -#LDFLAGS+=-Wl,--no-relax - - - -ASFLAGS+=$(CFLAGS) -CXXFLAGS+=$(CFLAGS) - -CLEAN_DIRS=$(SUBDIRS:%=clean-%) -ALL_DIRS=$(SUBDIRS:%=all-%) - -OBJDUMPFLAGS+=-Mnumeric,no-aliases - -.PHONY: all clean world $(CLEAN_DIRS) $(ALL_DIRS) - - -%.bin : % - $(OBJCOPY) $< -O binary $@ - -%.lst : % - $(OBJDUMP) $(OBJDUMPFLAGS) -dr --disassemble-all $< > $<.lst - -% : %.o - $(LINK.cc) $(LDFLAGS) -o $@ $^ $(LDLIBS) - $(SIZE) -x -A $@ - -%.s: %.c - $(COMPILE.c) -S -o $@ $< - -%.s: %.cc - $(COMPILE.cc) -S -o $@ $< - -%.o: %.c - $(COMPILE.c) -o $@ $< - -%.o: %.cc - $(COMPILE.cc) -o $@ $< - -%.srec: % - $(OBJCOPY) $< -O srec $@ - - - - -all:: $(ALL_DIRS) - -clean:: $(CLEAN_DIRS) - -$(ALL_DIRS):: - $(MAKE) -C $(@:all-%=%) all - -$(CLEAN_DIRS):: - $(MAKE) -C $(@:clean-%=%) clean - -world:: clean all diff --git a/cpp/_crt0.S-k0 b/cpp/_crt0.S-k0 deleted file mode 100644 index dbe07d9..0000000 --- a/cpp/_crt0.S-k0 +++ /dev/null @@ -1,42 +0,0 @@ - .text - .global _start - .type _start, @function - -_start: - # Initialize global pointer - .option push - .option norelax - la gp, __global_pointer$ - .option pop - - li sp, 0x1fff0 - - # Clear the bss segment - la a0, __bss_start - la a1, __BSS_END__ - -clear_bss: - bgeu a0, a1, finish_bss - sb x0, 0(a0) - addi a0, a0, 1 - beq x0, x0, clear_bss -finish_bss: - - nop //! - - call main - - nop //! - - # abort execution here - ebreak - - .section .rodata -alfabet: - .string "abcdefghijklmnopqrstuwxyz" -slowo: - - .section .data -wynik: - .string "mpabi" - .space 26 # rezerwuje 26 bajtów dla wyniku, zainicjowane na 0 \ No newline at end of file diff --git a/cpp/_crt0.S-k1 b/cpp/_crt0.S-k1 deleted file mode 100644 index 09af34b..0000000 --- a/cpp/_crt0.S-k1 +++ /dev/null @@ -1,39 +0,0 @@ - .text - .global _start - .type _start, @function - -_start: - # Initialize global pointer - .option push - .option norelax - la gp, __global_pointer$ - .option pop - - # Initialize stack pointer from linker script symbol - la sp, __stack_top - - # Clear the BSS segment - la a0, __bss_start - la a1, __bss_end - -clear_bss: - bgeu a0, a1, finish_bss - sb x0, 0(a0) - addi a0, a0, 1 - j clear_bss -finish_bss: - - call main - - ebreak - -.section .rodata - -alfabet: - .string "abcdefghijklmnopqrstuwxyz" -slowo: - - .section .data -wynik: - .string "mpabi" - .space 26 # rezerwuje 26 bajtów dla wyniku, zainicjowane na 0 diff --git a/cpp/murax_128k_ram-sp.ld b/cpp/murax_128k_ram-sp.ld deleted file mode 100644 index b3ac278..0000000 --- a/cpp/murax_128k_ram-sp.ld +++ /dev/null @@ -1,43 +0,0 @@ -MEMORY -{ - RAM (wx) : ORIGIN = 0x0, LENGTH = 128K -} - -SECTIONS -{ - .text : - { - *(.text*) - *(.rodata*) - } > RAM - - .data : - { - *(.data*) - } > RAM - - .bss : - { - *(.bss*) - *(COMMON) - } > RAM - - /* Add stack at the end of RAM */ - . = ALIGN(4); - _end = .; - PROVIDE(end = .); - - /* Define stack size and location */ - _stack_size = 0x4000; /* Example stack size: 16KB */ - _stack_end = ORIGIN(RAM) + LENGTH(RAM); /* End of RAM */ - _stack_start = _stack_end - _stack_size; /* Calculate start of the stack */ - .stack (NOLOAD) : - { - . = ALIGN(4); - . = . + _stack_size; - . = ALIGN(4); - _sp = .; - } > RAM - - PROVIDE(__stack = _sp); -} diff --git a/cpp/murax_128k_ram.ld b/cpp/murax_128k_ram.ld deleted file mode 100644 index 244668e..0000000 --- a/cpp/murax_128k_ram.ld +++ /dev/null @@ -1,67 +0,0 @@ -/* Linker script for a system with 128KB RAM starting at 0x10000 */ -MEMORY -{ - RAM (wx) : ORIGIN = 0x0000, LENGTH = 128K -} - -SECTIONS -{ - /* Place code and readonly data at the beginning of RAM */ - .text : - { - *(.text*) - *(.rodata*) - } > RAM - - /* Place initialized data right after the .text section */ - .data : - { - . = ALIGN(4); - *(.data*) - } > RAM - - /* Uninitialized data (BSS) follows initialized data */ - .bss : - { - . = ALIGN(4); - __bss_start = .; - *(.bss*) - *(COMMON) - . = ALIGN(4); - __bss_end = .; - } > RAM - - /* Define heap start right after bss */ - . = ALIGN(4); - __heap_start = .; - PROVIDE(heap_start = __heap_start); - - /* Leave space for the heap by not explicitly defining its end */ - /* The heap grows towards the stack */ - - /* Reserve space for the stack at the end of RAM */ - /* Let's say we want a 16KB stack */ - . = ALIGN(4); - __stack_size = 16K; /* Size of the stack */ - __stack_top = ORIGIN(RAM) + LENGTH(RAM); /* Top of the stack */ - __stack_start = __stack_top - __stack_size; /* Start of the stack */ - .stack (NOLOAD) : - { - . = __stack_start; - . += __stack_size; /* Allocate space for the stack */ - . = ALIGN(4); - } > RAM - - PROVIDE(__stack = __stack_top); - PROVIDE(stack_top = __stack_top); - PROVIDE(stack_start = __stack_start); - - /* Heap end is dynamically located at the start of the stack */ - __heap_end = __stack_start; - PROVIDE(heap_end = __heap_end); - - /* End of RAM usage */ - . = ALIGN(4); - _end = .; - PROVIDE(end = _end); -} diff --git a/cpp/murax_128k_ram.ld-kopia b/cpp/murax_128k_ram.ld-kopia deleted file mode 100644 index 6488ff3..0000000 --- a/cpp/murax_128k_ram.ld-kopia +++ /dev/null @@ -1,13 +0,0 @@ -MEMORY -{ - RAM (wx) : ORIGIN = 0x10000, LENGTH = 128K -} - -SECTIONS -{ - .text : { *(.text*) } > RAM - .rodata : { *(.rodata*) } > RAM - .data : { *(.data*) } > RAM - .bss : { *(.bss*) } > RAM - _end = .; /* Definiuje koniec sekcji danych, może być używane do określenia rozmiaru sterty */ -} diff --git a/igit-borys.py b/igit-borys.py deleted file mode 100644 index 8c226d8..0000000 --- a/igit-borys.py +++ /dev/null @@ -1,111 +0,0 @@ -import argparse -import json -import sys -import subprocess -import os -from datetime import datetime - -DEFAULT_CONFIG = { - "user": "borysr", - "email": "borysr@gmail.com", - "remotes": [{ - "name": "r", # Zaktualizowano z "default" na "mpabi" - "protocol": "http", - "domain": "qstack.pl", - "port": "3000", - "token_name": "t", - "token": "8ee3f1b7980197aeceadee3cf4d980f817d44f06", - "group": "1i-2023", - "project": "homework" - }] -} - -def load_or_create_config(config_file, args): - config_exists = os.path.exists(config_file) and os.stat(config_file).st_size != 0 - if config_exists: - with open(config_file, 'r') as file: - config = json.load(file) - else: - config = DEFAULT_CONFIG.copy() - - # Znajdź istniejące zdalne repozytorium o podanej nazwie - remote = next((remote for remote in config['remotes'] if remote['name'] == args.remote), None) - - # Jeśli istnieje zdalne repozytorium i podano argumenty związane z konfiguracją zdalnego repozytorium - if remote: - for field in ['protocol', 'domain', 'port', 'token_name', 'token', 'group', 'project']: - # Aktualizuj tylko, jeśli argument został jawnie podany - if getattr(args, field, None) is not None: - remote[field] = getattr(args, field) - - # Jeśli zdalne repozytorium nie istnieje, ale podano nazwę, tworzymy nowe zdalne repozytorium - elif args.remote: - new_remote = {'name': args.remote} - for field in ['protocol', 'domain', 'port', 'token_name', 'token', 'group', 'project']: - new_remote[field] = getattr(args, field, DEFAULT_CONFIG['remotes'][0].get(field, '')) - if new_remote[field] == None: - new_remote[field] = DEFAULT_CONFIG['remotes'][0].get(field, '') - config['remotes'].append(new_remote) - - # Aktualizuj informacje o użytkowniku i email, tylko jeśli zostały podane - if getattr(args, 'user', None): - config['user'] = args.user - if getattr(args, 'email_domain', None): - config['email'] = f"{args.user}@{args.email_domain}" - - # Zapisz zmodyfikowaną konfigurację - with open(config_file, 'w') as file: - json.dump(config, file, indent=4) - - return config - - -def init_git_repo(config): - user_name = config['user'] - user_email = config['email'] - branch_name = f"{user_name}-{datetime.now().strftime('%Y-%m-%d')}" - - if subprocess.run(["git", "rev-parse", "--git-dir"], stderr=subprocess.DEVNULL).returncode != 0: - subprocess.run(["git", "init"]) - subprocess.run(["git", "config", "user.name", user_name]) - subprocess.run(["git", "config", "user.email", user_email]) - subprocess.run(["git", "checkout", "-b", branch_name]) - print("Git repository initialized.") - else: - print("Already inside a Git repository. Skipping initialization.") - - remotesFromList = str(subprocess.run(["git", "remote", "-v"], capture_output=True).stdout) - remotesFromList = remotesFromList.replace('b\'', "").replace('\'', "").split('\\n') - for rm in remotesFromList: - name = rm.split("\\t")[0] - subprocess.run(["git", "remote", "remove", name], stderr=subprocess.DEVNULL) - - for remote in config['remotes']: - remote_url = f"{remote['protocol']}://{remote['token_name']}:{remote['token']}@{remote['domain']}:{remote['port']}/{remote['group']}/{remote['project']}" - # Usunięcie i ponowne dodanie zdalnego repozytorium, jeśli jest zaktualizowane - #subprocess.run(["git", "remote", "remove", remote['name']], stderr=subprocess.DEVNULL) - subprocess.run(["git", "remote", "add", remote['name'], remote_url]) - print(f"Remote '{remote['name']}' added or updated.") - -def main(): - parser = argparse.ArgumentParser(description="Git repository initializer with custom configuration.") - parser.add_argument("--user", help="User name") - parser.add_argument("--email_domain", help="Email domain") - parser.add_argument("--config", help="Path to the JSON config file", default="conf.json") - parser.add_argument("--remote", help="Name of the remote to add or update") - parser.add_argument("--protocol", help="Remote protocol") - parser.add_argument("--domain", help="Remote domain") - parser.add_argument("--port", help="Remote port") - parser.add_argument("--token_name", help="Remote token name") - parser.add_argument("--token", help="Remote token") - parser.add_argument("--group", help="Group name") - parser.add_argument("--project", help="Project name") - - args = parser.parse_args() - - config = load_or_create_config(args.config, args) - init_git_repo(config) - print("Git repository initialized and configured based on the provided configuration.") - -if __name__ == "__main__": - main() From cdb06c4c44ec4041935debcc77470c6e71ded84f Mon Sep 17 00:00:00 2001 From: mpabi Date: Sat, 25 May 2024 17:08:02 +0000 Subject: [PATCH 08/10] Prefer const and inline to #define. --- cpp/_rvmain.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cpp/_rvmain.cpp b/cpp/_rvmain.cpp index 08d91db..9f05cc6 100644 --- a/cpp/_rvmain.cpp +++ b/cpp/_rvmain.cpp @@ -12,14 +12,19 @@ void strcpy(char *s, char *t) while (*s++ = *t++); } -class GamePlayer { + +// Effective C++ by Scott Meyers +// page. 6 +// Item 1: Prefer const and inline to #define. +// +class NewDefine{ private: + static const int ALLOCSIZE= 10000; - static const int NUM_TURNS = 5; - int scores[NUM_TURNS]; +}; -} c; +const int NewDefine::ALLOCSIZE; #define ALLOCSIZE 10000 From fa96a5d3b9670bf52b5445d49d94f208218ba143 Mon Sep 17 00:00:00 2001 From: mpabi Date: Sat, 25 May 2024 17:22:43 +0000 Subject: [PATCH 09/10] applied Borys chages ;) --- cpp/_rvmain.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/cpp/_rvmain.cpp b/cpp/_rvmain.cpp index 9f05cc6..1cd6766 100644 --- a/cpp/_rvmain.cpp +++ b/cpp/_rvmain.cpp @@ -73,7 +73,7 @@ bool is_delim(char c, const char *delims) { } char *simple_strtok(char *str, const char *delims) { - char *static_str = (char *) NULL; // Przechowuje wskaźnik do bieżącej pozycji w ciągu + static char *static_str = (char *) NULL; if (str !=(char *) NULL) { static_str = str; @@ -83,7 +83,6 @@ char *simple_strtok(char *str, const char *delims) { return (char *)NULL; } - // Skip initial delimiters while (*static_str && is_delim(*static_str, delims)) { static_str++; } @@ -94,7 +93,6 @@ char *simple_strtok(char *str, const char *delims) { char *token_start = static_str; - // Find the end of the token while (*static_str && !is_delim(*static_str, delims)) { static_str++; } @@ -109,11 +107,8 @@ char *simple_strtok(char *str, const char *delims) { char buf[1000]; struct model * p = (struct model *) buf; //p[1] -<<<<<<< HEAD - -======= ->>>>>>> mpabi +/* int alg(char *ptr) { const char *delims = " ,.!?:;\n\t"; int pos = 0; @@ -123,11 +118,26 @@ int alg(char *ptr) { p[pos].ptr = token; p[pos].len = strlen(token); ++pos; - token = simple_strtok((char *)NULL, delims); // Set ptr to NULL after the first call to continue tokenizing the same string + token = simple_strtok((char *)NULL, delims); } return pos; } +*/ + +int alg(char *ptr) { + const char *delims = " ,.!?:;\n\t"; + int pos = 0; + + char *token = simple_strtok(ptr, delims); + while (token != (char *)NULL) { + p[pos].len = strlen(token); + ++pos; + token = simple_strtok((char *)NULL, delims); + } + return pos; +} + int main() { char *str = " Success is often defined as the ability to reach your goals in life, whatever those goals may be. In some ways, a better word for success might be attainment, accomplishment, or progress. It is not necessarily a destination but a journey that helps develop the skills and resources you need to thrive."; From a0f7585ae11c960607a83c09844bf8c203308f08 Mon Sep 17 00:00:00 2001 From: mpabi Date: Sat, 25 May 2024 20:12:41 +0000 Subject: [PATCH 10/10] gdb tested ;) --- cpp/_rvmain.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cpp/_rvmain.cpp b/cpp/_rvmain.cpp index 1cd6766..338a5e7 100644 --- a/cpp/_rvmain.cpp +++ b/cpp/_rvmain.cpp @@ -131,6 +131,7 @@ int alg(char *ptr) { char *token = simple_strtok(ptr, delims); while (token != (char *)NULL) { + p[pos].ptr = token; p[pos].len = strlen(token); ++pos; token = simple_strtok((char *)NULL, delims); @@ -138,7 +139,9 @@ int alg(char *ptr) { return pos; } - +// gdb: p/x (model[]*)p[0].len +// gdb: p/s (char *)(model[]*)p[2].ptr +// :) powered by rv32i int main() { char *str = " Success is often defined as the ability to reach your goals in life, whatever those goals may be. In some ways, a better word for success might be attainment, accomplishment, or progress. It is not necessarily a destination but a journey that helps develop the skills and resources you need to thrive."; alg(str);