diff options
Diffstat (limited to 'testsuite/synth/mem01')
-rw-r--r-- | testsuite/synth/mem01/NOTES.txt | 9 | ||||
-rw-r--r-- | testsuite/synth/mem01/sram01.vhdl | 29 | ||||
-rw-r--r-- | testsuite/synth/mem01/srom01.vhdl | 28 | ||||
-rw-r--r-- | testsuite/synth/mem01/tb_sram01.vhdl | 43 | ||||
-rw-r--r-- | testsuite/synth/mem01/tb_srom01.vhdl | 38 | ||||
-rwxr-xr-x | testsuite/synth/mem01/testsuite.sh | 2 |
6 files changed, 148 insertions, 1 deletions
diff --git a/testsuite/synth/mem01/NOTES.txt b/testsuite/synth/mem01/NOTES.txt new file mode 100644 index 000000000..84edd5041 --- /dev/null +++ b/testsuite/synth/mem01/NOTES.txt @@ -0,0 +1,9 @@ +Tests for RAMs +-------------- + +rom1: asynchronous ROM +srom01: Read (initialized ROM). +sram01: Read+Write (at the same address). +dpram1: Read+Write (using signals, without enables) +dpram2: Read+Write (using a variable, without enables) +dpram3: Read+Write (like dpram2 but downto) diff --git a/testsuite/synth/mem01/sram01.vhdl b/testsuite/synth/mem01/sram01.vhdl new file mode 100644 index 000000000..b4bfd0d2e --- /dev/null +++ b/testsuite/synth/mem01/sram01.vhdl @@ -0,0 +1,29 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity sram01 is + port ( + clk_i : std_logic; + addr_i : std_logic_vector(3 downto 0); + data_i : std_logic_vector(7 downto 0); + data_o : out std_logic_vector(7 downto 0); + wen_i : std_logic); +end sram01; + +architecture behav of sram01 is +begin + process (clk_i, addr_i) + type mem_type is array (0 to 15) of std_logic_vector (7 downto 0); + variable mem : mem_type; + variable addr : natural range mem_type'range; + begin + if rising_edge(clk_i) then + addr := to_integer (unsigned (addr_i)); + data_o <= mem (addr); + if wen_i = '1' then + mem (addr) := data_i; + end if; + end if; + end process; +end behav; diff --git a/testsuite/synth/mem01/srom01.vhdl b/testsuite/synth/mem01/srom01.vhdl new file mode 100644 index 000000000..1d8e70b64 --- /dev/null +++ b/testsuite/synth/mem01/srom01.vhdl @@ -0,0 +1,28 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity srom01 is + port ( + clk_i : std_logic; + addr_i : std_logic_vector(3 downto 0); + data_o : out std_logic_vector(7 downto 0)); +end srom01; + +architecture behav of srom01 is +begin + process (clk_i, addr_i) + type mem_type is array (0 to 15) of std_logic_vector (7 downto 0); + constant mem : mem_type := ( + x"f0", x"e1", x"d2", x"c3", + x"b4", x"a5", x"96", x"87", + x"78", x"69", x"5a", x"4b", + x"3c", x"2d", x"1e", x"0f"); + variable addr : natural range mem_type'range; + begin + if rising_edge(clk_i) then + addr := to_integer (unsigned (addr_i)); + data_o <= mem (addr); + end if; + end process; +end behav; diff --git a/testsuite/synth/mem01/tb_sram01.vhdl b/testsuite/synth/mem01/tb_sram01.vhdl new file mode 100644 index 000000000..6fa0a7106 --- /dev/null +++ b/testsuite/synth/mem01/tb_sram01.vhdl @@ -0,0 +1,43 @@ +entity tb_sram01 is +end tb_sram01; + +library ieee; +use ieee.std_logic_1164.all; + +architecture behav of tb_sram01 is + signal addr : std_logic_vector(3 downto 0); + signal rdat : std_logic_vector(7 downto 0); + signal wdat : std_logic_vector(7 downto 0); + signal wen : std_logic; + signal clk : std_logic; +begin + dut: entity work.sram01 + port map (clk_i => clk, addr_i => addr, data_i => wdat, data_o => rdat, + wen_i => wen); + + process + procedure pulse is + begin + clk <= '0'; + wait for 1 ns; + clk <= '1'; + wait for 1 ns; + end pulse; + begin + addr <= "0000"; + wdat <= x"01"; + wen <= '1'; + pulse; + + addr <= "0001"; + wdat <= x"02"; + pulse; + + addr <= "0000"; + wen <= '0'; + pulse; + assert rdat = x"01" severity failure; + + wait; + end process; +end behav; diff --git a/testsuite/synth/mem01/tb_srom01.vhdl b/testsuite/synth/mem01/tb_srom01.vhdl new file mode 100644 index 000000000..530423a67 --- /dev/null +++ b/testsuite/synth/mem01/tb_srom01.vhdl @@ -0,0 +1,38 @@ +entity tb_srom01 is +end tb_srom01; + +library ieee; +use ieee.std_logic_1164.all; + +architecture behav of tb_srom01 is + signal addr : std_logic_vector(3 downto 0); + signal rdat : std_logic_vector(7 downto 0); + signal clk : std_logic; +begin + dut: entity work.srom01 + port map (clk_i => clk, addr_i => addr, data_o => rdat); + + process + procedure pulse is + begin + clk <= '0'; + wait for 1 ns; + clk <= '1'; + wait for 1 ns; + end pulse; + begin + addr <= "0000"; + pulse; + assert rdat = x"f0" severity failure; + + addr <= "0001"; + pulse; + assert rdat = x"e1" severity failure; + + addr <= "0100"; + pulse; + assert rdat = x"b4" severity failure; + + wait; + end process; +end behav; diff --git a/testsuite/synth/mem01/testsuite.sh b/testsuite/synth/mem01/testsuite.sh index 8d0b840a5..073c69ea4 100755 --- a/testsuite/synth/mem01/testsuite.sh +++ b/testsuite/synth/mem01/testsuite.sh @@ -2,7 +2,7 @@ . ../../testenv.sh -for t in rom1 dpram1 dpram2 dpram3; do +for t in rom1 srom01 sram01 dpram1 dpram2 dpram3; do analyze $t.vhdl tb_$t.vhdl elab_simulate tb_$t clean |