Skip to content

Instantly share code, notes, and snippets.

View aumouvantsillage's full-sized avatar

Guillaume Savaton aumouvantsillage

View GitHub Profile
@aumouvantsillage
aumouvantsillage / tiny-hdl-example-v1.rkt
Last active May 26, 2020 20:54
Racket DSL example: Tiny-HDL
#lang racket
(require "tiny-hdl-macros.rkt")
(entity half-adder ([input a] [input b] [output s] [output co]))
(entity full-adder ([input a] [input b] [input ci] [output s] [output co]))
(architecture half-adder-arch half-adder
(assign (port-ref half-adder s) (xor (port-ref half-adder a) (port-ref half-adder b)))
@aumouvantsillage
aumouvantsillage / sugar-for-struct-accessors.rkt
Last active July 6, 2020 15:42
Syntactic sugar to access Racket struct fields without prefixing them with the struct type name.
#lang racket
(require
syntax/parse/define
(for-syntax racket/syntax))
; Define an instance of a structure:
; - name: the name of the instance
; - sname: the name of the struct type
; - arg ...: the arguments for the struct type constructor