Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > help to input array

Reply
Thread Tools

help to input array

 
 
ashu
Guest
Posts: n/a
 
      01-12-2006
hi friends
i have written a program to search a no. in an arrray & get the result
in form of apulse going high or low,but
given no is compared with only the last value & desired output is not
coming.
my basic problem is to input an array directly to input port.also if
somebody can give some example program or tips about reading & writing
files in vhdl. i m using modelsim.
i have written the code & test bench for the code for refrene.
thanks
ashwani anand

library ieee ;
use ieee.std_logic_1164.all ;
package my is
type arec is array (0 to 49 ) of integer range 0 to 50 ;
type inst is record
ary : arec ;

end record ;
end my ;

library ieee ;
use ieee.std_logic_1164.all ;
use work.my .all ;

entity rec is

port( a : in inst ;
b : in integer range 0 to 55 ;
o : out std_logic );
end rec ;

architecture a of rec is
begin
process (a,b)

-- variable q : integer range 0 to 55 ;
-- variable p : integer range 0 to 50 ;

begin


for i in 0 to 49 loop

-- p := b ;

--q := a.ary(i) ;

if (b = a.ary(i)) then

o <= '1' ;

else

o <= '0' ;

end if ;
end loop ;
end process ;
end a ;

--TEST BENCH


library ieee ;
use ieee.std_logic_1164.all ;

package my is
type arec is array (0 to 49 ) of integer range 0 to 50 ;
type inst is record
ary : arec ;

end record ;
end my ;

library ieee ;
use ieee.std_logic_1164.all ;
use work.my .all ;

entity tb_rec is
end ;

architecture a of tb_rec is


component rec

port ( a : in inst ;
b : in integer range 0 to 50 ;
o : out std_logic );

end component ;

signal o : std_logic ;
signal a : inst ;
signal b : integer range 0 to 55 ;

begin

U1 : rec port map (a =>a,b =>b , o =>o );

process

variable t : integer range 0 to 55;
variable q : integer range 0 to 55;
begin

wait for 10 ns ;
b <= 50 ;
wait for 10 ns ;


t := 1 ;

for i in 0 to 49 loop

a.ary(i) <= t ;

t := t + 1 ;

if (t = 51 ) then

t := 0 ;
wait for 10 ns ;
b <= 52 ;
wait for 10 ns ;

wait for 10 ns ;
b <= 23 ;
wait for 10 ns ;

end if ;
end loop ;


end process ;

end a;

result of this program is a pulse high for 23 & 50 low for 52 but it is
remaning high for 50 only which is last value stored in array.

 
Reply With Quote
 
 
 
 
jens
Guest
Posts: n/a
 
      01-12-2006
The lack of formatting makes it very difficult to read, but it appears
as if the problem comes from the fact that the last signal assignment
in a process wins, so o can only be '1' when b = a.ary(49).

Using a default signal assigment might work...

o <= '0' ;

for i in 0 to 49 loop
if (b = a.ary(i)) then
o <= '1' ;
end if ;
end loop ;

This assumes that a parallel comparison is what is desired, and
hopefully there's a clock outside of this process somewhere that is
clocking the inputs and outputs of this process.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
const and array of array (of array ...) Mara Guida C Programming 3 09-03-2009 07:54 AM
Which is faster in ASIC: 2-input AND gate or a 2-input multiplexer Weng Tianxiang VHDL 12 08-11-2005 10:50 AM
length of an array in a struct in an array of structs in a struct in an array of structs Tuan Bui Perl Misc 14 07-29-2005 02:39 PM
Pass input Array value to function to calc different input value Susan Cranford Javascript 2 07-05-2005 02:53 AM
Length of Array of Array of Array Tom Perl Misc 3 12-20-2004 05:23 PM



Advertisments