1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-22 14:33:51 +00:00

verilog: scope view go to current position, no more scrolling

This commit is contained in:
Steven Hugg 2021-06-23 18:44:30 -05:00
parent f8532b44aa
commit 4a916b88e3
2 changed files with 20 additions and 5 deletions

View File

@ -34,6 +34,7 @@ export class WaveformView {
zoom : number = 8;
t0 : number = 0;
tsel : number = -1;
tnow : number = -1;
pageWidth : number;
clocksPerPage : number;
clockMax : number;
@ -161,6 +162,10 @@ export class WaveformView {
this.toolbar.add('shift+right', 'Move right 1/4 page', 'glyphicon-fast-forward', (e,combo) => {
this.setSelTime(this.tsel + this.clocksPerPage/4);
});
this.toolbar.add('space', 'Go to current time', 'glyphicon-flash', (e,combo) => {
this.setOrgTime(this.tnow);
this.setSelTime(this.tnow);
});
this.toolbar.add('h', 'Switch between hex/decimal format', 'glyphicon-barcode', (e,combo) => {
this.hexformat = !this.hexformat;
this.refresh();
@ -181,11 +186,12 @@ export class WaveformView {
this.t0 = this.roundT(t);
this.refresh();
}
setEndTime(t : number) {
this.setOrgTime(t - this.clocksPerPage);
setCurrentTime(t : number) {
this.tnow = this.roundT(t);
this.refresh();
}
setSelTime(t : number) {
t = this.roundT(t);
if (t >= this.t0 + this.clocksPerPage - 1)
@ -302,6 +308,15 @@ export class WaveformView {
ctx.fillText(s, x, ycen);
}
}
// draw current line
if (this.tnow >= this.t0) {
ctx.strokeStyle = ctx.fillStyle = "#6666cc";
ctx.beginPath();
x = (this.tnow - this.t0)*this.zoom + this.zoom/2;
ctx.moveTo(x, 0);
ctx.lineTo(x, h);
ctx.stroke();
}
// draw labels
ctx.fillStyle = "white";
ctx.textAlign = "left";

View File

@ -438,7 +438,7 @@ var VerilogPlatform = function(mainElement, options) {
this.refreshVideoFrame();
// set scope offset
if (trace && this.waveview) {
this.waveview.setEndTime(Math.floor(trace_index/trace_signals.length));
this.waveview.setCurrentTime(Math.floor(trace_index/trace_signals.length));
}
}