aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2014-09-02 21:16:10 +0200
committerTristan Gingold <tgingold@free.fr>2014-09-02 21:16:10 +0200
commite393e8b7babd9d2dbe5e6bb7816b82036b857a1f (patch)
treea6625ac078dd93c52dec38a446583ec40ca0ec14
parent936e3917bfdd298dd67b8866e25fae5a1e74317d (diff)
downloadghdl-e393e8b7babd9d2dbe5e6bb7816b82036b857a1f.tar.gz
ghdl-e393e8b7babd9d2dbe5e6bb7816b82036b857a1f.tar.bz2
ghdl-e393e8b7babd9d2dbe5e6bb7816b82036b857a1f.zip
Add testcase for indexed image.
-rw-r--r--testsuite/gna/bug01/foo.vhdl41
-rw-r--r--testsuite/gna/bug01/repro.vhdl16
-rw-r--r--testsuite/gna/bug01/tb.vhdl116
-rwxr-xr-xtestsuite/gna/bug01/testsuite.sh12
4 files changed, 185 insertions, 0 deletions
diff --git a/testsuite/gna/bug01/foo.vhdl b/testsuite/gna/bug01/foo.vhdl
new file mode 100644
index 000000000..5b597fadb
--- /dev/null
+++ b/testsuite/gna/bug01/foo.vhdl
@@ -0,0 +1,41 @@
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+entity foo is
+ constant m: integer := 3;
+ constant n: integer := 5;
+ constant h: integer := 4;
+ constant DATA_SIZE: integer :=5;
+end entity;
+
+architecture fum of foo is
+ signal OUTPUT : SIGNED((DATA_SIZE+DATA_SIZE)+(m-1)-1 downto 0) := "000011110110" ;
+
+ type Vector is record
+ OUTPUT_test : SIGNED((DATA_SIZE+DATA_SIZE)+(m-1)-1 downto 0);
+ end record;
+
+ type VectorArray is array (natural range <>) of Vector;
+
+ constant Vectors : VectorArray := (
+ -- Values to be compaired to calculated output
+ (OUTPUT_test =>"000011110110"), -- 246 (CORRECT)
+ (OUTPUT_test =>"000101001000") -- 382 (INCORRECT)
+ );
+
+begin
+TEST:
+ process
+ begin
+ for i in Vectors'RANGE loop
+ assert OUTPUT = Vectors(i).OUTPUT_test
+ report "Incorrect Output on vector line " & integer'image(i) &
+-- lf & "Expected:" & integer'image(i)(to_integer((Vectors(i).OUTPUT_test)))
+ lf & "Expected:" & integer'image(to_integer((Vectors(i).OUTPUT_test)))
+ severity error;
+ end loop;
+ wait;
+ end process;
+
+end architecture;
diff --git a/testsuite/gna/bug01/repro.vhdl b/testsuite/gna/bug01/repro.vhdl
new file mode 100644
index 000000000..5538eafd1
--- /dev/null
+++ b/testsuite/gna/bug01/repro.vhdl
@@ -0,0 +1,16 @@
+entity repro is
+
+end repro;
+
+architecture behav of repro is
+
+begin -- behav
+
+ process
+ variable v : integer := 523;
+ variable a : integer := 2;
+ begin
+ assert false report integer'image(v)(a);
+ wait;
+ end process;
+end behav;
diff --git a/testsuite/gna/bug01/tb.vhdl b/testsuite/gna/bug01/tb.vhdl
new file mode 100644
index 000000000..34be7ef34
--- /dev/null
+++ b/testsuite/gna/bug01/tb.vhdl
@@ -0,0 +1,116 @@
+LIBRARY ieee;
+USE ieee.std_logic_1164.ALL;
+use IEEE.NUMERIC_STD.ALL;
+
+ENTITY TestBenchAutomated IS
+-- Generics passed in
+generic (m: integer := 3; n: integer := 5; h: integer := 4; DATA_SIZE: integer :=5);
+END TestBenchAutomated;
+
+ARCHITECTURE behavior OF TestBenchAutomated IS
+
+ -- Component Declaration for the Unit Under Test (UUT)
+ COMPONENT TopLevelM_M
+ generic (m: integer := 3; n: integer := 5; h: integer := 4; DATA_SIZE: integer :=5);
+ PORT(
+ clk : IN std_logic;
+ next_in : IN std_logic; --User input
+ rst_in : IN std_logic; --User input
+ OUTPUT : OUT SIGNED((DATA_SIZE+DATA_SIZE)+(m-1)-1 downto 0) --Calculated DATA output
+ );
+ END COMPONENT;
+
+
+ --Inputs
+ signal clk : std_logic := '0';
+ signal next_in : std_logic := '0';
+ signal rst_in : std_logic := '0';
+
+ --Outputs
+ signal OUTPUT : SIGNED((DATA_SIZE+DATA_SIZE)+(m-1)-1 downto 0);
+
+ -- Clock period definitions
+ constant clk_period : time := 10 ns;
+
+ --Variable to be used in assert section
+ type Vector is record
+ OUTPUT_test : SIGNED((DATA_SIZE+DATA_SIZE)+(m-1)-1 downto 0);
+ end record;
+
+type VectorArray is array (natural range <>) of Vector;
+
+constant Vectors : VectorArray := (
+ -- Values to be compaired to calculated output
+ (OUTPUT_test =>"000000110000"), -- 48
+ (OUTPUT_test =>"000011110110"), -- 246
+ (OUTPUT_test =>"000101001000"), -- 382 <--- Purposefully incorrect value, Should be '000100001000' = 264
+ (OUTPUT_test =>"111111010011"), -- -45
+ (OUTPUT_test =>"111101001100"), -- -180
+ (OUTPUT_test =>"111111001111"), -- -49
+ (OUTPUT_test =>"000000101011"), -- 43 Purposefully incorrect value, Should be '000010101011' = 171
+ (OUTPUT_test =>"000000010011"), -- 19
+ (OUTPUT_test =>"111111100101"), -- -27
+ (OUTPUT_test =>"111110111011"), -- -69
+ (OUTPUT_test =>"111110111011"), -- -69
+ (OUTPUT_test =>"000000101101"), -- 45
+ (OUTPUT_test =>"111011011110"), -- -290
+ (OUTPUT_test =>"000001010110"), -- 86
+ (OUTPUT_test =>"000011110010"), -- 242
+ (OUTPUT_test =>"000000111110"), -- 125
+ (OUTPUT_test =>"111111001001"), -- -55
+ (OUTPUT_test =>"000100010101"), -- 277
+ (OUTPUT_test =>"111111100011"), -- -29
+ (OUTPUT_test =>"111101111101"));-- -131
+
+
+
+BEGIN
+
+ -- Instantiate the Unit Under Test (UUT)
+ uut: TopLevelM_M PORT MAP (
+ clk => clk,
+ next_in => next_in,
+ rst_in => rst_in,
+ OUTPUT => OUTPUT
+ );
+
+ -- Clock process definitions
+ clk_process :process
+ begin
+ clk <= '0';
+ wait for clk_period/2;
+ clk <= '1';
+ wait for clk_period/2;
+ end process;
+ -- Process to simulate user input and to check output is correct
+Test :process
+ variable i : integer;
+ begin
+ wait for 100 ns;
+ rst_in <= '1';
+ wait for clk_period*3;
+ rst_in <= '0';
+
+ --Loops through enough times to cover matrix and more to show it freezes in S_Wait state
+ for i in 0 to 50 loop
+
+ for i in Vectors'range loop
+
+ next_in <= '1';
+ wait for clk_period*5;
+ next_in <= '0';
+ wait for clk_period*4; --Appropriate amount of clock cycles needed for calculations to be displayed at output
+ --Check the output is the same as expected
+ assert OUTPUT = Vectors(i).OUTPUT_test
+ report "Incorrect Output on vector line" & integer'image(i) &
+ lf & "Expected:" & integer'image(i)(to_integer((Vectors(i).OUTPUT_test))) --& lf &
+ --"But got" & integer'image(i)(to_integer(signed(OUTPUT)))
+ severity error;
+
+ end loop;
+ end loop;
+
+ wait;
+
+ end process;
+END;
diff --git a/testsuite/gna/bug01/testsuite.sh b/testsuite/gna/bug01/testsuite.sh
new file mode 100755
index 000000000..363758e4e
--- /dev/null
+++ b/testsuite/gna/bug01/testsuite.sh
@@ -0,0 +1,12 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+analyze foo.vhdl
+elab_simulate foo
+
+analyze tb.vhdl
+# elab_simulate testbenchautomated --ieee-asserts=disable --stop-time=100us
+clean
+
+echo "Test successful"