Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
eine committed Jan 21, 2020
1 parent b06474f commit b2ba5f3
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 100 deletions.
103 changes: 3 additions & 100 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,109 +2,12 @@ name: 'push'

on: [ push, pull_request ]

env:
DOCKER_REGISTRY: docker.pkg.github.com
# https://github.com/tox-dev/tox/issues/1468
PY_COLORS: 1

jobs:

fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
with:
python-version: 3.7
- name: install dependencies
run: |
pip install -U pip --progress-bar off
pip install -U virtualenv tox --progress-bar off
- name: run 'black'
run: tox -e py37-fmt -- --check

lin:
strategy:
fail-fast: false
max-parallel: 2
matrix:
task: [
37-lint,
36-unit,
37-unit,
]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
with:
python-version: 3.7
- name: install dependencies
run: |
pip install -U pip --progress-bar off
pip install -U virtualenv tox --progress-bar off
- name: run job
run: |
tox -e py${{ matrix.task }} -- --color=yes
docker:
strategy:
fail-fast: false
max-parallel: 2
matrix:
task: [
{do: 38-acceptance, tag: llvm},
{do: 38-vcomponents, tag: mcode},
]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
- name: docker login
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login -u vunit-gha --password-stdin "$DOCKER_REGISTRY"
- name: run job
run: |
docker run --rm -tv $(pwd):/src -w /src "$DOCKER_REGISTRY"/vunit/vunit/dev:${{ matrix.task.tag }} tox -e py${{ matrix.task.do }}-ghdl
- name: docker logout
run: docker logout "$DOCKER_REGISTRY"
if: always()

win:
strategy:
fail-fast: false
max-parallel: 4
matrix:
task: [
37-acceptance-ghdl,
37-vcomponents-ghdl,
37-lint,
36-unit,
37-unit,
]
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- name: git submodule update
run: git submodule update --init --recursive
if: (endsWith( matrix.task, '-lint' ) || endsWith( matrix.task, '-unit' )) == false
- uses: actions/setup-python@v1
with:
python-version: 3.7
- name: install dependencies
run: |
pip install -U pip --progress-bar off
pip install -U virtualenv tox --progress-bar off
- name: install GHDL
if: endsWith( matrix.task, '-ghdl' )
shell: bash
run: |
curl -fsSL -o ghdl.zip https://github.com/ghdl/ghdl/releases/download/v0.36/ghdl-0.36-mingw32-mcode.zip
7z x ghdl.zip "-o../ghdl" -y
mv ../ghdl/GHDL/0.36-mingw32-mcode/ ../ghdl-v0.36
rm -rf ../ghdl ghdl.zip
- name: run job
shell: bash
run: |
export PATH=$PATH:$(pwd)/../ghdl-v0.36/bin
tox -e py${{ matrix.task }} -- --color=yes
- run: |
cd examples/vhdl/sjaeckel
./test.sh
8 changes: 8 additions & 0 deletions examples/vhdl/sjaeckel/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
docker_opts = --rm -v /$(shell pwd)://work -w //work --user $(shell id -u)
docker_img ?= ghdl/vunit:gcc
test_threads = 4

default: run

run:
docker run ${docker_opts} ${docker_img} sh -c 'python3 run.py -p ${test_threads}'
24 changes: 24 additions & 0 deletions examples/vhdl/sjaeckel/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from os.path import join, dirname
from vunit import VUnit
from subprocess import check_call
import os

ui = VUnit.from_argv()

ui.add_osvvm()
ui.add_verification_components()

ui.add_source_files_from_csv(join(dirname(__file__), "vunit_files.csv"))

lib = ui.library("lib")
lib.set_sim_option("enable_coverage", True)
lib.set_compile_option("ghdl.flags", ["-g", "-O2", "-Wc,-fprofile-arcs", "-Wc,-ftest-coverage"])
lib.set_sim_option("ghdl.elab_flags", ["-Wl,-lgcov", "-Wl,--coverage"])

def post_run(results):
#srcs = join(dirname(__file__), "src/rtl/*.vhd").lstrip("/")
#check_call(["gcovr", "-r", os.getcwd(), "-f", srcs])
check_call(["gcovr", "-r", os.getcwd()])


ui.main(post_run=post_run)
32 changes: 32 additions & 0 deletions examples/vhdl/sjaeckel/src/rtl/serial_io.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity serial_io is
port(
-- generic signals
clk : in std_logic;
rst : in std_logic;
-- input data
io_i : in std_logic;
-- output-data
io_o : out std_logic
);
end serial_io;

architecture Behavioral of serial_io is
signal r : std_logic;
begin

proc : process(clk, rst) is
begin
if rst = '1' then
r <= '1';
io_o <= '1';
elsif rising_edge(clk) then
r <= io_i;
io_o <= r;
end if;
end process proc;

end Behavioral;
88 changes: 88 additions & 0 deletions examples/vhdl/sjaeckel/src/sim/tb_serial_io.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.NUMERIC_STD.all;

library vunit_lib;
context vunit_lib.vunit_context;
context vunit_lib.vc_context;

library osvvm;
use osvvm.RandomPkg.all;

entity tb_serial_io is
generic(
runner_cfg : string);
end entity;

architecture tb of tb_serial_io is
constant clk_period : time := 1 sec / (1000 * 1000);

signal rst : std_logic := '1';
signal clk : std_logic := '0';

shared variable rnd_stimuli, rnd_expected : RandomPType;

constant uart_slv_bfm : uart_slave_t := new_uart_slave(initial_baud_rate => 57600,
data_length => 8);
constant uart_slv : stream_slave_t := as_stream(uart_slv_bfm);

constant uart_ma_bfm : uart_master_t := new_uart_master(initial_baud_rate => 57600);
constant uart_ma : stream_master_t := as_stream(uart_ma_bfm);

signal io_i, io_o : std_logic;

begin

main : process
variable rnd8 : std_logic_vector(7 downto 0);

begin
test_runner_setup(runner, runner_cfg);

wait until rising_edge(clk);
wait until rising_edge(clk);
wait until rising_edge(clk);
rst <= '0';
wait until rising_edge(clk);
wait until rising_edge(clk);

-- Initialize to same seed to get same sequence
rnd_stimuli.InitSeed(rnd_stimuli'instance_name);
rnd_expected.InitSeed(rnd_stimuli'instance_name);

while test_suite loop
if run("test_send_one_byte") then
rnd8 := rnd_stimuli.RandSlv(8);
push_stream(net, uart_ma, rnd8);
check_stream(net, uart_slv, rnd8(7 downto 0));
end if;
end loop;

test_runner_cleanup(runner);
wait;
end process;
test_runner_watchdog(runner, 10 ms);

clk <= not clk after (clk_period / 2);

dut : entity work.serial_io
port map(
clk => clk,
rst => rst,
io_i => io_i,
io_o => io_o
);

uart_master_bfm : entity vunit_lib.uart_master
generic map(
uart => uart_ma_bfm)
port map(
tx => io_i);

uart_slave_bfm : entity vunit_lib.uart_slave
generic map(
uart => uart_slv_bfm)
port map(
rx => io_o);

end architecture;
15 changes: 15 additions & 0 deletions examples/vhdl/sjaeckel/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env sh

set -e

IMG=ghdl/vunit:gcc
docker pull "$IMG"
time make docker_img="$IMG"

rm -rf vunit_out *.gc*

IMG=ghdl/vunit:gcc-master
docker pull "$IMG"
time make docker_img="$IMG"

rm -rf vunit_out *.gc*
2 changes: 2 additions & 0 deletions examples/vhdl/sjaeckel/vunit_files.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lib,src/rtl/serial_io.vhd
lib,src/sim/tb_serial_io.vhd

0 comments on commit b2ba5f3

Please sign in to comment.