yosys_execution = {
let mkdirIfNotPresent = (dirName, parentName) => {
let locals = ys.read_dir(parentName);
if (!locals.includes(dirName)) {
ys.window.FS.mkdir(parentName + dirName);
}
}
print_buf.textContent = ''
fileList2.forEach( (file, i) => {
let fname = Object.keys(file)[0];
print_buf.textContent += `write file: ${fname}\n`;
let dirs = fname.split('/')
dirs.pop()
dirs.forEach( d => {
mkdirIfNotPresent(d, './')
ys.window.FS.chdir(d);
});
dirs.forEach( d => ys.window.FS.chdir('..'));
ys.write_file(fname, textStrs[i]);
});
ys.run('design -reset')
print_buf.textContent += ys.print_buffer
fileList2.forEach( (file, i) => {
let fname = Object.keys(file)[0];
if (file[fname].is_include_file) return;
ys.run('read_verilog -defer ' + fname);
print_buf.textContent += ys.print_buffer
});
mkdirIfNotPresent('shareice40','/')
let cells_sim = d3.text('https://raw.githubusercontent.com/YosysHQ/yosys/master/techlibs/ice40/cells_sim.v')
ys.write_file('/shareice40/cells_sim.v', cells_sim);
let brams_text = d3.text('https://raw.githubusercontent.com/YosysHQ/yosys/master/techlibs/ice40/brams.txt')
ys.write_file('/shareice40/brams.txt', brams_text);
let brams_map = d3.text('https://raw.githubusercontent.com/YosysHQ/yosys/master/techlibs/ice40/brams_map.v')
ys.write_file('/shareice40/brams_map.v', brams_map);
let arith_map = d3.text('https://raw.githubusercontent.com/YosysHQ/yosys/master/techlibs/ice40/arith_map.v')
ys.write_file('/shareice40/arith_map.v', arith_map);
ys.run('read_verilog -lib /shareice40/cells_sim.v');
print_buf.textContent += ys.print_buffer
ys.run(`hierarchy -check -top ${targetInfo.toplevel}`);
print_buf.textContent += ys.print_buffer
ys.run('synth -run coarse')
print_buf.textContent += ys.print_buffer
ys.run('memory_bram -rules /shareice40/brams.txt; techmap -map /shareice40/brams_map.v')
print_buf.textContent += ys.print_buffer
ys.run("opt -fast -mux_undef -undriven -fine; memory_map; opt -undriven -fine");
print_buf.textContent += ys.print_buffer
ys.run("techmap -map +/tech_map.v");
print_buf.textContent += ys.print_buffer
}