HDLRuby 2.6.3 → 2.6.10
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/hdr_samples/comparison_bench.rb +40 -0
- data/lib/HDLRuby/hdr_samples/multi_timed_bench.rb +54 -0
- data/lib/HDLRuby/hdr_samples/neg_arith_bench.rb +11 -0
- data/lib/HDLRuby/hdr_samples/type_minmax_bench.rb +37 -0
- data/lib/HDLRuby/hdr_samples/with_to_array.rb +29 -0
- data/lib/HDLRuby/hdrcc.rb +1 -0
- data/lib/HDLRuby/hruby_high.rb +22 -3
- data/lib/HDLRuby/hruby_low.rb +31 -0
- data/lib/HDLRuby/hruby_low2c.rb +3 -1
- data/lib/HDLRuby/hruby_verilog_name.rb +50 -32
- data/lib/HDLRuby/sim/hruby_sim.h +16 -2
- data/lib/HDLRuby/sim/hruby_sim_calc.c +293 -18
- data/lib/HDLRuby/sim/hruby_sim_vcd.c +2 -2
- data/lib/HDLRuby/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 219077a50d543c3ecdb964a7bd7571f5c0db02ece82a0efb7670e5531acf437d
|
4
|
+
data.tar.gz: 2bbff4911a6c7ff9ec3c33287b61d4a1b7efd5c7dc789975d89e53b3f42638c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c95ef3fa229c2e9283cd78f86c9f6fa4ad4f80d0e3f6153ee444e2c75d754dc7098a5547ce623f8aa85b1860e24522f8404a6e654849d0250897acca26134f9a
|
7
|
+
data.tar.gz: '023502192d5189e2a85a4d69d3f63bb81d58d38496812be03b8c7c5c92791309412e21cbb4d68aa79f03372d296635cafe55264e5483d12d8eef56236b188aeb'
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# Test the comparison operators.
|
2
|
+
|
3
|
+
# A benchmark for the adder.
|
4
|
+
system :adder_bench do
|
5
|
+
[8].inner :x, :y
|
6
|
+
signed[8].inner :u,:v
|
7
|
+
inner :ue, :ult, :ule, :ugt, :uge
|
8
|
+
inner :se, :slt, :sle, :sgt, :sge
|
9
|
+
|
10
|
+
par do
|
11
|
+
ue <= (x == y)
|
12
|
+
ult <= (x < y)
|
13
|
+
ule <= (x <= y)
|
14
|
+
ugt <= (x > y)
|
15
|
+
uge <= (x >= y)
|
16
|
+
|
17
|
+
se <= (u == v)
|
18
|
+
slt <= (u < v)
|
19
|
+
sle <= (u <= v)
|
20
|
+
sgt <= (u > v)
|
21
|
+
sge <= (u >= v)
|
22
|
+
end
|
23
|
+
|
24
|
+
timed do
|
25
|
+
x <= 0
|
26
|
+
y <= 0
|
27
|
+
u <= 0
|
28
|
+
v <= 0
|
29
|
+
!10.ns
|
30
|
+
x <= 1
|
31
|
+
u <= 1
|
32
|
+
!10.ns
|
33
|
+
y <= 2
|
34
|
+
v <= 2
|
35
|
+
!10.ns
|
36
|
+
x <= 2
|
37
|
+
u <= -2
|
38
|
+
!10.ns
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Test the execution of multiple timed behaviors
|
2
|
+
system :multi_timed do
|
3
|
+
inner :clk1, :clk2, :rst, :button
|
4
|
+
[8].inner :counter1, :counter2
|
5
|
+
|
6
|
+
# The process controlling counter1.
|
7
|
+
par(clk1.posedge) do
|
8
|
+
hif(rst) { counter1 <= 0 }
|
9
|
+
helsif(button) { counter1 <= counter1 + 1 }
|
10
|
+
end
|
11
|
+
|
12
|
+
# The process controlling counter2.
|
13
|
+
par(clk2.posedge) do
|
14
|
+
hif(rst) { counter2 <= 0 }
|
15
|
+
helsif(button) { counter2 <= counter2 + 1 }
|
16
|
+
end
|
17
|
+
|
18
|
+
# The process for clk1
|
19
|
+
timed do
|
20
|
+
50.times do
|
21
|
+
clk1 <= 0
|
22
|
+
!10.ns
|
23
|
+
clk1 <= 1
|
24
|
+
!10.ns
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# The process for clk2
|
29
|
+
timed do
|
30
|
+
80.times do
|
31
|
+
clk2 <= 0
|
32
|
+
!3.ns
|
33
|
+
clk2 <= 1
|
34
|
+
!3.ns
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# The control process
|
39
|
+
timed do
|
40
|
+
rst <= 0
|
41
|
+
button <= 0
|
42
|
+
!10.ns
|
43
|
+
rst <= 1
|
44
|
+
!20.ns
|
45
|
+
rst <= 0
|
46
|
+
!10.ns
|
47
|
+
10.times do
|
48
|
+
button <= 1
|
49
|
+
!20.ns
|
50
|
+
button <= 0
|
51
|
+
!20.ns
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
# A benchmark for testing the arithmetic with signed values.
|
3
3
|
system :neg_arith_bench do
|
4
4
|
signed[11..0].inner :x,:y,:z
|
5
|
+
inner :cmp
|
5
6
|
|
6
7
|
timed do
|
7
8
|
x <= 10
|
@@ -9,41 +10,51 @@ system :neg_arith_bench do
|
|
9
10
|
z <= 0
|
10
11
|
!10.ns
|
11
12
|
z <= 10 * 10
|
13
|
+
cmp <= (10 < 10)
|
12
14
|
!10.ns
|
13
15
|
z <= x * y
|
16
|
+
cmp <= (x < y)
|
14
17
|
!10.ns
|
15
18
|
x <= 10
|
16
19
|
y <= -10
|
17
20
|
!10.ns
|
18
21
|
z <= 10 * (-10)
|
22
|
+
cmp <= (10 < -10)
|
19
23
|
!10.ns
|
20
24
|
z <= x * y
|
25
|
+
cmp <= (x < y)
|
21
26
|
!10.ns
|
22
27
|
x <= -10
|
23
28
|
y <= 10
|
24
29
|
!10.ns
|
25
30
|
z <= (-10) * 10
|
31
|
+
cmp <= (-10 < 10)
|
26
32
|
!10.ns
|
27
33
|
z <= x * y
|
34
|
+
cmp <= (x < y)
|
28
35
|
!10.ns
|
29
36
|
x <= -10
|
30
37
|
y <= -10
|
31
38
|
!10.ns
|
32
39
|
z <= (-10) * (-10)
|
40
|
+
cmp <= (-10 < -10)
|
33
41
|
!10.ns
|
34
42
|
z <= x * y
|
43
|
+
cmp <= (x < y)
|
35
44
|
!10.ns
|
36
45
|
x <= _000000011010
|
37
46
|
y <= _000011111010
|
38
47
|
z <= 0
|
39
48
|
!10.ns
|
40
49
|
z <= x * y
|
50
|
+
cmp <= (x < y)
|
41
51
|
!10.ns
|
42
52
|
x <= _000000011010
|
43
53
|
y <= _111111111010
|
44
54
|
z <= 0
|
45
55
|
!10.ns
|
46
56
|
z <= x * y
|
57
|
+
cmp <= (x < y)
|
47
58
|
!10.ns
|
48
59
|
end
|
49
60
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Test the type method min and max
|
2
|
+
|
3
|
+
# A benchmark for the adder.
|
4
|
+
system :adder_bench do
|
5
|
+
[32].inner :x
|
6
|
+
signed[32].inner :y
|
7
|
+
|
8
|
+
timed do
|
9
|
+
x <= 0
|
10
|
+
y <= 0
|
11
|
+
!10.ns
|
12
|
+
x <= bit[8].max
|
13
|
+
y <= signed[8].max
|
14
|
+
!10.ns
|
15
|
+
x <= bit[8].min
|
16
|
+
y <= signed[8].min
|
17
|
+
!10.ns
|
18
|
+
x <= bit[10].max
|
19
|
+
y <= signed[10].max
|
20
|
+
!10.ns
|
21
|
+
x <= bit[10].min
|
22
|
+
y <= signed[10].min
|
23
|
+
!10.ns
|
24
|
+
x <= bit[16].max
|
25
|
+
y <= signed[16].max
|
26
|
+
!10.ns
|
27
|
+
x <= bit[16].min
|
28
|
+
y <= signed[16].min
|
29
|
+
!10.ns
|
30
|
+
x <= bit[32].max
|
31
|
+
y <= signed[32].max
|
32
|
+
!10.ns
|
33
|
+
x <= bit[32].min
|
34
|
+
y <= signed[32].min
|
35
|
+
!10.ns
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
def connect8(i0,i1,i2,i3,i4,i5,i6,i7,
|
3
|
+
o0,o1,o2,o3,o4,o5,o6,o7)
|
4
|
+
o0 <= i0
|
5
|
+
o1 <= i1
|
6
|
+
o2 <= i2
|
7
|
+
o3 <= i3
|
8
|
+
o4 <= i4
|
9
|
+
o5 <= i5
|
10
|
+
o6 <= i6
|
11
|
+
o7 <= i7
|
12
|
+
end
|
13
|
+
|
14
|
+
# A benchmark for testing the conversion to ruby array of expressions.
|
15
|
+
system :with_to_bench do
|
16
|
+
[8].inner :val
|
17
|
+
inner :b0,:b1,:b2,:b3,:b4,:b5,:b6,:b7
|
18
|
+
|
19
|
+
connect8(*val,b0,b1,b2,b3,b4,b5,b6,b7)
|
20
|
+
|
21
|
+
timed do
|
22
|
+
val <= _01101010
|
23
|
+
!10.ns
|
24
|
+
val <= _01011010
|
25
|
+
!10.ns
|
26
|
+
val <= _00001111
|
27
|
+
!10.ns
|
28
|
+
end
|
29
|
+
end
|
data/lib/HDLRuby/hdrcc.rb
CHANGED
@@ -637,6 +637,7 @@ elsif $options[:clang] then
|
|
637
637
|
name = $output + "/" +
|
638
638
|
HDLRuby::Low::Low2C.c_name(systemT.name) +
|
639
639
|
".c"
|
640
|
+
# puts "for systemT=#{systemT.name} generating: #{name}"
|
640
641
|
# Open the file for current systemT
|
641
642
|
outfile = File.open(name,"w")
|
642
643
|
# Generate the C code in to.
|
data/lib/HDLRuby/hruby_high.rb
CHANGED
@@ -609,7 +609,8 @@ module HDLRuby::High
|
|
609
609
|
# possible arguments +args+.
|
610
610
|
def instantiate(i_name,*args)
|
611
611
|
# Create the eigen type.
|
612
|
-
eigen = self.expand(High.names_create(i_name.to_s + ":T"), *args)
|
612
|
+
# eigen = self.expand(High.names_create(i_name.to_s + ":T"), *args)
|
613
|
+
eigen = self.expand(HDLRuby.uniq_name(i_name.to_s + ":T"), *args)
|
613
614
|
|
614
615
|
# Create the instance and sets its eigen system to +eigen+.
|
615
616
|
instance = @instance_class.new(i_name,eigen)
|
@@ -758,8 +759,10 @@ module HDLRuby::High
|
|
758
759
|
"Cannot convert a system without a name to HDLRuby::Low."
|
759
760
|
end
|
760
761
|
# Create the resulting low system type.
|
761
|
-
systemTL = HDLRuby::Low::SystemT.new(High.names_create(name),
|
762
|
+
# systemTL = HDLRuby::Low::SystemT.new(High.names_create(name),
|
763
|
+
systemTL = HDLRuby::Low::SystemT.new(HDLRuby.uniq_name(name),
|
762
764
|
self.scope.to_low)
|
765
|
+
# puts "New low from system #{self.name}: #{systemTL.name}"
|
763
766
|
# For debugging: set the source high object
|
764
767
|
systemTL.properties[:low2high] = self.hdr_id
|
765
768
|
self.properties[:high2low] = systemTL
|
@@ -2655,7 +2658,6 @@ module HDLRuby::High
|
|
2655
2658
|
end
|
2656
2659
|
end
|
2657
2660
|
|
2658
|
-
|
2659
2661
|
# Converts to a select operator using current expression as
|
2660
2662
|
# condition for one of the +choices+.
|
2661
2663
|
#
|
@@ -2671,6 +2673,7 @@ module HDLRuby::High
|
|
2671
2673
|
end
|
2672
2674
|
|
2673
2675
|
|
2676
|
+
|
2674
2677
|
# Methods for conversion for HDLRuby::Low: type processing, flattening
|
2675
2678
|
# and so on
|
2676
2679
|
|
@@ -4234,6 +4237,22 @@ module HDLRuby::High
|
|
4234
4237
|
# end
|
4235
4238
|
# end
|
4236
4239
|
|
4240
|
+
# Extends the TrueClass class for computing for conversion to expression.
|
4241
|
+
class ::TrueClass
|
4242
|
+
# Converts to a new high-level expression.
|
4243
|
+
def to_expr
|
4244
|
+
return Value.new(Integer,1)
|
4245
|
+
end
|
4246
|
+
end
|
4247
|
+
|
4248
|
+
# Extends the FalseClass class for computing for conversion to expression.
|
4249
|
+
class ::FalseClass
|
4250
|
+
# Converts to a new high-level expression.
|
4251
|
+
def to_expr
|
4252
|
+
return Value.new(Integer,0)
|
4253
|
+
end
|
4254
|
+
end
|
4255
|
+
|
4237
4256
|
# Extends the Integer class for computing for conversion to expression.
|
4238
4257
|
class ::Integer
|
4239
4258
|
# Converts to a new high-level expression.
|
data/lib/HDLRuby/hruby_low.rb
CHANGED
@@ -1276,6 +1276,18 @@ module HDLRuby::Low
|
|
1276
1276
|
end
|
1277
1277
|
end
|
1278
1278
|
|
1279
|
+
# Gets the type max value if any.
|
1280
|
+
# Default: not defined.
|
1281
|
+
def max
|
1282
|
+
raise AnyError, "No max value for type #{self}"
|
1283
|
+
end
|
1284
|
+
|
1285
|
+
# Gets the type min value if any.
|
1286
|
+
# Default: not defined.
|
1287
|
+
def min
|
1288
|
+
raise AnyError, "No min value for type #{self}"
|
1289
|
+
end
|
1290
|
+
|
1279
1291
|
# Get the direction of the type, little or big endian.
|
1280
1292
|
def direction
|
1281
1293
|
# By default, little endian.
|
@@ -1617,6 +1629,25 @@ module HDLRuby::Low
|
|
1617
1629
|
return @base.width * ((first-last).abs + 1)
|
1618
1630
|
end
|
1619
1631
|
|
1632
|
+
# Gets the type max value if any.
|
1633
|
+
def max
|
1634
|
+
if (self.signed?) then
|
1635
|
+
return (2**(self.width-1))-1
|
1636
|
+
else
|
1637
|
+
return (2**(self.width))-1
|
1638
|
+
end
|
1639
|
+
end
|
1640
|
+
|
1641
|
+
# Gets the type min value if any.
|
1642
|
+
# Default: not defined.
|
1643
|
+
def min
|
1644
|
+
if (self.signed?) then
|
1645
|
+
return -(2**(self.width-1))
|
1646
|
+
else
|
1647
|
+
return 0
|
1648
|
+
end
|
1649
|
+
end
|
1650
|
+
|
1620
1651
|
# Get the direction of the type, little or big endian.
|
1621
1652
|
def direction
|
1622
1653
|
return @range.first < @range.last ? :big : :little
|
data/lib/HDLRuby/hruby_low2c.rb
CHANGED
@@ -1570,7 +1570,9 @@ module HDLRuby::Low
|
|
1570
1570
|
# puts "content=#{self.content} str=#{str}"
|
1571
1571
|
end
|
1572
1572
|
# Is it a fully defined number?
|
1573
|
-
|
1573
|
+
# NOTE: bignum values are not supported by the simulation engine
|
1574
|
+
# yet, therefore numeric values are limited to 64 max.
|
1575
|
+
if str =~ /^[01]+$/ && str.length <= 64 then
|
1574
1576
|
# Yes, generate a numeral value.
|
1575
1577
|
res << " " * (level+1)*3
|
1576
1578
|
res << "static unsigned long long data[] = { "
|
@@ -10,41 +10,59 @@ module HDLRuby::Verilog
|
|
10
10
|
|
11
11
|
# Since it is possible to use $ and numbers other than the beginning of the character string, it is divided.
|
12
12
|
def name_to_verilog(name)
|
13
|
-
ref = "" # For storing the converted character.
|
14
|
-
name = name.to_s # Ensure name is a string
|
15
|
-
|
16
|
-
if (name[0] =~ /[a-zA-Z]/) then
|
17
|
-
|
18
|
-
|
19
|
-
elsif (name[0] == "_") then
|
20
|
-
|
21
|
-
# If it does not satisfy the above, it is another character.
|
22
|
-
# In that case, convert it to UTF-8 and convert it to a usable character string.
|
23
|
-
else
|
24
|
-
|
13
|
+
# ref = "" # For storing the converted character.
|
14
|
+
# name = name.to_s # Ensure name is a string
|
15
|
+
#
|
16
|
+
# if (name[0] =~ /[a-zA-Z]/) then
|
17
|
+
# ref << name[0]
|
18
|
+
# # _ To convert it to __.
|
19
|
+
# elsif (name[0] == "_") then
|
20
|
+
# ref << "__"
|
21
|
+
# # If it does not satisfy the above, it is another character.
|
22
|
+
# # In that case, convert it to UTF-8 and convert it to a usable character string.
|
23
|
+
# else
|
24
|
+
# l = name[0].bytes.map{|v| v.to_s(16)}.join # Conversion to UTF-8 hexadecimal number.
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
end
|
26
|
+
# ref << "_" + l.rjust(6,"0") # Add an underscore indicating conversion.
|
27
|
+
# # The remainder of 6 digits is filled with 0.
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# name[1..-1].each_char do |c|
|
31
|
+
# # Confirmation of characters in array.
|
32
|
+
# # If it is a-zA-Z 0 - 9, it is added to ref as it is.
|
33
|
+
# if (c =~ /[a-zA-Z0-9]|\$/) then
|
34
|
+
# ref << c
|
35
|
+
# # _ To convert it to __.
|
36
|
+
# elsif (c == "_") then
|
37
|
+
# ref << "__"
|
38
|
+
# # If it does not satisfy the above, it is another character.
|
39
|
+
# # In that case, convert it to UTF-8 and convert it to a usable character string.
|
40
|
+
# else
|
41
|
+
# l = c.bytes.map{|v| v.to_s(16)}.join # Conversion to UTF-8 hexadecimal number.
|
42
|
+
#
|
43
|
+
# ref << "_" + l.rjust(6,"0") # Add an underscore indicating conversion.
|
44
|
+
# # The remainder of 6 digits is filled with 0.
|
45
|
+
# end
|
46
|
+
# end
|
47
|
+
# return ref
|
48
|
+
|
29
49
|
|
30
|
-
|
31
|
-
#
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
# The remainder of 6 digits is filled with 0.
|
50
|
+
name = name.to_s
|
51
|
+
# Convert special characters.
|
52
|
+
name = name.each_char.map do |c|
|
53
|
+
if c=~ /[a-z0-9]/ then
|
54
|
+
c
|
55
|
+
elsif c == "_" then
|
56
|
+
"__"
|
57
|
+
else
|
58
|
+
"_" + c.ord.to_s
|
59
|
+
end
|
60
|
+
end.join
|
61
|
+
# First character: only letter is possible.
|
62
|
+
unless name[0] =~ /[a-z_]/ then
|
63
|
+
name = "_" + name
|
45
64
|
end
|
46
|
-
|
47
|
-
return ref
|
65
|
+
return name
|
48
66
|
end
|
49
67
|
|
50
68
|
#puts ref
|
data/lib/HDLRuby/sim/hruby_sim.h
CHANGED
@@ -219,6 +219,13 @@ Value shift_right_value(Value src0, Value src1, Value dst);
|
|
219
219
|
* @return dst */
|
220
220
|
extern Value equal_value(Value src0, Value src1, Value dst);
|
221
221
|
|
222
|
+
/** Computes the greater comparision of two values.
|
223
|
+
* @param src0 the first source value of the comparison
|
224
|
+
* @param src1 the second source value of the comparison
|
225
|
+
* @param dst the destination value
|
226
|
+
* @return dst */
|
227
|
+
extern Value greater_value(Value src0, Value src1, Value dst);
|
228
|
+
|
222
229
|
/** Computes the lesser comparision of two values.
|
223
230
|
* @param src0 the first source value of the comparison
|
224
231
|
* @param src1 the second source value of the comparison
|
@@ -226,12 +233,19 @@ extern Value equal_value(Value src0, Value src1, Value dst);
|
|
226
233
|
* @return dst */
|
227
234
|
extern Value lesser_value(Value src0, Value src1, Value dst);
|
228
235
|
|
229
|
-
/** Computes the greater comparision of two values.
|
236
|
+
/** Computes the greater or equal comparision of two values.
|
230
237
|
* @param src0 the first source value of the comparison
|
231
238
|
* @param src1 the second source value of the comparison
|
232
239
|
* @param dst the destination value
|
233
240
|
* @return dst */
|
234
|
-
extern Value
|
241
|
+
extern Value greater_equal_value(Value src0, Value src1, Value dst);
|
242
|
+
|
243
|
+
/** Computes the lesser or equal comparision of two values.
|
244
|
+
* @param src0 the first source value of the comparison
|
245
|
+
* @param src1 the second source value of the comparison
|
246
|
+
* @param dst the destination value
|
247
|
+
* @return dst */
|
248
|
+
extern Value lesser_equal_value(Value src0, Value src1, Value dst);
|
235
249
|
|
236
250
|
/** Selects a value depending on a condition.
|
237
251
|
* @param cond the condition to use for selecting a value
|
@@ -686,6 +686,41 @@ static Value mod_value_defined_bitstring(Value src0, Value src1, Value dst) {
|
|
686
686
|
}
|
687
687
|
|
688
688
|
|
689
|
+
/** Computes the greater comparision of two defined bitstring values.
|
690
|
+
* @param src0 the first source value of the addition
|
691
|
+
* @param src1 the second source value of the addition
|
692
|
+
* @param dst the destination value
|
693
|
+
* @return dst */
|
694
|
+
static Value greater_value_defined_bitstring(Value src0, Value src1, Value dst) {
|
695
|
+
/* Sets state of the destination using the first source. */
|
696
|
+
dst->type = src0->type;
|
697
|
+
dst->numeric = 1;
|
698
|
+
|
699
|
+
/* Perform the comparison. */
|
700
|
+
if (src0->type->flags.sign) {
|
701
|
+
if (src1->type->flags.sign) {
|
702
|
+
dst->data_int =
|
703
|
+
((signed long long)value2integer(src0) >
|
704
|
+
(signed long long)value2integer(src1));
|
705
|
+
} else {
|
706
|
+
dst->data_int =
|
707
|
+
((signed long long)value2integer(src0) >
|
708
|
+
(unsigned long long)value2integer(src1));
|
709
|
+
}
|
710
|
+
} else {
|
711
|
+
if (src1->type->flags.sign) {
|
712
|
+
dst->data_int =
|
713
|
+
((unsigned long long)value2integer(src0) >
|
714
|
+
(signed long long)value2integer(src1));
|
715
|
+
} else {
|
716
|
+
dst->data_int =
|
717
|
+
((unsigned long long)value2integer(src0) >
|
718
|
+
(unsigned long long)value2integer(src1));
|
719
|
+
}
|
720
|
+
}
|
721
|
+
return dst;
|
722
|
+
}
|
723
|
+
|
689
724
|
/** Computes the lesser comparision of two defined bitstring values.
|
690
725
|
* @param src0 the first source value of the addition
|
691
726
|
* @param src1 the second source value of the addition
|
@@ -697,23 +732,97 @@ static Value lesser_value_defined_bitstring(Value src0, Value src1, Value dst) {
|
|
697
732
|
dst->numeric = 1;
|
698
733
|
|
699
734
|
/* Perform the comparison. */
|
700
|
-
|
735
|
+
if (src0->type->flags.sign) {
|
736
|
+
if (src1->type->flags.sign) {
|
737
|
+
dst->data_int =
|
738
|
+
((signed long long)value2integer(src0) <
|
739
|
+
(signed long long)value2integer(src1));
|
740
|
+
} else {
|
741
|
+
dst->data_int =
|
742
|
+
((signed long long)value2integer(src0) <
|
743
|
+
(unsigned long long)value2integer(src1));
|
744
|
+
}
|
745
|
+
} else {
|
746
|
+
if (src1->type->flags.sign) {
|
747
|
+
dst->data_int =
|
748
|
+
((unsigned long long)value2integer(src0) <
|
749
|
+
(signed long long)value2integer(src1));
|
750
|
+
} else {
|
751
|
+
dst->data_int =
|
752
|
+
((unsigned long long)value2integer(src0) <
|
753
|
+
(unsigned long long)value2integer(src1));
|
754
|
+
}
|
755
|
+
}
|
701
756
|
return dst;
|
702
757
|
}
|
703
758
|
|
759
|
+
/** Computes the greater or equal comparision of two defined bitstring values.
|
760
|
+
* @param src0 the first source value of the addition
|
761
|
+
* @param src1 the second source value of the addition
|
762
|
+
* @param dst the destination value
|
763
|
+
* @return dst */
|
764
|
+
static Value greater_equal_value_defined_bitstring(Value src0, Value src1, Value dst) {
|
765
|
+
/* Sets state of the destination using the first source. */
|
766
|
+
dst->type = src0->type;
|
767
|
+
dst->numeric = 1;
|
704
768
|
|
705
|
-
|
769
|
+
/* Perform the comparison. */
|
770
|
+
if (src0->type->flags.sign) {
|
771
|
+
if (src1->type->flags.sign) {
|
772
|
+
dst->data_int =
|
773
|
+
((signed long long)value2integer(src0) >=
|
774
|
+
(signed long long)value2integer(src1));
|
775
|
+
} else {
|
776
|
+
dst->data_int =
|
777
|
+
((signed long long)value2integer(src0) >=
|
778
|
+
(unsigned long long)value2integer(src1));
|
779
|
+
}
|
780
|
+
} else {
|
781
|
+
if (src1->type->flags.sign) {
|
782
|
+
dst->data_int =
|
783
|
+
((unsigned long long)value2integer(src0) >=
|
784
|
+
(signed long long)value2integer(src1));
|
785
|
+
} else {
|
786
|
+
dst->data_int =
|
787
|
+
((unsigned long long)value2integer(src0) >=
|
788
|
+
(unsigned long long)value2integer(src1));
|
789
|
+
}
|
790
|
+
}
|
791
|
+
return dst;
|
792
|
+
}
|
793
|
+
|
794
|
+
/** Computes the lesser or equal comparision of two defined bitstring values.
|
706
795
|
* @param src0 the first source value of the addition
|
707
796
|
* @param src1 the second source value of the addition
|
708
797
|
* @param dst the destination value
|
709
798
|
* @return dst */
|
710
|
-
static Value
|
799
|
+
static Value lesser_equal_value_defined_bitstring(Value src0, Value src1, Value dst) {
|
711
800
|
/* Sets state of the destination using the first source. */
|
712
801
|
dst->type = src0->type;
|
713
802
|
dst->numeric = 1;
|
714
803
|
|
715
804
|
/* Perform the comparison. */
|
716
|
-
|
805
|
+
if (src0->type->flags.sign) {
|
806
|
+
if (src1->type->flags.sign) {
|
807
|
+
dst->data_int =
|
808
|
+
((signed long long)value2integer(src0) <=
|
809
|
+
(signed long long)value2integer(src1));
|
810
|
+
} else {
|
811
|
+
dst->data_int =
|
812
|
+
((signed long long)value2integer(src0) <=
|
813
|
+
(unsigned long long)value2integer(src1));
|
814
|
+
}
|
815
|
+
} else {
|
816
|
+
if (src1->type->flags.sign) {
|
817
|
+
dst->data_int =
|
818
|
+
((unsigned long long)value2integer(src0) <=
|
819
|
+
(signed long long)value2integer(src1));
|
820
|
+
} else {
|
821
|
+
dst->data_int =
|
822
|
+
((unsigned long long)value2integer(src0) <=
|
823
|
+
(unsigned long long)value2integer(src1));
|
824
|
+
}
|
825
|
+
}
|
717
826
|
return dst;
|
718
827
|
}
|
719
828
|
|
@@ -1762,13 +1871,49 @@ static Value equal_value_numeric(Value src0, Value src1, Value dst) {
|
|
1762
1871
|
dst->type = src0->type;
|
1763
1872
|
dst->numeric = 1;
|
1764
1873
|
|
1765
|
-
/* Perform the !XOR. */
|
1766
|
-
// dst->data_int = (src0->data_int
|
1767
|
-
|
1874
|
+
// /* Perform the !XOR. */
|
1875
|
+
// dst->data_int = ~(src0->data_int ^ src1->data_int);
|
1876
|
+
/* Perform the comparison. */
|
1877
|
+
dst->data_int = (src0->data_int == src1->data_int) ? 1 : 0;
|
1768
1878
|
return dst;
|
1769
1879
|
}
|
1770
1880
|
|
1771
1881
|
|
1882
|
+
/** Computes the greater comparision of two numeric values.
|
1883
|
+
* @param src0 the first source value of the addition
|
1884
|
+
* @param src1 the second source value of the addition
|
1885
|
+
* @param dst the destination value
|
1886
|
+
* @return the destination value */
|
1887
|
+
static Value greater_value_numeric(Value src0, Value src1, Value dst) {
|
1888
|
+
/* Sets state of the destination using the first source. */
|
1889
|
+
dst->type = src0->type;
|
1890
|
+
dst->numeric = 1;
|
1891
|
+
|
1892
|
+
/* Perform the greater. */
|
1893
|
+
if (src0->type->flags.sign) {
|
1894
|
+
if (src1->type->flags.sign) {
|
1895
|
+
dst->data_int =
|
1896
|
+
((signed long long)src0->data_int >
|
1897
|
+
(signed long long)src1->data_int);
|
1898
|
+
} else {
|
1899
|
+
dst->data_int =
|
1900
|
+
((signed long long)src0->data_int >
|
1901
|
+
(unsigned long long)src1->data_int);
|
1902
|
+
}
|
1903
|
+
} else {
|
1904
|
+
if (src1->type->flags.sign) {
|
1905
|
+
dst->data_int =
|
1906
|
+
((unsigned long long)src0->data_int >
|
1907
|
+
(signed long long)src1->data_int);
|
1908
|
+
} else {
|
1909
|
+
dst->data_int =
|
1910
|
+
((unsigned long long)src0->data_int >
|
1911
|
+
(unsigned long long)src1->data_int);
|
1912
|
+
}
|
1913
|
+
}
|
1914
|
+
return dst;
|
1915
|
+
}
|
1916
|
+
|
1772
1917
|
/** Computes the lesser comparision of two numeric values.
|
1773
1918
|
* @param src0 the first source value of the addition
|
1774
1919
|
* @param src1 the second source value of the addition
|
@@ -1780,22 +1925,97 @@ static Value lesser_value_numeric(Value src0, Value src1, Value dst) {
|
|
1780
1925
|
dst->numeric = 1;
|
1781
1926
|
|
1782
1927
|
/* Perform the lesser. */
|
1783
|
-
|
1928
|
+
if (src0->type->flags.sign) {
|
1929
|
+
if (src1->type->flags.sign) {
|
1930
|
+
dst->data_int =
|
1931
|
+
((signed long long)src0->data_int <
|
1932
|
+
(signed long long)src1->data_int);
|
1933
|
+
} else {
|
1934
|
+
dst->data_int =
|
1935
|
+
((signed long long)src0->data_int <
|
1936
|
+
(unsigned long long)src1->data_int);
|
1937
|
+
}
|
1938
|
+
} else {
|
1939
|
+
if (src1->type->flags.sign) {
|
1940
|
+
dst->data_int =
|
1941
|
+
((unsigned long long)src0->data_int <
|
1942
|
+
(signed long long)src1->data_int);
|
1943
|
+
} else {
|
1944
|
+
dst->data_int =
|
1945
|
+
((unsigned long long)src0->data_int <
|
1946
|
+
(unsigned long long)src1->data_int);
|
1947
|
+
}
|
1948
|
+
}
|
1784
1949
|
return dst;
|
1785
1950
|
}
|
1786
1951
|
|
1787
|
-
/** Computes the greater comparision of two numeric values.
|
1952
|
+
/** Computes the greater or equal comparision of two numeric values.
|
1788
1953
|
* @param src0 the first source value of the addition
|
1789
1954
|
* @param src1 the second source value of the addition
|
1790
1955
|
* @param dst the destination value
|
1791
1956
|
* @return the destination value */
|
1792
|
-
static Value
|
1957
|
+
static Value greater_equal_value_numeric(Value src0, Value src1, Value dst) {
|
1793
1958
|
/* Sets state of the destination using the first source. */
|
1794
1959
|
dst->type = src0->type;
|
1795
1960
|
dst->numeric = 1;
|
1796
1961
|
|
1797
|
-
/* Perform the
|
1798
|
-
|
1962
|
+
/* Perform the greater or equal. */
|
1963
|
+
if (src0->type->flags.sign) {
|
1964
|
+
if (src1->type->flags.sign) {
|
1965
|
+
dst->data_int =
|
1966
|
+
((signed long long)src0->data_int >=
|
1967
|
+
(signed long long)src1->data_int);
|
1968
|
+
} else {
|
1969
|
+
dst->data_int =
|
1970
|
+
((signed long long)src0->data_int >=
|
1971
|
+
(unsigned long long)src1->data_int);
|
1972
|
+
}
|
1973
|
+
} else {
|
1974
|
+
if (src1->type->flags.sign) {
|
1975
|
+
dst->data_int =
|
1976
|
+
((unsigned long long)src0->data_int >=
|
1977
|
+
(signed long long)src1->data_int);
|
1978
|
+
} else {
|
1979
|
+
dst->data_int =
|
1980
|
+
((unsigned long long)src0->data_int >=
|
1981
|
+
(unsigned long long)src1->data_int);
|
1982
|
+
}
|
1983
|
+
}
|
1984
|
+
return dst;
|
1985
|
+
}
|
1986
|
+
|
1987
|
+
/** Computes the lesser or equal comparision of two numeric values.
|
1988
|
+
* @param src0 the first source value of the addition
|
1989
|
+
* @param src1 the second source value of the addition
|
1990
|
+
* @param dst the destination value
|
1991
|
+
* @return the destination value */
|
1992
|
+
static Value lesser_equal_value_numeric(Value src0, Value src1, Value dst) {
|
1993
|
+
/* Sets state of the destination using the first source. */
|
1994
|
+
dst->type = src0->type;
|
1995
|
+
dst->numeric = 1;
|
1996
|
+
|
1997
|
+
/* Perform the lesser or equal. */
|
1998
|
+
if (src0->type->flags.sign) {
|
1999
|
+
if (src1->type->flags.sign) {
|
2000
|
+
dst->data_int =
|
2001
|
+
((signed long long)src0->data_int <=
|
2002
|
+
(signed long long)src1->data_int);
|
2003
|
+
} else {
|
2004
|
+
dst->data_int =
|
2005
|
+
((signed long long)src0->data_int <=
|
2006
|
+
(unsigned long long)src1->data_int);
|
2007
|
+
}
|
2008
|
+
} else {
|
2009
|
+
if (src1->type->flags.sign) {
|
2010
|
+
dst->data_int =
|
2011
|
+
((unsigned long long)src0->data_int <=
|
2012
|
+
(signed long long)src1->data_int);
|
2013
|
+
} else {
|
2014
|
+
dst->data_int =
|
2015
|
+
((unsigned long long)src0->data_int <=
|
2016
|
+
(unsigned long long)src1->data_int);
|
2017
|
+
}
|
2018
|
+
}
|
1799
2019
|
return dst;
|
1800
2020
|
}
|
1801
2021
|
|
@@ -2434,6 +2654,34 @@ Value equal_value(Value src0, Value src1, Value dst) {
|
|
2434
2654
|
}
|
2435
2655
|
|
2436
2656
|
|
2657
|
+
|
2658
|
+
/** Computes the greater comparision of two general values.
|
2659
|
+
* @param src0 the first source value of the addition
|
2660
|
+
* @param src1 the second source value of the addition
|
2661
|
+
* @param dst the destination value
|
2662
|
+
* @return dst */
|
2663
|
+
Value greater_value(Value src0, Value src1, Value dst) {
|
2664
|
+
/* Might allocate a new value so save the current pool state. */
|
2665
|
+
unsigned int pos = get_value_pos();
|
2666
|
+
/* Do a numeric computation if possible, otherwise fallback to bitstring
|
2667
|
+
* computation. */
|
2668
|
+
if (src0->numeric && src1->numeric) {
|
2669
|
+
/* Both sources are numeric. */
|
2670
|
+
return greater_value_numeric(src0,src1,dst);
|
2671
|
+
} else if (is_defined_value(src0) && is_defined_value(src1)) {
|
2672
|
+
/* Both sources can be converted to numeric values. */
|
2673
|
+
return greater_value_defined_bitstring(src0,src1,dst);
|
2674
|
+
} else {
|
2675
|
+
/* Cannot compute (for now), simply undefines the destination. */
|
2676
|
+
/* First ensure dst has the right shape. */
|
2677
|
+
copy_value(src0,dst);
|
2678
|
+
/* Then make it undefined. */
|
2679
|
+
set_undefined_bitstring(dst);
|
2680
|
+
}
|
2681
|
+
return dst;
|
2682
|
+
}
|
2683
|
+
|
2684
|
+
|
2437
2685
|
/** Computes the lesser comparision of two general values.
|
2438
2686
|
* @param src0 the first source value of the addition
|
2439
2687
|
* @param src1 the second source value of the addition
|
@@ -2461,22 +2709,22 @@ Value lesser_value(Value src0, Value src1, Value dst) {
|
|
2461
2709
|
}
|
2462
2710
|
|
2463
2711
|
|
2464
|
-
/** Computes the greater comparision of two
|
2465
|
-
* @param src0 the first source value of the
|
2466
|
-
* @param src1 the second source value of the
|
2712
|
+
/** Computes the greater or equal comparision of two values.
|
2713
|
+
* @param src0 the first source value of the comparison
|
2714
|
+
* @param src1 the second source value of the comparison
|
2467
2715
|
* @param dst the destination value
|
2468
2716
|
* @return dst */
|
2469
|
-
Value
|
2717
|
+
Value greater_equal_value(Value src0, Value src1, Value dst) {
|
2470
2718
|
/* Might allocate a new value so save the current pool state. */
|
2471
2719
|
unsigned int pos = get_value_pos();
|
2472
2720
|
/* Do a numeric computation if possible, otherwise fallback to bitstring
|
2473
2721
|
* computation. */
|
2474
2722
|
if (src0->numeric && src1->numeric) {
|
2475
2723
|
/* Both sources are numeric. */
|
2476
|
-
return
|
2724
|
+
return greater_equal_value_numeric(src0,src1,dst);
|
2477
2725
|
} else if (is_defined_value(src0) && is_defined_value(src1)) {
|
2478
2726
|
/* Both sources can be converted to numeric values. */
|
2479
|
-
return
|
2727
|
+
return greater_equal_value_defined_bitstring(src0,src1,dst);
|
2480
2728
|
} else {
|
2481
2729
|
/* Cannot compute (for now), simply undefines the destination. */
|
2482
2730
|
/* First ensure dst has the right shape. */
|
@@ -2487,6 +2735,33 @@ Value greater_value(Value src0, Value src1, Value dst) {
|
|
2487
2735
|
return dst;
|
2488
2736
|
}
|
2489
2737
|
|
2738
|
+
/** Computes the lesser or equal comparision of two values.
|
2739
|
+
* @param src0 the first source value of the comparison
|
2740
|
+
* @param src1 the second source value of the comparison
|
2741
|
+
* @param dst the destination value
|
2742
|
+
* @return dst */
|
2743
|
+
Value lesser_equal_value(Value src0, Value src1, Value dst) {
|
2744
|
+
/* Might allocate a new value so save the current pool state. */
|
2745
|
+
unsigned int pos = get_value_pos();
|
2746
|
+
/* Do a numeric computation if possible, otherwise fallback to bitstring
|
2747
|
+
* computation. */
|
2748
|
+
if (src0->numeric && src1->numeric) {
|
2749
|
+
/* Both sources are numeric. */
|
2750
|
+
return lesser_equal_value_numeric(src0,src1,dst);
|
2751
|
+
} else if (is_defined_value(src0) && is_defined_value(src1)) {
|
2752
|
+
/* Both sources can be converted to numeric values. */
|
2753
|
+
return lesser_equal_value_defined_bitstring(src0,src1,dst);
|
2754
|
+
} else {
|
2755
|
+
/* Cannot compute (for now), simply undefines the destination. */
|
2756
|
+
/* First ensure dst has the right shape. */
|
2757
|
+
copy_value(src0,dst);
|
2758
|
+
/* Then make it undefined. */
|
2759
|
+
set_undefined_bitstring(dst);
|
2760
|
+
}
|
2761
|
+
return dst;
|
2762
|
+
}
|
2763
|
+
|
2764
|
+
|
2490
2765
|
|
2491
2766
|
/** Selects a value depending on a general condition.
|
2492
2767
|
* @param cond the condition to use for selecting a value
|
@@ -366,8 +366,8 @@ static void vcd_print_header() {
|
|
366
366
|
extern void init_vcd_visualizer(char* name) {
|
367
367
|
/* Open the resulting file with name: <name>.vcd */
|
368
368
|
char filename[256];
|
369
|
-
strncpy(filename,name,
|
370
|
-
strncat(filename,".vcd",
|
369
|
+
strncpy(filename,name,255);
|
370
|
+
strncat(filename,".vcd",255);
|
371
371
|
vcd_file = fopen(filename,"w");
|
372
372
|
|
373
373
|
/* Initialize the vizualizer printer engine. */
|
data/lib/HDLRuby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: HDLRuby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lovic Gauthier
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- lib/HDLRuby/hdr_samples/alu.rb
|
84
84
|
- lib/HDLRuby/hdr_samples/bstr_bench.rb
|
85
85
|
- lib/HDLRuby/hdr_samples/calculator.rb
|
86
|
+
- lib/HDLRuby/hdr_samples/comparison_bench.rb
|
86
87
|
- lib/HDLRuby/hdr_samples/constant_in_function.rb
|
87
88
|
- lib/HDLRuby/hdr_samples/counter_bench.rb
|
88
89
|
- lib/HDLRuby/hdr_samples/dff.rb
|
@@ -102,6 +103,7 @@ files:
|
|
102
103
|
- lib/HDLRuby/hdr_samples/memory_test.rb
|
103
104
|
- lib/HDLRuby/hdr_samples/multer_gen.rb
|
104
105
|
- lib/HDLRuby/hdr_samples/multer_seq.rb
|
106
|
+
- lib/HDLRuby/hdr_samples/multi_timed_bench.rb
|
105
107
|
- lib/HDLRuby/hdr_samples/music.rb
|
106
108
|
- lib/HDLRuby/hdr_samples/named_sub.rb
|
107
109
|
- lib/HDLRuby/hdr_samples/neg_arith_bench.rb
|
@@ -133,6 +135,7 @@ files:
|
|
133
135
|
- lib/HDLRuby/hdr_samples/sw_encrypt_cpusim_bench.rb
|
134
136
|
- lib/HDLRuby/hdr_samples/system_open.rb
|
135
137
|
- lib/HDLRuby/hdr_samples/tuple.rb
|
138
|
+
- lib/HDLRuby/hdr_samples/type_minmax_bench.rb
|
136
139
|
- lib/HDLRuby/hdr_samples/with_channel.rb
|
137
140
|
- lib/HDLRuby/hdr_samples/with_class.rb
|
138
141
|
- lib/HDLRuby/hdr_samples/with_connector.rb
|
@@ -147,6 +150,7 @@ files:
|
|
147
150
|
- lib/HDLRuby/hdr_samples/with_memory_rom.rb
|
148
151
|
- lib/HDLRuby/hdr_samples/with_multi_channels.rb
|
149
152
|
- lib/HDLRuby/hdr_samples/with_reconf.rb
|
153
|
+
- lib/HDLRuby/hdr_samples/with_to_array.rb
|
150
154
|
- lib/HDLRuby/hdrcc.rb
|
151
155
|
- lib/HDLRuby/high_samples/_adder_fault.rb
|
152
156
|
- lib/HDLRuby/high_samples/_generic_transmission2.rb
|