cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
7,320 Views
Registered: ‎03-31-2014

VHDL CODE FOR ARRAYS

plz give the VHDL code for adding 2 arrays having integer values in the range -3 to 3.................

plz help..........

0 Kudos
5 Replies
Highlighted
Xilinx Employee
Xilinx Employee
7,111 Views
Registered: ‎10-24-2013

Re: VHDL CODE FOR ARRAYS

Did you google to find some help? here is some reference.
http://stackoverflow.com/questions/14060613/sum-of-array-elements-vhdl
Thanks,Vijay
--------------------------------------------------------------------------------------------
Please mark the post as an answer "Accept as solution" in case it helped resolve your query.
Give kudos in case a post in case it guided to the solution.
0 Kudos
Highlighted
Xilinx Employee
Xilinx Employee
7,089 Views
Registered: ‎08-01-2008

Re: VHDL CODE FOR ARRAYS

1.Use ROM to store array element

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity rams_21b is
port (CLK : in std_logic;
EN : in std_logic;
ADDR : in std_logic_vector(5 downto 0);
DATA : out std_logic_vector(19 downto 0));
end rams_21b;

architecture syn of rams_21b is
type rom_type is array (63 downto 0) of std_logic_vector (19 downto 0);
signal ROM : rom_type:= (X"0200A", X"00300", X"08101", X"04000", X"08601", X"0233A",
X"00300", X"08602", X"02310", X"0203B", X"08300", X"04002",
X"08201", X"00500", X"04001", X"02500", X"00340", X"00241",
X"04002", X"08300", X"08201", X"00500", X"08101", X"00602",
X"04003", X"0241E", X"00301", X"00102", X"02122", X"02021",
X"00301", X"00102", X"02222", X"04001", X"00342", X"0232B",
X"00900", X"00302", X"00102", X"04002", X"00900", X"08201",
X"02023", X"00303", X"02433", X"00301", X"04004", X"00301",
X"00102", X"02137", X"02036", X"00301", X"00102", X"02237",
X"04004", X"00304", X"04040", X"02500", X"02500", X"02500",
X"0030D", X"02341", X"08201", X"0400D");

signal rdata : std_logic_vector(19 downto 0);
begin

rdata <= ROM(conv_integer(ADDR));

process (CLK)
begin
if (CLK'event and CLK = '1') then
if (EN = '1') then
DATA <= rdata;
end if;
end if;
end process;

end syn;

2. use arithemtic operation to addition



process (<input1>, <input2>)
begin
if <add_sub> = '1' then
<addsub_output> <= <input1> + <input2>;
else
<addsub_output> <= <input1> - <input2>;
end if;
end process;
Thanks and Regards
Balkrishan
--------------------------------------------------------------------------------------------
Please mark the post as an answer "Accept as solution" in case it helped resolve your query.
Give kudos in case a post in case it guided to the solution.
0 Kudos
Highlighted
7,077 Views
Registered: ‎03-31-2014

Re: VHDL CODE FOR ARRAYS

sir, i copied ur progrm in vhdl,it was giving syntax error at position where process is writtn.....

use od DATA&colon; was giving error...plz help...........

 

 

 

0 Kudos
Highlighted
Xilinx Employee
Xilinx Employee
7,074 Views
Registered: ‎08-01-2008

Re: VHDL CODE FOR ARRAYS

these example code available in ISE language template . The error may be coming from copy past. You can just try to rewrite code manully

Thanks and Regards
Balkrishan
--------------------------------------------------------------------------------------------
Please mark the post as an answer "Accept as solution" in case it helped resolve your query.
Give kudos in case a post in case it guided to the solution.
0 Kudos
Highlighted
Xilinx Employee
Xilinx Employee
7,029 Views
Registered: ‎10-24-2013

Re: VHDL CODE FOR ARRAYS

avantika3012@gmail.com Did the above posts helped solving your issue? If yes please close the thread by marking the solution.
Thanks,Vijay
--------------------------------------------------------------------------------------------
Please mark the post as an answer "Accept as solution" in case it helped resolve your query.
Give kudos in case a post in case it guided to the solution.
0 Kudos