HDLRuby 2.11.4 → 2.11.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b3303f28a79a14a42fb2421335afdbaa40c148440e622edaca2f8a98804192d
4
- data.tar.gz: 12dd7c5fd160141c151db950b7d797ef53bf012549ef983f8cf1b648edb3a85e
3
+ metadata.gz: 3a24b730862e801cb34298c05648bf25586a22e0010821e890e05bd31848f3d4
4
+ data.tar.gz: a9b88f03c706f758c08cb3438a92f180ad977257f2c5b56e5a40c95bd83f6ea8
5
5
  SHA512:
6
- metadata.gz: 94ba5098e5e8003f64c53f86ba47f8e831e3e49d39aa4f8991f3595dfec560749079720a6602bf76f2e31eacf88c922a0c689bf575e2ec17a48256dba70010d0
7
- data.tar.gz: 1856330cc10987e979ed13211d3a6aaaa1f382bfe9a6831a4a235eac35ea912844c5ca9b667f2a899b87a47518c29e38cb8c9b7c6a5ee27e953872fb810b8f30
6
+ metadata.gz: 4d7e6d175b79fb2d0702bebebda2ec00042508a303865e06dad98ca999117ec664c7f9cf9db514e95f03802c8b07e5abc06e7b25d329a2d715948ff4333cb8ca
7
+ data.tar.gz: 9f9d6b129c9caf9a13165fc54e6158b1dcef292117224690e0066f561e53ea006597fafc9f03585bc82d2868debda933528a5c78eea0621ebb2fbd0794087610
@@ -86,6 +86,7 @@ static VALUE RCSimPointer;
86
86
 
87
87
  /* My own realloc. */
88
88
  static void* my_realloc(void* pointer, size_t old_size, size_t new_size) {
89
+ // printf("my_realloc with old_size=%lu new_size=%lu\n",old_size,new_size);
89
90
  if(old_size >= new_size) { return pointer; }
90
91
  void* new_pointer = malloc(new_size);
91
92
  memcpy(new_pointer,pointer,old_size);
@@ -265,6 +266,8 @@ VALUE rcsim_make_behavior(VALUE mod, VALUE timed) {
265
266
  } else {
266
267
  /* The behavior is not timed. */
267
268
  behavior->timed = 0;
269
+ /* It must be initialized though. */
270
+ register_init_behavior(behavior);
268
271
  }
269
272
  behavior->active_time = 0;
270
273
  behavior->thread = NULL;
@@ -299,11 +302,14 @@ VALUE rcsim_make_event(VALUE mod, VALUE typeV, VALUE sigV) {
299
302
  }
300
303
 
301
304
 
305
+ static size_t last_signal_id = 0;
306
+
302
307
  /* Creating a signal C object. */
303
308
  VALUE rcsim_make_signal(VALUE mod, VALUE name, VALUE type) {
304
309
  // printf("rcsim_make_signal\n");
305
310
  /* Allocates the signal. */
306
311
  SignalI signal = (SignalI)malloc(sizeof(SignalIS));
312
+ signal->id = last_signal_id++;
307
313
  // printf("signal=%p\n",signal);
308
314
  /* Set it up. */
309
315
  signal->kind = SIGNALI;
@@ -312,7 +318,7 @@ VALUE rcsim_make_signal(VALUE mod, VALUE name, VALUE type) {
312
318
  // printf("signal->name=%p\n",signal->name);
313
319
  // printf("Creating signal named=%s\n",signal->name);
314
320
  value_to_rcsim(TypeS,type,signal->type);
315
- // printf("type width=%llu\n",type_width(signal->type));
321
+ // printf("&type=%p type=%p width=%llu\n",&(signal->type),signal->type,type_width(signal->type));
316
322
  signal->c_value = make_value(signal->type,0);
317
323
  // printf("signal->c_value=%p\n",signal->c_value);
318
324
  signal->c_value->signal = signal;
@@ -375,6 +381,7 @@ VALUE rcsim_make_transmit(VALUE mod, VALUE left, VALUE right) {
375
381
  // printf("transmit=%p\n",transmit);
376
382
  /* Set it up. */
377
383
  transmit->kind = TRANSMIT;
384
+ transmit->owner = NULL;
378
385
  value_to_rcsim(ReferenceS,left,transmit->left);
379
386
  value_to_rcsim(ExpressionS,right,transmit->right);
380
387
  /* Returns the C transmit embedded into a ruby VALUE. */
@@ -392,6 +399,7 @@ VALUE rcsim_make_print(VALUE mod) {
392
399
  // printf("print=%p\n",print);
393
400
  /* Set it up. */
394
401
  print->kind = PRINT;
402
+ print->owner = NULL;
395
403
  print->num_args = 0;
396
404
  print->args = NULL;
397
405
  /* Returns the C print embedded into a ruby VALUE. */
@@ -409,6 +417,7 @@ VALUE rcsim_make_timeWait(VALUE mod, VALUE unitV, VALUE delayV) {
409
417
  // printf("timeWait=%p\n",timeWait);
410
418
  /* Set it up. */
411
419
  timeWait->kind = TIME_WAIT;
420
+ timeWait->owner = NULL;
412
421
  /* Compute the delay. */
413
422
  unsigned long long delay;
414
423
  delay = NUM2LL(delayV);
@@ -438,6 +447,7 @@ VALUE rcsim_make_timeRepeat(VALUE mod, VALUE numberV, VALUE statementV) {
438
447
  // printf("timeRepeat=%p\n",timeRepeat); fflush(stdout);
439
448
  /* Set it up. */
440
449
  timeRepeat->kind = TIME_REPEAT;
450
+ timeRepeat->owner = NULL;
441
451
  /* Get and set the number of repeatition. */
442
452
  long long number;
443
453
  number = NUM2LL(numberV);
@@ -460,6 +470,7 @@ VALUE rcsim_make_timeTerminate(VALUE mod) {
460
470
  // printf("timeTerminate=%p\n",timeTerminate);
461
471
  /* Set it up. */
462
472
  timeTerminate->kind = TIME_TERMINATE;
473
+ timeTerminate->owner = NULL;
463
474
  /* Returns the C time terminate embedded into a ruby VALUE. */
464
475
  VALUE res;
465
476
  rcsim_to_value(TimeTerminateS,timeTerminate,res);
@@ -475,6 +486,7 @@ VALUE rcsim_make_hif(VALUE mod, VALUE conditionV, VALUE yesV, VALUE noV) {
475
486
  // printf("hif=%p\n",hif);
476
487
  /* Set it up. */
477
488
  hif->kind = HIF;
489
+ hif->owner = NULL;
478
490
  value_to_rcsim(ExpressionS,conditionV,hif->condition);
479
491
  value_to_rcsim(StatementS,yesV,hif->yes);
480
492
  if (TYPE(noV) == T_NIL)
@@ -499,6 +511,7 @@ VALUE rcsim_make_hcase(VALUE mod, VALUE valueV, VALUE defoltV) {
499
511
  // printf("hcase=%p\n",hcase);
500
512
  /* Set it up. */
501
513
  hcase->kind = HCASE;
514
+ hcase->owner = NULL;
502
515
  value_to_rcsim(ExpressionS,valueV,hcase->value);
503
516
  hcase->num_whens = 0;
504
517
  hcase->matches = NULL;
@@ -550,6 +563,7 @@ VALUE rcsim_make_value_numeric(VALUE mod, VALUE typeV, VALUE contentV) {
550
563
  value->capacity = 0;
551
564
  value->data_str = NULL;
552
565
  value->data_int = NUM2LL(contentV);
566
+ // printf("value->data_int=%lld\n",value->data_int);
553
567
  /* Returns the C value embedded into a ruby VALUE. */
554
568
  VALUE res;
555
569
  rcsim_to_value(ValueS,value,res);
@@ -591,6 +605,7 @@ VALUE rcsim_make_cast(VALUE mod, VALUE type, VALUE child) {
591
605
  // printf("cast=%p\n",cast);
592
606
  /* Set it up. */
593
607
  cast->kind = CAST;
608
+ cast->owner = NULL;
594
609
  value_to_rcsim(TypeS,type,cast->type);
595
610
  value_to_rcsim(ExpressionS,child,cast->child);
596
611
  /* Returns the C cast embedded into a ruby VALUE. */
@@ -607,6 +622,7 @@ VALUE rcsim_make_unary(VALUE mod, VALUE type, VALUE operator, VALUE child) {
607
622
  // printf("unary=%p\n",unary);
608
623
  /* Set it up. */
609
624
  unary->kind = UNARY;
625
+ unary->owner = NULL;
610
626
  value_to_rcsim(TypeS,type,unary->type);
611
627
  switch(sym_to_char(operator)) {
612
628
  case (unsigned char)'~': unary->oper = not_value; break;
@@ -628,6 +644,7 @@ VALUE rcsim_make_binary(VALUE mod, VALUE type, VALUE operator, VALUE left, VALUE
628
644
  // printf("binary=%p\n",binary);
629
645
  /* Set it up. */
630
646
  binary->kind = BINARY;
647
+ binary->owner = NULL;
631
648
  value_to_rcsim(TypeS,type,binary->type);
632
649
  switch(sym_to_char(operator)) {
633
650
  case (unsigned char)'+': binary->oper = add_value; break;
@@ -664,6 +681,7 @@ VALUE rcsim_make_select(VALUE mod, VALUE type, VALUE sel) {
664
681
  // printf("select=%p\n",select);
665
682
  /* Set it up. */
666
683
  select->kind = SELECT;
684
+ select->owner = NULL;
667
685
  value_to_rcsim(TypeS,type,select->type);
668
686
  value_to_rcsim(ExpressionS,sel,select->select);
669
687
  select->num_choices = 0;
@@ -682,6 +700,7 @@ VALUE rcsim_make_concat(VALUE mod, VALUE type, VALUE dirV) {
682
700
  // printf("concat=%p\n",concat);
683
701
  /* Set it up. */
684
702
  concat->kind = CONCAT;
703
+ concat->owner = NULL;
685
704
  value_to_rcsim(TypeS,type,concat->type);
686
705
  concat->num_exprs = 0;
687
706
  concat->exprs = NULL;
@@ -700,6 +719,7 @@ VALUE rcsim_make_refConcat(VALUE mod, VALUE type, VALUE dirV) {
700
719
  // printf("refConcat=%p\n",refConcat);
701
720
  /* Set it up. */
702
721
  refConcat->kind = REF_CONCAT;
722
+ refConcat->owner = NULL;
703
723
  value_to_rcsim(TypeS,type,refConcat->type);
704
724
  refConcat->num_refs = 0;
705
725
  refConcat->refs = NULL;
@@ -718,6 +738,7 @@ VALUE rcsim_make_refIndex(VALUE mod, VALUE type, VALUE index, VALUE ref) {
718
738
  // printf("refIndex=%p\n",refIndex);
719
739
  /* Set it up. */
720
740
  refIndex->kind = REF_INDEX;
741
+ refIndex->owner = NULL;
721
742
  value_to_rcsim(TypeS,type,refIndex->type);
722
743
  value_to_rcsim(ExpressionS,index,refIndex->index);
723
744
  value_to_rcsim(ReferenceS,ref,refIndex->ref);
@@ -735,6 +756,7 @@ VALUE rcsim_make_refRange(VALUE mod, VALUE type, VALUE first, VALUE last, VALUE
735
756
  // printf("refRange=%p\n",refRange);
736
757
  /* Set it up. */
737
758
  refRange->kind = REF_RANGE;
759
+ refRange->owner = NULL;
738
760
  value_to_rcsim(TypeS,type,refRange->type);
739
761
  value_to_rcsim(ExpressionS,first,refRange->first);
740
762
  value_to_rcsim(ExpressionS,last,refRange->last);
@@ -754,6 +776,7 @@ VALUE rcsim_make_stringE(VALUE mod, VALUE strV) {
754
776
  // printf("stringE=%p\n",stringE);
755
777
  /* Set it up. */
756
778
  stringE->kind = STRINGE;
779
+ stringE->owner = NULL;
757
780
  stringE->str = strdup(StringValueCStr(strV));
758
781
  /* Returns the C character string embedded into a ruby VALUE. */
759
782
  VALUE res;
@@ -777,8 +800,8 @@ VALUE rcsim_add_systemT_inputs(VALUE mod, VALUE systemTV, VALUE sigVs) {
777
800
  // printf("first systemT->inputs=%p\n",systemT->inputs); fflush(stdout);
778
801
  // systemT->inputs=realloc(systemT->inputs,
779
802
  // sizeof(SignalI[systemT->num_inputs]));
780
- systemT->inputs=my_realloc(systemT->inputs,sizeof(SignalI[old_num]),
781
- sizeof(SignalI[systemT->num_inputs]));
803
+ systemT->inputs=(SignalI*)my_realloc(systemT->inputs,
804
+ sizeof(SignalI[old_num]), sizeof(SignalI[systemT->num_inputs]));
782
805
  // printf("now systemT->inputs=%p\n",systemT->inputs); fflush(stdout);
783
806
  // printf("access test: %p\n",systemT->inputs[0]); fflush(stdout);
784
807
  /* Get and add the signals from the Ruby value. */
@@ -804,8 +827,8 @@ VALUE rcsim_add_systemT_outputs(VALUE mod, VALUE systemTV, VALUE sigVs) {
804
827
  // printf("first systemT->outputs=%p\n",systemT->outputs); fflush(stdout);
805
828
  // systemT->outputs =realloc(systemT->outputs,
806
829
  // sizeof(SignalI[systemT->num_outputs]));
807
- systemT->outputs =my_realloc(systemT->outputs,sizeof(SignalI[old_num]),
808
- sizeof(SignalI[systemT->num_outputs]));
830
+ systemT->outputs =(SignalI*)my_realloc(systemT->outputs,
831
+ sizeof(SignalI[old_num]), sizeof(SignalI[systemT->num_outputs]));
809
832
  // printf("now systemT->outputs=%p\n",systemT->outputs); fflush(stdout);
810
833
  // printf("access test: %p\n",systemT->outputs[0]); fflush(stdout);
811
834
  /* Get and add the signals from the Ruby value. */
@@ -831,8 +854,8 @@ VALUE rcsim_add_systemT_inouts(VALUE mod, VALUE systemTV, VALUE sigVs) {
831
854
  // printf("first systemT->inouts=%p\n",systemT->inouts); fflush(stdout);
832
855
  // systemT->inouts =realloc(systemT->inouts,
833
856
  // sizeof(SignalI[systemT->num_inouts]));
834
- systemT->inouts =my_realloc(systemT->inouts,sizeof(SignalI[old_num]),
835
- sizeof(SignalI[systemT->num_inouts]));
857
+ systemT->inouts =(SignalI*)my_realloc(systemT->inouts,
858
+ sizeof(SignalI[old_num]), sizeof(SignalI[systemT->num_inouts]));
836
859
  // printf("now systemT->inouts=%p\n",systemT->inouts); fflush(stdout);
837
860
  // printf("access test: %p\n",systemT->inouts[0]); fflush(stdout);
838
861
  /* Get and add the signals from the Ruby value. */
@@ -858,8 +881,8 @@ VALUE rcsim_add_scope_inners(VALUE mod, VALUE scopeV, VALUE sigVs) {
858
881
  // printf("first scope->inners=%p\n",scope->inners); fflush(stdout);
859
882
  // scope->inners = realloc(scope->inners,
860
883
  // sizeof(SignalI[scope->num_inners]));
861
- scope->inners = my_realloc(scope->inners,sizeof(SignalI[old_num]),
862
- sizeof(SignalI[scope->num_inners]));
884
+ scope->inners = (SignalI*)my_realloc(scope->inners,
885
+ sizeof(SignalI[old_num]), sizeof(SignalI[scope->num_inners]));
863
886
  // printf("now scope->inners=%p\n",scope->inners); fflush(stdout);
864
887
  // printf("access test: %p\n",scope->inners[0]); fflush(stdout);
865
888
  /* Get and add the signals from the Ruby value. */
@@ -888,8 +911,8 @@ VALUE rcsim_add_scope_behaviors(VALUE mod, VALUE scopeV, VALUE behVs) {
888
911
  // printf("first scope->behaviors=%p\n",scope->behaviors); fflush(stdout);
889
912
  // scope->behaviors = realloc(scope->behaviors,
890
913
  // sizeof(Behavior[scope->num_behaviors]));
891
- scope->behaviors = my_realloc(scope->behaviors,sizeof(Behavior[old_num]),
892
- sizeof(Behavior[scope->num_behaviors]));
914
+ scope->behaviors = (Behavior*)my_realloc(scope->behaviors,
915
+ sizeof(Behavior[old_num]), sizeof(Behavior[scope->num_behaviors]));
893
916
  // printf("now scope->behaviors=%p\n",scope->behaviors); fflush(stdout);
894
917
  // printf("access test: %p\n",scope->behaviors[0]); fflush(stdout);
895
918
  /* Get and add the behaviors from the Ruby value. */
@@ -915,8 +938,8 @@ VALUE rcsim_add_scope_systemIs(VALUE mod, VALUE scopeV, VALUE sysVs) {
915
938
  // printf("first scope->systemIs=%p\n",scope->systemIs); fflush(stdout);
916
939
  // scope->systemIs = realloc(scope->systemIs,
917
940
  // sizeof(SystemI[scope->num_systemIs]));
918
- scope->systemIs = my_realloc(scope->systemIs,sizeof(SystemI[old_num]),
919
- sizeof(SystemI[scope->num_systemIs]));
941
+ scope->systemIs = (SystemI*)my_realloc(scope->systemIs,
942
+ sizeof(SystemI[old_num]), sizeof(SystemI[scope->num_systemIs]));
920
943
  // printf("now scope->systemIs=%p\n",scope->systemIs); fflush(stdout);
921
944
  // printf("access test: %p\n",scope->systemIs[0]); fflush(stdout);
922
945
  /* Get and add the system instances from the Ruby value. */
@@ -942,8 +965,8 @@ VALUE rcsim_add_scope_scopes(VALUE mod, VALUE scopeV, VALUE scpVs) {
942
965
  // printf("first scope->scopes=%p\n",scope->scopes); fflush(stdout);
943
966
  // scope->scopes = realloc(scope->scopes,
944
967
  // sizeof(Scope[scope->num_scopes]));
945
- scope->scopes = my_realloc(scope->scopes,sizeof(Scope[old_num]),
946
- sizeof(Scope[scope->num_scopes]));
968
+ scope->scopes = (Scope*)my_realloc(scope->scopes,
969
+ sizeof(Scope[old_num]), sizeof(Scope[scope->num_scopes]));
947
970
  // printf("now scope->scopes=%p\n",scope->scopes); fflush(stdout);
948
971
  // printf("access test: %p\n",scope->scopes[0]); fflush(stdout);
949
972
  /* Get and add the sub scopes from the Ruby value. */
@@ -969,8 +992,8 @@ VALUE rcsim_add_behavior_events(VALUE mod, VALUE behaviorV, VALUE eventVs) {
969
992
  // printf("first behavior->events=%p\n",behavior->events); fflush(stdout);
970
993
  // behavior->events = realloc(behavior->events,
971
994
  // sizeof(Event[behavior->num_events]));
972
- behavior->events = my_realloc(behavior->events,sizeof(Event[old_num]),
973
- sizeof(Event[behavior->num_events]));
995
+ behavior->events = (Event*)my_realloc(behavior->events,
996
+ sizeof(Event[old_num]), sizeof(Event[behavior->num_events]));
974
997
  // printf("now behavior->events=%p\n",behavior->events); fflush(stdout);
975
998
  // printf("access test: %p\n",behavior->events[0]); fflush(stdout);
976
999
  /* Get and add the events from the Ruby value. */
@@ -986,7 +1009,8 @@ VALUE rcsim_add_behavior_events(VALUE mod, VALUE behaviorV, VALUE eventVs) {
986
1009
  sig->num_any++;
987
1010
  // printf("first sig->any=%p\n",sig->any); fflush(stdout);
988
1011
  // sig->any = realloc(sig->any,sizeof(Object[sig->num_any]));
989
- sig->any = my_realloc(sig->any,sizeof(Object[sig->num_any-1]),sizeof(Object[sig->num_any]));
1012
+ sig->any = (Object*)my_realloc(sig->any,
1013
+ sizeof(Object[sig->num_any-1]),sizeof(Object[sig->num_any]));
990
1014
  // printf("now sig->any=%p\n",sig->any); fflush(stdout);
991
1015
  // printf("access test: %p\n",sig->any[0]); fflush(stdout);
992
1016
  // show_access(sig->any,sig->num_any-1);
@@ -997,7 +1021,8 @@ VALUE rcsim_add_behavior_events(VALUE mod, VALUE behaviorV, VALUE eventVs) {
997
1021
  sig->num_pos++;
998
1022
  // printf("first sig->pos=%p\n",sig->pos); fflush(stdout);
999
1023
  // sig->pos = realloc(sig->pos,sizeof(Object[sig->num_pos]));
1000
- sig->pos = my_realloc(sig->pos,sizeof(Object[sig->num_pos-1]),sizeof(Object[sig->num_pos]));
1024
+ sig->pos = (Object*)my_realloc(sig->pos,
1025
+ sizeof(Object[sig->num_pos-1]),sizeof(Object[sig->num_pos]));
1001
1026
  // printf("now sig->pos=%p\n",sig->pos); fflush(stdout);
1002
1027
  // printf("access test: %p\n",sig->pos[0]); fflush(stdout);
1003
1028
  // show_access(sig->pos,sig->num_pos-1);
@@ -1008,7 +1033,8 @@ VALUE rcsim_add_behavior_events(VALUE mod, VALUE behaviorV, VALUE eventVs) {
1008
1033
  sig->num_neg++;
1009
1034
  // printf("first sig->neg=%p\n",sig->neg); fflush(stdout);
1010
1035
  // sig->neg = realloc(sig->neg,sizeof(Object[sig->num_neg]));
1011
- sig->neg = my_realloc(sig->neg,sizeof(Object[sig->num_neg-1]),sizeof(Object[sig->num_neg]));
1036
+ sig->neg = (Object*)my_realloc(sig->neg,
1037
+ sizeof(Object[sig->num_neg-1]),sizeof(Object[sig->num_neg]));
1012
1038
  // printf("now sig->neg=%p\n",sig->neg); fflush(stdout);
1013
1039
  // printf("access test: %p\n",sig->neg[0]); fflush(stdout);
1014
1040
  // show_access(sig->neg,sig->num_neg-1);
@@ -1035,8 +1061,8 @@ VALUE rcsim_add_systemI_systemTs(VALUE mod, VALUE systemIV, VALUE sysVs) {
1035
1061
  // printf("first systemI->systems=%p\n",systemI->systems); fflush(stdout);
1036
1062
  // systemI->systems=realloc(systemI->systems,
1037
1063
  // sizeof(SystemT[systemI->num_systems]));
1038
- systemI->systems=my_realloc(systemI->systems,sizeof(SystemT[old_num]),
1039
- sizeof(SystemT[systemI->num_systems]));
1064
+ systemI->systems = (SystemT*)my_realloc(systemI->systems,
1065
+ sizeof(SystemT[old_num]), sizeof(SystemT[systemI->num_systems]));
1040
1066
  // printf("now systemI->systems=%p\n",systemI->systems); fflush(stdout);
1041
1067
  // printf("access test: %p\n",systemI->systems[0]); fflush(stdout);
1042
1068
  /* Get and add the alternate system types from the Ruby value. */
@@ -1062,8 +1088,8 @@ VALUE rcsim_add_print_args(VALUE mod, VALUE printV, VALUE argVs) {
1062
1088
  // printf("first print->args=%p\n",print->args); fflush(stdout);
1063
1089
  // print->args = realloc(print->args,
1064
1090
  // sizeof(Expression[print->num_args]));
1065
- print->args = my_realloc(print->args,sizeof(Expression[old_num]),
1066
- sizeof(Expression[print->num_args]));
1091
+ print->args = (Expression*)my_realloc(print->args,
1092
+ sizeof(Expression[old_num]), sizeof(Expression[print->num_args]));
1067
1093
  // printf("now print->args=%p\n",print->args); fflush(stdout);
1068
1094
  // printf("access test: %p\n",print->args[0]); fflush(stdout);
1069
1095
  /* Get and add the arguments from the Ruby value. */
@@ -1089,11 +1115,13 @@ VALUE rcsim_add_hif_noifs(VALUE mod, VALUE hifV, VALUE condVs, VALUE stmntVs) {
1089
1115
  // printf("first hif->noconds=%p\n",hif->noconds); fflush(stdout);
1090
1116
  // printf("first hif->nostmnts=%p\n",hif->nostmnts); fflush(stdout);
1091
1117
  // hif->noconds = realloc(hif->noconds,sizeof(Expression[hif->num_noifs]));
1092
- hif->noconds = my_realloc(hif->noconds,sizeof(Expression[old_num]),sizeof(Expression[hif->num_noifs]));
1118
+ hif->noconds = (Expression*)my_realloc(hif->noconds,
1119
+ sizeof(Expression[old_num]),sizeof(Expression[hif->num_noifs]));
1093
1120
  // printf("now hif->noconds=%p\n",hif->noconds); fflush(stdout);
1094
1121
  // printf("access test: %p\n",hif->noconds[0]); fflush(stdout);
1095
1122
  // hif->nostmnts = realloc(hif->nostmnts,sizeof(Statement[hif->num_noifs]));
1096
- hif->nostmnts = my_realloc(hif->nostmnts,sizeof(Statement[old_num]),sizeof(Statement[hif->num_noifs]));
1123
+ hif->nostmnts = (Statement*)my_realloc(hif->nostmnts,
1124
+ sizeof(Statement[old_num]),sizeof(Statement[hif->num_noifs]));
1097
1125
  // printf("now hif->nostmnts=%p\n",hif->nostmnts); fflush(stdout);
1098
1126
  // printf("access test: %p\n",hif->nostmnts[0]); fflush(stdout);
1099
1127
  /* Get and add the noifs from the Ruby value. */
@@ -1124,14 +1152,14 @@ VALUE rcsim_add_hcase_whens(VALUE mod, VALUE hcaseV, VALUE matchVs, VALUE stmntV
1124
1152
  // printf("first hcase->stmnts=%p\n",hcase->stmnts); fflush(stdout);
1125
1153
  // hcase->matches = realloc(hcase->matches,
1126
1154
  // sizeof(Expression[hcase->num_whens]));
1127
- hcase->matches = my_realloc(hcase->matches,sizeof(Expression[old_num]),
1128
- sizeof(Expression[hcase->num_whens]));
1155
+ hcase->matches = (Expression*)my_realloc(hcase->matches,
1156
+ sizeof(Expression[old_num]), sizeof(Expression[hcase->num_whens]));
1129
1157
  // printf("now hcase->matches=%p\n",hcase->matches); fflush(stdout);
1130
1158
  // printf("access test: %p\n",hcase->matches[0]); fflush(stdout);
1131
1159
  // hcase->stmnts = realloc(hcase->stmnts,
1132
1160
  // sizeof(Statement[hcase->num_whens]));
1133
- hcase->stmnts = my_realloc(hcase->stmnts,sizeof(Statement[old_num]),
1134
- sizeof(Statement[hcase->num_whens]));
1161
+ hcase->stmnts = (Statement*)my_realloc(hcase->stmnts,
1162
+ sizeof(Statement[old_num]), sizeof(Statement[hcase->num_whens]));
1135
1163
  // printf("now hcase->stmnts=%p\n",hcase->stmnts); fflush(stdout);
1136
1164
  // printf("access test: %p\n",hcase->stmnts[0]); fflush(stdout);
1137
1165
  /* Get and add the whens from the Ruby value. */
@@ -1161,8 +1189,8 @@ VALUE rcsim_add_block_inners(VALUE mod, VALUE blockV, VALUE sigVs) {
1161
1189
  // printf("first block->inners=%p\n",block->inners); fflush(stdout);
1162
1190
  // block->inners = realloc(block->inners,
1163
1191
  // sizeof(SignalI[block->num_inners]));
1164
- block->inners = my_realloc(block->inners,sizeof(SignalI[old_num]),
1165
- sizeof(SignalI[block->num_inners]));
1192
+ block->inners = (SignalI*)my_realloc(block->inners,
1193
+ sizeof(SignalI[old_num]), sizeof(SignalI[block->num_inners]));
1166
1194
  // printf("now block->inners=%p\n",block->inners); fflush(stdout);
1167
1195
  // printf("access test: %p\n",block->inners[0]); fflush(stdout);
1168
1196
  /* Get and add the signals from the Ruby value. */
@@ -1188,8 +1216,8 @@ VALUE rcsim_add_block_statements(VALUE mod, VALUE blockV, VALUE stmntVs) {
1188
1216
  // printf("first block->stmnts=%p\n",block->stmnts); fflush(stdout);
1189
1217
  // block->stmnts = realloc(block->stmnts,
1190
1218
  // sizeof(Statement[block->num_stmnts]));
1191
- block->stmnts = my_realloc(block->stmnts,sizeof(Statement[old_num]),
1192
- sizeof(Statement[block->num_stmnts]));
1219
+ block->stmnts = (Statement*)my_realloc(block->stmnts,
1220
+ sizeof(Statement[old_num]), sizeof(Statement[block->num_stmnts]));
1193
1221
  // printf("now block->stmnts=%p\n",block->stmnts); fflush(stdout);
1194
1222
  // printf("access test: %p\n",block->stmnts[0]); fflush(stdout);
1195
1223
  /* Get and add the statements from the Ruby value. */
@@ -1215,8 +1243,8 @@ VALUE rcsim_add_select_choices(VALUE mod, VALUE selectV, VALUE choiceVs) {
1215
1243
  // printf("first select->choices=%p\n",select->choices); fflush(stdout);
1216
1244
  // select->choices = realloc(select->choices,
1217
1245
  // sizeof(Expression[select->num_choices]));
1218
- select->choices = my_realloc(select->choices,sizeof(Expression[old_num]),
1219
- sizeof(Expression[select->num_choices]));
1246
+ select->choices = (Expression*)my_realloc(select->choices,
1247
+ sizeof(Expression[old_num]),sizeof(Expression[select->num_choices]));
1220
1248
  // printf("now select->choices=%p\n",select->choices); fflush(stdout);
1221
1249
  // printf("access test: %p\n",select->choices[0]); fflush(stdout);
1222
1250
  /* Get and add the choices from the Ruby value. */
@@ -1243,8 +1271,8 @@ VALUE rcsim_add_concat_expressions(VALUE mod, VALUE concatV, VALUE exprVs) {
1243
1271
  // printf("first concat->exprs=%p\n",concat->exprs); fflush(stdout);
1244
1272
  // concat->exprs = realloc(concat->exprs,
1245
1273
  // sizeof(Expression[concat->num_exprs]));
1246
- concat->exprs = my_realloc(concat->exprs,sizeof(Expression[old_num]),
1247
- sizeof(Expression[concat->num_exprs]));
1274
+ concat->exprs = (Expression*)my_realloc(concat->exprs,
1275
+ sizeof(Expression[old_num]), sizeof(Expression[concat->num_exprs]));
1248
1276
  // printf("now concat->exprs=%p\n",concat->exprs); fflush(stdout);
1249
1277
  // printf("access test: %p\n",concat->exprs[0]); fflush(stdout);
1250
1278
  /* Get and add the expressions from the Ruby value. */
@@ -1270,8 +1298,8 @@ VALUE rcsim_add_refConcat_refs(VALUE mod, VALUE refConcatV, VALUE refVs) {
1270
1298
  // printf("first refConcat->refs=%p\n",refConcat->refs); fflush(stdout);
1271
1299
  // refConcat->refs = realloc(refConcat->refs,
1272
1300
  // sizeof(Reference[refConcat->num_refs]));
1273
- refConcat->refs = my_realloc(refConcat->refs,sizeof(Reference[old_num]),
1274
- sizeof(Reference[refConcat->num_refs]));
1301
+ refConcat->refs = (Reference*)my_realloc(refConcat->refs,
1302
+ sizeof(Reference[old_num]), sizeof(Reference[refConcat->num_refs]));
1275
1303
  // printf("now refConcat->refs=%p\n",refConcat->refs); fflush(stdout);
1276
1304
  // printf("access test: %p\n",refConcat->refs[0]); fflush(stdout);
1277
1305
  /* Get and add the references from the Ruby value. */
@@ -1280,6 +1308,7 @@ VALUE rcsim_add_refConcat_refs(VALUE mod, VALUE refConcatV, VALUE refVs) {
1280
1308
  // show_access(refConcat->refs,old_num+i);
1281
1309
  value_to_rcsim(ReferenceS,rb_ary_entry(refVs,i),ref);
1282
1310
  refConcat->refs[old_num + i] = ref;
1311
+ // printf("ref=%p ref &type=%p type=%p width=%llu\n",ref,&(ref->type),ref->type,type_width(ref->type));
1283
1312
  }
1284
1313
  return refConcatV;
1285
1314
  }
@@ -1336,11 +1365,11 @@ VALUE rcsim_set_signal_value(VALUE mod, VALUE signalV, VALUE exprV) {
1336
1365
  Expression expr;
1337
1366
  value_to_rcsim(ExpressionS,exprV,expr);
1338
1367
  /* Compute the value from it. */
1339
- // Value value = calc_expression(expr);
1340
1368
  Value value = get_value();
1341
1369
  value = calc_expression(expr,value);
1342
1370
  /* Copies the value. */
1343
1371
  signal->f_value = copy_value(value,signal->f_value);
1372
+ signal->c_value = copy_value(value,signal->c_value);
1344
1373
  free_value();
1345
1374
  return signalV;
1346
1375
  }
@@ -1349,8 +1378,11 @@ VALUE rcsim_set_signal_value(VALUE mod, VALUE signalV, VALUE exprV) {
1349
1378
  /** Starts the C-Ruby hybrid simulation.
1350
1379
  * @param systemTV the top system type.
1351
1380
  * @param name the name of the simulation.
1352
- * @param vcd tells if the vcd generation is used or not. */
1353
- VALUE rcsim_main(VALUE mod, VALUE systemTV, VALUE name, VALUE vcd) {
1381
+ * @param outmode tells which output mode is used:
1382
+ * 0: standard
1383
+ * 1: mute
1384
+ * 2: vcd */
1385
+ VALUE rcsim_main(VALUE mod, VALUE systemTV, VALUE name, VALUE outmodeV) {
1354
1386
  /* Get the C system type from the Ruby value. */
1355
1387
  SystemT systemT;
1356
1388
  value_to_rcsim(SystemTS,systemTV,systemT);
@@ -1358,11 +1390,18 @@ VALUE rcsim_main(VALUE mod, VALUE systemTV, VALUE name, VALUE vcd) {
1358
1390
  top_system = systemT;
1359
1391
  /* Enable it. */
1360
1392
  set_enable_system(systemT,1);
1393
+ /* Get the output mode. */
1394
+ int outmode = NUM2INT(outmodeV);
1361
1395
  /* Starts the simulation. */
1362
- if (TYPE(vcd) == T_TRUE)
1363
- hruby_sim_core(StringValueCStr(name),init_vcd_visualizer,-1);
1364
- else
1365
- hruby_sim_core(StringValueCStr(name),init_default_visualizer,-1);
1396
+ switch(outmode) {
1397
+ case 0: hruby_sim_core(StringValueCStr(name),init_default_visualizer,-1);
1398
+ break;
1399
+ case 1: hruby_sim_core(StringValueCStr(name),init_mute_visualizer,-1);
1400
+ break;
1401
+ case 2: hruby_sim_core(StringValueCStr(name),init_vcd_visualizer,-1);
1402
+ break;
1403
+ default:hruby_sim_core(StringValueCStr(name),init_default_visualizer,-1);
1404
+ }
1366
1405
  return systemTV;
1367
1406
  }
1368
1407
 
@@ -1406,7 +1445,7 @@ void Init_hruby_sim() {
1406
1445
  rb_define_singleton_method(mod,"rcsim_make_binary",rcsim_make_binary,4);
1407
1446
  rb_define_singleton_method(mod,"rcsim_make_select",rcsim_make_select,2);
1408
1447
  rb_define_singleton_method(mod,"rcsim_make_concat",rcsim_make_concat,2);
1409
- rb_define_singleton_method(mod,"rcsim_make_refConcat",rcsim_make_refConcat,1);
1448
+ rb_define_singleton_method(mod,"rcsim_make_refConcat",rcsim_make_refConcat,2);
1410
1449
  rb_define_singleton_method(mod,"rcsim_make_refIndex",rcsim_make_refIndex,3);
1411
1450
  rb_define_singleton_method(mod,"rcsim_make_refRange",rcsim_make_refRange,4);
1412
1451
  rb_define_singleton_method(mod,"rcsim_make_stringE",rcsim_make_stringE,1);