aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-05-07 08:19:44 +0200
committerTristan Gingold <tgingold@free.fr>2020-05-07 08:27:37 +0200
commit0ed7faecf056394561daaeb67250a4177f1829e6 (patch)
treec05564957d5c0df2d9a81f87bc70e659825586aa
parent3a9f459038346ac395281bbae18332b3d5861d02 (diff)
downloadghdl-0ed7faecf056394561daaeb67250a4177f1829e6.tar.gz
ghdl-0ed7faecf056394561daaeb67250a4177f1829e6.tar.bz2
ghdl-0ed7faecf056394561daaeb67250a4177f1829e6.zip
testsuite/synth: add a test for nested memories.
-rw-r--r--testsuite/synth/arr02/arr03.vhdl38
-rw-r--r--testsuite/synth/arr02/tb_arr03.vhdl49
-rwxr-xr-xtestsuite/synth/arr02/testsuite.sh2
3 files changed, 88 insertions, 1 deletions
diff --git a/testsuite/synth/arr02/arr03.vhdl b/testsuite/synth/arr02/arr03.vhdl
new file mode 100644
index 000000000..0363a2bda
--- /dev/null
+++ b/testsuite/synth/arr02/arr03.vhdl
@@ -0,0 +1,38 @@
+library ieee;
+use ieee.std_logic_1164.all;
+
+entity arr03 is
+ port (
+ a : std_logic_vector (31 downto 0);
+ sel : natural range 0 to 3;
+ clk : std_logic;
+ res : out std_logic_vector (3 downto 0));
+end arr03;
+
+architecture behav of arr03 is
+ type t_mem is array (0 to 3) of std_logic_vector (7 downto 0);
+ type t_stage is record
+ sel : natural range 0 to 3;
+ val : t_mem;
+ end record;
+
+ signal s : t_stage;
+begin
+ process (clk) is
+ begin
+ if rising_edge (clk) then
+ s.sel <= sel;
+ s.val <= (a (31 downto 24),
+ a (23 downto 16),
+ a (15 downto 8),
+ a (7 downto 0));
+ end if;
+ end process;
+
+ process (clk) is
+ begin
+ if rising_edge (clk) then
+ res <= s.val (s.sel)(6 downto 3);
+ end if;
+ end process;
+end behav;
diff --git a/testsuite/synth/arr02/tb_arr03.vhdl b/testsuite/synth/arr02/tb_arr03.vhdl
new file mode 100644
index 000000000..fa57c0756
--- /dev/null
+++ b/testsuite/synth/arr02/tb_arr03.vhdl
@@ -0,0 +1,49 @@
+entity tb_arr03 is
+end tb_arr03;
+
+library ieee;
+use ieee.std_logic_1164.all;
+
+architecture behav of tb_arr03 is
+ signal a : std_logic_vector (31 downto 0);
+ signal sel : natural range 0 to 3;
+ signal clk : std_logic;
+ signal res : std_logic_vector (3 downto 0);
+begin
+ dut: entity work.arr03
+ port map (a, sel, clk, res);
+
+ process
+ procedure pulse is
+ begin
+ clk <= '0';
+ wait for 1 ns;
+ clk <= '1';
+ wait for 1 ns;
+ end pulse;
+ begin
+ a <= x"a1b2c3d4";
+ sel <= 0;
+ pulse;
+ pulse;
+ assert res = b"0100" severity failure;
+
+ sel <= 1;
+ pulse;
+ assert res = b"0100" severity failure;
+
+ sel <= 2;
+ pulse;
+ assert res = b"0110" severity failure;
+
+ sel <= 3;
+ pulse;
+ assert res = b"1000" severity failure;
+
+ sel <= 0;
+ pulse;
+ assert res = b"1010" severity failure;
+
+ wait;
+ end process;
+end behav;
diff --git a/testsuite/synth/arr02/testsuite.sh b/testsuite/synth/arr02/testsuite.sh
index 441d8285d..d35c23a9a 100755
--- a/testsuite/synth/arr02/testsuite.sh
+++ b/testsuite/synth/arr02/testsuite.sh
@@ -2,7 +2,7 @@
. ../../testenv.sh
-for t in arr01 arr02; do
+for t in arr01 arr02 arr03; do
synth_tb $t
done