From baaa268a2f813e8ffb9fdff1256d7c37bb21743a Mon Sep 17 00:00:00 2001 From: Goblin Oats Date: Mon, 18 Sep 2023 11:55:47 +0100 Subject: [PATCH] docs: update how to write an instruction to include trace info --- notes/how_to_write_an_instruction.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/notes/how_to_write_an_instruction.md b/notes/how_to_write_an_instruction.md index 0202052..25bff2d 100644 --- a/notes/how_to_write_an_instruction.md +++ b/notes/how_to_write_an_instruction.md @@ -54,4 +54,23 @@ Continuing on this example, let's take a look at the `inx` function in the `inst Once we have constrained all the reads and writes we will need to generate the intermediary permutation product and return it which is used to verify correct execution along the recursion tree. All files will need this and it should be present in the stubbed code. -That's all there is to it! \ No newline at end of file +That's all there is to it! + +## How to generate emulator trace for your instruction and use it for test cases + +For example INSTR could be INX, ADC, etc. +``` +cd emulator +cargo run --release test_roms/cpu/nestest.nes --trace --instr_name +``` + +--trace is a flag to turn on the trace feature in the emulator
+--instr_name will filter a small subset of the instructions + +When the emulator opens, hit enter to run all the tests and then hit CTRL + Q. The emulator will close and you will see a ```trace.json``` file output into the ```emulator/``` directory. This is a human readable format of the trace. + +It's possible to generate tests for your INSTR from this trace by doing the following: + +``` +node ./circuits/scripts/convert_emulator_trace.js ./emulator/trace.json +``` \ No newline at end of file