HDLRuby 3.7.6 → 3.7.7
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/lib/HDLRuby/std/sequencer_sw.rb +93 -30
- data/lib/HDLRuby/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15e4da96afaa32db3686dcbad0ea327db644719dadfdba4ed6dcef1464f1e391
|
4
|
+
data.tar.gz: 1d08ab446037ab8ae6b86e6394a209a03ef06e8bcf233d10d9af25d059873f47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 444499b3dc4f0577f113630a521bf7de67186f8dc2936c8626b91fd1dc556fac9b5f361f7265dbe81123c6a8391054eca2d57076e3067653b41c9566125d5b65
|
7
|
+
data.tar.gz: 9284989cce6b6006c3551e6d5f8e40a29a8c16726d168cab4347f27b596eac1962f045cd260c072ad0be31665e69f2f84ce6406e28b65d378262bc7586c39fbb
|
@@ -1325,10 +1325,10 @@ module RubyHDL::High
|
|
1325
1325
|
return @base.to_c + "[#{self.size.to_i}]"
|
1326
1326
|
else
|
1327
1327
|
# Simple vector type case.
|
1328
|
-
if float? then
|
1328
|
+
if @base.float? then
|
1329
1329
|
return @base.to_c
|
1330
1330
|
else
|
1331
|
-
return @base + " long long"
|
1331
|
+
return @base.to_c + " long long"
|
1332
1332
|
end
|
1333
1333
|
end
|
1334
1334
|
end
|
@@ -1338,7 +1338,7 @@ module RubyHDL::High
|
|
1338
1338
|
if @base.is_a?(TypeVector) then
|
1339
1339
|
# Array type case.
|
1340
1340
|
base_init = @base.to_c_init
|
1341
|
-
return "
|
1341
|
+
return "{" + ([base_init] * self.size.to_i).join(",") + "}"
|
1342
1342
|
else
|
1343
1343
|
return "0"
|
1344
1344
|
end
|
@@ -1919,7 +1919,13 @@ module RubyHDL::High
|
|
1919
1919
|
end
|
1920
1920
|
|
1921
1921
|
# Convert to C code.
|
1922
|
-
|
1922
|
+
def to_c
|
1923
|
+
if @content.is_a?(::Array) then
|
1924
|
+
return "{" + @content.to_s[1..-2] + "}"
|
1925
|
+
else
|
1926
|
+
return @content.to_s
|
1927
|
+
end
|
1928
|
+
end
|
1923
1929
|
end
|
1924
1930
|
|
1925
1931
|
|
@@ -2000,10 +2006,11 @@ module RubyHDL::High
|
|
2000
2006
|
|
2001
2007
|
# Convert to C code.
|
2002
2008
|
def to_c
|
2003
|
-
return "switch(#{@sel.to_c}) {\n" +
|
2004
|
-
|
2005
|
-
|
2006
|
-
|
2009
|
+
# return "switch(#{@sel.to_c}) {\n" +
|
2010
|
+
# @choices.map.with_index do |choice,i|
|
2011
|
+
# "case #{i}:\n#{choice.to_c}\nbreak;"
|
2012
|
+
# end.join("\n") + "\n}"
|
2013
|
+
return "#{@sel.to_c} ? #{@choices[1].to_c} : #{@choices[0].to_c}"
|
2007
2014
|
end
|
2008
2015
|
end
|
2009
2016
|
|
@@ -2112,6 +2119,7 @@ module RubyHDL::High
|
|
2112
2119
|
|
2113
2120
|
# Describes a SW implementation of an range reference.
|
2114
2121
|
class RefRange < Ref
|
2122
|
+
using RubyHDL::High
|
2115
2123
|
attr_reader :base
|
2116
2124
|
|
2117
2125
|
# Create a new index reference with +type+ data type +base+ base
|
@@ -2178,7 +2186,11 @@ module RubyHDL::High
|
|
2178
2186
|
smask = (1.to_value<<(@rng.first+1-@rng.last))-1
|
2179
2187
|
cmask = ~(smask << @rng.last)
|
2180
2188
|
# Get the final base.
|
2181
|
-
|
2189
|
+
if @base.is_a?(Ref) then
|
2190
|
+
base = @base.final_base.to_c
|
2191
|
+
else
|
2192
|
+
base = @base.to_c
|
2193
|
+
end
|
2182
2194
|
# Generate the ruby code.
|
2183
2195
|
return "(#{base} & #{cmask.to_c}) >> (#{@rng.last.to_c})"
|
2184
2196
|
end
|
@@ -2256,7 +2268,7 @@ module RubyHDL::High
|
|
2256
2268
|
def to_c
|
2257
2269
|
if (@left.is_a?(RefIndex) or @left.is_a?(RefRange)) then
|
2258
2270
|
if @left.base.type.base.is_a?(TypeVector) then
|
2259
|
-
return "#{@left.to_c} = #{@right.to_c}"
|
2271
|
+
return "#{@left.to_c} = #{@right.to_c};"
|
2260
2272
|
else
|
2261
2273
|
# Get the access range.
|
2262
2274
|
rng = @left.range
|
@@ -2275,7 +2287,7 @@ module RubyHDL::High
|
|
2275
2287
|
end
|
2276
2288
|
end
|
2277
2289
|
|
2278
|
-
# Describes a SW implementation of a
|
2290
|
+
# Describes a SW implementation of a sif statement.
|
2279
2291
|
class Sif < Statement
|
2280
2292
|
# Create a new if statement in sequencer +sequencer+
|
2281
2293
|
# with +cond+ condition and +ruby_block+
|
@@ -2336,7 +2348,7 @@ module RubyHDL::High
|
|
2336
2348
|
|
2337
2349
|
# Convert to C code.
|
2338
2350
|
def to_c
|
2339
|
-
res = @sequencer.
|
2351
|
+
res = @sequencer.clk_up_c + "\nif(#{@condition.to_c}) {\n#{@yes_blk.to_c}\n}"
|
2340
2352
|
@elsifs.each do |(cond,blk)|
|
2341
2353
|
res << "\nelse if(#{cond.to_c}) {\n#{blk.to_c}\n}"
|
2342
2354
|
end
|
@@ -2347,6 +2359,33 @@ module RubyHDL::High
|
|
2347
2359
|
end
|
2348
2360
|
end
|
2349
2361
|
|
2362
|
+
# Describes a SW implementation of a hif statement.
|
2363
|
+
class Hif < Sif
|
2364
|
+
# Convert to Ruby code.
|
2365
|
+
def to_ruby
|
2366
|
+
res = "\nif((#{@condition.to_ruby}) != 0)\n#{@yes_blk.to_ruby}\n"
|
2367
|
+
@elsifs.each do |(cond,blk)|
|
2368
|
+
res << "elsif((#{cond.to_ruby}) != 0)\n#{blk.to_ruby}\n"
|
2369
|
+
end
|
2370
|
+
if @else_blk then
|
2371
|
+
res << "else\n#{@else_blk.to_ruby}\n"
|
2372
|
+
end
|
2373
|
+
return res + "end\n"
|
2374
|
+
end
|
2375
|
+
|
2376
|
+
# Convert to C code.
|
2377
|
+
def to_c
|
2378
|
+
res = "\nif(#{@condition.to_c}) {\n#{@yes_blk.to_c}\n}"
|
2379
|
+
@elsifs.each do |(cond,blk)|
|
2380
|
+
res << "\nelse if(#{cond.to_c}) {\n#{blk.to_c}\n}"
|
2381
|
+
end
|
2382
|
+
if @else_blk then
|
2383
|
+
res << "\nelse {\n#{@else_blk.to_c}\n}"
|
2384
|
+
end
|
2385
|
+
return res
|
2386
|
+
end
|
2387
|
+
end
|
2388
|
+
|
2350
2389
|
# Describes a SW implementation of a loop statement.
|
2351
2390
|
class Sloop < Statement
|
2352
2391
|
# Create a new infinite loop statement in sequencer +sequencer+
|
@@ -2494,7 +2533,7 @@ module RubyHDL::High
|
|
2494
2533
|
|
2495
2534
|
# Convert to Ruby code.
|
2496
2535
|
def to_c
|
2497
|
-
return @sequencer.clk_up_c + "\nreturn #{
|
2536
|
+
return @sequencer.clk_up_c + "\nreturn #{@value.to_c};"
|
2498
2537
|
end
|
2499
2538
|
end
|
2500
2539
|
|
@@ -2642,7 +2681,7 @@ module RubyHDL::High
|
|
2642
2681
|
|
2643
2682
|
# Convert to C code.
|
2644
2683
|
def to_c
|
2645
|
-
return "\n__#{name}(" + @args.map {|arg| arg.to_ruby}.join(",") + ");"
|
2684
|
+
return "\n__#{@name}(" + @args.map {|arg| arg.to_ruby}.join(",") + ");"
|
2646
2685
|
end
|
2647
2686
|
|
2648
2687
|
# Create an iterator for a given method +meth+.
|
@@ -3007,7 +3046,7 @@ module RubyHDL::High
|
|
3007
3046
|
def to_c
|
3008
3047
|
return "" if @arguments.empty?
|
3009
3048
|
# Create the format.
|
3010
|
-
format = @arguments.
|
3049
|
+
format = @arguments.map do |arg|
|
3011
3050
|
if arg.is_a?(Expression) then
|
3012
3051
|
arg.type.signed? ? "%lld" : "%llu"
|
3013
3052
|
else
|
@@ -3015,13 +3054,13 @@ module RubyHDL::High
|
|
3015
3054
|
end
|
3016
3055
|
end.join
|
3017
3056
|
return "printf(\"#{format}\"," +
|
3018
|
-
@arguments.
|
3057
|
+
@arguments.map do |arg|
|
3019
3058
|
if arg.is_a?(::String) then
|
3020
|
-
"\"#{arg}\""
|
3059
|
+
"\"#{arg.gsub(/\n/,"\\n")}\""
|
3021
3060
|
else
|
3022
3061
|
arg.to_c
|
3023
3062
|
end
|
3024
|
-
end.join(",")
|
3063
|
+
end.join(",") + ");"
|
3025
3064
|
end
|
3026
3065
|
end
|
3027
3066
|
|
@@ -3459,7 +3498,9 @@ module RubyHDL::High
|
|
3459
3498
|
end
|
3460
3499
|
|
3461
3500
|
# Convert to C code.
|
3462
|
-
|
3501
|
+
def to_c
|
3502
|
+
return "__" + self.name.to_s
|
3503
|
+
end
|
3463
3504
|
|
3464
3505
|
# Check if a value is defined for the signal.
|
3465
3506
|
def value?
|
@@ -3616,14 +3657,14 @@ module RubyHDL::High
|
|
3616
3657
|
# Convert to C code.
|
3617
3658
|
def to_c
|
3618
3659
|
res = ""
|
3619
|
-
# Generate the arguments if any.
|
3620
|
-
if @args.any? then
|
3621
|
-
|
3622
|
-
end
|
3660
|
+
# # Generate the arguments if any.
|
3661
|
+
# if @args.any? then
|
3662
|
+
# res = "(#{@args.map(&:to_c).join(",")})\n"
|
3663
|
+
# end
|
3623
3664
|
# Generate the statements.
|
3624
|
-
res += "{" + @statements.map do |stmnt|
|
3625
|
-
stmnt.
|
3626
|
-
end.join + "}"
|
3665
|
+
res += "{\n" + @statements.map do |stmnt|
|
3666
|
+
stmnt.to_c + "\n"
|
3667
|
+
end.join + "\n}"
|
3627
3668
|
return res
|
3628
3669
|
end
|
3629
3670
|
|
@@ -3663,7 +3704,11 @@ module RubyHDL::High
|
|
3663
3704
|
def sif(cond, &ruby_block)
|
3664
3705
|
self << RubyHDL::High::Sif.new(@sequencer,cond,&ruby_block)
|
3665
3706
|
end
|
3666
|
-
|
3707
|
+
|
3708
|
+
# Create a sequential if statement on +cond+.
|
3709
|
+
def hif(cond, &ruby_block)
|
3710
|
+
self << RubyHDL::High::Hif.new(@sequencer,cond,&ruby_block)
|
3711
|
+
end
|
3667
3712
|
|
3668
3713
|
# Create a sequential elsif statement on +cond+.
|
3669
3714
|
def selsif(cond, &ruby_block)
|
@@ -3769,7 +3814,7 @@ module RubyHDL::High
|
|
3769
3814
|
|
3770
3815
|
# Convert to C code.
|
3771
3816
|
def to_c
|
3772
|
-
return "unsigned long long __#{name}(#{@args.map {|arg| "unsigned long long " + arg.to_c}.join(",")} {\n#{@blk.sequencer.clk_up_c}\n#{@blk.to_c}\n}\n"
|
3817
|
+
return "unsigned long long __#{name}(#{@args.map {|arg| "unsigned long long __" + arg.to_c}.join(",")}) {\n#{@blk.sequencer.clk_up_c}\n#{@blk.to_c}\n}\n"
|
3773
3818
|
end
|
3774
3819
|
end
|
3775
3820
|
|
@@ -3858,11 +3903,29 @@ BUILD
|
|
3858
3903
|
def to_c
|
3859
3904
|
typ = nil
|
3860
3905
|
res = <<-BUILDC
|
3906
|
+
#include <stdio.h>
|
3907
|
+
|
3861
3908
|
#{RubyHDL::High.global_sblock.each_signal.map do |signal|
|
3862
3909
|
typ = signal.type
|
3863
|
-
|
3910
|
+
if signal.value? then
|
3911
|
+
if signal.array? then
|
3912
|
+
typ.base.to_c + " " + signal.to_c + "[#{typ.size}]" " = {" +
|
3913
|
+
signal.value.inspect[1..-2] + "};"
|
3914
|
+
else
|
3915
|
+
typ.to_c + " " + signal.to_c + "=" + signal.value.inspect + ";"
|
3916
|
+
end
|
3917
|
+
else
|
3918
|
+
if signal.array? then
|
3919
|
+
typ.base.to_c + " " + signal.to_c + "[#{typ.size}]" + " =" + typ.to_c_init + ";"
|
3920
|
+
else
|
3921
|
+
typ.to_c + " " + signal.to_c + "=" + typ.to_c_init + ";"
|
3922
|
+
end
|
3923
|
+
end
|
3864
3924
|
end.join("\n")}
|
3865
|
-
|
3925
|
+
|
3926
|
+
#{@sfunctions.map {|n,f| f.to_c }.join("\n\n")}
|
3927
|
+
|
3928
|
+
void sequencer() #{@blk.to_c}
|
3866
3929
|
BUILDC
|
3867
3930
|
return res
|
3868
3931
|
end
|
data/lib/HDLRuby/version.rb
CHANGED