Catalog npm
Back to packageRELEASE DETAILS

1.0.3

npm

16ttac-sim

16 Bit Transport Triggered Architecture CPU Simulator

Published2 Jan 2023
Direct dependencies12
Transitive dependenciesNot calculated

README

Current package documentation

16TTAC-sim

A compiler and simulator written in TypeScript for an imaginary 16bit Transport Triggered Architecture CPU.

The CPU

  • Uses the TTA architecture
  • Up to 128 sources and destinations each
  • Accumulator and Address registers
  • 16-bit fixed width instruction, with optional 16-bit operand
  • 64 kiloword, or 128KB RAM size
  • 256-word stack
  • Conditional execution using Carry and Zero flags
  • Halting support
  • Built-in IO support

Instruction structure:

  • bits 15-9 - source
  • bits 8-2 - destination
  • bit 1 - if set, instruction is only executed if the carry flag is set
  • bit 0 - if set, instruction is only executed if the zero flag is set

Sources and destinations:

All sources and destinations are completely customizable, but you can look here to see the descriptions of all of them that are available by default.

The assembly language

Here is a small code snippet that should explain the whole syntax:

//Comments are single line

//Some example variable declarations:
word var = 123
word var2 = 0x5
word string[10] = "hello"
word string2[10] = [09,98,'c']
word MUL_ARR[10][2] = [[0,1], [2,3], "a"]

//Some example instructions:
SOURCE => DESTINATION
SOURCE => DESTINATION c //Executes only if the carry flag is set
SOURCE => DESTINATION z //Executes only if the zero flag is set
SOURCE => DESTINATION c z //Executes only if the carry and the zero flag are set

//Source can also be a constant value, provided by the operand
123 => DESTINATION
0xFFFF => DESTINATION
'a' => DESTINATION

//Source can also be a reference to a variable
string => ADR
var2 => ADR

//Labels:
label:
123 => ACC
another_label:
string => PUSH

The Toolchain

The toolchain is written in TypeScript, it is made to work both in web and node. It also works as a standalone tool that you can use with npx.

Using 16TTAC-sim as an npx tool

$ npx 16ttac-sim -h
$ npx 16ttac-sim examples/numbers.txt

Using 16TTAC-sim as a library

$ npm i 16ttac-sim

//Include the required files...

const parser = new Parser();
const compiler = new Compiler();
const program = new Command();

let simRunning = true;
const sim = new Sim({
  haltCallback: () => {
    console.log("\n\nHalting");
    simRunning = false;
  }
});

sim.initializeMemory(compiler.compile(parser.parse(sourceCode)));

while(simRunning) sim.singleStep();

For more complicated examples with IO, look at cli.ts and sim.test.ts.

Adding your own instructions

The main advantage of Transport Triggered Architecture is the ease of adding custom instructions, to do so you can extend the defaultInstructionDictionary or you can create your own dictionary.

Important:

A dictionary needs one source with isOperand set for the toolchain to work correctly.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 12

Native requirements
12 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
ohm-js
Environment
{
  "local_name": "ohm-js",
  "alias": false,
  "peer_metadata": null
}
^16.4.0runtime
commander
Environment
{
  "local_name": "commander",
  "alias": false,
  "peer_metadata": null
}
^9.4.1runtime
jest
Environment
{
  "local_name": "jest",
  "alias": false,
  "peer_metadata": null
}
^29.3.1development
husky
Environment
{
  "local_name": "husky",
  "alias": false,
  "peer_metadata": null
}
^8.0.2development
nodemon
Environment
{
  "local_name": "nodemon",
  "alias": false,
  "peer_metadata": null
}
^2.0.20development
ts-jest
Environment
{
  "local_name": "ts-jest",
  "alias": false,
  "peer_metadata": null
}
^29.0.3development
ts-node
Environment
{
  "local_name": "ts-node",
  "alias": false,
  "peer_metadata": null
}
^10.9.1development
prettier
Environment
{
  "local_name": "prettier",
  "alias": false,
  "peer_metadata": null
}
2.8.1development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^4.9.3development
@types/jest
Environment
{
  "local_name": "@types/jest",
  "alias": false,
  "peer_metadata": null
}
^29.2.4development
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
^18.11.11development
lint-staged
Environment
{
  "local_name": "lint-staged",
  "alias": false,
  "peer_metadata": null
}
^13.1.0development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "4544bb09cda6e5d2deb1e4101a80cd9cb4eca52d",
  "tarball": "https://registry.npmjs.org/16ttac-sim/-/16ttac-sim-1.0.3.tgz",
  "fileCount": 19,
  "integrity": "sha512-MTXRd9OdN2MBXujV9WXMQMbNwmqJ3vbjMq5ZEwG/QvPqkaRwS1K1NQcIdn1jnSSmNGeKoAJ9vWwbZu62k5nOqw==",
  "signatures": [
    {
      "sig": "MEYCIQDh87eS+RmP7noXbGYTB1JBPZ/9h1bC2bnRzIUdxUTHQQIhAJmZoR8p9DqWiAHnSBcN99PiDAY0GmGplDdpo4IPkGok",
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
    }
  ],
  "unpackedSize": 30449,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjswD1ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr7MQ//czz6kgsRgXtS/3/CVawEz0qKKRmQKeBuq4JLJceL2FdA8zNG\r\nAnjOeePoe53sT/kkwndr/IRyIrKozAGLWYetw7X6/IPqk5SartpiQdMOayqQ\r\nNg16yWr8YNycUDGtN9BxPEfBD/9kdmWz0s7t+7V3uhrG6y7+90K0XrzxlUfp\r\nIfB+uOR68lEpr3AhvibFoFdOm8OXPCFA7WACoesUeeT2+vrjzbWBcUP3Jamy\r\nEIt/oUfITBdt/E1Gj39oV6jquE1zl8l8RxTXCHAeGLTVPEPIcB2atRHJDZPY\r\nv0NJfn8nua5oSfXBp9bqeDJ49uPqLKqEj8XKtadJHbn/h0LV8HCw9tF9ohRJ\r\nT7mEWN1CLQx9xqVYp9jcFgmrOolqRczxieHTyzbper5hCvkd4g7/LUxQrBzd\r\nef/+fp3Q9oZlMXaBhQo02A6N5va+IGf/kBmAtnm72fCgCqMixjn4HiZTwv5V\r\n0rffWgXfa0ofhHHgKcgYL7lpLGRXSh3tlzI0IoHH3cQ7AykEtmHG9pPFEe74\r\nq4vBMXqECCSBp2dU2ry+gHDTtquHWe0nlMVkGrrvTa8ZhmIwt8n1eW0SGszn\r\nf9pGeaXKwAGv1kHDtDnriWmRiek/CQxIxAmkdP1SIFGserESe8a5G4OwWFH6\r\nDt6ZK/fOUQSwOdye65lQLUFZ8HQwn7kW1D0=\r\n=eYff\r\n-----END PGP SIGNATURE-----\r\n"
}

Repository

PENDING
stopnoanime/16ttac-sim

Shared repository data · GitHub

License detected in repository
Not collected

Repository

PENDING
stopnoanime/8ttacs

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 18:17 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:868da50b64921a45e44092d2e4ec7efb881ff13bbcebc9090e9e5d543fbf00e2

Other collected versions

2.0.122 Oct2.0.020 Oct1.0.1514 Mar1.0.1414 Mar1.0.1314 Mar1.0.1213 MarView all collected versions →