HDLRuby 2.0.8

Sign up to get free protection for your applications and to get access to all the features.
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,738 @@
1
+ require 'HDLRuby'
2
+
3
+
4
+ module HDLRuby::Low
5
+
6
+
7
+ ##
8
+ # Converts a HDLRuby::Low description to a HDLRuby::High text
9
+ # description
10
+ #
11
+ ########################################################################
12
+
13
+ ## Provides tools for converting HDLRuby::Low objects to HDLRuby::High.
14
+ module Low2High
15
+
16
+ ## Tells if an HDLRuby::Low +name+ syntax is compatible for
17
+ # HDLRuby::High.
18
+ def self.high_name?(name)
19
+ return name =~ /^[a-zA-Z_][a-zA-Z_0-9]*$/
20
+ end
21
+
22
+ ## Converts a HDLRuby::Low +name+ for declaration to HDLRuby::High.
23
+ def self.high_decl_name(name)
24
+ if high_name?(name) then
25
+ # Compatible name return it as is.
26
+ return name.to_s
27
+ else
28
+ # Incompatible, use quotes.
29
+ return "\"#{name}\""
30
+ end
31
+ end
32
+
33
+ ## Converts a HDLRuby::Low +name+ for usage to HDLRuby::High.
34
+ def self.high_use_name(name)
35
+ if high_name?(name) then
36
+ # Compatible name return it as is.
37
+ return name.to_s
38
+ else
39
+ # Incompatible, use the HDLRuby::High "send" operator.
40
+ return "(+:\"#{name}\")"
41
+ end
42
+ end
43
+
44
+ ## Convert a HDLRuby::Low +name+ for instantiation to HDLRuby::High
45
+ # with args as argument.
46
+ def self.high_call_name(name,args)
47
+ if high_name?(name) then
48
+ # Compatible name return it as is.
49
+ return "#{name} #{[*args].join(",")}"
50
+ else
51
+ # Incompatible, use the HDLRuby::High "send" operator.
52
+ return "send(:\"#{name}\",#{[*args].join(",")})"
53
+ end
54
+ end
55
+ end
56
+
57
+
58
+
59
+ ## Extends the SystemT class with generation of HDLRuby::High text.
60
+ class SystemT
61
+
62
+ # Generates the text of the equivalent HDLRuby::High code.
63
+ # +level+ is the hierachical level of the object.
64
+ def to_high(level = 0)
65
+ # The resulting string.
66
+ res = ""
67
+ # Generate the header.
68
+ res << " " * (level*3)
69
+ res << "system :#{Low2High.high_decl_name(self.name)} do\n"
70
+ # Generate the interface.
71
+ # Inputs.
72
+ self.each_input do |input|
73
+ res << " " * ((level+1)*3)
74
+ res << input.type.to_high(level+1)
75
+ res << ".input :" << Low2High.high_decl_name(input.name)
76
+ res << "\n"
77
+ end
78
+ # Outputs.
79
+ self.each_output do |output|
80
+ res << " " * ((level+1)*3)
81
+ res << output.type.to_high(level+1)
82
+ res << ".output :" << Low2High.high_decl_name(output.name)
83
+ res << "\n"
84
+ end
85
+ # Inouts.
86
+ self.each_inout do |inout|
87
+ res << " " * ((level+1)*3)
88
+ res << inout.type.to_high(level+1)
89
+ res << ".inout :" << Low2High.high_decl_name(inout.name)
90
+ res << "\n"
91
+ end
92
+ # Generate the scope.
93
+ res << " " * (level*3)
94
+ res << "\n"
95
+ res << self.scope.to_high(level+1,false)
96
+ # End of the system.
97
+ res << " " * (level*3)
98
+ res << "end\n\n"
99
+ # Return the result.
100
+ return res
101
+ end
102
+ end
103
+
104
+
105
+ ## Extends the Scope class with generation of HDLRuby::High text.
106
+ class Scope
107
+
108
+ # Generates the text of the equivalent HDLRuby::High code.
109
+ # +level+ is the hierachical level of the object and
110
+ # +header+ tells if the header is to generate or not.
111
+ def to_high(level = 0,header = true)
112
+ # The resulting string.
113
+ res = ""
114
+ # Generate the header if required.
115
+ if header then
116
+ res << (" " * (level*3)) << "sub "
117
+ unless self.name.empty? then
118
+ res << ":" << Low2High.high_decl_name(self.name) << " "
119
+ end
120
+ res << "do\n"
121
+ end
122
+ level = level + 1 if header
123
+ # Generate the sub types.
124
+ # Assume the types are TypeDef.
125
+ self.each_type do |type|
126
+ res << " " * (level*3)
127
+ res << "typedef :#{type.name} do\n"
128
+ res << " " * ((level+1)*3) << type.def.to_high(level)
129
+ res << " " * (level*3) << "end\n"
130
+ end
131
+ # Generaste the sub system types.
132
+ self.each_systemT { |systemT| res << systemT.to_high(level) }
133
+ # Generate the inners declaration.
134
+ self.each_inner do |inner|
135
+ res << " " * (level*3)
136
+ res << inner.type.to_high(level)
137
+ res << ".inner :" << Low2High.high_decl_name(inner.name) << "\n"
138
+ end
139
+ # Generate the instances.
140
+ res << "\n" if self.each_inner.any?
141
+ self.each_systemI do |systemI|
142
+ res << " " * (level*3)
143
+ res << systemI.to_high(level) << "\n"
144
+ end
145
+ # Generate the sub scopes.
146
+ self.each_scope do |scope|
147
+ res << scope.to_high(level)
148
+ end
149
+ # Generate the connections.
150
+ res << "\n" if self.each_scope.any?
151
+ self.each_connection do |connection|
152
+ res << connection.to_high(level)
153
+ end
154
+ # Generate the behaviors.
155
+ res << "\n" if self.each_connection.any?
156
+ self.each_behavior do |behavior|
157
+ res << behavior.to_high(level)
158
+ end
159
+ # Close the scope if required.
160
+ if header then
161
+ res << " " * ((level-1)*3) << "end\n"
162
+ end
163
+ # Return the result.
164
+ return res
165
+ end
166
+ end
167
+
168
+
169
+ ## Extends the Type class with generation of HDLRuby::High text.
170
+ class Type
171
+
172
+ # Generates the text of the equivalent HDLRuby::High code.
173
+ # +level+ is the hierachical level of the object.
174
+ def to_high(level = 0)
175
+ return Low2High.high_use_name(self.name)
176
+ end
177
+ end
178
+
179
+ ## Extends the TypeDef class with generation of HDLRuby::High text.
180
+ class TypeDef
181
+
182
+ # Generates the text of the equivalent HDLRuby::High code.
183
+ # +level+ is the hierachical level of the object.
184
+ def to_high(level = 0)
185
+ # Simply generates the redefined type.
186
+ self.def.to_high(level)
187
+ end
188
+ end
189
+
190
+ ## Extends the TypeVector class with generation of HDLRuby::High text.
191
+ class TypeVector
192
+
193
+ # Generates the text of the equivalent HDLRuby::High code.
194
+ # +level+ is the hierachical level of the object.
195
+ def to_high(level = 0)
196
+ # The resulting string.
197
+ res = ""
198
+ # Generate the base.
199
+ res << self.base.to_high(level)
200
+ # Generate the range.
201
+ res << "[" << self.range.first.to_high(level) << ".." <<
202
+ self.range.last.to_high(level) << "]"
203
+ # Return the result.
204
+ return res
205
+ end
206
+ end
207
+
208
+ ## Extends the TypeTuple class with generation of HDLRuby::High text.
209
+ class TypeTuple
210
+
211
+ # Generates the text of the equivalent HDLRuby::High code.
212
+ # +level+ is the hierachical level of the object.
213
+ def to_high(level = 0)
214
+ # The resulting string.
215
+ res = "["
216
+ # Generate each sub type.
217
+ res << self.each_type.map { |type| type.to_high(level) }.join(", ")
218
+ # Close the tuple.
219
+ res << "]"
220
+ # Return the result.
221
+ return res
222
+ end
223
+ end
224
+
225
+ ## Extends the TypeStruct class with generation of HDLRuby::High text.
226
+ class TypeStruct
227
+
228
+ # Generates the text of the equivalent HDLRuby::High code.
229
+ # +level+ is the hierachical level of the object.
230
+ def to_high(level = 0)
231
+ # The resulting string.
232
+ res = "{ "
233
+ # Generate each sub type.
234
+ res << self.each.map do |key,type|
235
+ "#{key}: " + type.to_high(level)
236
+ end.join(", ")
237
+ # Close the struct.
238
+ res << " }"
239
+ # Return the result.
240
+ return res
241
+ end
242
+ end
243
+
244
+
245
+ ## Extends the Behavior class with generation of HDLRuby::High text.
246
+ class Behavior
247
+
248
+ # Generates the text of the equivalent HDLRuby::High code.
249
+ # +level+ is the hierachical level of the object and +timed+
250
+ # tells if the behavior is a time behavior or not.
251
+ def to_high(level = 0,timed = false)
252
+ # The resulting string.
253
+ res = " " * (level*3)
254
+ # Generate the header.
255
+ if timed then
256
+ res << "timed"
257
+ else
258
+ res << self.block.mode.to_s
259
+ end
260
+ if self.each_event.any? then
261
+ res << "( "
262
+ res << self.each_event.map do |event|
263
+ event.to_high(level)
264
+ end.join(", ")
265
+ res << " )"
266
+ end
267
+ res << " do\n"
268
+ # Generate the content.
269
+ res << self.block.to_high(level+1,false)
270
+ # Close the behavior.
271
+ res << " " * (level*3) << "end\n"
272
+ # Return the result.
273
+ return res
274
+ end
275
+ end
276
+
277
+ ## Extends the TimeBehavior class with generation of HDLRuby::High text.
278
+ class TimeBehavior
279
+
280
+ # Generates the text of the equivalent HDLRuby::High code.
281
+ # +level+ is the hierachical level of the object.
282
+ def to_high(level = 0)
283
+ super(level,true)
284
+ end
285
+ end
286
+
287
+
288
+ ## Extends the Event class with generation of HDLRuby::High text.
289
+ class Event
290
+
291
+ # Generates the text of the equivalent HDLRuby::High code.
292
+ # +level+ is the hierachical level of the object.
293
+ def to_high(level = 0)
294
+ return self.ref.to_high(level) + ".#{self.type}"
295
+ end
296
+ end
297
+
298
+
299
+ ## Extends the SignalI class with generation of HDLRuby::High text.
300
+ class SignalI
301
+
302
+ # Generates the text of the equivalent HDLRuby::High code.
303
+ # +level+ is the hierachical level of the object.
304
+ def to_high(level = 0)
305
+ return Low2High.high_use_name(self.name)
306
+ end
307
+ end
308
+
309
+
310
+ ## Extends the SystemI class with generation of HDLRuby::High text.
311
+ class SystemI
312
+
313
+ # Generates the text of the equivalent HDLRuby::High code.
314
+ # +level+ is the hierachical level of the object.
315
+ def to_high(level = 0)
316
+ return Low2High.high_call_name(self.systemT.name,
317
+ ":" + Low2High.high_decl_name(self.name))
318
+ end
319
+ end
320
+
321
+
322
+ ## Extends the Statement class with generation of HDLRuby::High text.
323
+ class Statement
324
+
325
+ # Generates the text of the equivalent HDLRuby::High code.
326
+ # +level+ is the hierachical level of the object.
327
+ def to_high(level = 0)
328
+ # Should never be here.
329
+ raise AnyError, "Internal error: to_high should be implemented in class :#{self.class}"
330
+ end
331
+ end
332
+
333
+ ## Extends the Transmit class with generation of HDLRuby::High text.
334
+ class Transmit
335
+
336
+ # Generates the text of the equivalent HDLRuby::High code.
337
+ # +level+ is the hierachical level of the object.
338
+ def to_high(level = 0)
339
+ return " " * (level*3) +
340
+ self.left.to_high(level) + " <= " +
341
+ self.right.to_high(level) + "\n"
342
+ end
343
+ end
344
+
345
+ ## Extends the If class with generation of HDLRuby::High text.
346
+ class If
347
+
348
+ # Generates the text of the equivalent HDLRuby::High code.
349
+ # +level+ is the hierachical level of the object.
350
+ def to_high(level = 0)
351
+ # The result string.
352
+ res = " " * (level*3)
353
+ # Generate the test.
354
+ res << "hif " << self.condition.to_high(level) << " do\n"
355
+ # Generate the yes part.
356
+ res << self.yes.to_high(level+1)
357
+ res << " " * (level*3) << "end\n"
358
+ # Generate the alternate if parts.
359
+ self.each_noif do |cond,stmnt|
360
+ res << " " * (level*3)
361
+ res << "helsif " << cond.to_high(level) << " do\n"
362
+ res << stmnt.to_high(level+1)
363
+ res << " " * (level*3) << "end\n"
364
+ end
365
+ # Generate the no part if any.
366
+ if self.no then
367
+ res << " " * (level*3)
368
+ res << "helse do\n" << self.no.to_high(level+1)
369
+ res << " " * (level*3) << "end\n"
370
+ end
371
+ # Return the result.
372
+ return res
373
+ end
374
+ end
375
+
376
+ ## Extends the When class with generation of HDLRuby::High text.
377
+ class When
378
+
379
+ # Generates the text of the equivalent HDLRuby::High code.
380
+ # +level+ is the hierachical level of the object.
381
+ def to_high(level = 0)
382
+ # The result string.
383
+ res = " " * (level*3)
384
+ # Generate the match.
385
+ res << "hwhen " << self.match.to_high(level+1) << " do\n"
386
+ # Generate the statement.
387
+ res << self.statement.to_high(level+1)
388
+ # Close the when.
389
+ res << " " * (level*3) << "end\n"
390
+ # Returns the result.
391
+ return res
392
+ end
393
+ end
394
+
395
+ ## Extends the Case class with generation of HDLRuby::High text.
396
+ class Case
397
+
398
+ # Generates the text of the equivalent HDLRuby::High code.
399
+ # +level+ is the hierachical level of the object.
400
+ def to_high(level = 0)
401
+ # The result string.
402
+ res = " " * (level*3)
403
+ # Generate the test.
404
+ res << "hcase " << self.value.to_high(level) << "\n"
405
+ # Generate the whens.
406
+ self.each_when do |w|
407
+ res << w.to_high(level)
408
+ end
409
+ # Generatethe default.
410
+ if self.default then
411
+ res << " " * (level*3)
412
+ res << "helse do\n"
413
+ res << self.default.to_high(level+1)
414
+ res << " " * (level*3)
415
+ res << "end\n"
416
+ end
417
+ # Return the resulting string.
418
+ return res
419
+ end
420
+ end
421
+
422
+
423
+ ## Extends the Delay class with generation of HDLRuby::High text.
424
+ class Delay
425
+
426
+ # Generates the text of the equivalent HDLRuby::High code.
427
+ # +level+ is the hierachical level of the object.
428
+ def to_high(level = 0)
429
+ return self.value.to_high(level) + ".#{self.unit}"
430
+ end
431
+ end
432
+
433
+
434
+ ## Extends the TimeWait class with generation of HDLRuby::High text.
435
+ class TimeWait
436
+
437
+ # Generates the text of the equivalent HDLRuby::High code.
438
+ # +level+ is the hierachical level of the object.
439
+ def to_high(level = 0)
440
+ # The resulting string.
441
+ res = " " * (level*3)
442
+ # Generate the wait.
443
+ res << "wait " << self.delay.to_high(level) << "\n"
444
+ # Return the resulting string.
445
+ return res
446
+ end
447
+ end
448
+
449
+ ## Extends the TimeRepeat class with generation of HDLRuby::High text.
450
+ class TimeRepeat
451
+
452
+ # Generates the text of the equivalent HDLRuby::High code.
453
+ # +level+ is the hierachical level of the object.
454
+ def to_high(level = 0)
455
+ # The resulting string.
456
+ res = " " * (level*3)
457
+ # Generate the header.
458
+ res << "repeat " << self.delay.to_high(level) << " do\n"
459
+ # Generate the statement to repeat.
460
+ res << self.statement.to_high(level+1)
461
+ # Close the repeat.
462
+ res << " " * (level*3) << "end\n"
463
+ # Return the resulting string.
464
+ return res
465
+ end
466
+ end
467
+
468
+ ## Extends the Block class with generation of HDLRuby::High text.
469
+ class Block
470
+
471
+ # Generates the text of the equivalent HDLRuby::High code.
472
+ # +level+ is the hierachical level of the object.
473
+ # +header+ tells if the header is to generate or not.
474
+ # +timed+ tells if its a timed block.
475
+ def to_high(level = 0, header = true, timed = false)
476
+ # The resulting string.
477
+ res = ""
478
+ # Generate the header if required.
479
+ if header then
480
+ if timed then
481
+ res << " " * (level*3) << "timed "
482
+ else
483
+ res << " " * (level*3) << "#{self.mode} "
484
+ end
485
+ unless self.name.empty? then
486
+ res << ":" << Low2High.high_decl_name(self.name) << " "
487
+ end
488
+ res << "do\n"
489
+ end
490
+ level = level + 1 if header
491
+ # Generate the inners declaration.
492
+ self.each_inner do |inner|
493
+ res << " " * (level*3)
494
+ res << inner.type.to_high(level)
495
+ res << ".inner :" << Low2High.high_decl_name(inner.name) << "\n"
496
+ end
497
+ # Generate the statements.
498
+ self.each_statement do |stmnt|
499
+ res << stmnt.to_high(level)
500
+ end
501
+ # Close the block.
502
+ if header then
503
+ res << " " * ((level-1)*3) << "end\n"
504
+ end
505
+ # Return the result.
506
+ return res
507
+ end
508
+ end
509
+
510
+ ## Extends the TimeBlock class with generation of HDLRuby::High text.
511
+ class TimeBlock
512
+
513
+ # Generates the text of the equivalent HDLRuby::High code.
514
+ # +level+ is the hierachical level of the object.
515
+ def to_high(level = 0, header = true)
516
+ super(level,header,true)
517
+ end
518
+ end
519
+
520
+
521
+ ## Extends the Code class with generation of HDLRuby::High text.
522
+ class Code
523
+
524
+ # Generates the text of the equivalent HDLRuby::High code.
525
+ # +level+ is the hierachical level of the object.
526
+ def to_high(level = 0)
527
+ return self.content.to_s
528
+ end
529
+ end
530
+
531
+ ## Extends the Connection class with generation of HDLRuby::High text.
532
+ class Connection
533
+ # Nothing required, Transmit is generated identically.
534
+ end
535
+
536
+
537
+ ## Extends the Expression class with generation of HDLRuby::High text.
538
+ class Expression
539
+
540
+ # Generates the text of the equivalent HDLRuby::High code.
541
+ # +level+ is the hierachical level of the object.
542
+ def to_high(level = 0)
543
+ # Should never be here.
544
+ raise AnyError, "Internal error: to_high should be implemented in class :#{self.class}"
545
+ end
546
+ end
547
+
548
+ ## Extends the Value class with generation of HDLRuby::High text.
549
+ class Value
550
+
551
+ # Generates the text of the equivalent HDLRuby::High code.
552
+ # +level+ is the hierachical level of the object.
553
+ def to_high(level = 0)
554
+ if self.content.is_a?(HDLRuby::BitString) then
555
+ return "_#{self.content}"
556
+ else
557
+ return self.content.to_s
558
+ end
559
+ end
560
+ end
561
+
562
+ ## Extends the Cast class with generation of HDLRuby::High text.
563
+ class Cast
564
+
565
+ # Generates the text of the equivalent HDLRuby::High code.
566
+ # +level+ is the hierachical level of the object.
567
+ def to_high(level = 0)
568
+ return self.child.to_high(level) +
569
+ ".cast(" + self.type.to_high(level) + ")"
570
+ end
571
+ end
572
+
573
+ ## Extends the Operation class with generation of HDLRuby::High text.
574
+ class Operation
575
+
576
+ # Generates the text of the equivalent HDLRuby::High code.
577
+ # +level+ is the hierachical level of the object.
578
+ def to_high(level = 0)
579
+ # Should never be here.
580
+ raise AnyError, "Internal error: to_high should be implemented in class :#{self.class}"
581
+ end
582
+ end
583
+
584
+ ## Extends the Unary class with generation of HDLRuby::High text.
585
+ class Unary
586
+
587
+ # Generates the text of the equivalent HDLRuby::High code.
588
+ # +level+ is the hierachical level of the object.
589
+ def to_high(level = 0)
590
+ return "(#{self.operator.to_s[0]}" + self.child.to_high(level) + ")"
591
+ end
592
+ end
593
+
594
+ ## Extends the Binary class with generation of HDLRuby::High text.
595
+ class Binary
596
+
597
+ # Generates the text of the equivalent HDLRuby::High code.
598
+ # +level+ is the hierachical level of the object.
599
+ def to_high(level = 0)
600
+ return "(" + self.left.to_high(level) + self.operator.to_s +
601
+ self.right.to_high(level) + ")"
602
+ end
603
+ end
604
+
605
+ ## Extends the Select class with generation of HDLRuby::High text.
606
+ class Select
607
+
608
+ # Generates the text of the equivalent HDLRuby::High code.
609
+ # +level+ is the hierachical level of the object.
610
+ def to_high(level = 0)
611
+ # The resulting string.
612
+ res = ""
613
+ # Generate the header.
614
+ res << "mux(" + self.select.to_high(level) << ", "
615
+ # Generate the choices
616
+ res << self.each_choice.map do |choice|
617
+ choice.to_high(level+1)
618
+ end.join(", ")
619
+ # Close the select.
620
+ res << ")"
621
+ # Return the resulting string.
622
+ return res
623
+ end
624
+ end
625
+
626
+ ## Extends the Concat class with generation of HDLRuby::High text.
627
+ class Concat
628
+
629
+ # Generates the text of the equivalent HDLRuby::High code.
630
+ # +level+ is the hierachical level of the object.
631
+ def to_high(level = 0)
632
+ # The resulting string.
633
+ res = ""
634
+ # Generate the header.
635
+ res << "[ "
636
+ # Generate the expressions.
637
+ res << self.each_expression.map do |expression|
638
+ expression.to_high(level+1)
639
+ end.join(", ")
640
+ # Close the select.
641
+ res << " ]"
642
+ # Return the resulting string.
643
+ return res
644
+ end
645
+ end
646
+
647
+
648
+ ## Extends the Ref class with generation of HDLRuby::High text.
649
+ class Ref
650
+
651
+ # Generates the text of the equivalent HDLRuby::High code.
652
+ # +level+ is the hierachical level of the object.
653
+ def to_high(level = 0)
654
+ # Should never be here.
655
+ raise AnyError, "Internal error: to_high should be implemented in class :#{self.class}"
656
+ end
657
+ end
658
+
659
+ ## Extends the RefConcat class with generation of HDLRuby::High text.
660
+ class RefConcat
661
+
662
+ # Generates the text of the equivalent HDLRuby::High code.
663
+ # +level+ is the hierachical level of the object.
664
+ def to_high(level = 0)
665
+ # The resulting string.
666
+ res = ""
667
+ # Generate the header.
668
+ res << "[ "
669
+ # Generate the references.
670
+ res << self.each_ref.map do |ref|
671
+ ref.to_high(level+1)
672
+ end.join(", ")
673
+ # Close the select.
674
+ res << " ]"
675
+ # Return the resulting string.
676
+ return res
677
+ end
678
+ end
679
+
680
+ ## Extends the RefIndex class with generation of HDLRuby::High text.
681
+ class RefIndex
682
+
683
+ # Generates the text of the equivalent HDLRuby::High code.
684
+ # +level+ is the hierachical level of the object.
685
+ def to_high(level = 0)
686
+ return self.ref.to_high(level) + "[#{self.index.to_high(level)}]"
687
+ end
688
+ end
689
+
690
+ ## Extends the RefRange class with generation of HDLRuby::High text.
691
+ class RefRange
692
+
693
+ # Generates the text of the equivalent HDLRuby::High code.
694
+ # +level+ is the hierachical level of the object.
695
+ def to_high(level = 0)
696
+ return self.ref.to_high(level) +
697
+ "[(#{self.range.first.to_high(level)})..(#{self.range.last.to_high(level)})]"
698
+ end
699
+ end
700
+
701
+ ## Extends the RefName class with generation of HDLRuby::High text.
702
+ class RefName
703
+
704
+ # Generates the text of the equivalent HDLRuby::High code.
705
+ # +level+ is the hierachical level of the object.
706
+ def to_high(level = 0)
707
+ # The resulting string.
708
+ res = ""
709
+ # Generates the sub reference if any.
710
+ res << self.ref.to_high(level) << "." unless self.ref.is_a?(RefThis)
711
+ # Generates the current reference.
712
+ res << Low2High.high_use_name(self.name)
713
+ # Returns the resulting string.
714
+ return res
715
+ end
716
+ end
717
+
718
+ ## Extends the RefThis class with generation of HDLRuby::High text.
719
+ class RefThis
720
+
721
+ # Generates the text of the equivalent HDLRuby::High code.
722
+ # +level+ is the hierachical level of the object.
723
+ def to_high(level = 0)
724
+ return ""
725
+ end
726
+ end
727
+
728
+ ## Extends the Numeric class with generation of HDLRuby::High text.
729
+ class ::Numeric
730
+
731
+ # Generates the text of the equivalent HDLRuby::High code.
732
+ # +level+ is the hierachical level of the object.
733
+ def to_high(level = 0)
734
+ return self.to_s
735
+ end
736
+ end
737
+
738
+ end