" +
@@ -244,7 +244,7 @@
var key_hex = '0x' + parseInt(elto.key).toString(16) ;
// ui-address_and_tags
- var labels = SIMWARE.hash_labels_rev[elto.key] ;
+ var labels = SIMWARE.hash_labels_firm_rev[elto.key] ;
if (typeof labels !== 'undefined') {
labels = '' +
'"+index+"/"+ws_records.length+" "+msg)}if(ws_record_pb_obj!==null){var next_pbval=100*index/ws_records.length;ws_record_pb_obj.css("width",next_pbval+"%").attr("aria-valuenow",next_pbval)}}function simcore_record_playAt(index_current,index_last){if(ws_is_playing===false){simcore_record_showMsg(ws_last_played,"Stopped by user.");return}ws_last_played=index_current;if(index_current>=index_last){simcore_record_showMsg(index_last,"Done.");return}if(ws_records[index_current].description==="_pending event_"){simcore_record_playAt(index_current+1,index_last);return}eval(ws_records[index_current].element);var index_next=index_current+1;simcore_record_showMsg(index_next,ws_records[index_current].description);var wait_time=500;if(index_next0&&ws_records[ws_records.length-1].description==="_pending event_"){distance=ws_glowing_time}simcore_record_pushElto("_pending event_",";",distance)}}function simcore_record_resolve_pending(description,elto){if(ws_is_recording===true){var last_pending=ws_records.length;while(last_pending>0){last_pending--;if(ws_records[last_pending].description==="_pending event_"){break}}if(last_pending===0){simcore_record_setTimeBeforeNow(0);simcore_record_append_new(description,elto);return}ws_records[last_pending].description=description;ws_records[last_pending].element=elto;simcore_record_showMsg(0,"Recording...")}}function simcore_record_setTimeBeforeNow(distance){ws_last_time=Date.now()-distance}function simcore_record_addTimeAfterLast(distance){ws_last_time=ws_last_time+distance}function array_includes(arr,val){if(typeof arr.includes!="undefined"){return arr.includes(val)}for(var i=0;i0){e=i;n=n+1}}if(n>0){var tri_state_names=simhw_internalState("tri_state_names");var tri_name=tri_state_names[e];update_draw(simhw_sim_signal(tri_name),1)}if(n>1){update_bus_visibility("internalbus_fire","visible");simhw_internalState_set("fire_visible","internalbus",true);simhw_sim_state("BUS_IB").value=4294967295}else{update_bus_visibility("internalbus_fire","hidden");simhw_internalState_set("fire_visible","internalbus",false)}return n}function update_system_bus_fire(number_active_tri){if(simhw_internalState_get("fire_visible","databus")==true){update_bus_visibility("databus_fire","hidden");simhw_internalState_set("fire_visible","databus",false)}if(number_active_tri>1){update_bus_visibility("databus_fire","visible");simhw_internalState_set("fire_visible","databus",true);simhw_sim_state("BUS_DB").value=4294967295}return number_active_tri}function fn_updateE_now(key){if("E"==simhw_sim_signal(key).type){update_state(key)}}function fn_updateE_future(key){if(jit_fire_ndep[key]<1)fn_updateE_now(key);else return new Promise((function(resolve,reject){fn_updateE_now(key)}))}function fn_updateL_now(key){update_draw(simhw_sim_signal(key),simhw_sim_signal(key).value);if("L"==simhw_sim_signal(key).type){update_state(key)}}function fn_updateL_future(key){if(jit_fire_ndep[key]<1)fn_updateL_now(key);else return new Promise((function(resolve,reject){fn_updateL_now(key)}))}function update_state(key){var index_behavior=0;switch(simhw_sim_signal(key).behavior.length){case 0:return;break;case 1:index_behavior=0;break;default:index_behavior=simhw_sim_signal(key).value;if(simhw_sim_signal(key).behavior.lengthreg_maddr){break}assoc_i=i}if(-1==assoc_i){ws_alert("A new 'unknown' instruction is inserted,\n"+"please edit it (co, nwords, etc.) in the firmware textarea.");var new_ins=new Object;new_ins["name"]="unknown";new_ins["signature"]="unknown";new_ins["signatureGlobal"]="unknown";new_ins["co"]=0;new_ins["nwords"]=0;new_ins["mc-start"]=0;new_ins["fields"]=new Array;new_ins["microcode"]=new Array;new_ins["microcomments"]=new Array;SIMWARE["firmware"].push(new_ins);assoc_i=SIMWARE["firmware"].length-1}var pos=reg_maddr-parseInt(SIMWARE["firmware"][assoc_i]["mc-start"]);if(typeof SIMWARE["firmware"][assoc_i]["microcode"][pos]=="undefined"){SIMWARE["firmware"][assoc_i]["microcode"][pos]=new Object;SIMWARE["firmware"][assoc_i]["microcomments"][pos]=""}SIMWARE["firmware"][assoc_i]["microcode"][pos][key]=simhw_sim_signal(key).value;if(simhw_sim_signal(key).default_value==simhw_sim_signal(key).value){delete SIMWARE["firmware"][assoc_i]["microcode"][pos][key]}var bits=get_value(simhw_sim_state("REG_IR")).toString(2);bits="00000000000000000000000000000000".substring(0,32-bits.length)+bits;show_memories_values()}function propage_signal_update(key){if(true===get_cfg("is_interactive")){if(simhw_sim_signal(key).value!=simhw_sim_signal(key).default_value)simhw_sim_state("REG_MICROINS").value[key]=simhw_sim_signal(key).value;else delete simhw_sim_state("REG_MICROINS").value[key];var maddr_name=simhw_sim_ctrlStates_get().mpc.state;var curr_maddr=get_value(simhw_sim_state(maddr_name));var mc_obj=simhw_internalState("MC");var mcelto=control_memory_get(mc_obj,curr_maddr);if(typeof mcelto==="undefined"){mcelto={value:{},comments:null}}mcelto.value[key]=simhw_sim_signal(key).value;mcelto.comments=[];control_memory_set(mc_obj,curr_maddr,mcelto);update_signal_firmware(key);var SIMWARE=get_simware();document.getElementById("inputFirmware").value=saveFirmware(SIMWARE)}compute_behavior("FIRE "+key)}function update_memories(preSIMWARE){var i=0;set_simware(preSIMWARE);var SIMWARE=get_simware();simhw_internalState_reset("MC",{});var mc_obj=simhw_internalState("MC");var mcelto=null;for(i=0;i>23&255)-127;var mantissa=1+(hexvalue&8388607)/8388608;var valuef=sign*mantissa*Math.pow(2,exponent);if(-127===exponent)if(1===mantissa)valuef=sign===1?"+0":"-0";else valuef=sign*((hexvalue&8388607)/8388607)*Math.pow(2,-126);if(128===exponent)if(1===mantissa)valuef=sign===1?"+Inf":"-Inf";else valuef="NaN";return valuef}function uint_to_float32(value){var buf=new ArrayBuffer(4);new Uint32Array(buf)[0]=value;return new Float32Array(buf)[0]}function float32_to_uint(value){var buf=new ArrayBuffer(4);new Float32Array(buf)[0]=value;return new Uint32Array(buf)[0]}function float_class(a){var s=a&2147483648;s=s>>31;var e=a&2139095040;e=e>>23;var m=a&8388607;let rd=0;if(!m&&!e){rd=s?3:4}else if(!e){rd=s?2:6}else if(!(e^255)){if(m)rd=s?8:9;else rd=s?0:7}else{rd=s?1:5}return rd}function float_class_power2(a){var s=a&2147483648;s=s>>31;var e=a&2139095040;e=e>>23;var m=a&8388607;let rd=0;if(!m&&!e){rd=s?1<<3:1<<4}else if(!e){rd=s?1<<2:1<<6}else if(!(e^255)){if(m)rd=s?1<<8:1<<9;else rd=s?1<<0:1<<7}else{rd=s?1<<1:1<<5}return rd}function hex2char8(hexvalue){var valuec=[];valuec[0]=String.fromCharCode((hexvalue&4278190080)>>24);valuec[1]=String.fromCharCode((hexvalue&16711680)>>16);valuec[2]=String.fromCharCode((hexvalue&65280)>>8);valuec[3]=String.fromCharCode((hexvalue&255)>>0);return valuec}function simcoreui_pack(val,pack_size){var base_str="0".repeat(pack_size);return base_str.substring(0,pack_size-val.length)+val}function hex2bin(hexvalue){var valuebin=hexvalue.toString(2);valuebin=simcoreui_pack(valuebin,32);valuebin=valuebin.substring(0,4)+" "+valuebin.substring(4,8)+" "+valuebin.substring(8,12)+" "+valuebin.substring(12,16)+"
"+valuebin.substring(16,20)+" "+valuebin.substring(20,24)+" "+valuebin.substring(24,28)+" "+valuebin.substring(28,32);return valuebin}function value2string(format,value){var fmt_value="";var fmt=format.split("_");switch(fmt[0]){case"unsigned":fmt_value=value.toString(fmt[1]).toUpperCase();break;case"float":fmt_value=hex2float(value);break;case"char":fmt_value="'"+String.fromCharCode(value)+"'";break;default:fmt_value=value.toString()}if(fmt[2]==="fill"){fmt_value=simcoreui_pack(fmt_value,8)}return fmt_value}function show_rf_names(){return simcore_action_ui("CPU",0,"show_rf_names")()}function get_screen_content(){return simcore_action_ui("SCREEN",0,"get_screen_content")()}function set_screen_content(screen){simcore_action_ui("SCREEN",0,"set_screen_content")(screen)}function get_keyboard_content(){return simcore_action_ui("KBD",0,"get_keyboard_content")()}function set_keyboard_content(keystrokes){simcore_action_ui("KBD",0,"set_keyboard_content")(keystrokes)}function show_main_memory(memory,index,redraw,updates){return simcore_action_ui("MEMORY",0,"show_main_memory")(memory,index,redraw,updates)}function show_control_memory(memory,index,redraw){return simcore_action_ui("MEMORY",0,"show_control_memory")(memory,index,redraw)}function show_cache_memory(memory){return simcore_action_ui("MEMORY",0,"show_cache_memory")(memory)}function show_memories_values(){var pc_name=simhw_sim_ctrlStates_get().pc.state;var reg_pc=get_value(simhw_sim_state(pc_name));show_main_memory(simhw_internalState("MP"),reg_pc,true,true);var maddr_name=simhw_sim_ctrlStates_get().mpc.state;var reg_maddr=get_value(simhw_sim_state(maddr_name));show_control_memory(simhw_internalState("MC"),reg_maddr,true);show_cache_memory(simhw_internalState("CM"))}function update_draw(obj,value){return simcore_action_ui("CPU",1,"update_draw")(obj,value)}function update_bus_visibility(bus_name,value){return simcore_action_ui("CPU",1,"update_bus_visibility")(bus_name,value)}function refresh(){for(var key in simhw_sim_signals()){update_draw(simhw_sim_signals()[key],simhw_sim_signals()[key].value)}show_dbg_ir(get_value(simhw_sim_state("REG_IR_DECO")))}function show_dbg_ir(value){return simcore_action_ui("MEMORY",0,"show_dbg_ir")(value)}function show_dbg_mpc(){return simcore_action_ui("MEMORY",0,"show_dbg_mpc")()}function show_asmdbg_pc(){return simcore_action_ui("MEMORY",0,"show_asmdbg_pc")()}function ws_alert(msg){if(typeof document==="undefined"){console.log(msg);return true}alert(msg);return true}function element_scroll_get(list_id){var offset=0;var obj_byid=$(list_id);if(obj_byid.length>0){offset=obj_byid[0].scrollTop}return offset}function element_scroll_set(list_id,offset){var obj_byid=$(list_id);if(obj_byid.length>0){obj_byid[0].scrollTop=offset}}function element_scroll_setRelative(list_id,obj_id,offset){var obj_byid=$(obj_id);if(obj_byid.length>0){var topPos=obj_byid[0].offsetTop;element_scroll_set(list_id,topPos+offset)}}var colors_schemes={color14:["#000000","#FFFFFF","#FF0000","#FF8800","#FFFF00","#88FF00","#00FF00","#00FF88","#00FFFF","#0088FF","#0000FF","#8800FF","#FF00FF","#FF0088"],color16:["#000000","#FFFFFF","#9D9D9D","#BE2633","#E06F8B","#493C2B","#A46422","#EB8931","#F7E26B","#2F484E","#44891A","#A3CE27","#1B2632","#005784","#31A2F2","#B2DCEF"],color256:["#000000","#800000","#008000","#808000","#000080","#800080","#008080","#c0c0c0","#808080","#ff0000","#00ff00","#ffff00","#0000ff","#ff00ff","#00ffff","#ffffff","#000000","#00005f","#000087","#0000af","#0000d7","#0000ff","#005f00","#005f5f","#005f87","#005faf","#005fd7","#005fff","#008700","#00875f","#008787","#0087af","#0087d7","#0087ff","#00af00","#00af5f","#00af87","#00afaf","#00afd7","#00afff","#00d700","#00d75f","#00d787","#00d7af","#00d7d7","#00d7ff","#00ff00","#00ff5f","#00ff87","#00ffaf","#00ffd7","#00ffff","#5f0000","#5f005f","#5f0087","#5f00af","#5f00d7","#5f00ff","#5f5f00","#5f5f5f","#5f5f87","#5f5faf","#5f5fd7","#5f5fff","#5f8700","#5f875f","#5f8787","#5f87af","#5f87d7","#5f87ff","#5faf00","#5faf5f","#5faf87","#5fafaf","#5fafd7","#5fafff","#5fd700","#5fd75f","#5fd787","#5fd7af","#5fd7d7","#5fd7ff","#5fff00","#5fff5f","#5fff87","#5fffaf","#5fffd7","#5fffff","#870000","#87005f","#870087","#8700af","#8700d7","#8700ff","#875f00","#875f5f","#875f87","#875faf","#875fd7","#875fff","#878700","#87875f","#878787","#8787af","#8787d7","#8787ff","#87af00","#87af5f","#87af87","#87afaf","#87afd7","#87afff","#87d700","#87d75f","#87d787","#87d7af","#87d7d7","#87d7ff","#87ff00","#87ff5f","#87ff87","#87ffaf","#87ffd7","#87ffff","#af0000","#af005f","#af0087","#af00af","#af00d7","#af00ff","#af5f00","#af5f5f","#af5f87","#af5faf","#af5fd7","#af5fff","#af8700","#af875f","#af8787","#af87af","#af87d7","#af87ff","#afaf00","#afaf5f","#afaf87","#afafaf","#afafd7","#afafff","#afd700","#afd75f","#afd787","#afd7af","#afd7d7","#afd7ff","#afff00","#afff5f","#afff87","#afffaf","#afffd7","#afffff","#d70000","#d7005f","#d70087","#d700af","#d700d7","#d700ff","#d75f00","#d75f5f","#d75f87","#d75faf","#d75fd7","#d75fff","#d78700","#d7875f","#d78787","#d787af","#d787d7","#d787ff","#d7af00","#d7af5f","#d7af87","#d7afaf","#d7afd7","#d7afff","#d7d700","#d7d75f","#d7d787","#d7d7af","#d7d7d7","#d7d7ff","#d7ff00","#d7ff5f","#d7ff87","#d7ffaf","#d7ffd7","#d7ffff","#ff0000","#ff005f","#ff0087","#ff00af","#ff00d7","#ff00ff","#ff5f00","#ff5f5f","#ff5f87","#ff5faf","#ff5fd7","#ff5fff","#ff8700","#ff875f","#ff8787","#ff87af","#ff87d7","#ff87ff","#ffaf00","#ffaf5f","#ffaf87","#ffafaf","#ffafd7","#ffafff","#ffd700","#ffd75f","#ffd787","#ffd7af","#ffd7d7","#ffd7ff","#ffff00","#ffff5f","#ffff87","#ffffaf","#ffffd7","#ffffff","#080808","#121212","#1c1c1c","#262626","#303030","#3a3a3a","#444444","#4e4e4e","#585858","#626262","#6c6c6c","#767676","#808080","#8a8a8a","#949494","#9e9e9e","#a8a8a8","#b2b2b2","#bcbcbc","#c6c6c6","#d0d0d0","#dadada","#e4e4e4","#eeeeee"]};function colors_clone(cs){var colors=colors_schemes[cs];if(typeof colors=="undefined"){colors=colors_schemes["color16"]}return colors.map((x=>x))}function simcore_init(with_ui){var ret={};ret.msg="";ret.ok=true;if(with_ui){restore_cfg()}else{reset_cfg_values()}return ret}function simcore_init_hw(simhw_name){var ret={};ret.msg="";ret.ok=true;var hwid=simhw_getIdByName(simhw_name);if(hwid<0){ret.msg="ERROR: unknown hardware: "+simhw_name+".
\n";ret.ok=false;return ret}simhw_setActive(hwid);var ret1=simcore_init_ui({});if(false===ret1.ok){ret.msg=ret.msg;ret.ok=false;return ret}return ret}function simcore_welcome(){var ret={};ret.msg="";ret.ok=true;console.log("");console.log("██╗ ██╗███████╗██████╗ ███████╗██╗███╗ ███╗");console.log("██║ ██║██╔════╝██╔══██╗██╔════╝██║████╗ ████║");console.log("██║ █╗ ██║█████╗ ██████╔╝███████╗██║██╔████╔██║");console.log("██║███╗██║██╔══╝ ██╔═══╝ ╚════██║██║██║╚██╔╝██║");console.log("╚███╔███╔╝███████╗██║ ███████║██║██║ ╚═╝ ██║");console.log(" ╚══╝╚══╝ ╚══════╝╚═╝ ╚══════╝╚═╝╚═╝ ╚═╝");console.log("");console.log("Stable: https://github.com/wepsim/wepsim");console.log("Beta: https://github.com/acaldero/wepsim");console.log("");return ret}function simcore_init_ui(hash_detail2init){var ret={};ret.msg="";ret.ok=true;var detail_id=0;var sim_components=simhw_sim_components();for(var elto in sim_components){sim_components[elto].details_ui=[];for(var index in sim_components[elto].details_name){sim_components[elto].details_ui[index]={};detail_id=sim_components[elto].details_name[index];if(typeof hash_detail2init[detail_id]!=="undefined"){sim_components[elto].details_ui[index]=hash_detail2init[detail_id];sim_components[elto].details_ui[index].init()}}}return ret}function simcore_action_ui(component_name,detail_id,action_name){var sim_components=simhw_sim_components();if(typeof sim_components[component_name].details_ui==="undefined"){return simcore_do_nothing_handler}if(typeof sim_components[component_name].details_ui[detail_id][action_name]==="undefined"){return simcore_do_nothing_handler}return sim_components[component_name].details_ui[detail_id][action_name]}function simcore_init_eventlistener(context,hash_detail2action,hash_signal2action){var context_obj=null;var r=[];var o=null;context_obj=document.getElementById(context).contentDocument;if(null==context_obj){console.log('warning: unreferenced graphic element context named "'+r[0]+'".');return}var sim_signals=simhw_sim_signals();for(var key in sim_signals){if(typeof hash_signal2action[key+"click"]==="undefined"){hash_signal2action[key+"click"]=function(key_value){return function(){hash_signal2action[""](key_value,"click")}}(key)}if(typeof hash_signal2action[key+"dblclick"]==="undefined"){hash_signal2action[key+"dblclick"]=function(key_value){return function(){hash_signal2action[""](key_value,"dblclick")}}(key)}for(var j=0;j\n"+"Please load some assembly code.
";ret.ok=false;return ret}var SIMWARE=get_simware();if(!(typeof curr_segments[".ktext"]!="undefined"&&SIMWARE.labels2.kmain)&&!(typeof curr_segments[".text"]!="undefined"&&SIMWARE.labels2.main)){ret.msg="labels 'kmain' (in .ktext) or 'main' (in .text) do not exist!";ret.ok=false;return ret}return ret}function simcore_packerror_at(reg_maddr,msg){var ret={};var hex_maddr="0x"+parseInt(reg_maddr).toString(16);ret.ok=false;ret.msg=msg+" at maddr="+hex_maddr+".";return ret}function simcore_check_if_can_continue2(reg_maddr,reg_pc){var ret={};ret.ok=true;ret.msg="";var curr_MC=simhw_internalState("MC");var mcelto=control_memory_get(curr_MC,reg_maddr);if(typeof mcelto==="undefined"){return simcore_packerror_at(reg_maddr,"Error: undefined microinstruction")}if(simhw_internalState_get("fire_visible","databus")==true||simhw_internalState_get("fire_visible","internalbus")==true){return simcore_packerror_at(reg_maddr,"Error: two or more tri-states are active")}var curr_segments=simhw_internalState("segments");if(reg_pc=curr_segments[".ktext"].begin){return ret}if(reg_pc=curr_segments[".text"].begin){return ret}if(mcelto.is_native&&0===reg_maddr){if(reg_pc==curr_segments[".ktext"].end||reg_pc==curr_segments[".text"].end){return ret}}if(false==mcelto.is_native&&0!==reg_maddr){if(reg_pc==curr_segments[".ktext"].end||reg_pc==curr_segments[".text"].end){return ret}}ret.ok=false;ret.msg="The program has finished because the PC register points outside .ktext/.text code segments";return ret}function simcore_check_if_can_continue(){var pc_name=simhw_sim_ctrlStates_get().pc.state;var reg_pc=parseInt(get_value(simhw_sim_state(pc_name)));var maddr_name=simhw_sim_ctrlStates_get().mpc.state;var reg_maddr=get_value(simhw_sim_state(maddr_name));return simcore_check_if_can_continue2(reg_maddr,reg_pc)}function simcore_reset(){var ret={};ret.msg="";ret.ok=true;var SIMWARE=get_simware();var curr_firm=simhw_internalState("FIRMWARE");var curr_segments=simhw_internalState("segments");var curr_MC=simhw_internalState("MC");var sim_components=simhw_sim_components();var ctrl_states=simhw_sim_ctrlStates_get();var pc_name=ctrl_states.pc.state;var pc_state=simhw_sim_state(pc_name);var sp_name=ctrl_states.sp.state;var sp_state=simhw_sim_state(sp_name);if(curr_firm.stackRegister!=null){sp_name=curr_firm.stackRegister;sp_state=simhw_sim_states().BR[sp_name];ctrl_states.sp.state="BR."+curr_firm.stackRegister}for(var elto in sim_components){var reset_signal_name=sim_components[elto].name+"_RESET";compute_general_behavior(reset_signal_name)}if(typeof curr_segments[".ktext"]!=="undefined"&&SIMWARE.labels2.kmain){set_value(pc_state,parseInt(SIMWARE.labels2.kmain));show_asmdbg_pc()}else if(typeof curr_segments[".text"]!=="undefined"&&SIMWARE.labels2.main){set_value(pc_state,parseInt(SIMWARE.labels2.main));show_asmdbg_pc()}if(typeof curr_segments[".stack"]!=="undefined"&&typeof sp_state!=="undefined"){set_value(sp_state,parseInt(curr_segments[".stack"].end)&4294967292)}var new_maddr=get_value(simhw_sim_state("MUXA_MICROADDR"));var mcelto=control_memory_get(curr_MC,new_maddr);if(typeof mcelto==="undefined"){mcelto={value:simhw_sim_state("REG_MICROINS").default_value,is_native:false}}var new_mins=get_value(mcelto);if(false==mcelto.is_native){compute_general_behavior("CLOCK")}show_dbg_ir(get_value(simhw_sim_state("REG_IR_DECO")));for(elto in sim_components){for(var index in sim_components[elto].details_name){if(typeof sim_components[elto].details_ui[index].reset!=="undefined"){sim_components[elto].details_ui[index].reset()}}}return ret}function simcore_execute_microinstruction(){var ret=simcore_check_if_can_continue();if(false===ret.ok){return ret}compute_general_behavior("CLOCK");show_dbg_mpc();return ret}function simcore_execute_microinstruction2(reg_maddr,reg_pc){var ret=simcore_check_if_can_continue2(reg_maddr,reg_pc);if(false===ret.ok){return ret}compute_general_behavior("CLOCK");show_dbg_mpc();return ret}function simcore_execute_microprogram(options){var ret=simcore_check_if_can_continue();if(false===ret.ok){return ret}var before_state=null;var after_state=null;var curr_mpc="";var curr_MC=simhw_internalState("MC");var maddr_name=simhw_sim_ctrlStates_get().mpc.state;var maddr_state=simhw_sim_state(maddr_name);if(typeof options.before_microinstruction==="undefined"){options.before_microinstruction=simcore_do_nothing_handler}if(typeof options.after_microinstruction==="undefined"){options.after_microinstruction=simcore_do_nothing_handler}var i_clks=0;var limitless=options.cycles_limit<0;var cur_addr=0;var mcelto=null;var oolimits=false;do{options.before_microinstruction(curr_MC,cur_addr);compute_general_behavior("CLOCK");i_clks++;options.after_microinstruction(curr_MC,cur_addr);if(limitless===false&&i_clks>=options.cycles_limit){ret.msg="Warning: clock cycles limit reached in a single instruction.";ret.ok=false;break}cur_addr=get_value(maddr_state);mcelto=control_memory_get(curr_MC,cur_addr);if(typeof mcelto==="undefined"){ret.msg="Error: undefined microinstruction at "+cur_addr+".";ret.ok=false;break}if(i_clks>=options.cycles_limit&&-1!=options.cycles_limit){oolimits=true}}while(false==oolimits&&0!=cur_addr);if(true==ret.ok&&mcelto.is_native){compute_general_behavior("CLOCK")}if(get_cfg("DBG_level")=="microinstruction"){show_dbg_mpc()}return ret}function simcore_execute_program(options){var ret={};ret.ok=true;ret.msg="";var curr_segments=simhw_internalState("segments");var pc_name=simhw_sim_ctrlStates_get().pc.state;var pc_state=simhw_sim_state(pc_name);var reg_pc=get_value(pc_state);var reg_pc_before=get_value(pc_state)-4;var code_begin=0;if(typeof curr_segments[".text"]!="undefined"&&typeof curr_segments[".text"].begin!="undefined")code_begin=parseInt(curr_segments[".text"].begin);var code_end=0;if(typeof curr_segments[".text"]!="undefined"&&typeof curr_segments[".text"].end!="undefined")code_end=parseInt(curr_segments[".text"].end);var kcode_begin=0;if(typeof curr_segments[".ktext"]!="undefined"&&typeof curr_segments[".ktext"].begin!="undefined")kcode_begin=parseInt(curr_segments[".ktext"].begin);var kcode_end=0;if(typeof curr_segments[".ktext"]!="undefined"&&typeof curr_segments[".ktext"].end!="undefined")kcode_end=parseInt(curr_segments[".ktext"].end);var ret1=null;var before_state=null;var after_state=null;var curr_pc="";var SIMWARE=get_simware();if(typeof options.verbalize!=="undefined"){set_cfg("verbal_verbose",options.verbalize)}if(typeof options.before_instruction==="undefined"){options.before_instruction=simcore_do_nothing_handler}if(typeof options.after_instruction==="undefined"){options.after_instruction=simcore_do_nothing_handler}var ins_executed=0;while(reg_pc=code_begin||reg_pc=kcode_begin){options.before_instruction(SIMWARE,reg_pc);ret1=simcore_execute_microprogram(options);if(false===ret1.ok){return ret1}options.after_instruction(SIMWARE,reg_pc);ins_executed++;if(ins_executed>options.instruction_limit&&-1!=options.instruction_limit){ret.ok=false;ret.msg="more than "+options.instruction_limit+" instructions executed before application ends.";return ret}reg_pc_before=reg_pc;reg_pc=get_value(pc_state)}return ret}function simcore_do_nothing_handler(){return null}function simcore_compile_firmware(textToMCompile){var ret={};ret.msg="";ret.ok=true;if(""==textToMCompile){ret.msg="Empty Firmware";ret.ok=false;return ret}var preSM=null;try{preSM=loadFirmware(textToMCompile);ret.simware=preSM}catch(e){ret.msg="ERROR: at line: "+e.lineNumber+" and column: "+e.columnNumber;ret.ok=false;return ret}if(preSM.error!=null){ret.msg=preSM.error;ret.ok=false;return ret}update_memories(preSM);simcore_reset();return ret}function simcore_compile_assembly(textToCompile){var ret={};ret.msg="";ret.ok=true;var SIMWARE=get_simware();if(SIMWARE.firmware.length===0){ret.msg="Empty microcode, please load the microcode first.";ret.ok=false;return ret}var SIMWAREaddon=simlang_compile(textToCompile,SIMWARE);ret.simware=SIMWAREaddon;if(SIMWAREaddon.error!=null){ret.msg=SIMWAREaddon.error;ret.ok=false;return ret}set_simware(SIMWAREaddon);update_memories(SIMWARE);simcore_reset();return ret}function simcore_hardware_export(hw_name){var ret={};ret.msg="{}";ret.ok=false;var hw_obj=simhw_getObjByName(hw_name);if(null===hw_obj){return ret}ret.ok=true;ret.msg=JSON.stringify(hw_obj,(function(key,value){if(typeof value==="function"){return"/Function("+value.toString()+")/"}return value}));return ret}function simcore_hardware_import(hw_json){var ret={};ret.msg="";ret.ok=true;hw_obj=JSON.parse(hw_json,(function(key,value){if(typeof value==="string"&&value.startsWith("/Function(")&&value.endsWith(")/")){value=value.substring(10,value.length-2);return eval("("+value+")")}return value}));simhw_add(hw_obj);return ret}function simcore_native_get_signal(elto){return get_value(simhw_sim_signal(elto))>>>0}function simcore_native_set_signal(elto,value){set_value(simhw_sim_signal(elto),value);compute_behavior("FIRE "+elto);return value}function simcore_native_get_value(component,elto){var index=0;var sim_components=simhw_sim_components();var compo_index=component;if("BR"===component)compo_index="CPU";if("DEVICE"===component)compo_index="IO";if(typeof sim_components[compo_index].get_value!=="undefined"){return sim_components[compo_index].get_value(elto)}return false}function simcore_native_set_value(component,elto,value){var index=0;var sim_components=simhw_sim_components();var compo_index=component;if("BR"===component)compo_index="CPU";if("DEVICE"===component)compo_index="IO";if(typeof sim_components[compo_index].set_value!=="undefined"){return sim_components[compo_index].set_value(elto,value)}return false}function simcore_native_get_fields(signature_raw){var SIMWARE=get_simware();for(var key in SIMWARE.firmware){if(SIMWARE.firmware[key].signatureRaw===signature_raw){return SIMWARE.firmware[key].fields}}}function simcore_native_get_field_from_ir(fields,index){if(typeof fields[index]==="undefined"){ws_alert("simcore_native_get_field_from_ir: index ("+index+") out of range.");return false}var value=get_value(simhw_sim_state("REG_IR"));var left_shift=31-parseInt(fields[index].startbit);var right_shift=parseInt(fields[index].stopbit);value=value<>>left_shift;value=value>>>right_shift;return value}function simcore_native_deco(){compute_behavior("DECO")}function simcore_native_go_maddr(maddr){set_value(simhw_sim_state("MUXA_MICROADDR"),maddr)}function simcore_native_go_opcode(){var maddr=get_value(simhw_sim_state("ROM_MUXA"));set_value(simhw_sim_state("MUXA_MICROADDR"),maddr)}function simcore_native_go_instruction(signature_raw){var SIMWARE=get_simware();for(var key in SIMWARE.firmware){if(SIMWARE.firmware[key].signatureRaw===signature_raw){var maddr=SIMWARE.firmware[key]["mc-start"];set_value(simhw_sim_state("MUXA_MICROADDR"),maddr);return}}}function simcore_simstate_checklist2state(checklist){var o={};var ret=false;checklist=checklist.replace(/;|==|!=|>=|<=|=|>|v!=""));for(var i=0;i"===expected_result[compo][elto].op)diff.fulfill=parseInt(diff.obtained)>parseInt(diff.expected);else if("<"===expected_result[compo][elto].op)diff.fulfill=parseInt(diff.obtained)="===expected_result[compo][elto].op)diff.fulfill=parseInt(diff.obtained)>=parseInt(diff.expected);else if("<="===expected_result[compo][elto].op)diff.fulfill=parseInt(diff.obtained)<=parseInt(diff.expected);else if("=="===expected_result[compo][elto].op)diff.fulfill=diff.expected==diff.obtained;else if("!="===expected_result[compo][elto].op)diff.fulfill=diff.expected!=diff.obtained;d.result.push(diff);if(diff.fulfill===false)d.errors++}}if(newones_too&&typeof obtained_result[compo]!="undefined"){for(elto in obtained_result[compo]){d.neltos_obtained++;if(typeof expected_result[compo]!="undefined"&&typeof expected_result[compo][elto]!="undefined"){continue}diff={};diff.expected=obtained_result[compo][elto].default_value;diff.obtained=obtained_result[compo][elto].value;diff.fulfill=diff.expected===diff.obtained;diff.elto_type=compo.toLowerCase();diff.elto_id=obtained_result[compo][elto].id;diff.elto_op="=";d.result.push(diff);if(diff.fulfill===false)d.errors++}}}return d}function simcore_simstate_diff_results(expected_result,obtained_result){return simcore_simstate_check_results(expected_result,obtained_result,true)}function simcore_simstate_diff_states(before_state_obj,after_state_obj){var before_arr=simcore_simstate_state2checklist(before_state_obj,"").split(";");var after_arr=simcore_simstate_state2checklist(after_state_obj,"").split(";");return after_arr.filter((function(elto){return!before_arr.includes(elto)})).join(";").trim()}function simcore_simstate_checkreport2txt(checklist){var o="";for(var i=0;i"+""+""+"Type | "+"IdentificationId. | "+"Values in the clipboard state | "+"Values in the selected state | "+"
"+""+"";for(var i=0;i"+""+checklist[i].elto_type+" | "+""+checklist[i].elto_id+" | "+""+checklist[i].elto_op+" "+checklist[i].expected+" | "+""+checklist[i].obtained+" | "+""}o+=""+"
";return o}function simcore_voice_canSpeak(){if(typeof window.speechSynthesis=="undefined"){return false}if(false===get_cfg("use_voice")){return false}return true}function simcore_voice_speak(msg){var ssu=null;if(simcore_voice_canSpeak()){ssu=new SpeechSynthesisUtterance(msg);ssu.lang="es-ES";if("en"==get_cfg("ws_idiom"))ssu.lang="en-US";if("es"==get_cfg("ws_idiom"))ssu.lang="es-EN";window.speechSynthesis.speak(ssu)}}function simcore_voice_stopSpeak(){if(simcore_voice_canSpeak()){window.speechSynthesis.cancel()}}var simcore_rest={};function simcore_rest_reset(){simcore_rest={}}function simcore_rest_add(name,description){simcore_rest[name]={endpoint:description.endpoint,user:description.user,pass:description.pass,last_request:null}}function simcore_rest_list(){return simcore_rest}function simcore_rest_get(name){return simcore_rest[name]}function simcore_rest_call(name,method,uri,data){var rest_info=simcore_rest[name];if(typeof rest_info==="undefined"){return false}var api_endpoint=rest_info.endpoint;if(api_endpoint.value instanceof Vuex.Store){api_endpoint=get_value(api_endpoint)}if(api_endpoint.trim()===""){return false}var basic_auth="Basic "+btoa(rest_info.user+":"+rest_info.pass);var enc_data=JSON.stringify(data);var request={url:api_endpoint+uri,type:method,contentType:"application/json",accepts:"application/json",cache:false,dataType:"json",data:enc_data,beforeSend:function(xhr){if(rest_info.user.trim()!==""){xhr.setRequestHeader("Authorization",basic_auth)}},error:function(jqXHR){console.log("ajax error "+jqXHR.status)}};rest_info.last_request=$.ajax(request);return true}var simcore_notifications=[];function simcore_notifications_get(){return simcore_notifications}function simcore_notifications_reset(){simcore_notifications=[]}function simcore_notifications_add2(ntf){simcore_notifications.push({title:ntf.title,message:ntf.message,type:ntf.type,date:ntf.date})}function simcore_notifications_add(ntf_title,ntf_message,ntf_type,ntf_delay){simcore_notifications.push({title:$("").html(ntf_title).text(),message:$("
").html(ntf_message).text(),type:ntf_type,date:(new Date).getTime()})}function get_value(sim_obj){if(sim_obj.value instanceof Vuex.Store){return sim_obj.value.state.value}return sim_obj.value}function set_value(sim_obj,value){if(sim_obj.value instanceof Vuex.Store){sim_obj.value.commit("set_value",value);return}var old_value=sim_obj.value;sim_obj.value=value;if(old_value!=value){sim_obj.changed=true}}function reset_value(sim_obj){if(sim_obj.value instanceof Vuex.Store){set_value(sim_obj,sim_obj.default_value);return}if(typeof sim_obj.default_value=="object"){sim_obj.changed=true;sim_obj.value=Object.create(sim_obj.default_value);return}if(sim_obj instanceof Array){sim_obj.changed=true;for(var i=0;i",""":'"',"'":"'"};function treatHTMLSequences(text_with_html){var re=null;var key=null;for(key in html_sequences){re=new RegExp(key,"gi");text_with_html=text_with_html.replace(re,html_sequences[key])}return text_with_html}function control_memory_getkeys(memory){return Object.keys(memory)}function control_memory_get(memory,elto){return memory[elto]}function control_memory_set(memory,elto,melto){if(typeof melto.changed==="undefined")melto.changed=false;if(typeof melto.state==="undefined")melto.state=false;if(typeof melto.breakpoint==="undefined")melto.breakpoint=false;if(typeof melto.notify==="undefined")melto.notify=[];if(typeof melto.is_native==="undefined")melto.is_native=false;var comments_str="";if(null!=melto.comments){comments_str=melto.comments;if(melto.comments instanceof Array)comments_str=melto.comments.join("\n");melto.state=melto.state||comments_str.trim().split("state:").length>1;melto.breakpoint=melto.breakpoint||comments_str.trim().split("break:").length>1;melto.notify=comments_str.trim().split("notify:");for(var k=0;k";if(active_verbal.trim()==="")active_verbal="";return"Activated signals are: "+active_signals+". Associated actions are: "+active_verbal}function main_memory_getkeys(memory){return Object.keys(memory)}function main_memory_get(memory,elto){return memory[elto]}function main_memory_set(memory,elto,melto){if(typeof melto.changed==="undefined")melto.changed=false;if(typeof melto.state==="undefined")melto.state=false;if(typeof melto.breakpoint==="undefined")melto.breakpoint=false;if(typeof melto.notify==="undefined")melto.notify=[];if(typeof melto.is_assembly==="undefined")melto.is_assembly=false;if(typeof melto.source==="undefined")melto.source="";var comments_str="";if(null!=melto.comments){comments_str=melto.comments.join("\n");melto.state=melto.state||comments_str.trim().split("state:").length>1;melto.breakpoint=melto.breakpoint||comments_str.trim().split("break:").length>1;melto.notify=comments_str.trim().split("notify:");for(var k=0;k>8;if(2==filter_elto)dbvalue=(value&16711680)>>16;if(3==filter_elto)dbvalue=(value&4278190080)>>24;break;case 1:if(0==filter_elto)dbvalue=value&65535;if(1==filter_elto)dbvalue=value&65535;if(2==filter_elto)dbvalue=(value&4294901760)>>16;if(3==filter_elto)dbvalue=(value&4294901760)>>16;break;case 2:if(0==filter_elto)dbvalue=value&16777215;if(1==filter_elto)dbvalue=value&4294967040;break;case 3:dbvalue=value;break}return dbvalue}function main_memory_updatevalues(value,dbvalue,filter_size,filter_elto){switch(filter_size){case 0:if(0==filter_elto)value=value&4294967040|dbvalue&255;if(1==filter_elto)value=value&4294902015|(dbvalue&255)<<8;if(2==filter_elto)value=value&4278255615|(dbvalue&255)<<16;if(3==filter_elto)value=value&16777215|(dbvalue&255)<<24;break;case 1:if(0==filter_elto)value=value&4294901760|dbvalue&65535;if(1==filter_elto)value=value&4294901760|dbvalue&65535;if(2==filter_elto)value=value&65535|(dbvalue&65535)<<16;if(3==filter_elto)value=value&65535|(dbvalue&65535)<<16;break;case 2:if(0==filter_elto)value=value&4278190080|dbvalue&16777215;if(1==filter_elto)value=value&255|dbvalue&4294967040;break;case 3:value=dbvalue;break}return value}function main_memory_get_program_counter(){var r_ref=simhw_sim_ctrlStates_get().pc;var r_value=null;if(typeof r_ref!=="undefined"){r_ref=simhw_sim_state(r_ref.state)}if(typeof r_ref!=="undefined"){r_value=get_value(r_ref)}return r_value}function main_memory_get_baseaddr(){var r_ref=simhw_sim_ctrlStates_get();if(typeof r_ref==="undefined"){return null}var parts=null;var r_value=0;var r_ref2=null;var all_baseaddr={};for(var elto in r_ref){if(r_ref[elto].is_pointer==false){continue}parts=r_ref[elto].state.split(".");if(parts[0]=="BR"){r_value=4294967292;r_ref2=simhw_sim_states().BR[parts[1]]}else{r_value=0;r_ref2=simhw_sim_state(r_ref[elto].state)}if(typeof r_ref2!=="undefined"){r_value=get_value(r_ref2)}all_baseaddr[elto]=r_value}return all_baseaddr}function get_deco_from_pc(pc){var mp_obj=simhw_internalState("MP");if(typeof mp_obj==="undefined"||typeof mp_obj[pc]==="undefined"||typeof mp_obj[pc].source==="undefined"){return""}return mp_obj[pc].source}function get_verbal_from_current_pc(){var pc_name=simhw_sim_ctrlStates_get().pc.state;var reg_pc=get_value(simhw_sim_state(pc_name));var pc=parseInt(reg_pc)-4;var decins=get_deco_from_pc(pc);if(""==decins.trim()){decins="not jet defined"}return"Current instruction is: "+decins+" and PC points to "+show_value(pc)+". "}function cache_memory_update_stats(memory,address,parts,r_w,m_h,clock_timestamp){memory.stats.n_access++;memory.stats.last_addr=address;memory.stats.last_parts=parts;memory.stats.last_r_w=r_w;memory.stats.last_h_m=m_h;if(m_h=="miss"){memory.stats.n_misses++}else{memory.stats.n_hits++}memory.sets[parts.set].tags[parts.tag].n_access++;if(r_w=="write"){memory.sets[parts.set].tags[parts.tag].dirty=1}memory.sets[parts.set].tags[parts.tag].timestamp=clock_timestamp}function cache_memory_select_victim(memory,set){var keys=Object.keys(memory.sets[set].tags);var tag_victim=0;if(memory.cfg.replace_pol=="lfu"){tag_victim=keys[0];var tag_naccess=memory.sets[parts.set].tags[tag_victim].n_access;for(var i=1;imemory.sets[parts.set].tags[keys[i]].n_access){tag_victim=keys[i];tag_naccess=memory.sets[parts.set].tags[tag_victim].n_access}}}else if(memory.cfg.replace_pol=="fifo"){tag_victim=keys[0];var tag_stamp=memory.sets[parts.set].tags[tag_victim].timestamp;for(var i=1;imemory.sets[parts.set].tags[keys[i]].timestamp){tag_victim=keys[i];tag_stamp=memory.sets[parts.set].tags[tag_victim].timestamp}}}else if(memory.cfg.replace_pol=="first"){tag_victim=keys[0]}return tag_victim}function cache_memory_init(name,via_size,off_size,set_size,replace_pol,su_pol,next_cache){var c={stats:{},cfg:{},sets:{}};c.cfg.name=name;c.cfg.via_size=via_size;c.cfg.off_size=off_size;c.cfg.set_size=set_size;c.cfg.vps_size=via_size-set_size;c.cfg.tag_size=32-set_size-off_size;c.cfg.mask_tag=Math.pow(2,c.cfg.tag_size)-1>>>0;c.cfg.mask_set=Math.pow(2,c.cfg.set_size)-1>>>0;c.cfg.mask_off=Math.pow(2,c.cfg.off_size)-1>>>0;c.cfg.mask_tag=c.cfg.mask_tag<<32-c.cfg.tag_size>>>0;c.cfg.mask_set=c.cfg.mask_set<>>0;c.cfg.replace_pol=replace_pol;c.cfg.su_pol=su_pol;c.cfg.next_cache=next_cache;c.stats.n_access=0;c.stats.n_hits=0;c.stats.n_misses=0;c.stats.last_addr=0;c.stats.last_parts=cache_memory_split(c,0);c.stats.last_r_w="";c.stats.last_h_m="";return c}function cache_memory_init2(cfg){return cache_memory_init(cfg.name,cfg.via_size,cfg.off_size,cfg.set_size,cfg.replace_pol,cfg.su_pol,cfg.next_cache)}function cache_memory_init3(array_cm_cfg){var array_cm=[];for(var i=0;i>>0;parts.tag=(address&memory.cfg.mask_tag)>>>32-memory.cfg.tag_size;parts.set=(address&memory.cfg.mask_set)>>>memory.cfg.off_size;parts.offset=address&memory.cfg.mask_off;return parts}function cache_memory_access(memory,address,r_w,clock_timestamp){if(memory.cfg.su_pol!="unified"){if("split_i"==memory.cfg.su_pol&&segments_addr_within_text(address)==false){return false}if("split_d"==memory.cfg.su_pol&&segments_addr_within_data(address)==false){return false}}var parts=cache_memory_split(memory,address);if(typeof memory.sets[parts.set]=="undefined"){memory.sets[parts.set]={tags:{},number_tags:0}}if(typeof memory.sets[parts.set].tags[parts.tag]!="undefined"&&memory.sets[parts.set].tags[parts.tag].valid==1){cache_memory_update_stats(memory,address,parts,r_w,"hit",clock_timestamp);return true}if(typeof memory.sets[parts.set].number_tags>3){var tag_victim=cache_memory_select_victim(memory,parts.set);memory.sets[parts.set].tags[tag_victim].valid=0;memory.sets[parts.set].number_tags--}memory.sets[parts.set].tags[parts.tag]={n_access:0,valid:1,dirty:0};memory.sets[parts.set].number_tags++;cache_memory_update_stats(memory,address,parts,r_w,"miss",clock_timestamp);if(memory.cfg.next_cache!=null){cache_memory_access(memory.cfg.next_cache,address,r_w)}return false}var sim={systems:[],active:null,index:0};function simhw_add(newElto){var found=-1;for(var m=0;m=0&&sim.systems.length>=newActive){sim.active=sim.systems[newActive];sim.index=newActive}compile_behaviors();firedep_to_fireorder(jit_fire_dep);compute_references();compile_verbals()}function simhw_getIdByName(short_name){for(var m=0;m>>0).toString(16)}function check_behavior(){if(0==simhw_sim_signals().length){ws_alert("ALERT: empty signals!!!")}if(0==simhw_sim_states().length){ws_alert("ALERT: empty states!!!")}for(var key in simhw_sim_signals()){for(var key2 in simhw_sim_signal(key).behavior){var behaviors=simhw_sim_signal(key).behavior[key2].split(";");for(var i=0;i "+behavior_k[0]+" ("+behavior_i+")");return}if(behavior_k.length!=simhw_syntax_behavior(behavior_k[0]).nparameters){ws_alert("ALERT: Behavior has an incorrect number of elements --\x3e "+behavior_i+"/"+simhw_syntax_behavior(behavior_k[0]).nparameters);return}for(var j=1;j '"+behavior_i);return}else if("S"==t&&typeof simhw_sim_signal(s[0])=="undefined"){ws_alert("ALERT: Behavior has an undefined reference to a signal -> '"+behavior_i);return}else if("X"==t&&typeof simhw_sim_state(s[0])=="undefined"&&typeof simhw_sim_signal(s[0])=="undefined"){ws_alert("ALERT: Behavior has an undefined reference to a object state OR signal -> '"+behavior_i);return}}}}}}var jit_behaviors=false;var jit_verbals=false;var jit_fire_dep=null;var jit_fire_order=null;var jit_dep_network=null;var jit_fire_ndep=null;function firedep_to_fireorder(jit_fire_dep){var allfireto=false;jit_fire_order=[];jit_fire_ndep=[];for(var sig in simhw_sim_signals()){if(typeof jit_fire_dep[sig]=="undefined"){jit_fire_order.push(sig);continue}ndep=0;allfireto=false;for(var sigorg in jit_fire_dep[sig]){ndep++;if(jit_fire_dep[sig][sigorg]==simhw_sim_signal(sigorg).behavior.length){allfireto=true}}jit_fire_ndep[sig]=ndep;if(allfireto==false)jit_fire_order.push(sig)}}function compile_behaviors(){var jit_bes="";jit_fire_dep={};var sig_obj=null;var expr_obj=null;for(var sig in simhw_sim_signals()){jit_bes+="simhw_sim_signal('"+sig+"').behavior_fn = new Array();\n";for(var val in simhw_sim_signal(sig).behavior){var input_behavior=simhw_sim_signal(sig).behavior[val];var jit_be="";var s_exprs=input_behavior.split(";");for(var i=0;i"+v+"";if("Signals"!=enum_name)o+="("+(i+1)+") "+v;else o+="("+(i+1)+") "+hash_eltos[array_eltos[i]].ref+": "+v;if(i!=array_eltos.length-1){o+=str_enditem}}o+=". ";return o}function simhwelto_describe_component_enum(elto_path,array_eltos,hash_eltos,enum_name){var o="";o+=""+i18n_get_TagFor("hw","It has")+""+" "+array_eltos.length+" "+""+i18n_get_TagFor("hw",enum_name)+""+": "+simhwelto_describe_component_enum_aux(elto_path,array_eltos,hash_eltos,enum_name,", ");return o}function simhwelto_describe_component(elto_path,elto,format){var o="";o+=elto.description+".
"+"- "+simhwelto_describe_component_enum(elto_path+":states:",elto.states_inputs,elto.states,"inputs")+"
"+" - "+simhwelto_describe_component_enum(elto_path+":states:",elto.states_outputs,elto.states,"outputs")+"
"+" - "+simhwelto_describe_component_enum(elto_path+":signals:",elto.signals_inputs,elto.signals,"signals")+"
"+"
";if(format!="html"){o.replace(/<[^>]*>?/gm,"")}return o}var ep_def={sim_name:"Elemental Processor",sim_short_name:"ep",sim_img_processor:"repo/hardware/ep/images/processor.svg",sim_img_controlunit:"repo/hardware/ep/images/controlunit.svg",sim_img_cpu:"repo/hardware/ep/images/cpu.svg",components:{},states:{},signals:{},behaviors:{},elements:{},internal_states:{},ctrl_states:{},events:{}};simhw_add(ep_def);sim.ep.behaviors.PRINT_S={nparameters:2,types:["S"],operation:function(s_expr){console.log(s_expr[1]+": 0x"+sim.ep.signals[s_expr[1]].value.toString(16))},verbal:function(s_expr){return"Print value of signal "+s_expr[1]+": 0x"+sim.ep.signals[s_expr[1]].value.toString(16)+". "}};sim.ep.behaviors.PRINT_E={nparameters:2,types:["E"],operation:function(s_expr){console.log(s_expr[1]+": 0x"+sim.ep.states[s_expr[1]].value.toString(16))},verbal:function(s_expr){return"Print value of state "+s_expr[1]+": 0x"+sim.ep.states[s_expr[1]].value.toString(16)+". "}};sim.ep.components["CPU"]={name:"CPU",version:"1",abilities:["CPU"],details_name:["REGISTER_FILE","CONTROL_MEMORY","CLOCK","CPU_STATS"],details_fire:[["svg_p:text3029","svg_p:text3031"],["svg_cu:text3010"],["svg_p:text3459-7","svg_cu:text4138","svg_cu:text4138-7"],["svg_p:text3495"]],write_state:function(vec){if(typeof vec.CPU=="undefined"){vec.CPU={}}var internal_reg=["PC","SR"];var value=0;for(var i=0;i>>0;if(value!=0){vec.CPU["R"+i]={type:"register",default_value:0,id:"R"+i,op:"=",value:"0x"+value.toString(16)}}}for(i=0;i>>0;if(value!=0){vec.CPU[internal_reg[i]]={type:"register",default_value:0,id:internal_reg[i],op:"=",value:"0x"+value.toString(16)}}}return vec},read_state:function(vec,check){if(typeof vec.CPU=="undefined"){vec.CPU={}}var key=check["id"].toUpperCase().trim();var val=parseInt(check["value"]).toString(16);if("REGISTER"==check["type"].toUpperCase().trim()){vec.CPU[key]={type:"register",default_value:0,id:key,op:check["condition"],value:"0x"+val};return true}return false},get_state:function(reg){var value=0;var r_reg=reg.toUpperCase().trim();if(typeof sim.ep.states["REG_"+r_reg]!="undefined"){value=get_value(sim.ep.states["REG_"+r_reg])>>>0;return"0x"+value.toString(16)}r_reg=r_reg.replace("R","");var index=parseInt(r_reg);if(typeof sim.ep.states.BR[index]!="undefined"){value=get_value(sim.ep.states.BR[index])>>>0;return"0x"+value.toString(16)}return null},get_value:function(elto){if(Number.isInteger(elto))index=elto;else index=parseInt(elto);if(isNaN(index))return get_value(simhw_sim_state(elto))>>>0;return get_value(simhw_sim_states().BR[index])>>>0},set_value:function(elto,value){var pc_name=simhw_sim_ctrlStates_get().pc.state;if(Number.isInteger(elto))index=elto;else index=parseInt(elto);if(isNaN(index)){set_value(simhw_sim_state(elto),value);if(pc_name===elto){show_asmdbg_pc()}return value}return set_value(simhw_sim_states().BR[index],value)}};sim.ep.ctrl_states.pc={name:"PC",state:"REG_PC",is_pointer:true};sim.ep.ctrl_states.sp={name:"SP",state:"BR.29",is_pointer:true};sim.ep.ctrl_states.fp={name:"FP",state:"BR.30",is_pointer:true};sim.ep.ctrl_states.ir={name:"IR",state:"REG_IR",default_eltos:{co:{begin:0,end:5,length:6},cop:{begin:28,end:31,length:4},oc:{begin:0,end:6,length:7}},is_pointer:false};sim.ep.ctrl_states.mpc={name:"mPC",state:"REG_MICROADDR",is_pointer:false};sim.ep.internal_states.MC={};sim.ep.internal_states.ROM={};sim.ep.internal_states.FIRMWARE=ws_empty_firmware;sim.ep.internal_states.io_hash={};sim.ep.internal_states.fire_stack=[];sim.ep.internal_states.tri_state_names=["T1","T2","T3","T4","T5","T6","T7","T8","T9","T10","T11","T12"];sim.ep.internal_states.fire_visible={databus:false,internalbus:false};sim.ep.internal_states.filter_states=["REG_IR_DECO,col-12","REG_IR,col-auto","REG_PC,col-auto","REG_MAR,col-auto","REG_MBR,col-auto","REG_RT1,col-auto","REG_RT2,col-auto","REG_RT3,col-auto","REG_SR,col-auto","REG_MICROADDR,col-auto"];sim.ep.internal_states.filter_signals=["A0,0","B,0","C,0","SELA,5","SELB,5","SELC,2","SELCOP,0","MR,0","MC,0","C0,0","C1,0","C2,0","C3,0","C4,0","C5,0","C6,0","C7,0","T1,0","T2,0","T3,0","T4,0","T5,0","T6,0","T7,0","T8,0","T9,0","T10,0","T11,0","M1,0","M2,0","M7,0","MA,0","MB,0","SELP,0","LC,0","SE,0","SIZE,0","OFFSET,0","BW,0","R,0","W,0","TA,0","TD,0","IOR,0","IOW,0","TEST_I,0","TEST_U,0"];sim.ep.internal_states.alu_flags={flag_n:0,flag_z:0,flag_v:0,flag_c:0};sim.ep.states.BR=[];sim.ep.states.BR[0]={name:"R0",verbal:"Register 0",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[1]={name:"R1",verbal:"Register 1",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[2]={name:"R2",verbal:"Register 2",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[3]={name:"R3",verbal:"Register 3",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[4]={name:"R4",verbal:"Register 4",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[5]={name:"R5",verbal:"Register 5",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[6]={name:"R6",verbal:"Register 6",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[7]={name:"R7",verbal:"Register 7",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[8]={name:"R8",verbal:"Register 8",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[9]={name:"R9",verbal:"Register 9",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[10]={name:"R10",verbal:"Register 10",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[11]={name:"R11",verbal:"Register 11",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[12]={name:"R12",verbal:"Register 12",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[13]={name:"R13",verbal:"Register 13",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[14]={name:"R14",verbal:"Register 14",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[15]={name:"R15",verbal:"Register 15",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[16]={name:"R16",verbal:"Register 16",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[17]={name:"R17",verbal:"Register 17",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[18]={name:"R18",verbal:"Register 18",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[19]={name:"R19",verbal:"Register 19",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[20]={name:"R20",verbal:"Register 20",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[21]={name:"R21",verbal:"Register 21",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[22]={name:"R22",verbal:"Register 22",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[23]={name:"R23",verbal:"Register 23",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[24]={name:"R24",verbal:"Register 24",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[25]={name:"R25",verbal:"Register 25",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[26]={name:"R26",verbal:"Register 26",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[27]={name:"R27",verbal:"Register 27",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[28]={name:"R28",verbal:"Register 28",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[29]={name:"R29",verbal:"Register 29",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[30]={name:"R30",verbal:"Register 30",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[31]={name:"R31",verbal:"Register 31",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["REG_PC"]={name:"PC",verbal:"Program Counter Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["REG_MAR"]={name:"MAR",verbal:"Memory Address Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["REG_MBR"]={name:"MBR",verbal:"Memory Data Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["REG_IR"]={name:"IR",verbal:"Instruction Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["REG_RT1"]={name:"RT1",verbal:"Temporal 1 Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["REG_RT2"]={name:"RT2",verbal:"Temporal 2 Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["REG_RT3"]={name:"RT3",verbal:"Temporal 3 Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["REG_SR"]={name:"SR",verbal:"State Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["BUS_IB"]={name:"I_BUS",verbal:"Internal Bus",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["BUS_AB"]={name:"A_BUS",verbal:"Address Bus",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["BUS_CB"]={name:"C_BUS",verbal:"Control Bus",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["BUS_DB"]={name:"D_BUS",verbal:"Data Bus",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["C2_T2"]={name:"C2_T2",verbal:"Output of PC",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["RA_T9"]={name:"RA_T9",verbal:"Input of T9 Tristate",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["RB_T10"]={name:"RB_T10",verbal:"Input of T10 Tristate",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["HPC_T12"]={name:"HPC_T12",verbal:"Input of T12 Tristate",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["SELEC_T3"]={name:"SELEC_T3",verbal:"Input of T3 Tristate",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["SELP_M7"]={name:"SELP_M7",verbal:"Output of MUX SelP",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["ALU_C6"]={name:"ALU_C6",verbal:"Input of Temporal 3 Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["MA_ALU"]={name:"MA_ALU",verbal:"Input ALU via MA",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["MB_ALU"]={name:"MB_ALU",verbal:"Input ALU via MB",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["FLAG_C"]={name:"FLAG_C",verbal:"Carry Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.ep.states["FLAG_V"]={name:"FLAG_V",verbal:"Overflow Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.ep.states["FLAG_N"]={name:"FLAG_N",verbal:"Negative Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.ep.states["FLAG_Z"]={name:"FLAG_Z",verbal:"Zero Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.ep.states["FLAG_I"]={name:"FLAG_I",verbal:"Interruption Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.ep.states["FLAG_U"]={name:"FLAG_U",verbal:"User Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.ep.states["REG_MICROADDR"]={name:"µADDR",verbal:"Microaddress Register",visible:true,nbits:"12",value:0,default_value:0,draw_data:["svg_cu:text4667"]};sim.ep.states["REG_MICROINS"]={name:"µINS",verbal:"Microinstruction Register",visible:true,nbits:"77",value:{},default_value:{},draw_data:[]};sim.ep.states["FETCH"]={name:"FETCH",verbal:"Input Fetch",visible:false,nbits:"12",value:0,default_value:0,draw_data:[]};sim.ep.states["ROM_MUXA"]={name:"ROM_MUXA",verbal:"Input ROM",visible:false,nbits:"12",value:0,default_value:0,draw_data:[]};sim.ep.states["SUM_ONE"]={name:"SUM_ONE",verbal:"Input next microinstruction",visible:false,nbits:"12",value:1,default_value:1,draw_data:[]};sim.ep.states["MUXA_MICROADDR"]={name:"MUXA_MICROADDR",verbal:"Input microaddress",visible:false,nbits:"12",value:0,default_value:0,draw_data:[]};sim.ep.states["MUXC_MUXB"]={name:"MUXC_MUXB",verbal:"Output of MUX C",visible:false,nbits:"1",value:0,default_value:0,draw_data:[]};sim.ep.states["INEX"]={name:"INEX",verbal:"Illegal Instruction Exception",visible:false,nbits:"1",value:0,default_value:0,draw_data:[]};sim.ep.states["BS_M1"]={name:"BS_M1",verbal:"from Memory",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["BS_TD"]={name:"BS_TD",verbal:"Memory",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["INTV"]={name:"INTV",verbal:"Interruption Vector",visible:false,nbits:"8",value:0,default_value:0,draw_data:[]};sim.ep.states["M2_C2"]={name:"M2_C2",verbal:"Input of Program Counter",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["M1_C1"]={name:"M1_C1",verbal:"Input of Memory Data Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["M7_C7"]={name:"M7_C7",verbal:"Input of State Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["VAL_ZERO"]={name:"VAL_ZERO",verbal:"Wired Zero",visible:false,nbits:"1",value:0,default_value:0,draw_data:[]};sim.ep.states["VAL_ONE"]={name:"VAL_ONE",verbal:"Wired One",visible:false,nbits:"32",value:1,default_value:1,draw_data:[]};sim.ep.states["VAL_FOUR"]={name:"VAL_FOUR",verbal:"Wired Four",visible:false,nbits:"32",value:4,default_value:4,draw_data:[]};sim.ep.states["REG_IR_DECO"]={name:"IR_DECO",verbal:"Instruction Decoded",visible:true,nbits:"0",value:0,default_value:0,draw_data:[]};sim.ep.states["DECO_INS"]={name:"DECO_INS",verbal:"Instruction decoded in binary",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["CLK"]={name:"CLK",verbal:"Clock",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["ACC_TIME"]={name:"ACC_TIME",verbal:"Accumulated CPU time",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["TTCPU"]={name:"TTCPU",verbal:"Several Tristates to the internal data bus in CPU activated",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["ACC_PWR"]={name:"ACC_PWR",verbal:"Accumulated Energy Consumption",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.signals["C"]={name:"C",visible:true,type:"L",value:0,default_value:0,nbits:"4",behavior:["MV MUXC_MUXB VAL_ZERO; FIRE B","MBIT MUXC_MUXB INT 0 1; FIRE B","MBIT MUXC_MUXB IORDY 0 1; FIRE B","MBIT MUXC_MUXB MRDY 0 1; FIRE B","MBIT MUXC_MUXB REG_SR 0 1; FIRE B","MBIT MUXC_MUXB REG_SR 1 1; FIRE B","MBIT MUXC_MUXB REG_SR 28 1; FIRE B","MBIT MUXC_MUXB REG_SR 29 1; FIRE B","MBIT MUXC_MUXB REG_SR 30 1; FIRE B","MBIT MUXC_MUXB REG_SR 31 1; FIRE B","MV MUXC_MUXB INEX; FIRE B"],fire_name:["svg_cu:text3410"],draw_data:[["svg_cu:path3108"],["svg_cu:path3062"],["svg_cu:path3060"],["svg_cu:path3136"],["svg_cu:path3482"],["svg_cu:path3480"],["svg_cu:path3488"],["svg_cu:path3486"],["svg_cu:path3484"],["svg_cu:path3484-9"],["svg_cu:path3108-3","svg_cu:path3260-3-8-6","svg_cu:path3260-3-8","svg_cu:path3260-3"]],draw_name:[["svg_cu:path3496","svg_cu:path3414","svg_cu:path3194-08"]]};sim.ep.signals["B"]={name:"B",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV A1 MUXC_MUXB; FIRE A1","NOT_ES A1 MUXC_MUXB; FIRE A1"],depends_on:["CLK"],fire_name:["svg_cu:text3408"],draw_data:[["svg_cu:path3100-8-7","svg_cu:path3108-1","svg_cu:path3200-1"],["svg_cu:path3392","svg_cu:path3372","svg_cu:path3390","svg_cu:path3384","svg_cu:path3100-8-7","svg_cu:path3386","svg_cu:path3200-1"]],draw_name:[[],["svg_cu:path3194-0","svg_cu:path3138-8","svg_cu:path3498-6"]]};sim.ep.signals["A0"]={name:"A0",visible:false,type:"L",value:0,default_value:0,nbits:"1",behavior:["SBIT_SIGNAL A0A1 0 1; FIRE A0A1","SBIT_SIGNAL A0A1 1 1; FIRE A0A1"],depends_on:["CLK"],fire_name:["svg_cu:text3406"],draw_data:[["svg_cu:path3096"],["svg_cu:path3096"]],draw_name:[[],["svg_cu:path3138-8-1","svg_cu:path3098-2","svg_cu:path3124-2-5"]]};sim.ep.signals["A1"]={name:"A1",visible:false,type:"L",value:0,default_value:0,nbits:"1",behavior:["SBIT_SIGNAL A0A1 0 0; FIRE A0A1","SBIT_SIGNAL A0A1 1 0; FIRE A0A1"],depends_on:["CLK"],fire_name:[],draw_data:[["svg_cu:path3094"],["svg_cu:path3094"]],draw_name:[[]]};sim.ep.signals["A0A1"]={name:"A0A1",visible:true,type:"L",value:0,default_value:0,nbits:"2",behavior:["PLUS1 MUXA_MICROADDR REG_MICROADDR","CP_FIELD MUXA_MICROADDR REG_MICROINS/MADDR","MV MUXA_MICROADDR ROM_MUXA","MV MUXA_MICROADDR FETCH"],depends_on:["CLK"],fire_name:[],draw_data:[["svg_cu:path3102","svg_cu:path3100","svg_cu:path3098","svg_cu:path3100-9","svg_cu:path3088","svg_cu:path3082"],["svg_cu:path3104","svg_cu:path3134","svg_cu:path3500","svg_cu:path3416"],["svg_cu:path3124-2-4","svg_cu:path3124-2","svg_cu:path3504","svg_cu:path3100-8","svg_cu:path3234-9"],["svg_cu:path3124"]],draw_name:[[]]};sim.ep.signals["C0"]={name:"C0",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","LOAD REG_MAR BUS_IB"],fire_name:["svg_p:text3077"],draw_data:[["svg_p:path3081"]],draw_name:[["svg_p:path3075"]]};sim.ep.signals["C1"]={name:"C1",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","LOAD REG_MBR M1_C1"],fire_name:["svg_p:text3079"],draw_data:[["svg_p:path3055"]],draw_name:[["svg_p:path3073"]]};sim.ep.signals["C2"]={name:"C2",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","LOAD REG_PC M2_C2; UPDATEDPC"],fire_name:["svg_p:text3179"],draw_data:[["svg_p:path3485"]],draw_name:[["svg_p:path3177"]]};sim.ep.signals["C3"]={name:"C3",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","LOAD REG_IR BUS_IB; DECO; FIRE_IFSET C 10"],fire_name:["svg_p:text3439"],draw_data:[["svg_p:path3339"]],draw_name:[["svg_p:path3337"]]};sim.ep.signals["C4"]={name:"C4",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","LOAD REG_RT1 BUS_IB"],fire_name:["svg_p:text3441"],draw_data:[["svg_p:path3263"]],draw_name:[["svg_p:path3255"]]};sim.ep.signals["C5"]={name:"C5",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","LOAD REG_RT2 BUS_IB"],fire_name:["svg_p:text3443"],draw_data:[["svg_p:path3277"]],draw_name:[["svg_p:path3269"]]};sim.ep.signals["C6"]={name:"C6",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","LOAD REG_RT3 ALU_C6"],fire_name:["svg_p:text3445"],draw_data:[["svg_p:path3325","svg_p:path3323","svg_p:path3321","svg_p:path3261-8","svg_p:path3317-9","svg_p:path3901-6-9"]],draw_name:[["svg_p:path3245"]]};sim.ep.signals["C7"]={name:"C7",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","LOAD REG_SR M7_C7"],fire_name:["svg_p:text3655"],draw_data:[["svg_p:path3651-9"]],draw_name:[["svg_p:path3681"]]};sim.ep.signals["TA"]={name:"TA",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","MV BUS_AB REG_MAR; MOVE_BITSE A1A0 0 2 BUS_AB 0; FIRE_IFCHANGED A1A0 A1A0"],fire_name:["svg_p:text3091"],draw_data:[["svg_p:path3061-2","svg_p:path3083","svg_p:path3089","svg_p:path3597","svg_p:path3513","svg_p:path3601","svg_p:path3601-2","svg_p:path3187","svg_p:path3087","svg_p:path2995","svg_p:path3535"]],draw_name:[["svg_p:path3085"]]};sim.ep.signals["TD"]={name:"TD",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; CHECK_RTD","MV BUS_DB BS_TD; MOVE_BITSE A1A0 0 2 BUS_AB 0; FIRE_IFCHANGED A1A0 A1A0; CHECK_RTD"],fire_name:["svg_p:text3103"],draw_data:[["svg_p:path3545","svg_p:path3093","svg_p:path3101","svg_p:path3587","svg_p:path3515","svg_p:path3071","svg_p:path3419","svg_p:path3099","svg_p:path3097","svg_p:path3559-5","svg_p:path3419-1-0","svg_p:path3583","svg_p:path3419-1","svg_p:path3491","svg_p:path3641","svg_p:path3541"]],draw_name:[["svg_p:path3095"]]};sim.ep.signals["T1"]={name:"T1",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 0","MV BUS_IB REG_MBR; FIRE M7; FIRE M2; FIRE M1; SET_TT TTCPU 0"],fire_name:["svg_p:text3105"],draw_data:[["svg_p:path3071","svg_p:path3065","svg_p:path3071","svg_p:path3049","svg_p:path3063-9","svg_p:path3071","svg_p:path3071","svg_p:path3069"]],draw_name:[["svg_p:path3067"]]};sim.ep.signals["T2"]={name:"T2",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 1","MV BUS_IB REG_PC; FIRE M7; FIRE M2; FIRE M1; SET_TT TTCPU 1"],fire_name:["svg_p:text3449"],draw_data:[["svg_p:path3195","svg_p:path3199","svg_p:path3201","svg_p:path3049"]],draw_name:[["svg_p:path3329"]]};sim.ep.signals["T3"]={name:"T3",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 2","MV BUS_IB SELEC_T3; FIRE M7; FIRE M2; FIRE M1; SET_TT TTCPU 2"],fire_name:["svg_p:text3451"],draw_data:[["svg_p:path3341","svg_p:path3347","svg_p:path3349","svg_p:path3931","svg_p:path3345","svg_p:path3049"]],draw_name:[["svg_p:path3351"]]};sim.ep.signals["T4"]={name:"T4",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 3","MV BUS_IB REG_RT1; FIRE M7; FIRE M2; FIRE M1; SET_TT TTCPU 3"],fire_name:["svg_p:text3453"],draw_data:[["svg_p:path3257","svg_p:path3261","svg_p:path3259","svg_p:path3049"]],draw_name:[["svg_p:path3305"]]};sim.ep.signals["T5"]={name:"T5",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 4","MV BUS_IB REG_RT2; FIRE M7; FIRE M2; FIRE M1; SET_TT TTCPU 4"],fire_name:["svg_p:text3455"],draw_data:[["svg_p:path3271","svg_p:path3275","svg_p:path3273","svg_p:path3049"]],draw_name:[["svg_p:path3307"]]};sim.ep.signals["T6"]={name:"T6",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 5","MV BUS_IB ALU_C6; FIRE M7; FIRE M2; FIRE M1; SET_TT TTCPU 5"],fire_name:["svg_p:text3457"],draw_data:[["svg_p:path3315","svg_p:path3589","svg_p:path3317","svg_p:path3163-2","svg_p:path3049","svg_p:path3321","svg_p:path3261-8","svg_p:path3317-9","svg_p:path3901-6-9"]],draw_name:[["svg_p:path3319"]]};sim.ep.signals["T7"]={name:"T7",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 6","MV BUS_IB REG_RT3; FIRE M7; FIRE M2; FIRE M1; SET_TT TTCPU 6"],fire_name:["svg_p:text3459"],draw_data:[["svg_p:path3309","svg_p:path3327","svg_p:path3311","svg_p:path3049"]],draw_name:[["svg_p:path3313"]]};sim.ep.signals["T8"]={name:"T8",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 7","MV BUS_IB REG_SR; FIRE M7; FIRE M2; FIRE M1; SET_TT TTCPU 7"],fire_name:["svg_p:text3657"],draw_data:[["svg_p:path3645","svg_p:path3651","svg_p:path3647","svg_p:path3049"]],draw_name:[["svg_p:path3649"]]};sim.ep.signals["T9"]={name:"T9",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 8","MV BUS_IB RA_T9; FIRE M7; FIRE M2; FIRE M1; SET_TT TTCPU 8"],fire_name:["svg_p:text3147"],draw_data:[["svg_p:path3131","svg_p:path3143","svg_p:path3139","svg_p:path3049","svg_p:path3143-9"]],draw_name:[["svg_p:path3133"]]};sim.ep.signals["T10"]={name:"T10",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 9","MV BUS_IB RB_T10; FIRE M7; FIRE M2; FIRE M1; SET_TT TTCPU 9"],fire_name:["svg_p:text3149"],draw_data:[["svg_p:path3135","svg_p:path3145","svg_p:path3141","svg_p:path3049","svg_p:path3145-5"]],draw_name:[["svg_p:path3137"]]};sim.ep.signals["T11"]={name:"T11",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 10","CP_FIELD BUS_IB REG_MICROINS/EXCODE; FIRE M7; FIRE M2; FIRE M1; SET_TT TTCPU 10"],fire_name:["svg_p:text3147-5","svg_cu:tspan4426"],draw_data:[["svg_cu:path3131-3","svg_p:path3131-3","svg_p:path3145","svg_p:path3081-3","svg_p:path3139-7","svg_p:path3049","svg_cu:path3081-3","svg_cu:path3139-7"]],draw_name:[["svg_p:path3133-6","svg_cu:path3133-6"]]};sim.ep.signals["T12"]={name:"T12",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 11","MV BUS_IB HPC_T12; FIRE M7; FIRE M2; FIRE M1; SET_TT TTCPU 11"],fire_name:["svg_p:text3147-5-0-1-1"],draw_data:[["svg_p:path3131-3-8-4-31","svg_p:path3139-7-1-4-3","svg_p:path3049","svg_p:path3081-3-8-5-3","svg_p:path3081-3-8-5-3-7"]],draw_name:[["svg_p:path3133-6-9-7-5"]]};sim.ep.signals["M1"]={name:"M1",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV M1_C1 BUS_IB","MV M1_C1 BS_M1"],depends_on:["C1"],fire_name:["svg_p:text3469"],draw_data:[["svg_p:path3063","svg_p:path3061","svg_p:path3059"],["svg_p:path3057","svg_p:path3641","svg_p:path3419","svg_p:path3583","svg_p:path3491"]],draw_name:[[],["svg_p:path3447"]]};sim.ep.signals["M2"]={name:"M2",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV M2_C2 BUS_IB","PLUS4 M2_C2 REG_PC"],depends_on:["C2"],fire_name:["svg_p:text3471"],draw_data:[["svg_p:path3217","svg_p:path3215","svg_p:path3213","svg_p:path3213-9"],["svg_p:path3211","svg_p:path3209","svg_p:path3193","svg_p:path3207","svg_p:path3197","svg_p:path3201"]],draw_name:[[],["svg_p:path3467","svg_p:path3467"]]};sim.ep.signals["M7"]={name:"M7",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV M7_C7 BUS_IB","MV M7_C7 SELP_M7"],depends_on:["C7"],fire_name:["svg_p:text3673"],draw_data:[["svg_p:path3691","svg_p:path3693","svg_p:path3659"],["svg_p:path3695"]],draw_name:[[],["svg_p:path3667"]]};sim.ep.signals["MA"]={name:"MA",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV MA_ALU RA_T9; FIRE COP","MV MA_ALU REG_RT1; FIRE COP"],depends_on:["SELA","SELB"],fire_name:["svg_p:text3463"],draw_data:[["svg_p:path3249","svg_p:path3161","svg_p:path3165"],["svg_p:path3279"]],draw_name:[[],["svg_p:path3423"]]};sim.ep.signals["MB"]={name:"MB",visible:true,type:"L",value:0,default_value:0,nbits:"2",behavior:["MV MB_ALU RB_T10; FIRE COP","MV MB_ALU REG_RT2; FIRE COP","MV MB_ALU VAL_FOUR; FIRE COP","MV MB_ALU VAL_ONE; FIRE COP"],depends_on:["SELA","SELB"],fire_name:["svg_p:text3465"],draw_data:[["svg_p:path3281","svg_p:path3171","svg_p:path3169"],["svg_p:path3283"],["svg_p:path3295","svg_p:path3293"],["svg_p:path3297","svg_p:path3299"]],draw_name:[[],["svg_p:path3425","svg_p:path3427"]]};sim.ep.signals["MH"]={name:"MH",visible:true,type:"L",value:0,default_value:0,nbits:"2",behavior:["MV HPC_T12 CLK","MV HPC_T12 ACC_TIME","MV HPC_T12 ACC_PWR","NOP"],fire_name:["svg_p:text3147-5-0-1-8-4"],draw_data:[[],["svg_p:path3081-3-8-5-3"]],draw_name:[[],["svg_p:path3306-8-7-6"]]};sim.ep.signals["COP"]={name:"COP",visible:true,type:"L",value:0,default_value:0,nbits:"5",forbidden:true,behavior:["NOP_ALU; UPDATE_NZVC","AND ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","OR ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","NOT ALU_C6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","XOR ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","SRL ALU_C6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","SRA ALU_C6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","SL ALU_C6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","RR ALU_C6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","RL ALU_C6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","ADD ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","SUB ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","MUL ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","DIV ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","MOD ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","LUI ALU_C6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","FADD ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","FSUB ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","FMUL ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","FDIV ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","FCVT ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","FCLASS ALU_C6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","ADDU ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","SUBU ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","MULU ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","DIVU ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU"],depends_on:["SELCOP"],fire_name:["svg_p:text3303"],draw_data:[["svg_p:path3237","svg_p:path3239","svg_p:path3261-8","svg_p:path3321","svg_p:path3901-6","svg_p:path3317-9"]],draw_name:[["svg_p:path3009","svg_p:path3301"]]};sim.ep.signals["SELP"]={name:"SELP",visible:true,type:"L",value:0,default_value:0,nbits:"2",behavior:["NOP","MV SELP_M7 REG_SR; UPDATE_FLAG SELP_M7 FLAG_U 0; FIRE M7","MV SELP_M7 REG_SR; UPDATE_FLAG SELP_M7 FLAG_I 1; FIRE M7","MV SELP_M7 REG_SR; UPDATE_FLAG SELP_M7 FLAG_C 31; UPDATE_FLAG SELP_M7 FLAG_V 30; UPDATE_FLAG SELP_M7 FLAG_N 29; UPDATE_FLAG SELP_M7 FLAG_Z 28; FIRE M7"],fire_name:["svg_p:text3703"],draw_data:[[],["svg_p:path3643"],["svg_p:path3705"],["svg_p:path3675","svg_p:path3331"]],draw_name:[[],["svg_p:path3697"]]};sim.ep.signals["SELA"]={name:"SELA",visible:true,type:"L",value:0,default_value:0,nbits:"5",behavior:["FIRE MR_RA"],depends_on:["RA"],fire_name:["svg_cu:text3164"],draw_data:[[]],draw_name:[[]]};sim.ep.signals["SELB"]={name:"SELB",visible:true,type:"L",value:0,default_value:0,nbits:"5",behavior:["FIRE MR_RB"],depends_on:["RB"],fire_name:["svg_cu:text3168"],draw_data:[[]],draw_name:[[]]};sim.ep.signals["SELC"]={name:"SELC",visible:true,type:"L",value:0,default_value:0,nbits:"5",behavior:["FIRE MR_RC"],depends_on:["RC"],fire_name:["svg_cu:text3172"],draw_data:[[]],draw_name:[[]]};sim.ep.signals["SELCOP"]={name:"SELCOP",visible:true,type:"L",value:0,default_value:0,nbits:"5",behavior:["FIRE MC"],depends_on:["COP"],fire_name:["svg_cu:text3312"],draw_data:[[]],draw_name:[[]]};sim.ep.signals["EXCODE"]={name:"EXCODE",visible:true,type:"L",value:0,default_value:0,nbits:"4",behavior:["FIRE T11"],fire_name:["svg_cu:text3312-6"],draw_data:[[]],draw_name:[]};sim.ep.signals["RA"]={name:"RA",visible:true,type:"L",value:0,default_value:0,nbits:"5",forbidden:true,behavior:["GET RA_T9 BR RA; FIRE_IFSET T9 1; FIRE_IFSET MA 0"],depends_on:["SELA"],fire_name:["svg_p:text3107"],draw_data:[[]],draw_name:[["svg_p:path3109"]]};sim.ep.signals["RB"]={name:"RB",visible:true,type:"L",value:0,default_value:0,nbits:"5",forbidden:true,behavior:["GET RB_T10 BR RB; FIRE_IFSET T10 1; FIRE_IFSET MB 0"],depends_on:["SELB"],fire_name:["svg_p:text3123"],draw_data:[[]],draw_name:[["svg_p:path3113"]]};sim.ep.signals["RC"]={name:"RC",visible:true,type:"L",value:0,default_value:0,nbits:"5",forbidden:true,behavior:["FIRE LC"],depends_on:["SELC"],fire_name:["svg_p:text3125"],draw_data:[[]],draw_name:[["svg_p:path3117"]]};sim.ep.signals["LC"]={name:"LC",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","SET BR RC BUS_IB"],fire_name:["svg_p:text3127"],draw_data:[["svg_p:path3153","svg_p:path3151","svg_p:path3129"]],draw_name:[["svg_p:path3121"]]};sim.ep.signals["SE"]={name:"SE",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MBITS SELEC_T3 0 REG_IR OFFSET SIZE 0 SE; FIRE T3; MOVE_BITS SBWA 4 1 SE; FIRE_IFCHANGED SBWA SE","MBITS SELEC_T3 0 REG_IR OFFSET SIZE 0 SE; FIRE T3; MOVE_BITS SBWA 4 1 SE; FIRE_IFCHANGED SBWA SE"],depends_on:["T3"],fire_name:["svg_p:text3593","svg_p:text3431"],draw_data:[[]],draw_name:[["svg_p:path3591","svg_p:path3447-7-7"]]};sim.ep.signals["SIZE"]={name:"SIZE",visible:true,type:"L",value:0,default_value:0,nbits:"5",behavior:["MBITS SELEC_T3 0 REG_IR OFFSET SIZE 0 SE; FIRE T3"],depends_on:["T3"],fire_name:["svg_p:text3363"],draw_data:[[]],draw_name:[["svg_p:path3355"]]};sim.ep.signals["OFFSET"]={name:"OFFSET",visible:true,type:"L",value:0,default_value:0,nbits:"5",behavior:["MBITS SELEC_T3 0 REG_IR OFFSET SIZE 0 SE; FIRE T3"],depends_on:["T3"],fire_name:["svg_p:text3707"],draw_data:[[]],draw_name:[["svg_p:path3359"]]};sim.ep.signals["MC"]={name:"MC",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MBIT COP REG_IR 0 5; FIRE COP;","CP_FIELD COP REG_MICROINS/SELCOP; FIRE COP;"],depends_on:["SELCOP"],fire_name:["svg_cu:text3322","svg_cu:text3172-1-5"],draw_data:[["svg_cu:path3320","svg_cu:path3142"],["svg_cu:path3318","svg_cu:path3502-6"]],draw_name:[[],["svg_cu:path3306"]]};sim.ep.signals["MR"]={name:"MR",verbal:["Copy from IR[SelA], from IR[SelB], and from IR[SelB] into RA, RB, and RC. ","Copy SelA, SelB, and SelB into RA, RB, and RC. "],visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV MR_RA MR; FIRE MR_RA; MV MR_RB MR; FIRE MR_RB; MV MR_RC MR; FIRE MR_RC;","MV MR_RA MR; FIRE MR_RA; MV MR_RB MR; FIRE MR_RB; MV MR_RC MR; FIRE MR_RC;"],depends_on:["SELA","SELB","SELC"],fire_name:["svg_cu:text3222","svg_cu:text3242","svg_cu:text3254","svg_cu:text3172-1"],draw_data:[["svg_cu:path3494","svg_cu:path3492","svg_cu:path3490","svg_cu:path3188","svg_cu:path3190","svg_cu:path3192","svg_cu:path3194","svg_cu:path3276","svg_cu:path3290","svg_cu:path3260","svg_cu:path3196","svg_cu:path3278","svg_cu:path3292","svg_cu:path3142","svg_cu:path3258-4","svg_cu:path3390-7","svg_cu:path3258","svg_cu:path3280","svg_cu:path3200","svg_cu:path3204","svg_cu:path3208","svg_cu:path3268","svg_cu:path3316"],["svg_cu:path3270","svg_cu:path3282","svg_cu:path3300","svg_cu:path3258","svg_cu:path3260","svg_cu:path3258-4","svg_cu:path3278","svg_cu:path3196","svg_cu:path3294","svg_cu:path3292","svg_cu:path3288","svg_cu:path3280","svg_cu:path3258","svg_cu:path3258-4","svg_cu:path3390-7","svg_cu:path3268","svg_cu:path3364","svg_cu:path3316"]],draw_name:[[],["svg_cu:path3220","svg_cu:path3240","svg_cu:path3252"]]};sim.ep.signals["MR_RA"]={name:"MR_RA",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MBIT_SN RA REG_IR REG_MICROINS/SELA 5; FIRE RA;","CP_FIELD RA REG_MICROINS/SELA; FIRE RA;"],fire_name:[],draw_data:[[]],draw_name:[[]]};sim.ep.signals["MR_RB"]={name:"MR_RB",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MBIT_SN RB REG_IR REG_MICROINS/SELB 5; FIRE RB;","CP_FIELD RB REG_MICROINS/SELB; FIRE RB;"],fire_name:[],draw_data:[[]],draw_name:[[]]};sim.ep.signals["MR_RC"]={name:"MR_RC",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MBIT_SN RC REG_IR REG_MICROINS/SELC 5; FIRE RC;","CP_FIELD RC REG_MICROINS/SELC; FIRE RC;"],fire_name:[],draw_data:[[]],draw_name:[[]]};sim.ep.signals["BW"]={name:"BW",verbal:["Select one byte (based on A1A0) from Word. ","Select two bytes (one Half Word based on A1A0) from Word. ","","Select the full Word. "],visible:true,type:"L",value:0,default_value:0,nbits:"2",behavior:["MOVE_BITS BWA 2 2 BW; MOVE_BITS SBWA 2 2 BW; FIRE_IFCHANGED BWA BW; FIRE SBWA; RESET_CHANGED BW","MOVE_BITS BWA 2 2 BW; MOVE_BITS SBWA 2 2 BW; FIRE_IFCHANGED BWA BW; FIRE SBWA; RESET_CHANGED BW","MOVE_BITS BWA 2 2 BW; MOVE_BITS SBWA 2 2 BW; FIRE_IFCHANGED BWA BW; FIRE SBWA; RESET_CHANGED BW","MOVE_BITS BWA 2 2 BW; MOVE_BITS SBWA 2 2 BW; FIRE_IFCHANGED BWA BW; FIRE SBWA; RESET_CHANGED BW"],fire_name:["svg_p:text3433"],draw_data:[["svg_p:path3061-2-6","svg_p:path3101-8","svg_p:path3535-8"]],draw_name:[[],[]]};sim.ep.signals["A1A0"]={name:"A1A0",visible:true,type:"L",value:0,default_value:0,nbits:"2",behavior:["MOVE_BITS BWA 0 2 A1A0; MOVE_BITS SBWA 0 2 A1A0; FIRE BWA; FIRE SBWA","MOVE_BITS BWA 0 2 A1A0; MOVE_BITS SBWA 0 2 A1A0; FIRE BWA; FIRE SBWA","MOVE_BITS BWA 0 2 A1A0; MOVE_BITS SBWA 0 2 A1A0; FIRE BWA; FIRE SBWA","MOVE_BITS BWA 0 2 A1A0; MOVE_BITS SBWA 0 2 A1A0; FIRE BWA; FIRE SBWA"],fire_name:["svg_p:text3603"],draw_data:[[],[]],draw_name:[[],[]]};sim.ep.signals["BWA"]={name:"BWA",visible:false,type:"L",value:0,default_value:0,nbits:"4",behavior:["BSEL BS_TD 0 8 REG_MBR 0; FIRE TD; FIRE R; FIRE W","BSEL BS_TD 8 8 REG_MBR 0; FIRE TD; FIRE R; FIRE W","BSEL BS_TD 16 8 REG_MBR 0; FIRE TD; FIRE R; FIRE W","BSEL BS_TD 24 8 REG_MBR 0; FIRE TD; FIRE R; FIRE W","BSEL BS_TD 0 16 REG_MBR 0; FIRE TD; FIRE R; FIRE W","BSEL BS_TD 0 16 REG_MBR 0; FIRE TD; FIRE R; FIRE W","BSEL BS_TD 0 16 REG_MBR 0; FIRE TD; FIRE R; FIRE W","BSEL BS_TD 0 16 REG_MBR 0; FIRE TD; FIRE R; FIRE W","BSEL BS_TD 16 16 REG_MBR 0; FIRE TD; FIRE R; FIRE W","BSEL BS_TD 16 16 REG_MBR 0; FIRE TD; FIRE R; FIRE W","BSEL BS_TD 16 16 REG_MBR 0; FIRE TD; FIRE R; FIRE W","BSEL BS_TD 16 16 REG_MBR 0; FIRE TD; FIRE R; FIRE W","MV BS_TD REG_MBR; FIRE TD; FIRE R; FIRE W","MV BS_TD REG_MBR; FIRE TD; FIRE R; FIRE W","MV BS_TD REG_MBR; FIRE TD; FIRE R; FIRE W","MV BS_TD REG_MBR; FIRE TD; FIRE R; FIRE W"],fire_name:["svg_p:text3533-5"],draw_data:[[],[]],draw_name:[[],[]]};sim.ep.signals["SBWA"]={name:"SBWA",visible:false,type:"L",value:0,default_value:0,nbits:"5",behavior:["BSEL BS_M1 0 8 BUS_DB 0; FIRE M1","BSEL BS_M1 0 8 BUS_DB 8; FIRE M1","BSEL BS_M1 0 8 BUS_DB 16; FIRE M1","BSEL BS_M1 0 8 BUS_DB 24; FIRE M1","BSEL BS_M1 0 16 BUS_DB 0; FIRE M1","BSEL BS_M1 0 16 BUS_DB 0; FIRE M1","BSEL BS_M1 0 16 BUS_DB 0; FIRE M1","BSEL BS_M1 0 16 BUS_DB 0; FIRE M1","BSEL BS_M1 0 16 BUS_DB 16; FIRE M1","BSEL BS_M1 0 16 BUS_DB 16; FIRE M1","BSEL BS_M1 0 16 BUS_DB 16; FIRE M1","BSEL BS_M1 0 16 BUS_DB 16; FIRE M1","MV BS_M1 BUS_DB; FIRE M1","MV BS_M1 BUS_DB; FIRE M1","MV BS_M1 BUS_DB; FIRE M1","MV BS_M1 BUS_DB; FIRE M1","BSEL BS_M1 0 8 BUS_DB 0; EXT_SIG BS_M1 7; FIRE M1","BSEL BS_M1 0 8 BUS_DB 8; EXT_SIG BS_M1 7; FIRE M1","BSEL BS_M1 0 8 BUS_DB 16; EXT_SIG BS_M1 7; FIRE M1","BSEL BS_M1 0 8 BUS_DB 24; EXT_SIG BS_M1 7; FIRE M1","BSEL BS_M1 0 16 BUS_DB 0; EXT_SIG BS_M1 15; FIRE M1","BSEL BS_M1 0 16 BUS_DB 0; EXT_SIG BS_M1 15; FIRE M1","BSEL BS_M1 0 16 BUS_DB 0; EXT_SIG BS_M1 15; FIRE M1","BSEL BS_M1 0 16 BUS_DB 0; EXT_SIG BS_M1 15; FIRE M1","BSEL BS_M1 0 16 BUS_DB 16; EXT_SIG BS_M1 15; FIRE M1","BSEL BS_M1 0 16 BUS_DB 16; EXT_SIG BS_M1 15; FIRE M1","BSEL BS_M1 0 16 BUS_DB 16; EXT_SIG BS_M1 15; FIRE M1","BSEL BS_M1 0 16 BUS_DB 16; EXT_SIG BS_M1 15; FIRE M1","MV BS_M1 BUS_DB; FIRE M1","MV BS_M1 BUS_DB; FIRE M1","MV BS_M1 BUS_DB; FIRE M1","MV BS_M1 BUS_DB; FIRE M1"],fire_name:[],draw_data:[[],[]],draw_name:[[],[]]};sim.ep.signals["IOR"]={name:"IOR",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","MOVE_BITS KBD_IOR 0 1 IOR; MOVE_BITS SCR_IOR 0 1 IOR; MOVE_BITS L3D_IOR 0 1 IOR; MOVE_BITS L3D_IOR 0 1 IOR; FIRE KBD_IOR; FIRE SCR_IOR; FIRE L3D_IOR; FIRE LEDM_IOR"],fire_name:["svg_p:text3715"],draw_data:[[],["svg_p:path3733","svg_p:path3491","svg_p:text3715"]],draw_name:[[],[]]};sim.ep.signals["IOW"]={name:"IOW",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","MOVE_BITS SCR_IOW 0 1 IOW; FIRE SCR_IOW; MOVE_BITS IO_IOW 0 1 IOW; FIRE IO_IOW; MOVE_BITS L3D_IOW 0 1 IOW; FIRE L3D_IOW; MOVE_BITS LEDM_IOW 0 1 IOW; FIRE LEDM_IOW"],fire_name:["svg_p:text3717"],draw_data:[[],["svg_p:path3735","svg_p:path3491","svg_p:text3717"]],draw_name:[[],[]]};sim.ep.signals["I"]={name:"I",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV FLAG_I VAL_ZERO; FIRE_IFSET SELP 2","MV FLAG_I VAL_ONE; FIRE_IFSET SELP 2"],fire_name:[],draw_data:[[],[]],draw_name:[[],[]]};sim.ep.signals["U"]={name:"U",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV FLAG_U VAL_ZERO; FIRE_IFSET SELP 2","MV FLAG_U VAL_ONE; FIRE_IFSET SELP 2"],fire_name:[],draw_data:[[],[]],draw_name:[[],[]]};sim.ep.signals["TEST_C"]={name:"TEST_C",visible:true,type:"L",value:0,default_value:0,nbits:"1",forbidden:true,behavior:["MV FLAG_C VAL_ZERO; FIRE_IFSET SELP 2","MV FLAG_C VAL_ONE; FIRE_IFSET SELP 3"],depends_on:["SELCOP","COP"],fire_name:["svg_p:text3701-3"],draw_data:[["svg_p:text3701-3"]],draw_name:[[]]};sim.ep.signals["TEST_V"]={name:"TEST_V",visible:true,type:"L",value:0,default_value:0,nbits:"1",forbidden:true,behavior:["MV FLAG_V VAL_ZERO; FIRE_IFSET SELP 2","MV FLAG_V VAL_ONE; FIRE_IFSET SELP 3"],depends_on:["SELCOP","COP"],fire_name:["svg_p:text3701-3-1"],draw_data:[["svg_p:text3701-3-1"]],draw_name:[[]]};sim.ep.signals["TEST_N"]={name:"TEST_N",visible:true,type:"L",value:0,default_value:0,nbits:"1",forbidden:true,behavior:["MV FLAG_N VAL_ZERO; FIRE_IFSET SELP 2","MV FLAG_N VAL_ONE; FIRE_IFSET SELP 3"],depends_on:["SELCOP","COP"],fire_name:["svg_p:text3701-3-2"],draw_data:[["svg_p:text3701-3-2"]],draw_name:[[]]};sim.ep.signals["TEST_Z"]={name:"TEST_Z",visible:true,type:"L",value:0,default_value:0,nbits:"1",forbidden:true,behavior:["MV FLAG_Z VAL_ZERO; FIRE_IFSET SELP 2","MV FLAG_Z VAL_ONE; FIRE_IFSET SELP 3"],depends_on:["SELCOP","COP"],fire_name:["svg_p:text3701-3-5"],draw_data:[["svg_p:text3701-3-5"]],draw_name:[[]]};sim.ep.signals["TEST_I"]={name:"TEST_I",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV FLAG_I VAL_ZERO; FIRE_IFSET SELP 2","MV FLAG_I VAL_ONE; FIRE_IFSET SELP 2"],depends_on:["CLK"],fire_name:["svg_p:text3669"],draw_data:[["svg_p:text3669"]],draw_name:[[]]};sim.ep.signals["TEST_U"]={name:"TEST_U",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV FLAG_U VAL_ZERO; FIRE_IFSET SELP 1","MV FLAG_U VAL_ONE; FIRE_IFSET SELP 1"],depends_on:["CLK"],fire_name:["svg_p:text3669-1"],draw_data:[["svg_p:text3669-1"]],draw_name:[[]]};sim.ep.signals["TEST_INTV"]={name:"TEST_INTV",visible:true,type:"L",value:0,default_value:0,nbits:"8",forbidden:true,behavior:["MBIT INTV TEST_INTV 0 32"],depends_on:["INT"],fire_name:["svg_p:tspan4225"],draw_data:[["svg_p:path3749"]],draw_name:[[]]};sim.ep.behaviors["NOP"]={nparameters:1,operation:function(s_expr){},verbal:function(s_expr){return""}};sim.ep.behaviors["NOP_ALU"]={nparameters:1,operation:function(s_expr){sim.ep.internal_states.alu_flags.flag_n=0;sim.ep.internal_states.alu_flags.flag_z=0;sim.ep.internal_states.alu_flags.flag_c=0;sim.ep.internal_states.alu_flags.flag_v=0},verbal:function(s_expr){return""}};sim.ep.behaviors["MV"]={nparameters:3,types:["X","X"],operation:function(s_expr){sim_elto_org=get_reference(s_expr[2]);sim_elto_dst=get_reference(s_expr[1]);newval=get_value(sim_elto_org);set_value(sim_elto_dst,newval)},verbal:function(s_expr){var sim_elto_org=get_reference(s_expr[2]);var newval=get_value(sim_elto_org);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from "+show_verbal(s_expr[2])+" to "+show_verbal(s_expr[1])+" value "+show_value(newval)+". "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" ("+show_value(newval)+"). "}};sim.ep.behaviors["LOAD"]={nparameters:3,types:["X","X"],operation:function(s_expr){sim_elto_org=get_reference(s_expr[2]);sim_elto_dst=get_reference(s_expr[1]);newval=get_value(sim_elto_org);set_value(sim_elto_dst,newval)},verbal:function(s_expr){var sim_elto_org=get_reference(s_expr[2]);var newval=get_value(sim_elto_org);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Load from "+show_verbal(s_expr[2])+" to "+show_verbal(s_expr[1])+" value "+show_value(newval)+". "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" ("+show_value(newval)+"). "}};sim.ep.behaviors["CP_FIELD"]={nparameters:3,types:["X","X"],operation:function(s_expr){r=s_expr[2].split("/");sim_elto_org=get_reference(r[0]);newval=get_value(sim_elto_org);newval=newval[r[1]];if(typeof newval!="undefined"){sim_elto_dst=get_reference(s_expr[1]);set_value(sim_elto_dst,newval)}},verbal:function(s_expr){var newval=0;var r=s_expr[2].split("/");var sim_elto_org=get_reference(r[0]);var sim_elto_dst=get_reference(r[1]);if(typeof sim_elto_dst=="undefined")sim_elto_dst={};if(typeof sim_elto_org.value[r[1]]!="undefined")newval=sim_elto_org.value[r[1]];else if(typeof sim_elto_dst.default_value!="undefined")newval=sim_elto_dst.default_value;else newval="<undefined>";var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from Field "+r[1]+" of "+show_verbal(r[0])+" to "+show_verbal(s_expr[1])+" value "+newval+". "}return show_verbal(s_expr[1])+" = "+show_verbal(r[0])+"."+r[1]+" ("+newval+"). "}};sim.ep.behaviors["NOT_ES"]={nparameters:3,types:["S","E"],operation:function(s_expr){set_value(sim.ep.signals[s_expr[1]],Math.abs(get_value(sim.ep.states[s_expr[2]])-1))},verbal:function(s_expr){var value=Math.abs(get_value(sim.ep.states[s_expr[2]])-1);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Set "+show_verbal(s_expr[1])+" with value "+show_value(value)+" (Logical NOT of "+s_expr[2]+"). "}return show_verbal(s_expr[1])+" = "+show_value(value)+" (Logical NOT "+s_expr[2]+"). "}};sim.ep.behaviors["GET"]={nparameters:4,types:["E","E","S"],operation:function(s_expr){set_value(sim.ep.states[s_expr[1]],get_value(sim.ep.states[s_expr[2]][sim.ep.signals[s_expr[3]].value]))},verbal:function(s_expr){var value=get_value(sim.ep.states[s_expr[2]][sim.ep.signals[s_expr[3]].value]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Set "+show_verbal(s_expr[1])+" with value "+show_value(value)+" (Register File "+s_expr[3]+"). "}return show_verbal(s_expr[1])+" = "+show_value(value)+" (Register File "+s_expr[3]+"). "}};sim.ep.behaviors["SET"]={nparameters:4,types:["E","S","E"],operation:function(s_expr){set_value(sim.ep.states[s_expr[1]][sim.ep.signals[s_expr[2]].value],get_value(sim.ep.states[s_expr[3]]))},verbal:function(s_expr){var value=get_value(sim.ep.states[s_expr[3]]);var o_ref=sim.ep.states[s_expr[1]][sim.ep.signals[s_expr[2]].value];var o_verbal=o_ref.name;if(typeof o_ref.verbal!="undefined")o_verbal=o_ref.verbal;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy to "+o_verbal+" the value "+show_value(value)+". "}return o_verbal+" = "+show_value(value)+". "}};sim.ep.behaviors["AND"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])&get_value(sim.ep.states[s_expr[3]]);set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_v=0;sim.ep.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])&get_value(sim.ep.states[s_expr[3]]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU AND with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (AND). "}};sim.ep.behaviors["OR"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])|get_value(sim.ep.states[s_expr[3]]);set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_v=0;sim.ep.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])|get_value(sim.ep.states[s_expr[3]]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU OR with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (OR). "}};sim.ep.behaviors["NOT"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=~get_value(sim.ep.states[s_expr[2]]);set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_v=0;sim.ep.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=~get_value(sim.ep.states[s_expr[2]]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU NOT with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (NOT). "}};sim.ep.behaviors["XOR"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])^get_value(sim.ep.states[s_expr[3]]);set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_v=0;sim.ep.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])^get_value(sim.ep.states[s_expr[3]]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU XOR with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (XOR). "}};sim.ep.behaviors["SRL"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])>>>1;set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_v=0;sim.ep.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])>>>1;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Shift Right Logical with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (SRL). "}};sim.ep.behaviors["SRA"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])>>1;set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_v=0;sim.ep.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])>>1;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Shift Right Arithmetic with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (SRA). "}};sim.ep.behaviors["SL"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])<<1;set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_v=0;sim.ep.internal_states.alu_flags.flag_c=result>>>31},verbal:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])<<1;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Shift Left with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (SL). "}};sim.ep.behaviors["RR"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])>>>1|(get_value(sim.ep.states[s_expr[2]])&1)<<31;set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_v=0;sim.ep.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])>>>1|(get_value(sim.ep.states[s_expr[2]])&1)<<31;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Right Rotation with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (RR). "}};sim.ep.behaviors["RL"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])<<1|(get_value(sim.ep.states[s_expr[2]])&2147483648)>>>31;set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_v=0;sim.ep.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])<<1|(get_value(sim.ep.states[s_expr[2]])&2147483648)>>>31;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Left Rotation with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (LR). "}};sim.ep.behaviors["ADD"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var b=get_value(sim.ep.states[s_expr[3]])<<0;var result=a+b;set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_c=a>>>31&&b>>>31;sim.ep.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.ep.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.ep.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var b=get_value(sim.ep.states[s_expr[3]])<<0;var result=a+b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU ADD with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (ADD). "}};sim.ep.behaviors["SUB"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var b=get_value(sim.ep.states[s_expr[3]])<<0;var result=a-b;set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_c=a>>>31&&b>>>31;sim.ep.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.ep.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.ep.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var b=get_value(sim.ep.states[s_expr[3]])<<0;var result=a-b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU SUB with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (SUB). "}};sim.ep.behaviors["MUL"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var b=get_value(sim.ep.states[s_expr[3]])<<0;var result=a*b;set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_c=0;sim.ep.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.ep.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.ep.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var b=get_value(sim.ep.states[s_expr[3]])<<0;var result=a*b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU MUL with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (MUL). "}};sim.ep.behaviors["DIV"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var b=get_value(sim.ep.states[s_expr[3]])<<0;if(0==b){set_value(sim.ep.states[s_expr[1]],0);sim.ep.internal_states.alu_flags.flag_n=0;sim.ep.internal_states.alu_flags.flag_z=1;sim.ep.internal_states.alu_flags.flag_v=1;sim.ep.internal_states.alu_flags.flag_c=0;return}var result=Math.floor(a/b);set_value(sim.ep.states[s_expr[1]],result);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_v=0;sim.ep.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var b=get_value(sim.ep.states[s_expr[3]])<<0;if(0==b){return"ALU DIV zero by zero (oops!). "}var result=Math.floor(a/b);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU DIV with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (DIV). "}};sim.ep.behaviors["MOD"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var b=get_value(sim.ep.states[s_expr[3]])<<0;if(0==b){set_value(sim.ep.states[s_expr[1]],0);sim.ep.internal_states.alu_flags.flag_n=0;sim.ep.internal_states.alu_flags.flag_z=1;sim.ep.internal_states.alu_flags.flag_v=1;sim.ep.internal_states.alu_flags.flag_c=0;return}var result=a%b;set_value(sim.ep.states[s_expr[1]],result);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_v=0;sim.ep.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var b=get_value(sim.ep.states[s_expr[3]])<<0;if(0==b){return"ALU MOD zero by zero (oops!). "}var result=a%b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU MOD with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (MOD). "}};sim.ep.behaviors["LUI"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])<<16;set_value(sim.ep.states[s_expr[1]],result);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_v=0;sim.ep.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])<<16;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Load Upper Immediate with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (LUI). "}};sim.ep.behaviors["ADDU"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])>>>0;var b=get_value(sim.ep.states[s_expr[3]])>>>0;var result=a+b;set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_c=0;sim.ep.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.ep.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.ep.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])>>>0;var b=get_value(sim.ep.states[s_expr[3]])>>>0;var result=a+b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU ADDU with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (ADDU). "}};sim.ep.behaviors["SUBU"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])>>>0;var b=get_value(sim.ep.states[s_expr[3]])>>>0;var result=a-b;set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_c=0;sim.ep.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.ep.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.ep.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])>>>0;var b=get_value(sim.ep.states[s_expr[3]])>>>0;var result=a-b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU SUBU with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (SUBU). "}};sim.ep.behaviors["MULU"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])>>>0;var b=get_value(sim.ep.states[s_expr[3]])>>>0;var result=a*b;set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_c=0;sim.ep.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.ep.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.ep.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])>>>0;var b=get_value(sim.ep.states[s_expr[3]])>>>0;var result=a*b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU MULU with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (MULU). "}};sim.ep.behaviors["DIVU"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])>>>0;var b=get_value(sim.ep.states[s_expr[3]])>>>0;if(0==b){set_value(sim.ep.states[s_expr[1]],0);sim.ep.internal_states.alu_flags.flag_n=0;sim.ep.internal_states.alu_flags.flag_z=1;sim.ep.internal_states.alu_flags.flag_v=1;sim.ep.internal_states.alu_flags.flag_c=0;return}var result=Math.floor(a/b);set_value(sim.ep.states[s_expr[1]],result);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_v=0;sim.ep.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])>>>0;var b=get_value(sim.ep.states[s_expr[3]])>>>0;if(0==b){return"ALU DIVU zero by zero (oops!). "}var result=Math.floor(a/b);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU DIVU with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (DIVU). "}};sim.ep.behaviors["FADD"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]]);var b=get_value(sim.ep.states[s_expr[3]]);var result=hex2float(a)+hex2float(b);set_value(sim.ep.states[s_expr[1]],float32_to_uint(result));sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_c=0;sim.ep.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.ep.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.ep.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]]);var b=get_value(sim.ep.states[s_expr[3]]);var result=hex2float(a)+hex2float(b);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU FADD with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (FADD). "}};sim.ep.behaviors["FSUB"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]]);var b=get_value(sim.ep.states[s_expr[3]]);var result=hex2float(a)-hex2float(b);set_value(sim.ep.states[s_expr[1]],float32_to_uint(result));sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_c=0;sim.ep.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.ep.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.ep.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]]);var b=get_value(sim.ep.states[s_expr[3]]);var result=hex2float(a)-hex2float(b);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU FSUB with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (FSUB). "}};sim.ep.behaviors["FMUL"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]]);var b=get_value(sim.ep.states[s_expr[3]]);var result=hex2float(a)*hex2float(b);set_value(sim.ep.states[s_expr[1]],float32_to_uint(result));sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_c=0;sim.ep.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.ep.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.ep.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]]);var b=get_value(sim.ep.states[s_expr[3]]);var result=hex2float(a)*hex2float(b);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU FMUL with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (FMUL). "}};sim.ep.behaviors["FDIV"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]]);var b=get_value(sim.ep.states[s_expr[3]]);var result=hex2float(a)/hex2float(b);set_value(sim.ep.states[s_expr[1]],float32_to_uint(result));sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_c=0;sim.ep.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.ep.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.ep.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]]);var b=get_value(sim.ep.states[s_expr[3]]);var result=hex2float(a)-hex2float(b);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU FDIV with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (FDIV). "}};sim.ep.behaviors["FCVT"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])>>>0;var b=get_value(sim.ep.states[s_expr[3]]);var result=a;switch(b){case 1:result=hex2float(result);result=Math.trunc(result);break;case 2:result=hex2float(result);result=Math.round(result);break;case 4:result=result.toFixed(5);result=parseFloat(result);result=float2decimal(result);break;default:break}set_value(sim.ep.states[s_expr[1]],result);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_c=0;sim.ep.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.ep.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.ep.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])>>>0;var b=get_value(sim.ep.states[s_expr[3]]);var result=a;switch(b){case 1:result=hex2float(result);result=Math.trunc(result);break;case 2:result=hex2float(result);result=Math.round(result);break;case 4:result=result.toFixed(5);result=parseFloat(result);result=float2decimal(result);break;default:break}var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU FCVT with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (FCVT). "}};sim.ep.behaviors["FCLASS"]={nparameters:3,types:["E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])>>>0;var result=float_class(a);set_value(sim.ep.states[s_expr[1]],result);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_c=0;sim.ep.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.ep.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.ep.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[1]])>>>0;var result=float_class(a);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU FCLASS with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (FCLASS). "}};sim.ep.behaviors["PLUS1"]={nparameters:3,types:["E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var result=a+1;set_value(sim.ep.states[s_expr[1]],result>>>0)},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var result=a+1;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy to "+show_verbal(s_expr[1])+" "+show_verbal(s_expr[2])+" plus one with result "+show_value(result)+". "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" + 1"+" ("+show_value(result)+"). "}};sim.ep.behaviors["PLUS4"]={nparameters:3,types:["E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var result=a+4;set_value(sim.ep.states[s_expr[1]],result>>>0)},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var result=a+4;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy to "+show_verbal(s_expr[1])+" "+show_verbal(s_expr[2])+" plus four with result "+show_value(result)+". "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" + 4"+" ("+show_value(result)+"). "}};sim.ep.behaviors["SET_TT"]={nparameters:3,types:["E","I"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[1]])<<0;var b=parseInt(s_expr[2]);var m=Math.pow(2,b);var r=a|m;set_value(sim.ep.states[s_expr[1]],r);update_cpu_bus_fire(r,b)},verbal:function(s_expr){return""}};sim.ep.behaviors["RST_TT"]={nparameters:3,types:["E","I"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[1]])<<0;var b=parseInt(s_expr[2]);var m=Math.pow(2,b);var r=a&~m;set_value(sim.ep.states[s_expr[1]],r);update_cpu_bus_fire(r,b)},verbal:function(s_expr){return""}};sim.ep.behaviors["CHECK_RTD"]={nparameters:1,operation:function(s_expr){var number_active_tri=parseInt(simhw_sim_signal("TD").value)+parseInt(simhw_sim_signal("R").value);update_system_bus_fire(number_active_tri)},verbal:function(s_expr){return""}};sim.ep.behaviors["MBIT"]={nparameters:5,types:["X","X","I","I"],operation:function(s_expr){var sim_elto_dst=get_reference(s_expr[1]);var sim_elto_org=get_reference(s_expr[2]);var offset=parseInt(s_expr[3]);var size=parseInt(s_expr[4]);var n1=get_value(sim_elto_org).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(offset+size-1),size);set_value(sim_elto_dst,parseInt(n2,2))},verbal:function(s_expr){var sim_elto_dst=get_reference(s_expr[1]);var sim_elto_org=get_reference(s_expr[2]);var offset=parseInt(s_expr[3]);var size=parseInt(s_expr[4]);var n1=get_value(sim_elto_org).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(offset+size-1),size);var n3=parseInt(n2,2);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from "+show_verbal(s_expr[2])+" to "+show_verbal(s_expr[1])+" value "+show_value(n3)+" (copied "+size+" bits from bit "+offset+"). "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" ("+show_value(n3)+", "+size+" bits from bit "+offset+"). "}};sim.ep.behaviors["MBIT_SN"]={nparameters:5,types:["S","E","E","I"],operation:function(s_expr){var base=0;var r=s_expr[3].split("/");if(1==r.length)base=get_value(sim.ep.states[s_expr[3]]);else if(typeof sim.ep.states[r[0]].value[r[1]]!="undefined")base=sim.ep.states[r[0]].value[r[1]];else if(typeof sim.ep.signals[r[1]].default_value!="undefined")base=sim.ep.signals[r[1]].default_value;else if(typeof sim.ep.states[r[1]].default_value!="undefined")base=sim.ep.states[r[1]].default_value;else ws_alert("WARN: undefined state/field pair -> "+r[0]+"/"+r[1]);var offset=parseInt(s_expr[4]);var n1=get_value(sim.ep.states[s_expr[2]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;var n3=n2.substr(31-(base+offset-1),offset);set_value(sim.ep.signals[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){var base=0;var r=s_expr[3].split("/");if(1==r.length)base=get_value(sim.ep.states[s_expr[3]]);else if(typeof sim.ep.states[r[0]].value[r[1]]!="undefined")base=sim.ep.states[r[0]].value[r[1]];else if(typeof sim.ep.signals[r[1]].default_value!="undefined")base=sim.ep.signals[r[1]].default_value;else if(typeof sim.ep.states[r[1]].default_value!="undefined")base=sim.ep.states[r[1]].default_value;else ws_alert("WARN: undefined state/field pair -> "+r[0]+"/"+r[1]);var offset=parseInt(s_expr[4]);var n1=get_value(sim.ep.states[s_expr[2]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;var n3=n2.substr(31-(base+offset-1),offset);var from_elto="";if(1==r.length)from_elto=show_verbal(s_expr[3]);else from_elto=show_verbal(s_expr[2])+"["+r[1]+"] ";var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from "+from_elto+"into "+show_verbal(s_expr[1])+" "+"value "+parseInt(n3,2)+". "}return show_verbal(s_expr[1])+" = "+from_elto+" ("+parseInt(n3,2)+"). "}};sim.ep.behaviors["SBIT_SIGNAL"]={nparameters:4,types:["X","I","I"],operation:function(s_expr){sim_elto_dst=get_reference(s_expr[1]);var new_value=sim_elto_dst.value;var mask=1<>>0)},verbal:function(s_expr){sim_elto_dst=get_reference(s_expr[1]);var new_value=sim_elto_dst.value;var mask=1<>>0)}};sim.ep.behaviors["UPDATE_FLAG"]={nparameters:4,types:["X","X","I"],operation:function(s_expr){sim_elto_org=get_reference(s_expr[2]);sim_elto_dst=get_reference(s_expr[1]);var new_value=sim_elto_dst.value&~(1<>>0)},verbal:function(s_expr){sim_elto_org=get_reference(s_expr[2]);sim_elto_dst=get_reference(s_expr[1]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Update "+show_verbal(s_expr[2])+" to value "+sim_elto_org.value+". "}return show_verbal(s_expr[1])+"."+show_verbal(s_expr[3])+" = "+sim_elto_org.value+". "}};sim.ep.behaviors["MBITS"]={nparameters:8,types:["E","I","E","S","S","I","S"],operation:function(s_expr){var offset=parseInt(sim.ep.signals[s_expr[4]].value);var size=parseInt(sim.ep.signals[s_expr[5]].value);var n1=get_value(sim.ep.states[s_expr[3]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(offset+size-1),size);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;if("1"==sim.ep.signals[s_expr[7]].value&&"1"==n2.substr(0,1)){n3="11111111111111111111111111111111".substring(0,32-n2.length)+n2}set_value(sim.ep.states[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){var offset=parseInt(sim.ep.signals[s_expr[4]].value);var size=parseInt(sim.ep.signals[s_expr[5]].value);var n1=get_value(sim.ep.states[s_expr[3]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(offset+size-1),size);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;if("1"==sim.ep.signals[s_expr[7]].value&&"1"==n2.substr(0,1)){n3="11111111111111111111111111111111".substring(0,32-n2.length)+n2}n1=parseInt(n3,2);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return" Copy from "+show_verbal(s_expr[3])+" to "+show_verbal(s_expr[1])+" value "+show_value(n1)+" (copied "+size+" bits from bit "+offset+"). "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[3])+" ("+show_value(n1)+", "+size+" bits from bit "+offset+"). "}};sim.ep.behaviors["BSEL"]={nparameters:6,types:["E","I","I","E","I"],operation:function(s_expr){var posd=parseInt(s_expr[2]);var poso=parseInt(s_expr[5]);var len=parseInt(s_expr[3]);var n1=get_value(sim.ep.states[s_expr[4]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(poso+len)+1,len);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var n4="00000000000000000000000000000000".substr(0,posd);n3=n3+n4;set_value(sim.ep.states[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){var posd=parseInt(s_expr[2]);var len=parseInt(s_expr[3]);var poso=parseInt(s_expr[5]);var n1=get_value(sim.ep.states[s_expr[4]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(poso+len)+1,len);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var n4="00000000000000000000000000000000".substr(0,posd);n3=n3+n4;var n5=parseInt(n3,2);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from "+show_verbal(s_expr[4])+" to "+show_verbal(s_expr[1])+" value "+show_value(n5)+" (copied "+len+" bits, from bit "+poso+" of "+s_expr[4]+" to bit "+posd+" of "+s_expr[1]+"). "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[4])+" ("+show_value(n5)+", "+len+" bits, from bit "+poso+" of "+s_expr[4]+" to bit "+posd+" of "+s_expr[1]+"). "}};sim.ep.behaviors["EXT_SIG"]={nparameters:3,types:["E","I"],operation:function(s_expr){var n1=get_value(sim.ep.states[s_expr[1]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;var n3=n2.substr(31-s_expr[2],31);var n4=n3;if("1"==n2[31-s_expr[2]]){n4="11111111111111111111111111111111".substring(0,32-n3.length)+n4}set_value(sim.ep.states[s_expr[1]],parseInt(n4,2))},verbal:function(s_expr){var n1=get_value(sim.ep.states[s_expr[1]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;var n3=n2.substr(31-s_expr[2],31);var n4=n3;if("1"==n2[31-s_expr[2]]){n4="11111111111111111111111111111111".substring(0,32-n3.length)+n4}var n5=parseInt(n4,2);return"Sign Extension with value "+show_value(n5)+". "}};sim.ep.behaviors["MOVE_BITS"]={nparameters:5,types:["S","I","I","S"],operation:function(s_expr){var posd=parseInt(s_expr[2]);var poso=0;var len=parseInt(s_expr[3]);var n1=sim.ep.signals[s_expr[4]].value.toString(2);n1="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n1=n1.substr(31-poso-len+1,len);var n2=sim.ep.signals[s_expr[1]].value.toString(2);n2="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var m1=n2.substr(0,32-(posd+len));var m2=n2.substr(31-posd+1,posd);var n3=m1+n1+m2;set_value(sim.ep.signals[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){return""}};sim.ep.behaviors["MOVE_BITSE"]={nparameters:6,types:["S","I","I","E","I"],operation:function(s_expr){var posd=parseInt(s_expr[2]);var poso=parseInt(s_expr[5]);var len=parseInt(s_expr[3]);var n1=get_value(sim.ep.states[s_expr[4]]).toString(2);n1="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n1=n1.substr(31-poso-len+1,len);var n2=sim.ep.signals[s_expr[1]].value.toString(2);n2="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var m1=n2.substr(0,32-(posd+len));var m2=n2.substr(31-posd+1,posd);var n3=m1+n1+m2;set_value(sim.ep.signals[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){return""}};sim.ep.behaviors["DECO"]={nparameters:1,operation:function(s_expr){sim.ep.states["INEX"].value=0;var oi=decode_instruction(sim.ep.internal_states.FIRMWARE,sim.ep.ctrl_states.ir,get_value(sim.ep.states["REG_IR"]));if(null==oi.oinstruction){ws_alert("ERROR: undefined instruction code in IR ("+"co:"+oi.op_code.toString(2)+", "+"cop:"+oi.cop_code.toString(2)+")");sim.ep.states["ROM_MUXA"].value=0;sim.ep.states["INEX"].value=1;return-1}var rom_addr=oi.op_code<<6;if(typeof oi.oinstruction.cop!="undefined"){rom_addr=rom_addr+oi.cop_code}if(typeof sim.ep.internal_states["ROM"][rom_addr]=="undefined"){ws_alert("ERROR: undefined rom address "+rom_addr+" in firmware");sim.ep.states["ROM_MUXA"].value=0;return-1}sim.ep.states["ROM_MUXA"].value=sim.ep.internal_states["ROM"][rom_addr];var val=get_value(sim.ep.states["DECO_INS"]);set_value(sim.ep.states["DECO_INS"],val+1);var pc=get_value(sim.ep.states["REG_PC"])-4;var decins=get_deco_from_pc(pc);set_value(sim.ep.states["REG_IR_DECO"],decins);show_dbg_ir(get_value(sim.ep.states["REG_IR_DECO"]))},verbal:function(s_expr){return"Decode instruction. "}};sim.ep.behaviors["FIRE"]={nparameters:2,types:["S"],operation:function(s_expr){if(sim.ep.internal_states.fire_stack.indexOf(s_expr[1])!=-1){return}sim.ep.internal_states.fire_stack.push(s_expr[1]);update_draw(sim.ep.signals[s_expr[1]],sim.ep.signals[s_expr[1]].value);if("L"==sim.ep.signals[s_expr[1]].type){update_state(s_expr[1])}sim.ep.internal_states.fire_stack.pop(s_expr[1])},verbal:function(s_expr){return""}};sim.ep.behaviors["FIRE_IFSET"]={nparameters:3,types:["S","I"],operation:function(s_expr){if(get_value(sim.ep.signals[s_expr[1]])!=parseInt(s_expr[2])){return}sim.ep.behaviors["FIRE"].operation(s_expr)},verbal:function(s_expr){return""}};sim.ep.behaviors["FIRE_IFCHANGED"]={nparameters:3,types:["S","X"],operation:function(s_expr){sim_elto=get_reference(s_expr[2]);if(sim_elto.changed==false){return}sim.ep.behaviors["FIRE"].operation(s_expr)},verbal:function(s_expr){return""}};sim.ep.behaviors["RESET_CHANGED"]={nparameters:2,types:["X"],operation:function(s_expr){sim_elto=get_reference(s_expr[1]);sim_elto.changed=false},verbal:function(s_expr){return""}};sim.ep.behaviors["CLOCK"]={nparameters:1,operation:function(s_expr){var new_maddr=null;var mcelto=null;var t0=performance.now();var val=get_value(sim.ep.states["CLK"]);set_value(sim.ep.states["CLK"],val+1);set_value(sim.ep.states["TTCPU"],0);new_maddr=get_value(sim.ep.states["REG_MICROADDR"]);mcelto=sim.ep.internal_states["MC"][new_maddr];if(typeof mcelto!=="undefined"&&false==mcelto.is_native){for(var i=0;i>>0},set_value:function(elto,value){var origin="";var r_value=main_memory_get_program_counter();if(r_value!=null){origin="PC=0x"+r_value.toString(16)}var melto={value:value>>>0,source_tracking:[origin],comments:null};var valref=main_memory_set(sim.ep.internal_states.MP,elto,melto);show_main_memory(sim.ep.internal_states.MP,elto,typeof valref==="undefined",true);return value}};sim.ep.internal_states.segments={};sim.ep.internal_states.MP_wc=0;sim.ep.internal_states.MP={};sim.ep.internal_states.CM_cfg=[];sim.ep.internal_states.CM=[];sim.ep.signals.MRDY={name:"MRDY",visible:true,type:"L",value:0,default_value:0,nbits:"1",depends_on:["CLK"],behavior:["FIRE_IFCHANGED MRDY C","FIRE_IFCHANGED MRDY C"],fire_name:["svg_p:tspan3916","svg_p:text3909"],draw_data:[[],["svg_p:path3895","svg_p:path3541"]],draw_name:[[],[]]};sim.ep.signals.R={name:"R",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; CHECK_RTD","MEM_READ BUS_AB BUS_DB BWA MRDY CLK; FIRE MRDY; CHECK_RTD"],fire_name:["svg_p:text3533-5-2","svg_p:text3713"],draw_data:[[],["svg_p:path3557","svg_p:path3571"]],draw_name:[[],[]]};sim.ep.signals.W={name:"W",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","MEM_WRITE BUS_AB BUS_DB BWA MRDY CLK; FIRE MRDY"],fire_name:["svg_p:text3533-5-08","svg_p:text3527","svg_p:text3431-7"],draw_data:[[],["svg_p:path3559","svg_p:path3575","svg_p:path3447-7"]],draw_name:[[],[]]};sim.ep.behaviors.MEM_READ={nparameters:6,types:["E","E","S","S","E"],operation:function(s_expr){var address=sim.ep.states[s_expr[1]].value;var dbvalue=sim.ep.states[s_expr[2]].value;var bw=sim.ep.signals[s_expr[3]].value;var clk=get_value(sim.ep.states[s_expr[5]]);sim.ep.signals[s_expr[4]].value=0;var remain=get_value(sim.ep.internal_states.MP_wc);if(typeof sim.ep.events.mem[clk-1]!="undefined"&&sim.ep.events.mem[clk-1]>0){remain=sim.ep.events.mem[clk-1]-1}var first_time=typeof sim.ep.events.mem[clk]=="undefined";sim.ep.events.mem[clk]=remain;if(remain>0){return}address=address&4294967292;var value=main_memory_getvalue(sim.ep.internal_states.MP,address);var full_redraw=false;if(typeof value==="undefined"){value=0;full_redraw=true}dbvalue=main_memory_fusionvalues(dbvalue,value,bw);sim.ep.states[s_expr[2]].value=dbvalue>>>0;sim.ep.signals[s_expr[4]].value=1;show_main_memory(sim.ep.internal_states.MP,address,full_redraw,false);if(first_time&&sim.ep.internal_states.CM.length>0){cache_memory_access(sim.ep.internal_states.CM[0],address,"read",clk)}},verbal:function(s_expr){var verbal="";var address=sim.ep.states[s_expr[1]].value;var dbvalue=sim.ep.states[s_expr[2]].value;var bw=sim.ep.signals[s_expr[3]].value;var clk=get_value(sim.ep.states[s_expr[5]]);var bw_type="word";if(0==(bw&12))bw_type="byte";else if(1==(bw&12))bw_type="half";var value=main_memory_getvalue(sim.ep.internal_states.MP,address);if(typeof value==="undefined")value=0;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){verbal="Try to read a "+bw_type+" from memory "+"at address 0x"+address.toString(16)+" with value 0x"+value.toString(16)+". "}verbal="Memory output = 0x"+value.toString(16)+" (Read a "+bw_type+" from 0x"+address.toString(16)+"). ";return verbal}};sim.ep.behaviors.MEM_WRITE={nparameters:6,types:["E","E","S","S","E"],operation:function(s_expr){var address=sim.ep.states[s_expr[1]].value;var dbvalue=sim.ep.states[s_expr[2]].value;var bw=sim.ep.signals[s_expr[3]].value;var clk=get_value(sim.ep.states[s_expr[5]]);sim.ep.signals[s_expr[4]].value=0;var remain=get_value(sim.ep.internal_states.MP_wc);if(typeof sim.ep.events.mem[clk-1]!="undefined"&&sim.ep.events.mem[clk-1]>0){remain=sim.ep.events.mem[clk-1]-1}var first_time=typeof sim.ep.events.mem[clk]=="undefined";sim.ep.events.mem[clk]=remain;if(remain>0){return}address=address&4294967292;var value=main_memory_getvalue(sim.ep.internal_states.MP,address);var full_redraw=false;if(typeof value==="undefined"){value=0;full_redraw=true}value=main_memory_fusionvalues(value,dbvalue,bw);var origin="";var r_value=main_memory_get_program_counter();if(r_value!=null){origin="PC=0x"+r_value.toString(16)}var melto={value:value>>>0,source_tracking:[origin],comments:null};var valref=main_memory_set(sim.ep.internal_states.MP,address,melto);sim.ep.signals[s_expr[4]].value=1;show_main_memory(sim.ep.internal_states.MP,address,full_redraw,true);if(first_time&&sim.ep.internal_states.CM.length>0){cache_memory_access(sim.ep.internal_states.CM[0],address,"write",clk)}},verbal:function(s_expr){var verbal="";var address=sim.ep.states[s_expr[1]].value;var dbvalue=sim.ep.states[s_expr[2]].value;var bw=sim.ep.signals[s_expr[3]].value;var clk=get_value(sim.ep.states[s_expr[5]]);var bw_type="word";if(0==(bw&12))bw_type="byte";else if(1==(bw&12))bw_type="half";var value=main_memory_getvalue(sim.ep.internal_states.MP,address);if(typeof value==="undefined")value=0;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){verbal="Try to write a "+bw_type+" to memory "+"at address 0x"+address.toString(16)+" with value "+value.toString(16)+". "}verbal="Memory[0x"+address.toString(16)+"] = "+"0x"+value.toString(16)+" (Write a "+bw_type+" to 0x"+address.toString(16)+"). ";return verbal}};sim.ep.behaviors.MEMORY_RESET={nparameters:1,operation:function(s_expr){sim.ep.events.mem={}},verbal:function(s_expr){return"Reset main memory (all values will be zeroes). "}};sim.ep.elements.memory={name:"Main memory",description:"Main memory subsystem",type:"subcomponent",belongs:"MEMORY",states:{addr:{ref:"BUS_AB"},data:{ref:"BUS_DB"},mrdy:{ref:"MRDY"}},signals:{be:{ref:"BWA"},r:{ref:"R"},w:{ref:"W"}},states_inputs:["addr","data"],states_outputs:["mrdy","data"],signals_inputs:["be","r","w"],signals_output:[]};sim.ep.components.IO={name:"IO",version:"1",abilities:["IO_TIMER"],details_name:["IO_STATS","IO_CONFIG"],details_fire:[["svg_p:text3775"],[]],write_state:function(vec){return vec},read_state:function(o,check){return false},get_state:function(reg){return null},get_value:function(elto){var associated_state=simhw_internalState_get("io_hash",elto);var value=get_value(simhw_sim_state(associated_state))>>>0;set_value(simhw_sim_state("BUS_AB"),elto);set_value(simhw_sim_signal("IOR"),1);compute_behavior("FIRE IOR");value=get_value(simhw_sim_state("BUS_DB"));return value},set_value:function(elto,value){var associated_state=simhw_internalState_get("io_hash",elto);set_value(simhw_sim_state(associated_state),value);set_value(simhw_sim_state("BUS_AB"),elto);set_value(simhw_sim_state("BUS_DB"),value);set_value(simhw_sim_signal("IOW"),1);compute_behavior("FIRE IOW");return value}};sim.ep.internal_states.io_int_factory=[];sim.ep.internal_states.io_int_factory[0]={period:0,probability:.5,accumulated:0,active:false};sim.ep.internal_states.io_int_factory[1]={period:0,probability:.5,accumulated:0,active:false};sim.ep.internal_states.io_int_factory[2]={period:0,probability:.5,accumulated:0,active:false};sim.ep.internal_states.io_int_factory[3]={period:0,probability:.5,accumulated:0,active:false};sim.ep.internal_states.io_int_factory[4]={period:0,probability:.5,accumulated:0,active:false};sim.ep.internal_states.io_int_factory[5]={period:0,probability:.5,accumulated:0,active:false};sim.ep.internal_states.io_int_factory[6]={period:0,probability:.5,accumulated:0,active:false};sim.ep.internal_states.io_int_factory[7]={period:0,probability:.5,accumulated:0,active:false};var IOSR_ID=4352;var IOCR_ID=4356;var IODR_ID=4360;sim.ep.internal_states.io_hash[IOSR_ID]="IOSR";sim.ep.internal_states.io_hash[IOCR_ID]="IOCR";sim.ep.internal_states.io_hash[IODR_ID]="IODR";sim.ep.states.IOSR={name:"IOSR",verbal:"IO State Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.IOCR={name:"IOCR",verbal:"IO Control Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.IODR={name:"IODR",verbal:"IO Data Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.signals.INT={name:"INT",visible:true,type:"L",value:0,default_value:0,nbits:"1",depends_on:["CLK"],behavior:["FIRE C","FIRE C"],fire_name:["svg_p:tspan4199"],draw_data:[[],["svg_p:path3809"]],draw_name:[[],[]]};sim.ep.signals.IORDY={name:"IORDY",visible:true,type:"L",value:0,default_value:0,nbits:"1",depends_on:["CLK"],behavior:["FIRE_IFCHANGED IORDY C","FIRE_IFCHANGED IORDY C"],fire_name:["svg_p:tspan4089","svg_p:path3793","svg_p:text3911"],draw_data:[[],["svg_p:path3897"]],draw_name:[[],[]]};sim.ep.signals.IO_IOR={name:"IO_IOR",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","IO_IOR BUS_AB BUS_DB IOSR IOCR IODR CLK; FIRE SBWA"],fire_name:["svg_p:tspan4173"],draw_data:[[],["svg_p:path3795","svg_p:path3733"]],draw_name:[[],[]]};sim.ep.signals.IO_IOW={name:"IO_IOW",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","IO_IOW BUS_AB BUS_DB IOSR IOCR IODR CLK; FIRE SBWA"],fire_name:["svg_p:text3785-0-6-0-5-5"],draw_data:[[],["svg_p:path3805","svg_p:path3733"]],draw_name:[[],[]]};sim.ep.signals.IO_IE={name:"IO_IE",visible:true,type:"L",value:1,default_value:1,nbits:"1",behavior:["NOP","IO_CHK_I CLK INT INTV; FIRE C"],fire_name:[],draw_data:[[],[]],draw_name:[[],[]]};sim.ep.signals.INTA={name:"INTA",visible:true,type:"L",value:1,default_value:0,nbits:"1",behavior:["NOP","INTA CLK INT INTA BUS_DB INTV; FIRE BW; FIRE C"],fire_name:["svg_p:text3785-0-6-0-5-5-1-1"],draw_data:[[],["svg_p:path3807","svg_p:path3737"]],draw_name:[[],[]]};sim.ep.behaviors.IO_IOR={nparameters:7,types:["E","E","E","E","E","E"],operation:function(s_expr){var bus_ab=get_value(sim.ep.states[s_expr[1]]);var iosr=get_value(sim.ep.states[s_expr[3]]);var iocr=get_value(sim.ep.states[s_expr[4]]);var iodr=get_value(sim.ep.states[s_expr[5]]);if(bus_ab==IOSR_ID)set_value(sim.ep.states[s_expr[2]],iosr);if(bus_ab==IOCR_ID)set_value(sim.ep.states[s_expr[2]],iocr);if(bus_ab==IODR_ID)set_value(sim.ep.states[s_expr[2]],iodr)},verbal:function(s_expr){var verbal="";var bus_ab=get_value(sim.ep.states[s_expr[1]]);var iosr=get_value(sim.ep.states[s_expr[3]]);var iocr=get_value(sim.ep.states[s_expr[4]]);var iodr=get_value(sim.ep.states[s_expr[5]]);if(bus_ab==IOSR_ID)verbal="I/O device read at IOSR of value "+iosr+". ";if(bus_ab==IOCR_ID)verbal="I/O device read at IOCR of value "+iocr+". ";if(bus_ab==IODR_ID)verbal="I/O device read at IODR of value "+iodr+". ";return verbal}};sim.ep.behaviors.IO_IOW={nparameters:7,types:["E","E","E","E","E","E"],operation:function(s_expr){var bus_ab=get_value(sim.ep.states[s_expr[1]]);var bus_db=get_value(sim.ep.states[s_expr[2]]);if(bus_ab!=IOSR_ID&&bus_ab!=IOCR_ID&&bus_ab!=IODR_ID){return}if(bus_ab==IOSR_ID)set_value(sim.ep.states[s_expr[3]],bus_db);if(bus_ab==IOCR_ID)set_value(sim.ep.states[s_expr[4]],bus_db);if(bus_ab==IODR_ID)set_value(sim.ep.states[s_expr[5]],bus_db);var iocr_id=get_value(sim.ep.states[s_expr[4]]);var iodr_id=get_value(sim.ep.states[s_expr[5]]);if(iocr_id<0||iocr_id>7)return;set_var(sim.ep.internal_states.io_int_factory[iocr_id].period,iodr_id);set_var(sim.ep.internal_states.io_int_factory[iocr_id].probability,1);if(0==iodr_id){set_var(sim.ep.internal_states.io_int_factory[iocr_id].probability,0)}},verbal:function(s_expr){var verbal="";var bus_ab=get_value(sim.ep.states[s_expr[1]]);var bus_db=get_value(sim.ep.states[s_expr[2]]);if(bus_ab==IOSR_ID)verbal="I/O device write at IOSR with value "+bus_db+". ";if(bus_ab==IOCR_ID)verbal="I/O device write at IOCR with value "+bus_db+". ";if(bus_ab==IODR_ID)verbal="I/O device write at IODR with value "+bus_db+". ";return verbal}};sim.ep.behaviors.IO_CHK_I={nparameters:4,types:["E","S","E"],operation:function(s_expr){var clk=get_value(sim.ep.states[s_expr[1]]);for(var i=sim.ep.internal_states.io_int_factory.length-1;i>=0;i--){if(get_var(sim.ep.internal_states.io_int_factory[i].period)==0)continue;if(get_var(sim.ep.internal_states.io_int_factory[i].active)==true){set_value(sim.ep.signals[s_expr[2]],1);set_value(sim.ep.states[s_expr[3]],i)}if(clk%get_var(sim.ep.internal_states.io_int_factory[i].period)==0){if(Math.random()>get_var(sim.ep.internal_states.io_int_factory[i].probability))continue;var acc=get_var(sim.ep.internal_states.io_int_factory[i].accumulated);set_var(sim.ep.internal_states.io_int_factory[i].accumulated,acc+1);set_var(sim.ep.internal_states.io_int_factory[i].active,true);if(typeof sim.ep.events.io[clk]=="undefined"){sim.ep.events.io[clk]=[]}sim.ep.events.io[clk].push(i);set_value(sim.ep.signals[s_expr[2]],1);set_value(sim.ep.states[s_expr[3]],i)}}},verbal:function(s_expr){return"Check I/O Interruption. "}};sim.ep.behaviors.INTA={nparameters:6,types:["E","S","S","E","E"],operation:function(s_expr){var clk=get_value(sim.ep.states[s_expr[1]]);if(typeof sim.ep.events.io[clk]!="undefined"){set_value(sim.ep.states[s_expr[4]],sim.ep.events.io[clk][0]);return}set_value(sim.ep.signals[s_expr[2]],0);set_value(sim.ep.states[s_expr[5]],0);for(var i=0;i>>0;set_value(simhw_sim_state("BUS_AB"),elto);set_value(simhw_sim_signal("IOR"),1);compute_behavior("FIRE IOR");value=get_value(simhw_sim_state("BUS_DB"));return value},set_value:function(elto,value){var associated_state=simhw_internalState_get("io_hash",elto);set_value(simhw_sim_state(associated_state),value);set_value(simhw_sim_state("BUS_AB"),elto);set_value(simhw_sim_state("BUS_DB"),value);set_value(simhw_sim_signal("IOW"),1);compute_behavior("FIRE IOW");return value}};sim.ep.internal_states.l3d_dim=4;sim.ep.internal_states.l3d_neltos=Math.pow(sim.ep.internal_states.l3d_dim,3);sim.ep.internal_states.l3d_state=Array.from({length:sim.ep.internal_states.l3d_neltos},(()=>({active:false})));sim.ep.internal_states.l3d_frame="0".repeat(sim.ep.internal_states.l3d_neltos);var L3DSR_ID=8448;var L3DCR_ID=8452;var L3DDR_ID=8456;sim.ep.internal_states.io_hash[L3DSR_ID]="L3DSR";sim.ep.internal_states.io_hash[L3DCR_ID]="L3DCR";sim.ep.internal_states.io_hash[L3DDR_ID]="L3DDR";sim.ep.states.L3DSR={name:"L3DSR",verbal:"L3D State Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.L3DCR={name:"L3DCR",verbal:"L3D Control Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.L3DDR={name:"L3DDR",verbal:"L3D Data Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.signals.L3D_IOR={name:"L3D_IOR",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","L3D_IOR BUS_AB BUS_DB L3DSR L3DCR L3DDR CLK; FIRE SBWA"],fire_name:["svg_p:tspan4173"],draw_data:[[],["svg_p:path3795","svg_p:path3733"]],draw_name:[[],[]]};sim.ep.signals.L3D_IOW={name:"L3D_IOW",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","L3D_IOW BUS_AB BUS_DB L3DSR L3DCR L3DDR CLK; FIRE SBWA; L3D_SYNC"],fire_name:["svg_p:text3785-0-6-0-5-5"],draw_data:[[],["svg_p:path3805","svg_p:path3733"]],draw_name:[[],[]]};sim.ep.behaviors.L3D_IOR={nparameters:7,types:["E","E","E","E","E","E"],operation:function(s_expr){var bus_ab=get_value(sim.ep.states[s_expr[1]]);var iosr=get_value(sim.ep.states[s_expr[3]]);var iocr=get_value(sim.ep.states[s_expr[4]]);var iodr=get_value(sim.ep.states[s_expr[5]]);if(bus_ab==L3DCR_ID){set_value(sim.ep.states[s_expr[2]],iocr)}if(bus_ab==L3DDR_ID){set_value(sim.ep.states[s_expr[2]],iodr)}if(bus_ab==L3DSR_ID){var x=(iodr&4278190080)>>24;var y=(iodr&16711680)>>16;var z=(iodr&65280)>>8;var p=z*Math.pow(sim.ep.internal_states.l3d_dim,2)+y*sim.ep.internal_states.l3d_dim+x;var s=get_var(sim.ep.internal_states.l3d_state[p].active);set_value(sim.ep.states[s_expr[2]],s)}},verbal:function(s_expr){var verbal="";var bus_ab=get_value(sim.ep.states[s_expr[1]]);var iosr=get_value(sim.ep.states[s_expr[3]]);var iocr=get_value(sim.ep.states[s_expr[4]]);var iodr=get_value(sim.ep.states[s_expr[5]]);if(bus_ab==L3DSR_ID)verbal="I/O device read at L3DSR of value "+iosr+". ";if(bus_ab==L3DCR_ID)verbal="I/O device read at L3DCR of value "+iocr+". ";if(bus_ab==L3DDR_ID)verbal="I/O device read at L3DDR of value "+iodr+". ";return verbal}};sim.ep.behaviors.L3D_IOW={nparameters:7,types:["E","E","E","E","E","E"],operation:function(s_expr){var bus_ab=get_value(sim.ep.states[s_expr[1]]);var bus_db=get_value(sim.ep.states[s_expr[2]]);if(bus_ab!=L3DSR_ID&&bus_ab!=L3DCR_ID&&bus_ab!=L3DDR_ID){return}if(bus_ab==L3DSR_ID){set_value(sim.ep.states[s_expr[3]],bus_db)}if(bus_ab==L3DDR_ID){set_value(sim.ep.states[s_expr[5]],bus_db)}if(bus_ab==L3DCR_ID){set_value(sim.ep.states[s_expr[4]],bus_db);var x=(bus_db&4278190080)>>24;var y=(bus_db&16711680)>>16;var z=(bus_db&65280)>>8;var p=z*Math.pow(sim.ep.internal_states.l3d_dim,2)+y*sim.ep.internal_states.l3d_dim+x;var s=(bus_db&255)!=0;set_var(sim.ep.internal_states.l3d_state[p].active,s)}},verbal:function(s_expr){var verbal="";var bus_ab=get_value(sim.ep.states[s_expr[1]]);var bus_db=get_value(sim.ep.states[s_expr[2]]);if(bus_ab==L3DSR_ID)verbal="I/O device write at L3DSR with value "+bus_db+". ";if(bus_ab==L3DCR_ID)verbal="I/O device write at L3DCR with value "+bus_db+". ";if(bus_ab==L3DDR_ID)verbal="I/O device write at L3DDR with value "+bus_db+". ";return verbal}};sim.ep.behaviors.L3D_RESET={nparameters:1,operation:function(s_expr){sim.ep.events.l3d={};var n=sim.ep.internal_states.l3d_state.length;for(var i=0;i>>0;set_value(simhw_sim_state("BUS_AB"),elto);set_value(simhw_sim_signal("IOR"),1);compute_behavior("FIRE IOR");value=get_value(simhw_sim_state("BUS_DB"));return value},set_value:function(elto,value){var associated_state=simhw_internalState_get("io_hash",elto);set_value(simhw_sim_state(associated_state),value);set_value(simhw_sim_state("BUS_AB"),elto);set_value(simhw_sim_state("BUS_DB"),value);set_value(simhw_sim_signal("IOW"),1);compute_behavior("FIRE IOW");return value}};sim.ep.internal_states.ledm_dim=24;sim.ep.internal_states.ledm_neltos=Math.pow(sim.ep.internal_states.ledm_dim,2);sim.ep.internal_states.ledm_state=Array.from({length:sim.ep.internal_states.ledm_neltos},(()=>({color:0})));sim.ep.internal_states.ledm_colors=colors_clone("");sim.ep.internal_states.ledm_frame="0".repeat(sim.ep.internal_states.ledm_neltos);var LEDMSR_ID=12544;var LEDMCR_ID=12548;var LEDMDR_ID=12552;sim.ep.internal_states.io_hash[LEDMSR_ID]="LEDMSR";sim.ep.internal_states.io_hash[LEDMCR_ID]="LEDMCR";sim.ep.internal_states.io_hash[LEDMDR_ID]="LEDMDR";sim.ep.states.LEDMSR={name:"LEDMSR",verbal:"LEDM State Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.LEDMCR={name:"LEDMCR",verbal:"LEDM Control Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.LEDMDR={name:"LEDMDR",verbal:"LEDM Data Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.signals.LEDM_IOR={name:"LEDM_IOR",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","LEDM_IOR BUS_AB BUS_DB LEDMSR LEDMCR LEDMDR CLK; FIRE SBWA"],fire_name:["svg_p:tspan4173"],draw_data:[[],["svg_p:path3795","svg_p:path3733"]],draw_name:[[],[]]};sim.ep.signals.LEDM_IOW={name:"LEDM_IOW",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","LEDM_IOW BUS_AB BUS_DB LEDMSR LEDMCR LEDMDR CLK; FIRE SBWA; LEDM_SYNC"],fire_name:["svg_p:text3785-0-6-0-5-5"],draw_data:[[],["svg_p:path3805","svg_p:path3733"]],draw_name:[[],[]]};sim.ep.behaviors.LEDM_IOR={nparameters:7,types:["E","E","E","E","E","E"],operation:function(s_expr){var bus_ab=get_value(sim.ep.states[s_expr[1]]);var iosr=get_value(sim.ep.states[s_expr[3]]);var iocr=get_value(sim.ep.states[s_expr[4]]);var iodr=get_value(sim.ep.states[s_expr[5]]);if(bus_ab==LEDMCR_ID){set_value(sim.ep.states[s_expr[2]],iocr)}if(bus_ab==LEDMDR_ID){set_value(sim.ep.states[s_expr[2]],iodr)}if(bus_ab==LEDMSR_ID){var x=(iodr&4278190080)>>24;var y=(iodr&16711680)>>16;var p=y*sim.ep.internal_states.ledm_dim+x;var s=get_var(sim.ep.internal_states.ledm_state[p].color);set_value(sim.ep.states[s_expr[2]],s)}},verbal:function(s_expr){var verbal="";var bus_ab=get_value(sim.ep.states[s_expr[1]]);var iosr=get_value(sim.ep.states[s_expr[3]]);var iocr=get_value(sim.ep.states[s_expr[4]]);var iodr=get_value(sim.ep.states[s_expr[5]]);if(bus_ab==LEDMSR_ID)verbal="I/O device read at LEDMSR of value "+iosr+". ";if(bus_ab==LEDMCR_ID)verbal="I/O device read at LEDMCR of value "+iocr+". ";if(bus_ab==LEDMDR_ID)verbal="I/O device read at LEDMDR of value "+iodr+". ";return verbal}};sim.ep.behaviors.LEDM_IOW={nparameters:7,types:["E","E","E","E","E","E"],operation:function(s_expr){var bus_ab=get_value(sim.ep.states[s_expr[1]]);var bus_db=get_value(sim.ep.states[s_expr[2]]);switch(bus_ab){case LEDMSR_ID:set_value(sim.ep.states[s_expr[3]],bus_db);break;case LEDMDR_ID:set_value(sim.ep.states[s_expr[5]],bus_db);break;case LEDMCR_ID:set_value(sim.ep.states[s_expr[4]],bus_db);break;default:break}if(LEDMCR_ID==bus_ab){var dr=get_value(sim.ep.states[s_expr[5]]);if(16&bus_db){var x=(dr&4278190080)>>24;var y=(dr&16711680)>>16;var s=dr&255;set_value(sim.ep.states[s_expr[3]],1);if(x>=sim.ep.internal_states.ledm_dim&&y>=sim.ep.internal_states.ledm_dim){set_value(sim.ep.states[s_expr[3]],-1);return}var p=y*sim.ep.internal_states.ledm_dim+x;set_var(sim.ep.internal_states.ledm_state[p].color,s)}if(32&bus_db){set_value(sim.ep.states[s_expr[3]],1);var s=0;var neltos=sim.ep.internal_states.ledm_neltos;for(var p=0;p>0);set_var(sim.ep.internal_states.ledm_state[p+1].color,(s&65280)>>8);set_var(sim.ep.internal_states.ledm_state[p+2].color,(s&16711680)>>16);set_var(sim.ep.internal_states.ledm_state[p+3].color,(s&4278190080)>>24)}}if(64&bus_db){set_value(sim.ep.states[s_expr[3]],1);var s=0;var c="";var neltos=sim.ep.internal_states.ledm_colors.length;for(var p=0;p>>8;s=s.toString(16);c="#"+simcoreui_pack(s,6);sim.ep.internal_states.ledm_colors[p]=c}neltos=sim.ep.internal_states.ledm_neltos;for(var p=0;p>24;var y=(dr&16711680)>>16;var s=dr&255;verbal="I/O device write at LEDMCR with value "+bus_db+" (set pixel x:"+x+", y:"+y+", with color:"+s+"). "}if(64&bus_db){verbal="I/O device write at LEDMCR with value "+bus_db+" (set color palette at:"+bus_db+"). "}break;default:break}return verbal}};sim.ep.behaviors.LEDM_RESET={nparameters:1,operation:function(s_expr){sim.ep.events.ledm={};sim.ep.internal_states.ledm_colors=colors_clone("");for(var i=0;i>>0;if(value!=0){vec.CPU["R"+i]={type:"register",default_value:0,id:"R"+i,op:"=",value:"0x"+value.toString(16)}}}for(var i=0;i>>0;if(value!=0){vec.CPU[internal_reg[i]]={type:"register",default_value:0,id:internal_reg[i],op:"=",value:"0x"+value.toString(16)}}}return vec},read_state:function(vec,check){if(typeof vec.CPU=="undefined")vec.CPU={};var key=check["id"].toUpperCase().trim();var val=parseInt(check["value"]).toString(16);if("REGISTER"==check["type"].toUpperCase().trim()){vec.CPU[key]={type:"register",default_value:0,id:key,op:check["condition"],value:"0x"+val};return true}return false},get_state:function(reg){var r_reg=reg.toUpperCase().trim();if(typeof sim.poc.states["REG_"+r_reg]!="undefined"){var value=get_value(sim.poc.states["REG_"+r_reg])>>>0;return"0x"+value.toString(16)}r_reg=r_reg.replace("R","");var index=parseInt(r_reg);if(typeof sim.poc.states.BR[index]!="undefined"){var value=get_value(sim.poc.states.BR[index])>>>0;return"0x"+value.toString(16)}return null},get_value:function(elto){if(Number.isInteger(elto))index=elto;else index=parseInt(elto);if(isNaN(index))return get_value(simhw_sim_state(elto))>>>0;return get_value(simhw_sim_states().BR[index])>>>0},set_value:function(elto,value){var pc_name=simhw_sim_ctrlStates_get().pc.state;if(Number.isInteger(elto))index=elto;else index=parseInt(elto);if(isNaN(index)){set_value(simhw_sim_state(elto),value);if(pc_name===elto){show_asmdbg_pc()}return value}return set_value(simhw_sim_states().BR[index],value)}};sim.poc.ctrl_states.pc={name:"PC",state:"REG_PC",is_pointer:true};sim.poc.ctrl_states.sp={name:"SP",state:"BR.29",is_pointer:true};sim.poc.ctrl_states.fp={name:"FP",state:"BR.30",is_pointer:true};sim.poc.ctrl_states.ir={name:"IR",state:"REG_IR",default_eltos:{co:{begin:0,end:5,length:6},cop:{begin:27,end:31,length:5},oc:{begin:0,end:6,length:7}},is_pointer:false};sim.poc.ctrl_states.mpc={name:"mPC",state:"REG_MICROADDR",is_pointer:false};sim.poc.internal_states.MC={};sim.poc.internal_states.ROM={};sim.poc.internal_states.FIRMWARE=ws_empty_firmware;sim.poc.internal_states.io_hash={};sim.poc.internal_states.fire_stack=[];sim.poc.internal_states.tri_state_names=["T1","T2","T3","T6","T8","T9","T10","T11","T12"];sim.poc.internal_states.fire_visible={databus:false,internalbus:false};sim.poc.internal_states.filter_states=["REG_IR_DECO,col-12","REG_IR,col-auto","REG_PC,col-auto","REG_SR,col-auto","REG_RT1,col-auto","REG_MAR,col-auto","REG_MBR,col-auto","REG_MICROADDR,col-auto"];sim.poc.internal_states.filter_signals=["A0,0","B,0","C,0","SELA,5","SELB,5","SELC,2","SELCOP,0","MRA,0","MRB,0","MRC,0","MC,0","C0,0","C1,0","C2,0","C3,0","C4,0","C7,0","T1,0","T2,0","T3,0","T6,0","T8,0","T9,0","T10,0","T11,0","M1,0","M7,0","MA,0","MB,0","LC,0","SE,0","SIZE,0","OFFSET,0","BW,0","R,0","W,0","TA,0","TD,0","IOR,0","IOW,0","TEST_I,0","TEST_U,0"];sim.poc.internal_states.alu_flags={flag_n:0,flag_z:0,flag_v:0,flag_c:0};sim.poc.states.BR=[];sim.poc.states.BR[0]={name:"R0",verbal:"Register 0",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[1]={name:"R1",verbal:"Register 1",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[2]={name:"R2",verbal:"Register 2",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[3]={name:"R3",verbal:"Register 3",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[4]={name:"R4",verbal:"Register 4",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[5]={name:"R5",verbal:"Register 5",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[6]={name:"R6",verbal:"Register 6",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[7]={name:"R7",verbal:"Register 7",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[8]={name:"R8",verbal:"Register 8",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[9]={name:"R9",verbal:"Register 9",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[10]={name:"R10",verbal:"Register 10",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[11]={name:"R11",verbal:"Register 11",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[12]={name:"R12",verbal:"Register 12",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[13]={name:"R13",verbal:"Register 13",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[14]={name:"R14",verbal:"Register 14",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[15]={name:"R15",verbal:"Register 15",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[16]={name:"R16",verbal:"Register 16",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[17]={name:"R17",verbal:"Register 17",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[18]={name:"R18",verbal:"Register 18",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[19]={name:"R19",verbal:"Register 19",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[20]={name:"R20",verbal:"Register 20",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[21]={name:"R21",verbal:"Register 21",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[22]={name:"R22",verbal:"Register 22",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[23]={name:"R23",verbal:"Register 23",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[24]={name:"R24",verbal:"Register 24",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[25]={name:"R25",verbal:"Register 25",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[26]={name:"R26",verbal:"Register 26",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[27]={name:"R27",verbal:"Register 27",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[28]={name:"R28",verbal:"Register 28",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[29]={name:"R29",verbal:"Register 29",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[30]={name:"R30",verbal:"Register 30",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[31]={name:"R31",verbal:"Register 31",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[32]={name:"R32",verbal:"Register 32",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[33]={name:"R33",verbal:"Register 33",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[34]={name:"R34",verbal:"Register 34",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[35]={name:"R35",verbal:"Register 35",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[36]={name:"R36",verbal:"Register 36",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[37]={name:"R37",verbal:"Register 37",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[38]={name:"R38",verbal:"Register 38",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[39]={name:"R39",verbal:"Register 39",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[40]={name:"R40",verbal:"Register 40",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[41]={name:"R41",verbal:"Register 41",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[42]={name:"R42",verbal:"Register 42",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[43]={name:"R43",verbal:"Register 43",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[44]={name:"R44",verbal:"Register 44",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[45]={name:"R45",verbal:"Register 45",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[46]={name:"R46",verbal:"Register 46",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[47]={name:"R47",verbal:"Register 47",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[48]={name:"R48",verbal:"Register 48",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[49]={name:"R49",verbal:"Register 49",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[50]={name:"R50",verbal:"Register 50",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[51]={name:"R51",verbal:"Register 51",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[52]={name:"R52",verbal:"Register 52",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[53]={name:"R53",verbal:"Register 53",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[54]={name:"R54",verbal:"Register 54",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[55]={name:"R55",verbal:"Register 55",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[56]={name:"R56",verbal:"Register 56",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[57]={name:"R57",verbal:"Register 57",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[58]={name:"R58",verbal:"Register 58",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[59]={name:"R59",verbal:"Register 59",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[60]={name:"R60",verbal:"Register 60",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[61]={name:"R61",verbal:"Register 61",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[62]={name:"R62",verbal:"Register 62",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[63]={name:"R63",verbal:"Register 63",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["REG_PC"]={name:"PC",verbal:"Program Counter Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["REG_MAR"]={name:"MAR",verbal:"Memory Address Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["REG_MBR"]={name:"MBR",verbal:"Memory Data Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["REG_IR"]={name:"IR",verbal:"Instruction Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["REG_SR"]={name:"SR",verbal:"State Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["REG_RT1"]={name:"RT1",verbal:"Temporal Register 1",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["BUS_IB"]={name:"I_BUS",verbal:"Internal Bus",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["BUS_AB"]={name:"A_BUS",verbal:"Address Bus",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["BUS_CB"]={name:"C_BUS",verbal:"Control Bus",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["BUS_DB"]={name:"D_BUS",verbal:"Data Bus",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["RA_T9"]={name:"RA_T9",verbal:"Input of T9 Tristate",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["RB_T10"]={name:"RB_T10",verbal:"Input of T10 Tristate",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["HPC_T12"]={name:"HPC_T12",verbal:"Input of T12 Tristate",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["SELEC_T3"]={name:"SELEC_T3",verbal:"Input of T3 Tristate",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["ALU_T6"]={name:"ALU_T6",verbal:"Input of T6 Tristate",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["MA_ALU"]={name:"MA_ALU",verbal:"Input ALU via MA",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["MB_ALU"]={name:"MB_ALU",verbal:"Input ALU via MB",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["FLAG_C"]={name:"FLAG_C",verbal:"Carry Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.poc.states["FLAG_V"]={name:"FLAG_V",verbal:"Overflow Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.poc.states["FLAG_N"]={name:"FLAG_N",verbal:"Negative Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.poc.states["FLAG_Z"]={name:"FLAG_Z",verbal:"Zero Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.poc.states["FLAG_I"]={name:"FLAG_I",verbal:"Interruption Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.poc.states["FLAG_U"]={name:"FLAG_U",verbal:"User Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.poc.states["REG_MICROADDR"]={name:"µADDR",verbal:"Microaddress Register",visible:true,nbits:"12",value:0,default_value:0,draw_data:["svg_cu:text4667"]};sim.poc.states["REG_MICROINS"]={name:"µINS",verbal:"Microinstruction Register",visible:true,nbits:"77",value:{},default_value:{},draw_data:[]};sim.poc.states["FETCH"]={name:"FETCH",verbal:"Input Fetch",visible:false,nbits:"12",value:0,default_value:0,draw_data:[]};sim.poc.states["ROM_MUXA"]={name:"ROM_MUXA",verbal:"Input ROM",visible:false,nbits:"12",value:0,default_value:0,draw_data:[]};sim.poc.states["SUM_ONE"]={name:"SUM_ONE",verbal:"Input next microinstruction",visible:false,nbits:"12",value:1,default_value:1,draw_data:[]};sim.poc.states["MUXA_MICROADDR"]={name:"MUXA_MICROADDR",verbal:"Input microaddress",visible:false,nbits:"12",value:0,default_value:0,draw_data:[]};sim.poc.states["MUXC_MUXB"]={name:"MUXC_MUXB",verbal:"Output of MUX C",visible:false,nbits:"1",value:0,default_value:0,draw_data:[]};sim.poc.states["INEX"]={name:"INEX",verbal:"Illegal Instruction Exception",visible:false,nbits:"1",value:0,default_value:0,draw_data:[]};sim.poc.states["BS_M1"]={name:"BS_M1",verbal:"from Memory",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["BS_TD"]={name:"BS_TD",verbal:"Memory",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["INTV"]={name:"INTV",verbal:"Interruption Vector",visible:false,nbits:"8",value:0,default_value:0,draw_data:[]};sim.poc.states["M1_C1"]={name:"M1_C1",verbal:"Input of Memory Data Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["M7_C7"]={name:"M7_C7",verbal:"Input of State Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["VAL_ZERO"]={name:"VAL_ZERO",verbal:"Wired Zero",visible:false,nbits:"1",value:0,default_value:0,draw_data:[]};sim.poc.states["VAL_ONE"]={name:"VAL_ONE",verbal:"Wired One",visible:false,nbits:"32",value:1,default_value:1,draw_data:[]};sim.poc.states["VAL_FOUR"]={name:"VAL_FOUR",verbal:"Wired Four",visible:false,nbits:"32",value:4,default_value:4,draw_data:[]};sim.poc.states["REG_IR_DECO"]={name:"IR_DECO",verbal:"Instruction Decoded",visible:true,nbits:"0",value:0,default_value:0,draw_data:[]};sim.poc.states["DECO_INS"]={name:"DECO_INS",verbal:"Instruction decoded in binary",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["CLK"]={name:"CLK",verbal:"Clock",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["ACC_TIME"]={name:"ACC_TIME",verbal:"Accumulated CPU time",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["TTCPU"]={name:"TTCPU",verbal:"Several Tristates to the internal data bus in CPU activated",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["ACC_PWR"]={name:"ACC_PWR",verbal:"Accumulated Energy Consumption",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.signals["C"]={name:"C",visible:true,type:"L",value:0,default_value:0,nbits:"4",behavior:["MV MUXC_MUXB VAL_ZERO; FIRE_IFCHANGED B MUXC_MUXB; RESET_CHANGED MUXC_MUXB","MBIT MUXC_MUXB INT 0 1; FIRE_IFCHANGED B MUXC_MUXB; RESET_CHANGED MUXC_MUXB","MBIT MUXC_MUXB IORDY 0 1; FIRE_IFCHANGED B MUXC_MUXB; RESET_CHANGED MUXC_MUXB","MBIT MUXC_MUXB MRDY 0 1; FIRE_IFCHANGED B MUXC_MUXB; RESET_CHANGED MUXC_MUXB","MBIT MUXC_MUXB REG_SR 0 1; FIRE_IFCHANGED B MUXC_MUXB; RESET_CHANGED MUXC_MUXB","MBIT MUXC_MUXB REG_SR 1 1; FIRE_IFCHANGED B MUXC_MUXB; RESET_CHANGED MUXC_MUXB","MBIT MUXC_MUXB REG_SR 28 1; FIRE_IFCHANGED B MUXC_MUXB; RESET_CHANGED MUXC_MUXB","MBIT MUXC_MUXB REG_SR 29 1; FIRE_IFCHANGED B MUXC_MUXB; RESET_CHANGED MUXC_MUXB","MBIT MUXC_MUXB REG_SR 30 1; FIRE_IFCHANGED B MUXC_MUXB; RESET_CHANGED MUXC_MUXB","MBIT MUXC_MUXB REG_SR 31 1; FIRE_IFCHANGED B MUXC_MUXB; RESET_CHANGED MUXC_MUXB","MV MUXC_MUXB INEX; FIRE_IFCHANGED B MUXC_MUXB; RESET_CHANGED MUXC_MUXB"],fire_name:["svg_cu:text3410"],draw_data:[["svg_cu:path3108"],["svg_cu:path3062"],["svg_cu:path3060"],["svg_cu:path3136"],["svg_cu:path3482"],["svg_cu:path3480"],["svg_cu:path3488"],["svg_cu:path3486"],["svg_cu:path3484"],["svg_cu:path3484-9"],["svg_cu:path3108-3","svg_cu:path3260-3-8-6","svg_cu:path3260-3-8","svg_cu:path3260-3"]],draw_name:[["svg_cu:path3496","svg_cu:path3414","svg_cu:path3194-08"]]};sim.poc.signals["B"]={name:"B",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV A1 MUXC_MUXB; FIRE A1","NOT_ES A1 MUXC_MUXB; FIRE A1"],depends_on:["CLK"],fire_name:["svg_cu:text3408"],draw_data:[["svg_cu:path3094-7","svg_cu:path3100-8-7","svg_cu:path3198-7","svg_cu:path3200-1"],["svg_cu:path3392","svg_cu:path3372","svg_cu:path3390","svg_cu:path3384","svg_cu:path3108-1","svg_cu:path3100-8-7","svg_cu:path3200-1","svg_cu:path3386"]],draw_name:[[],["svg_cu:path3194-0","svg_cu:path3138-8","svg_cu:path3498-6"]]};sim.poc.signals["A0"]={name:"A0",visible:false,type:"L",value:0,default_value:0,nbits:"1",behavior:["SBIT_SIGNAL A0A1 0 1; FIRE A0A1","SBIT_SIGNAL A0A1 1 1; FIRE A0A1"],depends_on:["CLK"],fire_name:["svg_cu:text3406"],draw_data:[["svg_cu:path3096"],["svg_cu:path3096"]],draw_name:[[],["svg_cu:path3138-8-1","svg_cu:path3098-2","svg_cu:path3124-2-5"]]};sim.poc.signals["A1"]={name:"A1",visible:false,type:"L",value:0,default_value:0,nbits:"1",behavior:["SBIT_SIGNAL A0A1 0 0; FIRE A0A1","SBIT_SIGNAL A0A1 1 0; FIRE A0A1"],depends_on:["CLK"],fire_name:[],draw_data:[["svg_cu:path3094"],["svg_cu:path3094"]],draw_name:[[]]};sim.poc.signals["A0A1"]={name:"A0A1",visible:true,type:"L",value:0,default_value:0,nbits:"2",behavior:["PLUS1 MUXA_MICROADDR REG_MICROADDR","CP_FIELD MUXA_MICROADDR REG_MICROINS/MADDR","MV MUXA_MICROADDR ROM_MUXA","MV MUXA_MICROADDR FETCH"],depends_on:["CLK"],fire_name:[],draw_data:[["svg_cu:path3102","svg_cu:path3100","svg_cu:path3098","svg_cu:path3100-9","svg_cu:path3088","svg_cu:path3082"],["svg_cu:path3104","svg_cu:path3134","svg_cu:path3500","svg_cu:path3416","svg_cu:path3124-2-4","svg_cu:path3124-2"],["svg_cu:path3504","svg_cu:path3100-8","svg_cu:path3234-9"],["svg_cu:path3124"]],draw_name:[[]]};sim.poc.signals["C0"]={name:"C0",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","MV REG_MAR BUS_IB"],fire_name:["svg_p:text3077"],draw_data:[["svg_p:path3081"]],draw_name:[["svg_p:path3075"]]};sim.poc.signals["C1"]={name:"C1",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","MV REG_MBR M1_C1"],fire_name:["svg_p:text3079"],draw_data:[["svg_p:path3055"]],draw_name:[["svg_p:path3073"]]};sim.poc.signals["C2"]={name:"C2",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","MV REG_PC BUS_IB; UPDATEDPC"],fire_name:["svg_p:text3179"],draw_data:[["svg_p:path3217"]],draw_name:[["svg_p:path3177"]]};sim.poc.signals["C3"]={name:"C3",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","MV REG_IR BUS_IB; DECO; FIRE_IFSET C 10"],fire_name:["svg_p:text3439"],draw_data:[["svg_p:path3339","svg_p:path3913-4","svg_p:path3659-1"]],draw_name:[["svg_p:path3337"]]};sim.poc.signals["C4"]={name:"C4",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","MV REG_RT1 BUS_IB"],fire_name:["svg_p:tspan482"],draw_data:[["svg_p:path3339-4"]],draw_name:[["svg_p:path3337-0"]]};sim.poc.signals["C7"]={name:"C7",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","MV REG_SR M7_C7"],fire_name:["svg_p:text3655"],draw_data:[["svg_p:path3651-9"]],draw_name:[["svg_p:path3681"]]};sim.poc.signals["TA"]={name:"TA",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","MV BUS_AB REG_MAR"],fire_name:["svg_p:text3091"],draw_data:[["svg_p:path3083","svg_p:path3089","svg_p:path3597","svg_p:path3513","svg_p:path3601","svg_p:path3601-2","svg_p:path3187","svg_p:path3087","svg_p:path2995","svg_p:path3535"]],draw_name:[["svg_p:path3085"]]};sim.poc.signals["TD"]={name:"TD",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; CHECK_RTD","MV BUS_DB REG_MBR; FIRE R; FIRE W; CHECK_RTD"],fire_name:["svg_p:text3103"],draw_data:[["svg_p:path3093","svg_p:path3101","svg_p:path3587","svg_p:path3419-8","svg_p:path3071","svg_p:path3099","svg_p:path3097","svg_p:path3559-5","svg_p:path3419-1-0","svg_p:path3583","svg_p:path3419-1","svg_p:path3491","svg_p:path3641","svg_p:path3541"]],draw_name:[["svg_p:path3095"]]};sim.poc.signals["T1"]={name:"T1",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 0","MV BUS_IB REG_MBR; FIRE M7; FIRE M1; SET_TT TTCPU 0"],fire_name:["svg_p:text3105"],draw_data:[["svg_p:path3065","svg_p:path3071","svg_p:path3069","svg_p:path3049","svg_p:path3063-9","svg_p:path3071"]],draw_name:[["svg_p:path3067"]]};sim.poc.signals["T2"]={name:"T2",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 1","MV BUS_IB REG_PC; FIRE M7; FIRE M1; SET_TT TTCPU 1"],fire_name:["svg_p:text3449"],draw_data:[["svg_p:path3195","svg_p:path3199","svg_p:path3201","svg_p:path3049"]],draw_name:[["svg_p:path3329"]]};sim.poc.signals["T3"]={name:"T3",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 2","MV BUS_IB SELEC_T3; FIRE M7; FIRE M1; SET_TT TTCPU 2"],fire_name:["svg_p:text3451"],draw_data:[["svg_p:path3347","svg_p:path3349","svg_p:path3931","svg_p:path3345","svg_p:path3049","svg_p:path3341"]],draw_name:[["svg_p:path3351"]]};sim.poc.signals["T6"]={name:"T6",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 3","MV BUS_IB ALU_T6; FIRE M7; FIRE M1; SET_TT TTCPU 3"],fire_name:["svg_p:text3457"],draw_data:[["svg_p:path3315","svg_p:path3589","svg_p:path3317","svg_p:path3163-2","svg_p:path3049","svg_p:path3317-9","svg_p:path3321","svg_p:path3261-8"]],draw_name:[["svg_p:path3319"]]};sim.poc.signals["T8"]={name:"T8",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 4","MV BUS_IB REG_SR; FIRE M7; FIRE M1; SET_TT TTCPU 4"],fire_name:["svg_p:text3657"],draw_data:[["svg_p:path3645","svg_p:path3651","svg_p:path3647","svg_p:path3049"]],draw_name:[["svg_p:path3649"]]};sim.poc.signals["T9"]={name:"T9",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 5","MV BUS_IB RA_T9; FIRE M7; FIRE M1; SET_TT TTCPU 5"],fire_name:["svg_p:text3147"],draw_data:[["svg_p:path3131","svg_p:path3143","svg_p:path3139","svg_p:path3049","svg_p:path3143-9"]],draw_name:[["svg_p:path3133"]]};sim.poc.signals["T10"]={name:"T10",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 6","MV BUS_IB RB_T10; FIRE M7; FIRE M1; SET_TT TTCPU 6"],fire_name:["svg_p:text3149"],draw_data:[["svg_p:path3135","svg_p:path3145","svg_p:path3141","svg_p:path3049","svg_p:path3145-5"]],draw_name:[["svg_p:path3137"]]};sim.poc.signals["T11"]={name:"T11",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 7","CP_FIELD BUS_IB REG_MICROINS/EXCODE; FIRE M7; FIRE M1; SET_TT TTCPU 7"],fire_name:["svg_p:text3147-5","svg_cu:tspan4426"],draw_data:[["svg_p:path3131-3","svg_p:path3081-3","svg_p:path3139-7","svg_p:path3049","svg_cu:path3081-3","svg_cu:path3139-7","svg_cu:path3502"]],draw_name:[["svg_p:path3133-6","svg_cu:path3133-6"]]};sim.poc.signals["T12"]={name:"T12",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 8","MV BUS_IB HPC_T12; FIRE M7; FIRE M1; SET_TT TTCPU 8"],fire_name:["svg_p:text3147-5-0-1-1"],draw_data:[["svg_p:path3131-3-8-4-31","svg_p:path3139-7-1-4-3","svg_cu:path3049","svg_p:path3081-3-8-5-3","svg_p:path3081-3-8-5-3-7"]],draw_name:[["svg_p:path3133-6-9-7-5"]]};sim.poc.signals["M1"]={name:"M1",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV M1_C1 BUS_IB","MV M1_C1 BUS_DB"],depends_on:["C1"],fire_name:["svg_p:text3469"],draw_data:[["svg_p:path3063","svg_p:path3061","svg_p:path3059"],["svg_p:path3057","svg_p:path3641","svg_p:path3419","svg_p:path3583","svg_p:path3491"]],draw_name:[[],["svg_p:path3447"]]};sim.poc.signals["M7"]={name:"M7",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV M7_C7 BUS_IB","MV M7_C7 REG_SR; UPDATE_FLAG M7_C7 FLAG_C 31; UPDATE_FLAG M7_C7 FLAG_V 30; UPDATE_FLAG M7_C7 FLAG_N 29; UPDATE_FLAG M7_C7 FLAG_Z 28"],depends_on:["C7"],fire_name:["svg_p:text3673"],draw_data:[["svg_p:path3691","svg_p:path3693","svg_p:path3659"],["svg_p:path3695","svg_p:path3331"]],draw_name:[[],["svg_p:path3667"]]};sim.poc.signals["MA"]={name:"MA",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV MA_ALU RA_T9; FIRE COP","MV MA_ALU BUS_IB; FIRE COP"],depends_on:["SELA","SELB"],fire_name:["svg_p:text3463"],draw_data:[["svg_p:path3249","svg_p:path3161","svg_p:path3165"],["svg_p:path3279"]],draw_name:[[],["svg_p:path3423"]]};sim.poc.signals["MB"]={name:"MB",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV MB_ALU RB_T10; FIRE COP","MV MB_ALU REG_PC; FIRE COP"],depends_on:["SELA","SELB"],fire_name:["svg_p:text3465"],draw_data:[["svg_p:path3281","svg_p:path3171","svg_p:path3169"],["svg_p:path3283"]],draw_name:[[],["svg_p:path3425","svg_p:path3427"]]};sim.poc.signals["MH"]={name:"MH",visible:true,type:"L",value:0,default_value:0,nbits:"2",behavior:["MV HPC_T12 CLK","MV HPC_T12 ACC_TIME","MV HPC_T12 ACC_PWR","NOP"],fire_name:["svg_p:text3147-5-0-1-8-4"],draw_data:[[],["svg_p:path3081-3-8-5-3"]],draw_name:[[],["svg_p:path3306-8-7-6"]]};sim.poc.signals["COP"]={name:"COP",visible:true,type:"L",value:0,default_value:0,nbits:"5",forbidden:true,behavior:["NOP_ALU; UPDATE_NZVC","AND ALU_T6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","OR ALU_T6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","NOT ALU_T6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","XOR ALU_T6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","SRL ALU_T6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","SRA ALU_T6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","SL ALU_T6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","RR ALU_T6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","RL ALU_T6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","ADD ALU_T6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","SUB ALU_T6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","MUL ALU_T6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","DIV ALU_T6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","MOD ALU_T6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","LUI ALU_T6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","ADDFOUR ALU_T6 MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","ADDONE ALU_T6 MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","SUBFOUR ALU_T6 MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","SUBONE ALU_T6 MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","FADD ALU_T6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","FSUB ALU_T6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","FMUL ALU_T6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","FDIV ALU_T6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","FMOD ALU_T6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU"],depends_on:["SELCOP"],fire_name:["svg_p:text3303"],draw_data:[["svg_p:path3237","svg_p:path3239","svg_p:path3261-8","svg_p:path3321","svg_p:path3901-6","svg_p:path3317-9"]],draw_name:[["svg_p:path3009","svg_p:path3301"]]};sim.poc.signals["SELA"]={name:"SELA",visible:true,type:"L",value:0,default_value:0,nbits:"6",behavior:["FIRE_IFCHANGED MRA SELA; RESET_CHANGED SELA"],depends_on:["RA"],fire_name:["svg_cu:text3164"],draw_data:[[]],draw_name:[[]]};sim.poc.signals["SELB"]={name:"SELB",visible:true,type:"L",value:0,default_value:0,nbits:"6",behavior:["FIRE_IFCHANGED MRB SELB; RESET_CHANGED SELB"],depends_on:["RB"],fire_name:["svg_cu:text3168"],draw_data:[[]],draw_name:[[]]};sim.poc.signals["SELC"]={name:"SELC",visible:true,type:"L",value:0,default_value:0,nbits:"6",behavior:["FIRE_IFCHANGED MRC SELC; RESET_CHANGED SELC"],depends_on:["RC"],fire_name:["svg_cu:text3172"],draw_data:[[]],draw_name:[[]]};sim.poc.signals["SELCOP"]={name:"SELCOP",visible:true,type:"L",value:0,default_value:0,nbits:"5",behavior:["FIRE_IFCHANGED MC SELCOP; RESET_CHANGED SELCOP"],depends_on:["COP"],fire_name:["svg_cu:text3312"],draw_data:[[]],draw_name:[[]]};sim.poc.signals["EXCODE"]={name:"EXCODE",visible:true,type:"L",value:0,default_value:0,nbits:"4",behavior:["FIRE T11"],fire_name:["svg_cu:text3312-6"],draw_data:[[]],draw_name:[[]]};sim.poc.signals["RA"]={name:"RA",visible:true,type:"L",value:0,default_value:0,nbits:"6",forbidden:true,behavior:["GET RA_T9 BR RA; FIRE_IFSET T9 1; FIRE_IFSET MA 0"],depends_on:["SELA"],fire_name:["svg_p:text3107"],draw_data:[[]],draw_name:[["svg_p:path3109"]]};sim.poc.signals["RB"]={name:"RB",visible:true,type:"L",value:0,default_value:0,nbits:"6",forbidden:true,behavior:["GET RB_T10 BR RB; FIRE_IFSET T10 1; FIRE_IFSET MB 0"],depends_on:["SELB"],fire_name:["svg_p:text3123"],draw_data:[[]],draw_name:[["svg_p:path3113"]]};sim.poc.signals["RC"]={name:"RC",visible:true,type:"L",value:0,default_value:0,nbits:"6",forbidden:true,behavior:["FIRE LC"],depends_on:["SELC"],fire_name:["svg_p:text3125"],draw_data:[[]],draw_name:[["svg_p:path3117"]]};sim.poc.signals["LC"]={name:"LC",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","SET BR RC BUS_IB"],fire_name:["svg_p:text3127"],draw_data:[["svg_p:path3153","svg_p:path3151","svg_p:path3129"]],draw_name:[["svg_p:path3121"]]};sim.poc.signals["SE"]={name:"SE",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MBITS SELEC_T3 0 REG_RT1 OFFSET SIZE 0 SE; FIRE T3","MBITS SELEC_T3 0 REG_RT1 OFFSET SIZE 0 SE; FIRE T3"],depends_on:["T3"],fire_name:["svg_p:text3593"],draw_data:[[]],draw_name:[["svg_p:path3591","svg_p:path3447-7-7"]]};sim.poc.signals["SIZE"]={name:"SIZE",visible:true,type:"L",value:0,default_value:0,nbits:"5",behavior:["MBITS SELEC_T3 0 REG_RT1 OFFSET SIZE 0 SE; FIRE T3"],depends_on:["T3"],fire_name:["svg_p:text3363"],draw_data:[[]],draw_name:[["svg_p:path3355"]]};sim.poc.signals["OFFSET"]={name:"OFFSET",visible:true,type:"L",value:0,default_value:0,nbits:"5",behavior:["MBITS SELEC_T3 0 REG_RT1 OFFSET SIZE 0 SE; FIRE T3"],depends_on:["T3"],fire_name:["svg_p:text3707"],draw_data:[[]],draw_name:[["svg_p:path3359"]]};sim.poc.signals["MC"]={name:"MC",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MBIT COP REG_IR 0 5; FIRE_IFCHANGED COP MC","CP_FIELD COP REG_MICROINS/SELCOP; FIRE_IFCHANGED COP MC"],depends_on:["SELCOP"],fire_name:["svg_cu:text3322","svg_cu:text3172-1-5"],draw_data:[["svg_cu:path3320","svg_cu:path3142"],["svg_cu:path3318","svg_cu:path3502-6","svg_cu:path3232-6"]],draw_name:[[],["svg_cu:path3306"]]};sim.poc.signals["MRA"]={name:"MRA",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MBIT_SN RA REG_IR REG_MICROINS/SELA 5; FIRE RA;","CP_FIELD RA REG_MICROINS/SELA; FIRE RA;"],depends_on:["SELA"],fire_name:["svg_cu:text3222"],draw_data:[["svg_cu:path3494","svg_cu:path3492","svg_cu:path3490","svg_cu:path3142b","svg_cu:path3188","svg_cu:path3190","svg_cu:path3192","svg_cu:path3194","svg_cu:path3276","svg_cu:path3290","svg_cu:path3260","svg_cu:path3200","svg_cu:path3266","svg_cu:path3138","svg_cu:path3268","svg_cu:path3198","svg_cu:path3200"],["svg_cu:path3270","svg_cu:path3258","svg_cu:path3260","svg_cu:path3294","svg_cu:path3288","svg_cu:path3280","svg_cu:path3258","svg_cu:path3280","svg_cu:path3266","svg_cu:path3268"]],draw_name:[[],["svg_cu:path3220"]]};sim.poc.signals["MRB"]={name:"MRB",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MBIT_SN RB REG_IR REG_MICROINS/SELB 5; FIRE RB;","CP_FIELD RB REG_MICROINS/SELB; FIRE RB;"],depends_on:["SELB"],fire_name:["svg_cu:text3242"],draw_data:[["svg_cu:path3196","svg_cu:path3278","svg_cu:path3292","svg_cu:path3138-1","svg_cu:path3204","svg_cu:path3204","svg_cu:path3264"],["svg_cu:path3282","svg_cu:path3258-4","svg_cu:path3278","svg_cu:path3196","svg_cu:path3258-4","svg_cu:path3204","svg_cu:path3264"]],draw_name:[[],["svg_cu:path3240"]]};sim.poc.signals["MRC"]={name:"MRC",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MBIT_SN RC REG_IR REG_MICROINS/SELC 5; FIRE RC;","CP_FIELD RC REG_MICROINS/SELC; FIRE RC;"],depends_on:["SELC"],fire_name:["svg_cu:text3254"],draw_data:[["svg_cu:path3494","svg_cu:path3492","svg_cu:path3490","svg_cu:path3142b","svg_cu:path3188","svg_cu:path3190","svg_cu:path3192","svg_cu:path3194","svg_cu:path3276","svg_cu:path3290","svg_cu:path3232","svg_cu:path3292","svg_cu:path3138-1-5","svg_cu:path3208","svg_cu:path3316"],["svg_cu:path3300","svg_cu:path3294","svg_cu:path3292","svg_cu:path3288","svg_cu:path3232"]],draw_name:[[],["svg_cu:path3252"]]};sim.poc.signals["IOR"]={name:"IOR",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","MOVE_BITS SCR_IOR 0 1 IOR; FIRE SCR_IOR; MOVE_BITS IO_IOR 0 1 IOR; FIRE IO_IOR; MOVE_BITS L3D_IOR 0 1 IOR; FIRE L3D_IOR; MOVE_BITS KBD_IOR 0 1 IOR; FIRE KBD_IOR; MOVE_BITS LEDM_IOR 0 1 IOR; FIRE LEDM_IOR"],fire_name:[],draw_data:[[],["svg_p:path3733","svg_p:path3491","svg_p:text3715"]],draw_name:[[],[]]};sim.poc.signals["IOW"]={name:"IOW",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","MOVE_BITS SCR_IOW 0 1 IOW; FIRE SCR_IOW; MOVE_BITS IO_IOW 0 1 IOW; FIRE IO_IOW; MOVE_BITS L3D_IOW 0 1 IOW; FIRE L3D_IOW; MOVE_BITS LEDM_IOW 0 1 IOW; FIRE LEDM_IOW"],fire_name:[],draw_data:[[],["svg_p:path3735","svg_p:path3491","svg_p:text3717"]],draw_name:[[],[]]};sim.poc.signals["TEST_C"]={name:"TEST_C",visible:true,type:"L",value:0,default_value:0,nbits:"1",forbidden:true,behavior:["MV FLAG_C VAL_ZERO; FIRE M7","MV FLAG_C VAL_ONE; FIRE M7"],depends_on:["SELCOP"],fire_name:["svg_p:text3701-3"],draw_data:[["svg_p:text3701-3"]],draw_name:[[]]};sim.poc.signals["TEST_V"]={name:"TEST_V",visible:true,type:"L",value:0,default_value:0,nbits:"1",forbidden:true,behavior:["MV FLAG_V VAL_ZERO; FIRE M7","MV FLAG_V VAL_ONE; FIRE M7"],depends_on:["SELCOP"],fire_name:["svg_p:text3701-3-1"],draw_data:[["svg_p:text3701-3-1"]],draw_name:[[]]};sim.poc.signals["TEST_N"]={name:"TEST_N",visible:true,type:"L",value:0,default_value:0,nbits:"1",forbidden:true,behavior:["MV FLAG_N VAL_ZERO; FIRE M7","MV FLAG_N VAL_ONE; FIRE M7"],depends_on:["SELCOP"],fire_name:["svg_p:text3701-3-2"],draw_data:[["svg_p:text3701-3-2"]],draw_name:[[]]};sim.poc.signals["TEST_Z"]={name:"TEST_Z",visible:true,type:"L",value:0,default_value:0,nbits:"1",forbidden:true,behavior:["MV FLAG_Z VAL_ZERO; FIRE M7","MV FLAG_Z VAL_ONE; FIRE M7"],depends_on:["SELCOP"],fire_name:["svg_p:text3701-3-5"],draw_data:[["svg_p:text3701-3-5"]],draw_name:[[]]};sim.poc.signals["TEST_I"]={name:"TEST_I",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV FLAG_I VAL_ZERO; FIRE M7","MV FLAG_I VAL_ONE; FIRE M7"],depends_on:["CLK"],fire_name:["svg_cu:text3440"],draw_data:[["svg_cu:text3440"]],draw_name:[[]]};sim.poc.signals["TEST_U"]={name:"TEST_U",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV FLAG_U VAL_ZERO; FIRE M7","MV FLAG_U VAL_ONE; FIRE M7"],depends_on:["CLK"],fire_name:["svg_cu:text3442"],draw_data:[["svg_cu:text3442"]],draw_name:[[]]};sim.poc.signals["TEST_INTV"]={name:"TEST_INTV",visible:true,type:"L",value:0,default_value:0,nbits:"8",forbidden:true,behavior:["MBIT INTV TEST_INTV 0 32"],depends_on:["INT"],fire_name:["svg_p:tspan4225"],draw_data:[["svg_p:path3749"]],draw_name:[[]]};sim.poc.behaviors["NOP"]={nparameters:1,operation:function(s_expr){},verbal:function(s_expr){return""}};sim.poc.behaviors["NOP_ALU"]={nparameters:1,operation:function(s_expr){sim.poc.internal_states.alu_flags.flag_n=0;sim.poc.internal_states.alu_flags.flag_z=0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){return"Reset ALU flags. "}};sim.poc.behaviors["MV"]={nparameters:3,types:["X","X"],operation:function(s_expr){sim_elto_org=get_reference(s_expr[2]);sim_elto_dst=get_reference(s_expr[1]);newval=get_value(sim_elto_org);set_value(sim_elto_dst,newval)},verbal:function(s_expr){var sim_elto_org=get_reference(s_expr[2]);var newval=get_value(sim_elto_org);var verbose=get_cfg("verbal_verbose");if(verbose!=="short"){return"Copy from "+show_verbal(s_expr[2])+" to "+show_verbal(s_expr[1])+" value "+show_value(newval)+". "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" ("+show_value(newval)+"). "}};sim.poc.behaviors["LOAD"]={nparameters:3,types:["X","X"],operation:function(s_expr){sim_elto_org=get_reference(s_expr[2]);sim_elto_dst=get_reference(s_expr[1]);newval=get_value(sim_elto_org);set_value(sim_elto_dst,newval)},verbal:function(s_expr){var sim_elto_org=get_reference(s_expr[2]);var newval=get_value(sim_elto_org);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Load from "+show_verbal(s_expr[2])+" to "+show_verbal(s_expr[1])+" value "+show_value(newval)+". "}return show_verbal(s_expr[1])+" = "+show_value(newval)+" ( "+show_verbal(s_expr[2])+"). "}};sim.poc.behaviors["CP_FIELD"]={nparameters:3,types:["X","X"],operation:function(s_expr){r=s_expr[2].split("/");sim_elto_org=get_reference(r[0]);newval=get_value(sim_elto_org);newval=newval[r[1]];if(typeof newval!="undefined"){sim_elto_dst=get_reference(s_expr[1]);set_value(sim_elto_dst,newval)}},verbal:function(s_expr){var r=s_expr[2].split("/");var sim_elto_org=get_reference(r[0]);var newval=get_value(sim_elto_org);newval=newval[r[1]];if(typeof newval=="undefined")newval="<undefined>";else newval=show_value(newval);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return'Copy from "'+show_verbal(r[0])+'"['+r[1]+"] "+"to "+show_verbal(s_expr[1])+" (value "+newval+"). "}return show_verbal(s_expr[1])+" = "+show_verbal(r[0])+"."+r[1]+" ("+newval+"). "}};sim.poc.behaviors["NOT_ES"]={nparameters:3,types:["S","E"],operation:function(s_expr){set_value(sim.poc.signals[s_expr[1]],Math.abs(get_value(sim.poc.states[s_expr[2]])-1))},verbal:function(s_expr){var value=Math.abs(get_value(sim.poc.states[s_expr[2]])-1);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Set "+show_verbal(s_expr[1])+" with value "+show_value(value)+" (Logical NOT of "+s_expr[2]+"). "}return show_verbal(s_expr[1])+" = "+show_value(value)+" (Logical NOT "+s_expr[2]+"). "}};sim.poc.behaviors["GET"]={nparameters:4,types:["E","E","S"],operation:function(s_expr){set_value(sim.poc.states[s_expr[1]],get_value(sim.poc.states[s_expr[2]][sim.poc.signals[s_expr[3]].value]))},verbal:function(s_expr){var value=get_value(sim.poc.states[s_expr[2]][sim.poc.signals[s_expr[3]].value]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Set "+show_verbal(s_expr[1])+" with value "+show_value(value)+" (Register File "+s_expr[3]+"). "}return show_verbal(s_expr[1])+" = "+show_value(value)+" (Register File "+s_expr[3]+"). "}};sim.poc.behaviors["SET"]={nparameters:4,types:["E","S","E"],operation:function(s_expr){set_value(sim.poc.states[s_expr[1]][sim.poc.signals[s_expr[2]].value],get_value(sim.poc.states[s_expr[3]]))},verbal:function(s_expr){var value=get_value(sim.poc.states[s_expr[3]]);var o_ref=sim.poc.states[s_expr[1]][sim.poc.signals[s_expr[2]].value];var o_verbal=o_ref.name;if(typeof o_ref.verbal!="undefined")o_verbal=o_ref.verbal;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy to "+o_verbal+" the value "+show_value(value)+". "}return o_verbal+" = "+show_value(value)+". "}};sim.poc.behaviors["AND"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])&get_value(sim.poc.states[s_expr[3]]);set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])&get_value(sim.poc.states[s_expr[3]]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU AND with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (AND). "}};sim.poc.behaviors["OR"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])|get_value(sim.poc.states[s_expr[3]]);set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])|get_value(sim.poc.states[s_expr[3]]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU OR with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (OR). "}};sim.poc.behaviors["NOT"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=~get_value(sim.poc.states[s_expr[2]]);set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=~get_value(sim.poc.states[s_expr[2]]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU NOT with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (NOT). "}};sim.poc.behaviors["XOR"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])^get_value(sim.poc.states[s_expr[3]]);set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])^get_value(sim.poc.states[s_expr[3]]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU XOR with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (XOR). "}};sim.poc.behaviors["SRL"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])>>>1;set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])>>>1;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Shift Right Logical with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (SRL). "}};sim.poc.behaviors["SRA"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])>>1;set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])>>1;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Shift Right Arithmetic with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (SRA). "}};sim.poc.behaviors["SL"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])<<1;set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])<<1;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Shift Left with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (SL). "}};sim.poc.behaviors["RR"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])>>>1|(get_value(sim.poc.states[s_expr[2]])&1)<<31;set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])>>>1|(get_value(sim.poc.states[s_expr[2]])&1)<<31;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Right Rotation with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (RR). "}};sim.poc.behaviors["RL"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])<<1|(get_value(sim.poc.states[s_expr[2]])&2147483648)>>>31;set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])<<1|(get_value(sim.poc.states[s_expr[2]])&2147483648)>>>31;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Left Rotation with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (LR). "}};sim.poc.behaviors["ADD"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a+b;set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_c=a>>>31&&b>>>31;sim.poc.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.poc.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.poc.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a+b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU ADD with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (ADD). "}};sim.poc.behaviors["SUB"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a-b;set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_c=a>>>31&&b>>>31;sim.poc.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.poc.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.poc.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a-b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU SUB with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (SUB). "}};sim.poc.behaviors["MUL"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a*b;set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_c=0;sim.poc.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.poc.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.poc.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a*b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU MUL with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (MUL). "}};sim.poc.behaviors["DIV"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;if(0==b){set_value(sim.poc.states[s_expr[1]],0);sim.poc.internal_states.alu_flags.flag_n=0;sim.poc.internal_states.alu_flags.flag_z=1;sim.poc.internal_states.alu_flags.flag_v=1;sim.poc.internal_states.alu_flags.flag_c=0;return}var result=Math.floor(a/b);set_value(sim.poc.states[s_expr[1]],result);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;if(0==b){return"ALU DIV zero by zero (oops!). "}var result=Math.floor(a/b);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU DIV with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (DIV). "}};sim.poc.behaviors["MOD"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;if(0==b){set_value(sim.poc.states[s_expr[1]],0);sim.poc.internal_states.alu_flags.flag_n=0;sim.poc.internal_states.alu_flags.flag_z=1;sim.poc.internal_states.alu_flags.flag_v=1;sim.poc.internal_states.alu_flags.flag_c=0;return}var result=a%b;set_value(sim.poc.states[s_expr[1]],result);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;if(0==b){return"ALU MOD zero by zero (oops!). "}var result=a%b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU MOD with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (MOD). "}};sim.poc.behaviors["LUI"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])<<16;set_value(sim.poc.states[s_expr[1]],result);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])<<16;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Load Upper Immediate with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (LUI). "}};sim.poc.behaviors["ADDFOUR"]={nparameters:3,types:["E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=4;var result=a+b;set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_c=a>>>31&&b>>>31;sim.poc.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.poc.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.poc.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var result=a+4;return"ALU ADD 4 with result "+show_value(result)+". "}};sim.poc.behaviors["ADDONE"]={nparameters:3,types:["E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=1;var result=a+b;set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_c=a>>>31&&b>>>31;sim.poc.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.poc.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.poc.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var result=a+1;return"ALU ADD 1 with result "+show_value(result)+". "}};sim.poc.behaviors["SUBFOUR"]={nparameters:3,types:["E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=4;var result=a-b;set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_c=a>>>31&&b>>>31;sim.poc.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.poc.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.poc.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var result=a-4;return"ALU SUB 4 with result "+show_value(result)+". "}};sim.poc.behaviors["SUBONE"]={nparameters:3,types:["E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=1;var result=a-b;set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_c=a>>>31&&b>>>31;sim.poc.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.poc.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.poc.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var result=a-1;return"ALU SUB 1 with result "+show_value(result)+". "}};sim.poc.behaviors["FADD"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a.toFixed(2)+b.toFixed(2);set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_c=0;sim.poc.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.poc.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.poc.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a.toFixed(2)+b.toFixed(2);return"ALU Float ADD with result "+result+". "}};sim.poc.behaviors["FSUB"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a.toFixed(2)-b.toFixed(2);set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_c=0;sim.poc.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.poc.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.poc.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a.toFixed(2)-b.toFixed(2);return"ALU Float SUB with result "+result+". "}};sim.poc.behaviors["FMUL"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a.toFixed(2)*b.toFixed(2);set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_c=0;sim.poc.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.poc.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.poc.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a.toFixed(2)*b.toFixed(2);return"ALU Float MUL with result "+result+". "}};sim.poc.behaviors["FDIV"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;if(0==b){set_value(sim.poc.states[s_expr[1]],0);sim.poc.internal_states.alu_flags.flag_n=0;sim.poc.internal_states.alu_flags.flag_z=1;sim.poc.internal_states.alu_flags.flag_v=1;sim.poc.internal_states.alu_flags.flag_c=0;return}var result=Math.floor(a/b);set_value(sim.poc.states[s_expr[1]],result);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a.toFixed(2)/b.toFixed(2);return"ALU Float DIV with result "+result+". "}};sim.poc.behaviors["FMOD"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var result=(get_value(sim.poc.states[s_expr[2]])<<0)%(get_value(sim.poc.states[s_expr[3]])<<0);set_value(sim.poc.states[s_expr[1]],result);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a.toFixed(2)%b.toFixed(2);return"ALU Float MOD with result "+result+". "}};sim.poc.behaviors["LUI"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])<<16;set_value(sim.poc.states[s_expr[1]],result);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])<<16;return"ALU Load Upper Immediate with result "+show_value(result)+". "}};sim.poc.behaviors["PLUS1"]={nparameters:3,types:["E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var result=a+1;set_value(sim.poc.states[s_expr[1]],result>>>0)},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var result=a+1;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Add one to "+show_verbal(s_expr[2])+" and copy to "+show_verbal(s_expr[1])+" with result "+show_value(result)+". "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" + 1"+" ("+show_value(result)+"). "}};sim.poc.behaviors["PLUS4"]={nparameters:3,types:["E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var result=a+4;set_value(sim.poc.states[s_expr[1]],result>>>0)},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var result=a+4;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Add four to "+show_verbal(s_expr[2])+" and copy to "+show_verbal(s_expr[1])+" with result "+show_value(result)+". "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" + 4"+" ("+show_value(result)+"). "}};sim.poc.behaviors["SET_TT"]={nparameters:3,types:["E","I"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[1]])<<0;var b=parseInt(s_expr[2]);var m=Math.pow(2,b);var r=a|m;set_value(sim.poc.states[s_expr[1]],r);update_cpu_bus_fire(r,b)},verbal:function(s_expr){return""}};sim.poc.behaviors["RST_TT"]={nparameters:3,types:["E","I"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[1]])<<0;var b=parseInt(s_expr[2]);var m=Math.pow(2,b);var r=a&~m;set_value(sim.poc.states[s_expr[1]],r);update_cpu_bus_fire(r,b)},verbal:function(s_expr){return""}};sim.poc.behaviors["CHECK_RTD"]={nparameters:1,operation:function(s_expr){var number_active_tri=parseInt(simhw_sim_signal("TD").value)+parseInt(simhw_sim_signal("R").value);update_system_bus_fire(number_active_tri)},verbal:function(s_expr){return""}};sim.poc.behaviors["MBIT"]={nparameters:5,types:["X","X","I","I"],operation:function(s_expr){var sim_elto_dst=get_reference(s_expr[1]);var sim_elto_org=get_reference(s_expr[2]);var offset=parseInt(s_expr[3]);var size=parseInt(s_expr[4]);var n1=get_value(sim_elto_org).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(offset+size-1),size);set_value(sim_elto_dst,parseInt(n2,2))},verbal:function(s_expr){var sim_elto_dst=get_reference(s_expr[1]);var sim_elto_org=get_reference(s_expr[2]);var offset=parseInt(s_expr[3]);var size=parseInt(s_expr[4]);var n1=get_value(sim_elto_org).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(offset+size-1),size);var n3=parseInt(n2,2);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from "+show_verbal(s_expr[2])+" to "+show_verbal(s_expr[1])+" value "+show_value(n3)+" (copied "+size+" bits from bit "+offset+"). "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" ("+show_value(n3)+", "+size+" bits from bit "+offset+"). "}};sim.poc.behaviors["MBIT_SN"]={nparameters:5,types:["S","E","E","I"],operation:function(s_expr){var base=0;var r=s_expr[3].split("/");if(1==r.length)base=get_value(sim.poc.states[s_expr[3]]);else if(typeof sim.poc.states[r[0]].value[r[1]]!="undefined")base=sim.poc.states[r[0]].value[r[1]];else if(typeof sim.poc.signals[r[1]].default_value!="undefined")base=sim.poc.signals[r[1]].default_value;else if(typeof sim.poc.states[r[1]].default_value!="undefined")base=sim.poc.states[r[1]].default_value;else ws_alert("WARN: undefined state/field pair -> "+r[0]+"/"+r[1]);var offset=parseInt(s_expr[4]);var n1=get_value(sim.poc.states[s_expr[2]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;var n3=n2.substr(31-(base+offset-1),offset);set_value(sim.poc.signals[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){var base=0;var r=s_expr[3].split("/");if(1==r.length)base=get_value(sim.poc.states[s_expr[3]]);else if(typeof sim.poc.states[r[0]].value[r[1]]!="undefined")base=sim.poc.states[r[0]].value[r[1]];else if(typeof sim.poc.signals[r[1]].default_value!="undefined")base=sim.poc.signals[r[1]].default_value;else if(typeof sim.poc.states[r[1]].default_value!="undefined")base=sim.poc.states[r[1]].default_value;else ws_alert("WARN: undefined state/field pair -> "+r[0]+"/"+r[1]);var offset=parseInt(s_expr[4]);var n1=get_value(sim.poc.states[s_expr[2]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;var n3=n2.substr(31-(base+offset-1),offset);var from_elto="";if(1==r.length)from_elto=show_verbal(s_expr[3]);else from_elto='"'+show_verbal(s_expr[2])+'"['+r[1]+"] ";var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from "+from_elto+"into "+show_verbal(s_expr[1])+" "+"value "+parseInt(n3,2)+". "}return show_verbal(s_expr[1])+" = "+from_elto+" ("+parseInt(n3,2)+"). "}};sim.poc.behaviors["SBIT_SIGNAL"]={nparameters:4,types:["X","I","I"],operation:function(s_expr){sim_elto_dst=get_reference(s_expr[1]);var new_value=sim_elto_dst.value;var mask=1<>>0)},verbal:function(s_expr){sim_elto_dst=get_reference(s_expr[1]);var new_value=sim_elto_dst.value;var mask=1<>>0)}};sim.poc.behaviors["UPDATE_FLAG"]={nparameters:4,types:["X","X","I"],operation:function(s_expr){sim_elto_org=get_reference(s_expr[2]);sim_elto_dst=get_reference(s_expr[1]);var new_value=sim_elto_dst.value&~(1<>>0)},verbal:function(s_expr){sim_elto_org=get_reference(s_expr[2]);sim_elto_dst=get_reference(s_expr[1]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Update "+show_verbal(s_expr[2])+" to value "+sim_elto_org.value+". "}return show_verbal(s_expr[1])+"."+show_verbal(s_expr[3])+" = "+sim_elto_org.value+". "}};sim.poc.behaviors["MBITS"]={nparameters:8,types:["E","I","E","S","S","I","S"],operation:function(s_expr){var offset=parseInt(sim.poc.signals[s_expr[4]].value);var size=parseInt(sim.poc.signals[s_expr[5]].value);var n1=get_value(sim.poc.states[s_expr[3]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(offset+size-1),size);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;if("1"==sim.poc.signals[s_expr[7]].value&&"1"==n2.substr(0,1)){n3="11111111111111111111111111111111".substring(0,32-n2.length)+n2}set_value(sim.poc.states[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){var offset=parseInt(sim.poc.signals[s_expr[4]].value);var size=parseInt(sim.poc.signals[s_expr[5]].value);var n1=get_value(sim.poc.states[s_expr[3]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(offset+size-1),size);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;if("1"==sim.poc.signals[s_expr[7]].value&&"1"==n2.substr(0,1)){n3="11111111111111111111111111111111".substring(0,32-n2.length)+n2}n1=parseInt(n3,2);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return" Copy from "+show_verbal(s_expr[3])+" to "+show_verbal(s_expr[1])+" value "+show_value(n1)+" (copied "+size+" bits from bit "+offset+"). "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[3])+" ("+show_value(n1)+", "+size+" bits from bit "+offset+"). "}};sim.poc.behaviors["BSEL"]={nparameters:6,types:["E","I","I","E","I"],operation:function(s_expr){var posd=parseInt(s_expr[2]);var poso=parseInt(s_expr[5]);var len=parseInt(s_expr[3]);var n1=get_value(sim.poc.states[s_expr[4]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(poso+len)+1,len);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var n4="00000000000000000000000000000000".substr(0,posd);n3=n3+n4;set_value(sim.poc.states[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){var posd=parseInt(s_expr[2]);var len=parseInt(s_expr[3]);var poso=parseInt(s_expr[5]);var n1=get_value(sim.poc.states[s_expr[4]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(poso+len)+1,len);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var n4="00000000000000000000000000000000".substr(0,posd);n3=n3+n4;var n5=parseInt(n3,2);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from "+show_verbal(s_expr[4])+" to "+show_verbal(s_expr[1])+" value "+show_value(n5)+" (copied "+len+" bits, from bit "+poso+" of "+s_expr[4]+" to bit "+posd+" of "+s_expr[1]+"). "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[4])+" ("+show_value(n5)+", "+len+" bits, from bit "+poso+" of "+s_expr[4]+" to bit "+posd+" of "+s_expr[1]+"). "}};sim.poc.behaviors["EXT_SIG"]={nparameters:3,types:["E","I"],operation:function(s_expr){var n1=get_value(sim.poc.states[s_expr[1]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;var n3=n2.substr(31-s_expr[2],31);var n4=n3;if("1"==n2[31-s_expr[2]]){n4="11111111111111111111111111111111".substring(0,32-n3.length)+n4}set_value(sim.poc.states[s_expr[1]],parseInt(n4,2))},verbal:function(s_expr){var n1=get_value(sim.poc.states[s_expr[1]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;var n3=n2.substr(31-s_expr[2],31);var n4=n3;if("1"==n2[31-s_expr[2]]){n4="11111111111111111111111111111111".substring(0,32-n3.length)+n4}var n5=parseInt(n4,2);return"Sign Extension with value "+show_value(n5)+". "}};sim.poc.behaviors["MOVE_BITS"]={nparameters:5,types:["S","I","I","S"],operation:function(s_expr){var posd=parseInt(s_expr[2]);var poso=0;var len=parseInt(s_expr[3]);var n1=sim.poc.signals[s_expr[4]].value.toString(2);n1="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n1=n1.substr(31-poso-len+1,len);var n2=sim.poc.signals[s_expr[1]].value.toString(2);n2="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var m1=n2.substr(0,32-(posd+len));var m2=n2.substr(31-posd+1,posd);var n3=m1+n1+m2;set_value(sim.poc.signals[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){return""}};sim.poc.behaviors["MOVE_BITSE"]={nparameters:6,types:["S","I","I","E","I"],operation:function(s_expr){var posd=parseInt(s_expr[2]);var poso=parseInt(s_expr[5]);var len=parseInt(s_expr[3]);var n1=get_value(sim.poc.states[s_expr[4]]).toString(2);n1="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n1=n1.substr(31-poso-len+1,len);var n2=sim.poc.signals[s_expr[1]].value.toString(2);n2="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var m1=n2.substr(0,32-(posd+len));var m2=n2.substr(31-posd+1,posd);var n3=m1+n1+m2;set_value(sim.poc.signals[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){return""}};sim.poc.behaviors["DECO"]={nparameters:1,operation:function(s_expr){sim.poc.states["INEX"].value=0;var oi=decode_instruction(sim.poc.internal_states.FIRMWARE,sim.poc.ctrl_states.ir,get_value(sim.poc.states["REG_IR"]));if(null==oi.oinstruction){ws_alert("ERROR: undefined instruction code in IR ("+"co:"+oi.op_code.toString(2)+", "+"cop:"+oi.cop_code.toString(2)+")");sim.poc.states["ROM_MUXA"].value=0;sim.poc.states["INEX"].value=1;return-1}var rom_addr=oi.op_code<<6;if(typeof oi.oinstruction.cop!="undefined"){rom_addr=rom_addr+oi.cop_code}if(typeof sim.poc.internal_states["ROM"][rom_addr]=="undefined"){ws_alert("ERROR: undefined rom address "+rom_addr+" in firmware");sim.poc.states["ROM_MUXA"].value=0;return-1}sim.poc.states["ROM_MUXA"].value=sim.poc.internal_states["ROM"][rom_addr];var val=get_value(sim.poc.states["DECO_INS"]);set_value(sim.poc.states["DECO_INS"],val+1);var pc=get_value(sim.poc.states["REG_PC"])-4;var decins=get_deco_from_pc(pc);set_value(sim.poc.states["REG_IR_DECO"],decins);show_dbg_ir(get_value(sim.poc.states["REG_IR_DECO"]))},verbal:function(s_expr){return"Decode instruction. "}};sim.poc.behaviors["FIRE"]={nparameters:2,types:["S"],operation:function(s_expr){if(sim.poc.internal_states.fire_stack.indexOf(s_expr[1])!=-1){return}sim.poc.internal_states.fire_stack.push(s_expr[1]);update_draw(sim.poc.signals[s_expr[1]],sim.poc.signals[s_expr[1]].value);if("L"==sim.poc.signals[s_expr[1]].type){update_state(s_expr[1])}sim.poc.internal_states.fire_stack.pop(s_expr[1])},verbal:function(s_expr){return""}};sim.poc.behaviors["FIRE_IFSET"]={nparameters:3,types:["S","I"],operation:function(s_expr){if(get_value(sim.poc.signals[s_expr[1]])!=parseInt(s_expr[2])){return}sim.poc.behaviors["FIRE"].operation(s_expr)},verbal:function(s_expr){return""}};sim.poc.behaviors["FIRE_IFCHANGED"]={nparameters:3,types:["S","X"],operation:function(s_expr){sim_elto=get_reference(s_expr[2]);if(sim_elto.changed==false)return;sim.poc.behaviors["FIRE"].operation(s_expr)},verbal:function(s_expr){return""}};sim.poc.behaviors["RESET_CHANGED"]={nparameters:2,types:["X"],operation:function(s_expr){sim_elto=get_reference(s_expr[1]);sim_elto.changed=false},verbal:function(s_expr){return""}};sim.poc.behaviors["CLOCK"]={nparameters:1,operation:function(s_expr){var new_maddr=null;var mcelto=null;var t0=performance.now();var val=get_value(sim.poc.states["CLK"]);set_value(sim.poc.states["CLK"],val+1);set_value(sim.poc.states["TTCPU"],0);new_maddr=get_value(sim.poc.states["REG_MICROADDR"]);mcelto=sim.poc.internal_states["MC"][new_maddr];if(typeof mcelto!=="undefined"&&false==mcelto.is_native){for(var i=0;i>>0},set_value:function(elto,value){var origin="";var r_value=main_memory_get_program_counter();if(r_value!=null){origin="PC=0x"+r_value.toString(16)}var melto={value:value>>>0,source_tracking:[origin],comments:null};var valref=main_memory_set(sim.poc.internal_states.MP,elto,melto);show_main_memory(sim.poc.internal_states.MP,elto,typeof valref==="undefined",true);return value}};sim.poc.internal_states.segments={};sim.poc.internal_states.MP={};sim.poc.internal_states.MP_wc=0;sim.poc.internal_states.CM_cfg=[];sim.poc.internal_states.CM=[];sim.poc.signals.MRDY={name:"MRDY",visible:true,type:"L",value:0,default_value:0,nbits:"1",depends_on:["CLK"],behavior:["FIRE_IFCHANGED MRDY C","FIRE_IFCHANGED MRDY C"],fire_name:["svg_p:tspan3916"],draw_data:[[],["svg_p:path3895","svg_p:path3541"]],draw_name:[[],[]]};sim.poc.signals.R={name:"R",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; CHECK_RTD","MEM_READ BUS_AB BUS_DB BW MRDY CLK; FIRE M1; FIRE MRDY; CHECK_RTD"],fire_name:["svg_p:text3533-5-2"],draw_data:[[],["svg_p:path3557","svg_p:path3571"]],draw_name:[[],[]]};sim.poc.signals.W={name:"W",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","MEM_WRITE BUS_AB BUS_DB BW MRDY CLK; FIRE M1; FIRE MRDY"],fire_name:["svg_p:text3533-5-08"],draw_data:[[],["svg_p:path3559","svg_p:path3575","svg_p:path3447-7"]],draw_name:[[],[]]};sim.poc.signals.BW={name:"BW",verbal:["Access to one byte from memory. ","Access to two bytes from memory. ","Access to three bytes from memory. ","Access to a word from memory. "],visible:true,type:"L",value:0,default_value:0,nbits:"2",behavior:["FIRE R; FIRE W","FIRE R; FIRE W","FIRE R; FIRE W","FIRE R; FIRE W"],fire_name:["svg_p:text3533-5-2-8"],draw_data:[["svg_p:path3557-0"]],draw_name:[[],[]]};sim.poc.behaviors.MEM_READ={nparameters:6,types:["E","E","S","S","E"],operation:function(s_expr){var address=sim.poc.states[s_expr[1]].value;var dbvalue=sim.poc.states[s_expr[2]].value;var bw=sim.poc.signals[s_expr[3]].value;var clk=get_value(sim.poc.states[s_expr[5]]);sim.poc.signals[s_expr[4]].value=0;var remain=get_value(sim.poc.internal_states.MP_wc);if(typeof sim.poc.events.mem[clk-1]!="undefined"&&sim.poc.events.mem[clk-1]>0){remain=sim.poc.events.mem[clk-1]-1}var first_time=typeof sim.poc.events.mem[clk]=="undefined";sim.poc.events.mem[clk]=remain;if(remain>0){return}var wordress=address&4294967292;var value=main_memory_getvalue(sim.poc.internal_states.MP,wordress);var full_redraw=false;if(typeof value==="undefined"){value=0;full_redraw=true}dbvalue=main_memory_extractvalues(value,bw,address&3);sim.poc.states[s_expr[2]].value=dbvalue>>>0;sim.poc.signals[s_expr[4]].value=1;show_main_memory(sim.poc.internal_states.MP,wordress,full_redraw,false);if(first_time&&sim.poc.internal_states.CM.length>0){cache_memory_access(sim.poc.internal_states.CM[0],address,"read",clk)}},verbal:function(s_expr){var verbal="";var address=sim.poc.states[s_expr[1]].value;var dbvalue=sim.poc.states[s_expr[2]].value;var bw=sim.poc.signals[s_expr[3]].value;var clk=get_value(sim.poc.states[s_expr[5]]);switch(bw){case 0:bw_type="byte";break;case 1:bw_type="half";break;case 2:bw_type="three bytes";break;case 3:bw_type="word";break}var value=main_memory_getvalue(sim.poc.internal_states.MP,address);if(typeof value==="undefined"){value=0}verbal="Try to read a "+bw_type+" from memory "+"at address 0x"+address.toString(16)+" with value "+value.toString(16)+". ";return verbal}};sim.poc.behaviors.MEM_WRITE={nparameters:6,types:["E","E","S","S","E"],operation:function(s_expr){var address=sim.poc.states[s_expr[1]].value;var dbvalue=sim.poc.states[s_expr[2]].value;var bw=sim.poc.signals[s_expr[3]].value;var clk=get_value(sim.poc.states[s_expr[5]]);sim.poc.signals[s_expr[4]].value=0;var remain=get_value(sim.poc.internal_states.MP_wc);if(typeof sim.poc.events.mem[clk-1]!="undefined"&&sim.poc.events.mem[clk-1]>0){remain=sim.poc.events.mem[clk-1]-1}var first_time=typeof sim.poc.events.mem[clk]=="undefined";sim.poc.events.mem[clk]=remain;if(remain>0){return}var wordress=address&4294967292;var value=main_memory_getvalue(sim.poc.internal_states.MP,wordress);var full_redraw=false;if(typeof value==="undefined"){value=0;full_redraw=true}value=main_memory_updatevalues(value,dbvalue,bw,address&3);var origin="";var r_value=main_memory_get_program_counter();if(r_value!=null){origin="PC=0x"+r_value.toString(16)}var melto={value:value>>>0,source_tracking:[origin],comments:null};var elto=main_memory_set(sim.poc.internal_states.MP,wordress,melto);sim.poc.signals[s_expr[4]].value=1;show_main_memory(sim.poc.internal_states.MP,wordress,full_redraw,true);if(first_time&&sim.poc.internal_states.CM.length>0){cache_memory_access(sim.poc.internal_states.CM[0],address,"write",clk)}},verbal:function(s_expr){var verbal="";var address=sim.poc.states[s_expr[1]].value;var dbvalue=sim.poc.states[s_expr[2]].value;var bw=sim.poc.signals[s_expr[3]].value;var clk=get_value(sim.poc.states[s_expr[5]]);switch(bw){case 0:bw_type="byte";break;case 1:bw_type="half";break;case 2:bw_type="three bytes";break;case 3:bw_type="word";break}var value=main_memory_getvalue(sim.poc.internal_states.MP,address);if(typeof value==="undefined"){value=0}verbal="Try to write a "+bw_type+" to memory "+"at address 0x"+address.toString(16)+" with value "+value.toString(16)+". ";return verbal}};sim.poc.behaviors.MEMORY_RESET={nparameters:1,operation:function(s_expr){sim.poc.events.mem={}},verbal:function(s_expr){return"Reset the memory (all values will be zeroes). "}};sim.poc.elements.memory={name:"Main memory",description:"Main memory subsystem",type:"subcomponent",belongs:"MEMORY",states:{addr:{ref:"BUS_AB"},data:{ref:"BUS_DB"},mrdy:{ref:"MRDY"}},signals:{bw:{ref:"BW"},r:{ref:"R"},w:{ref:"W"}},states_inputs:["addr","data"],states_outputs:["mrdy","data"],signals_inputs:["bw","r","w"],signals_output:[]};sim.poc.components.IO={name:"IO",version:"1",abilities:["IO_TIMER"],details_name:["IO_STATS","IO_CONFIG"],details_fire:[["svg_p:text3775"],[]],write_state:function(vec){return vec},read_state:function(o,check){return false},get_state:function(reg){return null},get_value:function(elto){var associated_state=simhw_internalState_get("io_hash",elto);var value=get_value(simhw_sim_state(associated_state))>>>0;set_value(simhw_sim_state("BUS_AB"),elto);set_value(simhw_sim_signal("IOR"),1);compute_behavior("FIRE IOR");value=get_value(simhw_sim_state("BUS_DB"));return value},set_value:function(elto,value){var associated_state=simhw_internalState_get("io_hash",elto);set_value(simhw_sim_state(associated_state),value);set_value(simhw_sim_state("BUS_AB"),elto);set_value(simhw_sim_state("BUS_DB"),value);set_value(simhw_sim_signal("IOW"),1);compute_behavior("FIRE IOW");return value}};sim.poc.internal_states.io_int_factory=[];sim.poc.internal_states.io_int_factory[0]={period:0,probability:.5,accumulated:0,active:false};sim.poc.internal_states.io_int_factory[1]={period:0,probability:.5,accumulated:0,active:false};sim.poc.internal_states.io_int_factory[2]={period:0,probability:.5,accumulated:0,active:false};sim.poc.internal_states.io_int_factory[3]={period:0,probability:.5,accumulated:0,active:false};sim.poc.internal_states.io_int_factory[4]={period:0,probability:.5,accumulated:0,active:false};sim.poc.internal_states.io_int_factory[5]={period:0,probability:.5,accumulated:0,active:false};sim.poc.internal_states.io_int_factory[6]={period:0,probability:.5,accumulated:0,active:false};sim.poc.internal_states.io_int_factory[7]={period:0,probability:.5,accumulated:0,active:false};var IOSR_ID=4352;var IOCR_ID=4356;var IODR_ID=4360;sim.poc.internal_states.io_hash[IOSR_ID]="IOSR";sim.poc.internal_states.io_hash[IOCR_ID]="IOCR";sim.poc.internal_states.io_hash[IODR_ID]="IODR";sim.poc.states.IOSR={name:"IOSR",verbal:"IO State Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.IOCR={name:"IOCR",verbal:"IO Control Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.IODR={name:"IODR",verbal:"IO Data Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.signals.INT={name:"INT",visible:true,type:"L",value:0,default_value:0,nbits:"1",depends_on:["CLK"],behavior:["FIRE C","FIRE C"],fire_name:["svg_p:tspan4199"],draw_data:[[],["svg_p:path3809"]],draw_name:[[],[]]};sim.poc.signals.IORDY={name:"IORDY",visible:true,type:"L",value:0,default_value:0,nbits:"1",depends_on:["CLK"],behavior:["FIRE_IFCHANGED IORDY C","FIRE_IFCHANGED IORDY C"],fire_name:["svg_p:tspan4089","svg_p:path3793","svg_p:tspan4089"],draw_data:[[],["svg_p:path3897"]],draw_name:[[],[]]};sim.poc.signals.IO_IOR={name:"IO_IOR",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","IO_IOR BUS_AB BUS_DB IOSR IOCR IODR CLK; FIRE M1"],fire_name:["svg_p:tspan4173"],draw_data:[[],["svg_p:path3795","svg_p:path3733"]],draw_name:[[],[]]};sim.poc.signals.IO_IOW={name:"IO_IOW",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","IO_IOW BUS_AB BUS_DB IOSR IOCR IODR CLK; FIRE M1"],fire_name:["svg_p:text3785-0-6-0-5-5"],draw_data:[[],["svg_p:path3805","svg_p:path3733"]],draw_name:[[],[]]};sim.poc.signals.IO_IE={name:"IO_IE",visible:true,type:"L",value:1,default_value:1,nbits:"1",behavior:["NOP","IO_CHK_I CLK INT INTV; FIRE C"],fire_name:[],draw_data:[[],[]],draw_name:[[],[]]};sim.poc.signals.INTA={name:"INTA",visible:true,type:"L",value:1,default_value:0,nbits:"1",behavior:["NOP","INTA CLK INT INTA BUS_DB INTV; FIRE M1; FIRE C"],fire_name:["svg_p:text3785-0-6-0-5-5-1-1"],draw_data:[[],["svg_p:path3807","svg_p:path3737"]],draw_name:[[],[]]};sim.poc.behaviors.IO_IOR={nparameters:7,types:["E","E","E","E","E","E"],operation:function(s_expr){var bus_ab=get_value(sim.poc.states[s_expr[1]]);var iosr=get_value(sim.poc.states[s_expr[3]]);var iocr=get_value(sim.poc.states[s_expr[4]]);var iodr=get_value(sim.poc.states[s_expr[5]]);if(bus_ab==IOSR_ID)set_value(sim.poc.states[s_expr[2]],iosr);if(bus_ab==IOCR_ID)set_value(sim.poc.states[s_expr[2]],iocr);if(bus_ab==IODR_ID)set_value(sim.poc.states[s_expr[2]],iodr)},verbal:function(s_expr){var verbal="";var bus_ab=get_value(sim.poc.states[s_expr[1]]);var iosr=get_value(sim.poc.states[s_expr[3]]);var iocr=get_value(sim.poc.states[s_expr[4]]);var iodr=get_value(sim.poc.states[s_expr[5]]);if(bus_ab==IOSR_ID)verbal="I/O device read at IOSR of value "+iosr+". ";if(bus_ab==IOCR_ID)verbal="I/O device read at IOCR of value "+iocr+". ";if(bus_ab==IODR_ID)verbal="I/O device read at IODR of value "+iodr+". ";return verbal}};sim.poc.behaviors.IO_IOW={nparameters:7,types:["E","E","E","E","E","E"],operation:function(s_expr){var bus_ab=get_value(sim.poc.states[s_expr[1]]);var bus_db=get_value(sim.poc.states[s_expr[2]]);if(bus_ab!=IOSR_ID&&bus_ab!=IOCR_ID&&bus_ab!=IODR_ID){return}if(bus_ab==IOSR_ID)set_value(sim.poc.states[s_expr[3]],bus_db);if(bus_ab==IOCR_ID)set_value(sim.poc.states[s_expr[4]],bus_db);if(bus_ab==IODR_ID)set_value(sim.poc.states[s_expr[5]],bus_db);var iocr_id=get_value(sim.poc.states[s_expr[4]]);var iodr_id=get_value(sim.poc.states[s_expr[5]]);if(iocr_id<0||iocr_id>7)return;set_var(sim.poc.internal_states.io_int_factory[iocr_id].period,iodr_id);set_var(sim.poc.internal_states.io_int_factory[iocr_id].probability,1);if(0==iodr_id)set_var(sim.poc.internal_states.io_int_factory[iocr_id].probability,0)},verbal:function(s_expr){var verbal="";var bus_ab=get_value(sim.poc.states[s_expr[1]]);var bus_db=get_value(sim.poc.states[s_expr[2]]);if(bus_ab==IOSR_ID)verbal="I/O device write at IOSR with value "+bus_db+". ";if(bus_ab==IOCR_ID)verbal="I/O device write at IOCR with value "+bus_db+". ";if(bus_ab==IODR_ID)verbal="I/O device write at IODR with value "+bus_db+". ";return verbal}};sim.poc.behaviors.IO_CHK_I={nparameters:4,types:["E","S","E"],operation:function(s_expr){var clk=get_value(sim.poc.states[s_expr[1]]);for(var i=sim.poc.internal_states.io_int_factory.length-1;i>=0;i--){if(get_var(sim.poc.internal_states.io_int_factory[i].period)==0)continue;if(get_var(sim.poc.internal_states.io_int_factory[i].active)==true){set_value(sim.poc.signals[s_expr[2]],1);set_value(sim.poc.states[s_expr[3]],i)}if(clk%get_var(sim.poc.internal_states.io_int_factory[i].period)==0){if(Math.random()>get_var(sim.poc.internal_states.io_int_factory[i].probability))continue;set_var(sim.poc.internal_states.io_int_factory[i].accumulated,get_var(sim.poc.internal_states.io_int_factory[i].accumulated)+1);set_var(sim.poc.internal_states.io_int_factory[i].active,true);if(typeof sim.poc.events.io[clk]=="undefined")sim.poc.events.io[clk]=[];sim.poc.events.io[clk].push(i);set_value(sim.poc.signals[s_expr[2]],1);set_value(sim.poc.states[s_expr[3]],i)}}},verbal:function(s_expr){return"Check I/O Interruption. "}};sim.poc.behaviors.INTA={nparameters:6,types:["E","S","S","E","E"],operation:function(s_expr){var clk=get_value(sim.poc.states[s_expr[1]]);if(typeof sim.poc.events.io[clk]!="undefined"){set_value(sim.poc.states[s_expr[4]],sim.poc.events.io[clk][0]);return}set_value(sim.poc.signals[s_expr[2]],0);set_value(sim.poc.states[s_expr[5]],0);for(var i=0;i>>0;set_value(simhw_sim_state("BUS_AB"),elto);set_value(simhw_sim_signal("L3DR"),1);compute_behavior("FIRE L3DR");value=get_value(simhw_sim_state("BUS_DB"));return value},set_value:function(elto,value){var associated_state=simhw_internalState_get("io_hash",elto);set_value(simhw_sim_state(associated_state),value);set_value(simhw_sim_state("BUS_AB"),elto);set_value(simhw_sim_state("BUS_DB"),value);set_value(simhw_sim_signal("L3DW"),1);compute_behavior("FIRE L3DW");return value}};sim.poc.internal_states.l3d_dim=4;sim.poc.internal_states.l3d_neltos=Math.pow(sim.poc.internal_states.l3d_dim,3);sim.poc.internal_states.l3d_state=Array.from({length:sim.poc.internal_states.l3d_neltos},(()=>({active:false})));sim.poc.internal_states.l3d_frame="0".repeat(sim.poc.internal_states.l3d_neltos);var L3DSR_ID=8448;var L3DCR_ID=8452;var L3DDR_ID=8456;sim.poc.internal_states.io_hash[L3DSR_ID]="L3DSR";sim.poc.internal_states.io_hash[L3DCR_ID]="L3DCR";sim.poc.internal_states.io_hash[L3DDR_ID]="L3DDR";sim.poc.states.L3DSR={name:"L3DSR",verbal:"L3D State Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.L3DCR={name:"L3DCR",verbal:"L3D Control Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.L3DDR={name:"L3DDR",verbal:"L3D Data Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.signals.L3D_IOR={name:"L3D_IOR",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","L3D_IOR BUS_AB BUS_DB L3DSR L3DCR L3DDR CLK; FIRE M1"],fire_name:["svg_p:tspan4173"],draw_data:[[],["svg_p:path3795","svg_p:path3733"]],draw_name:[[],[]]};sim.poc.signals.L3D_IOW={name:"L3D_IOW",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","L3D_IOW BUS_AB BUS_DB L3DSR L3DCR L3DDR CLK; FIRE M1; L3D_SYNC"],fire_name:["svg_p:text3785-0-6-0-5-5"],draw_data:[[],["svg_p:path3805","svg_p:path3733"]],draw_name:[[],[]]};sim.poc.behaviors.L3D_IOR={nparameters:7,types:["E","E","E","E","E","E"],operation:function(s_expr){var bus_ab=get_value(sim.poc.states[s_expr[1]]);var iosr=get_value(sim.poc.states[s_expr[3]]);var iocr=get_value(sim.poc.states[s_expr[4]]);var iodr=get_value(sim.poc.states[s_expr[5]]);if(bus_ab==L3DCR_ID){set_value(sim.poc.states[s_expr[2]],iocr)}if(bus_ab==L3DDR_ID){set_value(sim.poc.states[s_expr[2]],iodr)}if(bus_ab==L3DCR_ID){var x=(iodr&4278190080)>>24;var y=(iodr&16711680)>>16;var z=(iodr&65280)>>8;var p=z*Math.pow(sim.poc.internal_states.l3d_dim,2)+y*sim.poc.internal_states.l3d_dim+x;var s=get_var(sim.poc.internal_states.l3d_state[p].active);set_value(sim.poc.states[s_expr[2]],s)}},verbal:function(s_expr){var verbal="";var bus_ab=get_value(sim.poc.states[s_expr[1]]);var iosr=get_value(sim.poc.states[s_expr[3]]);var iocr=get_value(sim.poc.states[s_expr[4]]);var iodr=get_value(sim.poc.states[s_expr[5]]);if(bus_ab==L3DSR_ID)verbal="I/O device read at L3DSR of value "+iosr+". ";if(bus_ab==L3DCR_ID)verbal="I/O device read at L3DCR of value "+iocr+". ";if(bus_ab==L3DDR_ID)verbal="I/O device read at L3DDR of value "+iodr+". ";return verbal}};sim.poc.behaviors.L3D_IOW={nparameters:7,types:["E","E","E","E","E","E"],operation:function(s_expr){var bus_ab=get_value(sim.poc.states[s_expr[1]]);var bus_db=get_value(sim.poc.states[s_expr[2]]);if(bus_ab!=L3DSR_ID&&bus_ab!=L3DCR_ID&&bus_ab!=L3DDR_ID){return}if(bus_ab==L3DSR_ID){set_value(sim.poc.states[s_expr[3]],bus_db)}if(bus_ab==L3DDR_ID){set_value(sim.poc.states[s_expr[5]],bus_db)}if(bus_ab==L3DCR_ID){set_value(sim.poc.states[s_expr[4]],bus_db);var x=(bus_db&4278190080)>>24;var y=(bus_db&16711680)>>16;var z=(bus_db&65280)>>8;var p=z*Math.pow(sim.poc.internal_states.l3d_dim,2)+y*sim.poc.internal_states.l3d_dim+x;var s=(bus_db&255)!=0;var l3dstates=sim.poc.internal_states.l3d_state;set_var(l3dstates[p].active,s)}},verbal:function(s_expr){var verbal="";var bus_ab=get_value(sim.poc.states[s_expr[1]]);var bus_db=get_value(sim.poc.states[s_expr[2]]);if(bus_ab==L3DSR_ID)verbal="I/O device write at L3DSR with value "+bus_db+". ";if(bus_ab==L3DCR_ID)verbal="I/O device write at L3DCR with value "+bus_db+". ";if(bus_ab==L3DDR_ID)verbal="I/O device write at L3DDR with value "+bus_db+". ";return verbal}};sim.poc.behaviors.L3D_RESET={nparameters:1,operation:function(s_expr){sim.poc.events.l3d={};var n=sim.poc.internal_states.l3d_state.length;for(var i=0;i>>0;set_value(simhw_sim_state("BUS_AB"),elto);set_value(simhw_sim_signal("LEDMR"),1);compute_behavior("FIRE LEDMR");value=get_value(simhw_sim_state("BUS_DB"));return value},set_value:function(elto,value){var associated_state=simhw_internalState_get("io_hash",elto);set_value(simhw_sim_state(associated_state),value);set_value(simhw_sim_state("BUS_AB"),elto);set_value(simhw_sim_state("BUS_DB"),value);set_value(simhw_sim_signal("LEDMW"),1);compute_behavior("FIRE LEDMW");return value}};sim.poc.internal_states.ledm_dim=24;sim.poc.internal_states.ledm_neltos=Math.pow(sim.poc.internal_states.ledm_dim,2);sim.poc.internal_states.ledm_state=Array.from({length:sim.poc.internal_states.ledm_neltos},(()=>({color:0})));sim.poc.internal_states.ledm_colors=colors_clone("");sim.poc.internal_states.ledm_frame="0".repeat(sim.poc.internal_states.ledm_neltos);var LEDMSR_ID=12544;var LEDMCR_ID=12548;var LEDMDR_ID=12552;sim.poc.internal_states.io_hash[LEDMSR_ID]="LEDMSR";sim.poc.internal_states.io_hash[LEDMCR_ID]="LEDMCR";sim.poc.internal_states.io_hash[LEDMDR_ID]="LEDMDR";sim.poc.states.LEDMSR={name:"LEDMSR",verbal:"LEDM State Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.LEDMCR={name:"LEDMCR",verbal:"LEDM Control Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.LEDMDR={name:"LEDMDR",verbal:"LEDM Data Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.signals.LEDM_IOR={name:"LEDM_IOR",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","LEDM_IOR BUS_AB BUS_DB LEDMSR LEDMCR LEDMDR CLK; FIRE M1"],fire_name:["svg_p:tspan4173"],draw_data:[[],["svg_p:path3795","svg_p:path3733"]],draw_name:[[],[]]};sim.poc.signals.LEDM_IOW={name:"LEDM_IOW",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","LEDM_IOW BUS_AB BUS_DB LEDMSR LEDMCR LEDMDR CLK; FIRE M1; LEDM_SYNC"],fire_name:["svg_p:text3785-0-6-0-5-5"],draw_data:[[],["svg_p:path3805","svg_p:path3733"]],draw_name:[[],[]]};sim.poc.behaviors.LEDM_IOR={nparameters:7,types:["E","E","E","E","E","E"],operation:function(s_expr){var bus_ab=get_value(sim.poc.states[s_expr[1]]);var iosr=get_value(sim.poc.states[s_expr[3]]);var iocr=get_value(sim.poc.states[s_expr[4]]);var iodr=get_value(sim.poc.states[s_expr[5]]);if(bus_ab==LEDMCR_ID){set_value(sim.poc.states[s_expr[2]],iocr)}if(bus_ab==LEDMDR_ID){set_value(sim.poc.states[s_expr[2]],iodr)}if(bus_ab==LEDMCR_ID){var x=(iodr&4278190080)>>24;var y=(iodr&16711680)>>16;var p=y*sim.poc.internal_states.ledm_dim+x;var s=get_var(sim.poc.internal_states.ledm_state[p].color);set_value(sim.poc.states[s_expr[2]],s)}},verbal:function(s_expr){var verbal="";var bus_ab=get_value(sim.poc.states[s_expr[1]]);var iosr=get_value(sim.poc.states[s_expr[3]]);var iocr=get_value(sim.poc.states[s_expr[4]]);var iodr=get_value(sim.poc.states[s_expr[5]]);if(bus_ab==LEDMSR_ID)verbal="I/O device read at LEDMSR of value "+iosr+". ";if(bus_ab==LEDMCR_ID)verbal="I/O device read at LEDMCR of value "+iocr+". ";if(bus_ab==LEDMDR_ID)verbal="I/O device read at LEDMDR of value "+iodr+". ";return verbal}};sim.poc.behaviors.LEDM_IOW={nparameters:7,types:["E","E","E","E","E","E"],operation:function(s_expr){var bus_ab=get_value(sim.poc.states[s_expr[1]]);var bus_db=get_value(sim.poc.states[s_expr[2]]);switch(bus_ab){case LEDMSR_ID:set_value(sim.poc.states[s_expr[3]],bus_db);break;case LEDMDR_ID:set_value(sim.poc.states[s_expr[5]],bus_db);break;case LEDMCR_ID:set_value(sim.poc.states[s_expr[4]],bus_db);break;default:break}if(LEDMCR_ID==bus_ab){var dr=get_value(sim.poc.states[s_expr[5]]);if(16&bus_db){var x=(dr&4278190080)>>24;var y=(dr&16711680)>>16;var s=dr&255;set_value(sim.poc.states[s_expr[3]],1);if(x>=sim.poc.internal_states.ledm_dim&&y>=sim.poc.internal_states.ledm_dim){set_value(sim.poc.states[s_expr[3]],-1);return}var p=y*sim.poc.internal_states.ledm_dim+x;set_var(sim.poc.internal_states.ledm_state[p].color,s)}if(32&bus_db){set_value(sim.poc.states[s_expr[3]],1);var s=0;var neltos=sim.poc.internal_states.ledm_neltos;var ldmstates=sim.poc.internal_states.ledm_state;for(var p=0;p>0);set_var(sim.poc.internal_states.ledm_state[p+1].color,(s&65280)>>8);set_var(sim.poc.internal_states.ledm_state[p+2].color,(s&16711680)>>16);set_var(sim.poc.internal_states.ledm_state[p+3].color,(s&4278190080)>>24)}}if(64&bus_db){set_value(sim.poc.states[s_expr[3]],1);var s=0;var c="";var neltos=sim.poc.internal_states.ledm_colors.length;for(var p=0;p>>8;s=s.toString(16);c="#"+simcoreui_pack(s,6);sim.poc.internal_states.ledm_colors[p]=c}neltos=sim.poc.internal_states.ledm_neltos;for(var p=0;p>24;var y=(dr&16711680)>>16;var s=dr&255;verbal="I/O device write at LEDMCR with value "+bus_db+" (set pixel x:"+x+", y:"+y+", with color:"+s+"). "}if(64&bus_db){verbal="I/O device write at LEDMCR with value "+bus_db+" (set color palette at:"+bus_db+"). "}break;default:break}return verbal}};sim.poc.behaviors.LEDM_RESET={nparameters:1,operation:function(s_expr){sim.poc.events.ledm={};sim.poc.internal_states.ledm_colors=colors_clone("");for(var i=0;i>>0;if(value!=0){vec.CPU["R"+i]={type:"register",default_value:0,id:"R"+i,op:"=",value:"0x"+value.toString(16)}}}for(i=0;i>>0;if(value!=0){vec.CPU[internal_reg[i]]={type:"register",default_value:0,id:internal_reg[i],op:"=",value:"0x"+value.toString(16)}}}return vec},read_state:function(vec,check){if(typeof vec.CPU=="undefined"){vec.CPU={}}var key=check["id"].toUpperCase().trim();var val=parseInt(check["value"]).toString(16);if("REGISTER"==check["type"].toUpperCase().trim()){vec.CPU[key]={type:"register",default_value:0,id:key,op:check["condition"],value:"0x"+val};return true}return false},get_state:function(reg){var value=0;var r_reg=reg.toUpperCase().trim();if(typeof sim.rv.states["REG_"+r_reg]!="undefined"){value=get_value(sim.rv.states["REG_"+r_reg])>>>0;return"0x"+value.toString(16)}r_reg=r_reg.replace("R","");var index=parseInt(r_reg);if(typeof sim.rv.states.BR[index]!="undefined"){value=get_value(sim.rv.states.BR[index])>>>0;return"0x"+value.toString(16)}return null},get_value:function(elto){if(Number.isInteger(elto))index=elto;else index=parseInt(elto);if(isNaN(index))return get_value(simhw_sim_state(elto))>>>0;return get_value(simhw_sim_states().BR[index])>>>0},set_value:function(elto,value){var pc_name=simhw_sim_ctrlStates_get().pc.state;if(Number.isInteger(elto))index=elto;else index=parseInt(elto);if(isNaN(index)){set_value(simhw_sim_state(elto),value);if(pc_name===elto){show_asmdbg_pc()}return value}return set_value(simhw_sim_states().BR[index],value)}};sim.rv.ctrl_states.pc={name:"PC",state:"REG_PC",is_pointer:true};sim.rv.ctrl_states.sp={name:"SP",state:"BR.29",is_pointer:true};sim.rv.ctrl_states.fp={name:"FP",state:"BR.30",is_pointer:true};sim.rv.ctrl_states.ir={name:"IR",state:"REG_IR",default_eltos:{co:{begin:0,end:5,length:6},cop:{begin:28,end:31,length:4},oc:{begin:25,end:31,length:7},eoc:{type:2,bits_field:[[14,12],[31,25]],bits:[[17,19],[0,6]],lengths:[3,7],length:10}},is_pointer:false};sim.rv.ctrl_states.mpc={name:"mPC",state:"REG_MICROADDR",is_pointer:false};sim.rv.internal_states.MC={};sim.rv.internal_states.ROM={};sim.rv.internal_states.FIRMWARE=ws_empty_firmware;sim.rv.internal_states.io_hash={};sim.rv.internal_states.fire_stack=[];sim.rv.internal_states.tri_state_names=[];sim.rv.internal_states.fire_visible={databus:false,internalbus:false};sim.rv.internal_states.filter_states=["REG_IR_DECO,col-12","REG_IR,col-auto","REG_PC,col-auto","REG_OUT,col-auto","REG_MICROADDR,col-auto"];sim.rv.internal_states.filter_signals=["CU,0","ALUOP,0","M1,0","M2,0","M3,0","M4,0","JUMP,0","PCWRITE,0","IMR,0","IRWRITE,0","RW,0","WOUT,0","DMR,0","DMW,0","WBE,0","SE,0"];sim.rv.internal_states.alu_flags={flag_n:0,flag_z:0};sim.rv.states.BR=[];sim.rv.states.BR[0]={name:"R0",verbal:"Register 0",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[1]={name:"R1",verbal:"Register 1",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[2]={name:"R2",verbal:"Register 2",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[3]={name:"R3",verbal:"Register 3",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[4]={name:"R4",verbal:"Register 4",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[5]={name:"R5",verbal:"Register 5",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[6]={name:"R6",verbal:"Register 6",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[7]={name:"R7",verbal:"Register 7",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[8]={name:"R8",verbal:"Register 8",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[9]={name:"R9",verbal:"Register 9",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[10]={name:"R10",verbal:"Register 10",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[11]={name:"R11",verbal:"Register 11",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[12]={name:"R12",verbal:"Register 12",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[13]={name:"R13",verbal:"Register 13",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[14]={name:"R14",verbal:"Register 14",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[15]={name:"R15",verbal:"Register 15",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[16]={name:"R16",verbal:"Register 16",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[17]={name:"R17",verbal:"Register 17",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[18]={name:"R18",verbal:"Register 18",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[19]={name:"R19",verbal:"Register 19",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[20]={name:"R20",verbal:"Register 20",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[21]={name:"R21",verbal:"Register 21",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[22]={name:"R22",verbal:"Register 22",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[23]={name:"R23",verbal:"Register 23",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[24]={name:"R24",verbal:"Register 24",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[25]={name:"R25",verbal:"Register 25",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[26]={name:"R26",verbal:"Register 26",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[27]={name:"R27",verbal:"Register 27",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[28]={name:"R28",verbal:"Register 28",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[29]={name:"R29",verbal:"Register 29",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[30]={name:"R30",verbal:"Register 30",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[31]={name:"R31",verbal:"Register 31",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["REG_PC"]={name:"PC",verbal:"Program Counter Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["REG_IR"]={name:"IR",verbal:"Instruction Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["REG_OUT"]={name:"OUT",verbal:"Out Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["M4_PC"]={name:"M4_PC",verbal:"Input PCWrite via M4",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["RDATA"]={name:"RDATA",verbal:"Read data form Instruction Memory (Input Instruction Register via Instruction Memory)",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["M2_ALU"]={name:"M2_ALU",verbal:"Input ALU via M2",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["M3_ALU"]={name:"M3_ALU",verbal:"Input ALU via M3",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["ALU_WOUT"]={name:"ALU_WOUT",verbal:"Input of OUT Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["FLAG_N"]={name:"FLAG_N",verbal:"Negative Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.rv.states["FLAG_Z"]={name:"FLAG_Z",verbal:"Zero Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.rv.states["REG_MICROADDR"]={name:"µADDR",verbal:"Microaddress Register",visible:true,nbits:"12",value:0,default_value:0,draw_data:[]};sim.rv.states["REG_MICROINS"]={name:"µINS",verbal:"Microinstruction Register",visible:true,nbits:"77",value:{},default_value:{},draw_data:[]};sim.rv.states["FETCH"]={name:"FETCH",verbal:"Input Fetch",visible:false,nbits:"12",value:0,default_value:0,draw_data:[]};sim.rv.states["ROM_MUXA"]={name:"ROM_MUXA",verbal:"Input ROM",visible:false,nbits:"12",value:0,default_value:0,draw_data:[]};sim.rv.states["MUXA_MICROADDR"]={name:"MUXA_MICROADDR",verbal:"Input microaddress",visible:false,nbits:"12",value:0,default_value:0,draw_data:[]};sim.rv.states["MUXC_MUXB"]={name:"MUXC_MUXB",verbal:"Output of MUX C",visible:false,nbits:"1",value:0,default_value:0,draw_data:[]};sim.rv.states["INEX"]={name:"INEX",verbal:"Illegal Instruction Exception",visible:false,nbits:"1",value:0,default_value:0,draw_data:[]};sim.rv.states["DM_BS"]={name:"DM_BS",verbal:"From Data Memory to Byte/Word Selector",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["BS_M1"]={name:"BS_M1",verbal:"From Byte/Word Selector to Mux 1",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["VAL_ZERO"]={name:"VAL_ZERO",verbal:"Wired Zero",visible:false,nbits:"1",value:0,default_value:0,draw_data:[]};sim.rv.states["VAL_ONE"]={name:"VAL_ONE",verbal:"Wired One",visible:false,nbits:"32",value:1,default_value:1,draw_data:[]};sim.rv.states["VAL_FOUR"]={name:"VAL_FOUR",verbal:"Wired Four",visible:false,nbits:"32",value:4,default_value:4,draw_data:[]};sim.rv.states["VAL_IMM"]={name:"VAL_IMM",verbal:"Immediate Value Generator",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["REG_IR_DECO"]={name:"IR_DECO",verbal:"Instruction Decoded",visible:true,nbits:"0",value:0,default_value:0,draw_data:[]};sim.rv.states["DECO_INS"]={name:"DECO_INS",verbal:"Instruction decoded in binary",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["CLK"]={name:"CLK",verbal:"Clock",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["ACC_TIME"]={name:"ACC_TIME",verbal:"Accumulated CPU time",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["TTCPU"]={name:"TTCPU",verbal:"Several Tristates to the internal data bus in CPU activated",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["ACC_PWR"]={name:"ACC_PWR",verbal:"Accumulated Energy Consumption",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.signals["CU"]={name:"CU",visible:true,type:"L",value:0,default_value:0,nbits:"3",behavior:["PLUS1 MUXA_MICROADDR REG_MICROADDR","CP_FIELD MUXA_MICROADDR REG_MICROINS/MADDR","MV MUXA_MICROADDR ROM_MUXA","MV MUXA_MICROADDR FETCH","JUMP_MADDR_N MUXA_MICROADDR REG_MICROINS/MADDR REG_MICROADDR 0","JUMP_MADDR_N MUXA_MICROADDR REG_MICROINS/MADDR REG_MICROADDR 1","JUMP_MADDR_Z MUXA_MICROADDR REG_MICROINS/MADDR REG_MICROADDR 0","JUMP_MADDR_Z MUXA_MICROADDR REG_MICROINS/MADDR REG_MICROADDR 1"],depends_on:["CLK"],fire_name:["svg_p:text7417"],draw_data:[["svg_p:path7391","svg_p:path7393","svg_p:path7395","svg_p:path7397","svg_p:path7399","svg_p:path7401"]],draw_name:[["svg_p:path7357","svg_p:path7329","svg_p:path7331"]]};sim.rv.signals["PCWRITE"]={name:"PCWRITE",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","LOAD REG_PC M4_PC; UPDATEDPC"],fire_name:["svg_p:text7155"],draw_data:[[]],draw_name:[["svg_p:path7145","svg_p:path7125","svg_p:path7127"]]};sim.rv.signals["JUMP"]={name:"JUMP",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","LOAD_J REG_PC M4_PC; UPDATEDPC_J"],fire_name:["svg_p:text7173"],draw_data:[[]],draw_name:[["svg_p:path7133","svg_p:path7143","svg_p:path7147","svg_p:path7135"]]};sim.rv.signals["IRWRITE"]={name:"IRWRITE",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","LOAD REG_IR RDATA; DECO"],fire_name:["svg_p:text7309"],draw_data:[["svg_p:path6711","svg_p_path:6713","svg_p:path6981","svg_p:path6903","svg_p:path6905"]],draw_name:[["svg_p:path7301"]]};sim.rv.signals["GEN_IMM"]={name:"GEN_IMM",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","DECO_IMM VAL_IMM 0 REG_IR OFFSET SIZE 0 SE_IMM"],fire_name:["svg_p:text7300"],draw_data:[["svg_p:path6981","svg_p:path6903","svg_p:path:6904"]],draw_name:[["svg_p:path7146"]]};sim.rv.signals["SE_IMM"]={name:"SE_IMM",visible:true,type:"L",value:0,default_value:1,nbits:"1",verbal:["Set superior bits of immediate value to 0.","Extend sign of immediate value."],behavior:["NOP","NOP"],fire_name:["svg_p:text7301"],draw_data:[[]],draw_name:[["svg_p:path7292"]]};sim.rv.signals["SIZE"]={name:"SIZE",visible:true,type:"L",value:0,default_value:0,nbits:"5",behavior:["NOP"],fire_name:["svg_p:text7302"],draw_data:[[]],draw_name:[["svg_p:path7293"]]};sim.rv.signals["OFFSET"]={name:"OFFSET",visible:true,type:"L",value:0,default_value:0,nbits:"5",behavior:["NOP"],fire_name:["svg_p:text7303"],draw_data:[[]],draw_name:[["svg_p:path7294"]]};sim.rv.signals["WOUT"]={name:"WOUT",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","LOAD REG_OUT ALU_WOUT"],fire_name:["svg_p:text7279"],draw_data:[["svg_p:path6837","svg_p:path6839"]],draw_name:[["svg_p:path7271"]]};sim.rv.signals["IMR"]={name:"IMR",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","READ_IM"],fire_name:["svg_p:text7213"],draw_data:[["svg_p:path6691","svg_p:path6693"]],draw_name:[["svg_p:path7205"]]};sim.rv.signals["REG_R1"]={name:"REG_R1",visible:true,type:"L",value:0,default_value:15,nbits:"5",behavior:["NOP"],fire_name:[],draw_data:[[]],draw_name:[[]]};sim.rv.signals["REG_R2"]={name:"REG_R2",visible:true,type:"L",value:0,default_value:20,nbits:"5",behavior:["NOP"],fire_name:[],draw_data:[[]],draw_name:[[]]};sim.rv.signals["REG_W2"]={name:"REG_W2",visible:true,type:"L",value:0,default_value:7,nbits:"5",behavior:["NOP"],fire_name:[],draw_data:[[]],draw_name:[[]]};sim.rv.states["M1_RW"]={name:"M1_RW",verbal:"Input Register File via M1",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["W_DATA"]={name:"W_DATA",verbal:"Write Data",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["R_DATA1"]={name:"R_DATA1",verbal:"Read Data 1",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["R_DATA2"]={name:"R_DATA2",verbal:"Read Data 2",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.signals["RW"]={name:"RW",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["MBIT_SN REG_R1 REG_IR REG_MICROINS/REG_R1 5; GET R_DATA1 BR REG_R1; MBIT_SN REG_R2 REG_IR REG_MICROINS/REG_R2 5; GET R_DATA2 BR REG_R2","MBIT_SN REG_W2 REG_IR REG_MICROINS/REG_W2 5; SET BR REG_W2 M1_RW"],fire_name:["svg_p:text7299"],draw_data:[["svg_p:path6725","svg_p:path6727","svg_p:path6729","svg_p:path6731","svg_p:path6733","svg_p:path6735","svg_p:path6915","svg_p:path6913","svg_p:path6907","svg_p:path6909"]],draw_name:[["svg_p:path7291"]]};sim.rv.signals["M2"]={name:"M2",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV M2_ALU REG_PC; FIRE ALUOP","MV M2_ALU R_DATA1; FIRE ALUOP"],depends_on:["ALUOP"],fire_name:["svg_p:text7229"],draw_data:[["svg_p:path6691-3","svg_p:path6987","svg_p:path6989","svg_p:path6983","svg_p:path6991","svg_p:path6775","svg_p:path6777"],["svg_p:path6779","svg_p:path6781"]],draw_name:[[],["svg_p:path7199"]]};sim.rv.signals["M3"]={name:"M3",visible:true,type:"L",value:0,default_value:0,nbits:"2",behavior:["MV M3_ALU R_DATA2; FIRE ALUOP","MV M3_ALU VAL_FOUR; FIRE ALUOP","MV M3_ALU VAL_IMM; FIRE ALUOP","NOP"],fire_name:["svg_p:text7237"],depends_on:["ALUOP"],draw_data:[["svg_p:path6821","svg_p:path6823"],["svg_p:path7001","svg_p:path7003"],["svg_p:path7015","svg_p:path7013","svg_p:path6825","svg_p:path6827"]],draw_name:[[],["svg_p:path7197"]]};sim.rv.signals["M4"]={name:"M4",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV M4_PC REG_OUT","MV M4_PC ALU_WOUT"],depends_on:["PCWRITE"],fire_name:["svg_p:text7289"],draw_data:[["svg_p:path7075","svg_p:path7043","svg_p:path7045","svg_p:path7047","svg_p:path7123","svg_p:path7121","svg_p:path7041","svg_p:path7039","svg_p:path7035","svg_p:path7037"],["svg_p:path6837-6","svg_p:path7073","svg_p:path7115","svg_p:path7117","svg_p:path7119","svg_p:path7123","svg_p:path7121","svg_p:path7041","svg_p:path7039","svg_p:path7035","svg_p:path7037"]],draw_name:[[],["svg_p:path7281"]]};sim.rv.signals["ALUOP"]={name:"ALUOP",visible:true,type:"L",value:0,default_value:0,nbits:"5",behavior:["NOP_ALU; UPDATE_NZ","AND ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","OR ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","NOT ALU_WOUT M2_ALU; UPDATE_NZ","XOR ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","SRL ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","SRA ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","SL ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","RR ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","RL ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","ADD ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","SUB ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","MUL ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","DIV ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","MOD ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","LUI ALU_WOUT M2_ALU; UPDATE_NZ","ADDU ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","SUBU ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","MULU ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","DIVU ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU","MV ALU_WOUT M2_ALU; UPDATE_NZ","MV ALU_WOUT M3_ALU; UPDATE_NZ"],fire_name:["svg_p:text7269"],draw_data:[["svg_p:path6845","svg_p:path6847","svg_p:path6841","svg_p:path6843"]],draw_name:[["svg_p:path7249"]]};sim.rv.signals.DMR={name:"DMR",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV DM_BS REG_OUT; FIRE WBE","MEM_READ ALU_WOUT DM_BS WBE CLK; FIRE WBE"],fire_name:["svg_p:text7589","svg_p:text7507"],draw_data:[[],["svg_p:path7525","svg_p:path6837-6","svg_p:path7073","svg_p:path7619","svg_p:path7571","svg_p:path7573"]],draw_name:[[],[]]};sim.rv.signals.DMW={name:"DMW",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","MEM_WRITE ALU_WOUT DM_BS WBE CLK"],fire_name:["svg_p:text7597","svg_p:text7515"],draw_data:[[],["svg_p:path7527","svg_p:path6837-6","svg_p:path7073","svg_p:path7619","svg_p:path7571","svg_p:path7573"]],draw_name:[[],[]]};sim.rv.signals["WBE"]={name:"WBE",visible:false,type:"L",value:0,default_value:0,nbits:"2",behavior:["MV BS_M1 DM_BS","BWSEL BS_M1 DM_BS 0 0 8 SE","BWSEL BS_M1 DM_BS 0 0 16 SE","NOP"],depends_on:["RW"],fire_name:["svg_p:text7555","svg_p:text7433"],draw_data:[["svg_p:path7075-2","svg_p:path7043-6","svg_p:path7203","svg_p:path7579","svg_p:path7581","svg_p:path7567","svg_p:path7569","svg_p:path7421","svg_p:path7423"]],draw_name:[["svg_p:path7529","svg_p:path7425"]]};sim.rv.signals["SE"]={name:"SE",visible:true,type:"L",value:0,default_value:1,nbits:"1",verbal:["If WBE is enabled, set superior bits of Word to 0.","If WBE is enabled, extend byte sign to Word."],behavior:["NOP","NOP"],fire_name:["svg_p:text7453"],draw_data:[[]],draw_name:[["svg_p:path7445"]]};sim.rv.signals["M1"]={name:"M1",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV M1_RW BS_M1","MV M1_RW FLAG_N"],depends_on:["RW"],fire_name:["svg_p:text7221"],draw_data:[["svg_p:path7021","svg_p:path7023","svg_p:path7565","svg_p:path6911","svg_p:path6895","svg_p:path6897"],["svg_p:path7621","svg_p:path7025","svg_p:path7017","svg_p:path7019","svg_p:path6899","svg_p:path6901"]],draw_name:[[],["svg_p:path7195"]]};sim.rv.signals["TEST_N"]={name:"TEST_N",visible:true,type:"L",value:0,default_value:0,nbits:"1",forbidden:true,behavior:["MV FLAG_N VAL_ZERO","MV FLAG_N VAL_ONE"],depends_on:["ALUOP"],fire_name:["svg_p:text351","svg_p:text7185"],draw_data:[["svg_p:path7251"]],draw_name:[["svg_p:path7157"]]};sim.rv.signals["TEST_Z"]={name:"TEST_Z",visible:true,type:"L",value:0,default_value:0,nbits:"1",forbidden:true,behavior:["MV FLAG_Z VAL_ZERO","MV FLAG_Z VAL_ONE"],depends_on:["ALUOP"],fire_name:["svg_p:text7615","svg_p:text7193"],draw_data:[["svg_p:path7617"]],draw_name:[["svg_p:path7165"]]};sim.rv.behaviors["NOP"]={nparameters:1,operation:function(s_expr){},verbal:function(s_expr){return""}};sim.rv.behaviors["NOP_ALU"]={nparameters:1,operation:function(s_expr){sim.rv.internal_states.alu_flags.flag_n=0;sim.rv.internal_states.alu_flags.flag_z=0},verbal:function(s_expr){return""}};sim.rv.behaviors["MV"]={nparameters:3,types:["X","X"],operation:function(s_expr){sim_elto_org=get_reference(s_expr[2]);sim_elto_dst=get_reference(s_expr[1]);newval=get_value(sim_elto_org);set_value(sim_elto_dst,newval)},verbal:function(s_expr){var sim_elto_org=get_reference(s_expr[2]);var newval=get_value(sim_elto_org);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from "+show_verbal(s_expr[2])+" to "+show_verbal(s_expr[1])+" value "+show_value(newval)+". "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" ("+show_value(newval)+"). "}};sim.rv.behaviors["LOAD"]={nparameters:3,types:["X","X"],operation:function(s_expr){var sim_elto_org=get_reference(s_expr[2]);var sim_elto_dst=get_reference(s_expr[1]);var newval=get_value(sim_elto_org);set_value(sim_elto_dst,newval)},verbal:function(s_expr){var sim_elto_org=get_reference(s_expr[2]);var newval=get_value(sim_elto_org);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Load from "+show_verbal(s_expr[2])+" to "+show_verbal(s_expr[1])+" value "+show_value(newval)+". "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" ("+show_value(newval)+"). "}};sim.rv.behaviors["LOAD_J"]={nparameters:3,types:["X","X"],operation:function(s_expr){if(!get_value(sim.rv.states["FLAG_N"])&&!get_value(sim.rv.states["FLAG_Z"])){return}var sim_elto_org=get_reference(s_expr[2]);var sim_elto_dst=get_reference(s_expr[1]);var newval=get_value(sim_elto_org);set_value(sim_elto_dst,newval)},verbal:function(s_expr){var sim_elto_org=get_reference(s_expr[2]);var sim_elto_dst=get_reference(s_expr[1]);var newval=get_value(sim_elto_org);return"Jump if N or Z (new value is '"+newval+"' )"}};sim.rv.behaviors["CP_FIELD"]={nparameters:3,types:["X","X"],operation:function(s_expr){r=s_expr[2].split("/");sim_elto_org=get_reference(r[0]);newval=get_value(sim_elto_org);newval=newval[r[1]];if(typeof newval!="undefined"){sim_elto_dst=get_reference(s_expr[1]);set_value(sim_elto_dst,newval)}},verbal:function(s_expr){var newval=0;var r=s_expr[2].split("/");var sim_elto_org=get_reference(r[0]);var sim_elto_dst=get_reference(r[1]);if(typeof sim_elto_dst=="undefined")sim_elto_dst={};if(typeof sim_elto_org.value[r[1]]!="undefined")newval=sim_elto_org.value[r[1]];else if(typeof sim_elto_dst.default_value!="undefined")newval=sim_elto_dst.default_value;else newval="<undefined>";var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from Field "+r[1]+" of "+show_verbal(r[0])+" to "+show_verbal(s_expr[1])+" value "+newval+". "}return show_verbal(s_expr[1])+" = "+show_verbal(r[0])+"."+r[1]+" ("+newval+"). "}};sim.rv.behaviors["JUMP_MADDR_N"]={nparameters:5,types:["X","X","E","I"],operation:function(s_expr){if(get_value(sim.rv.states["FLAG_N"])!=parseInt(s_expr[4])){var a=get_value(sim.rv.states[s_expr[3]])<<0;var result=a+1;set_value(sim.rv.states[s_expr[1]],result>>>0)}else{r=s_expr[2].split("/");sim_elto_org=get_reference(r[0]);newval=get_value(sim_elto_org);newval=newval[r[1]];if(typeof newval!="undefined"){sim_elto_dst=get_reference(s_expr[1]);set_value(sim_elto_dst,newval)}}},verbal:function(s_expr){if(parseInt(s_expr[4])){return"Jump to REG_MICROINS/MADDR if Flag N = 1."}else{return"Jump to REG_MICROINS/MADDR if Flag N = 0."}}};sim.rv.behaviors["JUMP_MADDR_Z"]={nparameters:5,types:["X","X","E","I"],operation:function(s_expr){if(get_value(sim.rv.states["FLAG_Z"])!=parseInt(s_expr[4])){var a=get_value(sim.rv.states[s_expr[3]])<<0;var result=a+1;set_value(sim.rv.states[s_expr[1]],result>>>0)}else{r=s_expr[2].split("/");sim_elto_org=get_reference(r[0]);newval=get_value(sim_elto_org);newval=newval[r[1]];if(typeof newval!="undefined"){sim_elto_dst=get_reference(s_expr[1]);set_value(sim_elto_dst,newval)}}},verbal:function(s_expr){if(parseInt(s_expr[4])){return"Jump to REG_MICROINS/MADDR if Flag Z = 1."}else{return"Jump to REG_MICROINS/MADDR if Flag Z = 0."}}};sim.rv.behaviors["NOT_ES"]={nparameters:3,types:["S","E"],operation:function(s_expr){set_value(sim.rv.signals[s_expr[1]],Math.abs(get_value(sim.rv.states[s_expr[2]])-1))},verbal:function(s_expr){var value=Math.abs(get_value(sim.rv.states[s_expr[2]])-1);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Set "+show_verbal(s_expr[1])+" with value "+show_value(value)+" (Logical NOT of "+s_expr[2]+"). "}return show_verbal(s_expr[1])+" = "+show_value(value)+" (Logical NOT "+s_expr[2]+"). "}};sim.rv.behaviors["GET"]={nparameters:4,types:["E","E","S"],operation:function(s_expr){set_value(sim.rv.states[s_expr[1]],get_value(sim.rv.states[s_expr[2]][sim.rv.signals[s_expr[3]].value]))},verbal:function(s_expr){var value=get_value(sim.rv.states[s_expr[2]][sim.rv.signals[s_expr[3]].value]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Set "+show_verbal(s_expr[1])+" with value "+show_value(value)+" (Register File "+s_expr[3]+"). "}return show_verbal(s_expr[1])+" = "+show_value(value)+" (Register File "+s_expr[3]+"). "}};sim.rv.behaviors["SET"]={nparameters:4,types:["E","S","E"],operation:function(s_expr){set_value(sim.rv.states[s_expr[1]][sim.rv.signals[s_expr[2]].value],get_value(sim.rv.states[s_expr[3]]))},verbal:function(s_expr){var value=get_value(sim.rv.states[s_expr[3]]);var o_ref=sim.rv.states[s_expr[1]][sim.rv.signals[s_expr[2]].value];var o_verbal=o_ref.name;if(typeof o_ref.verbal!="undefined")o_verbal=o_ref.verbal;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy to "+o_verbal+" the value "+show_value(value)+". "}return o_verbal+" = "+show_value(value)+". "}};sim.rv.behaviors["AND"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var result=get_value(sim.rv.states[s_expr[2]])&get_value(sim.rv.states[s_expr[3]]);set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var result=get_value(sim.rv.states[s_expr[2]])&get_value(sim.rv.states[s_expr[3]]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU AND with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (AND). "}};sim.rv.behaviors["OR"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var result=get_value(sim.rv.states[s_expr[2]])|get_value(sim.rv.states[s_expr[3]]);set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var result=get_value(sim.rv.states[s_expr[2]])|get_value(sim.rv.states[s_expr[3]]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU OR with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (OR). "}};sim.rv.behaviors["NOT"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=~get_value(sim.rv.states[s_expr[2]]);set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var result=~get_value(sim.rv.states[s_expr[2]]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU NOT with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (NOT). "}};sim.rv.behaviors["XOR"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var result=get_value(sim.rv.states[s_expr[2]])^get_value(sim.rv.states[s_expr[3]]);set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var result=get_value(sim.rv.states[s_expr[2]])^get_value(sim.rv.states[s_expr[3]]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU XOR with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (XOR). "}};sim.rv.behaviors["SRL"]={nparameters:3,types:["E","E","E"],operation:function(s_expr){var shifts=get_value(sim.rv.states[s_expr[3]]);var result=get_value(sim.rv.states[s_expr[2]])>>>shifts;set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var shifts=get_value(sim.rv.states[s_expr[3]]);var result=get_value(sim.rv.states[s_expr[2]])>>>shifts;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Shift Right Logical with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (SRL). "}};sim.rv.behaviors["SRA"]={nparameters:3,types:["E","E","E"],operation:function(s_expr){var shifts=get_value(sim.rv.states[s_expr[3]]);var result=get_value(sim.rv.states[s_expr[2]])>>shifts;set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var shifts=get_value(sim.rv.states[s_expr[3]]);var result=get_value(sim.rv.states[s_expr[2]])>>shifts;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Shift Right Arithmetic with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (SRA). "}};sim.rv.behaviors["SL"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var shifts=get_value(sim.rv.states[s_expr[3]]);var result=get_value(sim.rv.states[s_expr[2]])<>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var shifts=get_value(sim.rv.states[s_expr[3]]);var result=get_value(sim.rv.states[s_expr[2]])<>>rotations|(get_value(sim.rv.states[s_expr[2]])&rotations)<<31;set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var rotations=get_value(sim.rv.states[s_expr[3]]);var result=get_value(sim.rv.states[s_expr[2]])>>>rotations|(get_value(sim.rv.states[s_expr[2]])&rotations)<<31;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Right Rotation with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (RR). "}};sim.rv.behaviors["RL"]={nparameters:3,types:["E","E"],operation:function(s_expr){var rotations=get_value(sim.rv.states[s_expr[3]]);var result=get_value(sim.rv.states[s_expr[2]])<>>31;set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var rotations=get_value(sim.rv.states[s_expr[3]]);var result=get_value(sim.rv.states[s_expr[2]])<>>31;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Left Rotation with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (LR). "}};sim.rv.behaviors["ADD"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var b=get_value(sim.rv.states[s_expr[3]])<<0;var result=a+b;set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var b=get_value(sim.rv.states[s_expr[3]])<<0;var result=a+b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU ADD with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (ADD). "}};sim.rv.behaviors["SUB"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var b=get_value(sim.rv.states[s_expr[3]])<<0;var result=a-b;set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var b=get_value(sim.rv.states[s_expr[3]])<<0;var result=a-b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU SUB with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (SUB). "}};sim.rv.behaviors["MUL"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var b=get_value(sim.rv.states[s_expr[3]])<<0;var result=a*b;set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var b=get_value(sim.rv.states[s_expr[3]])<<0;var result=a*b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU MUL with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (MUL). "}};sim.rv.behaviors["DIV"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var b=get_value(sim.rv.states[s_expr[3]])<<0;if(0==b){set_value(sim.rv.states[s_expr[1]],0);sim.rv.internal_states.alu_flags.flag_n=0;sim.rv.internal_states.alu_flags.flag_z=1;return}var result=Math.floor(a/b);set_value(sim.rv.states[s_expr[1]],result);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var b=get_value(sim.rv.states[s_expr[3]])<<0;if(0==b){return"ALU DIV zero by zero (oops!). "}var result=Math.floor(a/b);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU DIV with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (DIV). "}};sim.rv.behaviors["MOD"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var b=get_value(sim.rv.states[s_expr[3]])<<0;if(0==b){set_value(sim.rv.states[s_expr[1]],0);sim.rv.internal_states.alu_flags.flag_n=0;sim.rv.internal_states.alu_flags.flag_z=1;return}var result=a%b;set_value(sim.rv.states[s_expr[1]],result);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var b=get_value(sim.rv.states[s_expr[3]])<<0;if(0==b){return"ALU MOD zero by zero (oops!). "}var result=a%b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU MOD with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (MOD). "}};sim.rv.behaviors["LUI"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.rv.states[s_expr[2]])<<16;set_value(sim.rv.states[s_expr[1]],result);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var result=get_value(sim.rv.states[s_expr[2]])<<16;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Load Upper Immediate with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (LUI). "}};sim.rv.behaviors["ADDU"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])>>>0;var b=get_value(sim.rv.states[s_expr[3]])>>>0;var result=a+b;set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])>>>0;var b=get_value(sim.rv.states[s_expr[3]])>>>0;var result=a+b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU ADDU with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (ADDU). "}};sim.rv.behaviors["SUBU"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])>>>0;var b=get_value(sim.rv.states[s_expr[3]])>>>0;var result=a-b;set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])>>>0;var b=get_value(sim.rv.states[s_expr[3]])>>>0;var result=a-b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU SUBU with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (SUBU). "}};sim.rv.behaviors["MULU"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])>>>0;var b=get_value(sim.rv.states[s_expr[3]])>>>0;var result=a*b;set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])>>>0;var b=get_value(sim.rv.states[s_expr[3]])>>>0;var result=a*b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU MULU with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (MULU). "}};sim.rv.behaviors["DIVU"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])>>>0;var b=get_value(sim.rv.states[s_expr[3]])>>>0;if(0==b){set_value(sim.rv.states[s_expr[1]],0);sim.rv.internal_states.alu_flags.flag_n=0;sim.rv.internal_states.alu_flags.flag_z=1;return}var result=Math.floor(a/b);set_value(sim.rv.states[s_expr[1]],result);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])>>>0;var b=get_value(sim.rv.states[s_expr[3]])>>>0;if(0==b){return"ALU DIVU zero by zero (oops!). "}var result=Math.floor(a/b);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU DIVU with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (DIVU). "}};sim.rv.behaviors["FADD"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]]);var b=get_value(sim.rv.states[s_expr[3]]);var result=hex2float(a)+hex2float(b);set_value(sim.rv.states[s_expr[1]],float32_to_uint(result));sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]]);var b=get_value(sim.rv.states[s_expr[3]]);var result=hex2float(a)+hex2float(b);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU FADD with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (FADD). "}};sim.rv.behaviors["FSUB"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]]);var b=get_value(sim.rv.states[s_expr[3]]);var result=hex2float(a)-hex2float(b);set_value(sim.rv.states[s_expr[1]],float32_to_uint(result));sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]]);var b=get_value(sim.rv.states[s_expr[3]]);var result=hex2float(a)-hex2float(b);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU FSUB with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (FSUB). "}};sim.rv.behaviors["FMUL"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]]);var b=get_value(sim.rv.states[s_expr[3]]);var result=hex2float(a)*hex2float(b);set_value(sim.rv.states[s_expr[1]],float32_to_uint(result));sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]]);var b=get_value(sim.rv.states[s_expr[3]]);var result=hex2float(a)*hex2float(b);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU FMUL with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (FMUL). "}};sim.rv.behaviors["FDIV"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]]);var b=get_value(sim.rv.states[s_expr[3]]);var result=hex2float(a)/hex2float(b);set_value(sim.rv.states[s_expr[1]],float32_to_uint(result));sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]]);var b=get_value(sim.rv.states[s_expr[3]]);var result=hex2float(a)-hex2float(b);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU FDIV with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (FDIV). "}};sim.rv.behaviors["FCVT"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])>>>0;var b=get_value(sim.rv.states[s_expr[3]]);var result=a;switch(b){case 1:result=hex2float(result);result=Math.trunc(result);break;case 2:result=hex2float(result);result=Math.round(result);break;case 4:result=result.toFixed(5);result=parseFloat(result);result=float2decimal(result);break;default:break}set_value(sim.rv.states[s_expr[1]],result);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])>>>0;var b=get_value(sim.rv.states[s_expr[3]]);var result=a;switch(b){case 1:result=hex2float(result);result=Math.trunc(result);break;case 2:result=hex2float(result);result=Math.round(result);break;case 4:result=result.toFixed(5);result=parseFloat(result);result=float2decimal(result);break;default:break}var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU FCVT with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (FCVT). "}};sim.rv.behaviors["FCLASS"]={nparameters:3,types:["E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])>>>0;var result=float_class(a);set_value(sim.rv.states[s_expr[1]],result);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[1]])>>>0;var result=float_class(a);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU FCLASS with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (FCLASS). "}};sim.rv.behaviors["PLUS1"]={nparameters:3,types:["E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var result=a+1;set_value(sim.rv.states[s_expr[1]],result>>>0)},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var result=a+1;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy to "+show_verbal(s_expr[1])+" "+show_verbal(s_expr[2])+" plus one with result "+show_value(result)+". "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" + 1"+" ("+show_value(result)+"). "}};sim.rv.behaviors["PLUS4"]={nparameters:3,types:["E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var result=a+4;set_value(sim.rv.states[s_expr[1]],result>>>0)},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var result=a+4;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy to "+show_verbal(s_expr[1])+" "+show_verbal(s_expr[2])+" plus four with result "+show_value(result)+". "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" + 4"+" ("+show_value(result)+"). "}};sim.rv.behaviors["SET_TT"]={nparameters:3,types:["E","I"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[1]])<<0;var b=parseInt(s_expr[2]);var m=Math.pow(2,b);var r=a|m;set_value(sim.rv.states[s_expr[1]],r);update_cpu_bus_fire(r,b)},verbal:function(s_expr){return""}};sim.rv.behaviors["RST_TT"]={nparameters:3,types:["E","I"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[1]])<<0;var b=parseInt(s_expr[2]);var m=Math.pow(2,b);var r=a&~m;set_value(sim.rv.states[s_expr[1]],r);update_cpu_bus_fire(r,b)},verbal:function(s_expr){return""}};sim.rv.behaviors["MBIT"]={nparameters:5,types:["X","X","I","I"],operation:function(s_expr){var sim_elto_dst=get_reference(s_expr[1]);var sim_elto_org=get_reference(s_expr[2]);var offset=parseInt(s_expr[3]);var size=parseInt(s_expr[4]);var n1=get_value(sim_elto_org).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(offset+size-1),size);set_value(sim_elto_dst,parseInt(n2,2))},verbal:function(s_expr){var sim_elto_dst=get_reference(s_expr[1]);var sim_elto_org=get_reference(s_expr[2]);var offset=parseInt(s_expr[3]);var size=parseInt(s_expr[4]);var n1=get_value(sim_elto_org).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(offset+size-1),size);var n3=parseInt(n2,2);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from "+show_verbal(s_expr[2])+" to "+show_verbal(s_expr[1])+" value "+show_value(n3)+" (copied "+size+" bits from bit "+offset+"). "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" ("+show_value(n3)+", "+size+" bits from bit "+offset+"). "}};sim.rv.behaviors["MBIT_SN"]={nparameters:5,types:["S","E","E","I"],operation:function(s_expr){var base=0;var r=s_expr[3].split("/");if(1==r.length)base=get_value(sim.rv.states[s_expr[3]]);else if(typeof sim.rv.states[r[0]].value[r[1]]!="undefined")base=sim.rv.states[r[0]].value[r[1]];else if(typeof sim.rv.signals[r[1]].default_value!="undefined")base=sim.rv.signals[r[1]].default_value;else if(typeof sim.rv.states[r[1]].default_value!="undefined")base=sim.rv.states[r[1]].default_value;else ws_alert("WARN: undefined state/field pair -> "+r[0]+"/"+r[1]);var offset=parseInt(s_expr[4]);var n1=get_value(sim.rv.states[s_expr[2]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;var n3=n2.substr(31-(base+offset-1),offset);set_value(sim.rv.signals[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){var base=0;var r=s_expr[3].split("/");if(1==r.length)base=get_value(sim.rv.states[s_expr[3]]);else if(typeof sim.rv.states[r[0]].value[r[1]]!="undefined")base=sim.rv.states[r[0]].value[r[1]];else if(typeof sim.rv.signals[r[1]].default_value!="undefined")base=sim.rv.signals[r[1]].default_value;else if(typeof sim.rv.states[r[1]].default_value!="undefined")base=sim.rv.states[r[1]].default_value;else ws_alert("WARN: undefined state/field pair -> "+r[0]+"/"+r[1]);var offset=parseInt(s_expr[4]);var n1=get_value(sim.rv.states[s_expr[2]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;var n3=n2.substr(31-(base+offset-1),offset);var from_elto="";if(1==r.length)from_elto=show_verbal(s_expr[3]);else from_elto=show_verbal(s_expr[2])+"["+r[1]+"] ";var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from "+from_elto+"into "+show_verbal(s_expr[1])+" "+"value "+parseInt(n3,2)+". "}return show_verbal(s_expr[1])+" = "+from_elto+" ("+parseInt(n3,2)+").
"}};sim.rv.behaviors["SBIT_SIGNAL"]={nparameters:4,types:["X","I","I"],operation:function(s_expr){sim_elto_dst=get_reference(s_expr[1]);var new_value=sim_elto_dst.value;var mask=1<>>0)},verbal:function(s_expr){sim_elto_dst=get_reference(s_expr[1]);var new_value=sim_elto_dst.value;var mask=1<>>0)}};sim.rv.behaviors["UPDATE_FLAG"]={nparameters:4,types:["X","X","I"],operation:function(s_expr){sim_elto_org=get_reference(s_expr[2]);sim_elto_dst=get_reference(s_expr[1]);var new_value=sim_elto_dst.value&~(1<>>0)},verbal:function(s_expr){sim_elto_org=get_reference(s_expr[2]);sim_elto_dst=get_reference(s_expr[1]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Update "+show_verbal(s_expr[2])+" to value "+sim_elto_org.value+". "}return show_verbal(s_expr[1])+"."+show_verbal(s_expr[3])+" = "+sim_elto_org.value+". "}};sim.rv.behaviors["MBITS"]={nparameters:8,types:["E","I","E","S","S","I","S"],operation:function(s_expr){var offset=parseInt(sim.rv.signals[s_expr[4]].value);var size=parseInt(sim.rv.signals[s_expr[5]].value);var n1=get_value(sim.rv.states[s_expr[3]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(offset+size-1),size);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;if("1"==sim.rv.signals[s_expr[7]].value&&"1"==n2.substr(0,1)){n3="11111111111111111111111111111111".substring(0,32-n2.length)+n2}set_value(sim.rv.states[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){var offset=parseInt(sim.rv.signals[s_expr[4]].value);var size=parseInt(sim.rv.signals[s_expr[5]].value);var n1=get_value(sim.rv.states[s_expr[3]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(offset+size-1),size);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;if("1"==sim.rv.signals[s_expr[7]].value&&"1"==n2.substr(0,1)){n3="11111111111111111111111111111111".substring(0,32-n2.length)+n2}n1=parseInt(n3,2);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return" Copy from "+show_verbal(s_expr[3])+" to "+show_verbal(s_expr[1])+" value "+show_value(n1)+" (copied "+size+" bits from bit "+offset+"). "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[3])+" ("+show_value(n1)+", "+size+" bits from bit "+offset+"). "}};sim.rv.behaviors["DECO_IMM"]={nparameters:8,types:["E","I","E","S","S","I","S"],operation:function(s_expr){var oi=decode_instruction(sim.rv.internal_states.FIRMWARE,sim.rv.ctrl_states.ir,get_value(sim.rv.states["REG_IR"]));var bits=[];var startbit;var stopbit;for(var i=0;i=0;i--){for(var j=31-bits[i][0];j<=31-bits[i][1];j++){n2+=n1[j]}}n2="00000000000000000000000000000000".substring(0,32-n2.length)+n2;n2=n2.substr(31-(size-1),size);n2=n2+"0".repeat(offset);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;if("1"==sim.rv.signals[s_expr[7]].value&&"1"==n2.substr(0,1)){n3="11111111111111111111111111111111".substring(0,32-n2.length)+n2}set_value(sim.rv.states[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){return"Generate immediate value"}};sim.rv.behaviors["BSEL"]={nparameters:6,types:["E","I","I","E","I"],operation:function(s_expr){var posd=parseInt(s_expr[2]);var poso=parseInt(s_expr[5]);var len=parseInt(s_expr[3]);var n1=get_value(sim.rv.states[s_expr[4]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(poso+len)+1,len);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var n4="00000000000000000000000000000000".substr(0,posd);n3=n3+n4;set_value(sim.rv.states[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){var posd=parseInt(s_expr[2]);var len=parseInt(s_expr[3]);var poso=parseInt(s_expr[5]);var n1=get_value(sim.rv.states[s_expr[4]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(poso+len)+1,len);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var n4="00000000000000000000000000000000".substr(0,posd);n3=n3+n4;var n5=parseInt(n3,2);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from "+show_verbal(s_expr[4])+" to "+show_verbal(s_expr[1])+" value "+show_value(n5)+" (copied "+len+" bits, from bit "+poso+" of "+s_expr[4]+" to bit "+posd+" of "+s_expr[1]+"). "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[4])+" ("+show_value(n5)+", "+len+" bits, from bit "+poso+" of "+s_expr[4]+" to bit "+posd+" of "+s_expr[1]+"). "}};sim.rv.behaviors["BWSEL"]={nparameters:7,types:["E","E","I","I","I","S"],operation:function(s_expr){var posd=parseInt(s_expr[3]);var poso=parseInt(s_expr[4]);var len=parseInt(s_expr[5]);var sign_ext=sim.rv.signals[s_expr[6]].value;var n1=get_value(sim.rv.states[s_expr[2]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(poso+len)+1,len);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var n4="00000000000000000000000000000000".substr(0,posd);n3=n3+n4;if(sign_ext){var s1=n2;var s2="00000000000000000000000000000000".substring(0,32-s1.length)+s1;var s3=s2.substr(31-(len-1),31);var s4=s3;if("1"==s2[31-(len-1)]){s4="11111111111111111111111111111111".substring(0,32-s3.length)+s4}set_value(sim.rv.states[s_expr[1]],parseInt(s4,2))}else{n3="00000000000000000000000000000000".substring(0,32-n3.length)+n3;set_value(sim.rv.states[s_expr[1]],parseInt(n3,2))}},verbal:function(s_expr){var posd=parseInt(s_expr[3]);var poso=parseInt(s_expr[4]);var len=parseInt(s_expr[5]);var sign_ext=sim.rv.signals[s_expr[6]].value;var n1=get_value(sim.rv.states[s_expr[2]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(poso+len)+1,len);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var n4="00000000000000000000000000000000".substr(0,posd);n3=n3+n4;if(sign_ext){var s1=n2;var s2="00000000000000000000000000000000".substring(0,32-s1.length)+s1;var s3=s2.substr(31-(len-1),31);var s4=s3;if("1"==s2[31-(len-1)]){s4="11111111111111111111111111111111".substring(0,32-s3.length)+s4}var value=parseInt(s4,2);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from "+show_verbal(s_expr[2])+" to "+show_verbal(s_expr[1])+" value "+show_value(value)+ +" (copied "+len+" bits, from bit "+poso+" to bit "+(posd+len)+" with sign extension)."}else{return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" ("+show_value(value)+", "+len+" bits, from bit "+poso+" of "+s_expr[2]+" to bit "+(posd+8)+" of "+s_expr[1]+"). "}}else{var value=parseInt(n3,2);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from "+show_verbal(s_expr[2])+" to "+show_verbal(s_expr[1])+" value "+show_value(value)+ +" (copied "+len+" bits, from bit "+poso+" to bit "+(posd+len)+" without sign extension)."}else{return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" ("+show_value(value)+", "+len+" bits, from bit "+poso+" of "+s_expr[2]+" to bit "+(posd+8)+" of "+s_expr[1]+"). "}}}};sim.rv.behaviors["EXT_SIG"]={nparameters:3,types:["E","I"],operation:function(s_expr){var n1=get_value(sim.rv.states[s_expr[1]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;var n3=n2.substr(31-s_expr[2],31);var n4=n3;if("1"==n2[31-s_expr[2]]){n4="11111111111111111111111111111111".substring(0,32-n3.length)+n4}set_value(sim.rv.states[s_expr[1]],parseInt(n4,2))},verbal:function(s_expr){var n1=get_value(sim.rv.states[s_expr[1]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;var n3=n2.substr(31-s_expr[2],31);var n4=n3;if("1"==n2[31-s_expr[2]]){n4="11111111111111111111111111111111".substring(0,32-n3.length)+n4}var n5=parseInt(n4,2);return"Sign Extension with value "+show_value(n5)+". "}};sim.rv.behaviors["MOVE_BITS"]={nparameters:5,types:["S","I","I","S"],operation:function(s_expr){var posd=parseInt(s_expr[2]);var poso=0;var len=parseInt(s_expr[3]);var n1=sim.rv.signals[s_expr[4]].value.toString(2);n1="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n1=n1.substr(31-poso-len+1,len);var n2=sim.rv.signals[s_expr[1]].value.toString(2);n2="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var m1=n2.substr(0,32-(posd+len));var m2=n2.substr(31-posd+1,posd);var n3=m1+n1+m2;set_value(sim.rv.signals[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){return""}};sim.rv.behaviors["MOVE_BITSE"]={nparameters:6,types:["S","I","I","E","I"],operation:function(s_expr){var posd=parseInt(s_expr[2]);var poso=parseInt(s_expr[5]);var len=parseInt(s_expr[3]);var n1=get_value(sim.rv.states[s_expr[4]]).toString(2);n1="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n1=n1.substr(31-poso-len+1,len);var n2=sim.rv.signals[s_expr[1]].value.toString(2);n2="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var m1=n2.substr(0,32-(posd+len));var m2=n2.substr(31-posd+1,posd);var n3=m1+n1+m2;set_value(sim.rv.signals[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){return""}};sim.rv.behaviors["READ_IM"]={nparameters:1,operation:function(s_expr){var address=get_value(sim.rv.states["REG_PC"]);var clk=get_value(sim.rv.states["CLK"]);var remain=get_value(sim.rv.internal_states.MP_wc);if(typeof sim.rv.events.mem[clk-1]!="undefined"&&sim.rv.events.mem[clk-1]>0){remain=sim.rv.events.mem[clk-1]-1}var first_time=typeof sim.rv.events.mem[clk]=="undefined";sim.rv.events.mem[clk]=remain;if(remain>0){return}address=address&4294967292;var value=main_memory_getvalue(sim.rv.internal_states.MP,address);var full_redraw=false;if(typeof value==="undefined"){value=0;full_redraw=true}show_main_memory(sim.rv.internal_states.MP,address,full_redraw,false);if(first_time&&sim.rv.internal_states.CM.length>0){cache_memory_access(sim.rv.internal_states.CM[0],address,"read",clk)}var ins=main_memory_getvalue(sim.rv.internal_states.MP,address);if(typeof ins==="undefined")ins=0;set_value(sim.rv.states["RDATA"],ins)},verbal:function(s_expr){var verbal="";var address=get_value(sim.rv.states["REG_PC"]);var value=main_memory_getvalue(sim.rv.internal_states.MP,address);if(typeof value==="undefined")value=0;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){verbal="Try to read an instruction from Instruction Memory "+"at address 0x"+address.toString(16)+" with value 0x"+value.toString(16)+". ";return verbal}verbal="Memory output = 0x"+value.toString(16)+" (Read an instruction from Instruction Memory"+" at address 0x"+address.toString(16)+"). ";return verbal}};sim.rv.behaviors["DECO"]={nparameters:1,operation:function(s_expr){sim.rv.states["INEX"].value=0;var oi=decode_instruction(sim.rv.internal_states.FIRMWARE,sim.rv.ctrl_states.ir,get_value(sim.rv.states["REG_IR"]));if(null==oi.oinstruction){if(oi.cop_code!==undefined){ws_alert("ERROR: undefined instruction code in IR ("+"co:"+oi.op_code.toString(2)+", "+"cop:"+oi.cop_code.toString(2)+")")}else if(oi.eoc!==undefined){ws_alert("ERROR: undefined instruction code in IR ("+"co:"+oi.op_code.toString(2)+", "+"eoc:"+oi.eoc.toString(2)+")")}sim.rv.states["ROM_MUXA"].value=0;sim.rv.states["INEX"].value=1;return-1}var rom_addr=oi.op_code<<6;if(oi.oinstruction.cop!==undefined){rom_addr=rom_addr+oi.cop_code}else if(oi.oinstruction.eoc!==undefined){rom_addr=rom_addr+oi.eoc}if(typeof sim.rv.internal_states["ROM"][rom_addr]=="undefined"){ws_alert("ERROR: undefined rom address "+rom_addr+" in firmware");sim.rv.states["ROM_MUXA"].value=0;return-1}sim.rv.states["ROM_MUXA"].value=sim.rv.internal_states["ROM"][rom_addr];var val=get_value(sim.rv.states["DECO_INS"]);set_value(sim.rv.states["DECO_INS"],val+1);var pc=get_value(sim.rv.states["REG_PC"])-4;var decins=get_deco_from_pc(pc);set_value(sim.rv.states["REG_IR_DECO"],decins);show_dbg_ir(get_value(sim.rv.states["REG_IR_DECO"]))},verbal:function(s_expr){return"Decode instruction. "}};sim.rv.behaviors["FIRE"]={nparameters:2,types:["S"],operation:function(s_expr){if(sim.rv.internal_states.fire_stack.indexOf(s_expr[1])!=-1){return}sim.rv.internal_states.fire_stack.push(s_expr[1]);update_draw(sim.rv.signals[s_expr[1]],sim.rv.signals[s_expr[1]].value);if("L"==sim.rv.signals[s_expr[1]].type){update_state(s_expr[1])}sim.rv.internal_states.fire_stack.pop(s_expr[1])},verbal:function(s_expr){return""}};sim.rv.behaviors["FIRE_IFSET"]={nparameters:3,types:["S","I"],operation:function(s_expr){if(get_value(sim.rv.signals[s_expr[1]])!=parseInt(s_expr[2])){return}sim.rv.behaviors["FIRE"].operation(s_expr)},verbal:function(s_expr){return""}};sim.rv.behaviors["FIRE_IFCHANGED"]={nparameters:3,types:["S","X"],operation:function(s_expr){sim_elto=get_reference(s_expr[2]);if(sim_elto.changed==false){return}sim.rv.behaviors["FIRE"].operation(s_expr)},verbal:function(s_expr){return""}};sim.rv.behaviors["RESET_CHANGED"]={nparameters:2,types:["X"],operation:function(s_expr){sim_elto=get_reference(s_expr[1]);sim_elto.changed=false},verbal:function(s_expr){return""}};sim.rv.behaviors["CLOCK"]={nparameters:1,operation:function(s_expr){var new_maddr=null;var mcelto=null;var t0=performance.now();var val=get_value(sim.rv.states["CLK"]);set_value(sim.rv.states["CLK"],val+1);set_value(sim.rv.states["TTCPU"],0);new_maddr=get_value(sim.rv.states["REG_MICROADDR"]);mcelto=sim.rv.internal_states["MC"][new_maddr];if(typeof mcelto!=="undefined"&&false==mcelto.is_native){for(var i=0;i>>0},set_value:function(elto,value){var origin="";var r_value=main_memory_get_program_counter();if(r_value!=null){origin="PC=0x"+r_value.toString(16)}var melto={value:value>>>0,source_tracking:[origin],comments:null};var valref=main_memory_set(sim.rv.internal_states.MP,elto,melto);show_main_memory(sim.rv.internal_states.MP,elto,typeof valref==="undefined",true);return value}};sim.rv.internal_states.segments={};sim.rv.internal_states.MP_wc=0;sim.rv.internal_states.MP={};sim.rv.internal_states.CM_cfg=[];sim.rv.internal_states.CM=[];sim.rv.behaviors.MEM_READ={nparameters:5,types:["E","E","S","E"],operation:function(s_expr){var address="0x"+get_value(sim.rv.states[s_expr[1]]).toString(16);var dbvalue=get_value(sim.rv.states[s_expr[2]]);var bw=sim.rv.signals[s_expr[3]].value;var clk=get_value(sim.rv.states[s_expr[4]]);var remain=get_value(sim.rv.internal_states.MP_wc);if(typeof sim.rv.events.mem[clk-1]!="undefined"&&sim.rv.events.mem[clk-1]>0){remain=sim.rv.events.mem[clk-1]-1}var first_time=typeof sim.rv.events.mem[clk]=="undefined";sim.rv.events.mem[clk]=remain;if(remain>0){return}address=address&4294967292;var value=main_memory_getvalue(sim.rv.internal_states.MP,address);var full_redraw=false;if(typeof value==="undefined"){value=0;full_redraw=true}if(bw==1){var byte_s=0;dbvalue=main_memory_fusionvalues(dbvalue,value,byte_s)}else if(bw==2){var byte_s=4;dbvalue=main_memory_fusionvalues(dbvalue,value,byte_s)}else{dbvalue=value}set_value(sim.rv.states[s_expr[2]],dbvalue>>>0);show_main_memory(sim.rv.internal_states.MP,address,full_redraw,false);if(first_time&&sim.rv.internal_states.CM.length>0){cache_memory_access(sim.rv.internal_states.CM[0],address,"read",clk)}},verbal:function(s_expr){var verbal="";var address="0x"+get_value(sim.rv.states[s_expr[1]]).toString(16);var dbvalue=get_value(sim.rv.states[s_expr[2]]);var bw=sim.rv.signals[s_expr[3]].value;var clk=get_value(sim.rv.states[s_expr[4]]);var bw_type="word";if(bw==1)bw_type="byte";else if(bw==2)bw_type="half";var value=main_memory_getvalue(sim.rv.internal_states.MP,address);if(typeof value==="undefined")value=0;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){verbal="Try to read a "+bw_type+" from memory "+"at address "+address+" with value 0x"+value.toString(16)+". "}verbal="Memory output = 0x"+value.toString(16)+" (Read a "+bw_type+" from "+address+"). ";return verbal}};sim.rv.behaviors.MEM_WRITE={nparameters:5,types:["E","E","S","E"],operation:function(s_expr){var address="0x"+get_value(sim.rv.states[s_expr[1]]).toString(16);var dbvalue=get_value(sim.rv.states[s_expr[2]]);var bw=sim.rv.signals[s_expr[3]].value;var clk=get_value(sim.rv.states[s_expr[4]]);var remain=get_value(sim.rv.internal_states.MP_wc);if(typeof sim.rv.events.mem[clk-1]!="undefined"&&sim.rv.events.mem[clk-1]>0){remain=sim.rv.events.mem[clk-1]-1}var first_time=typeof sim.rv.events.mem[clk]=="undefined";sim.rv.events.mem[clk]=remain;if(remain>0){return}address=address&4294967292;var value=main_memory_getvalue(sim.rv.internal_states.MP,address);var full_redraw=false;if(typeof value==="undefined"){value=0;full_redraw=true}if(bw==1){var byte_s=0;value=main_memory_fusionvalues(value,dbvalue,byte_s)}else if(bw==2){var byte_s=4;value=main_memory_fusionvalues(value,dbvalue,byte_s)}else{var byte_s=12;value=main_memory_fusionvalues(value,dbvalue,byte_s)}var origin="";var r_value=main_memory_get_program_counter();if(r_value!=null){origin="PC=0x"+r_value.toString(16)}var melto={value:value>>>0,source_tracking:[origin],comments:null};var valref=main_memory_set(sim.rv.internal_states.MP,address,melto);show_main_memory(sim.rv.internal_states.MP,address,full_redraw,true);if(first_time&&sim.rv.internal_states.CM.length>0){cache_memory_access(sim.rv.internal_states.CM[0],address,"write",clk)}},verbal:function(s_expr){var verbal="";var address="0x"+get_value(sim.rv.states[s_expr[1]]).toString(16);var dbvalue=get_value(sim.rv.states[s_expr[2]]);var bw=sim.rv.signals[s_expr[3]].value;var clk=get_value(sim.rv.states[s_expr[4]]);var bw_type="word";if(bw==1)bw_type="byte";else if(bw==2)bw_type="half";var value=main_memory_getvalue(sim.rv.internal_states.MP,address);if(typeof value==="undefined")value=0;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){verbal="Try to write a "+bw_type+" to memory "+"at address "+address+" with value "+value.toString(16)+". "}verbal="Memory["+address+"] = "+"0x"+value.toString(16)+" (Write a "+bw_type+" to "+address+"). ";return verbal}};sim.rv.behaviors.MEMORY_RESET={nparameters:1,operation:function(s_expr){sim.rv.events.mem={}},verbal:function(s_expr){return"Reset main memory (all values will be zeroes). "}};sim.rv.elements.memory={name:"Main memory",description:"Main memory subsystem",type:"subcomponent",belongs:"MEMORY",states:{addr:{ref:"M3_ALU"},wdata:{ref:"REG_OUT"},rdata:{ref:"DM_BS"}},signals:{wbe:{ref:"WBE"},dmr:{ref:"DMR"},dmw:{ref:"DMW"}},states_inputs:["addr","wdata"],states_outputs:["rdata"],signals_inputs:["wbe","dmr","dmw"],signals_output:[]};function frm_nextToken(context){var tok="";var first="";var last="";var token_type="";while("# \t\n\r".indexOf(context.text[context.t])!=-1&&context.t0)line2=context.newlines[context.newlines.length-1]+1;var line1=0;if(context.newlines.length>1)line1=context.newlines[context.newlines.length-2]+1;var lowI=line1;var highI=Math.min(context.t-1,line2+32);for(;typeof context.text[highI+1]!="undefined"&&context.text[highI+1]!="\n";highI++);var line3=highI+2;highI++;for(;typeof context.text[highI+1]!="undefined"&&context.text[highI+1]!="\n";highI++);highI++;context.error="
"+""+"...\n";for(var i=lowI;i"+"(*) "+i18n_get_TagFor("compiler","PROBLEM AROUND LINE")+" "+context.line+":
"+msgError+".
";simcore_ga("compile","compile.error","compile.error."+msgError);return context}function frm_getLabelContext(context){return{t:context.t,line:context.line,newlines:context.newlines.slice()}}function frm_setLabelContext(context,labelContext){context.t=labelContext.t;context.line=labelContext.line;context.newlines=labelContext.newlines}function frm_getComments(context){return context.comments.join("\n")}function frm_resetComments(context){context.comments=[]}function frm_nextNative(context){var first=context.t;var last=context.t;var braces=1;while(context.t=Math.pow(2,simhw_sim_signal(nombre_tok).nbits)){return frm_langError(context,i18n_get_TagFor("compiler","OUT OF RANGE")+"'"+frm_getToken(context)+"'")}frm_nextToken(context)}if(frm_isToken(context,",")){frm_nextToken(context)}}var acc_cmt=frm_getComments(context);microcomments.push(acc_cmt);frm_resetComments(context);microprograma.push(microInstruccionAux);context.contadorMC++;frm_nextToken(context);if(frm_isToken(context,","))frm_nextToken(context)}if(microprograma.length===0){return frm_langError(context,i18n_get_TagFor("compiler","EMPTY MICROCODE"))}frm_nextToken(context);return{NATIVE:"",microprograma:microprograma,microcomments:microcomments}}function read_native(context){var microprograma=[];var microcomments=[];if(!frm_isToken(context,"{")){return frm_langError(context,i18n_get_TagFor("compiler","OPEN BRACE NOT FOUND"))}frm_nextNative(context);var native_code=frm_getToken(context);microprograma.push({});microcomments.push("");frm_nextToken(context);return{NATIVE:native_code,microprograma:microprograma,microcomments:microcomments}}function firm_begin_read(context){var instruccionAux={};instruccionAux.name=frm_getToken(context);instruccionAux["mc-start"]=context.contadorMC;instruccionAux["is_native"]=false;frm_nextToken(context);if(frm_isToken(context,",")){frm_nextToken(context)}if(frm_isToken(context,"native")){instruccionAux["is_native"]=true;frm_nextToken(context);if(frm_isToken(context,",")){frm_nextToken(context)}context.etiquetas[context.contadorMC]="fetch"}if(true==instruccionAux.is_native)ret=read_native(context);else ret=firm_mcode_signals_read(context);if(typeof ret.error!="undefined"){return ret}instruccionAux.signature="begin";instruccionAux.signatureGlobal="begin";instruccionAux.signatureUser="begin";instruccionAux.signatureRaw="begin";instruccionAux.NATIVE=ret.NATIVE;instruccionAux.microcode=ret.microprograma;instruccionAux.microcomments=ret.microcomments;context.instrucciones.push(instruccionAux);context.contadorMC=context.contadorMC+9;return{}}function firm_pseudoinstructions_read(context){frm_nextToken(context);if(!frm_isToken(context,"{")){return frm_langError(context,i18n_get_TagFor("compiler","OPEN BRACE NOT FOUND"))}frm_nextToken(context);while(!frm_isToken(context,"}")){var pseudoInstructionAux={};var pseudoInitial={};pseudoInitial.signature="";pseudoInitial.name="";pseudoInitial.fields=[];pseudoInitial.name=frm_getToken(context);pseudoInitial.signature=pseudoInitial.signature+frm_getToken(context)+",";frm_nextToken(context);while(!frm_isToken(context,"{")){var pseudoFieldAux={};pseudoFieldAux.name="";pseudoFieldAux.type="";pseudoFieldAux.indirect=false;if(frm_isToken(context,"(")){frm_nextToken(context);pseudoFieldAux.name+=frm_getToken(context);frm_nextToken(context);if(!frm_isToken(context,")")){return frm_langError(context,i18n_get_TagFor("compiler","CLOSE PAREN. NOT FOUND"))}frm_nextToken(context);pseudoFieldAux.indirect=true}else{pseudoFieldAux.name+=frm_getToken(context);frm_nextToken(context)}if(!frm_isToken(context,"=")){return frm_langError(context,i18n_get_TagFor("compiler","EQUAL NOT FOUND")+" (for name=type)")}frm_nextToken(context);pseudoFieldAux.type+=frm_getToken(context).replace("num","inm");switch(pseudoFieldAux.type){case"reg":case"inm":case"addr":case"address":break;default:return frm_langError(context,i18n_get_TagFor("compiler","INVALID PARAMETER")+pseudoFieldAux.type+"."+i18n_get_TagFor("compiler","ALLOWED PARAMETER"))}pseudoInitial.fields.push(pseudoFieldAux);if(pseudoFieldAux.indirect==true)pseudoInitial.signature+="("+frm_getToken(context)+"),";else pseudoInitial.signature+=frm_getToken(context)+",";frm_nextToken(context);if(frm_isToken(context,",")){frm_nextToken(context)}}frm_nextToken(context);pseudoInitial.signature=pseudoInitial.signature.substr(0,pseudoInitial.signature.length-1).replace(/num/g,"inm");pseudoInstructionAux.initial=pseudoInitial;var contPseudoFinish=0;var pseudoFinishAux={};pseudoFinishAux.signature="";var inStart=0;var cont=false;while(!frm_isToken(context,"}")){if(inStart==0){for(i=0;i32*parseInt(instruccionAux.nwords)-1){return frm_langError(context,i18n_get_TagFor("compiler","STARTBIT OoR")+"'"+frm_getToken(context)+"'")}frm_nextToken(context);if(!frm_isToken(context,",")){return frm_langError(context,i18n_get_TagFor("compiler","COMMA NOT FOUND"))}frm_nextToken(context);instruccionAux.fields[camposInsertados].stopbit=frm_getToken(context);var stop=parseInt(instruccionAux.fields[camposInsertados].stopbit);if(stop>32*parseInt(instruccionAux.nwords)){return frm_langError(context,i18n_get_TagFor("compiler","STOPBIT OoR")+"'"+frm_getToken(context)+"'")}for(i=stop;i<=start;i++){if(typeof instruccionAux.overlapping[i]!="undefined"){return frm_langError(context,i18n_get_TagFor("compiler","OVERLAPPING FIELD")+instruccionAux.fields[camposInsertados].name)}instruccionAux.overlapping[i]=1}frm_nextToken(context);if(!frm_isToken(context,")")){return frm_langError(context,i18n_get_TagFor("compiler","CLOSE PAREN. NOT FOUND"))}frm_nextToken(context);if(instruccionAux.fields[camposInsertados].type=="address"){if(frm_getToken(context)!="abs"&&frm_getToken(context)!="rel"){return frm_langError(context,i18n_get_TagFor("compiler","INCORRECT ADDRESSING"))}instruccionAux.fields[camposInsertados].address_type=frm_getToken(context);frm_nextToken(context)}if(frm_isToken(context,",")){frm_nextToken(context)}return{}}function firm_instruction_read_fixed_fields(context,instruccionAux,xr_info,all_ones_co){var ret={};frm_nextToken(context);if(!frm_isToken(context,"co")){return frm_langError(context,i18n_get_TagFor("compiler","NO CO FIELD"))}ret=firm_instruction_co_read(context,instruccionAux,xr_info,all_ones_co);if(typeof ret.error!="undefined"){return ret}if(frm_isToken(context,"cop")){ret=firm_instruction_cop_read(context,instruccionAux);if(typeof ret.error!="undefined"){return ret}}if(frm_isToken(context,"nwords")){ret=firm_instruction_nword_read(context,instruccionAux);if(typeof ret.error!="undefined"){return ret}}var campos=instruccionAux.fields;var firma=instruccionAux.signature;var firmaUsuario=instruccionAux.signatureUser;var firmaGlobal=instruccionAux.signatureGlobal;var camposInsertados=0;while(camposInsertados32*parseInt(instruccionAux.nwords)-1){return frm_langError(context,i18n_get_TagFor("compiler","STARTBIT OoR")+"'"+frm_getToken(context)+"'")}frm_nextToken(context);if(!frm_isToken(context,":")){return frm_langError(context,i18n_get_TagFor("compiler","COLON NOT FOUND"))}frm_nextToken(context);tmp_fields.stopbit=frm_getToken(context);var stop=parseInt(tmp_fields.stopbit);if(stop>32*parseInt(instruccionAux.nwords)){return frm_langError(context,i18n_get_TagFor("compiler","STOPBIT OoR")+"'"+frm_getToken(context)+"'")}frm_nextToken(context);if(!frm_isToken(context,")")){return frm_langError(context,i18n_get_TagFor("compiler","CLOSE PAREN. NOT FOUND"))}}else{frm_nextToken(context);if(!frm_isToken(context,"(")){return frm_langError(context,i18n_get_TagFor("compiler","OPEN PAREN. NOT FOUND"))}frm_nextToken(context);var start=frm_getToken(context);var stop=start;if(start>32*parseInt(instruccionAux.nwords)-1){return frm_langError(context,i18n_get_TagFor("compiler","STARTBIT OoR")+"'"+frm_getToken(context)+"'")}frm_nextToken(context);if(frm_isToken(context,":")){frm_nextToken(context);stop=frm_getToken(context);if(stop>32*parseInt(instruccionAux.nwords)){return frm_langError(context,i18n_get_TagFor("compiler","STOPBIT OoR")+"'"+frm_getToken(context)+"'")}frm_nextToken(context);if(frm_isToken(context,")")){tmp_fields.startbit=start;tmp_fields.stopbit=stop}}if(frm_isToken(context,"|")){var bits=[[start,stop]];var bits_aux=[];while(!frm_isToken(context,")")){frm_nextToken(context);if(frm_getToken(context)==")")continue;bits_aux[0]=frm_getToken(context);if(bits_aux[0]>32*parseInt(instruccionAux.nwords)){return frm_langError(context,i18n_get_TagFor("compiler","BIT OoR")+"'"+frm_getToken(context)+"'")}frm_nextToken(context);if(frm_getToken(context)==")"){bits.push([bits_aux[0],bits_aux[0]]);continue}if(!frm_isToken(context,":")&&!frm_isToken(context,"|")){return frm_langError(context,i18n_get_TagFor("compiler","COLON OR PIPE NOT FOUND"))}if(frm_isToken(context,":")){frm_nextToken(context);bits_aux[1]=frm_getToken(context);frm_nextToken(context)}else if(frm_isToken(context,"|")){bits_aux[1]=bits_aux[0]}if(bits_aux[1]>32*parseInt(instruccionAux.nwords)){return frm_langError(context,i18n_get_TagFor("compiler","BIT OoR")+"'"+frm_getToken(context)+"'")}bits.push([bits_aux[0],bits_aux[1]])}var total_bits=0;for(i=0;i100){return frm_langError(context,i18n_get_TagFor("compiler","MORE 100 FIELDS"))}if(auxValue=="co"){return frm_langError(context,i18n_get_TagFor("compiler","CO AS FIELD NAME"))}if(auxValue=="nwords"){return frm_langError(context,i18n_get_TagFor("compiler","NW AS FIELD NAME"))}}if(frm_isToken(context,"(")){firma=firma+",(";if(plus_found)firmaUsuario=firmaUsuario+"+(";else firmaUsuario=firmaUsuario+" (";frm_nextToken(context);if(!frm_isToken(context,",")&&!frm_isToken(context,"(")&&!frm_isToken(context,")")){var campoAux={};campoAux.name=frm_getToken(context);instruccionAux.fields.push(campoAux);instruccionAux.numeroCampos++;firma=firma+frm_getToken(context);firmaUsuario=firmaUsuario+frm_getToken(context);frm_nextToken(context)}else{return frm_langError(context,i18n_get_TagFor("compiler","MISSING TOKEN ON")+"'"+context.co_cop[instruccionAux.co].signature+"'")}if(frm_isToken(context,")")){firma=firma+")";firmaUsuario=firmaUsuario+")";frm_nextToken(context)}else{return frm_langError(context,i18n_get_TagFor("compiler","MISSING ) ON")+"'"+context.co_cop[instruccionAux.co].signature+"'")}}firma=firma+",";firmaUsuario=firmaUsuario+" "}firma=firma.substr(0,firma.length-1);firma=firma.replace(/,,/g,",");firmaUsuario=firmaUsuario.substr(0,firmaUsuario.length-1);firmaUsuario=firmaUsuario.replace(/ /g," ");instruccionAux.signature=firma;instruccionAux.signatureGlobal=firma;instruccionAux.signatureUser=firmaUsuario;instruccionAux.signatureRaw=firmaUsuario;if(2==context.version){ret=firm_instruction_read_fields_v2(context,instruccionAux,xr_info,all_ones_oc)}else{ret=firm_instruction_read_fixed_fields(context,instruccionAux,xr_info,all_ones_co)}if(typeof ret.error!="undefined"){return ret}ret={};if(true==instruccionAux.is_native)ret=read_native(context);else ret=firm_mcode_signals_read(context);if(typeof ret.error!="undefined")return ret;instruccionAux.NATIVE=ret.NATIVE;instruccionAux.microcode=ret.microprograma;instruccionAux.microcomments=ret.microcomments;context.instrucciones.push(instruccionAux);context.contadorMC=context.contadorMC+9;if(!frm_isToken(context,"}")){return frm_langError(context,i18n_get_TagFor("compiler","CLOSE BRACE NOT FOUND"))}frm_nextToken(context);return{}}function simlang_native_adapt_replaceSyscall(icode){var rc="";var me="";var ff="capi_print_char|capi_print_int|capi_print_float|capi_print_double|capi_print_string|"+"capi_read_char|capi_read_int|capi_read_float|capi_read_double|capi_read_string|"+"capi_sbrk|capi_exit";var re=new RegExp("("+ff+")\\(([^)]*)\\)","g");var match=re.exec(icode);while(match!==null){var f=match[1].trim();var p=match[2].trim().split(",");switch(f){case"capi_print_char":rc="// "+f+" \n"+"\tvar tmp1 = 0x000000FF & "+p[0]+" ;\n"+"\tset_screen_content(tmp1.toString()) ;\n";break;case"capi_print_int":rc="// "+f+" \n"+"\tset_screen_content("+p[0]+".toString()) ;\n";break;case"capi_print_float":rc="// "+f+" \n"+"\tvar tmp1 = hex2float("+p[0]+") ;\n"+"\tset_screen_content(tmp1.toString()) ;\n";break;case"capi_print_double":rc="// "+f+" \n"+"\tvar tmp1 = hex2float("+p[0]+") ;\n"+"\tset_screen_content(tmp1.toString()) ;\n";break;case"capi_print_string":rc="// "+f+" \n"+'\tvar tmp1 = "" ;\n'+'\tvar tmp2 = simcore_native_get_value("MEMORY", '+p[0]+") ;\n"+"\tfor (var k="+p[0]+"+1; (tmp2 !== 0) && (k<8*1024); k++) {\n"+"\t tmp1 += tmp2.toString() ;\n"+'\t tmp2 = simcore_native_get_value("MEMORY", k) ;\n'+"\t} ;\n"+"\tset_screen_content(tmp1) ;\n";break;case"capi_read_char":rc="// "+f+" \n"+"\tvar tmp1 = get_screen_content() ;\n"+"\tvar "+p[0]+" = 0x000000FF & parseInt(tmp1) ;\n";break;case"capi_read_int":rc="// "+f+" \n"+"\tvar tmp1 = get_screen_content() ;\n"+"\tvar "+p[0]+" = parseInt(tmp1) ;\n";break;case"capi_read_float":rc="// "+f+" \n"+"\tvar tmp1 = get_screen_content() ;\n"+"\tvar "+p[0]+" = parseFloat(tmp1) ;\n";break;case"capi_read_double":rc="// "+f+" \n"+"\tvar tmp1 = get_screen_content() ;\n"+"\tvar "+p[0]+" = parseFloat(tmp1) ;\n";break;case"capi_read_string":rc="// "+f+" \n"+"\tvar tmp1 = get_screen_content() ;\n"+"\tfor (var k=0; k<"+p[1]+"; k++) {\n"+'\t simcore_native_set_value("MEMORY", '+p[0]+"+k, tmp1[k]) ;\n"+"\t} ;\n";break;case"capi_sbrk":rc="// "+f+" \n"+"// TODO: _sbrk_("+p[0]+", "+p[1]+");\n";break;case"capi_exit":rc="// "+f+" \n"+"// exit by setting P.C. register outside text segment\n"+"\tvar pc_name = simhw_sim_ctrlStates_get().pc.state ;\n"+'\tsimcore_native_set_value("CPU", pc_name, 0x00000000) ;\n';break;default:rc="// "+f+" \n"+"// unknown syscall\n";break}me=new RegExp(f+"\\(([^)]*)\\)","g");icode=icode.replace(me,rc);match=re.exec(icode)}return icode}function simlang_native_adapt_provideRegister(icode,reg_log,rf_phy,reg_phy){var re=new RegExp(reg_log,"g");if(icode.search(re)!=-1){icode="var "+reg_log+" = simcore_native_get_value('"+rf_phy+"', "+reg_phy+") ;\n"+icode+"\n"+"simcore_native_set_value('"+rf_phy+"', "+reg_phy+", "+reg_log+") ;\n"}return icode}function simlang_native_adapt_providePC(icode){var re=/PC/g;if(icode.search(re)!=-1){icode="var pc_name = simhw_sim_ctrlStates_get().pc.state ;\n"+"var PC = simcore_native_get_value('CPU', pc_name) ;\n"+icode+"simcore_native_set_value('CPU', pc_name, PC) ;\n"}return icode}function simlang_native_adapt_replaceIf(icode){var re=new RegExp("[iI][fF]\\s*\\(([^\\\\)]*)\\)\\s*{([^\\\\}]*)}\\s*[eE][lL][sS][eE]{[^}]*}\\s*","g");if(icode.search(re)!=-1){var match=re.exec(icode);try{icode=icode.replace(re,"\n")}catch(e){console.log("Syntax error that cause a run-time error: "+e.toString());console.log(match)}}return icode}function simlang_native_adapt_addInitialTabTab(lines_code){var code_lines;code_lines=lines_code.split("\n");code_lines=code_lines.map((function(x){return"\t\t"+x}));return code_lines.join("\n")}function simlang_native_adapt_instructionDefinition(lines_code){var code_lines=lines_code.split(";");if(code_lines.length===1&&!lines_code.trim().startsWith("if")){lines_code=lines_code+";\n"}lines_code=simlang_native_adapt_replaceSyscall(lines_code);lines_code=simlang_native_adapt_provideRegister(lines_code,"HI","CPU","'REG_RT2'");lines_code=simlang_native_adapt_provideRegister(lines_code,"LO","CPU","'REG_RT1'");lines_code=simlang_native_adapt_provideRegister(lines_code,"ra","BR","31");lines_code=simlang_native_adapt_providePC(lines_code);lines_code=simlang_native_adapt_addInitialTabTab(lines_code);return lines_code}function simlang_native_adapt_getField(j,rf,reg){return"\t\t"+"var f_"+reg+" = "+"simcore_native_get_field_from_ir(fields, "+j+") ;\n"+"\t\t"+"var "+reg+" = "+"simcore_native_get_value('"+rf+"', f_"+reg+") ;\n"}function simlang_native_adapt_setField(j,rf,reg){return"\t\t"+"simcore_native_set_value('"+rf+"', f_"+reg+", "+reg+");\n"}function simlang_native_adapt_headerField(fname,tname,start,stop){return"\t"+tname+"("+start+":"+stop+")="+fname+",\n"}function simlang_native_beginMicrocode(){var o="";o+="\n"+"#\n"+"# WepSIM (https://wepsim.github.io/wepsim/)\n"+"#\n"+"\n"+"firmware_version = 2\n"+"\n"+"##\n"+"## Microcode Section\n"+"##\n"+"\n"+"begin,\n"+"native\n"+"{\n"+" // (once) initialize BR2 as FP register file\n"+' if (typeof BR2 === "undefined")\n'+" {\n"+" BR2 = [] ;\n"+" FCSR = 0 ;\n"+" for (var i=0; i<32; i++)\n"+" {\n"+" BR2[i] = {\n"+' name:"R"+i,\n'+' verbal:"Register "+i,\n'+" visible:true,\n"+' nbits:"32",\n'+" value:0,\n"+" default_value:0,\n"+" draw_data:[]\n"+" } ;\n"+" }\n"+" }\n"+"\n"+" // fetch\n"+' var addr = simcore_native_get_value("CPU", "REG_PC") ;\n'+' var value = simcore_native_get_value("MEMORY", addr) ;\n'+"\n"+' simcore_native_set_value("CPU", "REG_IR", value) ;\n'+' simcore_native_set_value("CPU", "REG_PC", addr + 4) ;\n'+"\n"+" simcore_native_deco() ;\n"+" simcore_native_go_opcode() ;\n"+"}\n";return o}function simlang_native_adapt_instructionSet(instruction_list){var o="";var gfields=[];var sfields=[];var hfields=[];var io={};var line_signature="";var signature_names="";var signature_order="";for(var i=0;i> 32);\n"+"\t\t "+io.fields[j].name+"2 = "+io.fields[j].name+" >> 32;\n"+"\t\t"+"simcore_native_set_value('BR2', "+"f_"+io.fields[j].name+"+0, "+io.fields[j].name+"1);\n"+"\t\t"+"simcore_native_set_value('BR2', "+"f_"+io.fields[j].name+"+1, "+io.fields[j].name+"2);\n";break;case"inm":hfields[k]=simlang_native_adapt_headerField(io.fields[j].name,"inm",io.fields[j].startbit,io.fields[j].stopbit);gfields[k]="\t\t"+"var "+io.fields[j].name+" = "+"simcore_native_get_field_from_ir(fields, "+(k-1)+") ;\n\t";break}}var co_cop="\t"+"co=111111,"+"\n";var lines_code=simlang_native_adapt_instructionDefinition(io.definition);if(lines_code.trim()!==""){lines_code="\t\t"+"// instruction specific code"+"\n"+lines_code+"\n"}var gfields_str=gfields.join("");if(gfields_str.trim()!==""){gfields_str="\t\t"+"// get fields values..."+"\n"+gfields_str+"\n"}var sfields_str=sfields.join("");if(sfields_str.trim()!==""){sfields_str="\t\t"+"// set fields values..."+"\n"+sfields_str+"\n"}o+="\n"+line_signature+" {"+"\n"+co_cop+"\t"+"nwords="+io.nwords+","+"\n"+hfields.join("")+"\t"+"native,"+"\n"+"\t"+"{\n"+gfields_str+"\n"+lines_code+"\n"+sfields_str+"\n"+"\t\t"+"// go fetch"+"\n"+"\t\t"+"simcore_native_go_maddr(0);"+"\n"+"\t"+"}"+"\n"+"}\n"}return o}function simlang_native_registerSection(register_list){var o="";var d="";var index=0;for(index=0;index=last_oc){return frm_langError(context,i18n_get_TagFor("compiler","NO OC CODES"))}first_oc=parseInt(r.label_oc,2);curr_instruction.oc=r.label_oc;context.oc_eoc[r.label_oc].signature=curr_instruction.signature;if(r.label_eoc!==""){curr_instruction.eoc=r.label_eoc;context.oc_eoc[r.label_oc].eoc[r.label_eoc]=curr_instruction.signature;context.oc_eoc[r.label_oc].witheoc=true}}}else{var ir_co_length=6;if(typeof ir_info!=="undefined"){ir_co_length=ir_info.ir.default_eltos.co.length}var first_co=0;var last_co=Math.pow(2,ir_co_length)-1;var last_co_str=last_co.toString(2);var curr_instruction=null;for(i=0;i=last_co){return frm_langError(context,i18n_get_TagFor("compiler","NO CO CODES"))}first_co=parseInt(r.label_co,2);curr_instruction.co=r.label_co;context.co_cop[r.label_co].signature=curr_instruction.signature;if(r.label_cop!==""){curr_instruction.cop=r.label_cop;context.co_cop[r.label_co].cop[r.label_cop]=curr_instruction.signature;context.co_cop[r.label_co].withcop=true}}}var labelsFounded=0;if(context.labelsNotFound.length>0){for(i=0;i0){for(var j=0;j0){file+="registers"+"\n{\n";for(i=0;i=context.text.length}function asm_nextToken(context){var tok="";var first="";var last="";var token_type="";while("# \t\n\r".indexOf(context.text[context.t])!=-1&&context.t0)line2=context.newlines[context.newlines.length-1]+1;var line1=0;if(context.newlines.length>1)line1=context.newlines[context.newlines.length-2]+1;var lowI=line1;var highI=Math.min(context.t-1,line2+32);for(;typeof context.text[highI+1]!="undefined"&&context.text[highI+1]!="\n";highI++);var line3=highI+2;highI++;for(;typeof context.text[highI+1]!="undefined"&&context.text[highI+1]!="\n";highI++);highI++;context.error="
"+""+"...\n";for(var i=lowI;i"+"(*) "+i18n_get_TagFor("compiler","PROBLEM AROUND LINE")+" "+context.line+":
"+msgError+".
";simcore_ga("compile","compile.error","compile.error."+msgError);return context}function asm_getLabelContext(context){return{t:context.t,line:context.line,newlines:context.newlines.slice()}}function asm_setLabelContext(context,labelContext){context.t=labelContext.t;context.line=labelContext.line;context.newlines=labelContext.newlines}function asm_getComments(context){return context.comments.join("\n")}function asm_resetComments(context){context.comments=[]}sim_segments={".kdata":{name:".kdata",begin:0,end:255,color:"#FF99CC",kindof:"data"},".ktext":{name:".ktext",begin:256,end:4095,color:"#A9D0F5",kindof:"text"},".data":{name:".data",begin:4096,end:32767,color:"#FACC2E",kindof:"data"},".text":{name:".text",begin:32768,end:131071,color:"#BEF781",kindof:"text"},".stack":{name:".stack",begin:131071,end:1048576,color:"#F1F2A3",kindof:"stack"}};function segments_addr_within_text(address){return address>=sim_segments[".text"].begin&&address<=sim_segments[".text"].end||address>=sim_segments[".ktext"].begin&&address<=sim_segments[".ktext"].end}function segments_addr_within_data(address){return address>=sim_segments[".data"].begin&&address<=sim_segments[".data"].end||address>=sim_segments[".kdata"].begin&&address<=sim_segments[".kdata"].end}ws_directives={".kdata":{name:".kdata",kindof:"segment",size:0,attrs:["data"]},".ktext":{name:".ktext",kindof:"segment",size:0,attrs:["text"]},".data":{name:".data",kindof:"segment",size:0,attrs:["data"]},".text":{name:".text",kindof:"segment",size:0,attrs:["text"]},".byte":{name:".byte",kindof:"datatype",size:1,attrs:["numeric"]},".half":{name:".half",kindof:"datatype",size:2,attrs:["numeric"]},".word":{name:".word",kindof:"datatype",size:4,attrs:["numeric"]},".dword":{name:".dword",kindof:"datatype",size:8,attrs:["numeric"]},".float":{name:".float",kindof:"datatype",size:4,attrs:["numeric"]},".double":{name:".double",kindof:"datatype",size:8,attrs:["numeric"]},".ascii":{name:".ascii",kindof:"datatype",size:1,attrs:["string"]},".asciiz":{name:".asciiz",kindof:"datatype",size:1,attrs:["string"]},".string":{name:".string",kindof:"datatype",size:1,attrs:["string"]},".space":{name:".space",kindof:"datatype",size:1,attrs:["space"]},".zero":{name:".zero",kindof:"datatype",size:1,attrs:["space"]},".align":{name:".align",kindof:"datatype",size:0,attrs:["align"]},".balign":{name:".balign",kindof:"datatype",size:0,attrs:["align"]}};function wsasm_is_directive_kindof(text,kindof){if(typeof ws_directives[text]==="undefined"){return false}return ws_directives[text].kindof==kindof}function wsasm_is_directive(text){return typeof ws_directives[text]!=="undefined"}function wsasm_is_directive_segment(text){return wsasm_is_directive_kindof(text,"segment")}function wsasm_is_directive_datatype(text){return wsasm_is_directive_kindof(text,"datatype")}function wsasm_get_datatype_size(datatype){if(typeof ws_directives[datatype]==="undefined"){console.log("ERROR: not defined datatype: "+datatype+"\n");return 0}return ws_directives[datatype].size}function wsasm_has_datatype_attr(datatype,attr){if(typeof ws_directives[datatype]==="undefined"){return false}return ws_directives[datatype].attrs.includes(attr)}BYTE_LENGTH=8;WORD_BYTES=4;WORD_LENGTH=WORD_BYTES*BYTE_LENGTH;sim_datatypes={".byte":{name:".byte",kindof:"datatype",size:1},".half":{name:".half",kindof:"datatype",size:2},".word":{name:".word",kindof:"datatype",size:4},".float":{name:".float",kindof:"datatype",size:4},".double":{name:".double",kindof:"datatype",size:8},".ascii":{name:".ascii",kindof:"datatype",size:1},".asciiz":{name:".asciiz",kindof:"datatype",size:1},".space":{name:".space",kindof:"datatype",size:1},".string":{name:".string",kindof:"datatype",size:1},".zero":{name:".zero",kindof:"datatype",size:1},".align":{name:".align",kindof:"datatype",size:0}};function isDecimal(n){var ret={number:0,isDecimal:false};if(n.length>1&&n[0]=="0"){return ret}if(typeof n==="string"&&n.includes(".")){return ret}if(!isNaN(parseFloat(n))&&isFinite(n)){ret.isDecimal=true;ret.number=parseInt(n);return ret}return ret}function isOctal(n){var ret={number:0,isDecimal:false};if(n.substring(0,1)=="0"){var octal=n.substring(1).replace(/\b0+/g,"");ret.number=parseInt(octal,8);ret.isDecimal=ret.number.toString(8)===octal;return ret}return ret}function isHex(n){var ret={number:0,isDecimal:false};if(n.substring(0,2).toLowerCase()=="0x"){var hex=n.substring(2).toLowerCase().replace(/\b0+/g,"");if(hex==""){hex="0"}ret.number=parseInt(hex,16);ret.isDecimal=ret.number.toString(16)===hex;return ret}return ret}function isChar(n){var ret={number:0,isDecimal:false};var ret1=treatControlSequences(n);if(true==ret1.error){return ret}var possible_value=ret1.string;if(possible_value[0]=="'"&&possible_value[2]=="'"||possible_value[0]=='"'&&possible_value[2]=='"'){ret.number=possible_value.charCodeAt(1);ret.isDecimal=true;return ret}return ret}function isFloat(n){var ret={number:0,isFloat:false};var non_float=/[a-df-zA-DF-Z]+/;if(non_float.test(n)===true){return ret}ret.number=parseFloat(n);ret.isFloat=!isNaN(ret.number);return ret}function get_decimal_value(possible_value){var ret={number:0,isDecimal:true};ret=isOctal(possible_value);if(ret.isDecimal===false){ret=isHex(possible_value)}if(ret.isDecimal===false){ret=isDecimal(possible_value)}if(ret.isDecimal===false){ret=isChar(possible_value)}return ret}function decimal2binary(number,size){var num_base2=number.toString(2);var num_base2_length=num_base2.length;if(num_base2_length>WORD_LENGTH){return[num_base2,size-num_base2_length,num_base2_length]}num_base2=(number>>>0).toString(2);num_base2_length=num_base2.length;if(number>=0){return[num_base2,size-num_base2_length,num_base2_length]}num_base2="1"+num_base2.replace(/^[1]+/g,"");num_base2_length=num_base2.length;if(num_base2_length>size){return[num_base2,size-num_base2_length,num_base2_length]}num_base2="1".repeat(size-num_base2.length)+num_base2;return[num_base2,size-num_base2.length,num_base2_length]}function get_inm_value(value){var ret1={};var ret={number:0,isDecimal:false,isFloat:false};ret1=get_decimal_value(value);if(ret1.isDecimal==true){ret1.isFloat=false;return ret1}ret1=isFloat(value);if(ret1.isFloat==true){ret1.isDecimal=false;return ret1}return ret}directives={".kdata":{name:".kdata",kindof:"segment",size:0},".ktext":{name:".ktext",kindof:"segment",size:0},".data":{name:".data",kindof:"segment",size:0},".text":{name:".text",kindof:"segment",size:0},".byte":{name:".byte",kindof:"datatype",size:1},".half":{name:".half",kindof:"datatype",size:2},".word":{name:".word",kindof:"datatype",size:4},".float":{name:".float",kindof:"datatype",size:4},".double":{name:".double",kindof:"datatype",size:8},".ascii":{name:".ascii",kindof:"datatype",size:1},".asciiz":{name:".asciiz",kindof:"datatype",size:1},".space":{name:".space",kindof:"datatype",size:1},".string":{name:".string",kindof:"datatype",size:1},".zero":{name:".zero",kindof:"datatype",size:1},".align":{name:".align",kindof:"datatype",size:0}};function get_datatype_size(datatype){if(typeof directives[datatype]==="undefined"){console.log("ERROR: not defined datatype: "+datatype+"\n");return 0}return directives[datatype].size}function is_directive_kindof(text,kindof){if(typeof directives[text]==="undefined"){return false}return directives[text].kindof==kindof}function is_directive(text){return typeof directives[text]!=="undefined"}function is_directive_segment(text){return is_directive_kindof(text,"segment")}function is_directive_datatype(text){return is_directive_kindof(text,"datatype")}function isValidTag(tag){if(tag.trim()==""){return false}var ret=isDecimal(tag[0]);if(ret.isDecimal==true){return false}var myRegEx=/[^a-z,_\d]/i;return!myRegEx.test(tag)}function sum_array(a){return a.reduce((function(a,b){return a+b}),0)}function get_candidate(advance,instruction){var candidate=false;var candidates={};var signatures={};for(i=0;icandidates[i]){min=candidates[i];candidate=i}}}return candidate?parseInt(candidate):candidate}function reset_assembly(nwords){return"0".repeat(WORD_LENGTH*nwords)}function assembly_replacement(machineCode,num_bits,startbit,stopbit,free_space){var machineCodeAux=machineCode.substring(0,machineCode.length-startbit+free_space);machineCode=machineCodeAux+num_bits+machineCode.substring(machineCode.length-stopbit);return machineCode}function assembly_co_cop(machineCode,co,cop){var xr_info=simhw_sim_ctrlStates_get();if(co!==false)machineCode=assembly_replacement(machineCode,co,WORD_LENGTH,WORD_LENGTH-6,0);if(cop!==false)machineCode=assembly_replacement(machineCode,cop,xr_info.ir.default_eltos.cop.length,0,0);return machineCode}function writememory_and_reset(mp,gen,nwords){if(gen.byteWord>=WORD_BYTES){var melto={value:gen.machineCode,source_tracking:gen.track_source,comments:gen.comments};main_memory_set(mp,"0x"+gen.seg_ptr.toString(16),melto);gen.seg_ptr=gen.seg_ptr+WORD_BYTES;gen.byteWord=0;gen.track_source=[];gen.comments=[];gen.machineCode=reset_assembly(nwords)}}function is_end_of_file(context){return""===asm_getToken(context)&&context.t>=context.text.length}function read_data(context,datosCU,ret){var seg_name=asm_getToken(context);var gen={};gen.byteWord=0;gen.track_source=[];gen.comments=[];gen.machineCode=reset_assembly(1);gen.seg_ptr=ret.seg[seg_name].begin;asm_nextToken(context);while(!is_directive_segment(asm_getToken(context))&&!is_end_of_file(context)){var possible_tag="";while(!is_directive_datatype(asm_getToken(context))&&!is_end_of_file(context)){possible_tag=asm_getToken(context);if("TAG"!=asm_getTokenType(context)){if(""==possible_tag){possible_tag="[empty]"}return asm_langError(context,i18n_get_TagFor("compiler","NO TAG OR DIRECTIVE")+"'"+possible_tag+"'")}var tag=possible_tag.substring(0,possible_tag.length-1);if(!isValidTag(tag)){return asm_langError(context,i18n_get_TagFor("compiler","INVALID TAG FORMAT")+"'"+tag+"'")}if(context.firmware[tag]){return asm_langError(context,i18n_get_TagFor("compiler","TAG OR INSTRUCTION")+"'"+tag+"'")}if(ret.labels2[tag]){return asm_langError(context,i18n_get_TagFor("compiler","REPEATED TAG")+"'"+tag+"'")}ret.labels2[tag]="0x"+(gen.seg_ptr+gen.byteWord).toString(16);asm_nextToken(context)}if(is_end_of_file(context)){break}var possible_datatype=asm_getToken(context);if(".word"==possible_datatype||".half"==possible_datatype||".byte"==possible_datatype||".float"==possible_datatype||".double"==possible_datatype){var size=get_datatype_size(possible_datatype);asm_nextToken(context);var possible_value=asm_getToken(context);while(!is_directive(asm_getToken(context))&&!is_end_of_file(context)){var label_found=false;var ret1=get_inm_value(possible_value);var number=ret1.number;if(ret1.isDecimal==false&&ret1.isFloat==false){if(".word"!==possible_datatype){return asm_langError(context,i18n_get_TagFor("compiler","NO NUMERIC DATATYPE")+"'"+possible_value+"'")}if(!isValidTag(possible_value)){return asm_langError(context,i18n_get_TagFor("compiler","INVALID TAG FORMAT")+"'"+possible_value+"'")}if(context.firmware[possible_value]){return asm_langError(context,i18n_get_TagFor("compiler","TAG OR INSTRUCTION")+"'"+possible_value+"'")}number=0;label_found=true}if(ret1.isDecimal==true)a=decimal2binary(number,size*BYTE_LENGTH);else a=float2binary(number,size*BYTE_LENGTH);num_bits=a[0];free_space=a[1];if(free_space<0){return asm_langError(context,i18n_get_TagFor("compiler","EXPECTED VALUE")+possible_datatype+"' ("+size*BYTE_LENGTH+" bits), "+i18n_get_TagFor("compiler","BUT INSERTED")+possible_value+"' ("+num_bits.length+" bits) "+i18n_get_TagFor("compiler","INSTEAD"))}writememory_and_reset(ret.mp,gen,1);while((gen.seg_ptr+gen.byteWord)%size!=0){gen.byteWord++;writememory_and_reset(ret.mp,gen,1)}if(""!=possible_tag){ret.labels2[possible_tag.substring(0,possible_tag.length-1)]="0x"+(gen.seg_ptr+gen.byteWord).toString(16);possible_tag=""}if(label_found){ret.labels["0x"+gen.seg_ptr.toString(16)]={name:possible_value,addr:gen.seg_ptr,startbit:31,stopbit:0,rel:undefined,nwords:1,labelContext:asm_getLabelContext(context)}}gen.machineCode=assembly_replacement(gen.machineCode,num_bits,BYTE_LENGTH*(size+gen.byteWord),BYTE_LENGTH*gen.byteWord,free_space);gen.byteWord+=size;gen.track_source.push(possible_value);asm_nextToken(context);if(","==asm_getToken(context)){asm_nextToken(context)}if(is_directive(asm_getToken(context))||"TAG"==asm_getTokenType(context)||"."==asm_getToken(context)[0]){break}possible_value=asm_getToken(context)}}else if(".space"==possible_datatype||".zero"==possible_datatype){asm_nextToken(context);var possible_value=asm_getToken(context);var ret1=isDecimal(possible_value);possible_value=ret1.number;if(ret1.isDecimal==false){return asm_langError(context,i18n_get_TagFor("compiler","NO NUMBER OF BYTES")+"'"+possible_value+"'")}if(possible_value<0){return asm_langError(context,i18n_get_TagFor("compiler","NO POSITIVE NUMBER")+"'"+possible_value+"'")}for(i=0;i=0){return asm_langError(context,i18n_get_TagFor("compiler","INVALID ALIGN VALUE")+"'"+possible_value+"'. "+i18n_get_TagFor("compiler","REMEMBER ALIGN VAL"))}writememory_and_reset(ret.mp,gen,1);var align_offset=Math.pow(2,parseInt(possible_value));switch(align_offset){case 1:break;case 2:if(gen.byteWord&1==1)gen.byteWord++;break;default:writememory_and_reset(ret.mp,gen,1);while(gen.seg_ptr%align_offset!=0||gen.byteWord!=0){gen.byteWord++;writememory_and_reset(ret.mp,gen,1)}}asm_nextToken(context)}else if(".ascii"==possible_datatype||".asciiz"==possible_datatype||".string"==possible_datatype){asm_nextToken(context);var possible_value=asm_getToken(context);var ret1=treatControlSequences(possible_value);if(true==ret1.error){return asm_langError(context,ret1.string)}possible_value=ret1.string;while(!is_directive(asm_getToken(context))&&!is_end_of_file(context)){writememory_and_reset(ret.mp,gen,1);if('"'!==possible_value[0]){return asm_langError(context,i18n_get_TagFor("compiler","NO QUOTATION MARKS")+"'"+possible_value+"'")}if('"'!==possible_value[possible_value.length-1]){return asm_langError(context,i18n_get_TagFor("compiler","NOT CLOSED STRING"))}if(""==possible_value){return asm_langError(context,i18n_get_TagFor("compiler","NOT CLOSED STRING"))}if("STRING"!=asm_getTokenType(context)){return asm_langError(context,i18n_get_TagFor("compiler","NO QUOTATION MARKS")+"'"+possible_value+"'")}for(i=0;i0){var melto={value:gen.machineCode,source_tracking:gen.track_source,comments:gen.comments};main_memory_set(ret.mp,"0x"+gen.seg_ptr.toString(16),melto);gen.seg_ptr=gen.seg_ptr+WORD_BYTES}ret.seg[seg_name].end=gen.seg_ptr}function read_text(context,datosCU,ret){var seg_name=asm_getToken(context);var seg_ptr=ret.seg[seg_name].begin;var firmware=context.firmware;var pseudoInstructions=context.pseudoInstructions;var finish=[];var isPseudo=false;var pfinish=[];var npseudoInstructions=0;var pseudo_fields={};var counter=-1;var candidate;var error="";var registers={};for(i=0;i=signature_fields[j].length){if("TAG"!=asm_getTokenType(context)&&!firmware[value]&&!is_end_of_file(context)){advance[j]=0}continue}var field=firmware[instruction][j].fields[i];var size=field.startbit-field.stopbit+1;var label_found=false;var sel_found=false;switch(field.type){case"address":case"inm":if(isPseudo&&"sel"==value){counter++;var start=pfinish[counter++];var stop=pfinish[counter++];var value=pseudo_fields[pfinish[counter++]];counter++;sel_found=true}var ret1=get_inm_value(value);converted=ret1.number;if(ret1.isDecimal==false&&ret1.isFloat==false){error=i18n_get_TagFor("compiler","NO NUMERIC DATATYPE")+"'"+value+"'";if(value[0]=="'"){advance[j]=0;break}if(!isValidTag(value)){advance[j]=0;break}if(firmware[value]){error=i18n_get_TagFor("compiler","TAG OR INSTRUCTION")+"'"+value+"'";advance[j]=0;break}label_found=true}if(sel_found){if(ret1.isDecimal==true)res=decimal2binary(converted,WORD_LENGTH);else res=float2binary(converted,WORD_LENGTH);if(res[1]<0){return asm_langError(context,"'"+value+"' "+i18n_get_TagFor("compiler","BIGGER THAN")+WORD_LENGTH+" "+i18n_get_TagFor("compiler","BITS"))}if(label_found){s[i+1]=value}else{converted="0".repeat(res[1])+res[0];converted=converted.substring(WORD_LENGTH-start-1,WORD_LENGTH-stop);converted=parseInt(converted,2);s[i+1]="0x"+converted.toString(16)}}if(!label_found){if(ret1.isDecimal==true)var res=decimal2binary(converted,size);else var res=float2binary(converted,size);if(field.type=="address"&&"rel"==field.address_type){res=decimal2binary(converted,size)}}break;case"reg":if(typeof value==="undefined"){error=i18n_get_TagFor("compiler","INS. MISSING FIELD");advance[j]=0;break}var aux=false;if(value.startsWith("(")){if("(reg)"!=signature_fields[j][i]){error=i18n_get_TagFor("compiler","UNEXPECTED (REG)");advance[j]=0;break}if(counter==-1){asm_nextToken(context);value=asm_getToken(context)}else{value=pseudo_fields[pfinish[counter++]]}aux=true}else{if("(reg)"==signature_fields[j][i]){error=i18n_get_TagFor("compiler","EXPECTED (REG)")+"'"+value+"'";advance[j]=0;break}}if(typeof registers[value]==="undefined"){error=i18n_get_TagFor("compiler","EXPECTED REG")+"'"+value+"'";advance[j]=0;break}if(aux){s[i+1]="("+value+")";if(counter==-1){asm_nextToken(context);aux=asm_getToken(context)}else{aux=pfinish[counter++]}if(")"!=aux){error=i18n_get_TagFor("compiler","CLOSE PAREN. NOT FOUND");advance[j]=0;break}}var ret1=isDecimal(registers[value]);converted=ret1.number;var res=decimal2binary(converted,size);value=s[i+1];break;default:return asm_langError(context,i18n_get_TagFor("compiler","UNKNOWN 1")+"'"+field.type+"'")}if(advance[j]==1&&!label_found){if(res[1]<0){if(field.type=="address"&&"rel"==field.address_type){error="Relative value ("+(converted-seg_ptr-WORD_BYTES)+" in decimal)"+i18n_get_TagFor("compiler","NEEDS")+res[0].length+i18n_get_TagFor("compiler","SPACE FOR # BITS")+size+" "+i18n_get_TagFor("compiler","BITS")}else{error="'"+value+"'"+i18n_get_TagFor("compiler","NEEDS")+res[0].length+i18n_get_TagFor("compiler","SPACE FOR # BITS")+size+" "+i18n_get_TagFor("compiler","BITS")}advance[j]=0}}if(advance[j]==1&&!(isPseudo&&counter==-1)){binaryAux[j][i]={num_bits:label_found?false:res[0],free_space:label_found?false:res[1],startbit:field.startbit,stopbit:field.stopbit,rel:label_found?field.address_type:false,islabel:label_found,field_name:value,issel:sel_found,sel_start:start,sel_stop:stop}}}if(sum_array(advance)==0){break}if("TAG"==asm_getTokenType(context)||firmware[value]){break}}for(i=0;i0&&i0&&i==firmware[instruction].length-1){format+=" or "}format+="'"+firmware[instruction][i].signatureUser+"'"}if(format==""){format="'"+instruction+"' "+i18n_get_TagFor("compiler","UNKNOWN MC FORMAT")}var sum_res=sum_array(advance);if(sum_res==0){if(advance.length===1){return asm_langError(context,error+".
"+i18n_get_TagFor("compiler","REMEMBER I. FORMAT")+format)}return asm_langError(context,i18n_get_TagFor("compiler","NOT MATCH MICRO")+"
"+i18n_get_TagFor("compiler","REMEMBER I. FORMAT")+format+". "+i18n_get_TagFor("compiler","CHECK MICROCODE"))}if(sum_res>1){candidate=get_candidate(advance,firmware[instruction]);if(candidate===false){return asm_langError(context,i18n_get_TagFor("compiler","SEVERAL CANDIDATES")+format)}}if(isPseudo){if(counter==-1){var s_ori=s.join(" ");s_ori=s_ori.trim();var key="";var val="";pseudo_fields={};for(i=0;i1){s_ori=" "}if(pfinish[counter]=="\n"){counter++}}var machineCode=reset_assembly(firmware[instruction][candidate].nwords);machineCode=assembly_co_cop(machineCode,firmware[instruction][candidate].co,firmware[instruction][candidate].cop);var l_addr="";for(i=0;i=0;i--){if(icontext.text.length){break}}ret.seg[seg_name].end=seg_ptr}function simlang_compile_v1(text,datosCU){var context={};context.line=1;context.error=null;context.i=0;context.contadorMC=0;context.etiquetas={};context.labelsNotFound=[];context.instrucciones=[];context.co_cop={};context.registers=[];context.text=text;context.tokens=[];context.token_types=[];context.t=0;context.newlines=[];context.pseudoInstructions=[];context.stackRegister=null;context.firmware={};context.comments=[];for(i=0;i=0;j--){var melto={value:machineCode.substring(j*WORD_LENGTH,(j+1)*WORD_LENGTH),source_tracking:null,comments:null};main_memory_set(ret.mp,"0x"+auxAddr.toString(16),melto);auxAddr+=WORD_BYTES}}if(text_found){if(typeof ret.labels2["main"]==="undefined"&&typeof ret.labels2["kmain"]==="undefined"){return asm_langError(context,i18n_get_TagFor("compiler","NO MAIN OR KMAIN"))}}for(var key in ret.labels2){ret.hash_labels2_rev[ret.labels2[key]]=key}for(var skey in ret.seg){ret.hash_seg_rev.push({begin:parseInt(ret.seg[skey].begin),name:skey})}return ret}function bits_size(bits){var len=0;for(var i=0;istr.length-1)return str;return str.substring(0,index)+chr+str.substring(index+1)}function assembly_oc_eoc_v2(machineCode,oc,eoc){var xr_info=simhw_sim_ctrlStates_get();var bits=xr_info.ir.default_eltos.eoc.bits_field;var start=31-xr_info.ir.default_eltos.oc.begin+1;var stop=31-xr_info.ir.default_eltos.oc.end;if(oc!==false)machineCode=assembly_replace_v2(machineCode,oc,start,stop,0,0);if(eoc!==false)if(eoc.length===3){machineCode=assembly_replace_v2(machineCode,eoc,bits[0][0]+1,bits[0][1],0,0)}else{var j=0;for(var k=0;k=31-bits[k][0];i--){if(j>=0){machineCode=setCharAt(machineCode,i,num_bits[j]);j--}}}}return machineCode}function read_data_v2(context,datosCU,ret){var seg_name=asm_getToken(context);var gen={};gen.byteWord=0;gen.track_source=[];gen.comments=[];gen.machineCode=reset_assembly(1);gen.seg_ptr=ret.seg[seg_name].begin;asm_nextToken(context);while(!is_directive_segment(asm_getToken(context))&&!is_end_of_file(context)){var possible_tag="";while(!is_directive_datatype(asm_getToken(context))&&!is_end_of_file(context)){possible_tag=asm_getToken(context);if("TAG"!=asm_getTokenType(context)){if(""==possible_tag){possible_tag="[empty]"}return asm_langError(context,i18n_get_TagFor("compiler","NO TAG OR DIRECTIVE")+"'"+possible_tag+"'")}var tag=possible_tag.substring(0,possible_tag.length-1);if(!isValidTag(tag)){return asm_langError(context,i18n_get_TagFor("compiler","INVALID TAG FORMAT")+"'"+tag+"'")}if(context.firmware[tag]){return asm_langError(context,i18n_get_TagFor("compiler","TAG OR INSTRUCTION")+"'"+tag+"'")}if(ret.labels2[tag]){return asm_langError(context,i18n_get_TagFor("compiler","REPEATED TAG")+"'"+tag+"'")}ret.labels2[tag]="0x"+(gen.seg_ptr+gen.byteWord).toString(16);asm_nextToken(context)}if(is_end_of_file(context)){break}var possible_datatype=asm_getToken(context);if(".word"==possible_datatype||".half"==possible_datatype||".byte"==possible_datatype||".float"==possible_datatype||".double"==possible_datatype){var size=get_datatype_size(possible_datatype);asm_nextToken(context);var possible_value=asm_getToken(context);while(!is_directive(asm_getToken(context))&&!is_end_of_file(context)){var label_found=false;var ret1=get_inm_value(possible_value);var number=ret1.number;if(ret1.isDecimal==false&&ret1.isFloat==false){if(".word"!==possible_datatype){return asm_langError(context,i18n_get_TagFor("compiler","NO NUMERIC DATATYPE")+"'"+possible_value+"'")}if(!isValidTag(possible_value)){return asm_langError(context,i18n_get_TagFor("compiler","INVALID TAG FORMAT")+"'"+possible_value+"'")}if(context.firmware[possible_value]){return asm_langError(context,i18n_get_TagFor("compiler","TAG OR INSTRUCTION")+"'"+possible_value+"'")}number=0;label_found=true}if(ret1.isDecimal==true)a=decimal2binary(number,size*BYTE_LENGTH);else a=float2binary(number,size*BYTE_LENGTH);num_bits=a[0];free_space=a[1];if(free_space<0){return asm_langError(context,i18n_get_TagFor("compiler","EXPECTED VALUE")+possible_datatype+"' ("+size*BYTE_LENGTH+" bits), "+i18n_get_TagFor("compiler","BUT INSERTED")+possible_value+"' ("+num_bits.length+" bits) "+i18n_get_TagFor("compiler","INSTEAD"))}writememory_and_reset(ret.mp,gen,1);while((gen.seg_ptr+gen.byteWord)%size!=0){gen.byteWord++;writememory_and_reset(ret.mp,gen,1)}if(""!=possible_tag){ret.labels2[possible_tag.substring(0,possible_tag.length-1)]="0x"+(gen.seg_ptr+gen.byteWord).toString(16);possible_tag=""}if(label_found){ret.labels["0x"+gen.seg_ptr.toString(16)]={name:possible_value,addr:gen.seg_ptr,startbit:31,stopbit:0,rel:undefined,nwords:1,labelContext:asm_getLabelContext(context)}}gen.machineCode=assembly_replacement(gen.machineCode,num_bits,BYTE_LENGTH*(size+gen.byteWord),BYTE_LENGTH*gen.byteWord,free_space);gen.byteWord+=size;gen.track_source.push(possible_value);asm_nextToken(context);if(","==asm_getToken(context)){asm_nextToken(context)}if(is_directive(asm_getToken(context))||"TAG"==asm_getTokenType(context)||"."==asm_getToken(context)[0]){break}possible_value=asm_getToken(context)}}else if(".space"==possible_datatype||".zero"==possible_datatype){asm_nextToken(context);var possible_value=asm_getToken(context);var ret1=isDecimal(possible_value);possible_value=ret1.number;if(ret1.isDecimal==false){return asm_langError(context,i18n_get_TagFor("compiler","NO NUMBER OF BYTES")+"'"+possible_value+"'")}if(possible_value<0){return asm_langError(context,i18n_get_TagFor("compiler","NO POSITIVE NUMBER")+"'"+possible_value+"'")}for(i=0;i=0){return asm_langError(context,i18n_get_TagFor("compiler","INVALID ALIGN VALUE")+"'"+possible_value+"'. "+i18n_get_TagFor("compiler","REMEMBER ALIGN VAL"))}writememory_and_reset(ret.mp,gen,1);var align_offset=Math.pow(2,parseInt(possible_value));switch(align_offset){case 1:break;case 2:if(gen.byteWord&1==1)gen.byteWord++;break;default:writememory_and_reset(ret.mp,gen,1);while(gen.seg_ptr%align_offset!=0||gen.byteWord!=0){gen.byteWord++;writememory_and_reset(ret.mp,gen,1)}}asm_nextToken(context)}else if(".ascii"==possible_datatype||".asciiz"==possible_datatype||".string"==possible_datatype){asm_nextToken(context);var possible_value=asm_getToken(context);var ret1=treatControlSequences(possible_value);if(true==ret1.error){return asm_langError(context,ret1.string)}possible_value=ret1.string;while(!is_directive(asm_getToken(context))&&!is_end_of_file(context)){writememory_and_reset(ret.mp,gen,1);if('"'!==possible_value[0]){return asm_langError(context,i18n_get_TagFor("compiler","NO QUOTATION MARKS")+"'"+possible_value+"'")}if('"'!==possible_value[possible_value.length-1]){return asm_langError(context,i18n_get_TagFor("compiler","NOT CLOSED STRING"))}if(""==possible_value){return asm_langError(context,i18n_get_TagFor("compiler","NOT CLOSED STRING"))}if("STRING"!=asm_getTokenType(context)){return asm_langError(context,i18n_get_TagFor("compiler","NO QUOTATION MARKS")+"'"+possible_value+"'")}for(i=0;i0){var melto={value:gen.machineCode,source_tracking:gen.track_source,comments:gen.comments};main_memory_set(ret.mp,"0x"+gen.seg_ptr.toString(16),melto);gen.seg_ptr=gen.seg_ptr+WORD_BYTES}ret.seg[seg_name].end=gen.seg_ptr}function read_text_v2(context,datosCU,ret){var seg_name=asm_getToken(context);var seg_ptr=ret.seg[seg_name].begin;var firmware=context.firmware;var pseudoInstructions=context.pseudoInstructions;var finish=[];var isPseudo=false;var pfinish=[];var npseudoInstructions=0;var pseudo_fields={};var counter=-1;var candidate;var error="";var registers={};for(i=0;i=signature_fields[j].length){if("TAG"!=asm_getTokenType(context)&&!firmware[value]&&!is_end_of_file(context)){advance[j]=0}continue}var field=firmware[instruction][j].fields[i];if(field.bits!==undefined)var size=bits_size(field.bits);else var size=field.startbit-field.stopbit+1;var label_found=false;var sel_found=false;switch(field.type){case"address":case"inm":case"imm":if(isPseudo&&"sel"==value){counter++;var start=pfinish[counter++];var stop=pfinish[counter++];var value=pseudo_fields[pfinish[counter++]];counter++;sel_found=true}var ret1=get_inm_value(value);converted=ret1.number;if(ret1.isDecimal==false&&ret1.isFloat==false){error=i18n_get_TagFor("compiler","NO NUMERIC DATATYPE")+"'"+value+"'";if(value[0]=="'"){advance[j]=0;break}if(!isValidTag(value)){advance[j]=0;break}if(firmware[value]){error=i18n_get_TagFor("compiler","TAG OR INSTRUCTION")+"'"+value+"'";advance[j]=0;break}label_found=true}if(sel_found){if(ret1.isDecimal==true)res=decimal2binary(converted,WORD_LENGTH);else res=float2binary(converted,WORD_LENGTH);if(res[1]<0){return asm_langError(context,"'"+value+"' "+i18n_get_TagFor("compiler","BIGGER THAN")+WORD_LENGTH+" "+i18n_get_TagFor("compiler","BITS"))}if(label_found){s[i+1]=value}else{converted="0".repeat(res[1])+res[0];converted=converted.substring(WORD_LENGTH-start-1,WORD_LENGTH-stop);converted=parseInt(converted,2);s[i+1]="0x"+converted.toString(16)}}if(!label_found){if(ret1.isDecimal==true)var res=decimal2binary(converted,size);else var res=float2binary(converted,size);if(field.type=="address"&&"rel"==field.address_type){res=decimal2binary(converted,size)}}break;case"reg":if(typeof value==="undefined"){error=i18n_get_TagFor("compiler","INS. MISSING FIELD");advance[j]=0;break}var aux=false;if(value.startsWith("(")){if("(reg)"!=signature_fields[j][i]){error=i18n_get_TagFor("compiler","UNEXPECTED (REG)");advance[j]=0;break}if(counter==-1){asm_nextToken(context);value=asm_getToken(context)}else{value=pseudo_fields[pfinish[counter++]]}aux=true}else{if("(reg)"==signature_fields[j][i]){error=i18n_get_TagFor("compiler","EXPECTED (REG)")+"'"+value+"'";advance[j]=0;break}}if(typeof registers[value]==="undefined"){error=i18n_get_TagFor("compiler","EXPECTED REG")+"'"+value+"'";advance[j]=0;break}if(aux){s[i+1]="("+value+")";if(counter==-1){asm_nextToken(context);aux=asm_getToken(context)}else{aux=pfinish[counter++]}if(")"!=aux){error=i18n_get_TagFor("compiler","CLOSE PAREN. NOT FOUND");advance[j]=0;break}}var ret1=isDecimal(registers[value]);converted=ret1.number;var res=decimal2binary(converted,size);value=s[i+1];break;default:return asm_langError(context,i18n_get_TagFor("compiler","UNKNOWN 1")+"'"+field.type+"'")}if(advance[j]==1&&!label_found){if(res[1]<0){if(field.type=="address"&&"rel"==field.address_type){error="Relative value ("+(converted-seg_ptr-WORD_BYTES)+" in decimal)"+i18n_get_TagFor("compiler","NEEDS")+res[0].length+i18n_get_TagFor("compiler","SPACE FOR # BITS")+size+" "+i18n_get_TagFor("compiler","BITS")}else{error="'"+value+"'"+i18n_get_TagFor("compiler","NEEDS")+res[0].length+i18n_get_TagFor("compiler","SPACE FOR # BITS")+size+" "+i18n_get_TagFor("compiler","BITS")}advance[j]=0}}if(advance[j]==1&&!(isPseudo&&counter==-1)){binaryAux[j][i]={num_bits:label_found?false:res[0],free_space:label_found?false:res[1],startbit:field.startbit,stopbit:field.stopbit,bits:field.bits,rel:label_found?field.address_type:false,islabel:label_found,field_name:value,issel:sel_found,sel_start:start,sel_stop:stop}}}if(sum_array(advance)==0){break}if("TAG"==asm_getTokenType(context)||firmware[value]){break}}for(i=0;i0&&i0&&i==firmware[instruction].length-1){format+=" or "}format+="'"+firmware[instruction][i].signatureUser+"'"}if(format==""){format="'"+instruction+"' "+i18n_get_TagFor("compiler","UNKNOWN MC FORMAT")}var sum_res=sum_array(advance);if(sum_res==0){if(advance.length===1){return asm_langError(context,error+".
"+i18n_get_TagFor("compiler","REMEMBER I. FORMAT")+format)}return asm_langError(context,i18n_get_TagFor("compiler","NOT MATCH MICRO")+"
"+i18n_get_TagFor("compiler","REMEMBER I. FORMAT")+format+". "+i18n_get_TagFor("compiler","CHECK MICROCODE"))}if(sum_res>1){candidate=get_candidate(advance,firmware[instruction]);if(candidate===false){return asm_langError(context,i18n_get_TagFor("compiler","SEVERAL CANDIDATES")+format)}}if(isPseudo){if(counter==-1){var s_ori=s.join(" ");s_ori=s_ori.trim();var key="";var val="";pseudo_fields={};for(i=0;i1){s_ori=" "}if(pfinish[counter]=="\n"){counter++}}var machineCode=reset_assembly(firmware[instruction][candidate].nwords);if(firmware[instruction][candidate].co!==false){machineCode=assembly_co_cop(machineCode,firmware[instruction][candidate].co,firmware[instruction][candidate].cop)}else{machineCode=assembly_oc_eoc_v2(machineCode,firmware[instruction][candidate].oc,firmware[instruction][candidate].eoc)}var l_addr="";for(i=0;i=0;i--){if(icontext.text.length){break}}ret.seg[seg_name].end=seg_ptr}function simlang_compile_v2(text,datosCU){var context={};context.line=1;context.error=null;context.i=0;context.contadorMC=0;context.etiquetas={};context.labelsNotFound=[];context.instrucciones=[];context.co_cop={};context.oc_eoc={};context.registers=[];context.text=text;context.tokens=[];context.token_types=[];context.t=0;context.newlines=[];context.pseudoInstructions=[];context.stackRegister=null;context.firmware={};context.comments=[];for(i=0;i=0;j--){var melto={value:machineCode.substring(j*WORD_LENGTH,(j+1)*WORD_LENGTH),source_tracking:null,comments:null};main_memory_set(ret.mp,"0x"+auxAddr.toString(16),melto);auxAddr+=WORD_BYTES}}if(text_found){if(typeof ret.labels2["main"]==="undefined"&&typeof ret.labels2["kmain"]==="undefined"){return asm_langError(context,i18n_get_TagFor("compiler","NO MAIN OR KMAIN"))}}for(var key in ret.labels2){ret.hash_labels2_rev[ret.labels2[key]]=key}for(var skey in ret.seg){ret.hash_seg_rev.push({begin:parseInt(ret.seg[skey].begin),name:skey})}return ret}function wsasm_new_objElto(base_elto){var elto={comments:[],labels:[],track_source:[],seg_name:"",datatype:"",byte_size:0,value:0,binary:"",firm_reference:null,firm_reference_index:-1,pending:[]};if(null!=base_elto){elto.seg_name=base_elto.seg_name;elto.datatype=base_elto.datatype;elto.byte_size=base_elto.byte_size}return elto}function wsasm_make_signature_user(elto,use_as_around){elto.signature_user="";for(let j=0;jstop_bit){sel_start=WORD_LENGTH-1-start_bit;sel_stop=WORD_LENGTH-1-stop_bit}else{sel_stop=WORD_LENGTH-1-start_bit;sel_start=WORD_LENGTH-1-stop_bit}valbin=parseInt(value);valbin=valbin.toString(2).padStart(WORD_LENGTH,"0");valbin=valbin.substring(sel_start,sel_stop+1);return valbin}function wsasm_prepare_context_firmware(context,CU_data){let elto=null;let aux=null;let start_bit=0;let stop_bit=0;let lower_bit=0;let w_n_bits=0;let w_index=0;let n_bits=0;for(let i=0;i=0){return asm_langError(context,i18n_get_TagFor("compiler","INVALID ALIGN VALUE")+"'"+possible_value+"'. "+i18n_get_TagFor("compiler","REMEMBER ALIGN VAL"))}var align_offset=parseInt(possible_value);if(".align"==elto.datatype){align_offset=Math.pow(2,align_offset)}elto.seg_name=seg_name;elto.track_source.push(".align "+possible_value);elto.comments.push(acc_cmt);elto.byte_size=align_offset;elto.value=possible_value;ret.obj.push(elto);elto=wsasm_new_objElto(null);asm_nextToken(context)}else if(wsasm_has_datatype_attr(elto.datatype,"string")){asm_nextToken(context);possible_value=asm_getToken(context);ret1=treatControlSequences(possible_value);if(true==ret1.error){return asm_langError(context,ret1.string)}possible_value=ret1.string;while(!wsasm_is_directive(asm_getToken(context))&&!wsasm_isEndOfFile(context)){if('"'!==possible_value[0]){return asm_langError(context,i18n_get_TagFor("compiler","NO QUOTATION MARKS")+"'"+possible_value+"'")}if('"'!==possible_value[possible_value.length-1]){return asm_langError(context,i18n_get_TagFor("compiler","NOT CLOSED STRING"))}if(""==possible_value){return asm_langError(context,i18n_get_TagFor("compiler","NOT CLOSED STRING"))}if("STRING"!=asm_getTokenType(context)){return asm_langError(context,i18n_get_TagFor("compiler","NO QUOTATION MARKS")+"'"+possible_value+"'")}elto.seg_name=seg_name;elto.comments.push(acc_cmt);elto.value=[];for(i=0;i>>0).toString(2);value=value.padStart(n_bits,"0")}else{value="0".padStart(n_bits,"0")}for(let k=start_bit;k<=stop_bit;k++){arr_encoded[k]=value[k-start_bit]}}return arr_encoded.join("")}function wsasm_src2obj_text_getDistance(elto_firm_reference_i,elto_value){var candidate_type_as_string=elto_firm_reference_i.signature_type_str.replaceAll("address","inm");var candidate_size_as_intarr=elto_firm_reference_i.signature_size_arr;var signature_type_as_string=elto_value.signature_type_arr.join(" ").replaceAll("address","inm");var signature_size_as_intarr=elto_value.signature_size_arr;if(candidate_type_as_string!=signature_type_as_string){return-1}var distance=0;var distance_j=0;var offset_j=0;offset_j=candidate_size_as_intarr.length-signature_size_as_intarr.length;for(let j=0;jdistance){elto.firm_reference_distance=distance;elto.firm_reference_index=i}}if(0==candidates){var msg=elto.source;if(typeof elto.associated_pseudo!=="undefined"){msg=elto.source+' (as part of "'+elto.associated_pseudo.source+'")'}msg=i18n_get_TagFor("compiler","NOT MATCH FORMAT")+"
"+i18n_get_TagFor("compiler","REMEMBER FORMAT USED")+" for '"+msg+"':
"+elto.value.signature_user+".
"+i18n_get_TagFor("compiler","CHECK MICROCODE");return asm_langError(context,msg)}elto.byte_size=elto.firm_reference[elto.firm_reference_index].nwords*WORD_BYTES;return ret}function wsasm_src2obj_text_instr_op_match(context,ret,elto,atom,parentheses){var opx="";if(typeof context.registers[atom]!="undefined"){if(parentheses){elto.value.fields.push("("+atom+")");elto.value.signature_type_arr.push("(reg)")}else{elto.value.fields.push(atom);elto.value.signature_type_arr.push("reg")}elto.value.signature_size_arr.push(context.registers[atom].toString(2).length);return ret}var ret1=get_inm_value(atom);if(ret1.isDecimal||ret1.isFloat){var a=null;if(ret1.isDecimal)a=decimal2binary(ret1.number,elto.byte_size*BYTE_LENGTH);else a=float2binary(ret1.number,elto.byte_size*BYTE_LENGTH);if(parentheses){elto.value.fields.push("("+atom+")");elto.value.signature_type_arr.push("(inm)")}else{elto.value.fields.push(atom);elto.value.signature_type_arr.push("inm")}elto.value.signature_size_arr.push(a[2]);return ret}if(parentheses){elto.value.fields.push("("+atom+")");elto.value.signature_type_arr.push("(address)")}else{elto.value.fields.push(atom);elto.value.signature_type_arr.push("address")}elto.value.signature_size_arr.push(1);return ret}function wsasm_src2obj_text_ops_getAtom(context,pseudo_context){var opx="";if(pseudo_context!=null){if(pseudo_context.index>=pseudo_context.parts.length){return""}pseudo_context.index++;opx=pseudo_context.parts[pseudo_context.index]}else{asm_nextToken(context);opx=asm_getToken(context);if(wsasm_isEndOfFile(context)||"TAG"==asm_getTokenType(context)){return""}}if(typeof context.firmware[opx]!=="undefined"||wsasm_is_directive_segment(opx)){return""}return opx}function wsasm_src2obj_text_elto_fields(context,ret,elto,pseudo_context){var ret1=null;var opx="";var atom="";var par=false;opx=wsasm_src2obj_text_ops_getAtom(context,pseudo_context);while(opx!=""&&elto.value.fields.length<100){if(","==opx){opx=wsasm_src2obj_text_ops_getAtom(context,pseudo_context);if(""==opx)continue}atom=opx;par=false;if("sel"==opx){var sel={start:0,stop:0,label:""};var valbin="0";opx=wsasm_src2obj_text_ops_getAtom(context,pseudo_context);if("("!=opx){return asm_langError(context,i18n_get_TagFor("compiler","OPEN PAREN. NOT FOUND"))}sel.stop=wsasm_src2obj_text_ops_getAtom(context,pseudo_context);sel.stop=parseInt(sel.stop);if(isNaN(sel.stop)){return asm_langError(context,i18n_get_TagFor("compiler","NO POSITIVE NUMBER")+sel.stop)}opx=wsasm_src2obj_text_ops_getAtom(context,pseudo_context);if(","!=opx){return asm_langError(context,i18n_get_TagFor("compiler","COMMA NOT FOUND"))}sel.start=wsasm_src2obj_text_ops_getAtom(context,pseudo_context);sel.start=parseInt(sel.start);if(isNaN(sel.start)){return asm_langError(context,i18n_get_TagFor("compiler","NO POSITIVE NUMBER")+sel.start)}opx=wsasm_src2obj_text_ops_getAtom(context,pseudo_context);if(","!=opx){return asm_langError(context,i18n_get_TagFor("compiler","COMMA NOT FOUND"))}sel.label=wsasm_src2obj_text_ops_getAtom(context,pseudo_context);opx=wsasm_src2obj_text_ops_getAtom(context,pseudo_context);if(")"!=opx){return asm_langError(context,i18n_get_TagFor("compiler","CLOSE PAREN. NOT FOUND"))}a=get_inm_value(sel.label);if(a.isDecimal){valbin=wsasm_get_sel_valbin(sel.label,sel.start,sel.stop);atom=parseInt(valbin,2).toString(10)}else{if(!wsasm_is_ValidTag(sel.label)){return asm_langError(context,i18n_get_TagFor("compiler","LABEL NOT DEFINED")+": '"+sel.label+"'")}atom=sel.label+"["+sel.start+":"+sel.stop+"]"}}else if("("==opx){par=true;atom=wsasm_src2obj_text_ops_getAtom(context,pseudo_context);if(""==atom){return asm_langError(context,i18n_get_TagFor("compiler","CLOSE PAREN. NOT FOUND"))}opx=wsasm_src2obj_text_ops_getAtom(context,pseudo_context);if(")"!=opx){return asm_langError(context,i18n_get_TagFor("compiler","CLOSE PAREN. NOT FOUND"))}}ret1=wsasm_src2obj_text_instr_op_match(context,ret,elto,atom,par);if(ret1.error!=null){return ret1}opx=wsasm_src2obj_text_ops_getAtom(context,pseudo_context)}if(elto.value.fields.length>100){return asm_langError(context,i18n_get_TagFor("compiler","NOT MATCH FORMAT")+".
"+i18n_get_TagFor("compiler","REMEMBER FORMAT USED")+" '"+elto.source+"'.
"+i18n_get_TagFor("compiler","CHECK MICROCODE"))}elto.value.signature_type_str=elto.value.signature_type_arr.join(" ");elto.value.signature_size_str=elto.value.signature_size_arr.join(" ");elto.value.signature_user=wsasm_make_signature_user(elto.value,"+");return ret}function wsasm_find_candidate_and_encode(context,ret,elto){ret=wsasm_find_instr_candidates(context,ret,elto);if(ret.error!=null){return ret}var candidate=elto.firm_reference[elto.firm_reference_index];elto.binary=wsasm_encode_instruction(context,ret,elto,candidate);return ret}function wsasm_src2obj_text(context,ret){var possible_tag="";var possible_value="";var possible_inst="";var tag="";var acc_cmt="";var elto=null;var candidate=null;var seg_name=asm_getToken(context);asm_nextToken(context);elto=wsasm_new_objElto(null);while(!wsasm_is_directive_segment(asm_getToken(context))&&!wsasm_isEndOfFile(context)){acc_cmt=asm_getComments(context);asm_resetComments(context);possible_tag="";while(typeof context.firmware[asm_getToken(context)]==="undefined"&&!wsasm_isEndOfFile(context)){possible_tag=asm_getToken(context);if("TAG"!=asm_getTokenType(context)){if(""==possible_tag){possible_tag="[empty]"}return asm_langError(context,i18n_get_TagFor("compiler","NO TAG, DIR OR INS")+"'"+possible_tag+"'")}tag=possible_tag.substring(0,possible_tag.length-1);if(!wsasm_is_ValidTag(tag)){return asm_langError(context,i18n_get_TagFor("compiler","INVALID TAG FORMAT")+"'"+tag+"'")}if(context.firmware[tag]){return asm_langError(context,i18n_get_TagFor("compiler","TAG OR INSTRUCTION")+"'"+tag+"'")}if(ret.labels2[tag]){return asm_langError(context,i18n_get_TagFor("compiler","REPEATED TAG")+"'"+tag+"'")}elto.labels.push(tag);asm_nextToken(context)}if(wsasm_isEndOfFile(context)){if(elto.labels.length>0){ret.obj.push(elto)}break}possible_inst=asm_getToken(context);elto.seg_name=seg_name;elto.byte_size=WORD_BYTES;elto.value={};elto.value.instruction=possible_inst;elto.firm_reference=context.firmware[possible_inst];elto.value.fields=[];elto.value.signature_type_arr=[possible_inst];elto.value.signature_size_arr=[];ret=wsasm_src2obj_text_elto_fields(context,ret,elto,null);if(ret.error!=null){return ret}if(elto.value.fields.length>0)elto.source=elto.value.instruction+" "+elto.value.fields.join(" ");else elto.source=elto.value.instruction;elto.comments.push(acc_cmt);elto.track_source.push(elto.source);ret=wsasm_find_instr_candidates(context,ret,elto);if(ret.error!=null){return ret}var candidate=elto.firm_reference[elto.firm_reference_index];if(candidate.isPseudoinstruction==false){elto.datatype="instruction";elto.binary=wsasm_encode_instruction(context,ret,elto,candidate)}else{elto.datatype="pseudoinstruction";elto.binary=""}ret.obj.push(elto);elto=wsasm_new_objElto(elto)}return ret}function wsasm_src2obj_helper(context,ret){ret.data_found=false;ret.text_found=false;asm_nextToken(context);while(!wsasm_isEndOfFile(context)){var segname=asm_getToken(context);if(typeof ret.seg[segname]==="undefined"){return asm_langError(context,i18n_get_TagFor("compiler","INVALID SEGMENT NAME")+"'"+segname+"'")}if("data"==ret.seg[segname].kindof){ret=wsasm_src2obj_data(context,ret);ret.data_found=true}if(ret.error!=null){return ret}if("text"==ret.seg[segname].kindof){ret=wsasm_src2obj_text(context,ret);ret.text_found=true}if(ret.error!=null){return ret}}return ret}function wsasm_resolve_pseudo(context,ret){var pseudo_context={parts:null,index:0};var pseudo_elto=null;var elto=null;var eltos=[];var possible_inst="";var ret1=null;var pseudo_values="";var pseudo_replace="";for(let i=0;i1){padding=elto_align-last_assigned[seg_name]%elto_align;last_assigned[seg_name]+=padding}continue}elto_ptr=last_assigned[seg_name];if(ret.obj[i].datatype!="instruction"&&wsasm_get_datatype_size(ret.obj[i].datatype)==WORD_BYTES){if(elto_ptr%WORD_BYTES!=0)elto_ptr+=WORD_BYTES-elto_ptr%WORD_BYTES}ret.obj[i].seg_ptr=seg_ptr;ret.obj[i].elto_ptr=elto_ptr;ret.obj[i].byte_offset=elto_ptr-seg_ptr;ret.obj[i].padding=0;for(var j=0;j>>0).toString(2);ret.labels_valbin[label]=valbin;return ret}var value_arr=label.split(/^(.*)\[(\d+):(\d+)\]/s);if(value_arr.length<5){return asm_langError(context,i18n_get_TagFor("compiler","LABEL NOT DEFINED")+": '"+label+"'")}var sel_stop=parseInt(value_arr[2]);var sel_start=parseInt(value_arr[3]);var sel_label=value_arr[1];value=ret.labels2[sel_label];if(typeof value==="undefined"){return asm_langError(context,i18n_get_TagFor("compiler","LABEL NOT DEFINED")+": '"+sel_label+"'")}valbin=wsasm_get_sel_valbin(value,sel_start,sel_stop);ret.labels_valbin[label]=valbin;return ret}function wsasm_resolve_labels(context,ret){var elto=null;var value=0;var arr_encoded=null;var candidate_old=null;var candidate=null;ret=wsasm_compute_labels(context,ret,0);if(ret.error!=null){return ret}for(let i=0;ielto.pending[j].n_bits){elto.pending=[];ret=wsasm_find_candidate_and_encode(context,ret,elto);if(ret.error!=null){return ret}candidate=elto.firm_reference[elto.firm_reference_index];if(candiate.isPseudoinstruction){ret=wsasm_resolve_pseudo(context,ret);if(ret.error!=null){return ret}}if(candiate.nwords!=candiate_old.nwords){ret=wsasm_compute_labels(context,ret,i);if(ret.error!=null){return ret}}}if(elto.pending[j].rel){value=parseInt(value,2);value=(value>>>0)-(elto.elto_ptr+WORD_BYTES);if(value<0){value=(value>>>0).toString(2);value="1"+value.replace(/^[1]+/g,"");value=value.padStart(elto.pending[j].n_bits,"1")}else{value=value.toString(2)}}}if(value.length>elto.pending[j].n_bits){return asm_langError(context,"'"+elto.pending[j].label+"'"+i18n_get_TagFor("compiler","NEEDS")+value.length+i18n_get_TagFor("compiler","SPACE FOR # BITS")+elto.pending[j].n_bits+" "+i18n_get_TagFor("compiler","BITS"))}value=value.padStart(elto.pending[j].n_bits,"0");arr_encoded=elto.binary.split("");for(var k=elto.pending[j].start_bit;k<=elto.pending[j].stop_bit;k++){arr_encoded[k]=value[k-elto.pending[j].start_bit]}elto.binary=arr_encoded.join("");if("field-data"==elto.pending[j].type){elto.value=parseInt(value,2)}}}for(var key in ret.labels2){ret.hash_labels2_rev[ret.labels2[key]]=key}for(var skey in ret.seg){ret.hash_seg_rev.push({begin:parseInt(ret.seg[skey].begin),name:skey})}return ret}function wsasm_writememory_if_word(mp,gen,track_source,track_comments){if(gen.byteWord1){var last_assigned=parseInt(gen.addr)+gen.byteWord;var padding=elto_align-last_assigned%elto_align;for(var k=0;k>>0).toString(2);if(ret.obj[i].value<0)valuebin=valuebin.substr(valuebin.length-n_bytes*BYTE_LENGTH,n_bytes*BYTE_LENGTH);else valuebin=valuebin.padStart(n_bytes*BYTE_LENGTH,"0");for(let j=0;jstr.length-1)return str;return str.substring(0,index)+chr+str.substring(index+1)}function assembly_replace(machineCode,num_bits,startbit,stopbit,bits,free_space){if(startbit!==undefined&&stopbit!==undefined){var machineCodeAux=machineCode.substring(0,machineCode.length-startbit+free_space);machineCode=machineCodeAux+num_bits+machineCode.substring(machineCode.length-stopbit);if(machineCode.length<32){machineCode="0".repeat(32-machineCode.length)+machineCode}}else{console.log("Previous machine code: "+machineCode);var j=num_bits.length-1;for(var k=0;k=31-bits[k][0];i--){if(j>=0){machineCode=setCharAt(machineCode,i,num_bits[j]);j--;console.log(machineCode)}}}}return machineCode}function simlang_compile_prepare_context(datosCU){var context={};context.line=1;context.error=null;context.i=0;context.contadorMC=0;context.etiquetas={};context.labelsNotFound=[];context.instrucciones=[];context.co_cop={};context.oc_eoc={};context.registers=[];context.text="";context.tokens=[];context.token_types=[];context.t=0;context.newlines=[];context.pseudoInstructions=[];context.stackRegister=null;context.firmware={};context.comments=[];for(i=0;i=0){return asm_langError(context,i18n_get_TagFor("compiler","INVALID ALIGN VALUE")+"'"+possible_value+"'. "+i18n_get_TagFor("compiler","REMEMBER ALIGN VAL"))}writememory_and_reset(ret.mp,gen,1);var align_offset=Math.pow(2,parseInt(possible_value));switch(align_offset){case 1:break;case 2:if(gen.byteWord&1==1)gen.byteWord++;break;default:writememory_and_reset(ret.mp,gen,1);while(gen.seg_ptr%align_offset!=0||gen.byteWord!=0){gen.byteWord++;writememory_and_reset(ret.mp,gen,1)}}asm_nextToken(context)}else if(".ascii"==possible_datatype||".asciiz"==possible_datatype||".string"==possible_datatype){asm_nextToken(context);var possible_value=asm_getToken(context);var ret1=treatControlSequences(possible_value);if(true==ret1.error)return asm_langError(context,ret1.string);possible_value=ret1.string;while(!is_directive(asm_getToken(context))&&!is_end_of_file(context)){writememory_and_reset(ret.mp,gen,1);if('"'!==possible_value[0]){return asm_langError(context,i18n_get_TagFor("compiler","NO QUOTATION MARKS")+"'"+possible_value+"'")}if('"'!==possible_value[possible_value.length-1]){return asm_langError(context,i18n_get_TagFor("compiler","NOT CLOSED STRING"))}if(""==possible_value){return asm_langError(context,i18n_get_TagFor("compiler","NOT CLOSED STRING"))}if("STRING"!=asm_getTokenType(context)){return asm_langError(context,i18n_get_TagFor("compiler","NO QUOTATION MARKS")+"'"+possible_value+"'")}for(i=0;i0){var melto={value:gen.machineCode,source_tracking:gen.track_source,comments:gen.comments};main_memory_set(ret.mp,"0x"+gen.seg_ptr.toString(16),melto);gen.seg_ptr=gen.seg_ptr+WORD_BYTES}ret.seg[seg_name].end=gen.seg_ptr}function read_text_v3(context,datosCU,ret){console.log(context.firmware);var seg_name=asm_getToken(context);var seg_ptr=ret.seg[seg_name].begin;var error="";asm_nextToken(context);while(!is_directive_segment(asm_getToken(context))&&!is_end_of_file(context)){while(typeof context.firmware[asm_getToken(context)]==="undefined"&&!is_end_of_file(context)){var possible_tag=asm_getToken(context);if("TAG"!=asm_getTokenType(context)){if(""==possible_tag)possible_tag="[empty]";return asm_langError(context,i18n_get_TagFor("compiler","NO TAG, DIR OR INS")+"'"+possible_tag+"'")}var tag=possible_tag.substring(0,possible_tag.length-1);if(!isValidTag(tag)){return asm_langError(context,i18n_get_TagFor("compiler","INVALID TAG FORMAT")+"'"+tag+"'")}if(context.firmware[tag]){return asm_langError(context,i18n_get_TagFor("compiler","TAG OR INSTRUCTION")+"'"+tag+"'")}if(ret.labels2[tag]){return asm_langError(context,i18n_get_TagFor("compiler","REPEATED TAG")+"'"+tag+"'")}ret.labels2[tag]="0x"+seg_ptr.toString(16);asm_nextToken(context)}if(is_end_of_file(context))break;var instruction=asm_getToken(context);var signature_fields=[];var signature_user_fields=[];var advance=[];var max_length=0;var binaryAux=[];var firmware_instruction_length=0;if(typeof context.firmware[instruction]!=="undefined"){firmware_instruction_length=context.firmware[instruction].length}var val=[];for(i=0;i=signature_fields[j].length){if("TAG"!=asm_getTokenType(context)&&!context.firmware[value]&&!is_end_of_file(context))advance[j]=0;continue}var field=context.firmware[instruction][j].fields[i];console.log(field);if(field.startbit!==undefined&&field.stopbit!==undefined)var size=field.startbit-field.stopbit+1;else var size=bits_size(field.bits);var label_found=false;var sel_found=false;switch(field.type){case"address":case"inm":case"imm":var ret1=get_inm_value(value);converted=ret1.number;if(ret1.isDecimal==false&&ret1.isFloat==false){error=i18n_get_TagFor("compiler","NO NUMERIC DATATYPE")+"'"+value+"'";if(value[0]=="'"){advance[j]=0;break}if(!isValidTag(value)){advance[j]=0;break}if(context.firmware[value]){error=i18n_get_TagFor("compiler","TAG OR INSTRUCTION")+"'"+value+"'";advance[j]=0;break}label_found=true}if(!label_found){if(ret1.isDecimal==true)var res=decimal2binary(converted,size);else var res=float2binary(converted,size);if(field.type=="address"&&"rel"==field.address_type){res=decimal2binary(converted,size)}}console.log("Inmediato: "+ret1);break;case"reg":if(typeof value==="undefined"){error=i18n_get_TagFor("compiler","INS. MISSING FIELD");advance[j]=0;break}var aux=false;if(value.startsWith("(")){if("(reg)"!=signature_fields[j][i]){error=i18n_get_TagFor("compiler","UNEXPECTED (REG)");advance[j]=0;break}asm_nextToken(context);value=asm_getToken(context);aux=true}else{if("(reg)"==signature_fields[j][i]){error=i18n_get_TagFor("compiler","EXPECTED (REG)")+"'"+value+"'";advance[j]=0;break}}if(typeof context.registers[value]==="undefined"){error=i18n_get_TagFor("compiler","EXPECTED REG")+"'"+value+"'";advance[j]=0;break}if(aux){s[i+1]="("+value+")";asm_nextToken(context);aux=asm_getToken(context);if(")"!=aux){error=i18n_get_TagFor("compiler","CLOSE PAREN. NOT FOUND");advance[j]=0;break}}var ret1=isDecimal(context.registers[value]);converted=ret1.number;var res=decimal2binary(converted,size);value=s[i+1];break;default:return asm_langError(context,i18n_get_TagFor("compiler","UNKNOWN 1")+"'"+field.type+"'")}if(advance[j]==1&&!label_found){if(res[1]<0){if(field.type=="address"&&"rel"==field.address_type){error="Relative value ("+(converted-seg_ptr-WORD_BYTES)+" in decimal)"+i18n_get_TagFor("compiler","NEEDS")+res[0].length+i18n_get_TagFor("compiler","SPACE FOR # BITS")+size+" "+i18n_get_TagFor("compiler","BITS")}else{error="'"+value+"'"+i18n_get_TagFor("compiler","NEEDS")+res[0].length+i18n_get_TagFor("compiler","SPACE FOR # BITS")+size+" "+i18n_get_TagFor("compiler","BITS")}advance[j]=0}}if(advance[j]==1){binaryAux[j][i]={num_bits:label_found?false:res[0],free_space:label_found?false:res[1],startbit:field.startbit,stopbit:field.stopbit,bits:field.bits,rel:label_found?field.address_type:false,islabel:label_found,field_name:value}}}if(sum_array(advance)==0)break;if("TAG"==asm_getTokenType(context)||context.firmware[value])break}for(i=0;i0&&i0&&i==context.firmware[instruction].length-1)format+=" or ";format+="'"+context.firmware[instruction][i].signatureUser+"'"}if(format==""){format="'"+instruction+"' "+i18n_get_TagFor("compiler","UNKNOWN MC FORMAT")}var sum_res=sum_array(advance);if(sum_res==0){if(advance.length===1){return asm_langError(context,error+".
"+i18n_get_TagFor("compiler","REMEMBER I. FORMAT")+format)}return asm_langError(context,i18n_get_TagFor("compiler","NOT MATCH MICRO")+"
"+i18n_get_TagFor("compiler","REMEMBER I. FORMAT")+format+". "+i18n_get_TagFor("compiler","CHECK MICROCODE"))}if(sum_res>1){candidate=get_candidate(advance,firmware[instruction]);if(candidate===false){return asm_langError(context,i18n_get_TagFor("compiler","SEVERAL CANDIDATES")+format)}}var machineCode=reset_assembly(context.firmware[instruction][candidate].nwords);console.log("Código máquina original: "+machineCode);if(context.firmware[instruction][candidate].co!==false){machineCode=assembly_co_cop(machineCode,context.firmware[instruction][candidate].co,context.firmware[instruction][candidate].cop);console.log("Código máquina co+cop: "+machineCode)}else{console.log(context.firmware[instruction][candidate]);machineCode=assembly_oc_eoc(machineCode,context.firmware[instruction][candidate].oc,context.firmware[instruction][candidate].eoc);console.log("OC: "+context.firmware[instruction][candidate].oc);console.log("EOC: "+context.firmware[instruction][candidate].eoc);console.log("Código máquina oc+eoc: "+machineCode)}var l_addr="";for(i=0;i=0;i--){if(icontext.text.length)break}ret.seg[seg_name].end=seg_ptr}function simlang_compile_pass1(context,datosCU,text){var ret={};ret.seg=sim_segments;ret.mp={};ret.labels={};ret.labels2={};ret.hash_labels2_rev={};ret.hash_seg_rev=[];ret.data_found=false;ret.text_found=false;asm_nextToken(context);while(!is_end_of_file(context)){var segname=asm_getToken(context);if(typeof ret.seg[segname]==="undefined"){return asm_langError(context,i18n_get_TagFor("compiler","INVALID SEGMENT NAME")+"'"+segname+"'")}if("data"==ret.seg[segname].kindof){read_data_v3(context,ret);ret.data_found=true}if("text"==ret.seg[segname].kindof){read_text_v3(context,datosCU,ret);ret.text_found=true}if(context.error!=null){ret.error=context.error;return ret}}return ret}function simlang_compile_pass2(context,ret){return ret}function simlang_compile_pass3(context,ret){for(var i in ret.labels){var value=ret.labels2[ret.labels[i].name];if(typeof value==="undefined"){asm_setLabelContext(context,ret.labels[i].labelContext);return asm_langError(context,i18n_get_TagFor("compiler","LABEL NOT DEFINED")+"'"+ret.labels[i].name+"'")}var machineCode="";var auxAddr=ret.labels[i].addr;for(j=0;j=0;j--){var melto={value:machineCode.substring(j*WORD_LENGTH,(j+1)*WORD_LENGTH),source_tracking:null,comments:null};main_memory_set(ret.mp,"0x"+auxAddr.toString(16),melto);auxAddr+=WORD_BYTES}}if(ret.text_found){if(typeof ret.labels2["main"]==="undefined"&&typeof ret.labels2["kmain"]==="undefined"){return asm_langError(context,i18n_get_TagFor("compiler","NO MAIN OR KMAIN"))}}for(var key in ret.labels2){ret.hash_labels2_rev[ret.labels2[key]]=key}for(var skey in ret.seg){ret.hash_seg_rev.push({begin:parseInt(ret.seg[skey].begin),name:skey})}return ret}function simlang_compile_v3(text,datosCU){var context=simlang_compile_prepare_context(datosCU);context.text=text;var ret=simlang_compile_pass1(context,datosCU,text);if(ret.error!=null){return ret}ret=simlang_compile_pass2(context,ret);console.log(ret);if(ret.error!=null){return ret}ret=simlang_compile_pass3(context,ret);if(ret.error!=null){return ret}return ret}function simlang_compile(text,datosCU){var ret=null;if(typeof ws_ng!="undefined"){ret=wsasm_src2mem(datosCU,text)}ret=simlang_compile_v2(text,datosCU);return ret}
\ No newline at end of file
+var WSCFG={};function get_cfg(field){return WSCFG[field].value}function set_cfg(field,value){WSCFG[field].value=value}function update_cfg(field,value){WSCFG[field].value=value;simcore_record_append_new("Set configuration option "+field+" to "+value,'update_cfg("'+field+'","'+value+'");\n');simcore_ga("config","config."+WSCFG.version.value,"config."+WSCFG.version.value+"."+field+"."+value);save_cfg()}function is_cfg_empty(){return Object.keys(WSCFG).length===0}function save_cfg(){try{for(var item in WSCFG){localStorage.setItem("wepsim_"+item,get_cfg(item))}}catch(err){console.log("WepSIM can not save the configuration in a persistent way on this web browser,\n"+"found following error: \n"+err.message)}set_secondary_cfg()}function restore_cfg(){WSCFG=get_primary_cfg();set_secondary_cfg();if(localStorage===null){return}var default_value=null;var saved_value=null;for(var item in WSCFG){if(item==="version"){continue}default_value=get_cfg(item);set_cfg(item,localStorage.getItem("wepsim_"+item));if(WSCFG[item].type!="string"){try{saved_value=JSON.parse(get_cfg(item));set_cfg(item,saved_value)}catch(e){saved_value=null}}if(saved_value===null){set_cfg(item,default_value)}}set_secondary_cfg()}function reset_cfg(){WSCFG=get_primary_cfg();set_secondary_cfg();save_cfg()}function reset_cfg_values(){WSCFG=get_primary_cfg();set_secondary_cfg()}function upgrade_cfg(){var wscfg=get_primary_cfg();var item=null;for(item in wscfg){if(typeof WSCFG[item]==="undefined"){WSCFG[item]=wscfg[item]}if(WSCFG[item].value===null||WSCFG[item].value==="null"){WSCFG[item].value=wscfg[item].value}}if(wscfg.build.value!=WSCFG.build.value){for(item in wscfg){if(wscfg[item].upgrade){WSCFG[item]=wscfg[item]}}}set_secondary_cfg();save_cfg()}function is_mobile(){if(typeof navigator==="undefined"){return false}if(typeof navigator.userAgentData=="undefined"){return false}return navigator.userAgentData.mobile}function is_cordova(){return document.URL.indexOf("http://")===-1&&document.URL.indexOf("https://")===-1}function get_primary_cfg(){var wscfg={version:{upgrade:false,type:"string",value:"2.3.0"},build:{upgrade:true,type:"string",value:"2.3.0.20230701A"},color_data_active:{upgrade:false,type:"string",value:"#0066FF"},color_data_inactive:{upgrade:false,type:"string",value:"#000000"},color_name_active:{upgrade:false,type:"string",value:"#FF0000"},color_name_inactive:{upgrade:false,type:"string",value:"#000000"},size_active:{upgrade:false,type:"float",value:3},size_inactive:{upgrade:false,type:"float",value:1},is_byvalue:{upgrade:false,type:"boolean",value:false},CPUCU_show_graph:{upgrade:false,type:"boolean",value:true},RF_display_format:{upgrade:false,type:"string",value:"unsigned_16_fill"},RF_display_name:{upgrade:false,type:"string",value:"numerical"},MEM_display_format:{upgrade:false,type:"string",value:"unsigned_16_nofill"},MEM_show_segments:{upgrade:false,type:"boolean",value:false},MEM_show_source:{upgrade:false,type:"boolean",value:false},MEM_display_direction:{upgrade:false,type:"string",value:"h2l"},is_editable:{upgrade:false,type:"boolean",value:true},DBG_delay:{upgrade:false,type:"int",value:5},DBG_level:{upgrade:false,type:"string",value:"microinstruction"},DBG_limitins:{upgrade:false,type:"int",value:1e4},DBG_limitick:{upgrade:false,type:"int",value:1e3},DBG_skip_notifycolon:{upgrade:false,type:"boolean",value:false},ICON_theme:{upgrade:false,type:"string",value:"classic"},AS_enable:{upgrade:false,type:"boolean",value:true},AS_delay:{upgrade:false,type:"int",value:500},NOTIF_delay:{upgrade:false,type:"int",value:1e3},CPUCU_size:{upgrade:false,type:"int",value:7},C1C2_size:{upgrade:false,type:"int",value:8},SHOWCODE_label:{upgrade:false,type:"boolean",value:true},SHOWCODE_addr:{upgrade:false,type:"boolean",value:true},SHOWCODE_hex:{upgrade:false,type:"boolean",value:true},SHOWCODE_ins:{upgrade:false,type:"boolean",value:true},SHOWCODE_pins:{upgrade:false,type:"boolean",value:true},ws_mode:{upgrade:false,type:"string",value:"newbie"},ws_action:{upgrade:false,type:"string",value:"checkpoint"},is_interactive:{upgrade:false,type:"boolean",value:true},is_quick_interactive:{upgrade:false,type:"boolean",value:false},ws_idiom:{upgrade:false,type:"string",value:"en"},use_voice:{upgrade:false,type:"boolean",value:false},ws_skin_ui:{upgrade:false,type:"string",value:"classic"},ws_skin_user:{upgrade:false,type:"string",value:"only_asm:of:only_frequent:of"},ws_skin_dark_mode:{upgrade:false,type:"boolean",value:false},editor_theme:{upgrade:false,type:"string",value:"default"},editor_mode:{upgrade:false,type:"string",value:"default"},base_url:{upgrade:true,type:"string",value:"https://acaldero.github.io/wepsim/ws_dist/"},cfg_url:{upgrade:true,type:"string",value:"repo/configuration/default.json"},example_url:{upgrade:true,type:"string",value:"repo/examples_set/default.json"},hw_url:{upgrade:true,type:"string",value:"repo/hardware/hw.json"},max_json_size:{upgrade:true,type:"int",value:1*1024*1024},verbal_verbose:{upgrade:false,type:"string",value:"math"},extended_ui:{upgrade:false,type:"boolean",value:false},use_ga:{upgrade:false,type:"boolean",value:true}};if(is_mobile()){wscfg.NOTIF_delay.value=2e3;wscfg.ICON_theme.value="cat1";wscfg.CPUCU_size.value=7;wscfg.C1C2_size.value=14;wscfg.ws_skin_ui.value="compact"}return wscfg}function set_secondary_cfg(){var dbg_delay=get_cfg("DBG_delay");if(dbg_delay<5){cfg_show_rf_delay=350;cfg_show_eltos_delay=350;cfg_show_main_memory_delay=450;cfg_show_control_memory_delay=360;cfg_show_dbg_ir_delay=300;cfg_show_rf_refresh_delay=120}else{cfg_show_rf_delay=100;cfg_show_eltos_delay=100;cfg_show_main_memory_delay=150;cfg_show_control_memory_delay=120;cfg_show_dbg_ir_delay=100;cfg_show_rf_refresh_delay=30}cfg_show_asmdbg_pc_delay=50;if(dbg_delay<3)cfg_show_asmdbg_pc_delay=150}var ws_cfg_hash={};var ws_cfg_set=[];function cfgset_init(){var url_list=get_cfg("cfg_url");ws_cfg_set=wepsim_url_getJSON(url_list);for(var i=0;i"+index+"/"+ws_records.length+" "+msg)}if(ws_record_pb_obj!==null){var next_pbval=100*index/ws_records.length;ws_record_pb_obj.css("width",next_pbval+"%").attr("aria-valuenow",next_pbval)}}function simcore_record_playAt(index_current,index_last){if(ws_is_playing===false){simcore_record_showMsg(ws_last_played,"Stopped by user.");return}ws_last_played=index_current;if(index_current>=index_last){simcore_record_showMsg(index_last,"Done.");return}if(ws_records[index_current].description==="_pending event_"){simcore_record_playAt(index_current+1,index_last);return}eval(ws_records[index_current].element);var index_next=index_current+1;simcore_record_showMsg(index_next,ws_records[index_current].description);var wait_time=500;if(index_next0&&ws_records[ws_records.length-1].description==="_pending event_"){distance=ws_glowing_time}simcore_record_pushElto("_pending event_",";",distance)}}function simcore_record_resolve_pending(description,elto){if(ws_is_recording===true){var last_pending=ws_records.length;while(last_pending>0){last_pending--;if(ws_records[last_pending].description==="_pending event_"){break}}if(last_pending===0){simcore_record_setTimeBeforeNow(0);simcore_record_append_new(description,elto);return}ws_records[last_pending].description=description;ws_records[last_pending].element=elto;simcore_record_showMsg(0,"Recording...")}}function simcore_record_setTimeBeforeNow(distance){ws_last_time=Date.now()-distance}function simcore_record_addTimeAfterLast(distance){ws_last_time=ws_last_time+distance}function array_includes(arr,val){if(typeof arr.includes!="undefined"){return arr.includes(val)}for(var i=0;i0){e=i;n=n+1}}if(n>0){var tri_state_names=simhw_internalState("tri_state_names");var tri_name=tri_state_names[e];update_draw(simhw_sim_signal(tri_name),1)}if(n>1){update_bus_visibility("internalbus_fire","visible");simhw_internalState_set("fire_visible","internalbus",true);simhw_sim_state("BUS_IB").value=4294967295}else{update_bus_visibility("internalbus_fire","hidden");simhw_internalState_set("fire_visible","internalbus",false)}return n}function update_system_bus_fire(number_active_tri){if(simhw_internalState_get("fire_visible","databus")==true){update_bus_visibility("databus_fire","hidden");simhw_internalState_set("fire_visible","databus",false)}if(number_active_tri>1){update_bus_visibility("databus_fire","visible");simhw_internalState_set("fire_visible","databus",true);simhw_sim_state("BUS_DB").value=4294967295}return number_active_tri}function fn_updateE_now(key){if("E"==simhw_sim_signal(key).type){update_state(key)}}function fn_updateE_future(key){if(jit_fire_ndep[key]<1)fn_updateE_now(key);else return new Promise((function(resolve,reject){fn_updateE_now(key)}))}function fn_updateL_now(key){update_draw(simhw_sim_signal(key),simhw_sim_signal(key).value);if("L"==simhw_sim_signal(key).type){update_state(key)}}function fn_updateL_future(key){if(jit_fire_ndep[key]<1)fn_updateL_now(key);else return new Promise((function(resolve,reject){fn_updateL_now(key)}))}function update_state(key){var index_behavior=0;switch(simhw_sim_signal(key).behavior.length){case 0:return;break;case 1:index_behavior=0;break;default:index_behavior=simhw_sim_signal(key).value;if(simhw_sim_signal(key).behavior.lengthreg_maddr){break}assoc_i=i}if(-1==assoc_i){ws_alert("A new 'unknown' instruction is inserted,\n"+"please edit it (co, nwords, etc.) in the firmware textarea.");var new_ins=new Object;new_ins["name"]="unknown";new_ins["signature"]="unknown";new_ins["signatureGlobal"]="unknown";new_ins["co"]=0;new_ins["nwords"]=0;new_ins["mc-start"]=0;new_ins["fields"]=new Array;new_ins["microcode"]=new Array;new_ins["microcomments"]=new Array;SIMWARE["firmware"].push(new_ins);assoc_i=SIMWARE["firmware"].length-1}var pos=reg_maddr-parseInt(SIMWARE["firmware"][assoc_i]["mc-start"]);if(typeof SIMWARE["firmware"][assoc_i]["microcode"][pos]=="undefined"){SIMWARE["firmware"][assoc_i]["microcode"][pos]=new Object;SIMWARE["firmware"][assoc_i]["microcomments"][pos]=""}SIMWARE["firmware"][assoc_i]["microcode"][pos][key]=simhw_sim_signal(key).value;if(simhw_sim_signal(key).default_value==simhw_sim_signal(key).value){delete SIMWARE["firmware"][assoc_i]["microcode"][pos][key]}var bits=get_value(simhw_sim_state("REG_IR")).toString(2);bits="00000000000000000000000000000000".substring(0,32-bits.length)+bits;show_memories_values()}function propage_signal_update(key){if(true===get_cfg("is_interactive")){if(simhw_sim_signal(key).value!=simhw_sim_signal(key).default_value)simhw_sim_state("REG_MICROINS").value[key]=simhw_sim_signal(key).value;else delete simhw_sim_state("REG_MICROINS").value[key];var maddr_name=simhw_sim_ctrlStates_get().mpc.state;var curr_maddr=get_value(simhw_sim_state(maddr_name));var mc_obj=simhw_internalState("MC");var mcelto=control_memory_get(mc_obj,curr_maddr);if(typeof mcelto==="undefined"){mcelto={value:{},comments:null}}mcelto.value[key]=simhw_sim_signal(key).value;mcelto.comments=[];control_memory_set(mc_obj,curr_maddr,mcelto);update_signal_firmware(key);var SIMWARE=get_simware();document.getElementById("inputFirmware").value=saveFirmware(SIMWARE)}compute_behavior("FIRE "+key)}function update_memories(preSIMWARE){var i=0;set_simware(preSIMWARE);var SIMWARE=get_simware();simhw_internalState_reset("MC",{});var mc_obj=simhw_internalState("MC");var mcelto=null;for(i=0;i>23&255)-127;var mantissa=1+(hexvalue&8388607)/8388608;var valuef=sign*mantissa*Math.pow(2,exponent);if(-127===exponent)if(1===mantissa)valuef=sign===1?"+0":"-0";else valuef=sign*((hexvalue&8388607)/8388607)*Math.pow(2,-126);if(128===exponent)if(1===mantissa)valuef=sign===1?"+Inf":"-Inf";else valuef="NaN";return valuef}function uint_to_float32(value){var buf=new ArrayBuffer(4);new Uint32Array(buf)[0]=value;return new Float32Array(buf)[0]}function float32_to_uint(value){var buf=new ArrayBuffer(4);new Float32Array(buf)[0]=value;return new Uint32Array(buf)[0]}function float_class(a){var s=a&2147483648;s=s>>31;var e=a&2139095040;e=e>>23;var m=a&8388607;let rd=0;if(!m&&!e){rd=s?3:4}else if(!e){rd=s?2:6}else if(!(e^255)){if(m)rd=s?8:9;else rd=s?0:7}else{rd=s?1:5}return rd}function float_class_power2(a){var s=a&2147483648;s=s>>31;var e=a&2139095040;e=e>>23;var m=a&8388607;let rd=0;if(!m&&!e){rd=s?1<<3:1<<4}else if(!e){rd=s?1<<2:1<<6}else if(!(e^255)){if(m)rd=s?1<<8:1<<9;else rd=s?1<<0:1<<7}else{rd=s?1<<1:1<<5}return rd}function hex2char8(hexvalue){var valuec=[];valuec[0]=String.fromCharCode((hexvalue&4278190080)>>24);valuec[1]=String.fromCharCode((hexvalue&16711680)>>16);valuec[2]=String.fromCharCode((hexvalue&65280)>>8);valuec[3]=String.fromCharCode((hexvalue&255)>>0);return valuec}function simcoreui_pack(val,pack_size){var base_str="0".repeat(pack_size);return base_str.substring(0,pack_size-val.length)+val}function hex2bin(hexvalue){var valuebin=hexvalue.toString(2);valuebin=simcoreui_pack(valuebin,32);valuebin=valuebin.substring(0,4)+" "+valuebin.substring(4,8)+" "+valuebin.substring(8,12)+" "+valuebin.substring(12,16)+"
"+valuebin.substring(16,20)+" "+valuebin.substring(20,24)+" "+valuebin.substring(24,28)+" "+valuebin.substring(28,32);return valuebin}function value2string(format,value){var fmt_value="";var fmt=format.split("_");switch(fmt[0]){case"unsigned":fmt_value=value.toString(fmt[1]).toUpperCase();break;case"float":fmt_value=hex2float(value);break;case"char":fmt_value="'"+String.fromCharCode(value)+"'";break;default:fmt_value=value.toString()}if(fmt[2]==="fill"){fmt_value=simcoreui_pack(fmt_value,8)}return fmt_value}function show_rf_names(){return simcore_action_ui("CPU",0,"show_rf_names")()}function get_screen_content(){return simcore_action_ui("SCREEN",0,"get_screen_content")()}function set_screen_content(screen){simcore_action_ui("SCREEN",0,"set_screen_content")(screen)}function get_keyboard_content(){return simcore_action_ui("KBD",0,"get_keyboard_content")()}function set_keyboard_content(keystrokes){simcore_action_ui("KBD",0,"set_keyboard_content")(keystrokes)}function show_main_memory(memory,index,redraw,updates){return simcore_action_ui("MEMORY",0,"show_main_memory")(memory,index,redraw,updates)}function show_control_memory(memory,index,redraw){return simcore_action_ui("MEMORY",0,"show_control_memory")(memory,index,redraw)}function show_cache_memory(memory){return simcore_action_ui("MEMORY",0,"show_cache_memory")(memory)}function show_memories_values(){var pc_name=simhw_sim_ctrlStates_get().pc.state;var reg_pc=get_value(simhw_sim_state(pc_name));show_main_memory(simhw_internalState("MP"),reg_pc,true,true);var maddr_name=simhw_sim_ctrlStates_get().mpc.state;var reg_maddr=get_value(simhw_sim_state(maddr_name));show_control_memory(simhw_internalState("MC"),reg_maddr,true);show_cache_memory(simhw_internalState("CM"))}function update_draw(obj,value){return simcore_action_ui("CPU",1,"update_draw")(obj,value)}function update_bus_visibility(bus_name,value){return simcore_action_ui("CPU",1,"update_bus_visibility")(bus_name,value)}function refresh(){for(var key in simhw_sim_signals()){update_draw(simhw_sim_signals()[key],simhw_sim_signals()[key].value)}show_dbg_ir(get_value(simhw_sim_state("REG_IR_DECO")))}function show_dbg_ir(value){return simcore_action_ui("MEMORY",0,"show_dbg_ir")(value)}function show_dbg_mpc(){return simcore_action_ui("MEMORY",0,"show_dbg_mpc")()}function show_asmdbg_pc(){return simcore_action_ui("MEMORY",0,"show_asmdbg_pc")()}function ws_alert(msg){if(typeof document==="undefined"){console.log(msg);return true}alert(msg);return true}function element_scroll_get(list_id){var offset=0;var obj_byid=$(list_id);if(obj_byid.length>0){offset=obj_byid[0].scrollTop}return offset}function element_scroll_set(list_id,offset){var obj_byid=$(list_id);if(obj_byid.length>0){obj_byid[0].scrollTop=offset}}function element_scroll_setRelative(list_id,obj_id,offset){var obj_byid=$(obj_id);if(obj_byid.length>0){var topPos=obj_byid[0].offsetTop;element_scroll_set(list_id,topPos+offset)}}var colors_schemes={color14:["#000000","#FFFFFF","#FF0000","#FF8800","#FFFF00","#88FF00","#00FF00","#00FF88","#00FFFF","#0088FF","#0000FF","#8800FF","#FF00FF","#FF0088"],color16:["#000000","#FFFFFF","#9D9D9D","#BE2633","#E06F8B","#493C2B","#A46422","#EB8931","#F7E26B","#2F484E","#44891A","#A3CE27","#1B2632","#005784","#31A2F2","#B2DCEF"],color256:["#000000","#800000","#008000","#808000","#000080","#800080","#008080","#c0c0c0","#808080","#ff0000","#00ff00","#ffff00","#0000ff","#ff00ff","#00ffff","#ffffff","#000000","#00005f","#000087","#0000af","#0000d7","#0000ff","#005f00","#005f5f","#005f87","#005faf","#005fd7","#005fff","#008700","#00875f","#008787","#0087af","#0087d7","#0087ff","#00af00","#00af5f","#00af87","#00afaf","#00afd7","#00afff","#00d700","#00d75f","#00d787","#00d7af","#00d7d7","#00d7ff","#00ff00","#00ff5f","#00ff87","#00ffaf","#00ffd7","#00ffff","#5f0000","#5f005f","#5f0087","#5f00af","#5f00d7","#5f00ff","#5f5f00","#5f5f5f","#5f5f87","#5f5faf","#5f5fd7","#5f5fff","#5f8700","#5f875f","#5f8787","#5f87af","#5f87d7","#5f87ff","#5faf00","#5faf5f","#5faf87","#5fafaf","#5fafd7","#5fafff","#5fd700","#5fd75f","#5fd787","#5fd7af","#5fd7d7","#5fd7ff","#5fff00","#5fff5f","#5fff87","#5fffaf","#5fffd7","#5fffff","#870000","#87005f","#870087","#8700af","#8700d7","#8700ff","#875f00","#875f5f","#875f87","#875faf","#875fd7","#875fff","#878700","#87875f","#878787","#8787af","#8787d7","#8787ff","#87af00","#87af5f","#87af87","#87afaf","#87afd7","#87afff","#87d700","#87d75f","#87d787","#87d7af","#87d7d7","#87d7ff","#87ff00","#87ff5f","#87ff87","#87ffaf","#87ffd7","#87ffff","#af0000","#af005f","#af0087","#af00af","#af00d7","#af00ff","#af5f00","#af5f5f","#af5f87","#af5faf","#af5fd7","#af5fff","#af8700","#af875f","#af8787","#af87af","#af87d7","#af87ff","#afaf00","#afaf5f","#afaf87","#afafaf","#afafd7","#afafff","#afd700","#afd75f","#afd787","#afd7af","#afd7d7","#afd7ff","#afff00","#afff5f","#afff87","#afffaf","#afffd7","#afffff","#d70000","#d7005f","#d70087","#d700af","#d700d7","#d700ff","#d75f00","#d75f5f","#d75f87","#d75faf","#d75fd7","#d75fff","#d78700","#d7875f","#d78787","#d787af","#d787d7","#d787ff","#d7af00","#d7af5f","#d7af87","#d7afaf","#d7afd7","#d7afff","#d7d700","#d7d75f","#d7d787","#d7d7af","#d7d7d7","#d7d7ff","#d7ff00","#d7ff5f","#d7ff87","#d7ffaf","#d7ffd7","#d7ffff","#ff0000","#ff005f","#ff0087","#ff00af","#ff00d7","#ff00ff","#ff5f00","#ff5f5f","#ff5f87","#ff5faf","#ff5fd7","#ff5fff","#ff8700","#ff875f","#ff8787","#ff87af","#ff87d7","#ff87ff","#ffaf00","#ffaf5f","#ffaf87","#ffafaf","#ffafd7","#ffafff","#ffd700","#ffd75f","#ffd787","#ffd7af","#ffd7d7","#ffd7ff","#ffff00","#ffff5f","#ffff87","#ffffaf","#ffffd7","#ffffff","#080808","#121212","#1c1c1c","#262626","#303030","#3a3a3a","#444444","#4e4e4e","#585858","#626262","#6c6c6c","#767676","#808080","#8a8a8a","#949494","#9e9e9e","#a8a8a8","#b2b2b2","#bcbcbc","#c6c6c6","#d0d0d0","#dadada","#e4e4e4","#eeeeee"]};function colors_clone(cs){var colors=colors_schemes[cs];if(typeof colors=="undefined"){colors=colors_schemes["color16"]}return colors.map((x=>x))}function simcore_init(with_ui){var ret={};ret.msg="";ret.ok=true;if(with_ui){restore_cfg()}else{reset_cfg_values()}return ret}function simcore_init_hw(simhw_name){var ret={};ret.msg="";ret.ok=true;var hwid=simhw_getIdByName(simhw_name);if(hwid<0){ret.msg="ERROR: unknown hardware: "+simhw_name+".
\n";ret.ok=false;return ret}simhw_setActive(hwid);var ret1=simcore_init_ui({});if(false===ret1.ok){ret.msg=ret.msg;ret.ok=false;return ret}return ret}function simcore_welcome(){var ret={};ret.msg="";ret.ok=true;console.log("");console.log("██╗ ██╗███████╗██████╗ ███████╗██╗███╗ ███╗");console.log("██║ ██║██╔════╝██╔══██╗██╔════╝██║████╗ ████║");console.log("██║ █╗ ██║█████╗ ██████╔╝███████╗██║██╔████╔██║");console.log("██║███╗██║██╔══╝ ██╔═══╝ ╚════██║██║██║╚██╔╝██║");console.log("╚███╔███╔╝███████╗██║ ███████║██║██║ ╚═╝ ██║");console.log(" ╚══╝╚══╝ ╚══════╝╚═╝ ╚══════╝╚═╝╚═╝ ╚═╝");console.log("");console.log("Stable: https://github.com/wepsim/wepsim");console.log("Beta: https://github.com/acaldero/wepsim");console.log("");return ret}function simcore_init_ui(hash_detail2init){var ret={};ret.msg="";ret.ok=true;var detail_id=0;var sim_components=simhw_sim_components();for(var elto in sim_components){sim_components[elto].details_ui=[];for(var index in sim_components[elto].details_name){sim_components[elto].details_ui[index]={};detail_id=sim_components[elto].details_name[index];if(typeof hash_detail2init[detail_id]!=="undefined"){sim_components[elto].details_ui[index]=hash_detail2init[detail_id];sim_components[elto].details_ui[index].init()}}}return ret}function simcore_action_ui(component_name,detail_id,action_name){var sim_components=simhw_sim_components();if(typeof sim_components[component_name].details_ui==="undefined"){return simcore_do_nothing_handler}if(typeof sim_components[component_name].details_ui[detail_id][action_name]==="undefined"){return simcore_do_nothing_handler}return sim_components[component_name].details_ui[detail_id][action_name]}function simcore_init_eventlistener(context,hash_detail2action,hash_signal2action){var context_obj=null;var r=[];var o=null;context_obj=document.getElementById(context).contentDocument;if(null==context_obj){console.log('warning: unreferenced graphic element context named "'+r[0]+'".');return}var sim_signals=simhw_sim_signals();for(var key in sim_signals){if(typeof hash_signal2action[key+"click"]==="undefined"){hash_signal2action[key+"click"]=function(key_value){return function(){hash_signal2action[""](key_value,"click")}}(key)}if(typeof hash_signal2action[key+"dblclick"]==="undefined"){hash_signal2action[key+"dblclick"]=function(key_value){return function(){hash_signal2action[""](key_value,"dblclick")}}(key)}for(var j=0;j\n"+"Please load some assembly code.
";ret.ok=false;return ret}var SIMWARE=get_simware();if(!(typeof curr_segments[".ktext"]!="undefined"&&SIMWARE.labels_asm.kmain)&&!(typeof curr_segments[".text"]!="undefined"&&SIMWARE.labels_asm.main)){ret.msg="labels 'kmain' (in .ktext) or 'main' (in .text) do not exist!";ret.ok=false;return ret}return ret}function simcore_packerror_at(reg_maddr,msg){var ret={};var hex_maddr="0x"+parseInt(reg_maddr).toString(16);ret.ok=false;ret.msg=msg+" at maddr="+hex_maddr+".";return ret}function simcore_check_if_can_continue2(reg_maddr,reg_pc){var ret={};ret.ok=true;ret.msg="";var curr_MC=simhw_internalState("MC");var mcelto=control_memory_get(curr_MC,reg_maddr);if(typeof mcelto==="undefined"){return simcore_packerror_at(reg_maddr,"Error: undefined microinstruction")}if(simhw_internalState_get("fire_visible","databus")==true||simhw_internalState_get("fire_visible","internalbus")==true){return simcore_packerror_at(reg_maddr,"Error: two or more tri-states are active")}var curr_segments=simhw_internalState("segments");if(reg_pc=curr_segments[".ktext"].begin){return ret}if(reg_pc=curr_segments[".text"].begin){return ret}if(mcelto.is_native&&0===reg_maddr){if(reg_pc==curr_segments[".ktext"].end||reg_pc==curr_segments[".text"].end){return ret}}if(false==mcelto.is_native&&0!==reg_maddr){if(reg_pc==curr_segments[".ktext"].end||reg_pc==curr_segments[".text"].end){return ret}}ret.ok=false;ret.msg="The program has finished because the PC register points outside .ktext/.text code segments";return ret}function simcore_check_if_can_continue(){var pc_name=simhw_sim_ctrlStates_get().pc.state;var reg_pc=parseInt(get_value(simhw_sim_state(pc_name)));var maddr_name=simhw_sim_ctrlStates_get().mpc.state;var reg_maddr=get_value(simhw_sim_state(maddr_name));return simcore_check_if_can_continue2(reg_maddr,reg_pc)}function simcore_reset(){var ret={};ret.msg="";ret.ok=true;var SIMWARE=get_simware();var curr_firm=simhw_internalState("FIRMWARE");var curr_segments=simhw_internalState("segments");var curr_MC=simhw_internalState("MC");var sim_components=simhw_sim_components();var ctrl_states=simhw_sim_ctrlStates_get();var pc_name=ctrl_states.pc.state;var pc_state=simhw_sim_state(pc_name);var sp_name=ctrl_states.sp.state;var sp_state=simhw_sim_state(sp_name);if(curr_firm.stackRegister!=null){sp_name=curr_firm.stackRegister;sp_state=simhw_sim_states().BR[sp_name];ctrl_states.sp.state="BR."+curr_firm.stackRegister}for(var elto in sim_components){var reset_signal_name=sim_components[elto].name+"_RESET";compute_general_behavior(reset_signal_name)}if(typeof curr_segments[".ktext"]!=="undefined"&&SIMWARE.labels_asm.kmain){set_value(pc_state,parseInt(SIMWARE.labels_asm.kmain));show_asmdbg_pc()}else if(typeof curr_segments[".text"]!=="undefined"&&SIMWARE.labels_asm.main){set_value(pc_state,parseInt(SIMWARE.labels_asm.main));show_asmdbg_pc()}if(typeof curr_segments[".stack"]!=="undefined"&&typeof sp_state!=="undefined"){set_value(sp_state,parseInt(curr_segments[".stack"].end)&4294967292)}var new_maddr=get_value(simhw_sim_state("MUXA_MICROADDR"));var mcelto=control_memory_get(curr_MC,new_maddr);if(typeof mcelto==="undefined"){mcelto={value:simhw_sim_state("REG_MICROINS").default_value,is_native:false}}var new_mins=get_value(mcelto);if(false==mcelto.is_native){compute_general_behavior("CLOCK")}show_dbg_ir(get_value(simhw_sim_state("REG_IR_DECO")));for(elto in sim_components){for(var index in sim_components[elto].details_name){if(typeof sim_components[elto].details_ui[index].reset!=="undefined"){sim_components[elto].details_ui[index].reset()}}}return ret}function simcore_execute_microinstruction(){var ret=simcore_check_if_can_continue();if(false===ret.ok){return ret}compute_general_behavior("CLOCK");show_dbg_mpc();return ret}function simcore_execute_microinstruction2(reg_maddr,reg_pc){var ret=simcore_check_if_can_continue2(reg_maddr,reg_pc);if(false===ret.ok){return ret}compute_general_behavior("CLOCK");show_dbg_mpc();return ret}function simcore_execute_microprogram(options){var ret=simcore_check_if_can_continue();if(false===ret.ok){return ret}var before_state=null;var after_state=null;var curr_mpc="";var curr_MC=simhw_internalState("MC");var maddr_name=simhw_sim_ctrlStates_get().mpc.state;var maddr_state=simhw_sim_state(maddr_name);if(typeof options.before_microinstruction==="undefined"){options.before_microinstruction=simcore_do_nothing_handler}if(typeof options.after_microinstruction==="undefined"){options.after_microinstruction=simcore_do_nothing_handler}var i_clks=0;var limitless=options.cycles_limit<0;var cur_addr=0;var mcelto=null;var oolimits=false;do{options.before_microinstruction(curr_MC,cur_addr);compute_general_behavior("CLOCK");i_clks++;options.after_microinstruction(curr_MC,cur_addr);if(limitless===false&&i_clks>=options.cycles_limit){ret.msg="Warning: clock cycles limit reached in a single instruction.";ret.ok=false;break}cur_addr=get_value(maddr_state);mcelto=control_memory_get(curr_MC,cur_addr);if(typeof mcelto==="undefined"){ret.msg="Error: undefined microinstruction at "+cur_addr+".";ret.ok=false;break}if(i_clks>=options.cycles_limit&&-1!=options.cycles_limit){oolimits=true}}while(false==oolimits&&0!=cur_addr);if(true==ret.ok&&mcelto.is_native){compute_general_behavior("CLOCK")}if(get_cfg("DBG_level")=="microinstruction"){show_dbg_mpc()}return ret}function simcore_execute_program(options){var ret={};ret.ok=true;ret.msg="";var curr_segments=simhw_internalState("segments");var pc_name=simhw_sim_ctrlStates_get().pc.state;var pc_state=simhw_sim_state(pc_name);var reg_pc=get_value(pc_state);var reg_pc_before=get_value(pc_state)-4;var code_begin=0;if(typeof curr_segments[".text"]!="undefined"&&typeof curr_segments[".text"].begin!="undefined")code_begin=parseInt(curr_segments[".text"].begin);var code_end=0;if(typeof curr_segments[".text"]!="undefined"&&typeof curr_segments[".text"].end!="undefined")code_end=parseInt(curr_segments[".text"].end);var kcode_begin=0;if(typeof curr_segments[".ktext"]!="undefined"&&typeof curr_segments[".ktext"].begin!="undefined")kcode_begin=parseInt(curr_segments[".ktext"].begin);var kcode_end=0;if(typeof curr_segments[".ktext"]!="undefined"&&typeof curr_segments[".ktext"].end!="undefined")kcode_end=parseInt(curr_segments[".ktext"].end);var ret1=null;var before_state=null;var after_state=null;var curr_pc="";var SIMWARE=get_simware();if(typeof options.verbalize!=="undefined"){set_cfg("verbal_verbose",options.verbalize)}if(typeof options.before_instruction==="undefined"){options.before_instruction=simcore_do_nothing_handler}if(typeof options.after_instruction==="undefined"){options.after_instruction=simcore_do_nothing_handler}var ins_executed=0;while(reg_pc=code_begin||reg_pc=kcode_begin){options.before_instruction(SIMWARE,reg_pc);ret1=simcore_execute_microprogram(options);if(false===ret1.ok){return ret1}options.after_instruction(SIMWARE,reg_pc);ins_executed++;if(ins_executed>options.instruction_limit&&-1!=options.instruction_limit){ret.ok=false;ret.msg="more than "+options.instruction_limit+" instructions executed before application ends.";return ret}reg_pc_before=reg_pc;reg_pc=get_value(pc_state)}return ret}function simcore_do_nothing_handler(){return null}function simcore_compile_firmware(textToMCompile){var ret={};ret.msg="";ret.ok=true;if(""==textToMCompile){ret.msg="Empty Firmware";ret.ok=false;return ret}var preSM=null;try{preSM=loadFirmware(textToMCompile);ret.simware=preSM}catch(e){ret.msg="ERROR: at line: "+e.lineNumber+" and column: "+e.columnNumber;ret.ok=false;return ret}if(preSM.error!=null){ret.msg=preSM.error;ret.ok=false;return ret}update_memories(preSM);simcore_reset();return ret}function simcore_compile_assembly(textToCompile){var ret={};ret.msg="";ret.ok=true;var SIMWARE=get_simware();if(SIMWARE.firmware.length===0){ret.msg="Empty microcode, please load the microcode first.";ret.ok=false;return ret}var SIMWAREaddon=simlang_compile(textToCompile,SIMWARE);ret.simware=SIMWAREaddon;if(SIMWAREaddon.error!=null){ret.msg=SIMWAREaddon.error;ret.ok=false;return ret}set_simware(SIMWAREaddon);update_memories(SIMWARE);simcore_reset();return ret}function simcore_hardware_export(hw_name){var ret={};ret.msg="{}";ret.ok=false;var hw_obj=simhw_getObjByName(hw_name);if(null===hw_obj){return ret}ret.ok=true;ret.msg=JSON.stringify(hw_obj,(function(key,value){if(typeof value==="function"){return"/Function("+value.toString()+")/"}return value}));return ret}function simcore_hardware_import(hw_json){var ret={};ret.msg="";ret.ok=true;hw_obj=JSON.parse(hw_json,(function(key,value){if(typeof value==="string"&&value.startsWith("/Function(")&&value.endsWith(")/")){value=value.substring(10,value.length-2);return eval("("+value+")")}return value}));simhw_add(hw_obj);return ret}function simcore_native_get_signal(elto){return get_value(simhw_sim_signal(elto))>>>0}function simcore_native_set_signal(elto,value){set_value(simhw_sim_signal(elto),value);compute_behavior("FIRE "+elto);return value}function simcore_native_get_value(component,elto){var index=0;var sim_components=simhw_sim_components();var compo_index=component;if("BR"===component)compo_index="CPU";if("DEVICE"===component)compo_index="IO";if(typeof sim_components[compo_index].get_value!=="undefined"){return sim_components[compo_index].get_value(elto)}return false}function simcore_native_set_value(component,elto,value){var index=0;var sim_components=simhw_sim_components();var compo_index=component;if("BR"===component)compo_index="CPU";if("DEVICE"===component)compo_index="IO";if(typeof sim_components[compo_index].set_value!=="undefined"){return sim_components[compo_index].set_value(elto,value)}return false}function simcore_native_get_fields(signature_raw){var SIMWARE=get_simware();for(var key in SIMWARE.firmware){if(SIMWARE.firmware[key].signatureRaw===signature_raw){return SIMWARE.firmware[key].fields}}}function simcore_native_get_field_from_ir(fields,index){if(typeof fields[index]==="undefined"){ws_alert("simcore_native_get_field_from_ir: index ("+index+") out of range.");return false}var value=get_value(simhw_sim_state("REG_IR"));var left_shift=31-parseInt(fields[index].startbit);var right_shift=parseInt(fields[index].stopbit);value=value<>>left_shift;value=value>>>right_shift;return value}function simcore_native_deco(){compute_behavior("DECO")}function simcore_native_go_maddr(maddr){set_value(simhw_sim_state("MUXA_MICROADDR"),maddr)}function simcore_native_go_opcode(){var maddr=get_value(simhw_sim_state("ROM_MUXA"));set_value(simhw_sim_state("MUXA_MICROADDR"),maddr)}function simcore_native_go_instruction(signature_raw){var SIMWARE=get_simware();for(var key in SIMWARE.firmware){if(SIMWARE.firmware[key].signatureRaw===signature_raw){var maddr=SIMWARE.firmware[key]["mc-start"];set_value(simhw_sim_state("MUXA_MICROADDR"),maddr);return}}}function simcore_simstate_checklist2state(checklist){var o={};var ret=false;checklist=checklist.replace(/;|==|!=|>=|<=|=|>|v!=""));for(var i=0;i"===expected_result[compo][elto].op)diff.fulfill=parseInt(diff.obtained)>parseInt(diff.expected);else if("<"===expected_result[compo][elto].op)diff.fulfill=parseInt(diff.obtained)="===expected_result[compo][elto].op)diff.fulfill=parseInt(diff.obtained)>=parseInt(diff.expected);else if("<="===expected_result[compo][elto].op)diff.fulfill=parseInt(diff.obtained)<=parseInt(diff.expected);else if("=="===expected_result[compo][elto].op)diff.fulfill=diff.expected==diff.obtained;else if("!="===expected_result[compo][elto].op)diff.fulfill=diff.expected!=diff.obtained;d.result.push(diff);if(diff.fulfill===false)d.errors++}}if(newones_too&&typeof obtained_result[compo]!="undefined"){for(elto in obtained_result[compo]){d.neltos_obtained++;if(typeof expected_result[compo]!="undefined"&&typeof expected_result[compo][elto]!="undefined"){continue}diff={};diff.expected=obtained_result[compo][elto].default_value;diff.obtained=obtained_result[compo][elto].value;diff.fulfill=diff.expected===diff.obtained;diff.elto_type=compo.toLowerCase();diff.elto_id=obtained_result[compo][elto].id;diff.elto_op="=";d.result.push(diff);if(diff.fulfill===false)d.errors++}}}return d}function simcore_simstate_diff_results(expected_result,obtained_result){return simcore_simstate_check_results(expected_result,obtained_result,true)}function simcore_simstate_diff_states(before_state_obj,after_state_obj){var before_arr=simcore_simstate_state2checklist(before_state_obj,"").split(";");var after_arr=simcore_simstate_state2checklist(after_state_obj,"").split(";");return after_arr.filter((function(elto){return!before_arr.includes(elto)})).join(";").trim()}function simcore_simstate_checkreport2txt(checklist){var o="";for(var i=0;i"+""+""+"Type | "+"IdentificationId. | "+"Values in the clipboard state | "+"Values in the selected state | "+"
"+""+"";for(var i=0;i"+""+checklist[i].elto_type+" | "+""+checklist[i].elto_id+" | "+""+checklist[i].elto_op+" "+checklist[i].expected+" | "+""+checklist[i].obtained+" | "+""}o+=""+"";return o}function simcore_voice_canSpeak(){if(typeof window.speechSynthesis=="undefined"){return false}if(false===get_cfg("use_voice")){return false}return true}function simcore_voice_speak(msg){var ssu=null;if(simcore_voice_canSpeak()){ssu=new SpeechSynthesisUtterance(msg);ssu.lang="es-ES";if("en"==get_cfg("ws_idiom"))ssu.lang="en-US";if("es"==get_cfg("ws_idiom"))ssu.lang="es-EN";window.speechSynthesis.speak(ssu)}}function simcore_voice_stopSpeak(){if(simcore_voice_canSpeak()){window.speechSynthesis.cancel()}}var simcore_rest={};function simcore_rest_reset(){simcore_rest={}}function simcore_rest_add(name,description){simcore_rest[name]={endpoint:description.endpoint,user:description.user,pass:description.pass,last_request:null}}function simcore_rest_list(){return simcore_rest}function simcore_rest_get(name){return simcore_rest[name]}function simcore_rest_call(name,method,uri,data){var rest_info=simcore_rest[name];if(typeof rest_info==="undefined"){return false}var api_endpoint=rest_info.endpoint;if(api_endpoint.value instanceof Vuex.Store){api_endpoint=get_value(api_endpoint)}if(api_endpoint.trim()===""){return false}var basic_auth="Basic "+btoa(rest_info.user+":"+rest_info.pass);var enc_data=JSON.stringify(data);var request={url:api_endpoint+uri,type:method,contentType:"application/json",accepts:"application/json",cache:false,dataType:"json",data:enc_data,beforeSend:function(xhr){if(rest_info.user.trim()!==""){xhr.setRequestHeader("Authorization",basic_auth)}},error:function(jqXHR){console.log("ajax error "+jqXHR.status)}};rest_info.last_request=$.ajax(request);return true}var simcore_notifications=[];function simcore_notifications_get(){return simcore_notifications}function simcore_notifications_reset(){simcore_notifications=[]}function simcore_notifications_add2(ntf){simcore_notifications.push({title:ntf.title,message:ntf.message,type:ntf.type,date:ntf.date})}function simcore_notifications_add(ntf_title,ntf_message,ntf_type,ntf_delay){simcore_notifications.push({title:$("").html(ntf_title).text(),message:$("
").html(ntf_message).text(),type:ntf_type,date:(new Date).getTime()})}function get_value(sim_obj){if(sim_obj.value instanceof Vuex.Store){return sim_obj.value.state.value}return sim_obj.value}function set_value(sim_obj,value){if(sim_obj.value instanceof Vuex.Store){sim_obj.value.commit("set_value",value);return}var old_value=sim_obj.value;sim_obj.value=value;if(old_value!=value){sim_obj.changed=true}}function reset_value(sim_obj){if(sim_obj.value instanceof Vuex.Store){set_value(sim_obj,sim_obj.default_value);return}if(typeof sim_obj.default_value=="object"){sim_obj.changed=true;sim_obj.value=Object.create(sim_obj.default_value);return}if(sim_obj instanceof Array){sim_obj.changed=true;for(var i=0;i",""":'"',"'":"'"};function treatHTMLSequences(text_with_html){var re=null;var key=null;for(key in html_sequences){re=new RegExp(key,"gi");text_with_html=text_with_html.replace(re,html_sequences[key])}return text_with_html}function control_memory_getkeys(memory){return Object.keys(memory)}function control_memory_get(memory,elto){return memory[elto]}function control_memory_set(memory,elto,melto){if(typeof melto.changed==="undefined")melto.changed=false;if(typeof melto.state==="undefined")melto.state=false;if(typeof melto.breakpoint==="undefined")melto.breakpoint=false;if(typeof melto.notify==="undefined")melto.notify=[];if(typeof melto.is_native==="undefined")melto.is_native=false;var comments_str="";if(null!=melto.comments){comments_str=melto.comments;if(melto.comments instanceof Array)comments_str=melto.comments.join("\n");melto.state=melto.state||comments_str.trim().split("state:").length>1;melto.breakpoint=melto.breakpoint||comments_str.trim().split("break:").length>1;melto.notify=comments_str.trim().split("notify:");for(var k=0;k";if(active_verbal.trim()==="")active_verbal="";return"Activated signals are: "+active_signals+". Associated actions are: "+active_verbal}function main_memory_getkeys(memory){return Object.keys(memory)}function main_memory_get(memory,elto){return memory[elto]}function main_memory_set(memory,elto,melto){if(typeof melto.changed==="undefined")melto.changed=false;if(typeof melto.state==="undefined")melto.state=false;if(typeof melto.breakpoint==="undefined")melto.breakpoint=false;if(typeof melto.notify==="undefined")melto.notify=[];if(typeof melto.is_assembly==="undefined")melto.is_assembly=false;if(typeof melto.source==="undefined")melto.source="";var comments_str="";if(null!=melto.comments){comments_str=melto.comments.join("\n");melto.state=melto.state||comments_str.trim().split("state:").length>1;melto.breakpoint=melto.breakpoint||comments_str.trim().split("break:").length>1;melto.notify=comments_str.trim().split("notify:");for(var k=0;k>8;if(2==filter_elto)dbvalue=(value&16711680)>>16;if(3==filter_elto)dbvalue=(value&4278190080)>>24;break;case 1:if(0==filter_elto)dbvalue=value&65535;if(1==filter_elto)dbvalue=value&65535;if(2==filter_elto)dbvalue=(value&4294901760)>>16;if(3==filter_elto)dbvalue=(value&4294901760)>>16;break;case 2:if(0==filter_elto)dbvalue=value&16777215;if(1==filter_elto)dbvalue=value&4294967040;break;case 3:dbvalue=value;break}return dbvalue}function main_memory_updatevalues(value,dbvalue,filter_size,filter_elto){switch(filter_size){case 0:if(0==filter_elto)value=value&4294967040|dbvalue&255;if(1==filter_elto)value=value&4294902015|(dbvalue&255)<<8;if(2==filter_elto)value=value&4278255615|(dbvalue&255)<<16;if(3==filter_elto)value=value&16777215|(dbvalue&255)<<24;break;case 1:if(0==filter_elto)value=value&4294901760|dbvalue&65535;if(1==filter_elto)value=value&4294901760|dbvalue&65535;if(2==filter_elto)value=value&65535|(dbvalue&65535)<<16;if(3==filter_elto)value=value&65535|(dbvalue&65535)<<16;break;case 2:if(0==filter_elto)value=value&4278190080|dbvalue&16777215;if(1==filter_elto)value=value&255|dbvalue&4294967040;break;case 3:value=dbvalue;break}return value}function main_memory_get_program_counter(){var r_ref=simhw_sim_ctrlStates_get().pc;var r_value=null;if(typeof r_ref!=="undefined"){r_ref=simhw_sim_state(r_ref.state)}if(typeof r_ref!=="undefined"){r_value=get_value(r_ref)}return r_value}function main_memory_get_baseaddr(){var r_ref=simhw_sim_ctrlStates_get();if(typeof r_ref==="undefined"){return null}var parts=null;var r_value=0;var r_ref2=null;var all_baseaddr={};for(var elto in r_ref){if(r_ref[elto].is_pointer==false){continue}parts=r_ref[elto].state.split(".");if(parts[0]=="BR"){r_value=4294967292;r_ref2=simhw_sim_states().BR[parts[1]]}else{r_value=0;r_ref2=simhw_sim_state(r_ref[elto].state)}if(typeof r_ref2!=="undefined"){r_value=get_value(r_ref2)}all_baseaddr[elto]=r_value}return all_baseaddr}function get_deco_from_pc(pc){var mp_obj=simhw_internalState("MP");if(typeof mp_obj==="undefined"||typeof mp_obj[pc]==="undefined"||typeof mp_obj[pc].source==="undefined"){return""}return mp_obj[pc].source}function get_verbal_from_current_pc(){var pc_name=simhw_sim_ctrlStates_get().pc.state;var reg_pc=get_value(simhw_sim_state(pc_name));var pc=parseInt(reg_pc)-4;var decins=get_deco_from_pc(pc);if(""==decins.trim()){decins="not jet defined"}return"Current instruction is: "+decins+" and PC points to "+show_value(pc)+". "}function cache_memory_update_stats(memory,address,parts,r_w,m_h,clock_timestamp){memory.stats.n_access++;memory.stats.last_addr=address;memory.stats.last_parts=parts;memory.stats.last_r_w=r_w;memory.stats.last_h_m=m_h;if(m_h=="miss"){memory.stats.n_misses++}else{memory.stats.n_hits++}memory.sets[parts.set].tags[parts.tag].n_access++;if(r_w=="write"){memory.sets[parts.set].tags[parts.tag].dirty=1}memory.sets[parts.set].tags[parts.tag].timestamp=clock_timestamp}function cache_memory_select_victim(memory,set){var keys=Object.keys(memory.sets[set].tags);var tag_victim=0;if(memory.cfg.replace_pol=="lfu"){tag_victim=keys[0];var tag_naccess=memory.sets[parts.set].tags[tag_victim].n_access;for(var i=1;imemory.sets[parts.set].tags[keys[i]].n_access){tag_victim=keys[i];tag_naccess=memory.sets[parts.set].tags[tag_victim].n_access}}}else if(memory.cfg.replace_pol=="fifo"){tag_victim=keys[0];var tag_stamp=memory.sets[parts.set].tags[tag_victim].timestamp;for(var i=1;imemory.sets[parts.set].tags[keys[i]].timestamp){tag_victim=keys[i];tag_stamp=memory.sets[parts.set].tags[tag_victim].timestamp}}}else if(memory.cfg.replace_pol=="first"){tag_victim=keys[0]}return tag_victim}function cache_memory_init(name,via_size,off_size,set_size,replace_pol,su_pol,next_cache){var c={stats:{},cfg:{},sets:{}};c.cfg.name=name;c.cfg.via_size=via_size;c.cfg.off_size=off_size;c.cfg.set_size=set_size;c.cfg.vps_size=via_size-set_size;c.cfg.tag_size=32-set_size-off_size;c.cfg.mask_tag=Math.pow(2,c.cfg.tag_size)-1>>>0;c.cfg.mask_set=Math.pow(2,c.cfg.set_size)-1>>>0;c.cfg.mask_off=Math.pow(2,c.cfg.off_size)-1>>>0;c.cfg.mask_tag=c.cfg.mask_tag<<32-c.cfg.tag_size>>>0;c.cfg.mask_set=c.cfg.mask_set<>>0;c.cfg.replace_pol=replace_pol;c.cfg.su_pol=su_pol;c.cfg.next_cache=next_cache;c.stats.n_access=0;c.stats.n_hits=0;c.stats.n_misses=0;c.stats.last_addr=0;c.stats.last_parts=cache_memory_split(c,0);c.stats.last_r_w="";c.stats.last_h_m="";return c}function cache_memory_init2(cfg){return cache_memory_init(cfg.name,cfg.via_size,cfg.off_size,cfg.set_size,cfg.replace_pol,cfg.su_pol,cfg.next_cache)}function cache_memory_init3(array_cm_cfg){var array_cm=[];for(var i=0;i>>0;parts.tag=(address&memory.cfg.mask_tag)>>>32-memory.cfg.tag_size;parts.set=(address&memory.cfg.mask_set)>>>memory.cfg.off_size;parts.offset=address&memory.cfg.mask_off;return parts}function cache_memory_access(memory,address,r_w,clock_timestamp){if(memory.cfg.su_pol!="unified"){if("split_i"==memory.cfg.su_pol&&segments_addr_within_text(address)==false){return false}if("split_d"==memory.cfg.su_pol&&segments_addr_within_data(address)==false){return false}}var parts=cache_memory_split(memory,address);if(typeof memory.sets[parts.set]=="undefined"){memory.sets[parts.set]={tags:{},number_tags:0}}if(typeof memory.sets[parts.set].tags[parts.tag]!="undefined"&&memory.sets[parts.set].tags[parts.tag].valid==1){cache_memory_update_stats(memory,address,parts,r_w,"hit",clock_timestamp);return true}if(typeof memory.sets[parts.set].number_tags>3){var tag_victim=cache_memory_select_victim(memory,parts.set);memory.sets[parts.set].tags[tag_victim].valid=0;memory.sets[parts.set].number_tags--}memory.sets[parts.set].tags[parts.tag]={n_access:0,valid:1,dirty:0};memory.sets[parts.set].number_tags++;cache_memory_update_stats(memory,address,parts,r_w,"miss",clock_timestamp);if(memory.cfg.next_cache!=null){cache_memory_access(memory.cfg.next_cache,address,r_w)}return false}var sim={systems:[],active:null,index:0};function simhw_add(newElto){var found=-1;for(var m=0;m=0&&sim.systems.length>=newActive){sim.active=sim.systems[newActive];sim.index=newActive}compile_behaviors();firedep_to_fireorder(jit_fire_dep);compute_references();compile_verbals()}function simhw_getIdByName(short_name){for(var m=0;m>>0).toString(16)}function check_behavior(){if(0==simhw_sim_signals().length){ws_alert("ALERT: empty signals!!!")}if(0==simhw_sim_states().length){ws_alert("ALERT: empty states!!!")}for(var key in simhw_sim_signals()){for(var key2 in simhw_sim_signal(key).behavior){var behaviors=simhw_sim_signal(key).behavior[key2].split(";");for(var i=0;i "+behavior_k[0]+" ("+behavior_i+")");return}if(behavior_k.length!=simhw_syntax_behavior(behavior_k[0]).nparameters){ws_alert("ALERT: Behavior has an incorrect number of elements --\x3e "+behavior_i+"/"+simhw_syntax_behavior(behavior_k[0]).nparameters);return}for(var j=1;j '"+behavior_i);return}else if("S"==t&&typeof simhw_sim_signal(s[0])=="undefined"){ws_alert("ALERT: Behavior has an undefined reference to a signal -> '"+behavior_i);return}else if("X"==t&&typeof simhw_sim_state(s[0])=="undefined"&&typeof simhw_sim_signal(s[0])=="undefined"){ws_alert("ALERT: Behavior has an undefined reference to a object state OR signal -> '"+behavior_i);return}}}}}}var jit_behaviors=false;var jit_verbals=false;var jit_fire_dep=null;var jit_fire_order=null;var jit_dep_network=null;var jit_fire_ndep=null;function firedep_to_fireorder(jit_fire_dep){var allfireto=false;jit_fire_order=[];jit_fire_ndep=[];for(var sig in simhw_sim_signals()){if(typeof jit_fire_dep[sig]=="undefined"){jit_fire_order.push(sig);continue}ndep=0;allfireto=false;for(var sigorg in jit_fire_dep[sig]){ndep++;if(jit_fire_dep[sig][sigorg]==simhw_sim_signal(sigorg).behavior.length){allfireto=true}}jit_fire_ndep[sig]=ndep;if(allfireto==false)jit_fire_order.push(sig)}}function compile_behaviors(){var jit_bes="";jit_fire_dep={};var sig_obj=null;var expr_obj=null;for(var sig in simhw_sim_signals()){jit_bes+="simhw_sim_signal('"+sig+"').behavior_fn = new Array();\n";for(var val in simhw_sim_signal(sig).behavior){var input_behavior=simhw_sim_signal(sig).behavior[val];var jit_be="";var s_exprs=input_behavior.split(";");for(var i=0;i"+v+"";if("Signals"!=enum_name)o+="("+(i+1)+") "+v;else o+="("+(i+1)+") "+hash_eltos[array_eltos[i]].ref+": "+v;if(i!=array_eltos.length-1){o+=str_enditem}}o+=". ";return o}function simhwelto_describe_component_enum(elto_path,array_eltos,hash_eltos,enum_name){var o="";o+=""+i18n_get_TagFor("hw","It has")+""+" "+array_eltos.length+" "+""+i18n_get_TagFor("hw",enum_name)+""+": "+simhwelto_describe_component_enum_aux(elto_path,array_eltos,hash_eltos,enum_name,", ");return o}function simhwelto_describe_component(elto_path,elto,format){var o="";o+=elto.description+".
"+"- "+simhwelto_describe_component_enum(elto_path+":states:",elto.states_inputs,elto.states,"inputs")+"
"+" - "+simhwelto_describe_component_enum(elto_path+":states:",elto.states_outputs,elto.states,"outputs")+"
"+" - "+simhwelto_describe_component_enum(elto_path+":signals:",elto.signals_inputs,elto.signals,"signals")+"
"+"
";if(format!="html"){o.replace(/<[^>]*>?/gm,"")}return o}var ep_def={sim_name:"Elemental Processor",sim_short_name:"ep",sim_img_processor:"repo/hardware/ep/images/processor.svg",sim_img_controlunit:"repo/hardware/ep/images/controlunit.svg",sim_img_cpu:"repo/hardware/ep/images/cpu.svg",components:{},states:{},signals:{},behaviors:{},elements:{},internal_states:{},ctrl_states:{},events:{}};simhw_add(ep_def);sim.ep.behaviors.PRINT_S={nparameters:2,types:["S"],operation:function(s_expr){console.log(s_expr[1]+": 0x"+sim.ep.signals[s_expr[1]].value.toString(16))},verbal:function(s_expr){return"Print value of signal "+s_expr[1]+": 0x"+sim.ep.signals[s_expr[1]].value.toString(16)+". "}};sim.ep.behaviors.PRINT_E={nparameters:2,types:["E"],operation:function(s_expr){console.log(s_expr[1]+": 0x"+sim.ep.states[s_expr[1]].value.toString(16))},verbal:function(s_expr){return"Print value of state "+s_expr[1]+": 0x"+sim.ep.states[s_expr[1]].value.toString(16)+". "}};sim.ep.components["CPU"]={name:"CPU",version:"1",abilities:["CPU"],details_name:["REGISTER_FILE","CONTROL_MEMORY","CLOCK","CPU_STATS"],details_fire:[["svg_p:text3029","svg_p:text3031"],["svg_cu:text3010"],["svg_p:text3459-7","svg_cu:text4138","svg_cu:text4138-7"],["svg_p:text3495"]],write_state:function(vec){if(typeof vec.CPU=="undefined"){vec.CPU={}}var internal_reg=["PC","SR"];var value=0;for(var i=0;i>>0;if(value!=0){vec.CPU["R"+i]={type:"register",default_value:0,id:"R"+i,op:"=",value:"0x"+value.toString(16)}}}for(i=0;i>>0;if(value!=0){vec.CPU[internal_reg[i]]={type:"register",default_value:0,id:internal_reg[i],op:"=",value:"0x"+value.toString(16)}}}return vec},read_state:function(vec,check){if(typeof vec.CPU=="undefined"){vec.CPU={}}var key=check["id"].toUpperCase().trim();var val=parseInt(check["value"]).toString(16);if("REGISTER"==check["type"].toUpperCase().trim()){vec.CPU[key]={type:"register",default_value:0,id:key,op:check["condition"],value:"0x"+val};return true}return false},get_state:function(reg){var value=0;var r_reg=reg.toUpperCase().trim();if(typeof sim.ep.states["REG_"+r_reg]!="undefined"){value=get_value(sim.ep.states["REG_"+r_reg])>>>0;return"0x"+value.toString(16)}r_reg=r_reg.replace("R","");var index=parseInt(r_reg);if(typeof sim.ep.states.BR[index]!="undefined"){value=get_value(sim.ep.states.BR[index])>>>0;return"0x"+value.toString(16)}return null},get_value:function(elto){if(Number.isInteger(elto))index=elto;else index=parseInt(elto);if(isNaN(index))return get_value(simhw_sim_state(elto))>>>0;return get_value(simhw_sim_states().BR[index])>>>0},set_value:function(elto,value){var pc_name=simhw_sim_ctrlStates_get().pc.state;if(Number.isInteger(elto))index=elto;else index=parseInt(elto);if(isNaN(index)){set_value(simhw_sim_state(elto),value);if(pc_name===elto){show_asmdbg_pc()}return value}return set_value(simhw_sim_states().BR[index],value)}};sim.ep.ctrl_states.pc={name:"PC",state:"REG_PC",is_pointer:true};sim.ep.ctrl_states.sp={name:"SP",state:"BR.29",is_pointer:true};sim.ep.ctrl_states.fp={name:"FP",state:"BR.30",is_pointer:true};sim.ep.ctrl_states.ir={name:"IR",state:"REG_IR",default_eltos:{co:{begin:0,end:5,length:6},cop:{begin:28,end:31,length:4},oc:{begin:0,end:6,length:7}},is_pointer:false};sim.ep.ctrl_states.mpc={name:"mPC",state:"REG_MICROADDR",is_pointer:false};sim.ep.internal_states.MC={};sim.ep.internal_states.ROM={};sim.ep.internal_states.FIRMWARE=ws_empty_firmware;sim.ep.internal_states.io_hash={};sim.ep.internal_states.fire_stack=[];sim.ep.internal_states.tri_state_names=["T1","T2","T3","T4","T5","T6","T7","T8","T9","T10","T11","T12"];sim.ep.internal_states.fire_visible={databus:false,internalbus:false};sim.ep.internal_states.filter_states=["REG_IR_DECO,col-12","REG_IR,col-auto","REG_PC,col-auto","REG_MAR,col-auto","REG_MBR,col-auto","REG_RT1,col-auto","REG_RT2,col-auto","REG_RT3,col-auto","REG_SR,col-auto","REG_MICROADDR,col-auto"];sim.ep.internal_states.filter_signals=["A0,0","B,0","C,0","SELA,5","SELB,5","SELC,2","SELCOP,0","MR,0","MC,0","C0,0","C1,0","C2,0","C3,0","C4,0","C5,0","C6,0","C7,0","T1,0","T2,0","T3,0","T4,0","T5,0","T6,0","T7,0","T8,0","T9,0","T10,0","T11,0","M1,0","M2,0","M7,0","MA,0","MB,0","SELP,0","LC,0","SE,0","SIZE,0","OFFSET,0","BW,0","R,0","W,0","TA,0","TD,0","IOR,0","IOW,0","TEST_I,0","TEST_U,0"];sim.ep.internal_states.alu_flags={flag_n:0,flag_z:0,flag_v:0,flag_c:0};sim.ep.states.BR=[];sim.ep.states.BR[0]={name:"R0",verbal:"Register 0",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[1]={name:"R1",verbal:"Register 1",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[2]={name:"R2",verbal:"Register 2",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[3]={name:"R3",verbal:"Register 3",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[4]={name:"R4",verbal:"Register 4",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[5]={name:"R5",verbal:"Register 5",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[6]={name:"R6",verbal:"Register 6",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[7]={name:"R7",verbal:"Register 7",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[8]={name:"R8",verbal:"Register 8",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[9]={name:"R9",verbal:"Register 9",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[10]={name:"R10",verbal:"Register 10",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[11]={name:"R11",verbal:"Register 11",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[12]={name:"R12",verbal:"Register 12",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[13]={name:"R13",verbal:"Register 13",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[14]={name:"R14",verbal:"Register 14",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[15]={name:"R15",verbal:"Register 15",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[16]={name:"R16",verbal:"Register 16",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[17]={name:"R17",verbal:"Register 17",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[18]={name:"R18",verbal:"Register 18",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[19]={name:"R19",verbal:"Register 19",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[20]={name:"R20",verbal:"Register 20",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[21]={name:"R21",verbal:"Register 21",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[22]={name:"R22",verbal:"Register 22",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[23]={name:"R23",verbal:"Register 23",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[24]={name:"R24",verbal:"Register 24",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[25]={name:"R25",verbal:"Register 25",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[26]={name:"R26",verbal:"Register 26",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[27]={name:"R27",verbal:"Register 27",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[28]={name:"R28",verbal:"Register 28",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[29]={name:"R29",verbal:"Register 29",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[30]={name:"R30",verbal:"Register 30",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.BR[31]={name:"R31",verbal:"Register 31",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["REG_PC"]={name:"PC",verbal:"Program Counter Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["REG_MAR"]={name:"MAR",verbal:"Memory Address Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["REG_MBR"]={name:"MBR",verbal:"Memory Data Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["REG_IR"]={name:"IR",verbal:"Instruction Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["REG_RT1"]={name:"RT1",verbal:"Temporal 1 Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["REG_RT2"]={name:"RT2",verbal:"Temporal 2 Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["REG_RT3"]={name:"RT3",verbal:"Temporal 3 Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["REG_SR"]={name:"SR",verbal:"State Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["BUS_IB"]={name:"I_BUS",verbal:"Internal Bus",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["BUS_AB"]={name:"A_BUS",verbal:"Address Bus",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["BUS_CB"]={name:"C_BUS",verbal:"Control Bus",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["BUS_DB"]={name:"D_BUS",verbal:"Data Bus",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["C2_T2"]={name:"C2_T2",verbal:"Output of PC",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["RA_T9"]={name:"RA_T9",verbal:"Input of T9 Tristate",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["RB_T10"]={name:"RB_T10",verbal:"Input of T10 Tristate",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["HPC_T12"]={name:"HPC_T12",verbal:"Input of T12 Tristate",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["SELEC_T3"]={name:"SELEC_T3",verbal:"Input of T3 Tristate",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["SELP_M7"]={name:"SELP_M7",verbal:"Output of MUX SelP",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["ALU_C6"]={name:"ALU_C6",verbal:"Input of Temporal 3 Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["MA_ALU"]={name:"MA_ALU",verbal:"Input ALU via MA",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["MB_ALU"]={name:"MB_ALU",verbal:"Input ALU via MB",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["FLAG_C"]={name:"FLAG_C",verbal:"Carry Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.ep.states["FLAG_V"]={name:"FLAG_V",verbal:"Overflow Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.ep.states["FLAG_N"]={name:"FLAG_N",verbal:"Negative Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.ep.states["FLAG_Z"]={name:"FLAG_Z",verbal:"Zero Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.ep.states["FLAG_I"]={name:"FLAG_I",verbal:"Interruption Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.ep.states["FLAG_U"]={name:"FLAG_U",verbal:"User Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.ep.states["REG_MICROADDR"]={name:"µADDR",verbal:"Microaddress Register",visible:true,nbits:"12",value:0,default_value:0,draw_data:["svg_cu:text4667"]};sim.ep.states["REG_MICROINS"]={name:"µINS",verbal:"Microinstruction Register",visible:true,nbits:"77",value:{},default_value:{},draw_data:[]};sim.ep.states["FETCH"]={name:"FETCH",verbal:"Input Fetch",visible:false,nbits:"12",value:0,default_value:0,draw_data:[]};sim.ep.states["ROM_MUXA"]={name:"ROM_MUXA",verbal:"Input ROM",visible:false,nbits:"12",value:0,default_value:0,draw_data:[]};sim.ep.states["SUM_ONE"]={name:"SUM_ONE",verbal:"Input next microinstruction",visible:false,nbits:"12",value:1,default_value:1,draw_data:[]};sim.ep.states["MUXA_MICROADDR"]={name:"MUXA_MICROADDR",verbal:"Input microaddress",visible:false,nbits:"12",value:0,default_value:0,draw_data:[]};sim.ep.states["MUXC_MUXB"]={name:"MUXC_MUXB",verbal:"Output of MUX C",visible:false,nbits:"1",value:0,default_value:0,draw_data:[]};sim.ep.states["INEX"]={name:"INEX",verbal:"Illegal Instruction Exception",visible:false,nbits:"1",value:0,default_value:0,draw_data:[]};sim.ep.states["BS_M1"]={name:"BS_M1",verbal:"from Memory",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["BS_TD"]={name:"BS_TD",verbal:"Memory",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["INTV"]={name:"INTV",verbal:"Interruption Vector",visible:false,nbits:"8",value:0,default_value:0,draw_data:[]};sim.ep.states["M2_C2"]={name:"M2_C2",verbal:"Input of Program Counter",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["M1_C1"]={name:"M1_C1",verbal:"Input of Memory Data Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["M7_C7"]={name:"M7_C7",verbal:"Input of State Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["VAL_ZERO"]={name:"VAL_ZERO",verbal:"Wired Zero",visible:false,nbits:"1",value:0,default_value:0,draw_data:[]};sim.ep.states["VAL_ONE"]={name:"VAL_ONE",verbal:"Wired One",visible:false,nbits:"32",value:1,default_value:1,draw_data:[]};sim.ep.states["VAL_FOUR"]={name:"VAL_FOUR",verbal:"Wired Four",visible:false,nbits:"32",value:4,default_value:4,draw_data:[]};sim.ep.states["REG_IR_DECO"]={name:"IR_DECO",verbal:"Instruction Decoded",visible:true,nbits:"0",value:0,default_value:0,draw_data:[]};sim.ep.states["DECO_INS"]={name:"DECO_INS",verbal:"Instruction decoded in binary",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["CLK"]={name:"CLK",verbal:"Clock",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["ACC_TIME"]={name:"ACC_TIME",verbal:"Accumulated CPU time",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["TTCPU"]={name:"TTCPU",verbal:"Several Tristates to the internal data bus in CPU activated",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states["ACC_PWR"]={name:"ACC_PWR",verbal:"Accumulated Energy Consumption",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.signals["C"]={name:"C",visible:true,type:"L",value:0,default_value:0,nbits:"4",behavior:["MV MUXC_MUXB VAL_ZERO; FIRE B","MBIT MUXC_MUXB INT 0 1; FIRE B","MBIT MUXC_MUXB IORDY 0 1; FIRE B","MBIT MUXC_MUXB MRDY 0 1; FIRE B","MBIT MUXC_MUXB REG_SR 0 1; FIRE B","MBIT MUXC_MUXB REG_SR 1 1; FIRE B","MBIT MUXC_MUXB REG_SR 28 1; FIRE B","MBIT MUXC_MUXB REG_SR 29 1; FIRE B","MBIT MUXC_MUXB REG_SR 30 1; FIRE B","MBIT MUXC_MUXB REG_SR 31 1; FIRE B","MV MUXC_MUXB INEX; FIRE B"],fire_name:["svg_cu:text3410"],draw_data:[["svg_cu:path3108"],["svg_cu:path3062"],["svg_cu:path3060"],["svg_cu:path3136"],["svg_cu:path3482"],["svg_cu:path3480"],["svg_cu:path3488"],["svg_cu:path3486"],["svg_cu:path3484"],["svg_cu:path3484-9"],["svg_cu:path3108-3","svg_cu:path3260-3-8-6","svg_cu:path3260-3-8","svg_cu:path3260-3"]],draw_name:[["svg_cu:path3496","svg_cu:path3414","svg_cu:path3194-08"]]};sim.ep.signals["B"]={name:"B",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV A1 MUXC_MUXB; FIRE A1","NOT_ES A1 MUXC_MUXB; FIRE A1"],depends_on:["CLK"],fire_name:["svg_cu:text3408"],draw_data:[["svg_cu:path3100-8-7","svg_cu:path3108-1","svg_cu:path3200-1"],["svg_cu:path3392","svg_cu:path3372","svg_cu:path3390","svg_cu:path3384","svg_cu:path3100-8-7","svg_cu:path3386","svg_cu:path3200-1"]],draw_name:[[],["svg_cu:path3194-0","svg_cu:path3138-8","svg_cu:path3498-6"]]};sim.ep.signals["A0"]={name:"A0",visible:false,type:"L",value:0,default_value:0,nbits:"1",behavior:["SBIT_SIGNAL A0A1 0 1; FIRE A0A1","SBIT_SIGNAL A0A1 1 1; FIRE A0A1"],depends_on:["CLK"],fire_name:["svg_cu:text3406"],draw_data:[["svg_cu:path3096"],["svg_cu:path3096"]],draw_name:[[],["svg_cu:path3138-8-1","svg_cu:path3098-2","svg_cu:path3124-2-5"]]};sim.ep.signals["A1"]={name:"A1",visible:false,type:"L",value:0,default_value:0,nbits:"1",behavior:["SBIT_SIGNAL A0A1 0 0; FIRE A0A1","SBIT_SIGNAL A0A1 1 0; FIRE A0A1"],depends_on:["CLK"],fire_name:[],draw_data:[["svg_cu:path3094"],["svg_cu:path3094"]],draw_name:[[]]};sim.ep.signals["A0A1"]={name:"A0A1",visible:true,type:"L",value:0,default_value:0,nbits:"2",behavior:["PLUS1 MUXA_MICROADDR REG_MICROADDR","CP_FIELD MUXA_MICROADDR REG_MICROINS/MADDR","MV MUXA_MICROADDR ROM_MUXA","MV MUXA_MICROADDR FETCH"],depends_on:["CLK"],fire_name:[],draw_data:[["svg_cu:path3102","svg_cu:path3100","svg_cu:path3098","svg_cu:path3100-9","svg_cu:path3088","svg_cu:path3082"],["svg_cu:path3104","svg_cu:path3134","svg_cu:path3500","svg_cu:path3416"],["svg_cu:path3124-2-4","svg_cu:path3124-2","svg_cu:path3504","svg_cu:path3100-8","svg_cu:path3234-9"],["svg_cu:path3124"]],draw_name:[[]]};sim.ep.signals["C0"]={name:"C0",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","LOAD REG_MAR BUS_IB"],fire_name:["svg_p:text3077"],draw_data:[["svg_p:path3081"]],draw_name:[["svg_p:path3075"]]};sim.ep.signals["C1"]={name:"C1",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","LOAD REG_MBR M1_C1"],fire_name:["svg_p:text3079"],draw_data:[["svg_p:path3055"]],draw_name:[["svg_p:path3073"]]};sim.ep.signals["C2"]={name:"C2",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","LOAD REG_PC M2_C2; UPDATEDPC"],fire_name:["svg_p:text3179"],draw_data:[["svg_p:path3485"]],draw_name:[["svg_p:path3177"]]};sim.ep.signals["C3"]={name:"C3",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","LOAD REG_IR BUS_IB; DECO; FIRE_IFSET C 10"],fire_name:["svg_p:text3439"],draw_data:[["svg_p:path3339"]],draw_name:[["svg_p:path3337"]]};sim.ep.signals["C4"]={name:"C4",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","LOAD REG_RT1 BUS_IB"],fire_name:["svg_p:text3441"],draw_data:[["svg_p:path3263"]],draw_name:[["svg_p:path3255"]]};sim.ep.signals["C5"]={name:"C5",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","LOAD REG_RT2 BUS_IB"],fire_name:["svg_p:text3443"],draw_data:[["svg_p:path3277"]],draw_name:[["svg_p:path3269"]]};sim.ep.signals["C6"]={name:"C6",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","LOAD REG_RT3 ALU_C6"],fire_name:["svg_p:text3445"],draw_data:[["svg_p:path3325","svg_p:path3323","svg_p:path3321","svg_p:path3261-8","svg_p:path3317-9","svg_p:path3901-6-9"]],draw_name:[["svg_p:path3245"]]};sim.ep.signals["C7"]={name:"C7",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","LOAD REG_SR M7_C7"],fire_name:["svg_p:text3655"],draw_data:[["svg_p:path3651-9"]],draw_name:[["svg_p:path3681"]]};sim.ep.signals["TA"]={name:"TA",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","MV BUS_AB REG_MAR; MOVE_BITSE A1A0 0 2 BUS_AB 0; FIRE_IFCHANGED A1A0 A1A0"],fire_name:["svg_p:text3091"],draw_data:[["svg_p:path3061-2","svg_p:path3083","svg_p:path3089","svg_p:path3597","svg_p:path3513","svg_p:path3601","svg_p:path3601-2","svg_p:path3187","svg_p:path3087","svg_p:path2995","svg_p:path3535"]],draw_name:[["svg_p:path3085"]]};sim.ep.signals["TD"]={name:"TD",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; CHECK_RTD","MV BUS_DB BS_TD; MOVE_BITSE A1A0 0 2 BUS_AB 0; FIRE_IFCHANGED A1A0 A1A0; CHECK_RTD"],fire_name:["svg_p:text3103"],draw_data:[["svg_p:path3545","svg_p:path3093","svg_p:path3101","svg_p:path3587","svg_p:path3515","svg_p:path3071","svg_p:path3419","svg_p:path3099","svg_p:path3097","svg_p:path3559-5","svg_p:path3419-1-0","svg_p:path3583","svg_p:path3419-1","svg_p:path3491","svg_p:path3641","svg_p:path3541"]],draw_name:[["svg_p:path3095"]]};sim.ep.signals["T1"]={name:"T1",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 0","MV BUS_IB REG_MBR; FIRE M7; FIRE M2; FIRE M1; SET_TT TTCPU 0"],fire_name:["svg_p:text3105"],draw_data:[["svg_p:path3071","svg_p:path3065","svg_p:path3071","svg_p:path3049","svg_p:path3063-9","svg_p:path3071","svg_p:path3071","svg_p:path3069"]],draw_name:[["svg_p:path3067"]]};sim.ep.signals["T2"]={name:"T2",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 1","MV BUS_IB REG_PC; FIRE M7; FIRE M2; FIRE M1; SET_TT TTCPU 1"],fire_name:["svg_p:text3449"],draw_data:[["svg_p:path3195","svg_p:path3199","svg_p:path3201","svg_p:path3049"]],draw_name:[["svg_p:path3329"]]};sim.ep.signals["T3"]={name:"T3",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 2","MV BUS_IB SELEC_T3; FIRE M7; FIRE M2; FIRE M1; SET_TT TTCPU 2"],fire_name:["svg_p:text3451"],draw_data:[["svg_p:path3341","svg_p:path3347","svg_p:path3349","svg_p:path3931","svg_p:path3345","svg_p:path3049"]],draw_name:[["svg_p:path3351"]]};sim.ep.signals["T4"]={name:"T4",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 3","MV BUS_IB REG_RT1; FIRE M7; FIRE M2; FIRE M1; SET_TT TTCPU 3"],fire_name:["svg_p:text3453"],draw_data:[["svg_p:path3257","svg_p:path3261","svg_p:path3259","svg_p:path3049"]],draw_name:[["svg_p:path3305"]]};sim.ep.signals["T5"]={name:"T5",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 4","MV BUS_IB REG_RT2; FIRE M7; FIRE M2; FIRE M1; SET_TT TTCPU 4"],fire_name:["svg_p:text3455"],draw_data:[["svg_p:path3271","svg_p:path3275","svg_p:path3273","svg_p:path3049"]],draw_name:[["svg_p:path3307"]]};sim.ep.signals["T6"]={name:"T6",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 5","MV BUS_IB ALU_C6; FIRE M7; FIRE M2; FIRE M1; SET_TT TTCPU 5"],fire_name:["svg_p:text3457"],draw_data:[["svg_p:path3315","svg_p:path3589","svg_p:path3317","svg_p:path3163-2","svg_p:path3049","svg_p:path3321","svg_p:path3261-8","svg_p:path3317-9","svg_p:path3901-6-9"]],draw_name:[["svg_p:path3319"]]};sim.ep.signals["T7"]={name:"T7",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 6","MV BUS_IB REG_RT3; FIRE M7; FIRE M2; FIRE M1; SET_TT TTCPU 6"],fire_name:["svg_p:text3459"],draw_data:[["svg_p:path3309","svg_p:path3327","svg_p:path3311","svg_p:path3049"]],draw_name:[["svg_p:path3313"]]};sim.ep.signals["T8"]={name:"T8",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 7","MV BUS_IB REG_SR; FIRE M7; FIRE M2; FIRE M1; SET_TT TTCPU 7"],fire_name:["svg_p:text3657"],draw_data:[["svg_p:path3645","svg_p:path3651","svg_p:path3647","svg_p:path3049"]],draw_name:[["svg_p:path3649"]]};sim.ep.signals["T9"]={name:"T9",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 8","MV BUS_IB RA_T9; FIRE M7; FIRE M2; FIRE M1; SET_TT TTCPU 8"],fire_name:["svg_p:text3147"],draw_data:[["svg_p:path3131","svg_p:path3143","svg_p:path3139","svg_p:path3049","svg_p:path3143-9"]],draw_name:[["svg_p:path3133"]]};sim.ep.signals["T10"]={name:"T10",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 9","MV BUS_IB RB_T10; FIRE M7; FIRE M2; FIRE M1; SET_TT TTCPU 9"],fire_name:["svg_p:text3149"],draw_data:[["svg_p:path3135","svg_p:path3145","svg_p:path3141","svg_p:path3049","svg_p:path3145-5"]],draw_name:[["svg_p:path3137"]]};sim.ep.signals["T11"]={name:"T11",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 10","CP_FIELD BUS_IB REG_MICROINS/EXCODE; FIRE M7; FIRE M2; FIRE M1; SET_TT TTCPU 10"],fire_name:["svg_p:text3147-5","svg_cu:tspan4426"],draw_data:[["svg_cu:path3131-3","svg_p:path3131-3","svg_p:path3145","svg_p:path3081-3","svg_p:path3139-7","svg_p:path3049","svg_cu:path3081-3","svg_cu:path3139-7"]],draw_name:[["svg_p:path3133-6","svg_cu:path3133-6"]]};sim.ep.signals["T12"]={name:"T12",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 11","MV BUS_IB HPC_T12; FIRE M7; FIRE M2; FIRE M1; SET_TT TTCPU 11"],fire_name:["svg_p:text3147-5-0-1-1"],draw_data:[["svg_p:path3131-3-8-4-31","svg_p:path3139-7-1-4-3","svg_p:path3049","svg_p:path3081-3-8-5-3","svg_p:path3081-3-8-5-3-7"]],draw_name:[["svg_p:path3133-6-9-7-5"]]};sim.ep.signals["M1"]={name:"M1",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV M1_C1 BUS_IB","MV M1_C1 BS_M1"],depends_on:["C1"],fire_name:["svg_p:text3469"],draw_data:[["svg_p:path3063","svg_p:path3061","svg_p:path3059"],["svg_p:path3057","svg_p:path3641","svg_p:path3419","svg_p:path3583","svg_p:path3491"]],draw_name:[[],["svg_p:path3447"]]};sim.ep.signals["M2"]={name:"M2",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV M2_C2 BUS_IB","PLUS4 M2_C2 REG_PC"],depends_on:["C2"],fire_name:["svg_p:text3471"],draw_data:[["svg_p:path3217","svg_p:path3215","svg_p:path3213","svg_p:path3213-9"],["svg_p:path3211","svg_p:path3209","svg_p:path3193","svg_p:path3207","svg_p:path3197","svg_p:path3201"]],draw_name:[[],["svg_p:path3467","svg_p:path3467"]]};sim.ep.signals["M7"]={name:"M7",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV M7_C7 BUS_IB","MV M7_C7 SELP_M7"],depends_on:["C7"],fire_name:["svg_p:text3673"],draw_data:[["svg_p:path3691","svg_p:path3693","svg_p:path3659"],["svg_p:path3695"]],draw_name:[[],["svg_p:path3667"]]};sim.ep.signals["MA"]={name:"MA",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV MA_ALU RA_T9; FIRE COP","MV MA_ALU REG_RT1; FIRE COP"],depends_on:["SELA","SELB"],fire_name:["svg_p:text3463"],draw_data:[["svg_p:path3249","svg_p:path3161","svg_p:path3165"],["svg_p:path3279"]],draw_name:[[],["svg_p:path3423"]]};sim.ep.signals["MB"]={name:"MB",visible:true,type:"L",value:0,default_value:0,nbits:"2",behavior:["MV MB_ALU RB_T10; FIRE COP","MV MB_ALU REG_RT2; FIRE COP","MV MB_ALU VAL_FOUR; FIRE COP","MV MB_ALU VAL_ONE; FIRE COP"],depends_on:["SELA","SELB"],fire_name:["svg_p:text3465"],draw_data:[["svg_p:path3281","svg_p:path3171","svg_p:path3169"],["svg_p:path3283"],["svg_p:path3295","svg_p:path3293"],["svg_p:path3297","svg_p:path3299"]],draw_name:[[],["svg_p:path3425","svg_p:path3427"]]};sim.ep.signals["MH"]={name:"MH",visible:true,type:"L",value:0,default_value:0,nbits:"2",behavior:["MV HPC_T12 CLK","MV HPC_T12 ACC_TIME","MV HPC_T12 ACC_PWR","NOP"],fire_name:["svg_p:text3147-5-0-1-8-4"],draw_data:[[],["svg_p:path3081-3-8-5-3"]],draw_name:[[],["svg_p:path3306-8-7-6"]]};sim.ep.signals["COP"]={name:"COP",visible:true,type:"L",value:0,default_value:0,nbits:"5",forbidden:true,behavior:["NOP_ALU; UPDATE_NZVC","AND ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","OR ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","NOT ALU_C6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","XOR ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","SRL ALU_C6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","SRA ALU_C6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","SL ALU_C6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","RR ALU_C6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","RL ALU_C6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","ADD ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","SUB ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","MUL ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","DIV ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","MOD ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","LUI ALU_C6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","FADD ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","FSUB ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","FMUL ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","FDIV ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","FCVT ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","FCLASS ALU_C6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","ADDU ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","SUBU ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","MULU ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","DIVU ALU_C6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET SELP 3","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU"],depends_on:["SELCOP"],fire_name:["svg_p:text3303"],draw_data:[["svg_p:path3237","svg_p:path3239","svg_p:path3261-8","svg_p:path3321","svg_p:path3901-6","svg_p:path3317-9"]],draw_name:[["svg_p:path3009","svg_p:path3301"]]};sim.ep.signals["SELP"]={name:"SELP",visible:true,type:"L",value:0,default_value:0,nbits:"2",behavior:["NOP","MV SELP_M7 REG_SR; UPDATE_FLAG SELP_M7 FLAG_U 0; FIRE M7","MV SELP_M7 REG_SR; UPDATE_FLAG SELP_M7 FLAG_I 1; FIRE M7","MV SELP_M7 REG_SR; UPDATE_FLAG SELP_M7 FLAG_C 31; UPDATE_FLAG SELP_M7 FLAG_V 30; UPDATE_FLAG SELP_M7 FLAG_N 29; UPDATE_FLAG SELP_M7 FLAG_Z 28; FIRE M7"],fire_name:["svg_p:text3703"],draw_data:[[],["svg_p:path3643"],["svg_p:path3705"],["svg_p:path3675","svg_p:path3331"]],draw_name:[[],["svg_p:path3697"]]};sim.ep.signals["SELA"]={name:"SELA",visible:true,type:"L",value:0,default_value:0,nbits:"5",behavior:["FIRE MR_RA"],depends_on:["RA"],fire_name:["svg_cu:text3164"],draw_data:[[]],draw_name:[[]]};sim.ep.signals["SELB"]={name:"SELB",visible:true,type:"L",value:0,default_value:0,nbits:"5",behavior:["FIRE MR_RB"],depends_on:["RB"],fire_name:["svg_cu:text3168"],draw_data:[[]],draw_name:[[]]};sim.ep.signals["SELC"]={name:"SELC",visible:true,type:"L",value:0,default_value:0,nbits:"5",behavior:["FIRE MR_RC"],depends_on:["RC"],fire_name:["svg_cu:text3172"],draw_data:[[]],draw_name:[[]]};sim.ep.signals["SELCOP"]={name:"SELCOP",visible:true,type:"L",value:0,default_value:0,nbits:"5",behavior:["FIRE MC"],depends_on:["COP"],fire_name:["svg_cu:text3312"],draw_data:[[]],draw_name:[[]]};sim.ep.signals["EXCODE"]={name:"EXCODE",visible:true,type:"L",value:0,default_value:0,nbits:"4",behavior:["FIRE T11"],fire_name:["svg_cu:text3312-6"],draw_data:[[]],draw_name:[]};sim.ep.signals["RA"]={name:"RA",visible:true,type:"L",value:0,default_value:0,nbits:"5",forbidden:true,behavior:["GET RA_T9 BR RA; FIRE_IFSET T9 1; FIRE_IFSET MA 0"],depends_on:["SELA"],fire_name:["svg_p:text3107"],draw_data:[[]],draw_name:[["svg_p:path3109"]]};sim.ep.signals["RB"]={name:"RB",visible:true,type:"L",value:0,default_value:0,nbits:"5",forbidden:true,behavior:["GET RB_T10 BR RB; FIRE_IFSET T10 1; FIRE_IFSET MB 0"],depends_on:["SELB"],fire_name:["svg_p:text3123"],draw_data:[[]],draw_name:[["svg_p:path3113"]]};sim.ep.signals["RC"]={name:"RC",visible:true,type:"L",value:0,default_value:0,nbits:"5",forbidden:true,behavior:["FIRE LC"],depends_on:["SELC"],fire_name:["svg_p:text3125"],draw_data:[[]],draw_name:[["svg_p:path3117"]]};sim.ep.signals["LC"]={name:"LC",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","SET BR RC BUS_IB"],fire_name:["svg_p:text3127"],draw_data:[["svg_p:path3153","svg_p:path3151","svg_p:path3129"]],draw_name:[["svg_p:path3121"]]};sim.ep.signals["SE"]={name:"SE",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MBITS SELEC_T3 0 REG_IR OFFSET SIZE 0 SE; FIRE T3; MOVE_BITS SBWA 4 1 SE; FIRE_IFCHANGED SBWA SE","MBITS SELEC_T3 0 REG_IR OFFSET SIZE 0 SE; FIRE T3; MOVE_BITS SBWA 4 1 SE; FIRE_IFCHANGED SBWA SE"],depends_on:["T3"],fire_name:["svg_p:text3593","svg_p:text3431"],draw_data:[[]],draw_name:[["svg_p:path3591","svg_p:path3447-7-7"]]};sim.ep.signals["SIZE"]={name:"SIZE",visible:true,type:"L",value:0,default_value:0,nbits:"5",behavior:["MBITS SELEC_T3 0 REG_IR OFFSET SIZE 0 SE; FIRE T3"],depends_on:["T3"],fire_name:["svg_p:text3363"],draw_data:[[]],draw_name:[["svg_p:path3355"]]};sim.ep.signals["OFFSET"]={name:"OFFSET",visible:true,type:"L",value:0,default_value:0,nbits:"5",behavior:["MBITS SELEC_T3 0 REG_IR OFFSET SIZE 0 SE; FIRE T3"],depends_on:["T3"],fire_name:["svg_p:text3707"],draw_data:[[]],draw_name:[["svg_p:path3359"]]};sim.ep.signals["MC"]={name:"MC",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MBIT COP REG_IR 0 5; FIRE COP;","CP_FIELD COP REG_MICROINS/SELCOP; FIRE COP;"],depends_on:["SELCOP"],fire_name:["svg_cu:text3322","svg_cu:text3172-1-5"],draw_data:[["svg_cu:path3320","svg_cu:path3142"],["svg_cu:path3318","svg_cu:path3502-6"]],draw_name:[[],["svg_cu:path3306"]]};sim.ep.signals["MR"]={name:"MR",verbal:["Copy from IR[SelA], from IR[SelB], and from IR[SelB] into RA, RB, and RC. ","Copy SelA, SelB, and SelB into RA, RB, and RC. "],visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV MR_RA MR; FIRE MR_RA; MV MR_RB MR; FIRE MR_RB; MV MR_RC MR; FIRE MR_RC;","MV MR_RA MR; FIRE MR_RA; MV MR_RB MR; FIRE MR_RB; MV MR_RC MR; FIRE MR_RC;"],depends_on:["SELA","SELB","SELC"],fire_name:["svg_cu:text3222","svg_cu:text3242","svg_cu:text3254","svg_cu:text3172-1"],draw_data:[["svg_cu:path3494","svg_cu:path3492","svg_cu:path3490","svg_cu:path3188","svg_cu:path3190","svg_cu:path3192","svg_cu:path3194","svg_cu:path3276","svg_cu:path3290","svg_cu:path3260","svg_cu:path3196","svg_cu:path3278","svg_cu:path3292","svg_cu:path3142","svg_cu:path3258-4","svg_cu:path3390-7","svg_cu:path3258","svg_cu:path3280","svg_cu:path3200","svg_cu:path3204","svg_cu:path3208","svg_cu:path3268","svg_cu:path3316"],["svg_cu:path3270","svg_cu:path3282","svg_cu:path3300","svg_cu:path3258","svg_cu:path3260","svg_cu:path3258-4","svg_cu:path3278","svg_cu:path3196","svg_cu:path3294","svg_cu:path3292","svg_cu:path3288","svg_cu:path3280","svg_cu:path3258","svg_cu:path3258-4","svg_cu:path3390-7","svg_cu:path3268","svg_cu:path3364","svg_cu:path3316"]],draw_name:[[],["svg_cu:path3220","svg_cu:path3240","svg_cu:path3252"]]};sim.ep.signals["MR_RA"]={name:"MR_RA",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MBIT_SN RA REG_IR REG_MICROINS/SELA 5; FIRE RA;","CP_FIELD RA REG_MICROINS/SELA; FIRE RA;"],fire_name:[],draw_data:[[]],draw_name:[[]]};sim.ep.signals["MR_RB"]={name:"MR_RB",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MBIT_SN RB REG_IR REG_MICROINS/SELB 5; FIRE RB;","CP_FIELD RB REG_MICROINS/SELB; FIRE RB;"],fire_name:[],draw_data:[[]],draw_name:[[]]};sim.ep.signals["MR_RC"]={name:"MR_RC",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MBIT_SN RC REG_IR REG_MICROINS/SELC 5; FIRE RC;","CP_FIELD RC REG_MICROINS/SELC; FIRE RC;"],fire_name:[],draw_data:[[]],draw_name:[[]]};sim.ep.signals["BW"]={name:"BW",verbal:["Select one byte (based on A1A0) from Word. ","Select two bytes (one Half Word based on A1A0) from Word. ","","Select the full Word. "],visible:true,type:"L",value:0,default_value:0,nbits:"2",behavior:["MOVE_BITS BWA 2 2 BW; MOVE_BITS SBWA 2 2 BW; FIRE_IFCHANGED BWA BW; FIRE SBWA; RESET_CHANGED BW","MOVE_BITS BWA 2 2 BW; MOVE_BITS SBWA 2 2 BW; FIRE_IFCHANGED BWA BW; FIRE SBWA; RESET_CHANGED BW","MOVE_BITS BWA 2 2 BW; MOVE_BITS SBWA 2 2 BW; FIRE_IFCHANGED BWA BW; FIRE SBWA; RESET_CHANGED BW","MOVE_BITS BWA 2 2 BW; MOVE_BITS SBWA 2 2 BW; FIRE_IFCHANGED BWA BW; FIRE SBWA; RESET_CHANGED BW"],fire_name:["svg_p:text3433"],draw_data:[["svg_p:path3061-2-6","svg_p:path3101-8","svg_p:path3535-8"]],draw_name:[[],[]]};sim.ep.signals["A1A0"]={name:"A1A0",visible:true,type:"L",value:0,default_value:0,nbits:"2",behavior:["MOVE_BITS BWA 0 2 A1A0; MOVE_BITS SBWA 0 2 A1A0; FIRE BWA; FIRE SBWA","MOVE_BITS BWA 0 2 A1A0; MOVE_BITS SBWA 0 2 A1A0; FIRE BWA; FIRE SBWA","MOVE_BITS BWA 0 2 A1A0; MOVE_BITS SBWA 0 2 A1A0; FIRE BWA; FIRE SBWA","MOVE_BITS BWA 0 2 A1A0; MOVE_BITS SBWA 0 2 A1A0; FIRE BWA; FIRE SBWA"],fire_name:["svg_p:text3603"],draw_data:[[],[]],draw_name:[[],[]]};sim.ep.signals["BWA"]={name:"BWA",visible:false,type:"L",value:0,default_value:0,nbits:"4",behavior:["BSEL BS_TD 0 8 REG_MBR 0; FIRE TD; FIRE R; FIRE W","BSEL BS_TD 8 8 REG_MBR 0; FIRE TD; FIRE R; FIRE W","BSEL BS_TD 16 8 REG_MBR 0; FIRE TD; FIRE R; FIRE W","BSEL BS_TD 24 8 REG_MBR 0; FIRE TD; FIRE R; FIRE W","BSEL BS_TD 0 16 REG_MBR 0; FIRE TD; FIRE R; FIRE W","BSEL BS_TD 0 16 REG_MBR 0; FIRE TD; FIRE R; FIRE W","BSEL BS_TD 0 16 REG_MBR 0; FIRE TD; FIRE R; FIRE W","BSEL BS_TD 0 16 REG_MBR 0; FIRE TD; FIRE R; FIRE W","BSEL BS_TD 16 16 REG_MBR 0; FIRE TD; FIRE R; FIRE W","BSEL BS_TD 16 16 REG_MBR 0; FIRE TD; FIRE R; FIRE W","BSEL BS_TD 16 16 REG_MBR 0; FIRE TD; FIRE R; FIRE W","BSEL BS_TD 16 16 REG_MBR 0; FIRE TD; FIRE R; FIRE W","MV BS_TD REG_MBR; FIRE TD; FIRE R; FIRE W","MV BS_TD REG_MBR; FIRE TD; FIRE R; FIRE W","MV BS_TD REG_MBR; FIRE TD; FIRE R; FIRE W","MV BS_TD REG_MBR; FIRE TD; FIRE R; FIRE W"],fire_name:["svg_p:text3533-5"],draw_data:[[],[]],draw_name:[[],[]]};sim.ep.signals["SBWA"]={name:"SBWA",visible:false,type:"L",value:0,default_value:0,nbits:"5",behavior:["BSEL BS_M1 0 8 BUS_DB 0; FIRE M1","BSEL BS_M1 0 8 BUS_DB 8; FIRE M1","BSEL BS_M1 0 8 BUS_DB 16; FIRE M1","BSEL BS_M1 0 8 BUS_DB 24; FIRE M1","BSEL BS_M1 0 16 BUS_DB 0; FIRE M1","BSEL BS_M1 0 16 BUS_DB 0; FIRE M1","BSEL BS_M1 0 16 BUS_DB 0; FIRE M1","BSEL BS_M1 0 16 BUS_DB 0; FIRE M1","BSEL BS_M1 0 16 BUS_DB 16; FIRE M1","BSEL BS_M1 0 16 BUS_DB 16; FIRE M1","BSEL BS_M1 0 16 BUS_DB 16; FIRE M1","BSEL BS_M1 0 16 BUS_DB 16; FIRE M1","MV BS_M1 BUS_DB; FIRE M1","MV BS_M1 BUS_DB; FIRE M1","MV BS_M1 BUS_DB; FIRE M1","MV BS_M1 BUS_DB; FIRE M1","BSEL BS_M1 0 8 BUS_DB 0; EXT_SIG BS_M1 7; FIRE M1","BSEL BS_M1 0 8 BUS_DB 8; EXT_SIG BS_M1 7; FIRE M1","BSEL BS_M1 0 8 BUS_DB 16; EXT_SIG BS_M1 7; FIRE M1","BSEL BS_M1 0 8 BUS_DB 24; EXT_SIG BS_M1 7; FIRE M1","BSEL BS_M1 0 16 BUS_DB 0; EXT_SIG BS_M1 15; FIRE M1","BSEL BS_M1 0 16 BUS_DB 0; EXT_SIG BS_M1 15; FIRE M1","BSEL BS_M1 0 16 BUS_DB 0; EXT_SIG BS_M1 15; FIRE M1","BSEL BS_M1 0 16 BUS_DB 0; EXT_SIG BS_M1 15; FIRE M1","BSEL BS_M1 0 16 BUS_DB 16; EXT_SIG BS_M1 15; FIRE M1","BSEL BS_M1 0 16 BUS_DB 16; EXT_SIG BS_M1 15; FIRE M1","BSEL BS_M1 0 16 BUS_DB 16; EXT_SIG BS_M1 15; FIRE M1","BSEL BS_M1 0 16 BUS_DB 16; EXT_SIG BS_M1 15; FIRE M1","MV BS_M1 BUS_DB; FIRE M1","MV BS_M1 BUS_DB; FIRE M1","MV BS_M1 BUS_DB; FIRE M1","MV BS_M1 BUS_DB; FIRE M1"],fire_name:[],draw_data:[[],[]],draw_name:[[],[]]};sim.ep.signals["IOR"]={name:"IOR",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","MOVE_BITS KBD_IOR 0 1 IOR; MOVE_BITS SCR_IOR 0 1 IOR; MOVE_BITS L3D_IOR 0 1 IOR; MOVE_BITS L3D_IOR 0 1 IOR; FIRE KBD_IOR; FIRE SCR_IOR; FIRE L3D_IOR; FIRE LEDM_IOR"],fire_name:["svg_p:text3715"],draw_data:[[],["svg_p:path3733","svg_p:path3491","svg_p:text3715"]],draw_name:[[],[]]};sim.ep.signals["IOW"]={name:"IOW",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","MOVE_BITS SCR_IOW 0 1 IOW; FIRE SCR_IOW; MOVE_BITS IO_IOW 0 1 IOW; FIRE IO_IOW; MOVE_BITS L3D_IOW 0 1 IOW; FIRE L3D_IOW; MOVE_BITS LEDM_IOW 0 1 IOW; FIRE LEDM_IOW"],fire_name:["svg_p:text3717"],draw_data:[[],["svg_p:path3735","svg_p:path3491","svg_p:text3717"]],draw_name:[[],[]]};sim.ep.signals["I"]={name:"I",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV FLAG_I VAL_ZERO; FIRE_IFSET SELP 2","MV FLAG_I VAL_ONE; FIRE_IFSET SELP 2"],fire_name:[],draw_data:[[],[]],draw_name:[[],[]]};sim.ep.signals["U"]={name:"U",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV FLAG_U VAL_ZERO; FIRE_IFSET SELP 2","MV FLAG_U VAL_ONE; FIRE_IFSET SELP 2"],fire_name:[],draw_data:[[],[]],draw_name:[[],[]]};sim.ep.signals["TEST_C"]={name:"TEST_C",visible:true,type:"L",value:0,default_value:0,nbits:"1",forbidden:true,behavior:["MV FLAG_C VAL_ZERO; FIRE_IFSET SELP 2","MV FLAG_C VAL_ONE; FIRE_IFSET SELP 3"],depends_on:["SELCOP","COP"],fire_name:["svg_p:text3701-3"],draw_data:[["svg_p:text3701-3"]],draw_name:[[]]};sim.ep.signals["TEST_V"]={name:"TEST_V",visible:true,type:"L",value:0,default_value:0,nbits:"1",forbidden:true,behavior:["MV FLAG_V VAL_ZERO; FIRE_IFSET SELP 2","MV FLAG_V VAL_ONE; FIRE_IFSET SELP 3"],depends_on:["SELCOP","COP"],fire_name:["svg_p:text3701-3-1"],draw_data:[["svg_p:text3701-3-1"]],draw_name:[[]]};sim.ep.signals["TEST_N"]={name:"TEST_N",visible:true,type:"L",value:0,default_value:0,nbits:"1",forbidden:true,behavior:["MV FLAG_N VAL_ZERO; FIRE_IFSET SELP 2","MV FLAG_N VAL_ONE; FIRE_IFSET SELP 3"],depends_on:["SELCOP","COP"],fire_name:["svg_p:text3701-3-2"],draw_data:[["svg_p:text3701-3-2"]],draw_name:[[]]};sim.ep.signals["TEST_Z"]={name:"TEST_Z",visible:true,type:"L",value:0,default_value:0,nbits:"1",forbidden:true,behavior:["MV FLAG_Z VAL_ZERO; FIRE_IFSET SELP 2","MV FLAG_Z VAL_ONE; FIRE_IFSET SELP 3"],depends_on:["SELCOP","COP"],fire_name:["svg_p:text3701-3-5"],draw_data:[["svg_p:text3701-3-5"]],draw_name:[[]]};sim.ep.signals["TEST_I"]={name:"TEST_I",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV FLAG_I VAL_ZERO; FIRE_IFSET SELP 2","MV FLAG_I VAL_ONE; FIRE_IFSET SELP 2"],depends_on:["CLK"],fire_name:["svg_p:text3669"],draw_data:[["svg_p:text3669"]],draw_name:[[]]};sim.ep.signals["TEST_U"]={name:"TEST_U",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV FLAG_U VAL_ZERO; FIRE_IFSET SELP 1","MV FLAG_U VAL_ONE; FIRE_IFSET SELP 1"],depends_on:["CLK"],fire_name:["svg_p:text3669-1"],draw_data:[["svg_p:text3669-1"]],draw_name:[[]]};sim.ep.signals["TEST_INTV"]={name:"TEST_INTV",visible:true,type:"L",value:0,default_value:0,nbits:"8",forbidden:true,behavior:["MBIT INTV TEST_INTV 0 32"],depends_on:["INT"],fire_name:["svg_p:tspan4225"],draw_data:[["svg_p:path3749"]],draw_name:[[]]};sim.ep.behaviors["NOP"]={nparameters:1,operation:function(s_expr){},verbal:function(s_expr){return""}};sim.ep.behaviors["NOP_ALU"]={nparameters:1,operation:function(s_expr){sim.ep.internal_states.alu_flags.flag_n=0;sim.ep.internal_states.alu_flags.flag_z=0;sim.ep.internal_states.alu_flags.flag_c=0;sim.ep.internal_states.alu_flags.flag_v=0},verbal:function(s_expr){return""}};sim.ep.behaviors["MV"]={nparameters:3,types:["X","X"],operation:function(s_expr){sim_elto_org=get_reference(s_expr[2]);sim_elto_dst=get_reference(s_expr[1]);newval=get_value(sim_elto_org);set_value(sim_elto_dst,newval)},verbal:function(s_expr){var sim_elto_org=get_reference(s_expr[2]);var newval=get_value(sim_elto_org);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from "+show_verbal(s_expr[2])+" to "+show_verbal(s_expr[1])+" value "+show_value(newval)+". "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" ("+show_value(newval)+"). "}};sim.ep.behaviors["LOAD"]={nparameters:3,types:["X","X"],operation:function(s_expr){sim_elto_org=get_reference(s_expr[2]);sim_elto_dst=get_reference(s_expr[1]);newval=get_value(sim_elto_org);set_value(sim_elto_dst,newval)},verbal:function(s_expr){var sim_elto_org=get_reference(s_expr[2]);var newval=get_value(sim_elto_org);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Load from "+show_verbal(s_expr[2])+" to "+show_verbal(s_expr[1])+" value "+show_value(newval)+". "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" ("+show_value(newval)+"). "}};sim.ep.behaviors["CP_FIELD"]={nparameters:3,types:["X","X"],operation:function(s_expr){r=s_expr[2].split("/");sim_elto_org=get_reference(r[0]);newval=get_value(sim_elto_org);newval=newval[r[1]];if(typeof newval!="undefined"){sim_elto_dst=get_reference(s_expr[1]);set_value(sim_elto_dst,newval)}},verbal:function(s_expr){var newval=0;var r=s_expr[2].split("/");var sim_elto_org=get_reference(r[0]);var sim_elto_dst=get_reference(r[1]);if(typeof sim_elto_dst=="undefined")sim_elto_dst={};if(typeof sim_elto_org.value[r[1]]!="undefined")newval=sim_elto_org.value[r[1]];else if(typeof sim_elto_dst.default_value!="undefined")newval=sim_elto_dst.default_value;else newval="<undefined>";var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from Field "+r[1]+" of "+show_verbal(r[0])+" to "+show_verbal(s_expr[1])+" value "+newval+". "}return show_verbal(s_expr[1])+" = "+show_verbal(r[0])+"."+r[1]+" ("+newval+"). "}};sim.ep.behaviors["NOT_ES"]={nparameters:3,types:["S","E"],operation:function(s_expr){set_value(sim.ep.signals[s_expr[1]],Math.abs(get_value(sim.ep.states[s_expr[2]])-1))},verbal:function(s_expr){var value=Math.abs(get_value(sim.ep.states[s_expr[2]])-1);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Set "+show_verbal(s_expr[1])+" with value "+show_value(value)+" (Logical NOT of "+s_expr[2]+"). "}return show_verbal(s_expr[1])+" = "+show_value(value)+" (Logical NOT "+s_expr[2]+"). "}};sim.ep.behaviors["GET"]={nparameters:4,types:["E","E","S"],operation:function(s_expr){set_value(sim.ep.states[s_expr[1]],get_value(sim.ep.states[s_expr[2]][sim.ep.signals[s_expr[3]].value]))},verbal:function(s_expr){var value=get_value(sim.ep.states[s_expr[2]][sim.ep.signals[s_expr[3]].value]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Set "+show_verbal(s_expr[1])+" with value "+show_value(value)+" (Register File "+s_expr[3]+"). "}return show_verbal(s_expr[1])+" = "+show_value(value)+" (Register File "+s_expr[3]+"). "}};sim.ep.behaviors["SET"]={nparameters:4,types:["E","S","E"],operation:function(s_expr){set_value(sim.ep.states[s_expr[1]][sim.ep.signals[s_expr[2]].value],get_value(sim.ep.states[s_expr[3]]))},verbal:function(s_expr){var value=get_value(sim.ep.states[s_expr[3]]);var o_ref=sim.ep.states[s_expr[1]][sim.ep.signals[s_expr[2]].value];var o_verbal=o_ref.name;if(typeof o_ref.verbal!="undefined")o_verbal=o_ref.verbal;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy to "+o_verbal+" the value "+show_value(value)+". "}return o_verbal+" = "+show_value(value)+". "}};sim.ep.behaviors["AND"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])&get_value(sim.ep.states[s_expr[3]]);set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_v=0;sim.ep.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])&get_value(sim.ep.states[s_expr[3]]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU AND with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (AND). "}};sim.ep.behaviors["OR"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])|get_value(sim.ep.states[s_expr[3]]);set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_v=0;sim.ep.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])|get_value(sim.ep.states[s_expr[3]]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU OR with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (OR). "}};sim.ep.behaviors["NOT"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=~get_value(sim.ep.states[s_expr[2]]);set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_v=0;sim.ep.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=~get_value(sim.ep.states[s_expr[2]]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU NOT with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (NOT). "}};sim.ep.behaviors["XOR"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])^get_value(sim.ep.states[s_expr[3]]);set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_v=0;sim.ep.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])^get_value(sim.ep.states[s_expr[3]]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU XOR with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (XOR). "}};sim.ep.behaviors["SRL"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])>>>1;set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_v=0;sim.ep.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])>>>1;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Shift Right Logical with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (SRL). "}};sim.ep.behaviors["SRA"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])>>1;set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_v=0;sim.ep.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])>>1;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Shift Right Arithmetic with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (SRA). "}};sim.ep.behaviors["SL"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])<<1;set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_v=0;sim.ep.internal_states.alu_flags.flag_c=result>>>31},verbal:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])<<1;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Shift Left with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (SL). "}};sim.ep.behaviors["RR"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])>>>1|(get_value(sim.ep.states[s_expr[2]])&1)<<31;set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_v=0;sim.ep.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])>>>1|(get_value(sim.ep.states[s_expr[2]])&1)<<31;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Right Rotation with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (RR). "}};sim.ep.behaviors["RL"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])<<1|(get_value(sim.ep.states[s_expr[2]])&2147483648)>>>31;set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_v=0;sim.ep.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])<<1|(get_value(sim.ep.states[s_expr[2]])&2147483648)>>>31;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Left Rotation with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (LR). "}};sim.ep.behaviors["ADD"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var b=get_value(sim.ep.states[s_expr[3]])<<0;var result=a+b;set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_c=a>>>31&&b>>>31;sim.ep.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.ep.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.ep.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var b=get_value(sim.ep.states[s_expr[3]])<<0;var result=a+b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU ADD with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (ADD). "}};sim.ep.behaviors["SUB"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var b=get_value(sim.ep.states[s_expr[3]])<<0;var result=a-b;set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_c=a>>>31&&b>>>31;sim.ep.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.ep.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.ep.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var b=get_value(sim.ep.states[s_expr[3]])<<0;var result=a-b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU SUB with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (SUB). "}};sim.ep.behaviors["MUL"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var b=get_value(sim.ep.states[s_expr[3]])<<0;var result=a*b;set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_c=0;sim.ep.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.ep.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.ep.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var b=get_value(sim.ep.states[s_expr[3]])<<0;var result=a*b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU MUL with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (MUL). "}};sim.ep.behaviors["DIV"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var b=get_value(sim.ep.states[s_expr[3]])<<0;if(0==b){set_value(sim.ep.states[s_expr[1]],0);sim.ep.internal_states.alu_flags.flag_n=0;sim.ep.internal_states.alu_flags.flag_z=1;sim.ep.internal_states.alu_flags.flag_v=1;sim.ep.internal_states.alu_flags.flag_c=0;return}var result=Math.floor(a/b);set_value(sim.ep.states[s_expr[1]],result);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_v=0;sim.ep.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var b=get_value(sim.ep.states[s_expr[3]])<<0;if(0==b){return"ALU DIV zero by zero (oops!). "}var result=Math.floor(a/b);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU DIV with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (DIV). "}};sim.ep.behaviors["MOD"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var b=get_value(sim.ep.states[s_expr[3]])<<0;if(0==b){set_value(sim.ep.states[s_expr[1]],0);sim.ep.internal_states.alu_flags.flag_n=0;sim.ep.internal_states.alu_flags.flag_z=1;sim.ep.internal_states.alu_flags.flag_v=1;sim.ep.internal_states.alu_flags.flag_c=0;return}var result=a%b;set_value(sim.ep.states[s_expr[1]],result);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_v=0;sim.ep.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var b=get_value(sim.ep.states[s_expr[3]])<<0;if(0==b){return"ALU MOD zero by zero (oops!). "}var result=a%b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU MOD with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (MOD). "}};sim.ep.behaviors["LUI"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])<<16;set_value(sim.ep.states[s_expr[1]],result);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_v=0;sim.ep.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.ep.states[s_expr[2]])<<16;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Load Upper Immediate with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (LUI). "}};sim.ep.behaviors["ADDU"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])>>>0;var b=get_value(sim.ep.states[s_expr[3]])>>>0;var result=a+b;set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_c=0;sim.ep.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.ep.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.ep.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])>>>0;var b=get_value(sim.ep.states[s_expr[3]])>>>0;var result=a+b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU ADDU with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (ADDU). "}};sim.ep.behaviors["SUBU"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])>>>0;var b=get_value(sim.ep.states[s_expr[3]])>>>0;var result=a-b;set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_c=0;sim.ep.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.ep.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.ep.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])>>>0;var b=get_value(sim.ep.states[s_expr[3]])>>>0;var result=a-b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU SUBU with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (SUBU). "}};sim.ep.behaviors["MULU"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])>>>0;var b=get_value(sim.ep.states[s_expr[3]])>>>0;var result=a*b;set_value(sim.ep.states[s_expr[1]],result>>>0);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_c=0;sim.ep.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.ep.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.ep.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])>>>0;var b=get_value(sim.ep.states[s_expr[3]])>>>0;var result=a*b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU MULU with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (MULU). "}};sim.ep.behaviors["DIVU"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])>>>0;var b=get_value(sim.ep.states[s_expr[3]])>>>0;if(0==b){set_value(sim.ep.states[s_expr[1]],0);sim.ep.internal_states.alu_flags.flag_n=0;sim.ep.internal_states.alu_flags.flag_z=1;sim.ep.internal_states.alu_flags.flag_v=1;sim.ep.internal_states.alu_flags.flag_c=0;return}var result=Math.floor(a/b);set_value(sim.ep.states[s_expr[1]],result);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_v=0;sim.ep.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])>>>0;var b=get_value(sim.ep.states[s_expr[3]])>>>0;if(0==b){return"ALU DIVU zero by zero (oops!). "}var result=Math.floor(a/b);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU DIVU with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (DIVU). "}};sim.ep.behaviors["FADD"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]]);var b=get_value(sim.ep.states[s_expr[3]]);var result=hex2float(a)+hex2float(b);set_value(sim.ep.states[s_expr[1]],float32_to_uint(result));sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_c=0;sim.ep.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.ep.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.ep.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]]);var b=get_value(sim.ep.states[s_expr[3]]);var result=hex2float(a)+hex2float(b);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU FADD with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (FADD). "}};sim.ep.behaviors["FSUB"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]]);var b=get_value(sim.ep.states[s_expr[3]]);var result=hex2float(a)-hex2float(b);set_value(sim.ep.states[s_expr[1]],float32_to_uint(result));sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_c=0;sim.ep.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.ep.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.ep.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]]);var b=get_value(sim.ep.states[s_expr[3]]);var result=hex2float(a)-hex2float(b);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU FSUB with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (FSUB). "}};sim.ep.behaviors["FMUL"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]]);var b=get_value(sim.ep.states[s_expr[3]]);var result=hex2float(a)*hex2float(b);set_value(sim.ep.states[s_expr[1]],float32_to_uint(result));sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_c=0;sim.ep.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.ep.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.ep.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]]);var b=get_value(sim.ep.states[s_expr[3]]);var result=hex2float(a)*hex2float(b);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU FMUL with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (FMUL). "}};sim.ep.behaviors["FDIV"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]]);var b=get_value(sim.ep.states[s_expr[3]]);var result=hex2float(a)/hex2float(b);set_value(sim.ep.states[s_expr[1]],float32_to_uint(result));sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_c=0;sim.ep.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.ep.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.ep.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]]);var b=get_value(sim.ep.states[s_expr[3]]);var result=hex2float(a)-hex2float(b);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU FDIV with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (FDIV). "}};sim.ep.behaviors["FCVT"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])>>>0;var b=get_value(sim.ep.states[s_expr[3]]);var result=a;switch(b){case 1:result=hex2float(result);result=Math.trunc(result);break;case 2:result=hex2float(result);result=Math.round(result);break;case 4:result=result.toFixed(5);result=parseFloat(result);result=float2decimal(result);break;default:break}set_value(sim.ep.states[s_expr[1]],result);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_c=0;sim.ep.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.ep.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.ep.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])>>>0;var b=get_value(sim.ep.states[s_expr[3]]);var result=a;switch(b){case 1:result=hex2float(result);result=Math.trunc(result);break;case 2:result=hex2float(result);result=Math.round(result);break;case 4:result=result.toFixed(5);result=parseFloat(result);result=float2decimal(result);break;default:break}var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU FCVT with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (FCVT). "}};sim.ep.behaviors["FCLASS"]={nparameters:3,types:["E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])>>>0;var result=float_class(a);set_value(sim.ep.states[s_expr[1]],result);sim.ep.internal_states.alu_flags.flag_n=result<0?1:0;sim.ep.internal_states.alu_flags.flag_z=result==0?1:0;sim.ep.internal_states.alu_flags.flag_c=0;sim.ep.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.ep.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.ep.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[1]])>>>0;var result=float_class(a);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU FCLASS with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (FCLASS). "}};sim.ep.behaviors["PLUS1"]={nparameters:3,types:["E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var result=a+1;set_value(sim.ep.states[s_expr[1]],result>>>0)},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var result=a+1;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy to "+show_verbal(s_expr[1])+" "+show_verbal(s_expr[2])+" plus one with result "+show_value(result)+". "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" + 1"+" ("+show_value(result)+"). "}};sim.ep.behaviors["PLUS4"]={nparameters:3,types:["E","E"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var result=a+4;set_value(sim.ep.states[s_expr[1]],result>>>0)},verbal:function(s_expr){var a=get_value(sim.ep.states[s_expr[2]])<<0;var result=a+4;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy to "+show_verbal(s_expr[1])+" "+show_verbal(s_expr[2])+" plus four with result "+show_value(result)+". "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" + 4"+" ("+show_value(result)+"). "}};sim.ep.behaviors["SET_TT"]={nparameters:3,types:["E","I"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[1]])<<0;var b=parseInt(s_expr[2]);var m=Math.pow(2,b);var r=a|m;set_value(sim.ep.states[s_expr[1]],r);update_cpu_bus_fire(r,b)},verbal:function(s_expr){return""}};sim.ep.behaviors["RST_TT"]={nparameters:3,types:["E","I"],operation:function(s_expr){var a=get_value(sim.ep.states[s_expr[1]])<<0;var b=parseInt(s_expr[2]);var m=Math.pow(2,b);var r=a&~m;set_value(sim.ep.states[s_expr[1]],r);update_cpu_bus_fire(r,b)},verbal:function(s_expr){return""}};sim.ep.behaviors["CHECK_RTD"]={nparameters:1,operation:function(s_expr){var number_active_tri=parseInt(simhw_sim_signal("TD").value)+parseInt(simhw_sim_signal("R").value);update_system_bus_fire(number_active_tri)},verbal:function(s_expr){return""}};sim.ep.behaviors["MBIT"]={nparameters:5,types:["X","X","I","I"],operation:function(s_expr){var sim_elto_dst=get_reference(s_expr[1]);var sim_elto_org=get_reference(s_expr[2]);var offset=parseInt(s_expr[3]);var size=parseInt(s_expr[4]);var n1=get_value(sim_elto_org).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(offset+size-1),size);set_value(sim_elto_dst,parseInt(n2,2))},verbal:function(s_expr){var sim_elto_dst=get_reference(s_expr[1]);var sim_elto_org=get_reference(s_expr[2]);var offset=parseInt(s_expr[3]);var size=parseInt(s_expr[4]);var n1=get_value(sim_elto_org).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(offset+size-1),size);var n3=parseInt(n2,2);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from "+show_verbal(s_expr[2])+" to "+show_verbal(s_expr[1])+" value "+show_value(n3)+" (copied "+size+" bits from bit "+offset+"). "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" ("+show_value(n3)+", "+size+" bits from bit "+offset+"). "}};sim.ep.behaviors["MBIT_SN"]={nparameters:5,types:["S","E","E","I"],operation:function(s_expr){var base=0;var r=s_expr[3].split("/");if(1==r.length)base=get_value(sim.ep.states[s_expr[3]]);else if(typeof sim.ep.states[r[0]].value[r[1]]!="undefined")base=sim.ep.states[r[0]].value[r[1]];else if(typeof sim.ep.signals[r[1]].default_value!="undefined")base=sim.ep.signals[r[1]].default_value;else if(typeof sim.ep.states[r[1]].default_value!="undefined")base=sim.ep.states[r[1]].default_value;else ws_alert("WARN: undefined state/field pair -> "+r[0]+"/"+r[1]);var offset=parseInt(s_expr[4]);var n1=get_value(sim.ep.states[s_expr[2]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;var n3=n2.substr(31-(base+offset-1),offset);set_value(sim.ep.signals[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){var base=0;var r=s_expr[3].split("/");if(1==r.length)base=get_value(sim.ep.states[s_expr[3]]);else if(typeof sim.ep.states[r[0]].value[r[1]]!="undefined")base=sim.ep.states[r[0]].value[r[1]];else if(typeof sim.ep.signals[r[1]].default_value!="undefined")base=sim.ep.signals[r[1]].default_value;else if(typeof sim.ep.states[r[1]].default_value!="undefined")base=sim.ep.states[r[1]].default_value;else ws_alert("WARN: undefined state/field pair -> "+r[0]+"/"+r[1]);var offset=parseInt(s_expr[4]);var n1=get_value(sim.ep.states[s_expr[2]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;var n3=n2.substr(31-(base+offset-1),offset);var from_elto="";if(1==r.length)from_elto=show_verbal(s_expr[3]);else from_elto=show_verbal(s_expr[2])+"["+r[1]+"] ";var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from "+from_elto+"into "+show_verbal(s_expr[1])+" "+"value "+parseInt(n3,2)+". "}return show_verbal(s_expr[1])+" = "+from_elto+" ("+parseInt(n3,2)+"). "}};sim.ep.behaviors["SBIT_SIGNAL"]={nparameters:4,types:["X","I","I"],operation:function(s_expr){sim_elto_dst=get_reference(s_expr[1]);var new_value=sim_elto_dst.value;var mask=1<>>0)},verbal:function(s_expr){sim_elto_dst=get_reference(s_expr[1]);var new_value=sim_elto_dst.value;var mask=1<>>0)}};sim.ep.behaviors["UPDATE_FLAG"]={nparameters:4,types:["X","X","I"],operation:function(s_expr){sim_elto_org=get_reference(s_expr[2]);sim_elto_dst=get_reference(s_expr[1]);var new_value=sim_elto_dst.value&~(1<>>0)},verbal:function(s_expr){sim_elto_org=get_reference(s_expr[2]);sim_elto_dst=get_reference(s_expr[1]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Update "+show_verbal(s_expr[2])+" to value "+sim_elto_org.value+". "}return show_verbal(s_expr[1])+"."+show_verbal(s_expr[3])+" = "+sim_elto_org.value+". "}};sim.ep.behaviors["MBITS"]={nparameters:8,types:["E","I","E","S","S","I","S"],operation:function(s_expr){var offset=parseInt(sim.ep.signals[s_expr[4]].value);var size=parseInt(sim.ep.signals[s_expr[5]].value);var n1=get_value(sim.ep.states[s_expr[3]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(offset+size-1),size);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;if("1"==sim.ep.signals[s_expr[7]].value&&"1"==n2.substr(0,1)){n3="11111111111111111111111111111111".substring(0,32-n2.length)+n2}set_value(sim.ep.states[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){var offset=parseInt(sim.ep.signals[s_expr[4]].value);var size=parseInt(sim.ep.signals[s_expr[5]].value);var n1=get_value(sim.ep.states[s_expr[3]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(offset+size-1),size);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;if("1"==sim.ep.signals[s_expr[7]].value&&"1"==n2.substr(0,1)){n3="11111111111111111111111111111111".substring(0,32-n2.length)+n2}n1=parseInt(n3,2);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return" Copy from "+show_verbal(s_expr[3])+" to "+show_verbal(s_expr[1])+" value "+show_value(n1)+" (copied "+size+" bits from bit "+offset+"). "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[3])+" ("+show_value(n1)+", "+size+" bits from bit "+offset+"). "}};sim.ep.behaviors["BSEL"]={nparameters:6,types:["E","I","I","E","I"],operation:function(s_expr){var posd=parseInt(s_expr[2]);var poso=parseInt(s_expr[5]);var len=parseInt(s_expr[3]);var n1=get_value(sim.ep.states[s_expr[4]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(poso+len)+1,len);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var n4="00000000000000000000000000000000".substr(0,posd);n3=n3+n4;set_value(sim.ep.states[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){var posd=parseInt(s_expr[2]);var len=parseInt(s_expr[3]);var poso=parseInt(s_expr[5]);var n1=get_value(sim.ep.states[s_expr[4]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(poso+len)+1,len);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var n4="00000000000000000000000000000000".substr(0,posd);n3=n3+n4;var n5=parseInt(n3,2);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from "+show_verbal(s_expr[4])+" to "+show_verbal(s_expr[1])+" value "+show_value(n5)+" (copied "+len+" bits, from bit "+poso+" of "+s_expr[4]+" to bit "+posd+" of "+s_expr[1]+"). "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[4])+" ("+show_value(n5)+", "+len+" bits, from bit "+poso+" of "+s_expr[4]+" to bit "+posd+" of "+s_expr[1]+"). "}};sim.ep.behaviors["EXT_SIG"]={nparameters:3,types:["E","I"],operation:function(s_expr){var n1=get_value(sim.ep.states[s_expr[1]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;var n3=n2.substr(31-s_expr[2],31);var n4=n3;if("1"==n2[31-s_expr[2]]){n4="11111111111111111111111111111111".substring(0,32-n3.length)+n4}set_value(sim.ep.states[s_expr[1]],parseInt(n4,2))},verbal:function(s_expr){var n1=get_value(sim.ep.states[s_expr[1]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;var n3=n2.substr(31-s_expr[2],31);var n4=n3;if("1"==n2[31-s_expr[2]]){n4="11111111111111111111111111111111".substring(0,32-n3.length)+n4}var n5=parseInt(n4,2);return"Sign Extension with value "+show_value(n5)+". "}};sim.ep.behaviors["MOVE_BITS"]={nparameters:5,types:["S","I","I","S"],operation:function(s_expr){var posd=parseInt(s_expr[2]);var poso=0;var len=parseInt(s_expr[3]);var n1=sim.ep.signals[s_expr[4]].value.toString(2);n1="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n1=n1.substr(31-poso-len+1,len);var n2=sim.ep.signals[s_expr[1]].value.toString(2);n2="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var m1=n2.substr(0,32-(posd+len));var m2=n2.substr(31-posd+1,posd);var n3=m1+n1+m2;set_value(sim.ep.signals[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){return""}};sim.ep.behaviors["MOVE_BITSE"]={nparameters:6,types:["S","I","I","E","I"],operation:function(s_expr){var posd=parseInt(s_expr[2]);var poso=parseInt(s_expr[5]);var len=parseInt(s_expr[3]);var n1=get_value(sim.ep.states[s_expr[4]]).toString(2);n1="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n1=n1.substr(31-poso-len+1,len);var n2=sim.ep.signals[s_expr[1]].value.toString(2);n2="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var m1=n2.substr(0,32-(posd+len));var m2=n2.substr(31-posd+1,posd);var n3=m1+n1+m2;set_value(sim.ep.signals[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){return""}};sim.ep.behaviors["DECO"]={nparameters:1,operation:function(s_expr){sim.ep.states["INEX"].value=0;var oi=decode_instruction(sim.ep.internal_states.FIRMWARE,sim.ep.ctrl_states.ir,get_value(sim.ep.states["REG_IR"]));if(null==oi.oinstruction){ws_alert("ERROR: undefined instruction code in IR ("+"co:"+oi.op_code.toString(2)+", "+"cop:"+oi.cop_code.toString(2)+")");sim.ep.states["ROM_MUXA"].value=0;sim.ep.states["INEX"].value=1;return-1}var rom_addr=oi.op_code<<6;if(typeof oi.oinstruction.cop!="undefined"){rom_addr=rom_addr+oi.cop_code}if(typeof sim.ep.internal_states["ROM"][rom_addr]=="undefined"){ws_alert("ERROR: undefined rom address "+rom_addr+" in firmware");sim.ep.states["ROM_MUXA"].value=0;return-1}sim.ep.states["ROM_MUXA"].value=sim.ep.internal_states["ROM"][rom_addr];var val=get_value(sim.ep.states["DECO_INS"]);set_value(sim.ep.states["DECO_INS"],val+1);var pc=get_value(sim.ep.states["REG_PC"])-4;var decins=get_deco_from_pc(pc);set_value(sim.ep.states["REG_IR_DECO"],decins);show_dbg_ir(get_value(sim.ep.states["REG_IR_DECO"]))},verbal:function(s_expr){return"Decode instruction. "}};sim.ep.behaviors["FIRE"]={nparameters:2,types:["S"],operation:function(s_expr){if(sim.ep.internal_states.fire_stack.indexOf(s_expr[1])!=-1){return}sim.ep.internal_states.fire_stack.push(s_expr[1]);update_draw(sim.ep.signals[s_expr[1]],sim.ep.signals[s_expr[1]].value);if("L"==sim.ep.signals[s_expr[1]].type){update_state(s_expr[1])}sim.ep.internal_states.fire_stack.pop(s_expr[1])},verbal:function(s_expr){return""}};sim.ep.behaviors["FIRE_IFSET"]={nparameters:3,types:["S","I"],operation:function(s_expr){if(get_value(sim.ep.signals[s_expr[1]])!=parseInt(s_expr[2])){return}sim.ep.behaviors["FIRE"].operation(s_expr)},verbal:function(s_expr){return""}};sim.ep.behaviors["FIRE_IFCHANGED"]={nparameters:3,types:["S","X"],operation:function(s_expr){sim_elto=get_reference(s_expr[2]);if(sim_elto.changed==false){return}sim.ep.behaviors["FIRE"].operation(s_expr)},verbal:function(s_expr){return""}};sim.ep.behaviors["RESET_CHANGED"]={nparameters:2,types:["X"],operation:function(s_expr){sim_elto=get_reference(s_expr[1]);sim_elto.changed=false},verbal:function(s_expr){return""}};sim.ep.behaviors["CLOCK"]={nparameters:1,operation:function(s_expr){var new_maddr=null;var mcelto=null;var t0=performance.now();var val=get_value(sim.ep.states["CLK"]);set_value(sim.ep.states["CLK"],val+1);set_value(sim.ep.states["TTCPU"],0);new_maddr=get_value(sim.ep.states["REG_MICROADDR"]);mcelto=sim.ep.internal_states["MC"][new_maddr];if(typeof mcelto!=="undefined"&&false==mcelto.is_native){for(var i=0;i>>0},set_value:function(elto,value){var origin="";var r_value=main_memory_get_program_counter();if(r_value!=null){origin="PC=0x"+r_value.toString(16)}var melto={value:value>>>0,source_tracking:[origin],comments:null};var valref=main_memory_set(sim.ep.internal_states.MP,elto,melto);show_main_memory(sim.ep.internal_states.MP,elto,typeof valref==="undefined",true);return value}};sim.ep.internal_states.segments={};sim.ep.internal_states.MP_wc=0;sim.ep.internal_states.MP={};sim.ep.internal_states.CM_cfg=[];sim.ep.internal_states.CM=[];sim.ep.signals.MRDY={name:"MRDY",visible:true,type:"L",value:0,default_value:0,nbits:"1",depends_on:["CLK"],behavior:["FIRE_IFCHANGED MRDY C","FIRE_IFCHANGED MRDY C"],fire_name:["svg_p:tspan3916","svg_p:text3909"],draw_data:[[],["svg_p:path3895","svg_p:path3541"]],draw_name:[[],[]]};sim.ep.signals.R={name:"R",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; CHECK_RTD","MEM_READ BUS_AB BUS_DB BWA MRDY CLK; FIRE MRDY; CHECK_RTD"],fire_name:["svg_p:text3533-5-2","svg_p:text3713"],draw_data:[[],["svg_p:path3557","svg_p:path3571"]],draw_name:[[],[]]};sim.ep.signals.W={name:"W",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","MEM_WRITE BUS_AB BUS_DB BWA MRDY CLK; FIRE MRDY"],fire_name:["svg_p:text3533-5-08","svg_p:text3527","svg_p:text3431-7"],draw_data:[[],["svg_p:path3559","svg_p:path3575","svg_p:path3447-7"]],draw_name:[[],[]]};sim.ep.behaviors.MEM_READ={nparameters:6,types:["E","E","S","S","E"],operation:function(s_expr){var address=sim.ep.states[s_expr[1]].value;var dbvalue=sim.ep.states[s_expr[2]].value;var bw=sim.ep.signals[s_expr[3]].value;var clk=get_value(sim.ep.states[s_expr[5]]);sim.ep.signals[s_expr[4]].value=0;var remain=get_value(sim.ep.internal_states.MP_wc);if(typeof sim.ep.events.mem[clk-1]!="undefined"&&sim.ep.events.mem[clk-1]>0){remain=sim.ep.events.mem[clk-1]-1}var first_time=typeof sim.ep.events.mem[clk]=="undefined";sim.ep.events.mem[clk]=remain;if(remain>0){return}address=address&4294967292;var value=main_memory_getvalue(sim.ep.internal_states.MP,address);var full_redraw=false;if(typeof value==="undefined"){value=0;full_redraw=true}dbvalue=main_memory_fusionvalues(dbvalue,value,bw);sim.ep.states[s_expr[2]].value=dbvalue>>>0;sim.ep.signals[s_expr[4]].value=1;show_main_memory(sim.ep.internal_states.MP,address,full_redraw,false);if(first_time&&sim.ep.internal_states.CM.length>0){cache_memory_access(sim.ep.internal_states.CM[0],address,"read",clk)}},verbal:function(s_expr){var verbal="";var address=sim.ep.states[s_expr[1]].value;var dbvalue=sim.ep.states[s_expr[2]].value;var bw=sim.ep.signals[s_expr[3]].value;var clk=get_value(sim.ep.states[s_expr[5]]);var bw_type="word";if(0==(bw&12))bw_type="byte";else if(1==(bw&12))bw_type="half";var value=main_memory_getvalue(sim.ep.internal_states.MP,address);if(typeof value==="undefined")value=0;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){verbal="Try to read a "+bw_type+" from memory "+"at address 0x"+address.toString(16)+" with value 0x"+value.toString(16)+". "}verbal="Memory output = 0x"+value.toString(16)+" (Read a "+bw_type+" from 0x"+address.toString(16)+"). ";return verbal}};sim.ep.behaviors.MEM_WRITE={nparameters:6,types:["E","E","S","S","E"],operation:function(s_expr){var address=sim.ep.states[s_expr[1]].value;var dbvalue=sim.ep.states[s_expr[2]].value;var bw=sim.ep.signals[s_expr[3]].value;var clk=get_value(sim.ep.states[s_expr[5]]);sim.ep.signals[s_expr[4]].value=0;var remain=get_value(sim.ep.internal_states.MP_wc);if(typeof sim.ep.events.mem[clk-1]!="undefined"&&sim.ep.events.mem[clk-1]>0){remain=sim.ep.events.mem[clk-1]-1}var first_time=typeof sim.ep.events.mem[clk]=="undefined";sim.ep.events.mem[clk]=remain;if(remain>0){return}address=address&4294967292;var value=main_memory_getvalue(sim.ep.internal_states.MP,address);var full_redraw=false;if(typeof value==="undefined"){value=0;full_redraw=true}value=main_memory_fusionvalues(value,dbvalue,bw);var origin="";var r_value=main_memory_get_program_counter();if(r_value!=null){origin="PC=0x"+r_value.toString(16)}var melto={value:value>>>0,source_tracking:[origin],comments:null};var valref=main_memory_set(sim.ep.internal_states.MP,address,melto);sim.ep.signals[s_expr[4]].value=1;show_main_memory(sim.ep.internal_states.MP,address,full_redraw,true);if(first_time&&sim.ep.internal_states.CM.length>0){cache_memory_access(sim.ep.internal_states.CM[0],address,"write",clk)}},verbal:function(s_expr){var verbal="";var address=sim.ep.states[s_expr[1]].value;var dbvalue=sim.ep.states[s_expr[2]].value;var bw=sim.ep.signals[s_expr[3]].value;var clk=get_value(sim.ep.states[s_expr[5]]);var bw_type="word";if(0==(bw&12))bw_type="byte";else if(1==(bw&12))bw_type="half";var value=main_memory_getvalue(sim.ep.internal_states.MP,address);if(typeof value==="undefined")value=0;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){verbal="Try to write a "+bw_type+" to memory "+"at address 0x"+address.toString(16)+" with value "+value.toString(16)+". "}verbal="Memory[0x"+address.toString(16)+"] = "+"0x"+value.toString(16)+" (Write a "+bw_type+" to 0x"+address.toString(16)+"). ";return verbal}};sim.ep.behaviors.MEMORY_RESET={nparameters:1,operation:function(s_expr){sim.ep.events.mem={}},verbal:function(s_expr){return"Reset main memory (all values will be zeroes). "}};sim.ep.elements.memory={name:"Main memory",description:"Main memory subsystem",type:"subcomponent",belongs:"MEMORY",states:{addr:{ref:"BUS_AB"},data:{ref:"BUS_DB"},mrdy:{ref:"MRDY"}},signals:{be:{ref:"BWA"},r:{ref:"R"},w:{ref:"W"}},states_inputs:["addr","data"],states_outputs:["mrdy","data"],signals_inputs:["be","r","w"],signals_output:[]};sim.ep.components.IO={name:"IO",version:"1",abilities:["IO_TIMER"],details_name:["IO_STATS","IO_CONFIG"],details_fire:[["svg_p:text3775"],[]],write_state:function(vec){return vec},read_state:function(o,check){return false},get_state:function(reg){return null},get_value:function(elto){var associated_state=simhw_internalState_get("io_hash",elto);var value=get_value(simhw_sim_state(associated_state))>>>0;set_value(simhw_sim_state("BUS_AB"),elto);set_value(simhw_sim_signal("IOR"),1);compute_behavior("FIRE IOR");value=get_value(simhw_sim_state("BUS_DB"));return value},set_value:function(elto,value){var associated_state=simhw_internalState_get("io_hash",elto);set_value(simhw_sim_state(associated_state),value);set_value(simhw_sim_state("BUS_AB"),elto);set_value(simhw_sim_state("BUS_DB"),value);set_value(simhw_sim_signal("IOW"),1);compute_behavior("FIRE IOW");return value}};sim.ep.internal_states.io_int_factory=[];sim.ep.internal_states.io_int_factory[0]={period:0,probability:.5,accumulated:0,active:false};sim.ep.internal_states.io_int_factory[1]={period:0,probability:.5,accumulated:0,active:false};sim.ep.internal_states.io_int_factory[2]={period:0,probability:.5,accumulated:0,active:false};sim.ep.internal_states.io_int_factory[3]={period:0,probability:.5,accumulated:0,active:false};sim.ep.internal_states.io_int_factory[4]={period:0,probability:.5,accumulated:0,active:false};sim.ep.internal_states.io_int_factory[5]={period:0,probability:.5,accumulated:0,active:false};sim.ep.internal_states.io_int_factory[6]={period:0,probability:.5,accumulated:0,active:false};sim.ep.internal_states.io_int_factory[7]={period:0,probability:.5,accumulated:0,active:false};var IOSR_ID=4352;var IOCR_ID=4356;var IODR_ID=4360;sim.ep.internal_states.io_hash[IOSR_ID]="IOSR";sim.ep.internal_states.io_hash[IOCR_ID]="IOCR";sim.ep.internal_states.io_hash[IODR_ID]="IODR";sim.ep.states.IOSR={name:"IOSR",verbal:"IO State Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.IOCR={name:"IOCR",verbal:"IO Control Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.IODR={name:"IODR",verbal:"IO Data Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.signals.INT={name:"INT",visible:true,type:"L",value:0,default_value:0,nbits:"1",depends_on:["CLK"],behavior:["FIRE C","FIRE C"],fire_name:["svg_p:tspan4199"],draw_data:[[],["svg_p:path3809"]],draw_name:[[],[]]};sim.ep.signals.IORDY={name:"IORDY",visible:true,type:"L",value:0,default_value:0,nbits:"1",depends_on:["CLK"],behavior:["FIRE_IFCHANGED IORDY C","FIRE_IFCHANGED IORDY C"],fire_name:["svg_p:tspan4089","svg_p:path3793","svg_p:text3911"],draw_data:[[],["svg_p:path3897"]],draw_name:[[],[]]};sim.ep.signals.IO_IOR={name:"IO_IOR",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","IO_IOR BUS_AB BUS_DB IOSR IOCR IODR CLK; FIRE SBWA"],fire_name:["svg_p:tspan4173"],draw_data:[[],["svg_p:path3795","svg_p:path3733"]],draw_name:[[],[]]};sim.ep.signals.IO_IOW={name:"IO_IOW",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","IO_IOW BUS_AB BUS_DB IOSR IOCR IODR CLK; FIRE SBWA"],fire_name:["svg_p:text3785-0-6-0-5-5"],draw_data:[[],["svg_p:path3805","svg_p:path3733"]],draw_name:[[],[]]};sim.ep.signals.IO_IE={name:"IO_IE",visible:true,type:"L",value:1,default_value:1,nbits:"1",behavior:["NOP","IO_CHK_I CLK INT INTV; FIRE C"],fire_name:[],draw_data:[[],[]],draw_name:[[],[]]};sim.ep.signals.INTA={name:"INTA",visible:true,type:"L",value:1,default_value:0,nbits:"1",behavior:["NOP","INTA CLK INT INTA BUS_DB INTV; FIRE BW; FIRE C"],fire_name:["svg_p:text3785-0-6-0-5-5-1-1"],draw_data:[[],["svg_p:path3807","svg_p:path3737"]],draw_name:[[],[]]};sim.ep.behaviors.IO_IOR={nparameters:7,types:["E","E","E","E","E","E"],operation:function(s_expr){var bus_ab=get_value(sim.ep.states[s_expr[1]]);var iosr=get_value(sim.ep.states[s_expr[3]]);var iocr=get_value(sim.ep.states[s_expr[4]]);var iodr=get_value(sim.ep.states[s_expr[5]]);if(bus_ab==IOSR_ID)set_value(sim.ep.states[s_expr[2]],iosr);if(bus_ab==IOCR_ID)set_value(sim.ep.states[s_expr[2]],iocr);if(bus_ab==IODR_ID)set_value(sim.ep.states[s_expr[2]],iodr)},verbal:function(s_expr){var verbal="";var bus_ab=get_value(sim.ep.states[s_expr[1]]);var iosr=get_value(sim.ep.states[s_expr[3]]);var iocr=get_value(sim.ep.states[s_expr[4]]);var iodr=get_value(sim.ep.states[s_expr[5]]);if(bus_ab==IOSR_ID)verbal="I/O device read at IOSR of value "+iosr+". ";if(bus_ab==IOCR_ID)verbal="I/O device read at IOCR of value "+iocr+". ";if(bus_ab==IODR_ID)verbal="I/O device read at IODR of value "+iodr+". ";return verbal}};sim.ep.behaviors.IO_IOW={nparameters:7,types:["E","E","E","E","E","E"],operation:function(s_expr){var bus_ab=get_value(sim.ep.states[s_expr[1]]);var bus_db=get_value(sim.ep.states[s_expr[2]]);if(bus_ab!=IOSR_ID&&bus_ab!=IOCR_ID&&bus_ab!=IODR_ID){return}if(bus_ab==IOSR_ID)set_value(sim.ep.states[s_expr[3]],bus_db);if(bus_ab==IOCR_ID)set_value(sim.ep.states[s_expr[4]],bus_db);if(bus_ab==IODR_ID)set_value(sim.ep.states[s_expr[5]],bus_db);var iocr_id=get_value(sim.ep.states[s_expr[4]]);var iodr_id=get_value(sim.ep.states[s_expr[5]]);if(iocr_id<0||iocr_id>7)return;set_var(sim.ep.internal_states.io_int_factory[iocr_id].period,iodr_id);set_var(sim.ep.internal_states.io_int_factory[iocr_id].probability,1);if(0==iodr_id){set_var(sim.ep.internal_states.io_int_factory[iocr_id].probability,0)}},verbal:function(s_expr){var verbal="";var bus_ab=get_value(sim.ep.states[s_expr[1]]);var bus_db=get_value(sim.ep.states[s_expr[2]]);if(bus_ab==IOSR_ID)verbal="I/O device write at IOSR with value "+bus_db+". ";if(bus_ab==IOCR_ID)verbal="I/O device write at IOCR with value "+bus_db+". ";if(bus_ab==IODR_ID)verbal="I/O device write at IODR with value "+bus_db+". ";return verbal}};sim.ep.behaviors.IO_CHK_I={nparameters:4,types:["E","S","E"],operation:function(s_expr){var clk=get_value(sim.ep.states[s_expr[1]]);for(var i=sim.ep.internal_states.io_int_factory.length-1;i>=0;i--){if(get_var(sim.ep.internal_states.io_int_factory[i].period)==0)continue;if(get_var(sim.ep.internal_states.io_int_factory[i].active)==true){set_value(sim.ep.signals[s_expr[2]],1);set_value(sim.ep.states[s_expr[3]],i)}if(clk%get_var(sim.ep.internal_states.io_int_factory[i].period)==0){if(Math.random()>get_var(sim.ep.internal_states.io_int_factory[i].probability))continue;var acc=get_var(sim.ep.internal_states.io_int_factory[i].accumulated);set_var(sim.ep.internal_states.io_int_factory[i].accumulated,acc+1);set_var(sim.ep.internal_states.io_int_factory[i].active,true);if(typeof sim.ep.events.io[clk]=="undefined"){sim.ep.events.io[clk]=[]}sim.ep.events.io[clk].push(i);set_value(sim.ep.signals[s_expr[2]],1);set_value(sim.ep.states[s_expr[3]],i)}}},verbal:function(s_expr){return"Check I/O Interruption. "}};sim.ep.behaviors.INTA={nparameters:6,types:["E","S","S","E","E"],operation:function(s_expr){var clk=get_value(sim.ep.states[s_expr[1]]);if(typeof sim.ep.events.io[clk]!="undefined"){set_value(sim.ep.states[s_expr[4]],sim.ep.events.io[clk][0]);return}set_value(sim.ep.signals[s_expr[2]],0);set_value(sim.ep.states[s_expr[5]],0);for(var i=0;i>>0;set_value(simhw_sim_state("BUS_AB"),elto);set_value(simhw_sim_signal("IOR"),1);compute_behavior("FIRE IOR");value=get_value(simhw_sim_state("BUS_DB"));return value},set_value:function(elto,value){var associated_state=simhw_internalState_get("io_hash",elto);set_value(simhw_sim_state(associated_state),value);set_value(simhw_sim_state("BUS_AB"),elto);set_value(simhw_sim_state("BUS_DB"),value);set_value(simhw_sim_signal("IOW"),1);compute_behavior("FIRE IOW");return value}};sim.ep.internal_states.l3d_dim=4;sim.ep.internal_states.l3d_neltos=Math.pow(sim.ep.internal_states.l3d_dim,3);sim.ep.internal_states.l3d_state=Array.from({length:sim.ep.internal_states.l3d_neltos},(()=>({active:false})));sim.ep.internal_states.l3d_frame="0".repeat(sim.ep.internal_states.l3d_neltos);var L3DSR_ID=8448;var L3DCR_ID=8452;var L3DDR_ID=8456;sim.ep.internal_states.io_hash[L3DSR_ID]="L3DSR";sim.ep.internal_states.io_hash[L3DCR_ID]="L3DCR";sim.ep.internal_states.io_hash[L3DDR_ID]="L3DDR";sim.ep.states.L3DSR={name:"L3DSR",verbal:"L3D State Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.L3DCR={name:"L3DCR",verbal:"L3D Control Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.L3DDR={name:"L3DDR",verbal:"L3D Data Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.signals.L3D_IOR={name:"L3D_IOR",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","L3D_IOR BUS_AB BUS_DB L3DSR L3DCR L3DDR CLK; FIRE SBWA"],fire_name:["svg_p:tspan4173"],draw_data:[[],["svg_p:path3795","svg_p:path3733"]],draw_name:[[],[]]};sim.ep.signals.L3D_IOW={name:"L3D_IOW",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","L3D_IOW BUS_AB BUS_DB L3DSR L3DCR L3DDR CLK; FIRE SBWA; L3D_SYNC"],fire_name:["svg_p:text3785-0-6-0-5-5"],draw_data:[[],["svg_p:path3805","svg_p:path3733"]],draw_name:[[],[]]};sim.ep.behaviors.L3D_IOR={nparameters:7,types:["E","E","E","E","E","E"],operation:function(s_expr){var bus_ab=get_value(sim.ep.states[s_expr[1]]);var iosr=get_value(sim.ep.states[s_expr[3]]);var iocr=get_value(sim.ep.states[s_expr[4]]);var iodr=get_value(sim.ep.states[s_expr[5]]);if(bus_ab==L3DCR_ID){set_value(sim.ep.states[s_expr[2]],iocr)}if(bus_ab==L3DDR_ID){set_value(sim.ep.states[s_expr[2]],iodr)}if(bus_ab==L3DSR_ID){var x=(iodr&4278190080)>>24;var y=(iodr&16711680)>>16;var z=(iodr&65280)>>8;var p=z*Math.pow(sim.ep.internal_states.l3d_dim,2)+y*sim.ep.internal_states.l3d_dim+x;var s=get_var(sim.ep.internal_states.l3d_state[p].active);set_value(sim.ep.states[s_expr[2]],s)}},verbal:function(s_expr){var verbal="";var bus_ab=get_value(sim.ep.states[s_expr[1]]);var iosr=get_value(sim.ep.states[s_expr[3]]);var iocr=get_value(sim.ep.states[s_expr[4]]);var iodr=get_value(sim.ep.states[s_expr[5]]);if(bus_ab==L3DSR_ID)verbal="I/O device read at L3DSR of value "+iosr+". ";if(bus_ab==L3DCR_ID)verbal="I/O device read at L3DCR of value "+iocr+". ";if(bus_ab==L3DDR_ID)verbal="I/O device read at L3DDR of value "+iodr+". ";return verbal}};sim.ep.behaviors.L3D_IOW={nparameters:7,types:["E","E","E","E","E","E"],operation:function(s_expr){var bus_ab=get_value(sim.ep.states[s_expr[1]]);var bus_db=get_value(sim.ep.states[s_expr[2]]);if(bus_ab!=L3DSR_ID&&bus_ab!=L3DCR_ID&&bus_ab!=L3DDR_ID){return}if(bus_ab==L3DSR_ID){set_value(sim.ep.states[s_expr[3]],bus_db)}if(bus_ab==L3DDR_ID){set_value(sim.ep.states[s_expr[5]],bus_db)}if(bus_ab==L3DCR_ID){set_value(sim.ep.states[s_expr[4]],bus_db);var x=(bus_db&4278190080)>>24;var y=(bus_db&16711680)>>16;var z=(bus_db&65280)>>8;var p=z*Math.pow(sim.ep.internal_states.l3d_dim,2)+y*sim.ep.internal_states.l3d_dim+x;var s=(bus_db&255)!=0;set_var(sim.ep.internal_states.l3d_state[p].active,s)}},verbal:function(s_expr){var verbal="";var bus_ab=get_value(sim.ep.states[s_expr[1]]);var bus_db=get_value(sim.ep.states[s_expr[2]]);if(bus_ab==L3DSR_ID)verbal="I/O device write at L3DSR with value "+bus_db+". ";if(bus_ab==L3DCR_ID)verbal="I/O device write at L3DCR with value "+bus_db+". ";if(bus_ab==L3DDR_ID)verbal="I/O device write at L3DDR with value "+bus_db+". ";return verbal}};sim.ep.behaviors.L3D_RESET={nparameters:1,operation:function(s_expr){sim.ep.events.l3d={};var n=sim.ep.internal_states.l3d_state.length;for(var i=0;i>>0;set_value(simhw_sim_state("BUS_AB"),elto);set_value(simhw_sim_signal("IOR"),1);compute_behavior("FIRE IOR");value=get_value(simhw_sim_state("BUS_DB"));return value},set_value:function(elto,value){var associated_state=simhw_internalState_get("io_hash",elto);set_value(simhw_sim_state(associated_state),value);set_value(simhw_sim_state("BUS_AB"),elto);set_value(simhw_sim_state("BUS_DB"),value);set_value(simhw_sim_signal("IOW"),1);compute_behavior("FIRE IOW");return value}};sim.ep.internal_states.ledm_dim=24;sim.ep.internal_states.ledm_neltos=Math.pow(sim.ep.internal_states.ledm_dim,2);sim.ep.internal_states.ledm_state=Array.from({length:sim.ep.internal_states.ledm_neltos},(()=>({color:0})));sim.ep.internal_states.ledm_colors=colors_clone("");sim.ep.internal_states.ledm_frame="0".repeat(sim.ep.internal_states.ledm_neltos);var LEDMSR_ID=12544;var LEDMCR_ID=12548;var LEDMDR_ID=12552;sim.ep.internal_states.io_hash[LEDMSR_ID]="LEDMSR";sim.ep.internal_states.io_hash[LEDMCR_ID]="LEDMCR";sim.ep.internal_states.io_hash[LEDMDR_ID]="LEDMDR";sim.ep.states.LEDMSR={name:"LEDMSR",verbal:"LEDM State Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.LEDMCR={name:"LEDMCR",verbal:"LEDM Control Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.states.LEDMDR={name:"LEDMDR",verbal:"LEDM Data Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.ep.signals.LEDM_IOR={name:"LEDM_IOR",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","LEDM_IOR BUS_AB BUS_DB LEDMSR LEDMCR LEDMDR CLK; FIRE SBWA"],fire_name:["svg_p:tspan4173"],draw_data:[[],["svg_p:path3795","svg_p:path3733"]],draw_name:[[],[]]};sim.ep.signals.LEDM_IOW={name:"LEDM_IOW",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","LEDM_IOW BUS_AB BUS_DB LEDMSR LEDMCR LEDMDR CLK; FIRE SBWA; LEDM_SYNC"],fire_name:["svg_p:text3785-0-6-0-5-5"],draw_data:[[],["svg_p:path3805","svg_p:path3733"]],draw_name:[[],[]]};sim.ep.behaviors.LEDM_IOR={nparameters:7,types:["E","E","E","E","E","E"],operation:function(s_expr){var bus_ab=get_value(sim.ep.states[s_expr[1]]);var iosr=get_value(sim.ep.states[s_expr[3]]);var iocr=get_value(sim.ep.states[s_expr[4]]);var iodr=get_value(sim.ep.states[s_expr[5]]);if(bus_ab==LEDMCR_ID){set_value(sim.ep.states[s_expr[2]],iocr)}if(bus_ab==LEDMDR_ID){set_value(sim.ep.states[s_expr[2]],iodr)}if(bus_ab==LEDMSR_ID){var x=(iodr&4278190080)>>24;var y=(iodr&16711680)>>16;var p=y*sim.ep.internal_states.ledm_dim+x;var s=get_var(sim.ep.internal_states.ledm_state[p].color);set_value(sim.ep.states[s_expr[2]],s)}},verbal:function(s_expr){var verbal="";var bus_ab=get_value(sim.ep.states[s_expr[1]]);var iosr=get_value(sim.ep.states[s_expr[3]]);var iocr=get_value(sim.ep.states[s_expr[4]]);var iodr=get_value(sim.ep.states[s_expr[5]]);if(bus_ab==LEDMSR_ID)verbal="I/O device read at LEDMSR of value "+iosr+". ";if(bus_ab==LEDMCR_ID)verbal="I/O device read at LEDMCR of value "+iocr+". ";if(bus_ab==LEDMDR_ID)verbal="I/O device read at LEDMDR of value "+iodr+". ";return verbal}};sim.ep.behaviors.LEDM_IOW={nparameters:7,types:["E","E","E","E","E","E"],operation:function(s_expr){var bus_ab=get_value(sim.ep.states[s_expr[1]]);var bus_db=get_value(sim.ep.states[s_expr[2]]);switch(bus_ab){case LEDMSR_ID:set_value(sim.ep.states[s_expr[3]],bus_db);break;case LEDMDR_ID:set_value(sim.ep.states[s_expr[5]],bus_db);break;case LEDMCR_ID:set_value(sim.ep.states[s_expr[4]],bus_db);break;default:break}if(LEDMCR_ID==bus_ab){var dr=get_value(sim.ep.states[s_expr[5]]);if(16&bus_db){var x=(dr&4278190080)>>24;var y=(dr&16711680)>>16;var s=dr&255;set_value(sim.ep.states[s_expr[3]],1);if(x>=sim.ep.internal_states.ledm_dim&&y>=sim.ep.internal_states.ledm_dim){set_value(sim.ep.states[s_expr[3]],-1);return}var p=y*sim.ep.internal_states.ledm_dim+x;set_var(sim.ep.internal_states.ledm_state[p].color,s)}if(32&bus_db){set_value(sim.ep.states[s_expr[3]],1);var s=0;var neltos=sim.ep.internal_states.ledm_neltos;for(var p=0;p>0);set_var(sim.ep.internal_states.ledm_state[p+1].color,(s&65280)>>8);set_var(sim.ep.internal_states.ledm_state[p+2].color,(s&16711680)>>16);set_var(sim.ep.internal_states.ledm_state[p+3].color,(s&4278190080)>>24)}}if(64&bus_db){set_value(sim.ep.states[s_expr[3]],1);var s=0;var c="";var neltos=sim.ep.internal_states.ledm_colors.length;for(var p=0;p>>8;s=s.toString(16);c="#"+simcoreui_pack(s,6);sim.ep.internal_states.ledm_colors[p]=c}neltos=sim.ep.internal_states.ledm_neltos;for(var p=0;p>24;var y=(dr&16711680)>>16;var s=dr&255;verbal="I/O device write at LEDMCR with value "+bus_db+" (set pixel x:"+x+", y:"+y+", with color:"+s+"). "}if(64&bus_db){verbal="I/O device write at LEDMCR with value "+bus_db+" (set color palette at:"+bus_db+"). "}break;default:break}return verbal}};sim.ep.behaviors.LEDM_RESET={nparameters:1,operation:function(s_expr){sim.ep.events.ledm={};sim.ep.internal_states.ledm_colors=colors_clone("");for(var i=0;i>>0;if(value!=0){vec.CPU["R"+i]={type:"register",default_value:0,id:"R"+i,op:"=",value:"0x"+value.toString(16)}}}for(var i=0;i>>0;if(value!=0){vec.CPU[internal_reg[i]]={type:"register",default_value:0,id:internal_reg[i],op:"=",value:"0x"+value.toString(16)}}}return vec},read_state:function(vec,check){if(typeof vec.CPU=="undefined")vec.CPU={};var key=check["id"].toUpperCase().trim();var val=parseInt(check["value"]).toString(16);if("REGISTER"==check["type"].toUpperCase().trim()){vec.CPU[key]={type:"register",default_value:0,id:key,op:check["condition"],value:"0x"+val};return true}return false},get_state:function(reg){var r_reg=reg.toUpperCase().trim();if(typeof sim.poc.states["REG_"+r_reg]!="undefined"){var value=get_value(sim.poc.states["REG_"+r_reg])>>>0;return"0x"+value.toString(16)}r_reg=r_reg.replace("R","");var index=parseInt(r_reg);if(typeof sim.poc.states.BR[index]!="undefined"){var value=get_value(sim.poc.states.BR[index])>>>0;return"0x"+value.toString(16)}return null},get_value:function(elto){if(Number.isInteger(elto))index=elto;else index=parseInt(elto);if(isNaN(index))return get_value(simhw_sim_state(elto))>>>0;return get_value(simhw_sim_states().BR[index])>>>0},set_value:function(elto,value){var pc_name=simhw_sim_ctrlStates_get().pc.state;if(Number.isInteger(elto))index=elto;else index=parseInt(elto);if(isNaN(index)){set_value(simhw_sim_state(elto),value);if(pc_name===elto){show_asmdbg_pc()}return value}return set_value(simhw_sim_states().BR[index],value)}};sim.poc.ctrl_states.pc={name:"PC",state:"REG_PC",is_pointer:true};sim.poc.ctrl_states.sp={name:"SP",state:"BR.29",is_pointer:true};sim.poc.ctrl_states.fp={name:"FP",state:"BR.30",is_pointer:true};sim.poc.ctrl_states.ir={name:"IR",state:"REG_IR",default_eltos:{co:{begin:0,end:5,length:6},cop:{begin:27,end:31,length:5},oc:{begin:0,end:6,length:7}},is_pointer:false};sim.poc.ctrl_states.mpc={name:"mPC",state:"REG_MICROADDR",is_pointer:false};sim.poc.internal_states.MC={};sim.poc.internal_states.ROM={};sim.poc.internal_states.FIRMWARE=ws_empty_firmware;sim.poc.internal_states.io_hash={};sim.poc.internal_states.fire_stack=[];sim.poc.internal_states.tri_state_names=["T1","T2","T3","T6","T8","T9","T10","T11","T12"];sim.poc.internal_states.fire_visible={databus:false,internalbus:false};sim.poc.internal_states.filter_states=["REG_IR_DECO,col-12","REG_IR,col-auto","REG_PC,col-auto","REG_SR,col-auto","REG_RT1,col-auto","REG_MAR,col-auto","REG_MBR,col-auto","REG_MICROADDR,col-auto"];sim.poc.internal_states.filter_signals=["A0,0","B,0","C,0","SELA,5","SELB,5","SELC,2","SELCOP,0","MRA,0","MRB,0","MRC,0","MC,0","C0,0","C1,0","C2,0","C3,0","C4,0","C7,0","T1,0","T2,0","T3,0","T6,0","T8,0","T9,0","T10,0","T11,0","M1,0","M7,0","MA,0","MB,0","LC,0","SE,0","SIZE,0","OFFSET,0","BW,0","R,0","W,0","TA,0","TD,0","IOR,0","IOW,0","TEST_I,0","TEST_U,0"];sim.poc.internal_states.alu_flags={flag_n:0,flag_z:0,flag_v:0,flag_c:0};sim.poc.states.BR=[];sim.poc.states.BR[0]={name:"R0",verbal:"Register 0",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[1]={name:"R1",verbal:"Register 1",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[2]={name:"R2",verbal:"Register 2",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[3]={name:"R3",verbal:"Register 3",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[4]={name:"R4",verbal:"Register 4",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[5]={name:"R5",verbal:"Register 5",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[6]={name:"R6",verbal:"Register 6",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[7]={name:"R7",verbal:"Register 7",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[8]={name:"R8",verbal:"Register 8",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[9]={name:"R9",verbal:"Register 9",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[10]={name:"R10",verbal:"Register 10",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[11]={name:"R11",verbal:"Register 11",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[12]={name:"R12",verbal:"Register 12",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[13]={name:"R13",verbal:"Register 13",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[14]={name:"R14",verbal:"Register 14",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[15]={name:"R15",verbal:"Register 15",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[16]={name:"R16",verbal:"Register 16",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[17]={name:"R17",verbal:"Register 17",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[18]={name:"R18",verbal:"Register 18",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[19]={name:"R19",verbal:"Register 19",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[20]={name:"R20",verbal:"Register 20",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[21]={name:"R21",verbal:"Register 21",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[22]={name:"R22",verbal:"Register 22",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[23]={name:"R23",verbal:"Register 23",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[24]={name:"R24",verbal:"Register 24",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[25]={name:"R25",verbal:"Register 25",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[26]={name:"R26",verbal:"Register 26",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[27]={name:"R27",verbal:"Register 27",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[28]={name:"R28",verbal:"Register 28",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[29]={name:"R29",verbal:"Register 29",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[30]={name:"R30",verbal:"Register 30",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[31]={name:"R31",verbal:"Register 31",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[32]={name:"R32",verbal:"Register 32",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[33]={name:"R33",verbal:"Register 33",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[34]={name:"R34",verbal:"Register 34",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[35]={name:"R35",verbal:"Register 35",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[36]={name:"R36",verbal:"Register 36",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[37]={name:"R37",verbal:"Register 37",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[38]={name:"R38",verbal:"Register 38",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[39]={name:"R39",verbal:"Register 39",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[40]={name:"R40",verbal:"Register 40",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[41]={name:"R41",verbal:"Register 41",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[42]={name:"R42",verbal:"Register 42",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[43]={name:"R43",verbal:"Register 43",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[44]={name:"R44",verbal:"Register 44",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[45]={name:"R45",verbal:"Register 45",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[46]={name:"R46",verbal:"Register 46",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[47]={name:"R47",verbal:"Register 47",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[48]={name:"R48",verbal:"Register 48",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[49]={name:"R49",verbal:"Register 49",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[50]={name:"R50",verbal:"Register 50",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[51]={name:"R51",verbal:"Register 51",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[52]={name:"R52",verbal:"Register 52",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[53]={name:"R53",verbal:"Register 53",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[54]={name:"R54",verbal:"Register 54",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[55]={name:"R55",verbal:"Register 55",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[56]={name:"R56",verbal:"Register 56",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[57]={name:"R57",verbal:"Register 57",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[58]={name:"R58",verbal:"Register 58",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[59]={name:"R59",verbal:"Register 59",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[60]={name:"R60",verbal:"Register 60",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[61]={name:"R61",verbal:"Register 61",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[62]={name:"R62",verbal:"Register 62",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.BR[63]={name:"R63",verbal:"Register 63",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["REG_PC"]={name:"PC",verbal:"Program Counter Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["REG_MAR"]={name:"MAR",verbal:"Memory Address Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["REG_MBR"]={name:"MBR",verbal:"Memory Data Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["REG_IR"]={name:"IR",verbal:"Instruction Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["REG_SR"]={name:"SR",verbal:"State Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["REG_RT1"]={name:"RT1",verbal:"Temporal Register 1",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["BUS_IB"]={name:"I_BUS",verbal:"Internal Bus",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["BUS_AB"]={name:"A_BUS",verbal:"Address Bus",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["BUS_CB"]={name:"C_BUS",verbal:"Control Bus",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["BUS_DB"]={name:"D_BUS",verbal:"Data Bus",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["RA_T9"]={name:"RA_T9",verbal:"Input of T9 Tristate",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["RB_T10"]={name:"RB_T10",verbal:"Input of T10 Tristate",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["HPC_T12"]={name:"HPC_T12",verbal:"Input of T12 Tristate",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["SELEC_T3"]={name:"SELEC_T3",verbal:"Input of T3 Tristate",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["ALU_T6"]={name:"ALU_T6",verbal:"Input of T6 Tristate",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["MA_ALU"]={name:"MA_ALU",verbal:"Input ALU via MA",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["MB_ALU"]={name:"MB_ALU",verbal:"Input ALU via MB",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["FLAG_C"]={name:"FLAG_C",verbal:"Carry Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.poc.states["FLAG_V"]={name:"FLAG_V",verbal:"Overflow Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.poc.states["FLAG_N"]={name:"FLAG_N",verbal:"Negative Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.poc.states["FLAG_Z"]={name:"FLAG_Z",verbal:"Zero Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.poc.states["FLAG_I"]={name:"FLAG_I",verbal:"Interruption Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.poc.states["FLAG_U"]={name:"FLAG_U",verbal:"User Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.poc.states["REG_MICROADDR"]={name:"µADDR",verbal:"Microaddress Register",visible:true,nbits:"12",value:0,default_value:0,draw_data:["svg_cu:text4667"]};sim.poc.states["REG_MICROINS"]={name:"µINS",verbal:"Microinstruction Register",visible:true,nbits:"77",value:{},default_value:{},draw_data:[]};sim.poc.states["FETCH"]={name:"FETCH",verbal:"Input Fetch",visible:false,nbits:"12",value:0,default_value:0,draw_data:[]};sim.poc.states["ROM_MUXA"]={name:"ROM_MUXA",verbal:"Input ROM",visible:false,nbits:"12",value:0,default_value:0,draw_data:[]};sim.poc.states["SUM_ONE"]={name:"SUM_ONE",verbal:"Input next microinstruction",visible:false,nbits:"12",value:1,default_value:1,draw_data:[]};sim.poc.states["MUXA_MICROADDR"]={name:"MUXA_MICROADDR",verbal:"Input microaddress",visible:false,nbits:"12",value:0,default_value:0,draw_data:[]};sim.poc.states["MUXC_MUXB"]={name:"MUXC_MUXB",verbal:"Output of MUX C",visible:false,nbits:"1",value:0,default_value:0,draw_data:[]};sim.poc.states["INEX"]={name:"INEX",verbal:"Illegal Instruction Exception",visible:false,nbits:"1",value:0,default_value:0,draw_data:[]};sim.poc.states["BS_M1"]={name:"BS_M1",verbal:"from Memory",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["BS_TD"]={name:"BS_TD",verbal:"Memory",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["INTV"]={name:"INTV",verbal:"Interruption Vector",visible:false,nbits:"8",value:0,default_value:0,draw_data:[]};sim.poc.states["M1_C1"]={name:"M1_C1",verbal:"Input of Memory Data Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["M7_C7"]={name:"M7_C7",verbal:"Input of State Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["VAL_ZERO"]={name:"VAL_ZERO",verbal:"Wired Zero",visible:false,nbits:"1",value:0,default_value:0,draw_data:[]};sim.poc.states["VAL_ONE"]={name:"VAL_ONE",verbal:"Wired One",visible:false,nbits:"32",value:1,default_value:1,draw_data:[]};sim.poc.states["VAL_FOUR"]={name:"VAL_FOUR",verbal:"Wired Four",visible:false,nbits:"32",value:4,default_value:4,draw_data:[]};sim.poc.states["REG_IR_DECO"]={name:"IR_DECO",verbal:"Instruction Decoded",visible:true,nbits:"0",value:0,default_value:0,draw_data:[]};sim.poc.states["DECO_INS"]={name:"DECO_INS",verbal:"Instruction decoded in binary",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["CLK"]={name:"CLK",verbal:"Clock",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["ACC_TIME"]={name:"ACC_TIME",verbal:"Accumulated CPU time",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["TTCPU"]={name:"TTCPU",verbal:"Several Tristates to the internal data bus in CPU activated",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states["ACC_PWR"]={name:"ACC_PWR",verbal:"Accumulated Energy Consumption",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.signals["C"]={name:"C",visible:true,type:"L",value:0,default_value:0,nbits:"4",behavior:["MV MUXC_MUXB VAL_ZERO; FIRE_IFCHANGED B MUXC_MUXB; RESET_CHANGED MUXC_MUXB","MBIT MUXC_MUXB INT 0 1; FIRE_IFCHANGED B MUXC_MUXB; RESET_CHANGED MUXC_MUXB","MBIT MUXC_MUXB IORDY 0 1; FIRE_IFCHANGED B MUXC_MUXB; RESET_CHANGED MUXC_MUXB","MBIT MUXC_MUXB MRDY 0 1; FIRE_IFCHANGED B MUXC_MUXB; RESET_CHANGED MUXC_MUXB","MBIT MUXC_MUXB REG_SR 0 1; FIRE_IFCHANGED B MUXC_MUXB; RESET_CHANGED MUXC_MUXB","MBIT MUXC_MUXB REG_SR 1 1; FIRE_IFCHANGED B MUXC_MUXB; RESET_CHANGED MUXC_MUXB","MBIT MUXC_MUXB REG_SR 28 1; FIRE_IFCHANGED B MUXC_MUXB; RESET_CHANGED MUXC_MUXB","MBIT MUXC_MUXB REG_SR 29 1; FIRE_IFCHANGED B MUXC_MUXB; RESET_CHANGED MUXC_MUXB","MBIT MUXC_MUXB REG_SR 30 1; FIRE_IFCHANGED B MUXC_MUXB; RESET_CHANGED MUXC_MUXB","MBIT MUXC_MUXB REG_SR 31 1; FIRE_IFCHANGED B MUXC_MUXB; RESET_CHANGED MUXC_MUXB","MV MUXC_MUXB INEX; FIRE_IFCHANGED B MUXC_MUXB; RESET_CHANGED MUXC_MUXB"],fire_name:["svg_cu:text3410"],draw_data:[["svg_cu:path3108"],["svg_cu:path3062"],["svg_cu:path3060"],["svg_cu:path3136"],["svg_cu:path3482"],["svg_cu:path3480"],["svg_cu:path3488"],["svg_cu:path3486"],["svg_cu:path3484"],["svg_cu:path3484-9"],["svg_cu:path3108-3","svg_cu:path3260-3-8-6","svg_cu:path3260-3-8","svg_cu:path3260-3"]],draw_name:[["svg_cu:path3496","svg_cu:path3414","svg_cu:path3194-08"]]};sim.poc.signals["B"]={name:"B",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV A1 MUXC_MUXB; FIRE A1","NOT_ES A1 MUXC_MUXB; FIRE A1"],depends_on:["CLK"],fire_name:["svg_cu:text3408"],draw_data:[["svg_cu:path3094-7","svg_cu:path3100-8-7","svg_cu:path3198-7","svg_cu:path3200-1"],["svg_cu:path3392","svg_cu:path3372","svg_cu:path3390","svg_cu:path3384","svg_cu:path3108-1","svg_cu:path3100-8-7","svg_cu:path3200-1","svg_cu:path3386"]],draw_name:[[],["svg_cu:path3194-0","svg_cu:path3138-8","svg_cu:path3498-6"]]};sim.poc.signals["A0"]={name:"A0",visible:false,type:"L",value:0,default_value:0,nbits:"1",behavior:["SBIT_SIGNAL A0A1 0 1; FIRE A0A1","SBIT_SIGNAL A0A1 1 1; FIRE A0A1"],depends_on:["CLK"],fire_name:["svg_cu:text3406"],draw_data:[["svg_cu:path3096"],["svg_cu:path3096"]],draw_name:[[],["svg_cu:path3138-8-1","svg_cu:path3098-2","svg_cu:path3124-2-5"]]};sim.poc.signals["A1"]={name:"A1",visible:false,type:"L",value:0,default_value:0,nbits:"1",behavior:["SBIT_SIGNAL A0A1 0 0; FIRE A0A1","SBIT_SIGNAL A0A1 1 0; FIRE A0A1"],depends_on:["CLK"],fire_name:[],draw_data:[["svg_cu:path3094"],["svg_cu:path3094"]],draw_name:[[]]};sim.poc.signals["A0A1"]={name:"A0A1",visible:true,type:"L",value:0,default_value:0,nbits:"2",behavior:["PLUS1 MUXA_MICROADDR REG_MICROADDR","CP_FIELD MUXA_MICROADDR REG_MICROINS/MADDR","MV MUXA_MICROADDR ROM_MUXA","MV MUXA_MICROADDR FETCH"],depends_on:["CLK"],fire_name:[],draw_data:[["svg_cu:path3102","svg_cu:path3100","svg_cu:path3098","svg_cu:path3100-9","svg_cu:path3088","svg_cu:path3082"],["svg_cu:path3104","svg_cu:path3134","svg_cu:path3500","svg_cu:path3416","svg_cu:path3124-2-4","svg_cu:path3124-2"],["svg_cu:path3504","svg_cu:path3100-8","svg_cu:path3234-9"],["svg_cu:path3124"]],draw_name:[[]]};sim.poc.signals["C0"]={name:"C0",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","MV REG_MAR BUS_IB"],fire_name:["svg_p:text3077"],draw_data:[["svg_p:path3081"]],draw_name:[["svg_p:path3075"]]};sim.poc.signals["C1"]={name:"C1",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","MV REG_MBR M1_C1"],fire_name:["svg_p:text3079"],draw_data:[["svg_p:path3055"]],draw_name:[["svg_p:path3073"]]};sim.poc.signals["C2"]={name:"C2",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","MV REG_PC BUS_IB; UPDATEDPC"],fire_name:["svg_p:text3179"],draw_data:[["svg_p:path3217"]],draw_name:[["svg_p:path3177"]]};sim.poc.signals["C3"]={name:"C3",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","MV REG_IR BUS_IB; DECO; FIRE_IFSET C 10"],fire_name:["svg_p:text3439"],draw_data:[["svg_p:path3339","svg_p:path3913-4","svg_p:path3659-1"]],draw_name:[["svg_p:path3337"]]};sim.poc.signals["C4"]={name:"C4",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","MV REG_RT1 BUS_IB"],fire_name:["svg_p:tspan482"],draw_data:[["svg_p:path3339-4"]],draw_name:[["svg_p:path3337-0"]]};sim.poc.signals["C7"]={name:"C7",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","MV REG_SR M7_C7"],fire_name:["svg_p:text3655"],draw_data:[["svg_p:path3651-9"]],draw_name:[["svg_p:path3681"]]};sim.poc.signals["TA"]={name:"TA",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","MV BUS_AB REG_MAR"],fire_name:["svg_p:text3091"],draw_data:[["svg_p:path3083","svg_p:path3089","svg_p:path3597","svg_p:path3513","svg_p:path3601","svg_p:path3601-2","svg_p:path3187","svg_p:path3087","svg_p:path2995","svg_p:path3535"]],draw_name:[["svg_p:path3085"]]};sim.poc.signals["TD"]={name:"TD",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; CHECK_RTD","MV BUS_DB REG_MBR; FIRE R; FIRE W; CHECK_RTD"],fire_name:["svg_p:text3103"],draw_data:[["svg_p:path3093","svg_p:path3101","svg_p:path3587","svg_p:path3419-8","svg_p:path3071","svg_p:path3099","svg_p:path3097","svg_p:path3559-5","svg_p:path3419-1-0","svg_p:path3583","svg_p:path3419-1","svg_p:path3491","svg_p:path3641","svg_p:path3541"]],draw_name:[["svg_p:path3095"]]};sim.poc.signals["T1"]={name:"T1",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 0","MV BUS_IB REG_MBR; FIRE M7; FIRE M1; SET_TT TTCPU 0"],fire_name:["svg_p:text3105"],draw_data:[["svg_p:path3065","svg_p:path3071","svg_p:path3069","svg_p:path3049","svg_p:path3063-9","svg_p:path3071"]],draw_name:[["svg_p:path3067"]]};sim.poc.signals["T2"]={name:"T2",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 1","MV BUS_IB REG_PC; FIRE M7; FIRE M1; SET_TT TTCPU 1"],fire_name:["svg_p:text3449"],draw_data:[["svg_p:path3195","svg_p:path3199","svg_p:path3201","svg_p:path3049"]],draw_name:[["svg_p:path3329"]]};sim.poc.signals["T3"]={name:"T3",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 2","MV BUS_IB SELEC_T3; FIRE M7; FIRE M1; SET_TT TTCPU 2"],fire_name:["svg_p:text3451"],draw_data:[["svg_p:path3347","svg_p:path3349","svg_p:path3931","svg_p:path3345","svg_p:path3049","svg_p:path3341"]],draw_name:[["svg_p:path3351"]]};sim.poc.signals["T6"]={name:"T6",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 3","MV BUS_IB ALU_T6; FIRE M7; FIRE M1; SET_TT TTCPU 3"],fire_name:["svg_p:text3457"],draw_data:[["svg_p:path3315","svg_p:path3589","svg_p:path3317","svg_p:path3163-2","svg_p:path3049","svg_p:path3317-9","svg_p:path3321","svg_p:path3261-8"]],draw_name:[["svg_p:path3319"]]};sim.poc.signals["T8"]={name:"T8",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 4","MV BUS_IB REG_SR; FIRE M7; FIRE M1; SET_TT TTCPU 4"],fire_name:["svg_p:text3657"],draw_data:[["svg_p:path3645","svg_p:path3651","svg_p:path3647","svg_p:path3049"]],draw_name:[["svg_p:path3649"]]};sim.poc.signals["T9"]={name:"T9",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 5","MV BUS_IB RA_T9; FIRE M7; FIRE M1; SET_TT TTCPU 5"],fire_name:["svg_p:text3147"],draw_data:[["svg_p:path3131","svg_p:path3143","svg_p:path3139","svg_p:path3049","svg_p:path3143-9"]],draw_name:[["svg_p:path3133"]]};sim.poc.signals["T10"]={name:"T10",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 6","MV BUS_IB RB_T10; FIRE M7; FIRE M1; SET_TT TTCPU 6"],fire_name:["svg_p:text3149"],draw_data:[["svg_p:path3135","svg_p:path3145","svg_p:path3141","svg_p:path3049","svg_p:path3145-5"]],draw_name:[["svg_p:path3137"]]};sim.poc.signals["T11"]={name:"T11",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 7","CP_FIELD BUS_IB REG_MICROINS/EXCODE; FIRE M7; FIRE M1; SET_TT TTCPU 7"],fire_name:["svg_p:text3147-5","svg_cu:tspan4426"],draw_data:[["svg_p:path3131-3","svg_p:path3081-3","svg_p:path3139-7","svg_p:path3049","svg_cu:path3081-3","svg_cu:path3139-7","svg_cu:path3502"]],draw_name:[["svg_p:path3133-6","svg_cu:path3133-6"]]};sim.poc.signals["T12"]={name:"T12",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; RST_TT TTCPU 8","MV BUS_IB HPC_T12; FIRE M7; FIRE M1; SET_TT TTCPU 8"],fire_name:["svg_p:text3147-5-0-1-1"],draw_data:[["svg_p:path3131-3-8-4-31","svg_p:path3139-7-1-4-3","svg_cu:path3049","svg_p:path3081-3-8-5-3","svg_p:path3081-3-8-5-3-7"]],draw_name:[["svg_p:path3133-6-9-7-5"]]};sim.poc.signals["M1"]={name:"M1",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV M1_C1 BUS_IB","MV M1_C1 BUS_DB"],depends_on:["C1"],fire_name:["svg_p:text3469"],draw_data:[["svg_p:path3063","svg_p:path3061","svg_p:path3059"],["svg_p:path3057","svg_p:path3641","svg_p:path3419","svg_p:path3583","svg_p:path3491"]],draw_name:[[],["svg_p:path3447"]]};sim.poc.signals["M7"]={name:"M7",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV M7_C7 BUS_IB","MV M7_C7 REG_SR; UPDATE_FLAG M7_C7 FLAG_C 31; UPDATE_FLAG M7_C7 FLAG_V 30; UPDATE_FLAG M7_C7 FLAG_N 29; UPDATE_FLAG M7_C7 FLAG_Z 28"],depends_on:["C7"],fire_name:["svg_p:text3673"],draw_data:[["svg_p:path3691","svg_p:path3693","svg_p:path3659"],["svg_p:path3695","svg_p:path3331"]],draw_name:[[],["svg_p:path3667"]]};sim.poc.signals["MA"]={name:"MA",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV MA_ALU RA_T9; FIRE COP","MV MA_ALU BUS_IB; FIRE COP"],depends_on:["SELA","SELB"],fire_name:["svg_p:text3463"],draw_data:[["svg_p:path3249","svg_p:path3161","svg_p:path3165"],["svg_p:path3279"]],draw_name:[[],["svg_p:path3423"]]};sim.poc.signals["MB"]={name:"MB",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV MB_ALU RB_T10; FIRE COP","MV MB_ALU REG_PC; FIRE COP"],depends_on:["SELA","SELB"],fire_name:["svg_p:text3465"],draw_data:[["svg_p:path3281","svg_p:path3171","svg_p:path3169"],["svg_p:path3283"]],draw_name:[[],["svg_p:path3425","svg_p:path3427"]]};sim.poc.signals["MH"]={name:"MH",visible:true,type:"L",value:0,default_value:0,nbits:"2",behavior:["MV HPC_T12 CLK","MV HPC_T12 ACC_TIME","MV HPC_T12 ACC_PWR","NOP"],fire_name:["svg_p:text3147-5-0-1-8-4"],draw_data:[[],["svg_p:path3081-3-8-5-3"]],draw_name:[[],["svg_p:path3306-8-7-6"]]};sim.poc.signals["COP"]={name:"COP",visible:true,type:"L",value:0,default_value:0,nbits:"5",forbidden:true,behavior:["NOP_ALU; UPDATE_NZVC","AND ALU_T6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","OR ALU_T6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","NOT ALU_T6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","XOR ALU_T6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","SRL ALU_T6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","SRA ALU_T6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","SL ALU_T6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","RR ALU_T6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","RL ALU_T6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","ADD ALU_T6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","SUB ALU_T6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","MUL ALU_T6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","DIV ALU_T6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","MOD ALU_T6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","LUI ALU_T6 MA_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","ADDFOUR ALU_T6 MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","ADDONE ALU_T6 MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","SUBFOUR ALU_T6 MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","SUBONE ALU_T6 MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","FADD ALU_T6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","FSUB ALU_T6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","FMUL ALU_T6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","FDIV ALU_T6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","FMOD ALU_T6 MA_ALU MB_ALU; UPDATE_NZVC; FIRE_IFSET T6 1; FIRE_IFSET M7 1","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU"],depends_on:["SELCOP"],fire_name:["svg_p:text3303"],draw_data:[["svg_p:path3237","svg_p:path3239","svg_p:path3261-8","svg_p:path3321","svg_p:path3901-6","svg_p:path3317-9"]],draw_name:[["svg_p:path3009","svg_p:path3301"]]};sim.poc.signals["SELA"]={name:"SELA",visible:true,type:"L",value:0,default_value:0,nbits:"6",behavior:["FIRE_IFCHANGED MRA SELA; RESET_CHANGED SELA"],depends_on:["RA"],fire_name:["svg_cu:text3164"],draw_data:[[]],draw_name:[[]]};sim.poc.signals["SELB"]={name:"SELB",visible:true,type:"L",value:0,default_value:0,nbits:"6",behavior:["FIRE_IFCHANGED MRB SELB; RESET_CHANGED SELB"],depends_on:["RB"],fire_name:["svg_cu:text3168"],draw_data:[[]],draw_name:[[]]};sim.poc.signals["SELC"]={name:"SELC",visible:true,type:"L",value:0,default_value:0,nbits:"6",behavior:["FIRE_IFCHANGED MRC SELC; RESET_CHANGED SELC"],depends_on:["RC"],fire_name:["svg_cu:text3172"],draw_data:[[]],draw_name:[[]]};sim.poc.signals["SELCOP"]={name:"SELCOP",visible:true,type:"L",value:0,default_value:0,nbits:"5",behavior:["FIRE_IFCHANGED MC SELCOP; RESET_CHANGED SELCOP"],depends_on:["COP"],fire_name:["svg_cu:text3312"],draw_data:[[]],draw_name:[[]]};sim.poc.signals["EXCODE"]={name:"EXCODE",visible:true,type:"L",value:0,default_value:0,nbits:"4",behavior:["FIRE T11"],fire_name:["svg_cu:text3312-6"],draw_data:[[]],draw_name:[[]]};sim.poc.signals["RA"]={name:"RA",visible:true,type:"L",value:0,default_value:0,nbits:"6",forbidden:true,behavior:["GET RA_T9 BR RA; FIRE_IFSET T9 1; FIRE_IFSET MA 0"],depends_on:["SELA"],fire_name:["svg_p:text3107"],draw_data:[[]],draw_name:[["svg_p:path3109"]]};sim.poc.signals["RB"]={name:"RB",visible:true,type:"L",value:0,default_value:0,nbits:"6",forbidden:true,behavior:["GET RB_T10 BR RB; FIRE_IFSET T10 1; FIRE_IFSET MB 0"],depends_on:["SELB"],fire_name:["svg_p:text3123"],draw_data:[[]],draw_name:[["svg_p:path3113"]]};sim.poc.signals["RC"]={name:"RC",visible:true,type:"L",value:0,default_value:0,nbits:"6",forbidden:true,behavior:["FIRE LC"],depends_on:["SELC"],fire_name:["svg_p:text3125"],draw_data:[[]],draw_name:[["svg_p:path3117"]]};sim.poc.signals["LC"]={name:"LC",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","SET BR RC BUS_IB"],fire_name:["svg_p:text3127"],draw_data:[["svg_p:path3153","svg_p:path3151","svg_p:path3129"]],draw_name:[["svg_p:path3121"]]};sim.poc.signals["SE"]={name:"SE",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MBITS SELEC_T3 0 REG_RT1 OFFSET SIZE 0 SE; FIRE T3","MBITS SELEC_T3 0 REG_RT1 OFFSET SIZE 0 SE; FIRE T3"],depends_on:["T3"],fire_name:["svg_p:text3593"],draw_data:[[]],draw_name:[["svg_p:path3591","svg_p:path3447-7-7"]]};sim.poc.signals["SIZE"]={name:"SIZE",visible:true,type:"L",value:0,default_value:0,nbits:"5",behavior:["MBITS SELEC_T3 0 REG_RT1 OFFSET SIZE 0 SE; FIRE T3"],depends_on:["T3"],fire_name:["svg_p:text3363"],draw_data:[[]],draw_name:[["svg_p:path3355"]]};sim.poc.signals["OFFSET"]={name:"OFFSET",visible:true,type:"L",value:0,default_value:0,nbits:"5",behavior:["MBITS SELEC_T3 0 REG_RT1 OFFSET SIZE 0 SE; FIRE T3"],depends_on:["T3"],fire_name:["svg_p:text3707"],draw_data:[[]],draw_name:[["svg_p:path3359"]]};sim.poc.signals["MC"]={name:"MC",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MBIT COP REG_IR 0 5; FIRE_IFCHANGED COP MC","CP_FIELD COP REG_MICROINS/SELCOP; FIRE_IFCHANGED COP MC"],depends_on:["SELCOP"],fire_name:["svg_cu:text3322","svg_cu:text3172-1-5"],draw_data:[["svg_cu:path3320","svg_cu:path3142"],["svg_cu:path3318","svg_cu:path3502-6","svg_cu:path3232-6"]],draw_name:[[],["svg_cu:path3306"]]};sim.poc.signals["MRA"]={name:"MRA",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MBIT_SN RA REG_IR REG_MICROINS/SELA 5; FIRE RA;","CP_FIELD RA REG_MICROINS/SELA; FIRE RA;"],depends_on:["SELA"],fire_name:["svg_cu:text3222"],draw_data:[["svg_cu:path3494","svg_cu:path3492","svg_cu:path3490","svg_cu:path3142b","svg_cu:path3188","svg_cu:path3190","svg_cu:path3192","svg_cu:path3194","svg_cu:path3276","svg_cu:path3290","svg_cu:path3260","svg_cu:path3200","svg_cu:path3266","svg_cu:path3138","svg_cu:path3268","svg_cu:path3198","svg_cu:path3200"],["svg_cu:path3270","svg_cu:path3258","svg_cu:path3260","svg_cu:path3294","svg_cu:path3288","svg_cu:path3280","svg_cu:path3258","svg_cu:path3280","svg_cu:path3266","svg_cu:path3268"]],draw_name:[[],["svg_cu:path3220"]]};sim.poc.signals["MRB"]={name:"MRB",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MBIT_SN RB REG_IR REG_MICROINS/SELB 5; FIRE RB;","CP_FIELD RB REG_MICROINS/SELB; FIRE RB;"],depends_on:["SELB"],fire_name:["svg_cu:text3242"],draw_data:[["svg_cu:path3196","svg_cu:path3278","svg_cu:path3292","svg_cu:path3138-1","svg_cu:path3204","svg_cu:path3204","svg_cu:path3264"],["svg_cu:path3282","svg_cu:path3258-4","svg_cu:path3278","svg_cu:path3196","svg_cu:path3258-4","svg_cu:path3204","svg_cu:path3264"]],draw_name:[[],["svg_cu:path3240"]]};sim.poc.signals["MRC"]={name:"MRC",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MBIT_SN RC REG_IR REG_MICROINS/SELC 5; FIRE RC;","CP_FIELD RC REG_MICROINS/SELC; FIRE RC;"],depends_on:["SELC"],fire_name:["svg_cu:text3254"],draw_data:[["svg_cu:path3494","svg_cu:path3492","svg_cu:path3490","svg_cu:path3142b","svg_cu:path3188","svg_cu:path3190","svg_cu:path3192","svg_cu:path3194","svg_cu:path3276","svg_cu:path3290","svg_cu:path3232","svg_cu:path3292","svg_cu:path3138-1-5","svg_cu:path3208","svg_cu:path3316"],["svg_cu:path3300","svg_cu:path3294","svg_cu:path3292","svg_cu:path3288","svg_cu:path3232"]],draw_name:[[],["svg_cu:path3252"]]};sim.poc.signals["IOR"]={name:"IOR",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","MOVE_BITS SCR_IOR 0 1 IOR; FIRE SCR_IOR; MOVE_BITS IO_IOR 0 1 IOR; FIRE IO_IOR; MOVE_BITS L3D_IOR 0 1 IOR; FIRE L3D_IOR; MOVE_BITS KBD_IOR 0 1 IOR; FIRE KBD_IOR; MOVE_BITS LEDM_IOR 0 1 IOR; FIRE LEDM_IOR"],fire_name:[],draw_data:[[],["svg_p:path3733","svg_p:path3491","svg_p:text3715"]],draw_name:[[],[]]};sim.poc.signals["IOW"]={name:"IOW",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","MOVE_BITS SCR_IOW 0 1 IOW; FIRE SCR_IOW; MOVE_BITS IO_IOW 0 1 IOW; FIRE IO_IOW; MOVE_BITS L3D_IOW 0 1 IOW; FIRE L3D_IOW; MOVE_BITS LEDM_IOW 0 1 IOW; FIRE LEDM_IOW"],fire_name:[],draw_data:[[],["svg_p:path3735","svg_p:path3491","svg_p:text3717"]],draw_name:[[],[]]};sim.poc.signals["TEST_C"]={name:"TEST_C",visible:true,type:"L",value:0,default_value:0,nbits:"1",forbidden:true,behavior:["MV FLAG_C VAL_ZERO; FIRE M7","MV FLAG_C VAL_ONE; FIRE M7"],depends_on:["SELCOP"],fire_name:["svg_p:text3701-3"],draw_data:[["svg_p:text3701-3"]],draw_name:[[]]};sim.poc.signals["TEST_V"]={name:"TEST_V",visible:true,type:"L",value:0,default_value:0,nbits:"1",forbidden:true,behavior:["MV FLAG_V VAL_ZERO; FIRE M7","MV FLAG_V VAL_ONE; FIRE M7"],depends_on:["SELCOP"],fire_name:["svg_p:text3701-3-1"],draw_data:[["svg_p:text3701-3-1"]],draw_name:[[]]};sim.poc.signals["TEST_N"]={name:"TEST_N",visible:true,type:"L",value:0,default_value:0,nbits:"1",forbidden:true,behavior:["MV FLAG_N VAL_ZERO; FIRE M7","MV FLAG_N VAL_ONE; FIRE M7"],depends_on:["SELCOP"],fire_name:["svg_p:text3701-3-2"],draw_data:[["svg_p:text3701-3-2"]],draw_name:[[]]};sim.poc.signals["TEST_Z"]={name:"TEST_Z",visible:true,type:"L",value:0,default_value:0,nbits:"1",forbidden:true,behavior:["MV FLAG_Z VAL_ZERO; FIRE M7","MV FLAG_Z VAL_ONE; FIRE M7"],depends_on:["SELCOP"],fire_name:["svg_p:text3701-3-5"],draw_data:[["svg_p:text3701-3-5"]],draw_name:[[]]};sim.poc.signals["TEST_I"]={name:"TEST_I",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV FLAG_I VAL_ZERO; FIRE M7","MV FLAG_I VAL_ONE; FIRE M7"],depends_on:["CLK"],fire_name:["svg_cu:text3440"],draw_data:[["svg_cu:text3440"]],draw_name:[[]]};sim.poc.signals["TEST_U"]={name:"TEST_U",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV FLAG_U VAL_ZERO; FIRE M7","MV FLAG_U VAL_ONE; FIRE M7"],depends_on:["CLK"],fire_name:["svg_cu:text3442"],draw_data:[["svg_cu:text3442"]],draw_name:[[]]};sim.poc.signals["TEST_INTV"]={name:"TEST_INTV",visible:true,type:"L",value:0,default_value:0,nbits:"8",forbidden:true,behavior:["MBIT INTV TEST_INTV 0 32"],depends_on:["INT"],fire_name:["svg_p:tspan4225"],draw_data:[["svg_p:path3749"]],draw_name:[[]]};sim.poc.behaviors["NOP"]={nparameters:1,operation:function(s_expr){},verbal:function(s_expr){return""}};sim.poc.behaviors["NOP_ALU"]={nparameters:1,operation:function(s_expr){sim.poc.internal_states.alu_flags.flag_n=0;sim.poc.internal_states.alu_flags.flag_z=0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){return"Reset ALU flags. "}};sim.poc.behaviors["MV"]={nparameters:3,types:["X","X"],operation:function(s_expr){sim_elto_org=get_reference(s_expr[2]);sim_elto_dst=get_reference(s_expr[1]);newval=get_value(sim_elto_org);set_value(sim_elto_dst,newval)},verbal:function(s_expr){var sim_elto_org=get_reference(s_expr[2]);var newval=get_value(sim_elto_org);var verbose=get_cfg("verbal_verbose");if(verbose!=="short"){return"Copy from "+show_verbal(s_expr[2])+" to "+show_verbal(s_expr[1])+" value "+show_value(newval)+". "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" ("+show_value(newval)+"). "}};sim.poc.behaviors["LOAD"]={nparameters:3,types:["X","X"],operation:function(s_expr){sim_elto_org=get_reference(s_expr[2]);sim_elto_dst=get_reference(s_expr[1]);newval=get_value(sim_elto_org);set_value(sim_elto_dst,newval)},verbal:function(s_expr){var sim_elto_org=get_reference(s_expr[2]);var newval=get_value(sim_elto_org);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Load from "+show_verbal(s_expr[2])+" to "+show_verbal(s_expr[1])+" value "+show_value(newval)+". "}return show_verbal(s_expr[1])+" = "+show_value(newval)+" ( "+show_verbal(s_expr[2])+"). "}};sim.poc.behaviors["CP_FIELD"]={nparameters:3,types:["X","X"],operation:function(s_expr){r=s_expr[2].split("/");sim_elto_org=get_reference(r[0]);newval=get_value(sim_elto_org);newval=newval[r[1]];if(typeof newval!="undefined"){sim_elto_dst=get_reference(s_expr[1]);set_value(sim_elto_dst,newval)}},verbal:function(s_expr){var r=s_expr[2].split("/");var sim_elto_org=get_reference(r[0]);var newval=get_value(sim_elto_org);newval=newval[r[1]];if(typeof newval=="undefined")newval="<undefined>";else newval=show_value(newval);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return'Copy from "'+show_verbal(r[0])+'"['+r[1]+"] "+"to "+show_verbal(s_expr[1])+" (value "+newval+"). "}return show_verbal(s_expr[1])+" = "+show_verbal(r[0])+"."+r[1]+" ("+newval+"). "}};sim.poc.behaviors["NOT_ES"]={nparameters:3,types:["S","E"],operation:function(s_expr){set_value(sim.poc.signals[s_expr[1]],Math.abs(get_value(sim.poc.states[s_expr[2]])-1))},verbal:function(s_expr){var value=Math.abs(get_value(sim.poc.states[s_expr[2]])-1);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Set "+show_verbal(s_expr[1])+" with value "+show_value(value)+" (Logical NOT of "+s_expr[2]+"). "}return show_verbal(s_expr[1])+" = "+show_value(value)+" (Logical NOT "+s_expr[2]+"). "}};sim.poc.behaviors["GET"]={nparameters:4,types:["E","E","S"],operation:function(s_expr){set_value(sim.poc.states[s_expr[1]],get_value(sim.poc.states[s_expr[2]][sim.poc.signals[s_expr[3]].value]))},verbal:function(s_expr){var value=get_value(sim.poc.states[s_expr[2]][sim.poc.signals[s_expr[3]].value]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Set "+show_verbal(s_expr[1])+" with value "+show_value(value)+" (Register File "+s_expr[3]+"). "}return show_verbal(s_expr[1])+" = "+show_value(value)+" (Register File "+s_expr[3]+"). "}};sim.poc.behaviors["SET"]={nparameters:4,types:["E","S","E"],operation:function(s_expr){set_value(sim.poc.states[s_expr[1]][sim.poc.signals[s_expr[2]].value],get_value(sim.poc.states[s_expr[3]]))},verbal:function(s_expr){var value=get_value(sim.poc.states[s_expr[3]]);var o_ref=sim.poc.states[s_expr[1]][sim.poc.signals[s_expr[2]].value];var o_verbal=o_ref.name;if(typeof o_ref.verbal!="undefined")o_verbal=o_ref.verbal;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy to "+o_verbal+" the value "+show_value(value)+". "}return o_verbal+" = "+show_value(value)+". "}};sim.poc.behaviors["AND"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])&get_value(sim.poc.states[s_expr[3]]);set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])&get_value(sim.poc.states[s_expr[3]]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU AND with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (AND). "}};sim.poc.behaviors["OR"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])|get_value(sim.poc.states[s_expr[3]]);set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])|get_value(sim.poc.states[s_expr[3]]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU OR with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (OR). "}};sim.poc.behaviors["NOT"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=~get_value(sim.poc.states[s_expr[2]]);set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=~get_value(sim.poc.states[s_expr[2]]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU NOT with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (NOT). "}};sim.poc.behaviors["XOR"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])^get_value(sim.poc.states[s_expr[3]]);set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])^get_value(sim.poc.states[s_expr[3]]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU XOR with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (XOR). "}};sim.poc.behaviors["SRL"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])>>>1;set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])>>>1;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Shift Right Logical with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (SRL). "}};sim.poc.behaviors["SRA"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])>>1;set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])>>1;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Shift Right Arithmetic with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (SRA). "}};sim.poc.behaviors["SL"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])<<1;set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])<<1;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Shift Left with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (SL). "}};sim.poc.behaviors["RR"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])>>>1|(get_value(sim.poc.states[s_expr[2]])&1)<<31;set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])>>>1|(get_value(sim.poc.states[s_expr[2]])&1)<<31;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Right Rotation with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (RR). "}};sim.poc.behaviors["RL"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])<<1|(get_value(sim.poc.states[s_expr[2]])&2147483648)>>>31;set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])<<1|(get_value(sim.poc.states[s_expr[2]])&2147483648)>>>31;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Left Rotation with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (LR). "}};sim.poc.behaviors["ADD"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a+b;set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_c=a>>>31&&b>>>31;sim.poc.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.poc.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.poc.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a+b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU ADD with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (ADD). "}};sim.poc.behaviors["SUB"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a-b;set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_c=a>>>31&&b>>>31;sim.poc.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.poc.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.poc.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a-b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU SUB with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (SUB). "}};sim.poc.behaviors["MUL"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a*b;set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_c=0;sim.poc.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.poc.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.poc.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a*b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU MUL with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (MUL). "}};sim.poc.behaviors["DIV"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;if(0==b){set_value(sim.poc.states[s_expr[1]],0);sim.poc.internal_states.alu_flags.flag_n=0;sim.poc.internal_states.alu_flags.flag_z=1;sim.poc.internal_states.alu_flags.flag_v=1;sim.poc.internal_states.alu_flags.flag_c=0;return}var result=Math.floor(a/b);set_value(sim.poc.states[s_expr[1]],result);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;if(0==b){return"ALU DIV zero by zero (oops!). "}var result=Math.floor(a/b);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU DIV with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (DIV). "}};sim.poc.behaviors["MOD"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;if(0==b){set_value(sim.poc.states[s_expr[1]],0);sim.poc.internal_states.alu_flags.flag_n=0;sim.poc.internal_states.alu_flags.flag_z=1;sim.poc.internal_states.alu_flags.flag_v=1;sim.poc.internal_states.alu_flags.flag_c=0;return}var result=a%b;set_value(sim.poc.states[s_expr[1]],result);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;if(0==b){return"ALU MOD zero by zero (oops!). "}var result=a%b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU MOD with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (MOD). "}};sim.poc.behaviors["LUI"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])<<16;set_value(sim.poc.states[s_expr[1]],result);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])<<16;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Load Upper Immediate with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (LUI). "}};sim.poc.behaviors["ADDFOUR"]={nparameters:3,types:["E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=4;var result=a+b;set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_c=a>>>31&&b>>>31;sim.poc.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.poc.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.poc.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var result=a+4;return"ALU ADD 4 with result "+show_value(result)+". "}};sim.poc.behaviors["ADDONE"]={nparameters:3,types:["E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=1;var result=a+b;set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_c=a>>>31&&b>>>31;sim.poc.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.poc.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.poc.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var result=a+1;return"ALU ADD 1 with result "+show_value(result)+". "}};sim.poc.behaviors["SUBFOUR"]={nparameters:3,types:["E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=4;var result=a-b;set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_c=a>>>31&&b>>>31;sim.poc.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.poc.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.poc.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var result=a-4;return"ALU SUB 4 with result "+show_value(result)+". "}};sim.poc.behaviors["SUBONE"]={nparameters:3,types:["E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=1;var result=a-b;set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_c=a>>>31&&b>>>31;sim.poc.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.poc.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.poc.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var result=a-1;return"ALU SUB 1 with result "+show_value(result)+". "}};sim.poc.behaviors["FADD"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a.toFixed(2)+b.toFixed(2);set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_c=0;sim.poc.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.poc.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.poc.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a.toFixed(2)+b.toFixed(2);return"ALU Float ADD with result "+result+". "}};sim.poc.behaviors["FSUB"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a.toFixed(2)-b.toFixed(2);set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_c=0;sim.poc.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.poc.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.poc.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a.toFixed(2)-b.toFixed(2);return"ALU Float SUB with result "+result+". "}};sim.poc.behaviors["FMUL"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a.toFixed(2)*b.toFixed(2);set_value(sim.poc.states[s_expr[1]],result>>>0);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_c=0;sim.poc.internal_states.alu_flags.flag_v=0;if(result<0&&a>=0&&b>=0)sim.poc.internal_states.alu_flags.flag_v=1;if(result>=0&&a<0&&b<0)sim.poc.internal_states.alu_flags.flag_v=1},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a.toFixed(2)*b.toFixed(2);return"ALU Float MUL with result "+result+". "}};sim.poc.behaviors["FDIV"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;if(0==b){set_value(sim.poc.states[s_expr[1]],0);sim.poc.internal_states.alu_flags.flag_n=0;sim.poc.internal_states.alu_flags.flag_z=1;sim.poc.internal_states.alu_flags.flag_v=1;sim.poc.internal_states.alu_flags.flag_c=0;return}var result=Math.floor(a/b);set_value(sim.poc.states[s_expr[1]],result);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a.toFixed(2)/b.toFixed(2);return"ALU Float DIV with result "+result+". "}};sim.poc.behaviors["FMOD"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var result=(get_value(sim.poc.states[s_expr[2]])<<0)%(get_value(sim.poc.states[s_expr[3]])<<0);set_value(sim.poc.states[s_expr[1]],result);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var b=get_value(sim.poc.states[s_expr[3]])<<0;var result=a.toFixed(2)%b.toFixed(2);return"ALU Float MOD with result "+result+". "}};sim.poc.behaviors["LUI"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])<<16;set_value(sim.poc.states[s_expr[1]],result);sim.poc.internal_states.alu_flags.flag_n=result<0?1:0;sim.poc.internal_states.alu_flags.flag_z=result==0?1:0;sim.poc.internal_states.alu_flags.flag_v=0;sim.poc.internal_states.alu_flags.flag_c=0},verbal:function(s_expr){var result=get_value(sim.poc.states[s_expr[2]])<<16;return"ALU Load Upper Immediate with result "+show_value(result)+". "}};sim.poc.behaviors["PLUS1"]={nparameters:3,types:["E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var result=a+1;set_value(sim.poc.states[s_expr[1]],result>>>0)},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var result=a+1;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Add one to "+show_verbal(s_expr[2])+" and copy to "+show_verbal(s_expr[1])+" with result "+show_value(result)+". "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" + 1"+" ("+show_value(result)+"). "}};sim.poc.behaviors["PLUS4"]={nparameters:3,types:["E","E"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var result=a+4;set_value(sim.poc.states[s_expr[1]],result>>>0)},verbal:function(s_expr){var a=get_value(sim.poc.states[s_expr[2]])<<0;var result=a+4;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Add four to "+show_verbal(s_expr[2])+" and copy to "+show_verbal(s_expr[1])+" with result "+show_value(result)+". "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" + 4"+" ("+show_value(result)+"). "}};sim.poc.behaviors["SET_TT"]={nparameters:3,types:["E","I"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[1]])<<0;var b=parseInt(s_expr[2]);var m=Math.pow(2,b);var r=a|m;set_value(sim.poc.states[s_expr[1]],r);update_cpu_bus_fire(r,b)},verbal:function(s_expr){return""}};sim.poc.behaviors["RST_TT"]={nparameters:3,types:["E","I"],operation:function(s_expr){var a=get_value(sim.poc.states[s_expr[1]])<<0;var b=parseInt(s_expr[2]);var m=Math.pow(2,b);var r=a&~m;set_value(sim.poc.states[s_expr[1]],r);update_cpu_bus_fire(r,b)},verbal:function(s_expr){return""}};sim.poc.behaviors["CHECK_RTD"]={nparameters:1,operation:function(s_expr){var number_active_tri=parseInt(simhw_sim_signal("TD").value)+parseInt(simhw_sim_signal("R").value);update_system_bus_fire(number_active_tri)},verbal:function(s_expr){return""}};sim.poc.behaviors["MBIT"]={nparameters:5,types:["X","X","I","I"],operation:function(s_expr){var sim_elto_dst=get_reference(s_expr[1]);var sim_elto_org=get_reference(s_expr[2]);var offset=parseInt(s_expr[3]);var size=parseInt(s_expr[4]);var n1=get_value(sim_elto_org).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(offset+size-1),size);set_value(sim_elto_dst,parseInt(n2,2))},verbal:function(s_expr){var sim_elto_dst=get_reference(s_expr[1]);var sim_elto_org=get_reference(s_expr[2]);var offset=parseInt(s_expr[3]);var size=parseInt(s_expr[4]);var n1=get_value(sim_elto_org).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(offset+size-1),size);var n3=parseInt(n2,2);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from "+show_verbal(s_expr[2])+" to "+show_verbal(s_expr[1])+" value "+show_value(n3)+" (copied "+size+" bits from bit "+offset+"). "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" ("+show_value(n3)+", "+size+" bits from bit "+offset+"). "}};sim.poc.behaviors["MBIT_SN"]={nparameters:5,types:["S","E","E","I"],operation:function(s_expr){var base=0;var r=s_expr[3].split("/");if(1==r.length)base=get_value(sim.poc.states[s_expr[3]]);else if(typeof sim.poc.states[r[0]].value[r[1]]!="undefined")base=sim.poc.states[r[0]].value[r[1]];else if(typeof sim.poc.signals[r[1]].default_value!="undefined")base=sim.poc.signals[r[1]].default_value;else if(typeof sim.poc.states[r[1]].default_value!="undefined")base=sim.poc.states[r[1]].default_value;else ws_alert("WARN: undefined state/field pair -> "+r[0]+"/"+r[1]);var offset=parseInt(s_expr[4]);var n1=get_value(sim.poc.states[s_expr[2]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;var n3=n2.substr(31-(base+offset-1),offset);set_value(sim.poc.signals[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){var base=0;var r=s_expr[3].split("/");if(1==r.length)base=get_value(sim.poc.states[s_expr[3]]);else if(typeof sim.poc.states[r[0]].value[r[1]]!="undefined")base=sim.poc.states[r[0]].value[r[1]];else if(typeof sim.poc.signals[r[1]].default_value!="undefined")base=sim.poc.signals[r[1]].default_value;else if(typeof sim.poc.states[r[1]].default_value!="undefined")base=sim.poc.states[r[1]].default_value;else ws_alert("WARN: undefined state/field pair -> "+r[0]+"/"+r[1]);var offset=parseInt(s_expr[4]);var n1=get_value(sim.poc.states[s_expr[2]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;var n3=n2.substr(31-(base+offset-1),offset);var from_elto="";if(1==r.length)from_elto=show_verbal(s_expr[3]);else from_elto='"'+show_verbal(s_expr[2])+'"['+r[1]+"] ";var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from "+from_elto+"into "+show_verbal(s_expr[1])+" "+"value "+parseInt(n3,2)+". "}return show_verbal(s_expr[1])+" = "+from_elto+" ("+parseInt(n3,2)+"). "}};sim.poc.behaviors["SBIT_SIGNAL"]={nparameters:4,types:["X","I","I"],operation:function(s_expr){sim_elto_dst=get_reference(s_expr[1]);var new_value=sim_elto_dst.value;var mask=1<>>0)},verbal:function(s_expr){sim_elto_dst=get_reference(s_expr[1]);var new_value=sim_elto_dst.value;var mask=1<>>0)}};sim.poc.behaviors["UPDATE_FLAG"]={nparameters:4,types:["X","X","I"],operation:function(s_expr){sim_elto_org=get_reference(s_expr[2]);sim_elto_dst=get_reference(s_expr[1]);var new_value=sim_elto_dst.value&~(1<>>0)},verbal:function(s_expr){sim_elto_org=get_reference(s_expr[2]);sim_elto_dst=get_reference(s_expr[1]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Update "+show_verbal(s_expr[2])+" to value "+sim_elto_org.value+". "}return show_verbal(s_expr[1])+"."+show_verbal(s_expr[3])+" = "+sim_elto_org.value+". "}};sim.poc.behaviors["MBITS"]={nparameters:8,types:["E","I","E","S","S","I","S"],operation:function(s_expr){var offset=parseInt(sim.poc.signals[s_expr[4]].value);var size=parseInt(sim.poc.signals[s_expr[5]].value);var n1=get_value(sim.poc.states[s_expr[3]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(offset+size-1),size);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;if("1"==sim.poc.signals[s_expr[7]].value&&"1"==n2.substr(0,1)){n3="11111111111111111111111111111111".substring(0,32-n2.length)+n2}set_value(sim.poc.states[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){var offset=parseInt(sim.poc.signals[s_expr[4]].value);var size=parseInt(sim.poc.signals[s_expr[5]].value);var n1=get_value(sim.poc.states[s_expr[3]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(offset+size-1),size);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;if("1"==sim.poc.signals[s_expr[7]].value&&"1"==n2.substr(0,1)){n3="11111111111111111111111111111111".substring(0,32-n2.length)+n2}n1=parseInt(n3,2);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return" Copy from "+show_verbal(s_expr[3])+" to "+show_verbal(s_expr[1])+" value "+show_value(n1)+" (copied "+size+" bits from bit "+offset+"). "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[3])+" ("+show_value(n1)+", "+size+" bits from bit "+offset+"). "}};sim.poc.behaviors["BSEL"]={nparameters:6,types:["E","I","I","E","I"],operation:function(s_expr){var posd=parseInt(s_expr[2]);var poso=parseInt(s_expr[5]);var len=parseInt(s_expr[3]);var n1=get_value(sim.poc.states[s_expr[4]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(poso+len)+1,len);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var n4="00000000000000000000000000000000".substr(0,posd);n3=n3+n4;set_value(sim.poc.states[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){var posd=parseInt(s_expr[2]);var len=parseInt(s_expr[3]);var poso=parseInt(s_expr[5]);var n1=get_value(sim.poc.states[s_expr[4]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(poso+len)+1,len);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var n4="00000000000000000000000000000000".substr(0,posd);n3=n3+n4;var n5=parseInt(n3,2);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from "+show_verbal(s_expr[4])+" to "+show_verbal(s_expr[1])+" value "+show_value(n5)+" (copied "+len+" bits, from bit "+poso+" of "+s_expr[4]+" to bit "+posd+" of "+s_expr[1]+"). "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[4])+" ("+show_value(n5)+", "+len+" bits, from bit "+poso+" of "+s_expr[4]+" to bit "+posd+" of "+s_expr[1]+"). "}};sim.poc.behaviors["EXT_SIG"]={nparameters:3,types:["E","I"],operation:function(s_expr){var n1=get_value(sim.poc.states[s_expr[1]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;var n3=n2.substr(31-s_expr[2],31);var n4=n3;if("1"==n2[31-s_expr[2]]){n4="11111111111111111111111111111111".substring(0,32-n3.length)+n4}set_value(sim.poc.states[s_expr[1]],parseInt(n4,2))},verbal:function(s_expr){var n1=get_value(sim.poc.states[s_expr[1]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;var n3=n2.substr(31-s_expr[2],31);var n4=n3;if("1"==n2[31-s_expr[2]]){n4="11111111111111111111111111111111".substring(0,32-n3.length)+n4}var n5=parseInt(n4,2);return"Sign Extension with value "+show_value(n5)+". "}};sim.poc.behaviors["MOVE_BITS"]={nparameters:5,types:["S","I","I","S"],operation:function(s_expr){var posd=parseInt(s_expr[2]);var poso=0;var len=parseInt(s_expr[3]);var n1=sim.poc.signals[s_expr[4]].value.toString(2);n1="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n1=n1.substr(31-poso-len+1,len);var n2=sim.poc.signals[s_expr[1]].value.toString(2);n2="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var m1=n2.substr(0,32-(posd+len));var m2=n2.substr(31-posd+1,posd);var n3=m1+n1+m2;set_value(sim.poc.signals[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){return""}};sim.poc.behaviors["MOVE_BITSE"]={nparameters:6,types:["S","I","I","E","I"],operation:function(s_expr){var posd=parseInt(s_expr[2]);var poso=parseInt(s_expr[5]);var len=parseInt(s_expr[3]);var n1=get_value(sim.poc.states[s_expr[4]]).toString(2);n1="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n1=n1.substr(31-poso-len+1,len);var n2=sim.poc.signals[s_expr[1]].value.toString(2);n2="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var m1=n2.substr(0,32-(posd+len));var m2=n2.substr(31-posd+1,posd);var n3=m1+n1+m2;set_value(sim.poc.signals[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){return""}};sim.poc.behaviors["DECO"]={nparameters:1,operation:function(s_expr){sim.poc.states["INEX"].value=0;var oi=decode_instruction(sim.poc.internal_states.FIRMWARE,sim.poc.ctrl_states.ir,get_value(sim.poc.states["REG_IR"]));if(null==oi.oinstruction){ws_alert("ERROR: undefined instruction code in IR ("+"co:"+oi.op_code.toString(2)+", "+"cop:"+oi.cop_code.toString(2)+")");sim.poc.states["ROM_MUXA"].value=0;sim.poc.states["INEX"].value=1;return-1}var rom_addr=oi.op_code<<6;if(typeof oi.oinstruction.cop!="undefined"){rom_addr=rom_addr+oi.cop_code}if(typeof sim.poc.internal_states["ROM"][rom_addr]=="undefined"){ws_alert("ERROR: undefined rom address "+rom_addr+" in firmware");sim.poc.states["ROM_MUXA"].value=0;return-1}sim.poc.states["ROM_MUXA"].value=sim.poc.internal_states["ROM"][rom_addr];var val=get_value(sim.poc.states["DECO_INS"]);set_value(sim.poc.states["DECO_INS"],val+1);var pc=get_value(sim.poc.states["REG_PC"])-4;var decins=get_deco_from_pc(pc);set_value(sim.poc.states["REG_IR_DECO"],decins);show_dbg_ir(get_value(sim.poc.states["REG_IR_DECO"]))},verbal:function(s_expr){return"Decode instruction. "}};sim.poc.behaviors["FIRE"]={nparameters:2,types:["S"],operation:function(s_expr){if(sim.poc.internal_states.fire_stack.indexOf(s_expr[1])!=-1){return}sim.poc.internal_states.fire_stack.push(s_expr[1]);update_draw(sim.poc.signals[s_expr[1]],sim.poc.signals[s_expr[1]].value);if("L"==sim.poc.signals[s_expr[1]].type){update_state(s_expr[1])}sim.poc.internal_states.fire_stack.pop(s_expr[1])},verbal:function(s_expr){return""}};sim.poc.behaviors["FIRE_IFSET"]={nparameters:3,types:["S","I"],operation:function(s_expr){if(get_value(sim.poc.signals[s_expr[1]])!=parseInt(s_expr[2])){return}sim.poc.behaviors["FIRE"].operation(s_expr)},verbal:function(s_expr){return""}};sim.poc.behaviors["FIRE_IFCHANGED"]={nparameters:3,types:["S","X"],operation:function(s_expr){sim_elto=get_reference(s_expr[2]);if(sim_elto.changed==false)return;sim.poc.behaviors["FIRE"].operation(s_expr)},verbal:function(s_expr){return""}};sim.poc.behaviors["RESET_CHANGED"]={nparameters:2,types:["X"],operation:function(s_expr){sim_elto=get_reference(s_expr[1]);sim_elto.changed=false},verbal:function(s_expr){return""}};sim.poc.behaviors["CLOCK"]={nparameters:1,operation:function(s_expr){var new_maddr=null;var mcelto=null;var t0=performance.now();var val=get_value(sim.poc.states["CLK"]);set_value(sim.poc.states["CLK"],val+1);set_value(sim.poc.states["TTCPU"],0);new_maddr=get_value(sim.poc.states["REG_MICROADDR"]);mcelto=sim.poc.internal_states["MC"][new_maddr];if(typeof mcelto!=="undefined"&&false==mcelto.is_native){for(var i=0;i>>0},set_value:function(elto,value){var origin="";var r_value=main_memory_get_program_counter();if(r_value!=null){origin="PC=0x"+r_value.toString(16)}var melto={value:value>>>0,source_tracking:[origin],comments:null};var valref=main_memory_set(sim.poc.internal_states.MP,elto,melto);show_main_memory(sim.poc.internal_states.MP,elto,typeof valref==="undefined",true);return value}};sim.poc.internal_states.segments={};sim.poc.internal_states.MP={};sim.poc.internal_states.MP_wc=0;sim.poc.internal_states.CM_cfg=[];sim.poc.internal_states.CM=[];sim.poc.signals.MRDY={name:"MRDY",visible:true,type:"L",value:0,default_value:0,nbits:"1",depends_on:["CLK"],behavior:["FIRE_IFCHANGED MRDY C","FIRE_IFCHANGED MRDY C"],fire_name:["svg_p:tspan3916"],draw_data:[[],["svg_p:path3895","svg_p:path3541"]],draw_name:[[],[]]};sim.poc.signals.R={name:"R",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP; CHECK_RTD","MEM_READ BUS_AB BUS_DB BW MRDY CLK; FIRE M1; FIRE MRDY; CHECK_RTD"],fire_name:["svg_p:text3533-5-2"],draw_data:[[],["svg_p:path3557","svg_p:path3571"]],draw_name:[[],[]]};sim.poc.signals.W={name:"W",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","MEM_WRITE BUS_AB BUS_DB BW MRDY CLK; FIRE M1; FIRE MRDY"],fire_name:["svg_p:text3533-5-08"],draw_data:[[],["svg_p:path3559","svg_p:path3575","svg_p:path3447-7"]],draw_name:[[],[]]};sim.poc.signals.BW={name:"BW",verbal:["Access to one byte from memory. ","Access to two bytes from memory. ","Access to three bytes from memory. ","Access to a word from memory. "],visible:true,type:"L",value:0,default_value:0,nbits:"2",behavior:["FIRE R; FIRE W","FIRE R; FIRE W","FIRE R; FIRE W","FIRE R; FIRE W"],fire_name:["svg_p:text3533-5-2-8"],draw_data:[["svg_p:path3557-0"]],draw_name:[[],[]]};sim.poc.behaviors.MEM_READ={nparameters:6,types:["E","E","S","S","E"],operation:function(s_expr){var address=sim.poc.states[s_expr[1]].value;var dbvalue=sim.poc.states[s_expr[2]].value;var bw=sim.poc.signals[s_expr[3]].value;var clk=get_value(sim.poc.states[s_expr[5]]);sim.poc.signals[s_expr[4]].value=0;var remain=get_value(sim.poc.internal_states.MP_wc);if(typeof sim.poc.events.mem[clk-1]!="undefined"&&sim.poc.events.mem[clk-1]>0){remain=sim.poc.events.mem[clk-1]-1}var first_time=typeof sim.poc.events.mem[clk]=="undefined";sim.poc.events.mem[clk]=remain;if(remain>0){return}var wordress=address&4294967292;var value=main_memory_getvalue(sim.poc.internal_states.MP,wordress);var full_redraw=false;if(typeof value==="undefined"){value=0;full_redraw=true}dbvalue=main_memory_extractvalues(value,bw,address&3);sim.poc.states[s_expr[2]].value=dbvalue>>>0;sim.poc.signals[s_expr[4]].value=1;show_main_memory(sim.poc.internal_states.MP,wordress,full_redraw,false);if(first_time&&sim.poc.internal_states.CM.length>0){cache_memory_access(sim.poc.internal_states.CM[0],address,"read",clk)}},verbal:function(s_expr){var verbal="";var address=sim.poc.states[s_expr[1]].value;var dbvalue=sim.poc.states[s_expr[2]].value;var bw=sim.poc.signals[s_expr[3]].value;var clk=get_value(sim.poc.states[s_expr[5]]);switch(bw){case 0:bw_type="byte";break;case 1:bw_type="half";break;case 2:bw_type="three bytes";break;case 3:bw_type="word";break}var value=main_memory_getvalue(sim.poc.internal_states.MP,address);if(typeof value==="undefined"){value=0}verbal="Try to read a "+bw_type+" from memory "+"at address 0x"+address.toString(16)+" with value "+value.toString(16)+". ";return verbal}};sim.poc.behaviors.MEM_WRITE={nparameters:6,types:["E","E","S","S","E"],operation:function(s_expr){var address=sim.poc.states[s_expr[1]].value;var dbvalue=sim.poc.states[s_expr[2]].value;var bw=sim.poc.signals[s_expr[3]].value;var clk=get_value(sim.poc.states[s_expr[5]]);sim.poc.signals[s_expr[4]].value=0;var remain=get_value(sim.poc.internal_states.MP_wc);if(typeof sim.poc.events.mem[clk-1]!="undefined"&&sim.poc.events.mem[clk-1]>0){remain=sim.poc.events.mem[clk-1]-1}var first_time=typeof sim.poc.events.mem[clk]=="undefined";sim.poc.events.mem[clk]=remain;if(remain>0){return}var wordress=address&4294967292;var value=main_memory_getvalue(sim.poc.internal_states.MP,wordress);var full_redraw=false;if(typeof value==="undefined"){value=0;full_redraw=true}value=main_memory_updatevalues(value,dbvalue,bw,address&3);var origin="";var r_value=main_memory_get_program_counter();if(r_value!=null){origin="PC=0x"+r_value.toString(16)}var melto={value:value>>>0,source_tracking:[origin],comments:null};var elto=main_memory_set(sim.poc.internal_states.MP,wordress,melto);sim.poc.signals[s_expr[4]].value=1;show_main_memory(sim.poc.internal_states.MP,wordress,full_redraw,true);if(first_time&&sim.poc.internal_states.CM.length>0){cache_memory_access(sim.poc.internal_states.CM[0],address,"write",clk)}},verbal:function(s_expr){var verbal="";var address=sim.poc.states[s_expr[1]].value;var dbvalue=sim.poc.states[s_expr[2]].value;var bw=sim.poc.signals[s_expr[3]].value;var clk=get_value(sim.poc.states[s_expr[5]]);switch(bw){case 0:bw_type="byte";break;case 1:bw_type="half";break;case 2:bw_type="three bytes";break;case 3:bw_type="word";break}var value=main_memory_getvalue(sim.poc.internal_states.MP,address);if(typeof value==="undefined"){value=0}verbal="Try to write a "+bw_type+" to memory "+"at address 0x"+address.toString(16)+" with value "+value.toString(16)+". ";return verbal}};sim.poc.behaviors.MEMORY_RESET={nparameters:1,operation:function(s_expr){sim.poc.events.mem={}},verbal:function(s_expr){return"Reset the memory (all values will be zeroes). "}};sim.poc.elements.memory={name:"Main memory",description:"Main memory subsystem",type:"subcomponent",belongs:"MEMORY",states:{addr:{ref:"BUS_AB"},data:{ref:"BUS_DB"},mrdy:{ref:"MRDY"}},signals:{bw:{ref:"BW"},r:{ref:"R"},w:{ref:"W"}},states_inputs:["addr","data"],states_outputs:["mrdy","data"],signals_inputs:["bw","r","w"],signals_output:[]};sim.poc.components.IO={name:"IO",version:"1",abilities:["IO_TIMER"],details_name:["IO_STATS","IO_CONFIG"],details_fire:[["svg_p:text3775"],[]],write_state:function(vec){return vec},read_state:function(o,check){return false},get_state:function(reg){return null},get_value:function(elto){var associated_state=simhw_internalState_get("io_hash",elto);var value=get_value(simhw_sim_state(associated_state))>>>0;set_value(simhw_sim_state("BUS_AB"),elto);set_value(simhw_sim_signal("IOR"),1);compute_behavior("FIRE IOR");value=get_value(simhw_sim_state("BUS_DB"));return value},set_value:function(elto,value){var associated_state=simhw_internalState_get("io_hash",elto);set_value(simhw_sim_state(associated_state),value);set_value(simhw_sim_state("BUS_AB"),elto);set_value(simhw_sim_state("BUS_DB"),value);set_value(simhw_sim_signal("IOW"),1);compute_behavior("FIRE IOW");return value}};sim.poc.internal_states.io_int_factory=[];sim.poc.internal_states.io_int_factory[0]={period:0,probability:.5,accumulated:0,active:false};sim.poc.internal_states.io_int_factory[1]={period:0,probability:.5,accumulated:0,active:false};sim.poc.internal_states.io_int_factory[2]={period:0,probability:.5,accumulated:0,active:false};sim.poc.internal_states.io_int_factory[3]={period:0,probability:.5,accumulated:0,active:false};sim.poc.internal_states.io_int_factory[4]={period:0,probability:.5,accumulated:0,active:false};sim.poc.internal_states.io_int_factory[5]={period:0,probability:.5,accumulated:0,active:false};sim.poc.internal_states.io_int_factory[6]={period:0,probability:.5,accumulated:0,active:false};sim.poc.internal_states.io_int_factory[7]={period:0,probability:.5,accumulated:0,active:false};var IOSR_ID=4352;var IOCR_ID=4356;var IODR_ID=4360;sim.poc.internal_states.io_hash[IOSR_ID]="IOSR";sim.poc.internal_states.io_hash[IOCR_ID]="IOCR";sim.poc.internal_states.io_hash[IODR_ID]="IODR";sim.poc.states.IOSR={name:"IOSR",verbal:"IO State Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.IOCR={name:"IOCR",verbal:"IO Control Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.IODR={name:"IODR",verbal:"IO Data Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.signals.INT={name:"INT",visible:true,type:"L",value:0,default_value:0,nbits:"1",depends_on:["CLK"],behavior:["FIRE C","FIRE C"],fire_name:["svg_p:tspan4199"],draw_data:[[],["svg_p:path3809"]],draw_name:[[],[]]};sim.poc.signals.IORDY={name:"IORDY",visible:true,type:"L",value:0,default_value:0,nbits:"1",depends_on:["CLK"],behavior:["FIRE_IFCHANGED IORDY C","FIRE_IFCHANGED IORDY C"],fire_name:["svg_p:tspan4089","svg_p:path3793","svg_p:tspan4089"],draw_data:[[],["svg_p:path3897"]],draw_name:[[],[]]};sim.poc.signals.IO_IOR={name:"IO_IOR",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","IO_IOR BUS_AB BUS_DB IOSR IOCR IODR CLK; FIRE M1"],fire_name:["svg_p:tspan4173"],draw_data:[[],["svg_p:path3795","svg_p:path3733"]],draw_name:[[],[]]};sim.poc.signals.IO_IOW={name:"IO_IOW",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","IO_IOW BUS_AB BUS_DB IOSR IOCR IODR CLK; FIRE M1"],fire_name:["svg_p:text3785-0-6-0-5-5"],draw_data:[[],["svg_p:path3805","svg_p:path3733"]],draw_name:[[],[]]};sim.poc.signals.IO_IE={name:"IO_IE",visible:true,type:"L",value:1,default_value:1,nbits:"1",behavior:["NOP","IO_CHK_I CLK INT INTV; FIRE C"],fire_name:[],draw_data:[[],[]],draw_name:[[],[]]};sim.poc.signals.INTA={name:"INTA",visible:true,type:"L",value:1,default_value:0,nbits:"1",behavior:["NOP","INTA CLK INT INTA BUS_DB INTV; FIRE M1; FIRE C"],fire_name:["svg_p:text3785-0-6-0-5-5-1-1"],draw_data:[[],["svg_p:path3807","svg_p:path3737"]],draw_name:[[],[]]};sim.poc.behaviors.IO_IOR={nparameters:7,types:["E","E","E","E","E","E"],operation:function(s_expr){var bus_ab=get_value(sim.poc.states[s_expr[1]]);var iosr=get_value(sim.poc.states[s_expr[3]]);var iocr=get_value(sim.poc.states[s_expr[4]]);var iodr=get_value(sim.poc.states[s_expr[5]]);if(bus_ab==IOSR_ID)set_value(sim.poc.states[s_expr[2]],iosr);if(bus_ab==IOCR_ID)set_value(sim.poc.states[s_expr[2]],iocr);if(bus_ab==IODR_ID)set_value(sim.poc.states[s_expr[2]],iodr)},verbal:function(s_expr){var verbal="";var bus_ab=get_value(sim.poc.states[s_expr[1]]);var iosr=get_value(sim.poc.states[s_expr[3]]);var iocr=get_value(sim.poc.states[s_expr[4]]);var iodr=get_value(sim.poc.states[s_expr[5]]);if(bus_ab==IOSR_ID)verbal="I/O device read at IOSR of value "+iosr+". ";if(bus_ab==IOCR_ID)verbal="I/O device read at IOCR of value "+iocr+". ";if(bus_ab==IODR_ID)verbal="I/O device read at IODR of value "+iodr+". ";return verbal}};sim.poc.behaviors.IO_IOW={nparameters:7,types:["E","E","E","E","E","E"],operation:function(s_expr){var bus_ab=get_value(sim.poc.states[s_expr[1]]);var bus_db=get_value(sim.poc.states[s_expr[2]]);if(bus_ab!=IOSR_ID&&bus_ab!=IOCR_ID&&bus_ab!=IODR_ID){return}if(bus_ab==IOSR_ID)set_value(sim.poc.states[s_expr[3]],bus_db);if(bus_ab==IOCR_ID)set_value(sim.poc.states[s_expr[4]],bus_db);if(bus_ab==IODR_ID)set_value(sim.poc.states[s_expr[5]],bus_db);var iocr_id=get_value(sim.poc.states[s_expr[4]]);var iodr_id=get_value(sim.poc.states[s_expr[5]]);if(iocr_id<0||iocr_id>7)return;set_var(sim.poc.internal_states.io_int_factory[iocr_id].period,iodr_id);set_var(sim.poc.internal_states.io_int_factory[iocr_id].probability,1);if(0==iodr_id)set_var(sim.poc.internal_states.io_int_factory[iocr_id].probability,0)},verbal:function(s_expr){var verbal="";var bus_ab=get_value(sim.poc.states[s_expr[1]]);var bus_db=get_value(sim.poc.states[s_expr[2]]);if(bus_ab==IOSR_ID)verbal="I/O device write at IOSR with value "+bus_db+". ";if(bus_ab==IOCR_ID)verbal="I/O device write at IOCR with value "+bus_db+". ";if(bus_ab==IODR_ID)verbal="I/O device write at IODR with value "+bus_db+". ";return verbal}};sim.poc.behaviors.IO_CHK_I={nparameters:4,types:["E","S","E"],operation:function(s_expr){var clk=get_value(sim.poc.states[s_expr[1]]);for(var i=sim.poc.internal_states.io_int_factory.length-1;i>=0;i--){if(get_var(sim.poc.internal_states.io_int_factory[i].period)==0)continue;if(get_var(sim.poc.internal_states.io_int_factory[i].active)==true){set_value(sim.poc.signals[s_expr[2]],1);set_value(sim.poc.states[s_expr[3]],i)}if(clk%get_var(sim.poc.internal_states.io_int_factory[i].period)==0){if(Math.random()>get_var(sim.poc.internal_states.io_int_factory[i].probability))continue;set_var(sim.poc.internal_states.io_int_factory[i].accumulated,get_var(sim.poc.internal_states.io_int_factory[i].accumulated)+1);set_var(sim.poc.internal_states.io_int_factory[i].active,true);if(typeof sim.poc.events.io[clk]=="undefined")sim.poc.events.io[clk]=[];sim.poc.events.io[clk].push(i);set_value(sim.poc.signals[s_expr[2]],1);set_value(sim.poc.states[s_expr[3]],i)}}},verbal:function(s_expr){return"Check I/O Interruption. "}};sim.poc.behaviors.INTA={nparameters:6,types:["E","S","S","E","E"],operation:function(s_expr){var clk=get_value(sim.poc.states[s_expr[1]]);if(typeof sim.poc.events.io[clk]!="undefined"){set_value(sim.poc.states[s_expr[4]],sim.poc.events.io[clk][0]);return}set_value(sim.poc.signals[s_expr[2]],0);set_value(sim.poc.states[s_expr[5]],0);for(var i=0;i>>0;set_value(simhw_sim_state("BUS_AB"),elto);set_value(simhw_sim_signal("L3DR"),1);compute_behavior("FIRE L3DR");value=get_value(simhw_sim_state("BUS_DB"));return value},set_value:function(elto,value){var associated_state=simhw_internalState_get("io_hash",elto);set_value(simhw_sim_state(associated_state),value);set_value(simhw_sim_state("BUS_AB"),elto);set_value(simhw_sim_state("BUS_DB"),value);set_value(simhw_sim_signal("L3DW"),1);compute_behavior("FIRE L3DW");return value}};sim.poc.internal_states.l3d_dim=4;sim.poc.internal_states.l3d_neltos=Math.pow(sim.poc.internal_states.l3d_dim,3);sim.poc.internal_states.l3d_state=Array.from({length:sim.poc.internal_states.l3d_neltos},(()=>({active:false})));sim.poc.internal_states.l3d_frame="0".repeat(sim.poc.internal_states.l3d_neltos);var L3DSR_ID=8448;var L3DCR_ID=8452;var L3DDR_ID=8456;sim.poc.internal_states.io_hash[L3DSR_ID]="L3DSR";sim.poc.internal_states.io_hash[L3DCR_ID]="L3DCR";sim.poc.internal_states.io_hash[L3DDR_ID]="L3DDR";sim.poc.states.L3DSR={name:"L3DSR",verbal:"L3D State Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.L3DCR={name:"L3DCR",verbal:"L3D Control Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.L3DDR={name:"L3DDR",verbal:"L3D Data Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.signals.L3D_IOR={name:"L3D_IOR",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","L3D_IOR BUS_AB BUS_DB L3DSR L3DCR L3DDR CLK; FIRE M1"],fire_name:["svg_p:tspan4173"],draw_data:[[],["svg_p:path3795","svg_p:path3733"]],draw_name:[[],[]]};sim.poc.signals.L3D_IOW={name:"L3D_IOW",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","L3D_IOW BUS_AB BUS_DB L3DSR L3DCR L3DDR CLK; FIRE M1; L3D_SYNC"],fire_name:["svg_p:text3785-0-6-0-5-5"],draw_data:[[],["svg_p:path3805","svg_p:path3733"]],draw_name:[[],[]]};sim.poc.behaviors.L3D_IOR={nparameters:7,types:["E","E","E","E","E","E"],operation:function(s_expr){var bus_ab=get_value(sim.poc.states[s_expr[1]]);var iosr=get_value(sim.poc.states[s_expr[3]]);var iocr=get_value(sim.poc.states[s_expr[4]]);var iodr=get_value(sim.poc.states[s_expr[5]]);if(bus_ab==L3DCR_ID){set_value(sim.poc.states[s_expr[2]],iocr)}if(bus_ab==L3DDR_ID){set_value(sim.poc.states[s_expr[2]],iodr)}if(bus_ab==L3DCR_ID){var x=(iodr&4278190080)>>24;var y=(iodr&16711680)>>16;var z=(iodr&65280)>>8;var p=z*Math.pow(sim.poc.internal_states.l3d_dim,2)+y*sim.poc.internal_states.l3d_dim+x;var s=get_var(sim.poc.internal_states.l3d_state[p].active);set_value(sim.poc.states[s_expr[2]],s)}},verbal:function(s_expr){var verbal="";var bus_ab=get_value(sim.poc.states[s_expr[1]]);var iosr=get_value(sim.poc.states[s_expr[3]]);var iocr=get_value(sim.poc.states[s_expr[4]]);var iodr=get_value(sim.poc.states[s_expr[5]]);if(bus_ab==L3DSR_ID)verbal="I/O device read at L3DSR of value "+iosr+". ";if(bus_ab==L3DCR_ID)verbal="I/O device read at L3DCR of value "+iocr+". ";if(bus_ab==L3DDR_ID)verbal="I/O device read at L3DDR of value "+iodr+". ";return verbal}};sim.poc.behaviors.L3D_IOW={nparameters:7,types:["E","E","E","E","E","E"],operation:function(s_expr){var bus_ab=get_value(sim.poc.states[s_expr[1]]);var bus_db=get_value(sim.poc.states[s_expr[2]]);if(bus_ab!=L3DSR_ID&&bus_ab!=L3DCR_ID&&bus_ab!=L3DDR_ID){return}if(bus_ab==L3DSR_ID){set_value(sim.poc.states[s_expr[3]],bus_db)}if(bus_ab==L3DDR_ID){set_value(sim.poc.states[s_expr[5]],bus_db)}if(bus_ab==L3DCR_ID){set_value(sim.poc.states[s_expr[4]],bus_db);var x=(bus_db&4278190080)>>24;var y=(bus_db&16711680)>>16;var z=(bus_db&65280)>>8;var p=z*Math.pow(sim.poc.internal_states.l3d_dim,2)+y*sim.poc.internal_states.l3d_dim+x;var s=(bus_db&255)!=0;var l3dstates=sim.poc.internal_states.l3d_state;set_var(l3dstates[p].active,s)}},verbal:function(s_expr){var verbal="";var bus_ab=get_value(sim.poc.states[s_expr[1]]);var bus_db=get_value(sim.poc.states[s_expr[2]]);if(bus_ab==L3DSR_ID)verbal="I/O device write at L3DSR with value "+bus_db+". ";if(bus_ab==L3DCR_ID)verbal="I/O device write at L3DCR with value "+bus_db+". ";if(bus_ab==L3DDR_ID)verbal="I/O device write at L3DDR with value "+bus_db+". ";return verbal}};sim.poc.behaviors.L3D_RESET={nparameters:1,operation:function(s_expr){sim.poc.events.l3d={};var n=sim.poc.internal_states.l3d_state.length;for(var i=0;i>>0;set_value(simhw_sim_state("BUS_AB"),elto);set_value(simhw_sim_signal("LEDMR"),1);compute_behavior("FIRE LEDMR");value=get_value(simhw_sim_state("BUS_DB"));return value},set_value:function(elto,value){var associated_state=simhw_internalState_get("io_hash",elto);set_value(simhw_sim_state(associated_state),value);set_value(simhw_sim_state("BUS_AB"),elto);set_value(simhw_sim_state("BUS_DB"),value);set_value(simhw_sim_signal("LEDMW"),1);compute_behavior("FIRE LEDMW");return value}};sim.poc.internal_states.ledm_dim=24;sim.poc.internal_states.ledm_neltos=Math.pow(sim.poc.internal_states.ledm_dim,2);sim.poc.internal_states.ledm_state=Array.from({length:sim.poc.internal_states.ledm_neltos},(()=>({color:0})));sim.poc.internal_states.ledm_colors=colors_clone("");sim.poc.internal_states.ledm_frame="0".repeat(sim.poc.internal_states.ledm_neltos);var LEDMSR_ID=12544;var LEDMCR_ID=12548;var LEDMDR_ID=12552;sim.poc.internal_states.io_hash[LEDMSR_ID]="LEDMSR";sim.poc.internal_states.io_hash[LEDMCR_ID]="LEDMCR";sim.poc.internal_states.io_hash[LEDMDR_ID]="LEDMDR";sim.poc.states.LEDMSR={name:"LEDMSR",verbal:"LEDM State Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.LEDMCR={name:"LEDMCR",verbal:"LEDM Control Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.states.LEDMDR={name:"LEDMDR",verbal:"LEDM Data Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.poc.signals.LEDM_IOR={name:"LEDM_IOR",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","LEDM_IOR BUS_AB BUS_DB LEDMSR LEDMCR LEDMDR CLK; FIRE M1"],fire_name:["svg_p:tspan4173"],draw_data:[[],["svg_p:path3795","svg_p:path3733"]],draw_name:[[],[]]};sim.poc.signals.LEDM_IOW={name:"LEDM_IOW",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","LEDM_IOW BUS_AB BUS_DB LEDMSR LEDMCR LEDMDR CLK; FIRE M1; LEDM_SYNC"],fire_name:["svg_p:text3785-0-6-0-5-5"],draw_data:[[],["svg_p:path3805","svg_p:path3733"]],draw_name:[[],[]]};sim.poc.behaviors.LEDM_IOR={nparameters:7,types:["E","E","E","E","E","E"],operation:function(s_expr){var bus_ab=get_value(sim.poc.states[s_expr[1]]);var iosr=get_value(sim.poc.states[s_expr[3]]);var iocr=get_value(sim.poc.states[s_expr[4]]);var iodr=get_value(sim.poc.states[s_expr[5]]);if(bus_ab==LEDMCR_ID){set_value(sim.poc.states[s_expr[2]],iocr)}if(bus_ab==LEDMDR_ID){set_value(sim.poc.states[s_expr[2]],iodr)}if(bus_ab==LEDMCR_ID){var x=(iodr&4278190080)>>24;var y=(iodr&16711680)>>16;var p=y*sim.poc.internal_states.ledm_dim+x;var s=get_var(sim.poc.internal_states.ledm_state[p].color);set_value(sim.poc.states[s_expr[2]],s)}},verbal:function(s_expr){var verbal="";var bus_ab=get_value(sim.poc.states[s_expr[1]]);var iosr=get_value(sim.poc.states[s_expr[3]]);var iocr=get_value(sim.poc.states[s_expr[4]]);var iodr=get_value(sim.poc.states[s_expr[5]]);if(bus_ab==LEDMSR_ID)verbal="I/O device read at LEDMSR of value "+iosr+". ";if(bus_ab==LEDMCR_ID)verbal="I/O device read at LEDMCR of value "+iocr+". ";if(bus_ab==LEDMDR_ID)verbal="I/O device read at LEDMDR of value "+iodr+". ";return verbal}};sim.poc.behaviors.LEDM_IOW={nparameters:7,types:["E","E","E","E","E","E"],operation:function(s_expr){var bus_ab=get_value(sim.poc.states[s_expr[1]]);var bus_db=get_value(sim.poc.states[s_expr[2]]);switch(bus_ab){case LEDMSR_ID:set_value(sim.poc.states[s_expr[3]],bus_db);break;case LEDMDR_ID:set_value(sim.poc.states[s_expr[5]],bus_db);break;case LEDMCR_ID:set_value(sim.poc.states[s_expr[4]],bus_db);break;default:break}if(LEDMCR_ID==bus_ab){var dr=get_value(sim.poc.states[s_expr[5]]);if(16&bus_db){var x=(dr&4278190080)>>24;var y=(dr&16711680)>>16;var s=dr&255;set_value(sim.poc.states[s_expr[3]],1);if(x>=sim.poc.internal_states.ledm_dim&&y>=sim.poc.internal_states.ledm_dim){set_value(sim.poc.states[s_expr[3]],-1);return}var p=y*sim.poc.internal_states.ledm_dim+x;set_var(sim.poc.internal_states.ledm_state[p].color,s)}if(32&bus_db){set_value(sim.poc.states[s_expr[3]],1);var s=0;var neltos=sim.poc.internal_states.ledm_neltos;var ldmstates=sim.poc.internal_states.ledm_state;for(var p=0;p>0);set_var(sim.poc.internal_states.ledm_state[p+1].color,(s&65280)>>8);set_var(sim.poc.internal_states.ledm_state[p+2].color,(s&16711680)>>16);set_var(sim.poc.internal_states.ledm_state[p+3].color,(s&4278190080)>>24)}}if(64&bus_db){set_value(sim.poc.states[s_expr[3]],1);var s=0;var c="";var neltos=sim.poc.internal_states.ledm_colors.length;for(var p=0;p>>8;s=s.toString(16);c="#"+simcoreui_pack(s,6);sim.poc.internal_states.ledm_colors[p]=c}neltos=sim.poc.internal_states.ledm_neltos;for(var p=0;p>24;var y=(dr&16711680)>>16;var s=dr&255;verbal="I/O device write at LEDMCR with value "+bus_db+" (set pixel x:"+x+", y:"+y+", with color:"+s+"). "}if(64&bus_db){verbal="I/O device write at LEDMCR with value "+bus_db+" (set color palette at:"+bus_db+"). "}break;default:break}return verbal}};sim.poc.behaviors.LEDM_RESET={nparameters:1,operation:function(s_expr){sim.poc.events.ledm={};sim.poc.internal_states.ledm_colors=colors_clone("");for(var i=0;i>>0;if(value!=0){vec.CPU["R"+i]={type:"register",default_value:0,id:"R"+i,op:"=",value:"0x"+value.toString(16)}}}for(i=0;i>>0;if(value!=0){vec.CPU[internal_reg[i]]={type:"register",default_value:0,id:internal_reg[i],op:"=",value:"0x"+value.toString(16)}}}return vec},read_state:function(vec,check){if(typeof vec.CPU=="undefined"){vec.CPU={}}var key=check["id"].toUpperCase().trim();var val=parseInt(check["value"]).toString(16);if("REGISTER"==check["type"].toUpperCase().trim()){vec.CPU[key]={type:"register",default_value:0,id:key,op:check["condition"],value:"0x"+val};return true}return false},get_state:function(reg){var value=0;var r_reg=reg.toUpperCase().trim();if(typeof sim.rv.states["REG_"+r_reg]!="undefined"){value=get_value(sim.rv.states["REG_"+r_reg])>>>0;return"0x"+value.toString(16)}r_reg=r_reg.replace("R","");var index=parseInt(r_reg);if(typeof sim.rv.states.BR[index]!="undefined"){value=get_value(sim.rv.states.BR[index])>>>0;return"0x"+value.toString(16)}return null},get_value:function(elto){if(Number.isInteger(elto))index=elto;else index=parseInt(elto);if(isNaN(index))return get_value(simhw_sim_state(elto))>>>0;return get_value(simhw_sim_states().BR[index])>>>0},set_value:function(elto,value){var pc_name=simhw_sim_ctrlStates_get().pc.state;if(Number.isInteger(elto))index=elto;else index=parseInt(elto);if(isNaN(index)){set_value(simhw_sim_state(elto),value);if(pc_name===elto){show_asmdbg_pc()}return value}return set_value(simhw_sim_states().BR[index],value)}};sim.rv.ctrl_states.pc={name:"PC",state:"REG_PC",is_pointer:true};sim.rv.ctrl_states.sp={name:"SP",state:"BR.29",is_pointer:true};sim.rv.ctrl_states.fp={name:"FP",state:"BR.30",is_pointer:true};sim.rv.ctrl_states.ir={name:"IR",state:"REG_IR",default_eltos:{co:{begin:0,end:5,length:6},cop:{begin:28,end:31,length:4},oc:{begin:25,end:31,length:7},eoc:{type:2,bits_field:[[14,12],[31,25]],bits:[[17,19],[0,6]],lengths:[3,7],length:10}},is_pointer:false};sim.rv.ctrl_states.mpc={name:"mPC",state:"REG_MICROADDR",is_pointer:false};sim.rv.internal_states.MC={};sim.rv.internal_states.ROM={};sim.rv.internal_states.FIRMWARE=ws_empty_firmware;sim.rv.internal_states.io_hash={};sim.rv.internal_states.fire_stack=[];sim.rv.internal_states.tri_state_names=[];sim.rv.internal_states.fire_visible={databus:false,internalbus:false};sim.rv.internal_states.filter_states=["REG_IR_DECO,col-12","REG_IR,col-auto","REG_PC,col-auto","REG_OUT,col-auto","REG_MICROADDR,col-auto"];sim.rv.internal_states.filter_signals=["CU,0","ALUOP,0","M1,0","M2,0","M3,0","M4,0","JUMP,0","PCWRITE,0","IMR,0","IRWRITE,0","RW,0","WOUT,0","DMR,0","DMW,0","WBE,0","SE,0"];sim.rv.internal_states.alu_flags={flag_n:0,flag_z:0};sim.rv.states.BR=[];sim.rv.states.BR[0]={name:"R0",verbal:"Register 0",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[1]={name:"R1",verbal:"Register 1",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[2]={name:"R2",verbal:"Register 2",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[3]={name:"R3",verbal:"Register 3",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[4]={name:"R4",verbal:"Register 4",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[5]={name:"R5",verbal:"Register 5",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[6]={name:"R6",verbal:"Register 6",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[7]={name:"R7",verbal:"Register 7",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[8]={name:"R8",verbal:"Register 8",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[9]={name:"R9",verbal:"Register 9",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[10]={name:"R10",verbal:"Register 10",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[11]={name:"R11",verbal:"Register 11",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[12]={name:"R12",verbal:"Register 12",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[13]={name:"R13",verbal:"Register 13",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[14]={name:"R14",verbal:"Register 14",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[15]={name:"R15",verbal:"Register 15",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[16]={name:"R16",verbal:"Register 16",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[17]={name:"R17",verbal:"Register 17",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[18]={name:"R18",verbal:"Register 18",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[19]={name:"R19",verbal:"Register 19",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[20]={name:"R20",verbal:"Register 20",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[21]={name:"R21",verbal:"Register 21",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[22]={name:"R22",verbal:"Register 22",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[23]={name:"R23",verbal:"Register 23",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[24]={name:"R24",verbal:"Register 24",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[25]={name:"R25",verbal:"Register 25",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[26]={name:"R26",verbal:"Register 26",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[27]={name:"R27",verbal:"Register 27",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[28]={name:"R28",verbal:"Register 28",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[29]={name:"R29",verbal:"Register 29",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[30]={name:"R30",verbal:"Register 30",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states.BR[31]={name:"R31",verbal:"Register 31",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["REG_PC"]={name:"PC",verbal:"Program Counter Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["REG_IR"]={name:"IR",verbal:"Instruction Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["REG_OUT"]={name:"OUT",verbal:"Out Register",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["M4_PC"]={name:"M4_PC",verbal:"Input PCWrite via M4",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["RDATA"]={name:"RDATA",verbal:"Read data form Instruction Memory (Input Instruction Register via Instruction Memory)",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["M2_ALU"]={name:"M2_ALU",verbal:"Input ALU via M2",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["M3_ALU"]={name:"M3_ALU",verbal:"Input ALU via M3",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["ALU_WOUT"]={name:"ALU_WOUT",verbal:"Input of OUT Register",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["FLAG_N"]={name:"FLAG_N",verbal:"Negative Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.rv.states["FLAG_Z"]={name:"FLAG_Z",verbal:"Zero Flag",visible:true,nbits:"1",value:0,default_value:0,draw_data:[]};sim.rv.states["REG_MICROADDR"]={name:"µADDR",verbal:"Microaddress Register",visible:true,nbits:"12",value:0,default_value:0,draw_data:[]};sim.rv.states["REG_MICROINS"]={name:"µINS",verbal:"Microinstruction Register",visible:true,nbits:"77",value:{},default_value:{},draw_data:[]};sim.rv.states["FETCH"]={name:"FETCH",verbal:"Input Fetch",visible:false,nbits:"12",value:0,default_value:0,draw_data:[]};sim.rv.states["ROM_MUXA"]={name:"ROM_MUXA",verbal:"Input ROM",visible:false,nbits:"12",value:0,default_value:0,draw_data:[]};sim.rv.states["MUXA_MICROADDR"]={name:"MUXA_MICROADDR",verbal:"Input microaddress",visible:false,nbits:"12",value:0,default_value:0,draw_data:[]};sim.rv.states["MUXC_MUXB"]={name:"MUXC_MUXB",verbal:"Output of MUX C",visible:false,nbits:"1",value:0,default_value:0,draw_data:[]};sim.rv.states["INEX"]={name:"INEX",verbal:"Illegal Instruction Exception",visible:false,nbits:"1",value:0,default_value:0,draw_data:[]};sim.rv.states["DM_BS"]={name:"DM_BS",verbal:"From Data Memory to Byte/Word Selector",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["BS_M1"]={name:"BS_M1",verbal:"From Byte/Word Selector to Mux 1",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["VAL_ZERO"]={name:"VAL_ZERO",verbal:"Wired Zero",visible:false,nbits:"1",value:0,default_value:0,draw_data:[]};sim.rv.states["VAL_ONE"]={name:"VAL_ONE",verbal:"Wired One",visible:false,nbits:"32",value:1,default_value:1,draw_data:[]};sim.rv.states["VAL_FOUR"]={name:"VAL_FOUR",verbal:"Wired Four",visible:false,nbits:"32",value:4,default_value:4,draw_data:[]};sim.rv.states["VAL_IMM"]={name:"VAL_IMM",verbal:"Immediate Value Generator",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["REG_IR_DECO"]={name:"IR_DECO",verbal:"Instruction Decoded",visible:true,nbits:"0",value:0,default_value:0,draw_data:[]};sim.rv.states["DECO_INS"]={name:"DECO_INS",verbal:"Instruction decoded in binary",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["CLK"]={name:"CLK",verbal:"Clock",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["ACC_TIME"]={name:"ACC_TIME",verbal:"Accumulated CPU time",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["TTCPU"]={name:"TTCPU",verbal:"Several Tristates to the internal data bus in CPU activated",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["ACC_PWR"]={name:"ACC_PWR",verbal:"Accumulated Energy Consumption",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.signals["CU"]={name:"CU",visible:true,type:"L",value:0,default_value:0,nbits:"3",behavior:["PLUS1 MUXA_MICROADDR REG_MICROADDR","CP_FIELD MUXA_MICROADDR REG_MICROINS/MADDR","MV MUXA_MICROADDR ROM_MUXA","MV MUXA_MICROADDR FETCH","JUMP_MADDR_N MUXA_MICROADDR REG_MICROINS/MADDR REG_MICROADDR 0","JUMP_MADDR_N MUXA_MICROADDR REG_MICROINS/MADDR REG_MICROADDR 1","JUMP_MADDR_Z MUXA_MICROADDR REG_MICROINS/MADDR REG_MICROADDR 0","JUMP_MADDR_Z MUXA_MICROADDR REG_MICROINS/MADDR REG_MICROADDR 1"],depends_on:["CLK"],fire_name:["svg_p:text7417"],draw_data:[["svg_p:path7391","svg_p:path7393","svg_p:path7395","svg_p:path7397","svg_p:path7399","svg_p:path7401"]],draw_name:[["svg_p:path7357","svg_p:path7329","svg_p:path7331"]]};sim.rv.signals["PCWRITE"]={name:"PCWRITE",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","LOAD REG_PC M4_PC; UPDATEDPC"],fire_name:["svg_p:text7155"],draw_data:[[]],draw_name:[["svg_p:path7145","svg_p:path7125","svg_p:path7127"]]};sim.rv.signals["JUMP"]={name:"JUMP",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","LOAD_J REG_PC M4_PC; UPDATEDPC_J"],fire_name:["svg_p:text7173"],draw_data:[[]],draw_name:[["svg_p:path7133","svg_p:path7143","svg_p:path7147","svg_p:path7135"]]};sim.rv.signals["IRWRITE"]={name:"IRWRITE",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","LOAD REG_IR RDATA; DECO"],fire_name:["svg_p:text7309"],draw_data:[["svg_p:path6711","svg_p_path:6713","svg_p:path6981","svg_p:path6903","svg_p:path6905"]],draw_name:[["svg_p:path7301"]]};sim.rv.signals["GEN_IMM"]={name:"GEN_IMM",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","DECO_IMM VAL_IMM 0 REG_IR OFFSET SIZE 0 SE_IMM"],fire_name:["svg_p:text7300"],draw_data:[["svg_p:path6981","svg_p:path6903","svg_p:path:6904"]],draw_name:[["svg_p:path7146"]]};sim.rv.signals["SE_IMM"]={name:"SE_IMM",visible:true,type:"L",value:0,default_value:1,nbits:"1",verbal:["Set superior bits of immediate value to 0.","Extend sign of immediate value."],behavior:["NOP","NOP"],fire_name:["svg_p:text7301"],draw_data:[[]],draw_name:[["svg_p:path7292"]]};sim.rv.signals["SIZE"]={name:"SIZE",visible:true,type:"L",value:0,default_value:0,nbits:"5",behavior:["NOP"],fire_name:["svg_p:text7302"],draw_data:[[]],draw_name:[["svg_p:path7293"]]};sim.rv.signals["OFFSET"]={name:"OFFSET",visible:true,type:"L",value:0,default_value:0,nbits:"5",behavior:["NOP"],fire_name:["svg_p:text7303"],draw_data:[[]],draw_name:[["svg_p:path7294"]]};sim.rv.signals["WOUT"]={name:"WOUT",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","LOAD REG_OUT ALU_WOUT"],fire_name:["svg_p:text7279"],draw_data:[["svg_p:path6837","svg_p:path6839"]],draw_name:[["svg_p:path7271"]]};sim.rv.signals["IMR"]={name:"IMR",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["NOP","READ_IM"],fire_name:["svg_p:text7213"],draw_data:[["svg_p:path6691","svg_p:path6693"]],draw_name:[["svg_p:path7205"]]};sim.rv.signals["REG_R1"]={name:"REG_R1",visible:true,type:"L",value:0,default_value:15,nbits:"5",behavior:["NOP"],fire_name:[],draw_data:[[]],draw_name:[[]]};sim.rv.signals["REG_R2"]={name:"REG_R2",visible:true,type:"L",value:0,default_value:20,nbits:"5",behavior:["NOP"],fire_name:[],draw_data:[[]],draw_name:[[]]};sim.rv.signals["REG_W2"]={name:"REG_W2",visible:true,type:"L",value:0,default_value:7,nbits:"5",behavior:["NOP"],fire_name:[],draw_data:[[]],draw_name:[[]]};sim.rv.states["M1_RW"]={name:"M1_RW",verbal:"Input Register File via M1",visible:false,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["W_DATA"]={name:"W_DATA",verbal:"Write Data",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["R_DATA1"]={name:"R_DATA1",verbal:"Read Data 1",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.states["R_DATA2"]={name:"R_DATA2",verbal:"Read Data 2",visible:true,nbits:"32",value:0,default_value:0,draw_data:[]};sim.rv.signals["RW"]={name:"RW",visible:true,type:"E",value:0,default_value:0,nbits:"1",behavior:["MBIT_SN REG_R1 REG_IR REG_MICROINS/REG_R1 5; GET R_DATA1 BR REG_R1; MBIT_SN REG_R2 REG_IR REG_MICROINS/REG_R2 5; GET R_DATA2 BR REG_R2","MBIT_SN REG_W2 REG_IR REG_MICROINS/REG_W2 5; SET BR REG_W2 M1_RW"],fire_name:["svg_p:text7299"],draw_data:[["svg_p:path6725","svg_p:path6727","svg_p:path6729","svg_p:path6731","svg_p:path6733","svg_p:path6735","svg_p:path6915","svg_p:path6913","svg_p:path6907","svg_p:path6909"]],draw_name:[["svg_p:path7291"]]};sim.rv.signals["M2"]={name:"M2",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV M2_ALU REG_PC; FIRE ALUOP","MV M2_ALU R_DATA1; FIRE ALUOP"],depends_on:["ALUOP"],fire_name:["svg_p:text7229"],draw_data:[["svg_p:path6691-3","svg_p:path6987","svg_p:path6989","svg_p:path6983","svg_p:path6991","svg_p:path6775","svg_p:path6777"],["svg_p:path6779","svg_p:path6781"]],draw_name:[[],["svg_p:path7199"]]};sim.rv.signals["M3"]={name:"M3",visible:true,type:"L",value:0,default_value:0,nbits:"2",behavior:["MV M3_ALU R_DATA2; FIRE ALUOP","MV M3_ALU VAL_FOUR; FIRE ALUOP","MV M3_ALU VAL_IMM; FIRE ALUOP","NOP"],fire_name:["svg_p:text7237"],depends_on:["ALUOP"],draw_data:[["svg_p:path6821","svg_p:path6823"],["svg_p:path7001","svg_p:path7003"],["svg_p:path7015","svg_p:path7013","svg_p:path6825","svg_p:path6827"]],draw_name:[[],["svg_p:path7197"]]};sim.rv.signals["M4"]={name:"M4",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV M4_PC REG_OUT","MV M4_PC ALU_WOUT"],depends_on:["PCWRITE"],fire_name:["svg_p:text7289"],draw_data:[["svg_p:path7075","svg_p:path7043","svg_p:path7045","svg_p:path7047","svg_p:path7123","svg_p:path7121","svg_p:path7041","svg_p:path7039","svg_p:path7035","svg_p:path7037"],["svg_p:path6837-6","svg_p:path7073","svg_p:path7115","svg_p:path7117","svg_p:path7119","svg_p:path7123","svg_p:path7121","svg_p:path7041","svg_p:path7039","svg_p:path7035","svg_p:path7037"]],draw_name:[[],["svg_p:path7281"]]};sim.rv.signals["ALUOP"]={name:"ALUOP",visible:true,type:"L",value:0,default_value:0,nbits:"5",behavior:["NOP_ALU; UPDATE_NZ","AND ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","OR ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","NOT ALU_WOUT M2_ALU; UPDATE_NZ","XOR ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","SRL ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","SRA ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","SL ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","RR ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","RL ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","ADD ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","SUB ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","MUL ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","DIV ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","MOD ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","LUI ALU_WOUT M2_ALU; UPDATE_NZ","ADDU ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","SUBU ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","MULU ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","DIVU ALU_WOUT M2_ALU M3_ALU; UPDATE_NZ","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU","NOP_ALU","MV ALU_WOUT M2_ALU; UPDATE_NZ","MV ALU_WOUT M3_ALU; UPDATE_NZ"],fire_name:["svg_p:text7269"],draw_data:[["svg_p:path6845","svg_p:path6847","svg_p:path6841","svg_p:path6843"]],draw_name:[["svg_p:path7249"]]};sim.rv.signals.DMR={name:"DMR",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV DM_BS REG_OUT; FIRE WBE","MEM_READ ALU_WOUT DM_BS WBE CLK; FIRE WBE"],fire_name:["svg_p:text7589","svg_p:text7507"],draw_data:[[],["svg_p:path7525","svg_p:path6837-6","svg_p:path7073","svg_p:path7619","svg_p:path7571","svg_p:path7573"]],draw_name:[[],[]]};sim.rv.signals.DMW={name:"DMW",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["NOP","MEM_WRITE ALU_WOUT DM_BS WBE CLK"],fire_name:["svg_p:text7597","svg_p:text7515"],draw_data:[[],["svg_p:path7527","svg_p:path6837-6","svg_p:path7073","svg_p:path7619","svg_p:path7571","svg_p:path7573"]],draw_name:[[],[]]};sim.rv.signals["WBE"]={name:"WBE",visible:false,type:"L",value:0,default_value:0,nbits:"2",behavior:["MV BS_M1 DM_BS","BWSEL BS_M1 DM_BS 0 0 8 SE","BWSEL BS_M1 DM_BS 0 0 16 SE","NOP"],depends_on:["RW"],fire_name:["svg_p:text7555","svg_p:text7433"],draw_data:[["svg_p:path7075-2","svg_p:path7043-6","svg_p:path7203","svg_p:path7579","svg_p:path7581","svg_p:path7567","svg_p:path7569","svg_p:path7421","svg_p:path7423"]],draw_name:[["svg_p:path7529","svg_p:path7425"]]};sim.rv.signals["SE"]={name:"SE",visible:true,type:"L",value:0,default_value:1,nbits:"1",verbal:["If WBE is enabled, set superior bits of Word to 0.","If WBE is enabled, extend byte sign to Word."],behavior:["NOP","NOP"],fire_name:["svg_p:text7453"],draw_data:[[]],draw_name:[["svg_p:path7445"]]};sim.rv.signals["M1"]={name:"M1",visible:true,type:"L",value:0,default_value:0,nbits:"1",behavior:["MV M1_RW BS_M1","MV M1_RW FLAG_N"],depends_on:["RW"],fire_name:["svg_p:text7221"],draw_data:[["svg_p:path7021","svg_p:path7023","svg_p:path7565","svg_p:path6911","svg_p:path6895","svg_p:path6897"],["svg_p:path7621","svg_p:path7025","svg_p:path7017","svg_p:path7019","svg_p:path6899","svg_p:path6901"]],draw_name:[[],["svg_p:path7195"]]};sim.rv.signals["TEST_N"]={name:"TEST_N",visible:true,type:"L",value:0,default_value:0,nbits:"1",forbidden:true,behavior:["MV FLAG_N VAL_ZERO","MV FLAG_N VAL_ONE"],depends_on:["ALUOP"],fire_name:["svg_p:text351","svg_p:text7185"],draw_data:[["svg_p:path7251"]],draw_name:[["svg_p:path7157"]]};sim.rv.signals["TEST_Z"]={name:"TEST_Z",visible:true,type:"L",value:0,default_value:0,nbits:"1",forbidden:true,behavior:["MV FLAG_Z VAL_ZERO","MV FLAG_Z VAL_ONE"],depends_on:["ALUOP"],fire_name:["svg_p:text7615","svg_p:text7193"],draw_data:[["svg_p:path7617"]],draw_name:[["svg_p:path7165"]]};sim.rv.behaviors["NOP"]={nparameters:1,operation:function(s_expr){},verbal:function(s_expr){return""}};sim.rv.behaviors["NOP_ALU"]={nparameters:1,operation:function(s_expr){sim.rv.internal_states.alu_flags.flag_n=0;sim.rv.internal_states.alu_flags.flag_z=0},verbal:function(s_expr){return""}};sim.rv.behaviors["MV"]={nparameters:3,types:["X","X"],operation:function(s_expr){sim_elto_org=get_reference(s_expr[2]);sim_elto_dst=get_reference(s_expr[1]);newval=get_value(sim_elto_org);set_value(sim_elto_dst,newval)},verbal:function(s_expr){var sim_elto_org=get_reference(s_expr[2]);var newval=get_value(sim_elto_org);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from "+show_verbal(s_expr[2])+" to "+show_verbal(s_expr[1])+" value "+show_value(newval)+". "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" ("+show_value(newval)+"). "}};sim.rv.behaviors["LOAD"]={nparameters:3,types:["X","X"],operation:function(s_expr){var sim_elto_org=get_reference(s_expr[2]);var sim_elto_dst=get_reference(s_expr[1]);var newval=get_value(sim_elto_org);set_value(sim_elto_dst,newval)},verbal:function(s_expr){var sim_elto_org=get_reference(s_expr[2]);var newval=get_value(sim_elto_org);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Load from "+show_verbal(s_expr[2])+" to "+show_verbal(s_expr[1])+" value "+show_value(newval)+". "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" ("+show_value(newval)+"). "}};sim.rv.behaviors["LOAD_J"]={nparameters:3,types:["X","X"],operation:function(s_expr){if(!get_value(sim.rv.states["FLAG_N"])&&!get_value(sim.rv.states["FLAG_Z"])){return}var sim_elto_org=get_reference(s_expr[2]);var sim_elto_dst=get_reference(s_expr[1]);var newval=get_value(sim_elto_org);set_value(sim_elto_dst,newval)},verbal:function(s_expr){var sim_elto_org=get_reference(s_expr[2]);var sim_elto_dst=get_reference(s_expr[1]);var newval=get_value(sim_elto_org);return"Jump if N or Z (new value is '"+newval+"' )"}};sim.rv.behaviors["CP_FIELD"]={nparameters:3,types:["X","X"],operation:function(s_expr){r=s_expr[2].split("/");sim_elto_org=get_reference(r[0]);newval=get_value(sim_elto_org);newval=newval[r[1]];if(typeof newval!="undefined"){sim_elto_dst=get_reference(s_expr[1]);set_value(sim_elto_dst,newval)}},verbal:function(s_expr){var newval=0;var r=s_expr[2].split("/");var sim_elto_org=get_reference(r[0]);var sim_elto_dst=get_reference(r[1]);if(typeof sim_elto_dst=="undefined")sim_elto_dst={};if(typeof sim_elto_org.value[r[1]]!="undefined")newval=sim_elto_org.value[r[1]];else if(typeof sim_elto_dst.default_value!="undefined")newval=sim_elto_dst.default_value;else newval="<undefined>";var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from Field "+r[1]+" of "+show_verbal(r[0])+" to "+show_verbal(s_expr[1])+" value "+newval+". "}return show_verbal(s_expr[1])+" = "+show_verbal(r[0])+"."+r[1]+" ("+newval+"). "}};sim.rv.behaviors["JUMP_MADDR_N"]={nparameters:5,types:["X","X","E","I"],operation:function(s_expr){if(get_value(sim.rv.states["FLAG_N"])!=parseInt(s_expr[4])){var a=get_value(sim.rv.states[s_expr[3]])<<0;var result=a+1;set_value(sim.rv.states[s_expr[1]],result>>>0)}else{r=s_expr[2].split("/");sim_elto_org=get_reference(r[0]);newval=get_value(sim_elto_org);newval=newval[r[1]];if(typeof newval!="undefined"){sim_elto_dst=get_reference(s_expr[1]);set_value(sim_elto_dst,newval)}}},verbal:function(s_expr){if(parseInt(s_expr[4])){return"Jump to REG_MICROINS/MADDR if Flag N = 1."}else{return"Jump to REG_MICROINS/MADDR if Flag N = 0."}}};sim.rv.behaviors["JUMP_MADDR_Z"]={nparameters:5,types:["X","X","E","I"],operation:function(s_expr){if(get_value(sim.rv.states["FLAG_Z"])!=parseInt(s_expr[4])){var a=get_value(sim.rv.states[s_expr[3]])<<0;var result=a+1;set_value(sim.rv.states[s_expr[1]],result>>>0)}else{r=s_expr[2].split("/");sim_elto_org=get_reference(r[0]);newval=get_value(sim_elto_org);newval=newval[r[1]];if(typeof newval!="undefined"){sim_elto_dst=get_reference(s_expr[1]);set_value(sim_elto_dst,newval)}}},verbal:function(s_expr){if(parseInt(s_expr[4])){return"Jump to REG_MICROINS/MADDR if Flag Z = 1."}else{return"Jump to REG_MICROINS/MADDR if Flag Z = 0."}}};sim.rv.behaviors["NOT_ES"]={nparameters:3,types:["S","E"],operation:function(s_expr){set_value(sim.rv.signals[s_expr[1]],Math.abs(get_value(sim.rv.states[s_expr[2]])-1))},verbal:function(s_expr){var value=Math.abs(get_value(sim.rv.states[s_expr[2]])-1);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Set "+show_verbal(s_expr[1])+" with value "+show_value(value)+" (Logical NOT of "+s_expr[2]+"). "}return show_verbal(s_expr[1])+" = "+show_value(value)+" (Logical NOT "+s_expr[2]+"). "}};sim.rv.behaviors["GET"]={nparameters:4,types:["E","E","S"],operation:function(s_expr){set_value(sim.rv.states[s_expr[1]],get_value(sim.rv.states[s_expr[2]][sim.rv.signals[s_expr[3]].value]))},verbal:function(s_expr){var value=get_value(sim.rv.states[s_expr[2]][sim.rv.signals[s_expr[3]].value]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Set "+show_verbal(s_expr[1])+" with value "+show_value(value)+" (Register File "+s_expr[3]+"). "}return show_verbal(s_expr[1])+" = "+show_value(value)+" (Register File "+s_expr[3]+"). "}};sim.rv.behaviors["SET"]={nparameters:4,types:["E","S","E"],operation:function(s_expr){set_value(sim.rv.states[s_expr[1]][sim.rv.signals[s_expr[2]].value],get_value(sim.rv.states[s_expr[3]]))},verbal:function(s_expr){var value=get_value(sim.rv.states[s_expr[3]]);var o_ref=sim.rv.states[s_expr[1]][sim.rv.signals[s_expr[2]].value];var o_verbal=o_ref.name;if(typeof o_ref.verbal!="undefined")o_verbal=o_ref.verbal;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy to "+o_verbal+" the value "+show_value(value)+". "}return o_verbal+" = "+show_value(value)+". "}};sim.rv.behaviors["AND"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var result=get_value(sim.rv.states[s_expr[2]])&get_value(sim.rv.states[s_expr[3]]);set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var result=get_value(sim.rv.states[s_expr[2]])&get_value(sim.rv.states[s_expr[3]]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU AND with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (AND). "}};sim.rv.behaviors["OR"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var result=get_value(sim.rv.states[s_expr[2]])|get_value(sim.rv.states[s_expr[3]]);set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var result=get_value(sim.rv.states[s_expr[2]])|get_value(sim.rv.states[s_expr[3]]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU OR with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (OR). "}};sim.rv.behaviors["NOT"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=~get_value(sim.rv.states[s_expr[2]]);set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var result=~get_value(sim.rv.states[s_expr[2]]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU NOT with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (NOT). "}};sim.rv.behaviors["XOR"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var result=get_value(sim.rv.states[s_expr[2]])^get_value(sim.rv.states[s_expr[3]]);set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var result=get_value(sim.rv.states[s_expr[2]])^get_value(sim.rv.states[s_expr[3]]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU XOR with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (XOR). "}};sim.rv.behaviors["SRL"]={nparameters:3,types:["E","E","E"],operation:function(s_expr){var shifts=get_value(sim.rv.states[s_expr[3]]);var result=get_value(sim.rv.states[s_expr[2]])>>>shifts;set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var shifts=get_value(sim.rv.states[s_expr[3]]);var result=get_value(sim.rv.states[s_expr[2]])>>>shifts;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Shift Right Logical with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (SRL). "}};sim.rv.behaviors["SRA"]={nparameters:3,types:["E","E","E"],operation:function(s_expr){var shifts=get_value(sim.rv.states[s_expr[3]]);var result=get_value(sim.rv.states[s_expr[2]])>>shifts;set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var shifts=get_value(sim.rv.states[s_expr[3]]);var result=get_value(sim.rv.states[s_expr[2]])>>shifts;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Shift Right Arithmetic with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (SRA). "}};sim.rv.behaviors["SL"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var shifts=get_value(sim.rv.states[s_expr[3]]);var result=get_value(sim.rv.states[s_expr[2]])<>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var shifts=get_value(sim.rv.states[s_expr[3]]);var result=get_value(sim.rv.states[s_expr[2]])<>>rotations|(get_value(sim.rv.states[s_expr[2]])&rotations)<<31;set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var rotations=get_value(sim.rv.states[s_expr[3]]);var result=get_value(sim.rv.states[s_expr[2]])>>>rotations|(get_value(sim.rv.states[s_expr[2]])&rotations)<<31;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Right Rotation with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (RR). "}};sim.rv.behaviors["RL"]={nparameters:3,types:["E","E"],operation:function(s_expr){var rotations=get_value(sim.rv.states[s_expr[3]]);var result=get_value(sim.rv.states[s_expr[2]])<>>31;set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var rotations=get_value(sim.rv.states[s_expr[3]]);var result=get_value(sim.rv.states[s_expr[2]])<>>31;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Left Rotation with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (LR). "}};sim.rv.behaviors["ADD"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var b=get_value(sim.rv.states[s_expr[3]])<<0;var result=a+b;set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var b=get_value(sim.rv.states[s_expr[3]])<<0;var result=a+b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU ADD with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (ADD). "}};sim.rv.behaviors["SUB"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var b=get_value(sim.rv.states[s_expr[3]])<<0;var result=a-b;set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var b=get_value(sim.rv.states[s_expr[3]])<<0;var result=a-b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU SUB with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (SUB). "}};sim.rv.behaviors["MUL"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var b=get_value(sim.rv.states[s_expr[3]])<<0;var result=a*b;set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var b=get_value(sim.rv.states[s_expr[3]])<<0;var result=a*b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU MUL with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (MUL). "}};sim.rv.behaviors["DIV"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var b=get_value(sim.rv.states[s_expr[3]])<<0;if(0==b){set_value(sim.rv.states[s_expr[1]],0);sim.rv.internal_states.alu_flags.flag_n=0;sim.rv.internal_states.alu_flags.flag_z=1;return}var result=Math.floor(a/b);set_value(sim.rv.states[s_expr[1]],result);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var b=get_value(sim.rv.states[s_expr[3]])<<0;if(0==b){return"ALU DIV zero by zero (oops!). "}var result=Math.floor(a/b);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU DIV with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (DIV). "}};sim.rv.behaviors["MOD"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var b=get_value(sim.rv.states[s_expr[3]])<<0;if(0==b){set_value(sim.rv.states[s_expr[1]],0);sim.rv.internal_states.alu_flags.flag_n=0;sim.rv.internal_states.alu_flags.flag_z=1;return}var result=a%b;set_value(sim.rv.states[s_expr[1]],result);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var b=get_value(sim.rv.states[s_expr[3]])<<0;if(0==b){return"ALU MOD zero by zero (oops!). "}var result=a%b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU MOD with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (MOD). "}};sim.rv.behaviors["LUI"]={nparameters:3,types:["E","E"],operation:function(s_expr){var result=get_value(sim.rv.states[s_expr[2]])<<16;set_value(sim.rv.states[s_expr[1]],result);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var result=get_value(sim.rv.states[s_expr[2]])<<16;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU Load Upper Immediate with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (LUI). "}};sim.rv.behaviors["ADDU"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])>>>0;var b=get_value(sim.rv.states[s_expr[3]])>>>0;var result=a+b;set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])>>>0;var b=get_value(sim.rv.states[s_expr[3]])>>>0;var result=a+b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU ADDU with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (ADDU). "}};sim.rv.behaviors["SUBU"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])>>>0;var b=get_value(sim.rv.states[s_expr[3]])>>>0;var result=a-b;set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])>>>0;var b=get_value(sim.rv.states[s_expr[3]])>>>0;var result=a-b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU SUBU with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (SUBU). "}};sim.rv.behaviors["MULU"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])>>>0;var b=get_value(sim.rv.states[s_expr[3]])>>>0;var result=a*b;set_value(sim.rv.states[s_expr[1]],result>>>0);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])>>>0;var b=get_value(sim.rv.states[s_expr[3]])>>>0;var result=a*b;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU MULU with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (MULU). "}};sim.rv.behaviors["DIVU"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])>>>0;var b=get_value(sim.rv.states[s_expr[3]])>>>0;if(0==b){set_value(sim.rv.states[s_expr[1]],0);sim.rv.internal_states.alu_flags.flag_n=0;sim.rv.internal_states.alu_flags.flag_z=1;return}var result=Math.floor(a/b);set_value(sim.rv.states[s_expr[1]],result);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])>>>0;var b=get_value(sim.rv.states[s_expr[3]])>>>0;if(0==b){return"ALU DIVU zero by zero (oops!). "}var result=Math.floor(a/b);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU DIVU with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (DIVU). "}};sim.rv.behaviors["FADD"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]]);var b=get_value(sim.rv.states[s_expr[3]]);var result=hex2float(a)+hex2float(b);set_value(sim.rv.states[s_expr[1]],float32_to_uint(result));sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]]);var b=get_value(sim.rv.states[s_expr[3]]);var result=hex2float(a)+hex2float(b);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU FADD with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (FADD). "}};sim.rv.behaviors["FSUB"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]]);var b=get_value(sim.rv.states[s_expr[3]]);var result=hex2float(a)-hex2float(b);set_value(sim.rv.states[s_expr[1]],float32_to_uint(result));sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]]);var b=get_value(sim.rv.states[s_expr[3]]);var result=hex2float(a)-hex2float(b);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU FSUB with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (FSUB). "}};sim.rv.behaviors["FMUL"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]]);var b=get_value(sim.rv.states[s_expr[3]]);var result=hex2float(a)*hex2float(b);set_value(sim.rv.states[s_expr[1]],float32_to_uint(result));sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]]);var b=get_value(sim.rv.states[s_expr[3]]);var result=hex2float(a)*hex2float(b);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU FMUL with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (FMUL). "}};sim.rv.behaviors["FDIV"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]]);var b=get_value(sim.rv.states[s_expr[3]]);var result=hex2float(a)/hex2float(b);set_value(sim.rv.states[s_expr[1]],float32_to_uint(result));sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]]);var b=get_value(sim.rv.states[s_expr[3]]);var result=hex2float(a)-hex2float(b);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU FDIV with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (FDIV). "}};sim.rv.behaviors["FCVT"]={nparameters:4,types:["E","E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])>>>0;var b=get_value(sim.rv.states[s_expr[3]]);var result=a;switch(b){case 1:result=hex2float(result);result=Math.trunc(result);break;case 2:result=hex2float(result);result=Math.round(result);break;case 4:result=result.toFixed(5);result=parseFloat(result);result=float2decimal(result);break;default:break}set_value(sim.rv.states[s_expr[1]],result);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])>>>0;var b=get_value(sim.rv.states[s_expr[3]]);var result=a;switch(b){case 1:result=hex2float(result);result=Math.trunc(result);break;case 2:result=hex2float(result);result=Math.round(result);break;case 4:result=result.toFixed(5);result=parseFloat(result);result=float2decimal(result);break;default:break}var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU FCVT with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (FCVT). "}};sim.rv.behaviors["FCLASS"]={nparameters:3,types:["E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])>>>0;var result=float_class(a);set_value(sim.rv.states[s_expr[1]],result);sim.rv.internal_states.alu_flags.flag_n=result<0?1:0;sim.rv.internal_states.alu_flags.flag_z=result==0?1:0},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[1]])>>>0;var result=float_class(a);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"ALU FCLASS with result "+show_value(result)+". "}return"ALU output = "+show_value(result)+" (FCLASS). "}};sim.rv.behaviors["PLUS1"]={nparameters:3,types:["E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var result=a+1;set_value(sim.rv.states[s_expr[1]],result>>>0)},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var result=a+1;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy to "+show_verbal(s_expr[1])+" "+show_verbal(s_expr[2])+" plus one with result "+show_value(result)+". "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" + 1"+" ("+show_value(result)+"). "}};sim.rv.behaviors["PLUS4"]={nparameters:3,types:["E","E"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var result=a+4;set_value(sim.rv.states[s_expr[1]],result>>>0)},verbal:function(s_expr){var a=get_value(sim.rv.states[s_expr[2]])<<0;var result=a+4;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy to "+show_verbal(s_expr[1])+" "+show_verbal(s_expr[2])+" plus four with result "+show_value(result)+". "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" + 4"+" ("+show_value(result)+"). "}};sim.rv.behaviors["SET_TT"]={nparameters:3,types:["E","I"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[1]])<<0;var b=parseInt(s_expr[2]);var m=Math.pow(2,b);var r=a|m;set_value(sim.rv.states[s_expr[1]],r);update_cpu_bus_fire(r,b)},verbal:function(s_expr){return""}};sim.rv.behaviors["RST_TT"]={nparameters:3,types:["E","I"],operation:function(s_expr){var a=get_value(sim.rv.states[s_expr[1]])<<0;var b=parseInt(s_expr[2]);var m=Math.pow(2,b);var r=a&~m;set_value(sim.rv.states[s_expr[1]],r);update_cpu_bus_fire(r,b)},verbal:function(s_expr){return""}};sim.rv.behaviors["MBIT"]={nparameters:5,types:["X","X","I","I"],operation:function(s_expr){var sim_elto_dst=get_reference(s_expr[1]);var sim_elto_org=get_reference(s_expr[2]);var offset=parseInt(s_expr[3]);var size=parseInt(s_expr[4]);var n1=get_value(sim_elto_org).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(offset+size-1),size);set_value(sim_elto_dst,parseInt(n2,2))},verbal:function(s_expr){var sim_elto_dst=get_reference(s_expr[1]);var sim_elto_org=get_reference(s_expr[2]);var offset=parseInt(s_expr[3]);var size=parseInt(s_expr[4]);var n1=get_value(sim_elto_org).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(offset+size-1),size);var n3=parseInt(n2,2);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from "+show_verbal(s_expr[2])+" to "+show_verbal(s_expr[1])+" value "+show_value(n3)+" (copied "+size+" bits from bit "+offset+"). "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" ("+show_value(n3)+", "+size+" bits from bit "+offset+"). "}};sim.rv.behaviors["MBIT_SN"]={nparameters:5,types:["S","E","E","I"],operation:function(s_expr){var base=0;var r=s_expr[3].split("/");if(1==r.length)base=get_value(sim.rv.states[s_expr[3]]);else if(typeof sim.rv.states[r[0]].value[r[1]]!="undefined")base=sim.rv.states[r[0]].value[r[1]];else if(typeof sim.rv.signals[r[1]].default_value!="undefined")base=sim.rv.signals[r[1]].default_value;else if(typeof sim.rv.states[r[1]].default_value!="undefined")base=sim.rv.states[r[1]].default_value;else ws_alert("WARN: undefined state/field pair -> "+r[0]+"/"+r[1]);var offset=parseInt(s_expr[4]);var n1=get_value(sim.rv.states[s_expr[2]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;var n3=n2.substr(31-(base+offset-1),offset);set_value(sim.rv.signals[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){var base=0;var r=s_expr[3].split("/");if(1==r.length)base=get_value(sim.rv.states[s_expr[3]]);else if(typeof sim.rv.states[r[0]].value[r[1]]!="undefined")base=sim.rv.states[r[0]].value[r[1]];else if(typeof sim.rv.signals[r[1]].default_value!="undefined")base=sim.rv.signals[r[1]].default_value;else if(typeof sim.rv.states[r[1]].default_value!="undefined")base=sim.rv.states[r[1]].default_value;else ws_alert("WARN: undefined state/field pair -> "+r[0]+"/"+r[1]);var offset=parseInt(s_expr[4]);var n1=get_value(sim.rv.states[s_expr[2]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;var n3=n2.substr(31-(base+offset-1),offset);var from_elto="";if(1==r.length)from_elto=show_verbal(s_expr[3]);else from_elto=show_verbal(s_expr[2])+"["+r[1]+"] ";var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from "+from_elto+"into "+show_verbal(s_expr[1])+" "+"value "+parseInt(n3,2)+". "}return show_verbal(s_expr[1])+" = "+from_elto+" ("+parseInt(n3,2)+").
"}};sim.rv.behaviors["SBIT_SIGNAL"]={nparameters:4,types:["X","I","I"],operation:function(s_expr){sim_elto_dst=get_reference(s_expr[1]);var new_value=sim_elto_dst.value;var mask=1<>>0)},verbal:function(s_expr){sim_elto_dst=get_reference(s_expr[1]);var new_value=sim_elto_dst.value;var mask=1<>>0)}};sim.rv.behaviors["UPDATE_FLAG"]={nparameters:4,types:["X","X","I"],operation:function(s_expr){sim_elto_org=get_reference(s_expr[2]);sim_elto_dst=get_reference(s_expr[1]);var new_value=sim_elto_dst.value&~(1<>>0)},verbal:function(s_expr){sim_elto_org=get_reference(s_expr[2]);sim_elto_dst=get_reference(s_expr[1]);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Update "+show_verbal(s_expr[2])+" to value "+sim_elto_org.value+". "}return show_verbal(s_expr[1])+"."+show_verbal(s_expr[3])+" = "+sim_elto_org.value+". "}};sim.rv.behaviors["MBITS"]={nparameters:8,types:["E","I","E","S","S","I","S"],operation:function(s_expr){var offset=parseInt(sim.rv.signals[s_expr[4]].value);var size=parseInt(sim.rv.signals[s_expr[5]].value);var n1=get_value(sim.rv.states[s_expr[3]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(offset+size-1),size);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;if("1"==sim.rv.signals[s_expr[7]].value&&"1"==n2.substr(0,1)){n3="11111111111111111111111111111111".substring(0,32-n2.length)+n2}set_value(sim.rv.states[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){var offset=parseInt(sim.rv.signals[s_expr[4]].value);var size=parseInt(sim.rv.signals[s_expr[5]].value);var n1=get_value(sim.rv.states[s_expr[3]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(offset+size-1),size);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;if("1"==sim.rv.signals[s_expr[7]].value&&"1"==n2.substr(0,1)){n3="11111111111111111111111111111111".substring(0,32-n2.length)+n2}n1=parseInt(n3,2);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return" Copy from "+show_verbal(s_expr[3])+" to "+show_verbal(s_expr[1])+" value "+show_value(n1)+" (copied "+size+" bits from bit "+offset+"). "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[3])+" ("+show_value(n1)+", "+size+" bits from bit "+offset+"). "}};sim.rv.behaviors["DECO_IMM"]={nparameters:8,types:["E","I","E","S","S","I","S"],operation:function(s_expr){var oi=decode_instruction(sim.rv.internal_states.FIRMWARE,sim.rv.ctrl_states.ir,get_value(sim.rv.states["REG_IR"]));var bits=[];var startbit;var stopbit;for(var i=0;i=0;i--){for(var j=31-bits[i][0];j<=31-bits[i][1];j++){n2+=n1[j]}}n2="00000000000000000000000000000000".substring(0,32-n2.length)+n2;n2=n2.substr(31-(size-1),size);n2=n2+"0".repeat(offset);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;if("1"==sim.rv.signals[s_expr[7]].value&&"1"==n2.substr(0,1)){n3="11111111111111111111111111111111".substring(0,32-n2.length)+n2}set_value(sim.rv.states[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){return"Generate immediate value"}};sim.rv.behaviors["BSEL"]={nparameters:6,types:["E","I","I","E","I"],operation:function(s_expr){var posd=parseInt(s_expr[2]);var poso=parseInt(s_expr[5]);var len=parseInt(s_expr[3]);var n1=get_value(sim.rv.states[s_expr[4]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(poso+len)+1,len);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var n4="00000000000000000000000000000000".substr(0,posd);n3=n3+n4;set_value(sim.rv.states[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){var posd=parseInt(s_expr[2]);var len=parseInt(s_expr[3]);var poso=parseInt(s_expr[5]);var n1=get_value(sim.rv.states[s_expr[4]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(poso+len)+1,len);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var n4="00000000000000000000000000000000".substr(0,posd);n3=n3+n4;var n5=parseInt(n3,2);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from "+show_verbal(s_expr[4])+" to "+show_verbal(s_expr[1])+" value "+show_value(n5)+" (copied "+len+" bits, from bit "+poso+" of "+s_expr[4]+" to bit "+posd+" of "+s_expr[1]+"). "}return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[4])+" ("+show_value(n5)+", "+len+" bits, from bit "+poso+" of "+s_expr[4]+" to bit "+posd+" of "+s_expr[1]+"). "}};sim.rv.behaviors["BWSEL"]={nparameters:7,types:["E","E","I","I","I","S"],operation:function(s_expr){var posd=parseInt(s_expr[3]);var poso=parseInt(s_expr[4]);var len=parseInt(s_expr[5]);var sign_ext=sim.rv.signals[s_expr[6]].value;var n1=get_value(sim.rv.states[s_expr[2]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(poso+len)+1,len);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var n4="00000000000000000000000000000000".substr(0,posd);n3=n3+n4;if(sign_ext){var s1=n2;var s2="00000000000000000000000000000000".substring(0,32-s1.length)+s1;var s3=s2.substr(31-(len-1),31);var s4=s3;if("1"==s2[31-(len-1)]){s4="11111111111111111111111111111111".substring(0,32-s3.length)+s4}set_value(sim.rv.states[s_expr[1]],parseInt(s4,2))}else{n3="00000000000000000000000000000000".substring(0,32-n3.length)+n3;set_value(sim.rv.states[s_expr[1]],parseInt(n3,2))}},verbal:function(s_expr){var posd=parseInt(s_expr[3]);var poso=parseInt(s_expr[4]);var len=parseInt(s_expr[5]);var sign_ext=sim.rv.signals[s_expr[6]].value;var n1=get_value(sim.rv.states[s_expr[2]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n2=n2.substr(31-(poso+len)+1,len);var n3="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var n4="00000000000000000000000000000000".substr(0,posd);n3=n3+n4;if(sign_ext){var s1=n2;var s2="00000000000000000000000000000000".substring(0,32-s1.length)+s1;var s3=s2.substr(31-(len-1),31);var s4=s3;if("1"==s2[31-(len-1)]){s4="11111111111111111111111111111111".substring(0,32-s3.length)+s4}var value=parseInt(s4,2);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from "+show_verbal(s_expr[2])+" to "+show_verbal(s_expr[1])+" value "+show_value(value)+ +" (copied "+len+" bits, from bit "+poso+" to bit "+(posd+len)+" with sign extension)."}else{return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" ("+show_value(value)+", "+len+" bits, from bit "+poso+" of "+s_expr[2]+" to bit "+(posd+8)+" of "+s_expr[1]+"). "}}else{var value=parseInt(n3,2);var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){return"Copy from "+show_verbal(s_expr[2])+" to "+show_verbal(s_expr[1])+" value "+show_value(value)+ +" (copied "+len+" bits, from bit "+poso+" to bit "+(posd+len)+" without sign extension)."}else{return show_verbal(s_expr[1])+" = "+show_verbal(s_expr[2])+" ("+show_value(value)+", "+len+" bits, from bit "+poso+" of "+s_expr[2]+" to bit "+(posd+8)+" of "+s_expr[1]+"). "}}}};sim.rv.behaviors["EXT_SIG"]={nparameters:3,types:["E","I"],operation:function(s_expr){var n1=get_value(sim.rv.states[s_expr[1]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;var n3=n2.substr(31-s_expr[2],31);var n4=n3;if("1"==n2[31-s_expr[2]]){n4="11111111111111111111111111111111".substring(0,32-n3.length)+n4}set_value(sim.rv.states[s_expr[1]],parseInt(n4,2))},verbal:function(s_expr){var n1=get_value(sim.rv.states[s_expr[1]]).toString(2);var n2="00000000000000000000000000000000".substring(0,32-n1.length)+n1;var n3=n2.substr(31-s_expr[2],31);var n4=n3;if("1"==n2[31-s_expr[2]]){n4="11111111111111111111111111111111".substring(0,32-n3.length)+n4}var n5=parseInt(n4,2);return"Sign Extension with value "+show_value(n5)+". "}};sim.rv.behaviors["MOVE_BITS"]={nparameters:5,types:["S","I","I","S"],operation:function(s_expr){var posd=parseInt(s_expr[2]);var poso=0;var len=parseInt(s_expr[3]);var n1=sim.rv.signals[s_expr[4]].value.toString(2);n1="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n1=n1.substr(31-poso-len+1,len);var n2=sim.rv.signals[s_expr[1]].value.toString(2);n2="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var m1=n2.substr(0,32-(posd+len));var m2=n2.substr(31-posd+1,posd);var n3=m1+n1+m2;set_value(sim.rv.signals[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){return""}};sim.rv.behaviors["MOVE_BITSE"]={nparameters:6,types:["S","I","I","E","I"],operation:function(s_expr){var posd=parseInt(s_expr[2]);var poso=parseInt(s_expr[5]);var len=parseInt(s_expr[3]);var n1=get_value(sim.rv.states[s_expr[4]]).toString(2);n1="00000000000000000000000000000000".substring(0,32-n1.length)+n1;n1=n1.substr(31-poso-len+1,len);var n2=sim.rv.signals[s_expr[1]].value.toString(2);n2="00000000000000000000000000000000".substring(0,32-n2.length)+n2;var m1=n2.substr(0,32-(posd+len));var m2=n2.substr(31-posd+1,posd);var n3=m1+n1+m2;set_value(sim.rv.signals[s_expr[1]],parseInt(n3,2))},verbal:function(s_expr){return""}};sim.rv.behaviors["READ_IM"]={nparameters:1,operation:function(s_expr){var address=get_value(sim.rv.states["REG_PC"]);var clk=get_value(sim.rv.states["CLK"]);var remain=get_value(sim.rv.internal_states.MP_wc);if(typeof sim.rv.events.mem[clk-1]!="undefined"&&sim.rv.events.mem[clk-1]>0){remain=sim.rv.events.mem[clk-1]-1}var first_time=typeof sim.rv.events.mem[clk]=="undefined";sim.rv.events.mem[clk]=remain;if(remain>0){return}address=address&4294967292;var value=main_memory_getvalue(sim.rv.internal_states.MP,address);var full_redraw=false;if(typeof value==="undefined"){value=0;full_redraw=true}show_main_memory(sim.rv.internal_states.MP,address,full_redraw,false);if(first_time&&sim.rv.internal_states.CM.length>0){cache_memory_access(sim.rv.internal_states.CM[0],address,"read",clk)}var ins=main_memory_getvalue(sim.rv.internal_states.MP,address);if(typeof ins==="undefined")ins=0;set_value(sim.rv.states["RDATA"],ins)},verbal:function(s_expr){var verbal="";var address=get_value(sim.rv.states["REG_PC"]);var value=main_memory_getvalue(sim.rv.internal_states.MP,address);if(typeof value==="undefined")value=0;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){verbal="Try to read an instruction from Instruction Memory "+"at address 0x"+address.toString(16)+" with value 0x"+value.toString(16)+". ";return verbal}verbal="Memory output = 0x"+value.toString(16)+" (Read an instruction from Instruction Memory"+" at address 0x"+address.toString(16)+"). ";return verbal}};sim.rv.behaviors["DECO"]={nparameters:1,operation:function(s_expr){sim.rv.states["INEX"].value=0;var oi=decode_instruction(sim.rv.internal_states.FIRMWARE,sim.rv.ctrl_states.ir,get_value(sim.rv.states["REG_IR"]));if(null==oi.oinstruction){if(oi.cop_code!==undefined){ws_alert("ERROR: undefined instruction code in IR ("+"co:"+oi.op_code.toString(2)+", "+"cop:"+oi.cop_code.toString(2)+")")}else if(oi.eoc!==undefined){ws_alert("ERROR: undefined instruction code in IR ("+"co:"+oi.op_code.toString(2)+", "+"eoc:"+oi.eoc.toString(2)+")")}sim.rv.states["ROM_MUXA"].value=0;sim.rv.states["INEX"].value=1;return-1}var rom_addr=oi.op_code<<6;if(oi.oinstruction.cop!==undefined){rom_addr=rom_addr+oi.cop_code}else if(oi.oinstruction.eoc!==undefined){rom_addr=rom_addr+oi.eoc}if(typeof sim.rv.internal_states["ROM"][rom_addr]=="undefined"){ws_alert("ERROR: undefined rom address "+rom_addr+" in firmware");sim.rv.states["ROM_MUXA"].value=0;return-1}sim.rv.states["ROM_MUXA"].value=sim.rv.internal_states["ROM"][rom_addr];var val=get_value(sim.rv.states["DECO_INS"]);set_value(sim.rv.states["DECO_INS"],val+1);var pc=get_value(sim.rv.states["REG_PC"])-4;var decins=get_deco_from_pc(pc);set_value(sim.rv.states["REG_IR_DECO"],decins);show_dbg_ir(get_value(sim.rv.states["REG_IR_DECO"]))},verbal:function(s_expr){return"Decode instruction. "}};sim.rv.behaviors["FIRE"]={nparameters:2,types:["S"],operation:function(s_expr){if(sim.rv.internal_states.fire_stack.indexOf(s_expr[1])!=-1){return}sim.rv.internal_states.fire_stack.push(s_expr[1]);update_draw(sim.rv.signals[s_expr[1]],sim.rv.signals[s_expr[1]].value);if("L"==sim.rv.signals[s_expr[1]].type){update_state(s_expr[1])}sim.rv.internal_states.fire_stack.pop(s_expr[1])},verbal:function(s_expr){return""}};sim.rv.behaviors["FIRE_IFSET"]={nparameters:3,types:["S","I"],operation:function(s_expr){if(get_value(sim.rv.signals[s_expr[1]])!=parseInt(s_expr[2])){return}sim.rv.behaviors["FIRE"].operation(s_expr)},verbal:function(s_expr){return""}};sim.rv.behaviors["FIRE_IFCHANGED"]={nparameters:3,types:["S","X"],operation:function(s_expr){sim_elto=get_reference(s_expr[2]);if(sim_elto.changed==false){return}sim.rv.behaviors["FIRE"].operation(s_expr)},verbal:function(s_expr){return""}};sim.rv.behaviors["RESET_CHANGED"]={nparameters:2,types:["X"],operation:function(s_expr){sim_elto=get_reference(s_expr[1]);sim_elto.changed=false},verbal:function(s_expr){return""}};sim.rv.behaviors["CLOCK"]={nparameters:1,operation:function(s_expr){var new_maddr=null;var mcelto=null;var t0=performance.now();var val=get_value(sim.rv.states["CLK"]);set_value(sim.rv.states["CLK"],val+1);set_value(sim.rv.states["TTCPU"],0);new_maddr=get_value(sim.rv.states["REG_MICROADDR"]);mcelto=sim.rv.internal_states["MC"][new_maddr];if(typeof mcelto!=="undefined"&&false==mcelto.is_native){for(var i=0;i>>0},set_value:function(elto,value){var origin="";var r_value=main_memory_get_program_counter();if(r_value!=null){origin="PC=0x"+r_value.toString(16)}var melto={value:value>>>0,source_tracking:[origin],comments:null};var valref=main_memory_set(sim.rv.internal_states.MP,elto,melto);show_main_memory(sim.rv.internal_states.MP,elto,typeof valref==="undefined",true);return value}};sim.rv.internal_states.segments={};sim.rv.internal_states.MP_wc=0;sim.rv.internal_states.MP={};sim.rv.internal_states.CM_cfg=[];sim.rv.internal_states.CM=[];sim.rv.behaviors.MEM_READ={nparameters:5,types:["E","E","S","E"],operation:function(s_expr){var address="0x"+get_value(sim.rv.states[s_expr[1]]).toString(16);var dbvalue=get_value(sim.rv.states[s_expr[2]]);var bw=sim.rv.signals[s_expr[3]].value;var clk=get_value(sim.rv.states[s_expr[4]]);var remain=get_value(sim.rv.internal_states.MP_wc);if(typeof sim.rv.events.mem[clk-1]!="undefined"&&sim.rv.events.mem[clk-1]>0){remain=sim.rv.events.mem[clk-1]-1}var first_time=typeof sim.rv.events.mem[clk]=="undefined";sim.rv.events.mem[clk]=remain;if(remain>0){return}address=address&4294967292;var value=main_memory_getvalue(sim.rv.internal_states.MP,address);var full_redraw=false;if(typeof value==="undefined"){value=0;full_redraw=true}if(bw==1){var byte_s=0;dbvalue=main_memory_fusionvalues(dbvalue,value,byte_s)}else if(bw==2){var byte_s=4;dbvalue=main_memory_fusionvalues(dbvalue,value,byte_s)}else{dbvalue=value}set_value(sim.rv.states[s_expr[2]],dbvalue>>>0);show_main_memory(sim.rv.internal_states.MP,address,full_redraw,false);if(first_time&&sim.rv.internal_states.CM.length>0){cache_memory_access(sim.rv.internal_states.CM[0],address,"read",clk)}},verbal:function(s_expr){var verbal="";var address="0x"+get_value(sim.rv.states[s_expr[1]]).toString(16);var dbvalue=get_value(sim.rv.states[s_expr[2]]);var bw=sim.rv.signals[s_expr[3]].value;var clk=get_value(sim.rv.states[s_expr[4]]);var bw_type="word";if(bw==1)bw_type="byte";else if(bw==2)bw_type="half";var value=main_memory_getvalue(sim.rv.internal_states.MP,address);if(typeof value==="undefined")value=0;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){verbal="Try to read a "+bw_type+" from memory "+"at address "+address+" with value 0x"+value.toString(16)+". "}verbal="Memory output = 0x"+value.toString(16)+" (Read a "+bw_type+" from "+address+"). ";return verbal}};sim.rv.behaviors.MEM_WRITE={nparameters:5,types:["E","E","S","E"],operation:function(s_expr){var address="0x"+get_value(sim.rv.states[s_expr[1]]).toString(16);var dbvalue=get_value(sim.rv.states[s_expr[2]]);var bw=sim.rv.signals[s_expr[3]].value;var clk=get_value(sim.rv.states[s_expr[4]]);var remain=get_value(sim.rv.internal_states.MP_wc);if(typeof sim.rv.events.mem[clk-1]!="undefined"&&sim.rv.events.mem[clk-1]>0){remain=sim.rv.events.mem[clk-1]-1}var first_time=typeof sim.rv.events.mem[clk]=="undefined";sim.rv.events.mem[clk]=remain;if(remain>0){return}address=address&4294967292;var value=main_memory_getvalue(sim.rv.internal_states.MP,address);var full_redraw=false;if(typeof value==="undefined"){value=0;full_redraw=true}if(bw==1){var byte_s=0;value=main_memory_fusionvalues(value,dbvalue,byte_s)}else if(bw==2){var byte_s=4;value=main_memory_fusionvalues(value,dbvalue,byte_s)}else{var byte_s=12;value=main_memory_fusionvalues(value,dbvalue,byte_s)}var origin="";var r_value=main_memory_get_program_counter();if(r_value!=null){origin="PC=0x"+r_value.toString(16)}var melto={value:value>>>0,source_tracking:[origin],comments:null};var valref=main_memory_set(sim.rv.internal_states.MP,address,melto);show_main_memory(sim.rv.internal_states.MP,address,full_redraw,true);if(first_time&&sim.rv.internal_states.CM.length>0){cache_memory_access(sim.rv.internal_states.CM[0],address,"write",clk)}},verbal:function(s_expr){var verbal="";var address="0x"+get_value(sim.rv.states[s_expr[1]]).toString(16);var dbvalue=get_value(sim.rv.states[s_expr[2]]);var bw=sim.rv.signals[s_expr[3]].value;var clk=get_value(sim.rv.states[s_expr[4]]);var bw_type="word";if(bw==1)bw_type="byte";else if(bw==2)bw_type="half";var value=main_memory_getvalue(sim.rv.internal_states.MP,address);if(typeof value==="undefined")value=0;var verbose=get_cfg("verbal_verbose");if(verbose!=="math"){verbal="Try to write a "+bw_type+" to memory "+"at address "+address+" with value "+value.toString(16)+". "}verbal="Memory["+address+"] = "+"0x"+value.toString(16)+" (Write a "+bw_type+" to "+address+"). ";return verbal}};sim.rv.behaviors.MEMORY_RESET={nparameters:1,operation:function(s_expr){sim.rv.events.mem={}},verbal:function(s_expr){return"Reset main memory (all values will be zeroes). "}};sim.rv.elements.memory={name:"Main memory",description:"Main memory subsystem",type:"subcomponent",belongs:"MEMORY",states:{addr:{ref:"M3_ALU"},wdata:{ref:"REG_OUT"},rdata:{ref:"DM_BS"}},signals:{wbe:{ref:"WBE"},dmr:{ref:"DMR"},dmw:{ref:"DMW"}},states_inputs:["addr","wdata"],states_outputs:["rdata"],signals_inputs:["wbe","dmr","dmw"],signals_output:[]};function frm_nextToken(context){var tok="";var first="";var last="";var token_type="";while("# \t\n\r".indexOf(context.text[context.t])!=-1&&context.t0)line2=context.newlines[context.newlines.length-1]+1;var line1=0;if(context.newlines.length>1)line1=context.newlines[context.newlines.length-2]+1;var lowI=line1;var highI=Math.min(context.t-1,line2+32);for(;typeof context.text[highI+1]!="undefined"&&context.text[highI+1]!="\n";highI++);var line3=highI+2;highI++;for(;typeof context.text[highI+1]!="undefined"&&context.text[highI+1]!="\n";highI++);highI++;context.error="
"+""+"...\n";for(var i=lowI;i"+"(*) "+i18n_get_TagFor("compiler","PROBLEM AROUND LINE")+" "+context.line+":
"+msgError+".
";simcore_ga("compile","compile.error","compile.error."+msgError);return context}function frm_getLabelContext(context){return{t:context.t,line:context.line,newlines:context.newlines.slice()}}function frm_setLabelContext(context,labelContext){context.t=labelContext.t;context.line=labelContext.line;context.newlines=labelContext.newlines}function frm_getComments(context){return context.comments.join("\n")}function frm_resetComments(context){context.comments=[]}function frm_nextNative(context){var first=context.t;var last=context.t;var braces=1;while(context.t=Math.pow(2,simhw_sim_signal(nombre_tok).nbits)){return frm_langError(context,i18n_get_TagFor("compiler","OUT OF RANGE")+"'"+frm_getToken(context)+"'")}frm_nextToken(context)}if(frm_isToken(context,",")){frm_nextToken(context)}}var acc_cmt=frm_getComments(context);microcomments.push(acc_cmt);frm_resetComments(context);microprograma.push(microInstruccionAux);context.contadorMC++;frm_nextToken(context);if(frm_isToken(context,","))frm_nextToken(context)}if(microprograma.length===0){return frm_langError(context,i18n_get_TagFor("compiler","EMPTY MICROCODE"))}frm_nextToken(context);return{NATIVE:"",microprograma:microprograma,microcomments:microcomments}}function read_native(context){var microprograma=[];var microcomments=[];if(!frm_isToken(context,"{")){return frm_langError(context,i18n_get_TagFor("compiler","OPEN BRACE NOT FOUND"))}frm_nextNative(context);var native_code=frm_getToken(context);microprograma.push({});microcomments.push("");frm_nextToken(context);return{NATIVE:native_code,microprograma:microprograma,microcomments:microcomments}}function firm_begin_read(context){var instruccionAux={};instruccionAux.name=frm_getToken(context);instruccionAux["mc-start"]=context.contadorMC;instruccionAux["is_native"]=false;frm_nextToken(context);if(frm_isToken(context,",")){frm_nextToken(context)}if(frm_isToken(context,"native")){instruccionAux["is_native"]=true;frm_nextToken(context);if(frm_isToken(context,",")){frm_nextToken(context)}context.etiquetas[context.contadorMC]="fetch"}if(true==instruccionAux.is_native)ret=read_native(context);else ret=firm_mcode_signals_read(context);if(typeof ret.error!="undefined"){return ret}instruccionAux.signature="begin";instruccionAux.signatureGlobal="begin";instruccionAux.signatureUser="begin";instruccionAux.signatureRaw="begin";instruccionAux.NATIVE=ret.NATIVE;instruccionAux.microcode=ret.microprograma;instruccionAux.microcomments=ret.microcomments;context.instrucciones.push(instruccionAux);context.contadorMC=context.contadorMC+9;return{}}function firm_pseudoinstructions_read(context){frm_nextToken(context);if(!frm_isToken(context,"{")){return frm_langError(context,i18n_get_TagFor("compiler","OPEN BRACE NOT FOUND"))}frm_nextToken(context);while(!frm_isToken(context,"}")){var pseudoInstructionAux={};var pseudoInitial={};pseudoInitial.signature="";pseudoInitial.name="";pseudoInitial.fields=[];pseudoInitial.name=frm_getToken(context);pseudoInitial.signature=pseudoInitial.signature+frm_getToken(context)+",";frm_nextToken(context);while(!frm_isToken(context,"{")){var pseudoFieldAux={};pseudoFieldAux.name="";pseudoFieldAux.type="";pseudoFieldAux.indirect=false;if(frm_isToken(context,"(")){frm_nextToken(context);pseudoFieldAux.name+=frm_getToken(context);frm_nextToken(context);if(!frm_isToken(context,")")){return frm_langError(context,i18n_get_TagFor("compiler","CLOSE PAREN. NOT FOUND"))}frm_nextToken(context);pseudoFieldAux.indirect=true}else{pseudoFieldAux.name+=frm_getToken(context);frm_nextToken(context)}if(!frm_isToken(context,"=")){return frm_langError(context,i18n_get_TagFor("compiler","EQUAL NOT FOUND")+" (for name=type)")}frm_nextToken(context);pseudoFieldAux.type+=frm_getToken(context).replace("num","inm");switch(pseudoFieldAux.type){case"reg":case"inm":case"addr":case"address":break;default:return frm_langError(context,i18n_get_TagFor("compiler","INVALID PARAMETER")+pseudoFieldAux.type+"."+i18n_get_TagFor("compiler","ALLOWED PARAMETER"))}pseudoInitial.fields.push(pseudoFieldAux);if(pseudoFieldAux.indirect==true)pseudoInitial.signature+="("+frm_getToken(context)+"),";else pseudoInitial.signature+=frm_getToken(context)+",";frm_nextToken(context);if(frm_isToken(context,",")){frm_nextToken(context)}}frm_nextToken(context);pseudoInitial.signature=pseudoInitial.signature.substr(0,pseudoInitial.signature.length-1).replace(/num/g,"inm");pseudoInstructionAux.initial=pseudoInitial;var contPseudoFinish=0;var pseudoFinishAux={};pseudoFinishAux.signature="";var inStart=0;var cont=false;while(!frm_isToken(context,"}")){if(inStart==0){for(i=0;i32*parseInt(instruccionAux.nwords)-1){return frm_langError(context,i18n_get_TagFor("compiler","STARTBIT OoR")+"'"+frm_getToken(context)+"'")}frm_nextToken(context);if(!frm_isToken(context,",")){return frm_langError(context,i18n_get_TagFor("compiler","COMMA NOT FOUND"))}frm_nextToken(context);instruccionAux.fields[camposInsertados].stopbit=frm_getToken(context);var stop=parseInt(instruccionAux.fields[camposInsertados].stopbit);if(stop>32*parseInt(instruccionAux.nwords)){return frm_langError(context,i18n_get_TagFor("compiler","STOPBIT OoR")+"'"+frm_getToken(context)+"'")}for(i=stop;i<=start;i++){if(typeof instruccionAux.overlapping[i]!="undefined"){return frm_langError(context,i18n_get_TagFor("compiler","OVERLAPPING FIELD")+instruccionAux.fields[camposInsertados].name)}instruccionAux.overlapping[i]=1}frm_nextToken(context);if(!frm_isToken(context,")")){return frm_langError(context,i18n_get_TagFor("compiler","CLOSE PAREN. NOT FOUND"))}frm_nextToken(context);if(instruccionAux.fields[camposInsertados].type=="address"){if(frm_getToken(context)!="abs"&&frm_getToken(context)!="rel"){return frm_langError(context,i18n_get_TagFor("compiler","INCORRECT ADDRESSING"))}instruccionAux.fields[camposInsertados].address_type=frm_getToken(context);frm_nextToken(context)}if(frm_isToken(context,",")){frm_nextToken(context)}return{}}function firm_instruction_read_fixed_fields(context,instruccionAux,xr_info,all_ones_co){var ret={};frm_nextToken(context);if(!frm_isToken(context,"co")){return frm_langError(context,i18n_get_TagFor("compiler","NO CO FIELD"))}ret=firm_instruction_co_read(context,instruccionAux,xr_info,all_ones_co);if(typeof ret.error!="undefined"){return ret}if(frm_isToken(context,"cop")){ret=firm_instruction_cop_read(context,instruccionAux);if(typeof ret.error!="undefined"){return ret}}if(frm_isToken(context,"nwords")){ret=firm_instruction_nword_read(context,instruccionAux);if(typeof ret.error!="undefined"){return ret}}var campos=instruccionAux.fields;var firma=instruccionAux.signature;var firmaUsuario=instruccionAux.signatureUser;var firmaGlobal=instruccionAux.signatureGlobal;var camposInsertados=0;while(camposInsertados32*parseInt(instruccionAux.nwords)-1){return frm_langError(context,i18n_get_TagFor("compiler","STARTBIT OoR")+"'"+frm_getToken(context)+"'")}frm_nextToken(context);if(!frm_isToken(context,":")){return frm_langError(context,i18n_get_TagFor("compiler","COLON NOT FOUND"))}frm_nextToken(context);tmp_fields.stopbit=frm_getToken(context);var stop=parseInt(tmp_fields.stopbit);if(stop>32*parseInt(instruccionAux.nwords)){return frm_langError(context,i18n_get_TagFor("compiler","STOPBIT OoR")+"'"+frm_getToken(context)+"'")}frm_nextToken(context);if(!frm_isToken(context,")")){return frm_langError(context,i18n_get_TagFor("compiler","CLOSE PAREN. NOT FOUND"))}}else{frm_nextToken(context);if(!frm_isToken(context,"(")){return frm_langError(context,i18n_get_TagFor("compiler","OPEN PAREN. NOT FOUND"))}frm_nextToken(context);var start=frm_getToken(context);var stop=start;if(start>32*parseInt(instruccionAux.nwords)-1){return frm_langError(context,i18n_get_TagFor("compiler","STARTBIT OoR")+"'"+frm_getToken(context)+"'")}frm_nextToken(context);if(frm_isToken(context,":")){frm_nextToken(context);stop=frm_getToken(context);if(stop>32*parseInt(instruccionAux.nwords)){return frm_langError(context,i18n_get_TagFor("compiler","STOPBIT OoR")+"'"+frm_getToken(context)+"'")}frm_nextToken(context);if(frm_isToken(context,")")){tmp_fields.startbit=start;tmp_fields.stopbit=stop}}if(frm_isToken(context,"|")){var bits=[[start,stop]];var bits_aux=[];while(!frm_isToken(context,")")){frm_nextToken(context);if(frm_getToken(context)==")")continue;bits_aux[0]=frm_getToken(context);if(bits_aux[0]>32*parseInt(instruccionAux.nwords)){return frm_langError(context,i18n_get_TagFor("compiler","BIT OoR")+"'"+frm_getToken(context)+"'")}frm_nextToken(context);if(frm_getToken(context)==")"){bits.push([bits_aux[0],bits_aux[0]]);continue}if(!frm_isToken(context,":")&&!frm_isToken(context,"|")){return frm_langError(context,i18n_get_TagFor("compiler","COLON OR PIPE NOT FOUND"))}if(frm_isToken(context,":")){frm_nextToken(context);bits_aux[1]=frm_getToken(context);frm_nextToken(context)}else if(frm_isToken(context,"|")){bits_aux[1]=bits_aux[0]}if(bits_aux[1]>32*parseInt(instruccionAux.nwords)){return frm_langError(context,i18n_get_TagFor("compiler","BIT OoR")+"'"+frm_getToken(context)+"'")}bits.push([bits_aux[0],bits_aux[1]])}var total_bits=0;for(i=0;i100){return frm_langError(context,i18n_get_TagFor("compiler","MORE 100 FIELDS"))}if(auxValue=="co"){return frm_langError(context,i18n_get_TagFor("compiler","CO AS FIELD NAME"))}if(auxValue=="nwords"){return frm_langError(context,i18n_get_TagFor("compiler","NW AS FIELD NAME"))}}if(frm_isToken(context,"(")){firma=firma+",(";if(plus_found)firmaUsuario=firmaUsuario+"+(";else firmaUsuario=firmaUsuario+" (";frm_nextToken(context);if(!frm_isToken(context,",")&&!frm_isToken(context,"(")&&!frm_isToken(context,")")){var campoAux={};campoAux.name=frm_getToken(context);instruccionAux.fields.push(campoAux);instruccionAux.numeroCampos++;firma=firma+frm_getToken(context);firmaUsuario=firmaUsuario+frm_getToken(context);frm_nextToken(context)}else{return frm_langError(context,i18n_get_TagFor("compiler","MISSING TOKEN ON")+"'"+context.co_cop[instruccionAux.co].signature+"'")}if(frm_isToken(context,")")){firma=firma+")";firmaUsuario=firmaUsuario+")";frm_nextToken(context)}else{return frm_langError(context,i18n_get_TagFor("compiler","MISSING ) ON")+"'"+context.co_cop[instruccionAux.co].signature+"'")}}firma=firma+",";firmaUsuario=firmaUsuario+" "}firma=firma.substr(0,firma.length-1);firma=firma.replace(/,,/g,",");firmaUsuario=firmaUsuario.substr(0,firmaUsuario.length-1);firmaUsuario=firmaUsuario.replace(/ /g," ");instruccionAux.signature=firma;instruccionAux.signatureGlobal=firma;instruccionAux.signatureUser=firmaUsuario;instruccionAux.signatureRaw=firmaUsuario;if(2==context.version){ret=firm_instruction_read_fields_v2(context,instruccionAux,xr_info,all_ones_oc)}else{ret=firm_instruction_read_fixed_fields(context,instruccionAux,xr_info,all_ones_co)}if(typeof ret.error!="undefined"){return ret}ret={};if(true==instruccionAux.is_native)ret=read_native(context);else ret=firm_mcode_signals_read(context);if(typeof ret.error!="undefined")return ret;instruccionAux.NATIVE=ret.NATIVE;instruccionAux.microcode=ret.microprograma;instruccionAux.microcomments=ret.microcomments;context.instrucciones.push(instruccionAux);context.contadorMC=context.contadorMC+9;if(!frm_isToken(context,"}")){return frm_langError(context,i18n_get_TagFor("compiler","CLOSE BRACE NOT FOUND"))}frm_nextToken(context);return{}}function simlang_native_adapt_replaceSyscall(icode){var rc="";var me="";var ff="capi_print_char|capi_print_int|capi_print_float|capi_print_double|capi_print_string|"+"capi_read_char|capi_read_int|capi_read_float|capi_read_double|capi_read_string|"+"capi_sbrk|capi_exit";var re=new RegExp("("+ff+")\\(([^)]*)\\)","g");var match=re.exec(icode);while(match!==null){var f=match[1].trim();var p=match[2].trim().split(",");switch(f){case"capi_print_char":rc="// "+f+" \n"+"\tvar tmp1 = 0x000000FF & "+p[0]+" ;\n"+"\tset_screen_content(tmp1.toString()) ;\n";break;case"capi_print_int":rc="// "+f+" \n"+"\tset_screen_content("+p[0]+".toString()) ;\n";break;case"capi_print_float":rc="// "+f+" \n"+"\tvar tmp1 = hex2float("+p[0]+") ;\n"+"\tset_screen_content(tmp1.toString()) ;\n";break;case"capi_print_double":rc="// "+f+" \n"+"\tvar tmp1 = hex2float("+p[0]+") ;\n"+"\tset_screen_content(tmp1.toString()) ;\n";break;case"capi_print_string":rc="// "+f+" \n"+'\tvar tmp1 = "" ;\n'+'\tvar tmp2 = simcore_native_get_value("MEMORY", '+p[0]+") ;\n"+"\tfor (var k="+p[0]+"+1; (tmp2 !== 0) && (k<8*1024); k++) {\n"+"\t tmp1 += tmp2.toString() ;\n"+'\t tmp2 = simcore_native_get_value("MEMORY", k) ;\n'+"\t} ;\n"+"\tset_screen_content(tmp1) ;\n";break;case"capi_read_char":rc="// "+f+" \n"+"\tvar tmp1 = get_screen_content() ;\n"+"\tvar "+p[0]+" = 0x000000FF & parseInt(tmp1) ;\n";break;case"capi_read_int":rc="// "+f+" \n"+"\tvar tmp1 = get_screen_content() ;\n"+"\tvar "+p[0]+" = parseInt(tmp1) ;\n";break;case"capi_read_float":rc="// "+f+" \n"+"\tvar tmp1 = get_screen_content() ;\n"+"\tvar "+p[0]+" = parseFloat(tmp1) ;\n";break;case"capi_read_double":rc="// "+f+" \n"+"\tvar tmp1 = get_screen_content() ;\n"+"\tvar "+p[0]+" = parseFloat(tmp1) ;\n";break;case"capi_read_string":rc="// "+f+" \n"+"\tvar tmp1 = get_screen_content() ;\n"+"\tfor (var k=0; k<"+p[1]+"; k++) {\n"+'\t simcore_native_set_value("MEMORY", '+p[0]+"+k, tmp1[k]) ;\n"+"\t} ;\n";break;case"capi_sbrk":rc="// "+f+" \n"+"// TODO: _sbrk_("+p[0]+", "+p[1]+");\n";break;case"capi_exit":rc="// "+f+" \n"+"// exit by setting P.C. register outside text segment\n"+"\tvar pc_name = simhw_sim_ctrlStates_get().pc.state ;\n"+'\tsimcore_native_set_value("CPU", pc_name, 0x00000000) ;\n';break;default:rc="// "+f+" \n"+"// unknown syscall\n";break}me=new RegExp(f+"\\(([^)]*)\\)","g");icode=icode.replace(me,rc);match=re.exec(icode)}return icode}function simlang_native_adapt_provideRegister(icode,reg_log,rf_phy,reg_phy){var re=new RegExp(reg_log,"g");if(icode.search(re)!=-1){icode="var "+reg_log+" = simcore_native_get_value('"+rf_phy+"', "+reg_phy+") ;\n"+icode+"\n"+"simcore_native_set_value('"+rf_phy+"', "+reg_phy+", "+reg_log+") ;\n"}return icode}function simlang_native_adapt_providePC(icode){var re=/PC/g;if(icode.search(re)!=-1){icode="var pc_name = simhw_sim_ctrlStates_get().pc.state ;\n"+"var PC = simcore_native_get_value('CPU', pc_name) ;\n"+icode+"simcore_native_set_value('CPU', pc_name, PC) ;\n"}return icode}function simlang_native_adapt_replaceIf(icode){var re=new RegExp("[iI][fF]\\s*\\(([^\\\\)]*)\\)\\s*{([^\\\\}]*)}\\s*[eE][lL][sS][eE]{[^}]*}\\s*","g");if(icode.search(re)!=-1){var match=re.exec(icode);try{icode=icode.replace(re,"\n")}catch(e){console.log("Syntax error that cause a run-time error: "+e.toString());console.log(match)}}return icode}function simlang_native_adapt_addInitialTabTab(lines_code){var code_lines;code_lines=lines_code.split("\n");code_lines=code_lines.map((function(x){return"\t\t"+x}));return code_lines.join("\n")}function simlang_native_adapt_instructionDefinition(lines_code){var code_lines=lines_code.split(";");if(code_lines.length===1&&!lines_code.trim().startsWith("if")){lines_code=lines_code+";\n"}lines_code=simlang_native_adapt_replaceSyscall(lines_code);lines_code=simlang_native_adapt_provideRegister(lines_code,"HI","CPU","'REG_RT2'");lines_code=simlang_native_adapt_provideRegister(lines_code,"LO","CPU","'REG_RT1'");lines_code=simlang_native_adapt_provideRegister(lines_code,"ra","BR","31");lines_code=simlang_native_adapt_providePC(lines_code);lines_code=simlang_native_adapt_addInitialTabTab(lines_code);return lines_code}function simlang_native_adapt_getField(j,rf,reg){return"\t\t"+"var f_"+reg+" = "+"simcore_native_get_field_from_ir(fields, "+j+") ;\n"+"\t\t"+"var "+reg+" = "+"simcore_native_get_value('"+rf+"', f_"+reg+") ;\n"}function simlang_native_adapt_setField(j,rf,reg){return"\t\t"+"simcore_native_set_value('"+rf+"', f_"+reg+", "+reg+");\n"}function simlang_native_adapt_headerField(fname,tname,start,stop){return"\t"+tname+"("+start+":"+stop+")="+fname+",\n"}function simlang_native_beginMicrocode(){var o="";o+="\n"+"#\n"+"# WepSIM (https://wepsim.github.io/wepsim/)\n"+"#\n"+"\n"+"firmware_version = 2\n"+"\n"+"##\n"+"## Microcode Section\n"+"##\n"+"\n"+"begin,\n"+"native\n"+"{\n"+" // (once) initialize BR2 as FP register file\n"+' if (typeof BR2 === "undefined")\n'+" {\n"+" BR2 = [] ;\n"+" FCSR = 0 ;\n"+" for (var i=0; i<32; i++)\n"+" {\n"+" BR2[i] = {\n"+' name:"R"+i,\n'+' verbal:"Register "+i,\n'+" visible:true,\n"+' nbits:"32",\n'+" value:0,\n"+" default_value:0,\n"+" draw_data:[]\n"+" } ;\n"+" }\n"+" }\n"+"\n"+" // fetch\n"+' var addr = simcore_native_get_value("CPU", "REG_PC") ;\n'+' var value = simcore_native_get_value("MEMORY", addr) ;\n'+"\n"+' simcore_native_set_value("CPU", "REG_IR", value) ;\n'+' simcore_native_set_value("CPU", "REG_PC", addr + 4) ;\n'+"\n"+" simcore_native_deco() ;\n"+" simcore_native_go_opcode() ;\n"+"}\n";return o}function simlang_native_adapt_instructionSet(instruction_list){var o="";var gfields=[];var sfields=[];var hfields=[];var io={};var line_signature="";var signature_names="";var signature_order="";for(var i=0;i> 32);\n"+"\t\t "+io.fields[j].name+"2 = "+io.fields[j].name+" >> 32;\n"+"\t\t"+"simcore_native_set_value('BR2', "+"f_"+io.fields[j].name+"+0, "+io.fields[j].name+"1);\n"+"\t\t"+"simcore_native_set_value('BR2', "+"f_"+io.fields[j].name+"+1, "+io.fields[j].name+"2);\n";break;case"inm":hfields[k]=simlang_native_adapt_headerField(io.fields[j].name,"inm",io.fields[j].startbit,io.fields[j].stopbit);gfields[k]="\t\t"+"var "+io.fields[j].name+" = "+"simcore_native_get_field_from_ir(fields, "+(k-1)+") ;\n\t";break}}var co_cop="\t"+"co=111111,"+"\n";var lines_code=simlang_native_adapt_instructionDefinition(io.definition);if(lines_code.trim()!==""){lines_code="\t\t"+"// instruction specific code"+"\n"+lines_code+"\n"}var gfields_str=gfields.join("");if(gfields_str.trim()!==""){gfields_str="\t\t"+"// get fields values..."+"\n"+gfields_str+"\n"}var sfields_str=sfields.join("");if(sfields_str.trim()!==""){sfields_str="\t\t"+"// set fields values..."+"\n"+sfields_str+"\n"}o+="\n"+line_signature+" {"+"\n"+co_cop+"\t"+"nwords="+io.nwords+","+"\n"+hfields.join("")+"\t"+"native,"+"\n"+"\t"+"{\n"+gfields_str+"\n"+lines_code+"\n"+sfields_str+"\n"+"\t\t"+"// go fetch"+"\n"+"\t\t"+"simcore_native_go_maddr(0);"+"\n"+"\t"+"}"+"\n"+"}\n"}return o}function simlang_native_registerSection(register_list){var o="";var d="";var index=0;for(index=0;index=last_oc){return frm_langError(context,i18n_get_TagFor("compiler","NO OC CODES"))}first_oc=parseInt(r.label_oc,2);curr_instruction.oc=r.label_oc;context.oc_eoc[r.label_oc].signature=curr_instruction.signature;if(r.label_eoc!==""){curr_instruction.eoc=r.label_eoc;context.oc_eoc[r.label_oc].eoc[r.label_eoc]=curr_instruction.signature;context.oc_eoc[r.label_oc].witheoc=true}}}else{var ir_co_length=6;if(typeof ir_info!=="undefined"){ir_co_length=ir_info.ir.default_eltos.co.length}var first_co=0;var last_co=Math.pow(2,ir_co_length)-1;var last_co_str=last_co.toString(2);var curr_instruction=null;for(i=0;i=last_co){return frm_langError(context,i18n_get_TagFor("compiler","NO CO CODES"))}first_co=parseInt(r.label_co,2);curr_instruction.co=r.label_co;context.co_cop[r.label_co].signature=curr_instruction.signature;if(r.label_cop!==""){curr_instruction.cop=r.label_cop;context.co_cop[r.label_co].cop[r.label_cop]=curr_instruction.signature;context.co_cop[r.label_co].withcop=true}}}var labelsFounded=0;if(context.labelsNotFound.length>0){for(i=0;i0){for(var j=0;j0){file+="registers"+"\n{\n";for(i=0;i=context.text.length}function asm_nextToken(context){var tok="";var first="";var last="";var token_type="";while("# \t\n\r".indexOf(context.text[context.t])!=-1&&context.t0)line2=context.newlines[context.newlines.length-1]+1;var line1=0;if(context.newlines.length>1)line1=context.newlines[context.newlines.length-2]+1;var lowI=line1;var highI=Math.min(context.t-1,line2+32);for(;typeof context.text[highI+1]!="undefined"&&context.text[highI+1]!="\n";highI++);var line3=highI+2;highI++;for(;typeof context.text[highI+1]!="undefined"&&context.text[highI+1]!="\n";highI++);highI++;context.error="
"+""+"...\n";for(var i=lowI;i"+"(*) "+i18n_get_TagFor("compiler","PROBLEM AROUND LINE")+" "+context.line+":
"+msgError+".
";simcore_ga("compile","compile.error","compile.error."+msgError);return context}function asm_getLabelContext(context){return{t:context.t,line:context.line,newlines:context.newlines.slice()}}function asm_setLabelContext(context,labelContext){context.t=labelContext.t;context.line=labelContext.line;context.newlines=labelContext.newlines}function asm_getComments(context){return context.comments.join("\n")}function asm_resetComments(context){context.comments=[]}sim_segments={".kdata":{name:".kdata",begin:0,end:255,color:"#FF99CC",kindof:"data"},".ktext":{name:".ktext",begin:256,end:4095,color:"#A9D0F5",kindof:"text"},".data":{name:".data",begin:4096,end:32767,color:"#FACC2E",kindof:"data"},".text":{name:".text",begin:32768,end:131071,color:"#BEF781",kindof:"text"},".stack":{name:".stack",begin:131071,end:1048576,color:"#F1F2A3",kindof:"stack"}};function segments_addr_within_text(address){return address>=sim_segments[".text"].begin&&address<=sim_segments[".text"].end||address>=sim_segments[".ktext"].begin&&address<=sim_segments[".ktext"].end}function segments_addr_within_data(address){return address>=sim_segments[".data"].begin&&address<=sim_segments[".data"].end||address>=sim_segments[".kdata"].begin&&address<=sim_segments[".kdata"].end}ws_directives={".kdata":{name:".kdata",kindof:"segment",size:0,attrs:["data"]},".ktext":{name:".ktext",kindof:"segment",size:0,attrs:["text"]},".data":{name:".data",kindof:"segment",size:0,attrs:["data"]},".text":{name:".text",kindof:"segment",size:0,attrs:["text"]},".byte":{name:".byte",kindof:"datatype",size:1,attrs:["numeric"]},".half":{name:".half",kindof:"datatype",size:2,attrs:["numeric"]},".word":{name:".word",kindof:"datatype",size:4,attrs:["numeric"]},".dword":{name:".dword",kindof:"datatype",size:8,attrs:["numeric"]},".float":{name:".float",kindof:"datatype",size:4,attrs:["numeric"]},".double":{name:".double",kindof:"datatype",size:8,attrs:["numeric"]},".ascii":{name:".ascii",kindof:"datatype",size:1,attrs:["string"]},".asciiz":{name:".asciiz",kindof:"datatype",size:1,attrs:["string"]},".string":{name:".string",kindof:"datatype",size:1,attrs:["string"]},".space":{name:".space",kindof:"datatype",size:1,attrs:["space"]},".zero":{name:".zero",kindof:"datatype",size:1,attrs:["space"]},".align":{name:".align",kindof:"datatype",size:0,attrs:["align"]},".balign":{name:".balign",kindof:"datatype",size:0,attrs:["align"]}};function wsasm_is_directive_kindof(text,kindof){if(typeof ws_directives[text]==="undefined"){return false}return ws_directives[text].kindof==kindof}function wsasm_is_directive(text){return typeof ws_directives[text]!=="undefined"}function wsasm_is_directive_segment(text){return wsasm_is_directive_kindof(text,"segment")}function wsasm_is_directive_datatype(text){return wsasm_is_directive_kindof(text,"datatype")}function wsasm_get_datatype_size(datatype){if(typeof ws_directives[datatype]==="undefined"){console.log("ERROR: not defined datatype: "+datatype+"\n");return 0}return ws_directives[datatype].size}function wsasm_has_datatype_attr(datatype,attr){if(typeof ws_directives[datatype]==="undefined"){return false}return ws_directives[datatype].attrs.includes(attr)}BYTE_LENGTH=8;WORD_BYTES=4;WORD_LENGTH=WORD_BYTES*BYTE_LENGTH;sim_datatypes={".byte":{name:".byte",kindof:"datatype",size:1},".half":{name:".half",kindof:"datatype",size:2},".word":{name:".word",kindof:"datatype",size:4},".float":{name:".float",kindof:"datatype",size:4},".double":{name:".double",kindof:"datatype",size:8},".ascii":{name:".ascii",kindof:"datatype",size:1},".asciiz":{name:".asciiz",kindof:"datatype",size:1},".space":{name:".space",kindof:"datatype",size:1},".string":{name:".string",kindof:"datatype",size:1},".zero":{name:".zero",kindof:"datatype",size:1},".align":{name:".align",kindof:"datatype",size:0}};function isDecimal(n){var ret={number:0,isDecimal:false};if(n.length>1&&n[0]=="0"){return ret}if(typeof n==="string"&&n.includes(".")){return ret}if(!isNaN(parseFloat(n))&&isFinite(n)){ret.isDecimal=true;ret.number=parseInt(n);return ret}return ret}function isOctal(n){var ret={number:0,isDecimal:false};if(n.substring(0,1)=="0"){var octal=n.substring(1).replace(/\b0+/g,"");ret.number=parseInt(octal,8);ret.isDecimal=ret.number.toString(8)===octal;return ret}return ret}function isHex(n){var ret={number:0,isDecimal:false};if(n.substring(0,2).toLowerCase()=="0x"){var hex=n.substring(2).toLowerCase().replace(/\b0+/g,"");if(hex==""){hex="0"}ret.number=parseInt(hex,16);ret.isDecimal=ret.number.toString(16)===hex;return ret}return ret}function isChar(n){var ret={number:0,isDecimal:false};var ret1=treatControlSequences(n);if(true==ret1.error){return ret}var possible_value=ret1.string;if(possible_value[0]=="'"&&possible_value[2]=="'"||possible_value[0]=='"'&&possible_value[2]=='"'){ret.number=possible_value.charCodeAt(1);ret.isDecimal=true;return ret}return ret}function isFloat(n){var ret={number:0,isFloat:false};var non_float=/[a-df-zA-DF-Z]+/;if(non_float.test(n)===true){return ret}ret.number=parseFloat(n);ret.isFloat=!isNaN(ret.number);return ret}function get_decimal_value(possible_value){var ret={number:0,isDecimal:true};ret=isOctal(possible_value);if(ret.isDecimal===false){ret=isHex(possible_value)}if(ret.isDecimal===false){ret=isDecimal(possible_value)}if(ret.isDecimal===false){ret=isChar(possible_value)}return ret}function decimal2binary(number,size){var num_base2=number.toString(2);var num_base2_length=num_base2.length;if(num_base2_length>WORD_LENGTH){return[num_base2,size-num_base2_length,num_base2_length]}num_base2=(number>>>0).toString(2);num_base2_length=num_base2.length;if(number>=0){return[num_base2,size-num_base2_length,num_base2_length]}num_base2="1"+num_base2.replace(/^[1]+/g,"");num_base2_length=num_base2.length;if(num_base2_length>size){return[num_base2,size-num_base2_length,num_base2_length]}num_base2="1".repeat(size-num_base2.length)+num_base2;return[num_base2,size-num_base2.length,num_base2_length]}function get_inm_value(value){var ret1={};var ret={number:0,isDecimal:false,isFloat:false};ret1=get_decimal_value(value);if(ret1.isDecimal==true){ret1.isFloat=false;return ret1}ret1=isFloat(value);if(ret1.isFloat==true){ret1.isDecimal=false;return ret1}return ret}directives={".kdata":{name:".kdata",kindof:"segment",size:0},".ktext":{name:".ktext",kindof:"segment",size:0},".data":{name:".data",kindof:"segment",size:0},".text":{name:".text",kindof:"segment",size:0},".byte":{name:".byte",kindof:"datatype",size:1},".half":{name:".half",kindof:"datatype",size:2},".word":{name:".word",kindof:"datatype",size:4},".float":{name:".float",kindof:"datatype",size:4},".double":{name:".double",kindof:"datatype",size:8},".ascii":{name:".ascii",kindof:"datatype",size:1},".asciiz":{name:".asciiz",kindof:"datatype",size:1},".space":{name:".space",kindof:"datatype",size:1},".string":{name:".string",kindof:"datatype",size:1},".zero":{name:".zero",kindof:"datatype",size:1},".align":{name:".align",kindof:"datatype",size:0}};function get_datatype_size(datatype){if(typeof directives[datatype]==="undefined"){console.log("ERROR: not defined datatype: "+datatype+"\n");return 0}return directives[datatype].size}function is_directive_kindof(text,kindof){if(typeof directives[text]==="undefined"){return false}return directives[text].kindof==kindof}function is_directive(text){return typeof directives[text]!=="undefined"}function is_directive_segment(text){return is_directive_kindof(text,"segment")}function is_directive_datatype(text){return is_directive_kindof(text,"datatype")}function isValidTag(tag){if(tag.trim()==""){return false}var ret=isDecimal(tag[0]);if(ret.isDecimal==true){return false}var myRegEx=/[^a-z,_\d]/i;return!myRegEx.test(tag)}function sum_array(a){return a.reduce((function(a,b){return a+b}),0)}function get_candidate(advance,instruction){var candidate=false;var candidates={};var signatures={};for(i=0;icandidates[i]){min=candidates[i];candidate=i}}}return candidate?parseInt(candidate):candidate}function reset_assembly(nwords){return"0".repeat(WORD_LENGTH*nwords)}function assembly_replacement(machineCode,num_bits,startbit,stopbit,free_space){var machineCodeAux=machineCode.substring(0,machineCode.length-startbit+free_space);machineCode=machineCodeAux+num_bits+machineCode.substring(machineCode.length-stopbit);return machineCode}function assembly_co_cop(machineCode,co,cop){var xr_info=simhw_sim_ctrlStates_get();if(co!==false)machineCode=assembly_replacement(machineCode,co,WORD_LENGTH,WORD_LENGTH-6,0);if(cop!==false)machineCode=assembly_replacement(machineCode,cop,xr_info.ir.default_eltos.cop.length,0,0);return machineCode}function writememory_and_reset(mp,gen,nwords){if(gen.byteWord>=WORD_BYTES){var melto={value:gen.machineCode,source_tracking:gen.track_source,comments:gen.comments};main_memory_set(mp,"0x"+gen.seg_ptr.toString(16),melto);gen.seg_ptr=gen.seg_ptr+WORD_BYTES;gen.byteWord=0;gen.track_source=[];gen.comments=[];gen.machineCode=reset_assembly(nwords)}}function is_end_of_file(context){return""===asm_getToken(context)&&context.t>=context.text.length}function read_data(context,datosCU,ret){var seg_name=asm_getToken(context);var gen={};gen.byteWord=0;gen.track_source=[];gen.comments=[];gen.machineCode=reset_assembly(1);gen.seg_ptr=ret.seg[seg_name].begin;asm_nextToken(context);while(!is_directive_segment(asm_getToken(context))&&!is_end_of_file(context)){var possible_tag="";while(!is_directive_datatype(asm_getToken(context))&&!is_end_of_file(context)){possible_tag=asm_getToken(context);if("TAG"!=asm_getTokenType(context)){if(""==possible_tag){possible_tag="[empty]"}return asm_langError(context,i18n_get_TagFor("compiler","NO TAG OR DIRECTIVE")+"'"+possible_tag+"'")}var tag=possible_tag.substring(0,possible_tag.length-1);if(!isValidTag(tag)){return asm_langError(context,i18n_get_TagFor("compiler","INVALID TAG FORMAT")+"'"+tag+"'")}if(context.firmware[tag]){return asm_langError(context,i18n_get_TagFor("compiler","TAG OR INSTRUCTION")+"'"+tag+"'")}if(ret.labels_asm[tag]){return asm_langError(context,i18n_get_TagFor("compiler","REPEATED TAG")+"'"+tag+"'")}ret.labels_asm[tag]="0x"+(gen.seg_ptr+gen.byteWord).toString(16);asm_nextToken(context)}if(is_end_of_file(context)){break}var possible_datatype=asm_getToken(context);if(".word"==possible_datatype||".half"==possible_datatype||".byte"==possible_datatype||".float"==possible_datatype||".double"==possible_datatype){var size=get_datatype_size(possible_datatype);asm_nextToken(context);var possible_value=asm_getToken(context);while(!is_directive(asm_getToken(context))&&!is_end_of_file(context)){var label_found=false;var ret1=get_inm_value(possible_value);var number=ret1.number;if(ret1.isDecimal==false&&ret1.isFloat==false){if(".word"!==possible_datatype){return asm_langError(context,i18n_get_TagFor("compiler","NO NUMERIC DATATYPE")+"'"+possible_value+"'")}if(!isValidTag(possible_value)){return asm_langError(context,i18n_get_TagFor("compiler","INVALID TAG FORMAT")+"'"+possible_value+"'")}if(context.firmware[possible_value]){return asm_langError(context,i18n_get_TagFor("compiler","TAG OR INSTRUCTION")+"'"+possible_value+"'")}number=0;label_found=true}if(ret1.isDecimal==true)a=decimal2binary(number,size*BYTE_LENGTH);else a=float2binary(number,size*BYTE_LENGTH);num_bits=a[0];free_space=a[1];if(free_space<0){return asm_langError(context,i18n_get_TagFor("compiler","EXPECTED VALUE")+possible_datatype+"' ("+size*BYTE_LENGTH+" bits), "+i18n_get_TagFor("compiler","BUT INSERTED")+possible_value+"' ("+num_bits.length+" bits) "+i18n_get_TagFor("compiler","INSTEAD"))}writememory_and_reset(ret.mp,gen,1);while((gen.seg_ptr+gen.byteWord)%size!=0){gen.byteWord++;writememory_and_reset(ret.mp,gen,1)}if(""!=possible_tag){ret.labels_asm[possible_tag.substring(0,possible_tag.length-1)]="0x"+(gen.seg_ptr+gen.byteWord).toString(16);possible_tag=""}if(label_found){ret.labels["0x"+gen.seg_ptr.toString(16)]={name:possible_value,addr:gen.seg_ptr,startbit:31,stopbit:0,rel:undefined,nwords:1,labelContext:asm_getLabelContext(context)}}gen.machineCode=assembly_replacement(gen.machineCode,num_bits,BYTE_LENGTH*(size+gen.byteWord),BYTE_LENGTH*gen.byteWord,free_space);gen.byteWord+=size;gen.track_source.push(possible_value);asm_nextToken(context);if(","==asm_getToken(context)){asm_nextToken(context)}if(is_directive(asm_getToken(context))||"TAG"==asm_getTokenType(context)||"."==asm_getToken(context)[0]){break}possible_value=asm_getToken(context)}}else if(".space"==possible_datatype||".zero"==possible_datatype){asm_nextToken(context);var possible_value=asm_getToken(context);var ret1=isDecimal(possible_value);possible_value=ret1.number;if(ret1.isDecimal==false){return asm_langError(context,i18n_get_TagFor("compiler","NO NUMBER OF BYTES")+"'"+possible_value+"'")}if(possible_value<0){return asm_langError(context,i18n_get_TagFor("compiler","NO POSITIVE NUMBER")+"'"+possible_value+"'")}for(i=0;i=0){return asm_langError(context,i18n_get_TagFor("compiler","INVALID ALIGN VALUE")+"'"+possible_value+"'. "+i18n_get_TagFor("compiler","REMEMBER ALIGN VAL"))}writememory_and_reset(ret.mp,gen,1);var align_offset=Math.pow(2,parseInt(possible_value));switch(align_offset){case 1:break;case 2:if(gen.byteWord&1==1)gen.byteWord++;break;default:writememory_and_reset(ret.mp,gen,1);while(gen.seg_ptr%align_offset!=0||gen.byteWord!=0){gen.byteWord++;writememory_and_reset(ret.mp,gen,1)}}asm_nextToken(context)}else if(".ascii"==possible_datatype||".asciiz"==possible_datatype||".string"==possible_datatype){asm_nextToken(context);var possible_value=asm_getToken(context);var ret1=treatControlSequences(possible_value);if(true==ret1.error){return asm_langError(context,ret1.string)}possible_value=ret1.string;while(!is_directive(asm_getToken(context))&&!is_end_of_file(context)){writememory_and_reset(ret.mp,gen,1);if('"'!==possible_value[0]){return asm_langError(context,i18n_get_TagFor("compiler","NO QUOTATION MARKS")+"'"+possible_value+"'")}if('"'!==possible_value[possible_value.length-1]){return asm_langError(context,i18n_get_TagFor("compiler","NOT CLOSED STRING"))}if(""==possible_value){return asm_langError(context,i18n_get_TagFor("compiler","NOT CLOSED STRING"))}if("STRING"!=asm_getTokenType(context)){return asm_langError(context,i18n_get_TagFor("compiler","NO QUOTATION MARKS")+"'"+possible_value+"'")}for(i=0;i0){var melto={value:gen.machineCode,source_tracking:gen.track_source,comments:gen.comments};main_memory_set(ret.mp,"0x"+gen.seg_ptr.toString(16),melto);gen.seg_ptr=gen.seg_ptr+WORD_BYTES}ret.seg[seg_name].end=gen.seg_ptr}function read_text(context,datosCU,ret){var seg_name=asm_getToken(context);var seg_ptr=ret.seg[seg_name].begin;var firmware=context.firmware;var pseudoInstructions=context.pseudoInstructions;var finish=[];var isPseudo=false;var pfinish=[];var npseudoInstructions=0;var pseudo_fields={};var counter=-1;var candidate;var error="";var registers={};for(i=0;i=signature_fields[j].length){if("TAG"!=asm_getTokenType(context)&&!firmware[value]&&!is_end_of_file(context)){advance[j]=0}continue}var field=firmware[instruction][j].fields[i];var size=field.startbit-field.stopbit+1;var label_found=false;var sel_found=false;switch(field.type){case"address":case"inm":if(isPseudo&&"sel"==value){counter++;var start=pfinish[counter++];var stop=pfinish[counter++];var value=pseudo_fields[pfinish[counter++]];counter++;sel_found=true}var ret1=get_inm_value(value);converted=ret1.number;if(ret1.isDecimal==false&&ret1.isFloat==false){error=i18n_get_TagFor("compiler","NO NUMERIC DATATYPE")+"'"+value+"'";if(value[0]=="'"){advance[j]=0;break}if(!isValidTag(value)){advance[j]=0;break}if(firmware[value]){error=i18n_get_TagFor("compiler","TAG OR INSTRUCTION")+"'"+value+"'";advance[j]=0;break}label_found=true}if(sel_found){if(ret1.isDecimal==true)res=decimal2binary(converted,WORD_LENGTH);else res=float2binary(converted,WORD_LENGTH);if(res[1]<0){return asm_langError(context,"'"+value+"' "+i18n_get_TagFor("compiler","BIGGER THAN")+WORD_LENGTH+" "+i18n_get_TagFor("compiler","BITS"))}if(label_found){s[i+1]=value}else{converted="0".repeat(res[1])+res[0];converted=converted.substring(WORD_LENGTH-start-1,WORD_LENGTH-stop);converted=parseInt(converted,2);s[i+1]="0x"+converted.toString(16)}}if(!label_found){if(ret1.isDecimal==true)var res=decimal2binary(converted,size);else var res=float2binary(converted,size);if(field.type=="address"&&"rel"==field.address_type){res=decimal2binary(converted,size)}}break;case"reg":if(typeof value==="undefined"){error=i18n_get_TagFor("compiler","INS. MISSING FIELD");advance[j]=0;break}var aux=false;if(value.startsWith("(")){if("(reg)"!=signature_fields[j][i]){error=i18n_get_TagFor("compiler","UNEXPECTED (REG)");advance[j]=0;break}if(counter==-1){asm_nextToken(context);value=asm_getToken(context)}else{value=pseudo_fields[pfinish[counter++]]}aux=true}else{if("(reg)"==signature_fields[j][i]){error=i18n_get_TagFor("compiler","EXPECTED (REG)")+"'"+value+"'";advance[j]=0;break}}if(typeof registers[value]==="undefined"){error=i18n_get_TagFor("compiler","EXPECTED REG")+"'"+value+"'";advance[j]=0;break}if(aux){s[i+1]="("+value+")";if(counter==-1){asm_nextToken(context);aux=asm_getToken(context)}else{aux=pfinish[counter++]}if(")"!=aux){error=i18n_get_TagFor("compiler","CLOSE PAREN. NOT FOUND");advance[j]=0;break}}var ret1=isDecimal(registers[value]);converted=ret1.number;var res=decimal2binary(converted,size);value=s[i+1];break;default:return asm_langError(context,i18n_get_TagFor("compiler","UNKNOWN 1")+"'"+field.type+"'")}if(advance[j]==1&&!label_found){if(res[1]<0){if(field.type=="address"&&"rel"==field.address_type){error="Relative value ("+(converted-seg_ptr-WORD_BYTES)+" in decimal)"+i18n_get_TagFor("compiler","NEEDS")+res[0].length+i18n_get_TagFor("compiler","SPACE FOR # BITS")+size+" "+i18n_get_TagFor("compiler","BITS")}else{error="'"+value+"'"+i18n_get_TagFor("compiler","NEEDS")+res[0].length+i18n_get_TagFor("compiler","SPACE FOR # BITS")+size+" "+i18n_get_TagFor("compiler","BITS")}advance[j]=0}}if(advance[j]==1&&!(isPseudo&&counter==-1)){binaryAux[j][i]={num_bits:label_found?false:res[0],free_space:label_found?false:res[1],startbit:field.startbit,stopbit:field.stopbit,rel:label_found?field.address_type:false,islabel:label_found,field_name:value,issel:sel_found,sel_start:start,sel_stop:stop}}}if(sum_array(advance)==0){break}if("TAG"==asm_getTokenType(context)||firmware[value]){break}}for(i=0;i0&&i0&&i==firmware[instruction].length-1){format+=" or "}format+="'"+firmware[instruction][i].signatureUser+"'"}if(format==""){format="'"+instruction+"' "+i18n_get_TagFor("compiler","UNKNOWN MC FORMAT")}var sum_res=sum_array(advance);if(sum_res==0){if(advance.length===1){return asm_langError(context,error+".
"+i18n_get_TagFor("compiler","REMEMBER I. FORMAT")+format)}return asm_langError(context,i18n_get_TagFor("compiler","NOT MATCH MICRO")+"
"+i18n_get_TagFor("compiler","REMEMBER I. FORMAT")+format+". "+i18n_get_TagFor("compiler","CHECK MICROCODE"))}if(sum_res>1){candidate=get_candidate(advance,firmware[instruction]);if(candidate===false){return asm_langError(context,i18n_get_TagFor("compiler","SEVERAL CANDIDATES")+format)}}if(isPseudo){if(counter==-1){var s_ori=s.join(" ");s_ori=s_ori.trim();var key="";var val="";pseudo_fields={};for(i=0;i1){s_ori=" "}if(pfinish[counter]=="\n"){counter++}}var machineCode=reset_assembly(firmware[instruction][candidate].nwords);machineCode=assembly_co_cop(machineCode,firmware[instruction][candidate].co,firmware[instruction][candidate].cop);var l_addr="";for(i=0;i=0;i--){if(icontext.text.length){break}}ret.seg[seg_name].end=seg_ptr}function simlang_compile_v1(text,datosCU){var context={};context.line=1;context.error=null;context.i=0;context.contadorMC=0;context.etiquetas={};context.labelsNotFound=[];context.instrucciones=[];context.co_cop={};context.registers=[];context.text=text;context.tokens=[];context.token_types=[];context.t=0;context.newlines=[];context.pseudoInstructions=[];context.stackRegister=null;context.firmware={};context.comments=[];for(i=0;i=0;j--){var melto={value:machineCode.substring(j*WORD_LENGTH,(j+1)*WORD_LENGTH),source_tracking:null,comments:null};main_memory_set(ret.mp,"0x"+auxAddr.toString(16),melto);auxAddr+=WORD_BYTES}}if(text_found){if(typeof ret.labels_asm["main"]==="undefined"&&typeof ret.labels_asm["kmain"]==="undefined"){return asm_langError(context,i18n_get_TagFor("compiler","NO MAIN OR KMAIN"))}}for(var key in ret.labels_asm){ret.hash_labels_asm_rev[ret.labels_asm[key]]=key}for(var skey in ret.seg){ret.hash_seg_rev.push({begin:parseInt(ret.seg[skey].begin),name:skey})}return ret}function bits_size(bits){var len=0;for(var i=0;istr.length-1)return str;return str.substring(0,index)+chr+str.substring(index+1)}function assembly_oc_eoc_v2(machineCode,oc,eoc){var xr_info=simhw_sim_ctrlStates_get();var bits=xr_info.ir.default_eltos.eoc.bits_field;var start=31-xr_info.ir.default_eltos.oc.begin+1;var stop=31-xr_info.ir.default_eltos.oc.end;if(oc!==false)machineCode=assembly_replace_v2(machineCode,oc,start,stop,0,0);if(eoc!==false)if(eoc.length===3){machineCode=assembly_replace_v2(machineCode,eoc,bits[0][0]+1,bits[0][1],0,0)}else{var j=0;for(var k=0;k=31-bits[k][0];i--){if(j>=0){machineCode=setCharAt(machineCode,i,num_bits[j]);j--}}}}return machineCode}function read_data_v2(context,datosCU,ret){var seg_name=asm_getToken(context);var gen={};gen.byteWord=0;gen.track_source=[];gen.comments=[];gen.machineCode=reset_assembly(1);gen.seg_ptr=ret.seg[seg_name].begin;asm_nextToken(context);while(!is_directive_segment(asm_getToken(context))&&!is_end_of_file(context)){var possible_tag="";while(!is_directive_datatype(asm_getToken(context))&&!is_end_of_file(context)){possible_tag=asm_getToken(context);if("TAG"!=asm_getTokenType(context)){if(""==possible_tag){possible_tag="[empty]"}return asm_langError(context,i18n_get_TagFor("compiler","NO TAG OR DIRECTIVE")+"'"+possible_tag+"'")}var tag=possible_tag.substring(0,possible_tag.length-1);if(!isValidTag(tag)){return asm_langError(context,i18n_get_TagFor("compiler","INVALID TAG FORMAT")+"'"+tag+"'")}if(context.firmware[tag]){return asm_langError(context,i18n_get_TagFor("compiler","TAG OR INSTRUCTION")+"'"+tag+"'")}if(ret.labels_asm[tag]){return asm_langError(context,i18n_get_TagFor("compiler","REPEATED TAG")+"'"+tag+"'")}ret.labels_asm[tag]="0x"+(gen.seg_ptr+gen.byteWord).toString(16);asm_nextToken(context)}if(is_end_of_file(context)){break}var possible_datatype=asm_getToken(context);if(".word"==possible_datatype||".half"==possible_datatype||".byte"==possible_datatype||".float"==possible_datatype||".double"==possible_datatype){var size=get_datatype_size(possible_datatype);asm_nextToken(context);var possible_value=asm_getToken(context);while(!is_directive(asm_getToken(context))&&!is_end_of_file(context)){var label_found=false;var ret1=get_inm_value(possible_value);var number=ret1.number;if(ret1.isDecimal==false&&ret1.isFloat==false){if(".word"!==possible_datatype){return asm_langError(context,i18n_get_TagFor("compiler","NO NUMERIC DATATYPE")+"'"+possible_value+"'")}if(!isValidTag(possible_value)){return asm_langError(context,i18n_get_TagFor("compiler","INVALID TAG FORMAT")+"'"+possible_value+"'")}if(context.firmware[possible_value]){return asm_langError(context,i18n_get_TagFor("compiler","TAG OR INSTRUCTION")+"'"+possible_value+"'")}number=0;label_found=true}if(ret1.isDecimal==true)a=decimal2binary(number,size*BYTE_LENGTH);else a=float2binary(number,size*BYTE_LENGTH);num_bits=a[0];free_space=a[1];if(free_space<0){return asm_langError(context,i18n_get_TagFor("compiler","EXPECTED VALUE")+possible_datatype+"' ("+size*BYTE_LENGTH+" bits), "+i18n_get_TagFor("compiler","BUT INSERTED")+possible_value+"' ("+num_bits.length+" bits) "+i18n_get_TagFor("compiler","INSTEAD"))}writememory_and_reset(ret.mp,gen,1);while((gen.seg_ptr+gen.byteWord)%size!=0){gen.byteWord++;writememory_and_reset(ret.mp,gen,1)}if(""!=possible_tag){ret.labels_asm[possible_tag.substring(0,possible_tag.length-1)]="0x"+(gen.seg_ptr+gen.byteWord).toString(16);possible_tag=""}if(label_found){ret.labels["0x"+gen.seg_ptr.toString(16)]={name:possible_value,addr:gen.seg_ptr,startbit:31,stopbit:0,rel:undefined,nwords:1,labelContext:asm_getLabelContext(context)}}gen.machineCode=assembly_replacement(gen.machineCode,num_bits,BYTE_LENGTH*(size+gen.byteWord),BYTE_LENGTH*gen.byteWord,free_space);gen.byteWord+=size;gen.track_source.push(possible_value);asm_nextToken(context);if(","==asm_getToken(context)){asm_nextToken(context)}if(is_directive(asm_getToken(context))||"TAG"==asm_getTokenType(context)||"."==asm_getToken(context)[0]){break}possible_value=asm_getToken(context)}}else if(".space"==possible_datatype||".zero"==possible_datatype){asm_nextToken(context);var possible_value=asm_getToken(context);var ret1=isDecimal(possible_value);possible_value=ret1.number;if(ret1.isDecimal==false){return asm_langError(context,i18n_get_TagFor("compiler","NO NUMBER OF BYTES")+"'"+possible_value+"'")}if(possible_value<0){return asm_langError(context,i18n_get_TagFor("compiler","NO POSITIVE NUMBER")+"'"+possible_value+"'")}for(i=0;i=0){return asm_langError(context,i18n_get_TagFor("compiler","INVALID ALIGN VALUE")+"'"+possible_value+"'. "+i18n_get_TagFor("compiler","REMEMBER ALIGN VAL"))}writememory_and_reset(ret.mp,gen,1);var align_offset=Math.pow(2,parseInt(possible_value));switch(align_offset){case 1:break;case 2:if(gen.byteWord&1==1)gen.byteWord++;break;default:writememory_and_reset(ret.mp,gen,1);while(gen.seg_ptr%align_offset!=0||gen.byteWord!=0){gen.byteWord++;writememory_and_reset(ret.mp,gen,1)}}asm_nextToken(context)}else if(".ascii"==possible_datatype||".asciiz"==possible_datatype||".string"==possible_datatype){asm_nextToken(context);var possible_value=asm_getToken(context);var ret1=treatControlSequences(possible_value);if(true==ret1.error){return asm_langError(context,ret1.string)}possible_value=ret1.string;while(!is_directive(asm_getToken(context))&&!is_end_of_file(context)){writememory_and_reset(ret.mp,gen,1);if('"'!==possible_value[0]){return asm_langError(context,i18n_get_TagFor("compiler","NO QUOTATION MARKS")+"'"+possible_value+"'")}if('"'!==possible_value[possible_value.length-1]){return asm_langError(context,i18n_get_TagFor("compiler","NOT CLOSED STRING"))}if(""==possible_value){return asm_langError(context,i18n_get_TagFor("compiler","NOT CLOSED STRING"))}if("STRING"!=asm_getTokenType(context)){return asm_langError(context,i18n_get_TagFor("compiler","NO QUOTATION MARKS")+"'"+possible_value+"'")}for(i=0;i0){var melto={value:gen.machineCode,source_tracking:gen.track_source,comments:gen.comments};main_memory_set(ret.mp,"0x"+gen.seg_ptr.toString(16),melto);gen.seg_ptr=gen.seg_ptr+WORD_BYTES}ret.seg[seg_name].end=gen.seg_ptr}function read_text_v2(context,datosCU,ret){var seg_name=asm_getToken(context);var seg_ptr=ret.seg[seg_name].begin;var firmware=context.firmware;var pseudoInstructions=context.pseudoInstructions;var finish=[];var isPseudo=false;var pfinish=[];var npseudoInstructions=0;var pseudo_fields={};var counter=-1;var candidate;var error="";var registers={};for(i=0;i=signature_fields[j].length){if("TAG"!=asm_getTokenType(context)&&!firmware[value]&&!is_end_of_file(context)){advance[j]=0}continue}var field=firmware[instruction][j].fields[i];if(field.bits!==undefined)var size=bits_size(field.bits);else var size=field.startbit-field.stopbit+1;var label_found=false;var sel_found=false;switch(field.type){case"address":case"inm":case"imm":if(isPseudo&&"sel"==value){counter++;var start=pfinish[counter++];var stop=pfinish[counter++];var value=pseudo_fields[pfinish[counter++]];counter++;sel_found=true}var ret1=get_inm_value(value);converted=ret1.number;if(ret1.isDecimal==false&&ret1.isFloat==false){error=i18n_get_TagFor("compiler","NO NUMERIC DATATYPE")+"'"+value+"'";if(value[0]=="'"){advance[j]=0;break}if(!isValidTag(value)){advance[j]=0;break}if(firmware[value]){error=i18n_get_TagFor("compiler","TAG OR INSTRUCTION")+"'"+value+"'";advance[j]=0;break}label_found=true}if(sel_found){if(ret1.isDecimal==true)res=decimal2binary(converted,WORD_LENGTH);else res=float2binary(converted,WORD_LENGTH);if(res[1]<0){return asm_langError(context,"'"+value+"' "+i18n_get_TagFor("compiler","BIGGER THAN")+WORD_LENGTH+" "+i18n_get_TagFor("compiler","BITS"))}if(label_found){s[i+1]=value}else{converted="0".repeat(res[1])+res[0];converted=converted.substring(WORD_LENGTH-start-1,WORD_LENGTH-stop);converted=parseInt(converted,2);s[i+1]="0x"+converted.toString(16)}}if(!label_found){if(ret1.isDecimal==true)var res=decimal2binary(converted,size);else var res=float2binary(converted,size);if(field.type=="address"&&"rel"==field.address_type){res=decimal2binary(converted,size)}}break;case"reg":if(typeof value==="undefined"){error=i18n_get_TagFor("compiler","INS. MISSING FIELD");advance[j]=0;break}var aux=false;if(value.startsWith("(")){if("(reg)"!=signature_fields[j][i]){error=i18n_get_TagFor("compiler","UNEXPECTED (REG)");advance[j]=0;break}if(counter==-1){asm_nextToken(context);value=asm_getToken(context)}else{value=pseudo_fields[pfinish[counter++]]}aux=true}else{if("(reg)"==signature_fields[j][i]){error=i18n_get_TagFor("compiler","EXPECTED (REG)")+"'"+value+"'";advance[j]=0;break}}if(typeof registers[value]==="undefined"){error=i18n_get_TagFor("compiler","EXPECTED REG")+"'"+value+"'";advance[j]=0;break}if(aux){s[i+1]="("+value+")";if(counter==-1){asm_nextToken(context);aux=asm_getToken(context)}else{aux=pfinish[counter++]}if(")"!=aux){error=i18n_get_TagFor("compiler","CLOSE PAREN. NOT FOUND");advance[j]=0;break}}var ret1=isDecimal(registers[value]);converted=ret1.number;var res=decimal2binary(converted,size);value=s[i+1];break;default:return asm_langError(context,i18n_get_TagFor("compiler","UNKNOWN 1")+"'"+field.type+"'")}if(advance[j]==1&&!label_found){if(res[1]<0){if(field.type=="address"&&"rel"==field.address_type){error="Relative value ("+(converted-seg_ptr-WORD_BYTES)+" in decimal)"+i18n_get_TagFor("compiler","NEEDS")+res[0].length+i18n_get_TagFor("compiler","SPACE FOR # BITS")+size+" "+i18n_get_TagFor("compiler","BITS")}else{error="'"+value+"'"+i18n_get_TagFor("compiler","NEEDS")+res[0].length+i18n_get_TagFor("compiler","SPACE FOR # BITS")+size+" "+i18n_get_TagFor("compiler","BITS")}advance[j]=0}}if(advance[j]==1&&!(isPseudo&&counter==-1)){binaryAux[j][i]={num_bits:label_found?false:res[0],free_space:label_found?false:res[1],startbit:field.startbit,stopbit:field.stopbit,bits:field.bits,rel:label_found?field.address_type:false,islabel:label_found,field_name:value,issel:sel_found,sel_start:start,sel_stop:stop}}}if(sum_array(advance)==0){break}if("TAG"==asm_getTokenType(context)||firmware[value]){break}}for(i=0;i0&&i0&&i==firmware[instruction].length-1){format+=" or "}format+="'"+firmware[instruction][i].signatureUser+"'"}if(format==""){format="'"+instruction+"' "+i18n_get_TagFor("compiler","UNKNOWN MC FORMAT")}var sum_res=sum_array(advance);if(sum_res==0){if(advance.length===1){return asm_langError(context,error+".
"+i18n_get_TagFor("compiler","REMEMBER I. FORMAT")+format)}return asm_langError(context,i18n_get_TagFor("compiler","NOT MATCH MICRO")+"
"+i18n_get_TagFor("compiler","REMEMBER I. FORMAT")+format+". "+i18n_get_TagFor("compiler","CHECK MICROCODE"))}if(sum_res>1){candidate=get_candidate(advance,firmware[instruction]);if(candidate===false){return asm_langError(context,i18n_get_TagFor("compiler","SEVERAL CANDIDATES")+format)}}if(isPseudo){if(counter==-1){var s_ori=s.join(" ");s_ori=s_ori.trim();var key="";var val="";pseudo_fields={};for(i=0;i1){s_ori=" "}if(pfinish[counter]=="\n"){counter++}}var machineCode=reset_assembly(firmware[instruction][candidate].nwords);if(firmware[instruction][candidate].co!==false){machineCode=assembly_co_cop(machineCode,firmware[instruction][candidate].co,firmware[instruction][candidate].cop)}else{machineCode=assembly_oc_eoc_v2(machineCode,firmware[instruction][candidate].oc,firmware[instruction][candidate].eoc)}var l_addr="";for(i=0;i=0;i--){if(icontext.text.length){break}}ret.seg[seg_name].end=seg_ptr}function simlang_compile_v2(text,datosCU){var context={};context.line=1;context.error=null;context.i=0;context.contadorMC=0;context.etiquetas={};context.labelsNotFound=[];context.instrucciones=[];context.co_cop={};context.oc_eoc={};context.registers=[];context.text=text;context.tokens=[];context.token_types=[];context.t=0;context.newlines=[];context.pseudoInstructions=[];context.stackRegister=null;context.firmware={};context.comments=[];for(i=0;i=0;j--){var melto={value:machineCode.substring(j*WORD_LENGTH,(j+1)*WORD_LENGTH),source_tracking:null,comments:null};main_memory_set(ret.mp,"0x"+auxAddr.toString(16),melto);auxAddr+=WORD_BYTES}}if(text_found){if(typeof ret.labels_asm["main"]==="undefined"&&typeof ret.labels_asm["kmain"]==="undefined"){return asm_langError(context,i18n_get_TagFor("compiler","NO MAIN OR KMAIN"))}}for(var key in ret.labels_asm){ret.hash_labels_asm_rev[ret.labels_asm[key]]=key}for(var skey in ret.seg){ret.hash_seg_rev.push({begin:parseInt(ret.seg[skey].begin),name:skey})}return ret}function wsasm_new_objElto(base_elto){var elto={comments:[],labels:[],track_source:[],seg_name:"",datatype:"",byte_size:0,value:0,binary:"",firm_reference:null,firm_reference_index:-1,pending:[]};if(null!=base_elto){elto.seg_name=base_elto.seg_name;elto.datatype=base_elto.datatype;elto.byte_size=base_elto.byte_size}return elto}function wsasm_make_signature_user(elto,use_as_around){elto.signature_user="";for(let j=0;jstop_bit){sel_start=WORD_LENGTH-1-start_bit;sel_stop=WORD_LENGTH-1-stop_bit}else{sel_stop=WORD_LENGTH-1-start_bit;sel_start=WORD_LENGTH-1-stop_bit}valbin=parseInt(value);valbin=valbin.toString(2).padStart(WORD_LENGTH,"0");valbin=valbin.substring(sel_start,sel_stop+1);return valbin}function wsasm_prepare_context_firmware(context,CU_data){let elto=null;let aux=null;let start_bit=0;let stop_bit=0;let lower_bit=0;let w_n_bits=0;let w_index=0;let n_bits=0;for(let i=0;i=0){return asm_langError(context,i18n_get_TagFor("compiler","INVALID ALIGN VALUE")+"'"+possible_value+"'. "+i18n_get_TagFor("compiler","REMEMBER ALIGN VAL"))}var align_offset=parseInt(possible_value);if(".align"==elto.datatype){align_offset=Math.pow(2,align_offset)}elto.seg_name=seg_name;elto.track_source.push(".align "+possible_value);elto.comments.push(acc_cmt);elto.byte_size=align_offset;elto.value=possible_value;ret.obj.push(elto);elto=wsasm_new_objElto(null);asm_nextToken(context)}else if(wsasm_has_datatype_attr(elto.datatype,"string")){asm_nextToken(context);possible_value=asm_getToken(context);ret1=treatControlSequences(possible_value);if(true==ret1.error){return asm_langError(context,ret1.string)}possible_value=ret1.string;while(!wsasm_is_directive(asm_getToken(context))&&!wsasm_isEndOfFile(context)){if('"'!==possible_value[0]){return asm_langError(context,i18n_get_TagFor("compiler","NO QUOTATION MARKS")+"'"+possible_value+"'")}if('"'!==possible_value[possible_value.length-1]){return asm_langError(context,i18n_get_TagFor("compiler","NOT CLOSED STRING"))}if(""==possible_value){return asm_langError(context,i18n_get_TagFor("compiler","NOT CLOSED STRING"))}if("STRING"!=asm_getTokenType(context)){return asm_langError(context,i18n_get_TagFor("compiler","NO QUOTATION MARKS")+"'"+possible_value+"'")}elto.seg_name=seg_name;elto.comments.push(acc_cmt);elto.value=[];for(i=0;i>>0).toString(2);value=value.padStart(n_bits,"0")}else{value="0".padStart(n_bits,"0")}for(let k=start_bit;k<=stop_bit;k++){arr_encoded[k]=value[k-start_bit]}}return arr_encoded.join("")}function wsasm_src2obj_text_getDistance(elto_firm_reference_i,elto_value){var candidate_type_as_string=elto_firm_reference_i.signature_type_str.replaceAll("address","inm");var candidate_size_as_intarr=elto_firm_reference_i.signature_size_arr;var signature_type_as_string=elto_value.signature_type_arr.join(" ").replaceAll("address","inm");var signature_size_as_intarr=elto_value.signature_size_arr;if(candidate_type_as_string!=signature_type_as_string){return-1}var distance=0;var distance_j=0;var offset_j=0;offset_j=candidate_size_as_intarr.length-signature_size_as_intarr.length;for(let j=0;jdistance){elto.firm_reference_distance=distance;elto.firm_reference_index=i}}if(0==candidates){var msg=elto.source;if(typeof elto.associated_pseudo!=="undefined"){msg=elto.source+' (as part of "'+elto.associated_pseudo.source+'")'}msg=i18n_get_TagFor("compiler","NOT MATCH FORMAT")+"
"+i18n_get_TagFor("compiler","REMEMBER FORMAT USED")+" for '"+msg+"':
"+elto.value.signature_user+".
"+i18n_get_TagFor("compiler","CHECK MICROCODE");return asm_langError(context,msg)}elto.byte_size=elto.firm_reference[elto.firm_reference_index].nwords*WORD_BYTES;return ret}function wsasm_src2obj_text_instr_op_match(context,ret,elto,atom,parentheses){var opx="";if(typeof context.registers[atom]!="undefined"){if(parentheses){elto.value.fields.push("("+atom+")");elto.value.signature_type_arr.push("(reg)")}else{elto.value.fields.push(atom);elto.value.signature_type_arr.push("reg")}elto.value.signature_size_arr.push(context.registers[atom].toString(2).length);return ret}var ret1=get_inm_value(atom);if(ret1.isDecimal||ret1.isFloat){var a=null;if(ret1.isDecimal)a=decimal2binary(ret1.number,elto.byte_size*BYTE_LENGTH);else a=float2binary(ret1.number,elto.byte_size*BYTE_LENGTH);if(parentheses){elto.value.fields.push("("+atom+")");elto.value.signature_type_arr.push("(inm)")}else{elto.value.fields.push(atom);elto.value.signature_type_arr.push("inm")}elto.value.signature_size_arr.push(a[2]);return ret}if(parentheses){elto.value.fields.push("("+atom+")");elto.value.signature_type_arr.push("(address)")}else{elto.value.fields.push(atom);elto.value.signature_type_arr.push("address")}elto.value.signature_size_arr.push(1);return ret}function wsasm_src2obj_text_ops_getAtom(context,pseudo_context){var opx="";if(pseudo_context!=null){if(pseudo_context.index>=pseudo_context.parts.length){return""}pseudo_context.index++;opx=pseudo_context.parts[pseudo_context.index]}else{asm_nextToken(context);opx=asm_getToken(context);if(wsasm_isEndOfFile(context)||"TAG"==asm_getTokenType(context)){return""}}if(typeof context.firmware[opx]!=="undefined"||wsasm_is_directive_segment(opx)){return""}return opx}function wsasm_src2obj_text_elto_fields(context,ret,elto,pseudo_context){var ret1=null;var opx="";var atom="";var par=false;opx=wsasm_src2obj_text_ops_getAtom(context,pseudo_context);while(opx!=""&&elto.value.fields.length<100){if(","==opx){opx=wsasm_src2obj_text_ops_getAtom(context,pseudo_context);if(""==opx)continue}atom=opx;par=false;if("sel"==opx){var sel={start:0,stop:0,label:""};var valbin="0";opx=wsasm_src2obj_text_ops_getAtom(context,pseudo_context);if("("!=opx){return asm_langError(context,i18n_get_TagFor("compiler","OPEN PAREN. NOT FOUND"))}sel.stop=wsasm_src2obj_text_ops_getAtom(context,pseudo_context);sel.stop=parseInt(sel.stop);if(isNaN(sel.stop)){return asm_langError(context,i18n_get_TagFor("compiler","NO POSITIVE NUMBER")+sel.stop)}opx=wsasm_src2obj_text_ops_getAtom(context,pseudo_context);if(","!=opx){return asm_langError(context,i18n_get_TagFor("compiler","COMMA NOT FOUND"))}sel.start=wsasm_src2obj_text_ops_getAtom(context,pseudo_context);sel.start=parseInt(sel.start);if(isNaN(sel.start)){return asm_langError(context,i18n_get_TagFor("compiler","NO POSITIVE NUMBER")+sel.start)}opx=wsasm_src2obj_text_ops_getAtom(context,pseudo_context);if(","!=opx){return asm_langError(context,i18n_get_TagFor("compiler","COMMA NOT FOUND"))}sel.label=wsasm_src2obj_text_ops_getAtom(context,pseudo_context);opx=wsasm_src2obj_text_ops_getAtom(context,pseudo_context);if(")"!=opx){return asm_langError(context,i18n_get_TagFor("compiler","CLOSE PAREN. NOT FOUND"))}a=get_inm_value(sel.label);if(a.isDecimal){valbin=wsasm_get_sel_valbin(sel.label,sel.start,sel.stop);atom=parseInt(valbin,2).toString(10)}else{if(!wsasm_is_ValidTag(sel.label)){return asm_langError(context,i18n_get_TagFor("compiler","LABEL NOT DEFINED")+": '"+sel.label+"'")}atom=sel.label+"["+sel.start+":"+sel.stop+"]"}}else if("("==opx){par=true;atom=wsasm_src2obj_text_ops_getAtom(context,pseudo_context);if(""==atom){return asm_langError(context,i18n_get_TagFor("compiler","CLOSE PAREN. NOT FOUND"))}opx=wsasm_src2obj_text_ops_getAtom(context,pseudo_context);if(")"!=opx){return asm_langError(context,i18n_get_TagFor("compiler","CLOSE PAREN. NOT FOUND"))}}ret1=wsasm_src2obj_text_instr_op_match(context,ret,elto,atom,par);if(ret1.error!=null){return ret1}opx=wsasm_src2obj_text_ops_getAtom(context,pseudo_context)}if(elto.value.fields.length>100){return asm_langError(context,i18n_get_TagFor("compiler","NOT MATCH FORMAT")+".
"+i18n_get_TagFor("compiler","REMEMBER FORMAT USED")+" '"+elto.source+"'.
"+i18n_get_TagFor("compiler","CHECK MICROCODE"))}elto.value.signature_type_str=elto.value.signature_type_arr.join(" ");elto.value.signature_size_str=elto.value.signature_size_arr.join(" ");elto.value.signature_user=wsasm_make_signature_user(elto.value,"+");return ret}function wsasm_find_candidate_and_encode(context,ret,elto){ret=wsasm_find_instr_candidates(context,ret,elto);if(ret.error!=null){return ret}var candidate=elto.firm_reference[elto.firm_reference_index];elto.binary=wsasm_encode_instruction(context,ret,elto,candidate);return ret}function wsasm_src2obj_text(context,ret){var possible_tag="";var possible_value="";var possible_inst="";var tag="";var acc_cmt="";var elto=null;var candidate=null;var seg_name=asm_getToken(context);asm_nextToken(context);elto=wsasm_new_objElto(null);while(!wsasm_is_directive_segment(asm_getToken(context))&&!wsasm_isEndOfFile(context)){acc_cmt=asm_getComments(context);asm_resetComments(context);possible_tag="";while(typeof context.firmware[asm_getToken(context)]==="undefined"&&!wsasm_isEndOfFile(context)){possible_tag=asm_getToken(context);if("TAG"!=asm_getTokenType(context)){if(""==possible_tag){possible_tag="[empty]"}return asm_langError(context,i18n_get_TagFor("compiler","NO TAG, DIR OR INS")+"'"+possible_tag+"'")}tag=possible_tag.substring(0,possible_tag.length-1);if(!wsasm_is_ValidTag(tag)){return asm_langError(context,i18n_get_TagFor("compiler","INVALID TAG FORMAT")+"'"+tag+"'")}if(context.firmware[tag]){return asm_langError(context,i18n_get_TagFor("compiler","TAG OR INSTRUCTION")+"'"+tag+"'")}if(ret.labels_asm[tag]){return asm_langError(context,i18n_get_TagFor("compiler","REPEATED TAG")+"'"+tag+"'")}elto.labels.push(tag);asm_nextToken(context)}if(wsasm_isEndOfFile(context)){if(elto.labels.length>0){ret.obj.push(elto)}break}possible_inst=asm_getToken(context);elto.seg_name=seg_name;elto.byte_size=WORD_BYTES;elto.value={};elto.value.instruction=possible_inst;elto.firm_reference=context.firmware[possible_inst];elto.value.fields=[];elto.value.signature_type_arr=[possible_inst];elto.value.signature_size_arr=[];ret=wsasm_src2obj_text_elto_fields(context,ret,elto,null);if(ret.error!=null){return ret}if(elto.value.fields.length>0)elto.source=elto.value.instruction+" "+elto.value.fields.join(" ");else elto.source=elto.value.instruction;elto.comments.push(acc_cmt);elto.track_source.push(elto.source);ret=wsasm_find_instr_candidates(context,ret,elto);if(ret.error!=null){return ret}var candidate=elto.firm_reference[elto.firm_reference_index];if(candidate.isPseudoinstruction==false){elto.datatype="instruction";elto.binary=wsasm_encode_instruction(context,ret,elto,candidate)}else{elto.datatype="pseudoinstruction";elto.binary=""}ret.obj.push(elto);elto=wsasm_new_objElto(elto)}return ret}function wsasm_src2obj_helper(context,ret){ret.data_found=false;ret.text_found=false;asm_nextToken(context);while(!wsasm_isEndOfFile(context)){var segname=asm_getToken(context);if(typeof ret.seg[segname]==="undefined"){return asm_langError(context,i18n_get_TagFor("compiler","INVALID SEGMENT NAME")+"'"+segname+"'")}if("data"==ret.seg[segname].kindof){ret=wsasm_src2obj_data(context,ret);ret.data_found=true}if(ret.error!=null){return ret}if("text"==ret.seg[segname].kindof){ret=wsasm_src2obj_text(context,ret);ret.text_found=true}if(ret.error!=null){return ret}}return ret}function wsasm_resolve_pseudo(context,ret){var pseudo_context={parts:null,index:0};var pseudo_elto=null;var elto=null;var eltos=[];var possible_inst="";var ret1=null;var pseudo_values="";var pseudo_replace="";for(let i=0;i1){padding=elto_align-last_assigned[seg_name]%elto_align;last_assigned[seg_name]+=padding}continue}elto_ptr=last_assigned[seg_name];if(ret.obj[i].datatype!="instruction"&&wsasm_get_datatype_size(ret.obj[i].datatype)==WORD_BYTES){if(elto_ptr%WORD_BYTES!=0)elto_ptr+=WORD_BYTES-elto_ptr%WORD_BYTES}ret.obj[i].seg_ptr=seg_ptr;ret.obj[i].elto_ptr=elto_ptr;ret.obj[i].byte_offset=elto_ptr-seg_ptr;ret.obj[i].padding=0;for(var j=0;j>>0).toString(2);ret.labels_valbin[label]=valbin;return ret}var value_arr=label.split(/^(.*)\[(\d+):(\d+)\]/s);if(value_arr.length<5){return asm_langError(context,i18n_get_TagFor("compiler","LABEL NOT DEFINED")+": '"+label+"'")}var sel_stop=parseInt(value_arr[2]);var sel_start=parseInt(value_arr[3]);var sel_label=value_arr[1];value=ret.labels_asm[sel_label];if(typeof value==="undefined"){return asm_langError(context,i18n_get_TagFor("compiler","LABEL NOT DEFINED")+": '"+sel_label+"'")}valbin=wsasm_get_sel_valbin(value,sel_start,sel_stop);ret.labels_valbin[label]=valbin;return ret}function wsasm_resolve_labels(context,ret){var elto=null;var value=0;var arr_encoded=null;var candidate_old=null;var candidate=null;ret=wsasm_compute_labels(context,ret,0);if(ret.error!=null){return ret}for(let i=0;ielto.pending[j].n_bits){elto.pending=[];ret=wsasm_find_candidate_and_encode(context,ret,elto);if(ret.error!=null){return ret}candidate=elto.firm_reference[elto.firm_reference_index];if(candiate.isPseudoinstruction){ret=wsasm_resolve_pseudo(context,ret);if(ret.error!=null){return ret}}if(candiate.nwords!=candiate_old.nwords){ret=wsasm_compute_labels(context,ret,i);if(ret.error!=null){return ret}}}if(elto.pending[j].rel){value=parseInt(value,2);value=(value>>>0)-(elto.elto_ptr+WORD_BYTES);if(value<0){value=(value>>>0).toString(2);value="1"+value.replace(/^[1]+/g,"");value=value.padStart(elto.pending[j].n_bits,"1")}else{value=value.toString(2)}}}if(value.length>elto.pending[j].n_bits){return asm_langError(context,"'"+elto.pending[j].label+"'"+i18n_get_TagFor("compiler","NEEDS")+value.length+i18n_get_TagFor("compiler","SPACE FOR # BITS")+elto.pending[j].n_bits+" "+i18n_get_TagFor("compiler","BITS"))}value=value.padStart(elto.pending[j].n_bits,"0");arr_encoded=elto.binary.split("");for(var k=elto.pending[j].start_bit;k<=elto.pending[j].stop_bit;k++){arr_encoded[k]=value[k-elto.pending[j].start_bit]}elto.binary=arr_encoded.join("");if("field-data"==elto.pending[j].type){elto.value=parseInt(value,2)}}}for(var key in ret.labels_asm){ret.hash_labels_asm_rev[ret.labels_asm[key]]=key}for(var skey in ret.seg){ret.hash_seg_rev.push({begin:parseInt(ret.seg[skey].begin),name:skey})}return ret}function wsasm_writememory_if_word(mp,gen,track_source,track_comments){if(gen.byteWordparseInt(gen.addr)/WORD_BYTES){wsasm_zeropadding_and_writememory(ret.mp,gen);gen.addr="0x"+ret.obj[i].elto_ptr.toString(16)}if(wsasm_has_datatype_attr(ret.obj[i].datatype,"align")){var elto_align=ret.obj[i].byte_size;if(elto_align>1){var last_assigned=parseInt(gen.addr)+gen.byteWord;var padding=elto_align-last_assigned%elto_align;for(var k=0;k>>0).toString(2);if(ret.obj[i].value<0)valuebin=valuebin.substr(valuebin.length-n_bytes*BYTE_LENGTH,n_bytes*BYTE_LENGTH);else valuebin=valuebin.padStart(n_bytes*BYTE_LENGTH,"0");for(let j=0;jstr.length-1)return str;return str.substring(0,index)+chr+str.substring(index+1)}function assembly_replace(machineCode,num_bits,startbit,stopbit,bits,free_space){if(startbit!==undefined&&stopbit!==undefined){var machineCodeAux=machineCode.substring(0,machineCode.length-startbit+free_space);machineCode=machineCodeAux+num_bits+machineCode.substring(machineCode.length-stopbit);if(machineCode.length<32){machineCode="0".repeat(32-machineCode.length)+machineCode}}else{console.log("Previous machine code: "+machineCode);var j=num_bits.length-1;for(var k=0;k=31-bits[k][0];i--){if(j>=0){machineCode=setCharAt(machineCode,i,num_bits[j]);j--;console.log(machineCode)}}}}return machineCode}function simlang_compile_prepare_context(datosCU){var context={};context.line=1;context.error=null;context.i=0;context.contadorMC=0;context.etiquetas={};context.labelsNotFound=[];context.instrucciones=[];context.co_cop={};context.oc_eoc={};context.registers=[];context.text="";context.tokens=[];context.token_types=[];context.t=0;context.newlines=[];context.pseudoInstructions=[];context.stackRegister=null;context.firmware={};context.comments=[];for(i=0;i=0){return asm_langError(context,i18n_get_TagFor("compiler","INVALID ALIGN VALUE")+"'"+possible_value+"'. "+i18n_get_TagFor("compiler","REMEMBER ALIGN VAL"))}writememory_and_reset(ret.mp,gen,1);var align_offset=Math.pow(2,parseInt(possible_value));switch(align_offset){case 1:break;case 2:if(gen.byteWord&1==1)gen.byteWord++;break;default:writememory_and_reset(ret.mp,gen,1);while(gen.seg_ptr%align_offset!=0||gen.byteWord!=0){gen.byteWord++;writememory_and_reset(ret.mp,gen,1)}}asm_nextToken(context)}else if(".ascii"==possible_datatype||".asciiz"==possible_datatype||".string"==possible_datatype){asm_nextToken(context);var possible_value=asm_getToken(context);var ret1=treatControlSequences(possible_value);if(true==ret1.error)return asm_langError(context,ret1.string);possible_value=ret1.string;while(!is_directive(asm_getToken(context))&&!is_end_of_file(context)){writememory_and_reset(ret.mp,gen,1);if('"'!==possible_value[0]){return asm_langError(context,i18n_get_TagFor("compiler","NO QUOTATION MARKS")+"'"+possible_value+"'")}if('"'!==possible_value[possible_value.length-1]){return asm_langError(context,i18n_get_TagFor("compiler","NOT CLOSED STRING"))}if(""==possible_value){return asm_langError(context,i18n_get_TagFor("compiler","NOT CLOSED STRING"))}if("STRING"!=asm_getTokenType(context)){return asm_langError(context,i18n_get_TagFor("compiler","NO QUOTATION MARKS")+"'"+possible_value+"'")}for(i=0;i0){var melto={value:gen.machineCode,source_tracking:gen.track_source,comments:gen.comments};main_memory_set(ret.mp,"0x"+gen.seg_ptr.toString(16),melto);gen.seg_ptr=gen.seg_ptr+WORD_BYTES}ret.seg[seg_name].end=gen.seg_ptr}function read_text_v3(context,datosCU,ret){console.log(context.firmware);var seg_name=asm_getToken(context);var seg_ptr=ret.seg[seg_name].begin;var error="";asm_nextToken(context);while(!is_directive_segment(asm_getToken(context))&&!is_end_of_file(context)){while(typeof context.firmware[asm_getToken(context)]==="undefined"&&!is_end_of_file(context)){var possible_tag=asm_getToken(context);if("TAG"!=asm_getTokenType(context)){if(""==possible_tag)possible_tag="[empty]";return asm_langError(context,i18n_get_TagFor("compiler","NO TAG, DIR OR INS")+"'"+possible_tag+"'")}var tag=possible_tag.substring(0,possible_tag.length-1);if(!isValidTag(tag)){return asm_langError(context,i18n_get_TagFor("compiler","INVALID TAG FORMAT")+"'"+tag+"'")}if(context.firmware[tag]){return asm_langError(context,i18n_get_TagFor("compiler","TAG OR INSTRUCTION")+"'"+tag+"'")}if(ret.labels_asm[tag]){return asm_langError(context,i18n_get_TagFor("compiler","REPEATED TAG")+"'"+tag+"'")}ret.labels_asm[tag]="0x"+seg_ptr.toString(16);asm_nextToken(context)}if(is_end_of_file(context))break;var instruction=asm_getToken(context);var signature_fields=[];var signature_user_fields=[];var advance=[];var max_length=0;var binaryAux=[];var firmware_instruction_length=0;if(typeof context.firmware[instruction]!=="undefined"){firmware_instruction_length=context.firmware[instruction].length}var val=[];for(i=0;i=signature_fields[j].length){if("TAG"!=asm_getTokenType(context)&&!context.firmware[value]&&!is_end_of_file(context))advance[j]=0;continue}var field=context.firmware[instruction][j].fields[i];console.log(field);if(field.startbit!==undefined&&field.stopbit!==undefined)var size=field.startbit-field.stopbit+1;else var size=bits_size(field.bits);var label_found=false;var sel_found=false;switch(field.type){case"address":case"inm":case"imm":var ret1=get_inm_value(value);converted=ret1.number;if(ret1.isDecimal==false&&ret1.isFloat==false){error=i18n_get_TagFor("compiler","NO NUMERIC DATATYPE")+"'"+value+"'";if(value[0]=="'"){advance[j]=0;break}if(!isValidTag(value)){advance[j]=0;break}if(context.firmware[value]){error=i18n_get_TagFor("compiler","TAG OR INSTRUCTION")+"'"+value+"'";advance[j]=0;break}label_found=true}if(!label_found){if(ret1.isDecimal==true)var res=decimal2binary(converted,size);else var res=float2binary(converted,size);if(field.type=="address"&&"rel"==field.address_type){res=decimal2binary(converted,size)}}console.log("Inmediato: "+ret1);break;case"reg":if(typeof value==="undefined"){error=i18n_get_TagFor("compiler","INS. MISSING FIELD");advance[j]=0;break}var aux=false;if(value.startsWith("(")){if("(reg)"!=signature_fields[j][i]){error=i18n_get_TagFor("compiler","UNEXPECTED (REG)");advance[j]=0;break}asm_nextToken(context);value=asm_getToken(context);aux=true}else{if("(reg)"==signature_fields[j][i]){error=i18n_get_TagFor("compiler","EXPECTED (REG)")+"'"+value+"'";advance[j]=0;break}}if(typeof context.registers[value]==="undefined"){error=i18n_get_TagFor("compiler","EXPECTED REG")+"'"+value+"'";advance[j]=0;break}if(aux){s[i+1]="("+value+")";asm_nextToken(context);aux=asm_getToken(context);if(")"!=aux){error=i18n_get_TagFor("compiler","CLOSE PAREN. NOT FOUND");advance[j]=0;break}}var ret1=isDecimal(context.registers[value]);converted=ret1.number;var res=decimal2binary(converted,size);value=s[i+1];break;default:return asm_langError(context,i18n_get_TagFor("compiler","UNKNOWN 1")+"'"+field.type+"'")}if(advance[j]==1&&!label_found){if(res[1]<0){if(field.type=="address"&&"rel"==field.address_type){error="Relative value ("+(converted-seg_ptr-WORD_BYTES)+" in decimal)"+i18n_get_TagFor("compiler","NEEDS")+res[0].length+i18n_get_TagFor("compiler","SPACE FOR # BITS")+size+" "+i18n_get_TagFor("compiler","BITS")}else{error="'"+value+"'"+i18n_get_TagFor("compiler","NEEDS")+res[0].length+i18n_get_TagFor("compiler","SPACE FOR # BITS")+size+" "+i18n_get_TagFor("compiler","BITS")}advance[j]=0}}if(advance[j]==1){binaryAux[j][i]={num_bits:label_found?false:res[0],free_space:label_found?false:res[1],startbit:field.startbit,stopbit:field.stopbit,bits:field.bits,rel:label_found?field.address_type:false,islabel:label_found,field_name:value}}}if(sum_array(advance)==0)break;if("TAG"==asm_getTokenType(context)||context.firmware[value])break}for(i=0;i0&&i0&&i==context.firmware[instruction].length-1)format+=" or ";format+="'"+context.firmware[instruction][i].signatureUser+"'"}if(format==""){format="'"+instruction+"' "+i18n_get_TagFor("compiler","UNKNOWN MC FORMAT")}var sum_res=sum_array(advance);if(sum_res==0){if(advance.length===1){return asm_langError(context,error+".
"+i18n_get_TagFor("compiler","REMEMBER I. FORMAT")+format)}return asm_langError(context,i18n_get_TagFor("compiler","NOT MATCH MICRO")+"
"+i18n_get_TagFor("compiler","REMEMBER I. FORMAT")+format+". "+i18n_get_TagFor("compiler","CHECK MICROCODE"))}if(sum_res>1){candidate=get_candidate(advance,firmware[instruction]);if(candidate===false){return asm_langError(context,i18n_get_TagFor("compiler","SEVERAL CANDIDATES")+format)}}var machineCode=reset_assembly(context.firmware[instruction][candidate].nwords);console.log("Código máquina original: "+machineCode);if(context.firmware[instruction][candidate].co!==false){machineCode=assembly_co_cop(machineCode,context.firmware[instruction][candidate].co,context.firmware[instruction][candidate].cop);console.log("Código máquina co+cop: "+machineCode)}else{console.log(context.firmware[instruction][candidate]);machineCode=assembly_oc_eoc(machineCode,context.firmware[instruction][candidate].oc,context.firmware[instruction][candidate].eoc);console.log("OC: "+context.firmware[instruction][candidate].oc);console.log("EOC: "+context.firmware[instruction][candidate].eoc);console.log("Código máquina oc+eoc: "+machineCode)}var l_addr="";for(i=0;i=0;i--){if(icontext.text.length)break}ret.seg[seg_name].end=seg_ptr}function simlang_compile_pass1(context,datosCU,text){var ret={};ret.seg=sim_segments;ret.mp={};ret.labels={};ret.labels_asm={};ret.hash_labels_asm_rev={};ret.hash_seg_rev=[];ret.data_found=false;ret.text_found=false;asm_nextToken(context);while(!is_end_of_file(context)){var segname=asm_getToken(context);if(typeof ret.seg[segname]==="undefined"){return asm_langError(context,i18n_get_TagFor("compiler","INVALID SEGMENT NAME")+"'"+segname+"'")}if("data"==ret.seg[segname].kindof){read_data_v3(context,ret);ret.data_found=true}if("text"==ret.seg[segname].kindof){read_text_v3(context,datosCU,ret);ret.text_found=true}if(context.error!=null){ret.error=context.error;return ret}}return ret}function simlang_compile_pass2(context,ret){return ret}function simlang_compile_pass3(context,ret){for(var i in ret.labels){var value=ret.labels_asm[ret.labels[i].name];if(typeof value==="undefined"){asm_setLabelContext(context,ret.labels[i].labelContext);return asm_langError(context,i18n_get_TagFor("compiler","LABEL NOT DEFINED")+"'"+ret.labels[i].name+"'")}var machineCode="";var auxAddr=ret.labels[i].addr;for(j=0;j=0;j--){var melto={value:machineCode.substring(j*WORD_LENGTH,(j+1)*WORD_LENGTH),source_tracking:null,comments:null};main_memory_set(ret.mp,"0x"+auxAddr.toString(16),melto);auxAddr+=WORD_BYTES}}if(ret.text_found){if(typeof ret.labels_asm["main"]==="undefined"&&typeof ret.labels_asm["kmain"]==="undefined"){return asm_langError(context,i18n_get_TagFor("compiler","NO MAIN OR KMAIN"))}}for(var key in ret.labels_asm){ret.hash_labels_asm_rev[ret.labels_asm[key]]=key}for(var skey in ret.seg){ret.hash_seg_rev.push({begin:parseInt(ret.seg[skey].begin),name:skey})}return ret}function simlang_compile_v3(text,datosCU){var context=simlang_compile_prepare_context(datosCU);context.text=text;var ret=simlang_compile_pass1(context,datosCU,text);if(ret.error!=null){return ret}ret=simlang_compile_pass2(context,ret);console.log(ret);if(ret.error!=null){return ret}ret=simlang_compile_pass3(context,ret);if(ret.error!=null){return ret}return ret}function simlang_compile(text,datosCU){var ret=null;if(typeof ws_ng!="undefined"){ret=wsasm_src2mem(datosCU,text)}ret=simlang_compile_v2(text,datosCU);return ret}
\ No newline at end of file
diff --git a/ws_dist/min.wepsim_node.js b/ws_dist/min.wepsim_node.js
index 7378b55cd..3d939fef2 100644
--- a/ws_dist/min.wepsim_node.js
+++ b/ws_dist/min.wepsim_node.js
@@ -35,7 +35,7 @@
Vuex.Store = class {
} ;
-var WSCFG={};function get_cfg(field){return WSCFG[field].value}function set_cfg(field,value){WSCFG[field].value=value}function update_cfg(field,value){WSCFG[field].value=value;simcore_record_append_new("Set configuration option "+field+" to "+value,'update_cfg("'+field+'","'+value+'");\n');simcore_ga("config","config."+WSCFG.version.value,"config."+WSCFG.version.value+"."+field+"."+value);save_cfg()}function is_cfg_empty(){return Object.keys(WSCFG).length===0}function save_cfg(){try{for(var item in WSCFG){localStorage.setItem("wepsim_"+item,get_cfg(item))}}catch(err){console.log("WepSIM can not save the configuration in a persistent way on this web browser,\n"+"found following error: \n"+err.message)}set_secondary_cfg()}function restore_cfg(){WSCFG=get_primary_cfg();set_secondary_cfg();if(localStorage===null){return}var default_value=null;var saved_value=null;for(var item in WSCFG){if(item==="version"){continue}default_value=get_cfg(item);set_cfg(item,localStorage.getItem("wepsim_"+item));if(WSCFG[item].type!="string"){try{saved_value=JSON.parse(get_cfg(item));set_cfg(item,saved_value)}catch(e){saved_value=null}}if(saved_value===null){set_cfg(item,default_value)}}set_secondary_cfg()}function reset_cfg(){WSCFG=get_primary_cfg();set_secondary_cfg();save_cfg()}function reset_cfg_values(){WSCFG=get_primary_cfg();set_secondary_cfg()}function upgrade_cfg(){var wscfg=get_primary_cfg();var item=null;for(item in wscfg){if(typeof WSCFG[item]==="undefined"){WSCFG[item]=wscfg[item]}if(WSCFG[item].value===null||WSCFG[item].value==="null"){WSCFG[item].value=wscfg[item].value}}if(wscfg.build.value!=WSCFG.build.value){for(item in wscfg){if(wscfg[item].upgrade){WSCFG[item]=wscfg[item]}}}set_secondary_cfg();save_cfg()}function is_mobile(){if(typeof navigator==="undefined"){return false}if(typeof navigator.userAgentData=="undefined"){return false}return navigator.userAgentData.mobile}function is_cordova(){return document.URL.indexOf("http://")===-1&&document.URL.indexOf("https://")===-1}function get_primary_cfg(){var wscfg={version:{upgrade:false,type:"string",value:"2.3.0"},build:{upgrade:true,type:"string",value:"2.3.0.20230701A"},color_data_active:{upgrade:false,type:"string",value:"#0066FF"},color_data_inactive:{upgrade:false,type:"string",value:"#000000"},color_name_active:{upgrade:false,type:"string",value:"#FF0000"},color_name_inactive:{upgrade:false,type:"string",value:"#000000"},size_active:{upgrade:false,type:"float",value:3},size_inactive:{upgrade:false,type:"float",value:1},is_byvalue:{upgrade:false,type:"boolean",value:false},CPUCU_show_graph:{upgrade:false,type:"boolean",value:true},RF_display_format:{upgrade:false,type:"string",value:"unsigned_16_fill"},RF_display_name:{upgrade:false,type:"string",value:"numerical"},MEM_display_format:{upgrade:false,type:"string",value:"unsigned_16_nofill"},MEM_show_segments:{upgrade:false,type:"boolean",value:false},MEM_show_source:{upgrade:false,type:"boolean",value:false},MEM_display_direction:{upgrade:false,type:"string",value:"h2l"},is_editable:{upgrade:false,type:"boolean",value:true},DBG_delay:{upgrade:false,type:"int",value:5},DBG_level:{upgrade:false,type:"string",value:"microinstruction"},DBG_limitins:{upgrade:false,type:"int",value:1e4},DBG_limitick:{upgrade:false,type:"int",value:1e3},DBG_skip_notifycolon:{upgrade:false,type:"boolean",value:false},ICON_theme:{upgrade:false,type:"string",value:"classic"},AS_enable:{upgrade:false,type:"boolean",value:true},AS_delay:{upgrade:false,type:"int",value:500},NOTIF_delay:{upgrade:false,type:"int",value:1e3},CPUCU_size:{upgrade:false,type:"int",value:7},C1C2_size:{upgrade:false,type:"int",value:8},SHOWCODE_label:{upgrade:false,type:"boolean",value:true},SHOWCODE_addr:{upgrade:false,type:"boolean",value:true},SHOWCODE_hex:{upgrade:false,type:"boolean",value:true},SHOWCODE_ins:{upgrade:false,type:"boolean",value:true},SHOWCODE_pins:{upgrade:false,type:"boolean",value:true},ws_mode:{upgrade:false,type:"string",value:"newbie"},ws_action:{upgrade:false,type:"string",value:"checkpoint"},is_interactive:{upgrade:false,type:"boolean",value:true},is_quick_interactive:{upgrade:false,type:"boolean",value:false},ws_idiom:{upgrade:false,type:"string",value:"en"},use_voice:{upgrade:false,type:"boolean",value:false},ws_skin_ui:{upgrade:false,type:"string",value:"classic"},ws_skin_user:{upgrade:false,type:"string",value:"only_asm:of:only_frequent:of"},ws_skin_dark_mode:{upgrade:false,type:"boolean",value:false},editor_theme:{upgrade:false,type:"string",value:"default"},editor_mode:{upgrade:false,type:"string",value:"default"},base_url:{upgrade:true,type:"string",value:"https://acaldero.github.io/wepsim/ws_dist/"},cfg_url:{upgrade:true,type:"string",value:"repo/configuration/default.json"},example_url:{upgrade:true,type:"string",value:"repo/examples_set/default.json"},hw_url:{upgrade:true,type:"string",value:"repo/hardware/hw.json"},max_json_size:{upgrade:true,type:"int",value:1*1024*1024},verbal_verbose:{upgrade:false,type:"string",value:"math"},extended_ui:{upgrade:false,type:"boolean",value:false},use_ga:{upgrade:false,type:"boolean",value:true}};if(is_mobile()){wscfg.NOTIF_delay.value=2e3;wscfg.ICON_theme.value="cat1";wscfg.CPUCU_size.value=7;wscfg.C1C2_size.value=14;wscfg.ws_skin_ui.value="compact"}return wscfg}function set_secondary_cfg(){var dbg_delay=get_cfg("DBG_delay");if(dbg_delay<5){cfg_show_rf_delay=350;cfg_show_eltos_delay=350;cfg_show_main_memory_delay=450;cfg_show_control_memory_delay=360;cfg_show_dbg_ir_delay=300;cfg_show_rf_refresh_delay=120}else{cfg_show_rf_delay=100;cfg_show_eltos_delay=100;cfg_show_main_memory_delay=150;cfg_show_control_memory_delay=120;cfg_show_dbg_ir_delay=100;cfg_show_rf_refresh_delay=30}cfg_show_asmdbg_pc_delay=50;if(dbg_delay<3)cfg_show_asmdbg_pc_delay=150}var ws_cfg_hash={};var ws_cfg_set=[];function cfgset_init(){var url_list=get_cfg("cfg_url");ws_cfg_set=wepsim_url_getJSON(url_list);for(var i=0;i"+index+"/"+ws_records.length+" "+msg)}if(ws_record_pb_obj!==null){var next_pbval=100*index/ws_records.length;ws_record_pb_obj.css("width",next_pbval+"%").attr("aria-valuenow",next_pbval)}}function simcore_record_playAt(index_current,index_last){if(ws_is_playing===false){simcore_record_showMsg(ws_last_played,"Stopped by user.");return}ws_last_played=index_current;if(index_current>=index_last){simcore_record_showMsg(index_last,"Done.");return}if(ws_records[index_current].description==="_pending event_"){simcore_record_playAt(index_current+1,index_last);return}eval(ws_records[index_current].element);var index_next=index_current+1;simcore_record_showMsg(index_next,ws_records[index_current].description);var wait_time=500;if(index_next0&&ws_records[ws_records.length-1].description==="_pending event_"){distance=ws_glowing_time}simcore_record_pushElto("_pending event_",";",distance)}}function simcore_record_resolve_pending(description,elto){if(ws_is_recording===true){var last_pending=ws_records.length;while(last_pending>0){last_pending--;if(ws_records[last_pending].description==="_pending event_"){break}}if(last_pending===0){simcore_record_setTimeBeforeNow(0);simcore_record_append_new(description,elto);return}ws_records[last_pending].description=description;ws_records[last_pending].element=elto;simcore_record_showMsg(0,"Recording...")}}function simcore_record_setTimeBeforeNow(distance){ws_last_time=Date.now()-distance}function simcore_record_addTimeAfterLast(distance){ws_last_time=ws_last_time+distance}function array_includes(arr,val){if(typeof arr.includes!="undefined"){return arr.includes(val)}for(var i=0;i0){e=i;n=n+1}}if(n>0){var tri_state_names=simhw_internalState("tri_state_names");var tri_name=tri_state_names[e];update_draw(simhw_sim_signal(tri_name),1)}if(n>1){update_bus_visibility("internalbus_fire","visible");simhw_internalState_set("fire_visible","internalbus",true);simhw_sim_state("BUS_IB").value=4294967295}else{update_bus_visibility("internalbus_fire","hidden");simhw_internalState_set("fire_visible","internalbus",false)}return n}function update_system_bus_fire(number_active_tri){if(simhw_internalState_get("fire_visible","databus")==true){update_bus_visibility("databus_fire","hidden");simhw_internalState_set("fire_visible","databus",false)}if(number_active_tri>1){update_bus_visibility("databus_fire","visible");simhw_internalState_set("fire_visible","databus",true);simhw_sim_state("BUS_DB").value=4294967295}return number_active_tri}function fn_updateE_now(key){if("E"==simhw_sim_signal(key).type){update_state(key)}}function fn_updateE_future(key){if(jit_fire_ndep[key]<1)fn_updateE_now(key);else return new Promise((function(resolve,reject){fn_updateE_now(key)}))}function fn_updateL_now(key){update_draw(simhw_sim_signal(key),simhw_sim_signal(key).value);if("L"==simhw_sim_signal(key).type){update_state(key)}}function fn_updateL_future(key){if(jit_fire_ndep[key]<1)fn_updateL_now(key);else return new Promise((function(resolve,reject){fn_updateL_now(key)}))}function update_state(key){var index_behavior=0;switch(simhw_sim_signal(key).behavior.length){case 0:return;break;case 1:index_behavior=0;break;default:index_behavior=simhw_sim_signal(key).value;if(simhw_sim_signal(key).behavior.lengthreg_maddr){break}assoc_i=i}if(-1==assoc_i){ws_alert("A new 'unknown' instruction is inserted,\n"+"please edit it (co, nwords, etc.) in the firmware textarea.");var new_ins=new Object;new_ins["name"]="unknown";new_ins["signature"]="unknown";new_ins["signatureGlobal"]="unknown";new_ins["co"]=0;new_ins["nwords"]=0;new_ins["mc-start"]=0;new_ins["fields"]=new Array;new_ins["microcode"]=new Array;new_ins["microcomments"]=new Array;SIMWARE["firmware"].push(new_ins);assoc_i=SIMWARE["firmware"].length-1}var pos=reg_maddr-parseInt(SIMWARE["firmware"][assoc_i]["mc-start"]);if(typeof SIMWARE["firmware"][assoc_i]["microcode"][pos]=="undefined"){SIMWARE["firmware"][assoc_i]["microcode"][pos]=new Object;SIMWARE["firmware"][assoc_i]["microcomments"][pos]=""}SIMWARE["firmware"][assoc_i]["microcode"][pos][key]=simhw_sim_signal(key).value;if(simhw_sim_signal(key).default_value==simhw_sim_signal(key).value){delete SIMWARE["firmware"][assoc_i]["microcode"][pos][key]}var bits=get_value(simhw_sim_state("REG_IR")).toString(2);bits="00000000000000000000000000000000".substring(0,32-bits.length)+bits;show_memories_values()}function propage_signal_update(key){if(true===get_cfg("is_interactive")){if(simhw_sim_signal(key).value!=simhw_sim_signal(key).default_value)simhw_sim_state("REG_MICROINS").value[key]=simhw_sim_signal(key).value;else delete simhw_sim_state("REG_MICROINS").value[key];var maddr_name=simhw_sim_ctrlStates_get().mpc.state;var curr_maddr=get_value(simhw_sim_state(maddr_name));var mc_obj=simhw_internalState("MC");var mcelto=control_memory_get(mc_obj,curr_maddr);if(typeof mcelto==="undefined"){mcelto={value:{},comments:null}}mcelto.value[key]=simhw_sim_signal(key).value;mcelto.comments=[];control_memory_set(mc_obj,curr_maddr,mcelto);update_signal_firmware(key);var SIMWARE=get_simware();document.getElementById("inputFirmware").value=saveFirmware(SIMWARE)}compute_behavior("FIRE "+key)}function update_memories(preSIMWARE){var i=0;set_simware(preSIMWARE);var SIMWARE=get_simware();simhw_internalState_reset("MC",{});var mc_obj=simhw_internalState("MC");var mcelto=null;for(i=0;i>23&255)-127;var mantissa=1+(hexvalue&8388607)/8388608;var valuef=sign*mantissa*Math.pow(2,exponent);if(-127===exponent)if(1===mantissa)valuef=sign===1?"+0":"-0";else valuef=sign*((hexvalue&8388607)/8388607)*Math.pow(2,-126);if(128===exponent)if(1===mantissa)valuef=sign===1?"+Inf":"-Inf";else valuef="NaN";return valuef}function uint_to_float32(value){var buf=new ArrayBuffer(4);new Uint32Array(buf)[0]=value;return new Float32Array(buf)[0]}function float32_to_uint(value){var buf=new ArrayBuffer(4);new Float32Array(buf)[0]=value;return new Uint32Array(buf)[0]}function float_class(a){var s=a&2147483648;s=s>>31;var e=a&2139095040;e=e>>23;var m=a&8388607;let rd=0;if(!m&&!e){rd=s?3:4}else if(!e){rd=s?2:6}else if(!(e^255)){if(m)rd=s?8:9;else rd=s?0:7}else{rd=s?1:5}return rd}function float_class_power2(a){var s=a&2147483648;s=s>>31;var e=a&2139095040;e=e>>23;var m=a&8388607;let rd=0;if(!m&&!e){rd=s?1<<3:1<<4}else if(!e){rd=s?1<<2:1<<6}else if(!(e^255)){if(m)rd=s?1<<8:1<<9;else rd=s?1<<0:1<<7}else{rd=s?1<<1:1<<5}return rd}function hex2char8(hexvalue){var valuec=[];valuec[0]=String.fromCharCode((hexvalue&4278190080)>>24);valuec[1]=String.fromCharCode((hexvalue&16711680)>>16);valuec[2]=String.fromCharCode((hexvalue&65280)>>8);valuec[3]=String.fromCharCode((hexvalue&255)>>0);return valuec}function simcoreui_pack(val,pack_size){var base_str="0".repeat(pack_size);return base_str.substring(0,pack_size-val.length)+val}function hex2bin(hexvalue){var valuebin=hexvalue.toString(2);valuebin=simcoreui_pack(valuebin,32);valuebin=valuebin.substring(0,4)+" "+valuebin.substring(4,8)+" "+valuebin.substring(8,12)+" "+valuebin.substring(12,16)+"
"+valuebin.substring(16,20)+" "+valuebin.substring(20,24)+" "+valuebin.substring(24,28)+" "+valuebin.substring(28,32);return valuebin}function value2string(format,value){var fmt_value="";var fmt=format.split("_");switch(fmt[0]){case"unsigned":fmt_value=value.toString(fmt[1]).toUpperCase();break;case"float":fmt_value=hex2float(value);break;case"char":fmt_value="'"+String.fromCharCode(value)+"'";break;default:fmt_value=value.toString()}if(fmt[2]==="fill"){fmt_value=simcoreui_pack(fmt_value,8)}return fmt_value}function show_rf_names(){return simcore_action_ui("CPU",0,"show_rf_names")()}function get_screen_content(){return simcore_action_ui("SCREEN",0,"get_screen_content")()}function set_screen_content(screen){simcore_action_ui("SCREEN",0,"set_screen_content")(screen)}function get_keyboard_content(){return simcore_action_ui("KBD",0,"get_keyboard_content")()}function set_keyboard_content(keystrokes){simcore_action_ui("KBD",0,"set_keyboard_content")(keystrokes)}function show_main_memory(memory,index,redraw,updates){return simcore_action_ui("MEMORY",0,"show_main_memory")(memory,index,redraw,updates)}function show_control_memory(memory,index,redraw){return simcore_action_ui("MEMORY",0,"show_control_memory")(memory,index,redraw)}function show_cache_memory(memory){return simcore_action_ui("MEMORY",0,"show_cache_memory")(memory)}function show_memories_values(){var pc_name=simhw_sim_ctrlStates_get().pc.state;var reg_pc=get_value(simhw_sim_state(pc_name));show_main_memory(simhw_internalState("MP"),reg_pc,true,true);var maddr_name=simhw_sim_ctrlStates_get().mpc.state;var reg_maddr=get_value(simhw_sim_state(maddr_name));show_control_memory(simhw_internalState("MC"),reg_maddr,true);show_cache_memory(simhw_internalState("CM"))}function update_draw(obj,value){return simcore_action_ui("CPU",1,"update_draw")(obj,value)}function update_bus_visibility(bus_name,value){return simcore_action_ui("CPU",1,"update_bus_visibility")(bus_name,value)}function refresh(){for(var key in simhw_sim_signals()){update_draw(simhw_sim_signals()[key],simhw_sim_signals()[key].value)}show_dbg_ir(get_value(simhw_sim_state("REG_IR_DECO")))}function show_dbg_ir(value){return simcore_action_ui("MEMORY",0,"show_dbg_ir")(value)}function show_dbg_mpc(){return simcore_action_ui("MEMORY",0,"show_dbg_mpc")()}function show_asmdbg_pc(){return simcore_action_ui("MEMORY",0,"show_asmdbg_pc")()}function ws_alert(msg){if(typeof document==="undefined"){console.log(msg);return true}alert(msg);return true}function element_scroll_get(list_id){var offset=0;var obj_byid=$(list_id);if(obj_byid.length>0){offset=obj_byid[0].scrollTop}return offset}function element_scroll_set(list_id,offset){var obj_byid=$(list_id);if(obj_byid.length>0){obj_byid[0].scrollTop=offset}}function element_scroll_setRelative(list_id,obj_id,offset){var obj_byid=$(obj_id);if(obj_byid.length>0){var topPos=obj_byid[0].offsetTop;element_scroll_set(list_id,topPos+offset)}}var colors_schemes={color14:["#000000","#FFFFFF","#FF0000","#FF8800","#FFFF00","#88FF00","#00FF00","#00FF88","#00FFFF","#0088FF","#0000FF","#8800FF","#FF00FF","#FF0088"],color16:["#000000","#FFFFFF","#9D9D9D","#BE2633","#E06F8B","#493C2B","#A46422","#EB8931","#F7E26B","#2F484E","#44891A","#A3CE27","#1B2632","#005784","#31A2F2","#B2DCEF"],color256:["#000000","#800000","#008000","#808000","#000080","#800080","#008080","#c0c0c0","#808080","#ff0000","#00ff00","#ffff00","#0000ff","#ff00ff","#00ffff","#ffffff","#000000","#00005f","#000087","#0000af","#0000d7","#0000ff","#005f00","#005f5f","#005f87","#005faf","#005fd7","#005fff","#008700","#00875f","#008787","#0087af","#0087d7","#0087ff","#00af00","#00af5f","#00af87","#00afaf","#00afd7","#00afff","#00d700","#00d75f","#00d787","#00d7af","#00d7d7","#00d7ff","#00ff00","#00ff5f","#00ff87","#00ffaf","#00ffd7","#00ffff","#5f0000","#5f005f","#5f0087","#5f00af","#5f00d7","#5f00ff","#5f5f00","#5f5f5f","#5f5f87","#5f5faf","#5f5fd7","#5f5fff","#5f8700","#5f875f","#5f8787","#5f87af","#5f87d7","#5f87ff","#5faf00","#5faf5f","#5faf87","#5fafaf","#5fafd7","#5fafff","#5fd700","#5fd75f","#5fd787","#5fd7af","#5fd7d7","#5fd7ff","#5fff00","#5fff5f","#5fff87","#5fffaf","#5fffd7","#5fffff","#870000","#87005f","#870087","#8700af","#8700d7","#8700ff","#875f00","#875f5f","#875f87","#875faf","#875fd7","#875fff","#878700","#87875f","#878787","#8787af","#8787d7","#8787ff","#87af00","#87af5f","#87af87","#87afaf","#87afd7","#87afff","#87d700","#87d75f","#87d787","#87d7af","#87d7d7","#87d7ff","#87ff00","#87ff5f","#87ff87","#87ffaf","#87ffd7","#87ffff","#af0000","#af005f","#af0087","#af00af","#af00d7","#af00ff","#af5f00","#af5f5f","#af5f87","#af5faf","#af5fd7","#af5fff","#af8700","#af875f","#af8787","#af87af","#af87d7","#af87ff","#afaf00","#afaf5f","#afaf87","#afafaf","#afafd7","#afafff","#afd700","#afd75f","#afd787","#afd7af","#afd7d7","#afd7ff","#afff00","#afff5f","#afff87","#afffaf","#afffd7","#afffff","#d70000","#d7005f","#d70087","#d700af","#d700d7","#d700ff","#d75f00","#d75f5f","#d75f87","#d75faf","#d75fd7","#d75fff","#d78700","#d7875f","#d78787","#d787af","#d787d7","#d787ff","#d7af00","#d7af5f","#d7af87","#d7afaf","#d7afd7","#d7afff","#d7d700","#d7d75f","#d7d787","#d7d7af","#d7d7d7","#d7d7ff","#d7ff00","#d7ff5f","#d7ff87","#d7ffaf","#d7ffd7","#d7ffff","#ff0000","#ff005f","#ff0087","#ff00af","#ff00d7","#ff00ff","#ff5f00","#ff5f5f","#ff5f87","#ff5faf","#ff5fd7","#ff5fff","#ff8700","#ff875f","#ff8787","#ff87af","#ff87d7","#ff87ff","#ffaf00","#ffaf5f","#ffaf87","#ffafaf","#ffafd7","#ffafff","#ffd700","#ffd75f","#ffd787","#ffd7af","#ffd7d7","#ffd7ff","#ffff00","#ffff5f","#ffff87","#ffffaf","#ffffd7","#ffffff","#080808","#121212","#1c1c1c","#262626","#303030","#3a3a3a","#444444","#4e4e4e","#585858","#626262","#6c6c6c","#767676","#808080","#8a8a8a","#949494","#9e9e9e","#a8a8a8","#b2b2b2","#bcbcbc","#c6c6c6","#d0d0d0","#dadada","#e4e4e4","#eeeeee"]};function colors_clone(cs){var colors=colors_schemes[cs];if(typeof colors=="undefined"){colors=colors_schemes["color16"]}return colors.map((x=>x))}function simcore_init(with_ui){var ret={};ret.msg="";ret.ok=true;if(with_ui){restore_cfg()}else{reset_cfg_values()}return ret}function simcore_init_hw(simhw_name){var ret={};ret.msg="";ret.ok=true;var hwid=simhw_getIdByName(simhw_name);if(hwid<0){ret.msg="ERROR: unknown hardware: "+simhw_name+".
\n";ret.ok=false;return ret}simhw_setActive(hwid);var ret1=simcore_init_ui({});if(false===ret1.ok){ret.msg=ret.msg;ret.ok=false;return ret}return ret}function simcore_welcome(){var ret={};ret.msg="";ret.ok=true;console.log("");console.log("██╗ ██╗███████╗██████╗ ███████╗██╗███╗ ███╗");console.log("██║ ██║██╔════╝██╔══██╗██╔════╝██║████╗ ████║");console.log("██║ █╗ ██║█████╗ ██████╔╝███████╗██║██╔████╔██║");console.log("██║███╗██║██╔══╝ ██╔═══╝ ╚════██║██║██║╚██╔╝██║");console.log("╚███╔███╔╝███████╗██║ ███████║██║██║ ╚═╝ ██║");console.log(" ╚══╝╚══╝ ╚══════╝╚═╝ ╚══════╝╚═╝╚═╝ ╚═╝");console.log("");console.log("Stable: https://github.com/wepsim/wepsim");console.log("Beta: https://github.com/acaldero/wepsim");console.log("");return ret}function simcore_init_ui(hash_detail2init){var ret={};ret.msg="";ret.ok=true;var detail_id=0;var sim_components=simhw_sim_components();for(var elto in sim_components){sim_components[elto].details_ui=[];for(var index in sim_components[elto].details_name){sim_components[elto].details_ui[index]={};detail_id=sim_components[elto].details_name[index];if(typeof hash_detail2init[detail_id]!=="undefined"){sim_components[elto].details_ui[index]=hash_detail2init[detail_id];sim_components[elto].details_ui[index].init()}}}return ret}function simcore_action_ui(component_name,detail_id,action_name){var sim_components=simhw_sim_components();if(typeof sim_components[component_name].details_ui==="undefined"){return simcore_do_nothing_handler}if(typeof sim_components[component_name].details_ui[detail_id][action_name]==="undefined"){return simcore_do_nothing_handler}return sim_components[component_name].details_ui[detail_id][action_name]}function simcore_init_eventlistener(context,hash_detail2action,hash_signal2action){var context_obj=null;var r=[];var o=null;context_obj=document.getElementById(context).contentDocument;if(null==context_obj){console.log('warning: unreferenced graphic element context named "'+r[0]+'".');return}var sim_signals=simhw_sim_signals();for(var key in sim_signals){if(typeof hash_signal2action[key+"click"]==="undefined"){hash_signal2action[key+"click"]=function(key_value){return function(){hash_signal2action[""](key_value,"click")}}(key)}if(typeof hash_signal2action[key+"dblclick"]==="undefined"){hash_signal2action[key+"dblclick"]=function(key_value){return function(){hash_signal2action[""](key_value,"dblclick")}}(key)}for(var j=0;j\n"+"Please load some assembly code.
";ret.ok=false;return ret}var SIMWARE=get_simware();if(!(typeof curr_segments[".ktext"]!="undefined"&&SIMWARE.labels2.kmain)&&!(typeof curr_segments[".text"]!="undefined"&&SIMWARE.labels2.main)){ret.msg="labels 'kmain' (in .ktext) or 'main' (in .text) do not exist!";ret.ok=false;return ret}return ret}function simcore_packerror_at(reg_maddr,msg){var ret={};var hex_maddr="0x"+parseInt(reg_maddr).toString(16);ret.ok=false;ret.msg=msg+" at maddr="+hex_maddr+".";return ret}function simcore_check_if_can_continue2(reg_maddr,reg_pc){var ret={};ret.ok=true;ret.msg="";var curr_MC=simhw_internalState("MC");var mcelto=control_memory_get(curr_MC,reg_maddr);if(typeof mcelto==="undefined"){return simcore_packerror_at(reg_maddr,"Error: undefined microinstruction")}if(simhw_internalState_get("fire_visible","databus")==true||simhw_internalState_get("fire_visible","internalbus")==true){return simcore_packerror_at(reg_maddr,"Error: two or more tri-states are active")}var curr_segments=simhw_internalState("segments");if(reg_pc=curr_segments[".ktext"].begin){return ret}if(reg_pc=curr_segments[".text"].begin){return ret}if(mcelto.is_native&&0===reg_maddr){if(reg_pc==curr_segments[".ktext"].end||reg_pc==curr_segments[".text"].end){return ret}}if(false==mcelto.is_native&&0!==reg_maddr){if(reg_pc==curr_segments[".ktext"].end||reg_pc==curr_segments[".text"].end){return ret}}ret.ok=false;ret.msg="The program has finished because the PC register points outside .ktext/.text code segments";return ret}function simcore_check_if_can_continue(){var pc_name=simhw_sim_ctrlStates_get().pc.state;var reg_pc=parseInt(get_value(simhw_sim_state(pc_name)));var maddr_name=simhw_sim_ctrlStates_get().mpc.state;var reg_maddr=get_value(simhw_sim_state(maddr_name));return simcore_check_if_can_continue2(reg_maddr,reg_pc)}function simcore_reset(){var ret={};ret.msg="";ret.ok=true;var SIMWARE=get_simware();var curr_firm=simhw_internalState("FIRMWARE");var curr_segments=simhw_internalState("segments");var curr_MC=simhw_internalState("MC");var sim_components=simhw_sim_components();var ctrl_states=simhw_sim_ctrlStates_get();var pc_name=ctrl_states.pc.state;var pc_state=simhw_sim_state(pc_name);var sp_name=ctrl_states.sp.state;var sp_state=simhw_sim_state(sp_name);if(curr_firm.stackRegister!=null){sp_name=curr_firm.stackRegister;sp_state=simhw_sim_states().BR[sp_name];ctrl_states.sp.state="BR."+curr_firm.stackRegister}for(var elto in sim_components){var reset_signal_name=sim_components[elto].name+"_RESET";compute_general_behavior(reset_signal_name)}if(typeof curr_segments[".ktext"]!=="undefined"&&SIMWARE.labels2.kmain){set_value(pc_state,parseInt(SIMWARE.labels2.kmain));show_asmdbg_pc()}else if(typeof curr_segments[".text"]!=="undefined"&&SIMWARE.labels2.main){set_value(pc_state,parseInt(SIMWARE.labels2.main));show_asmdbg_pc()}if(typeof curr_segments[".stack"]!=="undefined"&&typeof sp_state!=="undefined"){set_value(sp_state,parseInt(curr_segments[".stack"].end)&4294967292)}var new_maddr=get_value(simhw_sim_state("MUXA_MICROADDR"));var mcelto=control_memory_get(curr_MC,new_maddr);if(typeof mcelto==="undefined"){mcelto={value:simhw_sim_state("REG_MICROINS").default_value,is_native:false}}var new_mins=get_value(mcelto);if(false==mcelto.is_native){compute_general_behavior("CLOCK")}show_dbg_ir(get_value(simhw_sim_state("REG_IR_DECO")));for(elto in sim_components){for(var index in sim_components[elto].details_name){if(typeof sim_components[elto].details_ui[index].reset!=="undefined"){sim_components[elto].details_ui[index].reset()}}}return ret}function simcore_execute_microinstruction(){var ret=simcore_check_if_can_continue();if(false===ret.ok){return ret}compute_general_behavior("CLOCK");show_dbg_mpc();return ret}function simcore_execute_microinstruction2(reg_maddr,reg_pc){var ret=simcore_check_if_can_continue2(reg_maddr,reg_pc);if(false===ret.ok){return ret}compute_general_behavior("CLOCK");show_dbg_mpc();return ret}function simcore_execute_microprogram(options){var ret=simcore_check_if_can_continue();if(false===ret.ok){return ret}var before_state=null;var after_state=null;var curr_mpc="";var curr_MC=simhw_internalState("MC");var maddr_name=simhw_sim_ctrlStates_get().mpc.state;var maddr_state=simhw_sim_state(maddr_name);if(typeof options.before_microinstruction==="undefined"){options.before_microinstruction=simcore_do_nothing_handler}if(typeof options.after_microinstruction==="undefined"){options.after_microinstruction=simcore_do_nothing_handler}var i_clks=0;var limitless=options.cycles_limit<0;var cur_addr=0;var mcelto=null;var oolimits=false;do{options.before_microinstruction(curr_MC,cur_addr);compute_general_behavior("CLOCK");i_clks++;options.after_microinstruction(curr_MC,cur_addr);if(limitless===false&&i_clks>=options.cycles_limit){ret.msg="Warning: clock cycles limit reached in a single instruction.";ret.ok=false;break}cur_addr=get_value(maddr_state);mcelto=control_memory_get(curr_MC,cur_addr);if(typeof mcelto==="undefined"){ret.msg="Error: undefined microinstruction at "+cur_addr+".";ret.ok=false;break}if(i_clks>=options.cycles_limit&&-1!=options.cycles_limit){oolimits=true}}while(false==oolimits&&0!=cur_addr);if(true==ret.ok&&mcelto.is_native){compute_general_behavior("CLOCK")}if(get_cfg("DBG_level")=="microinstruction"){show_dbg_mpc()}return ret}function simcore_execute_program(options){var ret={};ret.ok=true;ret.msg="";var curr_segments=simhw_internalState("segments");var pc_name=simhw_sim_ctrlStates_get().pc.state;var pc_state=simhw_sim_state(pc_name);var reg_pc=get_value(pc_state);var reg_pc_before=get_value(pc_state)-4;var code_begin=0;if(typeof curr_segments[".text"]!="undefined"&&typeof curr_segments[".text"].begin!="undefined")code_begin=parseInt(curr_segments[".text"].begin);var code_end=0;if(typeof curr_segments[".text"]!="undefined"&&typeof curr_segments[".text"].end!="undefined")code_end=parseInt(curr_segments[".text"].end);var kcode_begin=0;if(typeof curr_segments[".ktext"]!="undefined"&&typeof curr_segments[".ktext"].begin!="undefined")kcode_begin=parseInt(curr_segments[".ktext"].begin);var kcode_end=0;if(typeof curr_segments[".ktext"]!="undefined"&&typeof curr_segments[".ktext"].end!="undefined")kcode_end=parseInt(curr_segments[".ktext"].end);var ret1=null;var before_state=null;var after_state=null;var curr_pc="";var SIMWARE=get_simware();if(typeof options.verbalize!=="undefined"){set_cfg("verbal_verbose",options.verbalize)}if(typeof options.before_instruction==="undefined"){options.before_instruction=simcore_do_nothing_handler}if(typeof options.after_instruction==="undefined"){options.after_instruction=simcore_do_nothing_handler}var ins_executed=0;while(reg_pc=code_begin||reg_pc=kcode_begin){options.before_instruction(SIMWARE,reg_pc);ret1=simcore_execute_microprogram(options);if(false===ret1.ok){return ret1}options.after_instruction(SIMWARE,reg_pc);ins_executed++;if(ins_executed>options.instruction_limit&&-1!=options.instruction_limit){ret.ok=false;ret.msg="more than "+options.instruction_limit+" instructions executed before application ends.";return ret}reg_pc_before=reg_pc;reg_pc=get_value(pc_state)}return ret}function simcore_do_nothing_handler(){return null}function simcore_compile_firmware(textToMCompile){var ret={};ret.msg="";ret.ok=true;if(""==textToMCompile){ret.msg="Empty Firmware";ret.ok=false;return ret}var preSM=null;try{preSM=loadFirmware(textToMCompile);ret.simware=preSM}catch(e){ret.msg="ERROR: at line: "+e.lineNumber+" and column: "+e.columnNumber;ret.ok=false;return ret}if(preSM.error!=null){ret.msg=preSM.error;ret.ok=false;return ret}update_memories(preSM);simcore_reset();return ret}function simcore_compile_assembly(textToCompile){var ret={};ret.msg="";ret.ok=true;var SIMWARE=get_simware();if(SIMWARE.firmware.length===0){ret.msg="Empty microcode, please load the microcode first.";ret.ok=false;return ret}var SIMWAREaddon=simlang_compile(textToCompile,SIMWARE);ret.simware=SIMWAREaddon;if(SIMWAREaddon.error!=null){ret.msg=SIMWAREaddon.error;ret.ok=false;return ret}set_simware(SIMWAREaddon);update_memories(SIMWARE);simcore_reset();return ret}function simcore_hardware_export(hw_name){var ret={};ret.msg="{}";ret.ok=false;var hw_obj=simhw_getObjByName(hw_name);if(null===hw_obj){return ret}ret.ok=true;ret.msg=JSON.stringify(hw_obj,(function(key,value){if(typeof value==="function"){return"/Function("+value.toString()+")/"}return value}));return ret}function simcore_hardware_import(hw_json){var ret={};ret.msg="";ret.ok=true;hw_obj=JSON.parse(hw_json,(function(key,value){if(typeof value==="string"&&value.startsWith("/Function(")&&value.endsWith(")/")){value=value.substring(10,value.length-2);return eval("("+value+")")}return value}));simhw_add(hw_obj);return ret}function simcore_native_get_signal(elto){return get_value(simhw_sim_signal(elto))>>>0}function simcore_native_set_signal(elto,value){set_value(simhw_sim_signal(elto),value);compute_behavior("FIRE "+elto);return value}function simcore_native_get_value(component,elto){var index=0;var sim_components=simhw_sim_components();var compo_index=component;if("BR"===component)compo_index="CPU";if("DEVICE"===component)compo_index="IO";if(typeof sim_components[compo_index].get_value!=="undefined"){return sim_components[compo_index].get_value(elto)}return false}function simcore_native_set_value(component,elto,value){var index=0;var sim_components=simhw_sim_components();var compo_index=component;if("BR"===component)compo_index="CPU";if("DEVICE"===component)compo_index="IO";if(typeof sim_components[compo_index].set_value!=="undefined"){return sim_components[compo_index].set_value(elto,value)}return false}function simcore_native_get_fields(signature_raw){var SIMWARE=get_simware();for(var key in SIMWARE.firmware){if(SIMWARE.firmware[key].signatureRaw===signature_raw){return SIMWARE.firmware[key].fields}}}function simcore_native_get_field_from_ir(fields,index){if(typeof fields[index]==="undefined"){ws_alert("simcore_native_get_field_from_ir: index ("+index+") out of range.");return false}var value=get_value(simhw_sim_state("REG_IR"));var left_shift=31-parseInt(fields[index].startbit);var right_shift=parseInt(fields[index].stopbit);value=value<>>left_shift;value=value>>>right_shift;return value}function simcore_native_deco(){compute_behavior("DECO")}function simcore_native_go_maddr(maddr){set_value(simhw_sim_state("MUXA_MICROADDR"),maddr)}function simcore_native_go_opcode(){var maddr=get_value(simhw_sim_state("ROM_MUXA"));set_value(simhw_sim_state("MUXA_MICROADDR"),maddr)}function simcore_native_go_instruction(signature_raw){var SIMWARE=get_simware();for(var key in SIMWARE.firmware){if(SIMWARE.firmware[key].signatureRaw===signature_raw){var maddr=SIMWARE.firmware[key]["mc-start"];set_value(simhw_sim_state("MUXA_MICROADDR"),maddr);return}}}function simcore_simstate_checklist2state(checklist){var o={};var ret=false;checklist=checklist.replace(/;|==|!=|>=|<=|=|>|v!=""));for(var i=0;i"===expected_result[compo][elto].op)diff.fulfill=parseInt(diff.obtained)>parseInt(diff.expected);else if("<"===expected_result[compo][elto].op)diff.fulfill=parseInt(diff.obtained)="===expected_result[compo][elto].op)diff.fulfill=parseInt(diff.obtained)>=parseInt(diff.expected);else if("<="===expected_result[compo][elto].op)diff.fulfill=parseInt(diff.obtained)<=parseInt(diff.expected);else if("=="===expected_result[compo][elto].op)diff.fulfill=diff.expected==diff.obtained;else if("!="===expected_result[compo][elto].op)diff.fulfill=diff.expected!=diff.obtained;d.result.push(diff);if(diff.fulfill===false)d.errors++}}if(newones_too&&typeof obtained_result[compo]!="undefined"){for(elto in obtained_result[compo]){d.neltos_obtained++;if(typeof expected_result[compo]!="undefined"&&typeof expected_result[compo][elto]!="undefined"){continue}diff={};diff.expected=obtained_result[compo][elto].default_value;diff.obtained=obtained_result[compo][elto].value;diff.fulfill=diff.expected===diff.obtained;diff.elto_type=compo.toLowerCase();diff.elto_id=obtained_result[compo][elto].id;diff.elto_op="=";d.result.push(diff);if(diff.fulfill===false)d.errors++}}}return d}function simcore_simstate_diff_results(expected_result,obtained_result){return simcore_simstate_check_results(expected_result,obtained_result,true)}function simcore_simstate_diff_states(before_state_obj,after_state_obj){var before_arr=simcore_simstate_state2checklist(before_state_obj,"").split(";");var after_arr=simcore_simstate_state2checklist(after_state_obj,"").split(";");return after_arr.filter((function(elto){return!before_arr.includes(elto)})).join(";").trim()}function simcore_simstate_checkreport2txt(checklist){var o="";for(var i=0;i"+""+""+"Type | "+"IdentificationId. | "+"Values in the clipboard state | "+"Values in the selected state | "+"
"+""+"";for(var i=0;i"+""+checklist[i].elto_type+" | "+""+checklist[i].elto_id+" | "+""+checklist[i].elto_op+" "+checklist[i].expected+" | "+""+checklist[i].obtained+" | "+""}o+=""+"";return o}function simcore_voice_canSpeak(){if(typeof window.speechSynthesis=="undefined"){return false}if(false===get_cfg("use_voice")){return false}return true}function simcore_voice_speak(msg){var ssu=null;if(simcore_voice_canSpeak()){ssu=new SpeechSynthesisUtterance(msg);ssu.lang="es-ES";if("en"==get_cfg("ws_idiom"))ssu.lang="en-US";if("es"==get_cfg("ws_idiom"))ssu.lang="es-EN";window.speechSynthesis.speak(ssu)}}function simcore_voice_stopSpeak(){if(simcore_voice_canSpeak()){window.speechSynthesis.cancel()}}var simcore_rest={};function simcore_rest_reset(){simcore_rest={}}function simcore_rest_add(name,description){simcore_rest[name]={endpoint:description.endpoint,user:description.user,pass:description.pass,last_request:null}}function simcore_rest_list(){return simcore_rest}function simcore_rest_get(name){return simcore_rest[name]}function simcore_rest_call(name,method,uri,data){var rest_info=simcore_rest[name];if(typeof rest_info==="undefined"){return false}var api_endpoint=rest_info.endpoint;if(api_endpoint.value instanceof Vuex.Store){api_endpoint=get_value(api_endpoint)}if(api_endpoint.trim()===""){return false}var basic_auth="Basic "+btoa(rest_info.user+":"+rest_info.pass);var enc_data=JSON.stringify(data);var request={url:api_endpoint+uri,type:method,contentType:"application/json",accepts:"application/json",cache:false,dataType:"json",data:enc_data,beforeSend:function(xhr){if(rest_info.user.trim()!==""){xhr.setRequestHeader("Authorization",basic_auth)}},error:function(jqXHR){console.log("ajax error "+jqXHR.status)}};rest_info.last_request=$.ajax(request);return true}var simcore_notifications=[];function simcore_notifications_get(){return simcore_notifications}function simcore_notifications_reset(){simcore_notifications=[]}function simcore_notifications_add2(ntf){simcore_notifications.push({title:ntf.title,message:ntf.message,type:ntf.type,date:ntf.date})}function simcore_notifications_add(ntf_title,ntf_message,ntf_type,ntf_delay){simcore_notifications.push({title:$("").html(ntf_title).text(),message:$("
").html(ntf_message).text(),type:ntf_type,date:(new Date).getTime()})}function get_value(sim_obj){if(sim_obj.value instanceof Vuex.Store){return sim_obj.value.state.value}return sim_obj.value}function set_value(sim_obj,value){if(sim_obj.value instanceof Vuex.Store){sim_obj.value.commit("set_value",value);return}var old_value=sim_obj.value;sim_obj.value=value;if(old_value!=value){sim_obj.changed=true}}function reset_value(sim_obj){if(sim_obj.value instanceof Vuex.Store){set_value(sim_obj,sim_obj.default_value);return}if(typeof sim_obj.default_value=="object"){sim_obj.changed=true;sim_obj.value=Object.create(sim_obj.default_value);return}if(sim_obj instanceof Array){sim_obj.changed=true;for(var i=0;i",""":'"',"'":"'"};function treatHTMLSequences(text_with_html){var re=null;var key=null;for(key in html_sequences){re=new RegExp(key,"gi");text_with_html=text_with_html.replace(re,html_sequences[key])}return text_with_html}function control_memory_getkeys(memory){return Object.keys(memory)}function control_memory_get(memory,elto){return memory[elto]}function control_memory_set(memory,elto,melto){if(typeof melto.changed==="undefined")melto.changed=false;if(typeof melto.state==="undefined")melto.state=false;if(typeof melto.breakpoint==="undefined")melto.breakpoint=false;if(typeof melto.notify==="undefined")melto.notify=[];if(typeof melto.is_native==="undefined")melto.is_native=false;var comments_str="";if(null!=melto.comments){comments_str=melto.comments;if(melto.comments instanceof Array)comments_str=melto.comments.join("\n");melto.state=melto.state||comments_str.trim().split("state:").length>1;melto.breakpoint=melto.breakpoint||comments_str.trim().split("break:").length>1;melto.notify=comments_str.trim().split("notify:");for(var k=0;k";if(active_verbal.trim()==="")active_verbal="";return"Activated signals are: "+active_signals+". Associated actions are: "+active_verbal}function main_memory_getkeys(memory){return Object.keys(memory)}function main_memory_get(memory,elto){return memory[elto]}function main_memory_set(memory,elto,melto){if(typeof melto.changed==="undefined")melto.changed=false;if(typeof melto.state==="undefined")melto.state=false;if(typeof melto.breakpoint==="undefined")melto.breakpoint=false;if(typeof melto.notify==="undefined")melto.notify=[];if(typeof melto.is_assembly==="undefined")melto.is_assembly=false;if(typeof melto.source==="undefined")melto.source="";var comments_str="";if(null!=melto.comments){comments_str=melto.comments.join("\n");melto.state=melto.state||comments_str.trim().split("state:").length>1;melto.breakpoint=melto.breakpoint||comments_str.trim().split("break:").length>1;melto.notify=comments_str.trim().split("notify:");for(var k=0;k>8;if(2==filter_elto)dbvalue=(value&16711680)>>16;if(3==filter_elto)dbvalue=(value&4278190080)>>24;break;case 1:if(0==filter_elto)dbvalue=value&65535;if(1==filter_elto)dbvalue=value&65535;if(2==filter_elto)dbvalue=(value&4294901760)>>16;if(3==filter_elto)dbvalue=(value&4294901760)>>16;break;case 2:if(0==filter_elto)dbvalue=value&16777215;if(1==filter_elto)dbvalue=value&4294967040;break;case 3:dbvalue=value;break}return dbvalue}function main_memory_updatevalues(value,dbvalue,filter_size,filter_elto){switch(filter_size){case 0:if(0==filter_elto)value=value&4294967040|dbvalue&255;if(1==filter_elto)value=value&4294902015|(dbvalue&255)<<8;if(2==filter_elto)value=value&4278255615|(dbvalue&255)<<16;if(3==filter_elto)value=value&16777215|(dbvalue&255)<<24;break;case 1:if(0==filter_elto)value=value&4294901760|dbvalue&65535;if(1==filter_elto)value=value&4294901760|dbvalue&65535;if(2==filter_elto)value=value&65535|(dbvalue&65535)<<16;if(3==filter_elto)value=value&65535|(dbvalue&65535)<<16;break;case 2:if(0==filter_elto)value=value&4278190080|dbvalue&16777215;if(1==filter_elto)value=value&255|dbvalue&4294967040;break;case 3:value=dbvalue;break}return value}function main_memory_get_program_counter(){var r_ref=simhw_sim_ctrlStates_get().pc;var r_value=null;if(typeof r_ref!=="undefined"){r_ref=simhw_sim_state(r_ref.state)}if(typeof r_ref!=="undefined"){r_value=get_value(r_ref)}return r_value}function main_memory_get_baseaddr(){var r_ref=simhw_sim_ctrlStates_get();if(typeof r_ref==="undefined"){return null}var parts=null;var r_value=0;var r_ref2=null;var all_baseaddr={};for(var elto in r_ref){if(r_ref[elto].is_pointer==false){continue}parts=r_ref[elto].state.split(".");if(parts[0]=="BR"){r_value=4294967292;r_ref2=simhw_sim_states().BR[parts[1]]}else{r_value=0;r_ref2=simhw_sim_state(r_ref[elto].state)}if(typeof r_ref2!=="undefined"){r_value=get_value(r_ref2)}all_baseaddr[elto]=r_value}return all_baseaddr}function get_deco_from_pc(pc){var mp_obj=simhw_internalState("MP");if(typeof mp_obj==="undefined"||typeof mp_obj[pc]==="undefined"||typeof mp_obj[pc].source==="undefined"){return""}return mp_obj[pc].source}function get_verbal_from_current_pc(){var pc_name=simhw_sim_ctrlStates_get().pc.state;var reg_pc=get_value(simhw_sim_state(pc_name));var pc=parseInt(reg_pc)-4;var decins=get_deco_from_pc(pc);if(""==decins.trim()){decins="not jet defined"}return"Current instruction is: "+decins+" and PC points to "+show_value(pc)+". "}function cache_memory_update_stats(memory,address,parts,r_w,m_h,clock_timestamp){memory.stats.n_access++;memory.stats.last_addr=address;memory.stats.last_parts=parts;memory.stats.last_r_w=r_w;memory.stats.last_h_m=m_h;if(m_h=="miss"){memory.stats.n_misses++}else{memory.stats.n_hits++}memory.sets[parts.set].tags[parts.tag].n_access++;if(r_w=="write"){memory.sets[parts.set].tags[parts.tag].dirty=1}memory.sets[parts.set].tags[parts.tag].timestamp=clock_timestamp}function cache_memory_select_victim(memory,set){var keys=Object.keys(memory.sets[set].tags);var tag_victim=0;if(memory.cfg.replace_pol=="lfu"){tag_victim=keys[0];var tag_naccess=memory.sets[parts.set].tags[tag_victim].n_access;for(var i=1;imemory.sets[parts.set].tags[keys[i]].n_access){tag_victim=keys[i];tag_naccess=memory.sets[parts.set].tags[tag_victim].n_access}}}else if(memory.cfg.replace_pol=="fifo"){tag_victim=keys[0];var tag_stamp=memory.sets[parts.set].tags[tag_victim].timestamp;for(var i=1;imemory.sets[parts.set].tags[keys[i]].timestamp){tag_victim=keys[i];tag_stamp=memory.sets[parts.set].tags[tag_victim].timestamp}}}else if(memory.cfg.replace_pol=="first"){tag_victim=keys[0]}return tag_victim}function cache_memory_init(name,via_size,off_size,set_size,replace_pol,su_pol,next_cache){var c={stats:{},cfg:{},sets:{}};c.cfg.name=name;c.cfg.via_size=via_size;c.cfg.off_size=off_size;c.cfg.set_size=set_size;c.cfg.vps_size=via_size-set_size;c.cfg.tag_size=32-set_size-off_size;c.cfg.mask_tag=Math.pow(2,c.cfg.tag_size)-1>>>0;c.cfg.mask_set=Math.pow(2,c.cfg.set_size)-1>>>0;c.cfg.mask_off=Math.pow(2,c.cfg.off_size)-1>>>0;c.cfg.mask_tag=c.cfg.mask_tag<<32-c.cfg.tag_size>>>0;c.cfg.mask_set=c.cfg.mask_set<>>0;c.cfg.replace_pol=replace_pol;c.cfg.su_pol=su_pol;c.cfg.next_cache=next_cache;c.stats.n_access=0;c.stats.n_hits=0;c.stats.n_misses=0;c.stats.last_addr=0;c.stats.last_parts=cache_memory_split(c,0);c.stats.last_r_w="";c.stats.last_h_m="";return c}function cache_memory_init2(cfg){return cache_memory_init(cfg.name,cfg.via_size,cfg.off_size,cfg.set_size,cfg.replace_pol,cfg.su_pol,cfg.next_cache)}function cache_memory_init3(array_cm_cfg){var array_cm=[];for(var i=0;i>>0;parts.tag=(address&memory.cfg.mask_tag)>>>32-memory.cfg.tag_size;parts.set=(address&memory.cfg.mask_set)>>>memory.cfg.off_size;parts.offset=address&memory.cfg.mask_off;return parts}function cache_memory_access(memory,address,r_w,clock_timestamp){if(memory.cfg.su_pol!="unified"){if("split_i"==memory.cfg.su_pol&&segments_addr_within_text(address)==false){return false}if("split_d"==memory.cfg.su_pol&&segments_addr_within_data(address)==false){return false}}var parts=cache_memory_split(memory,address);if(typeof memory.sets[parts.set]=="undefined"){memory.sets[parts.set]={tags:{},number_tags:0}}if(typeof memory.sets[parts.set].tags[parts.tag]!="undefined"&&memory.sets[parts.set].tags[parts.tag].valid==1){cache_memory_update_stats(memory,address,parts,r_w,"hit",clock_timestamp);return true}if(typeof memory.sets[parts.set].number_tags>3){var tag_victim=cache_memory_select_victim(memory,parts.set);memory.sets[parts.set].tags[tag_victim].valid=0;memory.sets[parts.set].number_tags--}memory.sets[parts.set].tags[parts.tag]={n_access:0,valid:1,dirty:0};memory.sets[parts.set].number_tags++;cache_memory_update_stats(memory,address,parts,r_w,"miss",clock_timestamp);if(memory.cfg.next_cache!=null){cache_memory_access(memory.cfg.next_cache,address,r_w)}return false}var sim={systems:[],active:null,index:0};function simhw_add(newElto){var found=-1;for(var m=0;m=0&&sim.systems.length>=newActive){sim.active=sim.systems[newActive];sim.index=newActive}compile_behaviors();firedep_to_fireorder(jit_fire_dep);compute_references();compile_verbals()}function simhw_getIdByName(short_name){for(var m=0;m