Last active
September 11, 2017 07:48
-
-
Save rpbeltran/23f78fe865ac95d1e7a0c02f7ee9b2c5 to your computer and use it in GitHub Desktop.
A build system for testing HDL files for the NAND2TETRIS Hardware Simulator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Build System for Nand2Tetris HDL Test Files | |
{ | |
// This says what command to run by default ( should work for OSX and linux ) | |
"cmd": ["../tools/HardwareSimulator.sh", "$file"], | |
"windows": { | |
// This says what command to run if you use windows | |
"cmd": ["../tools/HardwareSimulator", "$file"] | |
}, | |
// Remove or comment this line to disable use with Build System "Automatic" | |
"selector": "source.tst", | |
// Sets the working path to that of the current file | |
"working_dir": "${file_path:${folder}}", | |
// Not strictly necessary, just being explicit | |
"encoding": "utf-8" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage Guide
Follow this guide to set up building for Sublime Text 2 or 3. If you encounter any difficulty setting this up, drop a comment here and I'll try to fix it. Currently only tested on OSX, but pretty confident about support for Linux and Windows.
Expected File Structure and Nand2Tertris Tools
First, the build system assumes that your files for NAND2TETRIS projects are all in a common directory along with the tools provided by Nand2Tetris, which has the following structure:
I can add support for modifying this file structure by setting a custom path for the build script, or for using tools added to the system path if this really bothers anybody, or you can just modify the proper
"cmd"
line in the build system for your OS if you feel comfortable doing this yourself.Adding a new Build System to Sublime Text
To add the build system to Sublime Text either download the file and move it to your local Sublime Packages folder, or if you don't know where that is, just follow these steps:
Tools > Build System > New Build System
and a new file should open. (Note: It is possible that this is located somewhere slightly different on Windows and/or Linux? I'm not sure.).sublime-build
.Now look in the list of build systems under
Tools > Build System
and see if it's there. If not, you may have to restart Sublime Text once before it appears.Usage
This build system will run tst files and show you the output. While viewing a tst file, you may run the build by following these steps:
Tools > Build System > Nand2Tetris_Hardware_tst
to set the current build systemTools > Build
or use the shortcutCommand + b
( I think it isctrl + b
for windows)Reading the Output
The output messages are exactly what you would see if you run the Hardware Simulator through terminal or cmd (which is really all we are doing).
A build of a successful circuit should output something like:
A build of a circuit which did not pass all tests should a=output something like:
Note: The given line number in this case corresponds to the first entry in the provided cmp file which did not pass
A build of a test script which is syntactically malformed
Note: line number corresponds to line number in your tst file, and the message which follows should sum up the problem