Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wokwi/hdl-parser
Parser for nand2tetris HDL (Hardware Description Language), written in JavaScript
https://github.com/wokwi/hdl-parser
hdl nand2tetris parser peggy
Last synced: about 1 month ago
JSON representation
Parser for nand2tetris HDL (Hardware Description Language), written in JavaScript
- Host: GitHub
- URL: https://github.com/wokwi/hdl-parser
- Owner: wokwi
- License: mit
- Created: 2021-09-27T19:16:04.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-03-09T11:56:52.000Z (almost 3 years ago)
- Last Synced: 2024-10-23T12:06:01.393Z (2 months ago)
- Topics: hdl, nand2tetris, parser, peggy
- Language: JavaScript
- Homepage:
- Size: 22.5 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hdl-parser
Parser for [nand2tetris](https://www.nand2tetris.org/) HDL (Hardware Description Language), built on top of [Peggy](https://peggyjs.org/).
[![Build Status](https://travis-ci.org/wokwi/hdl-parser.png?branch=master)](https://travis-ci.org/wokwi/hdl-parser)
[![NPM Version](https://img.shields.io/npm/v/hdl-parser)](https://www.npmjs.com/package/hdl-parser)
![License: MIT](https://img.shields.io/npm/l/hdl-parser)
![Types: TypeScript](https://img.shields.io/npm/types/hdl-parser)## Usage example
```javascript
const { parse } = require('hdl-parser');console.log(parse(`
CHIP Not {
IN in;
OUT out;PARTS:
Nand(a=in, b=true, out=out);
}
`));
```And the result:
```js
({
name: 'Not',
definitions: [
{ type: 'IN', pins: [{ name: 'in', bits: 1 }] },
{ type: 'OUT', pins: [{ name: 'out', bits: 1 }] },
],
parts: [
{
name: 'Nand',
connections: [
{ from: { pin: 'a', bits: null }, to: { pin: 'in', bits: null } },
{ from: { pin: 'b', bits: null }, to: { const: 'true' } },
{ from: { pin: 'out', bits: null }, to: { pin: 'out', bits: null } },
],
},
],
})
```For more examples, see the [tests file](tests.js).
## License
Released under the terms of [the MIT licence](LICENSE). Copyright (c) 2021, Uri Shaked.