Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
gussmith23 committed Jul 18, 2023
1 parent dd50934 commit 072fcf2
Show file tree
Hide file tree
Showing 24 changed files with 1,507 additions and 1,502 deletions.
32 changes: 16 additions & 16 deletions bin/main.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -289,16 +289,16 @@
(cons (cons "CARRY8" "../verilator_xilinx/CARRY8.v") xilinx-ultrascale-plus-carry8)
(cons (cons "DSP48E2" "../verilator_unisims/DSP48E2.v") xilinx-ultrascale-plus-dsp48e2))]
["lattice-ecp5"
(list
(cons (cons "LUT4" "../f4pga-arch-defs/ecp5/primitives/slice/LUT4.v") lattice-ecp5-lut4)
(cons (cons "CCU2C" "../f4pga-arch-defs/ecp5/primitives/slice/CCU2C.v") lattice-ecp5-ccu2c)
(cons (cons "MULT18X18D" "../lakeroad-private/lattice_ecp5/MULT18X18D.v")
lattice-ecp5-mult18x18d)
(cons (cons "MULT18X18C" "../lakeroad-private/lattice_ecp5/MULT18X18C.v")
lattice-ecp5-mult18x18c)
(cons (cons "ALU24B" "") lattice-ecp5-alu24b)
(cons (cons "ALU54A" "../lakeroad-private/lattice_ecp5/ALU54A_modified_for_racket_import.v")
lattice-ecp5-alu54a))]
(list (cons (cons "LUT4" "../f4pga-arch-defs/ecp5/primitives/slice/LUT4.v") lattice-ecp5-lut4)
(cons (cons "CCU2C" "../f4pga-arch-defs/ecp5/primitives/slice/CCU2C.v") lattice-ecp5-ccu2c)
(cons (cons "MULT18X18D" "../lakeroad-private/lattice_ecp5/MULT18X18D.v")
lattice-ecp5-mult18x18d)
(cons (cons "MULT18X18C" "../lakeroad-private/lattice_ecp5/MULT18X18C.v")
lattice-ecp5-mult18x18c)
(cons (cons "ALU24B" "") lattice-ecp5-alu24b)
(cons (cons "ALU54A"
"../lakeroad-private/lattice_ecp5/ALU54A_modified_for_racket_import.v")
lattice-ecp5-alu54a))]
["sofa"
(list (cons (cons "frac_lut4" "../modules_for_importing/SOFA/frac_lut4.v") sofa-frac-lut4))]
["intel" (list (cons (cons "altmult_accum" "unused") intel-altmult-accum))]
Expand Down Expand Up @@ -414,11 +414,11 @@

(match (out-format)
[(or "verilog" "yosys-techmap")
(display (with-output-to-string
(lambda ()
(when (not (system (format "yosys -q -p 'read_json ~a; write_verilog'"
(json-filepath))))
(error "Yosys failed."))))
(output-port))]
(display
(with-output-to-string (lambda ()
(when (not (system (format "yosys -q -p 'read_json ~a; write_verilog'"
(json-filepath))))
(error "Yosys failed."))))
(output-port))]

[_ (error "Invalid output format.")])])
336 changes: 168 additions & 168 deletions racket/architecture-description.rkt

Large diffs are not rendered by default.

64 changes: 32 additions & 32 deletions racket/btor.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@
(match tokens
[`("init" ,sort-id-str ,state-id-str ,next-val-id-str)
(set! init-hash
`(append (list (cons ,(make-state-key-expr
(string->symbol (format "state~a" state-id-str)))
`(append (list (cons ,(make-state-key-expr (string->symbol (format "state~a"
state-id-str)))
,(simple-compile next-val-id-str)))
,init-hash))]
[_ (void)])))
Expand Down Expand Up @@ -211,8 +211,8 @@
;;; We build a hash map that maps state symbols (e.g. 'state0) to the expressions that convey
;;; the output value for the state.
(set! output-state-hash
`(append (list (cons ,(make-state-key-expr
(hash-ref state-symbols (string->number state-id-str)))
`(append (list (cons ,(make-state-key-expr (hash-ref state-symbols
(string->number state-id-str)))
(signal-value ,(get-expr-id-str next-val-id-str))))
,output-state-hash))]
;;; Do nothing. Should be handled by the above code which does a first pass for init values.
Expand Down Expand Up @@ -258,18 +258,18 @@
;;; value by name and convert it to a signal.
(add-expr-id-str
id-str
`(let* ([state-value
(cond
[(assoc-has-key? ,merged-input-state-hash-symbol
,(make-state-key-expr state-symbol))
(bv->signal (assoc-ref ,merged-input-state-hash-symbol
,(make-state-key-expr state-symbol)))]
[(assoc-has-key? ,init-hash-symbol ,(make-state-key-expr state-symbol))
(bv->signal (assoc-ref ,init-hash-symbol
,(make-state-key-expr state-symbol)))]
[else
(bv->signal (,(hash-ref get-default-value-fn-hash
(string->number sort-id-str))))])])
`(let* ([state-value (cond
[(assoc-has-key? ,merged-input-state-hash-symbol
,(make-state-key-expr state-symbol))
(bv->signal (assoc-ref ,merged-input-state-hash-symbol
,(make-state-key-expr state-symbol)))]
[(assoc-has-key? ,init-hash-symbol
,(make-state-key-expr state-symbol))
(bv->signal (assoc-ref ,init-hash-symbol
,(make-state-key-expr state-symbol)))]
[else
(bv->signal (,(hash-ref get-default-value-fn-hash
(string->number sort-id-str))))])])
(when (not (signal? state-value))
(error "Expected signal"))
;;; TODO(@gussmith23): Signals don't just have to contain bvs, now that we've enabled
Expand All @@ -280,12 +280,12 @@
[`("sort" "bitvec" ,width-str)
(hash-set! sorts (string->number id-str) (bitvector (string->number width-str)))
(add-expr-id-str id-str (hash-ref sorts (string->number id-str)))
(hash-set! get-default-value-fn-hash
(string->number id-str)
`(lambda ()
(log-warning
"Getting default value of 0 for bitvector, this may be a bad idea!")
(bv 0 ,(string->number width-str))))]
(hash-set!
get-default-value-fn-hash
(string->number id-str)
`(lambda ()
(log-warning "Getting default value of 0 for bitvector, this may be a bad idea!")
(bv 0 ,(string->number width-str))))]
[`("sort" "array" ,index-sort-id-str ,element-sort-id-str)
(hash-set! sorts (string->number id-str) vector?)
(add-expr-id-str id-str (hash-ref sorts (string->number id-str)))
Expand Down Expand Up @@ -330,18 +330,18 @@
[`("output" ,id-str ,name) (hash-set! outs (string->symbol name) (get-expr-id-str id-str))]
[`("uext" ,out-type-id-str ,in-id-str ,_ ...)
(let ([s (get-expr-id-str in-id-str)])
(add-expr-id-str
id-str
`(bv->signal (zero-extend (signal-value ,s)
,(hash-ref sorts (string->number out-type-id-str)))
,s)))]
(add-expr-id-str id-str
`(bv->signal (zero-extend (signal-value ,s)
,(hash-ref sorts
(string->number out-type-id-str)))
,s)))]
[`("sext" ,out-type-id-str ,in-id-str ,_ ...)
(let ([s (get-expr-id-str in-id-str)])
(add-expr-id-str
id-str
`(bv->signal (sign-extend (signal-value ,s)
,(hash-ref sorts (string->number out-type-id-str)))
,s)))]
(add-expr-id-str id-str
`(bv->signal (sign-extend (signal-value ,s)
,(hash-ref sorts
(string->number out-type-id-str)))
,s)))]
[`("concat" ,out-type-id-str ,a-id-str ,b-id-str)
(let ([a (get-expr-id-str a-id-str)] [b (get-expr-id-str b-id-str)])
(add-expr-id-str id-str (op-call-builder concat a b)))]
Expand Down
8 changes: 4 additions & 4 deletions racket/comp-json.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,10 @@
(hash-set! netnames name net-details)))

(define (get-net-details netnames net-name)
(hash-ref
netnames
(as-symbol net-name)
(lambda () (error (format "Netnames ~a does not contain net-name ~a" netnames net-name)))))
(hash-ref netnames
(as-symbol net-name)
(lambda ()
(error (format "Netnames ~a does not contain net-name ~a" netnames net-name)))))

(define (get-net-details-from-module-in-doc doc mod-name net-name)
(get-cell (hash-ref (get-module-from-doc doc mod-name) 'netnames) net-name))
Expand Down
98 changes: 49 additions & 49 deletions racket/comparisons-on-lattice-example.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -207,55 +207,55 @@
;;; Once again, note the use of all ones (and not zeros) when
;;; padding the inputs to the ripple PFUs.
(lr:list
(list
(lr:concat
(lr:list (list (lr:bv (bv->signal (bv #b11 2)))
(lr:concat (lr:list (list (lr:list-ref ripple-pfu-0-output
(lr:integer 0))
(lr:list-ref ripple-pfu-1-output
(lr:integer 0))))))))
(lr:concat
(lr:list (list (lr:bv (bv->signal (bv #b11 2)))
(lr:concat (lr:list (list (lr:list-ref ripple-pfu-0-output
(lr:integer 1))
(lr:list-ref ripple-pfu-1-output
(lr:integer 1))))))))
(lr:concat
(lr:list (list (lr:bv (bv->signal (bv #b11 2)))
(lr:concat (lr:list (list (lr:list-ref ripple-pfu-0-output
(lr:integer 2))
(lr:list-ref ripple-pfu-1-output
(lr:integer 2))))))))
(lr:concat
(lr:list (list (lr:bv (bv->signal (bv #b11 2)))
(lr:concat (lr:list (list (lr:list-ref ripple-pfu-0-output
(lr:integer 3))
(lr:list-ref ripple-pfu-1-output
(lr:integer 3))))))))
(lr:concat
(lr:list (list (lr:bv (bv->signal (bv #b11 2)))
(lr:concat (lr:list (list (lr:list-ref ripple-pfu-0-output
(lr:integer 4))
(lr:list-ref ripple-pfu-1-output
(lr:integer 4))))))))
(lr:concat
(lr:list (list (lr:bv (bv->signal (bv #b11 2)))
(lr:concat (lr:list (list (lr:list-ref ripple-pfu-0-output
(lr:integer 5))
(lr:list-ref ripple-pfu-1-output
(lr:integer 5))))))))
(lr:concat
(lr:list (list (lr:bv (bv->signal (bv #b11 2)))
(lr:concat (lr:list (list (lr:list-ref ripple-pfu-0-output
(lr:integer 6))
(lr:list-ref ripple-pfu-1-output
(lr:integer 6))))))))
(lr:concat
(lr:list (list (lr:bv (bv->signal (bv #b11 2)))
(lr:concat
(lr:list (list (lr:list-ref ripple-pfu-0-output (lr:integer 7))
(lr:list-ref ripple-pfu-1-output
(lr:integer 7)))))))))))]
(list (lr:concat
(lr:list (list (lr:bv (bv->signal (bv #b11 2)))
(lr:concat (lr:list (list (lr:list-ref ripple-pfu-0-output
(lr:integer 0))
(lr:list-ref ripple-pfu-1-output
(lr:integer 0))))))))
(lr:concat
(lr:list (list (lr:bv (bv->signal (bv #b11 2)))
(lr:concat (lr:list (list (lr:list-ref ripple-pfu-0-output
(lr:integer 1))
(lr:list-ref ripple-pfu-1-output
(lr:integer 1))))))))
(lr:concat
(lr:list (list (lr:bv (bv->signal (bv #b11 2)))
(lr:concat (lr:list (list (lr:list-ref ripple-pfu-0-output
(lr:integer 2))
(lr:list-ref ripple-pfu-1-output
(lr:integer 2))))))))
(lr:concat
(lr:list (list (lr:bv (bv->signal (bv #b11 2)))
(lr:concat (lr:list (list (lr:list-ref ripple-pfu-0-output
(lr:integer 3))
(lr:list-ref ripple-pfu-1-output
(lr:integer 3))))))))
(lr:concat
(lr:list (list (lr:bv (bv->signal (bv #b11 2)))
(lr:concat (lr:list (list (lr:list-ref ripple-pfu-0-output
(lr:integer 4))
(lr:list-ref ripple-pfu-1-output
(lr:integer 4))))))))
(lr:concat
(lr:list (list (lr:bv (bv->signal (bv #b11 2)))
(lr:concat (lr:list (list (lr:list-ref ripple-pfu-0-output
(lr:integer 5))
(lr:list-ref ripple-pfu-1-output
(lr:integer 5))))))))
(lr:concat
(lr:list (list (lr:bv (bv->signal (bv #b11 2)))
(lr:concat (lr:list (list (lr:list-ref ripple-pfu-0-output
(lr:integer 6))
(lr:list-ref ripple-pfu-1-output
(lr:integer 6))))))))
(lr:concat
(lr:list (list (lr:bv (bv->signal (bv #b11 2)))
(lr:concat (lr:list (list (lr:list-ref ripple-pfu-0-output
(lr:integer 7))
(lr:list-ref
ripple-pfu-1-output
(lr:integer 7)))))))))))]

;;; Our output is the carry out of ripple PFU 2.
[cout (lr:list-ref ripple-pfu-2-output (lr:integer 8))])
Expand Down
18 changes: 9 additions & 9 deletions racket/compile-to-json.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,17 @@
[(lr:hw-module-instance module-name ports params filepath)
(let* ([input-ports
(filter (λ (p) (equal? (module-instance-port-direction p) 'input)) ports)]
[input-port-symbols
(map string->symbol (map module-instance-port-name input-ports))]
[input-port-symbols (map string->symbol
(map module-instance-port-name input-ports))]
;;; Pairs of input symbol with compiled expression.
[input-pairs (map (λ (p)
(cons (string->symbol (module-instance-port-name p))
(compile (module-instance-port-value p))))
input-ports)]
[output-ports
(filter (λ (p) (equal? (module-instance-port-direction p) 'output)) ports)]
[output-port-symbols
(map string->symbol (map module-instance-port-name output-ports))]
[output-port-symbols (map string->symbol
(map module-instance-port-name output-ports))]
;;; Pairs of output symbol with allocated bit ids.
[output-pairs
(map (λ (p)
Expand Down Expand Up @@ -338,11 +338,11 @@
(list (cons 'INJECT1_0 "NO")
(cons 'INJECT1_1 "NO")))
param-pairs)]
[cell (make-cell
module-name
(make-cell-port-directions input-port-symbols output-port-symbols)
(make-immutable-hash (append input-pairs output-pairs))
#:params (make-immutable-hash param-pairs))])
[cell (make-cell module-name
(make-cell-port-directions input-port-symbols
output-port-symbols)
(make-immutable-hash (append input-pairs output-pairs))
#:params (make-immutable-hash param-pairs))])

(add-cell (string->symbol module-name) cell)

Expand Down
Loading

0 comments on commit 072fcf2

Please sign in to comment.