Problem while simulation of array signals VHDL

Status
Not open for further replies.

harian

Junior Member level 1
Joined
Jan 13, 2015
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
137
hi,
i am new to Vhdl. I have written a test bench which read real Data from a text file,store it in a array in vhdl testbench. Then i have converted it into Std_logich vector and store this new data in another array.
I need to feed this array as Input to my testbench. I have done this with following code.
Code:
 type mem is array(1 to 10000) of real; --store real data 
type int0 is array(1 to 10000) of std_logic_vector(11 downto 0);--store converted data binary data
signal b0:int0;--signal to feeded to intput
b0(i)<=std_logic_vector(to_unsigned( ( integer  (data_in0(i)*65536.0)),12));-- converting to Std_logic_vector
--feeding the array to Input??????
for j in 1 to 10000 loop
in_operand0 <= b0(j);wait for 5 ns;
in_operand1 <= b1(j);wait for 5 ns;
b_out_1(j) <= out_result;wait for 5 ns;
end loop;

In the simulation,,In_operand0 and in_operand1 are just simulated für one vlaue of array "int0" i.e. Zero and the output is also showing just only one vlaue.
can you please help me or have any suggestion,sothat the whole elements of array be feeded at input "In_operand0 " and the output be shown related inputs for each and every element of Input array int0.
best regards
 


- Based on the code snippets you posted, what you have in your testbench looks to be OK.
- What is the simulation time at the end? Based on what you posted, the sim time should be 10000*5ns or 50000 ns. If it's not, then you simply haven't run the simulation long enough.
- If that's not it, then post your entire testbench (does not need to include whatever it is that you're testing). You've posted what appears to be the relevant pieces, but if it's not working for you, then the problem must be in some other area that you didn't think was relevant.

Kevin Jennings
 

thanks for the reply,, i have run it for 50000ns and also more say 1ms it is the same result. It is not able to read more than one element of the array
I am using only one process .In that process, i read the multiple text file,converting them in std logich and at end as in the code above feeding the inputs . all are simulating good except the array describes above..
 

thanks alot,,it worked,, it is due to simulation type..
i have another question regarding finding the maximum of a array of unsigned bit_vector
Code:
signal er1:std_logic_vector(11 down to 0);
process
variable maximum:std_logic_vector(11 dow to 0);
maximum:="00000000000";
er1<=maximum;wait for 5 ns;

if i in 0 to 36 loop
if (array_element(i)>er1) then
er1<=array_elemet(i);
else
er1 <= er1;
end if;
end loop;
end process

it is working but the value is not the maximum of the array. do u have any suggestion regarding this.
thanks
 

std_logic_vector is a container for bits it's not supposed to be a number which you can compare for '>' or '<'. Therefore, since you are performing a greater than comparison with std_logic_vector you are probably using something like std_logic_arith package, which defines arithmetic for std_logic_vectors. You shouldn't be using packages other than numeric_std if you want to work with integer numbers. numeric_std is an official IEEE package all the std_logic_arith, std_logic_unsigned, std_logic_signed packages were written by synopsys and put in the IEEE library (which was wrong on Synopsys' part).

My guess is you are not finding the maximum value which has a 1 in the most significant bit. I'm pretty sure this is because whatever is defined in the package you are using isn't interpreting the values as unsigned values, but more than likely as 2s complement signed values therefore "100000000000" (-2048) would be considered less than "011111111111" (2047) and less than "000000000000" (0)..

This is the reason you should post all your code not just snippets, I have to guess what your problem might be.. Besides that you don't even tell us what the values are that you are trying to compare so maybe I'm still wrong and your code isn't comparing "000000000101" and "000000001101" correctly. Don't know since all you say is it doesn't work.
 

aside from the non-standard coding style, the problem comes because you are using a signal in a for loop.
Signals get assigned when a process suspends, not immediatly (like a variable). So in your case every element in the array is compared to 0, and it will find the last element larger than zero, as a signal takes the last value assigned to it in the current delta. If you want an immediate result, you need to use a variable instead.

You want er1 to be a varaible, not a signal
(you also do not need the else case - it is implied by not having an else case anyway)
 

thanks, i have changed it to variable and it works..
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…