From e846e603febb5ace4092fa4fe9a11141e1b36465 Mon Sep 17 00:00:00 2001 From: 1138-4EB <1138-4EB@users.noreply.github.com> Date: Tue, 26 Nov 2019 09:30:38 +0100 Subject: [PATCH] use integer_array_t instead of array_t --- examples/vhdl/array/run.py | 10 ++-- examples/vhdl/array/src/test/tb_sobel_x.vhd | 59 +++++++++---------- examples/vhdl/array_axis_vcs/run.py | 11 +--- .../array_axis_vcs/src/test/tb_axis_loop.vhd | 30 ++++------ 4 files changed, 50 insertions(+), 60 deletions(-) diff --git a/examples/vhdl/array/run.py b/examples/vhdl/array/run.py index 4f33d09cb9..f9c2ebad48 100644 --- a/examples/vhdl/array/run.py +++ b/examples/vhdl/array/run.py @@ -8,9 +8,9 @@ Array ----- -Demonstrates the ``array_t`` data type of ``array_pkg.vhd`` which -can be used to handle dynamically sized 1D, 2D and 3D data as well -as storing and loading it from csv and raw files. +Demonstrates the ``integer_array_t`` data type, which can be used to +handle dynamically sized 1D, 2D and 3D data as well as storing and +loading it from csv and raw files. """ from os.path import join, dirname @@ -20,7 +20,6 @@ vu = VUnit.from_argv() vu.add_osvvm() -vu.add_array_util() src_path = join(dirname(__file__), "src") @@ -28,4 +27,7 @@ [join(src_path, "*.vhd"), join(src_path, "test", "*.vhd")] ) +vu.set_compile_option("ghdl.flags", ["-frelaxed"]) +vu.set_sim_option("ghdl.elab_flags", ["-frelaxed"]) + vu.main() diff --git a/examples/vhdl/array/src/test/tb_sobel_x.vhd b/examples/vhdl/array/src/test/tb_sobel_x.vhd index 08e8edb7c9..087b0abb93 100644 --- a/examples/vhdl/array/src/test/tb_sobel_x.vhd +++ b/examples/vhdl/array/src/test/tb_sobel_x.vhd @@ -10,8 +10,6 @@ use ieee.numeric_std.all; library vunit_lib; context vunit_lib.vunit_context; -use vunit_lib.array_pkg.all; - library osvvm; use osvvm.RandomPkg.all; @@ -31,25 +29,24 @@ architecture tb of tb_sobel_x is signal output_tlast : std_logic; signal output_tdata : signed(input_tdata'length downto 0); - shared variable image : array_t; - shared variable reference_image : array_t; + shared variable image, reference_image : integer_array_t; signal start, data_check_done, stimuli_done : boolean := false; begin main : process - procedure sobel_x(variable image : inout array_t; - variable result : inout array_t) is + procedure sobel_x(variable image : inout integer_array_t; + variable result : inout integer_array_t) is begin - result.init_2d(width => image.width, - height => image.height, - bit_width => image.bit_width+1, + result := new_2d(width => width(image), + height => height(image), + bit_width => bit_width(image)+1, is_signed => true); - for y in 0 to image.height-1 loop - for x in 0 to image.width-1 loop - result.set(x => x, y => y, - value => (image.get(minimum(x+1, image.width-1),y) - - image.get(maximum(x-1, 0), y))); + for y in 0 to height(image)-1 loop + for x in 0 to width(image)-1 loop + set(result, x => x, y => y, + value => (get(image, minimum(x+1, width(image)-1),y) - + get(image, maximum(x-1, 0), y))); end loop; end loop; @@ -57,10 +54,10 @@ begin variable rnd : RandomPType; - procedure randomize(variable arr : inout array_t) is + procedure randomize(variable arr : inout integer_array_t) is begin for idx in 0 to arr.length-1 loop - arr.set(idx, value => rnd.RandInt(arr.lower_limit, arr.upper_limit)); + set(arr, idx, value => rnd.RandInt(arr.lower_limit, arr.upper_limit)); end loop; end procedure; @@ -78,7 +75,7 @@ begin procedure test_random_image(width, height : natural) is begin - image.init_2d(width => width, height => height, + image := new_2d(width => width, height => height, bit_width => input_tdata'length, is_signed => false); randomize(image); @@ -96,8 +93,8 @@ begin test_random_image(16, 1); test_random_image(1, 1); elsif run("test_input_file_against_output_file") then - image.load_csv(tb_path & "input.csv"); - reference_image.load_csv(tb_path & "output.csv"); + image := load_csv(tb_path & "input.csv"); + reference_image := load_csv(tb_path & "output.csv"); run_test; end if; end loop; @@ -111,19 +108,19 @@ begin stimuli_done <= false; report ("Sending image of size " & - to_string(image.width) & "x" & - to_string(image.height)); + to_string(width(image)) & "x" & + to_string(height(image))); - for y in 0 to image.height-1 loop - for x in 0 to image.width-1 loop + for y in 0 to height(image)-1 loop + for x in 0 to width(image)-1 loop wait until rising_edge(clk); input_tvalid <= '1'; - if x = image.width-1 then + if x = width(image)-1 then input_tlast <= '1'; else input_tlast <= '0'; end if; - input_tdata <= to_unsigned(image.get(x,y), input_tdata'length); + input_tdata <= to_unsigned(get(image,x,y), input_tdata'length); end loop; end loop; @@ -137,17 +134,17 @@ begin begin wait until start and rising_edge(clk); data_check_done <= false; - for y in 0 to reference_image.height-1 loop - for x in 0 to reference_image.width-1 loop + for y in 0 to height(reference_image)-1 loop + for x in 0 to width(reference_image)-1 loop wait until output_tvalid = '1' and rising_edge(clk); - check_equal(output_tlast, x = reference_image.width-1); - check_equal(output_tdata, reference_image.get(x, y), + check_equal(output_tlast, x = width(reference_image)-1); + check_equal(output_tdata, get(reference_image, x, y), "x=" & to_string(x) & " y=" & to_string(y)); end loop; end loop; report ("Done checking image of size " & - to_string(reference_image.width) & "x" & - to_string(reference_image.height)); + to_string(width(reference_image)) & "x" & + to_string(height(reference_image))); data_check_done <= true; end process; diff --git a/examples/vhdl/array_axis_vcs/run.py b/examples/vhdl/array_axis_vcs/run.py index bb905743b4..6fc1d98982 100644 --- a/examples/vhdl/array_axis_vcs/run.py +++ b/examples/vhdl/array_axis_vcs/run.py @@ -8,11 +8,9 @@ Array and AXI4 Stream Verification Components --------------------------------------------- -Demonstrates ``array_t``, ``axi_stream_master_t`` and ``axi_stream_slave_t`` -data types of ``array_pkg.vhd``, ``stream_master_pkg`` and ``stream_slave_pkg``, -respectively. Also, ``push_axi_stream`` of ``axi_stream_pkg`` is used. A CSV file -is read, the content is sent in a row-major order to an AXI Stream buffer (FIFO) -and it is received back to be saved in a different file. Further information can +Shows how to use ``integer_array_t``, ``axi_stream_master_t`` and ``axi_stream_slave_t``. +A CSV file is read, the content is sent in a row-major order to an AXI Stream buffer +(FIFO) and it is received back to be saved in a different file. Further information can be found in the :ref:`verification component library user guide `, in subsection :ref:`Stream ` and in :vunit_file:`vhdl/verification_components/test/tb_axi_stream.vhd `. @@ -22,9 +20,6 @@ from vunit import VUnit vu = VUnit.from_argv() - -vu.add_osvvm() -vu.add_array_util() vu.add_verification_components() src_path = join(dirname(__file__), "src") diff --git a/examples/vhdl/array_axis_vcs/src/test/tb_axis_loop.vhd b/examples/vhdl/array_axis_vcs/src/test/tb_axis_loop.vhd index 5919f4f823..4670026297 100644 --- a/examples/vhdl/array_axis_vcs/src/test/tb_axis_loop.vhd +++ b/examples/vhdl/array_axis_vcs/src/test/tb_axis_loop.vhd @@ -17,7 +17,6 @@ context ieee.ieee_std_context; library vunit_lib; context vunit_lib.vunit_context; context vunit_lib.vc_context; -use vunit_lib.array_pkg.all; entity tb_axis_loop is generic ( @@ -48,7 +47,8 @@ architecture tb of tb_axis_loop is -- tb signals and variables signal clk, rst, rstn : std_logic := '0'; - shared variable m_I, m_O : array_t; + constant m_I : integer_array_t := load_csv(tb_path & csv_i); + constant m_O : integer_array_t := new_2d(width(m_I), height(m_I), data_width, true); signal start, done, saved : boolean := false; begin @@ -85,15 +85,13 @@ begin done <= false; wait until rising_edge(clk); - m_I.load_csv(tb_path & csv_i); + info("Sending m_I of size " & to_string(height(m_I)) & "x" & to_string(width(m_I)) & " to UUT..."); - info("Sending m_I of size " & to_string(m_I.height) & "x" & to_string(m_I.width) & " to UUT..."); - - for y in 0 to m_I.height-1 loop - for x in 0 to m_I.width-1 loop + for y in 0 to height(m_I)-1 loop + for x in 0 to width(m_I)-1 loop wait until rising_edge(clk); - if x = m_I.width-1 then last := '1'; else last := '0'; end if; - push_axi_stream(net, master_axi_stream, std_logic_vector(to_signed(m_I.get(x,y), data_width)) , tlast => last); + if x = width(m_I)-1 then last := '1'; else last := '0'; end if; + push_axi_stream(net, master_axi_stream, std_logic_vector(to_signed(get(m_I, x, y), data_width)) , tlast => last); end loop; end loop; @@ -111,24 +109,22 @@ begin saved <= false; wait for 50*clk_period; - m_O.init_2d(m_I.width, m_I.height, o'length, true); - - info("Receiving m_O of size " & to_string(m_O.height) & "x" & to_string(m_O.width) & " from UUT..."); + info("Receiving m_O of size " & to_string(height(m_O)) & "x" & to_string(width(m_O)) & " from UUT..."); - for y in 0 to m_O.height-1 loop - for x in 0 to m_O.width-1 loop + for y in 0 to height(m_O)-1 loop + for x in 0 to width(m_O)-1 loop pop_axi_stream(net, slave_axi_stream, tdata => o, tlast => last); - if (x = m_O.width-1) and (last='0') then + if (x = width(m_O)-1) and (last='0') then error("Something went wrong. Last misaligned!"); end if; - m_O.set(x,y,to_integer(signed(o))); + set(m_O, x, y, to_integer(signed(o))); end loop; end loop; info("m_O read!"); wait until rising_edge(clk); - m_O.save_csv(tb_path & csv_o); + save_csv(m_O, tb_path & csv_o); info("m_O saved!");