-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmifFileMaker.cpp
More file actions
46 lines (41 loc) · 1.03 KB
/
mifFileMaker.cpp
File metadata and controls
46 lines (41 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include <string>
#include <fstream>
#include<vector>
using namespace std;
int main(){
int bitWidth, dataDepth;
int counter=0;
string file_name,xData;
vector<string> theData;
ofstream memInitFile;
cout<<"Enter file name(w/o the extension): ";
cin>> file_name;
cout<<"\nEnter the bit-width of each word: ";
cin>>bitWidth;
cout<<"\nEnter the depth of the data: ";
cin>>dataDepth;
memInitFile.open(file_name+".mif");
for(auto i = 0; i<dataDepth; i++){
cout<<i<<"th memory location, or type 0x to end, USE BINARY!: ";
cin>>xData;
if(xData == "0x"){
break;
}
else{
theData.push_back(xData);
}
}
memInitFile<<"WIDTH = "<<bitWidth<<";\n";
memInitFile<<"DEPTH = "<<dataDepth<<";\n\n";
memInitFile<<"ADDRESS_RADIX = DEC;\nDATA_RADIX = BIN;\nCONTENT BEGIN\n";
for(auto i = theData.begin();i!=theData.end();i++){
memInitFile<<counter<<":"<< *i <<";\n";
cout<<counter<<":"<< *i <<";\n";
counter++;
}
memInitFile<<"END;";
memInitFile.close();
cout<<"done!\n";
return 0;
}