Git Product home page Git Product logo

denotational-hardware's Introduction

Denotational hardware design in Agda

Introduction

This Agda project aims to synthesize machine-verified, parallel hardware designs from high-level denotational specifications. The common algebraic abstraction is categories, as described in the talks From Haskell to Hardware via CCCs and Teaching new tricks to old programs, as well as the paper Compiling to categories.

The semantics of various representations are given by mappings from operationally motivated representations to their essential denotations. Those mappings are required to be homomorphic with respect to the shared programming interface. This requirement yields a collection of homomorphism equations all solutions of which are correct implementations. As a happy byproduct, the homomorphisms also ensure that all expected laws hold (assuming equivalence is denotational).

Dependencies

Building

Makefile targets:

  • compile: compiles the Test module, but you can compile faster from within the Emacs mode (∁-c C­x C-c).
  • tests: generates circuit diagrams in the Figures subdirectory (dot files and their PDF renderings).
  • listings: renders source code to deeply hyper-linked HTML. Start perusing at html/Everything.html.

Summary of important modules

  • Categorical:
    • Object: Shared interface to categorical products and exponentials as well as booleans.
    • Equiv: Basic interface for morphism equivalences and homomorphisms.
    • Raw: Category classes (including cartesian and cartesian closed). "Raw" as in lacking laws (adopting this use of "raw" from agda-stdlib).
    • Homomorphism: Homomorphism classes for categories, cartesian categories, etc.
  • Ty (module and directory, as with a few others below): Inductive representation of types/objects with booleans, products, and exponentials, along with mappings to objects in other categories.
  • Primitive: "Symbolic" (data type) representation of some common primitives, along with their homomorphic meanings. Currently monolithic, but may need some rethinking for modularity.
  • Routing: information-rearranging category, indexed by Ty.
  • Linearize: linearized representation of morphisms as alternating routings and primitives. Convenient for generating pictures and code.
  • Decode: A category construction and change-of-representation functor.
  • SSA: a simple static single-assignment ("SSA") program representation. Recursive, in order to support exponentials. Conversion from linearized morphisms.
  • Dot: generation of GraphViz format from SSA.
  • Samples: hardware-friendly algorithms.
  • Test: generate pictures from morphisms.
  • Everything: import all code as an easy check that everything works.

Troubleshooting

You might see an error message like this:

Calling: ghc -O -o /Users/sseefried/code/agda-machines/Test -Werror -i/Users/sseefried/code/agda-machines -main-is MAlonzo.Code.Test /Users/sseefried/code/agda-machines/MAlonzo/Code/Test.hs --make -fwarn-incomplete-patterns -fno-warn-overlapping-patterns
[  1 of 153] Compiling MAlonzo.RTE      ( MAlonzo/RTE.hs, MAlonzo/RTE.o )
Compilation error:

MAlonzo/RTE.hs:9:1: error:
    Could not find module ‘Numeric.IEEE’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
9 | import Numeric.IEEE ( IEEE(identicalIEEE, nan) )
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

You can fix this error with:

cabal install --lib ieee754

You can find out how to more about this issue here and here.

Contributing

I am trying to structure this project in such a way as to leave many clear opportunities to contribute (which I think I did poorly in agda-machines). For this reason, most functionality is accompanied by semantic functions of type Homomorphism _⇨₁_ _⇨₂_ for an established morphism type _⇨₂_ and a new morphism type _⇨₁_. A common first step is to prove specific homomorphism properties of type CategoryH _⇨₁_ _⇨₂_, CartesianH _⇨₁_ _⇨₂_, etc.

As of 2021-06-01, many of the proofs in agda-machines have not been moved over. You can peek there for hints or start fresh as an exercise.

See the open issues.

As another source of tasks, git grep TODO.

denotational-hardware's People

Contributors

bolt12 avatar conal avatar jwiegley avatar silky avatar sseefried avatar victorcmiraldo avatar

Watchers

 avatar

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.