1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-29 14:51:17 +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; zoom : number = 8;
t0 : number = 0; t0 : number = 0;
tsel : number = -1; tsel : number = -1;
tnow : number = -1;
pageWidth : number; pageWidth : number;
clocksPerPage : number; clocksPerPage : number;
clockMax : 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.toolbar.add('shift+right', 'Move right 1/4 page', 'glyphicon-fast-forward', (e,combo) => {
this.setSelTime(this.tsel + this.clocksPerPage/4); 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.toolbar.add('h', 'Switch between hex/decimal format', 'glyphicon-barcode', (e,combo) => {
this.hexformat = !this.hexformat; this.hexformat = !this.hexformat;
this.refresh(); this.refresh();
@ -182,8 +187,9 @@ export class WaveformView {
this.refresh(); this.refresh();
} }
setEndTime(t : number) { setCurrentTime(t : number) {
this.setOrgTime(t - this.clocksPerPage); this.tnow = this.roundT(t);
this.refresh();
} }
setSelTime(t : number) { setSelTime(t : number) {
@ -302,6 +308,15 @@ export class WaveformView {
ctx.fillText(s, x, ycen); 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 // draw labels
ctx.fillStyle = "white"; ctx.fillStyle = "white";
ctx.textAlign = "left"; ctx.textAlign = "left";

View File

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