HDLRuby 2.11.11 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/lib/HDLRuby/hruby_low.rb
CHANGED
@@ -850,6 +850,7 @@ module HDLRuby::Low
|
|
850
850
|
|
851
851
|
# Adds inner signal +signal+.
|
852
852
|
def add_inner(signal)
|
853
|
+
# puts "adding inner signal: #{signal.name}(#{signal})"
|
853
854
|
# Check and add the signal.
|
854
855
|
unless signal.is_a?(SignalI)
|
855
856
|
raise AnyError,
|
@@ -1632,6 +1633,112 @@ module HDLRuby::Low
|
|
1632
1633
|
|
1633
1634
|
alias_method :each_deep, :each_type_deep
|
1634
1635
|
|
1636
|
+
# Tells if the type signed.
|
1637
|
+
def signed?
|
1638
|
+
return @def.signed?
|
1639
|
+
end
|
1640
|
+
|
1641
|
+
# Tells if the type is unsigned.
|
1642
|
+
def unsigned?
|
1643
|
+
return @def.unsigned?
|
1644
|
+
end
|
1645
|
+
|
1646
|
+
# Tells if the type is fixed point.
|
1647
|
+
def fixed?
|
1648
|
+
return @def.fixed?
|
1649
|
+
end
|
1650
|
+
|
1651
|
+
# Tells if the type is floating point.
|
1652
|
+
def float?
|
1653
|
+
return @def.float?
|
1654
|
+
end
|
1655
|
+
|
1656
|
+
# Tells if the type is a leaf.
|
1657
|
+
def leaf?
|
1658
|
+
return @def.leaf?
|
1659
|
+
end
|
1660
|
+
|
1661
|
+
# Tells if the type of of vector kind.
|
1662
|
+
def vector?
|
1663
|
+
return @def.vector?
|
1664
|
+
end
|
1665
|
+
|
1666
|
+
# Gets the bitwidth of the type, by default 0.
|
1667
|
+
# Bit, signed, unsigned and Float base have a width of 1.
|
1668
|
+
def width
|
1669
|
+
return @def.width
|
1670
|
+
end
|
1671
|
+
|
1672
|
+
# Gets the type max value if any.
|
1673
|
+
# Default: not defined.
|
1674
|
+
def max
|
1675
|
+
return @def.max
|
1676
|
+
end
|
1677
|
+
|
1678
|
+
# Gets the type min value if any.
|
1679
|
+
# Default: not defined.
|
1680
|
+
def min
|
1681
|
+
return @def.min
|
1682
|
+
end
|
1683
|
+
|
1684
|
+
# Get the direction of the type, little or big endian.
|
1685
|
+
def direction
|
1686
|
+
return @def.direction
|
1687
|
+
end
|
1688
|
+
|
1689
|
+
# Tells if the type has a range.
|
1690
|
+
def range?
|
1691
|
+
return @def.range?
|
1692
|
+
end
|
1693
|
+
|
1694
|
+
# Gets the range of the type, by default range is not defined.
|
1695
|
+
def range
|
1696
|
+
return @def.range
|
1697
|
+
end
|
1698
|
+
|
1699
|
+
# Tells if the type has a base.
|
1700
|
+
def base?
|
1701
|
+
return @def.base?
|
1702
|
+
end
|
1703
|
+
|
1704
|
+
# Gets the base type, by default base type is not defined.
|
1705
|
+
def base
|
1706
|
+
return @def.base
|
1707
|
+
end
|
1708
|
+
|
1709
|
+
# Tells if the type has sub types.
|
1710
|
+
def types?
|
1711
|
+
return @def.types?
|
1712
|
+
end
|
1713
|
+
|
1714
|
+
# Tells if the type is regular (applies for tuples).
|
1715
|
+
def regular?
|
1716
|
+
return @def.regular?
|
1717
|
+
end
|
1718
|
+
|
1719
|
+
# Tells if the type has named sub types.
|
1720
|
+
def struct?
|
1721
|
+
return @def.struct?
|
1722
|
+
end
|
1723
|
+
|
1724
|
+
# Tells if the type is hierarchical.
|
1725
|
+
def hierarchical?
|
1726
|
+
return @def.hierarchical?
|
1727
|
+
end
|
1728
|
+
|
1729
|
+
# Tell if +type+ is equivalent to current type.
|
1730
|
+
#
|
1731
|
+
# NOTE: type can be compatible while not being equivalent, please
|
1732
|
+
# refer to `hruby_types.rb` for type compatibility.
|
1733
|
+
def equivalent?(type)
|
1734
|
+
return @def.equivalent?(type)
|
1735
|
+
end
|
1736
|
+
|
1737
|
+
# Converts to a bit vector.
|
1738
|
+
def to_vector
|
1739
|
+
return @def.to_vector
|
1740
|
+
end
|
1741
|
+
|
1635
1742
|
end
|
1636
1743
|
|
1637
1744
|
|
@@ -1812,7 +1919,7 @@ module HDLRuby::Low
|
|
1812
1919
|
end
|
1813
1920
|
|
1814
1921
|
##
|
1815
|
-
# Describes
|
1922
|
+
# Describes an unsigned integer data type.
|
1816
1923
|
class TypeUnsigned < TypeVector
|
1817
1924
|
|
1818
1925
|
# Creates a new vector type named +name+ from +base+ type and with
|
@@ -1925,7 +2032,7 @@ module HDLRuby::Low
|
|
1925
2032
|
def each(&ruby_block)
|
1926
2033
|
# No ruby block? Return an enumerator.
|
1927
2034
|
return to_enum(:each) unless ruby_block
|
1928
|
-
# A ruby block? Apply it on each
|
2035
|
+
# A ruby block? Apply it on each sub name/type pair.
|
1929
2036
|
@types.each(&ruby_block)
|
1930
2037
|
end
|
1931
2038
|
|
@@ -1935,7 +2042,7 @@ module HDLRuby::Low
|
|
1935
2042
|
def each_type(&ruby_block)
|
1936
2043
|
# No ruby block? Return an enumerator.
|
1937
2044
|
return to_enum(:each_type) unless ruby_block
|
1938
|
-
# A ruby block? Apply it on each
|
2045
|
+
# A ruby block? Apply it on each sub type.
|
1939
2046
|
@types.each(&ruby_block)
|
1940
2047
|
end
|
1941
2048
|
|
@@ -2021,16 +2128,18 @@ module HDLRuby::Low
|
|
2021
2128
|
##
|
2022
2129
|
# Describes a structure type.
|
2023
2130
|
class TypeStruct < Type
|
2024
|
-
|
2131
|
+
attr_reader :direction
|
2132
|
+
|
2133
|
+
# Creates a new structure type named +name+ with direction +dir+ and
|
2025
2134
|
# whose hierachy is given by +content+.
|
2026
|
-
def initialize(name,
|
2135
|
+
def initialize(name,dir,content)
|
2027
2136
|
# Initialize the type.
|
2028
2137
|
super(name)
|
2029
2138
|
|
2030
2139
|
# Set the direction.
|
2031
|
-
@direction =
|
2140
|
+
@direction = dir.to_sym
|
2032
2141
|
unless [:little, :big].include?(@direction)
|
2033
|
-
raise AnyError, "Invalid direction for a type: #{
|
2142
|
+
raise AnyError, "Invalid direction for a type: #{dir}"
|
2034
2143
|
end
|
2035
2144
|
|
2036
2145
|
# Check and set the content.
|
@@ -2046,7 +2155,8 @@ module HDLRuby::Low
|
|
2046
2155
|
# Comparison for hash: structural comparison.
|
2047
2156
|
def eql?(obj)
|
2048
2157
|
# General type comparison.
|
2049
|
-
return false unless super(obj)
|
2158
|
+
# return false unless super(obj)
|
2159
|
+
return false unless obj.is_a?(TypeStruct)
|
2050
2160
|
# Specific comparison.
|
2051
2161
|
idx = 0
|
2052
2162
|
obj.each_key do |name|
|
@@ -2078,8 +2188,13 @@ module HDLRuby::Low
|
|
2078
2188
|
end
|
2079
2189
|
|
2080
2190
|
# Gets a sub type by +name+.
|
2191
|
+
# NOTE: +name+ can also be an index.
|
2081
2192
|
def get_type(name)
|
2082
|
-
|
2193
|
+
if name.respond_to?(:to_sym) then
|
2194
|
+
return @types[name.to_sym]
|
2195
|
+
else
|
2196
|
+
return @types.values[name.to_i]
|
2197
|
+
end
|
2083
2198
|
end
|
2084
2199
|
|
2085
2200
|
# Iterates over the sub name/type pair.
|
@@ -2088,7 +2203,7 @@ module HDLRuby::Low
|
|
2088
2203
|
def each(&ruby_block)
|
2089
2204
|
# No ruby block? Return an enumerator.
|
2090
2205
|
return to_enum(:each) unless ruby_block
|
2091
|
-
# A ruby block? Apply it on each
|
2206
|
+
# A ruby block? Apply it on each sub name/type pair.
|
2092
2207
|
@types.each(&ruby_block)
|
2093
2208
|
end
|
2094
2209
|
|
@@ -2098,17 +2213,27 @@ module HDLRuby::Low
|
|
2098
2213
|
def each_type(&ruby_block)
|
2099
2214
|
# No ruby block? Return an enumerator.
|
2100
2215
|
return to_enum(:each_type) unless ruby_block
|
2101
|
-
# A ruby block? Apply it on each
|
2216
|
+
# A ruby block? Apply it on each sub type.
|
2102
2217
|
@types.each_value(&ruby_block)
|
2103
2218
|
end
|
2104
2219
|
|
2220
|
+
# Iterates over the keys.
|
2221
|
+
#
|
2222
|
+
# Returns an enumerator if no ruby block is given.
|
2223
|
+
def each_key(&ruby_block)
|
2224
|
+
# No ruby block? Return an enumerator.
|
2225
|
+
return to_enum(:each_key) unless ruby_block
|
2226
|
+
# A ruby block? Apply it on each key.
|
2227
|
+
@types.each_key(&ruby_block)
|
2228
|
+
end
|
2229
|
+
|
2105
2230
|
# Iterates over the sub type names.
|
2106
2231
|
#
|
2107
2232
|
# Returns an enumerator if no ruby block is given.
|
2108
2233
|
def each_name(&ruby_block)
|
2109
2234
|
# No ruby block? Return an enumerator.
|
2110
2235
|
return to_enum(:each_name) unless ruby_block
|
2111
|
-
# A ruby block? Apply it on each
|
2236
|
+
# A ruby block? Apply it on each name.
|
2112
2237
|
@types.each_key(&ruby_block)
|
2113
2238
|
end
|
2114
2239
|
|
@@ -2128,7 +2253,11 @@ module HDLRuby::Low
|
|
2128
2253
|
#
|
2129
2254
|
# NOTE: must be redefined for specific types.
|
2130
2255
|
def width
|
2131
|
-
|
2256
|
+
if @types.is_a?(Array) then
|
2257
|
+
return @types.reduce(0) {|sum,type| sum + type.width }
|
2258
|
+
else
|
2259
|
+
return @types.each_value.reduce(0) {|sum,type| sum + type.width }
|
2260
|
+
end
|
2132
2261
|
end
|
2133
2262
|
|
2134
2263
|
# # Checks the compatibility with +type+
|
@@ -2506,8 +2635,9 @@ module HDLRuby::Low
|
|
2506
2635
|
end
|
2507
2636
|
@value = val
|
2508
2637
|
val.parent = self
|
2509
|
-
|
2510
|
-
|
2638
|
+
# For memory optimization: no initialization if not used.
|
2639
|
+
# else
|
2640
|
+
# @value = nil
|
2511
2641
|
end
|
2512
2642
|
end
|
2513
2643
|
|
@@ -2517,6 +2647,40 @@ module HDLRuby::Low
|
|
2517
2647
|
false
|
2518
2648
|
end
|
2519
2649
|
|
2650
|
+
# Adds sub signal +sig+
|
2651
|
+
def add_signal(sig)
|
2652
|
+
# puts "add sub=#{sig.name} in signal=#{self}"
|
2653
|
+
# Sets the hash of sub signals if none.
|
2654
|
+
@signals = HashName.new unless @signals
|
2655
|
+
# Check and add the signal.
|
2656
|
+
unless sig.is_a?(SignalI)
|
2657
|
+
raise AnyError,
|
2658
|
+
"Invalid class for a signal instance: #{sig.class}"
|
2659
|
+
end
|
2660
|
+
# if @signals.include?(sig) then
|
2661
|
+
# raise AnyError, "SignalI #{sig.name} already present."
|
2662
|
+
# end
|
2663
|
+
# Set its parent.
|
2664
|
+
sig.parent = self
|
2665
|
+
# And add it
|
2666
|
+
@signals.add(sig)
|
2667
|
+
end
|
2668
|
+
|
2669
|
+
# Gets a sub signal by name.
|
2670
|
+
def get_signal(name)
|
2671
|
+
return @signals ? @signals[name] : nil
|
2672
|
+
end
|
2673
|
+
|
2674
|
+
# Iterates over the sub signals.
|
2675
|
+
#
|
2676
|
+
# Returns an enumerator if no ruby block is given.
|
2677
|
+
def each_signal(&ruby_block)
|
2678
|
+
# No ruby block? Return an enumerator.
|
2679
|
+
return to_enum(:each_signal) unless ruby_block
|
2680
|
+
# A ruby block? Apply it on each sub signal instance if any.
|
2681
|
+
@signals.each(&ruby_block) if @signals
|
2682
|
+
end
|
2683
|
+
|
2520
2684
|
# # Add decorator capability (modifies intialize to put after).
|
2521
2685
|
# include Hdecorator
|
2522
2686
|
|
@@ -4717,8 +4881,15 @@ module HDLRuby::Low
|
|
4717
4881
|
content.is_a?(HDLRuby::BitString)
|
4718
4882
|
# content = HDLRuby::BitString.new(content.to_s)
|
4719
4883
|
content = content.to_s
|
4720
|
-
if self.type.unsigned? && content[0] != 0 then
|
4721
|
-
content = "0" + content.rjust(self.type.width,content[0])
|
4884
|
+
if self.type.unsigned? && content[0] != "0" then
|
4885
|
+
# content = "0" + content.rjust(self.type.width,content[0])
|
4886
|
+
if content[0] == "1" then
|
4887
|
+
# Do not extend the 1, but 0 instead.
|
4888
|
+
content = "0" + content.rjust(self.type.width,"0")
|
4889
|
+
else
|
4890
|
+
# But extend the other.
|
4891
|
+
content = "0" + content.rjust(self.type.width,content[0])
|
4892
|
+
end
|
4722
4893
|
end
|
4723
4894
|
content = HDLRuby::BitString.new(content)
|
4724
4895
|
end
|
@@ -5946,7 +6117,7 @@ module HDLRuby::Low
|
|
5946
6117
|
|
5947
6118
|
|
5948
6119
|
##
|
5949
|
-
#
|
6120
|
+
# Describes a this reference.
|
5950
6121
|
#
|
5951
6122
|
# This is the current system.
|
5952
6123
|
class RefThis < Ref
|