npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

16ttac-sim

v2.0.1

Published

16 Bit Transport Triggered Architecture CPU Simulator

Downloads

74

Readme

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.