Skip to content

Commit

Permalink
Merge pull request #11 from rejunity/main
Browse files Browse the repository at this point in the history
perf: speed up access to "uo_out" while generating image from the sim
  • Loading branch information
urish authored Sep 14, 2024
2 parents d19a742 + 342668b commit 1ff79bb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ let jmod = new HDLModuleWASM(res.output.modules['TOP'], res.output.modules['@CON
//let jmod = new HDLModuleJS(res.output.modules['TOP'], res.output.modules['@CONST-POOL@']);
await jmod.init();

const uo_out_offset_in_jmod_databuf = jmod.globals.lookup("uo_out").offset;

function reset() {
const ui_in = jmod.state.ui_in;
jmod.powercycle();
Expand All @@ -44,7 +46,11 @@ function reset() {
reset();

function getVGASignals() {
const uo_out = jmod.state.uo_out as number;
// it is significanly faster to read 'uo_out' value directly from the jmod data buffer
// instead of jmod.state.uo_out acccessor property
// see HDLModuleWASM.defineProperty() implementation for inner details on how accessor works
const uo_out = jmod.data8[uo_out_offset_in_jmod_databuf];

return {
hsync: !!(uo_out & 0b10000000),
vsync: !!(uo_out & 0b00001000),
Expand Down

0 comments on commit 1ff79bb

Please sign in to comment.