| 1 | name: Build toolchain and examples |
| 2 | |
| 3 | on: |
| 4 | workflow_call: |
| 5 | inputs: |
| 6 | name: |
| 7 | required: true |
| 8 | type: string |
| 9 | yosys: |
| 10 | required: true |
| 11 | type: string |
| 12 | nextpnr: |
| 13 | required: true |
| 14 | type: string |
| 15 | |
| 16 | jobs: |
| 17 | build-tools: |
| 18 | runs-on: ubuntu-latest |
| 19 | steps: |
| 20 | - uses: actions/checkout@v4 |
| 21 | - name: Set up Python |
| 22 | uses: actions/setup-python@v5 |
| 23 | with: |
| 24 | python-version: '3.9' |
| 25 | - name: Install build deps |
| 26 | run: | |
| 27 | sudo apt-get update |
| 28 | sudo apt-get install build-essential clang bison flex \ |
| 29 | libreadline-dev gawk tcl-dev libffi-dev git libfl-dev \ |
| 30 | graphviz xdot pkg-config python3 libboost-system-dev \ |
| 31 | libboost-python-dev libboost-filesystem-dev zlib1g-dev \ |
| 32 | libboost-thread-dev libboost-program-options-dev libboost-iostreams-dev libboost-dev \ |
| 33 | libeigen3-dev |
| 34 | - name: Set up ccache |
| 35 | uses: hendrikmuhs/[email protected] |
| 36 | with: |
| 37 | key: ${{ inputs.name }} |
| 38 | max-size: 1G |
| 39 | - name: Download python package |
| 40 | uses: actions/download-artifact@v4 |
| 41 | with: |
| 42 | name: python-dist |
| 43 | path: dist |
| 44 | - name: Install apycula |
| 45 | run: pip install dist/*.whl |
| 46 | - name: Get yosys |
| 47 | run: | |
| 48 | git clone https://github.com/YosysHQ/yosys.git |
| 49 | cd yosys |
| 50 | git checkout ${{ inputs.yosys }} |
| 51 | git config user.email "ci@localhost" |
| 52 | git config user.name "CI" |
| 53 | #git fetch origin pull/5717/head:zaun-latch |
| 54 | #git merge --no-edit zaun-latch |
| 55 | git submodule update --init --recursive |
| 56 | - name: Build yosys |
| 57 | run: | |
| 58 | cd yosys |
| 59 | cmake -B build . -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache |
| 60 | cmake --build build --config Release --parallel $(nproc) |
| 61 | cmake --install build --prefix ${{ github.workspace }}/staging/usr/local --strip |
| 62 | - name: Build nextpnr |
| 63 | run: | |
| 64 | git clone https://github.com/YosysHQ/nextpnr.git |
| 65 | cd nextpnr |
| 66 | git checkout ${{ inputs.nextpnr }} |
| 67 | git config user.email "ci@localhost" |
| 68 | git config user.name "CI" |
| 69 | #git fetch origin pull/1652/head:zaun-latch |
| 70 | #git merge --no-edit zaun-latch |
| 71 | git submodule update --init --recursive |
| 72 | cmake -B build -DBUILD_PYTHON=OFF -DARCH="himbaechel" \ |
| 73 | -DHIMBAECHEL_UARCH=gowin -DHIMBAECHEL_GOWIN_DEVICES="all" \ |
| 74 | -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache |
| 75 | make -C build -j$(nproc) |
| 76 | make -C build install DESTDIR=${{ github.workspace }}/staging |
| 77 | - name: Package tools |
| 78 | run: tar czf tools.tar.gz -C staging/usr/local . |
| 79 | - name: Upload tools |
| 80 | uses: actions/upload-artifact@v4 |
| 81 | with: |
| 82 | name: tools-${{ inputs.name }} |
| 83 | path: tools.tar.gz |
| 84 | |
| 85 | example: |
| 86 | runs-on: ubuntu-latest |
| 87 | needs: [build-tools] |
| 88 | strategy: |
| 89 | fail-fast: false |
| 90 | matrix: |
| 91 | board: |
| 92 | - {target: tangnano20k, dir: examples} |
| 93 | - {target: primer20k, dir: examples} |
| 94 | - {target: tangnano, dir: examples, pure: true} |
| 95 | - {target: tangnano1k, dir: examples} |
| 96 | - {target: tangnano4k, dir: examples} |
| 97 | - {target: tangnano9k, dir: examples} |
| 98 | - {target: szfpga, dir: examples} |
| 99 | - {target: tec0117, dir: examples} |
| 100 | - {target: runber, dir: examples} |
| 101 | - {target: primer25k, dir: examples/gw5a} |
| 102 | - {target: tangmega138k, dir: examples/gw5a} |
| 103 | - {target: tangconsole60k, dir: examples/gw5a} |
| 104 | steps: |
| 105 | - uses: actions/checkout@v4 |
| 106 | - name: Set up Python |
| 107 | uses: actions/setup-python@v5 |
| 108 | with: |
| 109 | python-version: '3.9' |
| 110 | - name: Download tools |
| 111 | uses: actions/download-artifact@v4 |
| 112 | with: |
| 113 | name: tools-${{ inputs.name }} |
| 114 | - name: Install runtime deps |
| 115 | run: | |
| 116 | sudo apt-get update |
| 117 | sudo apt-get install -y libboost-filesystem1.83.0 libboost-program-options1.83.0 \ |
| 118 | libboost-iostreams1.83.0 libboost-thread1.83.0 libboost-system1.83.0 |
| 119 | - name: Install tools |
| 120 | run: sudo tar xzf tools.tar.gz -C /usr/local && sudo ldconfig |
| 121 | - name: Download python package |
| 122 | uses: actions/download-artifact@v4 |
| 123 | with: |
| 124 | name: python-dist |
| 125 | path: dist |
| 126 | - name: Install apycula |
| 127 | run: | |
| 128 | if [ "${{ matrix.board.pure }}" = "true" ]; then |
| 129 | pip install --no-deps dist/*.whl |
| 130 | pip install msgpack cattrs |
| 131 | else |
| 132 | pip install dist/*.whl |
| 133 | fi |
| 134 | - name: Build examples |
| 135 | run: make -C ${{ matrix.board.dir }} -j$(nproc) ${{ matrix.board.target }} |
| 136 | - name: Archive artifact |
| 137 | uses: actions/upload-artifact@v4 |
| 138 | with: |
| 139 | name: examples-${{ inputs.name }}-${{ matrix.board.target }} |
| 140 | path: ${{ matrix.board.dir }}/*.fs |
| 141 | - name: Sanity check |
| 142 | if: matrix.board.dir == 'examples' |
| 143 | run: | |
| 144 | make -C examples -j$(nproc) ${{ matrix.board.target }}-unpacked |
| 145 | cd examples |
| 146 | for f in *-unpacked.v; do |
| 147 | yosys -p "read_verilog $f; read_verilog -lib +/gowin/cells_sim.v; clean -purge; select -assert-any t:DFF*; select -assert-any t:*BUF;"; |
| 148 | done |
| 149 | |
| 150 | hil: |
| 151 | runs-on: [self-hosted, fpga] |
| 152 | needs: [example] |
| 153 | environment: Hardware in the loop |
| 154 | strategy: |
| 155 | fail-fast: false |
| 156 | matrix: |
| 157 | board: [tec0117, tangnano20k] |
| 158 | steps: |
| 159 | - uses: actions/checkout@v4 |
| 160 | - name: Download bitstreams |
| 161 | uses: actions/download-artifact@v4 |
| 162 | with: |
| 163 | name: examples-${{ inputs.name }}-${{ matrix.board }} |
| 164 | path: examples |
| 165 | - name: Run HIL tests |
| 166 | run: make -C examples hil-${{ matrix.board }} |