Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better port specifications #467

Merged
merged 41 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
52a86d3
initial fix of input flags to work with whatever inputs are given
vcanumalla Sep 21, 2023
74a74f9
got generic wide and
vcanumalla Sep 25, 2023
001c4c5
raco fmt
vcanumalla Sep 26, 2023
6b80c7c
modified tests to work with new flags, still must change sketches to …
vcanumalla Oct 2, 2023
383f3bc
wide and, get wide add next
vcanumalla Oct 6, 2023
f604fc3
removed dead code and some comments
vcanumalla Oct 19, 2023
2ece52d
added integration tests
vcanumalla Oct 19, 2023
558be73
Merge remote-tracking branch 'origin/main' into vcanumalla/parallel-dsp
vcanumalla Oct 19, 2023
b5635e5
verilator input bitwidth issue for testing large ops
vcanumalla Oct 19, 2023
c9704e7
Enable wider input bitwidths
gussmith23 Oct 23, 2023
9a32d97
Merge remote-tracking branch 'origin/gussmith23/fscanf-input-width' i…
vcanumalla Oct 23, 2023
5d5aaa7
clang error
vcanumalla Oct 28, 2023
7c267e4
new testing flags
vcanumalla Oct 30, 2023
8fbd337
able to access carryout port
vcanumalla Nov 1, 2023
a7eacf3
stupid c++ bug isnt letting me fly. YOU GOT TO LET ME FLY
vcanumalla Nov 2, 2023
633b557
verilator random input fix.
vcanumalla Nov 6, 2023
e7b6b99
combined sketch starting, some tests
vcanumalla Nov 6, 2023
290cf65
working xilinx-specific sketch
vcanumalla Nov 11, 2023
d9524ea
Merge remote-tracking branch 'uwsampl/main' into vcanumalla/parallel-dsp
gussmith23 Sep 7, 2024
f24962a
Undo most of the changes in #363
gussmith23 Sep 7, 2024
1bc9dbf
Undo another change
gussmith23 Sep 7, 2024
b49b676
Revert change
gussmith23 Sep 7, 2024
c5ff716
cleanup
gussmith23 Sep 7, 2024
0a538ca
Update bin/main.rkt
gussmith23 Sep 7, 2024
8f616e9
Update bin/main.rkt
gussmith23 Sep 7, 2024
719b5df
Fix documentation
gussmith23 Sep 7, 2024
5ce75d5
begin fixing a test
gussmith23 Sep 7, 2024
1652c06
Inputs are a map instead of a list now
gussmith23 Sep 9, 2024
b9a290c
Don't need --port flag, just keep track of ports
gussmith23 Sep 10, 2024
09779e3
Cons not list
gussmith23 Sep 10, 2024
d3b8c4b
Docs
gussmith23 Sep 10, 2024
850ef65
Fix symbol/string confusion
gussmith23 Sep 10, 2024
9183d4b
Fix port flag
gussmith23 Sep 10, 2024
e50656b
Sketches take a map as data inputs, not a list
gussmith23 Sep 10, 2024
bc86395
Fix calls
gussmith23 Sep 10, 2024
cd8c0f0
Remove unused file
gussmith23 Sep 10, 2024
249efbe
cdr -> cddr
gussmith23 Sep 16, 2024
bddf86f
Make assoc lists the right shape
gussmith23 Sep 17, 2024
6a8c3f4
Update plugin
gussmith23 Sep 17, 2024
2c29021
Update test
gussmith23 Sep 17, 2024
dc10fa1
fix test
gussmith23 Sep 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,10 @@ TODO(@gussmith23): Find better cross-platform regex. I thought Perl might be the
Lakeroad is usable via a Yosys plugin, which can be built separately and loaded directly into your existing Yosys installation. The plugin is located in [./yosys-plugin/](./yosys-plugin/) and can be built using the Makefile in that directory. The plugin can be loaded into Yosys using Yosys's `-m` option, e.g. `yosys -m lakeroad.so ...`. An example of this can be seen in [this integration test.](./integration_tests/lakeroad/xilinx_muladd_0_stage_signed_8_bit_yosys_plugin.sv)

Note: the Lakeroad plugin needs to be built in the same environment (i.e. same glibc version) as the Yosys executable it's being loaded into. This can be an issue e.g. when using the Yosys executable in `oss-cad-suite`. The easiest way to prevent this is to build Yosys yourself using their directions.

## Debugging for Developers

Debugging Racket and Rosette can be very frustrating. Here are notes that may be useful.

- Use errortrace in Racket.
- Use the Rosette symbolic debugger `symtrace`.
54 changes: 36 additions & 18 deletions bin/main.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@
;;; inputs is an association list mapping input name to an integer bitwidth.
(define inputs (make-parameter '()))
(define solver (make-parameter "bitwuzla"))
; List of (port-name:string, width:int) pairs.
(define ports (make-parameter '()))
(define (parse-dsl expr-str)
(define expr (read (open-input-string expr-str)))
(define (recursive-helper expr)
(match expr
[`(extract ,i ,j ,expr) (lr:extract (lr:integer i) (lr:integer j) (recursive-helper expr))]
[`(port ,(? symbol? sym) ,width)
; Add port to list of ports, if it's not there.
(unless (assoc sym (ports))
(ports (append (ports) (list (list (symbol->string sym) width)))))
(lr:var (symbol->string sym) width)]))
(recursive-helper expr))
(define extra-cycles (make-parameter 0))
(define solver-flags (make-parameter (make-hash)))
(define bitwuzla-path (make-parameter #f))
Expand Down Expand Up @@ -211,16 +224,21 @@
[("--module-name") v "Name given to the module produced." (module-name v)]
[("--input-signal")
v
"Name of an input signal to the module in the format `<name>:<bw` e.g. `a:8` This flag can be"
" specified multiple times. This currently only needs to be specified for sequential synthesis."
;;; Parse --input arg: split <name>:<bw> into name and bw, construct Rosette symbolic input.
(let* ([splits (string-split v ":")] [name (first splits)] [bw (string->number (second splits))])
(when (not (equal? 2 (length splits)))
(error (format "Invalid input signal specification: ~a" v)))
(when (assoc name (inputs))
(error "Signal " name " already present; did you duplicate an --input?"))
(inputs (append (inputs) (list (cons name bw)))))])
"Specify an input to the sketch, using a small domain-specific language. Generally, the inputs to"
" the sketch will correspond to the input ports of the module you are trying to compile. For"
" example, if you were compiling a multiplier module with 8-bit inputs `i0` and `i1` using the `dsp`"
" sketch, you would plug the `i0` and `i1` input ports into the `a` and `b` inputs of"
" the DSP sketch by specifying `--input-signal 'a:(port i0 8):8' --input-signal 'b:(port i1 8):8'`."
(let* ([splits (string-split v ":")]
[_ (when (not (equal? 3 (length splits)))
(error (format "Invalid input signal specification: ~a" v)))]
[id (first splits)]
[expr (parse-dsl (second splits))]
[bw (string->number (third splits))])

(when (assoc id (inputs))
(error "Signal " id " already present; did you duplicate an --input?"))
(inputs (append (inputs) (list (list id expr bw)))))])
;;; Set solver.
(match (solver)
["cvc5" (current-solver (cvc5 #:path (cvc5-path) #:logic 'QF_BV #:options (solver-flags)))]
Expand Down Expand Up @@ -393,7 +411,7 @@

(define sketch-inputs
(make-sketch-inputs #:output-width output-bitwidth
#:data (map (λ (p) (cons (lr:var (car p) (cdr p)) (cdr p))) (inputs))
#:data (map (lambda (p) (cons (first p) (cons (second p) (third p)))) (inputs))
#:clk (if (clock-name) (cons (lr:var (clock-name) 1) 1) #f)
#:rst (if (reset-name) (cons (lr:var (reset-name) 1) 1) #f)))
(define sketch (first (sketch-generator architecture-description sketch-inputs)))
Expand All @@ -415,16 +433,16 @@
[input-values
(map (λ (p)
(match p
[(cons name bw)
[(list name bw)
(cons name (bv->signal (constant (list "main.rkt" name) (bitvector bw))))]))
(inputs))]
(ports))]

;;; The same environments, but with symbolic values
[make-intermediate-inputs
(lambda (inputs iter)
(map (λ (p)
(match p
[(cons name bw)
[(list name bw)
(cons name (bv->signal (constant (list name "iter" iter) (bitvector bw))))]))
inputs))]

Expand All @@ -436,14 +454,14 @@
;;; First, we tick the clock with the inputs set to their input values.
[envs (append (list (cons (cons (clock-name) (bv->signal (bv 0 1))) input-values)
(cons (cons (clock-name) (bv->signal (bv 1 1)))
(make-intermediate-inputs (inputs) 0)))
(make-intermediate-inputs (ports) 0)))
;;; then, we tick the clock with the inputs set to symbolic values.
(apply append
(map (lambda (iter)
(list (cons (cons (clock-name) (bv->signal (bv 0 1)))
(make-intermediate-inputs (inputs) iter))
(make-intermediate-inputs (ports) iter))
(cons (cons (clock-name) (bv->signal (bv 1 1)))
(make-intermediate-inputs (inputs) iter))))
(make-intermediate-inputs (ports) iter))))
(range 1 (+ (pipeline-depth) (extra-cycles))))))]
;;; If there's a reset signal, set it to 0 in all envs.
[envs (if (reset-name)
Expand Down Expand Up @@ -496,10 +514,10 @@
(define envs
(list (append (map (λ (p)
(match p
[(cons name bw)
[(list name bw)
(cons name
(bv->signal (constant (list "main.rkt" name) (bitvector bw))))]))
(inputs))
(ports))
; If there's a clock, hardcode it to 0.
(if (clock-name) (list (cons (clock-name) (bv->signal (bv 0 1)))) (list)))))
(define input-symbolic-constants (symbolics envs))
Expand Down
8 changes: 4 additions & 4 deletions integration_tests/lakeroad/addmulor_3_stage_unsigneds_9_bit.v
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
// RUN: --pipeline-depth 3 \
// RUN: --clock-name clk \
// RUN: --module-name out \
// RUN: --input-signal a:9 \
// RUN: --input-signal b:9 \
// RUN: --input-signal c:9 \
// RUN: --input-signal d:9 \
// RUN: --input-signal 'a:(port a 9):9' \
// RUN: --input-signal 'b:(port b 9):9' \
// RUN: --input-signal 'c:(port c 9):9' \
// RUN: --input-signal 'd:(port d 9):9' \
// RUN: --timeout 90 \
// RUN: --extra-cycles 3 \
// RUN: || true) \
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/lakeroad/combinational_multiplier_lattice.v
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
// RUN: --top-module-name top \
// RUN: --verilog-module-out-signal p:16 \
// RUN: --module-name out \
// RUN: --input-signal a:16 \
// RUN: --input-signal b:16 \
// RUN: --input-signal 'a:(port a 16):16' \
// RUN: --input-signal 'b:(port b 16):16' \
// RUN: --timeout 120 \
// RUN: | FileCheck %s

Expand Down
4 changes: 2 additions & 2 deletions integration_tests/lakeroad/combinational_multiplier_xilinx.v
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// RUN: --verilog-module-out-signal p:16 \
// RUN: --pipeline-depth 0 \
// RUN: --module-name out \
// RUN: --input-signal a:16 \
// RUN: --input-signal b:16 \
// RUN: --input-signal 'a:(port a 16):16' \
// RUN: --input-signal 'b:(port b 16):16' \
// RUN: --timeout 90 \
// RUN: | FileCheck %s

Expand Down
4 changes: 2 additions & 2 deletions integration_tests/lakeroad/example_test_using_include.v
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
// RUN: --verilog-module-out-signal p:16 \
// RUN: --pipeline-depth 0 \
// RUN: --module-name out \
// RUN: --input-signal a:16 \
// RUN: --input-signal b:16 \
// RUN: --input-signal 'a:(port a 16):16' \
// RUN: --input-signal 'b:(port b 16):16' \
// RUN: --timeout 90 \
// RUN: > $outfile
// RUN: FileCheck %s < $outfile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// RUN: --top-module-name top \
// RUN: --verilog-module-out-signal p:18 \
// RUN: --module-name test_module \
// RUN: --input-signal a:18 \
// RUN: --input-signal b:18 \
// RUN: --input-signal 'a:(port a 18):18' \
// RUN: --input-signal 'b:(port b 18):18' \
// RUN: --timeout 120 \
// RUN: > $outfile
// RUN: FileCheck %s < $outfile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// RUN: --top-module-name top \
// RUN: --verilog-module-out-signal p:18 \
// RUN: --module-name test_module \
// RUN: --input-signal a:18 \
// RUN: --input-signal b:18 \
// RUN: --input-signal 'a:(port a 18):18' \
// RUN: --input-signal 'b:(port b 18):18' \
// RUN: --pipeline-depth 1 \
// RUN: --clock-name clk \
// RUN: --timeout 60 \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// RUN: --top-module-name top \
// RUN: --verilog-module-out-signal p:18 \
// RUN: --module-name test_module \
// RUN: --input-signal a:18 \
// RUN: --input-signal b:18 \
// RUN: --input-signal 'a:(port a 18):18' \
// RUN: --input-signal 'b:(port b 18):18' \
// RUN: --pipeline-depth 2 \
// RUN: --clock-name clk \
// RUN: --timeout 60 \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
// RUN: --pipeline-depth 2 \
// RUN: --clock-name clk \
// RUN: --module-name test_module \
// RUN: --input-signal a:8 \
// RUN: --input-signal b:8 \
// RUN: --input-signal 'a:(port a 8):8' \
// RUN: --input-signal 'b:(port b 8):8' \
// RUN: --extra-cycles 3 \
// RUN: --timeout 120 \
// RUN: > $outfile
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/lakeroad/mul16_yosys_techmap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ RUN: --architecture xilinx-ultrascale-plus \
RUN: --template dsp \
RUN: --out-format yosys-techmap \
RUN: --module-name out \
RUN: --input-signal a:16 \
RUN: --input-signal b:16 \
RUN: --input-signal 'a:(port a 16):16' \
RUN: --input-signal 'b:(port b 16):16' \
RUN: --verilog-module-out-signal p:16 \
RUN: --timeout 90 \
RUN: || true) \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
// RUN: --pipeline-depth 1 \
// RUN: --clock-name clk \
// RUN: --module-name out \
// RUN: --input-signal a:11 \
// RUN: --input-signal b:11 \
// RUN: --input-signal c:11 \
// RUN: --input-signal d:11 \
// RUN: --input-signal 'a:(port a 11):11' \
// RUN: --input-signal 'b:(port b 11):11' \
// RUN: --input-signal 'c:(port c 11):11' \
// RUN: --input-signal 'd:(port d 11):11' \
// RUN: --extra-cycles 3 \
// RUN: --timeout 120 \
// RUN: | FileCheck %s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
// RUN: --pipeline-depth 1 \
// RUN: --clock-name clk \
// RUN: --module-name out \
// RUN: --input-signal a:12 \
// RUN: --input-signal b:12 \
// RUN: --input-signal c:12 \
// RUN: --input-signal d:12 \
// RUN: --input-signal 'a:(port a 12):12' \
// RUN: --input-signal 'b:(port b 12):12' \
// RUN: --input-signal 'c:(port c 12):12' \
// RUN: --input-signal 'd:(port d 12):12' \
// RUN: --extra-cycles 3 \
// RUN: --timeout 120 \
// RUN: | FileCheck %s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
// RUN: --pipeline-depth 1 \
// RUN: --clock-name clk \
// RUN: --module-name test_module \
// RUN: --input-signal a:18 \
// RUN: --input-signal b:18 \
// RUN: --input-signal c:18 \
// RUN: --input-signal d:18 \
// RUN: --input-signal 'a:(port a 18):18' \
// RUN: --input-signal 'b:(port b 18):18' \
// RUN: --input-signal 'c:(port c 18):18' \
// RUN: --input-signal 'd:(port d 18):18' \
// RUN: --extra-cycles 1 \
// RUN: --timeout 120 \
// RUN: > $outfile
Expand Down
6 changes: 3 additions & 3 deletions integration_tests/lakeroad/one_stage_mul_or_lattice.v
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
// RUN: --pipeline-depth 1 \
// RUN: --clock-name clk \
// RUN: --module-name test_module \
// RUN: --input-signal a:16 \
// RUN: --input-signal b:16 \
// RUN: --input-signal c:16 \
// RUN: --input-signal 'a:(port a 16):16' \
// RUN: --input-signal 'b:(port b 16):16' \
// RUN: --input-signal 'c:(port c 16):16' \
// RUN: --extra-cycles 3 \
// RUN: --timeout 120 \
// RUN: > $outfile
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/lakeroad/one_stage_multiplier_lattice.v
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
// RUN: --pipeline-depth 1 \
// RUN: --clock-name clk \
// RUN: --module-name test_module \
// RUN: --input-signal a:16 \
// RUN: --input-signal b:16 \
// RUN: --input-signal 'a:(port a 16):16' \
// RUN: --input-signal 'b:(port b 16):16' \
// RUN: --extra-cycles 3 \
// RUN: --timeout 120 \
// RUN: > $outfile
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/lakeroad/pipeline_depth_0_with_clk_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
// RUN: --verilog-module-out-signal o:16 \
// RUN: --pipeline-depth 0 \
// RUN: --module-name out \
// RUN: --input-signal i:16 \
// RUN: --input-signal 'c:(port i 16):16' \
// RUN: --clock-name clk \
// RUN: --timeout 90 \
// RUN: | FileCheck %s

module simple(input clk, input [15:0] i, output [15:0] o);
assign o = a;
assign o = i;
endmodule

// CHECK: module out(clk, i, o);
6 changes: 3 additions & 3 deletions integration_tests/lakeroad/three_stage_mul_and_lattice.v
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
// RUN: --pipeline-depth 3 \
// RUN: --clock-name clk \
// RUN: --module-name out \
// RUN: --input-signal a:16 \
// RUN: --input-signal b:16 \
// RUN: --input-signal c:16 \
// RUN: --input-signal 'a:(port a 16):16' \
// RUN: --input-signal 'b:(port b 16):16' \
// RUN: --input-signal 'c:(port c 16):16' \
// RUN: --extra-cycles 3 \
// RUN: --timeout 120 \
// RUN: || true) \
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/lakeroad/three_stage_multiplier_lattice.v
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
// RUN: --pipeline-depth 3 \
// RUN: --clock-name clk \
// RUN: --module-name out \
// RUN: --input-signal a:16 \
// RUN: --input-signal b:16 \
// RUN: --input-signal 'a:(port a 16):16' \
// RUN: --input-signal 'b:(port b 16):16' \
// RUN: --extra-cycles 3 \
// RUN: --timeout 120 \
// RUN: | FileCheck %s
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/lakeroad/three_stage_multiplier_xilinx.v
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
// RUN: --pipeline-depth 3 \
// RUN: --clock-name clk \
// RUN: --module-name out \
// RUN: --input-signal a:16 \
// RUN: --input-signal b:16 \
// RUN: --input-signal 'a:(port a 16):16' \
// RUN: --input-signal 'b:(port b 16):16' \
// RUN: --timeout 90 \
// This one termiates with 2 extra cycles, but not 3.
// RUN: --extra-cycles 2 \
Expand Down
6 changes: 3 additions & 3 deletions integration_tests/lakeroad/two_stage_mul_and_lattice.v
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
// RUN: --pipeline-depth 2 \
// RUN: --clock-name clk \
// RUN: --module-name test_module \
// RUN: --input-signal a:16 \
// RUN: --input-signal b:16 \
// RUN: --input-signal c:16 \
// RUN: --input-signal 'a:(port a 16):16' \
// RUN: --input-signal 'b:(port b 16):16' \
// RUN: --input-signal 'c:(port c 16):16' \
// RUN: --timeout 90 \
// RUN: --extra-cycles 3 \
// RUN: > $outfile \
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/lakeroad/two_stage_multiplier_xilinx.v
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
// RUN: --pipeline-depth 2 \
// RUN: --clock-name clk \
// RUN: --module-name out \
// RUN: --input-signal a:16 \
// RUN: --input-signal b:16 \
// RUN: --input-signal 'a:(port a 16):16' \
// RUN: --input-signal 'b:(port b 16):16' \
// RUN: --extra-cycles 1 \
// RUN: --timeout 120 \
// RUN: | FileCheck %s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
// RUN: --pipeline-depth 1 \
// RUN: --clock-name clk \
// RUN: --module-name out \
// RUN: --input-signal a:11 \
// RUN: --input-signal b:11 \
// RUN: --input-signal c:11 \
// RUN: --input-signal d:11 \
// RUN: --input-signal 'a:(port a 11):11' \
// RUN: --input-signal 'b:(port b 11):11' \
// RUN: --input-signal 'c:(port c 11):11' \
// RUN: --input-signal 'd:(port d 11):11' \
// RUN: --timeout 120 \
// RUN: --extra-cycles 3 \
// RUN: > $outfile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
// RUN: --pipeline-depth 1 \
// RUN: --clock-name clk \
// RUN: --module-name out \
// RUN: --input-signal a:9 \
// RUN: --input-signal b:9 \
// RUN: --input-signal c:9 \
// RUN: --input-signal d:9 \
// RUN: --input-signal 'a:(port a 9):9' \
// RUN: --input-signal 'b:(port b 9):9' \
// RUN: --input-signal 'c:(port c 9):9' \
// RUN: --input-signal 'd:(port d 9):9' \
// RUN: --extra-cycles 3 \
// RUN: --timeout 120 \
// RUN: > $outfile
Expand Down
Loading
Loading