Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - help to input array

 
Thread Tools Search this Thread
Old 01-12-2006, 07:14 AM   #1
Default help to input array


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.



ashu
  Reply With Quote
Old 01-12-2006, 05:16 PM   #2
jens
 
Posts: n/a
Default Re: help to input array
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.



jens
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Wonderful data input with web reporting tool freezea Software 0 09-09-2009 05:30 AM
constants as of array of integers, for loops octavsly Hardware 0 04-25-2009 11:53 AM
Array Programme rits Software 2 03-04-2009 05:18 PM
How To Use S-Video Input on SIMA Color Corrector? Remove SPAM From Address to Reply DVD Video 4 11-17-2004 03:18 AM
DVD Recorder-DV input & Hard Drive ? Marion DVD Video 7 05-16-2004 06:31 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46