Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to write a Verilog program to read binary data from text file?

Status
Not open for further replies.

suganthitechno

Newbie level 2
Joined
Mar 16, 2009
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,297
How to write a Verilog program with large input size - 1024 bytes? any shortcut?

hi,
I am trying to develop verilog code for 1024 individual byte input..verilog does not allow array of vectors as input or output..i know i can use reg [7:0]mem[1023:0] and assign inputs to mem. but do i have to type all 1024 datas in portlist or is there any shortcut?
 

Re: How to write a Verilog program with large input size - 1024 bytes? any shortcut?

You have two options
- refer to Systemverilog enhancements of Verilog language
- remember 8*1024 = 8192
 

hi
I need to read 1024 bytes from text file in binary form.
In my program , i have memory [7:0]mem[1023:0] and i need to write binary data from text file to this mem. After getting binary data into the mem, i have to do some image processing manipulation(texture analysis) and write the result into another text file in binary form or any other form.
I tried fread, fopen, readmemh, but i am getting error
Can anyone post the detailed code to read binary data from file and to write in another file?
Also iam currently using modelsim..does file reading and writing work in xilinx?
 

I've done reading part alone.Here is the code to read 1024 bytes fom memory.The image should be first converted to text with hex values using MATLAB.
module file_readmemh_1;
reg [7:0] data_1 [0:1023];
initial $readmemh("lenaimghex.txt", data_1);
integer i;
initial begin
$display("rdata:");
for (i=0; i < 1024; i=i+1)
$display("%d:%h",i,data_1);
end
endmodule
I've referred it from some other website.display is not necessary.Note that you've the text file inthe same folder as that of the verilog file.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top