HDLRuby 2.11.11 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.html +3274 -0
- data/README.md +608 -99
- data/ext/hruby_sim/hruby_rcsim_build.c +27 -0
- data/ext/hruby_sim/hruby_sim.h +3 -0
- data/ext/hruby_sim/hruby_sim_calc.c +2 -0
- data/ext/hruby_sim/hruby_sim_core.c +17 -5
- data/ext/hruby_sim/hruby_sim_stack_calc.c +1 -1
- data/ext/hruby_sim/hruby_sim_tree_calc.c +8 -1
- data/ext/hruby_sim/hruby_sim_vcd.c +24 -7
- data/ext/hruby_sim/hruby_sim_vizualize.c +9 -1
- data/lib/HDLRuby/backend/hruby_allocator.rb +2 -2
- data/lib/HDLRuby/backend/hruby_c_allocator.rb +7 -7
- data/lib/HDLRuby/hdr_samples/constant_in_function.rb +3 -1
- data/lib/HDLRuby/hdr_samples/counter_dff_bench.rb +3 -1
- data/lib/HDLRuby/hdr_samples/huge_rom.rb +1 -1
- data/lib/HDLRuby/hdr_samples/mei8.rb +11 -11
- data/lib/HDLRuby/hdr_samples/mei8_bench.rb +12 -12
- data/lib/HDLRuby/hdr_samples/neg_arith_bench.rb +4 -4
- data/lib/HDLRuby/hdr_samples/rom_nest.rb +1 -1
- data/lib/HDLRuby/hdr_samples/ruby_fir_hw.rb +4 -4
- data/lib/HDLRuby/hdr_samples/struct.rb +44 -10
- data/lib/HDLRuby/hdr_samples/with_bram.rb +45 -0
- data/lib/HDLRuby/hdr_samples/with_bram_frame_stack.rb +105 -0
- data/lib/HDLRuby/hdr_samples/with_bram_stack.rb +69 -0
- data/lib/HDLRuby/hdr_samples/with_casts.rb +3 -3
- data/lib/HDLRuby/hdr_samples/with_concat.rb +6 -6
- data/lib/HDLRuby/hdr_samples/with_connector_memory.rb +2 -2
- data/lib/HDLRuby/hdr_samples/with_def.rb +10 -3
- data/lib/HDLRuby/hdr_samples/with_define_operator.rb +44 -0
- data/lib/HDLRuby/hdr_samples/with_fixpoint.rb +12 -12
- data/lib/HDLRuby/hdr_samples/with_init.rb +3 -3
- data/lib/HDLRuby/hdr_samples/with_leftright.rb +21 -0
- data/lib/HDLRuby/hdr_samples/with_reduce.rb +13 -13
- data/lib/HDLRuby/hdr_samples/with_ref_array.rb +6 -6
- data/lib/HDLRuby/hdr_samples/with_register_stack.rb +150 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer.rb +190 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer_deep.rb +91 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer_enumerable.rb +405 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer_enumerator.rb +89 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer_sync.rb +120 -0
- data/lib/HDLRuby/hdr_samples/with_subsums.rb +3 -3
- data/lib/HDLRuby/hdr_samples/with_terminate.rb +3 -3
- data/lib/HDLRuby/hdr_samples/with_to_a.rb +10 -10
- data/lib/HDLRuby/hdr_samples/with_values.rb +3 -3
- data/lib/HDLRuby/hdrcc.rb +29 -3
- data/lib/HDLRuby/hdrlib.rb +1 -1
- data/lib/HDLRuby/hruby_bstr.rb +10 -5
- data/lib/HDLRuby/hruby_db.rb +2 -2
- data/lib/HDLRuby/hruby_high.rb +152 -47
- data/lib/HDLRuby/hruby_high_fullname.rb +3 -1
- data/lib/HDLRuby/hruby_low.rb +189 -18
- data/lib/HDLRuby/hruby_low2c.rb +129 -54
- data/lib/HDLRuby/hruby_low2hdr.rb +66 -40
- data/lib/HDLRuby/hruby_low2high.rb +86 -44
- data/lib/HDLRuby/hruby_low2seq.rb +26 -18
- data/lib/HDLRuby/hruby_low2sym.rb +14 -13
- data/lib/HDLRuby/hruby_low2vhd.rb +80 -44
- data/lib/HDLRuby/hruby_low_bool2select.rb +61 -46
- data/lib/HDLRuby/hruby_low_casts_without_expression.rb +56 -44
- data/lib/HDLRuby/hruby_low_cleanup.rb +18 -16
- data/lib/HDLRuby/hruby_low_fix_types.rb +65 -32
- data/lib/HDLRuby/hruby_low_mutable.rb +83 -119
- data/lib/HDLRuby/hruby_low_resolve.rb +38 -30
- data/lib/HDLRuby/hruby_low_with_bool.rb +33 -16
- data/lib/HDLRuby/hruby_low_with_port.rb +3 -3
- data/lib/HDLRuby/hruby_low_with_var.rb +23 -9
- data/lib/HDLRuby/hruby_low_without_concat.rb +45 -19
- data/lib/HDLRuby/hruby_low_without_namespace.rb +47 -32
- data/lib/HDLRuby/hruby_low_without_parinseq.rb +32 -16
- data/lib/HDLRuby/hruby_low_without_select.rb +37 -24
- data/lib/HDLRuby/hruby_low_without_subsignals.rb +280 -0
- data/lib/HDLRuby/hruby_rcsim.rb +158 -134
- data/lib/HDLRuby/hruby_rsim.rb +194 -20
- data/lib/HDLRuby/hruby_rsim_mute.rb +2 -3
- data/lib/HDLRuby/hruby_rsim_vcd.rb +125 -50
- data/lib/HDLRuby/hruby_values.rb +48 -33
- data/lib/HDLRuby/hruby_verilog.rb +90 -48
- data/lib/HDLRuby/soft/stacks.rb +219 -0
- data/lib/HDLRuby/std/bram.rb +26 -0
- data/lib/HDLRuby/std/clocks.rb +1 -1
- data/lib/HDLRuby/std/fixpoint.rb +2 -2
- data/lib/HDLRuby/std/fsm.rb +48 -11
- data/lib/HDLRuby/std/function_generator.rb +2 -2
- data/lib/HDLRuby/std/sequencer.rb +1857 -0
- data/lib/HDLRuby/std/sequencer_sync.rb +400 -0
- data/lib/HDLRuby/std/std.rb +12 -0
- data/lib/HDLRuby/version.rb +1 -1
- data/tuto/adder_sat_flags_vcd.png +0 -0
- data/tuto/addsub_vcd.png +0 -0
- data/tuto/alu_vcd.png +0 -0
- data/tuto/bit_pong_vcd.png +0 -0
- data/tuto/checksum_vcd.png +0 -0
- data/tuto/circuit_hdr.odg +0 -0
- data/tuto/circuit_hdr.png +0 -0
- data/tuto/circuit_hie.odg +0 -0
- data/tuto/circuit_hie.png +0 -0
- data/tuto/circuit_view.odg +0 -0
- data/tuto/circuit_view.png +0 -0
- data/tuto/clock_counter_vcd.png +0 -0
- data/tuto/counter_ext_vcd.png +0 -0
- data/tuto/fact_vcd.png +0 -0
- data/tuto/hw_flow.odg +0 -0
- data/tuto/hw_flow.png +0 -0
- data/tuto/maxxer_vcd.png +0 -0
- data/tuto/pingpong0_vcd.png +0 -0
- data/tuto/pingpong1_vcd.png +0 -0
- data/tuto/pingpong2_vcd.png +0 -0
- data/tuto/ram_vcd.png +0 -0
- data/tuto/serializer_vcd.png +0 -0
- data/tuto/sw_flow.odg +0 -0
- data/tuto/sw_flow.png +0 -0
- data/tuto/the_counter_vcd.png +0 -0
- data/tuto/tutorial_sw.html +2359 -0
- data/tuto/tutorial_sw.md +2684 -0
- data/tuto/tutorial_sw.pdf +0 -0
- data/tuto/tutorial_sw_jp.md +417 -0
- metadata +49 -3
- data/lib/HDLRuby/hdr_samples/sumprod.rb +0 -29
@@ -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
|
@@ -115,8 +117,9 @@ 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.
|
119
120
|
class Binary
|
121
|
+
## Enhances Binary with verilog generation.
|
122
|
+
|
120
123
|
# Converts the system to Verilog code.
|
121
124
|
def to_verilog
|
122
125
|
return "(#{self.left.to_verilog} #{self.operator} #{self.right.to_verilog})"
|
@@ -158,9 +161,10 @@ module HDLRuby::Low
|
|
158
161
|
end
|
159
162
|
end
|
160
163
|
|
161
|
-
|
162
|
-
# Enhance Transmit with generation of verilog code.
|
164
|
+
|
163
165
|
class Transmit
|
166
|
+
## Enhances Transmit with generation of verilog code.
|
167
|
+
|
164
168
|
# Converts the system to Verilog code.
|
165
169
|
def to_verilog(spc = 3)
|
166
170
|
# Determine blocking assignment or nonblocking substitution from mode and return it.
|
@@ -169,8 +173,10 @@ module HDLRuby::Low
|
|
169
173
|
end
|
170
174
|
end
|
171
175
|
|
172
|
-
|
176
|
+
|
173
177
|
class Print
|
178
|
+
## Enhances Print with generation of verilog code.
|
179
|
+
|
174
180
|
# Converts the print to Verilog code.
|
175
181
|
def to_verilog(spc = 3)
|
176
182
|
code = "#{" " * spc}$write(#{self.each_arg.map do |arg|
|
@@ -180,17 +186,20 @@ module HDLRuby::Low
|
|
180
186
|
end
|
181
187
|
end
|
182
188
|
|
183
|
-
|
189
|
+
|
184
190
|
class TimeTerminate
|
191
|
+
## Enhances TimeTerminate with generation of verilog code.
|
192
|
+
|
185
193
|
# Converts the terminate to Verilog code.
|
186
194
|
def to_verilog(spc = 3)
|
187
195
|
return "#{" " * spc}$finish;"
|
188
196
|
end
|
189
197
|
end
|
190
198
|
|
191
|
-
|
192
|
-
# Enhance Block with generation of verilog code.
|
199
|
+
|
193
200
|
class Block
|
201
|
+
## Enhances Block with generation of verilog code.
|
202
|
+
# To scheduling to the Block.
|
194
203
|
|
195
204
|
# Converts the system to Verilog code adding 'spc' spaces at the begining
|
196
205
|
# of each line.
|
@@ -1439,9 +1448,10 @@ module HDLRuby::Low
|
|
1439
1448
|
end
|
1440
1449
|
end
|
1441
1450
|
|
1442
|
-
|
1443
|
-
# Enhance RefName with generation of verilog code.
|
1451
|
+
|
1444
1452
|
class RefName
|
1453
|
+
## Enhances RefName with generation of verilog code.
|
1454
|
+
|
1445
1455
|
# Converts the system to Verilog code using +renamer+ for producing Verilog-compatible names.
|
1446
1456
|
def to_verilog
|
1447
1457
|
vname = name_to_verilog(self.name)
|
@@ -1463,9 +1473,10 @@ module HDLRuby::Low
|
|
1463
1473
|
end
|
1464
1474
|
end
|
1465
1475
|
|
1466
|
-
|
1467
|
-
# Enhance RefIndex with generation of verilog code.
|
1476
|
+
|
1468
1477
|
class RefIndex
|
1478
|
+
## Enhances RefIndex with generation of verilog code.
|
1479
|
+
|
1469
1480
|
# Converts the system to Verilog code.
|
1470
1481
|
def to_verilog
|
1471
1482
|
return "#{self.ref.to_verilog}[#{self.index.to_verilog}]"
|
@@ -1473,9 +1484,9 @@ module HDLRuby::Low
|
|
1473
1484
|
end
|
1474
1485
|
|
1475
1486
|
|
1476
|
-
# Used to indicate the number of bits.
|
1477
|
-
# Enhance TypeVector with generation of verilog code.
|
1478
1487
|
class TypeVector
|
1488
|
+
## Enhances TypeVector with generation of verilog code.
|
1489
|
+
|
1479
1490
|
# Converts the system to Verilog code.
|
1480
1491
|
def to_verilog
|
1481
1492
|
# if self.base.name.to_s != "bit"
|
@@ -1486,16 +1497,22 @@ module HDLRuby::Low
|
|
1486
1497
|
end
|
1487
1498
|
end
|
1488
1499
|
|
1489
|
-
|
1500
|
+
|
1490
1501
|
class RefRange
|
1502
|
+
## Enhances RefRange with generation of verilog code.
|
1503
|
+
|
1504
|
+
# Necessary for displaying bit width (eg, specify and assign).
|
1505
|
+
|
1491
1506
|
# Converts the system to Verilog code.
|
1492
1507
|
def to_verilog(unknown = false)
|
1493
1508
|
return "#{self.ref.to_verilog}[#{self.range.first.to_getrange}:#{self.range.last.to_getrange}]"
|
1494
1509
|
end
|
1495
1510
|
end
|
1496
1511
|
|
1497
|
-
|
1512
|
+
|
1498
1513
|
class RefConcat
|
1514
|
+
## Enhances RefConcat with generation of verilog code.
|
1515
|
+
|
1499
1516
|
def to_verilog
|
1500
1517
|
ref = self.each_ref.to_a
|
1501
1518
|
|
@@ -1509,18 +1526,20 @@ module HDLRuby::Low
|
|
1509
1526
|
end
|
1510
1527
|
end
|
1511
1528
|
|
1512
|
-
|
1513
|
-
# Enhance HDLRuby with generation of verilog code.
|
1529
|
+
|
1514
1530
|
class HDLRuby::BitString
|
1531
|
+
## Enhances BitString with generation of verilog code.
|
1532
|
+
|
1515
1533
|
# Converts the system to Verilog code.
|
1516
1534
|
def to_verilog
|
1517
1535
|
return "#{self.to_s}"
|
1518
1536
|
end
|
1519
1537
|
end
|
1520
1538
|
|
1521
|
-
|
1522
|
-
# Enhance Select with generation of verilog code.
|
1539
|
+
|
1523
1540
|
class Select
|
1541
|
+
## Enhances Select with generation of verilog code.
|
1542
|
+
|
1524
1543
|
# Converts the system to Verilog code.
|
1525
1544
|
def to_verilog
|
1526
1545
|
# Outputs the first and second choices (choice (0) and choice (1)).
|
@@ -1535,9 +1554,10 @@ module HDLRuby::Low
|
|
1535
1554
|
end
|
1536
1555
|
end
|
1537
1556
|
|
1538
|
-
|
1539
|
-
# Enhance Value with generation of verilog code.
|
1557
|
+
|
1540
1558
|
class Value
|
1559
|
+
## Enhances Value with generation of verilog code.
|
1560
|
+
|
1541
1561
|
# Converts the system to Verilog code.
|
1542
1562
|
# If it is bit, it is b, and if it is int, it is represented by d. (Example: 4'b0000, 32'd1)
|
1543
1563
|
def to_verilog(unknown = nil)
|
@@ -1579,9 +1599,9 @@ module HDLRuby::Low
|
|
1579
1599
|
end
|
1580
1600
|
|
1581
1601
|
|
1582
|
-
# Used to transrate if.
|
1583
|
-
# Enhance If with generation of verilog code.
|
1584
1602
|
class If
|
1603
|
+
## Enhances If with generation of verilog code.
|
1604
|
+
|
1585
1605
|
# # Converts the system to Verilog code.
|
1586
1606
|
# def to_verilog(mode = nil)
|
1587
1607
|
# Converts to Verilog code, checking adding 'spc' spaces at the begining
|
@@ -1617,10 +1637,10 @@ module HDLRuby::Low
|
|
1617
1637
|
end
|
1618
1638
|
end
|
1619
1639
|
|
1620
|
-
|
1640
|
+
|
1621
1641
|
class Case
|
1622
|
-
|
1623
|
-
|
1642
|
+
## Enhances Case with generation of verilog code.
|
1643
|
+
|
1624
1644
|
# Converts to Verilog code, checking if variables are register
|
1625
1645
|
# or wire adding 'spc' spaces at the begining of each line.
|
1626
1646
|
def to_verilog(spc = 3)
|
@@ -1656,9 +1676,10 @@ module HDLRuby::Low
|
|
1656
1676
|
end
|
1657
1677
|
end
|
1658
1678
|
|
1659
|
-
|
1660
|
-
# Enhance Connection with generation of verilog code.
|
1679
|
+
|
1661
1680
|
class Connection
|
1681
|
+
## Enhances Connection with generation of verilog code.
|
1682
|
+
|
1662
1683
|
# Converts the system to Verilog code.
|
1663
1684
|
|
1664
1685
|
# Method used for array.
|
@@ -1715,23 +1736,29 @@ module HDLRuby::Low
|
|
1715
1736
|
end
|
1716
1737
|
end
|
1717
1738
|
|
1718
|
-
|
1739
|
+
|
1719
1740
|
class RefThis
|
1741
|
+
## Enhances RefThis with generation of verilog code.
|
1742
|
+
|
1720
1743
|
def to_another_verilog
|
1721
1744
|
return ""
|
1722
1745
|
end
|
1723
1746
|
end
|
1724
1747
|
|
1725
|
-
|
1748
|
+
|
1726
1749
|
class Unary
|
1750
|
+
## Enhances Unary with generation of verilog code.
|
1751
|
+
|
1727
1752
|
# Converts the system to Verilog code.
|
1728
1753
|
def to_verilog
|
1729
1754
|
return "#{self.operator[0]}#{self.child.to_verilog}"
|
1730
1755
|
end
|
1731
1756
|
end
|
1732
1757
|
|
1733
|
-
|
1758
|
+
|
1734
1759
|
class Cast
|
1760
|
+
## Enhances Cast with generation of verilog code.
|
1761
|
+
|
1735
1762
|
# Converts the system to Verilog code.
|
1736
1763
|
# NOTE: the cast is rounded up size bit-width cast is not supported
|
1737
1764
|
# by traditional verilog.
|
@@ -1773,9 +1800,10 @@ module HDLRuby::Low
|
|
1773
1800
|
end
|
1774
1801
|
end
|
1775
1802
|
|
1776
|
-
|
1777
|
-
# Enhance SignalI with generation of verilog code.
|
1803
|
+
|
1778
1804
|
class SignalI
|
1805
|
+
## Enhances SignalI with generation of verilog code.
|
1806
|
+
|
1779
1807
|
# Converts the system to Verilog code.
|
1780
1808
|
def to_verilog
|
1781
1809
|
# Convert unusable characters and return them.
|
@@ -1785,25 +1813,30 @@ module HDLRuby::Low
|
|
1785
1813
|
end
|
1786
1814
|
end
|
1787
1815
|
|
1788
|
-
|
1789
|
-
# Enhance Type with generation of verilog code.
|
1816
|
+
|
1790
1817
|
class Type
|
1818
|
+
## Enhances Type with generation of verilog code.
|
1819
|
+
|
1791
1820
|
# Converts the type to Verilog code.
|
1792
1821
|
def to_verilog
|
1793
1822
|
return self.name == :signed ? "#{self.name.to_s} " : ""
|
1794
1823
|
end
|
1795
1824
|
end
|
1796
1825
|
|
1797
|
-
|
1826
|
+
|
1798
1827
|
class TypeDef
|
1828
|
+
## Enhances TypeDef with generation of verilog code.
|
1829
|
+
|
1799
1830
|
# Converts the type to verilog code.
|
1800
1831
|
def to_verilog
|
1801
1832
|
return self.def.to_verilog
|
1802
1833
|
end
|
1803
1834
|
end
|
1804
1835
|
|
1805
|
-
|
1836
|
+
|
1806
1837
|
class Concat
|
1838
|
+
## Enhances Concat with generation of verilog code.
|
1839
|
+
|
1807
1840
|
def to_verilog
|
1808
1841
|
expression = self.each_expression.to_a
|
1809
1842
|
|
@@ -1817,14 +1850,19 @@ module HDLRuby::Low
|
|
1817
1850
|
end
|
1818
1851
|
end
|
1819
1852
|
|
1820
|
-
|
1821
|
-
# One of two people, TimeWait and Delay.
|
1853
|
+
|
1822
1854
|
class TimeWait
|
1855
|
+
## Enhances TimeWait with generation of verilog code.
|
1856
|
+
|
1823
1857
|
def to_verilog(spc = 3)
|
1824
1858
|
return (" " * spc) + self.delay.to_verilog + "\n"
|
1825
1859
|
end
|
1826
1860
|
end
|
1861
|
+
|
1862
|
+
|
1827
1863
|
class Delay
|
1864
|
+
## Enhances Delay with generation of verilog code.
|
1865
|
+
|
1828
1866
|
def to_verilog
|
1829
1867
|
time = self.value.to_s
|
1830
1868
|
if(self.unit.to_s == "ps") then
|
@@ -1842,8 +1880,9 @@ module HDLRuby::Low
|
|
1842
1880
|
end
|
1843
1881
|
|
1844
1882
|
|
1845
|
-
# Generate verilog code for the TimeRepeat.
|
1846
1883
|
class TimeRepeat
|
1884
|
+
## Enhances TimeRepeat with generation of verilog code.
|
1885
|
+
|
1847
1886
|
def to_verilog(spc = 3)
|
1848
1887
|
result = (" " * spc) + "repeat(#{self.number})" + "\n"
|
1849
1888
|
result << self.statement.to_verilog(spc+3)
|
@@ -1855,8 +1894,9 @@ module HDLRuby::Low
|
|
1855
1894
|
#class TypeTuple
|
1856
1895
|
#class Event
|
1857
1896
|
|
1858
|
-
|
1897
|
+
|
1859
1898
|
class SystemT
|
1899
|
+
## Enhances SystemT with generation of verilog code.
|
1860
1900
|
|
1861
1901
|
## Tells if a connection is actually a port connection.
|
1862
1902
|
def port_output_connection?(connection)
|
@@ -2163,9 +2203,10 @@ module HDLRuby::Low
|
|
2163
2203
|
codeC << "),"
|
2164
2204
|
end
|
2165
2205
|
end
|
2166
|
-
# Remove the last "," for conforming with Verilog syntax.
|
2167
|
-
|
2168
|
-
|
2206
|
+
# Remove the last "," if any for conforming with Verilog syntax.
|
2207
|
+
codeC.chop! if codeC[-1] == ","
|
2208
|
+
# And close the port connection.
|
2209
|
+
codeC << ");\n"
|
2169
2210
|
end
|
2170
2211
|
|
2171
2212
|
|
@@ -2254,8 +2295,9 @@ module HDLRuby::Low
|
|
2254
2295
|
end
|
2255
2296
|
|
2256
2297
|
|
2257
|
-
# Enhance StringE with generation of verilog code.
|
2258
2298
|
class StringE
|
2299
|
+
## Enhances stringE with generation of verilog code.
|
2300
|
+
|
2259
2301
|
# Converts the system to Verilog code.
|
2260
2302
|
def to_verilog(spc = 3)
|
2261
2303
|
code = "\"#{Low.v_string(self.content)}" +
|
@@ -2270,8 +2312,8 @@ end
|
|
2270
2312
|
|
2271
2313
|
|
2272
2314
|
|
2273
|
-
## Extends the Numeric class with generation of verilog text.
|
2274
2315
|
class ::Numeric
|
2316
|
+
## Extends the Numeric class with generation of verilog text.
|
2275
2317
|
|
2276
2318
|
# Generates the text of the equivalent verilog code.
|
2277
2319
|
# +level+ is the hierachical level of the object.
|
@@ -0,0 +1,219 @@
|
|
1
|
+
require 'std/bram'
|
2
|
+
|
3
|
+
module HDLRuby::High::Soft
|
4
|
+
|
5
|
+
|
6
|
+
# Declare the possible commands for the stack.
|
7
|
+
PUSH = 0 # Pushes the value of input din into the stack.
|
8
|
+
POP = 1 # Pops din values for the stack. If din is negative, allocates din elements on the stack.
|
9
|
+
READ = 2 # Read the value address din and output it on dout.
|
10
|
+
WRITE = 3 # Write the value at the top of the stack at address din.
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
# Describe a stack based on a BRAM (compatible with FPGA's)
|
17
|
+
# - 'widthD': data bit width
|
18
|
+
# - 'size' : the size of the stack
|
19
|
+
system :bram_stack do |widthD, size|
|
20
|
+
# Compute the address width.
|
21
|
+
widthA = (size-1).width
|
22
|
+
|
23
|
+
# Compute the bit width of the stack pointer register.
|
24
|
+
widthS = (size+1).width
|
25
|
+
|
26
|
+
# Declare the inputs and outputs.
|
27
|
+
input :clk, :rst, :ce
|
28
|
+
input :cmd
|
29
|
+
[widthD].input :din
|
30
|
+
[widthD].output :dout
|
31
|
+
output :empty, :full
|
32
|
+
|
33
|
+
# Declare the BRAM containing the stack data.
|
34
|
+
inner rwb: 1
|
35
|
+
[widthA].inner :addr
|
36
|
+
[widthD].inner :brin, :brout
|
37
|
+
bram(widthA,widthD).(:bramI).(clk,rwb,addr,brin,brout)
|
38
|
+
|
39
|
+
# Declare the stack pointer register and the top of stack value.
|
40
|
+
[widthS].inner sp: size
|
41
|
+
[widthD].inner :top
|
42
|
+
|
43
|
+
# Tells if the stack is empty or full.
|
44
|
+
empty <= (sp == size)
|
45
|
+
full <= (sp == 0)
|
46
|
+
|
47
|
+
# The output bus is the top of the stack.
|
48
|
+
dout <= top
|
49
|
+
|
50
|
+
# The clock process handling the access.
|
51
|
+
seq(clk.posedge) do
|
52
|
+
# By default, read before the top of the memory.
|
53
|
+
rwb <= 1
|
54
|
+
hif(rst) do
|
55
|
+
# sp is set to size (stack empty).
|
56
|
+
sp <= size
|
57
|
+
top <= 0
|
58
|
+
end
|
59
|
+
helsif(ce) do
|
60
|
+
# Now depending on the command.
|
61
|
+
hcase(cmd)
|
62
|
+
hwhen(PUSH) do
|
63
|
+
# Is the stack full?
|
64
|
+
hif(~full) do
|
65
|
+
# No, can push onto the stack.
|
66
|
+
# Update the top register.
|
67
|
+
top <= din
|
68
|
+
# Update the bram.
|
69
|
+
brin <= din
|
70
|
+
rwb <= 0
|
71
|
+
# Finally, decrease sp.
|
72
|
+
sp <= sp - 1
|
73
|
+
# The address is the top of the stack
|
74
|
+
addr <= sp
|
75
|
+
end
|
76
|
+
end
|
77
|
+
hwhen(POP) do
|
78
|
+
# Is the stack empty?
|
79
|
+
hif(~empty) do
|
80
|
+
# No, can pop from the stack.
|
81
|
+
# Update the top register.
|
82
|
+
top <= brout
|
83
|
+
# Finally, increase sp.
|
84
|
+
sp <= sp + 1
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
hif(~ce | cmd != PUSH) do
|
89
|
+
# By default the address is the top of the stack + 1
|
90
|
+
addr <= sp + 1
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
# Describe a frame stack based on a BRAM (compatible with FPGA's)
|
98
|
+
# - 'widthD': data bit width
|
99
|
+
# - 'size' : the size of the stack
|
100
|
+
# - 'depth' : the maximum number of frames.
|
101
|
+
system :bram_frame_stack do |widthD, size, depth|
|
102
|
+
# Compute the address width.
|
103
|
+
widthA = (size-1).width
|
104
|
+
|
105
|
+
# Compute the bit width of the frame pointers.
|
106
|
+
widthF = (size+1).width
|
107
|
+
|
108
|
+
# compute the bit width of the frame stack pointer.
|
109
|
+
widthS = (depth+1).width
|
110
|
+
|
111
|
+
# Create the type used for accessing the frame stack.
|
112
|
+
typedef(:locT) { { frame: bit[widthS], offset: bit[widthF] } }
|
113
|
+
|
114
|
+
# Declare the inputs and outputs.
|
115
|
+
input :clk, :rst, :ce
|
116
|
+
[2].input :cmd
|
117
|
+
locT.input :loc
|
118
|
+
[widthD].input :din
|
119
|
+
[widthD].output :dout
|
120
|
+
output :empty, :full
|
121
|
+
|
122
|
+
# Declare the frame index stac pointer.
|
123
|
+
[widthS].inner :sp
|
124
|
+
|
125
|
+
# Declare the frame index table.
|
126
|
+
bit[widthF][-depth].inner :indexes
|
127
|
+
|
128
|
+
# Declare the BRAM containing the frames data.
|
129
|
+
inner rwb: 1
|
130
|
+
[widthA].inner :addr
|
131
|
+
[widthD].inner :brin, :brout
|
132
|
+
bram(widthA,widthD).(:bramI).(clk,rwb,addr,brin,brout)
|
133
|
+
|
134
|
+
# Tells if the stack is empty or full.
|
135
|
+
empty <= (sp == depth)
|
136
|
+
full <= (sp == 0)
|
137
|
+
|
138
|
+
# The input data is always the input of the bram.
|
139
|
+
brin <= din
|
140
|
+
|
141
|
+
# The output is always the output of the bram.
|
142
|
+
dout <= brout
|
143
|
+
|
144
|
+
# The clock process handling the access.
|
145
|
+
seq(clk.posedge) do
|
146
|
+
# By default, read before the top of the memory.
|
147
|
+
rwb <= 1
|
148
|
+
hif(rst) do
|
149
|
+
# sp is set to depth (stack empty).
|
150
|
+
sp <= depth
|
151
|
+
end
|
152
|
+
helsif(ce) do
|
153
|
+
# Now depending on the command.
|
154
|
+
hcase(cmd)
|
155
|
+
hwhen(PUSH) do
|
156
|
+
# Is the stack full or is the frame to push empty?
|
157
|
+
hif(~(full | loc.offset == 0)) do
|
158
|
+
# No, we can proceed.
|
159
|
+
# Decrease sp.
|
160
|
+
sp <= sp - 1
|
161
|
+
# Adds the frame.
|
162
|
+
hif(~empty) do
|
163
|
+
indexes[sp] <= loc.offset + indexes[sp+1]
|
164
|
+
end
|
165
|
+
helse do
|
166
|
+
indexes[sp] <= loc.offset
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
hwhen(POP) do
|
171
|
+
# Is the stack empty?
|
172
|
+
hif(~empty) do
|
173
|
+
# No, can pop a frame from the stack.
|
174
|
+
# Increase sp.
|
175
|
+
sp <= sp + 1
|
176
|
+
end
|
177
|
+
end
|
178
|
+
hwhen(READ) do
|
179
|
+
# Read access, is the frame valid?
|
180
|
+
cur_frame = sp+loc.frame
|
181
|
+
hif (~(empty | cur_frame >= depth)) do
|
182
|
+
# The frame is valid. Is the offset valid?
|
183
|
+
addr_calc = indexes[cur_frame] - loc.offset - 1
|
184
|
+
hif ((cur_frame < depth-1) &
|
185
|
+
(addr_calc > indexes[cur_frame+1])) do
|
186
|
+
# Not the first frame and the address is valid.
|
187
|
+
addr <= addr_calc
|
188
|
+
end
|
189
|
+
helsif ((cur_frame == depth-1) &
|
190
|
+
(addr_calc + 1 > 0)) do
|
191
|
+
# The first frame and the address is valid.
|
192
|
+
addr <= addr_calc
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
hwhen(WRITE) do
|
197
|
+
# Write access, is the frame valid?
|
198
|
+
cur_frame = sp+loc.frame
|
199
|
+
hif (~(empty | cur_frame >= depth)) do
|
200
|
+
# The frame is valid. Is the offset valid?
|
201
|
+
addr_calc = indexes[cur_frame] - loc.offset - 1
|
202
|
+
hif ((cur_frame < depth-1) &
|
203
|
+
(addr_calc > indexes[cur_frame+1])) do
|
204
|
+
# Not the first frame and the address is valid.
|
205
|
+
addr <= addr_calc
|
206
|
+
rwb <= 0
|
207
|
+
end
|
208
|
+
helsif ((cur_frame == depth-1) &
|
209
|
+
(addr_calc + 1 > 0)) do
|
210
|
+
# The first frame and the address is valid.
|
211
|
+
addr <= addr_calc
|
212
|
+
rwb <= 0
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module HDLRuby::High::Std
|
2
|
+
|
3
|
+
# Describe a RAM compatibile with BRAM of FPGAs.
|
4
|
+
# - 'widthA': address bit width
|
5
|
+
# - 'widthD': data bit width
|
6
|
+
# - 'size': the size of the memory.
|
7
|
+
system :bram do |widthA, widthD, size = nil|
|
8
|
+
# Process size if required.
|
9
|
+
size = 2**widthA unless size
|
10
|
+
# puts "widthA=#{widthA} widthD=#{widthD} size=#{size}"
|
11
|
+
|
12
|
+
# Declares the io of the ram.
|
13
|
+
input :clk, :rwb
|
14
|
+
[widthA].input :addr
|
15
|
+
[widthD].input :din
|
16
|
+
[widthD].output :dout
|
17
|
+
|
18
|
+
bit[widthD][-size].inner mem: [ :"_b#{"0"*widthD}".to_value ] * size
|
19
|
+
|
20
|
+
par(clk.negedge) do
|
21
|
+
hif(rwb == 0) { mem[addr] <= din }
|
22
|
+
dout <= mem[addr]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/lib/HDLRuby/std/clocks.rb
CHANGED
@@ -135,8 +135,8 @@ module HDLRuby::High::Std
|
|
135
135
|
end
|
136
136
|
|
137
137
|
|
138
|
-
# Enhnace the events with multiply operator.
|
139
138
|
class HDLRuby::High::Event
|
139
|
+
# Enhance the events with multiply operator.
|
140
140
|
|
141
141
|
# Creates a new event activated every +times+ occurences of the
|
142
142
|
# current event.
|
data/lib/HDLRuby/std/fixpoint.rb
CHANGED
@@ -55,14 +55,14 @@ module HDLRuby::High::Std
|
|
55
55
|
if (typ.signed?) then
|
56
56
|
(left.as(signed[isize+fsize*2])*right) >> fsize
|
57
57
|
else
|
58
|
-
(left.as([isize+fsize*2])*right) >> fsize
|
58
|
+
(left.as(bit[isize+fsize*2])*right) >> fsize
|
59
59
|
end
|
60
60
|
end
|
61
61
|
typ.define_operator(:/) do |left,right|
|
62
62
|
if (typ.signed?) then
|
63
63
|
(left.as(signed[isize+fsize*2]) << fsize) / right
|
64
64
|
else
|
65
|
-
(left.as([isize+fsize*2]) << fsize) / right
|
65
|
+
(left.as(bit[isize+fsize*2]) << fsize) / right
|
66
66
|
end
|
67
67
|
end
|
68
68
|
# Define the removal of the point.
|