futil 0.1.2

Compiler Infrastructure for Hardware Accelerator Generation
ver = "0.3.2"

##### Compilation Tests ######
## Test each pass in isolation. Gets the pass flags from a comment on the first line of the file
[[tests]]
name = "[core] passes"
paths = [
  "tests/passes/*.futil",
  "tests/passes/**/*.futil",
]
# gets the pass flags a comment on the first line of the test file
cmd = """
flags=$(head -n 1 {} | cut -c 3-)
./target/debug/futil {} $flags
"""

[[tests]]
name = "[core] parsing"
# Round-tripping from the compiler should not change anything.
paths = [ "./tests/parsing/*.expect" ]
cmd = """
./target/debug/futil {} -p none
"""

## Tests the error messages generated by the compiler. Runs passes for error
## checking.
[[tests]]
name = "[core] errors"
paths = [
  "tests/errors/*.futil",
  "tests/errors/parser/*.futil"
]
cmd = """
./target/debug/futil {} -p well-formed -p papercut -p synthesis-papercut
"""

## Tests errors that occur at runtime
[[tests]]
name = "[core] runtime errors"
paths = [
  "tests/errors/runtime/*.futil"
]
cmd = """
fud exec -s futil.exec './target/debug/futil' \
         -s verilog.cycle_limit 500 \
         {} --to dat -q | \
         grep '%Error' | sed 's/%Error: [^:]*:[^:]*:/%Error:/'
"""

##### Correctness Tests #####
## Tests that ensure that individual control
## constructs have correct behavior when compiled.
[[tests]]
name = "correctness dynamic"
paths = [
  "tests/correctness/*.futil",
]
cmd = """
fud exec -s verilog.data {}.data \
         -s futil.flags '-d static-timing' \
         -s futil.exec './target/debug/futil' \
         -s verilog.cycle_limit 500 \
         {} --to dat \
         -q \
         | jq .memories
"""

[[tests]]
name = "numeric types correctness and parsing"
paths = [
  "tests/correctness/numeric-types/parsing/*.futil",
  "tests/correctness/numeric-types/bitnum/*.futil",
  "tests/correctness/numeric-types/fixed-point/*.futil"
]
cmd = """
fud exec -s verilog.data {}.data \
         {} --to dat -q | jq .memories
"""

[[tests]]
name = "[frontend] tcam testing"
paths = [
  "tests/correctness/tcam/*.futil"
]
cmd = """
fud exec -s verilog.data {}.data \
         {} --to dat -q | jq .memories
"""

## Same as correctness dynamic but runs with static-timing.
[[tests]]
name = "correctness static timing"
paths = [ "tests/correctness/*.futil" ]
cmd = """
fud exec -s verilog.cycle_limit 500 \
         -s verilog.data {}.data \
         -s futil.exec './target/debug/futil' \
         {} --to dat \
         -q \
         | jq .memories
"""

[[tests]]
name = "[frontend] systolic array correctness"
paths = [ "tests/correctness/systolic/*.systolic" ]
cmd = """
fud e --from systolic --to vcd_json \
      {} \
      -s verilog.data {}.data \
      -s futil.exec './target/debug/futil' \
      -q \
      | jq -f {}.jq

"""

[[tests]]
name = "[frontend] NTT pipeline correctness"
paths = [ "tests/correctness/ntt-pipeline/*.txt" ]
cmd = """
python3 frontends/ntt-pipeline/gen-ntt-pipeline.py {} > {}.futil; \
fud e {}.futil --to dat -s verilog.data {}.data -q 2>/dev/null; \
rm {}.futil;
"""

[[tests]]
name = "exp (taylor series approximation) correctness"
paths = [ "tests/correctness/exp/*.txt" ]
cmd = """
python3 calyx-py/calyx/gen_exp.py {} > {}.futil; \
fud e {}.futil --to dat -s verilog.data {}.data -q 2>/dev/null; \
rm {}.futil;
"""

[[tests]]
name = "[frontend] mrxl correctness"
paths = [ "frontends/mrxl/test/*.mrxl" ]
cmd = """
fud e -q {} --from mrxl --to dat -s verilog.data {}.data | jq .memories
"""

[[tests]]
name = "[frontend] relay correctness"
paths = ["tests/correctness/relay/*.relay"]
cmd = """
fud e -q {} --from relay --to dat -s verilog.data {}.data | jq .memories
"""

##### Backend Tests #####
[[tests]]
name = "[core] verilog backend"
paths = [ "tests/backend/verilog/*.futil" ]
cmd = """
flags=$(head -n 1 {} | cut -c 3-)
./target/debug/futil {} $flags
"""


##### Frontend Tests #####
[[tests]]
name = "[frontend] dahlia"
paths = [ "tests/frontend/dahlia/*.fuse" ]
cmd = """
fud e {} --to futil -q \
          -s futil.exec './target/debug/futil' \
        | tail -n+2
"""

[[tests]]
name = "[frontend] systolic array"
paths = [ "tests/frontend/systolic/array-*.systolic" ]
cmd = """
./frontends/systolic-lang/gen-systolic.py {}
"""

[[tests]]
name = "[frontend] NTT pipeline generation"
paths = [ "tests/frontend/ntt-pipeline/*.txt" ]
cmd = """
python3 frontends/ntt-pipeline/gen-ntt-pipeline.py {}
"""


[[tests]]
name = "[frontend] relay"
paths = ["tests/frontend/relay/*.relay"]
cmd = "python3 frontends/relay/relay_visitor.py {}"

[[tests]]
name = "[frontend] exp"
paths = ["tests/frontend/exp/*.txt"]
cmd = "python3 calyx-py/calyx/gen_exp.py {}"

[[tests]]
name = "python library AST"
paths = ["calyx-py/test/*.py"]
cmd = """
python3 {}
"""

##### Examples #####

[[tests]]
name = "language tutorial"
paths = ["examples/tutorial/*.futil"]
cmd = """
fud e {} --to dat -s verilog.data examples/tutorial/data.json -q
"""

[[tests]]
name = "memory by reference tutorial"
paths = ["examples/futil/memory-by-reference/*.futil"]
cmd = """
fud e {} --to dat -s verilog.data {}.data -q
"""

[[tests]]
name = "dahlia examples"
paths = ["examples/dahlia/*.fuse"]
cmd = """
fud e {} --to dat -s verilog.data {}.data -q
"""

[[tests]]
name = "[core] futil examples"
paths = ["examples/futil/*.futil"]
cmd = """
./target/debug/futil {}
"""