diff options
author | Tristan Gingold <tgingold@free.fr> | 2021-06-16 07:48:22 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2021-06-16 07:48:22 +0200 |
commit | 4c0f9967e541b914a207bd4419d62d00d3e1745c (patch) | |
tree | 8d5edcededa4d1aa4d167cffcbaceca6aae3e596 /testsuite/synth/issue1781 | |
parent | 9a913ec7ac5bc2193ec3df90bf7f43808f5c80c6 (diff) | |
download | ghdl-4c0f9967e541b914a207bd4419d62d00d3e1745c.tar.gz ghdl-4c0f9967e541b914a207bd4419d62d00d3e1745c.tar.bz2 ghdl-4c0f9967e541b914a207bd4419d62d00d3e1745c.zip |
testsuite/synth: add test for #1781
Diffstat (limited to 'testsuite/synth/issue1781')
-rw-r--r-- | testsuite/synth/issue1781/imem.vhdl | 105 | ||||
-rw-r--r-- | testsuite/synth/issue1781/imem2.vhdl | 104 | ||||
-rw-r--r-- | testsuite/synth/issue1781/imem2a.vhdl | 46 | ||||
-rw-r--r-- | testsuite/synth/issue1781/simple2.vhdl | 31 | ||||
-rw-r--r-- | testsuite/synth/issue1781/simple2_dc.vhdl | 34 | ||||
-rw-r--r-- | testsuite/synth/issue1781/simple3.vhdl | 25 | ||||
-rw-r--r-- | testsuite/synth/issue1781/tb_simple2.vhdl | 54 | ||||
-rwxr-xr-x | testsuite/synth/issue1781/testsuite.sh | 17 |
8 files changed, 416 insertions, 0 deletions
diff --git a/testsuite/synth/issue1781/imem.vhdl b/testsuite/synth/issue1781/imem.vhdl new file mode 100644 index 000000000..0ece4ebf6 --- /dev/null +++ b/testsuite/synth/issue1781/imem.vhdl @@ -0,0 +1,105 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity imem is + generic ( + IMEM_BASE : std_ulogic_vector(31 downto 0) := x"00000000"; + IMEM_SIZE : natural := 4*1024 + ); + port ( + clk_i : in std_ulogic; + rden_i : in std_ulogic; + wren_i : in std_ulogic; + ben_i : in std_ulogic_vector(03 downto 0); + addr_i : in std_ulogic_vector(31 downto 0); + data_i : in std_ulogic_vector(31 downto 0); + data_o : out std_ulogic_vector(31 downto 0); + ack_o : out std_ulogic + ); +end entity; + +architecture ok of imem is + signal addr : std_ulogic_vector(15 downto 0); + type ram_t is array(0 to 2**15-1) of std_ulogic_vector(31 downto 0); + signal acc_en : std_ulogic; + constant abb_c : std_logic_vector(31 downto 16) := (others=>'0'); +begin + addr <= addr_i(addr'left+2 downto 2); -- word aligned + acc_en <= addr_i(abb_c'range) ?= IMEM_BASE(abb_c'range); + process(clk_i) + variable memory : ram_t; + begin + if rising_edge(clk_i) then + if acc_en then + ack_o <= rden_i or wren_i; + end if; + if acc_en and wren_i then + for x in 0 to 3 loop + if ben_i(x) then + memory(to_integer(unsigned(addr)))((x+1)*8-1 downto x*8) := data_i((x+1)*8-1 downto x*8); + end if; + end loop; + end if; + if acc_en and rden_i then + data_o <= memory(to_integer(unsigned(addr))); + end if; + end if; + end process; +end architecture; + +architecture notok of imem is + signal addr : std_ulogic_vector(15 downto 0); + type ram_t is array(0 to 2**15-1) of std_ulogic_vector(31 downto 0); + signal acc_en : std_ulogic; + constant abb_c : std_logic_vector(31 downto 16) := (others=>'0'); +begin + addr <= addr_i(addr'left+2 downto 2); -- word aligned + acc_en <= addr_i(abb_c'range) ?= IMEM_BASE(abb_c'range); + process(clk_i) + variable memory : ram_t; + begin + if rising_edge(clk_i) and acc_en='1' then + ack_o <= rden_i or wren_i; + if wren_i then + for x in 0 to 3 loop + if ben_i(x) then + memory(to_integer(unsigned(addr)))((x+1)*8-1 downto x*8) := data_i((x+1)*8-1 downto x*8); + end if; + end loop; + end if; + if rden_i then + data_o <= memory(to_integer(unsigned(addr))); + end if; + end if; + end process; +end architecture; + +architecture neitherok of imem is + signal addr : std_ulogic_vector(15 downto 0); + type ram_t is array(0 to 2**15-1) of std_ulogic_vector(31 downto 0); + signal acc_en : std_ulogic; + constant abb_c : std_logic_vector(31 downto 16) := (others=>'0'); + begin + addr <= addr_i(addr'left+2 downto 2); -- word aligned + acc_en <= addr_i(abb_c'range) ?= IMEM_BASE(abb_c'range); + process(clk_i) + variable memory : ram_t; + begin + if rising_edge(clk_i) then + if acc_en then + ack_o <= rden_i or wren_i; + if wren_i then + for x in 0 to 3 loop + if ben_i(x) then + memory(to_integer(unsigned(addr)))((x+1)*8-1 downto x*8) := data_i((x+1)*8-1 downto x*8); + end if; + end loop; + end if; + if rden_i then + data_o <= memory(to_integer(unsigned(addr))); + end if; + end if; + end if; + end process; + end architecture; diff --git a/testsuite/synth/issue1781/imem2.vhdl b/testsuite/synth/issue1781/imem2.vhdl new file mode 100644 index 000000000..13d60dd5a --- /dev/null +++ b/testsuite/synth/issue1781/imem2.vhdl @@ -0,0 +1,104 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity imem2 is + generic ( + IMEM_BASE : std_ulogic_vector(31 downto 0) := x"00000000" + ); + port ( + clk_i : in std_ulogic; + rden_i : in std_ulogic; + wren_i : in std_ulogic; + ben_i : in std_ulogic_vector(03 downto 0); + addr_i : in std_ulogic_vector(31 downto 0); + data_i : in std_ulogic_vector(31 downto 0); + data_o : out std_ulogic_vector(31 downto 0); + ack_o : out std_ulogic + ); +end entity; + +architecture ok of imem2 is + signal addr : std_ulogic_vector(15 downto 0); + type ram_t is array(0 to 2**15-1) of std_ulogic_vector(31 downto 0); + signal acc_en : std_ulogic; + constant abb_c : std_logic_vector(31 downto 16) := (others=>'0'); +begin + addr <= addr_i(addr'left+2 downto 2); -- word aligned + acc_en <= addr_i(abb_c'range) ?= IMEM_BASE(abb_c'range); + process(clk_i) + variable memory : ram_t; + begin + if rising_edge(clk_i) then + if acc_en then + ack_o <= rden_i or wren_i; + end if; + if acc_en and wren_i then + for x in 0 to 3 loop + if ben_i(x) then + memory(to_integer(unsigned(addr)))((x+1)*8-1 downto x*8) := data_i((x+1)*8-1 downto x*8); + end if; + end loop; + end if; + if acc_en and rden_i then + data_o <= memory(to_integer(unsigned(addr))); + end if; + end if; + end process; +end architecture; + +architecture notok of imem2 is + signal addr : std_ulogic_vector(7 downto 0); + type ram_t is array(0 to 2**8-1) of std_ulogic_vector(31 downto 0); + signal acc_en : std_ulogic; + constant abb_c : std_logic_vector(31 downto 16) := (others=>'0'); +begin + addr <= addr_i(addr'left+2 downto 2); -- word aligned + acc_en <= addr_i(abb_c'range) ?= IMEM_BASE(abb_c'range); + process(clk_i) + variable memory : ram_t; + begin + if rising_edge(clk_i) and acc_en='1' then + ack_o <= rden_i or wren_i; + if wren_i then + for x in 0 to 3 loop + if ben_i(x) then + memory(to_integer(unsigned(addr)))((x+1)*8-1 downto x*8) := data_i((x+1)*8-1 downto x*8); + end if; + end loop; + end if; + if rden_i then + data_o <= memory(to_integer(unsigned(addr))); + end if; + end if; + end process; +end architecture; + +architecture neitherok of imem2 is + signal addr : std_ulogic_vector(15 downto 0); + type ram_t is array(0 to 2**15-1) of std_ulogic_vector(31 downto 0); + signal acc_en : std_ulogic; + constant abb_c : std_logic_vector(31 downto 16) := (others=>'0'); + begin + addr <= addr_i(addr'left+2 downto 2); -- word aligned + acc_en <= addr_i(abb_c'range) ?= IMEM_BASE(abb_c'range); + process(clk_i) + variable memory : ram_t; + begin + if rising_edge(clk_i) then + if acc_en then + ack_o <= rden_i or wren_i; + if wren_i then + for x in 0 to 3 loop + if ben_i(x) then + memory(to_integer(unsigned(addr)))((x+1)*8-1 downto x*8) := data_i((x+1)*8-1 downto x*8); + end if; + end loop; + end if; + if rden_i then + data_o <= memory(to_integer(unsigned(addr))); + end if; + end if; + end if; + end process; + end architecture; diff --git a/testsuite/synth/issue1781/imem2a.vhdl b/testsuite/synth/issue1781/imem2a.vhdl new file mode 100644 index 000000000..8f2000212 --- /dev/null +++ b/testsuite/synth/issue1781/imem2a.vhdl @@ -0,0 +1,46 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity imem2a is + generic ( + IMEM_BASE : std_ulogic_vector(31 downto 0) := x"00000000" + ); + port ( + clk_i : in std_ulogic; + rden_i : in std_ulogic; + wren_i : in std_ulogic; + ben_i : in std_ulogic_vector(01 downto 0); + addr_i : in std_ulogic_vector(31 downto 0); + data_i : in std_ulogic_vector(15 downto 0); + data_o : out std_ulogic_vector(15 downto 0); + ack_o : out std_ulogic + ); +end entity; + +architecture notok of imem2a is + signal addr : std_ulogic_vector(7 downto 0); + type ram_t is array(0 to 2**8-1) of std_ulogic_vector(15 downto 0); + signal acc_en : std_ulogic; +begin + addr <= addr_i(addr'left+2 downto 2); -- word aligned + acc_en <= '1'; + + process(clk_i) + variable memory : ram_t; + begin + if rising_edge(clk_i) and acc_en='1' then + ack_o <= rden_i or wren_i; + if wren_i then + for x in 0 to 1 loop + if ben_i(x) then + memory(to_integer(unsigned(addr)))((x+1)*8-1 downto x*8) := data_i((x+1)*8-1 downto x*8); + end if; + end loop; + end if; + if rden_i then + data_o <= memory(to_integer(unsigned(addr))); + end if; + end if; + end process; +end architecture; diff --git a/testsuite/synth/issue1781/simple2.vhdl b/testsuite/synth/issue1781/simple2.vhdl new file mode 100644 index 000000000..9d8a49ac0 --- /dev/null +++ b/testsuite/synth/issue1781/simple2.vhdl @@ -0,0 +1,31 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity simple2 is + port ( + clk_i : in std_ulogic; + rden_i : in std_ulogic; + wren_i : in std_ulogic; + addr_i : in std_ulogic_vector(7 downto 0); + data_i : in std_ulogic_vector(15 downto 0); + data_o : out std_ulogic_vector(15 downto 0) + ); +end entity; + +architecture notok of simple2 is + type ram_t is array(0 to 2**8-1) of std_ulogic_vector(15 downto 0); +begin + process(clk_i) + variable memory : ram_t; + begin + if rising_edge(clk_i) then + if wren_i = '1' then + memory(to_integer(unsigned(addr_i))) := data_i; + end if; + if rden_i = '1' then + data_o <= memory(to_integer(unsigned(addr_i))); + end if; + end if; + end process; +end architecture; diff --git a/testsuite/synth/issue1781/simple2_dc.vhdl b/testsuite/synth/issue1781/simple2_dc.vhdl new file mode 100644 index 000000000..6bc084577 --- /dev/null +++ b/testsuite/synth/issue1781/simple2_dc.vhdl @@ -0,0 +1,34 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity simple2_dc is + port ( + rclk_i : in std_ulogic; + wclk_i : in std_ulogic; + rden_i : in std_ulogic; + wren_i : in std_ulogic; + addr_i : in std_ulogic_vector(7 downto 0); + data_i : in std_ulogic_vector(15 downto 0); + data_o : out std_ulogic_vector(15 downto 0) + ); +end entity; + +architecture notok of simple2_dc is + type ram_t is array(0 to 2**8-1) of std_ulogic_vector(15 downto 0); +begin + process(wclk_i, rclk_i) + variable memory : ram_t; + begin + if rising_edge(wclk_i) then + if wren_i = '1' then + memory(to_integer(unsigned(addr_i))) := data_i; + end if; + end if; + if rising_edge(rclk_i) then + if rden_i = '1' then + data_o <= memory(to_integer(unsigned(addr_i))); + end if; + end if; + end process; +end architecture; diff --git a/testsuite/synth/issue1781/simple3.vhdl b/testsuite/synth/issue1781/simple3.vhdl new file mode 100644 index 000000000..fda848b5b --- /dev/null +++ b/testsuite/synth/issue1781/simple3.vhdl @@ -0,0 +1,25 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity imem2a is + port ( + clk_i : in std_ulogic; + addr_i : in std_ulogic_vector(30 downto 0); + data_i : in std_ulogic_vector(15 downto 0); + data_o : out std_ulogic_vector(15 downto 0) + ); +end entity; + +architecture notok of imem2a is + type ram_t is array(0 to 2**8-1) of std_ulogic_vector(15 downto 0); +begin + process(clk_i) + variable memory : ram_t; + begin + if rising_edge(clk_i) then + memory(to_integer(unsigned(addr_i))) := data_i; + data_o <= memory(to_integer(unsigned(addr_i))); + end if; + end process; +end architecture; diff --git a/testsuite/synth/issue1781/tb_simple2.vhdl b/testsuite/synth/issue1781/tb_simple2.vhdl new file mode 100644 index 000000000..5378ade4b --- /dev/null +++ b/testsuite/synth/issue1781/tb_simple2.vhdl @@ -0,0 +1,54 @@ +entity tb_simple2 is +end tb_simple2; + +library ieee; +use ieee.std_logic_1164.all; + +architecture behav of tb_simple2 is + signal addr : std_logic_vector(7 downto 0); + signal rdat : std_logic_vector(15 downto 0); + signal wdat : std_logic_vector(15 downto 0); + signal wren : std_logic; + signal rden : std_logic; + signal clk : std_logic; +begin + dut: entity work.simple2 + port map (clk_i => clk, rden_i => rden, wren_i => wren, + addr_i => addr, data_i => wdat, data_o => rdat); + + process + procedure pulse is + begin + clk <= '0'; + wait for 1 ns; + clk <= '1'; + wait for 1 ns; + end pulse; + begin + addr <= x"00"; + wdat <= x"0001"; + wren <= '1'; + rden <= '0'; + pulse; + + addr <= x"01"; + wdat <= x"0002"; + pulse; + + -- Simple read. + addr <= x"00"; + wren <= '0'; + rden <= '1'; + pulse; + assert rdat = x"0001" severity failure; + + -- Check write through. + addr <= x"03"; + wren <= '1'; + wdat <= x"3333"; + pulse; + assert rdat = x"3333" severity failure; + + wait; + end process; +end behav; diff --git a/testsuite/synth/issue1781/testsuite.sh b/testsuite/synth/issue1781/testsuite.sh new file mode 100755 index 000000000..47c90a237 --- /dev/null +++ b/testsuite/synth/issue1781/testsuite.sh @@ -0,0 +1,17 @@ +#! /bin/sh + +. ../../testenv.sh + + +export GHDL_STD_FLAGS=--std=08 + +synth_tb simple2 + +synth --out=none imem2a.vhdl -e 2> imem2a.err +grep -q "width: 16 bits, depth: 256" imem2a.err + +synth_analyze imem2 + + +clean +echo "Test successful" |