HDLRuby 2.10.5 → 2.11.0
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 +4 -4
- data/HDLRuby.gemspec +1 -0
- data/README.md +8 -4
- data/Rakefile +8 -0
- data/{lib/HDLRuby/sim/Makefile → ext/hruby_sim/Makefile_csim} +0 -0
- data/ext/hruby_sim/extconf.rb +13 -0
- data/ext/hruby_sim/hruby_rcsim_build.c +1188 -0
- data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_sim.h +255 -16
- data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_sim_calc.c +310 -181
- data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_sim_core.c +34 -17
- data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_sim_list.c +0 -0
- data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_sim_stack_calc.c +4 -1
- data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_sim_stack_calc.c.sav +0 -0
- data/ext/hruby_sim/hruby_sim_tree_calc.c +375 -0
- data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_sim_vcd.c +5 -5
- data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_sim_vizualize.c +2 -2
- data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_value_pool.c +4 -1
- data/lib/HDLRuby/hdr_samples/bstr_bench.rb +2 -0
- data/lib/HDLRuby/hdr_samples/case_bench.rb +2 -2
- data/lib/HDLRuby/hdr_samples/counter_bench.rb +0 -1
- data/lib/HDLRuby/hdr_samples/counter_dff_bench.rb +46 -0
- data/lib/HDLRuby/hdr_samples/dff_bench.rb +1 -1
- data/lib/HDLRuby/hdr_samples/print_bench.rb +62 -0
- data/lib/HDLRuby/hdr_samples/rom.rb +5 -3
- data/lib/HDLRuby/hdr_samples/simple_counter_bench.rb +43 -0
- data/lib/HDLRuby/hdrcc.rb +54 -8
- data/lib/HDLRuby/hruby_bstr.rb +1175 -917
- data/lib/HDLRuby/hruby_high.rb +200 -90
- data/lib/HDLRuby/hruby_high_fullname.rb +82 -0
- data/lib/HDLRuby/hruby_low.rb +41 -23
- data/lib/HDLRuby/hruby_low2c.rb +7 -0
- data/lib/HDLRuby/hruby_rcsim.rb +978 -0
- data/lib/HDLRuby/hruby_rsim.rb +1134 -0
- data/lib/HDLRuby/hruby_rsim_vcd.rb +322 -0
- data/lib/HDLRuby/hruby_values.rb +362 -18
- data/lib/HDLRuby/hruby_verilog.rb +21 -3
- data/lib/HDLRuby/version.rb +1 -1
- metadata +24 -13
@@ -21,6 +21,27 @@ typedef struct SystemIS_ SystemIS;
|
|
21
21
|
typedef struct CodeS_ CodeS;
|
22
22
|
typedef struct BlockS_ BlockS;
|
23
23
|
typedef struct EventS_ EventS;
|
24
|
+
#ifdef RCSIM
|
25
|
+
typedef struct StatementS_ StatementS;
|
26
|
+
typedef struct TransmitS_ TransmitS;
|
27
|
+
typedef struct PrintS_ PrintS;
|
28
|
+
typedef struct HIfS_ HIfS;
|
29
|
+
typedef struct HCaseS_ HCaseS;
|
30
|
+
typedef struct TimeWaitS_ TimeWaitS;
|
31
|
+
typedef struct TimeTerminateS_ TimeTerminateS;
|
32
|
+
typedef struct ExpressionS_ ExpressionS;
|
33
|
+
typedef struct UnaryS_ UnaryS;
|
34
|
+
typedef struct BinaryS_ BinaryS;
|
35
|
+
typedef struct SelectS_ SelectS;
|
36
|
+
typedef struct ConcatS_ ConcatS;
|
37
|
+
typedef struct CastS_ CastS;
|
38
|
+
typedef struct ReferenceS_ ReferenceS;
|
39
|
+
typedef struct RefObjectS_ RefObjectS;
|
40
|
+
typedef struct RefIndexS_ RefIndexS;
|
41
|
+
typedef struct RefRangeES_ RefRangeES;
|
42
|
+
typedef struct RefConcatS_ RefConcatS;
|
43
|
+
typedef struct StringES_ StringES;
|
44
|
+
#endif
|
24
45
|
|
25
46
|
typedef struct RefRangeS_ RefRangeS;
|
26
47
|
|
@@ -35,12 +56,44 @@ typedef struct SystemIS_* SystemI;
|
|
35
56
|
typedef struct CodeS_* Code;
|
36
57
|
typedef struct BlockS_* Block;
|
37
58
|
typedef struct EventS_* Event;
|
59
|
+
#ifdef RCSIM
|
60
|
+
typedef struct StatementS_* Statement;
|
61
|
+
typedef struct TransmitS_* Transmit;
|
62
|
+
typedef struct PrintS_* Print;
|
63
|
+
typedef struct HIfS_* HIf;
|
64
|
+
typedef struct HCaseS_* HCase;
|
65
|
+
typedef struct TimeWaitS_* TimeWait;
|
66
|
+
typedef struct TimeTerminateS_* TimeTerminate;
|
67
|
+
typedef struct ExpressionS_* Expression;
|
68
|
+
typedef struct UnaryS_* Unary;
|
69
|
+
typedef struct BinaryS_* Binary;
|
70
|
+
typedef struct SelectS_* Select;
|
71
|
+
typedef struct ConcatS_* Concat;
|
72
|
+
typedef struct CastS_* Cast;
|
73
|
+
typedef struct ReferenceS_* Reference;
|
74
|
+
typedef struct RefObjectS_* RefObject;
|
75
|
+
typedef struct RefIndexS_* RefIndex;
|
76
|
+
typedef struct RefRangeES_* RefRangeE;
|
77
|
+
typedef struct RefConcatS_* RefConcat;
|
78
|
+
typedef struct StringES_* StringE;
|
79
|
+
#endif
|
38
80
|
|
39
81
|
typedef struct RefRangeS_* RefRange;
|
40
82
|
|
41
83
|
/* The kinds of HDLRuby objects. */
|
42
|
-
|
43
|
-
|
84
|
+
/* NOTE: VALUEE, the kind for Values MUST be 0
|
85
|
+
* (this is assumed for faster Value processing). */
|
86
|
+
typedef enum {
|
87
|
+
#ifdef RCSIM
|
88
|
+
VALUEE = 0,
|
89
|
+
#endif
|
90
|
+
OBJECT, SYSTEMT, SIGNALI, SCOPE, BEHAVIOR, SYSTEMI, CODE, BLOCK, EVENT,
|
91
|
+
#ifdef RCSIM
|
92
|
+
/* Statements */ TRANSMIT, PRINT, HIF, HCASE, TIME_WAIT, TIME_TERMINATE,
|
93
|
+
/* Expressions */ UNARY, BINARY, SELECT, CONCAT, CAST,
|
94
|
+
/* References */ REF_OBJECT, REF_INDEX, REF_RANGE, REF_CONCAT,
|
95
|
+
/* Non-hardware*/ STRINGE,
|
96
|
+
#endif
|
44
97
|
} Kind;
|
45
98
|
|
46
99
|
/* The kinds of HDLRuby event edge. */
|
@@ -48,6 +101,13 @@ typedef enum {
|
|
48
101
|
ANYEDGE, POSEDGE, NEGEDGE
|
49
102
|
} Edge;
|
50
103
|
|
104
|
+
#ifdef RCSIM
|
105
|
+
/* The execution mode for a block. */
|
106
|
+
typedef enum {
|
107
|
+
PAR, SEQ
|
108
|
+
} Mode;
|
109
|
+
#endif
|
110
|
+
|
51
111
|
|
52
112
|
/* The interface to the type engine. */
|
53
113
|
typedef struct FlagsS_ {
|
@@ -91,9 +151,12 @@ extern Type get_type_vector(Type base, unsigned long long number);
|
|
91
151
|
|
92
152
|
/* The structure of a value. */
|
93
153
|
typedef struct ValueS_ {
|
154
|
+
#ifdef RCSIM
|
155
|
+
Kind kind; /* The kind of object. */
|
156
|
+
#endif
|
94
157
|
Type type; /* The type of the value. */
|
95
158
|
int numeric; /* Tell if the value is numeric or a bitstring. */
|
96
|
-
unsigned long long capacity
|
159
|
+
unsigned long long capacity;/* The capacity in char of the bit string. */
|
97
160
|
char* data_str; /* The bit string data if not numeric. */
|
98
161
|
unsigned long long data_int;/* The integer data if numeric. */
|
99
162
|
SignalI signal; /* The signal associated with the value if any. */
|
@@ -275,9 +338,9 @@ extern Value select_value(Value cond, Value dst, unsigned int num, ...);
|
|
275
338
|
* @param dir the direction of concatenation
|
276
339
|
* @param dst the destination value
|
277
340
|
* @return dst */
|
278
|
-
extern Value concat_value(int num, int dir, Value dst, ...);
|
279
|
-
extern Value concat_valueV(int num, int dir, Value dst, va_list args);
|
280
|
-
extern Value concat_valueP(int num, int dir, Value dst, Value* args);
|
341
|
+
extern Value concat_value(unsigned int num, int dir, Value dst, ...);
|
342
|
+
extern Value concat_valueV(unsigned int num, int dir, Value dst, va_list args);
|
343
|
+
extern Value concat_valueP(unsigned int num, int dir, Value dst, Value* args);
|
281
344
|
|
282
345
|
/** Casts a value to another type.
|
283
346
|
* @param src the source value
|
@@ -537,8 +600,14 @@ typedef struct BlockS_ {
|
|
537
600
|
|
538
601
|
char* name; /* The name of the block. */
|
539
602
|
int num_inners; /* The number of inners. */
|
540
|
-
SignalI* inners; /* The inners of the
|
603
|
+
SignalI* inners; /* The inners of the block. */
|
604
|
+
#ifdef RCSIM
|
605
|
+
int num_stmnts; /* The statements of the block. */
|
606
|
+
Statement* stmnts; /* The statements of the block. */
|
607
|
+
Mode mode; /* The execution mode. */
|
608
|
+
#else
|
541
609
|
void (*function)(); /* The function to execute for the block. */
|
610
|
+
#endif
|
542
611
|
} BlockS;
|
543
612
|
|
544
613
|
|
@@ -552,11 +621,162 @@ typedef struct EventS_ {
|
|
552
621
|
} EventS;
|
553
622
|
|
554
623
|
|
624
|
+
#ifdef RCSIM
|
625
|
+
|
626
|
+
/** The C model of a Statement. */
|
627
|
+
typedef struct StatementS_ {
|
628
|
+
Kind kind; /* The kind of object. */
|
629
|
+
} StatementS;
|
630
|
+
|
631
|
+
/** The C model of a transmit statement. */
|
632
|
+
typedef struct TransmitS_ {
|
633
|
+
Kind kind; /* The kind of object. */
|
634
|
+
Reference left; /* The left value. */
|
635
|
+
Expression right; /* The right value. */
|
636
|
+
} TransmitS;
|
637
|
+
|
638
|
+
/** The C model of a print statement. */
|
639
|
+
typedef struct PrintS_ {
|
640
|
+
Kind kind; /* The kind of object. */
|
641
|
+
int num_args; /* The number of arguments of the print. */
|
642
|
+
Expression* args; /* The arguments of the print. */
|
643
|
+
} PrintS;
|
644
|
+
|
645
|
+
/** The C model of a hardware if statement. */
|
646
|
+
typedef struct HIfS_ {
|
647
|
+
Kind kind; /* The kind of object. */
|
648
|
+
Expression condition; /* The condition. */
|
649
|
+
Statement yes; /* The statement executed if the condition is met. */
|
650
|
+
int num_noifs; /* The number of alternate conditions. */
|
651
|
+
Expression* noconds;/* The alternate conditions. */
|
652
|
+
Statement* nostmnts;/* The alternate statements. */
|
653
|
+
Statement no; /* The statement executed if the conditions are not met.*/
|
654
|
+
} HIfS;
|
655
|
+
|
656
|
+
/** The C model of a hardware case statement. */
|
657
|
+
typedef struct HCaseS_ {
|
658
|
+
Kind kind; /* The kind of object. */
|
659
|
+
Expression value; /* The value to match. */
|
660
|
+
int num_whens; /* The number of possible cases. */
|
661
|
+
Expression* matches;/* The cases matching values. */
|
662
|
+
Statement* stmnts; /* The corresponding statements. */
|
663
|
+
Statement defolt; /* The default statement. */
|
664
|
+
} HCaseS;
|
665
|
+
|
666
|
+
/** The C model of a time wait statement. */
|
667
|
+
typedef struct TimeWaitS_ {
|
668
|
+
Kind kind; /* The kind of object. */
|
669
|
+
// Expression delay; /* The delay to wait in pico seconds. */
|
670
|
+
unsigned long long delay; /* The delay to wait in pico seconds. */
|
671
|
+
} TimeWaitS;
|
672
|
+
|
673
|
+
/** The C model of a time terminate statement. */
|
674
|
+
typedef struct TimeTerminateS_ {
|
675
|
+
Kind kind; /* The kind of object. */
|
676
|
+
} TimeTerminateS;
|
677
|
+
|
678
|
+
|
679
|
+
/** The C model of an expression. */
|
680
|
+
typedef struct ExpressionS_ {
|
681
|
+
Kind kind; /* The kind of object. */
|
682
|
+
Type type; /* The type of the expression. */
|
683
|
+
} ExpressionS;
|
684
|
+
|
685
|
+
/** The C model of a unary expression. */
|
686
|
+
typedef struct UnaryS_ {
|
687
|
+
Kind kind; /* The kind of object. */
|
688
|
+
Type type; /* The type of the expression. */
|
689
|
+
Value (*oper)(Value,Value); /* The unary operator. */
|
690
|
+
Expression child; /* The child. */
|
691
|
+
} UnaryS;
|
692
|
+
|
693
|
+
/** The C model of a binary expression. */
|
694
|
+
typedef struct BinaryS_ {
|
695
|
+
Kind kind; /* The kind of object. */
|
696
|
+
Type type; /* The type of the expression. */
|
697
|
+
Value (*oper)(Value,Value,Value); /* The binary operator. */
|
698
|
+
Expression left; /* The left value. */
|
699
|
+
Expression right; /* The right value. */
|
700
|
+
} BinaryS;
|
701
|
+
|
702
|
+
/** The C model of a select expression. */
|
703
|
+
typedef struct SelectS_ {
|
704
|
+
Kind kind; /* The kind of object. */
|
705
|
+
Type type; /* The type of the expression. */
|
706
|
+
Expression select; /* The selection value. */
|
707
|
+
int num_choices; /* The number of choices. */
|
708
|
+
Expression* choices;/* The choices. */
|
709
|
+
} SelectS;
|
710
|
+
|
711
|
+
/** The C model of a concat expression. */
|
712
|
+
typedef struct ConcatS_ {
|
713
|
+
Kind kind; /* The kind of object. */
|
714
|
+
Type type; /* The type of the expression. */
|
715
|
+
int dir; /* The direction of the concat. */
|
716
|
+
int num_exprs; /* The number of sub expressions. */
|
717
|
+
Expression* exprs; /* The sub expressions. */
|
718
|
+
} ConcatS;
|
719
|
+
|
720
|
+
/** The C model of a cast expression. */
|
721
|
+
typedef struct CastS_ {
|
722
|
+
Kind kind; /* The kind of object. */
|
723
|
+
Type type; /* The type of the expression. */
|
724
|
+
Expression child; /* The child expression. */
|
725
|
+
} CastS;
|
726
|
+
|
727
|
+
|
728
|
+
/** The C model of a reference. */
|
729
|
+
typedef struct ReferenceS_ {
|
730
|
+
Kind kind; /* The kind of object. */
|
731
|
+
Type type; /* The type of the reference. */
|
732
|
+
} ReferenceS;
|
733
|
+
|
734
|
+
/** The C model of a reference to an object. */
|
735
|
+
typedef struct RefObjectS_ {
|
736
|
+
Kind kind; /* The kind of object. */
|
737
|
+
Type type; /* The type of the reference. */
|
738
|
+
Object object; /* The refered object. */
|
739
|
+
} RefObjectS;
|
740
|
+
|
741
|
+
/** The C model of an index reference. */
|
742
|
+
typedef struct RefIndexS_ {
|
743
|
+
Kind kind; /* The kind of object. */
|
744
|
+
Type type; /* The type of the reference. */
|
745
|
+
Expression index; /* The index. */
|
746
|
+
Reference ref; /* The reference to access. */
|
747
|
+
} RefIndexS;
|
748
|
+
|
749
|
+
/** The C model of a range reference (expression version!). */
|
750
|
+
typedef struct RefRangeES_ {
|
751
|
+
Kind kind; /* The kind of object. */
|
752
|
+
Type type; /* The type of the reference. */
|
753
|
+
Expression first; /* The first of the range. */
|
754
|
+
Expression last; /* The last of the range. */
|
755
|
+
Reference ref; /* The reference to access. */
|
756
|
+
} RefRangeES;
|
757
|
+
|
758
|
+
/** The C model of a concat reference. */
|
759
|
+
typedef struct RefConcatS_ {
|
760
|
+
Kind kind; /* The kind of object. */
|
761
|
+
Type type; /* The type of the reference. */
|
762
|
+
int dir; /* The direction of the concat. */
|
763
|
+
int num_refs; /* The number of sub references. */
|
764
|
+
Reference* refs; /* The sub references. */
|
765
|
+
} RefConcatS;
|
766
|
+
|
767
|
+
/** The C model of a charcter string. */
|
768
|
+
typedef struct StringES_ {
|
769
|
+
Kind kind; /* The kind of object. */
|
770
|
+
char* str; /* A pointer the to C character string. */
|
771
|
+
} StringES;
|
772
|
+
|
773
|
+
#endif
|
774
|
+
|
555
775
|
|
556
776
|
/* The interface to the simulator. */
|
557
777
|
|
558
778
|
/* The time units. */
|
559
|
-
typedef enum { S, MS, US, NS, PS
|
779
|
+
typedef enum { S, MS, US, NS, PS } Unit;
|
560
780
|
|
561
781
|
/** The top system. */
|
562
782
|
extern SystemT top_system;
|
@@ -570,7 +790,7 @@ extern void register_timed_behavior(Behavior behavior);
|
|
570
790
|
extern void register_signal(SignalI signal);
|
571
791
|
|
572
792
|
/** Makes the behavior wait for a given time.
|
573
|
-
* @param delay the delay to wait in
|
793
|
+
* @param delay the delay to wait in ps.
|
574
794
|
* @param behavior the current behavior. */
|
575
795
|
extern void hw_wait(unsigned long long delay, Behavior behavior);
|
576
796
|
|
@@ -636,9 +856,12 @@ extern void each_all_signal(void (*func)(SignalI));
|
|
636
856
|
* @param idx the index of the target system. */
|
637
857
|
extern void configure(SystemI systemI, int idx);
|
638
858
|
|
639
|
-
|
859
|
+
#ifdef __GNUC__
|
640
860
|
/** Terminates the simulation. */
|
861
|
+
extern void terminate() __attribute__((noreturn));
|
862
|
+
#else
|
641
863
|
extern void terminate();
|
864
|
+
#endif
|
642
865
|
|
643
866
|
/* Interface to the visualization engine. */
|
644
867
|
|
@@ -746,8 +969,8 @@ extern unsigned long long value2integer(Value value);
|
|
746
969
|
* @param base the type of the elements
|
747
970
|
* @param dst the destination value
|
748
971
|
* @return dst */
|
749
|
-
extern Value read_range(Value value,
|
750
|
-
|
972
|
+
extern Value read_range(Value value,
|
973
|
+
unsigned long long first, unsigned long long last, Type base, Value dst);
|
751
974
|
|
752
975
|
/** Writes to a range within a value.
|
753
976
|
* @param src the source value
|
@@ -756,8 +979,8 @@ extern Value read_range(Value value, long long first, long long last,
|
|
756
979
|
* @param base the type of the elements
|
757
980
|
* @param dst the destination value
|
758
981
|
* @return dst */
|
759
|
-
extern Value write_range(Value src,
|
760
|
-
Type base, Value dst);
|
982
|
+
extern Value write_range(Value src,
|
983
|
+
unsigned long long first, unsigned long long last, Type base, Value dst);
|
761
984
|
|
762
985
|
/** Writes to a range within a value but without overwrite with Z.
|
763
986
|
* @param src the source value
|
@@ -766,10 +989,25 @@ extern Value write_range(Value src, long long first, long long last,
|
|
766
989
|
* @param base the type of the elements
|
767
990
|
* @param dst the destination value
|
768
991
|
* @return dst */
|
769
|
-
extern Value write_range_no_z(Value src,
|
770
|
-
Type base, Value dst);
|
992
|
+
extern Value write_range_no_z(Value src,
|
993
|
+
unsigned long long first, unsigned long long last, Type base, Value dst);
|
994
|
+
|
995
|
+
|
996
|
+
#ifdef RCSIM
|
997
|
+
/** Tree-based computations. */
|
998
|
+
|
999
|
+
/** Calculates a tree expression.
|
1000
|
+
* @param expr the expression to execute.
|
1001
|
+
* @param res the expression where to write the result. */
|
1002
|
+
extern Value calc_expression(Expression expr, Value res);
|
771
1003
|
|
1004
|
+
/** Executes a statement.
|
1005
|
+
* @param stmnt the statement to execute.
|
1006
|
+
* @param mode blocking mode: 0: par, 1:seq
|
1007
|
+
* @param behavior the behavior in execution. */
|
1008
|
+
extern void execute_statement(Statement stmnt, int mode, Behavior behavior);
|
772
1009
|
|
1010
|
+
#else
|
773
1011
|
/** Stack-based computations. */
|
774
1012
|
|
775
1013
|
/** Push a value.
|
@@ -851,3 +1089,4 @@ extern void transmitR(RefRangeS ref);
|
|
851
1089
|
/* Transmit the top value to a range in a signal in sequence.
|
852
1090
|
* @param ref the ref to the range of the signal to transmit to. */
|
853
1091
|
extern void transmitR_seq(RefRangeS ref);
|
1092
|
+
#endif
|