HDLRuby 2.11.0 → 2.11.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/hruby_sim/hruby_rcsim_build.c +294 -62
- data/ext/hruby_sim/hruby_sim_calc.c +12 -9
- data/ext/hruby_sim/hruby_sim_core.c +9 -6
- data/ext/hruby_sim/hruby_value_pool.c +10 -4
- data/lib/HDLRuby/hruby_rcsim.rb +103 -72
- data/lib/HDLRuby/version.rb +1 -1
- metadata +2 -2
@@ -11,6 +11,20 @@
|
|
11
11
|
|
12
12
|
#include "hruby_sim.h"
|
13
13
|
|
14
|
+
// #if defined(_WIN32) || defined(_WIN64)
|
15
|
+
// #define show_access(POINTER,IDX) \
|
16
|
+
// printf("In %s accessing range [%p,%p](%i) at=%p with size=%i\n",__func__,(POINTER),(unsigned long long)(POINTER)+_msize((POINTER)),_msize((POINTER)),&((POINTER)[(IDX)]),sizeof((POINTER[(IDX)]))); fflush(stdout)
|
17
|
+
// #elif defined(__APPLE__)
|
18
|
+
// #define show_access(POINTER,IDX) \
|
19
|
+
// printf("In %s accessing range [%p,%p](%i) at=%p with size=%i\n",__func__,(POINTER),(unsigned long long)(POINTER)+malloc_size((POINTER)),malloc_size((POINTER)),&((POINTER)[(IDX)]),sizeof((POINTER[(IDX)]))); fflush(stdout)
|
20
|
+
// #else
|
21
|
+
// #define show_access(POINTER,IDX) \
|
22
|
+
// printf("In %s accessing range [%p,%p](%i) at=%p with size=%i\n",__func__,(POINTER),(unsigned long long)(POINTER)+malloc_usable_size((POINTER)),malloc_usable_size((POINTER)),&((POINTER)[(IDX)]),sizeof((POINTER[(IDX)]))); fflush(stdout)
|
23
|
+
// #endif
|
24
|
+
|
25
|
+
// #define show_access(POINTER,IDX)
|
26
|
+
|
27
|
+
|
14
28
|
/**
|
15
29
|
* The C-Ruby hybrid HDLRuby simulation builder.
|
16
30
|
**/
|
@@ -62,13 +76,23 @@ static VALUE RCSimPointer;
|
|
62
76
|
|
63
77
|
#define rcsim_to_value(TYPE,POINTER,VALUE) \
|
64
78
|
(VALUE) = Data_Wrap_Struct(RCSimPointer, 0, 0, (POINTER))
|
65
|
-
// (VALUE) = Data_Wrap_Struct(RCSimPointer, 0, free, (POINTER))
|
66
79
|
// (VALUE) = ULL2NUM((unsigned long long)(POINTER))
|
80
|
+
// (VALUE) = Data_Wrap_Struct(RCSimPointer, 0, free, (POINTER))
|
67
81
|
|
68
82
|
#define value_to_rcsim(TYPE,VALUE,POINTER) \
|
69
83
|
Data_Get_Struct((VALUE),TYPE,(POINTER))
|
70
84
|
// (POINTER) = (TYPE*)NUM2ULL((VALUE))
|
71
85
|
|
86
|
+
|
87
|
+
/* My own realloc. */
|
88
|
+
static void* my_realloc(void* pointer, size_t old_size, size_t new_size) {
|
89
|
+
if(old_size >= new_size) { return pointer; }
|
90
|
+
void* new_pointer = malloc(new_size);
|
91
|
+
memcpy(new_pointer,pointer,old_size);
|
92
|
+
free(pointer);
|
93
|
+
return new_pointer;
|
94
|
+
}
|
95
|
+
|
72
96
|
/*#### Generates the list of ID coressponding to the HDLRuby symbols. ####*/
|
73
97
|
|
74
98
|
static ID id_ANYEDGE;
|
@@ -168,12 +192,15 @@ VALUE rcsim_get_type_vector(VALUE mod, VALUE baseV, VALUE numV) {
|
|
168
192
|
|
169
193
|
/* Creating a systemT C object. */
|
170
194
|
VALUE rcsim_make_systemT(VALUE mod, VALUE name) {
|
195
|
+
// printf("rcsim_make_systemT\n");
|
171
196
|
/* Allocates the systemT. */
|
172
197
|
SystemT systemT = (SystemT)malloc(sizeof(SystemTS));
|
198
|
+
// printf("systemT=%p\n",systemT);
|
173
199
|
/* Set it up. */
|
174
200
|
systemT->kind = SYSTEMT;
|
175
201
|
systemT->owner = NULL;
|
176
202
|
systemT->name = strdup(StringValueCStr(name));
|
203
|
+
// printf("systemT->name=%p\n",systemT->name);
|
177
204
|
systemT->num_inputs = 0;
|
178
205
|
systemT->inputs = NULL;
|
179
206
|
systemT->num_outputs = 0;
|
@@ -191,12 +218,15 @@ VALUE rcsim_make_systemT(VALUE mod, VALUE name) {
|
|
191
218
|
|
192
219
|
/* Creating a scope C object. */
|
193
220
|
VALUE rcsim_make_scope(VALUE mod, VALUE name) {
|
221
|
+
// printf("rcsim_make_scope\n");
|
194
222
|
/* Allocates the scope. */
|
195
223
|
Scope scope = (Scope)malloc(sizeof(ScopeS));
|
224
|
+
// printf("scope=%p\n",scope);
|
196
225
|
/* Set it up. */
|
197
226
|
scope->kind = SCOPE;
|
198
227
|
scope->owner = NULL;
|
199
228
|
scope->name = strdup(StringValueCStr(name));
|
229
|
+
// printf("scope->name=%p\n",scope->name);
|
200
230
|
scope->num_systemIs = 0;
|
201
231
|
scope->systemIs = NULL;
|
202
232
|
scope->num_inners = 0;
|
@@ -216,14 +246,16 @@ VALUE rcsim_make_scope(VALUE mod, VALUE name) {
|
|
216
246
|
|
217
247
|
/* Creating a behavior C object. */
|
218
248
|
VALUE rcsim_make_behavior(VALUE mod, VALUE timed) {
|
249
|
+
// printf("rcsim_make_behavior\n");
|
219
250
|
/* Allocates the behavior. */
|
220
251
|
Behavior behavior = (Behavior)malloc(sizeof(BehaviorS));
|
221
|
-
// printf("
|
252
|
+
// printf("behavior=%p\n",behavior);
|
222
253
|
/* Set it up. */
|
223
254
|
behavior->kind = BEHAVIOR;
|
224
255
|
behavior->owner = NULL;
|
225
256
|
behavior->num_events = 0;
|
226
257
|
behavior->events = NULL;
|
258
|
+
behavior->block = NULL;
|
227
259
|
behavior->enabled = 0;
|
228
260
|
behavior->activated = 0;
|
229
261
|
if (TYPE(timed) == T_TRUE) {
|
@@ -235,6 +267,7 @@ VALUE rcsim_make_behavior(VALUE mod, VALUE timed) {
|
|
235
267
|
behavior->timed = 0;
|
236
268
|
}
|
237
269
|
behavior->active_time = 0;
|
270
|
+
behavior->thread = NULL;
|
238
271
|
/* Returns the C behavior embedded into a ruby VALUE. */
|
239
272
|
VALUE res;
|
240
273
|
rcsim_to_value(BehaviorS,behavior,res);
|
@@ -244,8 +277,10 @@ VALUE rcsim_make_behavior(VALUE mod, VALUE timed) {
|
|
244
277
|
|
245
278
|
/* Creating an event C object. */
|
246
279
|
VALUE rcsim_make_event(VALUE mod, VALUE typeV, VALUE sigV) {
|
280
|
+
// printf("rcsim_make_event\n");
|
247
281
|
/* Allocates the event. */
|
248
282
|
Event event = (Event)malloc(sizeof(EventS));
|
283
|
+
// printf("event=%p\n",event);
|
249
284
|
/* Set it up. */
|
250
285
|
event->kind = EVENT;
|
251
286
|
event->owner = NULL;
|
@@ -266,28 +301,36 @@ VALUE rcsim_make_event(VALUE mod, VALUE typeV, VALUE sigV) {
|
|
266
301
|
|
267
302
|
/* Creating a signal C object. */
|
268
303
|
VALUE rcsim_make_signal(VALUE mod, VALUE name, VALUE type) {
|
304
|
+
// printf("rcsim_make_signal\n");
|
269
305
|
/* Allocates the signal. */
|
270
306
|
SignalI signal = (SignalI)malloc(sizeof(SignalIS));
|
307
|
+
// printf("signal=%p\n",signal);
|
271
308
|
/* Set it up. */
|
272
309
|
signal->kind = SIGNALI;
|
273
310
|
signal->owner = NULL;
|
274
311
|
signal->name = strdup(StringValueCStr(name));
|
312
|
+
// printf("signal->name=%p\n",signal->name);
|
275
313
|
// printf("Creating signal named=%s\n",signal->name);
|
276
314
|
value_to_rcsim(TypeS,type,signal->type);
|
277
315
|
// printf("type width=%llu\n",type_width(signal->type));
|
278
316
|
signal->c_value = make_value(signal->type,0);
|
317
|
+
// printf("signal->c_value=%p\n",signal->c_value);
|
279
318
|
signal->c_value->signal = signal;
|
280
319
|
// printf("c_value=%p type=%p\n",signal->c_value,signal->c_value->type);
|
281
320
|
// printf("c_value type width=%llu\n",type_width(signal->c_value->type));
|
282
321
|
signal->f_value = make_value(signal->type,0);
|
322
|
+
// printf("signal->f_value=%p\n",signal->f_value);
|
283
323
|
signal->f_value->signal = signal;
|
284
324
|
signal->fading = 1; /* Initially the signal can be overwritten by anything.*/
|
285
325
|
signal->num_any = 0;
|
286
326
|
signal->any = NULL;
|
327
|
+
// signal->any = (SignalI*)calloc(32,sizeof(SignalI));
|
287
328
|
signal->num_pos = 0;
|
288
329
|
signal->pos = NULL;
|
330
|
+
// signal->pos = (SignalI*)calloc(32,sizeof(SignalI));
|
289
331
|
signal->num_neg = 0;
|
290
332
|
signal->neg = NULL;
|
333
|
+
// signal->neg = (SignalI*)calloc(32,sizeof(SignalI));
|
291
334
|
/* Register the signal. */
|
292
335
|
register_signal(signal);
|
293
336
|
/* Returns the C signal embedded into a ruby VALUE. */
|
@@ -299,17 +342,21 @@ VALUE rcsim_make_signal(VALUE mod, VALUE name, VALUE type) {
|
|
299
342
|
|
300
343
|
/* Creating a system instance C object. */
|
301
344
|
VALUE rcsim_make_systemI(VALUE mod, VALUE name, VALUE systemT) {
|
345
|
+
// printf("rcsim_make_systemI\n");
|
302
346
|
/* Allocates the system instance. */
|
303
347
|
SystemI systemI = (SystemI)malloc(sizeof(SystemIS));
|
348
|
+
// printf("systemI=%p\n",systemI);
|
304
349
|
/* Set it up. */
|
305
350
|
systemI->kind = SYSTEMI;
|
306
351
|
systemI->owner = NULL;
|
307
352
|
systemI->name = strdup(StringValueCStr(name));
|
353
|
+
// printf("systemI->name=%p\n",systemI->name);
|
308
354
|
// /* Name is made empty since redundant with Eigen system. */
|
309
355
|
// systemI->name = "";
|
310
356
|
value_to_rcsim(SystemTS,systemT,systemI->system);
|
311
357
|
systemI->num_systems = 1;
|
312
|
-
systemI->systems = (SystemT*)malloc(sizeof(SystemT));
|
358
|
+
systemI->systems = (SystemT*)malloc(sizeof(SystemT[1]));
|
359
|
+
// printf("systemI->systems=%p\n",systemI->systems); fflush(stdout);
|
313
360
|
systemI->systems[0] = systemI->system;
|
314
361
|
/* Configure the systemI to execute the default systemT. */
|
315
362
|
configure(systemI,0);
|
@@ -322,8 +369,10 @@ VALUE rcsim_make_systemI(VALUE mod, VALUE name, VALUE systemT) {
|
|
322
369
|
|
323
370
|
/* Creating a transmit C object. */
|
324
371
|
VALUE rcsim_make_transmit(VALUE mod, VALUE left, VALUE right) {
|
372
|
+
// printf("rcsim_make_transmit\n");
|
325
373
|
/* Allocates the transmit. */
|
326
374
|
Transmit transmit = (Transmit)malloc(sizeof(TransmitS));
|
375
|
+
// printf("transmit=%p\n",transmit);
|
327
376
|
/* Set it up. */
|
328
377
|
transmit->kind = TRANSMIT;
|
329
378
|
value_to_rcsim(ReferenceS,left,transmit->left);
|
@@ -337,8 +386,10 @@ VALUE rcsim_make_transmit(VALUE mod, VALUE left, VALUE right) {
|
|
337
386
|
|
338
387
|
/* Creating a print C object. */
|
339
388
|
VALUE rcsim_make_print(VALUE mod) {
|
389
|
+
// printf("rcsim_make_print\n");
|
340
390
|
/* Allocates the print. */
|
341
391
|
Print print = (Print)malloc(sizeof(PrintS));
|
392
|
+
// printf("print=%p\n",print);
|
342
393
|
/* Set it up. */
|
343
394
|
print->kind = PRINT;
|
344
395
|
print->num_args = 0;
|
@@ -352,8 +403,10 @@ VALUE rcsim_make_print(VALUE mod) {
|
|
352
403
|
|
353
404
|
/* Creating a time wait C object. */
|
354
405
|
VALUE rcsim_make_timeWait(VALUE mod, VALUE unitV, VALUE delayV) {
|
406
|
+
// printf("rcsim_make_timeWait\n");
|
355
407
|
/* Allocates the time wait. */
|
356
408
|
TimeWait timeWait = (TimeWait)malloc(sizeof(TimeWaitS));
|
409
|
+
// printf("timeWait=%p\n",timeWait);
|
357
410
|
/* Set it up. */
|
358
411
|
timeWait->kind = TIME_WAIT;
|
359
412
|
/* Compute the delay. */
|
@@ -380,8 +433,10 @@ VALUE rcsim_make_timeWait(VALUE mod, VALUE unitV, VALUE delayV) {
|
|
380
433
|
|
381
434
|
/* Creating a time terminate C object. */
|
382
435
|
VALUE rcsim_make_timeTerminate(VALUE mod) {
|
436
|
+
// printf("rcsim_make_timeTerminate\n");
|
383
437
|
/* Allocates the time terminate. */
|
384
438
|
TimeTerminate timeTerminate = (TimeTerminate)malloc(sizeof(TimeTerminateS));
|
439
|
+
// printf("timeTerminate=%p\n",timeTerminate);
|
385
440
|
/* Set it up. */
|
386
441
|
timeTerminate->kind = TIME_TERMINATE;
|
387
442
|
/* Returns the C time terminate embedded into a ruby VALUE. */
|
@@ -393,8 +448,10 @@ VALUE rcsim_make_timeTerminate(VALUE mod) {
|
|
393
448
|
|
394
449
|
/* Creating a hardware if C object. */
|
395
450
|
VALUE rcsim_make_hif(VALUE mod, VALUE condition, VALUE yes, VALUE no) {
|
451
|
+
// printf("rcsim_make_hif\n");
|
396
452
|
/* Allocates the hardware if. */
|
397
453
|
HIf hif = (HIf)malloc(sizeof(HIfS));
|
454
|
+
// printf("hif=%p\n",hif);
|
398
455
|
/* Set it up. */
|
399
456
|
hif->kind = HIF;
|
400
457
|
value_to_rcsim(ExpressionS,condition,hif->condition);
|
@@ -415,8 +472,10 @@ VALUE rcsim_make_hif(VALUE mod, VALUE condition, VALUE yes, VALUE no) {
|
|
415
472
|
|
416
473
|
/* Creating a hardware case C object. */
|
417
474
|
VALUE rcsim_make_hcase(VALUE mod, VALUE value, VALUE defolt) {
|
475
|
+
// printf("rcsim_make_hcase\n");
|
418
476
|
/* Allocates the hardware case. */
|
419
477
|
HCase hcase = (HCase)malloc(sizeof(HCaseS));
|
478
|
+
// printf("hcase=%p\n",hcase);
|
420
479
|
/* Set it up. */
|
421
480
|
hcase->kind = HCASE;
|
422
481
|
value_to_rcsim(ExpressionS,value,hcase->value);
|
@@ -436,8 +495,10 @@ VALUE rcsim_make_hcase(VALUE mod, VALUE value, VALUE defolt) {
|
|
436
495
|
|
437
496
|
/* Creating a block C object. */
|
438
497
|
VALUE rcsim_make_block(VALUE mod, VALUE mode) {
|
498
|
+
// printf("rcsim_make_block\n");
|
439
499
|
/* Allocates the block. */
|
440
500
|
Block block = (Block)malloc(sizeof(BlockS));
|
501
|
+
// printf("block=%p\n",block);
|
441
502
|
/* Set it up. */
|
442
503
|
block->kind = BLOCK;
|
443
504
|
block->owner = NULL;
|
@@ -456,15 +517,13 @@ VALUE rcsim_make_block(VALUE mod, VALUE mode) {
|
|
456
517
|
|
457
518
|
/* Creating a numeric value C object. */
|
458
519
|
VALUE rcsim_make_value_numeric(VALUE mod, VALUE typeV, VALUE contentV) {
|
459
|
-
//
|
460
|
-
// Value value = get_value();
|
461
|
-
// /* Sets its type. */
|
462
|
-
// value_to_rcsim(TypeS,typeV,value->type);
|
520
|
+
// printf("rcsim_make_value_numeric\n");
|
463
521
|
/* Get the type. */
|
464
522
|
Type type;
|
465
523
|
value_to_rcsim(TypeS,typeV,type);
|
466
524
|
/* Create the value. */
|
467
525
|
Value value = make_value(type,0);
|
526
|
+
// printf("value=%p\n",value);
|
468
527
|
/* Set it to numeric. */
|
469
528
|
value->numeric = 1;
|
470
529
|
value->capacity = 0;
|
@@ -479,15 +538,13 @@ VALUE rcsim_make_value_numeric(VALUE mod, VALUE typeV, VALUE contentV) {
|
|
479
538
|
|
480
539
|
/* Creating a bitstring value C object. */
|
481
540
|
VALUE rcsim_make_value_bitstring(VALUE mod, VALUE typeV, VALUE contentV) {
|
482
|
-
//
|
483
|
-
// Value value = get_value();
|
484
|
-
// /* Sets its type. */
|
485
|
-
// value_to_rcsim(TypeS,type,value->type);
|
541
|
+
// printf("rcsim_make_value_bitstring\n");
|
486
542
|
/* Get the type. */
|
487
543
|
Type type;
|
488
544
|
value_to_rcsim(TypeS,typeV,type);
|
489
545
|
/* Create the value. */
|
490
546
|
Value value = make_value(type,0);
|
547
|
+
// printf("value=%p\n",value);
|
491
548
|
// printf("Created from bitstring value=%p with type=%p\n",value,value->type);
|
492
549
|
// printf("and width=%llu\n",type_width(value->type));
|
493
550
|
/* Set it to bitstring. */
|
@@ -495,7 +552,8 @@ VALUE rcsim_make_value_bitstring(VALUE mod, VALUE typeV, VALUE contentV) {
|
|
495
552
|
/* Generate the string of the content. */
|
496
553
|
char* str = StringValueCStr(contentV);
|
497
554
|
value->capacity = strlen(str)+1;
|
498
|
-
value->data_str = calloc(sizeof(char)
|
555
|
+
value->data_str = calloc(value->capacity,sizeof(char));
|
556
|
+
// printf("value->data_str=%p\n",value->data_str);
|
499
557
|
strcpy(value->data_str,str);
|
500
558
|
/* Returns the C value embedded into a ruby VALUE. */
|
501
559
|
VALUE res;
|
@@ -506,8 +564,10 @@ VALUE rcsim_make_value_bitstring(VALUE mod, VALUE typeV, VALUE contentV) {
|
|
506
564
|
|
507
565
|
/* Creating a cast C object. */
|
508
566
|
VALUE rcsim_make_cast(VALUE mod, VALUE type, VALUE child) {
|
567
|
+
// printf("rcsim_make_cast\n");
|
509
568
|
/* Allocates the cast. */
|
510
569
|
Cast cast = (Cast)malloc(sizeof(CastS));
|
570
|
+
// printf("cast=%p\n",cast);
|
511
571
|
/* Set it up. */
|
512
572
|
cast->kind = CAST;
|
513
573
|
value_to_rcsim(TypeS,type,cast->type);
|
@@ -520,8 +580,10 @@ VALUE rcsim_make_cast(VALUE mod, VALUE type, VALUE child) {
|
|
520
580
|
|
521
581
|
/* Creating a unary value C object. */
|
522
582
|
VALUE rcsim_make_unary(VALUE mod, VALUE type, VALUE operator, VALUE child) {
|
583
|
+
// printf("rcsim_make_unary\n");
|
523
584
|
/* Allocates the unary. */
|
524
585
|
Unary unary= (Unary)malloc(sizeof(UnaryS));
|
586
|
+
// printf("unary=%p\n",unary);
|
525
587
|
/* Set it up. */
|
526
588
|
unary->kind = UNARY;
|
527
589
|
value_to_rcsim(TypeS,type,unary->type);
|
@@ -539,8 +601,10 @@ VALUE rcsim_make_unary(VALUE mod, VALUE type, VALUE operator, VALUE child) {
|
|
539
601
|
|
540
602
|
/* Creating a binary value C object. */
|
541
603
|
VALUE rcsim_make_binary(VALUE mod, VALUE type, VALUE operator, VALUE left, VALUE right) {
|
604
|
+
// printf("rcsim_make_binary\n");
|
542
605
|
/* Allocates the binary. */
|
543
606
|
Binary binary = (Binary)malloc(sizeof(BinaryS));
|
607
|
+
// printf("binary=%p\n",binary);
|
544
608
|
/* Set it up. */
|
545
609
|
binary->kind = BINARY;
|
546
610
|
value_to_rcsim(TypeS,type,binary->type);
|
@@ -573,8 +637,10 @@ VALUE rcsim_make_binary(VALUE mod, VALUE type, VALUE operator, VALUE left, VALUE
|
|
573
637
|
|
574
638
|
/* Creating a select C object. */
|
575
639
|
VALUE rcsim_make_select(VALUE mod, VALUE type, VALUE sel) {
|
640
|
+
// printf("rcsim_make_select\n");
|
576
641
|
/* Allocates the select. */
|
577
642
|
Select select = (Select)malloc(sizeof(SelectS));
|
643
|
+
// printf("select=%p\n",select);
|
578
644
|
/* Set it up. */
|
579
645
|
select->kind = SELECT;
|
580
646
|
value_to_rcsim(TypeS,type,select->type);
|
@@ -589,8 +655,10 @@ VALUE rcsim_make_select(VALUE mod, VALUE type, VALUE sel) {
|
|
589
655
|
|
590
656
|
/* Creating a concat C object. */
|
591
657
|
VALUE rcsim_make_concat(VALUE mod, VALUE type, VALUE dirV) {
|
658
|
+
// printf("rcsim_make_concat\n");
|
592
659
|
/* Allocates the concat. */
|
593
660
|
Concat concat = (Concat)malloc(sizeof(ConcatS));
|
661
|
+
// printf("concat=%p\n",concat);
|
594
662
|
/* Set it up. */
|
595
663
|
concat->kind = CONCAT;
|
596
664
|
value_to_rcsim(TypeS,type,concat->type);
|
@@ -605,8 +673,10 @@ VALUE rcsim_make_concat(VALUE mod, VALUE type, VALUE dirV) {
|
|
605
673
|
|
606
674
|
/* Creating a ref concat C object. */
|
607
675
|
VALUE rcsim_make_refConcat(VALUE mod, VALUE type, VALUE dirV) {
|
676
|
+
// printf("rcsim_make_refConcat\n");
|
608
677
|
/* Allocates the ref concat. */
|
609
678
|
RefConcat refConcat = (RefConcat)malloc(sizeof(RefConcatS));
|
679
|
+
// printf("refConcat=%p\n",refConcat);
|
610
680
|
/* Set it up. */
|
611
681
|
refConcat->kind = REF_CONCAT;
|
612
682
|
value_to_rcsim(TypeS,type,refConcat->type);
|
@@ -621,8 +691,10 @@ VALUE rcsim_make_refConcat(VALUE mod, VALUE type, VALUE dirV) {
|
|
621
691
|
|
622
692
|
/* Creating a ref index C object. */
|
623
693
|
VALUE rcsim_make_refIndex(VALUE mod, VALUE type, VALUE index, VALUE ref) {
|
694
|
+
// printf("rcsim_make_refIndex\n");
|
624
695
|
/* Allocates the ref index. */
|
625
696
|
RefIndex refIndex = (RefIndex)malloc(sizeof(RefIndexS));
|
697
|
+
// printf("refIndex=%p\n",refIndex);
|
626
698
|
/* Set it up. */
|
627
699
|
refIndex->kind = REF_INDEX;
|
628
700
|
value_to_rcsim(TypeS,type,refIndex->type);
|
@@ -636,8 +708,10 @@ VALUE rcsim_make_refIndex(VALUE mod, VALUE type, VALUE index, VALUE ref) {
|
|
636
708
|
|
637
709
|
/* Creating a ref range C object. */
|
638
710
|
VALUE rcsim_make_refRange(VALUE mod, VALUE type, VALUE first, VALUE last, VALUE ref) {
|
711
|
+
// printf("rcsim_make_refRange\n");
|
639
712
|
/* Allocates the ref range. */
|
640
713
|
RefRangeE refRange = (RefRangeE)malloc(sizeof(RefRangeES));
|
714
|
+
// printf("refRange=%p\n",refRange);
|
641
715
|
/* Set it up. */
|
642
716
|
refRange->kind = REF_RANGE;
|
643
717
|
value_to_rcsim(TypeS,type,refRange->type);
|
@@ -653,8 +727,10 @@ VALUE rcsim_make_refRange(VALUE mod, VALUE type, VALUE first, VALUE last, VALUE
|
|
653
727
|
|
654
728
|
/* Creating a character string C object. */
|
655
729
|
VALUE rcsim_make_stringE(VALUE mod, VALUE strV) {
|
730
|
+
// printf("rcsim_make_stringE\n");
|
656
731
|
/* Allocates the string. */
|
657
732
|
StringE stringE = (StringE)malloc(sizeof(StringES));
|
733
|
+
// printf("stringE=%p\n",stringE);
|
658
734
|
/* Set it up. */
|
659
735
|
stringE->kind = STRINGE;
|
660
736
|
stringE->str = strdup(StringValueCStr(strV));
|
@@ -671,19 +747,24 @@ VALUE rcsim_add_systemT_inputs(VALUE mod, VALUE systemTV, VALUE sigVs) {
|
|
671
747
|
/* Get the C systemT from the Ruby value. */
|
672
748
|
SystemT systemT;
|
673
749
|
value_to_rcsim(SystemTS,systemTV,systemT);
|
750
|
+
// printf("rcsim_add_systemT_inputs with systemT=%p\n",systemT);
|
674
751
|
// printf("Adding to systemT with kind=%d and name=%s\n",systemT->kind, systemT->name);
|
675
752
|
/* Prepare the size for the inputs. */
|
676
753
|
long num = RARRAY_LEN(sigVs);
|
677
754
|
long old_num = systemT->num_inputs;
|
678
755
|
systemT->num_inputs += num;
|
679
|
-
|
680
|
-
//
|
681
|
-
//
|
756
|
+
// printf("first systemT->inputs=%p\n",systemT->inputs); fflush(stdout);
|
757
|
+
// systemT->inputs=realloc(systemT->inputs,
|
758
|
+
// sizeof(SignalI[systemT->num_inputs]));
|
759
|
+
systemT->inputs=my_realloc(systemT->inputs,sizeof(SignalI[old_num]),
|
760
|
+
sizeof(SignalI[systemT->num_inputs]));
|
761
|
+
// printf("now systemT->inputs=%p\n",systemT->inputs); fflush(stdout);
|
762
|
+
// printf("access test: %p\n",systemT->inputs[0]); fflush(stdout);
|
682
763
|
/* Get and add the signals from the Ruby value. */
|
683
|
-
for(
|
764
|
+
for(long i=0; i< num; ++i) {
|
684
765
|
SignalI sig;
|
766
|
+
// show_access(systemT->inputs,old_num+i);
|
685
767
|
value_to_rcsim(SignalIS,rb_ary_entry(sigVs,i),sig);
|
686
|
-
// printf("old_num+i=%ld\n",old_num+i);
|
687
768
|
systemT->inputs[old_num + i] = sig;
|
688
769
|
}
|
689
770
|
return systemTV;
|
@@ -694,14 +775,22 @@ VALUE rcsim_add_systemT_outputs(VALUE mod, VALUE systemTV, VALUE sigVs) {
|
|
694
775
|
/* Get the C systemT from the Ruby value. */
|
695
776
|
SystemT systemT;
|
696
777
|
value_to_rcsim(SystemTS,systemTV,systemT);
|
778
|
+
// printf("rcsim_add_systemT_inputs with systemT=%p\n",systemT);
|
697
779
|
/* Prepare the size for the outputs. */
|
698
780
|
long num = RARRAY_LEN(sigVs);
|
699
781
|
long old_num = systemT->num_outputs;
|
700
782
|
systemT->num_outputs += num;
|
701
|
-
|
783
|
+
// printf("first systemT->outputs=%p\n",systemT->outputs); fflush(stdout);
|
784
|
+
// systemT->outputs =realloc(systemT->outputs,
|
785
|
+
// sizeof(SignalI[systemT->num_outputs]));
|
786
|
+
systemT->outputs =my_realloc(systemT->outputs,sizeof(SignalI[old_num]),
|
787
|
+
sizeof(SignalI[systemT->num_outputs]));
|
788
|
+
// printf("now systemT->outputs=%p\n",systemT->outputs); fflush(stdout);
|
789
|
+
// printf("access test: %p\n",systemT->outputs[0]); fflush(stdout);
|
702
790
|
/* Get and add the signals from the Ruby value. */
|
703
|
-
for(
|
791
|
+
for(long i=0; i< num; ++i) {
|
704
792
|
SignalI sig;
|
793
|
+
// show_access(systemT->outputs,old_num+i);
|
705
794
|
value_to_rcsim(SignalIS,rb_ary_entry(sigVs,i),sig);
|
706
795
|
systemT->outputs[old_num + i] = sig;
|
707
796
|
}
|
@@ -713,14 +802,22 @@ VALUE rcsim_add_systemT_inouts(VALUE mod, VALUE systemTV, VALUE sigVs) {
|
|
713
802
|
/* Get the C systemT from the Ruby value. */
|
714
803
|
SystemT systemT;
|
715
804
|
value_to_rcsim(SystemTS,systemTV,systemT);
|
805
|
+
// printf("rcsim_add_systemT_inputs with systemT=%p\n",systemT);
|
716
806
|
/* Prepare the size for the inouts. */
|
717
807
|
long num = RARRAY_LEN(sigVs);
|
718
808
|
long old_num = systemT->num_inouts;
|
719
809
|
systemT->num_inouts += num;
|
720
|
-
|
810
|
+
// printf("first systemT->inouts=%p\n",systemT->inouts); fflush(stdout);
|
811
|
+
// systemT->inouts =realloc(systemT->inouts,
|
812
|
+
// sizeof(SignalI[systemT->num_inouts]));
|
813
|
+
systemT->inouts =my_realloc(systemT->inouts,sizeof(SignalI[old_num]),
|
814
|
+
sizeof(SignalI[systemT->num_inouts]));
|
815
|
+
// printf("now systemT->inouts=%p\n",systemT->inouts); fflush(stdout);
|
816
|
+
// printf("access test: %p\n",systemT->inouts[0]); fflush(stdout);
|
721
817
|
/* Get and add the signals from the Ruby value. */
|
722
|
-
for(
|
818
|
+
for(long i=0; i< num; ++i) {
|
723
819
|
SignalI sig;
|
820
|
+
// show_access(systemT->inouts,old_num+i);
|
724
821
|
value_to_rcsim(SignalIS,rb_ary_entry(sigVs,i),sig);
|
725
822
|
systemT->inouts[old_num + i] = sig;
|
726
823
|
}
|
@@ -732,14 +829,22 @@ VALUE rcsim_add_scope_inners(VALUE mod, VALUE scopeV, VALUE sigVs) {
|
|
732
829
|
/* Get the C scope from the Ruby value. */
|
733
830
|
Scope scope;
|
734
831
|
value_to_rcsim(ScopeS,scopeV,scope);
|
832
|
+
// printf("rcsim_add_scope_inners with scope=%p\n",scope);
|
735
833
|
/* Prepare the size for the inners. */
|
736
834
|
long num = RARRAY_LEN(sigVs);
|
737
835
|
long old_num = scope->num_inners;
|
738
836
|
scope->num_inners += num;
|
739
|
-
|
837
|
+
// printf("first scope->inners=%p\n",scope->inners); fflush(stdout);
|
838
|
+
// scope->inners = realloc(scope->inners,
|
839
|
+
// sizeof(SignalI[scope->num_inners]));
|
840
|
+
scope->inners = my_realloc(scope->inners,sizeof(SignalI[old_num]),
|
841
|
+
sizeof(SignalI[scope->num_inners]));
|
842
|
+
// printf("now scope->inners=%p\n",scope->inners); fflush(stdout);
|
843
|
+
// printf("access test: %p\n",scope->inners[0]); fflush(stdout);
|
740
844
|
/* Get and add the signals from the Ruby value. */
|
741
|
-
for(
|
845
|
+
for(long i=0; i< num; ++i) {
|
742
846
|
SignalI sig;
|
847
|
+
// show_access(scope->inners,old_num+i);
|
743
848
|
value_to_rcsim(SignalIS,rb_ary_entry(sigVs,i),sig);
|
744
849
|
scope->inners[old_num + i] = sig;
|
745
850
|
}
|
@@ -748,18 +853,28 @@ VALUE rcsim_add_scope_inners(VALUE mod, VALUE scopeV, VALUE sigVs) {
|
|
748
853
|
|
749
854
|
/* Adds behaviors to a C scope. */
|
750
855
|
VALUE rcsim_add_scope_behaviors(VALUE mod, VALUE scopeV, VALUE behVs) {
|
856
|
+
// printf("rcsim_add_scope_behaviors\n");
|
751
857
|
/* Get the C scope from the Ruby value. */
|
752
858
|
Scope scope;
|
753
859
|
value_to_rcsim(ScopeS,scopeV,scope);
|
860
|
+
// printf("rcsim_add_scope_behaviors with scope=%p\n",scope);
|
754
861
|
/* Prepare the size for the behaviors. */
|
755
862
|
long num = RARRAY_LEN(behVs);
|
756
863
|
long old_num = scope->num_behaviors;
|
864
|
+
// printf("num=%lu old_num=%lu\n",num,old_num);
|
865
|
+
// printf("scope->behaviors=%p\n",scope->behaviors);
|
757
866
|
scope->num_behaviors += num;
|
758
|
-
scope->behaviors
|
759
|
-
|
867
|
+
// printf("first scope->behaviors=%p\n",scope->behaviors); fflush(stdout);
|
868
|
+
// scope->behaviors = realloc(scope->behaviors,
|
869
|
+
// sizeof(Behavior[scope->num_behaviors]));
|
870
|
+
scope->behaviors = my_realloc(scope->behaviors,sizeof(Behavior[old_num]),
|
871
|
+
sizeof(Behavior[scope->num_behaviors]));
|
872
|
+
// printf("now scope->behaviors=%p\n",scope->behaviors); fflush(stdout);
|
873
|
+
// printf("access test: %p\n",scope->behaviors[0]); fflush(stdout);
|
760
874
|
/* Get and add the behaviors from the Ruby value. */
|
761
|
-
for(
|
875
|
+
for(long i=0; i< num; ++i) {
|
762
876
|
Behavior beh;
|
877
|
+
// show_access(scope->behaviors,old_num+i);
|
763
878
|
value_to_rcsim(BehaviorS,rb_ary_entry(behVs,i),beh);
|
764
879
|
scope->behaviors[old_num + i] = beh;
|
765
880
|
}
|
@@ -771,15 +886,22 @@ VALUE rcsim_add_scope_systemIs(VALUE mod, VALUE scopeV, VALUE sysVs) {
|
|
771
886
|
/* Get the C scope from the Ruby value. */
|
772
887
|
Scope scope;
|
773
888
|
value_to_rcsim(ScopeS,scopeV,scope);
|
889
|
+
// printf("rcsim_add_scope_systemIs with scope=%p\n",scope);
|
774
890
|
/* Prepare the size for the system instances. */
|
775
891
|
long num = RARRAY_LEN(sysVs);
|
776
892
|
long old_num = scope->num_systemIs;
|
777
893
|
scope->num_systemIs += num;
|
778
|
-
scope->systemIs
|
779
|
-
|
894
|
+
// printf("first scope->systemIs=%p\n",scope->systemIs); fflush(stdout);
|
895
|
+
// scope->systemIs = realloc(scope->systemIs,
|
896
|
+
// sizeof(SystemI[scope->num_systemIs]));
|
897
|
+
scope->systemIs = my_realloc(scope->systemIs,sizeof(SystemI[old_num]),
|
898
|
+
sizeof(SystemI[scope->num_systemIs]));
|
899
|
+
// printf("now scope->systemIs=%p\n",scope->systemIs); fflush(stdout);
|
900
|
+
// printf("access test: %p\n",scope->systemIs[0]); fflush(stdout);
|
780
901
|
/* Get and add the system instances from the Ruby value. */
|
781
|
-
for(
|
902
|
+
for(long i=0; i< num; ++i) {
|
782
903
|
SystemI sys;
|
904
|
+
// show_access(scope->systemIs,old_num+i);
|
783
905
|
value_to_rcsim(SystemIS,rb_ary_entry(sysVs,i),sys);
|
784
906
|
scope->systemIs[old_num + i] = sys;
|
785
907
|
}
|
@@ -791,15 +913,22 @@ VALUE rcsim_add_scope_scopes(VALUE mod, VALUE scopeV, VALUE scpVs) {
|
|
791
913
|
/* Get the C scope from the Ruby value. */
|
792
914
|
Scope scope;
|
793
915
|
value_to_rcsim(ScopeS,scopeV,scope);
|
916
|
+
// printf("rcsim_add_scope_scopes with scope=%p\n",scope);
|
794
917
|
/* Prepare the size for the sub scopes. */
|
795
918
|
long num = RARRAY_LEN(scpVs);
|
796
919
|
long old_num = scope->num_scopes;
|
797
920
|
scope->num_scopes += num;
|
798
|
-
scope->scopes
|
799
|
-
|
921
|
+
// printf("first scope->scopes=%p\n",scope->scopes); fflush(stdout);
|
922
|
+
// scope->scopes = realloc(scope->scopes,
|
923
|
+
// sizeof(Scope[scope->num_scopes]));
|
924
|
+
scope->scopes = my_realloc(scope->scopes,sizeof(Scope[old_num]),
|
925
|
+
sizeof(Scope[scope->num_scopes]));
|
926
|
+
// printf("now scope->scopes=%p\n",scope->scopes); fflush(stdout);
|
927
|
+
// printf("access test: %p\n",scope->scopes[0]); fflush(stdout);
|
800
928
|
/* Get and add the sub scopes from the Ruby value. */
|
801
|
-
for(
|
929
|
+
for(long i=0; i< num; ++i) {
|
802
930
|
Scope scp;
|
931
|
+
// show_access(scope->scopes,old_num+i);
|
803
932
|
value_to_rcsim(ScopeS,rb_ary_entry(scpVs,i),scp);
|
804
933
|
scope->scopes[old_num + i] = scp;
|
805
934
|
}
|
@@ -811,15 +940,22 @@ VALUE rcsim_add_behavior_events(VALUE mod, VALUE behaviorV, VALUE eventVs) {
|
|
811
940
|
/* Get the C behavior from the Ruby value. */
|
812
941
|
Behavior behavior;
|
813
942
|
value_to_rcsim(BehaviorS,behaviorV,behavior);
|
943
|
+
// printf("rcsim_add_behavior_events with behavior=%p\n",behavior);
|
814
944
|
/* Prepare the size for the events. */
|
815
945
|
long num = RARRAY_LEN(eventVs);
|
816
946
|
long old_num = behavior->num_events;
|
817
947
|
behavior->num_events += num;
|
818
|
-
behavior->events
|
819
|
-
|
948
|
+
// printf("first behavior->events=%p\n",behavior->events); fflush(stdout);
|
949
|
+
// behavior->events = realloc(behavior->events,
|
950
|
+
// sizeof(Event[behavior->num_events]));
|
951
|
+
behavior->events = my_realloc(behavior->events,sizeof(Event[old_num]),
|
952
|
+
sizeof(Event[behavior->num_events]));
|
953
|
+
// printf("now behavior->events=%p\n",behavior->events); fflush(stdout);
|
954
|
+
// printf("access test: %p\n",behavior->events[0]); fflush(stdout);
|
820
955
|
/* Get and add the events from the Ruby value. */
|
821
|
-
for(
|
956
|
+
for(long i=0; i< num; ++i) {
|
822
957
|
Event event;
|
958
|
+
// show_access(behavior->events,old_num+i);
|
823
959
|
value_to_rcsim(EventS,rb_ary_entry(eventVs,i),event);
|
824
960
|
behavior->events[old_num + i] = event;
|
825
961
|
/* Update the signal of the event to say it activates the behavior. */
|
@@ -827,17 +963,35 @@ VALUE rcsim_add_behavior_events(VALUE mod, VALUE behaviorV, VALUE eventVs) {
|
|
827
963
|
switch(event->edge) {
|
828
964
|
case ANYEDGE:
|
829
965
|
sig->num_any++;
|
830
|
-
|
966
|
+
// printf("first sig->any=%p\n",sig->any); fflush(stdout);
|
967
|
+
// sig->any = realloc(sig->any,sizeof(Object[sig->num_any]));
|
968
|
+
sig->any = my_realloc(sig->any,sizeof(Object[sig->num_any-1]),sizeof(Object[sig->num_any]));
|
969
|
+
// printf("now sig->any=%p\n",sig->any); fflush(stdout);
|
970
|
+
// printf("access test: %p\n",sig->any[0]); fflush(stdout);
|
971
|
+
// show_access(sig->any,sig->num_any-1);
|
972
|
+
// printf("sig->any=%p\n",sig->any);
|
831
973
|
sig->any[sig->num_any-1] = (Object)behavior;
|
832
974
|
break;
|
833
975
|
case POSEDGE:
|
834
976
|
sig->num_pos++;
|
835
|
-
|
977
|
+
// printf("first sig->pos=%p\n",sig->pos); fflush(stdout);
|
978
|
+
// sig->pos = realloc(sig->pos,sizeof(Object[sig->num_pos]));
|
979
|
+
sig->pos = my_realloc(sig->pos,sizeof(Object[sig->num_pos-1]),sizeof(Object[sig->num_pos]));
|
980
|
+
// printf("now sig->pos=%p\n",sig->pos); fflush(stdout);
|
981
|
+
// printf("access test: %p\n",sig->pos[0]); fflush(stdout);
|
982
|
+
// show_access(sig->pos,sig->num_pos-1);
|
983
|
+
// printf("sig->pos=%p\n",sig->pos);
|
836
984
|
sig->pos[sig->num_pos-1] = (Object)behavior;
|
837
985
|
break;
|
838
986
|
case NEGEDGE:
|
839
987
|
sig->num_neg++;
|
840
|
-
|
988
|
+
// printf("first sig->neg=%p\n",sig->neg); fflush(stdout);
|
989
|
+
// sig->neg = realloc(sig->neg,sizeof(Object[sig->num_neg]));
|
990
|
+
sig->neg = my_realloc(sig->neg,sizeof(Object[sig->num_neg-1]),sizeof(Object[sig->num_neg]));
|
991
|
+
// printf("now sig->neg=%p\n",sig->neg); fflush(stdout);
|
992
|
+
// printf("access test: %p\n",sig->neg[0]); fflush(stdout);
|
993
|
+
// show_access(sig->neg,sig->num_neg-1);
|
994
|
+
// printf("sig->neg=%p\n",sig->neg);
|
841
995
|
sig->neg[sig->num_neg-1] = (Object)behavior;
|
842
996
|
break;
|
843
997
|
default:
|
@@ -852,14 +1006,22 @@ VALUE rcsim_add_systemI_systemTs(VALUE mod, VALUE systemIV, VALUE sysVs) {
|
|
852
1006
|
/* Get the C systemI from the Ruby value. */
|
853
1007
|
SystemI systemI;
|
854
1008
|
value_to_rcsim(SystemIS,systemIV,systemI);
|
1009
|
+
// printf("rcsim_add_systemI_systemTs with systemI=%p\n",systemI);
|
855
1010
|
/* Prepare the size for the alternate system types. */
|
856
1011
|
long num = RARRAY_LEN(sysVs);
|
857
1012
|
long old_num = systemI->num_systems;
|
858
1013
|
systemI->num_systems += num;
|
859
|
-
|
1014
|
+
// printf("first systemI->systems=%p\n",systemI->systems); fflush(stdout);
|
1015
|
+
// systemI->systems=realloc(systemI->systems,
|
1016
|
+
// sizeof(SystemT[systemI->num_systems]));
|
1017
|
+
systemI->systems=my_realloc(systemI->systems,sizeof(SystemT[old_num]),
|
1018
|
+
sizeof(SystemT[systemI->num_systems]));
|
1019
|
+
// printf("now systemI->systems=%p\n",systemI->systems); fflush(stdout);
|
1020
|
+
// printf("access test: %p\n",systemI->systems[0]); fflush(stdout);
|
860
1021
|
/* Get and add the alternate system types from the Ruby value. */
|
861
|
-
for(
|
1022
|
+
for(long i=0; i< num; ++i) {
|
862
1023
|
SystemT sys;
|
1024
|
+
// show_access(systemI->systems,old_num+i);
|
863
1025
|
value_to_rcsim(SystemTS,rb_ary_entry(sysVs,i),sys);
|
864
1026
|
systemI->systems[old_num + i] = sys;
|
865
1027
|
}
|
@@ -871,15 +1033,22 @@ VALUE rcsim_add_print_args(VALUE mod, VALUE printV, VALUE argVs) {
|
|
871
1033
|
/* Get the C print from the Ruby value. */
|
872
1034
|
Print print;
|
873
1035
|
value_to_rcsim(PrintS,printV,print);
|
1036
|
+
// printf("rcsim_add_print_args with print=%p\n",print);
|
874
1037
|
/* Prepare the size for the arguments. */
|
875
1038
|
long num = RARRAY_LEN(argVs);
|
876
1039
|
long old_num = print->num_args;
|
877
1040
|
print->num_args += num;
|
878
|
-
print->args
|
879
|
-
|
1041
|
+
// printf("first print->args=%p\n",print->args); fflush(stdout);
|
1042
|
+
// print->args = realloc(print->args,
|
1043
|
+
// sizeof(Expression[print->num_args]));
|
1044
|
+
print->args = my_realloc(print->args,sizeof(Expression[old_num]),
|
1045
|
+
sizeof(Expression[print->num_args]));
|
1046
|
+
// printf("now print->args=%p\n",print->args); fflush(stdout);
|
1047
|
+
// printf("access test: %p\n",print->args[0]); fflush(stdout);
|
880
1048
|
/* Get and add the arguments from the Ruby value. */
|
881
|
-
for(
|
1049
|
+
for(long i=0; i< num; ++i) {
|
882
1050
|
Expression arg;
|
1051
|
+
// show_access(print->args,old_num+i);
|
883
1052
|
value_to_rcsim(ExpressionS,rb_ary_entry(argVs,i),arg);
|
884
1053
|
print->args[old_num + i] = arg;
|
885
1054
|
}
|
@@ -891,16 +1060,27 @@ VALUE rcsim_add_hif_noifs(VALUE mod, VALUE hifV, VALUE condVs, VALUE stmntVs) {
|
|
891
1060
|
/* Get the C hardware if from the Ruby value. */
|
892
1061
|
HIf hif;
|
893
1062
|
value_to_rcsim(HIfS,hifV,hif);
|
1063
|
+
// printf("rcsim_add_hif_noifs with hif=%p\n",hif);
|
894
1064
|
/* Prepare the size for the noifs. */
|
895
1065
|
long num = RARRAY_LEN(condVs);
|
896
1066
|
long old_num = hif->num_noifs;
|
897
1067
|
hif->num_noifs += num;
|
898
|
-
|
899
|
-
|
1068
|
+
// printf("first hif->noconds=%p\n",hif->noconds); fflush(stdout);
|
1069
|
+
// printf("first hif->nostmnts=%p\n",hif->nostmnts); fflush(stdout);
|
1070
|
+
// hif->noconds = realloc(hif->noconds,sizeof(Expression[hif->num_noifs]));
|
1071
|
+
hif->noconds = my_realloc(hif->noconds,sizeof(Expression[old_num]),sizeof(Expression[hif->num_noifs]));
|
1072
|
+
// printf("now hif->noconds=%p\n",hif->noconds); fflush(stdout);
|
1073
|
+
// printf("access test: %p\n",hif->noconds[0]); fflush(stdout);
|
1074
|
+
// hif->nostmnts = realloc(hif->nostmnts,sizeof(Statement[hif->num_noifs]));
|
1075
|
+
hif->nostmnts = my_realloc(hif->nostmnts,sizeof(Statement[old_num]),sizeof(Statement[hif->num_noifs]));
|
1076
|
+
// printf("now hif->nostmnts=%p\n",hif->nostmnts); fflush(stdout);
|
1077
|
+
// printf("access test: %p\n",hif->nostmnts[0]); fflush(stdout);
|
900
1078
|
/* Get and add the noifs from the Ruby value. */
|
901
|
-
for(
|
1079
|
+
for(long i=0; i< num; ++i) {
|
902
1080
|
Expression cond;
|
903
1081
|
Statement stmnt;
|
1082
|
+
// show_access(hif->noconds,old_num+i);
|
1083
|
+
// show_access(hif->nostmnts,old_num+i);
|
904
1084
|
value_to_rcsim(ExpressionS,rb_ary_entry(condVs,i),cond);
|
905
1085
|
hif->noconds[old_num + i] = cond;
|
906
1086
|
value_to_rcsim(StatementS,rb_ary_entry(stmntVs,i),stmnt);
|
@@ -914,18 +1094,31 @@ VALUE rcsim_add_hcase_whens(VALUE mod, VALUE hcaseV, VALUE matchVs, VALUE stmntV
|
|
914
1094
|
/* Get the C hardware case from the Ruby value. */
|
915
1095
|
HCase hcase;
|
916
1096
|
value_to_rcsim(HCaseS,hcaseV,hcase);
|
1097
|
+
// printf("rcsim_add_hcase_whens with hcase=%p\n",hcase);
|
917
1098
|
/* Prepare the size for the noifs. */
|
918
1099
|
long num = RARRAY_LEN(matchVs);
|
919
1100
|
long old_num = hcase->num_whens;
|
920
1101
|
hcase->num_whens += num;
|
921
|
-
hcase->matches
|
922
|
-
|
923
|
-
hcase->
|
924
|
-
|
1102
|
+
// printf("first hcase->matches=%p\n",hcase->matches); fflush(stdout);
|
1103
|
+
// printf("first hcase->stmnts=%p\n",hcase->stmnts); fflush(stdout);
|
1104
|
+
// hcase->matches = realloc(hcase->matches,
|
1105
|
+
// sizeof(Expression[hcase->num_whens]));
|
1106
|
+
hcase->matches = my_realloc(hcase->matches,sizeof(Expression[old_num]),
|
1107
|
+
sizeof(Expression[hcase->num_whens]));
|
1108
|
+
// printf("now hcase->matches=%p\n",hcase->matches); fflush(stdout);
|
1109
|
+
// printf("access test: %p\n",hcase->matches[0]); fflush(stdout);
|
1110
|
+
// hcase->stmnts = realloc(hcase->stmnts,
|
1111
|
+
// sizeof(Statement[hcase->num_whens]));
|
1112
|
+
hcase->stmnts = my_realloc(hcase->stmnts,sizeof(Statement[old_num]),
|
1113
|
+
sizeof(Statement[hcase->num_whens]));
|
1114
|
+
// printf("now hcase->stmnts=%p\n",hcase->stmnts); fflush(stdout);
|
1115
|
+
// printf("access test: %p\n",hcase->stmnts[0]); fflush(stdout);
|
925
1116
|
/* Get and add the whens from the Ruby value. */
|
926
|
-
for(
|
1117
|
+
for(long i=0; i< num; ++i) {
|
927
1118
|
Expression match;
|
928
1119
|
Statement stmnt;
|
1120
|
+
// show_access(hcase->matches,old_num+i);
|
1121
|
+
// show_access(hcase->stmnts,old_num+i);
|
929
1122
|
value_to_rcsim(ExpressionS,rb_ary_entry(matchVs,i),match);
|
930
1123
|
hcase->matches[old_num + i] = match;
|
931
1124
|
value_to_rcsim(StatementS,rb_ary_entry(stmntVs,i),stmnt);
|
@@ -939,14 +1132,22 @@ VALUE rcsim_add_block_inners(VALUE mod, VALUE blockV, VALUE sigVs) {
|
|
939
1132
|
/* Get the C block from the Ruby value. */
|
940
1133
|
Block block;
|
941
1134
|
value_to_rcsim(BlockS,blockV,block);
|
1135
|
+
// printf("rcsim_add_block_inners with block=%p\n",block);
|
942
1136
|
/* Prepare the size for the inners. */
|
943
1137
|
long num = RARRAY_LEN(sigVs);
|
944
1138
|
long old_num = block->num_inners;
|
945
1139
|
block->num_inners += num;
|
946
|
-
|
1140
|
+
// printf("first block->inners=%p\n",block->inners); fflush(stdout);
|
1141
|
+
// block->inners = realloc(block->inners,
|
1142
|
+
// sizeof(SignalI[block->num_inners]));
|
1143
|
+
block->inners = my_realloc(block->inners,sizeof(SignalI[old_num]),
|
1144
|
+
sizeof(SignalI[block->num_inners]));
|
1145
|
+
// printf("now block->inners=%p\n",block->inners); fflush(stdout);
|
1146
|
+
// printf("access test: %p\n",block->inners[0]); fflush(stdout);
|
947
1147
|
/* Get and add the signals from the Ruby value. */
|
948
|
-
for(
|
1148
|
+
for(long i=0; i< num; ++i) {
|
949
1149
|
SignalI sig;
|
1150
|
+
// show_access(block->inners,old_num+i);
|
950
1151
|
value_to_rcsim(SignalIS,rb_ary_entry(sigVs,i),sig);
|
951
1152
|
block->inners[old_num + i] = sig;
|
952
1153
|
}
|
@@ -958,14 +1159,22 @@ VALUE rcsim_add_block_statements(VALUE mod, VALUE blockV, VALUE stmntVs) {
|
|
958
1159
|
/* Get the C block from the Ruby value. */
|
959
1160
|
Block block;
|
960
1161
|
value_to_rcsim(BlockS,blockV,block);
|
1162
|
+
// printf("rcsim_add_block_statements with block=%p\n",block);
|
961
1163
|
/* Prepare the size for the statements. */
|
962
1164
|
long num = RARRAY_LEN(stmntVs);
|
963
1165
|
long old_num = block->num_stmnts;
|
964
1166
|
block->num_stmnts += num;
|
965
|
-
|
1167
|
+
// printf("first block->stmnts=%p\n",block->stmnts); fflush(stdout);
|
1168
|
+
// block->stmnts = realloc(block->stmnts,
|
1169
|
+
// sizeof(Statement[block->num_stmnts]));
|
1170
|
+
block->stmnts = my_realloc(block->stmnts,sizeof(Statement[old_num]),
|
1171
|
+
sizeof(Statement[block->num_stmnts]));
|
1172
|
+
// printf("now block->stmnts=%p\n",block->stmnts); fflush(stdout);
|
1173
|
+
// printf("access test: %p\n",block->stmnts[0]); fflush(stdout);
|
966
1174
|
/* Get and add the statements from the Ruby value. */
|
967
|
-
for(
|
1175
|
+
for(long i=0; i< num; ++i) {
|
968
1176
|
Statement stmnt;
|
1177
|
+
// show_access(block->stmnts,old_num+i);
|
969
1178
|
value_to_rcsim(StatementS,rb_ary_entry(stmntVs,i),stmnt);
|
970
1179
|
block->stmnts[old_num + i] = stmnt;
|
971
1180
|
}
|
@@ -977,14 +1186,22 @@ VALUE rcsim_add_select_choices(VALUE mod, VALUE selectV, VALUE choiceVs) {
|
|
977
1186
|
/* Get the C select from the Ruby value. */
|
978
1187
|
Select select;
|
979
1188
|
value_to_rcsim(SelectS,selectV,select);
|
1189
|
+
// printf("rcsim_add_select_choices with select=%p\n",select);
|
980
1190
|
/* Prepare the size for the choices. */
|
981
1191
|
long num = RARRAY_LEN(choiceVs);
|
982
1192
|
long old_num = select->num_choices;
|
983
1193
|
select->num_choices += num;
|
984
|
-
|
1194
|
+
// printf("first select->choices=%p\n",select->choices); fflush(stdout);
|
1195
|
+
// select->choices = realloc(select->choices,
|
1196
|
+
// sizeof(Expression[select->num_choices]));
|
1197
|
+
select->choices = my_realloc(select->choices,sizeof(Expression[old_num]),
|
1198
|
+
sizeof(Expression[select->num_choices]));
|
1199
|
+
// printf("now select->choices=%p\n",select->choices); fflush(stdout);
|
1200
|
+
// printf("access test: %p\n",select->choices[0]); fflush(stdout);
|
985
1201
|
/* Get and add the choices from the Ruby value. */
|
986
|
-
for(
|
1202
|
+
for(long i=0; i< num; ++i) {
|
987
1203
|
Expression choice;
|
1204
|
+
// show_access(select->choices,old_num+i);
|
988
1205
|
value_to_rcsim(ExpressionS,rb_ary_entry(choiceVs,i),choice);
|
989
1206
|
select->choices[old_num + i] = choice;
|
990
1207
|
}
|
@@ -996,17 +1213,24 @@ VALUE rcsim_add_concat_expressions(VALUE mod, VALUE concatV, VALUE exprVs) {
|
|
996
1213
|
/* Get the C concat from the Ruby value. */
|
997
1214
|
Concat concat;
|
998
1215
|
value_to_rcsim(ConcatS,concatV,concat);
|
1216
|
+
// printf("rcsim_add_concat_expressions with concat=%p\n",concat);
|
999
1217
|
/* Prepare the size for the expressions. */
|
1000
1218
|
long num = RARRAY_LEN(exprVs);
|
1001
1219
|
long old_num = concat->num_exprs;
|
1002
1220
|
// printf("add_concat_expressions with num=%li old_num=%li\n",num,old_num);
|
1003
1221
|
concat->num_exprs += num;
|
1004
|
-
|
1222
|
+
// printf("first concat->exprs=%p\n",concat->exprs); fflush(stdout);
|
1223
|
+
// concat->exprs = realloc(concat->exprs,
|
1224
|
+
// sizeof(Expression[concat->num_exprs]));
|
1225
|
+
concat->exprs = my_realloc(concat->exprs,sizeof(Expression[old_num]),
|
1226
|
+
sizeof(Expression[concat->num_exprs]));
|
1227
|
+
// printf("now concat->exprs=%p\n",concat->exprs); fflush(stdout);
|
1228
|
+
// printf("access test: %p\n",concat->exprs[0]); fflush(stdout);
|
1005
1229
|
/* Get and add the expressions from the Ruby value. */
|
1006
|
-
for(
|
1230
|
+
for(long i=0; i< num; ++i) {
|
1007
1231
|
Expression expr;
|
1232
|
+
// show_access(concat->exprs,old_num+i);
|
1008
1233
|
value_to_rcsim(ExpressionS,rb_ary_entry(exprVs,i),expr);
|
1009
|
-
// printf("Adding expression with type width=%llu\n",type_width(expr->type));
|
1010
1234
|
concat->exprs[old_num + i] = expr;
|
1011
1235
|
}
|
1012
1236
|
return concatV;
|
@@ -1017,14 +1241,22 @@ VALUE rcsim_add_refConcat_refs(VALUE mod, VALUE refConcatV, VALUE refVs) {
|
|
1017
1241
|
/* Get the C refConcat from the Ruby value. */
|
1018
1242
|
RefConcat refConcat;
|
1019
1243
|
value_to_rcsim(RefConcatS,refConcatV,refConcat);
|
1244
|
+
// printf("rcsim_add_refConcat_refs with refConcat=%p\n",refConcat);
|
1020
1245
|
/* Prepare the size for the references. */
|
1021
1246
|
long num = RARRAY_LEN(refVs);
|
1022
1247
|
long old_num = refConcat->num_refs;
|
1023
1248
|
refConcat->num_refs += num;
|
1024
|
-
|
1249
|
+
// printf("first refConcat->refs=%p\n",refConcat->refs); fflush(stdout);
|
1250
|
+
// refConcat->refs = realloc(refConcat->refs,
|
1251
|
+
// sizeof(Reference[refConcat->num_refs]));
|
1252
|
+
refConcat->refs = my_realloc(refConcat->refs,sizeof(Reference[old_num]),
|
1253
|
+
sizeof(Reference[refConcat->num_refs]));
|
1254
|
+
// printf("now refConcat->refs=%p\n",refConcat->refs); fflush(stdout);
|
1255
|
+
// printf("access test: %p\n",refConcat->refs[0]); fflush(stdout);
|
1025
1256
|
/* Get and add the references from the Ruby value. */
|
1026
|
-
for(
|
1257
|
+
for(long i=0; i< num; ++i) {
|
1027
1258
|
Reference ref;
|
1259
|
+
// show_access(refConcat->refs,old_num+i);
|
1028
1260
|
value_to_rcsim(ReferenceS,rb_ary_entry(refVs,i),ref);
|
1029
1261
|
refConcat->refs[old_num + i] = ref;
|
1030
1262
|
}
|