mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-06-15 21:29:28 +00:00
verilog: support $readmemb/h("file", array)
This commit is contained in:
parent
8152a14a2b
commit
2aa818e320
|
@ -54,8 +54,7 @@ TODO:
|
||||||
- C/asm formatter
|
- C/asm formatter
|
||||||
- fix WebAudio (https://news.ycombinator.com/item?id=18066474)
|
- fix WebAudio (https://news.ycombinator.com/item?id=18066474)
|
||||||
- allow download of JSASM output
|
- allow download of JSASM output
|
||||||
- update bootstrap
|
- update bootstrap to 4.0
|
||||||
- $readmemb/h
|
|
||||||
- batariBasic: proper line numbers, debugging
|
- batariBasic: proper line numbers, debugging
|
||||||
- granular control over time scrubbing, show CPU state
|
- granular control over time scrubbing, show CPU state
|
||||||
- error showing replay div before rom starts
|
- error showing replay div before rom starts
|
||||||
|
@ -75,7 +74,6 @@ TODO:
|
||||||
- markdown, verilog: can't share
|
- markdown, verilog: can't share
|
||||||
- https://www.crowdsupply.com/tinyfpga/tinyfpga-bx
|
- https://www.crowdsupply.com/tinyfpga/tinyfpga-bx
|
||||||
- HTTPS warning
|
- HTTPS warning
|
||||||
- recording video indicator
|
|
||||||
- stego shareable images (http://pico-8.wikia.com/wiki/P8PNGFileFormat)
|
- stego shareable images (http://pico-8.wikia.com/wiki/P8PNGFileFormat)
|
||||||
- https://makecode.com/language?
|
- https://makecode.com/language?
|
||||||
- open ROM from URL?
|
- open ROM from URL?
|
||||||
|
@ -115,15 +113,15 @@ TODO:
|
||||||
- https://remotestoragejs.readthedocs.io/en/latest/getting-started/how-to-add.html ?
|
- https://remotestoragejs.readthedocs.io/en/latest/getting-started/how-to-add.html ?
|
||||||
- Verilog
|
- Verilog
|
||||||
- larger scope range, better scrolling
|
- larger scope range, better scrolling
|
||||||
|
- make scope data wrap around range
|
||||||
- remove FPS and play controls when Verilog scope paused
|
- remove FPS and play controls when Verilog scope paused
|
||||||
- when paused scope doesn't work
|
- when paused scope doesn't work
|
||||||
- Safari: scope doesn't show while CRT in use
|
- Safari: scope doesn't show while CRT in use (sometimes Firefox too)
|
||||||
- verilog debugging/reloading makes it slow
|
- verilog debugging/reloading makes it slow
|
||||||
- why loadState() on verilog kill perf?
|
- why loadState() on verilog kill perf?
|
||||||
- quantify verilog "graph iterations"
|
- quantify verilog "graph iterations"
|
||||||
- toolbar overlaps scope
|
- toolbar overlaps scope
|
||||||
- CPU debugging
|
- CPU debugging
|
||||||
- disassemble more code around breakpoint
|
|
||||||
- single-stepping vector games makes screen fade
|
- single-stepping vector games makes screen fade
|
||||||
- break on stack overflow, bad op, bad access, etc
|
- break on stack overflow, bad op, bad access, etc
|
||||||
- PPU/TIA register write visualization
|
- PPU/TIA register write visualization
|
||||||
|
|
|
@ -120,7 +120,11 @@ export function vl_stop(filename,lineno,hier) {
|
||||||
export function VL_RAND_RESET_I(bits) { return 0 | Math.floor(Math.random() * (1<<bits)); }
|
export function VL_RAND_RESET_I(bits) { return 0 | Math.floor(Math.random() * (1<<bits)); }
|
||||||
|
|
||||||
export function VL_RANDOM_I(bits) { return 0 | Math.floor(Math.random() * (1<<bits)); }
|
export function VL_RANDOM_I(bits) { return 0 | Math.floor(Math.random() * (1<<bits)); }
|
||||||
|
|
||||||
|
//export function VL_READMEM_Q(hex,width,depth,array_lsb,fnwords,filename,memp,start,end) {
|
||||||
|
//console.log(hex,width,depth,array_lsb,fnwords,filename,memp,start,end);
|
||||||
|
//}
|
||||||
|
|
||||||
// SIMULATOR BASE
|
// SIMULATOR BASE
|
||||||
|
|
||||||
abstract class VerilatorBase {
|
abstract class VerilatorBase {
|
||||||
|
|
|
@ -87,9 +87,9 @@ export class CodeProject {
|
||||||
this.pushAllFiles(files, m[2]+".json");
|
this.pushAllFiles(files, m[2]+".json");
|
||||||
}
|
}
|
||||||
// include $readmem[bh] (TODO)
|
// include $readmem[bh] (TODO)
|
||||||
let re3 = /\b\$readmem[bh]\("(.+?)"/gmi;
|
let re3 = /\$readmem[bh]\("(.+?)"/gmi;
|
||||||
while (m = re3.exec(text)) {
|
while (m = re3.exec(text)) {
|
||||||
this.pushAllFiles(files, m[2]);
|
this.pushAllFiles(files, m[1]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// for .asm -- [.]include "file"
|
// for .asm -- [.]include "file"
|
||||||
|
|
|
@ -1530,6 +1530,28 @@ function compileInlineASM(code:string, platform, options, errors, asmlines) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// convert $readmem(bh) to array assigns
|
||||||
|
function compileReadmemStmts(code, errors) {
|
||||||
|
var re3 = /\$readmem([bh])\("(.+?)",\s*(\w+)\)/gmi;
|
||||||
|
return code.replace(re3, function(_s,type,path,mem,index) {
|
||||||
|
var datafile = getWorkFileAsString(path);
|
||||||
|
if (datafile) {
|
||||||
|
var lines = datafile.split('\n');
|
||||||
|
var out = '';
|
||||||
|
for (var i=0; i<lines.length; i++) {
|
||||||
|
var line = lines[i].trim();
|
||||||
|
if (line !== '') {
|
||||||
|
out += 'mem[' + i + ']=\'' + type + line + ';'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
} else {
|
||||||
|
errors.push({line:0, msg:"Could not load $readmem file '"+path+'"'});
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function compileVerilator(step:BuildStep) {
|
function compileVerilator(step:BuildStep) {
|
||||||
loadNative("verilator_bin");
|
loadNative("verilator_bin");
|
||||||
loadGen("worker/verilator2js");
|
loadGen("worker/verilator2js");
|
||||||
|
@ -1554,7 +1576,9 @@ function compileVerilator(step:BuildStep) {
|
||||||
populateFiles(step, FS, {
|
populateFiles(step, FS, {
|
||||||
mainFilePath:step.path,
|
mainFilePath:step.path,
|
||||||
processFn:(code) => {
|
processFn:(code) => {
|
||||||
return compileInlineASM(code, platform, step, errors, asmlines);
|
code = compileReadmemStmts(code, errors);
|
||||||
|
code = compileInlineASM(code, platform, step, errors, asmlines);
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
starttime();
|
starttime();
|
||||||
|
|
|
@ -120,6 +120,6 @@ describe('string functions', function() {
|
||||||
assert.ok(util.isProbablyBinary('test.bin'));
|
assert.ok(util.isProbablyBinary('test.bin'));
|
||||||
assert.ok(util.isProbablyBinary('test.chr'));
|
assert.ok(util.isProbablyBinary('test.chr'));
|
||||||
assert.ok(!util.isProbablyBinary('test.txt'));
|
assert.ok(!util.isProbablyBinary('test.txt'));
|
||||||
assert.ok(!util.isProbablyBinary('test.dat'));
|
assert.ok(util.isProbablyBinary('test.dat'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user