Giter VIP home page Giter VIP logo

clash-calculator's Introduction

Calculator

This repository implements a simple desktop calculator in Clash. Output is shown on a 4-digit seven segment display, and input is via a 4x4 keypad. Alternatively, serial I/O can also be used, using the included 9600 bps UART.

This code is part of the book Retrocomputing with Clash: Haskell for FPGA Hardware Design at https://unsafePerform.IO/retroclash/.

Building

Use stack build to build and stack run to run the simulation.

For the hardware version, use the included Shakefile. An easy way to run it is via the provided mk shell script. Create a build.mk file with the following content:

TARGET = nexys-a7-50t
VIVADO_ROOT = /opt/somewhere/where/vivado/is/installed
ISE_ROOT = /opt/somewhere/where/ise/is/installed

Alternatively, if you have Vivado/ISE installed in Docker or similar, you can create a wrapper script and use that by setting VIVADO instead of VIVADO_ROOT:

TARGET = nexys-a7-50t
VIVADO = /usr/local/lib/docker-scripts/xilinx-vivado-2019.1-ubuntu-18.04/run
ISE = /usr/local/lib/docker-scripts/xilinx-ise-14.7-ubuntu-12.04/run

Supported target boards

Nexys A7-50T

A Xilinx 7-series FPGA based development board with integrated seven-segment display. A 4x4 keypad with a PMOD connector is available as an add-on; the code assumes this keypad is connected to PMOD port A of the Nexys A7. Serial I/O is supported via an onboard serial over USB bridge.

Papilio Pro & Papilio One

Papilio Pro uses a Xilinx 6-series FPGA, and the Papilio One uses a 3-series one. Both of these have a serial over USB bridge. The LogicStart MegaWing expansion board can be used for seven-segment output.

Other targets

Adding support to other Vivado or ISE based FPGA dev boards is very straightforward with the included Shake rules.

Targeting other FPGA toolchains will require adding support in the Shake rules. Alternatively, you can always just run Clash, and import the resulting Verilog files into your FPGA toolchain in a non-automated way.

clash-calculator's People

Contributors

gergoerdi avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

clash-calculator's Issues

stack can't resolve sdl2 dependency

I'm getting an error when I run stack build on this repo at 1f8189e

$ stack build
sdl2            > configure
sdl2            > Configuring sdl2-2.5.3.0...
sdl2            > Cabal-simple_mPHDZzAJ_3.2.1.0_ghc-8.10.7: The pkg-config package 'sdl2'
sdl2            > version ==2.0.6 || >2.0.6 is required but it could not be found.
sdl2            > 
            
--  While building package sdl2-2.5.3.0 using:
      /home/user/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_mPHDZzAJ_3.2.1.0_ghc-8.10.7 --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0 configure --user --package-db=clear --package-db=global --package-db=/home/user/.stack/snapshots/x86_64-linux-tinfo6/463703b87513d56ad734a0feab5764ec990bd8d05f8c2768a66fb7f3ed49ce32/8.10.7/pkgdb --libdir=/home/user/.stack/snapshots/x86_64-linux-tinfo6/463703b87513d56ad734a0feab5764ec990bd8d05f8c2768a66fb7f3ed49ce32/8.10.7/lib --bindir=/home/user/.stack/snapshots/x86_64-linux-tinfo6/463703b87513d56ad734a0feab5764ec990bd8d05f8c2768a66fb7f3ed49ce32/8.10.7/bin --datadir=/home/user/.stack/snapshots/x86_64-linux-tinfo6/463703b87513d56ad734a0feab5764ec990bd8d05f8c2768a66fb7f3ed49ce32/8.10.7/share --libexecdir=/home/user/.stack/snapshots/x86_64-linux-tinfo6/463703b87513d56ad734a0feab5764ec990bd8d05f8c2768a66fb7f3ed49ce32/8.10.7/libexec --sysconfdir=/home/user/.stack/snapshots/x86_64-linux-tinfo6/463703b87513d56ad734a0feab5764ec990bd8d05f8c2768a66fb7f3ed49ce32/8.10.7/etc --docdir=/home/user/.stack/snapshots/x86_64-linux-tinfo6/463703b87513d56ad734a0feab5764ec990bd8d05f8c2768a66fb7f3ed49ce32/8.10.7/doc/sdl2-2.5.3.0 --htmldir=/home/user/.stack/snapshots/x86_64-linux-tinfo6/463703b87513d56ad734a0feab5764ec990bd8d05f8c2768a66fb7f3ed49ce32/8.10.7/doc/sdl2-2.5.3.0 --haddockdir=/home/user/.stack/snapshots/x86_64-linux-tinfo6/463703b87513d56ad734a0feab5764ec990bd8d05f8c2768a66fb7f3ed49ce32/8.10.7/doc/sdl2-2.5.3.0 --dependency=StateVar=StateVar-1.2.2-E5VfLD39xuSBKKtL6sMcfd --dependency=base=base-4.14.3.0 --dependency=bytestring=bytestring-0.10.12.0 --dependency=exceptions=exceptions-0.10.4 --dependency=linear=linear-1.21.6-KBaG1OjkJdvCKIZzKnWvlf --dependency=text=text-1.2.4.1 --dependency=transformers=transformers-0.5.6.2 --dependency=vector=vector-0.12.3.1-IpFN1hPceHSIntrFAVL6vc -f-examples -f-no-linear -f-opengl-example --exact-configuration --ghc-option=-fhide-source-paths
    Process exited with code: ExitFailure 1
Progress 1/3

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.