diff options
Diffstat (limited to 'utils/regtools/swiss_knife.cpp')
-rw-r--r-- | utils/regtools/swiss_knife.cpp | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/utils/regtools/swiss_knife.cpp b/utils/regtools/swiss_knife.cpp index fb65b5ca24..2ea1fc4ad3 100644 --- a/utils/regtools/swiss_knife.cpp +++ b/utils/regtools/swiss_knife.cpp | |||
@@ -35,12 +35,12 @@ void print_context(const error_context_t& ctx) | |||
35 | { | 35 | { |
36 | for(size_t j = 0; j < ctx.count(); j++) | 36 | for(size_t j = 0; j < ctx.count(); j++) |
37 | { | 37 | { |
38 | error_t e = ctx.get(j); | 38 | err_t e = ctx.get(j); |
39 | switch(e.level()) | 39 | switch(e.level()) |
40 | { | 40 | { |
41 | case error_t::INFO: printf("[INFO]"); break; | 41 | case err_t::INFO: printf("[INFO]"); break; |
42 | case error_t::WARNING: printf("[WARN]"); break; | 42 | case err_t::WARNING: printf("[WARN]"); break; |
43 | case error_t::FATAL: printf("[FATAL]"); break; | 43 | case err_t::FATAL: printf("[FATAL]"); break; |
44 | default: printf("[UNK]"); break; | 44 | default: printf("[UNK]"); break; |
45 | } | 45 | } |
46 | if(e.location().size() != 0) | 46 | if(e.location().size() != 0) |
@@ -110,7 +110,7 @@ bool convert_v1_to_v2(const soc_desc_v1::soc_reg_t& in, node_t& out, error_conte | |||
110 | soc_word_t base = 0, stride = 0; | 110 | soc_word_t base = 0, stride = 0; |
111 | if(in.addr.size() <= 1) | 111 | if(in.addr.size() <= 1) |
112 | { | 112 | { |
113 | ctx.add(error_t(error_t::WARNING, loc, | 113 | ctx.add(err_t(err_t::WARNING, loc, |
114 | "register uses a formula but has only one instance")); | 114 | "register uses a formula but has only one instance")); |
115 | is_stride = false; | 115 | is_stride = false; |
116 | } | 116 | } |
@@ -125,7 +125,7 @@ bool convert_v1_to_v2(const soc_desc_v1::soc_reg_t& in, node_t& out, error_conte | |||
125 | 125 | ||
126 | if(is_stride) | 126 | if(is_stride) |
127 | { | 127 | { |
128 | ctx.add(error_t(error_t::INFO, loc, "promoted formula to base/stride")); | 128 | ctx.add(err_t(err_t::INFO, loc, "promoted formula to base/stride")); |
129 | out.instance[0].range.type = range_t::STRIDE; | 129 | out.instance[0].range.type = range_t::STRIDE; |
130 | out.instance[0].range.base = base; | 130 | out.instance[0].range.base = base; |
131 | out.instance[0].range.stride = stride; | 131 | out.instance[0].range.stride = stride; |
@@ -167,7 +167,7 @@ bool convert_v1_to_v2(const soc_desc_v1::soc_dev_t& in, node_t& out, error_conte | |||
167 | { | 167 | { |
168 | std::string loc = _loc + "." + in.name; | 168 | std::string loc = _loc + "." + in.name; |
169 | if(!in.version.empty()) | 169 | if(!in.version.empty()) |
170 | ctx.add(error_t(error_t::INFO, loc, "dropped version")); | 170 | ctx.add(err_t(err_t::INFO, loc, "dropped version")); |
171 | out.name = in.name; | 171 | out.name = in.name; |
172 | out.title = in.long_name; | 172 | out.title = in.long_name; |
173 | out.desc = in.desc; | 173 | out.desc = in.desc; |
@@ -330,10 +330,10 @@ int do_write(int argc, char **argv) | |||
330 | void check_name(const std::string& path, const std::string& name, error_context_t& ctx) | 330 | void check_name(const std::string& path, const std::string& name, error_context_t& ctx) |
331 | { | 331 | { |
332 | if(name.empty()) | 332 | if(name.empty()) |
333 | ctx.add(error_t(error_t::FATAL, path, "name is empty")); | 333 | ctx.add(err_t(err_t::FATAL, path, "name is empty")); |
334 | for(size_t i = 0; i < name.size(); i++) | 334 | for(size_t i = 0; i < name.size(); i++) |
335 | if(!isalnum(name[i]) && name[i] != '_') | 335 | if(!isalnum(name[i]) && name[i] != '_') |
336 | ctx.add(error_t(error_t::FATAL, path, "name '" + name + | 336 | ctx.add(err_t(err_t::FATAL, path, "name '" + name + |
337 | "' must only contain alphanumeric characters or '_'")); | 337 | "' must only contain alphanumeric characters or '_'")); |
338 | } | 338 | } |
339 | 339 | ||
@@ -351,7 +351,7 @@ void check_instance(const std::string& _path, const instance_t& inst, error_cont | |||
351 | var[inst.range.variable] = inst.range.first; | 351 | var[inst.range.variable] = inst.range.first; |
352 | soc_word_t res; | 352 | soc_word_t res; |
353 | if(!evaluate_formula(inst.range.formula, var, res, path + ".<formula>", ctx)) | 353 | if(!evaluate_formula(inst.range.formula, var, res, path + ".<formula>", ctx)) |
354 | ctx.add(error_t(error_t::FATAL, path + ".<formula>", | 354 | ctx.add(err_t(err_t::FATAL, path + ".<formula>", |
355 | "cannot evaluate formula")); | 355 | "cannot evaluate formula")); |
356 | } | 356 | } |
357 | } | 357 | } |
@@ -362,7 +362,7 @@ void check_field(const std::string& _path, const field_t& field, error_context_t | |||
362 | std::string path = _path + "." + field.name; | 362 | std::string path = _path + "." + field.name; |
363 | check_name(path, field.name, ctx); | 363 | check_name(path, field.name, ctx); |
364 | if(field.width == 0) | 364 | if(field.width == 0) |
365 | ctx.add(error_t(error_t::WARNING, path, "field has width 0")); | 365 | ctx.add(err_t(err_t::WARNING, path, "field has width 0")); |
366 | soc_word_t max = field.bitmask() >> field.pos; | 366 | soc_word_t max = field.bitmask() >> field.pos; |
367 | std::set< std::string > names; | 367 | std::set< std::string > names; |
368 | std::map< soc_word_t, std::string > map; | 368 | std::map< soc_word_t, std::string > map; |
@@ -373,12 +373,12 @@ void check_field(const std::string& _path, const field_t& field, error_context_t | |||
373 | std::string path_ = path + "." + n; | 373 | std::string path_ = path + "." + n; |
374 | check_name(path_, n, ctx); | 374 | check_name(path_, n, ctx); |
375 | if(v > max) | 375 | if(v > max) |
376 | ctx.add(error_t(error_t::FATAL, path_, "value does not fit into the field")); | 376 | ctx.add(err_t(err_t::FATAL, path_, "value does not fit into the field")); |
377 | if(names.find(n) != names.end()) | 377 | if(names.find(n) != names.end()) |
378 | ctx.add(error_t(error_t::FATAL, path, "duplicate name '" + n + "' in enums")); | 378 | ctx.add(err_t(err_t::FATAL, path, "duplicate name '" + n + "' in enums")); |
379 | names.insert(n); | 379 | names.insert(n); |
380 | if(map.find(v) != map.end()) | 380 | if(map.find(v) != map.end()) |
381 | ctx.add(error_t(error_t::WARNING, path, "'" + n + "' and '" + map[v] + "' have the same value")); | 381 | ctx.add(err_t(err_t::WARNING, path, "'" + n + "' and '" + map[v] + "' have the same value")); |
382 | map[v] = n; | 382 | map[v] = n; |
383 | } | 383 | } |
384 | } | 384 | } |
@@ -387,7 +387,7 @@ void check_register(const std::string& _path, const soc_desc::register_t& reg, e | |||
387 | { | 387 | { |
388 | std::string path = _path + ".<register>"; | 388 | std::string path = _path + ".<register>"; |
389 | if(reg.width != 8 && reg.width != 16 && reg.width != 32) | 389 | if(reg.width != 8 && reg.width != 16 && reg.width != 32) |
390 | ctx.add(error_t(error_t::WARNING, path, "width is not 8, 16 or 32")); | 390 | ctx.add(err_t(err_t::WARNING, path, "width is not 8, 16 or 32")); |
391 | for(size_t i = 0; i < reg.field.size(); i++) | 391 | for(size_t i = 0; i < reg.field.size(); i++) |
392 | check_field(path, reg.field[i], ctx); | 392 | check_field(path, reg.field[i], ctx); |
393 | std::set< std::string > names; | 393 | std::set< std::string > names; |
@@ -396,16 +396,16 @@ void check_register(const std::string& _path, const soc_desc::register_t& reg, e | |||
396 | { | 396 | { |
397 | std::string n = reg.field[i].name; | 397 | std::string n = reg.field[i].name; |
398 | if(names.find(n) != names.end()) | 398 | if(names.find(n) != names.end()) |
399 | ctx.add(error_t(error_t::FATAL, path, "duplicate name '" + n + "' in fields")); | 399 | ctx.add(err_t(err_t::FATAL, path, "duplicate name '" + n + "' in fields")); |
400 | if(reg.field[i].pos + reg.field[i].width > reg.width) | 400 | if(reg.field[i].pos + reg.field[i].width > reg.width) |
401 | ctx.add(error_t(error_t::FATAL, path, "field '" + n + "' does not fit into the register")); | 401 | ctx.add(err_t(err_t::FATAL, path, "field '" + n + "' does not fit into the register")); |
402 | names.insert(n); | 402 | names.insert(n); |
403 | if(bitmap & reg.field[i].bitmask()) | 403 | if(bitmap & reg.field[i].bitmask()) |
404 | { | 404 | { |
405 | /* find the duplicate to ease debugging */ | 405 | /* find the duplicate to ease debugging */ |
406 | for(size_t j = 0; j < i; j++) | 406 | for(size_t j = 0; j < i; j++) |
407 | if(reg.field[j].bitmask() & reg.field[i].bitmask()) | 407 | if(reg.field[j].bitmask() & reg.field[i].bitmask()) |
408 | ctx.add(error_t(error_t::FATAL, path, "overlap between fields '" + | 408 | ctx.add(err_t(err_t::FATAL, path, "overlap between fields '" + |
409 | reg.field[j].name + "' and '" + n + "'")); | 409 | reg.field[j].name + "' and '" + n + "'")); |
410 | } | 410 | } |
411 | bitmap |= reg.field[i].bitmask(); | 411 | bitmap |= reg.field[i].bitmask(); |
@@ -420,7 +420,7 @@ void check_node(const std::string& _path, const node_t& node, error_context_t& c | |||
420 | std::string path = _path + "." + node.name; | 420 | std::string path = _path + "." + node.name; |
421 | check_name(_path, node.name, ctx); | 421 | check_name(_path, node.name, ctx); |
422 | if(node.instance.empty()) | 422 | if(node.instance.empty()) |
423 | ctx.add(error_t(error_t::WARNING, path, "subnode with no instances")); | 423 | ctx.add(err_t(err_t::WARNING, path, "subnode with no instances")); |
424 | for(size_t j = 0; j < node.instance.size(); j++) | 424 | for(size_t j = 0; j < node.instance.size(); j++) |
425 | check_instance(path, node.instance[j], ctx); | 425 | check_instance(path, node.instance[j], ctx); |
426 | for(size_t i = 0; i < node.register_.size(); i++) | 426 | for(size_t i = 0; i < node.register_.size(); i++) |
@@ -440,7 +440,7 @@ void check_nodes(const std::string& path, const std::vector< node_t >& nodes, | |||
440 | { | 440 | { |
441 | std::string n = nodes[i].instance[j].name; | 441 | std::string n = nodes[i].instance[j].name; |
442 | if(names.find(n) != names.end()) | 442 | if(names.find(n) != names.end()) |
443 | ctx.add(error_t(error_t::FATAL, path, "duplicate instance name '" + | 443 | ctx.add(err_t(err_t::FATAL, path, "duplicate instance name '" + |
444 | n + "' in subnodes")); | 444 | n + "' in subnodes")); |
445 | names.insert(n); | 445 | names.insert(n); |
446 | } | 446 | } |
@@ -450,7 +450,7 @@ void check_nodes(const std::string& path, const std::vector< node_t >& nodes, | |||
450 | { | 450 | { |
451 | std::string n = nodes[i].name; | 451 | std::string n = nodes[i].name; |
452 | if(names.find(n) != names.end()) | 452 | if(names.find(n) != names.end()) |
453 | ctx.add(error_t(error_t::FATAL, path, "duplicate node name '" + n + | 453 | ctx.add(err_t(err_t::FATAL, path, "duplicate node name '" + n + |
454 | "' in subnodes")); | 454 | "' in subnodes")); |
455 | names.insert(n); | 455 | names.insert(n); |
456 | } | 456 | } |
@@ -832,4 +832,4 @@ int main(int argc, char **argv) | |||
832 | else | 832 | else |
833 | usage(); | 833 | usage(); |
834 | return 0; | 834 | return 0; |
835 | } \ No newline at end of file | 835 | } |