OpenCores
URL https://opencores.org/ocsvn/orsoc_graphics_accelerator/orsoc_graphics_accelerator/trunk

Subversion Repositories orsoc_graphics_accelerator

[/] [orsoc_graphics_accelerator/] [trunk/] [sw/] [utils/] [regger/] [regger.cpp] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 maiden
#include "regger.h"
2
 
3
regger::regger()
4
{
5
}
6
 
7
void regger::SetDriverToRTL()
8
{
9
    cout << "to be implemented" << endl;
10
}
11
 
12
void regger::SetRTLToDriver()
13
{
14
    cout << "In Dev" << endl;
15
/*
16
    for(int i=0; i<driver_params.size(); i++)
17
    {
18
 
19
        for(int j=0; j<rtl_params.size(); j++)
20
        {
21
            if(driver_params[i].name == rtl_params.name)
22
            {
23
                fstream fout( c_file.c_str(), fstream::in | fstream::out);
24
                while(fout)
25
                {
26
                    //fout.seekp( 0, ios_base::beg );
27
                    //fout.seekp()
28
                    //fout.write( "####", 4 );
29
                    //fout.close();
30
                }
31
            }
32
        }
33
    }
34
    */
35
}
36
 
37
void regger::ShowRegs()
38
{
39
    int width = 40;
40
 
41
    // for all driver regs, check what params that have the same name.
42
    cout << "REG" << setw(width) << "C" << setw(width) << "Verilog" << setw(width) << "Status"<< endl;
43
    for(unsigned int i=0; i<driver_params.size(); i++)
44
    {
45
        bool match = false;
46
        cout << driver_params[i].name << setw(width-driver_params[i].name.size())  << driver_params[i].prefix << " " << driver_params[i].value;
47
        for(unsigned int j=0; j<rtl_params.size(); j++)
48
        {
49
            if(rtl_params[j].name == driver_params[i].name )
50
            {
51
                match = true;
52
                cout << setw(width-(driver_params[i].prefix.size()+driver_params[i].value.size()+1)) <<  rtl_params[j].prefix << " " << rtl_params[j].value;
53
 
54
                // check if the same value is stored in booth values
55
                if(rtl_params[j].value == driver_params[i].value)
56
                    cout << endl;
57
                else
58
                    cout << setw(width-(rtl_params[j].prefix.size()+rtl_params[j].value.size()+1)) << "Warning, not matching!" << endl;
59
                break;
60
            }
61
        }
62
        if(!match)
63
            cout << setw(width-(driver_params[i].prefix.size()+driver_params[i].value.size()+1)) << ":(" << setw(width) << "Warning, Lonely Reg" << endl;
64
    }
65
    //check what regs exists in rtl but not in driver
66
    for(unsigned int j=0; j<rtl_params.size(); j++)
67
    {
68
        bool match = false;
69
        for(unsigned int i=0; i<driver_params.size(); i++)
70
        {
71
            if(rtl_params[j].name == driver_params[i].name )
72
            {
73
                match = true;
74
                break;
75
            }
76
        }
77
        if(!match)
78
            cout << rtl_params[j].name << setw(width-rtl_params[j].name.size()) << ":(" << setw(width-2) << rtl_params[j].prefix << " " << rtl_params[j].value << setw(width-(rtl_params[j].prefix.size()+rtl_params[j].value.size()+1)) << "Warning, Lonely Reg" << endl;
79
    }
80
 
81
}
82
 
83
#define LINELENGTH 1024
84
 
85
void regger::ScanFiles()
86
{
87
    ifstream fin;
88
    char line[LINELENGTH];
89
 
90
    fin.open(c_file.c_str());
91
    // scan .c file
92
    // locate params and add to rtl_params
93
    while(fin)
94
    {
95
        fin.getline(line,LINELENGTH);
96
        string sline = line;
97
        int pos = sline.find("#define");
98
        if(pos != -1)
99
        {
100
            param parameter;
101
            // get name:
102
            int start = sline.find_first_not_of(" ",pos+7);
103
            int end = sline.find_first_of(" ",start+1);
104
            string name = sline.substr(start,end-start);
105
            parameter.name = name;
106
 
107
            //debug
108
          //  cout  << start << " to " << end << ", ";
109
 
110
            // get var
111
            // first locates + else set start to first none space.
112
            start = sline.find_first_of("+",end+1);
113
            if(start != -1)
114
            {
115
                // if + found, then check if there is a 0x notation
116
                start = sline.find_first_of("x",start);
117
                // in no 0x natation, "start" value after space, else "start" value after x.
118
                if(start == -1)
119
                    start = sline.find_first_not_of(" ",end+1);
120
                else
121
                {
122
                    parameter.prefix = "0x";
123
                    start +=1;
124
                }
125
            }
126
            else
127
                start = sline.find_first_not_of(" ",end+1);
128
 
129
            // make sure we are not on a space.
130
            start = sline.find_first_not_of(" ",start);
131
 
132
            // end is after ) if found
133
            end = sline.find_first_of(")",start);
134
            if(end == -1)
135
            {
136
                // if no ) found, end after space, if no space found, end in end of row
137
                end = sline.find_first_of(" ",start);
138
                if(end == -1)
139
                    end = sline.size();
140
            }
141
 
142
            //final check, do we still have 0x notation?
143
            int check = sline.find("x",start);
144
            if(check != -1 && check < end)
145
            {
146
                parameter.prefix = "0x";
147
                start = check +1;
148
            }
149
 
150
 
151
           // cout << "Errcheck: " << start << "and" << end << "," << end-start << endl;
152
            string value = sline.substr(start,end-start);
153
            parameter.value = value;
154
 
155
            // strore parameter
156
            driver_params.push_back(parameter);
157
 
158
            //debug
159
         //   cout  << start << " to " << end << " is " << name << " and " << value << endl;
160
        }
161
 
162
 
163
    }
164
    fin.close();
165
    //cout << "next file" << endl;
166
    // scan.v file
167
    // locate define and add to driver_params
168
    fin.open(verilog_file.c_str());
169
    while(fin)
170
    {
171
        fin.getline(line,LINELENGTH);
172
        string sline = line;
173
        int pos = sline.find("parameter");
174
        if(pos != -1)
175
        {
176
            param parameter;
177
            // get name:
178
            int start = sline.find_first_of(" ",pos+1);
179
            start = sline.find_first_not_of(" ",start);
180
            int end = sline.find_first_of(" ",start+1);
181
            string name = sline.substr(start,end-start);
182
            parameter.name = name;
183
 
184
            // get prefix:
185
            start = sline.find_first_of("=",end+1);
186
 
187
            start = sline.find_first_not_of(" ",start+1);
188
            end =  sline.find_first_of("h",start);
189
            if(end == -1)
190
                end = start;
191
            else
192
                end +=1;
193
 
194
            parameter.prefix = sline.substr(start,end-start);
195
 
196
 
197
            // get var:
198
            int fnutt = sline.find_first_of("'",start+1);
199
            if(fnutt != -1)
200
                start = fnutt+2;
201
 
202
            end = sline.find_first_of(";",start+1);
203
 
204
            // make sure that no "=" signs are left in value.
205
            int equalSign = sline.find_first_of("=",start);
206
            if(equalSign != -1)
207
                start = sline.find_first_not_of(" ",equalSign+1);
208
 
209
            string value = sline.substr(start,end-start);
210
            parameter.value = value;
211
 
212
            // strore parameter
213
            rtl_params.push_back(parameter);
214
 
215
            //debug
216
            //cout << start << " to " << end << " is " << name << " and " << value << endl;
217
        }
218
    }
219
    fin.close();
220
}
221
 
222
void regger::AddFile(string cfile, string rtlfile)
223
{
224
 c_file = cfile;
225
 verilog_file = rtlfile;
226
 //cout << c_file << " " << verilog_file << endl;
227
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.