"use strict"; var VERILOG_PRESETS = [ {id:'hvsync.v', name:'Hello Verilog'}, {id:'pong.v', name:'Pong'}, ]; function VerilatorBase() { this.VL_RAND_RESET_I = function(bits) { return Math.floor(Math.random() * (1< 100) { vl_fatal("Verilated model didn't converge"); } } if (__VclockLoop > maxVclockLoop) { maxVclockLoop = __VclockLoop; console.log("Graph took " + maxVclockLoop + " iterations to stabilize"); } } this._eval_initial_loop = function(vlSymsp) { vlSymsp.__Vm_didInit = true; this._eval_initial(vlSymsp); vlSymsp.__Vm_activity = true; var __VclockLoop = 0; var __Vchange=1; while (__Vchange) { this._eval_settle(vlSymsp); this._eval(vlSymsp); __Vchange = this._change_request(vlSymsp); if (++__VclockLoop > 100) { vl_fatal("Verilated model didn't DC converge"); } } } } var VerilogPlatform = function(mainElement, options) { var self = this; var video, audio; var videoWidth=288; var videoHeight=248; var idata, timer; var gen; var frameRate = 60; var AUDIO_FREQ = 15700; var current_output; this.getPresets = function() { return VERILOG_PRESETS; } function tick2() { gen.tick2(); audio.addSingleSample(0+gen.audio); // TODO: sync with audio freq } var RGBLOOKUP = [ 0xff111111, 0xff1111ff, 0xff11ff11, 0xff11ffff, 0xffff1111, 0xffff11ff, 0xffffff11, 0xffffffff, ]; function updateVideoFrame() { var i=0; for (var y=0; y1 ? v.len*2+8 : 8; var y2 = y1+ys; var z = gen[v.name]; var y = y2 - ys*((z-lo)/hi); yposlist[i] = y2; //idata[x + y1*videoWidth] = COLOR_BORDER; //idata[x + y2*videoWidth] = COLOR_BORDER; idata[x + Math.round(y)*videoWidth] = COLOR_SIGNAL; y1 += ys+yb; } } video.updateFrame(); // draw labels var ctx = video.getContext(); ctx.font = "8px TinyFont"; ctx.fillStyle = "white"; for (var i=0; i