Coder Social home page Coder Social logo

0xakihiko / n2t-ide Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nand2tetris/web-ide

0.0 0.0 0.0 3.03 MB

Fork of the web-based IDE for https://nand2tetris.org

Home Page: https://0xakihiko.github.io/n2t-ide

License: Other

Shell 0.04% JavaScript 0.65% Assembly 11.79% Scilab 0.04% TypeScript 73.33% CSS 2.15% Hack 8.04% HTML 2.86% SCSS 1.10%

n2t-ide's Introduction

Nand2Tetris Software Suite

A Javascript reimplementation of the software suite described in www.nand2tetris.org and in "The Elements of Computing Systems" by Nisan and Schocken, MIT Press (2nd edition, 2021). The repo also includes the project files described in the website and in the book.

Presently the implementation focuses on the Hardware Simulator (projects 1, 2, 3, 5). The CPU and the VM Emulators will be next. The goal is to allow students complete the projects using modern, web-based tools, without having to download code to their computers.

Users can work with the tools via a web IDE, or via a VS Code extension. Both are described below.

User Guide

The user guide for the web IDE is available here and can also be accessed by clicking "Guide" at the top right of the published project.

The user guide for the extension is coming.

The parts of the user guide that describe the UI may be out of sync with the code since we keep experimenting with differtent UI's.

CLI

Install the CLI tool:

npm run build && npm i -g cli

Run the CLI:

cd nand2tetris/project/01
nand2tetris grade
nand2tetris run DMux4Way.tst

Run the CLI with a nand2tetris Java install:

cd nand2tetris/project/01
nand2tetris grade --java_ide=${HOME}/nand2tetris

Architecture

NAND2Tetris kit is a monorepo with several projects. simulator is the core NAND2Tetris code. projects has copies of project base and test files. runner is a utility to execute chips against a Java ide install, looking for nand2tetris.jar in $NAND2TETRIS_PATH. components are reusable React UI pieces suitable for both web and extension. web is a standalone web IDE. extension is a VSCode extension with editor support. cli is a command line NodeJS program (runnable with npx) to grade one or more project folders.

Simulator

Simulator has code to handle running the various emulators, regardless of interface or runtime. Simulator objects are also independant of language, and serve equally well to running tests as to binding to the DOM or printing to a CLI. chip, cpu, and vm cover the primary hack languages, with compare, output, and tst handling the common project tooling.

Languages

Languages are parsed using Ohm, a parser combinator library. Ohm works well for simple cases, but does not handle error recovery well. Replacing or augmenting this to handle a number of errors, rather than only the first, w

Web

NAND2Tetris Web IDE is a stand-alone single-page app with separate sections for Hack Hardware, CPU, and VM emulators. It has a unified file system using browser local storage to save users' solutions to project work. Emulators share simulator code, especially to handle executing tests as well as converting between Javascript 64-bit floating point numbers and Hack 16-bit integers.

The interface code is in the pages and components folders. Generally, a page creates a simulator at the top, some dynamic components in the middle, and a layout of HTML at the bottom. Pages should use semantic blocks as much as possible, with special attention on using <article> as a "Card".

React

The user interface is written in react, using functional components and vanilla hooks as much as possible. Pages are routable things, usually with a store connecting it to the appropriate simulation. Components are reusable pieces of UI, which take props to update their interface.

RXJS

Asynchronous one-off behavior in the project can be handled with promises & async/await syntax. For evented asynchronous behavior, use RXJS observables and subscriptions.

Pico

Jiffies extends PicoCSS, allowing rapid iteration on custom components. Some ideas have been moved upstream to Pico. Specific components in the forked Pico include inline-buttons and a property sheet.

Extension

A VSCode extension with language definitions and editor support.

  • npm run -w extension package builds the extension & related views into a stand-along .vsix file.
  • Run Extension launch configuration starts a new VSCode extension host to debug the extension.

Languages

Language support for .hdl & .tst uses the language libraries in simulator. Syntax errors are highlighted, with in-editor error diagnostics on the failing token. Syntax highlighting rules activate for HDL, TST, CMP, OUT, ASM, VM, and Jack files. Snippets are available for HDL, ASM, VM, Jack, and TST files.

Views

The extension adds an activity bar container, NAND2Tetris. NAND2TETRIS: HDL CHIP opens in the container, and shows a chip panel when the user has opened an HDL file. The panel attempts to update whenever changing HDL files, or when saving the file. It does not update if the new HDL does not parse.

Jiffies

Jiffies contains a few utility functions & types.

  • Result and Option encapsulate "Ok/Err" and "Some/None" variant types.
  • assert, assertExists, and checkExhaustive provide strongly-typed, portable assertions.
  • fs, a thin wrapper around LocalStorage and similar Record<string, string> objects allowing Filesystem like access.

Code of Conduct

This project is governed by its Code of Conduct.

n2t-ide's People

Contributors

davidsouther avatar netalondon avatar 0xakihiko avatar avivyaish avatar shimon-schocken avatar antoinepiret avatar w0zro avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.