Skip to content

Instantly share code, notes, and snippets.

@dgrnbrg
Created April 22, 2012 21:12
Show Gist options
  • Save dgrnbrg/2466965 to your computer and use it in GitHub Desktop.
Save dgrnbrg/2466965 to your computer and use it in GitHub Desktop.
;Define a module with 1 parameter (n)
;it's an up-counter
(defmodule counter [n]
[:outputs [x ((uintm n) 0)]]
(connect x (inc x)))
;Generate the verilog for the module
(println (module->verilog (counter 8)))
;Generate a testbest that verifies that it produces
;((uintm 8) 0), ((uintm 8) 1), ((uintm 8) 2), ... each cycle
(println
(make-testbench
(counter 8)
(map (fn [x]
{:x (verilog-repr ((uintm 8) x))})
(take 10 (iterate inc 0)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment