@specy/risc-v 3.4.1 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +139 -16
- package/dist/index.d.ts +139 -16
- package/dist/index.js +4970 -4324
- package/dist/index.mjs +4970 -4324
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -291,7 +291,18 @@ declare enum BackStepAction {
|
|
|
291
291
|
* Members mirror the core's `BackStepper.Action` by position, because the core reports an
|
|
292
292
|
* action as that enum's ordinal. Append here; never insert.
|
|
293
293
|
*/
|
|
294
|
-
CONTROL_AND_STATUS_COUNTERS_DECREMENT = 11
|
|
294
|
+
CONTROL_AND_STATUS_COUNTERS_DECREMENT = 11,
|
|
295
|
+
/**
|
|
296
|
+
* Restores one control and status register the way the host's setter wrote it, through the
|
|
297
|
+
* register's own value: a linked register writes the register it aliases, a read only counter
|
|
298
|
+
* is written anyway. Only a Poke records this, and only inside its own entry.
|
|
299
|
+
*/
|
|
300
|
+
CONTROL_AND_STATUS_REGISTER_POKE_RESTORE = 12,
|
|
301
|
+
/**
|
|
302
|
+
* A whole Poke: every value one `beginPoke`/`endPoke` transaction wrote, restored together.
|
|
303
|
+
* A Poke is a single back step, so it takes one slot of the undo size whatever it wrote.
|
|
304
|
+
*/
|
|
305
|
+
POKE = 13
|
|
295
306
|
}
|
|
296
307
|
/**
|
|
297
308
|
* Represents a back step in the simulation undo stack.
|
|
@@ -310,10 +321,82 @@ interface JsBackStep {
|
|
|
310
321
|
*/
|
|
311
322
|
readonly param2: number;
|
|
312
323
|
/**
|
|
313
|
-
* The program counter value before the action
|
|
324
|
+
* The program counter value before the action, or -1 for an action that belongs to no
|
|
325
|
+
* instruction: a Poke, or a host write made before anything ran.
|
|
314
326
|
*/
|
|
315
327
|
readonly pc: number;
|
|
328
|
+
/**
|
|
329
|
+
* Whether this step is a whole Poke rather than one effect of an instruction. It is the
|
|
330
|
+
* discriminator this list needs, since a Poke and a pre-run host write both carry `pc` -1.
|
|
331
|
+
*/
|
|
332
|
+
readonly isPoke: boolean;
|
|
316
333
|
}
|
|
334
|
+
/**
|
|
335
|
+
* One value a Poke changed: a register, named the way this package's getters spell it, or a run of
|
|
336
|
+
* consecutive memory bytes. `old` is what the simulator held when the write happened and `new` what
|
|
337
|
+
* it held when the Poke was closed, so a value written twice inside one Poke reports its final
|
|
338
|
+
* state.
|
|
339
|
+
*/
|
|
340
|
+
type JsPokeWrite = JsPokeRegisterWrite | JsPokeMemoryWrite;
|
|
341
|
+
/**
|
|
342
|
+
* A register a Poke wrote. `name` is the register's own name, as this package spells it: a key of
|
|
343
|
+
* `RISCVRegisters` (`t0`), an entry of `RISCV_FLOATING_POINT_REGISTERS` (`ft0`) or one of
|
|
344
|
+
* `RISCV_CSR_REGISTERS` (`fcsr`) - the file it belongs to is the file that name is in.
|
|
345
|
+
*
|
|
346
|
+
* Every register here is 64 bits wide, which no JS number holds, so both values are **signed
|
|
347
|
+
* decimal strings**, the shape `getRegisterValueLong` and `getRegistersValuesLong` already use:
|
|
348
|
+
* read them with `BigInt(write.old)`, and with `BigInt.asUintN(64, BigInt(write.old))` for the
|
|
349
|
+
* unsigned form that `highLowToBigint` returns for the same register.
|
|
350
|
+
*/
|
|
351
|
+
type JsPokeRegisterWrite = {
|
|
352
|
+
readonly type: 'register';
|
|
353
|
+
readonly name: string;
|
|
354
|
+
readonly old: string;
|
|
355
|
+
readonly new: string;
|
|
356
|
+
};
|
|
357
|
+
/**
|
|
358
|
+
* A run of consecutive memory bytes a Poke wrote, `address` being the first one, unsigned, and the
|
|
359
|
+
* two arrays holding one byte (0 to 255) per address. A Poke that writes addresses that are not
|
|
360
|
+
* adjacent reports one of these per run, by ascending address. Unlike `readMemoryBytes`, these are
|
|
361
|
+
* ordinary JS arrays.
|
|
362
|
+
*/
|
|
363
|
+
type JsPokeMemoryWrite = {
|
|
364
|
+
readonly type: 'memory';
|
|
365
|
+
readonly address: number;
|
|
366
|
+
readonly old: number[];
|
|
367
|
+
readonly new: number[];
|
|
368
|
+
};
|
|
369
|
+
/**
|
|
370
|
+
* One entry of the undo history: everything a single `undo()` reverts, which is either one executed
|
|
371
|
+
* instruction or one Poke. Entries, their back steps and their writes are ordinary objects with own
|
|
372
|
+
* properties, so a whole history can be cloned, serialized or deep-compared as it comes.
|
|
373
|
+
*/
|
|
374
|
+
type JsUndoGroup = JsInstructionUndoGroup | JsPokeUndoGroup;
|
|
375
|
+
/**
|
|
376
|
+
* One executed instruction, at the address `pc`, with every back step it recorded: the values it
|
|
377
|
+
* overwrote, and the `cycle`/`instret` decrement every instruction pushes on top of them.
|
|
378
|
+
*/
|
|
379
|
+
type JsInstructionUndoGroup = {
|
|
380
|
+
readonly kind: 'instruction';
|
|
381
|
+
readonly pc: number;
|
|
382
|
+
/** The instruction's back steps, newest first. */
|
|
383
|
+
readonly steps: JsBackStep[];
|
|
384
|
+
/** Always empty: only a Poke reports writes. */
|
|
385
|
+
readonly writes: readonly [];
|
|
386
|
+
};
|
|
387
|
+
/**
|
|
388
|
+
* One Poke: register or memory values written by the host between two instructions, recorded as a
|
|
389
|
+
* step of its own. It belongs to no instruction, so `pc` is -1 and undoing it restores exactly what
|
|
390
|
+
* `writes` lists, leaving the program counter, the counters, the call stack and everything else
|
|
391
|
+
* alone.
|
|
392
|
+
*/
|
|
393
|
+
type JsPokeUndoGroup = {
|
|
394
|
+
readonly kind: 'poke';
|
|
395
|
+
readonly pc: -1;
|
|
396
|
+
/** The single back step the Poke is: one slot of the history, whatever the Poke wrote. */
|
|
397
|
+
readonly steps: [JsBackStep];
|
|
398
|
+
readonly writes: JsPokeWrite[];
|
|
399
|
+
};
|
|
317
400
|
declare enum RISCVRegisters {
|
|
318
401
|
zero = 0,
|
|
319
402
|
ra = 1,
|
|
@@ -406,7 +489,8 @@ interface JsRiscV {
|
|
|
406
489
|
*/
|
|
407
490
|
setUndoSize(size: number): void;
|
|
408
491
|
/**
|
|
409
|
-
* Undoes the last instruction executed
|
|
492
|
+
* Undoes the newest entry of the history: the last instruction executed, or the last Poke made,
|
|
493
|
+
* whichever is on top. Undoing a Poke restores every value it wrote and touches nothing else.
|
|
410
494
|
*/
|
|
411
495
|
undo(): void;
|
|
412
496
|
/**
|
|
@@ -532,10 +616,10 @@ interface JsRiscV {
|
|
|
532
616
|
*/
|
|
533
617
|
getFloatingPointRegistersValues(): Int32Array;
|
|
534
618
|
/**
|
|
535
|
-
* Sets one floating point register
|
|
536
|
-
* presetting a register from the host is not something the program did.
|
|
537
|
-
*
|
|
538
|
-
* what you mean.
|
|
619
|
+
* Sets one floating point register. Outside a Poke the write is direct: no undo entry is
|
|
620
|
+
* recorded, because presetting a register from the host is not something the program did.
|
|
621
|
+
* Inside a Poke it joins the open transaction. Split the value with `bigintToHighLow`, and
|
|
622
|
+
* NaN-box a single yourself (`0xFFFFFFFFn << 32n | bits`) if that is what you mean.
|
|
539
623
|
* @param index Position in `RISCV_FLOATING_POINT_REGISTERS`. Must be a whole number from 0 to
|
|
540
624
|
* 31; anything else throws.
|
|
541
625
|
*/
|
|
@@ -549,18 +633,51 @@ interface JsRiscV {
|
|
|
549
633
|
*/
|
|
550
634
|
getControlAndStatusRegistersValues(): Int32Array;
|
|
551
635
|
/**
|
|
552
|
-
* Sets one control and status register
|
|
553
|
-
* Writing `fflags` or `frm` updates `fcsr`,
|
|
554
|
-
* here even though the program cannot write
|
|
636
|
+
* Sets one control and status register. Outside a Poke the write is direct and records no undo
|
|
637
|
+
* entry; inside a Poke it joins the open transaction. Writing `fflags` or `frm` updates `fcsr`,
|
|
638
|
+
* and writing a counter such as `cycle` is allowed here even though the program cannot write
|
|
639
|
+
* it - so a counter is pokeable, and undoing that Poke puts the counter back.
|
|
555
640
|
* @param index Position in `RISCV_CSR_REGISTERS`. Must be a whole number from 0 to 16;
|
|
556
641
|
* anything else throws.
|
|
557
642
|
*/
|
|
558
643
|
setControlAndStatusRegisterValue(index: number, high: number, low: number): void;
|
|
559
644
|
/**
|
|
560
|
-
* Gets the undo stack.
|
|
645
|
+
* Gets the undo stack, one element per back step, newest first. An instruction usually occupies
|
|
646
|
+
* several of them - it records the values it overwrote and the counter decrement - while a Poke
|
|
647
|
+
* is exactly one, the element with `isPoke` set, whatever it wrote. Use `getUndoGroups` to read
|
|
648
|
+
* the history the way `undo()` pops it, one entry per instruction or Poke.
|
|
561
649
|
* @returns An array of `JsBackStep` objects representing the history of the simulation.
|
|
562
650
|
*/
|
|
563
651
|
getUndoStack(): JsBackStep[];
|
|
652
|
+
/**
|
|
653
|
+
* Gets the undo history grouped the way `undo()` pops it: one entry per executed instruction or
|
|
654
|
+
* per Poke, newest first, each carrying the back steps it is made of. A Poke entry also carries
|
|
655
|
+
* what it changed, with the old and the new value of each write.
|
|
656
|
+
*/
|
|
657
|
+
getUndoGroups(): JsUndoGroup[];
|
|
658
|
+
/**
|
|
659
|
+
* Opens a Poke: a register or memory value changed by the host between two instructions,
|
|
660
|
+
* recorded in this history as a step of its own.
|
|
661
|
+
*
|
|
662
|
+
* Until `endPoke` the setters - `setRegisterValue`, `setFloatingPointRegisterValue`,
|
|
663
|
+
* `setControlAndStatusRegisterValue` and `setMemoryBytes` - journal what they write into the
|
|
664
|
+
* open transaction, however many of them are called, and `endPoke` records the lot as one
|
|
665
|
+
* history entry that one `undo()` reverts and that takes one slot of the undo size, whether it
|
|
666
|
+
* wrote one byte or a hundred. Outside a transaction the same setters stay direct and record
|
|
667
|
+
* nothing, which is what presetting state needs.
|
|
668
|
+
*
|
|
669
|
+
* Throws if a Poke is already open, or if a `step`/`simulate*` call is still in flight.
|
|
670
|
+
*/
|
|
671
|
+
beginPoke(): void;
|
|
672
|
+
/**
|
|
673
|
+
* Closes the open Poke.
|
|
674
|
+
* @returns True if it recorded one history entry, false if nothing changed - or if undo is
|
|
675
|
+
* disabled or its size is 0, in which case the writes stand but cannot be undone.
|
|
676
|
+
* Throws if no Poke is open.
|
|
677
|
+
*/
|
|
678
|
+
endPoke(): boolean;
|
|
679
|
+
/** Whether a Poke is open, so that the setters journal rather than writing straight through. */
|
|
680
|
+
pokeOpen(): boolean;
|
|
564
681
|
/**
|
|
565
682
|
* Reads a sequence of bytes from memory.
|
|
566
683
|
*
|
|
@@ -574,9 +691,13 @@ interface JsRiscV {
|
|
|
574
691
|
/**
|
|
575
692
|
* Writes a sequence of bytes to memory.
|
|
576
693
|
*
|
|
577
|
-
* Unlike `readMemoryBytes`, this writes the way the program does
|
|
578
|
-
* and
|
|
579
|
-
*
|
|
694
|
+
* Unlike `readMemoryBytes`, this writes the way the program does, so write observers are
|
|
695
|
+
* notified and a memory mapped display repaints. It records no undo step of its own: a host
|
|
696
|
+
* write is not an instruction, and recording it would make the next `undo()` revert it together
|
|
697
|
+
* with the instruction that ran before it. Inside a Poke the same write joins the open
|
|
698
|
+
* transaction instead, and a byte already holding the value written is skipped entirely.
|
|
699
|
+
*
|
|
700
|
+
* Use `setPeripheralWord` for a device keeping its own register up to date.
|
|
580
701
|
* @param address The starting memory address.
|
|
581
702
|
* @param bytes An array of bytes to write to memory.
|
|
582
703
|
*/
|
|
@@ -636,7 +757,9 @@ interface JsRiscV {
|
|
|
636
757
|
*/
|
|
637
758
|
getNextStatement(): JsProgramStatement;
|
|
638
759
|
/**
|
|
639
|
-
* Sets the value of a register.
|
|
760
|
+
* Sets the value of a register. Outside a Poke the write is direct: it records no undo step.
|
|
761
|
+
* Inside a Poke it joins the open transaction, except for `zero`, which holds no value and so
|
|
762
|
+
* is left alone.
|
|
640
763
|
* @param register The name of the register.
|
|
641
764
|
* @param value The value to set the register to.
|
|
642
765
|
*/
|
|
@@ -669,4 +792,4 @@ declare function bigintToHighLow(value: bigint): [high: number, low: number];
|
|
|
669
792
|
*/
|
|
670
793
|
declare function highLowToBigint(high: number, low: number): bigint;
|
|
671
794
|
|
|
672
|
-
export { BackStepAction, ConfirmResult, type CsrRegisterName, DialogType, type FloatingPointRegisterName, type HandlerMap, type HandlerMapFns, type JsBackStep, type JsInstruction, type JsInstructionToken, type JsProgramStatement, type JsRiscV, type JsRiscVStackFrame, type MemoryAccessObserver, type MemoryObserverHandle, type MemoryWriteObserver, RISCV, type RISCVAssembleError, type RISCVAssembleResult, RISCVRegisters, type RISCVSourceLocation, type RISCVSourceSet, RISCV_CSR_REGISTERS, RISCV_FLOATING_POINT_REGISTERS, RISCV_REGISTERS, type RegisterName, type RiscvTokenizedLine, StopReason, bigintToHighLow, highLowToBigint, makeRiscVFromFiles, registerHandlers, unimplementedHandler };
|
|
795
|
+
export { BackStepAction, ConfirmResult, type CsrRegisterName, DialogType, type FloatingPointRegisterName, type HandlerMap, type HandlerMapFns, type JsBackStep, type JsInstruction, type JsInstructionToken, type JsInstructionUndoGroup, type JsPokeMemoryWrite, type JsPokeRegisterWrite, type JsPokeUndoGroup, type JsPokeWrite, type JsProgramStatement, type JsRiscV, type JsRiscVStackFrame, type JsUndoGroup, type MemoryAccessObserver, type MemoryObserverHandle, type MemoryWriteObserver, RISCV, type RISCVAssembleError, type RISCVAssembleResult, RISCVRegisters, type RISCVSourceLocation, type RISCVSourceSet, RISCV_CSR_REGISTERS, RISCV_FLOATING_POINT_REGISTERS, RISCV_REGISTERS, type RegisterName, type RiscvTokenizedLine, StopReason, bigintToHighLow, highLowToBigint, makeRiscVFromFiles, registerHandlers, unimplementedHandler };
|
package/dist/index.d.ts
CHANGED
|
@@ -291,7 +291,18 @@ declare enum BackStepAction {
|
|
|
291
291
|
* Members mirror the core's `BackStepper.Action` by position, because the core reports an
|
|
292
292
|
* action as that enum's ordinal. Append here; never insert.
|
|
293
293
|
*/
|
|
294
|
-
CONTROL_AND_STATUS_COUNTERS_DECREMENT = 11
|
|
294
|
+
CONTROL_AND_STATUS_COUNTERS_DECREMENT = 11,
|
|
295
|
+
/**
|
|
296
|
+
* Restores one control and status register the way the host's setter wrote it, through the
|
|
297
|
+
* register's own value: a linked register writes the register it aliases, a read only counter
|
|
298
|
+
* is written anyway. Only a Poke records this, and only inside its own entry.
|
|
299
|
+
*/
|
|
300
|
+
CONTROL_AND_STATUS_REGISTER_POKE_RESTORE = 12,
|
|
301
|
+
/**
|
|
302
|
+
* A whole Poke: every value one `beginPoke`/`endPoke` transaction wrote, restored together.
|
|
303
|
+
* A Poke is a single back step, so it takes one slot of the undo size whatever it wrote.
|
|
304
|
+
*/
|
|
305
|
+
POKE = 13
|
|
295
306
|
}
|
|
296
307
|
/**
|
|
297
308
|
* Represents a back step in the simulation undo stack.
|
|
@@ -310,10 +321,82 @@ interface JsBackStep {
|
|
|
310
321
|
*/
|
|
311
322
|
readonly param2: number;
|
|
312
323
|
/**
|
|
313
|
-
* The program counter value before the action
|
|
324
|
+
* The program counter value before the action, or -1 for an action that belongs to no
|
|
325
|
+
* instruction: a Poke, or a host write made before anything ran.
|
|
314
326
|
*/
|
|
315
327
|
readonly pc: number;
|
|
328
|
+
/**
|
|
329
|
+
* Whether this step is a whole Poke rather than one effect of an instruction. It is the
|
|
330
|
+
* discriminator this list needs, since a Poke and a pre-run host write both carry `pc` -1.
|
|
331
|
+
*/
|
|
332
|
+
readonly isPoke: boolean;
|
|
316
333
|
}
|
|
334
|
+
/**
|
|
335
|
+
* One value a Poke changed: a register, named the way this package's getters spell it, or a run of
|
|
336
|
+
* consecutive memory bytes. `old` is what the simulator held when the write happened and `new` what
|
|
337
|
+
* it held when the Poke was closed, so a value written twice inside one Poke reports its final
|
|
338
|
+
* state.
|
|
339
|
+
*/
|
|
340
|
+
type JsPokeWrite = JsPokeRegisterWrite | JsPokeMemoryWrite;
|
|
341
|
+
/**
|
|
342
|
+
* A register a Poke wrote. `name` is the register's own name, as this package spells it: a key of
|
|
343
|
+
* `RISCVRegisters` (`t0`), an entry of `RISCV_FLOATING_POINT_REGISTERS` (`ft0`) or one of
|
|
344
|
+
* `RISCV_CSR_REGISTERS` (`fcsr`) - the file it belongs to is the file that name is in.
|
|
345
|
+
*
|
|
346
|
+
* Every register here is 64 bits wide, which no JS number holds, so both values are **signed
|
|
347
|
+
* decimal strings**, the shape `getRegisterValueLong` and `getRegistersValuesLong` already use:
|
|
348
|
+
* read them with `BigInt(write.old)`, and with `BigInt.asUintN(64, BigInt(write.old))` for the
|
|
349
|
+
* unsigned form that `highLowToBigint` returns for the same register.
|
|
350
|
+
*/
|
|
351
|
+
type JsPokeRegisterWrite = {
|
|
352
|
+
readonly type: 'register';
|
|
353
|
+
readonly name: string;
|
|
354
|
+
readonly old: string;
|
|
355
|
+
readonly new: string;
|
|
356
|
+
};
|
|
357
|
+
/**
|
|
358
|
+
* A run of consecutive memory bytes a Poke wrote, `address` being the first one, unsigned, and the
|
|
359
|
+
* two arrays holding one byte (0 to 255) per address. A Poke that writes addresses that are not
|
|
360
|
+
* adjacent reports one of these per run, by ascending address. Unlike `readMemoryBytes`, these are
|
|
361
|
+
* ordinary JS arrays.
|
|
362
|
+
*/
|
|
363
|
+
type JsPokeMemoryWrite = {
|
|
364
|
+
readonly type: 'memory';
|
|
365
|
+
readonly address: number;
|
|
366
|
+
readonly old: number[];
|
|
367
|
+
readonly new: number[];
|
|
368
|
+
};
|
|
369
|
+
/**
|
|
370
|
+
* One entry of the undo history: everything a single `undo()` reverts, which is either one executed
|
|
371
|
+
* instruction or one Poke. Entries, their back steps and their writes are ordinary objects with own
|
|
372
|
+
* properties, so a whole history can be cloned, serialized or deep-compared as it comes.
|
|
373
|
+
*/
|
|
374
|
+
type JsUndoGroup = JsInstructionUndoGroup | JsPokeUndoGroup;
|
|
375
|
+
/**
|
|
376
|
+
* One executed instruction, at the address `pc`, with every back step it recorded: the values it
|
|
377
|
+
* overwrote, and the `cycle`/`instret` decrement every instruction pushes on top of them.
|
|
378
|
+
*/
|
|
379
|
+
type JsInstructionUndoGroup = {
|
|
380
|
+
readonly kind: 'instruction';
|
|
381
|
+
readonly pc: number;
|
|
382
|
+
/** The instruction's back steps, newest first. */
|
|
383
|
+
readonly steps: JsBackStep[];
|
|
384
|
+
/** Always empty: only a Poke reports writes. */
|
|
385
|
+
readonly writes: readonly [];
|
|
386
|
+
};
|
|
387
|
+
/**
|
|
388
|
+
* One Poke: register or memory values written by the host between two instructions, recorded as a
|
|
389
|
+
* step of its own. It belongs to no instruction, so `pc` is -1 and undoing it restores exactly what
|
|
390
|
+
* `writes` lists, leaving the program counter, the counters, the call stack and everything else
|
|
391
|
+
* alone.
|
|
392
|
+
*/
|
|
393
|
+
type JsPokeUndoGroup = {
|
|
394
|
+
readonly kind: 'poke';
|
|
395
|
+
readonly pc: -1;
|
|
396
|
+
/** The single back step the Poke is: one slot of the history, whatever the Poke wrote. */
|
|
397
|
+
readonly steps: [JsBackStep];
|
|
398
|
+
readonly writes: JsPokeWrite[];
|
|
399
|
+
};
|
|
317
400
|
declare enum RISCVRegisters {
|
|
318
401
|
zero = 0,
|
|
319
402
|
ra = 1,
|
|
@@ -406,7 +489,8 @@ interface JsRiscV {
|
|
|
406
489
|
*/
|
|
407
490
|
setUndoSize(size: number): void;
|
|
408
491
|
/**
|
|
409
|
-
* Undoes the last instruction executed
|
|
492
|
+
* Undoes the newest entry of the history: the last instruction executed, or the last Poke made,
|
|
493
|
+
* whichever is on top. Undoing a Poke restores every value it wrote and touches nothing else.
|
|
410
494
|
*/
|
|
411
495
|
undo(): void;
|
|
412
496
|
/**
|
|
@@ -532,10 +616,10 @@ interface JsRiscV {
|
|
|
532
616
|
*/
|
|
533
617
|
getFloatingPointRegistersValues(): Int32Array;
|
|
534
618
|
/**
|
|
535
|
-
* Sets one floating point register
|
|
536
|
-
* presetting a register from the host is not something the program did.
|
|
537
|
-
*
|
|
538
|
-
* what you mean.
|
|
619
|
+
* Sets one floating point register. Outside a Poke the write is direct: no undo entry is
|
|
620
|
+
* recorded, because presetting a register from the host is not something the program did.
|
|
621
|
+
* Inside a Poke it joins the open transaction. Split the value with `bigintToHighLow`, and
|
|
622
|
+
* NaN-box a single yourself (`0xFFFFFFFFn << 32n | bits`) if that is what you mean.
|
|
539
623
|
* @param index Position in `RISCV_FLOATING_POINT_REGISTERS`. Must be a whole number from 0 to
|
|
540
624
|
* 31; anything else throws.
|
|
541
625
|
*/
|
|
@@ -549,18 +633,51 @@ interface JsRiscV {
|
|
|
549
633
|
*/
|
|
550
634
|
getControlAndStatusRegistersValues(): Int32Array;
|
|
551
635
|
/**
|
|
552
|
-
* Sets one control and status register
|
|
553
|
-
* Writing `fflags` or `frm` updates `fcsr`,
|
|
554
|
-
* here even though the program cannot write
|
|
636
|
+
* Sets one control and status register. Outside a Poke the write is direct and records no undo
|
|
637
|
+
* entry; inside a Poke it joins the open transaction. Writing `fflags` or `frm` updates `fcsr`,
|
|
638
|
+
* and writing a counter such as `cycle` is allowed here even though the program cannot write
|
|
639
|
+
* it - so a counter is pokeable, and undoing that Poke puts the counter back.
|
|
555
640
|
* @param index Position in `RISCV_CSR_REGISTERS`. Must be a whole number from 0 to 16;
|
|
556
641
|
* anything else throws.
|
|
557
642
|
*/
|
|
558
643
|
setControlAndStatusRegisterValue(index: number, high: number, low: number): void;
|
|
559
644
|
/**
|
|
560
|
-
* Gets the undo stack.
|
|
645
|
+
* Gets the undo stack, one element per back step, newest first. An instruction usually occupies
|
|
646
|
+
* several of them - it records the values it overwrote and the counter decrement - while a Poke
|
|
647
|
+
* is exactly one, the element with `isPoke` set, whatever it wrote. Use `getUndoGroups` to read
|
|
648
|
+
* the history the way `undo()` pops it, one entry per instruction or Poke.
|
|
561
649
|
* @returns An array of `JsBackStep` objects representing the history of the simulation.
|
|
562
650
|
*/
|
|
563
651
|
getUndoStack(): JsBackStep[];
|
|
652
|
+
/**
|
|
653
|
+
* Gets the undo history grouped the way `undo()` pops it: one entry per executed instruction or
|
|
654
|
+
* per Poke, newest first, each carrying the back steps it is made of. A Poke entry also carries
|
|
655
|
+
* what it changed, with the old and the new value of each write.
|
|
656
|
+
*/
|
|
657
|
+
getUndoGroups(): JsUndoGroup[];
|
|
658
|
+
/**
|
|
659
|
+
* Opens a Poke: a register or memory value changed by the host between two instructions,
|
|
660
|
+
* recorded in this history as a step of its own.
|
|
661
|
+
*
|
|
662
|
+
* Until `endPoke` the setters - `setRegisterValue`, `setFloatingPointRegisterValue`,
|
|
663
|
+
* `setControlAndStatusRegisterValue` and `setMemoryBytes` - journal what they write into the
|
|
664
|
+
* open transaction, however many of them are called, and `endPoke` records the lot as one
|
|
665
|
+
* history entry that one `undo()` reverts and that takes one slot of the undo size, whether it
|
|
666
|
+
* wrote one byte or a hundred. Outside a transaction the same setters stay direct and record
|
|
667
|
+
* nothing, which is what presetting state needs.
|
|
668
|
+
*
|
|
669
|
+
* Throws if a Poke is already open, or if a `step`/`simulate*` call is still in flight.
|
|
670
|
+
*/
|
|
671
|
+
beginPoke(): void;
|
|
672
|
+
/**
|
|
673
|
+
* Closes the open Poke.
|
|
674
|
+
* @returns True if it recorded one history entry, false if nothing changed - or if undo is
|
|
675
|
+
* disabled or its size is 0, in which case the writes stand but cannot be undone.
|
|
676
|
+
* Throws if no Poke is open.
|
|
677
|
+
*/
|
|
678
|
+
endPoke(): boolean;
|
|
679
|
+
/** Whether a Poke is open, so that the setters journal rather than writing straight through. */
|
|
680
|
+
pokeOpen(): boolean;
|
|
564
681
|
/**
|
|
565
682
|
* Reads a sequence of bytes from memory.
|
|
566
683
|
*
|
|
@@ -574,9 +691,13 @@ interface JsRiscV {
|
|
|
574
691
|
/**
|
|
575
692
|
* Writes a sequence of bytes to memory.
|
|
576
693
|
*
|
|
577
|
-
* Unlike `readMemoryBytes`, this writes the way the program does
|
|
578
|
-
* and
|
|
579
|
-
*
|
|
694
|
+
* Unlike `readMemoryBytes`, this writes the way the program does, so write observers are
|
|
695
|
+
* notified and a memory mapped display repaints. It records no undo step of its own: a host
|
|
696
|
+
* write is not an instruction, and recording it would make the next `undo()` revert it together
|
|
697
|
+
* with the instruction that ran before it. Inside a Poke the same write joins the open
|
|
698
|
+
* transaction instead, and a byte already holding the value written is skipped entirely.
|
|
699
|
+
*
|
|
700
|
+
* Use `setPeripheralWord` for a device keeping its own register up to date.
|
|
580
701
|
* @param address The starting memory address.
|
|
581
702
|
* @param bytes An array of bytes to write to memory.
|
|
582
703
|
*/
|
|
@@ -636,7 +757,9 @@ interface JsRiscV {
|
|
|
636
757
|
*/
|
|
637
758
|
getNextStatement(): JsProgramStatement;
|
|
638
759
|
/**
|
|
639
|
-
* Sets the value of a register.
|
|
760
|
+
* Sets the value of a register. Outside a Poke the write is direct: it records no undo step.
|
|
761
|
+
* Inside a Poke it joins the open transaction, except for `zero`, which holds no value and so
|
|
762
|
+
* is left alone.
|
|
640
763
|
* @param register The name of the register.
|
|
641
764
|
* @param value The value to set the register to.
|
|
642
765
|
*/
|
|
@@ -669,4 +792,4 @@ declare function bigintToHighLow(value: bigint): [high: number, low: number];
|
|
|
669
792
|
*/
|
|
670
793
|
declare function highLowToBigint(high: number, low: number): bigint;
|
|
671
794
|
|
|
672
|
-
export { BackStepAction, ConfirmResult, type CsrRegisterName, DialogType, type FloatingPointRegisterName, type HandlerMap, type HandlerMapFns, type JsBackStep, type JsInstruction, type JsInstructionToken, type JsProgramStatement, type JsRiscV, type JsRiscVStackFrame, type MemoryAccessObserver, type MemoryObserverHandle, type MemoryWriteObserver, RISCV, type RISCVAssembleError, type RISCVAssembleResult, RISCVRegisters, type RISCVSourceLocation, type RISCVSourceSet, RISCV_CSR_REGISTERS, RISCV_FLOATING_POINT_REGISTERS, RISCV_REGISTERS, type RegisterName, type RiscvTokenizedLine, StopReason, bigintToHighLow, highLowToBigint, makeRiscVFromFiles, registerHandlers, unimplementedHandler };
|
|
795
|
+
export { BackStepAction, ConfirmResult, type CsrRegisterName, DialogType, type FloatingPointRegisterName, type HandlerMap, type HandlerMapFns, type JsBackStep, type JsInstruction, type JsInstructionToken, type JsInstructionUndoGroup, type JsPokeMemoryWrite, type JsPokeRegisterWrite, type JsPokeUndoGroup, type JsPokeWrite, type JsProgramStatement, type JsRiscV, type JsRiscVStackFrame, type JsUndoGroup, type MemoryAccessObserver, type MemoryObserverHandle, type MemoryWriteObserver, RISCV, type RISCVAssembleError, type RISCVAssembleResult, RISCVRegisters, type RISCVSourceLocation, type RISCVSourceSet, RISCV_CSR_REGISTERS, RISCV_FLOATING_POINT_REGISTERS, RISCV_REGISTERS, type RegisterName, type RiscvTokenizedLine, StopReason, bigintToHighLow, highLowToBigint, makeRiscVFromFiles, registerHandlers, unimplementedHandler };
|