/* yasep/VHDL/config.js This file is distributed under terms of the Affero GPL v3 license or later, see http://yasep.org 2009-05-28 : yasep/tools/generate_VHDL.html created by whygee at f-cpu.org from opcode_map.html 2009-06-06 2009-07-11 2009-07-28 : Y 20090830 : config panel 20090920 : SULV->SLV dim. févr. 12 06:49:50 CET 2012 : windowed version dim. févr. 19 09:32:45 CET 2012 : adding valid instructions and such (should be generalised with "profiles") lun. févr. 20 12:14:17 CET 2012 : profiles almost working jeu. mai 10 05:17:49 CEST 2012 : moved to VHDL lun. juil. 29 08:21:49 CEST 2013 : trying to rebuild, as cleanup looks too hard 20130809 added parking 20140427 : IgnoreSND_x error found Purpose : Makes buttons that configure a profile and export the corresponding VHDL definitions Quite buggy, i'm rebuilding it... */ INIT(config={ win: null, opcodes_id:[], mul_id:[], cond_id:[], size_id:[], park_id:[], SplitMem_id:[], PtrUpd_id:[], empty:false, multable:{ "MUL8L":8, "MUL8H":8, "MULI":8, "LUT8":8, "MUL16H":16, "MUL16L":16}, changeInstruction: function(val,n,force) { // n:string (instruction name) if (typeof config.core!="object") wa("VHDL/config#name=empty"); // change only if different if ((force===true) || (val != config.opcodes_id[n].checked)) { var c=config.core, t; // Force some values if we're in "auto-collection" mode if((val===true) && config.empty) { if((c.datapath!=32) && config.Y32_id[n]){ config.core.datapath=32; config.win.shortmsg("force datapath=32"); } if ((t=config.multable[n]) && (t>c.multiplier)){ config.core.multiplier=t; config.win.shortmsg("force multiplier="+t); } } c.valid_instructions[n]=(val===true)? 1 : 0; config.opcodes_id[n].checked=val; delay(config.delay_check); } }, changeBox: function() { config.changeInstruction(this.checked, this.id, true); }, // check the configuration sanity // Warning !! potential crazy loop because changeInstruction // delay-calls check which calls changeInstruction... check: function() { var n, c=config.core; switch (c.multiplier) { case 0: case 8: // just filters the valid values. case 16: break; default : c.multiplier=0; } if (c.datapath!=32) c.datapath =16; config.size_id[c.datapath].checked=true; switch (c.datapath) { case 16: if (c.multiplier==16) c.multiplier =8; // constrain the MUL size // disable all the Y32only for (n in config.Y32_id) config.changeInstruction(false,n); // enable the Y16 break; case 32: // disable all the Y16only // enable the Y32 break; } if (c.Park!=1) c.Park=0; config.park_id[c.Park].checked=true; config.cond_id[c.CondR1].checked=true; config.mul_id[c.multiplier].checked=true; config.park_id[c.Park].checked=true; config.SplitMem_id[c.SplitMem].checked=true; config.PtrUpd_id[c.PtrUpd].checked=true; // config._id[c.].checked=true; for (n in config.multable) if (config.multable[n] > c.multiplier) config.changeInstruction(false,n); if (c.PC_length<3) c.PC_length=3; if (c.PC_length>c.datapath) c.PC_length=c.datapath; config.PCwidth_id.innerHTML =config.PCwidth_id.source =c.PC_length; }, //////////////////////// generate the file //////////////////////// emit_VHDL: function(){ config.check(); // Recompute the instruction mask ! ProfUtils.exportVHDL(config.core); }, //////////////////////////////////////////////////////////////////////// changeRadio: function() { config.trigger(this.name+"="+this.value); }, // yeah, it's a compact trick, but a simple one :-) ////////// /!\ it only works for a single profile, ////////// simultaneous multiple edition is not supported trigger: function(s) { if (s=="") return; if (s=="emitVHDL") return config.emit_VHDL(); var i,j=0,u,v; s=s.split(','); for (i in s){ u=s[i].split("="); if (u.length==2) { v=u[0]; if (v=="name") { if (j) // !=0 return alert("Malformed configuration request: the profile name must be the first parameter"); else config.change_profile(u[1]); } else if (typeof config.core[v]=="number") config.core[v]=+u[1]; j++; config.check(); } else return alert("Malformed configuration request : missing argument ?"); } }, AddProfile: function() { // config.nameInput_id.style.display="none"; }, change_profile: function(a) { if (typeof profiles[a] != "object") return Al8N("Ipn"); config.core=ProfUtils.inherit(a); config.name_id.innerHTML=a; config.empty=(a=="empty"); config.block_id.style.display="block"; var n, p=profiles[a]; /*{ // manually copies the sub-objects multiplier:p.multiplier, PC_length:p.PC_length, valid_instructions:[], // p.valid_instructions, => updated in changeInstruction datapath:p.datapath, CondR1:p.CondR1, Park:p.Park, SplitMem:p.SplitMem }; */ for (n in config.opcodes_id) config.changeInstruction( p.valid_instructions[n]===1, n, true); }, list_profiles: function(){ var l=config.list_div, p, d=dcE("div"), m="
"+profiles[p].comment+" |