Initial commit
This commit is contained in:
commit
0d1b73e3e0
255 files changed
+16057
No files matched your search
@@ -0,0 +1,9 @@
|
||||
artifacts += data.py __pycache__
|
||||
CHECK_RESULTS = true
|
||||
|
||||
include ../vhdl.mk
|
||||
|
||||
plot: CHECK_RESULTS = false
|
||||
plot: sim
|
||||
@echo Plotting resulting signal vs. expected signal ...
|
||||
@../../scripts/plot.py ${expected_data} 2> /dev/null
|
||||
@@ -0,0 +1,59 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
# Make sure that the top level is assigned to main
|
||||
$(if $(main),,\
|
||||
$(error Assign top level entity name to variable "main"))
|
||||
|
||||
# Make sure that at least on vhdl source is assigned
|
||||
$(if $(vhdl_srcs),,\
|
||||
$(error Assign at least on vhdl source to variable "vhdl_srcs"))
|
||||
|
||||
# Append prefix -d to all generics
|
||||
generics = $(addprefix -g,$(generics))
|
||||
|
||||
# Add VHDL 2008 as default build standard
|
||||
vhdl_flags += --std=08
|
||||
|
||||
vhdl_objs = $(vhdl_srcs:.vhd=.o)
|
||||
|
||||
assert_level := error
|
||||
|
||||
.PHONY: sim clean
|
||||
|
||||
sim: ${main}
|
||||
@../../scripts/execute_and_highlight.sh ghdl -r ${vhdl_flags} ${main} -gCHECK_RESULTS=${CHECK_RESULTS} \
|
||||
--read-wave-opt=${main}.wave \
|
||||
--assert-level=${assert_level}
|
||||
|
||||
gui: ${main}.ghw
|
||||
@echo "Viewing $<"
|
||||
@gtkwave $< --script=gtkwave.view
|
||||
|
||||
${main}.ghw: ${main} ${main}.wave
|
||||
@ghdl -r ${vhdl_flags} ${main} \
|
||||
--read-wave-opt=${main}.wave \
|
||||
--wave=$@
|
||||
|
||||
${main}: $(vhdl_objs)
|
||||
@echo "Elaborating ${main}"
|
||||
@ghdl -e ${vhdl_flags} ${main}
|
||||
|
||||
%.o: %.vhd
|
||||
@echo "Analysing $<"
|
||||
@ghdl -a ${vhdl_flags} $<
|
||||
|
||||
clean:
|
||||
@ghdl --clean
|
||||
@rm -rf ${main}.ghw work-obj08.cf ${vhdl_objs} ${main} ${artifacts}
|
||||
|
||||
help:
|
||||
@echo Use ghdl to simulate and synthesis a vhdl design.
|
||||
@echo
|
||||
@echo Build configuration variables:
|
||||
@echo main main entity
|
||||
@echo vhdl_flags
|
||||
@echo generics
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
# Make sure that the top level is assigned to main
|
||||
$(if $(main),,\
|
||||
$(error Assign top level entity name to variable "main"))
|
||||
|
||||
# Make sure that at least on vhdl source is assigned
|
||||
$(if $(vhdl_srcs),,\
|
||||
$(error Assign at least on vhdl source to variable "vhdl_srcs"))
|
||||
|
||||
# Append prefix -d to all generics
|
||||
generics = $(addprefix -g,$(generics))
|
||||
|
||||
# Add VHDL 2008 as default build standard
|
||||
vhdl_flags += -2008
|
||||
|
||||
vhdl_objs = $(vhdl_srcs:.vhd=.vhdo)
|
||||
verilog_objs = $(verilog_srcs:.v=.vo)
|
||||
|
||||
assert_level := error
|
||||
|
||||
.PHONY: sim clean
|
||||
|
||||
sim: ${verilog_objs} ${vhdl_objs}
|
||||
@vsim -gCHECK_RESULTS=${CHECK_RESULTS} -voptargs=+acc -c work.${main} -do "set StdArithNoWarnings 1; set NumericStdNoWarnings 1; run -all" \
|
||||
| ../../scripts/highlight_test_results.sh
|
||||
|
||||
gui: ${verilog_objs} ${vhdl_objs}
|
||||
@vsim -gCHECK_RESULTS=${CHECK_RESULTS} -gGUI_MODE=true -voptargs=+acc work.${main} -do "do vsim.wave; set StdArithNoWarnings 1; set NumericStdNoWarnings 1; run -all"
|
||||
|
||||
%.vo: %.v .libwork
|
||||
@echo "Analysing $<"
|
||||
@vlog -work work ${verilog_flags} $<
|
||||
|
||||
%.vhdo: %.vhd .libwork
|
||||
@echo "Analysing $<"
|
||||
@vcom -work work ${vhdl_flags} $<
|
||||
|
||||
|
||||
.libwork:
|
||||
@vlib work && vmap work work && touch $@
|
||||
|
||||
clean:
|
||||
@rm -rf work \
|
||||
.libwork \
|
||||
transcript \
|
||||
modelsim.ini \
|
||||
vlog.opt \
|
||||
vsim.wlf \
|
||||
data.py \
|
||||
data.pyc \
|
||||
|
||||
help:
|
||||
@echo Use ghdl to simulate and synthesis a vhdl design.
|
||||
@echo
|
||||
@echo Build configuration variables:
|
||||
@echo main main entity
|
||||
@echo vhdl_flags
|
||||
@echo generics
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
vhdl_srcs = ../../../hardware/system/reg32.vhd \
|
||||
../../../hardware/system/task.vhd \
|
||||
../../../hardware/system/avalon_slave.vhd \
|
||||
../../../hardware/system/avalon_slave_transitions.vhd \
|
||||
../../../hardware/system/hardware_task_control.vhd \
|
||||
../../../hardware/system/float_add.vhd \
|
||||
../../../hardware/signal_processing/add.vhd \
|
||||
../../../hardware/system/task_add.vhd \
|
||||
../../../hardware/system/data_channel_control.vhd \
|
||||
../../../hardware/system/data_sink_mux.vhd \
|
||||
../../../hardware/system/data_source_mux.vhd \
|
||||
../../../hardware/system/fifo.vhd \
|
||||
../../../hardware/system/data_channel.vhd \
|
||||
../test_utility.vhd \
|
||||
../test_avalon_slave.vhd \
|
||||
../test_hardware_task.vhd \
|
||||
../test_data_channel.vhd \
|
||||
../../data/sine_cosine.vhd \
|
||||
../../data/rand.vhd \
|
||||
../../data/add_rand.vhd \
|
||||
test_task_add_rand.vhd \
|
||||
|
||||
main = test_task_add_rand
|
||||
expected_data = ../../data/add_rand.py
|
||||
|
||||
include ../data_tests.mk
|
||||
|
||||
@@ -0,0 +1,184 @@
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
use ieee.float_pkg.all;
|
||||
|
||||
library work;
|
||||
use work.reg32.all;
|
||||
use work.avalon_slave.all;
|
||||
use work.test_utility.all;
|
||||
use work.test_avalon_slave.all;
|
||||
use work.task.all;
|
||||
use work.test_hardware_task.all;
|
||||
use work.test_data_channel_pkg.all;
|
||||
|
||||
library std;
|
||||
use std.env.all;
|
||||
use std.textio.all;
|
||||
|
||||
entity test_task_add_rand is
|
||||
generic( CHECK_RESULTS : boolean; GUI_MODE : boolean := false );
|
||||
end entity test_task_add_rand;
|
||||
|
||||
architecture test of test_task_add_rand is
|
||||
|
||||
procedure test_configure( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response ) is
|
||||
|
||||
variable index : integer := 0;
|
||||
variable writedata : std_logic_vector( 31 downto 0 );
|
||||
begin
|
||||
std.textio.write( std.textio.OUTPUT, " test_configure ... " );
|
||||
index := 0;
|
||||
writedata := x"08000000"; -- 2^32 / 32
|
||||
write_and_assert_config_eq( clk => clk, req => req, rsp => rsp,
|
||||
index => index, config => writedata );
|
||||
|
||||
index := 1;
|
||||
writedata := x"00000000";
|
||||
write_and_assert_config_eq( clk => clk, req => req, rsp => rsp,
|
||||
index => index, config => writedata );
|
||||
|
||||
index := 2;
|
||||
writedata := x"40800000"; -- 2 ** 2 = 4 float
|
||||
write_and_assert_config_eq( clk => clk, req => req, rsp => rsp,
|
||||
index => index, config => writedata );
|
||||
|
||||
std.textio.write( std.textio.OUTPUT, TEST_OK );
|
||||
|
||||
end procedure test_configure;
|
||||
|
||||
signal clk : std_logic := '0';
|
||||
signal reset : std_logic := '1';
|
||||
|
||||
signal req : work.avalon_slave.Request;
|
||||
signal rsp : work.avalon_slave.Response;
|
||||
|
||||
signal data_channel_req : work.avalon_slave.Request;
|
||||
signal data_channel_rsp : work.avalon_slave.Response;
|
||||
|
||||
signal signal_a_read : std_logic;
|
||||
signal signal_a_readdata : std_logic_vector( 31 downto 0 );
|
||||
|
||||
signal signal_b_read : std_logic;
|
||||
signal signal_b_readdata : std_logic_vector( 31 downto 0 );
|
||||
|
||||
signal signal_write : std_logic;
|
||||
signal signal_writedata : std_logic_vector( 31 downto 0 );
|
||||
|
||||
signal data_channel_read : std_logic;
|
||||
signal data_channel_readdata : std_logic_vector( 31 downto 0 );
|
||||
|
||||
begin
|
||||
|
||||
dut : entity work.task_add
|
||||
port map (
|
||||
clk => clk,
|
||||
reset => reset,
|
||||
|
||||
address => req.address,
|
||||
read => req.read,
|
||||
readdata => rsp.readdata,
|
||||
write => req.write,
|
||||
writedata => req.writedata,
|
||||
|
||||
signal_a_read => signal_a_read,
|
||||
signal_a_readdata => signal_a_readdata,
|
||||
|
||||
signal_b_read => signal_b_read,
|
||||
signal_b_readdata => signal_b_readdata,
|
||||
|
||||
signal_write => signal_write,
|
||||
signal_writedata => signal_writedata
|
||||
);
|
||||
|
||||
u_data_channel : entity work.data_channel
|
||||
port map (
|
||||
clk => clk,
|
||||
reset => reset,
|
||||
|
||||
ctrl_address => data_channel_req.address,
|
||||
ctrl_read => data_channel_req.read,
|
||||
ctrl_readdata => data_channel_rsp.readdata,
|
||||
ctrl_write => data_channel_req.write,
|
||||
ctrl_writedata => data_channel_req.writedata,
|
||||
|
||||
hw_sink_write => signal_write,
|
||||
hw_sink_writedata => signal_writedata,
|
||||
|
||||
hw_source_read => data_channel_read,
|
||||
hw_source_readdata => data_channel_readdata
|
||||
);
|
||||
|
||||
clk <= not clk after 10 ns;
|
||||
|
||||
reset_release : process is
|
||||
begin
|
||||
wait for 35 ns;
|
||||
reset <= '0';
|
||||
wait;
|
||||
end process reset_release;
|
||||
|
||||
input_data_a_simulus: process is
|
||||
variable index : integer := 0;
|
||||
begin
|
||||
while true loop
|
||||
signal_a_readdata <= to_std_logic_vector( to_float( work.sine_cosine_data.expected( index ) ) );
|
||||
wait until rising_edge( signal_a_read );
|
||||
if ( index < 1023 ) then
|
||||
index := index + 1;
|
||||
end if;
|
||||
end loop;
|
||||
end process input_data_a_simulus;
|
||||
|
||||
input_data_b_simulus: process is
|
||||
variable index : integer := 0;
|
||||
begin
|
||||
while true loop
|
||||
signal_b_readdata <= to_std_logic_vector( to_float( work.rand_data.expected( index ) ) );
|
||||
wait until rising_edge( signal_b_read );
|
||||
if ( index < 1023 ) then
|
||||
index := index + 1;
|
||||
end if;
|
||||
end loop;
|
||||
end process input_data_b_simulus;
|
||||
|
||||
stimulus: process is
|
||||
variable data_channel_config : std_logic_vector( 31 downto 0 ) := x"00000001";
|
||||
begin
|
||||
std.textio.write( std.textio.OUTPUT, "--------------------------------------------------------------------------------" & LF );
|
||||
std.textio.write( std.textio.OUTPUT, "Starting test_task_add_rand" & LF );
|
||||
wait until falling_edge( reset );
|
||||
wait until falling_edge( clk );
|
||||
|
||||
work.test_data_channel_pkg.write_and_assert_config( clk => clk,
|
||||
req => data_channel_req,
|
||||
rsp => data_channel_rsp,
|
||||
config => data_channel_config );
|
||||
|
||||
test_configure( clk => clk, req => req, rsp => rsp );
|
||||
test_execute( clk => clk, req => req, rsp => rsp,
|
||||
write => signal_write, writedata => signal_writedata );
|
||||
|
||||
for i in 0 to 10 loop
|
||||
wait until falling_edge( clk );
|
||||
end loop;
|
||||
|
||||
if ( CHECK_RESULTS ) then
|
||||
check_and_write_content( clk => clk,
|
||||
req => data_channel_req, rsp => data_channel_rsp,
|
||||
expected => work.add_rand_data.expected );
|
||||
else
|
||||
write_content( clk => clk,
|
||||
req => data_channel_req, rsp => data_channel_rsp );
|
||||
end if;
|
||||
|
||||
if ( GUI_MODE ) then
|
||||
std.env.stop;
|
||||
else
|
||||
std.env.finish;
|
||||
end if;
|
||||
end process stimulus;
|
||||
end architecture test;
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
$ version 1.1
|
||||
/test_task_add_sine_cosine/*
|
||||
/test_task_add_sine_cosine/dut/*
|
||||
/test_task_add_sine_cosine/dut/u_add/*
|
||||
/test_task_add_sine_cosine/dut/u_add/u_float_add/*
|
||||
@@ -0,0 +1,2 @@
|
||||
add wave -position end sim:/test_task_add_rand/dut/u_add/*
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
vhdl_srcs = ../../../hardware/system/reg32.vhd \
|
||||
../../../hardware/system/task.vhd \
|
||||
../../../hardware/system/avalon_slave.vhd \
|
||||
../../../hardware/system/avalon_slave_transitions.vhd \
|
||||
../../../hardware/system/hardware_task_control.vhd \
|
||||
../../../hardware/system/float_add.vhd \
|
||||
../../../hardware/signal_processing/add.vhd \
|
||||
../../../hardware/system/task_add.vhd \
|
||||
../../../hardware/system/data_channel_control.vhd \
|
||||
../../../hardware/system/data_sink_mux.vhd \
|
||||
../../../hardware/system/data_source_mux.vhd \
|
||||
../../../hardware/system/fifo.vhd \
|
||||
../../../hardware/system/data_channel.vhd \
|
||||
../test_utility.vhd \
|
||||
../test_avalon_slave.vhd \
|
||||
../test_hardware_task.vhd \
|
||||
../test_data_channel.vhd \
|
||||
../../data/sine.vhd \
|
||||
../../data/cosine.vhd \
|
||||
../../data/sine_cosine.vhd \
|
||||
test_task_add_sine_cosine.vhd \
|
||||
|
||||
main = test_task_add_sine_cosine
|
||||
expected_data = ../../data/sine_cosine.py
|
||||
|
||||
include ../data_tests.mk
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
use ieee.float_pkg.all;
|
||||
|
||||
library work;
|
||||
use work.reg32.all;
|
||||
use work.avalon_slave.all;
|
||||
use work.test_utility.all;
|
||||
use work.test_avalon_slave.all;
|
||||
use work.task.all;
|
||||
use work.sine_data.all;
|
||||
use work.test_hardware_task.all;
|
||||
use work.test_data_channel_pkg.all;
|
||||
|
||||
library std;
|
||||
use std.env.all;
|
||||
use std.textio.all;
|
||||
|
||||
entity test_task_add_sine_cosine is
|
||||
generic( CHECK_RESULTS : boolean; GUI_MODE : boolean := false );
|
||||
end entity test_task_add_sine_cosine;
|
||||
|
||||
architecture test of test_task_add_sine_cosine is
|
||||
|
||||
procedure test_configure( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response ) is
|
||||
|
||||
variable index : integer := 0;
|
||||
variable writedata : std_logic_vector( 31 downto 0 );
|
||||
begin
|
||||
std.textio.write( std.textio.OUTPUT, " test_configure ... " );
|
||||
index := 0;
|
||||
writedata := x"08000000"; -- 2^32 / 32
|
||||
write_and_assert_config_eq( clk => clk, req => req, rsp => rsp,
|
||||
index => index, config => writedata );
|
||||
|
||||
index := 1;
|
||||
writedata := x"00000000";
|
||||
write_and_assert_config_eq( clk => clk, req => req, rsp => rsp,
|
||||
index => index, config => writedata );
|
||||
|
||||
index := 2;
|
||||
writedata := x"40800000"; -- 2 ** 2 = 4 float
|
||||
write_and_assert_config_eq( clk => clk, req => req, rsp => rsp,
|
||||
index => index, config => writedata );
|
||||
|
||||
std.textio.write( std.textio.OUTPUT, TEST_OK );
|
||||
|
||||
end procedure test_configure;
|
||||
|
||||
signal clk : std_logic := '0';
|
||||
signal reset : std_logic := '1';
|
||||
|
||||
signal req : work.avalon_slave.Request;
|
||||
signal rsp : work.avalon_slave.Response;
|
||||
|
||||
signal data_channel_req : work.avalon_slave.Request;
|
||||
signal data_channel_rsp : work.avalon_slave.Response;
|
||||
|
||||
signal signal_a_read : std_logic;
|
||||
signal signal_a_readdata : std_logic_vector( 31 downto 0 );
|
||||
|
||||
signal signal_b_read : std_logic;
|
||||
signal signal_b_readdata : std_logic_vector( 31 downto 0 );
|
||||
|
||||
signal signal_write : std_logic;
|
||||
signal signal_writedata : std_logic_vector( 31 downto 0 );
|
||||
|
||||
signal data_channel_read : std_logic;
|
||||
signal data_channel_readdata : std_logic_vector( 31 downto 0 );
|
||||
|
||||
begin
|
||||
|
||||
dut : entity work.task_add
|
||||
port map (
|
||||
clk => clk,
|
||||
reset => reset,
|
||||
|
||||
address => req.address,
|
||||
read => req.read,
|
||||
readdata => rsp.readdata,
|
||||
write => req.write,
|
||||
writedata => req.writedata,
|
||||
|
||||
signal_a_read => signal_a_read,
|
||||
signal_a_readdata => signal_a_readdata,
|
||||
|
||||
signal_b_read => signal_b_read,
|
||||
signal_b_readdata => signal_b_readdata,
|
||||
|
||||
signal_write => signal_write,
|
||||
signal_writedata => signal_writedata
|
||||
);
|
||||
|
||||
u_data_channel : entity work.data_channel
|
||||
port map (
|
||||
clk => clk,
|
||||
reset => reset,
|
||||
|
||||
ctrl_address => data_channel_req.address,
|
||||
ctrl_read => data_channel_req.read,
|
||||
ctrl_readdata => data_channel_rsp.readdata,
|
||||
ctrl_write => data_channel_req.write,
|
||||
ctrl_writedata => data_channel_req.writedata,
|
||||
|
||||
hw_sink_write => signal_write,
|
||||
hw_sink_writedata => signal_writedata,
|
||||
|
||||
hw_source_read => data_channel_read,
|
||||
hw_source_readdata => data_channel_readdata
|
||||
);
|
||||
|
||||
clk <= not clk after 10 ns;
|
||||
|
||||
reset_release : process is
|
||||
begin
|
||||
wait for 35 ns;
|
||||
reset <= '0';
|
||||
wait;
|
||||
end process reset_release;
|
||||
|
||||
input_data_a_simulus: process is
|
||||
variable index : integer := 0;
|
||||
begin
|
||||
while true loop
|
||||
signal_a_readdata <= to_std_logic_vector( to_float( work.sine_data.expected( index ) ) );
|
||||
wait until rising_edge( signal_a_read );
|
||||
if ( index < 1023 ) then
|
||||
index := index + 1;
|
||||
end if;
|
||||
end loop;
|
||||
end process input_data_a_simulus;
|
||||
|
||||
input_data_b_simulus: process is
|
||||
variable index : integer := 0;
|
||||
begin
|
||||
while true loop
|
||||
signal_b_readdata <= to_std_logic_vector( to_float( work.cosine_data.expected( index ) ) );
|
||||
wait until rising_edge( signal_b_read );
|
||||
if ( index < 1023 ) then
|
||||
index := index + 1;
|
||||
end if;
|
||||
end loop;
|
||||
end process input_data_b_simulus;
|
||||
|
||||
stimulus: process is
|
||||
variable data_channel_config : std_logic_vector( 31 downto 0 ) := x"00000001";
|
||||
begin
|
||||
std.textio.write( std.textio.OUTPUT, "--------------------------------------------------------------------------------" & LF );
|
||||
std.textio.write( std.textio.OUTPUT, "Starting test_task_add_sine_cosine" & LF );
|
||||
wait until falling_edge( reset );
|
||||
wait until falling_edge( clk );
|
||||
|
||||
work.test_data_channel_pkg.write_and_assert_config( clk => clk,
|
||||
req => data_channel_req,
|
||||
rsp => data_channel_rsp,
|
||||
config => data_channel_config );
|
||||
|
||||
test_configure( clk => clk, req => req, rsp => rsp );
|
||||
test_execute( clk => clk, req => req, rsp => rsp,
|
||||
write => signal_write, writedata => signal_writedata );
|
||||
|
||||
for i in 0 to 10 loop
|
||||
wait until falling_edge( clk );
|
||||
end loop;
|
||||
|
||||
if ( CHECK_RESULTS ) then
|
||||
check_and_write_content( clk => clk,
|
||||
req => data_channel_req, rsp => data_channel_rsp,
|
||||
expected => work.sine_cosine_data.expected );
|
||||
else
|
||||
write_content( clk => clk,
|
||||
req => data_channel_req, rsp => data_channel_rsp );
|
||||
end if;
|
||||
|
||||
if ( GUI_MODE ) then
|
||||
std.env.stop;
|
||||
else
|
||||
std.env.finish;
|
||||
end if;
|
||||
end process stimulus;
|
||||
end architecture test;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
$ version 1.1
|
||||
/test_task_add_sine_cosine/*
|
||||
/test_task_add_sine_cosine/dut/*
|
||||
/test_task_add_sine_cosine/dut/u_add/*
|
||||
/test_task_add_sine_cosine/dut/u_add/u_float_add/*
|
||||
/test_task_add_sine_cosine/u_data_channel/**
|
||||
@@ -0,0 +1,2 @@
|
||||
add wave -position end sim:/test_task_add_sine_cosine/dut/u_add/*
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
|
||||
vhdl_srcs = ../../../hardware/system/reg32.vhd \
|
||||
../../../hardware/system/task.vhd \
|
||||
../../../hardware/system/avalon_slave.vhd \
|
||||
../../../hardware/system/avalon_slave_transitions.vhd \
|
||||
../../../hardware/system/float.vhd \
|
||||
../../../hardware/system/hardware_task_control.vhd \
|
||||
../../../hardware/system/data_channel_control.vhd \
|
||||
../../../hardware/system/data_sink_mux.vhd \
|
||||
../../../hardware/system/data_source_mux.vhd \
|
||||
../../../hardware/system/fifo.vhd \
|
||||
../../../hardware/system/data_channel.vhd \
|
||||
../../../hardware/system/cordic_pkg.vhd \
|
||||
../../../hardware/system/cordic.vhd \
|
||||
../../../hardware/system/fixed_sine.vhd \
|
||||
../../../hardware/system/float_sine.vhd \
|
||||
../../../hardware/signal_processing/sine.vhd \
|
||||
../../../hardware/system/task_sine.vhd \
|
||||
../test_utility.vhd \
|
||||
../test_avalon_slave.vhd \
|
||||
../test_hardware_task.vhd \
|
||||
../test_data_channel.vhd \
|
||||
../../data/cosine.vhd \
|
||||
test_task_cosine.vhd \
|
||||
|
||||
main = test_task_cosine
|
||||
expected_data = ../../data/cosine.py
|
||||
|
||||
include ../data_tests.mk
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
use ieee.float_pkg.all;
|
||||
|
||||
library work;
|
||||
use work.reg32.all;
|
||||
use work.avalon_slave.all;
|
||||
use work.test_utility.all;
|
||||
use work.test_avalon_slave.all;
|
||||
use work.task.all;
|
||||
use work.cosine_data.all;
|
||||
use work.test_hardware_task.all;
|
||||
use work.test_data_channel_pkg.all;
|
||||
|
||||
library std;
|
||||
use std.env.all;
|
||||
use std.textio.all;
|
||||
|
||||
entity test_task_cosine is
|
||||
generic( CHECK_RESULTS : boolean; GUI_MODE : boolean := false );
|
||||
end entity test_task_cosine;
|
||||
|
||||
architecture test of test_task_cosine is
|
||||
|
||||
procedure test_configure( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response ) is
|
||||
|
||||
variable index : integer := 0;
|
||||
variable writedata : std_logic_vector( 31 downto 0 );
|
||||
begin
|
||||
std.textio.write( std.textio.OUTPUT, " test_configure ... " );
|
||||
index := 0;
|
||||
writedata := x"0147ae14"; -- 2^32 / 32
|
||||
write_and_assert_config_eq( clk => clk, req => req, rsp => rsp,
|
||||
index => index, config => writedata );
|
||||
|
||||
index := 1;
|
||||
writedata := x"40000000";
|
||||
write_and_assert_config_eq( clk => clk, req => req, rsp => rsp,
|
||||
index => index, config => writedata );
|
||||
|
||||
index := 2;
|
||||
writedata := x"40000000"; -- 2 ** 2 = 4 float
|
||||
write_and_assert_config_eq( clk => clk, req => req, rsp => rsp,
|
||||
index => index, config => writedata );
|
||||
|
||||
std.textio.write( std.textio.OUTPUT, TEST_OK );
|
||||
|
||||
end procedure test_configure;
|
||||
|
||||
signal clk : std_logic := '0';
|
||||
signal reset : std_logic := '1';
|
||||
|
||||
signal req : work.avalon_slave.Request;
|
||||
signal rsp : work.avalon_slave.Response;
|
||||
|
||||
signal data_channel_req : work.avalon_slave.Request;
|
||||
signal data_channel_rsp : work.avalon_slave.Response;
|
||||
|
||||
signal signal_write : std_logic;
|
||||
signal signal_writedata : std_logic_vector( 31 downto 0 );
|
||||
|
||||
signal data_channel_read : std_logic;
|
||||
signal data_channel_readdata : std_logic_vector( 31 downto 0 );
|
||||
|
||||
begin
|
||||
|
||||
dut : entity work.task_sine
|
||||
port map (
|
||||
clk => clk,
|
||||
reset => reset,
|
||||
|
||||
address => req.address,
|
||||
read => req.read,
|
||||
readdata => rsp.readdata,
|
||||
write => req.write,
|
||||
writedata => req.writedata,
|
||||
|
||||
signal_write => signal_write,
|
||||
signal_writedata => signal_writedata
|
||||
);
|
||||
|
||||
u_data_channel : entity work.data_channel
|
||||
port map (
|
||||
clk => clk,
|
||||
reset => reset,
|
||||
|
||||
ctrl_address => data_channel_req.address,
|
||||
ctrl_read => data_channel_req.read,
|
||||
ctrl_readdata => data_channel_rsp.readdata,
|
||||
ctrl_write => data_channel_req.write,
|
||||
ctrl_writedata => data_channel_req.writedata,
|
||||
|
||||
hw_sink_write => signal_write,
|
||||
hw_sink_writedata => signal_writedata,
|
||||
|
||||
hw_source_read => data_channel_read,
|
||||
hw_source_readdata => data_channel_readdata
|
||||
);
|
||||
|
||||
clk <= not clk after 10 ns;
|
||||
|
||||
reset_release : process is
|
||||
begin
|
||||
wait for 35 ns;
|
||||
reset <= '0';
|
||||
wait;
|
||||
end process reset_release;
|
||||
|
||||
stimulus: process is
|
||||
variable data_channel_config : std_logic_vector( 31 downto 0 ) := x"00000001";
|
||||
begin
|
||||
wait until falling_edge( reset );
|
||||
|
||||
work.test_data_channel_pkg.write_and_assert_config( clk => clk,
|
||||
req => data_channel_req,
|
||||
rsp => data_channel_rsp,
|
||||
config => data_channel_config );
|
||||
|
||||
test_configure( clk => clk, req => req, rsp => rsp );
|
||||
test_execute( clk => clk, req => req, rsp => rsp,
|
||||
write => signal_write, writedata => signal_writedata );
|
||||
|
||||
if ( CHECK_RESULTS ) then
|
||||
check_and_write_content( clk => clk,
|
||||
req => data_channel_req, rsp => data_channel_rsp,
|
||||
expected => work.cosine_data.expected );
|
||||
else
|
||||
write_content( clk => clk,
|
||||
req => data_channel_req, rsp => data_channel_rsp );
|
||||
end if;
|
||||
|
||||
if ( GUI_MODE ) then
|
||||
std.env.stop;
|
||||
else
|
||||
std.env.finish;
|
||||
end if;
|
||||
end process stimulus;
|
||||
end architecture test;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
$ version 1.1
|
||||
/test_task_sine/*
|
||||
/test_task_sine/dut/*
|
||||
/test_task_sine/dut/u_sine/*
|
||||
/test_task_sine/dut/u_sine/u_float_sine/*
|
||||
/test_task_sine/dut/u_sine/u_float_sine/u_fixed_sine/*
|
||||
@@ -0,0 +1 @@
|
||||
add wave -position end sim:/test_task_cosine/dut/u_sine/*
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
vhdl_srcs = ../../../hardware/system/reg32.vhd \
|
||||
../../../hardware/system/task.vhd \
|
||||
../../../hardware/system/avalon_slave.vhd \
|
||||
../../../hardware/system/avalon_slave_transitions.vhd \
|
||||
../../../hardware/system/float.vhd \
|
||||
../../../hardware/system/hardware_task_control.vhd \
|
||||
../../../hardware/system/data_channel_control.vhd \
|
||||
../../../hardware/system/data_sink_mux.vhd \
|
||||
../../../hardware/system/data_source_mux.vhd \
|
||||
../../../hardware/system/fifo.vhd \
|
||||
../../../hardware/system/data_channel.vhd \
|
||||
../../../hardware/signal_processing/crc.vhd \
|
||||
../../../hardware/system/task_crc.vhd \
|
||||
../test_utility.vhd \
|
||||
../test_avalon_slave.vhd \
|
||||
../test_hardware_task.vhd \
|
||||
../test_data_channel.vhd \
|
||||
../../data/fft.vhd \
|
||||
../../data/crc.vhd \
|
||||
test_task_crc.vhd \
|
||||
|
||||
main = test_task_crc
|
||||
expected_data = ../../data/crc.py
|
||||
|
||||
CHECK_RESULTS = true
|
||||
|
||||
include ../vhdl.mk
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
use ieee.float_pkg.all;
|
||||
|
||||
library work;
|
||||
use work.reg32.all;
|
||||
use work.avalon_slave.all;
|
||||
use work.test_utility.all;
|
||||
use work.test_avalon_slave.all;
|
||||
use work.task.all;
|
||||
use work.crc_data.all;
|
||||
use work.fft_data.all;
|
||||
use work.test_hardware_task.all;
|
||||
use work.test_data_channel_pkg.all;
|
||||
|
||||
library std;
|
||||
use std.env.all;
|
||||
use std.textio.all;
|
||||
|
||||
entity test_task_crc is
|
||||
generic( CHECK_RESULTS : boolean );
|
||||
end entity test_task_crc;
|
||||
|
||||
architecture test of test_task_crc is
|
||||
|
||||
signal clk : std_logic := '0';
|
||||
signal reset : std_logic := '1';
|
||||
|
||||
signal req : work.avalon_slave.Request;
|
||||
signal rsp : work.avalon_slave.Response;
|
||||
|
||||
signal data_channel_req : work.avalon_slave.Request;
|
||||
signal data_channel_rsp : work.avalon_slave.Response;
|
||||
|
||||
signal signal_read : std_logic;
|
||||
signal signal_readdata : std_logic_vector( 31 downto 0 );
|
||||
|
||||
signal signal_write : std_logic;
|
||||
signal signal_writedata : std_logic_vector( 31 downto 0 );
|
||||
|
||||
signal data_channel_read : std_logic;
|
||||
signal data_channel_readdata : std_logic_vector( 31 downto 0 );
|
||||
|
||||
signal index_output : integer range 0 to 1023;
|
||||
|
||||
begin
|
||||
|
||||
dut : entity work.task_crc
|
||||
port map (
|
||||
clk => clk,
|
||||
reset => reset,
|
||||
|
||||
address => req.address,
|
||||
read => req.read,
|
||||
readdata => rsp.readdata,
|
||||
write => req.write,
|
||||
writedata => req.writedata,
|
||||
|
||||
signal_read => signal_read,
|
||||
signal_readdata => signal_readdata,
|
||||
|
||||
signal_write => signal_write,
|
||||
signal_writedata => signal_writedata
|
||||
);
|
||||
|
||||
u_data_channel : entity work.data_channel
|
||||
port map (
|
||||
clk => clk,
|
||||
reset => reset,
|
||||
|
||||
ctrl_address => data_channel_req.address,
|
||||
ctrl_read => data_channel_req.read,
|
||||
ctrl_readdata => data_channel_rsp.readdata,
|
||||
ctrl_write => data_channel_req.write,
|
||||
ctrl_writedata => data_channel_req.writedata,
|
||||
|
||||
hw_sink_write => signal_write,
|
||||
hw_sink_writedata => signal_writedata,
|
||||
|
||||
hw_source_read => data_channel_read,
|
||||
hw_source_readdata => data_channel_readdata
|
||||
);
|
||||
|
||||
clk <= not clk after 10 ns;
|
||||
|
||||
reset_release : process is
|
||||
begin
|
||||
wait for 35 ns;
|
||||
reset <= '0';
|
||||
wait;
|
||||
end process reset_release;
|
||||
|
||||
p_number_input_sample: process ( clk, reset ) is
|
||||
begin
|
||||
if ( reset = '1' ) then
|
||||
index_output <= 1;
|
||||
signal_readdata <= to_std_logic_vector( to_float( work.fft_data.expected( 0 ) ) );
|
||||
elsif ( rising_edge( clk ) ) then
|
||||
if signal_read = '1' then
|
||||
if index_output /= 1023 then
|
||||
index_output <= index_output + 1;
|
||||
end if;
|
||||
signal_readdata <= to_std_logic_vector( to_float( work.fft_data.expected( index_output ) ) );
|
||||
end if;
|
||||
end if;
|
||||
end process p_number_input_sample;
|
||||
|
||||
stimulus: process is
|
||||
variable data_channel_config : std_logic_vector( 31 downto 0 ) := x"00000001";
|
||||
variable expected_crc_value : std_logic_vector( 31 downto 0 ) := work.crc_data.expected;
|
||||
begin
|
||||
wait until falling_edge( reset );
|
||||
|
||||
work.test_data_channel_pkg.write_and_assert_config( clk => clk,
|
||||
req => data_channel_req,
|
||||
rsp => data_channel_rsp,
|
||||
config => data_channel_config );
|
||||
|
||||
test_execute( clk => clk, req => req, rsp => rsp,
|
||||
write => signal_write, writedata => signal_writedata );
|
||||
|
||||
std.textio.write( std.textio.OUTPUT, " test_crc_value ... " );
|
||||
|
||||
assert_read_sw_source_eq( clk => clk,
|
||||
req => data_channel_req, rsp => data_channel_rsp,
|
||||
expected => expected_crc_value );
|
||||
|
||||
std.textio.write( std.textio.OUTPUT, TEST_OK );
|
||||
|
||||
finish;
|
||||
end process stimulus;
|
||||
end architecture test;
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
$ version 1.1
|
||||
/test_task_crc/*
|
||||
/test_task_crc/dut/*
|
||||
@@ -0,0 +1,2 @@
|
||||
add wave -position end sim:/test_task_crc/dut/u_crc/*
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
|
||||
verilog_srcs = \
|
||||
../../../hardware/system/Butterfly.v \
|
||||
../../../hardware/system/DelayBuffer.v \
|
||||
../../../hardware/system/FFT1024_32B.v \
|
||||
../../../hardware/system/Multiply.v \
|
||||
../../../hardware/system/SdfUnit2.v \
|
||||
../../../hardware/system/SdfUnit.v \
|
||||
../../../hardware/system/Twiddle1024_32B.v \
|
||||
|
||||
vhdl_srcs = \
|
||||
../../../hardware/system/reg32.vhd \
|
||||
../../../hardware/system/avalon_slave.vhd \
|
||||
../../hardware/test_data_channel.vhd \
|
||||
../../../hardware/system/avalon_slave_transitions.vhd \
|
||||
../../../hardware/system/task.vhd \
|
||||
../../../hardware/system/hardware_task_control.vhd \
|
||||
../../../hardware/system/hardware_task.vhd \
|
||||
../../../hardware/system/float.vhd \
|
||||
../../../hardware/system/squareRoot_pipe.vhd \
|
||||
../../../hardware/system/fft_magnitude_calc.vhd \
|
||||
../../../hardware/signal_processing/fft.vhd \
|
||||
../../../hardware/system/task_fft.vhd \
|
||||
../test_utility.vhd \
|
||||
../test_avalon_slave.vhd \
|
||||
../test_hardware_task.vhd \
|
||||
../../data/add_rand.vhd \
|
||||
../../data/sine.vhd \
|
||||
../../data/fft.vhd \
|
||||
test_task_fft.vhd \
|
||||
|
||||
main = test_task_fft
|
||||
expected_data = ../../data/fft.py
|
||||
|
||||
include ../data_tests.mk
|
||||
|
||||
@@ -0,0 +1,233 @@
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
use ieee.float_pkg.all;
|
||||
|
||||
library work;
|
||||
use work.reg32.all;
|
||||
use work.avalon_slave.all;
|
||||
use work.test_utility.all;
|
||||
use work.test_avalon_slave.all;
|
||||
use work.task.all;
|
||||
use work.fft_data.all;
|
||||
use work.test_hardware_task.all;
|
||||
|
||||
library std;
|
||||
use std.env.all;
|
||||
use std.textio.all;
|
||||
|
||||
entity test_task_fft is
|
||||
end entity test_task_fft;
|
||||
|
||||
architecture test of test_task_fft is
|
||||
|
||||
procedure test_configure( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response ) is
|
||||
|
||||
variable index : integer := 0;
|
||||
variable writedata : std_logic_vector( 31 downto 0 );
|
||||
begin
|
||||
std.textio.write( std.textio.OUTPUT, " test_configure ... " );
|
||||
index := 0;
|
||||
writedata := x"08000000"; -- 2^32 / 32
|
||||
write_and_assert_config_eq( clk => clk, req => req, rsp => rsp,
|
||||
index => index, config => writedata );
|
||||
|
||||
index := 1;
|
||||
writedata := x"00000000";
|
||||
write_and_assert_config_eq( clk => clk, req => req, rsp => rsp,
|
||||
index => index, config => writedata );
|
||||
|
||||
index := 2;
|
||||
writedata := x"40800000"; -- 2 ** 2 = 4 float
|
||||
write_and_assert_config_eq( clk => clk, req => req, rsp => rsp,
|
||||
index => index, config => writedata );
|
||||
|
||||
std.textio.write( std.textio.OUTPUT, TEST_OK );
|
||||
|
||||
end procedure test_configure;
|
||||
|
||||
procedure test_execute( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
signal write : in std_logic;
|
||||
signal writedata : in std_logic_vector ) is
|
||||
|
||||
type data_array is array ( natural range <> ) of std_logic_vector( writedata'range );
|
||||
|
||||
variable expected_readdata : std_logic_vector( 31 downto 0 );
|
||||
variable index : integer := 0;
|
||||
|
||||
variable writedata_fft : integer;
|
||||
variable writedata_float : float32;
|
||||
variable writedata_real : real;
|
||||
variable expected_real : real;
|
||||
variable abs_err : real := 0.5e-1;
|
||||
variable result : data_array( 0 to work.task.STREAM_LEN - 1 );
|
||||
variable result_fft : data_array( 0 to work.task.STREAM_LEN - 1 );
|
||||
file data_file : text;
|
||||
file data_file_fft : text;
|
||||
file data_file_fft_bit_reversed : text;
|
||||
variable index_bit_reversed : std_logic_vector( 9 downto 0 );
|
||||
|
||||
begin
|
||||
std.textio.write( std.textio.OUTPUT, " test_execute ... " );
|
||||
|
||||
expected_readdata := to_std_logic_vector( TASK_IDLE, expected_readdata'length );
|
||||
assert_state_eq( clk => clk, req => req, rsp => rsp, state => expected_readdata );
|
||||
|
||||
write_start( clk => clk, req => req );
|
||||
|
||||
expected_readdata := to_std_logic_vector( TASK_RUNNING, expected_readdata'length );
|
||||
assert_state_eq( clk => clk, req => req, rsp => rsp, state => expected_readdata );
|
||||
|
||||
file_open( data_file, "data.py", write_mode );
|
||||
std.textio.write( data_file, "float_data = [" );
|
||||
|
||||
file_open( data_file_fft, "fft_out.py", write_mode );
|
||||
std.textio.write( data_file_fft, "ftt_out_data = [" );
|
||||
|
||||
while index < STREAM_LEN loop
|
||||
wait until falling_edge( clk );
|
||||
if ( write = '1' ) then
|
||||
result( index ) := writedata;
|
||||
writedata_float := to_float( result( index ) );
|
||||
writedata_real := to_real( writedata_float );
|
||||
std.textio.write( data_file, to_string( writedata_real ) & "," );
|
||||
|
||||
result_fft( index ) := writedata;
|
||||
writedata_fft := to_integer(signed(result_fft( index )));
|
||||
std.textio.write( data_file_fft, to_string( writedata_fft ) & "," );
|
||||
|
||||
index := index + 1;
|
||||
|
||||
end if;
|
||||
end loop;
|
||||
std.textio.write( data_file, "]" & LF );
|
||||
file_close( data_file );
|
||||
|
||||
std.textio.write( data_file_fft, "]" & LF );
|
||||
file_close( data_file_fft );
|
||||
|
||||
while index < STREAM_LEN loop
|
||||
writedata_float := to_float( result( index ) );
|
||||
writedata_real := to_real( writedata_float );
|
||||
expected_real := work.fft_data.expected( index );
|
||||
assert_near( writedata_real, expected_real, abs_err );
|
||||
end loop;
|
||||
|
||||
file_open( data_file_fft_bit_reversed, "fft_out_bit_reversed.py", write_mode );
|
||||
std.textio.write( data_file_fft_bit_reversed, "ftt_out_data = [" );
|
||||
|
||||
index := 0;
|
||||
index_bit_reversed := "0000000000";
|
||||
while index < STREAM_LEN loop
|
||||
index_bit_reversed := std_logic_vector(to_unsigned(index, index_bit_reversed'length));
|
||||
index_bit_reversed := index_bit_reversed(0)&index_bit_reversed(1)&index_bit_reversed(2)&index_bit_reversed(3)&index_bit_reversed(4)&index_bit_reversed(5)&index_bit_reversed(6)&index_bit_reversed(7)&index_bit_reversed(8)&index_bit_reversed(9);
|
||||
index := to_integer(unsigned(index_bit_reversed));
|
||||
|
||||
writedata_fft := to_integer(signed(result_fft( index )));
|
||||
|
||||
std.textio.write( data_file_fft_bit_reversed, to_string( writedata_fft ) & "," );
|
||||
|
||||
index_bit_reversed := index_bit_reversed(0)&index_bit_reversed(1)&index_bit_reversed(2)&index_bit_reversed(3)&index_bit_reversed(4)&index_bit_reversed(5)&index_bit_reversed(6)&index_bit_reversed(7)&index_bit_reversed(8)&index_bit_reversed(9);
|
||||
index := to_integer(unsigned(index_bit_reversed));
|
||||
|
||||
index := index + 1;
|
||||
|
||||
end loop;
|
||||
std.textio.write( data_file_fft_bit_reversed, "]" & LF );
|
||||
file_close( data_file_fft_bit_reversed );
|
||||
|
||||
std.textio.write( std.textio.OUTPUT, TEST_OK );
|
||||
end procedure test_execute;
|
||||
|
||||
signal clk : std_logic := '0';
|
||||
signal reset : std_logic := '1';
|
||||
|
||||
signal req : work.avalon_slave.Request;
|
||||
signal rsp : work.avalon_slave.Response;
|
||||
|
||||
signal signal_read : std_logic;
|
||||
signal signal_readdata : std_logic_vector( 31 downto 0 );
|
||||
signal index_output : integer range 0 to 1023;
|
||||
|
||||
type input_data_array is array ( natural range <> ) of std_logic_vector(31 downto 0);
|
||||
|
||||
constant input_data: input_data_array (0 to 1023) := (x"40daf8d9",x"400464d6",x"40707518",x"412f4d86",x"bf2c6338",x"3fe858d0",x"40a93c0d",x"411d1b42",x"40ae6f95",x"40f76d48",x"414b45bb",x"bf80c95c",x"40653088",x"40cf8814",x"404a5d41",x"40c8b99e",x"c0a2d52e",x"c097b780",x"c0618ef7",x"c0e982c7",x"c024cbd1",x"bf618a97",x"bfe51ce1",x"3fb47578",x"c11df822",x"c08594f9",x"403fd955",x"c0aa7966",x"bff13a72",x"40132fc6",x"bf2de1e2",x"4061d87f",x"c06ac864",x"bf711298",x"4011b5da",x"4110d242",x"402cc82f",x"413cdf10",x"4025bc6a",x"41356772",x"404ff73c",x"40ab30ae",x"412170aa",x"40326cc2",x"412caa7b",x"c09488ea",x"c092507c",x"c06f49b3",x"bf0d20d4",x"402ca19a",x"bff135fa",x"3fafefe8",x"c1197ab4",x"c10ca7e7",x"c0e7237f",x"c091c47c",x"c066436a",x"3d914c40",x"c0999d9d",x"bf82f570",x"c0e55fe3",x"c05520da",x"40605138",x"c021210c",x"40c78efa",x"bfd5f3be",x"3fd3d6b1",x"3fe55ef8",x"408eaf1a",x"bf99eb4a",x"400acf31",x"40ca0d76",x"c06f7ec0",x"c0156063",x"3fcbe0a0",x"4009d2a1",x"3feb3b7c",x"40f5953d",x"bfbe458a",x"4046b62c",x"c113cc05",x"c087d026",x"bfccd099",x"3f8155a6",x"c0f1209c",x"c11042a8",x"c0bf6ebc",x"3fc1136c",x"c1464c70",x"c12df84f",x"c10aa752",x"c0b06ec4",x"c08650e5",x"bfd06e2c",x"c0d2c72e",x"c0e3e57a",x"c08b3546",x"bfb0d585",x"403febfc",x"be122ec9",x"3fe57176",x"3fe53e46",x"4108cf43",x"3f01a6a4",x"403c3ee3",x"4017e4ad",x"40eb2c13",x"3ef0621c",x"40eba5ee",x"c09499f7",x"c054478c",x"bfac1b65",x"40b68a12",x"c11be620",x"c09ceffc",x"3f01c820",x"c0e2f412",x"c0a78f83",x"c0a41d0e",x"c05f2f6a",x"c0f98a04",x"c0fba274",x"c0fe9e26",x"c0a150f5",x"c07b476d",x"3e009bf0",x"c055c84d",x"bf142c8e",x"be67ec78",x"3dd2c0cc",x"3f011ca1",x"4077ccb8",x"3fc47cab",x"4107f727",x"bfd2f436",x"3f229404",x"403e75a3",x"405653d7",x"4055b80b",x"406c1a7a",x"408bf1a0",x"bf2951d8",x"3f5e1db9",x"3f0ceda0",x"bd48f1c8",x"40078de7",x"c0d40bfe",x"c047cafb",x"c02e4bc7",x"c03dd5ae",x"c0142d40",x"beadb830",x"c088264a",x"3eddd418",x"c07f2957",x"c0377cbb",x"3e6054b0",x"c0a43500",x"bfaf530d",x"404a35ab",x"c09d1b4d",x"3f137065",x"4029875f",x"40824c49",x"408786ed",x"40d59fa1",x"408f5241",x"410b56f8",x"40942720",x"4132ff7d",x"3f1748c0",x"407ed381",x"40886ce3",x"406f5b24",x"404b8482",x"4095a7c8",x"bfc0d0ee",x"c04d5c67",x"bef1981b",x"3f9b8e53",x"3f010d6c",x"40816b01",x"c03be548",x"bfe2e631",x"bf50b956",x"3fcb2630",x"c10cc7d7",x"c0ea1e79",x"c0996e64",x"bf4c0708",x"40df4d51",x"c082593a",x"3f911f18",x"40f2c5fe",x"3f240db0",x"407dd077",x"413a600e",x"beb58cb0",x"40014757",x"40b022de",x"4135f6b6",x"40a286ee",x"40c11cb7",x"410ced4a",x"bf935600",x"404d3b0a",x"41359a58",x"c09f481d",x"3da888b0",x"40ff55c1",x"bf8628b1",x"40559908",x"bfb1b61e",x"407bbeaa",x"c0a9e96e",x"c0fac5df",x"c0be2c58",x"c10fbd7b",x"c059776c",x"3ff23d0b",x"c0eef375",x"bfe29bf2",x"4021884b",x"3f07d900",x"40b22610",x"3daed460",x"4030b71f",x"40bf6a6e",x"3f9d6390",x"408a28d2",x"40a9da87",x"41306adc",x"40827670",x"40adf30d",x"40d3bb17",x"40c4c47c",x"40b053dc",x"411a898e",x"c041170a",x"3f230783",x"40b82185",x"c056f0a5",x"c0b27b9c",x"c08a913e",x"c0b1592a",x"c0ebbd8e",x"c08110fa",x"bf837a24",x"c082cffd",x"3fe6a02c",x"c0938da1",x"c03e4892",x"4015ee20",x"c04f04bf",x"bfba869f",x"be97d71c",x"408be6b0",x"beaf6864",x"4090daba",x"c089e406",x"3f9bc832",x"4128abc9",x"3f81999a",x"412b3f77",x"3fae413e",x"4092db9f",x"40ea6812",x"3fd46a6c",x"409e2e5c",x"c0696f7e",x"c018fc04",x"c07bf051",x"c0e7a797",x"c0c227ae",x"c05904cc",x"bfda9871",x"40492d22",x"c0d14fa4",x"c073a299",x"bfe46994",x"c0c18767",x"3e32b7c0",x"c1122d14",x"c140dffe",x"c12987f0",x"c1008994",x"c07640e8",x"bf0eaa08",x"c07e82be",x"bf9edaa2",x"40063aa3",x"c028afad",x"c03ef2d1",x"3f67c42c",x"405ec244",x"405c9d20",x"4040f756",x"401b9b21",x"406c6bbe",x"40543aca",x"410be00e",x"c0f35646",x"c101ed3c",x"c04273b8",x"40945b7d",x"c0ffe39e",x"c0d78e2c",x"c1123262",x"c0f7522a",x"c112c3f2",x"c154d998",x"c1537448",x"c14ae788",x"c0e56daa",x"bfee3c9e",x"c0b09aa8",x"c052c2eb",x"bf4acce8",x"c0fa6c22",x"c0a14e7e",x"c09a94ba",x"bf8d327f",x"4035c5b3",x"c03ea671",x"3f71fbc5",x"40f09f04",x"3fb6559a",x"40402833",x"40f2c9b0",x"3ffdacc4",x"40302c24",x"41118f2c",x"c0811c5a",x"3e833d44",x"40f77617",x"c0ceb437",x"c0011eb4",x"bf68a1b3",x"3f87bf94",x"c1035b72",x"c088c46d",x"3fad9ee0",x"c0eddc85",x"c11520cf",x"c0a3ae5c",x"c07f6a7e",x"406f84db",x"c0ab7840",x"40733e14",x"c06a6562",x"3ffd4321",x"bf8c24dd",x"3f927763",x"4042c5e0",x"bebc7778",x"3e71d150",x"3f1aedcc",x"4063fe9d",x"410fa150",x"3fd93bda",x"408ca422",x"409fc375",x"40b22aa6",x"40983215",x"4077de82",x"40ef5ece",x"3ff40f95",x"3ffbcd45",x"408f19d2",x"c0a83ae8",x"bfa0b156",x"bf18a1bb",x"40504818",x"c02d22cb",x"c0066d63",x"c006b74c",x"4018adb5",x"c049e8d2",x"3fd9b518",x"c112ab95",x"c03af28c",x"3f5a6b62",x"4075f720",x"c0b999c4",x"3ec39b04",x"405bb566",x"41145003",x"3e03bb30",x"c041d4aa",x"40565bb8",x"41476c6c",x"3de36dc0",x"40a020bd",x"414ce41b",x"40863b44",x"41129a5f",x"c028844a",x"c02b6540",x"c010647f",x"3feab4d4",x"41121b63",x"c0a16e58",x"bf2a96f9",x"4012eae9",x"c07973bb",x"c0b21017",x"c012342e",x"3ee9c9d8",x"c09d65e0",x"c0b6db34",x"c00e2a4a",x"bca9a3c0",xLine truncated
|
||||
signal signal_write : std_logic;
|
||||
signal signal_writedata : std_logic_vector( 31 downto 0 );
|
||||
|
||||
begin
|
||||
|
||||
dut : entity work.task_fft
|
||||
port map (
|
||||
clk => clk,
|
||||
reset => reset,
|
||||
|
||||
address => req.address,
|
||||
read => req.read,
|
||||
readdata => rsp.readdata,
|
||||
write => req.write,
|
||||
writedata => req.writedata,
|
||||
|
||||
signal_read => signal_read,
|
||||
signal_readdata => signal_readdata,
|
||||
|
||||
signal_write => signal_write,
|
||||
signal_writedata => signal_writedata
|
||||
);
|
||||
|
||||
clk <= not clk after 10 ns;
|
||||
|
||||
p_number_input_sample: process ( clk, reset ) is
|
||||
begin
|
||||
if ( reset = '1' ) then
|
||||
index_output <= 1;
|
||||
signal_readdata <= input_data(0);
|
||||
elsif ( rising_edge( clk ) ) then
|
||||
if signal_read = '1' then
|
||||
if index_output /= 1023 then
|
||||
index_output <= index_output + 1;
|
||||
end if;
|
||||
signal_readdata <= input_data(index_output);
|
||||
end if;
|
||||
end if;
|
||||
end process p_number_input_sample;
|
||||
|
||||
reset_release : process is
|
||||
begin
|
||||
wait for 435 ns;
|
||||
reset <= '0';
|
||||
wait;
|
||||
end process reset_release;
|
||||
|
||||
stimulus: process is
|
||||
variable address : std_logic_vector( 3 downto 0 );
|
||||
variable level : std_logic_vector( 31 downto 0 );
|
||||
variable readdata : std_logic_vector( 31 downto 0 );
|
||||
variable writedata : std_logic_vector( 31 downto 0 );
|
||||
variable expected_readdata : std_logic_vector( 31 downto 0 );
|
||||
begin
|
||||
std.textio.write( std.textio.OUTPUT, "--------------------------------------------------------------------------------" & LF );
|
||||
std.textio.write( std.textio.OUTPUT, "Starting test_task_fft" & LF );
|
||||
wait until falling_edge( reset );
|
||||
wait until falling_edge( clk );
|
||||
|
||||
test_configure( clk => clk, req => req, rsp => rsp );
|
||||
test_execute( clk => clk, req => req, rsp => rsp,
|
||||
|
||||
write => signal_write, writedata => signal_writedata );
|
||||
|
||||
wait until falling_edge( signal_write );
|
||||
|
||||
wait for 200 ns;
|
||||
std.textio.write( std.textio.OUTPUT, "Finished test_task_fft" & LF );
|
||||
std.textio.write( std.textio.OUTPUT, "--------------------------------------------------------------------------------" & LF );
|
||||
|
||||
std.env.finish( 0 );
|
||||
end process stimulus;
|
||||
end architecture test;
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
$ version 1.1
|
||||
/test_task_add_sine_cosine/*
|
||||
/test_task_add_sine_cosine/dut/*
|
||||
/test_task_add_sine_cosine/dut/u_add/*
|
||||
/test_task_add_sine_cosine/dut/u_add/u_float_add/*
|
||||
@@ -0,0 +1 @@
|
||||
add wave -position end sim:/test_task_fft/dut/*
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
vhdl_srcs = ../../../hardware/system/reg32.vhd \
|
||||
../../../hardware/system/avalon_slave.vhd \
|
||||
../../../hardware/system/avalon_slave_transitions.vhd \
|
||||
../../../hardware/system/task.vhd \
|
||||
../../../hardware/system/hardware_task_control.vhd \
|
||||
../../../hardware/system/data_channel_control.vhd \
|
||||
../../../hardware/system/data_sink_mux.vhd \
|
||||
../../../hardware/system/data_source_mux.vhd \
|
||||
../../../hardware/system/fifo.vhd \
|
||||
../../../hardware/system/data_channel.vhd \
|
||||
../../../hardware/signal_processing/rand.vhd \
|
||||
../../../hardware/system/task_rand.vhd \
|
||||
../test_utility.vhd \
|
||||
../test_avalon_slave.vhd \
|
||||
../test_hardware_task.vhd \
|
||||
../test_data_channel.vhd \
|
||||
../../data/rand.vhd \
|
||||
test_task_rand.vhd \
|
||||
|
||||
main = test_task_rand
|
||||
expected_data = ../../data/rand.py
|
||||
|
||||
include ../data_tests.mk
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
use ieee.float_pkg.all;
|
||||
|
||||
library work;
|
||||
use work.test_hardware_task.all;
|
||||
use work.task.all;
|
||||
use work.rand_data.all;
|
||||
use work.test_utility.all;
|
||||
use work.test_data_channel_pkg.all;
|
||||
|
||||
library std;
|
||||
use std.env.all;
|
||||
use std.textio.all;
|
||||
|
||||
entity test_task_rand is
|
||||
generic( CHECK_RESULTS : boolean; GUI_MODE : boolean := false );
|
||||
end entity test_task_rand;
|
||||
|
||||
architecture test of test_task_rand is
|
||||
|
||||
procedure test_configure( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response ) is
|
||||
|
||||
variable index : integer := 0;
|
||||
variable writedata : std_logic_vector( 31 downto 0 );
|
||||
begin
|
||||
std.textio.write( std.textio.OUTPUT, " test_configure ... " );
|
||||
|
||||
writedata := to_std_logic_vector( to_float( 1.3 ) );
|
||||
write_and_assert_config_eq( clk => clk, req => req, rsp => rsp,
|
||||
index => index, config => writedata );
|
||||
|
||||
std.textio.write( std.textio.OUTPUT, TEST_OK );
|
||||
end procedure test_configure;
|
||||
|
||||
procedure test_execute( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
signal write : in std_logic;
|
||||
signal writedata : in std_logic_vector( 31 downto 0 )) is
|
||||
|
||||
variable expected_readdata : std_logic_vector( 31 downto 0 );
|
||||
variable state : std_logic_vector( 31 downto 0 );
|
||||
variable index : integer := 0;
|
||||
|
||||
begin
|
||||
std.textio.write( std.textio.OUTPUT, " test_execute ... " );
|
||||
|
||||
expected_readdata := to_std_logic_vector( TASK_IDLE, expected_readdata'length );
|
||||
assert_state_eq( clk => clk, req => req, rsp => rsp, state => expected_readdata );
|
||||
|
||||
write_start( clk => clk, req => req );
|
||||
|
||||
expected_readdata := to_std_logic_vector( TASK_RUNNING, expected_readdata'length );
|
||||
assert_state_eq( clk => clk, req => req, rsp => rsp, state => expected_readdata );
|
||||
|
||||
while true loop
|
||||
work.test_hardware_task.read_state( clk => clk, req => req, rsp => rsp, state => state );
|
||||
if ( state = to_std_logic_vector( TASK_DONE, expected_readdata'length ) ) then
|
||||
exit;
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
std.textio.write( std.textio.OUTPUT, TEST_OK );
|
||||
end procedure test_execute;
|
||||
|
||||
signal clk : std_logic := '0';
|
||||
signal reset : std_logic := '1';
|
||||
|
||||
signal req : work.avalon_slave.Request;
|
||||
signal rsp : work.avalon_slave.Response;
|
||||
|
||||
signal data_channel_req : work.avalon_slave.Request;
|
||||
signal data_channel_rsp : work.avalon_slave.Response;
|
||||
|
||||
signal address : std_logic_vector( 3 downto 0 );
|
||||
signal read : std_logic := '0';
|
||||
signal readdata : std_logic_vector( 31 downto 0 );
|
||||
signal write : std_logic := '0';
|
||||
signal writedata : std_logic_vector( 31 downto 0 );
|
||||
|
||||
signal signal_write : std_logic;
|
||||
signal signal_writedata : std_logic_vector( 31 downto 0 );
|
||||
|
||||
signal results : work.reg32.RegArray( 0 to 1023 );
|
||||
|
||||
signal data_channel_read : std_logic;
|
||||
signal data_channel_readdata : std_logic_vector( 31 downto 0 );
|
||||
|
||||
begin
|
||||
|
||||
dut : entity work.task_rand
|
||||
port map (
|
||||
clk => clk,
|
||||
reset => reset,
|
||||
|
||||
address => req.address,
|
||||
read => req.read,
|
||||
readdata => rsp.readdata,
|
||||
write => req.write,
|
||||
writedata => req.writedata,
|
||||
|
||||
signal_write => signal_write,
|
||||
signal_writedata => signal_writedata
|
||||
);
|
||||
|
||||
u_data_channel : entity work.data_channel
|
||||
port map (
|
||||
clk => clk,
|
||||
reset => reset,
|
||||
|
||||
ctrl_address => data_channel_req.address,
|
||||
ctrl_read => data_channel_req.read,
|
||||
ctrl_readdata => data_channel_rsp.readdata,
|
||||
ctrl_write => data_channel_req.write,
|
||||
ctrl_writedata => data_channel_req.writedata,
|
||||
|
||||
hw_sink_write => signal_write,
|
||||
hw_sink_writedata => signal_writedata,
|
||||
|
||||
hw_source_read => data_channel_read,
|
||||
hw_source_readdata => data_channel_readdata
|
||||
);
|
||||
|
||||
clk <= not clk after 10 ns;
|
||||
|
||||
reset_release : process is
|
||||
begin
|
||||
wait for 35 ns;
|
||||
reset <= '0';
|
||||
wait;
|
||||
end process reset_release;
|
||||
|
||||
stimulus: process is
|
||||
constant expected : work.reg32.RegArray( 0 to 3 )
|
||||
:= ( 0 => ( others => 'U' ), 2 => ( others => 'U' ),
|
||||
others => ( others => '0' ) );
|
||||
|
||||
variable data_channel_config : std_logic_vector( 31 downto 0 ) := x"00000001";
|
||||
begin
|
||||
wait until falling_edge( reset );
|
||||
|
||||
work.test_data_channel_pkg.write_and_assert_config( clk => clk,
|
||||
req => data_channel_req,
|
||||
rsp => data_channel_rsp,
|
||||
config => data_channel_config );
|
||||
|
||||
test_configure( clk => clk, req => req, rsp => rsp );
|
||||
test_execute( clk => clk, req => req, rsp => rsp,
|
||||
write => signal_write, writedata => signal_writedata );
|
||||
|
||||
if ( CHECK_RESULTS ) then
|
||||
check_and_write_content( clk => clk,
|
||||
req => data_channel_req, rsp => data_channel_rsp,
|
||||
expected => work.rand_data.expected );
|
||||
else
|
||||
write_content( clk => clk,
|
||||
req => data_channel_req, rsp => data_channel_rsp );
|
||||
end if;
|
||||
|
||||
if ( GUI_MODE ) then
|
||||
std.env.stop;
|
||||
else
|
||||
std.env.finish;
|
||||
end if;
|
||||
end process stimulus;
|
||||
|
||||
end architecture test;
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
$ version 1.1
|
||||
/test_task_rand/*
|
||||
/test_task_rand/dut/**
|
||||
/test_task_rand/u_data_channel/**
|
||||
@@ -0,0 +1 @@
|
||||
add wave -position end sim:/test_task_rand/dut/u_rand/*
|
||||
@@ -0,0 +1,30 @@
|
||||
|
||||
vhdl_srcs = ../../../hardware/system/reg32.vhd \
|
||||
../../../hardware/system/task.vhd \
|
||||
../../../hardware/system/avalon_slave.vhd \
|
||||
../../../hardware/system/avalon_slave_transitions.vhd \
|
||||
../../../hardware/system/float.vhd \
|
||||
../../../hardware/system/hardware_task_control.vhd \
|
||||
../../../hardware/system/data_channel_control.vhd \
|
||||
../../../hardware/system/data_sink_mux.vhd \
|
||||
../../../hardware/system/data_source_mux.vhd \
|
||||
../../../hardware/system/fifo.vhd \
|
||||
../../../hardware/system/data_channel.vhd \
|
||||
../../../hardware/system/cordic_pkg.vhd \
|
||||
../../../hardware/system/cordic.vhd \
|
||||
../../../hardware/system/fixed_sine.vhd \
|
||||
../../../hardware/system/float_sine.vhd \
|
||||
../../../hardware/signal_processing/sine.vhd \
|
||||
../../../hardware/system/task_sine.vhd \
|
||||
../test_utility.vhd \
|
||||
../test_avalon_slave.vhd \
|
||||
../test_hardware_task.vhd \
|
||||
../test_data_channel.vhd \
|
||||
../../data/sine.vhd \
|
||||
test_task_sine.vhd \
|
||||
|
||||
main = test_task_sine
|
||||
expected_data = ../../data/sine.py
|
||||
|
||||
include ../data_tests.mk
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
use ieee.float_pkg.all;
|
||||
|
||||
library work;
|
||||
use work.reg32.all;
|
||||
use work.avalon_slave.all;
|
||||
use work.test_utility.all;
|
||||
use work.test_avalon_slave.all;
|
||||
use work.task.all;
|
||||
use work.sine_data.all;
|
||||
use work.test_hardware_task.all;
|
||||
use work.test_data_channel_pkg.all;
|
||||
|
||||
library std;
|
||||
use std.env.all;
|
||||
use std.textio.all;
|
||||
|
||||
entity test_task_sine is
|
||||
generic( CHECK_RESULTS : boolean; GUI_MODE : boolean := false );
|
||||
end entity test_task_sine;
|
||||
|
||||
architecture test of test_task_sine is
|
||||
|
||||
procedure test_configure( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response ) is
|
||||
|
||||
variable index : integer := 0;
|
||||
variable writedata : std_logic_vector( 31 downto 0 );
|
||||
begin
|
||||
std.textio.write( std.textio.OUTPUT, " test_configure ... " );
|
||||
index := 0;
|
||||
writedata := x"08000000"; -- 2^32 / 32
|
||||
write_and_assert_config_eq( clk => clk, req => req, rsp => rsp,
|
||||
index => index, config => writedata );
|
||||
|
||||
index := 1;
|
||||
writedata := x"00000000";
|
||||
write_and_assert_config_eq( clk => clk, req => req, rsp => rsp,
|
||||
index => index, config => writedata );
|
||||
|
||||
index := 2;
|
||||
writedata := x"40800000"; -- 2 ** 2 = 4 float
|
||||
write_and_assert_config_eq( clk => clk, req => req, rsp => rsp,
|
||||
index => index, config => writedata );
|
||||
|
||||
std.textio.write( std.textio.OUTPUT, TEST_OK );
|
||||
|
||||
end procedure test_configure;
|
||||
|
||||
signal clk : std_logic := '0';
|
||||
signal reset : std_logic := '1';
|
||||
|
||||
signal req : work.avalon_slave.Request;
|
||||
signal rsp : work.avalon_slave.Response;
|
||||
|
||||
signal data_channel_req : work.avalon_slave.Request;
|
||||
signal data_channel_rsp : work.avalon_slave.Response;
|
||||
|
||||
signal signal_write : std_logic;
|
||||
signal signal_writedata : std_logic_vector( 31 downto 0 );
|
||||
|
||||
signal data_channel_read : std_logic;
|
||||
signal data_channel_readdata : std_logic_vector( 31 downto 0 );
|
||||
|
||||
begin
|
||||
|
||||
dut : entity work.task_sine
|
||||
port map (
|
||||
clk => clk,
|
||||
reset => reset,
|
||||
|
||||
address => req.address,
|
||||
read => req.read,
|
||||
readdata => rsp.readdata,
|
||||
write => req.write,
|
||||
writedata => req.writedata,
|
||||
|
||||
signal_write => signal_write,
|
||||
signal_writedata => signal_writedata
|
||||
);
|
||||
|
||||
u_data_channel : entity work.data_channel
|
||||
port map (
|
||||
clk => clk,
|
||||
reset => reset,
|
||||
|
||||
ctrl_address => data_channel_req.address,
|
||||
ctrl_read => data_channel_req.read,
|
||||
ctrl_readdata => data_channel_rsp.readdata,
|
||||
ctrl_write => data_channel_req.write,
|
||||
ctrl_writedata => data_channel_req.writedata,
|
||||
|
||||
hw_sink_write => signal_write,
|
||||
hw_sink_writedata => signal_writedata,
|
||||
|
||||
hw_source_read => data_channel_read,
|
||||
hw_source_readdata => data_channel_readdata
|
||||
);
|
||||
|
||||
clk <= not clk after 10 ns;
|
||||
|
||||
reset_release : process
|
||||
begin
|
||||
wait for 35 ns;
|
||||
reset <= '0';
|
||||
wait;
|
||||
end process reset_release;
|
||||
|
||||
stimulus : process
|
||||
variable data_channel_config : std_logic_vector( 31 downto 0 ) := x"00000001";
|
||||
begin
|
||||
wait until falling_edge( reset );
|
||||
|
||||
work.test_data_channel_pkg.write_and_assert_config( clk => clk,
|
||||
req => data_channel_req,
|
||||
rsp => data_channel_rsp,
|
||||
config => data_channel_config );
|
||||
|
||||
test_configure( clk => clk, req => req, rsp => rsp );
|
||||
test_execute( clk => clk, req => req, rsp => rsp,
|
||||
write => signal_write, writedata => signal_writedata );
|
||||
|
||||
if ( CHECK_RESULTS ) then
|
||||
check_and_write_content( clk => clk,
|
||||
req => data_channel_req, rsp => data_channel_rsp,
|
||||
expected => work.sine_data.expected );
|
||||
else
|
||||
write_content( clk => clk,
|
||||
req => data_channel_req, rsp => data_channel_rsp );
|
||||
end if;
|
||||
|
||||
if ( GUI_MODE ) then
|
||||
std.env.stop;
|
||||
else
|
||||
std.env.finish;
|
||||
end if;
|
||||
end process stimulus;
|
||||
end architecture test;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
$ version 1.1
|
||||
/test_task_sine/*
|
||||
/test_task_sine/dut/*
|
||||
/test_task_sine/dut/u_sine/*
|
||||
/test_task_sine/dut/u_sine/u_float_sine/*
|
||||
/test_task_sine/dut/u_sine/u_float_sine/u_fixed_sine/*
|
||||
/test_task_sine/u_data_channel/**
|
||||
@@ -0,0 +1,24 @@
|
||||
onerror {resume}
|
||||
quietly WaveActivateNextPane {} 0
|
||||
add wave -noupdate /test_task_sine/*
|
||||
add wave -noupdate /test_task_sine/dut/*
|
||||
add wave -noupdate /test_task_sine/dut/u_sine/*
|
||||
add wave -noupdate /test_task_sine/dut/u_sine/u_float_sine/*
|
||||
add wave -noupdate /test_task_sine/dut/u_sine/u_float_sine/u_fixed_sine/*
|
||||
add wave -noupdate /test_task_sine/u_data_channel/**
|
||||
TreeUpdate [SetDefaultTree]
|
||||
quietly wave cursor active 1
|
||||
configure wave -namecolwidth 150
|
||||
configure wave -valuecolwidth 100
|
||||
configure wave -justifyvalue left
|
||||
configure wave -signalnamewidth 0
|
||||
configure wave -snapdistance 10
|
||||
configure wave -datasetprefix 0
|
||||
configure wave -rowmargin 4
|
||||
configure wave -childrowmargin 2
|
||||
configure wave -gridoffset 0
|
||||
configure wave -gridperiod 1
|
||||
configure wave -griddelta 40
|
||||
configure wave -timeline 0
|
||||
configure wave -timelineunits ns
|
||||
update
|
||||
@@ -0,0 +1,89 @@
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
|
||||
library work;
|
||||
use work.reg32.all;
|
||||
use work.avalon_slave.all;
|
||||
|
||||
package test_avalon_slave is
|
||||
|
||||
procedure read( signal clk : in std_logic;
|
||||
variable address : in std_logic_vector;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
variable data : out std_logic_vector );
|
||||
|
||||
procedure assert_readdata_eq( signal clk : in std_logic;
|
||||
variable address : in std_logic_vector;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
variable expected : in std_logic_vector;
|
||||
constant message : in string );
|
||||
|
||||
procedure write( signal clk : in std_logic;
|
||||
variable address : in std_logic_vector;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
variable data : in std_logic_vector );
|
||||
|
||||
end package test_avalon_slave;
|
||||
|
||||
package body test_avalon_slave is
|
||||
|
||||
procedure read( signal clk : in std_logic;
|
||||
variable address : in std_logic_vector;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
variable data : out std_logic_vector ) is
|
||||
begin
|
||||
|
||||
req.read <= '1';
|
||||
req.write <= '0';
|
||||
req.address <= address;
|
||||
wait until falling_edge( clk );
|
||||
wait until falling_edge( clk );
|
||||
req.read <= '0';
|
||||
data := rsp.readdata;
|
||||
wait until falling_edge( clk );
|
||||
|
||||
end procedure read;
|
||||
|
||||
procedure assert_readdata_eq( signal clk : in std_logic;
|
||||
variable address : in std_logic_vector;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
variable expected :in std_logic_vector;
|
||||
constant message : in string ) is
|
||||
|
||||
variable readdata : std_logic_vector( expected'range );
|
||||
begin
|
||||
|
||||
read( clk => clk,
|
||||
address => address,
|
||||
req => req,
|
||||
rsp => rsp,
|
||||
data => readdata );
|
||||
|
||||
assert( readdata = expected )
|
||||
report message & LF &
|
||||
" expected: " & to_string( expected ) & LF &
|
||||
" actual: " & to_string( readdata ) & LF
|
||||
severity error;
|
||||
end procedure assert_readdata_eq;
|
||||
|
||||
procedure write( signal clk : in std_logic;
|
||||
variable address : in std_logic_vector;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
variable data : in std_logic_vector ) is
|
||||
begin
|
||||
|
||||
req.read <= '0';
|
||||
req.write <= '1';
|
||||
req.address <= address;
|
||||
req.writedata <= data;
|
||||
wait until falling_edge( clk );
|
||||
req.write <= '0';
|
||||
|
||||
end procedure write;
|
||||
|
||||
end package body test_avalon_slave;
|
||||
@@ -0,0 +1,436 @@
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
use ieee.float_pkg.all;
|
||||
|
||||
library work;
|
||||
use work.avalon_slave.all;
|
||||
use work.test_utility.all;
|
||||
|
||||
library std;
|
||||
use std.textio.all;
|
||||
|
||||
package test_data_channel_pkg is
|
||||
procedure is_empty( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
variable res : out boolean );
|
||||
|
||||
procedure assert_empty( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response );
|
||||
|
||||
procedure assert_not_empty( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response );
|
||||
|
||||
procedure assert_full( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response );
|
||||
|
||||
procedure assert_not_full( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response );
|
||||
|
||||
procedure assert_level( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
variable level : in std_logic_vector );
|
||||
|
||||
procedure assert_config( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
variable config : in std_logic_vector );
|
||||
|
||||
procedure write_config( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
variable config : in std_logic_vector );
|
||||
|
||||
procedure write_and_assert_config( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
variable config : in std_logic_vector );
|
||||
|
||||
procedure write_clear( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request );
|
||||
|
||||
procedure write_sw_sink( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
variable data : in std_logic_vector );
|
||||
|
||||
procedure read_sw_source( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
variable data : out std_logic_vector );
|
||||
|
||||
procedure assert_read_sw_source_eq( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
variable expected : in std_logic_vector );
|
||||
|
||||
procedure write_hw_sink( signal clk : in std_logic;
|
||||
signal write : out std_logic;
|
||||
signal writedata : out std_logic_vector;
|
||||
variable data : in std_logic_vector );
|
||||
|
||||
procedure assert_read_hw_source_eq( signal clk : in std_logic;
|
||||
signal read : out std_logic;
|
||||
signal readdata : in std_logic_vector;
|
||||
variable expected : in std_logic_vector );
|
||||
|
||||
procedure write_content( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response );
|
||||
|
||||
procedure check_and_write_content( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
constant expected : real_array );
|
||||
|
||||
end package test_data_channel_pkg;
|
||||
|
||||
package body test_data_channel_pkg is
|
||||
procedure is_empty( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
variable res : out boolean ) is
|
||||
|
||||
variable address : std_logic_vector( 3 downto 0 );
|
||||
variable data : std_logic_vector( 31 downto 0 );
|
||||
constant EMPTY : std_logic_vector( 31 downto 0 ) := x"00000001";
|
||||
begin
|
||||
wait until falling_edge( clk );
|
||||
address := std_logic_vector( to_unsigned( 1, address'length ) );
|
||||
|
||||
work.test_avalon_slave.read( clk => clk,
|
||||
address => address,
|
||||
req => req,
|
||||
rsp => rsp,
|
||||
data => data );
|
||||
|
||||
res := data = EMPTY;
|
||||
end procedure is_empty;
|
||||
|
||||
procedure assert_empty( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response ) is
|
||||
|
||||
variable address : std_logic_vector( 3 downto 0 );
|
||||
variable expected_readdata : std_logic_vector( 31 downto 0 ) := x"00000001";
|
||||
begin
|
||||
wait until falling_edge( clk );
|
||||
address := std_logic_vector( to_unsigned( 1, address'length ) );
|
||||
expected_readdata := x"00000001";
|
||||
|
||||
work.test_avalon_slave.assert_readdata_eq( clk => clk,
|
||||
address => address,
|
||||
req => req,
|
||||
rsp => rsp,
|
||||
expected => expected_readdata,
|
||||
message => TEST_FAIL & " assert_empty" );
|
||||
end procedure assert_empty;
|
||||
|
||||
procedure assert_not_empty( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response ) is
|
||||
|
||||
variable address : std_logic_vector( 3 downto 0 );
|
||||
variable expected_readdata : std_logic_vector( 31 downto 0 ) := x"00000001";
|
||||
begin
|
||||
wait until falling_edge( clk );
|
||||
address := std_logic_vector( to_unsigned( 1, address'length ) );
|
||||
expected_readdata := x"00000000";
|
||||
|
||||
work.test_avalon_slave.assert_readdata_eq( clk => clk,
|
||||
address => address,
|
||||
req => req,
|
||||
rsp => rsp,
|
||||
expected => expected_readdata,
|
||||
message => TEST_FAIL & " assert_not_empty" );
|
||||
end procedure assert_not_empty;
|
||||
|
||||
procedure assert_full( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response ) is
|
||||
|
||||
variable address : std_logic_vector( 3 downto 0 );
|
||||
variable expected_readdata : std_logic_vector( 31 downto 0 ) := x"00000001";
|
||||
begin
|
||||
wait until falling_edge( clk );
|
||||
address := std_logic_vector( to_unsigned( 2, address'length ) );
|
||||
expected_readdata := x"00000001";
|
||||
|
||||
work.test_avalon_slave.assert_readdata_eq( clk => clk,
|
||||
address => address,
|
||||
req => req,
|
||||
rsp => rsp,
|
||||
expected => expected_readdata,
|
||||
message => TEST_FAIL & " assert_full" );
|
||||
end procedure assert_full;
|
||||
|
||||
procedure assert_not_full( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response ) is
|
||||
|
||||
variable address : std_logic_vector( 3 downto 0 );
|
||||
variable expected_readdata : std_logic_vector( 31 downto 0 ) := x"00000001";
|
||||
begin
|
||||
wait until falling_edge( clk );
|
||||
address := std_logic_vector( to_unsigned( 2, address'length ) );
|
||||
expected_readdata := x"00000000";
|
||||
|
||||
work.test_avalon_slave.assert_readdata_eq( clk => clk,
|
||||
address => address,
|
||||
req => req,
|
||||
rsp => rsp,
|
||||
expected => expected_readdata,
|
||||
message => TEST_FAIL & " assert_not_full" );
|
||||
end procedure assert_not_full;
|
||||
|
||||
procedure assert_level( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
variable level : in std_logic_vector ) is
|
||||
|
||||
variable address : std_logic_vector( 3 downto 0 );
|
||||
begin
|
||||
wait until falling_edge( clk );
|
||||
address := std_logic_vector( to_unsigned( 3, address'length ) );
|
||||
|
||||
work.test_avalon_slave.assert_readdata_eq( clk => clk,
|
||||
address => address,
|
||||
req => req,
|
||||
rsp => rsp,
|
||||
expected => level,
|
||||
message => TEST_FAIL & " assert_level" );
|
||||
end procedure assert_level;
|
||||
|
||||
procedure assert_config( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
variable config : in std_logic_vector ) is
|
||||
|
||||
variable address : std_logic_vector( 3 downto 0 );
|
||||
begin
|
||||
wait until falling_edge( clk );
|
||||
address := std_logic_vector( to_unsigned( 0, address'length ) );
|
||||
|
||||
work.test_avalon_slave.assert_readdata_eq( clk => clk,
|
||||
address => address,
|
||||
req => req,
|
||||
rsp => rsp,
|
||||
expected => config,
|
||||
message => TEST_FAIL & " assert_config" );
|
||||
end procedure assert_config;
|
||||
|
||||
procedure write_config( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
variable config : in std_logic_vector ) is
|
||||
|
||||
variable address : std_logic_vector( 3 downto 0 );
|
||||
begin
|
||||
wait until falling_edge( clk );
|
||||
address := std_logic_vector( to_unsigned( 0, address'length ) );
|
||||
|
||||
work.test_avalon_slave.write( clk => clk,
|
||||
address => address,
|
||||
req => req,
|
||||
data => config );
|
||||
end procedure write_config;
|
||||
|
||||
procedure write_and_assert_config( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
variable config : in std_logic_vector ) is
|
||||
|
||||
variable address : std_logic_vector( 3 downto 0 );
|
||||
begin
|
||||
write_config( clk => clk, req => req, config => config );
|
||||
assert_config( clk => clk, req => req, rsp => rsp, config => config );
|
||||
end procedure write_and_assert_config;
|
||||
|
||||
procedure write_clear( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request ) is
|
||||
|
||||
variable address : std_logic_vector( 3 downto 0 );
|
||||
variable clear : std_logic_vector( 31 downto 0 ) := x"00000001";
|
||||
begin
|
||||
wait until falling_edge( clk );
|
||||
address := std_logic_vector( to_unsigned( 6, address'length ) );
|
||||
|
||||
work.test_avalon_slave.write( clk => clk,
|
||||
address => address,
|
||||
req => req,
|
||||
data => clear );
|
||||
end procedure write_clear;
|
||||
|
||||
procedure write_sw_sink( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
variable data : in std_logic_vector ) is
|
||||
|
||||
variable address : std_logic_vector( 3 downto 0 );
|
||||
begin
|
||||
wait until falling_edge( clk );
|
||||
address := std_logic_vector( to_unsigned( 4, address'length ) );
|
||||
|
||||
work.test_avalon_slave.write( clk => clk,
|
||||
address => address,
|
||||
req => req,
|
||||
data => data );
|
||||
end procedure write_sw_sink;
|
||||
|
||||
procedure read_sw_source( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
variable data : out std_logic_vector ) is
|
||||
|
||||
variable address : std_logic_vector( 3 downto 0 );
|
||||
begin
|
||||
wait until falling_edge( clk );
|
||||
address := std_logic_vector( to_unsigned( 5, address'length ) );
|
||||
|
||||
work.test_avalon_slave.read( clk => clk,
|
||||
address => address,
|
||||
req => req,
|
||||
rsp => rsp,
|
||||
data => data );
|
||||
end procedure read_sw_source;
|
||||
|
||||
procedure assert_read_sw_source_eq( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
variable expected : in std_logic_vector ) is
|
||||
|
||||
variable address : std_logic_vector( 3 downto 0 );
|
||||
begin
|
||||
wait until falling_edge( clk );
|
||||
address := std_logic_vector( to_unsigned( 5, address'length ) );
|
||||
|
||||
work.test_avalon_slave.assert_readdata_eq( clk => clk,
|
||||
address => address,
|
||||
req => req,
|
||||
rsp => rsp,
|
||||
expected => expected,
|
||||
message => TEST_FAIL & " assert_readdata_eq" );
|
||||
end procedure assert_read_sw_source_eq;
|
||||
|
||||
procedure write_hw_sink( signal clk : in std_logic;
|
||||
signal write : out std_logic;
|
||||
signal writedata : out std_logic_vector;
|
||||
variable data : in std_logic_vector ) is
|
||||
begin
|
||||
|
||||
wait until falling_edge( clk );
|
||||
write <= '1';
|
||||
writedata <= data;
|
||||
wait until falling_edge( clk );
|
||||
write <= '0';
|
||||
|
||||
end procedure write_hw_sink;
|
||||
|
||||
procedure assert_read_hw_source_eq( signal clk : in std_logic;
|
||||
signal read : out std_logic;
|
||||
signal readdata : in std_logic_vector;
|
||||
variable expected : in std_logic_vector ) is
|
||||
begin
|
||||
|
||||
wait until falling_edge( clk );
|
||||
assert( readdata = expected )
|
||||
report TEST_FAIL & " assert_read_hw_source_eq" & LF &
|
||||
" expected: " & to_string( expected ) & LF &
|
||||
" actual: " & to_string( readdata ) & LF
|
||||
severity error;
|
||||
wait until falling_edge( clk );
|
||||
read <= '1';
|
||||
wait until falling_edge( clk );
|
||||
read <= '0';
|
||||
|
||||
end procedure assert_read_hw_source_eq;
|
||||
|
||||
procedure write_content( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response ) is
|
||||
|
||||
variable index : integer := 0;
|
||||
variable empty : boolean;
|
||||
variable value : std_logic_vector( 31 downto 0 );
|
||||
variable float_value : float32;
|
||||
variable real_value : real;
|
||||
file data_file : text;
|
||||
begin
|
||||
std.textio.write( std.textio.OUTPUT, " write_content ... " );
|
||||
|
||||
file_open( data_file, "data.py", write_mode );
|
||||
std.textio.write( data_file, "float_data = [" );
|
||||
|
||||
while true loop
|
||||
is_empty( clk => clk, req => req, rsp => rsp, res => empty );
|
||||
if ( empty ) then
|
||||
exit;
|
||||
end if;
|
||||
read_sw_source( clk => clk, req => req, rsp => rsp,
|
||||
data => value );
|
||||
float_value := to_float( value );
|
||||
real_value := to_real( float_value );
|
||||
std.textio.write( data_file, to_string( real_value ) & "," );
|
||||
index := index + 1;
|
||||
end loop;
|
||||
|
||||
while index < 1024 loop
|
||||
std.textio.write( data_file, "0.0 ," );
|
||||
index := index + 1;
|
||||
end loop;
|
||||
|
||||
std.textio.write( data_file, "]" & LF );
|
||||
file_close( data_file );
|
||||
|
||||
std.textio.write( std.textio.OUTPUT, TEST_OK );
|
||||
end procedure write_content;
|
||||
|
||||
procedure check_and_write_content( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
constant expected : real_array ) is
|
||||
|
||||
variable expected_readdata : std_logic_vector( 31 downto 0 );
|
||||
variable index : integer := 0;
|
||||
variable empty : boolean;
|
||||
variable value : std_logic_vector( 31 downto 0 );
|
||||
variable float_value : float32;
|
||||
variable real_value : real;
|
||||
variable expected_value : real;
|
||||
variable abs_err : real := 0.5e-1;
|
||||
file data_file : text;
|
||||
begin
|
||||
std.textio.write( std.textio.OUTPUT, " check_and_write_content ... " );
|
||||
|
||||
assert_full( clk => clk, req => req, rsp => rsp );
|
||||
|
||||
expected_readdata := std_logic_vector( to_unsigned( 0, expected_readdata'length ) );
|
||||
assert_level( clk => clk, req => req, rsp => rsp,
|
||||
level => expected_readdata );
|
||||
|
||||
file_open( data_file, "data.py", write_mode );
|
||||
std.textio.write( data_file, "float_data = [" );
|
||||
|
||||
while true loop
|
||||
is_empty( clk => clk, req => req, rsp => rsp, res => empty );
|
||||
if ( empty ) then
|
||||
exit;
|
||||
end if;
|
||||
read_sw_source( clk => clk, req => req, rsp => rsp,
|
||||
data => value );
|
||||
float_value := to_float( value );
|
||||
real_value := to_real( float_value );
|
||||
std.textio.write( data_file, to_string( real_value ) & "," );
|
||||
expected_value := expected( index );
|
||||
assert_element_near( real_value, expected_value, abs_err, index );
|
||||
index := index + 1;
|
||||
end loop;
|
||||
|
||||
std.textio.write( data_file, "]" & LF );
|
||||
file_close( data_file );
|
||||
|
||||
std.textio.write( std.textio.OUTPUT, TEST_OK );
|
||||
end procedure check_and_write_content;
|
||||
end package body test_data_channel_pkg;
|
||||
@@ -0,0 +1,217 @@
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
|
||||
library work;
|
||||
use work.reg32.all;
|
||||
use work.avalon_slave.all;
|
||||
use work.test_utility.all;
|
||||
use work.test_avalon_slave.all;
|
||||
use work.task.all;
|
||||
|
||||
package test_hardware_task is
|
||||
|
||||
procedure read_state( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
variable state : out std_logic_vector );
|
||||
|
||||
procedure assert_state_eq( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
variable state : std_logic_vector );
|
||||
|
||||
procedure assert_cycle_count_eq( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
variable cycle_count : std_logic_vector );
|
||||
|
||||
procedure write_start( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request );
|
||||
|
||||
procedure write_config( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
variable index : in integer;
|
||||
variable config : in std_logic_vector );
|
||||
|
||||
procedure assert_config_eq( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
variable index : in integer;
|
||||
variable config : in std_logic_vector );
|
||||
|
||||
procedure write_and_assert_config_eq( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
variable index : in integer;
|
||||
variable config : in std_logic_vector );
|
||||
|
||||
procedure assert_output_steam_data_eq( signal clk : in std_logic;
|
||||
signal write : std_logic;
|
||||
signal writedata : std_logic_vector;
|
||||
signal expected : work.reg32.RegArray );
|
||||
|
||||
procedure test_execute( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
signal write : in std_logic;
|
||||
signal writedata : in std_logic_vector );
|
||||
|
||||
end package test_hardware_task;
|
||||
|
||||
package body test_hardware_task is
|
||||
|
||||
procedure read_state( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
variable state : out std_logic_vector ) is
|
||||
|
||||
variable address : std_logic_vector( 3 downto 0 );
|
||||
begin
|
||||
wait until falling_edge( clk );
|
||||
address := std_logic_vector( to_unsigned( 1, address'length ) );
|
||||
|
||||
work.test_avalon_slave.read( clk => clk,
|
||||
address => address,
|
||||
req => req,
|
||||
rsp => rsp,
|
||||
data => state );
|
||||
end procedure read_state;
|
||||
|
||||
procedure assert_state_eq( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
variable state : std_logic_vector ) is
|
||||
|
||||
variable address : std_logic_vector( 3 downto 0 );
|
||||
begin
|
||||
wait until falling_edge( clk );
|
||||
address := std_logic_vector( to_unsigned( 1, address'length ) );
|
||||
|
||||
work.test_avalon_slave.assert_readdata_eq( clk => clk,
|
||||
address => address,
|
||||
req => req,
|
||||
rsp => rsp,
|
||||
expected => state,
|
||||
message => TEST_FAIL & " assert_state_eq" );
|
||||
end procedure assert_state_eq;
|
||||
|
||||
procedure assert_cycle_count_eq( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
variable cycle_count : std_logic_vector ) is
|
||||
|
||||
variable address : std_logic_vector( 3 downto 0 );
|
||||
begin
|
||||
wait until falling_edge( clk );
|
||||
address := std_logic_vector( to_unsigned( 2, address'length ) );
|
||||
|
||||
work.test_avalon_slave.assert_readdata_eq( clk => clk,
|
||||
address => address,
|
||||
req => req,
|
||||
rsp => rsp,
|
||||
expected => cycle_count,
|
||||
message => TEST_FAIL & " assert_cycle_count_eq" );
|
||||
end procedure assert_cycle_count_eq;
|
||||
|
||||
procedure write_start( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request ) is
|
||||
|
||||
variable address : std_logic_vector( 3 downto 0 );
|
||||
variable start : std_logic_vector( 31 downto 0 ) := ( others => '0' );
|
||||
begin
|
||||
wait until falling_edge( clk );
|
||||
address := std_logic_vector( to_unsigned( 0, address'length ) );
|
||||
|
||||
work.test_avalon_slave.write( clk => clk,
|
||||
address => address,
|
||||
req => req,
|
||||
data => START );
|
||||
|
||||
end procedure write_start;
|
||||
|
||||
procedure write_config( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
variable index : in integer;
|
||||
variable config : in std_logic_vector ) is
|
||||
|
||||
variable address : std_logic_vector( 3 downto 0 );
|
||||
begin
|
||||
wait until falling_edge( clk );
|
||||
address := std_logic_vector( to_unsigned( 3 + index, address'length ) );
|
||||
|
||||
work.test_avalon_slave.write( clk => clk,
|
||||
address => address,
|
||||
req => req,
|
||||
data => config );
|
||||
end procedure write_config;
|
||||
|
||||
procedure assert_config_eq( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
variable index : in integer;
|
||||
variable config : in std_logic_vector ) is
|
||||
|
||||
variable address : std_logic_vector( 3 downto 0 );
|
||||
begin
|
||||
wait until falling_edge( clk );
|
||||
address := std_logic_vector( to_unsigned( 3 + index, address'length ) );
|
||||
|
||||
work.test_avalon_slave.assert_readdata_eq( clk => clk,
|
||||
address => address,
|
||||
req => req,
|
||||
rsp => rsp,
|
||||
expected => config,
|
||||
message => TEST_FAIL & " assert_config_eq" );
|
||||
end procedure assert_config_eq;
|
||||
|
||||
procedure write_and_assert_config_eq( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
variable index : in integer;
|
||||
variable config : in std_logic_vector ) is
|
||||
|
||||
variable address : std_logic_vector( 3 downto 0 );
|
||||
begin
|
||||
write_config( clk => clk, req => req, index => index, config => config );
|
||||
assert_config_eq( clk => clk, req => req, rsp => rsp, index => index, config => config );
|
||||
end procedure write_and_assert_config_eq;
|
||||
|
||||
procedure assert_output_steam_data_eq( signal clk : in std_logic;
|
||||
signal write : std_logic;
|
||||
signal writedata : std_logic_vector;
|
||||
signal expected : work.reg32.RegArray ) is
|
||||
begin
|
||||
end procedure assert_output_steam_data_eq;
|
||||
|
||||
procedure test_execute( signal clk : in std_logic;
|
||||
signal req : out work.avalon_slave.Request;
|
||||
signal rsp : in work.avalon_slave.Response;
|
||||
signal write : in std_logic;
|
||||
signal writedata : in std_logic_vector ) is
|
||||
|
||||
variable expected_readdata : std_logic_vector( 31 downto 0 );
|
||||
variable state : std_logic_vector( 31 downto 0 );
|
||||
variable index : integer := 0;
|
||||
begin
|
||||
std.textio.write( std.textio.OUTPUT, " test_execute ... " );
|
||||
|
||||
expected_readdata := to_std_logic_vector( TASK_IDLE, expected_readdata'length );
|
||||
assert_state_eq( clk => clk, req => req, rsp => rsp, state => expected_readdata );
|
||||
|
||||
write_start( clk => clk, req => req );
|
||||
|
||||
expected_readdata := to_std_logic_vector( TASK_RUNNING, expected_readdata'length );
|
||||
assert_state_eq( clk => clk, req => req, rsp => rsp, state => expected_readdata );
|
||||
|
||||
while true loop
|
||||
work.test_hardware_task.read_state( clk => clk, req => req, rsp => rsp, state => state );
|
||||
if ( state = to_std_logic_vector( TASK_DONE, expected_readdata'length ) ) then
|
||||
exit;
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
std.textio.write( std.textio.OUTPUT, TEST_OK );
|
||||
end procedure test_execute;
|
||||
end package body test_hardware_task;
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
use ieee.float_pkg.all;
|
||||
|
||||
library std;
|
||||
use std.textio.all;
|
||||
|
||||
package test_utility is
|
||||
constant TEST_FAIL : string := "[ FAIL ]";
|
||||
constant TEST_OK : string := "[ OK ]" & LF;
|
||||
|
||||
type real_array is array ( natural range <> ) of real;
|
||||
|
||||
procedure assert_eq( variable a : in std_logic_vector; variable b : in std_logic_vector );
|
||||
|
||||
procedure assert_near( variable a : in real;
|
||||
variable b : in real;
|
||||
variable abs_err : in real );
|
||||
|
||||
procedure assert_element_near( variable a : in real;
|
||||
variable b : in real;
|
||||
variable abs_err : in real;
|
||||
variable index : in integer );
|
||||
|
||||
end package test_utility;
|
||||
|
||||
package body test_utility is
|
||||
|
||||
procedure assert_eq( variable a : in std_logic_vector; variable b : in std_logic_vector ) is
|
||||
begin
|
||||
|
||||
assert( a = b )
|
||||
report TEST_FAIL & "assert_eq" & LF &
|
||||
" a: " & to_string( a ) & LF &
|
||||
" b: " & to_string( b ) & LF
|
||||
severity error;
|
||||
end procedure assert_eq;
|
||||
|
||||
procedure assert_near( variable a : in real;
|
||||
variable b : in real;
|
||||
variable abs_err : in real ) is
|
||||
variable abs_diff : real;
|
||||
begin
|
||||
abs_diff := abs( a - b );
|
||||
assert( abs_diff <= abs_err )
|
||||
report TEST_FAIL & "assert_near" & LF &
|
||||
" a: " & to_string( a ) & LF &
|
||||
" b: " & to_string( b ) & LF &
|
||||
" " & to_string( abs_diff ) & " > " & to_string( abs_err ) & LF
|
||||
severity error;
|
||||
end procedure assert_near;
|
||||
|
||||
procedure assert_element_near( variable a : in real;
|
||||
variable b : in real;
|
||||
variable abs_err : in real;
|
||||
variable index : in integer ) is
|
||||
variable abs_diff : real;
|
||||
begin
|
||||
abs_diff := abs( a - b );
|
||||
assert( abs_diff <= abs_err )
|
||||
report TEST_FAIL & "assert_element_near" & LF &
|
||||
" element: " & integer'image( index ) & LF &
|
||||
" a: " & to_string( a ) & LF &
|
||||
" b: " & to_string( b ) & LF &
|
||||
" " & to_string( abs_diff ) & " > " & to_string( abs_err ) & LF
|
||||
severity error;
|
||||
end procedure assert_element_near;
|
||||
|
||||
end package body test_utility;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
ghdl_version = $(shell ghdl --version 2> /dev/null)
|
||||
vsim_version = $(shell vsim -version 2> /dev/null)
|
||||
|
||||
# in case verilog is part of the build a verilog capable simulator is required
|
||||
ifdef verilog_srcs
|
||||
ifneq (${vsim_version},)
|
||||
include ../questa-sim.mk
|
||||
else
|
||||
$(error No HDL simulation tool found for verilog!)
|
||||
endif
|
||||
else
|
||||
ifneq (${vsim_version},)
|
||||
include ../questa-sim.mk
|
||||
else
|
||||
ifneq (${ghdl_version},)
|
||||
include ../ghdl.mk
|
||||
else
|
||||
$(error No HDL simulation tool found!)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
Reference in new issue
Block a user