I am having a large text file which contains only the pixel values of an image.....here i can able to read the pixels using $readmemh system task..... but the prolem is memory......am using only 1000 words of memory as below reg [31:0] Mem [0:999]; initial $readmemh("pixels.txt",Mem); By this i can get only 1000 pixles from the text file and i will give these pixels to the next module for furthur processing....then i have to read the next 1000 pixels from the text file and put it in the Mem....similarly i want all the pixels to be readed from the txt file with the Mem size as 1000 and give those to the next module for furthur processing......so how i can do this plz i will be very thank full to u...plz help me.....
The Verilog system tasks $readmemb/h are prepared to fill only a part of the memory but not to read only a part of the file. This is different from C. So, I would suggest that you increase the size of the memory so that the complete file is read with one single call of $readmemh. Afterwards you may process the data in chunks of 1000 samples out of the memory.
Is there any method where we can read chunks of datas from a file using verilog....
No. It's quite simple to read the complete file. Why don't you do this?
i have tried but in icarus simulator the its reading upto 1980 words....after that it is giving error as below Error: Invalid input character
That's surprising! Are you sure that there is no invalid character in the file. If you delete the first n items does the error number stay the same?
thanks a lot for ur reply......s u r right sir....i found one invalid charachter over there now it is reading properly...
Hi I have converted an image into text file in hex format. I want to further process these pixel values in verilog code. how should i do it..? i tried using $readmemh ... but i am not able to read the text file.. please can any one send me the entire code to access the pixel value... Thanking you in advance.
Naz Saheb wrote: > i tried using $readmemh ... Show a little bit more of your code. And also some lines of the hex-file. > but i am not able to read the text file.. Why not? What problem do you encounter?
thanks for the reply sir i am not able to get where exactly i have to use $readmemh in my attached code. i tried for simple program below but it resulted in an error that no ports are declared, whats wrong?
1 | module text_read_write; |
2 | reg [7:0] mem [0:4]; |
3 | integer m,i; |
4 | |
5 | initial
|
6 | begin
|
7 | $readmemh("mem_in.txt", mem); |
8 | m=$fopen("mem_out.txt"); |
9 | for(i=0;i<5;i=i+1) |
10 | begin
|
11 | $fdisplay(m,"%h",mem[i]); |
12 | end
|
13 | $fclose(m); |
14 | end
|
15 | endmodule
|
text file values : 1 2 4 A B...
:
Edited by Moderator
Naz Saheb wrote: >>> I have converted an image into text file in hex format. Naz Saheb wrote: > text file values : If the attached img.txt has anything to do with your problem: there is no hex value inside this file! Its plain ASCII integer. Naz Saheb wrote: > i am not able to get where exactly i have to use $readmemh in my > attached code. Maybe you must generate a testbench for that module imageedge and feed that imageedge with stimuli read out of the img.txt. Am I wrong? Or what is this code snippet for? BTW: Why the heck did you pack a 4kB Verliog file with the file extension .txt into a ZIP? I unpacked it and attached is as a .v Verilog file to your post. Next time think and do it yourself, please.
:
Edited by Moderator
For reading a file in chunks you have to use $fopen and $fread or $fscanf. Easiest is reading binary data with $fread. Also saves you the trouble to create a txt file from your image file.
sorry for the mistake sir... sir can you please suggest how and where to assign the text file values of hex format as an input to an INOUT port in verilog ??? Is it in the main module or the test bench??? In the attached code file 'bus' is declared as an inout port which is a bidirectional bus. i want to give text file values as an input to the bus.. how can i proceed sir??
Can't we read 2-dimensional text file to verilog test bench? I want to make it read like that. please help me in this regard. Whether its possible or not? if possible the way? Here I'm attaching the text file.
Hi, Anyone please help me to read a large text file using verilog. I need to do edge detection without using FPGA. Thanks in advance.
Hi, Anyone can please help me to read a text file and load read value on some variables in verilog.
Hi there, I am trying to perform skin detection from an image in verilog. The image is of resolution 1200x900 ie, contains 1080000 pixels. Each pixel is represented by 24-bit RGB data in the hex file generated by MATLAB. 8 bits to represent intensities of R, G and B components in each pixel. So each line represents R/G/B component. Three lines represent a pixel, so total of 3240000 lines represent the complete image. From the image that is ready, I need to get selectively the skin pixels applying sort based on normal RGB value range of human skin. Skin pixels as kind of blacked and others as white, greyscaling. This pixel values of greyscaled image is written to a text and later to be read in matlab to get the image out of it Could you please share some light on this (code bits or relevant materials) Thanks
yk_learner wrote: > I am trying to perform skin detection from an image in verilog. For real life on real hadware or just in a simulation with a picture file? > Could you please share some light on this Pls start a completely new thread for a completely new question. > From the image that is ready What is a "ready picture"? In what way is that picture "ready"? Just as a hint: after writing your post you should have a look at it like you would know absolutely nothing about your specific problem. Because thats also the way we see your problem. If you do not understand your problem with the information you supplied, then we will have the very same problem.
Hello, Plz help me! I am trying to write data from a file to a memory, using the $readmem function, but I am facing the following problem: Readmemb's file name argument contains non-printable characters Whereas the data from my file only includes spaces, numbers, even no comments. Another problem is that when I want to write to the memory that I have configured before through a data register, how do I do that? Thank u so much for your help
JamesLuiz wrote: > Readmemb's file name argument contains non-printable characters Its filename is ghi.txt, that's all printable chars... Or do you mean the content of the file ghi.txt isn't really text, but instead it contains binary data? (**) In that case a 'b' is missing at r+ See there: https://stackoverflow.com/questions/25024751/read-binary-file-data-in-verilog-into-2d-array (**) if it contains binary data, why is it named "txt"?
:
Edited by Moderator
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
Log in with Google account
No account? Register here.