HDLRuby 2.0.8

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.
Files changed (224) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.travis.yml +5 -0
  4. data/.yardopts +1 -0
  5. data/Gemfile +4 -0
  6. data/HDLRuby.gemspec +36 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +2774 -0
  9. data/README.pdf +0 -0
  10. data/Rakefile +10 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +8 -0
  13. data/exe/hdrcc +3 -0
  14. data/lib/HDLRuby/alcc.rb +137 -0
  15. data/lib/HDLRuby/backend/hruby_allocator.rb +69 -0
  16. data/lib/HDLRuby/backend/hruby_c_allocator.rb +76 -0
  17. data/lib/HDLRuby/hdr_samples/adder.rb +7 -0
  18. data/lib/HDLRuby/hdr_samples/adder_assign_error.rb +11 -0
  19. data/lib/HDLRuby/hdr_samples/adder_bench.rb +27 -0
  20. data/lib/HDLRuby/hdr_samples/adder_gen.rb +7 -0
  21. data/lib/HDLRuby/hdr_samples/adder_nodef_error.rb +7 -0
  22. data/lib/HDLRuby/hdr_samples/addsub.rb +19 -0
  23. data/lib/HDLRuby/hdr_samples/addsubz.rb +22 -0
  24. data/lib/HDLRuby/hdr_samples/alu.rb +47 -0
  25. data/lib/HDLRuby/hdr_samples/calculator.rb +48 -0
  26. data/lib/HDLRuby/hdr_samples/counter_bench.rb +83 -0
  27. data/lib/HDLRuby/hdr_samples/dff.rb +9 -0
  28. data/lib/HDLRuby/hdr_samples/dff_bench.rb +66 -0
  29. data/lib/HDLRuby/hdr_samples/dff_counter.rb +20 -0
  30. data/lib/HDLRuby/hdr_samples/include.rb +14 -0
  31. data/lib/HDLRuby/hdr_samples/instance_open.rb +23 -0
  32. data/lib/HDLRuby/hdr_samples/mei8.rb +256 -0
  33. data/lib/HDLRuby/hdr_samples/mei8_bench.rb +309 -0
  34. data/lib/HDLRuby/hdr_samples/multer_gen.rb +8 -0
  35. data/lib/HDLRuby/hdr_samples/multer_seq.rb +29 -0
  36. data/lib/HDLRuby/hdr_samples/neural/a.rb +9 -0
  37. data/lib/HDLRuby/hdr_samples/neural/a_sub.rb +5 -0
  38. data/lib/HDLRuby/hdr_samples/neural/bw.rb +23 -0
  39. data/lib/HDLRuby/hdr_samples/neural/counter.rb +16 -0
  40. data/lib/HDLRuby/hdr_samples/neural/dadz.rb +9 -0
  41. data/lib/HDLRuby/hdr_samples/neural/dadz_sub.rb +4 -0
  42. data/lib/HDLRuby/hdr_samples/neural/forward.rb +153 -0
  43. data/lib/HDLRuby/hdr_samples/neural/forward_sub.rb +62 -0
  44. data/lib/HDLRuby/hdr_samples/neural/forward_sub_rand.rb +41 -0
  45. data/lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb +47 -0
  46. data/lib/HDLRuby/hdr_samples/neural/mem.rb +30 -0
  47. data/lib/HDLRuby/hdr_samples/neural/random.rb +23 -0
  48. data/lib/HDLRuby/hdr_samples/neural/selector.rb +29 -0
  49. data/lib/HDLRuby/hdr_samples/neural/sigmoid.rb +20 -0
  50. data/lib/HDLRuby/hdr_samples/neural/z.rb +33 -0
  51. data/lib/HDLRuby/hdr_samples/prog.obj +256 -0
  52. data/lib/HDLRuby/hdr_samples/ram.rb +18 -0
  53. data/lib/HDLRuby/hdr_samples/register_with_code_bench.rb +98 -0
  54. data/lib/HDLRuby/hdr_samples/rom.rb +10 -0
  55. data/lib/HDLRuby/hdr_samples/struct.rb +14 -0
  56. data/lib/HDLRuby/hdr_samples/sumprod.rb +29 -0
  57. data/lib/HDLRuby/hdr_samples/sw_encrypt_bench.rb +103 -0
  58. data/lib/HDLRuby/hdr_samples/sw_encrypt_cpu_bench.rb +261 -0
  59. data/lib/HDLRuby/hdr_samples/sw_encrypt_cpusim_bench.rb +302 -0
  60. data/lib/HDLRuby/hdr_samples/system_open.rb +11 -0
  61. data/lib/HDLRuby/hdr_samples/tuple.rb +16 -0
  62. data/lib/HDLRuby/hdr_samples/with_channel.rb +118 -0
  63. data/lib/HDLRuby/hdr_samples/with_class.rb +199 -0
  64. data/lib/HDLRuby/hdr_samples/with_decoder.rb +17 -0
  65. data/lib/HDLRuby/hdr_samples/with_fsm.rb +34 -0
  66. data/lib/HDLRuby/hdr_samples/with_reconf.rb +103 -0
  67. data/lib/HDLRuby/hdrcc.rb +623 -0
  68. data/lib/HDLRuby/high_samples/_adder_fault.rb +23 -0
  69. data/lib/HDLRuby/high_samples/_generic_transmission2.rb +146 -0
  70. data/lib/HDLRuby/high_samples/adder.rb +21 -0
  71. data/lib/HDLRuby/high_samples/adder_common_errors.rb +25 -0
  72. data/lib/HDLRuby/high_samples/addsub.rb +33 -0
  73. data/lib/HDLRuby/high_samples/addsubz.rb +37 -0
  74. data/lib/HDLRuby/high_samples/after.rb +28 -0
  75. data/lib/HDLRuby/high_samples/all_signals.rb +29 -0
  76. data/lib/HDLRuby/high_samples/alu.rb +61 -0
  77. data/lib/HDLRuby/high_samples/anonymous.rb +41 -0
  78. data/lib/HDLRuby/high_samples/before.rb +28 -0
  79. data/lib/HDLRuby/high_samples/blockblock.rb +26 -0
  80. data/lib/HDLRuby/high_samples/bugs/dadz.rb +22 -0
  81. data/lib/HDLRuby/high_samples/bugs/misample_instan.rb +20 -0
  82. data/lib/HDLRuby/high_samples/bugs/misample_updown.rb +22 -0
  83. data/lib/HDLRuby/high_samples/bugs/sample_add.rb +16 -0
  84. data/lib/HDLRuby/high_samples/bugs/sample_barrel.rb +13 -0
  85. data/lib/HDLRuby/high_samples/bugs/sample_daice.rb +57 -0
  86. data/lib/HDLRuby/high_samples/bugs/sample_kumiawase.rb +52 -0
  87. data/lib/HDLRuby/high_samples/bugs/sample_multi.rb +18 -0
  88. data/lib/HDLRuby/high_samples/bugs/sample_sub.rb +14 -0
  89. data/lib/HDLRuby/high_samples/bugs/z2.rb +32 -0
  90. data/lib/HDLRuby/high_samples/case.rb +32 -0
  91. data/lib/HDLRuby/high_samples/case2.rb +30 -0
  92. data/lib/HDLRuby/high_samples/change.rb +23 -0
  93. data/lib/HDLRuby/high_samples/clocks.rb +35 -0
  94. data/lib/HDLRuby/high_samples/comparer.rb +21 -0
  95. data/lib/HDLRuby/high_samples/conditionals.rb +29 -0
  96. data/lib/HDLRuby/high_samples/dff.rb +23 -0
  97. data/lib/HDLRuby/high_samples/each.rb +28 -0
  98. data/lib/HDLRuby/high_samples/exporter.rb +42 -0
  99. data/lib/HDLRuby/high_samples/functions.rb +60 -0
  100. data/lib/HDLRuby/high_samples/if_seq.rb +26 -0
  101. data/lib/HDLRuby/high_samples/inherit_as_dff.rb +32 -0
  102. data/lib/HDLRuby/high_samples/inherit_dff.rb +36 -0
  103. data/lib/HDLRuby/high_samples/instance.rb +37 -0
  104. data/lib/HDLRuby/high_samples/memory.rb +64 -0
  105. data/lib/HDLRuby/high_samples/multi_file.rb +27 -0
  106. data/lib/HDLRuby/high_samples/overload.rb +32 -0
  107. data/lib/HDLRuby/high_samples/paper_after.rb +49 -0
  108. data/lib/HDLRuby/high_samples/ram.rb +27 -0
  109. data/lib/HDLRuby/high_samples/registers.rb +139 -0
  110. data/lib/HDLRuby/high_samples/rom.rb +23 -0
  111. data/lib/HDLRuby/high_samples/scopeblockname.rb +37 -0
  112. data/lib/HDLRuby/high_samples/scopescope.rb +26 -0
  113. data/lib/HDLRuby/high_samples/shift.rb +31 -0
  114. data/lib/HDLRuby/high_samples/shift2.rb +40 -0
  115. data/lib/HDLRuby/high_samples/simple_instance.rb +31 -0
  116. data/lib/HDLRuby/high_samples/test_all.sh +10 -0
  117. data/lib/HDLRuby/high_samples/typedef.rb +24 -0
  118. data/lib/HDLRuby/high_samples/values.rb +70 -0
  119. data/lib/HDLRuby/high_samples/vector.rb +22 -0
  120. data/lib/HDLRuby/high_samples/with_decoder.rb +30 -0
  121. data/lib/HDLRuby/high_samples/with_fsm.rb +46 -0
  122. data/lib/HDLRuby/high_samples/with_pipe.rb +43 -0
  123. data/lib/HDLRuby/high_samples/with_seq.rb +25 -0
  124. data/lib/HDLRuby/hruby_bstr.rb +1085 -0
  125. data/lib/HDLRuby/hruby_check.rb +317 -0
  126. data/lib/HDLRuby/hruby_db.rb +432 -0
  127. data/lib/HDLRuby/hruby_error.rb +44 -0
  128. data/lib/HDLRuby/hruby_high.rb +4103 -0
  129. data/lib/HDLRuby/hruby_low.rb +4735 -0
  130. data/lib/HDLRuby/hruby_low2c.rb +1986 -0
  131. data/lib/HDLRuby/hruby_low2high.rb +738 -0
  132. data/lib/HDLRuby/hruby_low2seq.rb +248 -0
  133. data/lib/HDLRuby/hruby_low2sym.rb +126 -0
  134. data/lib/HDLRuby/hruby_low2vhd.rb +1437 -0
  135. data/lib/HDLRuby/hruby_low_bool2select.rb +295 -0
  136. data/lib/HDLRuby/hruby_low_cleanup.rb +193 -0
  137. data/lib/HDLRuby/hruby_low_fix_types.rb +437 -0
  138. data/lib/HDLRuby/hruby_low_mutable.rb +1803 -0
  139. data/lib/HDLRuby/hruby_low_resolve.rb +165 -0
  140. data/lib/HDLRuby/hruby_low_skeleton.rb +129 -0
  141. data/lib/HDLRuby/hruby_low_with_bool.rb +141 -0
  142. data/lib/HDLRuby/hruby_low_with_port.rb +167 -0
  143. data/lib/HDLRuby/hruby_low_with_var.rb +302 -0
  144. data/lib/HDLRuby/hruby_low_without_bit2vector.rb +88 -0
  145. data/lib/HDLRuby/hruby_low_without_concat.rb +162 -0
  146. data/lib/HDLRuby/hruby_low_without_connection.rb +113 -0
  147. data/lib/HDLRuby/hruby_low_without_namespace.rb +718 -0
  148. data/lib/HDLRuby/hruby_low_without_outread.rb +107 -0
  149. data/lib/HDLRuby/hruby_low_without_select.rb +206 -0
  150. data/lib/HDLRuby/hruby_serializer.rb +398 -0
  151. data/lib/HDLRuby/hruby_tools.rb +37 -0
  152. data/lib/HDLRuby/hruby_types.rb +239 -0
  153. data/lib/HDLRuby/hruby_values.rb +64 -0
  154. data/lib/HDLRuby/hruby_verilog.rb +1888 -0
  155. data/lib/HDLRuby/hruby_verilog_name.rb +52 -0
  156. data/lib/HDLRuby/low_samples/adder.yaml +97 -0
  157. data/lib/HDLRuby/low_samples/after.yaml +228 -0
  158. data/lib/HDLRuby/low_samples/before.yaml +223 -0
  159. data/lib/HDLRuby/low_samples/blockblock.yaml +48 -0
  160. data/lib/HDLRuby/low_samples/bugs/sample_add.yaml +97 -0
  161. data/lib/HDLRuby/low_samples/bugs/sample_daice.yaml +444 -0
  162. data/lib/HDLRuby/low_samples/bugs/sample_kumiawase.yaml +332 -0
  163. data/lib/HDLRuby/low_samples/bugs/sample_sub.yaml +97 -0
  164. data/lib/HDLRuby/low_samples/bugs/seqpar.yaml +184 -0
  165. data/lib/HDLRuby/low_samples/case.yaml +327 -0
  166. data/lib/HDLRuby/low_samples/change.yaml +135 -0
  167. data/lib/HDLRuby/low_samples/clocks.yaml +674 -0
  168. data/lib/HDLRuby/low_samples/cloner.rb +22 -0
  169. data/lib/HDLRuby/low_samples/comparer.yaml +85 -0
  170. data/lib/HDLRuby/low_samples/conditionals.yaml +133 -0
  171. data/lib/HDLRuby/low_samples/dff.yaml +107 -0
  172. data/lib/HDLRuby/low_samples/each.yaml +1328 -0
  173. data/lib/HDLRuby/low_samples/exporter.yaml +226 -0
  174. data/lib/HDLRuby/low_samples/functions.yaml +298 -0
  175. data/lib/HDLRuby/low_samples/generic_transmission.yaml +597 -0
  176. data/lib/HDLRuby/low_samples/inherit_as_dff.yaml +125 -0
  177. data/lib/HDLRuby/low_samples/inherit_dff.yaml +107 -0
  178. data/lib/HDLRuby/low_samples/load_yaml.rb +11 -0
  179. data/lib/HDLRuby/low_samples/memory.yaml +678 -0
  180. data/lib/HDLRuby/low_samples/namespace_extractor.rb +23 -0
  181. data/lib/HDLRuby/low_samples/overload.yaml +226 -0
  182. data/lib/HDLRuby/low_samples/paper_after.yaml +431 -0
  183. data/lib/HDLRuby/low_samples/port_maker.rb +14 -0
  184. data/lib/HDLRuby/low_samples/ram.yaml +207 -0
  185. data/lib/HDLRuby/low_samples/registers.yaml +228 -0
  186. data/lib/HDLRuby/low_samples/rom.yaml +2950 -0
  187. data/lib/HDLRuby/low_samples/shift.yaml +230 -0
  188. data/lib/HDLRuby/low_samples/shift2.yaml +2095 -0
  189. data/lib/HDLRuby/low_samples/simple_instance.yaml +102 -0
  190. data/lib/HDLRuby/low_samples/test_all.sh +43 -0
  191. data/lib/HDLRuby/low_samples/typedef.yaml +115 -0
  192. data/lib/HDLRuby/low_samples/values.yaml +577 -0
  193. data/lib/HDLRuby/low_samples/variable_maker.rb +14 -0
  194. data/lib/HDLRuby/low_samples/vector.yaml +56 -0
  195. data/lib/HDLRuby/low_samples/with_seq.yaml +188 -0
  196. data/lib/HDLRuby/low_samples/yaml2hdr.rb +10 -0
  197. data/lib/HDLRuby/low_samples/yaml2vhd.rb +19 -0
  198. data/lib/HDLRuby/sim/Makefile +19 -0
  199. data/lib/HDLRuby/sim/hruby_sim.h +590 -0
  200. data/lib/HDLRuby/sim/hruby_sim_calc.c +2362 -0
  201. data/lib/HDLRuby/sim/hruby_sim_core.c +589 -0
  202. data/lib/HDLRuby/sim/hruby_sim_list.c +93 -0
  203. data/lib/HDLRuby/sim/hruby_sim_vizualize.c +91 -0
  204. data/lib/HDLRuby/sim/hruby_value_pool.c +64 -0
  205. data/lib/HDLRuby/std/channel.rb +354 -0
  206. data/lib/HDLRuby/std/clocks.rb +165 -0
  207. data/lib/HDLRuby/std/counters.rb +82 -0
  208. data/lib/HDLRuby/std/decoder.rb +214 -0
  209. data/lib/HDLRuby/std/fsm.rb +516 -0
  210. data/lib/HDLRuby/std/pipeline.rb +220 -0
  211. data/lib/HDLRuby/std/reconf.rb +309 -0
  212. data/lib/HDLRuby/test_hruby_bstr.rb +2259 -0
  213. data/lib/HDLRuby/test_hruby_high.rb +594 -0
  214. data/lib/HDLRuby/test_hruby_high_low.rb +99 -0
  215. data/lib/HDLRuby/test_hruby_low.rb +934 -0
  216. data/lib/HDLRuby/v_samples/adder.v +10 -0
  217. data/lib/HDLRuby/v_samples/dff.v +12 -0
  218. data/lib/HDLRuby/v_samples/ram.v +20 -0
  219. data/lib/HDLRuby/v_samples/rom.v +270 -0
  220. data/lib/HDLRuby/version.rb +3 -0
  221. data/lib/HDLRuby.rb +11 -0
  222. data/makedoc +1 -0
  223. data/metadata.yaml +4 -0
  224. metadata +299 -0
@@ -0,0 +1,590 @@
1
+ /**
2
+ * The HDLRuby simulation global header, to include in C code
3
+ * generated by hruby_low2c.
4
+ **/
5
+
6
+ #include <pthread.h>
7
+
8
+
9
+ /* The interface to the HDLRuby objects C models. */
10
+
11
+ typedef struct TypeS_ TypeS;
12
+ typedef struct FlagsS_ FlagsS;
13
+ typedef struct ValueS_ ValueS;
14
+ typedef struct ObjectS_ ObjectS;
15
+ typedef struct SystemTS_ SystemTS;
16
+ typedef struct SignalIS_ SignalIS;
17
+ typedef struct ScopeS_ ScopeS;
18
+ typedef struct BehaviorS_ BehaviorS;
19
+ typedef struct SystemIS_ SystemIS;
20
+ typedef struct CodeS_ CodeS;
21
+ typedef struct BlockS_ BlockS;
22
+ typedef struct EventS_ EventS;
23
+
24
+ typedef struct RefRangeS_ RefRangeS;
25
+
26
+ typedef struct TypeS_* Type;
27
+ typedef struct ValueS_* Value;
28
+ typedef struct ObjectS_* Object;
29
+ typedef struct SystemTS_* SystemT;
30
+ typedef struct SignalIS_* SignalI;
31
+ typedef struct ScopeS_* Scope;
32
+ typedef struct BehaviorS_* Behavior;
33
+ typedef struct SystemIS_* SystemI;
34
+ typedef struct CodeS_* Code;
35
+ typedef struct BlockS_* Block;
36
+ typedef struct EventS_* Event;
37
+
38
+ typedef struct RefRangeS_* RefRange;
39
+
40
+ /* The kinds of HDLRuby objects. */
41
+ typedef enum {
42
+ OBJECT, SYSTEMT, SIGNALI, SCOPE, BEHAVIOR, SYSTEMI, CODE, BLOCK, EVENT
43
+ } Kind;
44
+
45
+ /* The kinds of HDLRuby event edge. */
46
+ typedef enum {
47
+ ANYEDGE, POSEDGE, NEGEDGE
48
+ } Edge;
49
+
50
+
51
+ /* The interface to the type engine. */
52
+ typedef struct FlagsS_ {
53
+ unsigned int all;
54
+ unsigned int sign : 1; /* Tells if the type is signed or not. */
55
+ } FlagsS;
56
+
57
+ /** The type structure. */
58
+ typedef struct TypeS_ {
59
+ unsigned long long base; /* The size in bits of the base elements. */
60
+ unsigned long long number; /* The number of elements of the type. */
61
+ FlagsS flags; /* The features of the type. */
62
+ } TypeS;
63
+
64
+
65
+ /** Computes the width in bits of a type.
66
+ * @param type the type to compute the width
67
+ * @return the resulting width in bits */
68
+ extern unsigned long long type_width(Type type);
69
+
70
+ /** Gets the single bit type. */
71
+ extern Type get_type_bit();
72
+
73
+ /** Gets the single signed bit type. */
74
+ extern Type get_type_signed();
75
+
76
+ /** Creates a new type from a HDLRuby TypeVector.
77
+ * @param base the type of an element
78
+ * @param number the number of base elements */
79
+ extern Type make_type_vector(Type base, unsigned long long number);
80
+
81
+ /** Gets a vector type by size and base.
82
+ * @param base the type of an element
83
+ * @param number the number of base elements */
84
+ extern Type get_type_vector(Type base, unsigned long long number);
85
+
86
+
87
+
88
+ /* The interface to the value computation engine. */
89
+
90
+ /* The structure of a value. */
91
+ typedef struct ValueS_ {
92
+ Type type; /* The type of the value. */
93
+ int numeric; /* Tell if the value is numeric or a bitstring. */
94
+ unsigned long long capacity; /* The capacity in char of the bit string. */
95
+ char* data_str; /* The bit string data if not numeric. */
96
+ unsigned long long data_int;/* The integer data if numeric. */
97
+ SignalI signal; /* The signal associated with the value if any. */
98
+ } ValueS;
99
+
100
+ /* The tructure of a reference to a range in a value. */
101
+ typedef struct RefRangeS_ {
102
+ SignalI signal; /* The refered signal. */
103
+ unsigned long long first; /* The first index in the range. */
104
+ unsigned long long last; /* The last index in the range. */
105
+ } RefRangeS;
106
+
107
+ /** Creates a new value.
108
+ * @param type the type of the value
109
+ * @param numeric tells if the value is numeric or not
110
+ * @return the resulting value */
111
+ extern Value make_value(Type type,int numeric);
112
+
113
+ /** Sets a value with data.
114
+ * @param value the value to fill
115
+ * @param numeric tell if the value is in numeric form or in bitstring form
116
+ * @param data the source data */
117
+ extern void set_value(Value value, int numeric, void* data);
118
+
119
+ /** Makes and sets a value with data.
120
+ * @param type the type of the value
121
+ * @param numeric tell if the value is in numeric form or in bitstring form
122
+ * @param data the source data */
123
+ extern Value make_set_value(Type type, int numeric, void* data);
124
+
125
+
126
+ /** Computes the neg of a value.
127
+ * @param src the source value of the neg
128
+ * @param dst the destination value
129
+ * @return dst */
130
+ extern Value neg_value(Value src, Value dst);
131
+
132
+ /** Computes the addition of two values.
133
+ * @param src0 the first source value of the addition
134
+ * @param src1 the second source value of the addition
135
+ * @param dst the destination value
136
+ * @return dst */
137
+ extern Value add_value(Value src0, Value src1, Value dst);
138
+
139
+ /** Computes the subtraction of two values.
140
+ * @param src0 the first source value of the subtraction
141
+ * @param src1 the second source value of the subtraction
142
+ * @param dst the destination value
143
+ * @return dst */
144
+ extern Value sub_value(Value src0, Value src1, Value dst);
145
+
146
+ /** Computes the not of a value.
147
+ * @param src the source value of the not
148
+ * @param dst the destination value
149
+ * @return dst */
150
+ extern Value not_value(Value src, Value dst);
151
+
152
+ /** Computes the AND of two values.
153
+ * @param src0 the first source value of the and
154
+ * @param src1 the second source value of the and
155
+ * @param dst the destination value
156
+ * @return dst */
157
+ extern Value and_value(Value src0, Value src1, Value dst);
158
+
159
+ /** Computes the OR of two values.
160
+ * @param src0 the first source value of the or
161
+ * @param src1 the second source value of the or
162
+ * @param dst the destination value
163
+ * @return dst */
164
+ extern Value or_value(Value src0, Value src1, Value dst);
165
+
166
+ /** Computes the XOR of two values.
167
+ * @param src0 the first source value of the or
168
+ * @param src1 the second source value of the or
169
+ * @param dst the destination value
170
+ * @return dst */
171
+ extern Value xor_value(Value src0, Value src1, Value dst);
172
+
173
+ /** Computes the left shift of two general values.
174
+ * @param src0 the first source value of the addition
175
+ * @param src1 the second source value of the addition
176
+ * @param dst the destination
177
+ * @return dst */
178
+ Value shift_left_value(Value src0, Value src1, Value dst);
179
+
180
+ /** Computes the right shift of two general values.
181
+ * @param src0 the first source value of the addition
182
+ * @param src1 the second source value of the addition
183
+ * @param dst the destination
184
+ * @return dst */
185
+ Value shift_right_value(Value src0, Value src1, Value dst);
186
+
187
+ /** Computes the equal (NXOR) of two values.
188
+ * @param src0 the first source value of the addition
189
+ * @param src1 the second source value of the addition
190
+ * @param dst the destination value
191
+ * @return dst */
192
+ extern Value equal_value(Value src0, Value src1, Value dst);
193
+
194
+ /** Selects a value depending on a condition.
195
+ * @param cond the condition to use for selecting a value
196
+ * @param dst the destination value
197
+ * @param num the number of values for the selection
198
+ * @return the selected value */
199
+ extern Value select_value(Value cond, Value dst, unsigned int num, ...);
200
+
201
+ /** Concat multiple values to a single one.
202
+ * @param num the number of values to concat
203
+ * @param dir the direction of concatenation
204
+ * @param dst the destination value
205
+ * @return dst */
206
+ extern Value concat_value(int num, int dir, Value dst, ...);
207
+
208
+ /** Casts a value to another type.
209
+ * @param src the source value
210
+ * @param type the type to cast to
211
+ * @param dst the destination value
212
+ * @return dst */
213
+ extern Value cast_value(Value src, Type type, Value dst);
214
+
215
+ /** Copies a value to another, the type of the destination is preserved.
216
+ * @param src the source value
217
+ * @param dst the destination value
218
+ * @return dst */
219
+ extern Value copy_value(Value src, Value dst);
220
+
221
+ /** Copies a value to another but without overwritting with Z, the type of
222
+ * the destination is preserved.
223
+ * @param src the source value
224
+ * @param dst the destination value
225
+ * @return dst */
226
+ extern Value copy_value_no_z(Value src, Value dst);
227
+
228
+ /** Testing if a value is 0.
229
+ * @param value the value to check
230
+ * @return 1 if 0 and 0 otherwize */
231
+ extern int zero_value(Value value);
232
+
233
+ /** Testing if a value is defined or not.
234
+ * @param value the value to check
235
+ * @return 1 if defined and 0 otherwize */
236
+ extern int is_defined_value(Value value);
237
+
238
+ /** Testing if two values have the same content (the type is not checked).
239
+ * @param value0 the first value to compare
240
+ * @param value1 the second value to compare
241
+ * @return 1 if same content. */
242
+ extern int same_content_value(Value value0, Value value1);
243
+
244
+ /** Testing if two values have the same content (the type is not checked).
245
+ * @param value0 the first value to compare
246
+ * @param first the first index of the range
247
+ * @param last the last index of the range
248
+ * @param value1 the second value to compare
249
+ * @return 1 if same content. */
250
+ extern int same_content_value_range(Value value0, unsigned long long first,
251
+ unsigned long long last, Value value1);
252
+
253
+ /** Creates a reference to a range inside a signal.
254
+ * @param signal the signal to refer
255
+ * @param first the start index of the range
256
+ * @param last the end index of the range
257
+ * @return the resulting reference */
258
+ extern RefRangeS make_ref_rangeS(SignalI signal, unsigned long long first,
259
+ unsigned long long last);
260
+
261
+
262
+ /* The interface for the lists. */
263
+
264
+ /** The list element data structure. */
265
+ typedef struct ElemS_ {
266
+ void* data; /* The data stored in the element. */
267
+ struct ElemS_* next; /* The next element in the lisdt if any. */
268
+ } ElemS;
269
+
270
+ typedef ElemS* Elem;
271
+
272
+ /** The list data structure. */
273
+ typedef struct ListS_ {
274
+ Elem head; /* The head of the list */
275
+ Elem tail; /* The tail of the list */
276
+ } ListS;
277
+
278
+ typedef ListS* List;
279
+
280
+ /** Get a list element for containing some data.
281
+ * @param data the data of the element
282
+ * @return the resulting element */
283
+ extern Elem get_element(void* data);
284
+
285
+ /** Delete an element (it will return to the pool).
286
+ * @param elem the element to delete */
287
+ void delete_element(Elem elem);
288
+
289
+ /** Tells if a list is empty.
290
+ * @param list the list to check. */
291
+ #define empty_list(list) ((list)->head == NULL)
292
+
293
+ /** Builds a list.
294
+ * @param list the place where to build the list
295
+ * @return the resulting list */
296
+ extern List build_list(List list);
297
+
298
+ /** Clears a list.
299
+ * @param list the list to clear */
300
+ extern void clear_list(List list);
301
+
302
+ /** Adds an element to the tail of a list.
303
+ * @param list the list to add the element in
304
+ * @param elem the element to add in the list */
305
+ extern void add_list(List list, Elem elem);
306
+
307
+ /** Remove the head of the list.
308
+ * @param list the list to remove the head from
309
+ * @return the removed element */
310
+ extern Elem remove_list(List list);
311
+
312
+
313
+ /* The interface for the pool of values. */
314
+
315
+ /** Get a fresh value. */
316
+ extern Value get_value();
317
+
318
+ /** Frees the last value of the pool. */
319
+ extern void free_value();
320
+
321
+ /** Gets the current state of the value pool. */
322
+ extern unsigned int get_value_pos();
323
+
324
+ /** Restores the state of the value pool.
325
+ * @param pos the new position in the pool */
326
+ extern void set_value_pos(unsigned int pos);
327
+
328
+ /** An HDLRuby object. */
329
+ typedef struct ObjectS_ {
330
+ Kind kind; /* The kind of object. */
331
+ Object owner; /* The owner of the object if any. */
332
+ } ObjectS;
333
+
334
+
335
+ /** The C model of a SystemT. */
336
+ typedef struct SystemTS_ {
337
+ Kind kind; /* The kind of object. */
338
+ Object owner; /* The owner if any. */
339
+
340
+ char* name; /* The name of the system. */
341
+ int num_inputs; /* The number of inputs. */
342
+ SignalI* inputs; /* The inputs of the system. */
343
+ int num_outputs; /* The number of outputs. */
344
+ SignalI* outputs; /* The outputs of the system. */
345
+ int num_inouts; /* The number of inouts. */
346
+ SignalI* inouts; /* The inouts of the system. */
347
+ Scope scope; /* The scope of the system. */
348
+ } SystemTS;
349
+
350
+
351
+ /** The C model of a Signal. */
352
+ typedef struct SignalIS_ {
353
+ Kind kind; /* The kind of object. */
354
+ Object owner; /* The owner if any. */
355
+
356
+ char* name; /* The name of the signal. */
357
+ Type type; /* The type of the signal. */
358
+ Value c_value; /* The current value of the signal. */
359
+ Value f_value; /* The future (next) value of the signal. */
360
+
361
+ int fading; /* Tell if the signal can be overwritten by Z. */
362
+
363
+ int num_any; /* The number of behavior activated on any edge. */
364
+ Object* any; /* The objects activated on any edge. */
365
+ int num_pos; /* The number of behavior activated on pos edge. */
366
+ Object* pos; /* The objects actvated on pos edge. */
367
+ int num_neg; /* The number of behavior activated on neg edge. */
368
+ Object* neg; /* The objects actvated on neg edge. */
369
+ } SignalIS;
370
+
371
+
372
+ /** The C model of a system instance. */
373
+ typedef struct SystemIS_ {
374
+ Kind kind; /* The kind of object. */
375
+ Object owner; /* The owner if any. */
376
+
377
+ char* name; /* The name of the signal. */
378
+ SystemT system; /* The instantiated system. */
379
+ } SystemIS;
380
+
381
+
382
+ /** The C model of a Scope. */
383
+ typedef struct ScopeS_ {
384
+ Kind kind; /* The kind of object. */
385
+ Object owner; /* The owner if any. */
386
+
387
+ char* name; /* The name of the scope. */
388
+ int num_systemIs; /* The number of system instances. */
389
+ SystemI* systemIs; /* The system instances of the scope. */
390
+ int num_inners; /* The number of inners. */
391
+ SignalI* inners; /* The inners of the scope. */
392
+ int num_scopes; /* The number of sub scopes. */
393
+ Scope *scopes; /* The sub scopes of the scope. */
394
+ int num_behaviors; /* The number of behaviors. */
395
+ Behavior* behaviors;/* The behaviors of the scope. */
396
+ int num_codes; /* The number of non-HDLRuby codes. */
397
+ Code* codes; /* The non-HDLRuby codes of the scope. */
398
+ } ScopeS;
399
+
400
+
401
+ /** The C model of a behavior. */
402
+ typedef struct BehaviorS_ {
403
+ Kind kind; /* The kind of object. */
404
+ Object owner; /* The owner if any. */
405
+
406
+ int num_events; /* The number of events. */
407
+ Event* events; /* The events of the behavior. */
408
+ Block block; /* The block of the behavior. */
409
+
410
+ int activated; /* Tells if the behavior is activated or not. */
411
+
412
+ int timed; /* Tell if the behavior is timed or not. */
413
+ unsigned long long active_time; /* The next time the behavior has to be activated. */
414
+ pthread_t thread; /* The thread assotiated with the behavior (if any).*/
415
+ } BehaviorS;
416
+
417
+
418
+ /** The C model of non-HDLRuby code. */
419
+ typedef struct CodeS_ {
420
+ Kind kind; /* The kind of object. */
421
+ Object owner; /* The owner if any. */
422
+
423
+ int num_events; /* The number of events. */
424
+ Event* events; /* The events of the behavior. */
425
+ void (*function)(); /* The function to execute for the code. */
426
+
427
+ int activated; /* Tells if the code is activated or not. */
428
+ } CodeS;
429
+
430
+
431
+ /** The C model of a Scope. */
432
+ typedef struct BlockS_ {
433
+ Kind kind; /* The kind of object. */
434
+ Object owner; /* The owner if any. */
435
+
436
+ int num_inners; /* The number of inners. */
437
+ SignalI* inners; /* The inners of the scope. */
438
+ void (*function)(); /* The function to execute for the block. */
439
+ } BlockS;
440
+
441
+
442
+ /** The C model of a Scope. */
443
+ typedef struct EventS_ {
444
+ Kind kind; /* The kind of object. */
445
+ Object owner; /* The owner if any. */
446
+
447
+ Edge edge; /* The edge of the event. */
448
+ SignalI signal; /* The signal of the event. */
449
+ } EventS;
450
+
451
+
452
+
453
+ /* The interface to the simulator. */
454
+
455
+ /* The time units. */
456
+ typedef enum { S, MS, US, NS, FS } Unit;
457
+
458
+ /** Adds a timed behavior for processing.
459
+ * @param behavior the timed behavior to register */
460
+ extern void register_timed_behavior(Behavior behavior);
461
+
462
+ /** Adds a signal for global processing.
463
+ * @param signal the signal to register */
464
+ extern void register_signal(SignalI signal);
465
+
466
+ /** Makes the behavior wait for a given time.
467
+ * @param delay the delay to wait in fs.
468
+ * @param behavior the current behavior. */
469
+ extern void hw_wait(unsigned long long delay, Behavior behavior);
470
+
471
+ // /** Transmit a signal to another signal.
472
+ // * @param dst the destination signal
473
+ // * @param src the source signal */
474
+ // extern void transmit(SignalI src, SignalI dst);
475
+
476
+ /** Touch a signal.
477
+ * @param signal the signal to touch */
478
+ extern void touch_signal(SignalI signal);
479
+
480
+ /** Transmit a value to a signal.
481
+ * @param value the value to transmit
482
+ * @param signal the signal to transmit the value to. */
483
+ extern void transmit_to_signal(Value value, SignalI signal);
484
+
485
+ /** Transmit a value to a range within a signal.
486
+ * @param value the value to transmit
487
+ * @param ref the reference to the range in the signal to transmit the
488
+ * value to. */
489
+ extern void transmit_to_signal_range(Value value, RefRangeS ref);
490
+
491
+
492
+ /** Touch a signal. in case of a sequential execution model.
493
+ * @param signal the signal to touch */
494
+ extern void touch_signal_seq(SignalI signal);
495
+
496
+ /** Transmit a value to a signal in case of a sequential execution model.
497
+ * @param value the value to transmit
498
+ * @param signal the signal to transmit the value to. */
499
+ extern void transmit_to_signal_seq(Value value, SignalI signal);
500
+
501
+ /** Transmit a value to a range within a signal in case of sequential
502
+ * execution model.
503
+ * @param value the value to transmit
504
+ * @param ref the reference to the range in the signal to transmit the
505
+ * value to. */
506
+ extern void transmit_to_signal_range_seq(Value value, RefRangeS ref);
507
+
508
+ /** Creates an event.
509
+ * @param edge the edge of the event
510
+ * @param signal the signal of the event */
511
+ extern Event make_event(Edge edge, SignalI signal);
512
+
513
+ /** Creates a delay.
514
+ * Actually generates an unsigned long long giving the corresponding
515
+ * delay in the base unit of the simulator.
516
+ * @param value the value of the delay
517
+ * @param unit the used unit
518
+ * @return the result delay in the base unit of the simulator (ns) */
519
+ extern unsigned long long make_delay(int value, Unit unit);
520
+
521
+
522
+
523
+
524
+ /* Interface to the visualization engine. */
525
+
526
+ /** Prints the time.
527
+ * @param time the time to show. */
528
+ extern void print_time(unsigned long long time);
529
+
530
+ /** Prints the time and goes to the next line.
531
+ * @param time the time to show. */
532
+ extern void println_time(unsigned long long time);
533
+
534
+ /** Prints the name of an object.
535
+ * @param object the object to print the name. */
536
+ extern void print_name(Object object);
537
+
538
+ /** Prints a value.
539
+ * @param value the value to print */
540
+ extern void print_value(Value value);
541
+
542
+ /** Prints a signal.
543
+ * @param signal the signal to show */
544
+ extern void print_signal(SignalI signal);
545
+
546
+ /** Prints a signal and goes to the next line.
547
+ * @param signal the signal to show */
548
+ extern void println_signal(SignalI signal);
549
+
550
+
551
+ /* The interface to the simulator core. */
552
+
553
+ /** The simulation core function.
554
+ * @param limit the time limit in fs. */
555
+ extern void hruby_sim_core(unsigned long long limit);
556
+
557
+
558
+
559
+ /* Access and conversion functions. */
560
+
561
+ /** Converts a value to a long long int.
562
+ * @param value the value to convert
563
+ * @return the resulting unsigned int. */
564
+ extern unsigned long long value2integer(Value value);
565
+
566
+ /** Reads a range from a value.
567
+ * @param value the value to read
568
+ * @param first the first index of the range
569
+ * @param last the last index of the range
570
+ * @param base the type of the elements
571
+ * @param dst the destination value
572
+ * @return dst */
573
+ extern Value read_range(Value value, long long first, long long last,
574
+ Type base, Value dst);
575
+
576
+ /** Writes to a range within a value.
577
+ * @param src the source value
578
+ * @param first the first index of the range
579
+ * @param last the last index of the range
580
+ * @param dst the destination value
581
+ * @return dst */
582
+ extern Value write_range(Value src, long long first, long long last, Value dst);
583
+
584
+ /** Writes to a range within a value but without overwrite with Z.
585
+ * @param src the source value
586
+ * @param first the first index of the range
587
+ * @param last the last index of the range
588
+ * @param dst the destination value
589
+ * @return dst */
590
+ extern Value write_range_no_z(Value src, long long first, long long last, Value dst);