Skip to content

Commit 035355f

Browse files
DSLX DMA: Implementation
Signed-off-by: Michal Czyz <[email protected]>
1 parent d381e14 commit 035355f

22 files changed

+5463
-0
lines changed

.github/actions/build/action.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: build
2+
description: 'Build XLS'
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Cache
8+
uses: ./.github/actions/cache
9+
10+
- name: Install dependencies via apt
11+
shell: bash
12+
run: sudo apt-get install python3-distutils python3-dev python-is-python3 libtinfo5 build-essential liblapack-dev libblas-dev gfortran
13+
14+
- name: Install bazelisk
15+
shell: bash
16+
run: |
17+
curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-amd64"
18+
mkdir -p "${GITHUB_WORKSPACE}/bin/"
19+
mv bazelisk-linux-amd64 "${GITHUB_WORKSPACE}/bin/bazel"
20+
chmod +x "${GITHUB_WORKSPACE}/bin/bazel"
21+
22+
- name: Bazel Build Tools (opt)
23+
shell: bash
24+
run: |
25+
"${GITHUB_WORKSPACE}/bin/bazel" build --local_cpu_resources=HOST_CPUS-1 --local_ram_resources=HOST_RAM*.9 -c opt --test_output=errors -- //xls/dslx:interpreter_main //xls/dslx/ir_convert:ir_converter_main //xls/tools:opt_main //xls/tools:codegen_main
26+

.github/actions/cache/action.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: cache
2+
description: 'Cache Bazel'
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Mount Bazel Cache
8+
uses: actions/cache@v4
9+
with:
10+
path: "~/.cache/bazel"
11+
# Create/use a cache called bazel-cache-22_04-<commit hash>
12+
# and read the latest cache with prefix bazel-cache-22_04-
13+
# if it doesn't already exist.
14+
key: bazel-cache-22_04-${{ github.sha }}
15+
restore-keys: bazel-cache-22_04-

.github/actions/free-disk/action.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: free-disk
2+
description: 'Removes unused files from runner'
3+
4+
# WARNING
5+
# This is not a 100% safe method of reclaiming space.
6+
# Your workflow may depend on removed files.
7+
8+
runs:
9+
using: "composite"
10+
steps:
11+
- name: Increase build space
12+
shell: bash
13+
run: |
14+
echo "Before cleanup"
15+
df -H
16+
sudo rm -rf /usr/share/dotnet/*
17+
sudo rm -rf /usr/local/lib/android/*
18+
sudo rm -rf /usr/share/dotnet
19+
sudo rm -rf /opt/ghc
20+
sudo rm -rf "/usr/local/share/boost"
21+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
22+
echo "After cleanup"
23+
df -H
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: implementation
2+
description: 'DSLX to Openroad P&R'
3+
inputs:
4+
xls_module:
5+
description: 'Module in //xls/modules'
6+
required: true
7+
default: 'xls/modules/dma'
8+
rule_ir:
9+
description: 'Bazel rule to generate optimized IR'
10+
required: true
11+
default: 'csr_opt_ir_benchmark'
12+
rule_verilog:
13+
description: 'Bazel rule to generate verilog'
14+
required: true
15+
default: 'verilog_csr'
16+
rule_synthesis:
17+
description: 'Bazel rule to synthesize verilog'
18+
required: true
19+
default: 'csr_benchmark_synth'
20+
rule_pnr:
21+
description: 'Bazel rule to place and route'
22+
required: true
23+
default: 'csr_place_and_route'
24+
runs:
25+
using: "composite"
26+
steps:
27+
- uses: ./.github/actions/cache
28+
29+
- name: Summary page
30+
shell: bash
31+
run: |
32+
echo "Module ${{inputs.xls_module}}" >> $GITHUB_STEP_SUMMARY
33+
34+
- name: IR
35+
shell: bash
36+
run: |
37+
bazel run --local_cpu_resources=HOST_CPUS-1 --local_ram_resources=HOST_RAM*.9 ${{inputs.xls_module}}:${{inputs.rule_ir}}
38+
39+
- name: Summary page
40+
shell: bash
41+
run: |
42+
echo "Generate IR :white_check_mark:" >> $GITHUB_STEP_SUMMARY
43+
44+
- name: Verilog
45+
shell: bash
46+
run: |
47+
bazel build --local_cpu_resources=HOST_CPUS-1 --local_ram_resources=HOST_RAM*.9 ${{inputs.xls_module}}:${{inputs.rule_verilog}}
48+
49+
- name: Summary page
50+
shell: bash
51+
run: |
52+
echo "Verilog codegen :white_check_mark:" >> $GITHUB_STEP_SUMMARY
53+
54+
- name: Synthesis
55+
shell: bash
56+
run: |
57+
bazel run --local_cpu_resources=HOST_CPUS-1 --local_ram_resources=HOST_RAM*.9 ${{inputs.xls_module}}:${{inputs.rule_synthesis}}
58+
59+
- name: Summary page
60+
shell: bash
61+
run: |
62+
echo -n "Synthesis :white_check_mark:" >> $GITHUB_STEP_SUMMARY
63+
64+
- name: P&R
65+
shell: bash
66+
run: |
67+
bazel build --local_cpu_resources=HOST_CPUS-1 --local_ram_resources=HOST_RAM*.9 ${{inputs.xls_module}}:${{inputs.rule_pnr}}
68+
69+
- name: Summary page
70+
shell: bash
71+
run: |
72+
echo -n "Place & Route :white_check_mark:" >> $GITHUB_STEP_SUMMARY
73+
74+
# ${variable/character_to_replace/new_character}
75+
# ${variable/ slash / underscore }
76+
- name: Prepare artifact name
77+
if: always()
78+
shell: bash
79+
run: |
80+
name_input=${{inputs.xls_module}}/${{inputs.rule_ir}}
81+
name_output="${name_input//\//_}"
82+
echo "artifact_name=${name_output}" >> "$GITHUB_ENV"
83+
84+
- name: Artifacts
85+
if: always()
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: artifacts-impl-${{ env.artifact_name }}
89+
path: |
90+
./bazel-bin/${{inputs.xls_module}}/*.log
91+
./bazel-bin/${{inputs.xls_module}}/*.textproto
92+
./bazel-bin/${{inputs.xls_module}}/*.ir
93+
./bazel-bin/${{inputs.xls_module}}/*.v
94+
./bazel-bin/${{inputs.xls_module}}/*.sv

.github/actions/test/action.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: test
2+
description: 'DSLX Test'
3+
inputs:
4+
xls_module:
5+
description: 'Module in //xls/modules'
6+
required: true
7+
default: 'xls/modules/dma'
8+
rule_test:
9+
description: 'Bazel rule to test DSLX'
10+
required: true
11+
default: 'test_csr'
12+
13+
runs:
14+
using: "composite"
15+
steps:
16+
- uses: ./.github/actions/cache
17+
18+
- name: IR
19+
shell: bash
20+
env:
21+
BAZEL_RESOURCES_OPT: "--local_cpu_resources=HOST_CPUS-1 --local_ram_resources=HOST_RAM*.9"
22+
BAZEL_RUN_OPT: ""
23+
run: |
24+
bazel run ${BAZEL_RESOURCES_OPT} ${BAZEL_RUN_OPT} ${{inputs.xls_module}}/${{inputs.rule_test}}

.github/scripts/validate_json.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright 2024 The XLS Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import json
16+
import os
17+
18+
# Execution
19+
# In root dir: python .github/scripts/validate_json.py
20+
21+
# This script uses bazel query to check if each target defined
22+
# in the xls-modules.json exists in the BUILD.
23+
24+
json_file = open('.github/workflows/xls-modules.json')
25+
26+
data = json.load(json_file)
27+
json_file.close()
28+
29+
bazel_rules = []
30+
for module in data['module']:
31+
for type in ["rule_ir", "rule_verilog", "rule_synthesis", "rule_pnr"]:
32+
bazel_rule = "bazel query " + module['xls_module'] + ":" + module[type]
33+
bazel_rules.append(bazel_rule)
34+
35+
for bazel_rule in bazel_rules:
36+
RC = os.system(bazel_rule)
37+
assert RC == 0

.github/workflows/xls-modules.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"module": [
3+
{
4+
"xls_module": "//xls/modules/dma",
5+
"rule_ir": "csr_opt_ir_benchmark",
6+
"rule_verilog": "verilog_csr",
7+
"rule_synthesis": "csr_benchmark_synth",
8+
"rule_pnr": "csr_place_and_route"
9+
},
10+
{
11+
"xls_module": "//xls/modules/dma",
12+
"rule_ir": "axi_csr_opt_ir_benchmark",
13+
"rule_verilog": "verilog_axi_csr",
14+
"rule_synthesis": "axi_csr_benchmark_synth",
15+
"rule_pnr": "axi_csr_place_and_route"
16+
},
17+
{
18+
"xls_module": "//xls/modules/dma",
19+
"rule_ir": "address_generator_opt_ir_benchmark",
20+
"rule_verilog": "verilog_address_generator",
21+
"rule_synthesis": "address_generator_benchmark_synth",
22+
"rule_pnr": "address_generator_place_and_route"
23+
},
24+
{
25+
"xls_module": "//xls/modules/dma",
26+
"rule_ir": "frontend_reader_opt_ir_benchmark",
27+
"rule_verilog": "verilog_frontend_reader",
28+
"rule_synthesis": "frontend_reader_benchmark_synth",
29+
"rule_pnr": "frontend_reader_place_and_route"
30+
},
31+
{
32+
"xls_module": "//xls/modules/dma",
33+
"rule_ir": "frontend_writer_opt_ir_benchmark",
34+
"rule_verilog": "verilog_frontend_writer",
35+
"rule_synthesis": "frontend_writer_benchmark_synth",
36+
"rule_pnr": "frontend_writer_place_and_route"
37+
}
38+
]
39+
}

0 commit comments

Comments
 (0)