ameetgohil / signalflip-js

verilator testbench w/ Javascript using N-API
MIT License
18 stars 3 forks source link

variable time between verilator ticks #33

Closed drom closed 3 years ago

drom commented 4 years ago

Example:

User adds 2 clock signals: clk8 and clk6 with period 8 and 6 units respectively.

  sim.addClock(new Clock(dut.clk8, 8));
  sim.addClock(new Clock(dut.clk6, 6));

Over the period of 17 units, simulator will run eval loop 34 times (ticks1) even so, it is sufficient to run it only 9 times. (ticks2)

{signal: [
  {name: 'clk8',  wave: 'L.H...L...H...L..'},
  {name: 'clk6',  wave: 'LH..L..H..L..H..L'},
  {name: 'ticks1', wave: 'HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH', period: 0.5},
  {name: 'ticks2', wave: '1.H.H...H...H.H.....H.....H.H...H.', period: 0.5},
]}

wavedrom(1)

Main simulation loop should progress with variable time delta. Example: https://github.com/drom/clocker/blob/master/src/tb.cpp#L28

Special code should calculate next delta and update clock counters. Example: https://github.com/drom/clocker/blob/master/src/clocker.h

ameetgohil commented 3 years ago

Done. v0.12.0 released