Giter VIP home page Giter VIP logo

tricpu's Introduction

Balanced ternary CPU hardware emulator

The architecture and instruction set was designed by mwk for Dragon CTF 2019. Here's the challenge: CPU Adventure 2. The architecture description is also there: SPOILERS.rst

This project implements that CPU on PYNQ FPGA board. There's one notable difference between this project and the original design, namely, division instruction. In CPU Adventure 2 division was implemented by converting from ternary to binary, doing division in binary, and converting back to ternary. In this project I've implemented balanced ternary division directly, hovewer, balanced ternary division works differently from binary division. Given integers a and b the algorithm finds integers q and r such that a = q*b + r and abs(r) is less than or equal to b / 2. For example, dividing 7 by 10 gives q = 1 and r = -3.

Files

Many files are copied from original cpuadventure2 repo: cpuadventure2

  • src/: Implementation of CPU. Written in Verilog with Vivado.
  • src/tras/: "tras" files, also copied from cpuadventure2
  • tricpu.hwh: Vivado file, connects top module with AXI, buttons, leds, etc.
  • tricpu.bit: Generated by Vivado.
  • main.py: Run this on PYNQ board. It uploads tricpu.bit to FPGA and implements termcalls and hypercalls on AXI.
  • term.c, term.so: termios interface, used by main.py
  • static/: Those files can be read from CPU with hypercalls.

tricpu's People

Contributors

mrqubo avatar

Stargazers

Michał Radwański avatar

Watchers

James Cloos avatar  avatar  avatar

tricpu's Issues

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.