HDLRuby 2.11.12 → 3.1.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.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/README.html +3274 -0
  3. data/README.md +660 -128
  4. data/ext/hruby_sim/hruby_sim_calc.c +2 -0
  5. data/lib/HDLRuby/backend/hruby_allocator.rb +2 -2
  6. data/lib/HDLRuby/backend/hruby_c_allocator.rb +7 -7
  7. data/lib/HDLRuby/hdr_samples/constant_in_function.rb +2 -1
  8. data/lib/HDLRuby/hdr_samples/mei8_bench.rb +1 -1
  9. data/lib/HDLRuby/hdr_samples/with_bram.rb +3 -3
  10. data/lib/HDLRuby/hdr_samples/with_bram_frame_stack.rb +105 -0
  11. data/lib/HDLRuby/hdr_samples/with_bram_stack.rb +69 -0
  12. data/lib/HDLRuby/hdr_samples/with_ref_expr.rb +30 -0
  13. data/lib/HDLRuby/hdr_samples/with_sequencer.rb +185 -0
  14. data/lib/HDLRuby/hdr_samples/with_sequencer_deep.rb +91 -0
  15. data/lib/HDLRuby/hdr_samples/with_sequencer_enumerable.rb +439 -0
  16. data/lib/HDLRuby/hdr_samples/with_sequencer_enumerator.rb +89 -0
  17. data/lib/HDLRuby/hdr_samples/with_sequencer_func.rb +63 -0
  18. data/lib/HDLRuby/hdr_samples/with_sequencer_sync.rb +120 -0
  19. data/lib/HDLRuby/hdrcc.rb +16 -3
  20. data/lib/HDLRuby/hdrlib.rb +1 -1
  21. data/lib/HDLRuby/hruby_db.rb +2 -2
  22. data/lib/HDLRuby/hruby_high.rb +61 -25
  23. data/lib/HDLRuby/hruby_high_fullname.rb +3 -1
  24. data/lib/HDLRuby/hruby_low.rb +2 -2
  25. data/lib/HDLRuby/hruby_low2c.rb +58 -43
  26. data/lib/HDLRuby/hruby_low2hdr.rb +66 -40
  27. data/lib/HDLRuby/hruby_low2high.rb +86 -44
  28. data/lib/HDLRuby/hruby_low2seq.rb +26 -18
  29. data/lib/HDLRuby/hruby_low2sym.rb +14 -13
  30. data/lib/HDLRuby/hruby_low2vhd.rb +78 -43
  31. data/lib/HDLRuby/hruby_low_bool2select.rb +61 -46
  32. data/lib/HDLRuby/hruby_low_casts_without_expression.rb +56 -44
  33. data/lib/HDLRuby/hruby_low_cleanup.rb +18 -16
  34. data/lib/HDLRuby/hruby_low_fix_types.rb +64 -32
  35. data/lib/HDLRuby/hruby_low_mutable.rb +53 -118
  36. data/lib/HDLRuby/hruby_low_resolve.rb +26 -31
  37. data/lib/HDLRuby/hruby_low_with_bool.rb +33 -16
  38. data/lib/HDLRuby/hruby_low_with_port.rb +3 -3
  39. data/lib/HDLRuby/hruby_low_with_var.rb +23 -9
  40. data/lib/HDLRuby/hruby_low_without_concat.rb +19 -13
  41. data/lib/HDLRuby/hruby_low_without_namespace.rb +47 -32
  42. data/lib/HDLRuby/hruby_low_without_parinseq.rb +18 -12
  43. data/lib/HDLRuby/hruby_low_without_select.rb +36 -23
  44. data/lib/HDLRuby/hruby_low_without_subsignals.rb +79 -39
  45. data/lib/HDLRuby/hruby_rcsim.rb +79 -64
  46. data/lib/HDLRuby/hruby_rsim.rb +64 -15
  47. data/lib/HDLRuby/hruby_rsim_mute.rb +2 -3
  48. data/lib/HDLRuby/hruby_rsim_vcd.rb +28 -25
  49. data/lib/HDLRuby/hruby_types.rb +5 -5
  50. data/lib/HDLRuby/hruby_values.rb +19 -8
  51. data/lib/HDLRuby/hruby_verilog.rb +191 -65
  52. data/lib/HDLRuby/hruby_verilog_name.rb +49 -42
  53. data/lib/HDLRuby/soft/stacks.rb +219 -0
  54. data/lib/HDLRuby/std/bram.rb +9 -5
  55. data/lib/HDLRuby/std/clocks.rb +1 -1
  56. data/lib/HDLRuby/std/fsm.rb +39 -10
  57. data/lib/HDLRuby/std/sequencer.rb +2085 -0
  58. data/lib/HDLRuby/std/sequencer_func.rb +533 -0
  59. data/lib/HDLRuby/std/sequencer_sync.rb +400 -0
  60. data/lib/HDLRuby/std/std.rb +13 -0
  61. data/lib/HDLRuby/version.rb +1 -1
  62. data/tuto/adder_sat_flags_vcd.png +0 -0
  63. data/tuto/addsub_vcd.png +0 -0
  64. data/tuto/alu_vcd.png +0 -0
  65. data/tuto/bit_pong_vcd.png +0 -0
  66. data/tuto/checksum_vcd.png +0 -0
  67. data/tuto/circuit_hdr.odg +0 -0
  68. data/tuto/circuit_hdr.png +0 -0
  69. data/tuto/circuit_hie.odg +0 -0
  70. data/tuto/circuit_hie.png +0 -0
  71. data/tuto/circuit_view.odg +0 -0
  72. data/tuto/circuit_view.png +0 -0
  73. data/tuto/clock_counter_vcd.png +0 -0
  74. data/tuto/counter_ext_vcd.png +0 -0
  75. data/tuto/fact_vcd.png +0 -0
  76. data/tuto/hw_flow.odg +0 -0
  77. data/tuto/hw_flow.png +0 -0
  78. data/tuto/maxxer_vcd.png +0 -0
  79. data/tuto/pingpong0_vcd.png +0 -0
  80. data/tuto/pingpong1_vcd.png +0 -0
  81. data/tuto/pingpong2_vcd.png +0 -0
  82. data/tuto/ram_vcd.png +0 -0
  83. data/tuto/serializer_vcd.png +0 -0
  84. data/tuto/sw_flow.odg +0 -0
  85. data/tuto/sw_flow.png +0 -0
  86. data/tuto/the_counter_vcd.png +0 -0
  87. data/tuto/tutorial_sw.html +2359 -0
  88. data/tuto/tutorial_sw.md +2890 -0
  89. data/tuto/tutorial_sw.pdf +0 -0
  90. data/tuto/tutorial_sw_jp.md +417 -0
  91. metadata +46 -2
@@ -4,10 +4,8 @@ require "HDLRuby/hruby_verilog_name.rb"
4
4
  require 'HDLRuby/hruby_low_mutable'
5
5
 
6
6
 
7
- # module HDLRuby::Verilog
8
7
  include HDLRuby::Verilog
9
8
 
10
- #include HDLRuby::Low
11
9
  module HDLRuby::Low
12
10
 
13
11
 
@@ -38,12 +36,16 @@ module HDLRuby::Low
38
36
  $vector_reg = "" # For storing signal type at structure declaration. (temporary)
39
37
  $vector_cnt = 0 # For allocating numbers at structure declaration. (temporary)
40
38
 
39
+
41
40
  class ::Integer
41
+ ## Extends the Integer class with generation of verilog text.
42
+
42
43
  def to_verilog
43
44
  to_s
44
45
  end
45
46
  end
46
47
 
48
+
47
49
  # Class summarizing "hash" used for "par" or "seq" conversion.
48
50
  class Fm
49
51
  attr_reader :fm_seq, :fm_par, :rep, :rep_sharp
@@ -87,10 +89,10 @@ module HDLRuby::Low
87
89
  # Convert the ranges to arrays.
88
90
  rngI,rngS = self.r2a(rngI), self.r2a(rngS)
89
91
  # Generate the name.
90
- return "trunc_#{rngI[0]}_#{rngI[1]}_#{rngS[0]}_#{rngS[1]}"
92
+ return "truncer_#{rngI[0]}_#{rngI[1]}_#{rngS[0]}_#{rngS[1]}"
91
93
  end
92
94
 
93
- # Generate the truncating functionds.
95
+ # Generate the truncating functions.
94
96
  def dump
95
97
  # Ensure there is only one truncating function per range.
96
98
  @truncers.sort!.uniq!
@@ -115,8 +117,56 @@ module HDLRuby::Low
115
117
  TruncersI = Truncers.new
116
118
 
117
119
 
118
- # A class that translates the left-hand side, operator, and right-hand side into form of expression.
120
+ # Class for generating the truncating functions in verilog.
121
+ # Such function are necessary as expression cannot be truncated directly.
122
+ class Indexers
123
+ def initialize
124
+ @indexers = []
125
+ end
126
+
127
+ # Add an indexer to of expression of verilog type +typI+ returning
128
+ # verilog type +typR+.
129
+ def add(typI,typR)
130
+ # Add them
131
+ @indexers << [typI,typR]
132
+ end
133
+ alias_method :<<, :add
134
+
135
+
136
+ # Generate an indexer function name for expression of verilog type
137
+ # +typI+ returning verilog type +typR+.
138
+ def indexer_name(typI,typR)
139
+ # Generate the name.
140
+ return "indexer_#{name_to_verilog(typI)}_#{name_to_verilog(typR)}"
141
+ end
142
+
143
+ # Generate the indexing functions.
144
+ def dump
145
+ # Ensure there is only one indexing function per range.
146
+ @indexers.sort!.uniq!
147
+ # Generate the resulting code.
148
+ codeT = ""
149
+ @indexers.each do |(typI,typR)|
150
+ codeT << " function #{typR} "
151
+ codeT << self.indexer_name(typI,typR)
152
+ codeT << "(input #{typI} val, input integer idx);\n"
153
+ codeT << " " << self.indexer_name(typI,typR) << " = "
154
+ codeT << "val[idx];\n"
155
+ codeT << " endfunction\n\n"
156
+ end
157
+ # Clears the indexers.
158
+ @indexers = []
159
+ return codeT
160
+ end
161
+ end
162
+
163
+ # Declaration of the truncating function generator.
164
+ IndexersI = Indexers.new
165
+
166
+
119
167
  class Binary
168
+ ## Enhances Binary with verilog generation.
169
+
120
170
  # Converts the system to Verilog code.
121
171
  def to_verilog
122
172
  return "(#{self.left.to_verilog} #{self.operator} #{self.right.to_verilog})"
@@ -158,9 +208,10 @@ module HDLRuby::Low
158
208
  end
159
209
  end
160
210
 
161
- # class of Represent blocking substitution or nonblocking assignment.
162
- # Enhance Transmit with generation of verilog code.
211
+
163
212
  class Transmit
213
+ ## Enhances Transmit with generation of verilog code.
214
+
164
215
  # Converts the system to Verilog code.
165
216
  def to_verilog(spc = 3)
166
217
  # Determine blocking assignment or nonblocking substitution from mode and return it.
@@ -169,8 +220,10 @@ module HDLRuby::Low
169
220
  end
170
221
  end
171
222
 
172
- # Enhance Print with generation of verilog code.
223
+
173
224
  class Print
225
+ ## Enhances Print with generation of verilog code.
226
+
174
227
  # Converts the print to Verilog code.
175
228
  def to_verilog(spc = 3)
176
229
  code = "#{" " * spc}$write(#{self.each_arg.map do |arg|
@@ -180,17 +233,20 @@ module HDLRuby::Low
180
233
  end
181
234
  end
182
235
 
183
- # Enhance TimeTerminate with generation of verilog code.
236
+
184
237
  class TimeTerminate
238
+ ## Enhances TimeTerminate with generation of verilog code.
239
+
185
240
  # Converts the terminate to Verilog code.
186
241
  def to_verilog(spc = 3)
187
242
  return "#{" " * spc}$finish;"
188
243
  end
189
244
  end
190
245
 
191
- # To scheduling to the Block.
192
- # Enhance Block with generation of verilog code.
246
+
193
247
  class Block
248
+ ## Enhances Block with generation of verilog code.
249
+ # To scheduling to the Block.
194
250
 
195
251
  # Converts the system to Verilog code adding 'spc' spaces at the begining
196
252
  # of each line.
@@ -1439,9 +1495,10 @@ module HDLRuby::Low
1439
1495
  end
1440
1496
  end
1441
1497
 
1442
- # Used to display variable names.
1443
- # Enhance RefName with generation of verilog code.
1498
+
1444
1499
  class RefName
1500
+ ## Enhances RefName with generation of verilog code.
1501
+
1445
1502
  # Converts the system to Verilog code using +renamer+ for producing Verilog-compatible names.
1446
1503
  def to_verilog
1447
1504
  vname = name_to_verilog(self.name)
@@ -1463,19 +1520,29 @@ module HDLRuby::Low
1463
1520
  end
1464
1521
  end
1465
1522
 
1466
- # Used to convert an array.
1467
- # Enhance RefIndex with generation of verilog code.
1523
+
1468
1524
  class RefIndex
1525
+ ## Enhances RefIndex with generation of verilog code.
1526
+
1469
1527
  # Converts the system to Verilog code.
1470
1528
  def to_verilog
1471
- return "#{self.ref.to_verilog}[#{self.index.to_verilog}]"
1529
+ # return "#{self.ref.to_verilog}[#{self.index.to_verilog}]"
1530
+ if self.ref.is_a?(RefName) then
1531
+ return "#{self.ref.to_verilog}[#{self.index.to_verilog}]"
1532
+ else
1533
+ # No a pure signal, need to use a function for accessing.
1534
+ at = self.ref.type.to_verilog
1535
+ rt = self.type.to_verilog
1536
+ IndexersI.add(at,rt)
1537
+ return "#{IndexersI.indexer_name(at,rt)}(#{self.ref.to_verilog},#{self.index.to_verilog})"
1538
+ end
1472
1539
  end
1473
1540
  end
1474
1541
 
1475
1542
 
1476
- # Used to indicate the number of bits.
1477
- # Enhance TypeVector with generation of verilog code.
1478
1543
  class TypeVector
1544
+ ## Enhances TypeVector with generation of verilog code.
1545
+
1479
1546
  # Converts the system to Verilog code.
1480
1547
  def to_verilog
1481
1548
  # if self.base.name.to_s != "bit"
@@ -1486,16 +1553,30 @@ module HDLRuby::Low
1486
1553
  end
1487
1554
  end
1488
1555
 
1489
- # Necessary for displaying bit width (eg, specify and assign).
1556
+
1490
1557
  class RefRange
1558
+ ## Enhances RefRange with generation of verilog code.
1559
+
1560
+ # Necessary for displaying bit width (eg, specify and assign).
1561
+
1491
1562
  # Converts the system to Verilog code.
1492
1563
  def to_verilog(unknown = false)
1493
- return "#{self.ref.to_verilog}[#{self.range.first.to_getrange}:#{self.range.last.to_getrange}]"
1564
+ if self.ref.is_a?(RefName) then
1565
+ return "#{self.ref.to_verilog}[#{self.range.first.to_getrange}:#{self.range.last.to_getrange}]"
1566
+ else
1567
+ # No a pure signal, need to use a function for accessing.
1568
+ sr = self.range.first.to_i..self.range.last.to_i
1569
+ cr = (self.type.width-1)..0
1570
+ TruncersI.add(cr,sr)
1571
+ return "#{TruncersI.truncer_name(cr,sr)}(#{self.ref.to_verilog})"
1572
+ end
1494
1573
  end
1495
1574
  end
1496
1575
 
1497
- # Use it when collecting references.
1576
+
1498
1577
  class RefConcat
1578
+ ## Enhances RefConcat with generation of verilog code.
1579
+
1499
1580
  def to_verilog
1500
1581
  ref = self.each_ref.to_a
1501
1582
 
@@ -1509,18 +1590,20 @@ module HDLRuby::Low
1509
1590
  end
1510
1591
  end
1511
1592
 
1512
- # Used to output bitstring.
1513
- # Enhance HDLRuby with generation of verilog code.
1593
+
1514
1594
  class HDLRuby::BitString
1595
+ ## Enhances BitString with generation of verilog code.
1596
+
1515
1597
  # Converts the system to Verilog code.
1516
1598
  def to_verilog
1517
1599
  return "#{self.to_s}"
1518
1600
  end
1519
1601
  end
1520
1602
 
1521
- # Used for connection using choice.
1522
- # Enhance Select with generation of verilog code.
1603
+
1523
1604
  class Select
1605
+ ## Enhances Select with generation of verilog code.
1606
+
1524
1607
  # Converts the system to Verilog code.
1525
1608
  def to_verilog
1526
1609
  # Outputs the first and second choices (choice (0) and choice (1)).
@@ -1535,9 +1618,10 @@ module HDLRuby::Low
1535
1618
  end
1536
1619
  end
1537
1620
 
1538
- # Used to output numbers.
1539
- # Enhance Value with generation of verilog code.
1621
+
1540
1622
  class Value
1623
+ ## Enhances Value with generation of verilog code.
1624
+
1541
1625
  # Converts the system to Verilog code.
1542
1626
  # If it is bit, it is b, and if it is int, it is represented by d. (Example: 4'b0000, 32'd1)
1543
1627
  def to_verilog(unknown = nil)
@@ -1556,20 +1640,28 @@ module HDLRuby::Low
1556
1640
  # end
1557
1641
  # return "#{self.type.range.first + 1}'b#{self.content.to_verilog}"
1558
1642
  if self.content.is_a?(Numeric) then
1559
- if self.content < 0 then
1560
- # str = (2**self.type.width + self.content).to_s(2)
1561
- str = self.content.to_s(2)
1562
- str = "0" * (self.type.width-str.length+1) + str[1..-1]
1563
- return "-#{self.type.width}'b#{str}"
1643
+ if self.type.signed? then
1644
+ if self.content < 0 then
1645
+ # str = (2**self.type.width + self.content).to_s(2)
1646
+ str = self.content.to_s(2)
1647
+ str = "0" * (self.type.width-str.length+1) + str[1..-1]
1648
+ return "-#{self.type.width}'sb#{str}"
1649
+ else
1650
+ str = self.content.to_s(2)
1651
+ str = "0" * (self.type.width-str.length) + str
1652
+ return "#{self.type.width}'sb#{str}"
1653
+ end
1564
1654
  else
1565
- str = self.content.to_s(2)
1566
- str = "0" * (self.type.width-str.length) + str
1567
- return "#{self.type.width}'b#{str}"
1655
+ return "#{self.type.width}'b#{self.content.to_s(2)}"
1568
1656
  end
1569
1657
  # return "#{self.type.width}'b#{str}"
1570
1658
  else
1571
1659
  str = self.content.to_verilog
1572
- return "#{str.length}'b#{str}"
1660
+ if self.content.negative? then
1661
+ return "#{str.length}'sb#{str}"
1662
+ else
1663
+ return "#{str.length}'b#{str}"
1664
+ end
1573
1665
  end
1574
1666
  end
1575
1667
  # How to use when simply obtaining the width
@@ -1579,9 +1671,9 @@ module HDLRuby::Low
1579
1671
  end
1580
1672
 
1581
1673
 
1582
- # Used to transrate if.
1583
- # Enhance If with generation of verilog code.
1584
1674
  class If
1675
+ ## Enhances If with generation of verilog code.
1676
+
1585
1677
  # # Converts the system to Verilog code.
1586
1678
  # def to_verilog(mode = nil)
1587
1679
  # Converts to Verilog code, checking adding 'spc' spaces at the begining
@@ -1617,10 +1709,10 @@ module HDLRuby::Low
1617
1709
  end
1618
1710
  end
1619
1711
 
1620
- # Used to translate case
1712
+
1621
1713
  class Case
1622
- # def to_verilog(mode = nil)
1623
- #
1714
+ ## Enhances Case with generation of verilog code.
1715
+
1624
1716
  # Converts to Verilog code, checking if variables are register
1625
1717
  # or wire adding 'spc' spaces at the begining of each line.
1626
1718
  def to_verilog(spc = 3)
@@ -1656,9 +1748,10 @@ module HDLRuby::Low
1656
1748
  end
1657
1749
  end
1658
1750
 
1659
- # Translate expression of combination circuit.
1660
- # Enhance Connection with generation of verilog code.
1751
+
1661
1752
  class Connection
1753
+ ## Enhances Connection with generation of verilog code.
1754
+
1662
1755
  # Converts the system to Verilog code.
1663
1756
 
1664
1757
  # Method used for array.
@@ -1715,23 +1808,29 @@ module HDLRuby::Low
1715
1808
  end
1716
1809
  end
1717
1810
 
1718
- # It could be used for instantiation.
1811
+
1719
1812
  class RefThis
1813
+ ## Enhances RefThis with generation of verilog code.
1814
+
1720
1815
  def to_another_verilog
1721
1816
  return ""
1722
1817
  end
1723
1818
  end
1724
1819
 
1725
- # Used when using "~" for expressions.
1820
+
1726
1821
  class Unary
1822
+ ## Enhances Unary with generation of verilog code.
1823
+
1727
1824
  # Converts the system to Verilog code.
1728
1825
  def to_verilog
1729
1826
  return "#{self.operator[0]}#{self.child.to_verilog}"
1730
1827
  end
1731
1828
  end
1732
1829
 
1733
- # Used when casting expressions.
1830
+
1734
1831
  class Cast
1832
+ ## Enhances Cast with generation of verilog code.
1833
+
1735
1834
  # Converts the system to Verilog code.
1736
1835
  # NOTE: the cast is rounded up size bit-width cast is not supported
1737
1836
  # by traditional verilog.
@@ -1743,10 +1842,20 @@ module HDLRuby::Low
1743
1842
  cw = self.child.type.width
1744
1843
  sw = self.type.width
1745
1844
  if self.type.signed? then
1746
- if (sw>cw) then
1747
- # Need to sign extend.
1748
- return "$signed({{#{sw-cw}{#{self.child.to_verilog}[#{cw-1}]}}," +
1749
- "#{self.child.to_verilog}})"
1845
+ # Need to sign extend.
1846
+ if cw == 1 then
1847
+ return "$signed({#{sw}{#{self.child.to_verilog}}})"
1848
+ elsif (sw>cw) then
1849
+ # return "$signed({{#{sw-cw}{#{self.child.to_verilog}[#{cw-1}]}}," + "#{self.child.to_verilog}})"
1850
+ if self.child.is_a?(RefName) then
1851
+ return "$signed({{#{sw-cw}{#{self.child.to_verilog}[#{cw-1}]}}," + "#{self.child.to_verilog}})"
1852
+ else
1853
+ # No a pure signal, need to use a function for accessing.
1854
+ at = self.child.type.to_verilog
1855
+ rt = bit.to_verilog
1856
+ IndexersI.add(at,rt)
1857
+ return "$signed({{#{sw-cw}{#{IndexersI.indexer_name(at,rt)}(#{self.child.to_verilog},#{cw-1})}}," + "#{self.child.to_verilog}})"
1858
+ end
1750
1859
  elsif (sw<cw) then
1751
1860
  # Need to truncate
1752
1861
  # return "$signed(#{self.child.to_verilog}[#{sw-1}:0])"
@@ -1773,9 +1882,10 @@ module HDLRuby::Low
1773
1882
  end
1774
1883
  end
1775
1884
 
1776
- # For declaring variables.
1777
- # Enhance SignalI with generation of verilog code.
1885
+
1778
1886
  class SignalI
1887
+ ## Enhances SignalI with generation of verilog code.
1888
+
1779
1889
  # Converts the system to Verilog code.
1780
1890
  def to_verilog
1781
1891
  # Convert unusable characters and return them.
@@ -1785,25 +1895,30 @@ module HDLRuby::Low
1785
1895
  end
1786
1896
  end
1787
1897
 
1788
- # If it is signed, it outputs signed.
1789
- # Enhance Type with generation of verilog code.
1898
+
1790
1899
  class Type
1900
+ ## Enhances Type with generation of verilog code.
1901
+
1791
1902
  # Converts the type to Verilog code.
1792
1903
  def to_verilog
1793
1904
  return self.name == :signed ? "#{self.name.to_s} " : ""
1794
1905
  end
1795
1906
  end
1796
1907
 
1797
- # Replace type by refered type.
1908
+
1798
1909
  class TypeDef
1910
+ ## Enhances TypeDef with generation of verilog code.
1911
+
1799
1912
  # Converts the type to verilog code.
1800
1913
  def to_verilog
1801
1914
  return self.def.to_verilog
1802
1915
  end
1803
1916
  end
1804
1917
 
1805
- # Use it when collecting.
1918
+
1806
1919
  class Concat
1920
+ ## Enhances Concat with generation of verilog code.
1921
+
1807
1922
  def to_verilog
1808
1923
  expression = self.each_expression.to_a
1809
1924
 
@@ -1817,14 +1932,19 @@ module HDLRuby::Low
1817
1932
  end
1818
1933
  end
1819
1934
 
1820
- # Look at the unit of time, convert the time to ps and output it.
1821
- # One of two people, TimeWait and Delay.
1935
+
1822
1936
  class TimeWait
1937
+ ## Enhances TimeWait with generation of verilog code.
1938
+
1823
1939
  def to_verilog(spc = 3)
1824
1940
  return (" " * spc) + self.delay.to_verilog + "\n"
1825
1941
  end
1826
1942
  end
1943
+
1944
+
1827
1945
  class Delay
1946
+ ## Enhances Delay with generation of verilog code.
1947
+
1828
1948
  def to_verilog
1829
1949
  time = self.value.to_s
1830
1950
  if(self.unit.to_s == "ps") then
@@ -1842,8 +1962,9 @@ module HDLRuby::Low
1842
1962
  end
1843
1963
 
1844
1964
 
1845
- # Generate verilog code for the TimeRepeat.
1846
1965
  class TimeRepeat
1966
+ ## Enhances TimeRepeat with generation of verilog code.
1967
+
1847
1968
  def to_verilog(spc = 3)
1848
1969
  result = (" " * spc) + "repeat(#{self.number})" + "\n"
1849
1970
  result << self.statement.to_verilog(spc+3)
@@ -1855,8 +1976,9 @@ module HDLRuby::Low
1855
1976
  #class TypeTuple
1856
1977
  #class Event
1857
1978
 
1858
- # Enhance SystemT with generation of verilog code.
1979
+
1859
1980
  class SystemT
1981
+ ## Enhances SystemT with generation of verilog code.
1860
1982
 
1861
1983
  ## Tells if a connection is actually a port connection.
1862
1984
  def port_output_connection?(connection)
@@ -2163,9 +2285,10 @@ module HDLRuby::Low
2163
2285
  codeC << "),"
2164
2286
  end
2165
2287
  end
2166
- # Remove the last "," for conforming with Verilog syntax.
2167
- # and close the port connection.
2168
- codeC[-1] = ");\n"
2288
+ # Remove the last "," if any for conforming with Verilog syntax.
2289
+ codeC.chop! if codeC[-1] == ","
2290
+ # And close the port connection.
2291
+ codeC << ");\n"
2169
2292
  end
2170
2293
 
2171
2294
 
@@ -2247,6 +2370,8 @@ module HDLRuby::Low
2247
2370
 
2248
2371
  # Adds the truncing functions.
2249
2372
  code << TruncersI.dump
2373
+ # Adds the indexing functions.
2374
+ code << IndexersI.dump
2250
2375
  # Adds the content code.
2251
2376
  code << codeC
2252
2377
  return code
@@ -2254,8 +2379,9 @@ module HDLRuby::Low
2254
2379
  end
2255
2380
 
2256
2381
 
2257
- # Enhance StringE with generation of verilog code.
2258
2382
  class StringE
2383
+ ## Enhances stringE with generation of verilog code.
2384
+
2259
2385
  # Converts the system to Verilog code.
2260
2386
  def to_verilog(spc = 3)
2261
2387
  code = "\"#{Low.v_string(self.content)}" +
@@ -2270,8 +2396,8 @@ end
2270
2396
 
2271
2397
 
2272
2398
 
2273
- ## Extends the Numeric class with generation of verilog text.
2274
2399
  class ::Numeric
2400
+ ## Extends the Numeric class with generation of verilog text.
2275
2401
 
2276
2402
  # Generates the text of the equivalent verilog code.
2277
2403
  # +level+ is the hierachical level of the object.
@@ -1,42 +1,49 @@
1
- # Program with inverse conversion
2
- # last update 2019 01 29
3
-
4
- module HDLRuby::Verilog
5
-
6
- # This is sample.
7
- # n = "abc_ABC_いろは"
8
- # puts n
9
- # name = n.split("")
10
-
11
- @@hdr2verilog = {}
12
-
13
- # Since it is possible to use $ and numbers other than the beginning of the character string, it is divided.
14
- def name_to_verilog(name)
15
- # name = name.to_s
16
- # # Convert special characters.
17
- # name = name.each_char.map do |c|
18
- # if c=~ /[a-z0-9]/ then
19
- # c
20
- # elsif c == "_" then
21
- # "__"
22
- # else
23
- # "_" + c.ord.to_s
24
- # end
25
- # end.join
26
- # # First character: only letter is possible.
27
- # unless name[0] =~ /[a-z_]/ then
28
- # name = "_" + name
29
- # end
30
- # return name
31
- name = name.to_s
32
- vname = @@hdr2verilog[name]
33
- unless vname then
34
- vname = "_v#{@@hdr2verilog.size}_#{name.split(/[^a-zA-Z_0-9]/)[-1]}"
35
- @@hdr2verilog[name] = vname
36
- end
37
- return vname
38
- end
39
-
40
- #puts ref
41
-
42
- end
1
+ # Program with inverse conversion
2
+ # last update 2019 01 29
3
+
4
+ module HDLRuby::Verilog
5
+
6
+ # This is sample.
7
+ # n = "abc_ABC_いろは"
8
+ # puts n
9
+ # name = n.split("")
10
+
11
+ @@hdr2verilog = {}
12
+
13
+ # Since it is possible to use $ and numbers other than the beginning of the character string, it is divided.
14
+ def name_to_verilog(name)
15
+ # name = name.to_s
16
+ # # Convert special characters.
17
+ # name = name.each_char.map do |c|
18
+ # if c=~ /[a-z0-9]/ then
19
+ # c
20
+ # elsif c == "_" then
21
+ # "__"
22
+ # else
23
+ # "_" + c.ord.to_s
24
+ # end
25
+ # end.join
26
+ # # First character: only letter is possible.
27
+ # unless name[0] =~ /[a-z_]/ then
28
+ # name = "_" + name
29
+ # end
30
+ # return name
31
+ name = name.to_s
32
+ vname = @@hdr2verilog[name]
33
+ unless vname then
34
+ # Shall we change the string?
35
+ if name.match?(/^[_a-zA-Z][_a-zA-Z0-9]*$/) then
36
+ # No, just clone
37
+ vname = name.clone
38
+ else
39
+ # Yes, ensure it is a verilog-compatible name.
40
+ vname = "_v#{@@hdr2verilog.size}_#{name.split(/[^a-zA-Z_0-9]/)[-1]}"
41
+ end
42
+ @@hdr2verilog[name] = vname
43
+ end
44
+ return vname
45
+ end
46
+
47
+ #puts ref
48
+
49
+ end