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

Reply

VHDL - help on an array problem

 
Thread Tools Search this Thread
Old 04-05-2005, 12:40 AM   #1
Default help on an array problem


The following is my source code;
-----------------------------------------------------------
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;

entity EGC is
generic(M : natural := 4);
Port ( input1 : in std_logic_vector(15 downto 0);
output1 : out std_logic_vector(15 downto 0));

end EGC;

architecture Behavioral of EGC is
subtype vector16 is std_logic_vector(15 downto 0);
type vector_M_16_Out is array(0 to M) of vector16;
signal out1: vector_M_16_Out;


begin

out1(0) <= input1;

proc0 : process(out1, input1)
begin
--out1(0) <= input1;
for i in 1 to M loop
out1(i) <= 2+out1(i-1);
end loop;
end process proc0;

output1 <= out1(M);
end Behavioral;
-----------------------------------------------

It is very strange that it doesn't work this way. All the signals
out1(0-4) are xxxx. But if I put "out1(0) <= input1;" into the
process, it works fine.
I can't understand this because the for loop in the process won't
modify the out1(0). Did I miss somthing? Any suggestions will be
appreciate.

For your convience, here is my test file and .do file:
test file
-----------------------------------------------
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;

------------------------entity Declaration----------------------------
entity test_EGC is
end test_EGC;

------------------------ Architecture Declaration
----------------------

architecture test_EGC of test_EGC is

signal output1, input1: std_logic_vector(15 downto 0);

component EGC
generic(M : natural := 4);
Port ( input1 : in std_logic_vector(15 downto 0);
output1 : out std_logic_vector(15 downto 0));

end component;

begin

proc_input1 : process is
begin
input1 <= X"0001";
wait for 60 ns;
input1 <= X"0000";
wait;
end process proc_input1; --proc_reset : process is

U_EGC : EGC
generic map(M=>4)
port map
( input1 => input1, output1 => output1);

end test_EGC;
-----------------------------------------------------
..do file
---------------------------------------------------
vsim work.test_EGC
view wave
add wave sim:/test_egc/output1
add wave sim:/test_egc/input1
add wave sim:/test_egc/u_egc/out1

run 500ns
--------------------------------------------------

Thank you,
Hongyan



hongyan
  Reply With Quote
Old 04-05-2005, 06:04 AM   #2
Ross Marchant
 
Posts: n/a
Default Re: help on an array problem
"hongyan" <> wrote in message
news: ups.com...
> The following is my source code;
> -----------------------------------------------------------
> library IEEE;
> use IEEE.std_logic_1164.all;
> use IEEE.std_logic_arith.all;
> use IEEE.std_logic_unsigned.all;
>
> entity EGC is
> generic(M : natural := 4);
> Port ( input1 : in std_logic_vector(15 downto 0);
> output1 : out std_logic_vector(15 downto 0));
>
> end EGC;
>
> architecture Behavioral of EGC is
> subtype vector16 is std_logic_vector(15 downto 0);
> type vector_M_16_Out is array(0 to M) of vector16;
> signal out1: vector_M_16_Out;
>
>
> begin
>
> out1(0) <= input1;
>
> proc0 : process(out1, input1)
> begin
> --out1(0) <= input1;
> for i in 1 to M loop
> out1(i) <= 2+out1(i-1);
> end loop;
> end process proc0;
>
> output1 <= out1(M);
> end Behavioral;
> -----------------------------------------------
>
> It is very strange that it doesn't work this way. All the signals
> out1(0-4) are xxxx. But if I put "out1(0) <= input1;" into the
> process, it works fine.
> I can't understand this because the for loop in the process won't
> modify the out1(0). Did I miss somthing? Any suggestions will be
> appreciate.
>

<snip>

I don't think Out1 should be in your process sensitivity list.
Everytime input1 changes proc0 is run, and at the same time Out0 is
undefined as although the inputs have been set, the outputs haven't been
assigned yet. Thus all the additions in the process are undefined, and will
generate Xs.

With the statement inside the process, Out1(0) is defined at the end of the
first iteration, and since you have Out1 in your process sensitivity list
the process will repeat until the additions have propagated to Out1(M) and
Out1 no longer changes.

Instead try:

out1(0) <= input1;

gen0:
for i in 1 to M generate
out1(i) <= 2+out1(i-1);
end generate;

output1 <= out1(M);

which to me seems more elegant.

Someone correct me if I'm wrong - I've only started coding vhdl (since uni)
last week.

Ross




Ross Marchant
  Reply With Quote
Old 04-05-2005, 08:20 AM   #3
Neo
 
Posts: n/a
Default Re: help on an array problem
I think this is more to do with how the simulator is assigning drivers
for the declared signals than with event scheduling. actually it should
work without problems as, an event on out1(0) should trigger the
process again. the input1 in the sensitivity list is unnecessary as
none of the assignments inside the process depend on it. but strangely
the out1(0) appears not to be driven at all.



Neo
  Reply With Quote
Old 04-06-2005, 01:26 PM   #4
hongyan
 
Posts: n/a
Default Re: help on an array problem
Thanks Neo. right, input1 in the sensitivity list is unnecessary.
And thanks for Ross, I know there are some other ways can solve the
problem. But I just wondering what cause the problem in my coding.



hongyan
  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
Dial Up Problem smackedass A+ Certification 3 02-02-2007 11:59 PM
Re: Virus Problem ** Help!** David BlandIII A+ Certification 1 03-02-2004 06:00 PM
Pioneer DVR3100S problem with Satellite receiver Samsung DCR 9500 Fredrik Bengtsson DVD Video 0 12-12-2003 02:32 PM
Re: Serious Computer Problem hootnholler A+ Certification 1 11-24-2003 12:18 PM
Re: Serious Computer Problem Bret A+ Certification 0 11-19-2003 12:51 AM




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