Module: RCSimCinterface

Defined in:
ext/hruby_sim/hruby_rcsim_build.c

Constant Summary collapse

CPorts =
RCSimCports

Class Method Summary collapse

Class Method Details

.rcsim_add_behavior_events(behaviorV, eventVs) ⇒ Object

Adds events to a C behavior.



1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1137

VALUE rcsim_add_behavior_events(VALUE mod, VALUE behaviorV, VALUE eventVs) {
    /* Get the C behavior from the Ruby value. */
    Behavior behavior;
    value_to_rcsim(BehaviorS,behaviorV,behavior);
    // printf("rcsim_add_behavior_events with behavior=%p\n",behavior);
    /* Prepare the size for the events. */
    long num = RARRAY_LEN(eventVs);
    long old_num = behavior->num_events;
    behavior->num_events += num;
    // printf("first behavior->events=%p\n",behavior->events); fflush(stdout);
    behavior->events = realloc(behavior->events,
                               sizeof(Event[behavior->num_events]));
    // behavior->events = (Event*)my_realloc(behavior->events,
    //         sizeof(Event[old_num]), sizeof(Event[behavior->num_events]));
    // printf("now behavior->events=%p\n",behavior->events); fflush(stdout);
    // printf("access test: %p\n",behavior->events[0]); fflush(stdout);
    /* Get and add the events from the Ruby value. */
    for(long i=0; i< num; ++i) {
        Event event;
        // show_access(behavior->events,old_num+i);
        value_to_rcsim(EventS,rb_ary_entry(eventVs,i),event);
        behavior->events[old_num + i] = event;
        /* Update the signal of the event to say it activates the behavior. */
        SignalI sig = event->signal;
        switch(event->edge) {
            case ANYEDGE:
                sig->num_any++;
    // printf("first sig->any=%p\n",sig->any); fflush(stdout);
                sig->any = realloc(sig->any,sizeof(Object[sig->num_any]));
                // sig->any = (Object*)my_realloc(sig->any,
                //     sizeof(Object[sig->num_any-1]),sizeof(Object[sig->num_any]));
    // printf("now sig->any=%p\n",sig->any); fflush(stdout);
    // printf("access test: %p\n",sig->any[0]); fflush(stdout);
        // show_access(sig->any,sig->num_any-1);
                // printf("sig->any=%p\n",sig->any);
                sig->any[sig->num_any-1] = (Object)behavior;
                break;
            case POSEDGE:
                sig->num_pos++;
    // printf("first sig->pos=%p\n",sig->pos); fflush(stdout);
                sig->pos = realloc(sig->pos,sizeof(Object[sig->num_pos]));
                // sig->pos = (Object*)my_realloc(sig->pos,
                //     sizeof(Object[sig->num_pos-1]),sizeof(Object[sig->num_pos]));
    // printf("now sig->pos=%p\n",sig->pos); fflush(stdout);
    // printf("access test: %p\n",sig->pos[0]); fflush(stdout);
        // show_access(sig->pos,sig->num_pos-1);
                // printf("sig->pos=%p\n",sig->pos);
                sig->pos[sig->num_pos-1] = (Object)behavior;
                break;
            case NEGEDGE:
                sig->num_neg++;
    // printf("first sig->neg=%p\n",sig->neg); fflush(stdout);
                sig->neg = realloc(sig->neg,sizeof(Object[sig->num_neg]));
                // sig->neg = (Object*)my_realloc(sig->neg,
                //     sizeof(Object[sig->num_neg-1]),sizeof(Object[sig->num_neg]));
    // printf("now sig->neg=%p\n",sig->neg); fflush(stdout);
    // printf("access test: %p\n",sig->neg[0]); fflush(stdout);
        // show_access(sig->neg,sig->num_neg-1);
                // printf("sig->neg=%p\n",sig->neg);
                sig->neg[sig->num_neg-1] = (Object)behavior;
                break;
            default:
                perror("Invalid value for an edge.");
        }
    }
    return behaviorV;
}

.rcsim_add_block_inners(blockV, sigVs) ⇒ Object

Adds inners to a C block.



1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1404

VALUE rcsim_add_block_inners(VALUE mod, VALUE blockV, VALUE sigVs) {
    /* Get the C block from the Ruby value. */
    Block block;
    value_to_rcsim(BlockS,blockV,block);
    // printf("rcsim_add_block_inners with block=%p\n",block);
    /* Prepare the size for the inners. */
    long num = RARRAY_LEN(sigVs);
    long old_num = block->num_inners;
    block->num_inners += num;
    // printf("first block->inners=%p\n",block->inners); fflush(stdout);
    block->inners = realloc(block->inners,
            sizeof(SignalI[block->num_inners]));
    // block->inners = (SignalI*)my_realloc(block->inners,
    //         sizeof(SignalI[old_num]), sizeof(SignalI[block->num_inners]));
    // printf("now block->inners=%p\n",block->inners); fflush(stdout);
    // printf("access test: %p\n",block->inners[0]); fflush(stdout);
    /* Get and add the signals from the Ruby value. */
    for(long i=0; i< num; ++i) {
        SignalI sig;
        // show_access(block->inners,old_num+i);
        value_to_rcsim(SignalIS,rb_ary_entry(sigVs,i),sig);
        block->inners[old_num + i] = sig;
    }
    return blockV;
}

.rcsim_add_block_statements(blockV, stmntVs) ⇒ Object

Adds statements to a C block.



1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1431

VALUE rcsim_add_block_statements(VALUE mod, VALUE blockV, VALUE stmntVs) {
    /* Get the C block from the Ruby value. */
    Block block;
    value_to_rcsim(BlockS,blockV,block);
    // printf("rcsim_add_block_statements with block=%p\n",block);
    /* Prepare the size for the statements. */
    long num = RARRAY_LEN(stmntVs);
    long old_num = block->num_stmnts;
    block->num_stmnts += num;
    // printf("first block->stmnts=%p\n",block->stmnts); fflush(stdout);
    block->stmnts = realloc(block->stmnts,
            sizeof(Statement[block->num_stmnts]));
    // block->stmnts = (Statement*)my_realloc(block->stmnts,
    //         sizeof(Statement[old_num]), sizeof(Statement[block->num_stmnts]));
    // printf("now block->stmnts=%p\n",block->stmnts); fflush(stdout);
    // printf("access test: %p\n",block->stmnts[0]); fflush(stdout);
    /* Get and add the statements from the Ruby value. */
    for(long i=0; i< num; ++i) {
        Statement stmnt;
        // show_access(block->stmnts,old_num+i);
        value_to_rcsim(StatementS,rb_ary_entry(stmntVs,i),stmnt);
        block->stmnts[old_num + i] = stmnt;
    }
    return blockV;
}

.rcsim_add_code_events(codeV, eventVs) ⇒ Object

Adds events to a C code.



1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1207

VALUE rcsim_add_code_events(VALUE mod, VALUE codeV, VALUE eventVs) {
    /* Get the C code from the Ruby value. */
    Code code;
    value_to_rcsim(CodeS,codeV,code);
    // printf("rcsim_add_codee_events with code=%p\n",code);
    /* Prepare the size for the events. */
    long num = RARRAY_LEN(eventVs);
    long old_num = code->num_events;
    code->num_events += num;
    // printf("first code->events=%p\n",code->events); fflush(stdout);
    code->events = realloc(code->events,
                               sizeof(Event[code->num_events]));
    // printf("now code->events=%p\n",code->events); fflush(stdout);
    // printf("access test: %p\n",code->events[0]); fflush(stdout);
    /* Get and add the events from the Ruby value. */
    for(long i=0; i< num; ++i) {
        Event event;
        value_to_rcsim(EventS,rb_ary_entry(eventVs,i),event);
        code->events[old_num + i] = event;
        /* Update the signal of the event to say it activates the code. */
        SignalI sig = event->signal;
        switch(event->edge) {
            case ANYEDGE:
                sig->num_any++;
                sig->any = realloc(sig->any,sizeof(Object[sig->num_any]));
                sig->any[sig->num_any-1] = (Object)code;
                break;
            case POSEDGE:
                sig->num_pos++;
                sig->pos = realloc(sig->pos,sizeof(Object[sig->num_pos]));
                sig->pos[sig->num_pos-1] = (Object)code;
                break;
            case NEGEDGE:
                sig->num_neg++;
                sig->neg = realloc(sig->neg,sizeof(Object[sig->num_neg]));
                sig->neg[sig->num_neg-1] = (Object)code;
                break;
            default:
                perror("Invalid value for an edge.");
        }
    }
    return codeV;
}

.rcsim_add_concat_expressions(concatV, exprVs) ⇒ Object

Adds expressions to a C concat.



1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1485

VALUE rcsim_add_concat_expressions(VALUE mod, VALUE concatV, VALUE exprVs) {
    /* Get the C concat from the Ruby value. */
    Concat concat;
    value_to_rcsim(ConcatS,concatV,concat);
    // printf("rcsim_add_concat_expressions with concat=%p\n",concat);
    /* Prepare the size for the expressions. */
    long num = RARRAY_LEN(exprVs);
    long old_num = concat->num_exprs;
    // printf("add_concat_expressions with num=%li old_num=%li\n",num,old_num);
    concat->num_exprs += num;
    // printf("first concat->exprs=%p\n",concat->exprs); fflush(stdout);
    concat->exprs = realloc(concat->exprs,
            sizeof(Expression[concat->num_exprs]));
    // concat->exprs = (Expression*)my_realloc(concat->exprs,
    //         sizeof(Expression[old_num]), sizeof(Expression[concat->num_exprs]));
    // printf("now concat->exprs=%p\n",concat->exprs); fflush(stdout);
    // printf("access test: %p\n",concat->exprs[0]); fflush(stdout);
    /* Get and add the expressions from the Ruby value. */
    for(long i=0; i< num; ++i) {
        Expression expr;
        // show_access(concat->exprs,old_num+i);
        value_to_rcsim(ExpressionS,rb_ary_entry(exprVs,i),expr);
        concat->exprs[old_num + i] = expr;
    }
    return concatV;
}

.rcsim_add_hcase_whens(hcaseV, matchVs, stmntVs) ⇒ Object

Adds whens to a C hardware case.



1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1366

VALUE rcsim_add_hcase_whens(VALUE mod, VALUE hcaseV, VALUE matchVs, VALUE stmntVs) {
    /* Get the C hardware case from the Ruby value. */
    HCase hcase;
    value_to_rcsim(HCaseS,hcaseV,hcase);
    // printf("rcsim_add_hcase_whens with hcase=%p\n",hcase);
    /* Prepare the size for the noifs. */
    long num = RARRAY_LEN(matchVs);
    long old_num = hcase->num_whens;
    hcase->num_whens += num;
    // printf("first hcase->matches=%p\n",hcase->matches); fflush(stdout);
    // printf("first hcase->stmnts=%p\n",hcase->stmnts); fflush(stdout);
    hcase->matches = realloc(hcase->matches,
                             sizeof(Expression[hcase->num_whens]));
    // hcase->matches = (Expression*)my_realloc(hcase->matches,
    //         sizeof(Expression[old_num]), sizeof(Expression[hcase->num_whens]));
    // printf("now hcase->matches=%p\n",hcase->matches); fflush(stdout);
    // printf("access test: %p\n",hcase->matches[0]); fflush(stdout);
    hcase->stmnts = realloc(hcase->stmnts,
                            sizeof(Statement[hcase->num_whens]));
    // hcase->stmnts = (Statement*)my_realloc(hcase->stmnts,
    //         sizeof(Statement[old_num]), sizeof(Statement[hcase->num_whens]));
    // printf("now hcase->stmnts=%p\n",hcase->stmnts); fflush(stdout);
    // printf("access test: %p\n",hcase->stmnts[0]); fflush(stdout);
    /* Get and add the whens from the Ruby value. */
    for(long i=0; i< num; ++i) {
        Expression match;
        Statement stmnt;
        // show_access(hcase->matches,old_num+i);
        // show_access(hcase->stmnts,old_num+i);
        value_to_rcsim(ExpressionS,rb_ary_entry(matchVs,i),match);
        hcase->matches[old_num + i] = match;
        value_to_rcsim(StatementS,rb_ary_entry(stmntVs,i),stmnt);
        hcase->stmnts[old_num + i] = stmnt;
    }
    return hcaseV;
}

.rcsim_add_hif_noifs(hifV, condVs, stmntVs) ⇒ Object

Adds noifs to a C hardware if.



1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1330

VALUE rcsim_add_hif_noifs(VALUE mod, VALUE hifV, VALUE condVs, VALUE stmntVs) {
    /* Get the C hardware if from the Ruby value. */
    HIf hif;
    value_to_rcsim(HIfS,hifV,hif);
    // printf("rcsim_add_hif_noifs with hif=%p\n",hif);
    /* Prepare the size for the noifs. */
    long num = RARRAY_LEN(condVs);
    long old_num = hif->num_noifs;
    hif->num_noifs += num;
    // printf("first hif->noconds=%p\n",hif->noconds); fflush(stdout);
    // printf("first hif->nostmnts=%p\n",hif->nostmnts); fflush(stdout);
    hif->noconds = realloc(hif->noconds,sizeof(Expression[hif->num_noifs]));
    // hif->noconds = (Expression*)my_realloc(hif->noconds,
    //         sizeof(Expression[old_num]),sizeof(Expression[hif->num_noifs]));
    // printf("now hif->noconds=%p\n",hif->noconds); fflush(stdout);
    // printf("access test: %p\n",hif->noconds[0]); fflush(stdout);
    hif->nostmnts = realloc(hif->nostmnts,sizeof(Statement[hif->num_noifs]));
    // hif->nostmnts = (Statement*)my_realloc(hif->nostmnts,
    //         sizeof(Statement[old_num]),sizeof(Statement[hif->num_noifs]));
    // printf("now hif->nostmnts=%p\n",hif->nostmnts); fflush(stdout);
    // printf("access test: %p\n",hif->nostmnts[0]); fflush(stdout);
    /* Get and add the noifs from the Ruby value. */
    for(long i=0; i< num; ++i) {
        Expression cond;
        Statement stmnt;
        // show_access(hif->noconds,old_num+i);
        // show_access(hif->nostmnts,old_num+i);
        value_to_rcsim(ExpressionS,rb_ary_entry(condVs,i),cond);
        hif->noconds[old_num + i] = cond;
        value_to_rcsim(StatementS,rb_ary_entry(stmntVs,i),stmnt);
        hif->nostmnts[old_num + i] = stmnt;
    }
    return hifV;
}

.rcsim_add_print_args(printV, argVs) ⇒ Object

Adds arguments to a C print.



1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1303

VALUE rcsim_add_print_args(VALUE mod, VALUE printV, VALUE argVs) {
    /* Get the C print from the Ruby value. */
    Print print;
    value_to_rcsim(PrintS,printV,print);
    // printf("rcsim_add_print_args with print=%p\n",print);
    /* Prepare the size for the arguments. */
    long num = RARRAY_LEN(argVs);
    long old_num = print->num_args;
    print->num_args += num;
    // printf("first print->args=%p\n",print->args); fflush(stdout);
    print->args = realloc(print->args,
                          sizeof(Expression[print->num_args]));
    // print->args = (Expression*)my_realloc(print->args,
    //         sizeof(Expression[old_num]), sizeof(Expression[print->num_args]));
    // printf("now print->args=%p\n",print->args); fflush(stdout);
    // printf("access test: %p\n",print->args[0]); fflush(stdout);
    /* Get and add the arguments from the Ruby value. */
    for(long i=0; i< num; ++i) {
        Expression arg;
        // show_access(print->args,old_num+i);
        value_to_rcsim(ExpressionS,rb_ary_entry(argVs,i),arg);
        print->args[old_num + i] = arg;
    }
    return printV;
}

.rcsim_add_refConcat_refs(refConcatV, refVs) ⇒ Object

Adds references to a C ref concat.



1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1513

VALUE rcsim_add_refConcat_refs(VALUE mod, VALUE refConcatV, VALUE refVs) {
    /* Get the C refConcat from the Ruby value. */
    RefConcat refConcat;
    value_to_rcsim(RefConcatS,refConcatV,refConcat);
    // printf("rcsim_add_refConcat_refs with refConcat=%p\n",refConcat);
    /* Prepare the size for the references. */
    long num = RARRAY_LEN(refVs);
    long old_num = refConcat->num_refs;
    refConcat->num_refs += num;
    // printf("first refConcat->refs=%p\n",refConcat->refs); fflush(stdout);
    refConcat->refs = realloc(refConcat->refs,
            sizeof(Reference[refConcat->num_refs]));
    // refConcat->refs = (Reference*)my_realloc(refConcat->refs,
    //         sizeof(Reference[old_num]), sizeof(Reference[refConcat->num_refs]));
    // printf("now refConcat->refs=%p\n",refConcat->refs); fflush(stdout);
    // printf("access test: %p\n",refConcat->refs[0]); fflush(stdout);
    /* Get and add the references from the Ruby value. */
    for(long i=0; i< num; ++i) {
        Reference ref;
        // show_access(refConcat->refs,old_num+i);
        value_to_rcsim(ReferenceS,rb_ary_entry(refVs,i),ref);
        refConcat->refs[old_num + i] = ref;
        // printf("ref=%p ref &type=%p type=%p width=%llu\n",ref,&(ref->type),ref->type,type_width(ref->type));
    }
    return refConcatV;
}

.rcsim_add_scope_behaviors(scopeV, behVs) ⇒ Object

Adds behaviors to a C scope.



1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1029

VALUE rcsim_add_scope_behaviors(VALUE mod, VALUE scopeV, VALUE behVs) {
    // printf("rcsim_add_scope_behaviors\n");
    /* Get the C scope from the Ruby value. */
    Scope scope;
    value_to_rcsim(ScopeS,scopeV,scope);
    // printf("rcsim_add_scope_behaviors with scope=%p\n",scope);
    /* Prepare the size for the behaviors. */
    long num = RARRAY_LEN(behVs);
    long old_num = scope->num_behaviors;
    // printf("num=%lu old_num=%lu\n",num,old_num);
    // printf("scope->behaviors=%p\n",scope->behaviors);
    scope->num_behaviors += num;
    // printf("first scope->behaviors=%p\n",scope->behaviors); fflush(stdout);
    scope->behaviors = realloc(scope->behaviors,
                               sizeof(Behavior[scope->num_behaviors]));
    // scope->behaviors = (Behavior*)my_realloc(scope->behaviors,
    //         sizeof(Behavior[old_num]), sizeof(Behavior[scope->num_behaviors]));
    // printf("now scope->behaviors=%p\n",scope->behaviors); fflush(stdout);
    // printf("access test: %p\n",scope->behaviors[0]); fflush(stdout);
    /* Get and add the behaviors from the Ruby value. */
    for(long i=0; i< num; ++i) {
        Behavior beh;
        // show_access(scope->behaviors,old_num+i);
        value_to_rcsim(BehaviorS,rb_ary_entry(behVs,i),beh);
        scope->behaviors[old_num + i] = beh;
    }
    return scopeV;
}

.rcsim_add_scope_codes(scopeV, codeVs) ⇒ Object

Adds codes to a C scope.



1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1086

VALUE rcsim_add_scope_codes(VALUE mod, VALUE scopeV, VALUE codeVs) {
    /* Get the C scope from the Ruby value. */
    Scope scope;
    value_to_rcsim(ScopeS,scopeV,scope);
    // printf("rcsim_add_scope_codes with scope=%p\n",scope);
    /* Prepare the size for the codes. */
    long num = RARRAY_LEN(codeVs);
    long old_num = scope->num_codes;
    scope->num_codes += num;
    // printf("first scope->codes=%p\n",scope->codes); fflush(stdout);
    scope->codes = realloc(scope->codes,
                            sizeof(Code[scope->num_codes]));
    // printf("now scope->codes=%p\n",scope->codes); fflush(stdout);
    // printf("access test: %p\n",scope->codes[0]); fflush(stdout);
    /* Get and add the codes from the Ruby value. */
    for(long i=0; i< num; ++i) {
        Code code;
        value_to_rcsim(CodeS,rb_ary_entry(codeVs,i),code);
        scope->codes[old_num + i] = code;
    }
    return scopeV;
}

.rcsim_add_scope_inners(scopeV, sigVs) ⇒ Object

Adds inners to a C scope.



1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1002

VALUE rcsim_add_scope_inners(VALUE mod, VALUE scopeV, VALUE sigVs) {
    /* Get the C scope from the Ruby value. */
    Scope scope;
    value_to_rcsim(ScopeS,scopeV,scope);
    // printf("rcsim_add_scope_inners with scope=%p\n",scope);
    /* Prepare the size for the inners. */
    long num = RARRAY_LEN(sigVs);
    long old_num = scope->num_inners;
    scope->num_inners += num;
    // printf("first scope->inners=%p\n",scope->inners); fflush(stdout);
    scope->inners = realloc(scope->inners,
            sizeof(SignalI[scope->num_inners]));
    // scope->inners = (SignalI*)my_realloc(scope->inners,
    //         sizeof(SignalI[old_num]), sizeof(SignalI[scope->num_inners]));
    // printf("now scope->inners=%p\n",scope->inners); fflush(stdout);
    // printf("access test: %p\n",scope->inners[0]); fflush(stdout);
    /* Get and add the signals from the Ruby value. */
    for(long i=0; i< num; ++i) {
        SignalI sig;
        // show_access(scope->inners,old_num+i);
        value_to_rcsim(SignalIS,rb_ary_entry(sigVs,i),sig);
        scope->inners[old_num + i] = sig;
    }
    return scopeV;
}

.rcsim_add_scope_scopes(scopeV, scpVs) ⇒ Object

Adds sub scopes to a C scope.



1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1110

VALUE rcsim_add_scope_scopes(VALUE mod, VALUE scopeV, VALUE scpVs) {
    /* Get the C scope from the Ruby value. */
    Scope scope;
    value_to_rcsim(ScopeS,scopeV,scope);
    // printf("rcsim_add_scope_scopes with scope=%p\n",scope);
    /* Prepare the size for the sub scopes. */
    long num = RARRAY_LEN(scpVs);
    long old_num = scope->num_scopes;
    scope->num_scopes += num;
    // printf("first scope->scopes=%p\n",scope->scopes); fflush(stdout);
    scope->scopes = realloc(scope->scopes,
                            sizeof(Scope[scope->num_scopes]));
    // scope->scopes = (Scope*)my_realloc(scope->scopes,
    //         sizeof(Scope[old_num]), sizeof(Scope[scope->num_scopes]));
    // printf("now scope->scopes=%p\n",scope->scopes); fflush(stdout);
    // printf("access test: %p\n",scope->scopes[0]); fflush(stdout);
    /* Get and add the sub scopes from the Ruby value. */
    for(long i=0; i< num; ++i) {
        Scope scp;
        // show_access(scope->scopes,old_num+i);
        value_to_rcsim(ScopeS,rb_ary_entry(scpVs,i),scp);
        scope->scopes[old_num + i] = scp;
    }
    return scopeV;
}

.rcsim_add_scope_systemIs(scopeV, sysVs) ⇒ Object

Adds system instances to a C scope.



1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1059

VALUE rcsim_add_scope_systemIs(VALUE mod, VALUE scopeV, VALUE sysVs) {
    /* Get the C scope from the Ruby value. */
    Scope scope;
    value_to_rcsim(ScopeS,scopeV,scope);
    // printf("rcsim_add_scope_systemIs with scope=%p\n",scope);
    /* Prepare the size for the system instances. */
    long num = RARRAY_LEN(sysVs);
    long old_num = scope->num_systemIs;
    scope->num_systemIs += num;
    // printf("first scope->systemIs=%p\n",scope->systemIs); fflush(stdout);
    scope->systemIs = realloc(scope->systemIs,
                               sizeof(SystemI[scope->num_systemIs]));
    // scope->systemIs = (SystemI*)my_realloc(scope->systemIs,
    //         sizeof(SystemI[old_num]), sizeof(SystemI[scope->num_systemIs]));
    // printf("now scope->systemIs=%p\n",scope->systemIs); fflush(stdout);
    // printf("access test: %p\n",scope->systemIs[0]); fflush(stdout);
    /* Get and add the system instances from the Ruby value. */
    for(long i=0; i< num; ++i) {
        SystemI sys;
        // show_access(scope->systemIs,old_num+i);
        value_to_rcsim(SystemIS,rb_ary_entry(sysVs,i),sys);
        scope->systemIs[old_num + i] = sys;
    }
    return scopeV;
}

.rcsim_add_select_choices(selectV, choiceVs) ⇒ Object

Adds choices to a C select.



1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1458

VALUE rcsim_add_select_choices(VALUE mod, VALUE selectV, VALUE choiceVs) {
    /* Get the C select from the Ruby value. */
    Select select;
    value_to_rcsim(SelectS,selectV,select);
    // printf("rcsim_add_select_choices with select=%p\n",select);
    /* Prepare the size for the choices. */
    long num = RARRAY_LEN(choiceVs);
    long old_num = select->num_choices;
    select->num_choices += num;
    // printf("first select->choices=%p\n",select->choices); fflush(stdout);
    select->choices = realloc(select->choices,
            sizeof(Expression[select->num_choices]));
    // Select->choices = (Expression*)my_realloc(select->choices,
    //         sizeof(Expression[old_num]),sizeof(Expression[select->num_choices]));
    // printf("now select->choices=%p\n",select->choices); fflush(stdout);
    // printf("access test: %p\n",select->choices[0]); fflush(stdout);
    /* Get and add the choices from the Ruby value. */
    for(long i=0; i< num; ++i) {
        Expression choice;
        // show_access(select->choices,old_num+i);
        value_to_rcsim(ExpressionS,rb_ary_entry(choiceVs,i),choice);
        select->choices[old_num + i] = choice;
    }
    return selectV;
}

.rcsim_add_signal_signals(signalIV, sigVs) ⇒ Object

Adds sub signals a C signal.



1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1280

VALUE rcsim_add_signal_signals(VALUE mod, VALUE signalIV, VALUE sigVs) {
    /* Get the C signal from the Ruby value. */
    SignalI signalI;
    value_to_rcsim(SignalIS,signalIV,signalI);
    // printf("rcsim_add_signal_signals with signalI=%p\n",signalI);
    /* Prepare the size for the alternate system types. */
    long num = RARRAY_LEN(sigVs);
    long old_num = signalI->num_signals;
    signalI->num_signals += num;
    signalI->signals=realloc(signalI->signals,
            sizeof(SignalI[signalI->num_signals]));
    // signalI->signals = (SignalI*)my_realloc(signalI->signals,
    //         sizeof(SignalI[old_num]), sizeof(SignalI[signalI->num_signals]));
    /* Get and add the alternate system types from the Ruby value. */
    for(long i=0; i< num; ++i) {
        SignalI sig;
        value_to_rcsim(SignalIS,rb_ary_entry(sigVs,i),sig);
        signalI->signals[old_num + i] = sig;
    }
    return signalIV;
}

.rcsim_add_systemI_systemTs(systemIV, sysVs) ⇒ Object

Adds alternate system types to a C system instance.



1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1253

VALUE rcsim_add_systemI_systemTs(VALUE mod, VALUE systemIV, VALUE sysVs) {
    /* Get the C systemI from the Ruby value. */
    SystemI systemI;
    value_to_rcsim(SystemIS,systemIV,systemI);
    // printf("rcsim_add_systemI_systemTs with systemI=%p\n",systemI);
    /* Prepare the size for the alternate system types. */
    long num = RARRAY_LEN(sysVs);
    long old_num = systemI->num_systems;
    systemI->num_systems += num;
    // printf("first systemI->systems=%p\n",systemI->systems); fflush(stdout);
    systemI->systems=realloc(systemI->systems,
            sizeof(SystemT[systemI->num_systems]));
    // systemI->systems = (SystemT*)my_realloc(systemI->systems,
    //         sizeof(SystemT[old_num]), sizeof(SystemT[systemI->num_systems]));
    // printf("now systemI->systems=%p\n",systemI->systems); fflush(stdout);
    // printf("access test: %p\n",systemI->systems[0]); fflush(stdout);
    /* Get and add the alternate system types from the Ruby value. */
    for(long i=0; i< num; ++i) {
        SystemT sys;
        // show_access(systemI->systems,old_num+i);
        value_to_rcsim(SystemTS,rb_ary_entry(sysVs,i),sys);
        systemI->systems[old_num + i] = sys;
    }
    return systemIV;
}

.rcsim_add_systemT_inouts(systemTV, sigVs) ⇒ Object

Adds inouts to a C systemT.



975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 975

VALUE rcsim_add_systemT_inouts(VALUE mod, VALUE systemTV, VALUE sigVs) {
    /* Get the C systemT from the Ruby value. */
    SystemT systemT;
    value_to_rcsim(SystemTS,systemTV,systemT);
    // printf("rcsim_add_systemT_inputs with systemT=%p\n",systemT);
    /* Prepare the size for the inouts. */
    long num = RARRAY_LEN(sigVs);
    long old_num = systemT->num_inouts;
    systemT->num_inouts += num;
    // printf("first systemT->inouts=%p\n",systemT->inouts); fflush(stdout);
    systemT->inouts =realloc(systemT->inouts,
            sizeof(SignalI[systemT->num_inouts]));
    // systemT->inouts =(SignalI*)my_realloc(systemT->inouts,
    //         sizeof(SignalI[old_num]), sizeof(SignalI[systemT->num_inouts]));
    // printf("now systemT->inouts=%p\n",systemT->inouts); fflush(stdout);
    // printf("access test: %p\n",systemT->inouts[0]); fflush(stdout);
    /* Get and add the signals from the Ruby value. */
    for(long i=0; i< num; ++i) {
        SignalI sig;
        // show_access(systemT->inouts,old_num+i);
        value_to_rcsim(SignalIS,rb_ary_entry(sigVs,i),sig);
        systemT->inouts[old_num + i] = sig;
    }
    return systemTV;
}

.rcsim_add_systemT_inputs(systemTV, sigVs) ⇒ Object

Adds inputs to a C systemT.



920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 920

VALUE rcsim_add_systemT_inputs(VALUE mod, VALUE systemTV, VALUE sigVs) {
    /* Get the C systemT from the Ruby value. */
    SystemT systemT;
    value_to_rcsim(SystemTS,systemTV,systemT);
    // printf("rcsim_add_systemT_inputs with systemT=%p\n",systemT);
    // printf("Adding to systemT with kind=%d and name=%s\n",systemT->kind, systemT->name);
    /* Prepare the size for the inputs. */
    long num = RARRAY_LEN(sigVs);
    long old_num = systemT->num_inputs;
    systemT->num_inputs += num;
    // printf("first systemT->inputs=%p\n",systemT->inputs); fflush(stdout);
    systemT->inputs=realloc(systemT->inputs,
            sizeof(SignalI[systemT->num_inputs]));
    // systemT->inputs=(SignalI*)my_realloc(systemT->inputs,
    //         sizeof(SignalI[old_num]), sizeof(SignalI[systemT->num_inputs]));
    // printf("now systemT->inputs=%p\n",systemT->inputs); fflush(stdout);
    // printf("access test: %p\n",systemT->inputs[0]); fflush(stdout);
    /* Get and add the signals from the Ruby value. */
    for(long i=0; i< num; ++i) {
        SignalI sig;
        // show_access(systemT->inputs,old_num+i);
        value_to_rcsim(SignalIS,rb_ary_entry(sigVs,i),sig);
        systemT->inputs[old_num + i] = sig;
    }
    return systemTV;
}

.rcsim_add_systemT_outputs(systemTV, sigVs) ⇒ Object

Adds outputs to a C systemT.



948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 948

VALUE rcsim_add_systemT_outputs(VALUE mod, VALUE systemTV, VALUE sigVs) {
    /* Get the C systemT from the Ruby value. */
    SystemT systemT;
    value_to_rcsim(SystemTS,systemTV,systemT);
    // printf("rcsim_add_systemT_inputs with systemT=%p\n",systemT);
    /* Prepare the size for the outputs. */
    long num = RARRAY_LEN(sigVs);
    long old_num = systemT->num_outputs;
    systemT->num_outputs += num;
    // printf("first systemT->outputs=%p\n",systemT->outputs); fflush(stdout);
    systemT->outputs =realloc(systemT->outputs,
            sizeof(SignalI[systemT->num_outputs]));
    // systemT->outputs =(SignalI*)my_realloc(systemT->outputs,
    //         sizeof(SignalI[old_num]), sizeof(SignalI[systemT->num_outputs]));
    // printf("now systemT->outputs=%p\n",systemT->outputs); fflush(stdout);
    // printf("access test: %p\n",systemT->outputs[0]); fflush(stdout);
    /* Get and add the signals from the Ruby value. */
    for(long i=0; i< num; ++i) {
        SignalI sig;
        // show_access(systemT->outputs,old_num+i);
        value_to_rcsim(SignalIS,rb_ary_entry(sigVs,i),sig);
        systemT->outputs[old_num + i] = sig;
    }
    return systemTV;
}

.rcsim_get_signal_fixnum(signalV) ⇒ Object

Gets the value of a C signal as a Ruby fixnum. Sets 0 if the value contains x or z bits.



1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1659

VALUE rcsim_get_signal_fixnum(VALUE mod, VALUE signalV) {
    Value value;
    /* Get the C signal from the Ruby value. */
    SignalI signal;
    value_to_rcsim(SignalIS,signalV,signal);
    // printf("rc_sim_get_signal_fixnum for signal=%s\n",signal->name);
    /* Get the value from the signal. */
    value = signal->c_value;
    // /* Is the value a numeric? */
    // if(value->numeric == 1) {
    //     /* Yes, return it as a Ruby fixnum. */
    //     return LONG2FIX(value->data_int);
    // } else {
    //     /* No, return 0. */
    //     return LONG2FIX(0);
    // }
    return LONG2FIX(value2integer(value));
}

.rcsim_get_type_bitObject

Get the bit type.



173
174
175
176
177
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 173

VALUE rcsim_get_type_bit(VALUE mod) {
    VALUE res;
    rcsim_to_value(TypeS,get_type_bit(),res);
    return res;
}

.rcsim_get_type_signedObject

Get the signed type.



180
181
182
183
184
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 180

VALUE rcsim_get_type_signed(VALUE mod) {
    VALUE res;
    rcsim_to_value(TypeS,get_type_signed(),res);
    return res;
}

.rcsim_get_type_vector(baseV, numV) ⇒ Object

Get a vector type.



187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 187

VALUE rcsim_get_type_vector(VALUE mod, VALUE baseV, VALUE numV) {
    /* Get the base type. */
    Type base;
    value_to_rcsim(TypeS,baseV,base);
    /* Get the number of elements. */
    unsigned long long num = NUM2LL(numV);
    /* Get the type. */
    Type type = get_type_vector(base,num);
    /* Return it as a Ruby VALUE. */
    VALUE res;
    rcsim_to_value(TypeS,type,res);
    return res;
}

.rcsim_load_c(codeV, libnameV, funcnameV) ⇒ Object

Loads a C program dynamic library (called from HDLRuby) for a code.



478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 478

VALUE rcsim_load_c(VALUE mod, VALUE codeV, VALUE libnameV, VALUE funcnameV) {
    char* libname;
    char* funcname;
    Code code;
    void* handle;

    libname  = StringValueCStr(libnameV);
    funcname = StringValueCStr(funcnameV);
   
    /* Get the code. */ 
    value_to_rcsim(CodeS,codeV,code);
    /* Load the library. */
    handle = dlopen(libname,RTLD_NOW | RTLD_GLOBAL);
    if (handle == NULL) {
        fprintf(stderr,"Unable to open program: %s\n",dlerror());
        exit(-1);
    }
    code->function = dlsym(handle,funcname);
    if (code->function == NULL) {
        fprintf(stderr,"Unable to get function: %s\n",code->name);
        exit(-1);
    }
    return codeV;
}

.rcsim_main(systemTV, name, outmodeV) ⇒ Object

Starts the C-Ruby hybrid simulation. @param systemTV the top system type. @param name the name of the simulation. @param outmode tells which output mode is used: 0: standard 1: mute 2: vcd



1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1733

VALUE rcsim_main(VALUE mod, VALUE systemTV, VALUE name, VALUE outmodeV) {
    /* Get the C system type from the Ruby value. */
    SystemT systemT;
    value_to_rcsim(SystemTS,systemTV,systemT);
    /* Set it as the top of the simulator. */
    top_system = systemT;
    /* Enable it. */
    set_enable_system(systemT,1);
    /* Get the output mode. */
    int outmode = NUM2INT(outmodeV);
    /* Starts the simulation. */
    switch(outmode) { 
        case 0: hruby_sim_core(StringValueCStr(name),init_default_visualizer,-1);
                break;
        case 1: hruby_sim_core(StringValueCStr(name),init_mute_visualizer,-1);
                break;
        case 2: hruby_sim_core(StringValueCStr(name),init_vcd_visualizer,-1);
                break;
        default:hruby_sim_core(StringValueCStr(name),init_default_visualizer,-1);
    }
    return systemTV;
}

.rcsim_make_behavior(timed) ⇒ Object

Creating a behavior C object.



259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 259

VALUE rcsim_make_behavior(VALUE mod, VALUE timed) {
    // printf("rcsim_make_behavior\n");
    /* Allocates the behavior. */
    Behavior behavior = (Behavior)malloc(sizeof(BehaviorS));
    // printf("behavior=%p\n",behavior);
    /* Set it up. */
    behavior->kind = BEHAVIOR;
    behavior->owner = NULL;
    behavior->num_events = 0;
    behavior->events = NULL;
    behavior->block = NULL;
    behavior->enabled = 0;
    behavior->activated = 0;
    if (TYPE(timed) == T_TRUE) {
        /* The behavior is timed, set it up and register it. */
        behavior->timed = 1;
        register_timed_behavior(behavior);
    } else {
        /* The behavior is not timed. */
        behavior->timed = 0;
        /* It must be initialized though. */
        register_init_behavior(behavior);
    }
    behavior->active_time = 0;
    behavior->thread = NULL;
    /* Returns the C behavior embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(BehaviorS,behavior,res);
    return res;
}

.rcsim_make_binary(type, operator, left, right) ⇒ Object

Creating a binary value C object.



770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 770

VALUE rcsim_make_binary(VALUE mod, VALUE type, VALUE operator, VALUE left, VALUE right) {
    // printf("rcsim_make_binary\n");
    /* Allocates the binary. */
    Binary binary = (Binary)malloc(sizeof(BinaryS));
    // printf("binary=%p\n",binary);
    /* Set it up. */
    binary->kind = BINARY;
    binary->owner = NULL;
    value_to_rcsim(TypeS,type,binary->type);
    switch(sym_to_char(operator)) {
        case (unsigned char)'+':         binary->oper = add_value; break;
        case (unsigned char)'-':         binary->oper = sub_value; break;
        case (unsigned char)'*':         binary->oper = mul_value; break;
        case (unsigned char)'/':         binary->oper = div_value; break;
        case (unsigned char)'%':         binary->oper = mod_value; break;
        case (unsigned char)'&':         binary->oper = and_value; break;
        case (unsigned char)'|':         binary->oper = or_value; break;
        case (unsigned char)'^':         binary->oper = xor_value; break;
        case (unsigned char)('<'+'<'*2): binary->oper = shift_left_value; break;
        case (unsigned char)('>'+'>'*2): binary->oper = shift_right_value; break;
        case (unsigned char)('='+'='*2): binary->oper = equal_value_c; break;
        case (unsigned char)('!'+'='*2): binary->oper = not_equal_value_c; break;
        case (unsigned char)'<':         binary->oper = lesser_value; break;
        case (unsigned char)('<'+'='*2): binary->oper = lesser_equal_value; break;
        case (unsigned char)'>':         binary->oper = greater_value; break;
        case (unsigned char)('>'+'='*2): binary->oper = greater_equal_value; break;
        default: perror("Invalid operator for binary.");
    }
    value_to_rcsim(ExpressionS,left,binary->left);
    value_to_rcsim(ExpressionS,right,binary->right);
    /* Returns the C binary embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(BinaryS,binary,res);
    return res;
}

.rcsim_make_block(modeV) ⇒ Object

Creating a block C object.



661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 661

VALUE rcsim_make_block(VALUE mod, VALUE modeV) {
    // printf("rcsim_make_block\n");
    /* Allocates the block. */
    Block block = (Block)malloc(sizeof(BlockS));
    // printf("block=%p\n",block);
    /* Set it up. */
    block->kind = BLOCK;
    block->owner = NULL;
    block->name = NULL;
    block->num_inners = 0;
    block->inners = NULL;
    block->num_stmnts = 0;
    block->stmnts = NULL;
    block->mode = SYM2ID(modeV) == id_PAR ? PAR : SEQ;
    /* Returns the C block embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(BlockS,block,res);
    return res;
}

.rcsim_make_cast(type, child) ⇒ Object

Creating a cast C object.



731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 731

VALUE rcsim_make_cast(VALUE mod, VALUE type, VALUE child) {
    // printf("rcsim_make_cast\n");
    /* Allocates the cast. */
    Cast cast = (Cast)malloc(sizeof(CastS));
    // printf("cast=%p\n",cast);
    /* Set it up. */
    cast->kind = CAST;
    cast->owner = NULL;
    value_to_rcsim(TypeS,type,cast->type);
    value_to_rcsim(ExpressionS,child,cast->child);
    /* Returns the C cast embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(CastS,cast,res);
    return res;
}

.rcsim_make_code(lang, funcname) ⇒ Object

Creating a system code C object. Note: HDLRuby Code object are actually refactored to Program object, but the low-level simulation still use Code as data structure. Hence, it may change in the future.



395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 395

VALUE rcsim_make_code(VALUE mod, VALUE lang, VALUE funcname) {
    // printf("rcsim_make_code\n");
    /* Allocates the code. */
    Code code = (Code)malloc(sizeof(CodeS));
    // printf("code=%p\n",code);
    /* Set it up. */
    code->kind  = CODE;
    code->owner = NULL;
    code->name = strdup(StringValueCStr(funcname));
    // printf("code->name=%p\n",code->name);
    code->num_events = 0;
    code->events = NULL;
    code->function = NULL;
    char* langStr = StringValueCStr(lang);
    if(strncmp(langStr,"ruby",4) == 0) {
        /* Ruby function. */
        code->function = ruby_function_wrap;
    } else if (strncmp(langStr,"c",1) == 0) {
        /* C or C-compatible dynamically compiled code: it will be loaded
         * afterward */
        code->function = NULL;
    } else {
        /* Other language function. */
        fprintf(stderr,"Unsupported language.");
        exit(-1);
    }
    code->enabled = 0;
    code->activated = 0;
    /* Returns the C code embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(CodeS,code,res);
    return res;
}

.rcsim_make_concat(type, dirV) ⇒ Object

Creating a concat C object.



826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 826

VALUE rcsim_make_concat(VALUE mod, VALUE type, VALUE dirV) {
    // printf("rcsim_make_concat\n");
    /* Allocates the concat. */
    Concat concat = (Concat)malloc(sizeof(ConcatS));
    // printf("concat=%p\n",concat);
    /* Set it up. */
    concat->kind = CONCAT;
    concat->owner = NULL;
    value_to_rcsim(TypeS,type,concat->type);
    concat->num_exprs = 0;
    concat->exprs = NULL;
    concat->dir = rb_id2name(SYM2ID(dirV))[0]=='l' ? 1 : 0;
    /* Returns the C concat embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(ConcatS,concat,res);
    return res;
}

.rcsim_make_event(typeV, sigV) ⇒ Object

Creating an event C object.



292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 292

VALUE rcsim_make_event(VALUE mod, VALUE typeV, VALUE sigV) {
    // printf("rcsim_make_event\n");
    /* Allocates the event. */
    Event event = (Event)malloc(sizeof(EventS));
    // printf("event=%p\n",event);
    /* Set it up. */
    event->kind = EVENT;
    event->owner = NULL;
    /* Its type. */
    ID id_edge = SYM2ID(typeV);
    if      (id_edge == id_POSEDGE) { event->edge = POSEDGE; }
    else if (id_edge == id_NEGEDGE) { event->edge = NEGEDGE; }
    else if (id_edge == id_ANYEDGE) { event->edge = ANYEDGE; }
    else  { perror("Invalid edge type."); }
    /* Its signal. */
    value_to_rcsim(SignalIS,sigV,event->signal);
    /* Returns the C event embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(EventS,event,res);
    return res;
}

.rcsim_make_hcase(valueV, defoltV) ⇒ Object

Creating a hardware case C object.



637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 637

VALUE rcsim_make_hcase(VALUE mod, VALUE valueV, VALUE defoltV) {
    // printf("rcsim_make_hcase\n");
    /* Allocates the hardware case. */
    HCase hcase = (HCase)malloc(sizeof(HCaseS));
    // printf("hcase=%p\n",hcase);
    /* Set it up. */
    hcase->kind = HCASE;
    hcase->owner = NULL;
    value_to_rcsim(ExpressionS,valueV,hcase->value);
    hcase->num_whens = 0;
    hcase->matches = NULL;
    hcase->stmnts = NULL;
    if (TYPE(defoltV) == T_NIL)
        hcase->defolt = NULL;
    else
        value_to_rcsim(StatementS,defoltV,hcase->defolt);
    /* Returns the C hardware case embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(HCaseS,hcase,res);
    return res;
}

.rcsim_make_hif(conditionV, yesV, noV) ⇒ Object

Creating a hardware if C object.



612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 612

VALUE rcsim_make_hif(VALUE mod, VALUE conditionV, VALUE yesV, VALUE noV) {
    // printf("rcsim_make_hif\n");
    /* Allocates the hardware if. */
    HIf hif = (HIf)malloc(sizeof(HIfS));
    // printf("hif=%p\n",hif);
    /* Set it up. */
    hif->kind = HIF;
    hif->owner = NULL;
    value_to_rcsim(ExpressionS,conditionV,hif->condition);
    value_to_rcsim(StatementS,yesV,hif->yes);
    if (TYPE(noV) == T_NIL)
        hif->no = NULL;
    else
        value_to_rcsim(StatementS,noV,hif->no);
    hif->num_noifs = 0;
    hif->noconds = NULL;
    hif->nostmnts = NULL;
    /* Returns the C hardware if embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(HIfS,hif,res);
    return res;
}

.rcsim_make_printObject

Creating a print C object.



525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 525

VALUE rcsim_make_print(VALUE mod) {
    // printf("rcsim_make_print\n");
    /* Allocates the print. */
    Print print = (Print)malloc(sizeof(PrintS));
    // printf("print=%p\n",print);
    /* Set it up. */
    print->kind = PRINT;
    print->owner = NULL;
    print->num_args = 0;
    print->args = NULL;
    /* Returns the C print embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(PrintS,print,res);
    return res;
}

.rcsim_make_refConcat(type, dirV) ⇒ Object

Creating a ref concat C object.



845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 845

VALUE rcsim_make_refConcat(VALUE mod, VALUE type, VALUE dirV) {
    // printf("rcsim_make_refConcat\n");
    /* Allocates the ref concat. */
    RefConcat refConcat = (RefConcat)malloc(sizeof(RefConcatS));
    // printf("refConcat=%p\n",refConcat);
    /* Set it up. */
    refConcat->kind = REF_CONCAT;
    refConcat->owner = NULL;
    value_to_rcsim(TypeS,type,refConcat->type);
    refConcat->num_refs = 0;
    refConcat->refs = NULL;
    refConcat->dir = rb_id2name(SYM2ID(dirV))[0]=='l' ? 0 : 1;
    /* Returns the C ref concat embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(RefConcatS,refConcat,res);
    return res;
}

.rcsim_make_refIndex(type, index, ref) ⇒ Object

Creating a ref index C object.



864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 864

VALUE rcsim_make_refIndex(VALUE mod, VALUE type, VALUE index, VALUE ref) {
    // printf("rcsim_make_refIndex\n");
    /* Allocates the ref index. */
    RefIndex refIndex = (RefIndex)malloc(sizeof(RefIndexS));
    // printf("refIndex=%p\n",refIndex);
    /* Set it up. */
    refIndex->kind = REF_INDEX;
    refIndex->owner = NULL;
    value_to_rcsim(TypeS,type,refIndex->type);
    value_to_rcsim(ExpressionS,index,refIndex->index);
    value_to_rcsim(ReferenceS,ref,refIndex->ref);
    /* Returns the C ref index embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(RefIndexS,refIndex,res);
    return res;
}

.rcsim_make_refRange(type, first, last, ref) ⇒ Object

Creating a ref range C object.



882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 882

VALUE rcsim_make_refRange(VALUE mod, VALUE type, VALUE first, VALUE last, VALUE ref) {
    // printf("rcsim_make_refRange\n");
    /* Allocates the ref range. */
    RefRangeE refRange = (RefRangeE)malloc(sizeof(RefRangeES));
    // printf("refRange=%p\n",refRange);
    /* Set it up. */
    refRange->kind = REF_RANGE;
    refRange->owner = NULL;
    value_to_rcsim(TypeS,type,refRange->type);
    value_to_rcsim(ExpressionS,first,refRange->first);
    value_to_rcsim(ExpressionS,last,refRange->last);
    value_to_rcsim(ReferenceS,ref,refRange->ref);
    /* Returns the C ref range embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(RefRangeES,refRange,res);
    return res;
}

.rcsim_make_scope(name) ⇒ Object

Creating a scope C object.



231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 231

VALUE rcsim_make_scope(VALUE mod, VALUE name) {
    // printf("rcsim_make_scope\n");
    /* Allocates the scope. */
    Scope scope = (Scope)malloc(sizeof(ScopeS));
    // printf("scope=%p\n",scope);
    /* Set it up. */
    scope->kind = SCOPE;
    scope->owner = NULL;
    scope->name = strdup(StringValueCStr(name));
    // printf("scope->name=%p\n",scope->name);
    scope->num_systemIs = 0;
    scope->systemIs = NULL;
    scope->num_inners = 0;
    scope->inners = NULL;
    scope->num_scopes = 0;
    scope->scopes = NULL;
    scope->num_behaviors = 0;
    scope->behaviors = NULL;
    scope->num_codes = 0;
    scope->codes = NULL;
    /* Returns the C scope embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(ScopeS,scope,res);
    return res;
}

.rcsim_make_select(type, sel) ⇒ Object

Creating a select C object.



807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 807

VALUE rcsim_make_select(VALUE mod, VALUE type, VALUE sel) {
    // printf("rcsim_make_select\n");
    /* Allocates the select. */
    Select select = (Select)malloc(sizeof(SelectS));
    // printf("select=%p\n",select);
    /* Set it up. */
    select->kind = SELECT;
    select->owner = NULL;
    value_to_rcsim(TypeS,type,select->type);
    value_to_rcsim(ExpressionS,sel,select->select);
    select->num_choices = 0;
    select->choices = NULL;
    /* Returns the C select embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(SelectS,select,res);
    return res;
}

.rcsim_make_signal(name, type) ⇒ Object

Creating a signal C object.



318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 318

VALUE rcsim_make_signal(VALUE mod, VALUE name, VALUE type) {
    // printf("rcsim_make_signal\n");
    /* Allocates the signal. */
    SignalI signal = (SignalI)malloc(sizeof(SignalIS));
    signal->id = last_signal_id++;
    // printf("signal=%p\n",signal);
    /* Set it up. */
    signal->kind = SIGNALI;
    signal->owner = NULL;
    signal->name = strdup(StringValueCStr(name));
    // printf("signal->name=%p\n",signal->name);
    // printf("Creating signal named=%s\n",signal->name);
    value_to_rcsim(TypeS,type,signal->type);
    // printf("&type=%p type=%p width=%llu\n",&(signal->type),signal->type,type_width(signal->type));
    signal->num_signals= 0;
    signal->signals = NULL;

    signal->c_value = make_value(signal->type,0);
    // printf("signal->c_value=%p\n",signal->c_value);
    signal->c_value->signal = signal;
    // printf("c_value=%p type=%p\n",signal->c_value,signal->c_value->type);
    // printf("c_value type width=%llu\n",type_width(signal->c_value->type));
    signal->f_value = make_value(signal->type,0);
    // printf("signal->f_value=%p\n",signal->f_value);
    signal->f_value->signal = signal;
    signal->fading = 1; /* Initially the signal can be overwritten by anything.*/
    signal->num_any = 0;
    signal->any = NULL;
    // signal->any = (SignalI*)calloc(32,sizeof(SignalI));
    signal->num_pos = 0;
    signal->pos = NULL;
    // signal->pos = (SignalI*)calloc(32,sizeof(SignalI));
    signal->num_neg = 0;
    signal->neg = NULL;
    // signal->neg = (SignalI*)calloc(32,sizeof(SignalI));
    /* Register the signal. */
    register_signal(signal);
    /* Returns the C signal embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(SignalIS,signal,res);
    return res;
}

.rcsim_make_stringE(strV) ⇒ Object

Creating a character string C object.



902
903
904
905
906
907
908
909
910
911
912
913
914
915
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 902

VALUE rcsim_make_stringE(VALUE mod, VALUE strV) {
    // printf("rcsim_make_stringE\n");
    /* Allocates the string. */
    StringE stringE = (StringE)malloc(sizeof(StringES));
    // printf("stringE=%p\n",stringE);
    /* Set it up. */
    stringE->kind = STRINGE;
    stringE->owner = NULL;
    stringE->str   = strdup(StringValueCStr(strV));
    /* Returns the C character string embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(StringES,stringE,res);
    return res;
}

.rcsim_make_systemI(name, systemT) ⇒ Object

Creating a system instance C object.



363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 363

VALUE rcsim_make_systemI(VALUE mod, VALUE name, VALUE systemT) {
    // printf("rcsim_make_systemI\n");
    /* Allocates the system instance. */
    SystemI systemI = (SystemI)malloc(sizeof(SystemIS));
    // printf("systemI=%p\n",systemI);
    /* Set it up. */
    systemI->kind = SYSTEMI;
    systemI->owner = NULL;
    systemI->name = strdup(StringValueCStr(name));
    // printf("systemI->name=%p\n",systemI->name);
    // /* Name is made empty since redundant with Eigen system. */
    // systemI->name = "";
    value_to_rcsim(SystemTS,systemT,systemI->system);
    systemI->num_systems = 1;
    systemI->systems = (SystemT*)malloc(sizeof(SystemT[1]));
    // printf("systemI->systems=%p\n",systemI->systems); fflush(stdout);
    systemI->systems[0] = systemI->system;
    /* Configure the systemI to execute the default systemT. */
    configure(systemI,0);
    /* Returns the C system instance embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(SystemIS,systemI,res);
    return res;
}

.rcsim_make_systemT(name) ⇒ Object

Creating a systemT C object.



205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 205

VALUE rcsim_make_systemT(VALUE mod, VALUE name) {
    // printf("rcsim_make_systemT\n");
    /* Allocates the systemT. */
    SystemT systemT = (SystemT)malloc(sizeof(SystemTS));
    // printf("systemT=%p\n",systemT);
    /* Set it up. */
    systemT->kind = SYSTEMT;
    systemT->owner = NULL;
    systemT->name = strdup(StringValueCStr(name));
    // printf("systemT->name=%p\n",systemT->name);
    systemT->num_inputs = 0;
    systemT->inputs = NULL;
    systemT->num_outputs = 0;
    systemT->outputs = NULL;
    systemT->num_inouts = 0;
    systemT->inouts = NULL;
    systemT->scope = NULL;
    // printf("Created systemT with kind=%d and name=%s\n",systemT->kind,systemT->name);
    /* Returns the C systemT embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(SystemTS,systemT,res);
    return res;
}

.rcsim_make_timeRepeat(numberV, statementV) ⇒ Object

Creating a time repeat C object.



573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 573

VALUE rcsim_make_timeRepeat(VALUE mod, VALUE numberV, VALUE statementV) {
    // printf("rcsim_make_timeRepeat\n"); fflush(stdout);
    /* Allocates the time repeat. */
    TimeRepeat timeRepeat = (TimeRepeat)malloc(sizeof(TimeRepeatS));
    // printf("timeRepeat=%p\n",timeRepeat); fflush(stdout);
    /* Set it up. */
    timeRepeat->kind = TIME_REPEAT;
    timeRepeat->owner = NULL;
    /* Get and set the number of repeatition. */
    long long number;
    number = NUM2LL(numberV);
    // printf("number=%lld\n",number); fflush(stdout);
    timeRepeat->number = number;
    /* Get and set the statement. */
    value_to_rcsim(StatementS,statementV,timeRepeat->statement);
    /* Returns the C time wait embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(TimeRepeatS,timeRepeat,res);
    return res;
}

.rcsim_make_timeTerminateObject

Creating a time terminate C object.



596
597
598
599
600
601
602
603
604
605
606
607
608
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 596

VALUE rcsim_make_timeTerminate(VALUE mod) {
    // printf("rcsim_make_timeTerminate\n");
    /* Allocates the time terminate. */
    TimeTerminate timeTerminate = (TimeTerminate)malloc(sizeof(TimeTerminateS));
    // printf("timeTerminate=%p\n",timeTerminate);
    /* Set it up. */
    timeTerminate->kind = TIME_TERMINATE;
    timeTerminate->owner = NULL;
    /* Returns the C time terminate embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(TimeTerminateS,timeTerminate,res);
    return res;
}

.rcsim_make_timeWait(unitV, delayV) ⇒ Object

Creating a time wait C object.



543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 543

VALUE rcsim_make_timeWait(VALUE mod, VALUE unitV, VALUE delayV) {
    // printf("rcsim_make_timeWait\n");
    /* Allocates the time wait. */
    TimeWait timeWait = (TimeWait)malloc(sizeof(TimeWaitS));
    // printf("timeWait=%p\n",timeWait);
    /* Set it up. */
    timeWait->kind = TIME_WAIT;
    timeWait->owner = NULL;
    /* Compute the delay. */
    unsigned long long delay;
    delay = NUM2LL(delayV);
    /* Adjust the delay depending on the unit. */
    const char* unit = rb_id2name(SYM2ID(unitV));
    switch(unit[0]) {
        case 'p': /* Ok as is. */         break;
        case 'n': delay *= 1000;          break;
        case 'u': delay *= 1000000;       break;
        case 'm': delay *= 1000000000;    break;
        case 's': delay *= 1000000000000; break;
        default:
                  perror("Invalid delay unit.");
    }
    timeWait->delay = delay;
    /* Returns the C time wait embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(TimeWaitS,timeWait,res);
    return res;
}

.rcsim_make_transmit(left, right) ⇒ Object

Creating a transmit C object.



507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 507

VALUE rcsim_make_transmit(VALUE mod, VALUE left, VALUE right) {
    // printf("rcsim_make_transmit\n");
    /* Allocates the transmit. */
    Transmit transmit = (Transmit)malloc(sizeof(TransmitS));
    // printf("transmit=%p\n",transmit);
    /* Set it up. */
    transmit->kind = TRANSMIT;
    transmit->owner = NULL;
    value_to_rcsim(ReferenceS,left,transmit->left);
    value_to_rcsim(ExpressionS,right,transmit->right);
    /* Returns the C transmit embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(TransmitS,transmit,res);
    return res;
}

.rcsim_make_unary(type, operator, child) ⇒ Object

Creating a unary value C object.



748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 748

VALUE rcsim_make_unary(VALUE mod, VALUE type, VALUE operator, VALUE child) {
    // printf("rcsim_make_unary\n");
    /* Allocates the unary. */
    Unary unary= (Unary)malloc(sizeof(UnaryS));
    // printf("unary=%p\n",unary);
    /* Set it up. */
    unary->kind = UNARY;
    unary->owner = NULL;
    value_to_rcsim(TypeS,type,unary->type);
    switch(sym_to_char(operator)) {
        case (unsigned char)'~':         unary->oper = not_value; break;
        case (unsigned char)('-'+'@'*2): unary->oper = neg_value; break;
        default: perror("Invalid operator for unary.");
    }
    value_to_rcsim(ExpressionS,child,unary->child);
    /* Returns the C unary embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(UnaryS,unary,res);
    return res;
}

.rcsim_make_value_bitstring(typeV, contentV) ⇒ Object

Creating a bitstring value C object.



705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 705

VALUE rcsim_make_value_bitstring(VALUE mod, VALUE typeV, VALUE contentV) {
    // printf("rcsim_make_value_bitstring\n");
    /* Get the type. */
    Type type;
    value_to_rcsim(TypeS,typeV,type);
    /* Create the value. */
    Value value = make_value(type,0);
    // printf("value=%p\n",value);
    // printf("Created from bitstring value=%p with type=%p\n",value,value->type);
    // printf("and width=%llu\n",type_width(value->type));
    /* Set it to bitstring. */
    value->numeric = 0;
    /* Generate the string of the content. */
    char* str = StringValueCStr(contentV);
    value->capacity = strlen(str)+1;
    value->data_str = calloc(value->capacity,sizeof(char));
    // printf("value->data_str=%p\n",value->data_str);
    strcpy(value->data_str,str);
    /* Returns the C value embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(ValueS,value,res);
    return res;
}

.rcsim_make_value_numeric(typeV, contentV) ⇒ Object

Creating a numeric value C object.



683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 683

VALUE rcsim_make_value_numeric(VALUE mod, VALUE typeV, VALUE contentV) {
    // printf("rcsim_make_value_numeric\n");
    /* Get the type. */
    Type type;
    value_to_rcsim(TypeS,typeV,type);
    /* Create the value. */
    Value value = make_value(type,0);
    // printf("value=%p\n",value);
    /* Set it to numeric. */
    value->numeric = 1;
    value->capacity = 0;
    value->data_str = NULL;
    value->data_int = NUM2LL(contentV);
    // printf("value->data_int=%lld\n",value->data_int);
    /* Returns the C value embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(ValueS,value,res);
    return res;
}

.rcsim_set_behavior_block(behaviorV, blockV) ⇒ Object

Sets the block for a C behavior.



1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1570

VALUE rcsim_set_behavior_block(VALUE mod, VALUE behaviorV, VALUE blockV) {
    /* Get the C behavior from the Ruby value. */
    Behavior behavior;
    value_to_rcsim(BehaviorS,behaviorV,behavior);
    /* Get the C block from the Ruby value. */
    Block block;
    value_to_rcsim(BlockS,blockV,block);
    /* Set the block. */
    behavior->block = block;
    return behaviorV;
}

.rcsim_set_owner(objV, ownerV) ⇒ Object

Sets the owner for a C simulation object.



1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1544

VALUE rcsim_set_owner(VALUE mod, VALUE objV, VALUE ownerV) {
    /* Get the C object from the Ruby value. */
    Object obj;
    value_to_rcsim(ObjectS,objV,obj);
    /* Get the C owner from the Ruby value. */
    Object owner;
    value_to_rcsim(ObjectS,ownerV,owner);
    /* Set the owner. */
    obj->owner = owner;
    return objV;
}

.rcsim_set_signal_value(signalV, exprV) ⇒ Object

Sets the value for a C signal. NOTE: for initialization only (the simulator events are not updated), otherwise, please use rcsim_transmit_to_signal or rc_sim_transmit_to_signal_seq.



1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1586

VALUE rcsim_set_signal_value(VALUE mod, VALUE signalV, VALUE exprV) {
    /* Get the C signal from the Ruby value. */
    SignalI signal;
    value_to_rcsim(SignalIS,signalV,signal);
    // printf("rc_sim_set_signal_value for signal=%s\n",signal->name);
    /* Get the C expression from the Ruby value. */
    Expression expr;
    value_to_rcsim(ExpressionS,exprV,expr);
    /* Compute the value from it. */
    Value value = get_value();
    value = calc_expression(expr,value);
    /* Copies the value. */
    signal->f_value = copy_value(value,signal->f_value);
    signal->c_value = copy_value(value,signal->c_value);
    free_value();
    return signalV;
}

.rcsim_set_systemT_scope(systemTV, scopeV) ⇒ Object

Sets the scope for a C system type.



1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1557

VALUE rcsim_set_systemT_scope(VALUE mod, VALUE systemTV, VALUE scopeV) {
    /* Get the C system type from the Ruby value. */
    SystemT systemT;
    value_to_rcsim(SystemTS,systemTV,systemT);
    /* Get the C scope from the Ruby value. */
    Scope scope;
    value_to_rcsim(ScopeS,scopeV,scope);
    /* Set the scope. */
    systemT->scope = scope;
    return systemTV;
}

.rcsim_transmit_fixnum_to_signal_seq(signalV, valR) ⇒ Object

Transmit a Ruby fixnum to a signal in a non-blocking fashion. NOTE: the simulator events are updated.



1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1697

VALUE rcsim_transmit_fixnum_to_signal_seq(VALUE mod, VALUE signalV, VALUE valR) {
    /* Get the C signal from the Ruby value. */
    SignalI signal;
    value_to_rcsim(SignalIS,signalV,signal);
    /* Compute the simualtion value from valR. */
    Value value = get_value();
    value->type = signal->type;
    value->numeric = 1;
    value->data_int = FIX2LONG(valR);
    /* Transmit it. */
    transmit_to_signal_seq(value, signal);
    /* End, return the transmitted expression. */
    return valR;
}