DmitrySoshnikov / hdl-js

Hardware description language (HDL) parser, and Hardware simulator.
MIT License
84 stars 11 forks source link

[Emulator] Support scripting for gates testing #30

Closed DmitrySoshnikov closed 6 years ago

DmitrySoshnikov commented 6 years ago

The --exec-on-data already allows accepting testing data, and validating the outputs. In addition we can provide an ability to do scripted testing of the pins, and manually call some events (like tick, tock, etc) in the scripts. This can be compatible with the nand2tetris script testing.

TODO:

Example testing And:

load And.hdl,
output-file And.out,
compare-to And.cmp,
output-list a%B3.1.3 b%B3.1.3 out%B3.1.3;

set a 0,
set b 0,
eval,
output;

set a 0,
set b 1,
eval,
output;

set a 1,
set b 0,
eval,
output;

set a 1,
set b 1,
eval,
output;

Output:

|   a   |   b   |  out  |
|   0   |   0   |   0   |
|   0   |   1   |   0   |
|   1   |   0   |   0   |
|   1   |   1   |   1   |
DmitrySoshnikov commented 6 years ago

Script parser support is added in https://github.com/DmitrySoshnikov/hdl-js/commit/858e6f451d80c0f4ade96e51f8ade3faca2b5f98.

DmitrySoshnikov commented 6 years ago

Base script interpreter is added in https://github.com/DmitrySoshnikov/hdl-js/commit/6b86a4541131966936e7f50de86808d3aa9f8896.

DmitrySoshnikov commented 6 years ago

CLI support is added in https://github.com/DmitrySoshnikov/hdl-js/commit/c4d174e490c01b549c60670d0b7c016c12d61f65.