stage4/generate_c/generate_c.cc
changeset 248 9cb18ec14fa2
parent 244 3a478229db8b
child 250 5d2927300e2c
equal deleted inserted replaced
247:560075ece524 248:9cb18ec14fa2
  1483           if (symbol->single_data_source != NULL) {
  1483           if (symbol->single_data_source != NULL) {
  1484             s4o.print(s4o.indent_spaces + "R_TRIG");
  1484             s4o.print(s4o.indent_spaces + "R_TRIG");
  1485             s4o.print(FB_INIT_SUFFIX);
  1485             s4o.print(FB_INIT_SUFFIX);
  1486             s4o.print("(&");
  1486             s4o.print("(&");
  1487             current_task_name->accept(*this);
  1487             current_task_name->accept(*this);
  1488             s4o.print("_R_TRIG);\n");
  1488             s4o.print("_R_TRIG, retain);\n");
  1489           }
  1489           }
  1490           break;
  1490           break;
  1491         case run_dt:
  1491         case run_dt:
  1492           if (symbol->single_data_source != NULL) {
  1492           if (symbol->single_data_source != NULL) {
  1493             symbol_c *config_var_decl = NULL;
  1493             symbol_c *config_var_decl = NULL;
  1494             symbol_c *res_var_decl = NULL;
  1494             symbol_c *res_var_decl = NULL;
       
  1495             unsigned int vartype;
  1495             symbol_c *current_var_reference = ((global_var_reference_c *)(symbol->single_data_source))->global_var_name;
  1496             symbol_c *current_var_reference = ((global_var_reference_c *)(symbol->single_data_source))->global_var_name;
  1496             res_var_decl = search_resource_instance->get_decl(current_var_reference);
  1497             res_var_decl = search_resource_instance->get_decl(current_var_reference);
  1497             if (res_var_decl == NULL) {
  1498             if (res_var_decl == NULL) {
  1498               config_var_decl = search_config_instance->get_decl(current_var_reference);
  1499               config_var_decl = search_config_instance->get_decl(current_var_reference);
  1499               if (config_var_decl == NULL)
  1500               if (config_var_decl == NULL)
  1500                 ERROR;
  1501                 ERROR;
       
  1502               vartype = search_config_instance->get_vartype();
  1501               s4o.print(s4o.indent_spaces + "{extern ");
  1503               s4o.print(s4o.indent_spaces + "{extern ");
  1502               config_var_decl->accept(*this);
  1504               config_var_decl->accept(*this);
  1503               s4o.print(" *");
  1505               s4o.print(" *");
  1504               symbol->single_data_source->accept(*this);
  1506               symbol->single_data_source->accept(*this);
  1505               s4o.print("; ");
  1507               s4o.print("; ");
  1506             }
  1508             }
  1507             else
  1509             else {
       
  1510               vartype = search_resource_instance->get_vartype();
  1508               s4o.print(s4o.indent_spaces);
  1511               s4o.print(s4o.indent_spaces);
       
  1512             }
       
  1513             s4o.print(SET_VAR);
       
  1514             s4o.print("(");
  1509             current_task_name->accept(*this);
  1515             current_task_name->accept(*this);
  1510             s4o.print("_R_TRIG.CLK = *");
  1516             s4o.print("_R_TRIG.CLK, *__GET_GLOBAL_");
  1511             symbol->single_data_source->accept(*this);
  1517             symbol->single_data_source->accept(*this);
  1512             s4o.print(";");
  1518             s4o.print("());");
  1513             if (config_var_decl != NULL)
  1519             if (config_var_decl != NULL)
  1514               s4o.print("}");
  1520               s4o.print("}");
  1515             s4o.print("\n");
  1521             s4o.print("\n");
  1516             s4o.print(s4o.indent_spaces + "R_TRIG");
  1522             s4o.print(s4o.indent_spaces + "R_TRIG");
  1517             s4o.print(FB_FUNCTION_SUFFIX);
  1523             s4o.print(FB_FUNCTION_SUFFIX);
  1519             current_task_name->accept(*this);
  1525             current_task_name->accept(*this);
  1520             s4o.print("_R_TRIG);\n");
  1526             s4o.print("_R_TRIG);\n");
  1521             s4o.print(s4o.indent_spaces);
  1527             s4o.print(s4o.indent_spaces);
  1522             current_task_name->accept(*this);
  1528             current_task_name->accept(*this);
  1523             s4o.print(" = ");
  1529             s4o.print(" = ");
       
  1530             s4o.print(GET_VAR);
       
  1531             s4o.print("(");
  1524             current_task_name->accept(*this);
  1532             current_task_name->accept(*this);
  1525             s4o.print("_R_TRIG.Q");
  1533             s4o.print("_R_TRIG.Q)");
  1526           }
  1534           }
  1527           else {
  1535           else {
  1528             s4o.print(s4o.indent_spaces);
  1536             s4o.print(s4o.indent_spaces);
  1529             current_task_name->accept(*this);
  1537             current_task_name->accept(*this);
  1530             s4o.print(" = ");
  1538             s4o.print(" = ");
  1743       current_configuration = symbol;
  1751       current_configuration = symbol;
  1744       
  1752       
  1745       calculate_common_ticktime_c calculate_common_ticktime;
  1753       calculate_common_ticktime_c calculate_common_ticktime;
  1746       symbol->accept(calculate_common_ticktime);
  1754       symbol->accept(calculate_common_ticktime);
  1747       common_ticktime = calculate_common_ticktime.get_common_ticktime();
  1755       common_ticktime = calculate_common_ticktime.get_common_ticktime();
       
  1756       if (common_ticktime == 0) {
       
  1757         fprintf(stderr, "\nYou must at least define a periodic task to set cycle period!");
       
  1758         ERROR;
       
  1759       }
  1748       
  1760       
  1749       symbol->configuration_name->accept(*this);
  1761       symbol->configuration_name->accept(*this);
  1750       stage4out_c config_s4o(current_builddir, current_name, "c");
  1762       stage4out_c config_s4o(current_builddir, current_name, "c");
  1751       generate_c_config_c generate_c_config(&config_s4o);
  1763       generate_c_config_c generate_c_config(&config_s4o);
  1752       symbol->accept(generate_c_config);
  1764       symbol->accept(generate_c_config);