2 D array initialization

Guest
hello,
can anyone tell me how to read from / write to a 2D array from a file?
 
<mk.supriya@gmail.com> wrote in message
news:1185346586.048651.163750@g12g2000prg.googlegroups.com...
hello,
can anyone tell me how to read from / write to a 2D array from a file?

By writing your own procedure that reads from / writes to each element one
at a time.

KJ
 
By writing your own procedure that reads from / writes to each element one
at a time.

KJ
i am not able to access the elements, every type of assignment i make
i get an error
 
On Wed, 25 Jul 2007 05:08:24 -0700, mk.supriya@gmail.com wrote:

i am not able to access the elements, every type of assignment i make
i get an error
How can anyone possibly help you from this non-description?
*I* can access the elements of a 2-D array, and do so routinely.
There is no fundamental problem. Show us a code fragment and
we'll try to help with YOUR problem.

A few guesses...
- you're using the wrong kind of double-subscript:
depending on how you defined the array, you may need
to use subscripts like (row,column) or (row)(column)
- the array is a signal, and you are trying to pass
elements of it to the READ procedures; those
procedures expect variables
Without seeing your code and the error message, these
can only be guesses.
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan.bromley@MYCOMPANY.com
http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
 
How can anyone possibly help you from this non-description?
*I* can access the elements of a 2-D array, and do so routinely.
There is no fundamental problem. Show us a code fragment and
we'll try to help with YOUR problem.

A few guesses...
- you're using the wrong kind of double-subscript:
depending on how you defined the array, you may need
to use subscripts like (row,column) or (row)(column)
- the array is a signal, and you are trying to pass
elements of it to the READ procedures; those
procedures expect variables
Without seeing your code and the error message, these
can only be guesses.
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan.brom...@MYCOMPANY.comhttp://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
hello,
when i ran the following code, it assigns 1 to each and every element
in the array tout.
instead of write(my_file,'1'), suppose i have defined an array of
bit_vector(0 to 7) if i give write(my_file,x"04") it gives fatal error
in XST
package arr is
type row is array (0 to 7) of character;
type mat is array (0 to 7) of row;
end arr;

use work.arr.all;

entity arrfile is
port ( tout: out mat);
end arrfile;

architecture ARCH of arrfile is
begin
process is
type ch_file is file of character;
file my_file : ch_file;
constant file_name : string := "testfile4.txt";
--constant matrix : mat := ((0,1) => 'a', (1,0)=> 'c', others => '0');
variable my_char : character;
begin
file_open(my_file, file_name, write_mode);
for i in 0 to 7 loop
for j in 0 to 7 loop
write(my_file, '1');
end loop;
end loop;
file_close(my_file);
wait for 2 ns;
file_open(my_file, file_name, read_mode);
for i in 0 to 7 loop
for j in 0 to 7 loop
read(my_file, my_char);
tout(i)(j) <= my_char;
end loop;
end loop;
file_close(my_file);
end process;
end ARCH;
 
is bit_vector(0 to 7)not equivalent to character?
if i define the file as a file of characters, why am i not able to get
data into a bit_vector?
 
mk.supriya@gmail.com wrote:
is bit_vector(0 to 7)not equivalent to character?
No.
character is a scaler type.
bit vector is an array type.

if i define the file as a file of characters, why am i not able to get
data into a bit_vector?
I could write a function to make such a conversion.
Here is a related example:

function int2sgn (arg : integer) return signed is
subtype vec_t is signed(127 downto 0);
variable arg_v : vec_t := to_signed(arg, vec_t'length);
constant min_c : natural := min_len_sgn(arg);
subtype this_sgn_t is signed(min_c -1 downto 0);
begin
return arg_v(this_sgn_t'range);
end function int2sgn;

Details here:
http://home.comcast.net/~mike_treseler/

-- Mike Treseler
 
mk.supriya@gmail.com a écrit :

hello,
when i ran the following code, it assigns 1 to each and every element
in the array tout.
instead of write(my_file,'1'), suppose i have defined an array of
bit_vector(0 to 7) if i give write(my_file,x"04") it gives fatal error
in XST
Hi
So you are tring to *synthesize* this ? No wonder it doesn't work, I
don't know of *any* synthesis tool that supports file access.

Nicolas
 
Hi
So you are tring to *synthesize* this ? No wonder it doesn't work, I
don't know of *any* synthesis tool that supports file access.

Nicolas
no i wasnt synthesising it, i was simulating using xilinx simulator,
thanks to Mr Mike and Mr.Jonathan i now have an idea as to what to do.
thanks again
 

Welcome to EDABoard.com

Sponsor

Back
Top