Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use matlab to generate sine Wave mif File

Shulou Source: shulou.com Published: 2022-06-01 06:28:39 10月04日 Update

This article mainly introduces how to use matlab to generate sine wave mif files, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

Use matlab to generate sine wave mif file

.mif files or .hex files are often used in the rom process in FPGA with altera. For beginners, whether mif or hex is a very confusing thing, here is a simple explanation of the format and creation of the mif file.

Mif is the abbreviation of memory initialization file, which means memory initialization file in Chinese. To put it bluntly, it is the file that assigns values to rom. Here is an example of a simple .mif file:

Bit width horizontal width of width=14;% memory

Depth = 1024;% how much data is there in the depth of the memory?

Address_radix=uns;% sets the address base value (which is actually what number the address is represented in) can be set to BIN (binary), OCT (octal), DEC (decimal), HEX (hexadecimal)

Data_radix=dec;% ditto

Content begin% start data area

0PUX 0;% address: data

1:29

2:57

3:86

...

...

...

1023:16008

End; end

Matlab source code:

Clear all

Close all

Clc

T = [0VR 0.1R 360];% input range 0-90 degrees, step 0.1 degrees

X = pi*t/180

Sin_val = sin (x)

Fid=fopen ('E:\ matlab_project\ sin\ sine.mif','wt')

Fprintf (fid,'width=14;\ n')

Fprintf (fid,'depth = 1024;\ n')

Fprintf (fid,'address_radix=uns;\ n')

Fprintf (fid,'data_radix=dec;\ n')

Fprintf (fid,'content begin\ n')

For jacks 1mm 1024

I=j-1

K=round (sin_val (j) * 16384)

If (krypton16384)

Knight 16383

End

Fprintf (fid,'%d:%d;\ nPhonology iMagnek)

End

Fprintf (fid,'end;\ n')

Fclose (fid)

Plot (sin_val)

Results:

Thank you for reading this article carefully. I hope the article "how to use matlab to generate sine wave mif files" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Files articles generation address memory that is data storage constant thing binary value octal interest beginner hexadecimal decimal at the same time actual width Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi MySQL Huawei Shulou Information Shulou Technology