Question: is there a way to write this code more efficient using a loop for 'load' and 'read' from ram? - - 8 Register Ram -

is there a way to write this code more efficient using a loop for 'load' and 'read' from ram?
--8 Register Ram
-- Ram_8Register_SarahJohn
-- Created by John Sarah
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
use ieee.numeric_std.all;
entity Ram_8Register_SarahJohn is
port
(
D : in std_logic_vector(15 downto 0);
Clock, Load : in std_logic;
address : in std_logic_vector(2 downto 0);
Q : out std_logic_vector(15 downto 0)
);
end Ram_8Register_SarahJohn;
Architecture behavioral of Ram_8Register_SarahJohn is
type Array8x16 is array(7 downto 0) of std_logic_vector(15 downto 0);
signal RAM : Array4x16;
signal index : integer range 0 to 7;
Begin
process (Clock)
Begin
if (Rising_edge(CLock)) then
if (Load ='1') then
if address=B"000" then RAM (0)<=D;
elsif address=B"001" then RAM (1)<=D;
elsif address=B"010" then RAM (2)<=D;
elsif address=B"011" then RAM (3)<=D;
elsif address=B"101" then RAM (4)<=D;
elsif address=B"110" then RAM (5)<=D;
elsif address=B"001" then RAM (6)<=D;
elsif address=B"111" then RAM (7)<=D;
End if;
Q<=D;
else
if address=B"000" then Q<=Ram (0);
elsif address=B"001" then Q<=RAM (1);
elsif address=B"010" then Q<=RAM (2);
elsif address=B"011" then Q<=RAM (3);
elsif address=B"100" then Q<=RAM (4);
elsif address=B"101" then Q<=RAM (5);
elsif address=B"110" then Q<=RAM (6);
elsif address=B"111" then Q<=RAM (7);
end if;
end if;
end if;
end process;
end behavioral;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!