diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-04-26 10:31:38 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-04-26 10:31:38 +0200 |
commit | c95cfdf958d9708d3e99c33aa76ba9e80c7ab32a (patch) | |
tree | 2362da44a34b1202f80a6750471360a97986e30f /testsuite/synth/synth109/ram4.vhdl | |
parent | bda14ed9ca901a0f5f7059e92a19fd88e0e1dab9 (diff) | |
download | ghdl-c95cfdf958d9708d3e99c33aa76ba9e80c7ab32a.tar.gz ghdl-c95cfdf958d9708d3e99c33aa76ba9e80c7ab32a.tar.bz2 ghdl-c95cfdf958d9708d3e99c33aa76ba9e80c7ab32a.zip |
testsuite/synth: add tests from ghdl/ghdl-yosys-plugin#109
Diffstat (limited to 'testsuite/synth/synth109/ram4.vhdl')
-rw-r--r-- | testsuite/synth/synth109/ram4.vhdl | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/testsuite/synth/synth109/ram4.vhdl b/testsuite/synth/synth109/ram4.vhdl new file mode 100644 index 000000000..134a55f4b --- /dev/null +++ b/testsuite/synth/synth109/ram4.vhdl @@ -0,0 +1,47 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity ram4 is + + generic ( + WIDTHB : integer := 32; + SIZEB : integer := 64; + ADDRWIDTHB : integer := 6 + ); + + port ( + clkB : in std_logic; + enB : in std_logic; + weB : in std_logic; + addrB : in std_logic_vector(ADDRWIDTHB-1 downto 0); + diB : in std_logic_vector(WIDTHB-1 downto 0); + doB : out std_logic_vector(WIDTHB-1 downto 0) + ); + +end ram4; + +architecture behavioral of ram4 is + constant WIDTH : natural := WIDTHB / 4; + constant SIZE : natural := SIZEB * 4; + type ramType is array (0 to SIZE-1) of std_logic_vector(WIDTH-1 downto 0); + shared variable ram : ramType := (others => (others => '0')); +begin + process (clkB) + begin + if rising_edge(clkB) then + if enB = '1' then + if weB = '1' then + ram(to_integer(unsigned(addrB)&"00")) := diB(WIDTH-1 downto 0); + ram(to_integer(unsigned(addrB)&"01")) := diB(2*WIDTH-1 downto WIDTH); + ram(to_integer(unsigned(addrB)&"10")) := diB(3*WIDTH-1 downto 2*WIDTH); + ram(to_integer(unsigned(addrB)&"11")) := diB(4*WIDTH-1 downto 3*WIDTH); + end if; + doB(WIDTH-1 downto 0) <= ram(to_integer(unsigned(addrB)&"00")); + doB(2*WIDTH-1 downto WIDTH) <= ram(to_integer(unsigned(addrB)&"01")); + doB(3*WIDTH-1 downto 2*WIDTH) <= ram(to_integer(unsigned(addrB)&"10")); + doB(4*WIDTH-1 downto 3*WIDTH) <= ram(to_integer(unsigned(addrB)&"11")); + end if; + end if; + end process; +end behavioral; |