Module: RCSimCinterface
- Defined in:
- ext/hruby_sim/hruby_rcsim_build.c
Class Method Summary collapse
-
.rcsim_add_behavior_events(behaviorV, eventVs) ⇒ Object
Adds events to a C behavior.
-
.rcsim_add_block_inners(blockV, sigVs) ⇒ Object
Adds inners to a C block.
-
.rcsim_add_block_statements(blockV, stmntVs) ⇒ Object
Adds statements to a C block.
-
.rcsim_add_concat_expressions(concatV, exprVs) ⇒ Object
Adds expressions to a C concat.
-
.rcsim_add_hcase_whens(hcaseV, matchVs, stmntVs) ⇒ Object
Adds whens to a C hardware case.
-
.rcsim_add_hif_noifs(hifV, condVs, stmntVs) ⇒ Object
Adds noifs to a C hardware if.
-
.rcsim_add_print_args(printV, argVs) ⇒ Object
Adds arguments to a C print.
-
.rcsim_add_refConcat_refs(refConcatV, refVs) ⇒ Object
Adds references to a C ref concat.
-
.rcsim_add_scope_behaviors(scopeV, behVs) ⇒ Object
Adds behaviors to a C scope.
-
.rcsim_add_scope_inners(scopeV, sigVs) ⇒ Object
Adds inners to a C scope.
-
.rcsim_add_scope_scopes(scopeV, scpVs) ⇒ Object
Adds sub scopes to a C scope.
-
.rcsim_add_scope_systemIs(scopeV, sysVs) ⇒ Object
Adds system instances to a C scope.
-
.rcsim_add_select_choices(selectV, choiceVs) ⇒ Object
Adds choices to a C select.
-
.rcsim_add_systemI_systemTs(systemIV, sysVs) ⇒ Object
Adds alternate system types to a C system instance.
-
.rcsim_add_systemT_inouts(systemTV, sigVs) ⇒ Object
Adds inouts to a C systemT.
-
.rcsim_add_systemT_inputs(systemTV, sigVs) ⇒ Object
Adds inputs to a C systemT.
-
.rcsim_add_systemT_outputs(systemTV, sigVs) ⇒ Object
Adds outputs to a C systemT.
-
.rcsim_get_type_bit ⇒ Object
Get the bit type.
-
.rcsim_get_type_signed ⇒ Object
Get the signed type.
-
.rcsim_get_type_vector(baseV, numV) ⇒ Object
Get a vector type.
-
.rcsim_main(systemTV, name, vcd) ⇒ Object
Starts the C-Ruby hybrid simulation.
-
.rcsim_make_behavior(timed) ⇒ Object
Creating a behavior C object.
-
.rcsim_make_binary(type, operator, left, right) ⇒ Object
Creating a binary value C object.
-
.rcsim_make_block(mode) ⇒ Object
Creating a block C object.
-
.rcsim_make_cast(type, child) ⇒ Object
Creating a cast C object.
-
.rcsim_make_concat(type, dirV) ⇒ Object
Creating a concat C object.
-
.rcsim_make_event(typeV, sigV) ⇒ Object
Creating an event C object.
-
.rcsim_make_hcase(value, defolt) ⇒ Object
Creating a hardware case C object.
-
.rcsim_make_hif(condition, yes, no) ⇒ Object
Creating a hardware if C object.
-
.rcsim_make_print ⇒ Object
Creating a print C object.
-
.rcsim_make_refConcat(type, dirV) ⇒ Object
Creating a ref concat C object.
-
.rcsim_make_refIndex(type, index, ref) ⇒ Object
Creating a ref index C object.
-
.rcsim_make_refRange(type, first, last, ref) ⇒ Object
Creating a ref range C object.
-
.rcsim_make_scope(name) ⇒ Object
Creating a scope C object.
-
.rcsim_make_select(type, sel) ⇒ Object
Creating a select C object.
-
.rcsim_make_signal(name, type) ⇒ Object
Creating a signal C object.
-
.rcsim_make_stringE(strV) ⇒ Object
Creating a character string C object.
-
.rcsim_make_systemI(name, systemT) ⇒ Object
Creating a system instance C object.
-
.rcsim_make_systemT(name) ⇒ Object
Creating a systemT C object.
-
.rcsim_make_timeTerminate ⇒ Object
Creating a time terminate C object.
-
.rcsim_make_timeWait(unitV, delayV) ⇒ Object
Creating a time wait C object.
-
.rcsim_make_transmit(left, right) ⇒ Object
Creating a transmit C object.
-
.rcsim_make_unary(type, operator, child) ⇒ Object
Creating a unary value C object.
-
.rcsim_make_value_bitstring(typeV, contentV) ⇒ Object
Creating a bitstring value C object.
-
.rcsim_make_value_numeric(typeV, contentV) ⇒ Object
Creating a numeric value C object.
-
.rcsim_set_behavior_block(behaviorV, blockV) ⇒ Object
Sets the block for a C behavior.
-
.rcsim_set_owner(objV, ownerV) ⇒ Object
Sets the owner for a C simulation object.
-
.rcsim_set_signal_value(signalV, exprV) ⇒ Object
Sets the value for a C signal.
-
.rcsim_set_systemT_scope(systemTV, scopeV) ⇒ Object
Sets the scope for a C system type.
Class Method Details
.rcsim_add_behavior_events(behaviorV, eventVs) ⇒ Object
Adds events to a C behavior.
812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 812
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);
/* Prepare the size for the events. */
long num = RARRAY_LEN(eventVs);
long old_num = behavior->num_events;
behavior->num_events += num;
behavior->events = realloc(behavior->events,
sizeof(Event)*behavior->num_events);
/* Get and add the events from the Ruby value. */
for(int i=0; i< num; ++i) {
Event event;
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++;
sig->any = realloc(sig->any,sizeof(Object)*sig->num_any);
sig->any[sig->num_any-1] = (Object)behavior;
break;
case POSEDGE:
sig->num_pos++;
sig->pos = realloc(sig->pos,sizeof(Object)*sig->num_pos);
sig->pos[sig->num_pos-1] = (Object)behavior;
break;
case NEGEDGE:
sig->num_neg++;
sig->neg = realloc(sig->neg,sizeof(Object)*sig->num_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.
940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 940
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);
/* Prepare the size for the inners. */
long num = RARRAY_LEN(sigVs);
long old_num = block->num_inners;
block->num_inners += num;
block->inners = realloc(block->inners,sizeof(SignalI)*block->num_inners);
/* Get and add the signals from the Ruby value. */
for(int i=0; i< num; ++i) {
SignalI sig;
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.
959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 959
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);
/* Prepare the size for the statements. */
long num = RARRAY_LEN(stmntVs);
long old_num = block->num_stmnts;
block->num_stmnts += num;
block->stmnts = realloc(block->stmnts,sizeof(Statement)*block->num_stmnts);
/* Get and add the statements from the Ruby value. */
for(int i=0; i< num; ++i) {
Statement stmnt;
value_to_rcsim(StatementS,rb_ary_entry(stmntVs,i),stmnt);
block->stmnts[old_num + i] = stmnt;
}
return blockV;
}
|
.rcsim_add_concat_expressions(concatV, exprVs) ⇒ Object
Adds expressions to a C concat.
997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 997
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);
/* 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;
concat->exprs = realloc(concat->exprs,sizeof(Expression)*concat->num_exprs);
/* Get and add the expressions from the Ruby value. */
for(int i=0; i< num; ++i) {
Expression expr;
value_to_rcsim(ExpressionS,rb_ary_entry(exprVs,i),expr);
// printf("Adding expression with type width=%llu\n",type_width(expr->type));
concat->exprs[old_num + i] = expr;
}
return concatV;
}
|
.rcsim_add_hcase_whens(hcaseV, matchVs, stmntVs) ⇒ Object
Adds whens to a C hardware case.
915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 915
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);
/* Prepare the size for the noifs. */
long num = RARRAY_LEN(matchVs);
long old_num = hcase->num_whens;
hcase->num_whens += num;
hcase->matches = realloc(hcase->matches,
sizeof(Expression)*hcase->num_whens);
hcase->stmnts = realloc(hcase->stmnts,
sizeof(Statement)*hcase->num_whens);
/* Get and add the whens from the Ruby value. */
for(int i=0; i< num; ++i) {
Expression match;
Statement stmnt;
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.
892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 892
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);
/* Prepare the size for the noifs. */
long num = RARRAY_LEN(condVs);
long old_num = hif->num_noifs;
hif->num_noifs += num;
hif->noconds = realloc(hif->noconds, sizeof(Expression)*hif->num_noifs);
hif->nostmnts = realloc(hif->nostmnts, sizeof(Statement)*hif->num_noifs);
/* Get and add the noifs from the Ruby value. */
for(int i=0; i< num; ++i) {
Expression cond;
Statement stmnt;
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.
872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 872
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);
/* Prepare the size for the arguments. */
long num = RARRAY_LEN(argVs);
long old_num = print->num_args;
print->num_args += num;
print->args = realloc(print->args,
sizeof(Expression)*print->num_args);
/* Get and add the arguments from the Ruby value. */
for(int i=0; i< num; ++i) {
Expression arg;
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.
1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1018
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);
/* Prepare the size for the references. */
long num = RARRAY_LEN(refVs);
long old_num = refConcat->num_refs;
refConcat->num_refs += num;
refConcat->refs = realloc(refConcat->refs,sizeof(Reference)*refConcat->num_refs);
/* Get and add the references from the Ruby value. */
for(int i=0; i< num; ++i) {
Reference ref;
value_to_rcsim(ReferenceS,rb_ary_entry(refVs,i),ref);
refConcat->refs[old_num + i] = ref;
}
return refConcatV;
}
|
.rcsim_add_scope_behaviors(scopeV, behVs) ⇒ Object
Adds behaviors to a C scope.
752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 752
VALUE rcsim_add_scope_behaviors(VALUE mod, VALUE scopeV, VALUE behVs) {
/* Get the C scope from the Ruby value. */
Scope scope;
value_to_rcsim(ScopeS,scopeV,scope);
/* Prepare the size for the behaviors. */
long num = RARRAY_LEN(behVs);
long old_num = scope->num_behaviors;
scope->num_behaviors += num;
scope->behaviors = realloc(scope->behaviors,
sizeof(Behavior)*scope->num_behaviors);
/* Get and add the behaviors from the Ruby value. */
for(int i=0; i< num; ++i) {
Behavior beh;
value_to_rcsim(BehaviorS,rb_ary_entry(behVs,i),beh);
scope->behaviors[old_num + i] = beh;
}
return scopeV;
}
|
.rcsim_add_scope_inners(scopeV, sigVs) ⇒ Object
Adds inners to a C scope.
733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 733
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);
/* Prepare the size for the inners. */
long num = RARRAY_LEN(sigVs);
long old_num = scope->num_inners;
scope->num_inners += num;
scope->inners = realloc(scope->inners,sizeof(SignalI)*scope->num_inners);
/* Get and add the signals from the Ruby value. */
for(int i=0; i< num; ++i) {
SignalI sig;
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.
792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 792
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);
/* Prepare the size for the sub scopes. */
long num = RARRAY_LEN(scpVs);
long old_num = scope->num_scopes;
scope->num_scopes += num;
scope->scopes = realloc(scope->scopes,
sizeof(Scope)*scope->num_scopes);
/* Get and add the sub scopes from the Ruby value. */
for(int i=0; i< num; ++i) {
Scope scp;
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.
772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 772
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);
/* Prepare the size for the system instances. */
long num = RARRAY_LEN(sysVs);
long old_num = scope->num_systemIs;
scope->num_systemIs += num;
scope->systemIs = realloc(scope->systemIs,
sizeof(SystemI)*scope->num_systemIs);
/* Get and add the system instances from the Ruby value. */
for(int i=0; i< num; ++i) {
SystemI sys;
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.
978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 978
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);
/* Prepare the size for the choices. */
long num = RARRAY_LEN(choiceVs);
long old_num = select->num_choices;
select->num_choices += num;
select->choices = realloc(select->choices,sizeof(Expression)*select->num_choices);
/* Get and add the choices from the Ruby value. */
for(int i=0; i< num; ++i) {
Expression choice;
value_to_rcsim(ExpressionS,rb_ary_entry(choiceVs,i),choice);
select->choices[old_num + i] = choice;
}
return selectV;
}
|
.rcsim_add_systemI_systemTs(systemIV, sysVs) ⇒ Object
Adds alternate system types to a C system instance.
853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 853
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);
/* Prepare the size for the alternate system types. */
long num = RARRAY_LEN(sysVs);
long old_num = systemI->num_systems;
systemI->num_systems += num;
systemI->systems=realloc(systemI->systems,sizeof(SystemT)*systemI->num_systems);
/* Get and add the alternate system types from the Ruby value. */
for(int i=0; i< num; ++i) {
SystemT sys;
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.
714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 714
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);
/* Prepare the size for the inouts. */
long num = RARRAY_LEN(sigVs);
long old_num = systemT->num_inouts;
systemT->num_inouts += num;
systemT->inouts =realloc(systemT->inouts,sizeof(SignalI)*systemT->num_inouts);
/* Get and add the signals from the Ruby value. */
for(int i=0; i< num; ++i) {
SignalI sig;
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.
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 672
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("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;
systemT->inputs=realloc(systemT->inputs,sizeof(SignalI)*systemT->num_inputs);
// printf("size=%d num=%i\n",malloc_size(systemT->inputs),systemT->num_inputs);
// printf("required size=%lu\n",sizeof(SignalI)*systemT->num_inputs);
/* Get and add the signals from the Ruby value. */
for(int i=0; i< num; ++i) {
SignalI sig;
value_to_rcsim(SignalIS,rb_ary_entry(sigVs,i),sig);
// printf("old_num+i=%ld\n",old_num+i);
systemT->inputs[old_num + i] = sig;
}
return systemTV;
}
|
.rcsim_add_systemT_outputs(systemTV, sigVs) ⇒ Object
Adds outputs to a C systemT.
695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 695
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);
/* Prepare the size for the outputs. */
long num = RARRAY_LEN(sigVs);
long old_num = systemT->num_outputs;
systemT->num_outputs += num;
systemT->outputs =realloc(systemT->outputs,sizeof(SignalI)*systemT->num_outputs);
/* Get and add the signals from the Ruby value. */
for(int i=0; i< num; ++i) {
SignalI sig;
value_to_rcsim(SignalIS,rb_ary_entry(sigVs,i),sig);
systemT->outputs[old_num + i] = sig;
}
return systemTV;
}
|
.rcsim_get_type_bit ⇒ Object
Get the bit type.
138 139 140 141 142 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 138 VALUE rcsim_get_type_bit(VALUE mod) { VALUE res; rcsim_to_value(TypeS,get_type_bit(),res); return res; } |
.rcsim_get_type_signed ⇒ Object
Get the signed type.
145 146 147 148 149 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 145 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.
152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 152
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_main(systemTV, name, vcd) ⇒ Object
Starts the C-Ruby hybrid simulation. @param systemTV the top system type. @param name the name of the simulation. @param vcd tells if the vcd generation is used or not.
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1102
VALUE rcsim_main(VALUE mod, VALUE systemTV, VALUE name, VALUE vcd) {
/* 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);
/* Starts the simulation. */
if (TYPE(vcd) == T_TRUE)
hruby_sim_core(StringValueCStr(name),init_vcd_visualizer,-1);
else
hruby_sim_core(StringValueCStr(name),init_default_visualizer,-1);
return systemTV;
}
|
.rcsim_make_behavior(timed) ⇒ Object
Creating a behavior C object.
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 218
VALUE rcsim_make_behavior(VALUE mod, VALUE timed) {
/* Allocates the behavior. */
Behavior behavior = (Behavior)malloc(sizeof(BehaviorS));
// printf("new 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;
}
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.
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 571 572 573 574 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 543
VALUE rcsim_make_binary(VALUE mod, VALUE type, VALUE operator, VALUE left, VALUE right) {
/* Allocates the binary. */
Binary binary = (Binary)malloc(sizeof(BinaryS));
/* Set it up. */
binary->kind = BINARY;
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(mode) ⇒ Object
Creating a block C object.
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 440
VALUE rcsim_make_block(VALUE mod, VALUE mode) {
/* Allocates the block. */
Block block = (Block)malloc(sizeof(BlockS));
/* 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(mode) == 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.
510 511 512 513 514 515 516 517 518 519 520 521 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 510
VALUE rcsim_make_cast(VALUE mod, VALUE type, VALUE child) {
/* Allocates the cast. */
Cast cast = (Cast)malloc(sizeof(CastS));
/* Set it up. */
cast->kind = CAST;
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_concat(type, dirV) ⇒ Object
Creating a concat C object.
593 594 595 596 597 598 599 600 601 602 603 604 605 606 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 593
VALUE rcsim_make_concat(VALUE mod, VALUE type, VALUE dirV) {
/* Allocates the concat. */
Concat concat = (Concat)malloc(sizeof(ConcatS));
/* Set it up. */
concat->kind = CONCAT;
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.
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 248
VALUE rcsim_make_event(VALUE mod, VALUE typeV, VALUE sigV) {
/* Allocates the event. */
Event event = (Event)malloc(sizeof(EventS));
/* 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(value, defolt) ⇒ Object
Creating a hardware case C object.
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 419
VALUE rcsim_make_hcase(VALUE mod, VALUE value, VALUE defolt) {
/* Allocates the hardware case. */
HCase hcase = (HCase)malloc(sizeof(HCaseS));
/* Set it up. */
hcase->kind = HCASE;
value_to_rcsim(ExpressionS,value,hcase->value);
hcase->num_whens = 0;
hcase->matches = NULL;
hcase->stmnts = NULL;
if (TYPE(defolt) == T_NIL)
hcase->defolt = NULL;
else
value_to_rcsim(StatementS,defolt,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(condition, yes, no) ⇒ Object
Creating a hardware if C object.
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 397
VALUE rcsim_make_hif(VALUE mod, VALUE condition, VALUE yes, VALUE no) {
/* Allocates the hardware if. */
HIf hif = (HIf)malloc(sizeof(HIfS));
/* Set it up. */
hif->kind = HIF;
value_to_rcsim(ExpressionS,condition,hif->condition);
value_to_rcsim(StatementS,yes,hif->yes);
if (TYPE(no) == T_NIL)
hif->no = NULL;
else
value_to_rcsim(StatementS,no,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_print ⇒ Object
Creating a print C object.
341 342 343 344 345 346 347 348 349 350 351 352 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 341
VALUE rcsim_make_print(VALUE mod) {
/* Allocates the print. */
Print print = (Print)malloc(sizeof(PrintS));
/* Set it up. */
print->kind = PRINT;
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.
609 610 611 612 613 614 615 616 617 618 619 620 621 622 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 609
VALUE rcsim_make_refConcat(VALUE mod, VALUE type, VALUE dirV) {
/* Allocates the ref concat. */
RefConcat refConcat = (RefConcat)malloc(sizeof(RefConcatS));
/* Set it up. */
refConcat->kind = REF_CONCAT;
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.
625 626 627 628 629 630 631 632 633 634 635 636 637 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 625
VALUE rcsim_make_refIndex(VALUE mod, VALUE type, VALUE index, VALUE ref) {
/* Allocates the ref index. */
RefIndex refIndex = (RefIndex)malloc(sizeof(RefIndexS));
/* Set it up. */
refIndex->kind = REF_INDEX;
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.
640 641 642 643 644 645 646 647 648 649 650 651 652 653 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 640
VALUE rcsim_make_refRange(VALUE mod, VALUE type, VALUE first, VALUE last, VALUE ref) {
/* Allocates the ref range. */
RefRangeE refRange = (RefRangeE)malloc(sizeof(RefRangeES));
/* Set it up. */
refRange->kind = REF_RANGE;
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.
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 193
VALUE rcsim_make_scope(VALUE mod, VALUE name) {
/* Allocates the scope. */
Scope scope = (Scope)malloc(sizeof(ScopeS));
/* Set it up. */
scope->kind = SCOPE;
scope->owner = NULL;
scope->name = strdup(StringValueCStr(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.
577 578 579 580 581 582 583 584 585 586 587 588 589 590 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 577
VALUE rcsim_make_select(VALUE mod, VALUE type, VALUE sel) {
/* Allocates the select. */
Select select = (Select)malloc(sizeof(SelectS));
/* Set it up. */
select->kind = SELECT;
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.
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 270
VALUE rcsim_make_signal(VALUE mod, VALUE name, VALUE type) {
/* Allocates the signal. */
SignalI signal = (SignalI)malloc(sizeof(SignalIS));
/* Set it up. */
signal->kind = SIGNALI;
signal->owner = NULL;
signal->name = strdup(StringValueCStr(name));
// printf("Creating signal named=%s\n",signal->name);
value_to_rcsim(TypeS,type,signal->type);
// printf("type width=%llu\n",type_width(signal->type));
signal->c_value = make_value(signal->type,0);
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);
signal->f_value->signal = signal;
signal->fading = 1; /* Initially the signal can be overwritten by anything.*/
signal->num_any = 0;
signal->any = NULL;
signal->num_pos = 0;
signal->pos = NULL;
signal->num_neg = 0;
signal->neg = NULL;
/* 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.
657 658 659 660 661 662 663 664 665 666 667 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 657
VALUE rcsim_make_stringE(VALUE mod, VALUE strV) {
/* Allocates the string. */
StringE stringE = (StringE)malloc(sizeof(StringES));
/* Set it up. */
stringE->kind = STRINGE;
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.
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 303
VALUE rcsim_make_systemI(VALUE mod, VALUE name, VALUE systemT) {
/* Allocates the system instance. */
SystemI systemI = (SystemI)malloc(sizeof(SystemIS));
/* Set it up. */
systemI->kind = SYSTEMI;
systemI->owner = NULL;
systemI->name = strdup(StringValueCStr(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));
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.
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 170
VALUE rcsim_make_systemT(VALUE mod, VALUE name) {
/* Allocates the systemT. */
SystemT systemT = (SystemT)malloc(sizeof(SystemTS));
/* Set it up. */
systemT->kind = SYSTEMT;
systemT->owner = NULL;
systemT->name = strdup(StringValueCStr(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_timeTerminate ⇒ Object
Creating a time terminate C object.
384 385 386 387 388 389 390 391 392 393 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 384
VALUE rcsim_make_timeTerminate(VALUE mod) {
/* Allocates the time terminate. */
TimeTerminate timeTerminate = (TimeTerminate)malloc(sizeof(TimeTerminateS));
/* Set it up. */
timeTerminate->kind = TIME_TERMINATE;
/* 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.
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 356
VALUE rcsim_make_timeWait(VALUE mod, VALUE unitV, VALUE delayV) {
/* Allocates the time wait. */
TimeWait timeWait = (TimeWait)malloc(sizeof(TimeWaitS));
/* Set it up. */
timeWait->kind = TIME_WAIT;
/* 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.
326 327 328 329 330 331 332 333 334 335 336 337 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 326
VALUE rcsim_make_transmit(VALUE mod, VALUE left, VALUE right) {
/* Allocates the transmit. */
Transmit transmit = (Transmit)malloc(sizeof(TransmitS));
/* Set it up. */
transmit->kind = TRANSMIT;
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.
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 524
VALUE rcsim_make_unary(VALUE mod, VALUE type, VALUE operator, VALUE child) {
/* Allocates the unary. */
Unary unary= (Unary)malloc(sizeof(UnaryS));
/* Set it up. */
unary->kind = UNARY;
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.
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 483
VALUE rcsim_make_value_bitstring(VALUE mod, VALUE typeV, VALUE contentV) {
// /* Allocates the value. */
// Value value = get_value();
// /* Sets its type. */
// value_to_rcsim(TypeS,type,value->type);
/* Get the type. */
Type type;
value_to_rcsim(TypeS,typeV,type);
/* Create the value. */
Value value = make_value(type,0);
// 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(sizeof(char),value->capacity);
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.
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 460
VALUE rcsim_make_value_numeric(VALUE mod, VALUE typeV, VALUE contentV) {
// /* Allocates the value. */
// Value value = get_value();
// /* Sets its type. */
// value_to_rcsim(TypeS,typeV,value->type);
/* Get the type. */
Type type;
value_to_rcsim(TypeS,typeV,type);
/* Create the value. */
Value value = make_value(type,0);
/* Set it to numeric. */
value->numeric = 1;
value->capacity = 0;
value->data_str = NULL;
value->data_int = NUM2LL(contentV);
/* 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.
1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1066
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.
1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1040
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.
1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1079
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 = calc_expression(expr);
Value value = get_value();
value = calc_expression(expr,value);
/* Copies the value. */
signal->f_value = copy_value(value,signal->f_value);
free_value();
return signalV;
}
|
.rcsim_set_systemT_scope(systemTV, scopeV) ⇒ Object
Sets the scope for a C system type.
1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1053
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;
}
|