mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-12-22 12:30:01 +00:00
variable inspection, bitmaps for verilog, active high hsync/vsync, powerup vs reset
This commit is contained in:
parent
2525d6e585
commit
48baf73ecb
@ -8,7 +8,7 @@ module digits10_case(digit, yofs, bits);
|
||||
|
||||
wire [6:0] caseexpr = {digit,yofs};
|
||||
always @(*)
|
||||
case (caseexpr)
|
||||
case (caseexpr)/*{w:5,h:5,count:10}*/
|
||||
7'o00: bits = 5'b11111;
|
||||
7'o01: bits = 5'b10001;
|
||||
7'o02: bits = 5'b10001;
|
||||
@ -81,11 +81,9 @@ module digits10_array(digit, yofs, bits);
|
||||
|
||||
reg [4:0] bitarray[10][5];
|
||||
|
||||
always @(*)
|
||||
bits = bitarray[digit][yofs];
|
||||
|
||||
initial
|
||||
begin
|
||||
assign bits = bitarray[digit][yofs];
|
||||
|
||||
initial begin/*{w:5,h:5,count:10}*/
|
||||
bitarray[0][0] = 5'b11111;
|
||||
bitarray[0][1] = 5'b10001;
|
||||
bitarray[0][2] = 5'b10001;
|
||||
|
@ -43,11 +43,10 @@ module hvsync_generator(
|
||||
else
|
||||
vpos <= 0;
|
||||
|
||||
reg vga_HS, vga_VS;
|
||||
always @(posedge clk)
|
||||
begin
|
||||
vga_HS <= (hpos>=START_H_RETRACE && hpos<=END_H_RETRACE);
|
||||
vga_VS <= (vpos==START_V_RETRACE);
|
||||
hsync <= (hpos>=START_H_RETRACE && hpos<=END_H_RETRACE);
|
||||
vsync <= (vpos==START_V_RETRACE);
|
||||
end
|
||||
|
||||
always @(posedge clk)
|
||||
@ -55,9 +54,6 @@ module hvsync_generator(
|
||||
display_on <= (hpos<H_DISPLAY) && (vpos<V_DISPLAY);
|
||||
end
|
||||
|
||||
assign hsync = ~vga_HS;
|
||||
assign vsync = ~vga_VS;
|
||||
|
||||
endmodule
|
||||
|
||||
`endif
|
||||
|
@ -187,14 +187,14 @@ function PixelEditor(parentDiv, fmt, palette, initialData, thumbnails) {
|
||||
|
||||
/////////////////
|
||||
|
||||
var pixel_re = /([0#]?)([x$%])([0-9a-f]+)/gi;
|
||||
var pixel_re = /([0#]?)([x$%]|\d'b)([0-9a-f]+)/gi;
|
||||
|
||||
function parseHexBytes(s) {
|
||||
var arr = [];
|
||||
var m;
|
||||
while (m = pixel_re.exec(s)) {
|
||||
var n;
|
||||
if (m[2].startsWith('%'))
|
||||
if (m[2].startsWith('%') || m[2].endsWith("b"))
|
||||
n = parseInt(m[3],2);
|
||||
else if (m[2].startsWith('x') || m[2].startsWith('$'))
|
||||
n = parseInt(m[3],16);
|
||||
@ -215,6 +215,8 @@ function replaceHexBytes(s, bytes) {
|
||||
li = pixel_re.lastIndex;
|
||||
if (m[2].startsWith('%'))
|
||||
result += m[1] + "%" + bytes[i++].toString(2);
|
||||
else if (m[2].endsWith('b'))
|
||||
result += m[1] + m[2] + bytes[i++].toString(2); // TODO
|
||||
else if (m[2].startsWith('x'))
|
||||
result += m[1] + "x" + hex(bytes[i++]);
|
||||
else if (m[2].startsWith('$'))
|
||||
|
@ -139,17 +139,19 @@ var VerilogPlatform = function(mainElement, options) {
|
||||
var paddle_x = 0;
|
||||
var paddle_y = 0;
|
||||
var switches = [0];
|
||||
var inspect_obj, inspect_sym;
|
||||
var inspect_data = new Uint32Array(videoWidth * videoHeight);
|
||||
|
||||
this.getPresets = function() { return VERILOG_PRESETS; }
|
||||
|
||||
var RGBLOOKUP = [
|
||||
0xff111111,
|
||||
0xff1111ff,
|
||||
0xff11ff11,
|
||||
0xff11ffff,
|
||||
0xffff1111,
|
||||
0xffff11ff,
|
||||
0xffffff11,
|
||||
0xff222222,
|
||||
0xff2222ff,
|
||||
0xff22ff22,
|
||||
0xff22ffff,
|
||||
0xffff2222,
|
||||
0xffff22ff,
|
||||
0xffffff22,
|
||||
0xffffffff,
|
||||
];
|
||||
|
||||
@ -158,23 +160,56 @@ var VerilogPlatform = function(mainElement, options) {
|
||||
audio.addSingleSample(0+gen.spkr); // TODO: sync with audio freq
|
||||
}
|
||||
|
||||
function updateInspectionFrame() {
|
||||
if (inspect_obj && inspect_sym) {
|
||||
var COLOR_BIT_OFF = 0xffff3333;
|
||||
var COLOR_BIT_ON = 0xffffffff;
|
||||
for (var y=0; y<videoHeight; y++) {
|
||||
var val = inspect_data[y * videoWidth];
|
||||
var i = y * videoWidth + 16;
|
||||
do {
|
||||
idata[i] = (val & 1) ? COLOR_BIT_ON : COLOR_BIT_OFF;
|
||||
i -= 2;
|
||||
val >>= 1;
|
||||
} while (val != 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateInspectionPostFrame() {
|
||||
if (inspect_obj && inspect_sym) {
|
||||
var ctx = video.getContext();
|
||||
var val = inspect_data[inspect_data.length-1];
|
||||
ctx.fillStyle = "black";
|
||||
ctx.fillRect(18, videoHeight-8, 30, 8);
|
||||
ctx.fillStyle = "white";
|
||||
ctx.fillText(val.toString(10), 20, videoHeight-1);
|
||||
}
|
||||
}
|
||||
|
||||
function updateVideoFrame() {
|
||||
var i=0;
|
||||
var i=4; // TODO, start @ 0?
|
||||
var trace=inspect_obj && inspect_sym;
|
||||
for (var y=0; y<videoHeight; y++) {
|
||||
gen.hpaddle = y > paddle_x ? 1 : 0;
|
||||
gen.vpaddle = y > paddle_y ? 1 : 0;
|
||||
for (var x=0; x<videoWidth; x++) {
|
||||
vidtick();
|
||||
if (trace) {
|
||||
inspect_data[i] = inspect_obj[inspect_sym];
|
||||
}
|
||||
idata[i++] = RGBLOOKUP[gen.rgb];
|
||||
}
|
||||
var z=0;
|
||||
while (gen.hsync && z++<videoWidth) vidtick();
|
||||
while (!gen.hsync && z++<videoWidth) vidtick();
|
||||
while (gen.hsync && z++<videoWidth) vidtick();
|
||||
}
|
||||
var z=0;
|
||||
while (gen.vsync && z++<videoWidth*80) vidtick();
|
||||
while (!gen.vsync && z++<videoWidth*80) vidtick();
|
||||
while (gen.vsync && z++<videoWidth*80) vidtick();
|
||||
updateInspectionFrame();
|
||||
video.updateFrame();
|
||||
updateInspectionPostFrame();
|
||||
}
|
||||
|
||||
var yposlist = [];
|
||||
@ -187,9 +222,9 @@ var VerilogPlatform = function(mainElement, options) {
|
||||
if (idata[i])
|
||||
idata[i] = 0; //<<= 1;
|
||||
}
|
||||
var COLOR_SIGNAL = 0xff11ff11;
|
||||
var COLOR_BORDER = 0xff661111;
|
||||
var COLOR_TRANS_SIGNAL = 0xff116611;
|
||||
var COLOR_SIGNAL = 0xff22ff22;
|
||||
var COLOR_BORDER = 0xff662222;
|
||||
var COLOR_TRANS_SIGNAL = 0xff226622;
|
||||
for (var x=0; x<videoWidth; x++) {
|
||||
gen.clk ^= 1;
|
||||
gen.eval();
|
||||
@ -221,11 +256,9 @@ var VerilogPlatform = function(mainElement, options) {
|
||||
video.updateFrame();
|
||||
// draw labels
|
||||
var ctx = video.getContext();
|
||||
ctx.font = "8px TinyFont";
|
||||
ctx.fillStyle = "white";
|
||||
for (var i=0; i<arr.length; i++) {
|
||||
var v = arr[i];
|
||||
ctx.textAlign = 'left';
|
||||
ctx.fillStyle = v.name == inspect_sym ? "yellow" : "white";
|
||||
ctx.fillText(v.name, 1, yposlist[i]);
|
||||
//ctx.textAlign = 'right';
|
||||
//ctx.fillText(""+gen[v.name], videoWidth-1, yposlist[i]);
|
||||
@ -240,6 +273,10 @@ var VerilogPlatform = function(mainElement, options) {
|
||||
// TODO
|
||||
video = new RasterVideo(mainElement,videoWidth,videoHeight);
|
||||
video.create();
|
||||
var ctx = video.getContext();
|
||||
ctx.font = "8px TinyFont";
|
||||
ctx.fillStyle = "white";
|
||||
ctx.textAlign = "left";
|
||||
setKeyboardFromMap(video, switches, VERILOG_KEYCODE_MAP);
|
||||
$(video.canvas).mousemove(function(e) {
|
||||
paddle_x = clamp(8,240,Math.floor(e.offsetX * video.canvas.width / $(video.canvas).width() - 20));
|
||||
@ -283,10 +320,8 @@ var VerilogPlatform = function(mainElement, options) {
|
||||
var base = new VerilatorBase();
|
||||
gen = new mod(base);
|
||||
gen.__proto__ = base;
|
||||
output.code = null;
|
||||
output.ports_signals = output.ports.concat(output.signals);
|
||||
current_output = output;
|
||||
this.reset();
|
||||
this.poweron();
|
||||
}
|
||||
|
||||
this.isRunning = function() {
|
||||
@ -301,14 +336,37 @@ var VerilogPlatform = function(mainElement, options) {
|
||||
if (gen.spkr !== undefined) audio.start();
|
||||
}
|
||||
|
||||
this.reset = function() {
|
||||
this.poweron = function() {
|
||||
gen._ctor_var_reset();
|
||||
this.reset();
|
||||
}
|
||||
this.reset = function() {
|
||||
gen.reset2();
|
||||
}
|
||||
this.getToolForFilename = function(fn) {
|
||||
return "verilator";
|
||||
}
|
||||
this.getDefaultExtension = function() { return ".v"; };
|
||||
|
||||
this.inspect = function(name) {
|
||||
if (!gen) return;
|
||||
if (name && !name.match(/^\w+$/)) return;
|
||||
var val = gen[name];
|
||||
if (val === undefined && current_output.code) {
|
||||
var re = new RegExp("(\\w+__DOT__" + name + ")\\b", "gm");
|
||||
var m = re.exec(current_output.code);
|
||||
if (m) {
|
||||
name = m[1];
|
||||
val = gen[name];
|
||||
}
|
||||
}
|
||||
if (val !== undefined) {
|
||||
inspect_obj = gen;
|
||||
inspect_sym = name;
|
||||
} else {
|
||||
inspect_obj = inspect_sym = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function traceTiming() {
|
||||
|
25
src/ui.js
25
src/ui.js
@ -189,10 +189,27 @@ function newEditor(mode) {
|
||||
setCode(editor.getValue());
|
||||
}, 200);
|
||||
});
|
||||
editor.on('cursorActivity', function(ed) {
|
||||
var start = editor.getCursor(true);
|
||||
var end = editor.getCursor(false);
|
||||
if (start.line == end.line && start.ch < end.ch) {
|
||||
var name = editor.getSelection();
|
||||
inspectVariable(editor, name);
|
||||
} else {
|
||||
inspectVariable(editor);
|
||||
}
|
||||
});
|
||||
scrollProfileView(editor);
|
||||
editor.setOption("mode", mode);
|
||||
}
|
||||
|
||||
function inspectVariable(editor, name) {
|
||||
var val;
|
||||
if (platform.inspect) {
|
||||
platform.inspect(name);
|
||||
}
|
||||
}
|
||||
|
||||
function getCurrentPresetTitle() {
|
||||
if (current_preset_index < 0)
|
||||
return "ROM";
|
||||
@ -1105,7 +1122,13 @@ function lookBackwardsForJSONComment(line, req) {
|
||||
var pos0 = start.ch;
|
||||
line--;
|
||||
while (++line < editor.lineCount()) {
|
||||
if (editor.getLine(line).indexOf(';') >= pos0) {
|
||||
var l = editor.getLine(line);
|
||||
var endsection;
|
||||
if (platform_id == 'verilog')
|
||||
endsection = l.indexOf('end') >= pos0;
|
||||
else
|
||||
endsection = l.indexOf(';') >= pos0;
|
||||
if (endsection) {
|
||||
var end = {line:line, ch:editor.getLine(line).length};
|
||||
return {obj:obj, start:start, end:end};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user