3 ms·
Open for contribution, its very simple code, and adding some testing logic would really help! I'm happy to guide and work with anyone on how to do this :) A re
by purple-leafy 2y ago
Open for contribution, its very simple code, and adding some testing logic would really help! I'm happy to guide and work with anyone on how to do this :)
A really simple way to start contributing would be to write some truth table tests for the nand_gate, then the other gates too.
EG: For the NAND gate, it would be as simple as the following (pseudocode):
/* TRUTH TABLE
* | a | b | out |
* ---------------
* | 0 | 0 | 1 |
* | 0 | 1 | 1 |
* | 1 | 0 | 1 |
* | 1 | 1 | 0 |
*/
// Define gate
Nand nand_instance;
// Set inputs to either 0 or 1
nand_instance.input.a = 0;
nand_instance.input.b = 0;
// Process logic
nand_gate(&nand_instance);
// Check output is correct
if (nand_instance.output.out == 1)
{
// PASSED
}
else
{
// FAILED
}
Oh and for anyone who looks at this sort of low level project (hardware etc) and feels its outside their ability, its not!
I say this because thats how I have always felt seeing such projects.
Its actually very, very simple code to understand and start yourself, and working through the NandToTetris course, you could probably do better than my code within a few days.
You could write such an emulator in any programming language