From 3cffc235f159b957a28f4cc32e63fac5639634d8 Mon Sep 17 00:00:00 2001 From: onsdagens Date: Thu, 12 Oct 2023 21:56:13 +0200 Subject: [PATCH] riscv model view implemented, some bugifxes to the editor and egui components, bugfix to the mem component, also made vizia left side panel smaller --- riscv/autosave.json | 1 + riscv/examples/empty.rs | 5 +- riscv/examples/riscv.rs | 441 +++++++++++------- riscv/src/components/decoder.rs | 2 +- riscv/src/components/instr_mem.rs | 7 +- riscv/src/components/reg_file.rs | 6 +- riscv/src/gui_egui/components/reg_file.rs | 9 +- .../src/gui_egui/components/sign_zero_ext.rs | 4 +- riscv/src/gui_vizia/components/alu.rs | 54 ++- .../src/gui_vizia/components/branch_logic.rs | 10 +- riscv/src/gui_vizia/components/decoder.rs | 8 +- riscv/src/gui_vizia/components/instr_mem.rs | 8 +- riscv/src/gui_vizia/components/lsb_zero.rs | 10 +- riscv/src/gui_vizia/components/reg_file.rs | 2 +- .../src/gui_vizia/components/sign_zero_ext.rs | 8 +- src/components/mem.rs | 26 +- src/gui_egui/components/mux.rs | 2 +- src/gui_egui/editor.rs | 24 +- src/gui_egui/editor_wire_mode.rs | 9 +- src/gui_vizia/gui.rs | 3 +- 20 files changed, 379 insertions(+), 260 deletions(-) create mode 100644 riscv/autosave.json diff --git a/riscv/autosave.json b/riscv/autosave.json new file mode 100644 index 00000000..a9fe3415 --- /dev/null +++ b/riscv/autosave.json @@ -0,0 +1 @@ +{"store":[{"type":"Constant","id":"pc_adder_c","pos":[480.0,700.0],"value":{"data":{"Data":4},"fmt":{"Hex":["_32",false]}}},{"type":"Wire","id":"pc_c","pos":[[480.0,700.0],[480.0,700.0],[520.0,700.0]],"input":{"id":"pc_adder_c","field":"out"}},{"type":"Constant","id":"zero_c","pos":[1360.0,440.0],"value":{"data":{"Data":0},"fmt":{"Hex":["_32",false]}}},{"type":"Wire","id":"zero_c_data","pos":[[1360.0,440.0],[1360.0,440.0],[1380.0,440.0]],"input":{"id":"zero_c","field":"out"}},{"type":"Register","id":"reg","pos":[460.0,740.0],"r_in":{"id":"pc_adder_mux","field":"out"}},{"type":"Register","id":"regfile_rd_reg","pos":[920.0,500.0],"r_in":{"id":"decoder","field":"regfile_rd"}},{"type":"Wire","id":"pc_to_branch_adder","pos":[[470.0,740.0],[480.0,740.0],[480.0,790.0],[480.0,790.0],[260.0,790.0],[260.0,790.0],[260.0,820.0],[260.0,820.0],[280.0,820.0]],"input":{"id":"reg","field":"out"}},{"type":"Wire","id":"pc_to_imem","pos":[[570.0,850.0],[570.0,850.0],[570.0,790.0],[570.0,790.0],[480.0,790.0]],"input":{"id":"reg","field":"out"}},{"type":"Register","id":"wb_reg","pos":[1120.0,220.0],"r_in":{"id":"wb_mux","field":"out"}},{"type":"Wire","id":"wb_reg_out","pos":[[1130.0,220.00002],[1130.0,220.00002],[1140.0,220.00002],[1142.5,220.00002],[1142.5,250.0]],"input":{"id":"wb_reg","field":"out"}},{"type":"InstrMem","width":200.0,"height":100.0,"id":"instr_mem","pos":[650.0,900.0],"bytes":{"0":14,"1":6,"2":84,"3":55,"4":124,"5":20,"6":4,"7":19,"8":80,"9":0,"10":4,"11":151,"12":9,"13":132,"14":132,"15":147,"16":0,"17":132,"18":160,"19":35,"20":80,"21":0,"22":5,"23":23,"24":9,"25":5,"26":5,"27":19,"28":80,"29":0,"30":5,"31":151,"32":255,"33":69,"34":133,"35":147,"36":2,"37":0,"38":0,"39":239,"40":1,"41":192,"42":0,"43":239,"44":1,"45":128,"46":0,"47":239,"48":1,"49":64,"50":0,"51":239,"52":1,"53":0,"54":0,"55":239,"56":0,"57":192,"58":0,"59":239,"60":5,"61":192,"62":0,"63":239,"64":0,"65":0,"66":0,"67":111,"68":80,"69":0,"70":4,"71":151,"72":5,"73":196,"74":132,"75":147,"76":0,"77":4,"78":164,"79":3,"80":0,"81":16,"82":2,"83":147,"84":0,"85":0,"86":3,"87":19,"88":0,"89":2,"90":140,"91":99,"92":0,"93":130,"94":243,"95":179,"96":0,"97":3,"98":148,"99":99,"100":0,"101":19,"102":3,"103":19,"104":0,"105":18,"106":146,"107":147,"108":254,"109":223,"110":240,"111":111,"112":1,"113":228,"114":19,"115":147,"116":0,"117":36,"118":94,"119":19,"120":1,"121":195,"122":227,"123":179,"124":64,"125":100,"126":94,"127":19,"128":0,"129":3,"130":132,"131":19,"132":1,"133":196,"134":68,"135":51,"136":0,"137":100,"138":68,"139":51,"140":0,"141":132,"142":160,"143":35,"144":0,"145":4,"146":5,"147":19,"148":0,"149":0,"150":128,"151":103,"152":0,"153":0,"154":0,"155":0,"156":0,"157":0,"158":0,"159":0,"160":0,"161":0,"162":0,"163":0,"164":0,"165":0,"166":0,"167":0,"168":0,"169":0,"170":0,"171":0,"172":0,"173":0,"174":0,"175":0,"176":0,"177":0,"178":0,"179":0,"180":0,"181":0,"182":0,"183":0,"184":0,"185":0,"186":0,"187":0,"188":0,"189":0,"190":0,"191":0,"192":0,"193":0,"194":0,"195":0,"196":0,"197":0,"198":0,"199":0,"200":0,"201":0,"202":0,"203":0,"204":0,"205":0,"206":0,"207":0,"208":0,"209":0,"210":0,"211":0,"212":0,"213":0,"214":0,"215":0,"216":0,"217":0,"218":0,"219":0,"220":0,"221":0,"222":0,"223":0,"224":0,"225":0,"226":0,"227":0,"228":0,"229":0,"230":0,"231":0,"232":0,"233":0,"234":0,"235":0,"236":0,"237":0,"238":0,"239":0,"240":0,"241":0,"242":0,"243":0,"244":0,"245":0,"246":0,"247":0,"248":0,"249":0,"250":0,"251":0,"252":0,"253":0,"254":0,"255":0,"256":0,"257":0,"258":0,"259":0,"260":0,"261":0,"262":0,"263":0,"264":0,"265":0,"266":0,"267":0,"268":0,"269":0,"270":0,"271":0,"272":0,"273":0,"274":0,"275":0,"276":0,"277":0,"278":0,"279":0,"280":0,"281":0,"282":0,"283":0,"284":0,"285":0,"286":0,"287":0,"288":0,"289":0,"290":0,"291":0,"292":0,"293":0,"294":0,"295":0,"296":0,"297":0,"298":0,"299":0,"300":0,"301":0,"302":0,"303":0,"304":0,"305":0,"306":0,"307":0,"308":0,"309":0,"310":0,"311":0,"312":0,"313":0,"314":0,"315":0,"316":0,"317":0,"318":0,"319":0,"320":0,"321":0,"322":0,"323":0,"324":0,"325":0,"326":0,"327":0,"328":0,"329":0,"330":0,"331":0,"332":0,"333":0,"334":0,"335":0,"336":0,"337":0,"338":0,"339":0,"340":0,"341":0,"342":0,"343":0,"344":0,"345":0,"346":0,"347":0,"348":0,"349":0,"350":0,"351":0,"352":0,"353":0,"354":0,"355":0,"356":0,"357":0,"358":0,"359":0,"360":0,"361":0,"362":0,"363":0,"364":0,"365":0,"366":0,"367":0,"368":0,"369":0,"370":0,"371":0,"372":0,"373":0,"374":0,"375":0,"376":0,"377":0,"378":0,"379":0,"380":0,"381":0,"382":0,"383":0,"384":0,"385":0,"386":0,"387":0,"388":0,"389":0,"390":0,"391":0,"392":0,"393":0,"394":0,"395":0,"396":0,"397":0,"398":0,"399":0,"400":0,"401":0,"402":0,"403":0,"404":0,"405":0,"406":0,"407":0,"408":0,"409":0,"410":0,"411":0,"412":0,"413":0,"414":0,"415":0,"416":0,"417":0,"418":0,"419":0,"420":0,"421":0,"422":0,"423":0,"424":0,"425":0,"426":0,"427":0,"428":0,"429":0,"430":0,"431":0,"432":0,"433":0,"434":0,"435":0,"436":0,"437":0,"438":0,"439":0,"440":0,"441":0,"442":0,"443":0,"444":0,"445":0,"446":0,"447":0,"448":0,"449":0,"450":0,"451":0,"452":0,"453":0,"454":0,"455":0,"456":0,"457":0,"458":0,"459":0,"460":0,"461":0,"462":0,"463":0,"464":0,"465":0,"466":0,"467":0,"468":0,"469":0,"470":0,"471":0,"472":0,"473":0,"474":0,"475":0,"476":0,"477":0,"478":0,"479":0,"480":0,"481":0,"482":0,"483":0,"484":0,"485":0,"486":0,"487":0,"488":0,"489":0,"490":0,"491":0,"492":0,"493":0,"494":0,"495":0,"496":0,"497":0,"498":0,"499":0,"500":0,"501":0,"502":0,"503":0,"504":0,"505":0,"506":0,"507":0,"508":0,"509":0,"510":0,"511":0,"512":0,"513":0,"514":0,"515":0,"516":0,"517":0,"518":0,"519":0,"520":0,"521":0,"522":0,"523":0,"524":0,"525":0,"526":0,"527":0,"528":0,"529":0,"530":0,"531":0,"532":0,"533":0,"534":0,"535":0,"536":0,"537":0,"538":0,"539":0,"540":0,"541":0,"542":0,"543":0,"544":0,"545":0,"546":0,"547":0,"548":0,"549":0,"550":0,"551":0,"552":0,"553":0,"554":0,"555":0,"556":0,"557":0,"558":0,"559":0,"560":0,"561":0,"562":0,"563":0,"564":0,"565":0,"566":0,"567":0,"568":0,"569":0,"570":0,"571":0,"572":0,"573":0,"574":0,"575":0,"576":0,"577":0,"578":0,"579":0,"580":0,"581":0,"582":0,"583":0,"584":0,"585":0,"586":0,"587":0,"588":0,"589":0,"590":0,"591":0,"592":0,"593":0,"594":0,"595":0,"596":0,"597":0,"598":0,"599":0,"600":0,"601":0,"602":0,"603":0,"604":0,"605":0,"606":0,"607":0,"608":0,"609":0,"610":0,"611":0,"612":0,"613":0,"614":0,"615":0,"616":0,"617":0,"618":0,"619":0,"620":0,"621":0,"622":0,"623":0,"624":0,"625":0,"626":0,"627":0,"628":0,"629":0,"630":0,"631":0,"632":0,"633":0,"634":0,"635":0,"636":0,"637":0,"638":0,"639":0,"640":0,"641":0,"642":0,"643":0,"644":0,"645":0,"646":0,"647":0,"648":0,"649":0,"650":0,"651":0,"652":0,"653":0,"654":0,"655":0,"656":0,"657":0,"658":0,"659":0,"660":0,"661":0,"662":0,"663":0,"664":0,"665":0,"666":0,"667":0,"668":0,"669":0,"670":0,"671":0,"672":0,"673":0,"674":0,"675":0,"676":0,"677":0,"678":0,"679":0,"680":0,"681":0,"682":0,"683":0,"684":0,"685":0,"686":0,"687":0,"688":0,"689":0,"690":0,"691":0,"692":0,"693":0,"694":0,"695":0,"696":0,"697":0,"698":0,"699":0,"700":0,"701":0,"702":0,"703":0,"704":0,"705":0,"706":0,"707":0,"708":0,"709":0,"710":0,"711":0,"712":0,"713":0,"714":0,"715":0,"716":0,"717":0,"718":0,"719":0,"720":0,"721":0,"722":0,"723":0,"724":0,"725":0,"726":0,"727":0,"728":0,"729":0,"730":0,"731":0,"732":0,"733":0,"734":0,"735":0,"736":0,"737":0,"738":0,"739":0,"740":0,"741":0,"742":0,"743":0,"744":0,"745":0,"746":0,"747":0,"748":0,"749":0,"750":0,"751":0,"752":0,"753":0,"754":0,"755":0,"756":0,"757":0,"758":0,"759":0,"760":0,"761":0,"762":0,"763":0,"764":0,"765":0,"766":0,"767":0,"768":0,"769":0,"770":0,"771":0,"772":0,"773":0,"774":0,"775":0,"776":0,"777":0,"778":0,"779":0,"780":0,"781":0,"782":0,"783":0,"784":0,"785":0,"786":0,"787":0,"788":0,"789":0,"790":0,"791":0,"792":0,"793":0,"794":0,"795":0,"796":0,"797":0,"798":0,"799":0,"800":0,"801":0,"802":0,"803":0,"804":0,"805":0,"806":0,"807":0,"808":0,"809":0,"810":0,"811":0,"812":0,"813":0,"814":0,"815":0,"816":0,"817":0,"818":0,"819":0,"820":0,"821":0,"822":0,"823":0,"824":0,"825":0,"826":0,"827":0,"828":0,"829":0,"830":0,"831":0,"832":0,"833":0,"834":0,"835":0,"836":0,"837":0,"838":0,"839":0,"840":0,"841":0,"842":0,"843":0,"844":0,"845":0,"846":0,"847":0,"848":0,"849":0,"850":0,"851":0,"852":0,"853":0,"854":0,"855":0,"856":0,"857":0,"858":0,"859":0,"860":0,"861":0,"862":0,"863":0,"864":0,"865":0,"866":0,"867":0,"868":0,"869":0,"870":0,"871":0,"872":0,"873":0,"874":0,"875":0,"876":0,"877":0,"878":0,"879":0,"880":0,"881":0,"882":0,"883":0,"884":0,"885":0,"886":0,"887":0,"888":0,"889":0,"890":0,"891":0,"892":0,"893":0,"894":0,"895":0,"896":0,"897":0,"898":0,"899":0,"900":0,"901":0,"902":0,"903":0,"904":0,"905":0,"906":0,"907":0,"908":0,"909":0,"910":0,"911":0,"912":0,"913":0,"914":0,"915":0,"916":0,"917":0,"918":0,"919":0,"920":0,"921":0,"922":0,"923":0,"924":0,"925":0,"926":0,"927":0,"928":0,"929":0,"930":0,"931":0,"932":0,"933":0,"934":0,"935":0,"936":0,"937":0,"938":0,"939":0,"940":0,"941":0,"942":0,"943":0,"944":0,"945":0,"946":0,"947":0,"948":0,"949":0,"950":0,"951":0,"952":0,"953":0,"954":0,"955":0,"956":0,"957":0,"958":0,"959":0,"960":0,"961":0,"962":0,"963":0,"964":0,"965":0,"966":0,"967":0,"968":0,"969":0,"970":0,"971":0,"972":0,"973":0,"974":0,"975":0,"976":0,"977":0,"978":0,"979":0,"980":0,"981":0,"982":0,"983":0,"984":0,"985":0,"986":0,"987":0,"988":0,"989":0,"990":0,"991":0,"992":0,"993":0,"994":0,"995":0,"996":0,"997":0,"998":0,"999":0,"1000":0,"1001":0,"1002":0,"1003":0,"1004":0,"1005":0,"1006":0,"1007":0,"1008":0,"1009":0,"1010":0,"1011":0,"1012":0,"1013":0,"1014":0,"1015":0,"1016":0,"1017":0,"1018":0,"1019":0,"1020":0,"1021":0,"1022":0,"1023":0,"1024":0,"1025":0,"1026":0,"1027":0,"1028":0,"1029":0,"1030":0,"1031":0,"1032":0,"1033":0,"1034":0,"1035":0,"1036":0,"1037":0,"1038":0,"1039":0,"1040":0,"1041":0,"1042":0,"1043":0,"1044":0,"1045":0,"1046":0,"1047":0,"1048":0,"1049":0,"1050":0,"1051":0,"1052":0,"1053":0,"1054":0,"1055":0,"1056":0,"1057":0,"1058":0,"1059":0,"1060":0,"1061":0,"1062":0,"1063":0,"1064":0,"1065":0,"1066":0,"1067":0,"1068":0,"1069":0,"1070":0,"1071":0,"1072":0,"1073":0,"1074":0,"1075":0,"1076":0,"1077":0,"1078":0,"1079":0,"1080":0,"1081":0,"1082":0,"1083":0,"1084":0,"1085":0,"1086":0,"1087":0,"1088":0,"1089":0,"1090":0,"1091":0,"1092":0,"1093":0,"1094":0,"1095":0,"1096":0,"1097":0,"1098":0,"1099":0,"1100":0,"1101":0,"1102":0,"1103":0,"1104":0,"1105":0,"1106":0,"1107":0,"1108":0,"1109":0,"1110":0,"1111":0,"1112":0,"1113":0,"1114":0,"1115":0,"1116":0,"1117":0,"1118":0,"1119":0,"1120":0,"1121":0,"1122":0,"1123":0,"1124":0,"1125":0,"1126":0,"1127":0,"1128":0,"1129":0,"1130":0,"1131":0,"1132":0,"1133":0,"1134":0,"1135":0,"1136":0,"1137":0,"1138":0,"1139":0,"1140":0,"1141":0,"1142":0,"1143":0,"1144":0,"1145":0,"1146":0,"1147":0,"1148":0,"1149":0,"1150":0,"1151":0,"1152":0,"1153":0,"1154":0,"1155":0,"1156":0,"1157":0,"1158":0,"1159":0,"1160":0,"1161":0,"1162":0,"1163":0,"1164":0,"1165":0,"1166":0,"1167":0,"1168":0,"1169":0,"1170":0,"1171":0,"1172":0,"1173":0,"1174":0,"1175":0,"1176":0,"1177":0,"1178":0,"1179":0,"1180":0,"1181":0,"1182":0,"1183":0,"1184":0,"1185":0,"1186":0,"1187":0,"1188":0,"1189":0,"1190":0,"1191":0,"1192":0,"1193":0,"1194":0,"1195":0,"1196":0,"1197":0,"1198":0,"1199":0,"1200":0,"1201":0,"1202":0,"1203":0,"1204":0,"1205":0,"1206":0,"1207":0,"1208":0,"1209":0,"1210":0,"1211":0,"1212":0,"1213":0,"1214":0,"1215":0,"1216":0,"1217":0,"1218":0,"1219":0,"1220":0,"1221":0,"1222":0,"1223":0,"1224":0,"1225":0,"1226":0,"1227":0,"1228":0,"1229":0,"1230":0,"1231":0,"1232":0,"1233":0,"1234":0,"1235":0,"1236":0,"1237":0,"1238":0,"1239":0,"1240":0,"1241":0,"1242":0,"1243":0,"1244":0,"1245":0,"1246":0,"1247":0,"1248":0,"1249":0,"1250":0,"1251":0,"1252":0,"1253":0,"1254":0,"1255":0,"1256":0,"1257":0,"1258":0,"1259":0,"1260":0,"1261":0,"1262":0,"1263":0,"1264":0,"1265":0,"1266":0,"1267":0,"1268":0,"1269":0,"1270":0,"1271":0,"1272":0,"1273":0,"1274":0,"1275":0,"1276":0,"1277":0,"1278":0,"1279":0},"pc":{"id":"reg","field":"out"},"range":{"start":0,"end":1280},"breakpoints":[8]},{"type":"Wire","id":"insn","pos":[[710.0,850.0],[710.0,850.0],[710.0,820.0],[710.0,820.0],[740.0,820.0],[740.0,820.0],[740.0,800.0]],"input":{"id":"instr_mem","field":"instruction"}},{"type":"Decoder","width":30.0,"height":600.0,"id":"decoder","pos":[740.0,500.0],"instruction":{"id":"instr_mem","field":"instruction"}},{"type":"Wire","id":"szext_sel","pos":[[755.0,469.99997],[755.0,469.99997],[860.0,469.99997],[860.0,469.99997],[860.0,760.0],[860.0,760.0],[1080.0,760.0],[1080.0,760.0],[1080.0,785.0]],"input":{"id":"decoder","field":"sign_zero_ext_sel"}},{"type":"Sext","id":"branch_imm_sext","pos":[140.0,900.0],"sext_in":{"id":"decoder","field":"branch_imm"},"in_size":13,"out_size":32},{"type":"Wire","id":"w1111111","pos":[[755.0,440.0],[755.0,440.0],[860.0,440.0],[860.0,440.0],[860.0,220.00002],[860.0,220.0],[990.0,220.0]],"input":{"id":"decoder","field":"regfile_we"}},{"type":"Wire","id":"jalr_imm","pos":[[755.0,800.0],[760.0,800.0],[760.0,960.0],[760.0,960.0],[90.0,960.0],[90.0,960.0],[90.0,760.0],[90.0,760.0],[100.0,760.0]],"input":{"id":"decoder","field":"jalr_imm"}},{"type":"Wire","id":"rs2","pos":[[755.0,410.0],[755.0,410.0],[890.0,410.0],[890.0,410.0],[890.0,600.0],[890.0,600.0],[955.0,600.0]],"input":{"id":"decoder","field":"regfile_rs2"}},{"type":"Wire","id":"rd","pos":[[755.0,350.0],[755.0,350.0],[860.0,350.0],[870.0,350.0],[870.0,499.99997],[870.0,500.0],[910.0,500.0]],"input":{"id":"decoder","field":"regfile_rd"}},{"type":"Wire","id":"branch_imm","pos":[[755.0,710.0],[755.0,710.0],[790.0,710.0],[790.0,710.0],[790.0,1000.00006],[790.0,1000.00006],[80.0,1000.00006],[80.0,1000.00006],[80.0,900.0],[80.0,900.0],[100.0,900.0]],"input":{"id":"decoder","field":"branch_imm"}},{"type":"Wire","id":"imm_a_data","pos":[[755.0,530.0],[755.0,530.0],[840.0,530.0],[840.0,530.0],[840.0,170.0],[840.0,170.0],[1350.0,170.0],[1350.0,170.0],[1350.0,420.0],[1350.0,420.0],[1380.0,420.0]],"input":{"id":"decoder","field":"imm_a_mux_data"}},{"type":"Wire","id":"data_mem_ctrl","pos":[[755.0,620.0],[755.0,620.0],[820.0,620.0],[820.0,620.0],[820.0,840.0],[820.0,840.0],[1520.0,840.0],[1520.0,840.0],[1520.0,850.0]],"input":{"id":"decoder","field":"data_mem_ctrl"}},{"type":"SZExt","height":30.0,"width":60.0,"id":"imm_szext","pos":[1080.0,800.0],"data_i":{"id":"decoder","field":"sign_zero_ext_data"},"sel_i":{"id":"decoder","field":"sign_zero_ext_sel"}},{"type":"Wire","id":"imm_szext_data","pos":[[1110.0,800.0],[1110.0,800.0],[1260.0,800.0],[1260.0,800.0],[1260.0,610.0],[1260.0,610.0],[1380.0,610.0]],"input":{"id":"imm_szext","field":"out"}},{"type":"Wire","id":"data_mem_size","pos":[[755.0,560.0],[755.0,560.0],[840.0,560.0],[840.0,560.0],[840.0,820.0],[840.0,820.0],[1560.0,820.0],[1560.0,820.0],[1560.0,850.0]],"input":{"id":"decoder","field":"data_mem_size"}},{"type":"Wire","id":"rs1","pos":[[755.0,380.0],[755.0,380.0],[930.0,380.0],[930.0,380.0],[930.0,400.0],[930.0,400.0],[955.0,400.0]],"input":{"id":"decoder","field":"regfile_rs1"}},{"type":"Sext","id":"jalr_se","pos":[140.0,760.0],"sext_in":{"id":"decoder","field":"jalr_imm"},"in_size":12,"out_size":32},{"type":"Wire","id":"jalr_imm_ext","pos":[[180.0,760.0],[180.0,760.0],[260.0,760.0]],"input":{"id":"jalr_se","field":"out"}},{"type":"Wire","id":"pc_to_alu","pos":[[480.0,790.0],[480.0,790.0],[530.0,790.0],[530.0,790.0],[530.0,1040.0],[530.0,1040.0],[1360.0,1040.0],[1360.0,1040.0],[1360.0,650.0],[1360.0,650.0],[1380.0,650.0]],"input":{"id":"reg","field":"out"}},{"type":"Wire","id":"branch_imm_ext","pos":[[180.0,900.0],[180.0,900.0],[200.0,900.0],[200.0,900.0],[200.0,870.0],[200.0,870.0],[220.0,870.0]],"input":{"id":"branch_imm_sext","field":"out"}},{"type":"Sext","id":"jal_imm_sext","pos":[140.0,820.0],"sext_in":{"id":"decoder","field":"big_imm"},"in_size":21,"out_size":32},{"type":"Mux","id":"branch_adder_mux","pos":[240.0,860.0],"select":{"id":"decoder","field":"pc_imm_sel"},"m_in":[{"id":"jal_imm_sext","field":"out"},{"id":"branch_imm_sext","field":"out"}]},{"type":"Wire","id":"branch_jal_imm","pos":[[260.0,860.0],[260.0,860.0],[280.0,860.0]],"input":{"id":"branch_adder_mux","field":"out"}},{"type":"Wire","id":"jal_imm_ext","pos":[[180.0,820.0],[180.0,820.0],[200.0,820.0],[200.0,820.0],[200.0,850.0],[200.0,850.0],[220.0,850.0]],"input":{"id":"jal_imm_sext","field":"out"}},{"type":"Register","id":"regfile_we_reg","pos":[1000.0,220.0],"r_in":{"id":"decoder","field":"regfile_we"}},{"type":"RegFile","id":"reg_file","pos":[1080.0,500.0],"width":250.0,"height":500.0,"read_addr1":{"id":"decoder","field":"regfile_rs1"},"read_addr2":{"id":"decoder","field":"regfile_rs2"},"write_data":{"id":"wb_reg","field":"out"},"write_addr":{"id":"regfile_rd_reg","field":"out"},"write_enable":{"id":"regfile_we_reg","field":"out"},"registers":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"history":[]},{"type":"Wire","id":"w","pos":[[1230.0,590.0],[1230.0,590.0],[1230.0,810.0],[1230.0,810.0],[1500.0,810.0],[1500.0,810.0],[1500.0,850.0]],"input":{"id":"reg_file","field":"reg_b"}},{"type":"BranchLogic","width":60.0,"height":60.0,"id":"branch_logic","pos":[1300.0,500.0],"rs1":{"id":"reg_file","field":"reg_a"},"rs2":{"id":"reg_file","field":"reg_b"},"ctrl":{"id":"decoder","field":"branch_logic_ctl"},"enable":{"id":"decoder","field":"branch_logic_enable"}},{"type":"Mux","id":"alu_operand_a_mux","pos":[1400.0,420.0],"select":{"id":"decoder","field":"alu_operand_a_sel"},"m_in":[{"id":"reg_file","field":"reg_a"},{"id":"decoder","field":"imm_a_mux_data"},{"id":"zero_c","field":"out"}]},{"type":"Wire","id":"alu_operand_a","pos":[[1420.0,420.0],[1420.0,420.0],[1440.0,420.0],[1440.0,420.0],[1440.0,499.99997],[1440.0,500.0],[1460.0,500.0]],"input":{"id":"alu_operand_a_mux","field":"out"}},{"type":"Wire","id":"rs2_data_blu","pos":[[1270.0,524.0],[1270.0,520.0],[1230.0,520.0],[1230.0,520.0],[1230.0,590.0],[1230.0,590.0],[1205.0,590.0]],"input":{"id":"reg_file","field":"reg_b"}},{"type":"Add","id":"jalr_adder","pos":[280.0,740.0],"a_in":{"id":"reg_file","field":"reg_a"},"b_in":{"id":"jalr_se","field":"out"}},{"type":"LSBZero","height":10.0,"width":10.0,"id":"jalr_stripper","pos":[320.0,740.0],"data_i":{"id":"jalr_adder","field":"out"}},{"type":"Wire","id":"jalr_addr","pos":[[325.0,740.0],[325.0,740.0],[380.0,740.0]],"input":{"id":"jalr_stripper","field":"out"}},{"type":"Wire","id":"rs2_data","pos":[[1205.0,600.0],[1205.0,590.0],[1380.0,590.0]],"input":{"id":"reg_file","field":"reg_b"}},{"type":"Wire","id":"w1","pos":[[1010.0,220.00002],[1017.5,220.00002],[1017.5,250.0]],"input":{"id":"regfile_we_reg","field":"out"}},{"type":"Wire","id":"jalr_addr_pre_strip","pos":[[300.0,740.0],[300.0,740.0],[315.0,740.0]],"input":{"id":"jalr_adder","field":"out"}},{"type":"Wire","id":"w111","pos":[[1142.5,250.00002],[1142.5,250.00002],[1142.5,220.00002]],"input":{"id":"wb_reg","field":"out"}},{"type":"Wire","id":"data_mem_sext","pos":[[755.0,590.0],[755.0,590.0],[830.0,590.0],[830.0,590.0],[830.0,830.0],[830.0,830.0],[1530.0,830.0],[1530.0,830.0],[1530.0,850.0]],"input":{"id":"decoder","field":"data_se"}},{"type":"Wire","id":"pc","pos":[[470.0,740.0],[470.0,740.0],[520.0,740.0]],"input":{"id":"reg","field":"out"}},{"type":"Wire","id":"w11111111","pos":[[1205.0,400.0],[1205.0,400.0],[1380.0,400.0]],"input":{"id":"reg_file","field":"reg_a"}},{"type":"Wire","id":"rd_reg_o","pos":[[930.0,499.99997],[930.0,500.0],[955.0,500.0]],"input":{"id":"regfile_rd_reg","field":"out"}},{"type":"Wire","id":"szext_data","pos":[[755.0,499.99997],[755.0,499.99997],[850.0,499.99997],[850.0,499.99997],[850.0,800.0],[850.0,800.0],[1050.0,800.0]],"input":{"id":"decoder","field":"sign_zero_ext_data"}},{"type":"Add","id":"pc_adder","pos":[540.0,720.0],"a_in":{"id":"pc_adder_c","field":"out"},"b_in":{"id":"reg","field":"out"}},{"type":"Mux","id":"alu_operand_b_mux","pos":[1400.0,620.0],"select":{"id":"decoder","field":"alu_operand_b_sel"},"m_in":[{"id":"reg_file","field":"reg_b"},{"id":"imm_szext","field":"out"},{"id":"pc_adder","field":"out"},{"id":"reg","field":"out"}]},{"type":"Wire","id":"alu_operand_b","pos":[[1420.0,620.0],[1420.0,620.0],[1440.0,620.0],[1440.0,620.0],[1440.0,540.0],[1440.0,540.0],[1460.0,540.0]],"input":{"id":"alu_operand_b_mux","field":"out"}},{"type":"ALU","id":"alu","pos":[1480.0,520.0],"operator_i":{"id":"decoder","field":"alu_operator"},"operand_a_i":{"id":"alu_operand_a_mux","field":"out"},"operand_b_i":{"id":"alu_operand_b_mux","field":"out"}},{"type":"Wire","id":"alu_result","pos":[[1500.0,520.0],[1500.0,520.0],[1510.0,520.0],[1510.0,520.0],[1510.0,509.99997],[1510.0,510.0],[1560.0,510.0]],"input":{"id":"alu","field":"result_o"}},{"type":"Wire","id":"data_mem_addr","pos":[[1500.0,520.0],[1510.0,520.0],[1510.0,850.0]],"input":{"id":"alu","field":"result_o"}},{"type":"Mem","id":"data_memory","pos":[1540.0,900.0],"width":100.0,"height":100.0,"big_endian":false,"data":{"id":"reg_file","field":"reg_b"},"addr":{"id":"alu","field":"result_o"},"ctrl":{"id":"decoder","field":"data_mem_ctrl"},"sext":{"id":"decoder","field":"data_se"},"size":{"id":"decoder","field":"data_mem_size"},"memory":{"1342177280":159,"1342177281":221,"1342177282":145,"1342177283":88,"1342177284":133,"1342177285":113,"1342177286":88,"1342177287":8,"1342177288":172,"1342177289":115,"1342177290":50,"1342177291":58,"1342177292":0,"1342177293":0,"1342177294":0,"1342177295":0,"1342177296":0,"1342177297":0,"1342177298":0,"1342177299":0,"1342177300":0,"1342177301":0,"1342177302":0,"1342177303":0,"1342177304":0,"1342177305":0,"1342177306":0,"1342177307":0,"1342177308":0,"1342177309":0,"1342177310":0,"1342177311":0,"1342177312":0,"1342177313":0,"1342177314":0,"1342177315":0,"1342177316":0,"1342177317":0,"1342177318":0,"1342177319":0,"1342177320":0,"1342177321":0,"1342177322":0,"1342177323":0,"1342177324":0,"1342177325":0,"1342177326":0,"1342177327":0,"1342177328":0,"1342177329":0,"1342177330":0,"1342177331":0,"1342177332":0,"1342177333":0,"1342177334":0,"1342177335":0,"1342177336":0,"1342177337":0,"1342177338":0,"1342177339":0,"1342177340":0,"1342177341":0,"1342177342":0,"1342177343":0,"1342177344":0,"1342177345":0,"1342177346":0,"1342177347":0,"1342177348":0,"1342177349":0,"1342177350":0,"1342177351":0,"1342177352":0,"1342177353":0,"1342177354":0,"1342177355":0,"1342177356":0,"1342177357":0,"1342177358":0,"1342177359":0,"1342177360":0,"1342177361":0,"1342177362":0,"1342177363":0,"1342177364":0,"1342177365":0,"1342177366":0,"1342177367":0,"1342177368":0,"1342177369":0,"1342177370":0,"1342177371":0,"1342177372":0,"1342177373":0,"1342177374":0,"1342177375":0,"1342177376":0,"1342177377":0,"1342177378":0,"1342177379":0,"1342177380":0,"1342177381":0,"1342177382":0,"1342177383":0,"1342177384":0,"1342177385":0,"1342177386":0,"1342177387":0,"1342177388":0,"1342177389":0,"1342177390":0,"1342177391":0,"1342177392":0,"1342177393":0,"1342177394":0,"1342177395":0,"1342177396":0,"1342177397":0,"1342177398":0,"1342177399":0,"1342177400":0,"1342177401":0,"1342177402":0,"1342177403":0,"1342177404":0,"1342177405":0,"1342177406":0,"1342177407":0,"1342177408":0,"1342177409":0,"1342177410":0,"1342177411":0,"1342177412":0,"1342177413":0,"1342177414":0,"1342177415":0,"1342177416":0,"1342177417":0,"1342177418":0,"1342177419":0,"1342177420":0,"1342177421":0,"1342177422":0,"1342177423":0,"1342177424":0,"1342177425":0,"1342177426":0,"1342177427":0,"1342177428":0,"1342177429":0,"1342177430":0,"1342177431":0,"1342177432":0,"1342177433":0,"1342177434":0,"1342177435":0,"1342177436":0,"1342177437":0,"1342177438":0,"1342177439":0,"1342177440":0,"1342177441":0,"1342177442":0,"1342177443":0,"1342177444":1,"1342177445":94,"1342177446":122,"1342177447":71,"1342177448":46,"1342177449":248,"1342177450":78,"1342177451":187,"1342177452":23,"1342177453":122,"1342177454":141,"1342177455":180,"1342177456":27,"1342177457":114,"1342177458":47,"1342177459":249,"1342177460":93,"1342177461":199,"1342177462":207,"1342177463":240,"1342177464":93,"1342177465":201,"1342177466":222,"1342177467":166,"1342177468":29,"1342177469":160,"1342177470":193,"1342177471":90,"1342177472":228,"1342177473":194,"1342177474":54,"1342177475":162,"1342177476":61,"1342177477":22,"1342177478":176,"1342177479":208,"1342177480":31,"1342177481":57,"1342177482":120,"1342177483":66,"1342177484":170,"1342177485":224,"1342177486":210,"1342177487":186,"1342177488":17,"1342177489":36,"1342177490":102,"1342177491":116,"1342177492":8,"1342177493":69,"1342177494":49,"1342177495":127,"1342177496":213,"1342177497":81,"1342177498":45,"1342177499":173,"1342177500":182,"1342177501":24,"1342177502":73,"1342177503":119,"1342177504":210,"1342177505":147,"1342177506":165,"1342177507":62,"1342177508":125,"1342177509":156,"1342177510":39,"1342177511":22,"1342177512":217,"1342177513":23,"1342177514":234,"1342177515":230,"1342177516":216,"1342177517":133,"1342177518":35,"1342177519":132,"1342177520":40,"1342177521":110,"1342177522":70,"1342177523":249,"1342177524":206,"1342177525":86,"1342177526":96,"1342177527":41,"1342177528":206,"1342177529":254,"1342177530":125,"1342177531":175,"1342177532":98,"1342177533":215,"1342177534":38,"1342177535":212,"1342177536":13,"1342177537":186,"1342177538":235,"1342177539":45,"1342177540":149,"1342177541":245,"1342177542":124,"1342177543":96,"1342177544":237,"1342177545":81,"1342177546":81,"1342177547":65,"1342177548":41,"1342177549":183,"1342177550":125,"1342177551":15,"1342177552":159,"1342177553":123,"1342177554":141,"1342177555":12,"1342177556":69,"1342177557":168,"1342177558":57,"1342177559":90,"1342177560":254,"1342177561":173,"1342177562":43,"1342177563":114,"1342177564":136,"1342177565":61,"1342177566":67,"1342177567":76,"1342177568":237,"1342177569":141,"1342177570":223,"1342177571":96,"1342177572":229,"1342177573":30,"1342177574":101,"1342177575":228,"1342177576":25,"1342177577":191,"1342177578":107,"1342177579":177,"1342177580":254,"1342177581":181,"1342177582":5,"1342177583":236,"1342177584":102,"1342177585":42,"1342177586":162,"1342177587":60,"1342177588":246,"1342177589":130,"1342177590":124,"1342177591":248,"1342177592":209,"1342177593":220,"1342177594":122,"1342177595":92,"1342177596":79,"1342177597":165,"1342177598":176,"1342177599":102,"1342177600":125,"1342177601":221,"1342177602":37,"1342177603":164,"1342177604":168,"1342177605":186,"1342177606":142,"1342177607":138,"1342177608":114,"1342177609":132,"1342177610":98,"1342177611":39,"1342177612":248,"1342177613":246,"1342177614":54,"1342177615":251,"1342177616":43,"1342177617":56,"1342177618":154,"1342177619":156,"1342177620":228,"1342177621":3,"1342177622":139,"1342177623":246,"1342177624":110,"1342177625":22,"1342177626":152,"1342177627":119,"1342177628":173,"1342177629":2,"1342177630":129,"1342177631":50,"1342177632":132,"1342177633":219,"1342177634":254,"1342177635":140,"1342177636":36,"1342177637":55,"1342177638":98,"1342177639":255,"1342177640":89,"1342177641":200,"1342177642":248,"1342177643":12,"1342177644":182,"1342177645":224,"1342177646":219,"1342177647":75,"1342177648":237,"1342177649":184,"1342177650":202,"1342177651":183,"1342177652":205,"1342177653":75,"1342177654":57,"1342177655":246,"1342177656":175,"1342177657":38,"1342177658":55,"1342177659":65,"1342177660":24,"1342177661":217,"1342177662":150,"1342177663":95,"1342177664":26,"1342177665":177,"1342177666":240,"1342177667":55,"1342177668":91,"1342177669":69,"1342177670":135,"1342177671":146,"1342177672":201,"1342177673":77,"1342177674":150,"1342177675":13,"1342177676":212,"1342177677":92,"1342177678":237,"1342177679":234,"1342177680":33,"1342177681":96,"1342177682":172,"1342177683":163,"1342177684":147,"1342177685":199,"1342177686":119,"1342177687":102,"1342177688":45,"1342177689":102,"1342177690":225,"1342177691":5,"1342177692":159,"1342177693":247,"1342177694":77,"1342177695":79,"1342177696":109,"1342177697":194,"1342177698":47,"1342177699":33,"1342177700":107,"1342177701":3,"1342177702":214,"1342177703":137,"1342177704":95,"1342177705":196,"1342177706":141,"1342177707":224,"1342177708":17,"1342177709":56,"1342177710":240,"1342177711":0,"1342177712":204,"1342177713":181,"1342177714":142,"1342177715":87,"1342177716":249,"1342177717":200,"1342177718":226,"1342177719":0,"1342177720":122,"1342177721":178,"1342177722":110,"1342177723":60,"1342177724":198,"1342177725":29,"1342177726":203,"1342177727":62,"1342177728":106,"1342177729":239,"1342177730":204,"1342177731":176,"1342177732":122,"1342177733":69,"1342177734":47,"1342177735":5,"1342177736":165,"1342177737":207,"1342177738":7,"1342177739":49,"1342177740":162,"1342177741":73,"1342177742":56,"1342177743":63,"1342177744":98,"1342177745":143,"1342177746":229,"1342177747":52,"1342177748":202,"1342177749":216,"1342177750":23,"1342177751":16,"1342177752":127,"1342177753":97,"1342177754":98,"1342177755":118,"1342177756":60,"1342177757":225,"1342177758":131,"1342177759":8,"1342177760":237,"1342177761":72,"1342177762":87,"1342177763":255,"1342177764":209,"1342177765":229,"1342177766":177,"1342177767":209,"1342177768":194,"1342177769":232,"1342177770":77,"1342177771":194,"1342177772":170,"1342177773":0,"1342177774":55,"1342177775":66,"1342177776":175,"1342177777":99,"1342177778":116,"1342177779":136,"1342177780":131,"1342177781":26,"1342177782":252,"1342177783":72,"1342177784":40,"1342177785":122,"1342177786":105,"1342177787":160,"1342177788":110,"1342177789":4,"1342177790":84,"1342177791":110,"1342177792":19,"1342177793":223,"1342177794":250,"1342177795":7,"1342177796":50,"1342177797":50,"1342177798":251,"1342177799":16,"1342177800":214,"1342177801":158,"1342177802":46,"1342177803":9,"1342177804":53,"1342177805":93,"1342177806":141,"1342177807":199,"1342177808":239,"1342177809":144,"1342177810":35,"1342177811":1,"1342177812":154,"1342177813":137,"1342177814":172,"1342177815":21,"1342177816":150,"1342177817":125,"1342177818":201,"1342177819":0,"1342177820":8,"1342177821":220,"1342177822":43,"1342177823":28,"1342177824":107,"1342177825":91,"1342177826":230,"1342177827":144,"1342177828":137,"1342177829":75,"1342177830":14,"1342177831":2,"1342177832":226,"1342177833":106,"1342177834":249,"1342177835":175,"1342177836":166,"1342177837":253,"1342177838":59,"1342177839":35,"1342177840":252,"1342177841":242,"1342177842":19,"1342177843":229,"1342177844":133,"1342177845":33,"1342177846":118,"1342177847":8,"1342177848":127,"1342177849":211,"1342177850":190,"1342177851":139,"1342177852":162,"1342177853":231,"1342177854":87,"1342177855":251,"1342177856":55,"1342177857":23,"1342177858":163,"1342177859":65,"1342177860":133,"1342177861":238,"1342177862":66,"1342177863":109,"1342177864":57,"1342177865":75,"1342177866":184,"1342177867":86,"1342177868":18,"1342177869":172,"1342177870":152,"1342177871":195,"1342177872":236,"1342177873":125,"1342177874":74,"1342177875":181,"1342177876":114,"1342177877":27,"1342177878":105,"1342177879":137,"1342177880":48,"1342177881":227,"1342177882":99,"1342177883":96,"1342177884":170,"1342177885":1,"1342177886":132,"1342177887":3,"1342177888":158,"1342177889":230,"1342177890":17,"1342177891":150,"1342177892":168,"1342177893":105,"1342177894":122,"1342177895":220,"1342177896":81,"1342177897":233,"1342177898":214,"1342177899":90,"1342177900":17,"1342177901":2,"1342177902":53,"1342177903":148,"1342177904":196,"1342177905":196,"1342177906":179,"1342177907":107,"1342177908":218,"1342177909":128,"1342177910":191,"1342177911":122,"1342177912":189,"1342177913":90,"1342177914":100,"1342177915":94,"1342177916":24,"1342177917":206,"1342177918":169,"1342177919":24,"1342177920":167,"1342177921":35,"1342177922":221,"1342177923":168,"1342177924":1,"1342177925":38,"1342177926":192,"1342177927":94,"1342177928":41,"1342177929":98,"1342177930":212,"1342177931":138,"1342177932":213,"1342177933":247,"1342177934":211,"1342177935":18,"1342177936":184,"1342177937":148,"1342177938":112,"1342177939":65,"1342177940":124,"1342177941":30,"1342177942":46,"1342177943":154,"1342177944":148,"1342177945":94,"1342177946":234,"1342177947":195,"1342177948":113,"1342177949":16,"1342177950":251,"1342177951":28,"1342177952":167,"1342177953":188,"1342177954":114,"1342177955":204,"1342177956":223,"1342177957":71,"1342177958":223,"1342177959":187,"1342177960":9,"1342177961":161,"1342177962":198,"1342177963":200,"1342177964":194,"1342177965":228,"1342177966":16,"1342177967":97,"1342177968":0,"1342177969":0,"1342177970":0,"1342177971":0,"1342177972":0,"1342177973":0,"1342177974":0,"1342177975":0,"1342177976":0,"1342177977":0,"1342177978":0,"1342177979":0,"1342177980":0,"1342177981":0,"1342177982":0,"1342177983":0,"1342177984":0,"1342177985":0,"1342177986":0,"1342177987":0,"1342177988":0,"1342177989":0,"1342177990":0,"1342177991":0,"1342177992":0,"1342177993":0,"1342177994":0,"1342177995":0,"1342177996":0,"1342177997":0,"1342177998":0,"1342177999":0,"1342178000":0,"1342178001":0,"1342178002":0,"1342178003":0,"1342178004":0,"1342178005":0,"1342178006":0,"1342178007":0,"1342178008":0,"1342178009":0,"1342178010":0,"1342178011":0,"1342178012":0,"1342178013":0,"1342178014":0,"1342178015":0,"1342178016":0,"1342178017":0,"1342178018":0,"1342178019":0,"1342178020":0,"1342178021":0,"1342178022":0,"1342178023":0,"1342178024":0,"1342178025":0,"1342178026":0,"1342178027":0,"1342178028":0,"1342178029":0,"1342178030":0,"1342178031":0,"1342178032":0,"1342178033":0,"1342178034":0,"1342178035":0,"1342178036":0,"1342178037":0,"1342178038":0,"1342178039":0,"1342178040":0,"1342178041":0,"1342178042":0,"1342178043":0,"1342178044":0,"1342178045":0,"1342178046":0,"1342178047":0,"1342178048":0,"1342178049":0,"1342178050":0,"1342178051":0,"1342178052":0,"1342178053":0,"1342178054":0,"1342178055":0,"1342178056":0,"1342178057":0,"1342178058":0,"1342178059":0,"1342178060":0,"1342178061":0,"1342178062":0,"1342178063":0,"1342178064":0,"1342178065":0,"1342178066":0,"1342178067":0,"1342178068":0,"1342178069":0,"1342178070":0,"1342178071":0,"1342178072":0,"1342178073":0,"1342178074":0,"1342178075":0,"1342178076":0,"1342178077":0,"1342178078":0,"1342178079":0,"1342178080":0,"1342178081":0,"1342178082":0,"1342178083":0,"1342178084":0,"1342178085":0,"1342178086":0,"1342178087":0,"1342178088":0,"1342178089":0,"1342178090":0,"1342178091":0,"1342178092":0,"1342178093":0,"1342178094":0,"1342178095":0,"1342178096":0,"1342178097":0,"1342178098":0,"1342178099":0,"1342178100":0,"1342178101":0,"1342178102":0,"1342178103":0,"1342178104":0,"1342178105":0,"1342178106":0,"1342178107":0,"1342178108":0,"1342178109":0,"1342178110":0,"1342178111":0,"1342178112":0,"1342178113":0,"1342178114":0,"1342178115":0,"1342178116":0,"1342178117":0,"1342178118":0,"1342178119":0,"1342178120":0,"1342178121":0,"1342178122":0,"1342178123":0,"1342178124":0,"1342178125":0,"1342178126":0,"1342178127":0,"1342178128":0,"1342178129":0,"1342178130":0,"1342178131":0,"1342178132":0,"1342178133":0,"1342178134":0,"1342178135":0,"1342178136":0,"1342178137":0,"1342178138":0,"1342178139":0,"1342178140":0,"1342178141":0,"1342178142":0,"1342178143":0,"1342178144":0,"1342178145":0,"1342178146":0,"1342178147":0,"1342178148":0,"1342178149":0,"1342178150":0,"1342178151":0,"1342178152":0,"1342178153":0,"1342178154":0,"1342178155":0,"1342178156":0,"1342178157":0,"1342178158":0,"1342178159":0,"1342178160":0,"1342178161":0,"1342178162":0,"1342178163":0,"1342178164":0,"1342178165":0,"1342178166":0,"1342178167":0,"1342178168":0,"1342178169":0,"1342178170":0,"1342178171":0,"1342178172":0,"1342178173":0,"1342178174":0,"1342178175":0,"1342178176":0,"1342178177":0,"1342178178":0,"1342178179":0,"1342178180":0,"1342178181":0,"1342178182":0,"1342178183":0,"1342178184":0,"1342178185":0,"1342178186":0,"1342178187":0,"1342178188":0,"1342178189":0,"1342178190":0,"1342178191":0,"1342178192":0,"1342178193":0,"1342178194":0,"1342178195":0,"1342178196":0,"1342178197":0,"1342178198":0,"1342178199":0,"1342178200":0,"1342178201":0,"1342178202":0,"1342178203":0,"1342178204":0,"1342178205":0,"1342178206":0,"1342178207":0,"1342178208":0,"1342178209":0,"1342178210":0,"1342178211":0,"1342178212":0,"1342178213":0,"1342178214":0,"1342178215":0,"1342178216":0,"1342178217":0,"1342178218":0,"1342178219":0,"1342178220":0,"1342178221":0,"1342178222":0,"1342178223":0,"1342178224":0,"1342178225":0,"1342178226":0,"1342178227":0,"1342178228":0,"1342178229":0,"1342178230":0,"1342178231":0,"1342178232":0,"1342178233":0,"1342178234":0,"1342178235":0,"1342178236":0,"1342178237":0,"1342178238":0,"1342178239":0,"1342178240":0,"1342178241":0,"1342178242":0,"1342178243":0,"1342178244":0,"1342178245":0,"1342178246":0,"1342178247":0,"1342178248":0,"1342178249":0,"1342178250":0,"1342178251":0,"1342178252":0,"1342178253":0,"1342178254":0,"1342178255":0,"1342178256":0,"1342178257":0,"1342178258":0,"1342178259":0,"1342178260":0,"1342178261":0,"1342178262":0,"1342178263":0,"1342178264":0,"1342178265":0,"1342178266":0,"1342178267":0,"1342178268":0,"1342178269":0,"1342178270":0,"1342178271":0,"1342178272":0,"1342178273":0,"1342178274":0,"1342178275":0,"1342178276":0,"1342178277":0,"1342178278":0,"1342178279":0,"1342178280":0,"1342178281":0,"1342178282":0,"1342178283":0,"1342178284":0,"1342178285":0,"1342178286":0,"1342178287":0,"1342178288":0,"1342178289":0,"1342178290":0,"1342178291":0,"1342178292":0,"1342178293":0,"1342178294":0,"1342178295":0,"1342178296":0,"1342178297":0,"1342178298":0,"1342178299":0,"1342178300":0,"1342178301":0,"1342178302":0,"1342178303":0,"1342178304":0,"1342178305":0,"1342178306":0,"1342178307":0,"1342178308":0,"1342178309":0,"1342178310":0,"1342178311":0,"1342178312":0,"1342178313":0,"1342178314":0,"1342178315":0,"1342178316":0,"1342178317":0,"1342178318":0,"1342178319":0,"1342178320":0,"1342178321":0,"1342178322":0,"1342178323":0,"1342178324":0,"1342178325":0,"1342178326":0,"1342178327":0,"1342178328":0,"1342178329":0,"1342178330":0,"1342178331":0,"1342178332":0,"1342178333":0,"1342178334":0,"1342178335":0,"1342178336":0,"1342178337":0,"1342178338":0,"1342178339":0,"1342178340":0,"1342178341":0,"1342178342":0,"1342178343":0,"1342178344":0,"1342178345":0,"1342178346":0,"1342178347":0,"1342178348":0,"1342178349":0,"1342178350":0,"1342178351":0,"1342178352":0,"1342178353":0,"1342178354":0,"1342178355":0,"1342178356":0,"1342178357":0,"1342178358":0,"1342178359":0,"1342178360":0,"1342178361":0,"1342178362":0,"1342178363":0,"1342178364":0,"1342178365":0,"1342178366":0,"1342178367":0,"1342178368":0,"1342178369":0,"1342178370":0,"1342178371":0,"1342178372":0,"1342178373":0,"1342178374":0,"1342178375":0,"1342178376":0,"1342178377":0,"1342178378":0,"1342178379":0,"1342178380":0,"1342178381":0,"1342178382":0,"1342178383":0,"1342178384":0,"1342178385":0,"1342178386":0,"1342178387":0,"1342178388":0,"1342178389":0,"1342178390":0,"1342178391":0,"1342178392":0,"1342178393":0,"1342178394":0,"1342178395":0,"1342178396":0,"1342178397":0,"1342178398":0,"1342178399":0,"1342178400":0,"1342178401":0,"1342178402":0,"1342178403":0,"1342178404":0,"1342178405":0,"1342178406":0,"1342178407":0,"1342178408":0,"1342178409":0,"1342178410":0,"1342178411":0,"1342178412":0,"1342178413":0,"1342178414":0,"1342178415":0,"1342178416":0,"1342178417":0,"1342178418":0,"1342178419":0,"1342178420":0,"1342178421":0,"1342178422":0,"1342178423":0,"1342178424":0,"1342178425":0,"1342178426":0,"1342178427":0,"1342178428":0,"1342178429":0,"1342178430":0,"1342178431":0,"1342178432":0,"1342178433":0,"1342178434":0,"1342178435":0,"1342178436":0,"1342178437":0,"1342178438":0,"1342178439":0,"1342178440":0,"1342178441":0,"1342178442":0,"1342178443":0,"1342178444":0,"1342178445":0,"1342178446":0,"1342178447":0,"1342178448":0,"1342178449":0,"1342178450":0,"1342178451":0,"1342178452":0,"1342178453":0,"1342178454":0,"1342178455":0,"1342178456":0,"1342178457":0,"1342178458":0,"1342178459":0,"1342178460":0,"1342178461":0,"1342178462":0,"1342178463":0,"1342178464":0,"1342178465":0,"1342178466":0,"1342178467":0,"1342178468":0,"1342178469":0,"1342178470":0,"1342178471":0,"1342178472":0,"1342178473":0,"1342178474":0,"1342178475":0,"1342178476":0,"1342178477":0,"1342178478":0,"1342178479":0,"1342178480":0,"1342178481":0,"1342178482":0,"1342178483":0,"1342178484":0,"1342178485":0,"1342178486":0,"1342178487":0,"1342178488":0,"1342178489":0,"1342178490":0,"1342178491":0,"1342178492":0,"1342178493":0,"1342178494":0,"1342178495":0,"1342178496":0,"1342178497":0,"1342178498":0,"1342178499":0,"1342178500":0,"1342178501":0,"1342178502":0,"1342178503":0,"1342178504":0,"1342178505":0,"1342178506":0,"1342178507":0,"1342178508":0,"1342178509":0,"1342178510":0,"1342178511":0,"1342178512":0,"1342178513":0,"1342178514":0,"1342178515":0,"1342178516":0,"1342178517":0,"1342178518":0,"1342178519":0,"1342178520":0,"1342178521":0,"1342178522":0,"1342178523":0,"1342178524":0,"1342178525":0,"1342178526":0,"1342178527":0,"1342178528":0,"1342178529":0,"1342178530":0,"1342178531":0,"1342178532":0,"1342178533":0,"1342178534":0,"1342178535":0,"1342178536":0,"1342178537":0,"1342178538":0,"1342178539":0,"1342178540":0,"1342178541":0,"1342178542":0,"1342178543":0,"1342178544":0,"1342178545":0,"1342178546":0,"1342178547":0,"1342178548":0,"1342178549":0,"1342178550":0,"1342178551":0,"1342178552":0,"1342178553":0,"1342178554":0,"1342178555":0,"1342178556":0,"1342178557":0,"1342178558":0,"1342178559":0},"range":{"start":1342177280,"end":1342178560}},{"type":"Mux","id":"wb_mux","pos":[1580.0,520.0],"select":{"id":"decoder","field":"wb_mux"},"m_in":[{"id":"alu","field":"result_o"},{"id":"data_memory","field":"data_o"}]},{"type":"Wire","id":"wb_data","pos":[[1600.0,520.0],[1600.0,520.0],[1640.0,520.0],[1640.0,520.0],[1640.0,180.0],[1640.0,180.0],[1100.0,180.0],[1100.0,180.0],[1100.0,220.00002],[1100.0,220.0],[1110.0,220.0]],"input":{"id":"wb_mux","field":"out"}},{"type":"Wire","id":"data_mem_o","pos":[[1570.0,850.0],[1570.0,850.0],[1570.0,570.0],[1570.0,570.0],[1540.0,570.0],[1540.0,570.0],[1540.0,530.0],[1540.0,530.0],[1560.0,530.0]],"input":{"id":"data_memory","field":"data_o"}},{"type":"Wire","id":"pcp4_to_alu","pos":[[580.0,720.0],[580.0,720.0],[580.0,840.0],[580.0,840.0],[540.0,840.0],[540.0,840.0],[540.0,1030.0],[540.0,1030.0],[1350.0,1030.0],[1350.0,1030.0],[1350.0,630.0],[1350.0,630.0],[1380.0,630.0]],"input":{"id":"pc_adder","field":"out"}},{"type":"Wire","id":"pc_to_mux","pos":[[560.0,720.0],[560.0,720.0],[580.0,720.0],[580.0,720.0],[580.0,660.0],[580.0,660.0],[360.0,660.0],[360.0,660.0],[360.0,720.0],[360.0,720.0],[380.0,720.0]],"input":{"id":"pc_adder","field":"out"}},{"type":"Wire","id":"jal_imm","pos":[[755.0,680.0],[755.0,680.0],[800.0,680.0],[800.0,680.0],[800.0,1010.00006],[800.0,1010.00006],[70.0,1010.00006],[70.0,1010.00006],[70.0,820.0],[70.0,820.0],[100.0,820.0]],"input":{"id":"decoder","field":"big_imm"}},{"type":"Add","id":"branch_adder","pos":[300.0,840.0],"a_in":{"id":"reg","field":"out"},"b_in":{"id":"branch_adder_mux","field":"out"}},{"type":"Mux","id":"pc_adder_mux","pos":[400.0,740.0],"select":{"id":"branch_logic","field":"out"},"m_in":[{"id":"pc_adder","field":"out"},{"id":"jalr_stripper","field":"out"},{"id":"branch_adder","field":"out"}]},{"type":"Wire","id":"w11","pos":[[420.0,740.0],[420.0,740.0],[450.0,740.0]],"input":{"id":"pc_adder_mux","field":"out"}},{"type":"Wire","id":"branch_adder_o","pos":[[320.0,840.0],[320.0,840.0],[360.0,840.0],[360.0,840.0],[360.0,760.0],[360.0,760.0],[380.0,760.0]],"input":{"id":"branch_adder","field":"out"}},{"type":"Wire","id":"w1111","pos":[[1205.0,400.0],[1230.0,400.0],[1230.0,469.99997],[1230.0,476.0],[1270.0,476.0]],"input":{"id":"reg_file","field":"reg_a"}}]} \ No newline at end of file diff --git a/riscv/examples/empty.rs b/riscv/examples/empty.rs index 5577c3d1..bca76165 100644 --- a/riscv/examples/empty.rs +++ b/riscv/examples/empty.rs @@ -20,9 +20,8 @@ struct Args { } fn main() { - let cs = ComponentStore { store: vec![] }; - let path = PathBuf::from("riscv.json"); - cs.save_file(&path); + let path = PathBuf::from("autosave.json"); + let cs = ComponentStore::load_file(&path); let dummy = Input::new("id", "field"); #[cfg(feature = "gui-egui")] { diff --git a/riscv/examples/riscv.rs b/riscv/examples/riscv.rs index bd31c3d9..a4440de4 100644 --- a/riscv/examples/riscv.rs +++ b/riscv/examples/riscv.rs @@ -41,12 +41,12 @@ fn main() { elf_from_asm(&args); let bytes = fs::read("./output").expect("The elf file could not be found"); let elf = ElfFile::new(&bytes).unwrap(); - riscv_elf_parse::Memory::new_from_elf(elf) + riscv_elf_parse::Memory::new_from_file(&bytes, true) } else { let bytes = fs::read(format!("{}", args.elf_path)).expect("The elf file could not be found"); let elf = ElfFile::new(&bytes).unwrap(); - riscv_elf_parse::Memory::new_from_elf(elf) + riscv_elf_parse::Memory::new_from_file(&bytes, true) }; println!("{}", memory); @@ -78,187 +78,274 @@ fn main() { data_mem.insert(element.0, element.1); } } - - let cs = ComponentStore { - store: vec![ - Add::rc_new( - "pc_adder", - (150.0, 120.0), - Input::new("pc_adder_c", "out"), - Input::new("reg", "out"), - ), - Constant::rc_new("pc_adder_c", (100.0, 100.0), 4), - Register::rc_new("reg", (100.0, 140.0), Input::new("pc_adder_mux", "out")), - Mux::rc_new( - "pc_adder_mux", - (100.0, 120.0), - Input::new("branch_logic", "out"), - vec![ - Input::new("pc_adder", "out"), - Input::new("jalr_stripper", "out"), - Input::new("branch_adder", "out"), - ], - ), - Add::rc_new( - "jalr_adder", - (100.0, 200.0), - Input::new("reg_file", "reg_a"), - Input::new("jalr_se", "out"), - ), - Rc::new(BranchLogic { - id: "branch_logic".to_string(), - pos: (725.0, 300.0), - rs1: Input::new("reg_file", "reg_a"), - rs2: Input::new("reg_file", "reg_b"), - ctrl: Input::new("decoder", "branch_logic_ctl"), - enable: Input::new("decoder", "branch_logic_enable"), - }), - Rc::new(LSBZero { - id: "jalr_stripper".to_string(), - pos: (600.0, 1000.0), - data_i: Input::new("jalr_adder", "out"), - }), - Sext::rc_new( - "jalr_se", - (900.0, 900.0), - Input::new("decoder", "jalr_imm"), - 12, - 32, - ), - Mux::rc_new( - "branch_adder_mux", - (500.0, 1000.0), - Input::new("decoder", "pc_imm_sel"), - vec![ - Input::new("jal_imm_sext", "out"), - Input::new("branch_imm_sext", "out"), - ], - ), - Add::rc_new( - "branch_adder", - (50.0, 400.0), - Input::new("reg", "out"), - Input::new("branch_adder_mux", "out"), - ), - Sext::rc_new( - "jal_imm_sext", - (500.0, 1000.0), - Input::new("decoder", "big_imm"), - 21, - 32, - ), - Sext::rc_new( - "branch_imm_sext", - (500.0, 1000.0), - Input::new("decoder", "branch_imm"), - 13, - 32, - ), - Rc::new(InstrMem { - id: "instr_mem".to_string(), - pos: (180.0, 400.0), - pc: Input::new("reg", "out"), - bytes: instr_mem, - range: instr_range, - breakpoints: Rc::new(RefCell::new(breakpoints)), - }), - Rc::new(Decoder { - id: "decoder".to_string(), - pos: (300.0, 150.0), - instruction: Input::new("instr_mem", "instruction"), - }), - Register::rc_new( - "regfile_we_reg", - (450.0, 50.0), - Input::new("decoder", "regfile_we"), - ), - Register::rc_new( - "regfile_rd_reg", - (480.0, 50.0), - Input::new("decoder", "regfile_rd"), - ), - Rc::new(SZExt { - id: "imm_szext".to_string(), - pos: (450.0, 1000.0), - data_i: Input::new("decoder", "sign_zero_ext_data"), - sel_i: Input::new("decoder", "sign_zero_ext_sel"), - }), - Rc::new(RegFile { - id: "reg_file".into(), - pos: (450.0, 150.0), - width: 100.0, - height: 100.0, - read_addr1: Input::new("decoder", "regfile_rs1"), - read_addr2: Input::new("decoder", "regfile_rs2"), - write_data: Input::new("wb_mux", "out"), - write_addr: Input::new("regfile_rd_reg", "out"), - write_enable: Input::new("regfile_we_reg", "out"), - registers: RegStore::new(Rc::new(RefCell::new([0; 32]))), - history: RegHistory::new(), - }), - Mem::rc_new_from_bytes( - "data_memory", - (700.0, 600.0), - 100.0, - 100.0, - false, - Input::new("reg_file", "reg_b"), - Input::new("alu", "result_o"), - Input::new("decoder", "data_mem_ctrl"), - Input::new("decoder", "data_se"), - Input::new("decoder", "data_mem_size"), - data_mem, - range, - ), - Constant::rc_new("zero_c", (680.0, 150.0), 0), - Mux::rc_new( - "alu_operand_a_mux", - (700.0, 150.0), - Input::new("decoder", "alu_operand_a_sel"), - vec![ + /* + let cs = ComponentStore { + store: vec![ + Add::rc_new( + "pc_adder", + (150.0, 120.0), + Input::new("pc_adder_c", "out"), + Input::new("reg", "out"), + ), + Constant::rc_new("pc_adder_c", (100.0, 100.0), 4), + Register::rc_new("reg", (100.0, 140.0), Input::new("pc_adder_mux", "out")), + Mux::rc_new( + "pc_adder_mux", + (100.0, 120.0), + Input::new("branch_logic", "out"), + vec![ + Input::new("pc_adder", "out"), + Input::new("jalr_stripper", "out"), + Input::new("branch_adder", "out"), + ], + ), + Add::rc_new( + "jalr_adder", + (100.0, 200.0), Input::new("reg_file", "reg_a"), - Input::new("decoder", "imm_a_mux_data"), - Input::new("zero_c", "out"), - ], - ), - Mux::rc_new( - "alu_operand_b_mux", - (700.0, 300.0), - Input::new("decoder", "alu_operand_b_sel"), - vec![ - Input::new("reg_file", "reg_b"), - Input::new("imm_szext", "out"), - Input::new("pc_adder", "out"), + Input::new("jalr_se", "out"), + ), + Rc::new(BranchLogic { + height: BRANCH_LOGIC_HEIGHT, + width: BRANCH_LOGIC_WIDTH, + id: "branch_logic".to_string(), + pos: (725.0, 300.0), + rs1: Input::new("reg_file", "reg_a"), + rs2: Input::new("reg_file", "reg_b"), + ctrl: Input::new("decoder", "branch_logic_ctl"), + enable: Input::new("decoder", "branch_logic_enable"), + }), + Rc::new(LSBZero { + height: LSB_ZERO_HEIGHT, + width: LSB_ZERO_WIDTH, + id: "jalr_stripper".to_string(), + pos: (600.0, 1000.0), + data_i: Input::new("jalr_adder", "out"), + }), + Sext::rc_new( + "jalr_se", + (900.0, 900.0), + Input::new("decoder", "jalr_imm"), + 12, + 32, + ), + Mux::rc_new( + "branch_adder_mux", + (500.0, 1000.0), + Input::new("decoder", "pc_imm_sel"), + vec![ + Input::new("jal_imm_sext", "out"), + Input::new("branch_imm_sext", "out"), + ], + ), + Add::rc_new( + "branch_adder", + (50.0, 400.0), Input::new("reg", "out"), - ], - ), - Rc::new(ALU { - id: "alu".to_string(), - pos: (800.0, 225.0), - operator_i: Input::new("decoder", "alu_operator"), - operand_a_i: Input::new("alu_operand_a_mux", "out"), - operand_b_i: Input::new("alu_operand_b_mux", "out"), - }), - Mux::rc_new( - "wb_mux", - (900.0, 225.0), - Input::new("decoder", "wb_mux"), - vec![ + Input::new("branch_adder_mux", "out"), + ), + Sext::rc_new( + "jal_imm_sext", + (500.0, 1000.0), + Input::new("decoder", "big_imm"), + 21, + 32, + ), + Sext::rc_new( + "branch_imm_sext", + (500.0, 1000.0), + Input::new("decoder", "branch_imm"), + 13, + 32, + ), + Rc::new(InstrMem { + height: INSTR_MEM_HEIGHT, + width: INSTR_MEM_WIDTH, + id: "instr_mem".to_string(), + pos: (180.0, 400.0), + pc: Input::new("reg", "out"), + bytes: instr_mem, + range: instr_range, + breakpoints: Rc::new(RefCell::new(breakpoints)), + }), + Rc::new(Decoder { + height: DECODER_HEIGHT, + width: DECODER_WIDTH, + id: "decoder".to_string(), + pos: (300.0, 150.0), + instruction: Input::new("instr_mem", "instruction"), + }), + Register::rc_new( + "regfile_we_reg", + (450.0, 50.0), + Input::new("decoder", "regfile_we"), + ), + Register::rc_new( + "regfile_rd_reg", + (480.0, 50.0), + Input::new("decoder", "regfile_rd"), + ), + Rc::new(SZExt { + height: SIGN_ZERO_EXT_HEIGHT, + width: SIGN_ZERO_EXT_WIDTH, + id: "imm_szext".to_string(), + pos: (450.0, 1000.0), + data_i: Input::new("decoder", "sign_zero_ext_data"), + sel_i: Input::new("decoder", "sign_zero_ext_sel"), + }), + Register::rc_new("wb_reg", (100.0, 140.0), Input::new("wb_mux", "out")), + Rc::new(RegFile { + id: "reg_file".into(), + pos: (450.0, 150.0), + width: REG_FILE_WIDTH, + height: REG_FILE_HEIGHT, + read_addr1: Input::new("decoder", "regfile_rs1"), + read_addr2: Input::new("decoder", "regfile_rs2"), + write_data: Input::new("wb_reg", "out"), + write_addr: Input::new("regfile_rd_reg", "out"), + write_enable: Input::new("regfile_we_reg", "out"), + registers: RegStore::new(Rc::new(RefCell::new([0; 32]))), + history: RegHistory::new(), + }), + Mem::rc_new_from_bytes( + "data_memory", + (700.0, 600.0), + 100.0, + 100.0, + false, + Input::new("reg_file", "reg_b"), Input::new("alu", "result_o"), - Input::new("data_memory", "data"), - ], - ), - ], - }; - + Input::new("decoder", "data_mem_ctrl"), + Input::new("decoder", "data_se"), + Input::new("decoder", "data_mem_size"), + data_mem, + range, + ), + Constant::rc_new("zero_c", (680.0, 150.0), 0), + Mux::rc_new( + "alu_operand_a_mux", + (700.0, 150.0), + Input::new("decoder", "alu_operand_a_sel"), + vec![ + Input::new("reg_file", "reg_a"), + Input::new("decoder", "imm_a_mux_data"), + Input::new("zero_c", "out"), + ], + ), + Mux::rc_new( + "alu_operand_b_mux", + (700.0, 300.0), + Input::new("decoder", "alu_operand_b_sel"), + vec![ + Input::new("reg_file", "reg_b"), + Input::new("imm_szext", "out"), + Input::new("pc_adder", "out"), + Input::new("reg", "out"), + ], + ), + Rc::new(ALU { + id: "alu".to_string(), + pos: (800.0, 225.0), + operator_i: Input::new("decoder", "alu_operator"), + operand_a_i: Input::new("alu_operand_a_mux", "out"), + operand_b_i: Input::new("alu_operand_b_mux", "out"), + }), + Mux::rc_new( + "wb_mux", + (900.0, 225.0), + Input::new("decoder", "wb_mux"), + vec![ + Input::new("alu", "result_o"), + Input::new("data_memory", "data"), + ], + ), + ], + }; + */ + let path = PathBuf::from("riscv.json"); + let cs = ComponentStore::load_file(&path); let path = PathBuf::from("riscv.json"); cs.save_file(&path); #[cfg(feature = "gui-egui")] - syncrim::gui_egui::gui(&cs, &path).ok(); + { + let dummy = Input::new("id", "field"); + let lib = ComponentStore { + store: vec![ + Rc::new(InstrMem { + width: INSTR_MEM_WIDTH, + height: INSTR_MEM_HEIGHT, + id: "dummy_instr_mem".to_string(), + pos: (0.0, 0.0), + pc: dummy.clone(), + bytes: BTreeMap::new(), + range: Range { + start: 0, + end: 0x1000, + }, + breakpoints: Rc::new(RefCell::new(HashSet::new())), + }), + Rc::new(ALU { + id: "dummy_alu".to_string(), + pos: (0.0, 0.0), + operator_i: dummy.clone(), + operand_a_i: dummy.clone(), + operand_b_i: dummy.clone(), + }), + Rc::new(BranchLogic { + width: BRANCH_LOGIC_WIDTH, + height: BRANCH_LOGIC_HEIGHT, + id: "dummy_blu".to_string(), + pos: (0.0, 0.0), + rs1: dummy.clone(), + rs2: dummy.clone(), + ctrl: dummy.clone(), + enable: dummy.clone(), + }), + Rc::new(Decoder { + width: DECODER_WIDTH, + height: DECODER_HEIGHT, + id: "dummy_decoder".to_string(), + pos: (0.0, 0.0), + instruction: dummy.clone(), + }), + Rc::new(LSBZero { + height: LSB_ZERO_HEIGHT, + width: LSB_ZERO_WIDTH, + id: "dummy_lsbzero".to_string(), + pos: (0.0, 0.0), + data_i: dummy.clone(), + }), + Rc::new(RegFile { + id: "dummy_reg_file".into(), + pos: (0.0, 0.0), + width: REG_FILE_WIDTH, + height: REG_FILE_HEIGHT, + read_addr1: dummy.clone(), + read_addr2: dummy.clone(), + write_data: dummy.clone(), + write_addr: dummy.clone(), + write_enable: dummy.clone(), + registers: RegStore::new(Rc::new(RefCell::new([0; 32]))), + history: RegHistory::new(), + }), + Rc::new(SZExt { + height: SIGN_ZERO_EXT_HEIGHT, + width: SIGN_ZERO_EXT_WIDTH, + id: "dummy_szext".to_string(), + pos: (0.0, 0.0), + data_i: dummy.clone(), + sel_i: dummy.clone(), + }), + ], + }; + let mut component_vec = lib.store.clone(); + component_vec.append(&mut syncrim::gui_egui::editor::Library::default().0.clone()); + syncrim::gui_egui::gui(cs, &path, syncrim::gui_egui::editor::Library(component_vec)); + } #[cfg(feature = "gui-vizia")] - syncrim::gui_vizia::gui(&cs, &path); + syncrim::gui_vizia::gui(cs, &path); } #[allow(unused_imports)] use log::LevelFilter; @@ -276,8 +363,8 @@ fn fern_setup_riscv() { // Add blanket level filter - // .level(log::LevelFilter::Debug); .level_for( - // "syncrim::gui_vizia::components::mem", - "riscv::gui_vizia::components::instr_mem", + "syncrim::simulator", + // "riscv::gui_vizia::components::instr_mem", log::LevelFilter::Trace, ) .level(log::LevelFilter::Error); @@ -362,4 +449,4 @@ fn elf_from_asm(args: &Args) { .status() .unwrap() }; -} \ No newline at end of file +} diff --git a/riscv/src/components/decoder.rs b/riscv/src/components/decoder.rs index 61bbd160..5b4c33ab 100644 --- a/riscv/src/components/decoder.rs +++ b/riscv/src/components/decoder.rs @@ -34,7 +34,7 @@ pub const DECODER_BRANCH_LOGIC_CTL_ID: &str = "branch_logic_ctl"; pub const DECODER_BRANCH_LOGIC_ENABLE_ID: &str = "branch_logic_enable"; pub const DECODER_JALR_IMM_ID: &str = "jalr_imm"; -pub const DECODER_HEIGHT: f32 = 200.0; +pub const DECODER_HEIGHT: f32 = 600.0; pub const DECODER_WIDTH: f32 = 30.0; #[derive(Serialize, Deserialize)] diff --git a/riscv/src/components/instr_mem.rs b/riscv/src/components/instr_mem.rs index dab75b42..b93ccb31 100644 --- a/riscv/src/components/instr_mem.rs +++ b/riscv/src/components/instr_mem.rs @@ -10,8 +10,6 @@ use std::{ use log::trace; use serde::{Deserialize, Serialize}; #[cfg(feature = "gui-egui")] -use std::rc::Rc; -#[cfg(feature = "gui-egui")] use syncrim::common::EguiComponent; use syncrim::common::{Component, Condition, Id, Input, InputPort, OutputType, Ports, Simulator}; pub const INSTR_MEM_PC_ID: &str = "pc"; @@ -48,6 +46,11 @@ impl Component for InstrMem { pos: (pos.0, pos.1), bytes: BTreeMap::new(), pc: dummy_input, + range: Range { + start: 0, + end: 0x1000, + }, + breakpoints: Rc::new(RefCell::new(HashSet::new())), })) } fn set_id_port(&mut self, target_port_id: Id, new_input: Input) { diff --git a/riscv/src/components/reg_file.rs b/riscv/src/components/reg_file.rs index 3a23391d..c1a62468 100644 --- a/riscv/src/components/reg_file.rs +++ b/riscv/src/components/reg_file.rs @@ -227,8 +227,10 @@ impl Component for RegFile { .get_input_value(&self.write_addr) .try_into() .unwrap(); - trace!("write_addr {}", write_addr); - self.registers.borrow_mut()[write_addr as usize] = data.try_into().unwrap(); + if write_addr != 0 { + trace!("write_addr {}", write_addr); + self.registers.borrow_mut()[write_addr as usize] = data.try_into().unwrap(); + } } // read after write diff --git a/riscv/src/gui_egui/components/reg_file.rs b/riscv/src/gui_egui/components/reg_file.rs index 680bc91b..f7ef668b 100644 --- a/riscv/src/gui_egui/components/reg_file.rs +++ b/riscv/src/gui_egui/components/reg_file.rs @@ -30,7 +30,6 @@ impl EguiComponent for RegFile { offset.y += self.pos.1 * scale; let s = scale; let o = offset; - // The shape let rect = Rect { min: oh((-self.width / 2f32, -self.height / 2f32), s, o), @@ -161,19 +160,19 @@ impl EguiComponent for RegFile { ), ( crate::components::REG_FILE_WRITE_DATA_ID.to_string(), - Pos2::new(-self.width / 3f32, -self.height / 2f32) + own_pos, + Pos2::new(self.width / 4f32, -self.height / 2f32) + own_pos, ), ( crate::components::REG_FILE_WRITE_ENABLE_ID.to_string(), - Pos2::new(self.width / 3f32, -self.height / 2f32) + own_pos, + Pos2::new(-self.width / 4f32, -self.height / 2f32) + own_pos, ), ( crate::components::REG_FILE_REG_A_OUT.to_string(), - Pos2::new(self.width / 2f32, -self.height / 3f32) + own_pos, + Pos2::new(self.width / 2f32, -self.height / 5f32) + own_pos, ), ( crate::components::REG_FILE_REG_B_OUT.to_string(), - Pos2::new(self.width / 2f32, self.height / 3f32) + own_pos, + Pos2::new(self.width / 2f32, self.height / 5f32) + own_pos, ), ] } diff --git a/riscv/src/gui_egui/components/sign_zero_ext.rs b/riscv/src/gui_egui/components/sign_zero_ext.rs index 1e95e062..2d76b952 100644 --- a/riscv/src/gui_egui/components/sign_zero_ext.rs +++ b/riscv/src/gui_egui/components/sign_zero_ext.rs @@ -129,7 +129,7 @@ impl EguiComponent for SZExt { vec![ ( crate::components::SIGN_ZERO_EXT_DATA_I_ID.to_string(), - Pos2::new(self.width / 2f32, 0.0) + own_pos, + Pos2::new(-self.width / 2f32, 0.0) + own_pos, ), ( crate::components::SIGN_ZERO_EXT_SEL_I_ID.to_string(), @@ -137,7 +137,7 @@ impl EguiComponent for SZExt { ), ( crate::components::SIGN_ZERO_EXT_OUT_ID.to_string(), - Pos2::new(-self.width / 2f32, 0.0) + own_pos, + Pos2::new(self.width / 2f32, 0.0) + own_pos, ), ] } diff --git a/riscv/src/gui_vizia/components/alu.rs b/riscv/src/gui_vizia/components/alu.rs index fff5b845..2e80758a 100644 --- a/riscv/src/gui_vizia/components/alu.rs +++ b/riscv/src/gui_vizia/components/alu.rs @@ -13,20 +13,19 @@ impl ViziaComponent for ALU { // create view fn view<'a>(&self, cx: &'a mut Context) -> Handle<'a, V> { V::new(cx, self, move |cx| { - trace!("---- Create ALU View"); + trace!("---- Create Add View"); - View::build(ALUView {}, cx, |cx| { + View::build(ALUView {}, cx, move |cx| { Label::new(cx, "ALU") - .left(Percentage(20.0)) - .top(Percentage(45.0)); + .left(Percentage(25.0)) + .top(Pixels(40.0 - 10.0)) + .hoverable(false); }) }) - .position_type(PositionType::SelfDirected) - .left(Pixels(self.pos.0 - 50.0)) - .top(Pixels(self.pos.1 - 100.0)) - .width(Pixels(100.0)) - .height(Pixels(200.0)) - .tooltip(|cx| new_component_tooltip(cx, self)) + .left(Pixels(self.pos.0 - 20.0)) + .top(Pixels(self.pos.1 - 40.0)) + .width(Pixels(40.0)) + .height(Pixels(80.0)) } } @@ -39,18 +38,37 @@ impl View for ALUView { fn draw(&self, cx: &mut DrawContext<'_>, canvas: &mut Canvas) { let bounds = cx.bounds(); - // println!("InstMem draw {:?}", bounds); + //trace!("Add draw {:?}", bounds); let mut path = Path::new(); - let mut paint = Paint::color(Color::rgbf(0.0, 1.0, 1.0)); + let mut paint = Paint::color(Color::rgbf(1.0, 0.0, 0.0)); paint.set_line_width(cx.logical_to_physical(1.0)); - path.move_to(bounds.left() + 0.5, bounds.top() + 0.5); - path.line_to(bounds.right() + 0.5, bounds.top() + 0.5); - path.line_to(bounds.right() + 0.5, bounds.bottom() + 0.5); - path.line_to(bounds.left() + 0.5, bounds.bottom() + 0.5); - path.line_to(bounds.left() + 0.5, bounds.top() + 0.5); + let height = bounds.height(); + let width = bounds.width(); + let top = bounds.top(); + let left = bounds.left(); + let right = bounds.right(); + let bottom = bounds.bottom(); - canvas.fill_path(&path, &paint); + // top left + path.move_to(left + 0.5, top + 0.5); + + // top right corner + path.line_to(left + width * 0.5 + 0.5, top + 0.5); + path.line_to(right + 0.5, top + height * 0.25 + 0.5); + + // bottom right corner + path.line_to(right + 0.5, bottom - height * 0.25 + 0.5); + path.line_to(left + width * 0.5 + 0.5, bottom + 0.5); + path.line_to(left + 0.5, bottom + 0.5); + + // left outtake + path.line_to(left + 0.5, bottom - 0.25 * height + 0.5); + path.line_to(left + width * 0.25 + 0.5, top + 0.5 * height + 0.5); + path.line_to(left + 0.5, top + 0.25 * height + 0.5); + path.line_to(left + 0.5, top + 0.5); + + canvas.stroke_path(&path, &paint); } } diff --git a/riscv/src/gui_vizia/components/branch_logic.rs b/riscv/src/gui_vizia/components/branch_logic.rs index abf864e9..bc334b2c 100644 --- a/riscv/src/gui_vizia/components/branch_logic.rs +++ b/riscv/src/gui_vizia/components/branch_logic.rs @@ -16,16 +16,16 @@ impl ViziaComponent for BranchLogic { trace!("---- Create BranchLogic View"); View::build(BranchLogicView {}, cx, |cx| { - Label::new(cx, "BranchLogic") + Label::new(cx, "Branch\nLogic") .left(Percentage(0.0)) .top(Percentage(0.0)); }) }) .position_type(PositionType::SelfDirected) - .left(Pixels(self.pos.0 - 50.0)) - .top(Pixels(self.pos.1 - 100.0)) - .width(Pixels(50.0)) - .height(Pixels(20.0)) + .left(Pixels(self.pos.0 - self.width / 2f32)) + .top(Pixels(self.pos.1 - self.height / 2f32)) + .width(Pixels(self.width)) + .height(Pixels(self.height)) .tooltip(|cx| new_component_tooltip(cx, self)) } } diff --git a/riscv/src/gui_vizia/components/decoder.rs b/riscv/src/gui_vizia/components/decoder.rs index 6ea717fb..98bcc854 100644 --- a/riscv/src/gui_vizia/components/decoder.rs +++ b/riscv/src/gui_vizia/components/decoder.rs @@ -21,10 +21,10 @@ impl ViziaComponent for Decoder { }) }) .position_type(PositionType::SelfDirected) - .left(Pixels(self.pos.0 - 50.0)) - .top(Pixels(self.pos.1 - 100.0)) - .width(Pixels(100.0)) - .height(Pixels(200.0)) + .left(Pixels(self.pos.0 - self.width / 2f32)) + .top(Pixels(self.pos.1 - self.height / 2f32)) + .width(Pixels(self.width)) + .height(Pixels(self.height)) .tooltip(|cx| new_component_tooltip(cx, self)) } } diff --git a/riscv/src/gui_vizia/components/instr_mem.rs b/riscv/src/gui_vizia/components/instr_mem.rs index bd7425d5..26ea7e09 100644 --- a/riscv/src/gui_vizia/components/instr_mem.rs +++ b/riscv/src/gui_vizia/components/instr_mem.rs @@ -25,10 +25,10 @@ impl ViziaComponent for InstrMem { .top(Pixels(10.0)) .hoverable(false) }) - .left(Pixels(self.pos.0 - 200.0 / 2.0)) - .top(Pixels(self.pos.1 - 50.0 / 2.0)) - .width(Pixels(200.0)) - .height(Pixels(50.0)) + .left(Pixels(self.pos.0 - self.width / 2.0)) + .top(Pixels(self.pos.1 - self.height / 2.0)) + .width(Pixels(self.width)) + .height(Pixels(self.height)) .background_color(Color::lightgrey()) } fn left_view(&self, cx: &mut Context) { diff --git a/riscv/src/gui_vizia/components/lsb_zero.rs b/riscv/src/gui_vizia/components/lsb_zero.rs index 721f5a37..31f6983a 100644 --- a/riscv/src/gui_vizia/components/lsb_zero.rs +++ b/riscv/src/gui_vizia/components/lsb_zero.rs @@ -15,16 +15,16 @@ impl ViziaComponent for LSBZero { V::new(cx, self, move |cx| { trace!("---- Create LSBZero View"); View::build(LSBZeroView {}, cx, |cx| { - Label::new(cx, "LSBZero") + Label::new(cx, "") .left(Percentage(0.0)) .top(Percentage(0.0)); }) }) .position_type(PositionType::SelfDirected) - .left(Pixels(self.pos.0 - 50.0)) - .top(Pixels(self.pos.1 - 100.0)) - .width(Pixels(50.0)) - .height(Pixels(20.0)) + .left(Pixels(self.pos.0 - self.width / 2f32)) + .top(Pixels(self.pos.1 - self.height / 2f32)) + .width(Pixels(self.width)) + .height(Pixels(self.height)) .tooltip(|cx| new_component_tooltip(cx, self)) } } diff --git a/riscv/src/gui_vizia/components/reg_file.rs b/riscv/src/gui_vizia/components/reg_file.rs index be04759c..1c59b1d5 100644 --- a/riscv/src/gui_vizia/components/reg_file.rs +++ b/riscv/src/gui_vizia/components/reg_file.rs @@ -112,7 +112,7 @@ impl ViziaComponent for RegFile { .background_color(Color::lightgrey()) .border_width(Pixels(1.0)) .border_color(Color::black()) - .width(Pixels(200.0)) + .width(Pixels(250.0)) .height(Pixels(500.0)) } } diff --git a/riscv/src/gui_vizia/components/sign_zero_ext.rs b/riscv/src/gui_vizia/components/sign_zero_ext.rs index 3fe53b23..f549f0b2 100644 --- a/riscv/src/gui_vizia/components/sign_zero_ext.rs +++ b/riscv/src/gui_vizia/components/sign_zero_ext.rs @@ -21,10 +21,10 @@ impl ViziaComponent for SZExt { }) }) .position_type(PositionType::SelfDirected) - .left(Pixels(self.pos.0 - 50.0)) - .top(Pixels(self.pos.1 - 100.0)) - .width(Pixels(50.0)) - .height(Pixels(20.0)) + .left(Pixels(self.pos.0 - self.width / 2f32)) + .top(Pixels(self.pos.1 - self.height / 2f32)) + .width(Pixels(self.width)) + .height(Pixels(self.height)) .tooltip(|cx| new_component_tooltip(cx, self)) } } diff --git a/src/components/mem.rs b/src/components/mem.rs index 00606c2a..ccc312e5 100644 --- a/src/components/mem.rs +++ b/src/components/mem.rs @@ -17,7 +17,7 @@ pub const MEM_CTRL_ID: &str = "ctrl"; pub const MEM_SEXT_ID: &str = "sext"; pub const MEM_SIZE_ID: &str = "size"; -pub const MEM_DATA_OUT_ID: &str = "data"; +pub const MEM_DATA_OUT_ID: &str = "data_o"; pub const MEM_ERR_OUT_ID: &str = "err"; #[derive(Serialize, Deserialize, Clone)] @@ -354,7 +354,7 @@ impl Component for Mem { sign != 0, self.big_endian, ); - simulator.set_out_value(&self.id, "data", value); + simulator.set_out_value(&self.id, "data_o", value); let value = self.memory.align(addr as usize, size as usize); trace!("align {:?}", value); simulator.set_out_value(&self.id, "err", value); // align @@ -375,7 +375,7 @@ impl Component for Mem { } } _ => { - simulator.set_out_value(&self.id, "data", SignalValue::Unknown); + simulator.set_out_value(&self.id, "data_o", SignalValue::Unknown); simulator.set_out_value(&self.id, "err", SignalValue::Unknown); // align } } @@ -428,7 +428,7 @@ mod test { fn test_mem_be() { let cs = ComponentStore { store: vec![ - Rc::new(ProbeOut::new("data")), + Rc::new(ProbeOut::new("data_o")), Rc::new(ProbeOut::new("addr")), Rc::new(ProbeOut::new("ctrl")), Rc::new(ProbeOut::new("size")), @@ -443,7 +443,7 @@ mod test { big_endian: true, // i.e., big endian // ports - data: Input::new("data", "out"), + data: Input::new("data_o", "out"), addr: Input::new("addr", "out"), ctrl: Input::new("ctrl", "out"), size: Input::new("size", "out"), @@ -464,7 +464,7 @@ mod test { assert_eq!(simulator.cycle, 1); // outputs - let out = &Input::new("mem", "data"); + let out = &Input::new("mem", "data_o"); let err = &Input::new("mem", "err"); // reset @@ -476,7 +476,7 @@ mod test { println!(""); - simulator.set_out_value("data", "out", 0xf0); + simulator.set_out_value("data_o", "out", 0xf0); simulator.set_out_value("addr", "out", 4); simulator.set_out_value("ctrl", "out", MemCtrl::Write as SignalUnsigned); simulator.set_out_value("size", "out", 1); @@ -584,7 +584,7 @@ mod test { println!(""); simulator.set_out_value("addr", "out", 10); - simulator.set_out_value("data", "out", 0x1234); + simulator.set_out_value("data_o", "out", 0x1234); simulator.set_out_value("ctrl", "out", MemCtrl::Write as SignalUnsigned); simulator.clock(); assert_eq!(simulator.cycle, 13); @@ -610,7 +610,7 @@ mod test { fn test_mem_le() { let cs = ComponentStore { store: vec![ - Rc::new(ProbeOut::new("data")), + Rc::new(ProbeOut::new("data_o")), Rc::new(ProbeOut::new("addr")), Rc::new(ProbeOut::new("ctrl")), Rc::new(ProbeOut::new("size")), @@ -625,7 +625,7 @@ mod test { big_endian: false, // i.e., little endian // ports - data: Input::new("data", "out"), + data: Input::new("data_o", "out"), addr: Input::new("addr", "out"), ctrl: Input::new("ctrl", "out"), size: Input::new("size", "out"), @@ -647,7 +647,7 @@ mod test { assert_eq!(simulator.cycle, 1); // outputs - let out = &Input::new("mem", "data"); + let out = &Input::new("mem", "data_o"); let err = &Input::new("mem", "err"); // reset @@ -656,7 +656,7 @@ mod test { // println!(""); - simulator.set_out_value("data", "out", 0xf0); + simulator.set_out_value("data_o", "out", 0xf0); simulator.set_out_value("addr", "out", 4); simulator.set_out_value("ctrl", "out", MemCtrl::Write as SignalUnsigned); simulator.set_out_value("size", "out", 1); // byte @@ -710,7 +710,7 @@ mod test { println!(""); simulator.set_out_value("addr", "out", 10); // b - simulator.set_out_value("data", "out", 0x1234); + simulator.set_out_value("data_o", "out", 0x1234); simulator.set_out_value("ctrl", "out", MemCtrl::Write as SignalUnsigned); simulator.set_out_value("size", "out", 2); diff --git a/src/gui_egui/components/mux.rs b/src/gui_egui/components/mux.rs index 4b24b4ca..84d7d5df 100644 --- a/src/gui_egui/components/mux.rs +++ b/src/gui_egui/components/mux.rs @@ -34,7 +34,7 @@ impl EguiComponent for Mux { // selector, here we can treat Signal better (see Vizia counterpart) let select: SignalUnsigned = match simulator { - Some(s) => s.get_input_value(&self.select).try_into().unwrap(), + Some(s) => s.get_input_value(&self.select).try_into().unwrap_or(0), None => 0, }; diff --git a/src/gui_egui/editor.rs b/src/gui_egui/editor.rs index 547bd07f..2289a6a4 100644 --- a/src/gui_egui/editor.rs +++ b/src/gui_egui/editor.rs @@ -336,17 +336,21 @@ impl Editor { let old_key = c.as_ref().get_id_ports().0; println!("{}, {:?}", old_key, e.contexts); match e.contexts.remove(&old_key) { - Some(mut context) => {c.render( - ui, - &mut context, - None, - e.offset + e.pan, - e.scale, - e.clip_rect, - e.editor_mode,); + Some(mut context) => { + c.render( + ui, + &mut context, + None, + e.offset + e.pan, + e.scale, + e.clip_rect, + e.editor_mode, + ); e.contexts.insert(context.id_tmp.clone(), context); - }, - _=>{println!("could remove old key")} + } + _ => { + println!("could remove old key") + } } } } diff --git a/src/gui_egui/editor_wire_mode.rs b/src/gui_egui/editor_wire_mode.rs index 5db82452..b30872ad 100644 --- a/src/gui_egui/editor_wire_mode.rs +++ b/src/gui_egui/editor_wire_mode.rs @@ -1,4 +1,4 @@ -use crate::common::{Components, Id, Input}; +use crate::common::{ComponentStore, Components, Id, Input}; use crate::components::Wire; use crate::gui_egui::editor::{ get_component, CloseToComponent, Editor, EditorMode, GridOptions, SnapPriority, @@ -11,7 +11,7 @@ use crate::gui_egui::helper::{ use egui::{ Color32, Context, CursorIcon, LayerId, PointerButton, Pos2, Rect, Response, Shape, Stroke, Vec2, }; -use std::rc::Rc; +use std::{path::PathBuf, rc::Rc}; pub struct WireMode { pub mode_ended: bool, @@ -131,6 +131,11 @@ pub fn last_click(e: &mut Editor, closest_uw: CloseToComponent) { println!("Seems like you don't exactly have one input at the start or end of the wire"); } } + let path = PathBuf::from("autosave.json"); + ComponentStore { + store: e.components.clone(), + } + .save_file(&path); reset_wire_mode(&mut e.wm); } diff --git a/src/gui_vizia/gui.rs b/src/gui_vizia/gui.rs index 3a663db7..44d6b8bd 100644 --- a/src/gui_vizia/gui.rs +++ b/src/gui_vizia/gui.rs @@ -271,7 +271,8 @@ pub fn gui(cs: ComponentStore, path: &PathBuf) { .border_width(Pixels(1.0)); }, ); - }); + }) + .width(Pixels(400.0)); // Mid panel ScrollView::new(cx, 0.0, 0.0, true, true, |cx| {