HDLRuby 2.5.0 → 2.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/HDLRuby/hdr_samples/adder.rb +1 -1
- data/lib/HDLRuby/hdr_samples/adder_bench.rb +1 -1
- data/lib/HDLRuby/hdr_samples/adder_gen.rb +1 -1
- data/lib/HDLRuby/hdr_samples/constant_in_function.rb +27 -0
- data/lib/HDLRuby/hdr_samples/dff_unit.rb +54 -0
- data/lib/HDLRuby/hdr_samples/huge_rom.rb +25 -0
- data/lib/HDLRuby/hdr_samples/logic_bench.rb +21 -0
- data/lib/HDLRuby/hdr_samples/mei8_bench.rb +1 -1
- data/lib/HDLRuby/hdr_samples/multi_timed_bench.rb +54 -0
- data/lib/HDLRuby/hdr_samples/music.rb +79 -0
- data/lib/HDLRuby/hdr_samples/named_sub.rb +42 -0
- data/lib/HDLRuby/hdr_samples/rom.rb +16 -0
- data/lib/HDLRuby/hdr_samples/with_function_generator.rb +25 -0
- data/lib/HDLRuby/hdrcc.rb +132 -24
- data/lib/HDLRuby/hruby_decorator.rb +3 -1
- data/lib/HDLRuby/hruby_high.rb +215 -27
- data/lib/HDLRuby/hruby_low.rb +402 -45
- data/lib/HDLRuby/hruby_low2c.rb +122 -168
- data/lib/HDLRuby/hruby_low2hdr.rb +738 -0
- data/lib/HDLRuby/hruby_low2high.rb +331 -549
- data/lib/HDLRuby/hruby_low2vhd.rb +39 -2
- data/lib/HDLRuby/hruby_low_bool2select.rb +29 -0
- data/lib/HDLRuby/hruby_low_casts_without_expression.rb +27 -0
- data/lib/HDLRuby/hruby_low_fix_types.rb +25 -0
- data/lib/HDLRuby/hruby_low_mutable.rb +70 -0
- data/lib/HDLRuby/hruby_low_resolve.rb +28 -0
- data/lib/HDLRuby/hruby_low_without_connection.rb +6 -3
- data/lib/HDLRuby/hruby_low_without_namespace.rb +7 -4
- data/lib/HDLRuby/hruby_low_without_select.rb +13 -0
- data/lib/HDLRuby/hruby_tools.rb +11 -1
- data/lib/HDLRuby/hruby_verilog.rb +1572 -1723
- data/lib/HDLRuby/sim/hruby_sim.h +29 -3
- data/lib/HDLRuby/sim/hruby_sim_calc.c +63 -6
- data/lib/HDLRuby/sim/hruby_sim_core.c +24 -9
- data/lib/HDLRuby/sim/hruby_sim_vcd.c +7 -3
- data/lib/HDLRuby/sim/hruby_sim_vizualize.c +22 -6
- data/lib/HDLRuby/std/fixpoint.rb +9 -0
- data/lib/HDLRuby/std/function_generator.rb +139 -0
- data/lib/HDLRuby/std/hruby_unit.rb +75 -0
- data/lib/HDLRuby/version.rb +1 -1
- metadata +16 -5
@@ -46,11 +46,13 @@ module HDLRuby
|
|
46
46
|
# Iterate over all the id with their object.
|
47
47
|
#
|
48
48
|
# Returns an enumerator if no ruby block is given.
|
49
|
+
#
|
50
|
+
# NOTE: converts the hash to an array to allow on-the-fly modification.
|
49
51
|
def self.each(&ruby_block)
|
50
52
|
# No ruby block? Return an enumerator.
|
51
53
|
return to_enum(:each) unless ruby_block
|
52
54
|
# A ruby block? Apply it on each object.
|
53
|
-
@@id_map.each(&ruby_block)
|
55
|
+
@@id_map.to_a.each(&ruby_block)
|
54
56
|
end
|
55
57
|
|
56
58
|
# The decorator also need to add properties to the HDLRuby objects.
|
data/lib/HDLRuby/hruby_high.rb
CHANGED
@@ -620,8 +620,8 @@ module HDLRuby::High
|
|
620
620
|
# Extend the instance.
|
621
621
|
instance.eigen_extend(@singleton_instanceO)
|
622
622
|
# puts "instance scope= #{instance.systemT.scope}"
|
623
|
-
# Add the instance.
|
624
|
-
High.top_user.send(:add_systemI,instance)
|
623
|
+
# Add the instance if instantiating within another system.
|
624
|
+
High.top_user.send(:add_systemI,instance) if High.top_user
|
625
625
|
|
626
626
|
# Execute the post instantiation tasks.
|
627
627
|
eigen.each_on_instance { |task| task.(instance) }
|
@@ -762,6 +762,7 @@ module HDLRuby::High
|
|
762
762
|
self.scope.to_low)
|
763
763
|
# For debugging: set the source high object
|
764
764
|
systemTL.properties[:low2high] = self.hdr_id
|
765
|
+
self.properties[:high2low] = systemTL
|
765
766
|
|
766
767
|
# Fills the interface of the new system
|
767
768
|
# from the included systems.
|
@@ -936,8 +937,19 @@ module HDLRuby::High
|
|
936
937
|
# Set the namespace for buidling the scope.
|
937
938
|
High.space_push(@namespace)
|
938
939
|
# Build the scope.
|
939
|
-
@return_value = High.top_user.instance_eval(&ruby_block)
|
940
|
+
# @return_value = High.top_user.instance_eval(&ruby_block)
|
941
|
+
res = High.top_user.instance_eval(&ruby_block)
|
940
942
|
High.space_pop
|
943
|
+
# Now gain access to the result within the sub scope.
|
944
|
+
if (res.is_a?(HRef)) then
|
945
|
+
@return_value = res.type.inner(HDLRuby.uniq_name)
|
946
|
+
High.space_push(@namespace)
|
947
|
+
@return_value <= res
|
948
|
+
High.space_pop
|
949
|
+
else
|
950
|
+
@return_value = res
|
951
|
+
end
|
952
|
+
# This will be the return value.
|
941
953
|
@return_value
|
942
954
|
end
|
943
955
|
|
@@ -1298,6 +1310,7 @@ module HDLRuby::High
|
|
1298
1310
|
scopeL = HDLRuby::Low::Scope.new(self.name)
|
1299
1311
|
# For debugging: set the source high object
|
1300
1312
|
scopeL.properties[:low2high] = self.hdr_id
|
1313
|
+
self.properties[:high2low] = scopeL
|
1301
1314
|
|
1302
1315
|
# Push the private namespace for the low generation.
|
1303
1316
|
High.space_push(@namespace)
|
@@ -1531,6 +1544,7 @@ module HDLRuby::High
|
|
1531
1544
|
typeL = HDLRuby::Low::Type.new(name)
|
1532
1545
|
# For debugging: set the source high object
|
1533
1546
|
typeL.properties[:low2high] = self.hdr_id
|
1547
|
+
self.properties[:high2low] = typeL
|
1534
1548
|
return typeL
|
1535
1549
|
end
|
1536
1550
|
end
|
@@ -1616,6 +1630,18 @@ module HDLRuby::High
|
|
1616
1630
|
include HbasicType
|
1617
1631
|
end
|
1618
1632
|
|
1633
|
+
# The string type
|
1634
|
+
StringT = define_type(:string)
|
1635
|
+
class << StringT
|
1636
|
+
# Converts the type to HDLRuby::Low.
|
1637
|
+
def to_low
|
1638
|
+
return Low::StringT
|
1639
|
+
end
|
1640
|
+
|
1641
|
+
include HbasicType
|
1642
|
+
end
|
1643
|
+
|
1644
|
+
|
1619
1645
|
# # The infer type.
|
1620
1646
|
# # Unspecified, but automatically infered when connected.
|
1621
1647
|
# Infer = define_type(:infer)
|
@@ -1672,6 +1698,7 @@ module HDLRuby::High
|
|
1672
1698
|
typeDefL = HDLRuby::Low::TypeDef.new(name,self.def.to_low)
|
1673
1699
|
# For debugging: set the source high object
|
1674
1700
|
typeDefL.properties[:low2high] = self.hdr_id
|
1701
|
+
self.properties[:high2low] = typeDefL
|
1675
1702
|
return typeDefL
|
1676
1703
|
end
|
1677
1704
|
end
|
@@ -1724,6 +1751,7 @@ module HDLRuby::High
|
|
1724
1751
|
typeDefL = HDLRuby::Low::TypeDef.new(name,self.def.to_low)
|
1725
1752
|
# For debugging: set the source high object
|
1726
1753
|
typeDefL.properties[:low2high] = self.hdr_id
|
1754
|
+
self.properties[:high2low] = typeDefL
|
1727
1755
|
return typeDefL
|
1728
1756
|
end
|
1729
1757
|
end
|
@@ -1741,6 +1769,7 @@ module HDLRuby::High
|
|
1741
1769
|
self.range.to_low)
|
1742
1770
|
# For debugging: set the source high object
|
1743
1771
|
typeVectorL.properties[:low2high] = self.hdr_id
|
1772
|
+
self.properties[:high2low] = typeVectorL
|
1744
1773
|
return typeVectorL
|
1745
1774
|
end
|
1746
1775
|
end
|
@@ -1820,6 +1849,7 @@ module HDLRuby::High
|
|
1820
1849
|
*@types.map { |type| type.to_low } )
|
1821
1850
|
# For debugging: set the source high object
|
1822
1851
|
typeTupleL.properties[:low2high] = self.hdr_id
|
1852
|
+
self.properties[:high2low] = typeTupleL
|
1823
1853
|
return typeTupleL
|
1824
1854
|
end
|
1825
1855
|
end
|
@@ -1840,6 +1870,7 @@ module HDLRuby::High
|
|
1840
1870
|
@types.map { |name,type| [name,type.to_low] } )
|
1841
1871
|
# For debugging: set the source high object
|
1842
1872
|
typeStructL.properties[:low2high] = self.hdr_id
|
1873
|
+
self.properties[:high2low] = typeStructL
|
1843
1874
|
return typeStructL
|
1844
1875
|
end
|
1845
1876
|
end
|
@@ -2007,7 +2038,8 @@ module HDLRuby::High
|
|
2007
2038
|
else
|
2008
2039
|
# No, perform a connection is order of declaration
|
2009
2040
|
connects.each.with_index do |csig,i|
|
2010
|
-
|
2041
|
+
csig = csig.to_expr
|
2042
|
+
# puts "csig=#{csig} i=#{i}"
|
2011
2043
|
# puts "systemT inputs=#{systemT.each_input.to_a.size}"
|
2012
2044
|
# Gets i-est signal to connect
|
2013
2045
|
ssig = self.systemT.get_interface_with_included(i)
|
@@ -2078,6 +2110,7 @@ module HDLRuby::High
|
|
2078
2110
|
systemTL)
|
2079
2111
|
# For debugging: set the source high object
|
2080
2112
|
systemIL.properties[:low2high] = self.hdr_id
|
2113
|
+
self.properties[:high2low] = systemIL
|
2081
2114
|
# Adds the other systemTs.
|
2082
2115
|
self.each_systemT do |systemT|
|
2083
2116
|
systemIL.add_systemT(systemT.to_low) unless systemT == self.systemT
|
@@ -2105,6 +2138,7 @@ module HDLRuby::High
|
|
2105
2138
|
end)
|
2106
2139
|
# For debugging: set the source high object
|
2107
2140
|
chunkL.properties[:low2high] = self.hdr_id
|
2141
|
+
self.properties[:high2low] = chunkL
|
2108
2142
|
return chunkL
|
2109
2143
|
end
|
2110
2144
|
end
|
@@ -2118,6 +2152,7 @@ module HDLRuby::High
|
|
2118
2152
|
codeL = HDLRuby::Low::Code.new
|
2119
2153
|
# For debugging: set the source high object
|
2120
2154
|
codeL.properties[:low2high] = self.hdr_id
|
2155
|
+
self.properties[:high2low] = codeL
|
2121
2156
|
# Add the low-level events.
|
2122
2157
|
self.each_event { |event| codeL.add_event(event.to_low) }
|
2123
2158
|
# Add the low-level code chunks.
|
@@ -2211,6 +2246,7 @@ module HDLRuby::High
|
|
2211
2246
|
self.each_noif {|cond,block| ifL.add_noif(cond.to_low,block.to_low)}
|
2212
2247
|
# For debugging: set the source high object
|
2213
2248
|
ifL.properties[:low2high] = self.hdr_id
|
2249
|
+
self.properties[:high2low] = ifL
|
2214
2250
|
return ifL
|
2215
2251
|
end
|
2216
2252
|
end
|
@@ -2235,6 +2271,7 @@ module HDLRuby::High
|
|
2235
2271
|
self.statement.to_low)
|
2236
2272
|
# For debugging: set the source high object
|
2237
2273
|
whenL.properties[:low2high] = self.hdr_id
|
2274
|
+
self.properties[:high2low] = whenL
|
2238
2275
|
return whenL
|
2239
2276
|
end
|
2240
2277
|
end
|
@@ -2282,6 +2319,7 @@ module HDLRuby::High
|
|
2282
2319
|
caseL = HDLRuby::Low::Case.new(@value.to_low)
|
2283
2320
|
# For debugging: set the source high object
|
2284
2321
|
caseL.properties[:low2high] = self.hdr_id
|
2322
|
+
self.properties[:high2low] = caseL
|
2285
2323
|
# Add each when case.
|
2286
2324
|
self.each_when do |w|
|
2287
2325
|
caseL.add_when(w.to_low)
|
@@ -2312,6 +2350,7 @@ module HDLRuby::High
|
|
2312
2350
|
delayL = HDLRuby::Low::Delay.new(self.value, self.unit)
|
2313
2351
|
# For debugging: set the source high object
|
2314
2352
|
delayL.properties[:low2high] = self.hdr_id
|
2353
|
+
self.properties[:high2low] = delayL
|
2315
2354
|
return delayL
|
2316
2355
|
end
|
2317
2356
|
end
|
@@ -2327,6 +2366,7 @@ module HDLRuby::High
|
|
2327
2366
|
timeWaitL = HDLRuby::Low::TimeWait.new(self.delay.to_low)
|
2328
2367
|
# For debugging: set the source high object
|
2329
2368
|
timeWaitL.properties[:low2high] = self.hdr_id
|
2369
|
+
self.properties[:high2low] = timeWaitL
|
2330
2370
|
return timeWaitL
|
2331
2371
|
end
|
2332
2372
|
end
|
@@ -2345,6 +2385,7 @@ module HDLRuby::High
|
|
2345
2385
|
self.delay.to_low)
|
2346
2386
|
# For debugging: set the source high object
|
2347
2387
|
timeRepeatL.properties[:low2high] = self.hdr_id
|
2388
|
+
self.properties[:high2low] = timeRepeatL
|
2348
2389
|
return timeRepeatL
|
2349
2390
|
end
|
2350
2391
|
end
|
@@ -2493,6 +2534,35 @@ module HDLRuby::High
|
|
2493
2534
|
return self.ljust(self[-1])
|
2494
2535
|
end
|
2495
2536
|
|
2537
|
+
# Match the type with +typ+:
|
2538
|
+
# - Recurse on the sub expr if hierachical type, raising an arror
|
2539
|
+
# if the expression is not hierarchical.
|
2540
|
+
# - Directly cast otherwise.
|
2541
|
+
def match_type(typ)
|
2542
|
+
# Has the type sub types?
|
2543
|
+
if typ.types? then
|
2544
|
+
unless self.is_a?(Concat) then
|
2545
|
+
raise AnyError,
|
2546
|
+
"Invalid class for assignment to hierarchical: #{self.class}."
|
2547
|
+
end
|
2548
|
+
return Concat.new(typ,
|
2549
|
+
self.each_expression.zip(typ.each_type).map do |e,t|
|
2550
|
+
e.match_type(t)
|
2551
|
+
end)
|
2552
|
+
elsif typ.vector? && typ.base.hierarchical? then
|
2553
|
+
unless self.is_a?(Concat) then
|
2554
|
+
raise AnyError,
|
2555
|
+
"Invalid class for assignment to hierarchical: #{self.class}."
|
2556
|
+
end
|
2557
|
+
return Concat.new(typ,
|
2558
|
+
self.each_expression.map do |e|
|
2559
|
+
e.match_type(typ.base)
|
2560
|
+
end)
|
2561
|
+
else
|
2562
|
+
return self.as(typ)
|
2563
|
+
end
|
2564
|
+
end
|
2565
|
+
|
2496
2566
|
# Gets the origin method for operation +op+.
|
2497
2567
|
def self.orig_operator(op)
|
2498
2568
|
return (op.to_s + "_orig").to_sym
|
@@ -2641,14 +2711,19 @@ module HDLRuby::High
|
|
2641
2711
|
#
|
2642
2712
|
# NOTE: it is converted afterward to an expression if required.
|
2643
2713
|
def <=(expr)
|
2714
|
+
# Cast expr to self if required.
|
2715
|
+
expr = expr.to_expr.match_type(self.type)
|
2716
|
+
# Generate the transmit.
|
2644
2717
|
if High.top_user.is_a?(HDLRuby::Low::Block) then
|
2645
2718
|
# We are in a block, so generate and add a Transmit.
|
2646
2719
|
High.top_user.
|
2647
|
-
add_statement(Transmit.new(self.to_ref,expr.to_expr))
|
2720
|
+
# add_statement(Transmit.new(self.to_ref,expr.to_expr))
|
2721
|
+
add_statement(Transmit.new(self.to_ref,expr))
|
2648
2722
|
else
|
2649
2723
|
# We are in a system type, so generate and add a Connection.
|
2650
2724
|
High.top_user.
|
2651
|
-
add_connection(Connection.new(self.to_ref,expr.to_expr))
|
2725
|
+
# add_connection(Connection.new(self.to_ref,expr.to_expr))
|
2726
|
+
add_connection(Connection.new(self.to_ref,expr))
|
2652
2727
|
end
|
2653
2728
|
end
|
2654
2729
|
end
|
@@ -2670,6 +2745,7 @@ module HDLRuby::High
|
|
2670
2745
|
castL =HDLRuby::Low::Cast.new(self.type.to_low,self.child.to_low)
|
2671
2746
|
# For debugging: set the source high object
|
2672
2747
|
castL.properties[:low2high] = self.hdr_id
|
2748
|
+
self.properties[:high2low] = castL
|
2673
2749
|
return castL
|
2674
2750
|
end
|
2675
2751
|
end
|
@@ -2693,6 +2769,7 @@ module HDLRuby::High
|
|
2693
2769
|
self.child.to_low)
|
2694
2770
|
# For debugging: set the source high object
|
2695
2771
|
unaryL.properties[:low2high] = self.hdr_id
|
2772
|
+
self.properties[:high2low] = unaryL
|
2696
2773
|
return unaryL
|
2697
2774
|
end
|
2698
2775
|
end
|
@@ -2717,6 +2794,7 @@ module HDLRuby::High
|
|
2717
2794
|
self.left.to_low, self.right.to_low)
|
2718
2795
|
# For debugging: set the source high object
|
2719
2796
|
binaryL.properties[:low2high] = self.hdr_id
|
2797
|
+
self.properties[:high2low] = binaryL
|
2720
2798
|
return binaryL
|
2721
2799
|
end
|
2722
2800
|
end
|
@@ -2751,6 +2829,7 @@ module HDLRuby::High
|
|
2751
2829
|
end)
|
2752
2830
|
# For debugging: set the source high object
|
2753
2831
|
selectL.properties[:low2high] = self.hdr_id
|
2832
|
+
self.properties[:high2low] = selectL
|
2754
2833
|
return selectL
|
2755
2834
|
end
|
2756
2835
|
end
|
@@ -2784,6 +2863,7 @@ module HDLRuby::High
|
|
2784
2863
|
)
|
2785
2864
|
# For debugging: set the source high object
|
2786
2865
|
concatL.properties[:low2high] = self.hdr_id
|
2866
|
+
self.properties[:high2low] = concatL
|
2787
2867
|
return concatL
|
2788
2868
|
end
|
2789
2869
|
end
|
@@ -2827,6 +2907,7 @@ module HDLRuby::High
|
|
2827
2907
|
valueL = HDLRuby::Low::Value.new(self.type.to_low,self.content)
|
2828
2908
|
# For debugging: set the source high object
|
2829
2909
|
valueL.properties[:low2high] = self.hdr_id
|
2910
|
+
self.properties[:high2low] = valueL
|
2830
2911
|
return valueL
|
2831
2912
|
end
|
2832
2913
|
|
@@ -2929,12 +3010,12 @@ module HDLRuby::High
|
|
2929
3010
|
|
2930
3011
|
# Converts the name reference to a HDLRuby::Low::RefName.
|
2931
3012
|
def to_low
|
2932
|
-
#
|
2933
|
-
# @base.to_ref.to_low,@object.name)
|
3013
|
+
# puts "to_low with base=#{@base} @object=#{@object}"
|
2934
3014
|
refNameL = HDLRuby::Low::RefName.new(self.type.to_low,
|
2935
3015
|
@base.to_ref.to_low,@object.name)
|
2936
3016
|
# For debugging: set the source high object
|
2937
3017
|
refNameL.properties[:low2high] = self.hdr_id
|
3018
|
+
self.properties[:high2low] = refNameL
|
2938
3019
|
return refNameL
|
2939
3020
|
end
|
2940
3021
|
|
@@ -2974,6 +3055,7 @@ module HDLRuby::High
|
|
2974
3055
|
)
|
2975
3056
|
# For debugging: set the source high object
|
2976
3057
|
refConcatL.properties[:low2high] = self.hdr_id
|
3058
|
+
self.properties[:high2low] = refConcatL
|
2977
3059
|
return refConcatL
|
2978
3060
|
end
|
2979
3061
|
end
|
@@ -2997,6 +3079,7 @@ module HDLRuby::High
|
|
2997
3079
|
self.ref.to_low,self.index.to_low)
|
2998
3080
|
# For debugging: set the source high object
|
2999
3081
|
refIndexL.properties[:low2high] = self.hdr_id
|
3082
|
+
self.properties[:high2low] = refIndexL
|
3000
3083
|
return refIndexL
|
3001
3084
|
end
|
3002
3085
|
end
|
@@ -3020,6 +3103,7 @@ module HDLRuby::High
|
|
3020
3103
|
self.ref.to_low,self.range.to_low)
|
3021
3104
|
# For debugging: set the source high object
|
3022
3105
|
refRangeL.properties[:low2high] = self.hdr_id
|
3106
|
+
self.properties[:high2low] = refRangeL
|
3023
3107
|
return refRangeL
|
3024
3108
|
end
|
3025
3109
|
end
|
@@ -3031,7 +3115,7 @@ module HDLRuby::High
|
|
3031
3115
|
|
3032
3116
|
# Converts to a new reference.
|
3033
3117
|
def to_ref
|
3034
|
-
return RefName.new(self.ref.to_ref,self.name)
|
3118
|
+
return RefName.new(self.type,self.ref.to_ref,self.name)
|
3035
3119
|
end
|
3036
3120
|
|
3037
3121
|
# Converts the name reference to HDLRuby::Low.
|
@@ -3042,6 +3126,7 @@ module HDLRuby::High
|
|
3042
3126
|
self.ref.to_low,self.name)
|
3043
3127
|
# For debugging: set the source high object
|
3044
3128
|
refNameL.properties[:low2high] = self.hdr_id
|
3129
|
+
self.properties[:high2low] = refNameL
|
3045
3130
|
return refNameL
|
3046
3131
|
end
|
3047
3132
|
end
|
@@ -3078,14 +3163,49 @@ module HDLRuby::High
|
|
3078
3163
|
refThisL = HDLRuby::Low::RefThis.new
|
3079
3164
|
# For debugging: set the source high object
|
3080
3165
|
refThisL.properties[:low2high] = self.hdr_id
|
3166
|
+
self.properties[:high2low] = refThisL
|
3081
3167
|
return refThisL
|
3082
3168
|
end
|
3083
3169
|
end
|
3084
3170
|
|
3171
|
+
##
|
3172
|
+
# Describes a string.
|
3173
|
+
#
|
3174
|
+
# NOTE: This is not synthesizable!
|
3175
|
+
class StringE < Low::StringE
|
3176
|
+
include HExpression
|
3177
|
+
|
3178
|
+
# Converts to an expression.
|
3179
|
+
def to_expr
|
3180
|
+
return StringE.new(self.content,*self.each_arg.map(&:to_expr))
|
3181
|
+
end
|
3182
|
+
|
3183
|
+
# Converts the connection to HDLRuby::Low.
|
3184
|
+
def to_low
|
3185
|
+
return HDLRuby::Low::StringE.new(self.content,
|
3186
|
+
*self.each_arg.map(&:to_low))
|
3187
|
+
end
|
3188
|
+
end
|
3189
|
+
|
3190
|
+
|
3191
|
+
|
3192
|
+
|
3193
|
+
# Sets the current this to +obj+.
|
3194
|
+
#
|
3195
|
+
# NOTE: do not use a this= style to avoid confusion.
|
3196
|
+
def set_this(obj = proc { RefThis.new })
|
3197
|
+
if (obj.is_a?(Proc)) then
|
3198
|
+
@@this = obj
|
3199
|
+
else
|
3200
|
+
@@this = proc { RefObject.new(RefThis.new,obj) }
|
3201
|
+
end
|
3202
|
+
end
|
3203
|
+
|
3085
3204
|
|
3086
3205
|
# Gives access to the *this* reference.
|
3087
3206
|
def this
|
3088
|
-
RefThis.new
|
3207
|
+
# RefThis.new
|
3208
|
+
@@this.call
|
3089
3209
|
end
|
3090
3210
|
|
3091
3211
|
|
@@ -3116,6 +3236,7 @@ module HDLRuby::High
|
|
3116
3236
|
eventL = HDLRuby::Low::Event.new(self.type,self.ref.to_low)
|
3117
3237
|
# For debugging: set the source high object
|
3118
3238
|
eventL.properties[:low2high] = self.hdr_id
|
3239
|
+
self.properties[:high2low] = eventL
|
3119
3240
|
return eventL
|
3120
3241
|
end
|
3121
3242
|
end
|
@@ -3158,10 +3279,33 @@ module HDLRuby::High
|
|
3158
3279
|
self.right.to_low)
|
3159
3280
|
# For debugging: set the source high object
|
3160
3281
|
transmitL.properties[:low2high] = self.hdr_id
|
3282
|
+
self.properties[:high2low] = transmitL
|
3161
3283
|
return transmitL
|
3162
3284
|
end
|
3163
3285
|
end
|
3164
3286
|
|
3287
|
+
|
3288
|
+
##
|
3289
|
+
# Describes a print statement: not synthesizable!
|
3290
|
+
class Print < Low::Print
|
3291
|
+
High = HDLRuby::High
|
3292
|
+
|
3293
|
+
include HStatement
|
3294
|
+
|
3295
|
+
# Creates a new statement for printing +args+.
|
3296
|
+
def initialize(*args)
|
3297
|
+
# Process the arguments.
|
3298
|
+
super(*args.map(&:to_expr))
|
3299
|
+
end
|
3300
|
+
|
3301
|
+
# Converts the connection to HDLRuby::Low.
|
3302
|
+
def to_low
|
3303
|
+
return HDLRuby::Low::Print.new(*self.each_arg.map(&:to_low))
|
3304
|
+
end
|
3305
|
+
|
3306
|
+
end
|
3307
|
+
|
3308
|
+
|
3165
3309
|
##
|
3166
3310
|
# Describes a connection.
|
3167
3311
|
class Connection < Low::Connection
|
@@ -3228,6 +3372,7 @@ module HDLRuby::High
|
|
3228
3372
|
self.right.to_low)
|
3229
3373
|
# For debugging: set the source high object
|
3230
3374
|
connectionL.properties[:low2high] = self.hdr_id
|
3375
|
+
self.properties[:high2low] = connectionL
|
3231
3376
|
return connectionL
|
3232
3377
|
end
|
3233
3378
|
end
|
@@ -3258,7 +3403,7 @@ module HDLRuby::High
|
|
3258
3403
|
# NOTE: +dir+ can be :input, :output, :inout or :inner
|
3259
3404
|
def initialize(name,type,dir,value = nil)
|
3260
3405
|
# Check the value.
|
3261
|
-
value = value.to_expr if value
|
3406
|
+
value = value.to_expr.match_type(type) if value
|
3262
3407
|
# Initialize the type structure.
|
3263
3408
|
super(name,type,value)
|
3264
3409
|
|
@@ -3341,6 +3486,7 @@ module HDLRuby::High
|
|
3341
3486
|
signalIL = HDLRuby::Low::SignalI.new(name,self.type.to_low)
|
3342
3487
|
# For debugging: set the source high object
|
3343
3488
|
signalIL.properties[:low2high] = self.hdr_id
|
3489
|
+
self.properties[:high2low] = signalIL
|
3344
3490
|
return signalIL
|
3345
3491
|
end
|
3346
3492
|
end
|
@@ -3357,7 +3503,7 @@ module HDLRuby::High
|
|
3357
3503
|
# and +value+.
|
3358
3504
|
def initialize(name,type,value)
|
3359
3505
|
# Check the value is a constant.
|
3360
|
-
value = value.to_expr
|
3506
|
+
value = value.to_expr.match_type(type)
|
3361
3507
|
unless value.constant? then
|
3362
3508
|
raise AnyError,"Non-constant value assignment to constant."
|
3363
3509
|
end
|
@@ -3406,6 +3552,7 @@ module HDLRuby::High
|
|
3406
3552
|
self.value.to_low)
|
3407
3553
|
# For debugging: set the source high object
|
3408
3554
|
signalCL.properties[:low2high] = self.hdr_id
|
3555
|
+
self.properties[:high2low] = signalCL
|
3409
3556
|
return signalCL
|
3410
3557
|
end
|
3411
3558
|
end
|
@@ -3479,13 +3626,6 @@ module HDLRuby::High
|
|
3479
3626
|
# Use its return value.
|
3480
3627
|
return block.return_value
|
3481
3628
|
end
|
3482
|
-
|
3483
|
-
# # Get the current mode of the block.
|
3484
|
-
# #
|
3485
|
-
# # NOTE: for name coherency purpose only.
|
3486
|
-
# def block
|
3487
|
-
# return self.mode
|
3488
|
-
# end
|
3489
3629
|
|
3490
3630
|
# Gets the current block.
|
3491
3631
|
def cur_block
|
@@ -3583,6 +3723,12 @@ module HDLRuby::High
|
|
3583
3723
|
end
|
3584
3724
|
statement.hwhen(match, mode, &ruby_block)
|
3585
3725
|
end
|
3726
|
+
|
3727
|
+
|
3728
|
+
# Prints.
|
3729
|
+
def hprint(*args)
|
3730
|
+
self.add_statement(Print.new(*args))
|
3731
|
+
end
|
3586
3732
|
end
|
3587
3733
|
|
3588
3734
|
|
@@ -3619,6 +3765,7 @@ module HDLRuby::High
|
|
3619
3765
|
blockL = HDLRuby::Low::Block.new(self.mode)
|
3620
3766
|
# For debugging: set the source high object
|
3621
3767
|
blockL.properties[:low2high] = self.hdr_id
|
3768
|
+
self.properties[:high2low] = blockL
|
3622
3769
|
# Push the namespace for the low generation.
|
3623
3770
|
High.space_push(@namespace)
|
3624
3771
|
# Pushes on the name stack for converting the internals of
|
@@ -3688,6 +3835,7 @@ module HDLRuby::High
|
|
3688
3835
|
blockL = HDLRuby::Low::TimeBlock.new(self.mode)
|
3689
3836
|
# For debugging: set the source high object
|
3690
3837
|
blockL.properties[:low2high] = self.hdr_id
|
3838
|
+
self.properties[:high2low] = blockL
|
3691
3839
|
# Add the inner signals
|
3692
3840
|
self.each_inner { |inner| blockL.add_inner(inner.to_low) }
|
3693
3841
|
# Add the statements
|
@@ -3781,6 +3929,7 @@ module HDLRuby::High
|
|
3781
3929
|
behaviorL = HDLRuby::Low::Behavior.new(blockL)
|
3782
3930
|
# For debugging: set the source high object
|
3783
3931
|
behaviorL.properties[:low2high] = self.hdr_id
|
3932
|
+
self.properties[:high2low] = behaviorL
|
3784
3933
|
eventLs.each(&behaviorL.method(:add_event))
|
3785
3934
|
return behaviorL
|
3786
3935
|
end
|
@@ -3810,7 +3959,8 @@ module HDLRuby::High
|
|
3810
3959
|
timeBehaviorL = HDLRuby::Low::TimeBehavior.new(blockL)
|
3811
3960
|
# For debugging: set the source high object
|
3812
3961
|
timeBehaviorL.properties[:low2high] = self.hdr_id
|
3813
|
-
|
3962
|
+
self.properties[:high2low] = timeBehaviorL
|
3963
|
+
eventLs.each(&timeBehaviorL.method(:add_event))
|
3814
3964
|
return timeBehaviorL
|
3815
3965
|
end
|
3816
3966
|
end
|
@@ -4116,13 +4266,40 @@ module HDLRuby::High
|
|
4116
4266
|
|
4117
4267
|
# Extends the String class for computing conversion to expression.
|
4118
4268
|
class ::String
|
4119
|
-
# Converts to a new high-level expression.
|
4120
|
-
def to_expr
|
4269
|
+
# # Converts to a new high-level expression.
|
4270
|
+
# def to_expr
|
4271
|
+
# # Convert the string to a bit string.
|
4272
|
+
# bstr = BitString.new(self)
|
4273
|
+
# # Use it to create the new value.
|
4274
|
+
# return Value.new(Bit[bstr.width],self)
|
4275
|
+
# end
|
4276
|
+
|
4277
|
+
# Converts to a new high-level value.
|
4278
|
+
def to_value
|
4121
4279
|
# Convert the string to a bit string.
|
4122
4280
|
bstr = BitString.new(self)
|
4123
4281
|
# Use it to create the new value.
|
4124
4282
|
return Value.new(Bit[bstr.width],self)
|
4125
4283
|
end
|
4284
|
+
|
4285
|
+
# Convert to a new high-level string expression
|
4286
|
+
def to_expr
|
4287
|
+
return StringE.new(self)
|
4288
|
+
end
|
4289
|
+
|
4290
|
+
# For now deactivated, needs rethinking.
|
4291
|
+
# # Rework format to generate HDLRuby string.
|
4292
|
+
# alias_method :__format_old__, :%
|
4293
|
+
# def %(args)
|
4294
|
+
# # Is there any HW argument?
|
4295
|
+
# if args.any? { |arg| arg.is_a?(HDLRuby::Low::Hparent) } then
|
4296
|
+
# # Yes generate a HDLRuby string.
|
4297
|
+
# return StringE.new(self,*args)
|
4298
|
+
# else
|
4299
|
+
# # No process the format normally.
|
4300
|
+
# self.__format_old__(args)
|
4301
|
+
# end
|
4302
|
+
# end
|
4126
4303
|
end
|
4127
4304
|
|
4128
4305
|
|
@@ -4216,11 +4393,14 @@ module HDLRuby::High
|
|
4216
4393
|
|
4217
4394
|
# Converts to a new high-level expression.
|
4218
4395
|
def to_expr
|
4219
|
-
# expr = Concat.new
|
4220
|
-
|
4221
|
-
|
4222
|
-
|
4223
|
-
|
4396
|
+
# expr = Concat.new(TypeTuple.new(:"",:little,*self.map do |elem|
|
4397
|
+
# elem.to_expr.type
|
4398
|
+
# end))
|
4399
|
+
elems = self.map {|elem| elem.to_expr }
|
4400
|
+
typ= TypeTuple.new(:"",:little)
|
4401
|
+
elems.each {|elem| typ.add_type(elem.type) }
|
4402
|
+
expr = Concat.new(typ)
|
4403
|
+
elems.each {|elem| expr.add_expression(elem) }
|
4224
4404
|
expr
|
4225
4405
|
end
|
4226
4406
|
|
@@ -4291,6 +4471,11 @@ module HDLRuby::High
|
|
4291
4471
|
end
|
4292
4472
|
end
|
4293
4473
|
|
4474
|
+
# Add support of the left arrow operator.
|
4475
|
+
def <=(expr)
|
4476
|
+
self.to_expr <= expr
|
4477
|
+
end
|
4478
|
+
|
4294
4479
|
# Array construction shortcuts
|
4295
4480
|
|
4296
4481
|
# Create an array whose number of elements is given by the content
|
@@ -4583,6 +4768,9 @@ def self.configure_high
|
|
4583
4768
|
end
|
4584
4769
|
end
|
4585
4770
|
|
4771
|
+
# Initialize the this.
|
4772
|
+
set_this
|
4773
|
+
|
4586
4774
|
# Generate the standard signals
|
4587
4775
|
$clk = Universe.scope.inner :__universe__clk__
|
4588
4776
|
$rst = Universe.scope.inner :__universe__rst__
|