HDLRuby 2.7.1 → 2.7.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/case_bench.rb +23 -18
- data/lib/HDLRuby/hdr_samples/with_init.rb +18 -0
- data/lib/HDLRuby/hdr_samples/with_instance.rb +42 -0
- data/lib/HDLRuby/hdr_samples/with_values.rb +3 -0
- data/lib/HDLRuby/hruby_high.rb +26 -4
- data/lib/HDLRuby/hruby_low.rb +2 -1
- data/lib/HDLRuby/hruby_low2c.rb +6 -12
- data/lib/HDLRuby/sim/hruby_sim.h +3 -0
- data/lib/HDLRuby/sim/hruby_sim_stack_calc.c +11 -0
- data/lib/HDLRuby/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4995e808d0aa2901a483011a4848bb9416d68850c95c74b9c2f2bf1fb3f648dc
|
4
|
+
data.tar.gz: 729643cd60228ab9ba4f3ab719e434b48963805ed6f4ac01dbcff2fdd6eb54b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82316dd87a532dbfa67d86fcdb13ade3f8329912bb6aa56ae0b5a4efe0a6110922912f52ae3558c4683147bb224ae2ed0b67e1d60e265d5d30624b3a2bee77be
|
7
|
+
data.tar.gz: 4df2cfb5c257838246fa2f953b3eeaa751902900ae4ea5319a69ca81f9e7eae49b75163fc621a81b2af1b399360c030ccf8717916c2abb7a5d2ffaad27d2b5df
|
@@ -1,30 +1,35 @@
|
|
1
1
|
# Test the comparison operators.
|
2
2
|
|
3
|
-
# A benchmark for the
|
3
|
+
# A benchmark for the if statement.
|
4
4
|
system :if_bench do
|
5
|
-
[8].inner :x, :
|
5
|
+
[8].inner :x, :z
|
6
6
|
|
7
7
|
par do
|
8
8
|
hcase(x)
|
9
|
-
hwhen(0)
|
10
|
-
hwhen(1)
|
11
|
-
hwhen(2)
|
12
|
-
hwhen(3)
|
13
|
-
|
9
|
+
hwhen(0) { z <= 0 }
|
10
|
+
hwhen(1) { z <= 1 }
|
11
|
+
hwhen(2) { z <= 4 }
|
12
|
+
hwhen(3) { z <= 9 }
|
13
|
+
hwhen(4) { z <= 16 }
|
14
|
+
hwhen(5) { z <= 25 }
|
15
|
+
hwhen(6) { z <= 36 }
|
16
|
+
hwhen(7) { z <= 49 }
|
17
|
+
hwhen(8) { z <= 64 }
|
18
|
+
hwhen(9) { z <= 81 }
|
19
|
+
hwhen(10) { z <= 100 }
|
20
|
+
hwhen(11) { z <= 121 }
|
21
|
+
hwhen(12) { z <= 144 }
|
22
|
+
hwhen(13) { z <= 169 }
|
23
|
+
hwhen(14) { z <= 196 }
|
24
|
+
hwhen(15) { z <= 225 }
|
25
|
+
helse { z <= _zzzzzzzz }
|
14
26
|
end
|
15
27
|
|
16
28
|
timed do
|
17
|
-
x <= 0
|
18
|
-
!10.ns
|
19
|
-
x <= 1
|
20
|
-
!10.ns
|
21
|
-
x <= 2
|
22
|
-
!10.ns
|
23
|
-
x <= 3
|
24
|
-
!10.ns
|
25
|
-
x <= 4
|
26
|
-
!10.ns
|
27
|
-
x <= 5
|
28
29
|
!10.ns
|
30
|
+
20.times do |i|
|
31
|
+
x <= i
|
32
|
+
!10.ns
|
33
|
+
end
|
29
34
|
end
|
30
35
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
# A benchmark for testing the initialization of signals.
|
3
|
+
system :with_init do
|
4
|
+
[8].constant cst0: 127
|
5
|
+
constant cst1: _1
|
6
|
+
[8].inner sig0: _10000000
|
7
|
+
inner sig1: _1
|
8
|
+
[8].inner :sig2
|
9
|
+
|
10
|
+
timed do
|
11
|
+
!10.ns
|
12
|
+
sig2 <= cst0 + cst1
|
13
|
+
sig0 <= sig0 + sig1
|
14
|
+
!10.ns
|
15
|
+
sig2 <= sig2 + sig1
|
16
|
+
!10.ns
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
# A benchmark for testing the instantiations.
|
5
|
+
|
6
|
+
system :adder do |typ|
|
7
|
+
typ.input :x, :y
|
8
|
+
typ.output :z
|
9
|
+
|
10
|
+
z <= x + y
|
11
|
+
end
|
12
|
+
|
13
|
+
system :truc do
|
14
|
+
[8].input :u, :v
|
15
|
+
[8].output :q
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
system :with_instance do
|
21
|
+
|
22
|
+
[8].inner :x0, :y0, :z0, :x1, :y1, :z1
|
23
|
+
|
24
|
+
truc(:montruc).(x0,y0,z0)
|
25
|
+
|
26
|
+
adder(bit[8]).(:adderI0).(x0,y0,z0)
|
27
|
+
adder(bit[8]).(:adderI1).(x: x1, y: y1, z: z1)
|
28
|
+
|
29
|
+
timed do
|
30
|
+
!10.ns
|
31
|
+
x0 <= 0
|
32
|
+
y0 <= 0
|
33
|
+
x1 <= 1
|
34
|
+
y1 <= 1
|
35
|
+
!10.ns
|
36
|
+
x0 <= 1
|
37
|
+
y0 <= 1
|
38
|
+
x1 <= 2
|
39
|
+
y1 <= 2
|
40
|
+
!10.ns
|
41
|
+
end
|
42
|
+
end
|
data/lib/HDLRuby/hruby_high.rb
CHANGED
@@ -256,9 +256,9 @@ module HDLRuby::High
|
|
256
256
|
SignalI.new(name,type,:inner))
|
257
257
|
elsif name.is_a?(Hash) then
|
258
258
|
# Names associated with values.
|
259
|
-
|
259
|
+
name.each do |key,value|
|
260
260
|
res = self.add_inner(
|
261
|
-
SignalI.new(
|
261
|
+
SignalI.new(key,type,:inner,value))
|
262
262
|
end
|
263
263
|
else
|
264
264
|
raise AnyError,
|
@@ -550,10 +550,14 @@ module HDLRuby::High
|
|
550
550
|
expanded = self.class.new(name.to_s) {}
|
551
551
|
# Include the mixin systems given when declaring the system.
|
552
552
|
@to_includes.each { |system| expanded.scope.include(system) }
|
553
|
+
# Include the previously includeds. */
|
554
|
+
self.scope.each_included { |system| expanded.scope.include(system) }
|
553
555
|
|
554
556
|
# Sets the generators of the expanded result.
|
555
557
|
expanded.add_generator(self)
|
556
558
|
@to_includes.each { |system| expanded.add_generator(system) }
|
559
|
+
# Also for the previously includeds. */
|
560
|
+
self.scope.each_included.each { |system| expanded.add_generator(system) }
|
557
561
|
|
558
562
|
# Fills the scope of the expanded class.
|
559
563
|
# puts "Build top with #{self.name} for #{name}"
|
@@ -1237,6 +1241,7 @@ module HDLRuby::High
|
|
1237
1241
|
end
|
1238
1242
|
# Adds it the list of includeds
|
1239
1243
|
@includes[include_name] = system
|
1244
|
+
# puts "@includes=#{@includes}"
|
1240
1245
|
|
1241
1246
|
end
|
1242
1247
|
|
@@ -2033,10 +2038,25 @@ module HDLRuby::High
|
|
2033
2038
|
connects.each do |key,value|
|
2034
2039
|
# Gets the signal corresponding to connect.
|
2035
2040
|
signal = self.get_signal(key)
|
2041
|
+
unless signal then
|
2042
|
+
# Look into the included systems.
|
2043
|
+
self.systemT.scope.each_included do |included|
|
2044
|
+
signal = included.get_signal(key)
|
2045
|
+
break if signal
|
2046
|
+
end
|
2047
|
+
end
|
2036
2048
|
# Check if it is an output.
|
2037
2049
|
isout = self.get_output(key)
|
2050
|
+
unless isout then
|
2051
|
+
# Look into the inlucded systems.
|
2052
|
+
self.systemT.scope.each_included do |included|
|
2053
|
+
isout = included.get_output(key)
|
2054
|
+
break if isout
|
2055
|
+
end
|
2056
|
+
end
|
2038
2057
|
# Convert it to a reference.
|
2039
2058
|
ref = RefObject.new(self.to_ref,signal)
|
2059
|
+
# puts "key=#{key} value=#{value} signal=#{signal} ref=#{ref}"
|
2040
2060
|
# Make the connection.
|
2041
2061
|
if isout then
|
2042
2062
|
value <= ref
|
@@ -3081,7 +3101,8 @@ module HDLRuby::High
|
|
3081
3101
|
# Converts to a new reference.
|
3082
3102
|
def to_ref
|
3083
3103
|
return RefIndex.new(self.type,
|
3084
|
-
self.ref.to_ref,self.index.to_expr)
|
3104
|
+
# self.ref.to_ref,self.index.to_expr)
|
3105
|
+
self.ref.to_expr,self.index.to_expr)
|
3085
3106
|
end
|
3086
3107
|
|
3087
3108
|
# Converts the index reference to HDLRuby::Low.
|
@@ -3496,7 +3517,8 @@ module HDLRuby::High
|
|
3496
3517
|
# Converts the system to HDLRuby::Low and set its +name+.
|
3497
3518
|
def to_low(name = self.name)
|
3498
3519
|
# return HDLRuby::Low::SignalI.new(name,self.type.to_low)
|
3499
|
-
|
3520
|
+
valueL = self.value ? self.value.to_low : nil
|
3521
|
+
signalIL = HDLRuby::Low::SignalI.new(name,self.type.to_low,valueL)
|
3500
3522
|
# # For debugging: set the source high object
|
3501
3523
|
# signalIL.properties[:low2high] = self.hdr_id
|
3502
3524
|
# self.properties[:high2low] = signalIL
|
data/lib/HDLRuby/hruby_low.rb
CHANGED
@@ -5342,7 +5342,8 @@ module HDLRuby::Low
|
|
5342
5342
|
def initialize(type,ref,index)
|
5343
5343
|
super(type)
|
5344
5344
|
# Check and set the accessed reference.
|
5345
|
-
unless ref.is_a?(Ref) then
|
5345
|
+
# unless ref.is_a?(Ref) then
|
5346
|
+
unless ref.is_a?(Expression) then
|
5346
5347
|
raise AnyError, "Invalid class for a reference: #{ref.class}."
|
5347
5348
|
end
|
5348
5349
|
@ref = ref
|
data/lib/HDLRuby/hruby_low2c.rb
CHANGED
@@ -1610,26 +1610,18 @@ module HDLRuby::Low
|
|
1610
1610
|
res << "{\n"
|
1611
1611
|
self.value.to_c(res,level+1)
|
1612
1612
|
res << " " * ((level+1)*3)
|
1613
|
-
res << "
|
1613
|
+
res << "dup();\n"
|
1614
1614
|
# Ensure the selection value is testable.
|
1615
1615
|
res << " " * ((level+1)*3)
|
1616
|
-
res << "if (
|
1616
|
+
res << "if (is_defined()) {\n"
|
1617
1617
|
# The condition is testable.
|
1618
1618
|
# Generate the case as a succession of if statements.
|
1619
|
-
first = true
|
1620
1619
|
self.each_when do |w|
|
1621
1620
|
res << " " * ((level+2)*3)
|
1622
|
-
|
1623
|
-
first = false
|
1624
|
-
else
|
1625
|
-
res << "else "
|
1626
|
-
end
|
1627
|
-
res << "if (value2integer(v) == "
|
1628
|
-
res << "value2integer(({\n"
|
1621
|
+
res << "dup();\n"
|
1629
1622
|
res << " " * ((level+2)*3)
|
1630
1623
|
w.match.to_c(res,level+2)
|
1631
|
-
res << "
|
1632
|
-
res << ")) {\n"
|
1624
|
+
res << "if (to_integer() == to_integer()) {\n"
|
1633
1625
|
w.statement.to_c(res,level+3)
|
1634
1626
|
res << " " * (level+2)*3
|
1635
1627
|
res << "}\n"
|
@@ -1643,6 +1635,8 @@ module HDLRuby::Low
|
|
1643
1635
|
end
|
1644
1636
|
# Close the case.
|
1645
1637
|
res << " " * (level+1)*3
|
1638
|
+
res << "pop();\n" # Remove the testing value.
|
1639
|
+
res << " " * (level+1)*3
|
1646
1640
|
res << "}\n"
|
1647
1641
|
res << " " * (level)*3
|
1648
1642
|
res << "}\n"
|
data/lib/HDLRuby/sim/hruby_sim.h
CHANGED
@@ -754,6 +754,9 @@ extern Value write_range_no_z(Value src, long long first, long long last,
|
|
754
754
|
* @param val the value to push. */
|
755
755
|
extern void push(Value val);
|
756
756
|
|
757
|
+
/** Duplicates a value in the stack. */
|
758
|
+
extern void dup();
|
759
|
+
|
757
760
|
/** Pops a value.
|
758
761
|
* @return the value. */
|
759
762
|
extern Value pop();
|
@@ -27,6 +27,17 @@ void push(Value val) {
|
|
27
27
|
}
|
28
28
|
}
|
29
29
|
|
30
|
+
/** Duplicates a value in the stack. */
|
31
|
+
void dup() {
|
32
|
+
if (head > 0 && head < STACK_SIZE) {
|
33
|
+
Value val = stack[head];
|
34
|
+
stack[--head] = val;
|
35
|
+
} else {
|
36
|
+
perror("Cannot dup in computation stack.\n");
|
37
|
+
exit(1);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
30
41
|
/** Pops a value.
|
31
42
|
* @return the value. */
|
32
43
|
Value pop() {
|
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.7.
|
4
|
+
version: 2.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lovic Gauthier
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -150,6 +150,8 @@ files:
|
|
150
150
|
- lib/HDLRuby/hdr_samples/with_fixpoint.rb
|
151
151
|
- lib/HDLRuby/hdr_samples/with_fsm.rb
|
152
152
|
- lib/HDLRuby/hdr_samples/with_function_generator.rb
|
153
|
+
- lib/HDLRuby/hdr_samples/with_init.rb
|
154
|
+
- lib/HDLRuby/hdr_samples/with_instance.rb
|
153
155
|
- lib/HDLRuby/hdr_samples/with_linear.rb
|
154
156
|
- lib/HDLRuby/hdr_samples/with_loop.rb
|
155
157
|
- lib/HDLRuby/hdr_samples/with_memory.rb
|