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.

reading .bin file from matlab in VHDL

Status
Not open for further replies.

haris343

Newbie level 1
Joined
Mar 1, 2011
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,292
i need help that i have created a .bin file in matlab and i want to read it it VHDL...!! kindly help me out !!

thanks alot !!
 

I would recommend you output a text file rather than binary from matlab. Reading text is easy in VHDL, but reading binary is simulator dependent. Modelsim is the easiest to read binary in.
 

so can u please help me how can i read the text file in vhdl...!! plus it will be more helpful if u can convert bin file to text file in VHDL...!!
 


    V

    Points: 2
    Helpful Answer Positive Rating
if you are using modelsim and want to read binary, you can read 1 character at a time from a file.

Code:
type bin_file_t is file of character;

file my_bin_file : bin_file_t open read_mode is "some_file.bin";
variable buf : character;
variable buf_int : integer;

.....
read(my_bin_file, buf);
buf_int := character'pos(buf);

Modelsim will do this fine and you have full byte access. Other simulators insist you have some obscure file header (ISE Simulator) while others just wont work.
 

do u have any idea which header file is to used while using ISE simulator...!!
 

Nope. I would generally avoid trying to read binary in VHDL. Matlab can read text easily, and so can VHDL.
 

Hey guys... I also want a help. (sorry my bad english)

I want create a test bench for a Filter in VHDL.

For it, I has need generate a file.bin with 10 bits (2^10 = 1024 levels of quantization). [Simulating a "A/D" conversor]

Its easy to make a file.bin in MATLAB
Code:
fs=fopen('file.bin','w+');fwrite(fs,0:1023,'bit10');fclose(fs);

But, how i can read bit-to-bit in each clock pulse?
I tried it: **broken link removed** but, isn't work...

Do not want to read 2 bytes and need to dispose of 6 bits...

Thx,
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top