1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-10-12 06:23:42 +00:00

verilog: change input value by clicking

This commit is contained in:
Steven Hugg 2021-04-29 15:25:29 -05:00
parent c654c758ea
commit add8ce7b8c
12 changed files with 5613 additions and 34 deletions

View File

@ -278,7 +278,9 @@ div.emuoverlay {
}
div.emuscope {
background-color:#333;
color:#ccc;
z-index:1;
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
}
div.emuspacer {
width:100%;
@ -757,3 +759,9 @@ div.asset_toolbar {
.tree-level-8 { background-color: #837163;}
.tree-level-9 { background-color: #7b8363;}
.tree-level-10 { background-color: #738363;}
.waverow {
}
.waverow.editable:hover {
background-color: #336633;
}

View File

@ -106,6 +106,7 @@ TODO:
- bad error msg if >2 moduels and top module doesn't match filename
- separate Scope View
- Audio doesn't work if clock != default
- change the input values for a module?
- single-stepping vector games makes screen fade
- break on stack overflow, illegal op, bad access, BRK, etc
- show in scope instead?

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

View File

@ -36,7 +36,6 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
<!-- firebase libs -->
<script defer src="https://www.gstatic.com/firebasejs/8.3.2/firebase-app.js"></script>
<script defer src="https://www.gstatic.com/firebasejs/8.3.2/firebase-auth.js"></script>
<!--<script defer src="https://www.gstatic.com/firebasejs/8.3.2/firebase-database.js"></script>-->
<script defer src="config.js"></script>
</head>

View File

@ -35,8 +35,8 @@
-<script async src='https://www.google-analytics.com/analytics.js'></script>
-
-<!-- firebase libs -->
-<script defer src="https://www.gstatic.com/firebasejs/5.11.1/firebase-app.js"></script>
-<script defer src="https://www.gstatic.com/firebasejs/5.11.1/firebase-auth.js"></script>
-<script defer src="https://www.gstatic.com/firebasejs/8.3.2/firebase-app.js"></script>
-<script defer src="https://www.gstatic.com/firebasejs/8.3.2/firebase-auth.js"></script>
-<script defer src="config.js"></script>
-
</head>

5534
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -16,7 +16,7 @@
"update-electron-app": "^1.5.0"
},
"devDependencies": {
"@types/bootbox": "^4.4.36",
"@types/bootbox": "^5.1.3",
"@types/bootstrap": "^3.4.0",
"@types/file-saver": "^2.0.1",
"@types/jquery": "^3.5.5",

12
res/README Normal file
View File

@ -0,0 +1,12 @@
# C64
How to build the ROM:
~~~
git clone https://github.com/MEGA65/open-roms
cd open-roms
make
cd build
cat basic_generic.rom chargen_openroms.rom kernal_generic.rom > c64.bios
~~~

Binary file not shown.

View File

@ -3,14 +3,24 @@ import { Toolbar } from "../common/emu";
declare var VirtualList;
const BUILTIN_INPUT_PORTS = [
'clk', 'reset',
];
export interface WaveformMeta {
label : string;
len : number;
//name : string;
//ofs : number;
//wordlen : number;
input : boolean;
output : boolean;
}
export interface WaveformProvider {
getSignalMetadata() : WaveformMeta[];
getSignalData(index:number, start:number, len:number) : number[];
setSignalValue(index:number, value:number);
}
export class WaveformView {
@ -70,15 +80,25 @@ export class WaveformView {
totalRows: this.meta.length+1,
generatorFn: (row : number) => {
var metarow = this.meta[row]; // TODO: why null?
var s = metarow != null ? metarow.label : "";
var linediv = document.createElement("div");
var canvas = document.createElement("canvas");
//var s = metarow != null ? metarow.label : "";
let linediv = document.createElement("div");
let canvas = document.createElement("canvas");
canvas.width = width - 12;
canvas.height = rowHeight;
linediv.appendChild(canvas); //document.createTextNode(s));
linediv.classList.add('waverow');
this.lines[row] = canvas;
this.refreshRow(row);
// click to change input
if (metarow && metarow.input && BUILTIN_INPUT_PORTS.indexOf(metarow.label) < 0) {
linediv.onmousedown = (e) => {
var meta = this.meta[row];
if (meta && meta.input) {
this.changeInputValue(row);
}
};
linediv.classList.add('editable');
}
return linediv;
}
});
@ -87,7 +107,12 @@ export class WaveformView {
//wlc.style = "overflow-x: hidden"; // TODO?
this.toolbar = new Toolbar(this.parent, this.parent);
this.toolbar.span.css('display','inline-block');
//var clklabel = document.createElement('span');
//clklabel.style.display = 'inline-block';
//clklabel.innerHTML = "TEST";
//$(this.parent).append(clklabel);
$(this.parent).append(wlc);
var down = false;
var selfn = (e) => {
this.setSelTime(e.offsetX / this.zoom + this.t0 - 0.5);
@ -189,6 +214,10 @@ export class WaveformView {
ctx.font = "14px Andale Mono, Lucida Console, monospace";
// clear to black
ctx.clearRect(0, 0, canvas.width, canvas.height);
// highlighted?
var tags = [];
if (meta.input && BUILTIN_INPUT_PORTS.indexOf(meta.label) < 0) tags.push('input');
//if (meta.output) tags.push('output');
// draw waveform
var fh = 12;
var b1 = fh+4;
@ -252,7 +281,39 @@ export class WaveformView {
// draw labels
ctx.fillStyle = "white";
ctx.textAlign = "left";
ctx.fillText(meta.label, 5, fh);
var lbl = meta.label;
if (tags.length > 0) { lbl += " (" + tags.join(', ') + ")"; }
ctx.fillText(lbl, 5, fh);
}
changeInputValue(row : number) {
var meta = this.meta[row];
if (!meta) return;
var data = this.wfp.getSignalData(row, this.t0, 1);
var oldValue = data[0] || 0;
var min = 0;
var max = (1 << meta.len) - 1;
if (max == 1) {
this.wfp.setSignalValue(row, oldValue > 0 ? 0 : 1);
} else {
var rangestr = `${min} to ${max}`;
bootbox.prompt({
value: oldValue+"",
inputType: "number",
//min: 0,
//max: meta.len-1,
//placeholder: rangestr,
title: `Enter new value for "${meta.label}" (${rangestr}):`,
callback: (result) => {
if (result != null) {
var value = parseInt(result);
if (value >= min && value <= max) {
this.wfp.setSignalValue(row, parseInt(result));
}
}
}
});
}
}
}

View File

@ -614,6 +614,12 @@ var VerilogPlatform = function(mainElement, options) {
return a;
}
setSignalValue(index:number, value:number) {
var meta = this.getSignalMetadata()[index];
gen[meta.label] = value;
this.reset();
}
printErrorCodeContext(e, code) {
if (e.lineNumber && e.message) {
var lines = code.split('\n');

View File

@ -4,7 +4,9 @@ type V2JS_Var = {
name:string,
len:number,
ofs:number,
arrdim?:number[]
arrdim?:number[],
input:boolean,
output:boolean,
}
type V2JS_Code = {
@ -37,6 +39,8 @@ function parseDecls(text:string, arr:V2JS_Var[], name:string, bin?:boolean, bout
name:m[2],
len:parseInt(m[3])+1,
ofs:parseInt(m[4]),
input:bin,
output:bout,
});
}
re = new RegExp(name + "(\\d*)[(](\\w+)\\[(\\d+)\\],(\\d+),(\\d+)[)]", 'gm');
@ -48,6 +52,8 @@ function parseDecls(text:string, arr:V2JS_Var[], name:string, bin?:boolean, bout
arrdim:[parseInt(m[3])],
len:parseInt(m[4])+1,
ofs:parseInt(m[5]),
input:bin,
output:bout,
});
}
re = new RegExp(name + "(\\d*)[(](\\w+)\\[(\\d+)\\]\\[(\\d+)\\],(\\d+),(\\d+)[)]", 'gm');
@ -59,6 +65,8 @@ function parseDecls(text:string, arr:V2JS_Var[], name:string, bin?:boolean, bout
arrdim:[parseInt(m[3]), parseInt(m[4])],
len:parseInt(m[5])+1,
ofs:parseInt(m[6]),
input:bin,
output:bout,
});
}
}