mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-06-09 15:29:29 +00:00
verilog: genModuleSync (for testing)
This commit is contained in:
parent
565d7d947c
commit
f634007e51
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
//import binaryen = require('binaryen');
|
//import binaryen = require('binaryen');
|
||||||
import { fn } from "jquery";
|
//import { fn } from "jquery";
|
||||||
import { HDLError, HDLModuleJS } from "./hdlruntime";
|
import { HDLError, HDLModuleJS } from "./hdlruntime";
|
||||||
import { HDLModuleWASM } from "./hdlwasm";
|
import { HDLModuleWASM } from "./hdlwasm";
|
||||||
import { CompileError, VerilogXMLParser } from "./vxmlparser";
|
import { CompileError, VerilogXMLParser } from "./vxmlparser";
|
||||||
|
@ -14,19 +14,15 @@ export function fuzz(buf) {
|
||||||
if (e instanceof CompileError) return;
|
if (e instanceof CompileError) return;
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
/*
|
if (1) {
|
||||||
if (0) {
|
|
||||||
var wmod = new HDLModuleWASM(parser.modules['TOP'], parser.modules['@CONST-POOL@']);
|
var wmod = new HDLModuleWASM(parser.modules['TOP'], parser.modules['@CONST-POOL@']);
|
||||||
wmod.traceBufferSize = 0x8000;
|
wmod.traceBufferSize = 0x8000;
|
||||||
wmod.maxMemoryMB = 0.25;
|
wmod.maxMemoryMB = 0.25;
|
||||||
wmod.init().then(() => {
|
wmod.initSync();
|
||||||
wmod.powercycle();
|
wmod.powercycle();
|
||||||
wmod.tick2(10000);
|
wmod.tick2(10000);
|
||||||
wmod.dispose();
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
*/
|
if (0) {
|
||||||
if (1) {
|
|
||||||
var jmod = new HDLModuleJS(parser.modules['TOP'], parser.modules['@CONST-POOL@']);
|
var jmod = new HDLModuleJS(parser.modules['TOP'], parser.modules['@CONST-POOL@']);
|
||||||
jmod.init();
|
jmod.init();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
import binaryen = require('binaryen');
|
import binaryen = require('binaryen');
|
||||||
import { hasDataType, HDLBinop, HDLBlock, HDLConstant, HDLDataType, HDLDataTypeObject, HDLExpr, HDLExtendop, HDLFuncCall, HDLModuleDef, HDLModuleRunner, HDLSourceLocation, HDLSourceObject, HDLTriop, HDLUnop, HDLValue, HDLVariableDef, HDLVarRef, HDLWhileOp, isArrayItem, isArrayType, isBigConstExpr, isBinop, isBlock, isConstExpr, isFuncCall, isLogicType, isTriop, isUnop, isVarDecl, isVarRef, isWhileop } from "./hdltypes";
|
import { hasDataType, HDLBinop, HDLBlock, HDLConstant, HDLDataType, HDLDataTypeObject, HDLExpr, HDLExtendop, HDLFuncCall, HDLModuleDef, HDLModuleRunner, HDLSourceLocation, HDLSourceObject, HDLTriop, HDLUnop, HDLValue, HDLVariableDef, HDLVarRef, HDLWhileOp, isArrayItem, isArrayType, isBigConstExpr, isBinop, isBlock, isConstExpr, isFuncCall, isLogicType, isTriop, isUnop, isVarDecl, isVarRef, isWhileop } from "./hdltypes";
|
||||||
import { HDLError } from "./hdlruntime";
|
import { HDLError } from "./hdlruntime";
|
||||||
import { EmuHalt } from '../emu';
|
|
||||||
|
|
||||||
const VERILATOR_UNIT_FUNCTIONS = [
|
const VERILATOR_UNIT_FUNCTIONS = [
|
||||||
"_ctor_var_reset",
|
"_ctor_var_reset",
|
||||||
|
@ -214,6 +213,13 @@ export class HDLModuleWASM implements HDLModuleRunner {
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
await this.genModule();
|
await this.genModule();
|
||||||
|
this.genStateInterface();
|
||||||
|
this.enableTracing();
|
||||||
|
}
|
||||||
|
|
||||||
|
initSync() {
|
||||||
|
this.genModuleSync();
|
||||||
|
this.genStateInterface();
|
||||||
this.enableTracing();
|
this.enableTracing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,6 +450,15 @@ export class HDLModuleWASM implements HDLModuleRunner {
|
||||||
var wasmData = this.bmod.emitBinary();
|
var wasmData = this.bmod.emitBinary();
|
||||||
var compiled = await WebAssembly.compile(wasmData);
|
var compiled = await WebAssembly.compile(wasmData);
|
||||||
this.instance = await WebAssembly.instantiate(compiled, this.getImportObject());
|
this.instance = await WebAssembly.instantiate(compiled, this.getImportObject());
|
||||||
|
}
|
||||||
|
|
||||||
|
private genModuleSync() {
|
||||||
|
var wasmData = this.bmod.emitBinary();
|
||||||
|
var compiled = new WebAssembly.Module(wasmData);
|
||||||
|
this.instance = new WebAssembly.Instance(compiled, this.getImportObject());
|
||||||
|
}
|
||||||
|
|
||||||
|
private genStateInterface() {
|
||||||
this.databuf = (this.instance.exports[MEMORY] as any).buffer;
|
this.databuf = (this.instance.exports[MEMORY] as any).buffer;
|
||||||
this.data8 = new Uint8Array(this.databuf);
|
this.data8 = new Uint8Array(this.databuf);
|
||||||
this.data16 = new Uint16Array(this.databuf);
|
this.data16 = new Uint16Array(this.databuf);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user