aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/synth/mem02
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-09-26 07:45:48 +0200
committerTristan Gingold <tgingold@free.fr>2019-09-26 07:45:48 +0200
commit2129c8a80b66baaabce48bcee92551865de86e74 (patch)
treea1faa2993e6d670f63b7dce217c8800f61077d0b /testsuite/synth/mem02
parentd07137710b5a1ff9a0d50341c2fa0432f9c7d4b0 (diff)
downloadghdl-2129c8a80b66baaabce48bcee92551865de86e74.tar.gz
ghdl-2129c8a80b66baaabce48bcee92551865de86e74.tar.bz2
ghdl-2129c8a80b66baaabce48bcee92551865de86e74.zip
testsuite/synth: add testcase for single bit memory.
Diffstat (limited to 'testsuite/synth/mem02')
-rw-r--r--testsuite/synth/mem02/ram3.vhdl25
-rw-r--r--testsuite/synth/mem02/tb_ram3.vhdl38
-rwxr-xr-xtestsuite/synth/mem02/testsuite.sh2
3 files changed, 64 insertions, 1 deletions
diff --git a/testsuite/synth/mem02/ram3.vhdl b/testsuite/synth/mem02/ram3.vhdl
new file mode 100644
index 000000000..d67667c3e
--- /dev/null
+++ b/testsuite/synth/mem02/ram3.vhdl
@@ -0,0 +1,25 @@
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+entity ram3 is
+ port (val : out std_logic_vector (7 downto 0);
+ waddr : std_logic_vector (2 downto 0);
+ wdat : std_logic;
+ clk : std_logic);
+end ram3;
+
+architecture behav of ram3 is
+ signal mem : std_logic_vector(7 downto 0);
+begin
+ process (clk)
+ variable ra : natural;
+ variable wa : natural;
+ begin
+ if rising_edge (clk) then
+ ra := to_integer(unsigned (waddr));
+ mem(ra) <= wdat;
+ end if;
+ end process;
+ val <= mem;
+end behav;
diff --git a/testsuite/synth/mem02/tb_ram3.vhdl b/testsuite/synth/mem02/tb_ram3.vhdl
new file mode 100644
index 000000000..d926e9481
--- /dev/null
+++ b/testsuite/synth/mem02/tb_ram3.vhdl
@@ -0,0 +1,38 @@
+entity tb_ram3 is
+end tb_ram3;
+
+library ieee;
+use ieee.std_logic_1164.all;
+
+architecture behav of tb_ram3 is
+ signal val : std_logic_vector(7 downto 0);
+ signal waddr : std_logic_vector(2 downto 0);
+ signal wdat : std_logic;
+ signal clk : std_logic;
+begin
+ dut: entity work.ram3
+ port map (waddr => waddr, wdat => wdat, val => val,
+ clk => clk);
+
+ process
+ procedure pulse is
+ begin
+ clk <= '0';
+ wait for 1 ns;
+ clk <= '1';
+ wait for 1 ns;
+ end pulse;
+ begin
+ waddr <= "000";
+ wdat <= '0';
+ pulse;
+
+ waddr <= "001";
+ wdat <= '1';
+ pulse;
+
+ assert (val and x"03") = x"02" severity failure;
+
+ wait;
+ end process;
+end behav;
diff --git a/testsuite/synth/mem02/testsuite.sh b/testsuite/synth/mem02/testsuite.sh
index ace30ab35..2d7da25bd 100755
--- a/testsuite/synth/mem02/testsuite.sh
+++ b/testsuite/synth/mem02/testsuite.sh
@@ -2,7 +2,7 @@
. ../../testenv.sh
-for t in dpram1; do
+for t in dpram1 ram3; do
analyze $t.vhdl tb_$t.vhdl
elab_simulate tb_$t
clean