درود
من می خواهم یک ماتریس را که در یک فایبل txt ذخیره کردم را در vhdl بخونم
چه کنم؟؟؟
کد زیر را چک کنید لطفا
زمانم محدود است
اضافه شده در تاریخ :
من کد زیر را نوشتم
فقط مشکیم اینه که چجوری اعداد را بگم جدا گانه بخونه و داخل آرایه ام بریزه
لطفا اگر کسی با دستور READLINE یا READ کارکرده کمک کنه
library ieee;
use ieee.std_logic_1164.all;
use IEEE.std_logic_signed.all;
use std.textio.all;--need for use read
entity matrix1 is
port(clk:in std_logic);
end matrix1;
architecture mat_read of matrix1 is
type px is array(511 downto 0,511 downto 0)of integer range 0 to 255;--array for save matrix
signal pxmat:px;
signal row,col:integer range 0 to 511:=0;--their show row and column
begin
process(clk)
file data_out: text;
variable fstatus: FILE_OPEN_STATUS;
variable count: integer range 0 to 511:= 0;
variable buf: LINE;-- buffer between the program and file
begin
file_open(fstatus, data_out, "mat.txt", read_mode);--open file and save it in data_out-------data_out and "mat" have same format
if( clk'event and clk='1' )then
readline(data_out,buf);--read from data_out and write in buf
read(buf,count);--transfer into count
pxmat(row,col)<=count;--transfer into array
col<=col+1;--for change column
if ((col=511)and(row<511))then--for chek and change row
row<=row+1;
col<=0;
end if;
end if;
end process;
end mat_read;
من می خواهم یک ماتریس را که در یک فایبل txt ذخیره کردم را در vhdl بخونم
چه کنم؟؟؟
کد زیر را چک کنید لطفا
زمانم محدود است
اضافه شده در تاریخ :
من کد زیر را نوشتم
فقط مشکیم اینه که چجوری اعداد را بگم جدا گانه بخونه و داخل آرایه ام بریزه
لطفا اگر کسی با دستور READLINE یا READ کارکرده کمک کنه
library ieee;
use ieee.std_logic_1164.all;
use IEEE.std_logic_signed.all;
use std.textio.all;--need for use read
entity matrix1 is
port(clk:in std_logic);
end matrix1;
architecture mat_read of matrix1 is
type px is array(511 downto 0,511 downto 0)of integer range 0 to 255;--array for save matrix
signal pxmat:px;
signal row,col:integer range 0 to 511:=0;--their show row and column
begin
process(clk)
file data_out: text;
variable fstatus: FILE_OPEN_STATUS;
variable count: integer range 0 to 511:= 0;
variable buf: LINE;-- buffer between the program and file
begin
file_open(fstatus, data_out, "mat.txt", read_mode);--open file and save it in data_out-------data_out and "mat" have same format
if( clk'event and clk='1' )then
readline(data_out,buf);--read from data_out and write in buf
read(buf,count);--transfer into count
pxmat(row,col)<=count;--transfer into array
col<=col+1;--for change column
if ((col=511)and(row<511))then--for chek and change row
row<=row+1;
col<=0;
end if;
end if;
end process;
end mat_read;
دیدگاه