Add FPGA tests to interface2 build workflow

This commit is contained in:
Andrew Kay
2021-10-07 20:55:16 -05:00
parent 680e5b108b
commit 4e235290ca
7 changed files with 50 additions and 22 deletions

View File

@@ -12,7 +12,23 @@ permissions:
contents: read
jobs:
test_fpga:
runs-on: ubuntu-latest
defaults:
run:
working-directory: interface2/fpga
name: Test FPGA
steps:
- uses: actions/checkout@v2
- name: Install Icarus Verilog
run: |
sudo apt-get update
sudo apt-get install iverilog
- name: Run tests
run: make tests
build_fpga:
needs: test_fpga
runs-on: ubuntu-latest
defaults:
run:
@@ -49,21 +65,21 @@ jobs:
fi
- name: Login to AWS ECR
if: env.BITSTREAM_CACHE_EXISTS == 'false'
run: aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $REGISTRY
env:
REGISTRY: ${{ secrets.AWS_ECR }}
id: aws_ecr_login
uses: aws-actions/amazon-ecr-login@v1
- name: Prepare iCEcube2
if: env.BITSTREAM_CACHE_EXISTS == 'false'
run: |
docker pull $REGISTRY/icecube2:latest
docker tag $REGISTRY/icecube2:latest icecube2:latest
echo $ICECUBE2_MAC_ADDRESS > rtl/.mac_address
ICECUBE2_IMAGE=$REGISTRY/icecube2:latest
echo "ICECUBE2_IMAGE=$ICECUBE2_IMAGE" >> $GITHUB_ENV
docker pull $ICECUBE2_IMAGE
env:
REGISTRY: ${{ secrets.AWS_ECR }}
ICECUBE2_MAC_ADDRESS: ${{ secrets.ICECUBE2_MAC_ADDRESS }}
REGISTRY: ${{ steps.aws_ecr_login.outputs.registry }}
- name: Build bitstream
if: env.BITSTREAM_CACHE_EXISTS == 'false'
run: make rtl
env:
ICECUBE2_MAC_ADDRESS: ${{ secrets.ICECUBE2_MAC_ADDRESS }}
- name: Cache bitstream
if: env.BITSTREAM_CACHE_EXISTS == 'false'
run: |
@@ -81,7 +97,7 @@ jobs:
- name: Attach bitstream
uses: actions/upload-artifact@v2
with:
name: bitstream
name: fpga_bitstream
path: |
interface2/fpga/rtl/top.bin
interface2/fpga/rtl/top_timing_report.txt
@@ -99,14 +115,14 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install platformio
- name: Download bitstream
uses: actions/download-artifact@v2
with:
name: bitstream
name: fpga_bitstream
path: interface2/fpga/rtl
- name: Build firmware
run: pio run

View File

@@ -1,5 +1,5 @@
# See https://github.com/halfmanhalftaco/fpga-docker/tree/master/Lattice_iCEcube2
ICECUBE2_WRAPPER = docker run -t --rm --volume $(RTL):/data --workdir /data --mac-address=$(shell cat .mac_address) icecube2:latest ./icecube2_env.sh
ICECUBE2_WRAPPER = docker run -t --rm --volume $(RTL):/data --workdir /data --mac-address=$(or $(ICECUBE2_MAC_ADDRESS),$(shell cat .mac_address)) $(or $(ICECUBE2_IMAGE),icecube2:latest) ./icecube2_env.sh
RTL = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
IMPLMNT = coax_Implmnt

View File

@@ -16,7 +16,7 @@ coax_tx_tb: coax_tx_tb.v $(RTL)/coax_tx.v $(RTL)/coax_tx_bit_timer.v
control_tb: control_tb.v $(RTL)/control.v $(RTL)/coax_buffered_tx.v $(RTL)/coax_tx.v $(RTL)/coax_tx_bit_timer.v $(RTL)/coax_buffer.v $(RTL)/third_party/*.v
test: $(TESTS)
$(foreach tb,$(TESTS),./run_test.sh $(tb);)
./run_tests.sh
clean:
rm -f *_tb *.vcd

View File

@@ -1,7 +1,7 @@
`define assert_equal(actual, expected, message) \
if ((actual) !== expected) \
begin \
$display("[ASSERTION FAILURE] %m (%s:%0d): %s", `__FILE__, `__LINE__, message); \
$display("[FAIL:ASSERTION] %m (%s:%0d): %s", `__FILE__, `__LINE__, message); \
$display("\tTime: %0t", $time); \
$display("\tExpected: %x", expected); \
$display("\tActual: %x", actual); \

View File

@@ -1,7 +0,0 @@
#!/bin/sh
VVP=vvp
echo "Running $1"
${VVP} -N $1

View File

@@ -0,0 +1,19 @@
#!/bin/bash
VVP=vvp
set -o pipefail
ANY_FAILURES=0
for TB in *_tb; do
echo "Running $TB"
${VVP} -n $TB | awk "BEGIN{f=0} /^\[FAIL:/{f=1} 1; END{exit(f)}"
if [ $? != 0 ]; then
ANY_FAILURES=1
fi
done
exit $ANY_FAILURES

View File

@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Display verbose output in CI environment.
if [ -n "$CI" ]; then