- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hii..
i'm trying to read ".txt" file representing an image, contains integer value like that.. 0 0 0 0 23 163 145 149 154 154 154 155 155 156 156 156 158 158 158 158 158 158 158 ......150 149 149 148 148 148 148 151 143 139 140 102 0 0 0 0 0 0 23 163 145 149 154 154 154 155 155 156 156 156 158 158 158 158 158 158 158 ......150 149 149 148 148 148 148 151 143 139 140 102 0 0 0 0 0 0 23 163 145 149 154 154 154 155 155 156 156 156 158 158 158 158 158 158 158 ......150 149 149 148 148 148 148 151 143 139 140 102 0 0 0 0 0 0 23 162 145 149 154 154 154 155 155 156 156 156 158 158 158 158 158 158 158 ......150 149 149 148 148 148 148 151 143 139 140 102 0 0 ....... ........... .......... 0 0 0 0 0 158 136 128 141 141 141 141 141 141 141 142 144 144 144 144 144 144 144 .......140 140 140 140 140 140 143 139 125 141 129 106 0 0 0 0 0 0 0 143 136 134 136 136 136 136 136 136 136 138 142 142 142 142 142 142 142 .......140 140 140 140 140 140 140 140 130 141 129 104 0 0 0 0 0 0 0 147 139 126 140 140 140 140 140 140 140 141 141 141 141 141 141 141 141 .......140 140 140 140 140 140 141 143 136 134 127 102 0 0 0 0 0 0 0 148 132 134 140 140 140 140 140 140 140 141 138 138 138 138 138 138 138 .......135 135 135 135 135 135 129 135 135 132 133 106 0 0 0 0 0 0 0 143 113 137 141 141 141 141 141 141 141 142 145 145 145 145 145 145 145 .......137 137 137 137 137 137 136 139 136 128 130 102 0 0 0 0 0 0 0 149 118 123 137 137 137 137 137 137 137 139 145 145 145 145 145 145 145 .......132 132 132 132 132 132 123 130 129 126 126 94 0 0 0 0 0 0 14 129 129 123 136 136 136 136 136 136 136 138 139 139 139 139 139 139 139 .......0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ....... 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 but whenever i start simulation i got this warning : )TEXTIO procedure READ(INTEGER) : Parameter L designates an empty string) hence it is not the estimated output i thought i was getting this warning since the entire data is integer and i'm declaring my file like this (file testing_read: text open read_mode is "abc.txt" ) so i changed it to be like that ( type integer_file is file of integer; .... file testing_read: integer_file open read_mode is "abc.txt"; ) after which i got this error when compiling: (No feasible entries for subprogram "READLINE".) I would be so happy for your reply.. thanks, Niveen..Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You cant use readline with a file of type integer, because its only defined for text files. And you woudnt want to do that anyway, because a file of integers is not a text file but a data file, so there is no "line" to speak of.
Anyway, you havent shown your code that reads from the text file. The problem will be your code, not the data file.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
so should i change file extension to .dat instead of .txt or what??
here is my process if (rising_edge(clk)) then if rst = '1' then eog_sig <= '0'; else--rst while (col_s < starting_line_col) loop if(NOT(endfile(testing_read))) then READLINE(testing_read, my_line_read); else eog_sig <= '1'; end if; col_s := col_s + 1; end loop; col_e := col_s; while col_e < (ending_line_col+1) loop if(NOT(endfile(testing_read))) then READLINE(testing_read, my_line_read); READ(my_line_read, s); end if; while (row_s < starting_line_row) loop READ(my_line_read, s); row_s := row_s + 1; end loop;--row_s < starting_line_row row_e := row_s; row_s := 1; while row_e < (ending_line_row+1) loop READ(my_line_read, s); row_e := row_e + 1; x := x+s; i := i+1; end loop; col_e := col_e + 1; end loop; results := x/i; x := 0; i := 1; resultd_out <= To_StdLogicVector(results,N) ; col_s := 1; col_e := 1; row_s := 1; row_e := 1; end if;--rst end if;--clk Note: starting_line_col, starting_line_row, ending_line_col, ending_line_row are input integer values representing a rectangular area of x,y,width,height from which i select certain area to calculate its avarage sorry for my lazy code.. execuse me cause i'm totally new in that field.. willing to write smart code next time... thanks for your patiance.. Niveen- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
renaming it .dat wont make a difference - it will still be a text file. You would have to regenerate the file writing the values direct to 32 bits rather than text values.
The error is becuase you have read in an empty line, or you're trying to read past the end of a line. are you sure you have all the dimensions correct?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
actually, its even simpler than that. You're reading the entire file in a single clock cycle. so on the next clock, you've got an empty file. you need to read 1 value per clock cycle, not all of them!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks alot.. i got your point.. :)
i'm having one more question -->can i restart reading the same file in the same clock cycle... Thanks, Niveen..- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yes you can. use the procedures:
FILE_CLOSE(my_file); FILE_OPEN(my_file);- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks Tricky sooo much
i wrote --> FILE_OPEN(testing_read); befor --> if(NOT(endfile(testing_read))) and FILE_CLOSE(testing_read); at the end but i got this error (No feasible entries for subprogram "file_open".) i want to finish reading the file every clk thats why i'm using a while loop and in the next clock the input values change so i want to re-read the same file again with the new rectangular area... what should i do then.. i really appreciate your help alot.. thanks your patiance, Niveen- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i got that file_open should be like that --> FILE_OPEN(testing_read,"abc.txt",read_mode);
i placed it after (else of rst) i also defined these two lines line 1-->type f_read is file of text; line 2-->file testing_read: f_read; and i'm still having this error No feasible entries for subprogram "READLINE". either i wrote integer or string instead of text in line 1 i don't know where is the problem.. :( thanks alot, Niveen..- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
its working now :)
i replaced line 1 & line 2 by --> file testing_read : text; file_open() on its place @ the begining and file_close() at the end... Niveen..
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page