// permet de traiter un template de fichier .vhd dans le cadre du projet
// Depan'Trex.
// Les champs suivant sont traités:
// %BSDL_LOC% : remplacés par une liste de PADs trouvé dans le fichier BDSL du FPGA correspondant.
// author : P.CARTON
//Utils = require("D:\\DEV\\syntalyser\\common\\utils.js");
/*
require("lib/Scintilla.js");
sci = new Scintilla();
a=sci.Call(sci.Const.SCI_ZOOMIN,2,3);
*/
require("lib/msvcrt.js");
//MessageBox("Title of Box", "My important message");
//msvcrt.puts("gseeeeeeeeee");
//putchar('r');
//puts("caca\0\0");
//alert(JSON.stringify(Dialog, null, 4));
function Conv_bsdl_padn(){
// TBD : OpenFileName
var Bsdl_File = "c:/xilinx/14.5/ISE_DS/ISE/spartan6/data/xc6slx45_fgg484.bsd"
var fso = new ActiveXObject("Scripting.FileSystemObject");
if (fso.FileExists(Bsdl_File)){
var f = fso.OpenTextFile(Bsdl_File, 1, false, 0);
var text = f.ReadAll();
f.Close();
} else {
alert("Bsdl_File not found");
return;
}
var io_tab = new Array();
var match = text.match(/port \(((.|\n)+?)\); --end/m);
if (match == null){
alert("fichier inexploitable, pas trouvé les correspondances port io<->PADS");
return;
}
re = /\s*(\w+):.*--\s*PAD(\w+)/ig
for (var i = 1;; i++)
{
// if (i >= MAX_FOR_I)throw "infinite loop while doing regexp";
match = re.exec(text); // -- Doing the regexp --
if (match == null)break;
var io_name = match[1];
var pad_n = match[2];
io_tab[parseInt(pad_n)] = io_name;
//alert(io_name+" - "+pad_n);
}
// on a maintenant dans io_tab le tableau indexé PADnn, valeur = nom de l'IO
var io_group = new Array();
var t = "";
var n = 0;
io_tab.forEach(function (v, padn){
if (v != undefined && (m = /^IO_(.+)/i.exec(v)))
{
if (n == 0)t = padn+" ";
t += (n > 0 ? "," : "") + m[1];
n ++;
} else {
if (n != 0){
t += " "+ padn;
io_group.push(t);
}
t = ""; n = 0;
}
});
bsdl_loc = io_group[0];
var text = currentview.text;
/*
text = text.replace(/%bus_name%/, function(m){
return "IO_OUT_inoutp";
});
*/
text = text.replace(/%IO_OUT_inoutp_BSDL%/g, bsdl_loc);
currentview.text = text;
// currentview.pos = 1;
// currentview.text = res;
//var file = Editor.currentView.files[Editor.currentView.file];
//alert(file);
//alert(currentview.files);
}
//Conv_bsdl_padn(currentView.text);
(function(){
try {
Depan_trex = (Depan_trex ? Depan_trex : false)
} catch(e) {
Depan_trex = false
}
if (!Depan_trex){
Depan_trex = Editor.addMenu("Depan'trex");
var rconv = {
key: 53, //https://keycode.info/
ctrl:true,
text:"Conv_bsdl_padn",
cmd:function(){
Conv_bsdl_padn();
}
}
Depan_trex.addItem(rconv);
addHotKey(rconv);
}
})()