Forum Discussion
Altera_Forum
Honored Contributor
17 years agoVHDL code for a sram
hi I am looking for a VHDL code for a sram with something unusual which is an Upper- and a Lower- Byte control. I do not know how to handle this! i have already written this part of code but it is no...
Altera_Forum
Honored Contributor
17 years agoHi,
I have fixed those problems, my code looks like that now: library ieee; library work; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use work.all; entity sram2 is port (clk : in std_logic; ce : in std_logic; oe : in std_logic; we : in std_logic; LB : in std_logic; UB : in std_logic; addr : in std_logic_vector(17 downto 0); data_in : inout std_logic_vector(15 downto 0); data_out : out std_logic_vector(15 downto 0) ); end sram2; architecture syn of sram2 is type ram_type is array (262144 downto 0) of std_logic_vector (15 downto 0); signal RAM: ram_type; signal temp: STD_LOGIC_VECTOR (15 downto 0); begin process (clk) begin if clk'event and clk = '1' then if ce='1' then RAM(conv_integer(addr)) <= "ZZZZZZZZZZZZZZZZ"; elsif ce = '0' then if oe = '1' and we='1' then report "Mauvaise valeur des signaux" severity warning; elsif we='0' then if UB='1' and LB='0' then temp <= "ZZZZZZZZ"&data_in(7)&data_in(6)&data_in(5)&data_in(4)&data_in(3)&data_in(2)&data_in(1)&data_in(0); data_in <= temp; RAM(conv_integer(addr)) <= data_in; elsif UB='0' and LB='1' then temp <= data_in(15)&data_in(14)&data_in(13)&data_in(12)&data_in(11)&data_in(10)&data_in(9)&data_in(8)&"ZZZZZZZZ"; data_in <= temp; RAM(conv_integer(addr)) <= data_in; elsif UB='0' and LB='0' then RAM(conv_integer(addr)) <= data_in; end if; elsif oe='0' then if we='0' then report "Mauvaise valeur des signaux" severity warning; elsif we='1'then if UB='1' and LB='0' then RAM(conv_integer(addr))(15)<='Z'; RAM(conv_integer(addr))(14)<='Z'; RAM(conv_integer(addr))(13)<='Z'; RAM(conv_integer(addr))(12)<='Z'; RAM(conv_integer(addr))(11)<='Z'; RAM(conv_integer(addr))(10)<='Z'; RAM(conv_integer(addr))(9) <='Z'; RAM(conv_integer(addr))(8) <='Z'; data_out <= RAM(conv_integer(addr)) ; elsif UB='0' and LB='1' then RAM(conv_integer(addr))(7)<='Z'; RAM(conv_integer(addr))(6)<='Z'; RAM(conv_integer(addr))(5)<='Z'; RAM(conv_integer(addr))(4)<='Z'; RAM(conv_integer(addr))(3)<='Z'; RAM(conv_integer(addr))(2)<='Z'; RAM(conv_integer(addr))(1)<='Z'; RAM(conv_integer(addr))(0)<='Z'; data_out <= RAM(conv_integer(addr)) ; else data_out <= RAM(conv_integer(addr)) ; end if; end if; end if; end if; end if; end process; end syn; My question is that ModelSim does not recognized 'Z' which is high-Z. How can I do? thanks for your answer