HDLRuby 2.7.11 → 2.10.2
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/README.md +14 -1
- data/lib/HDLRuby/hdr_samples/adder_gen.rb +22 -0
- data/lib/HDLRuby/hdr_samples/adder_gen_gen.rb +40 -0
- data/lib/HDLRuby/hdr_samples/dff_unit.rb +1 -1
- data/lib/HDLRuby/hdr_samples/with_def.rb +29 -0
- data/lib/HDLRuby/hdr_samples/with_delay.rb +72 -0
- data/lib/HDLRuby/hdr_samples/with_handshake.rb +110 -0
- data/lib/HDLRuby/hdr_samples/with_of.rb +51 -0
- data/lib/HDLRuby/hdr_samples/with_reconf.rb +75 -72
- data/lib/HDLRuby/hdr_samples/with_terminate.rb +32 -0
- data/lib/HDLRuby/hdrcc.rb +51 -5
- data/lib/HDLRuby/hdrlib.rb +592 -0
- data/lib/HDLRuby/hruby_high.rb +221 -44
- data/lib/HDLRuby/hruby_low.rb +210 -5
- data/lib/HDLRuby/hruby_low2c.rb +98 -9
- data/lib/HDLRuby/hruby_low2vhd.rb +12 -0
- data/lib/HDLRuby/hruby_low_bool2select.rb +12 -0
- data/lib/HDLRuby/hruby_low_fix_types.rb +20 -1
- data/lib/HDLRuby/hruby_low_resolve.rb +1 -1
- data/lib/HDLRuby/hruby_low_without_connection.rb +1 -0
- data/lib/HDLRuby/hruby_low_without_select.rb +11 -1
- data/lib/HDLRuby/hruby_verilog.rb +9 -1
- data/lib/HDLRuby/sim/hruby_sim.h +23 -1
- data/lib/HDLRuby/sim/hruby_sim_calc.c +3 -2
- data/lib/HDLRuby/sim/hruby_sim_core.c +60 -6
- data/lib/HDLRuby/sim/hruby_sim_vcd.c +1 -1
- data/lib/HDLRuby/std/delays.rb +92 -0
- data/lib/HDLRuby/std/handshakes.rb +60 -0
- data/lib/HDLRuby/std/reconf.rb +3 -0
- data/lib/HDLRuby/version.rb +1 -1
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 960102912fa0b766d6d17de3d6f4c727e022b459813c47ce5156d4f695a97231
|
4
|
+
data.tar.gz: d79ea380f00deed3419e8565ee82c59d9568fd8844e2422c2d00e163548225c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45f8c0e72f6ebfee3fbf7cbd0172ccb24995d175134ff8d456c1d7aef22466bd1a0bf8b1fac4fef9f2e912d6e51bd16426b6fd376a7e07796f03114ae8a2bc38
|
7
|
+
data.tar.gz: 1fe88f2ce84c4e48eacc20119804062cb50ccf1a36acec6c0bbb82e6e0e9b1414af93af8daff4760c722159fa319d3af19082a2533b34ba9d6bac33ac3cd0f5a
|
data/README.md
CHANGED
@@ -44,6 +44,7 @@ Where:
|
|
44
44
|
|
45
45
|
| Options | |
|
46
46
|
|:------------------|:-----------------------------------------------------|
|
47
|
+
| `-I, --interactive` | Run in interactive mode |
|
47
48
|
| `-y, --yaml` | Output in YAML format |
|
48
49
|
| `-v, --verilog` | Output in Verilog HDL format |
|
49
50
|
| `-V, --vhdl` | Output in VHDL format |
|
@@ -97,6 +98,18 @@ hdrcc -y -t multer -p 16,16,32 multer_gen.rb multer
|
|
97
98
|
hdrcc -S counter_bench.rb counter
|
98
99
|
```
|
99
100
|
|
101
|
+
* Run in interactive mode.
|
102
|
+
|
103
|
+
```
|
104
|
+
hdrcc -I
|
105
|
+
```
|
106
|
+
|
107
|
+
* Run in interactive mode using pry as UI.
|
108
|
+
|
109
|
+
```
|
110
|
+
hdrcc -I pry
|
111
|
+
```
|
112
|
+
|
100
113
|
|
101
114
|
## Using HDLRuby within Ruby
|
102
115
|
|
@@ -439,7 +452,7 @@ The description above is straight forward, but it would be necessary to rewrite
|
|
439
452
|
|
440
453
|
```ruby
|
441
454
|
system :sumprod do |typ,coefs|
|
442
|
-
typ[coefs.size].input ins
|
455
|
+
typ[coefs.size].input :ins
|
443
456
|
typ.output :o
|
444
457
|
|
445
458
|
o <= coefs.each_with_index.reduce(_0) do |sum,(coef,i)|
|
@@ -5,3 +5,25 @@ system :adder do |w|
|
|
5
5
|
|
6
6
|
s <= x.as(bit[w+1]) + y
|
7
7
|
end
|
8
|
+
|
9
|
+
|
10
|
+
# Testing the generic adder.
|
11
|
+
system :adder_bench do
|
12
|
+
width = 4
|
13
|
+
[width].inner :x,:y
|
14
|
+
[width+1].inner :z
|
15
|
+
|
16
|
+
adder(width).(:my_adder).(x,y,z)
|
17
|
+
|
18
|
+
timed do
|
19
|
+
x <= 0
|
20
|
+
y <= 0
|
21
|
+
!10.ns
|
22
|
+
x <= 1
|
23
|
+
!10.ns
|
24
|
+
y <= 1
|
25
|
+
!10.ns
|
26
|
+
x <= 15
|
27
|
+
!10.ns
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# A simple generic adder
|
2
|
+
system :adder do |w|
|
3
|
+
[(w-1)..0].input :i,:j
|
4
|
+
[w..0].output :k
|
5
|
+
|
6
|
+
k <= i.as(bit[w+1]) + j
|
7
|
+
end
|
8
|
+
|
9
|
+
# A module embedding two generic adders.
|
10
|
+
system :two_adders do |w|
|
11
|
+
[w*2].input :x, :y
|
12
|
+
[(w+1)*2].output :z
|
13
|
+
|
14
|
+
adder(w).(:adderI0).(x[(w-1)..0],y[(w-1)..0],z[w..0])
|
15
|
+
adder(w).(:adderI1).(x[(w*2-1)..w],y[(w*2-1)..w],z[(w*2+1)..(w+1)])
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
# Testing the generic adder.
|
20
|
+
system :adder_bench do
|
21
|
+
width = 4
|
22
|
+
[width*2].inner :a,:b
|
23
|
+
[(width+1)*2].inner :c
|
24
|
+
|
25
|
+
two_adders(width).(:my_adders).(a,b,c)
|
26
|
+
|
27
|
+
timed do
|
28
|
+
a <= 0
|
29
|
+
b <= 0
|
30
|
+
!10.ns
|
31
|
+
a <= 1
|
32
|
+
!10.ns
|
33
|
+
b <= 1
|
34
|
+
!10.ns
|
35
|
+
a <= 255
|
36
|
+
!10.ns
|
37
|
+
b <= 128
|
38
|
+
!10.ns
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# A test of def.
|
2
|
+
def lut84(content,addr)
|
3
|
+
bit[8][-4].inner tbl? => content.to_a
|
4
|
+
tbl![addr]
|
5
|
+
end
|
6
|
+
|
7
|
+
|
8
|
+
# A benchmark for testing the initialization of signals.
|
9
|
+
system :def_bench do
|
10
|
+
|
11
|
+
[2].inner :addr
|
12
|
+
[8].inner :val0, :val1
|
13
|
+
|
14
|
+
par do
|
15
|
+
val0 <= lut84([0,1,4,9],addr)
|
16
|
+
val1 <= lut84([0,1,4,9],3-addr)
|
17
|
+
end
|
18
|
+
|
19
|
+
timed do
|
20
|
+
addr <= 0
|
21
|
+
!10.ns
|
22
|
+
addr <= 1
|
23
|
+
!10.ns
|
24
|
+
addr <= 2
|
25
|
+
!10.ns
|
26
|
+
addr <= 3
|
27
|
+
!10.ns
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'std/delays.rb'
|
2
|
+
|
3
|
+
include HDLRuby::High::Std
|
4
|
+
|
5
|
+
# System descending for delayp for adding a reset.
|
6
|
+
system :delayp_rst do |num|
|
7
|
+
include(delayp(num))
|
8
|
+
|
9
|
+
input :rst
|
10
|
+
|
11
|
+
par(clk.posedge) do
|
12
|
+
hif(rst) { state <= 0 }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
# System testing delay, delayp and the new delayp_rst.
|
18
|
+
system :with_delays do
|
19
|
+
num = 10
|
20
|
+
|
21
|
+
# The clock and reset signals
|
22
|
+
inner :clk,:rst
|
23
|
+
# The request signals.
|
24
|
+
inner :req, :reqp, :reqp_rst
|
25
|
+
# The ack signals.
|
26
|
+
inner :ack, :ackp, :ackp_rst
|
27
|
+
|
28
|
+
# Instantiate the delays.
|
29
|
+
delay(num).(:delayI).(clk,req,ack)
|
30
|
+
delayp(num).(:delaypI).(clk,reqp,ackp)
|
31
|
+
delayp_rst(num).(:delaypI_rst).(rst,clk,reqp_rst,ackp_rst)
|
32
|
+
|
33
|
+
# Test the delays.
|
34
|
+
timed do
|
35
|
+
clk <= 0
|
36
|
+
rst <= 0
|
37
|
+
!10.ns
|
38
|
+
clk <= 1
|
39
|
+
!10.ns
|
40
|
+
clk <= 0
|
41
|
+
req <= 1
|
42
|
+
reqp <= 1
|
43
|
+
reqp_rst <= 1
|
44
|
+
!10.ns
|
45
|
+
clk <= 1
|
46
|
+
!10.ns
|
47
|
+
req <= 0
|
48
|
+
clk <= 0
|
49
|
+
rst <= 1
|
50
|
+
!10.ns
|
51
|
+
clk <= 1
|
52
|
+
!10.ns
|
53
|
+
clk <= 0
|
54
|
+
rst <= 0
|
55
|
+
!10.ns
|
56
|
+
clk <= 1
|
57
|
+
!10.ns
|
58
|
+
clk <= 0
|
59
|
+
reqp <= 0
|
60
|
+
!10.ns
|
61
|
+
clk <= 1
|
62
|
+
!10.ns
|
63
|
+
clk <= 0
|
64
|
+
reqp_rst <= 0
|
65
|
+
10.times do
|
66
|
+
!10.ns
|
67
|
+
clk <= 1
|
68
|
+
!10.ns
|
69
|
+
clk <= 0
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'std/handshakes.rb'
|
2
|
+
|
3
|
+
include HDLRuby::High::Std
|
4
|
+
|
5
|
+
|
6
|
+
# System using a handshake for summing inputs.
|
7
|
+
system :hs_adder do
|
8
|
+
input :clk
|
9
|
+
[8].input :x,:y
|
10
|
+
[8].output :z
|
11
|
+
|
12
|
+
inner :read, :write
|
13
|
+
|
14
|
+
include(hs_pipe(clk.posedge,read,write))
|
15
|
+
|
16
|
+
par(clk.posedge) do
|
17
|
+
hif(read) do
|
18
|
+
z <= x + y
|
19
|
+
write <= 1
|
20
|
+
end
|
21
|
+
hif(ackO) do
|
22
|
+
z <= _zzzzzzzz
|
23
|
+
write <= 0
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
# System testing handshakes.
|
30
|
+
system :with_handshake do
|
31
|
+
|
32
|
+
# The clock signal.
|
33
|
+
inner :clk
|
34
|
+
# The request and acknoledge signals.
|
35
|
+
inner :reqI,:ackI,:reqO,:ackO
|
36
|
+
|
37
|
+
# The input and output values.
|
38
|
+
[8].inner :x, :y, :z
|
39
|
+
|
40
|
+
# Instantiate the handshake adder.
|
41
|
+
hs_adder.(:adderI).(clk: clk, x: x, y: y, z: z,
|
42
|
+
reqI: reqI, ackI: ackI, reqO: reqO, ackO: ackO)
|
43
|
+
|
44
|
+
# Test the handshake adder.
|
45
|
+
timed do
|
46
|
+
clk <= 0
|
47
|
+
x <= 0
|
48
|
+
y <= 0
|
49
|
+
reqI <= 0
|
50
|
+
ackO <= 0
|
51
|
+
!10.ns
|
52
|
+
clk <= 1
|
53
|
+
!10.ns
|
54
|
+
clk <= 0
|
55
|
+
x <= 1
|
56
|
+
y <= 2
|
57
|
+
!10.ns
|
58
|
+
clk <= 1
|
59
|
+
!10.ns
|
60
|
+
clk <= 0
|
61
|
+
reqI <= 1
|
62
|
+
!10.ns
|
63
|
+
clk <= 1
|
64
|
+
!10.ns
|
65
|
+
clk <= 0
|
66
|
+
reqI <= 0
|
67
|
+
!10.ns
|
68
|
+
clk <= 1
|
69
|
+
!10.ns
|
70
|
+
clk <= 0
|
71
|
+
ackO <= 1
|
72
|
+
!10.ns
|
73
|
+
clk <= 1
|
74
|
+
!10.ns
|
75
|
+
clk <= 0
|
76
|
+
!10.ns
|
77
|
+
clk <= 1
|
78
|
+
!10.ns
|
79
|
+
clk <= 0
|
80
|
+
!10.ns
|
81
|
+
clk <= 1
|
82
|
+
!10.ns
|
83
|
+
clk <= 0
|
84
|
+
ackO <= 0
|
85
|
+
!10.ns
|
86
|
+
clk <= 0
|
87
|
+
x <= 3
|
88
|
+
y <= 4
|
89
|
+
!10.ns
|
90
|
+
clk <= 1
|
91
|
+
!10.ns
|
92
|
+
clk <= 0
|
93
|
+
reqI <= 1
|
94
|
+
!10.ns
|
95
|
+
clk <= 1
|
96
|
+
!10.ns
|
97
|
+
clk <= 0
|
98
|
+
reqI <= 0
|
99
|
+
!10.ns
|
100
|
+
clk <= 1
|
101
|
+
!10.ns
|
102
|
+
clk <= 0
|
103
|
+
ackO <= 1
|
104
|
+
!10.ns
|
105
|
+
clk <= 1
|
106
|
+
!10.ns
|
107
|
+
clk <= 0
|
108
|
+
ackO <= 0
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# Some abstract system.
|
2
|
+
system :sysA do
|
3
|
+
input :clk,:rst
|
4
|
+
input :d
|
5
|
+
output :q
|
6
|
+
end
|
7
|
+
|
8
|
+
# Some inheriting system.
|
9
|
+
system :sysH, sysA do
|
10
|
+
par(clk.posedge, rst.posedge) do
|
11
|
+
hprint("sys1\n")
|
12
|
+
q <= d & ~rst
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# Another system that have nothing to see with the others.
|
17
|
+
# Some abstract system.
|
18
|
+
system :sysO do
|
19
|
+
input :clk,:rst
|
20
|
+
input :d
|
21
|
+
output :q
|
22
|
+
|
23
|
+
par(clk.posedge, rst.posedge) do
|
24
|
+
hprint("sys1\n")
|
25
|
+
q <= d & ~rst
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
# A system for testing inheritance and of?
|
31
|
+
system :with_reconf do
|
32
|
+
input :clk,:rst
|
33
|
+
input :d
|
34
|
+
output :q
|
35
|
+
|
36
|
+
# Instantiate the abstract system.
|
37
|
+
sysA(:my_dffA).(clk,rst,d,q)
|
38
|
+
|
39
|
+
# Test the of?
|
40
|
+
puts "my_dffA.systemT.of?(sysA)=#{my_dffA.systemT.of?(sysA)}"
|
41
|
+
puts "my_dffA.systemT.of?(sysH)=#{my_dffA.systemT.of?(sysH)}"
|
42
|
+
puts "my_dffA.systemT.of?(sysO)=#{my_dffA.systemT.of?(sysO)}"
|
43
|
+
|
44
|
+
# Instantiate the inheriting system.
|
45
|
+
sysH(:my_dffH).(clk,rst,d,q)
|
46
|
+
|
47
|
+
# Test the of?
|
48
|
+
puts "my_dffH.systemT.of?(sysH)=#{my_dffH.systemT.of?(sysH)}"
|
49
|
+
puts "my_dffH.systemT.of?(sysA)=#{my_dffH.systemT.of?(sysA)}"
|
50
|
+
puts "my_dffH.systemT.of?(sysO)=#{my_dffH.systemT.of?(sysO)}"
|
51
|
+
end
|
@@ -1,63 +1,14 @@
|
|
1
|
-
require 'std/reconf.rb'
|
2
1
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
# Implementation of a vivado partial reconfiguration system.
|
9
|
-
reconf(:vivado_reconf) do |clk,rst|
|
10
|
-
|
11
|
-
# Get access to the interface of the reconfigurable component.
|
12
|
-
inputs = each_input
|
13
|
-
outputs = each_output
|
14
|
-
inouts = each_inout
|
15
|
-
|
16
|
-
# Create the main system with the interface and a channel for
|
17
|
-
# handling the reconfiguration.
|
18
|
-
main = system do
|
19
|
-
# Declares the inputs.
|
20
|
-
inputs.each do |i|
|
21
|
-
i.type.input(i.name)
|
22
|
-
end
|
23
|
-
# Declares the outputs.
|
24
|
-
outputs.each do |o|
|
25
|
-
o.type.output(o.name)
|
26
|
-
end
|
27
|
-
# Declares the inouts.
|
28
|
-
inouts.each do |io|
|
29
|
-
io.type.inout(io.name)
|
30
|
-
end
|
31
|
-
# An that's all: in vivado the main system is to be a black-box.
|
32
|
-
end
|
33
|
-
|
34
|
-
# And set it as the main system.
|
35
|
-
set_main(main)
|
36
|
-
|
37
|
-
# The switching circuit.
|
38
|
-
# reconfer = vivado_reconfigurer :do_reconf # Will be that later
|
39
|
-
# reconfer.clk <= clk
|
40
|
-
# reconfer.rst <= rst
|
41
|
-
reconfer = proc do |idx|
|
42
|
-
puts "Instantiating reconfiguration circuits with #{idx}"
|
43
|
-
end
|
44
|
-
|
45
|
-
# Defines the reconfiguring procedure: switch to system idx.
|
46
|
-
switcher do |idx,ruby_block|
|
47
|
-
reconfer.call(idx)
|
48
|
-
ruby_block.call
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
# Some system that can be used for recponfiguration.
|
2
|
+
# Some system that can be used for reconfiguration.
|
55
3
|
system :sys0 do
|
56
4
|
input :clk,:rst
|
57
5
|
input :d
|
58
6
|
output :q
|
59
7
|
|
60
|
-
|
8
|
+
par(clk.posedge) do
|
9
|
+
hprint("sys0\n")
|
10
|
+
q <= d & ~rst
|
11
|
+
end
|
61
12
|
end
|
62
13
|
|
63
14
|
system :sys1 do
|
@@ -65,7 +16,10 @@ system :sys1 do
|
|
65
16
|
input :d
|
66
17
|
output :q
|
67
18
|
|
68
|
-
(
|
19
|
+
par(clk.posedge, rst.posedge) do
|
20
|
+
hprint("sys1\n")
|
21
|
+
q <= d & ~rst
|
22
|
+
end
|
69
23
|
end
|
70
24
|
|
71
25
|
system :sys2 do
|
@@ -73,7 +27,10 @@ system :sys2 do
|
|
73
27
|
input :d
|
74
28
|
output :q
|
75
29
|
|
76
|
-
(
|
30
|
+
par(clk.posedge, rst.negedge) do
|
31
|
+
hprint("sys2\n")
|
32
|
+
q <= d & ~rst
|
33
|
+
end
|
77
34
|
end
|
78
35
|
|
79
36
|
# A system with a reconfifurable part.
|
@@ -81,23 +38,69 @@ system :with_reconf do
|
|
81
38
|
input :clk,:rst
|
82
39
|
input :d
|
83
40
|
output :q
|
84
|
-
[2].input :conf # The configuration number
|
85
|
-
|
86
|
-
inner :wait_reconf
|
87
41
|
|
88
|
-
#
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
42
|
+
# Instantiate the default configuration.
|
43
|
+
sys0(:my_dff).(clk,rst,d,q)
|
44
|
+
|
45
|
+
# Adds the additional configuration.
|
46
|
+
my_dff.choice(conf1: sys1, conf2: sys2)
|
47
|
+
|
48
|
+
timed do
|
49
|
+
clk <= 0
|
50
|
+
rst <= 0
|
51
|
+
d <= 0
|
52
|
+
!10.ns
|
53
|
+
clk <= 1
|
54
|
+
!10.ns
|
55
|
+
clk <= 0
|
56
|
+
rst <= 1
|
57
|
+
!10.ns
|
58
|
+
clk <= 1
|
59
|
+
!10.ns
|
60
|
+
clk <= 0
|
61
|
+
rst <= 0
|
62
|
+
!10.ns
|
63
|
+
3.times do |i|
|
64
|
+
clk <= 1
|
65
|
+
!10.ns
|
66
|
+
clk <= 0
|
67
|
+
d <= 1
|
68
|
+
!10.ns
|
69
|
+
clk <= 1
|
70
|
+
!10.ns
|
71
|
+
clk <= 0
|
72
|
+
d <= 0
|
73
|
+
!10.ns
|
74
|
+
clk <= 1
|
75
|
+
my_dff.configure((i+1)%3)
|
76
|
+
!10.ns
|
77
|
+
clk <= 0
|
78
|
+
!10.ns
|
101
79
|
end
|
80
|
+
clk <= 1
|
81
|
+
!10.ns
|
82
|
+
clk <= 0
|
83
|
+
d <= 1
|
84
|
+
!10.ns
|
85
|
+
clk <= 1
|
86
|
+
my_dff.configure(:conf1)
|
87
|
+
!10.ns
|
88
|
+
clk <= 0
|
89
|
+
d <= 0
|
90
|
+
!10.ns
|
91
|
+
clk <= 1
|
92
|
+
my_dff.configure(:conf2)
|
93
|
+
!10.ns
|
94
|
+
clk <= 0
|
95
|
+
d <= 1
|
96
|
+
!10.ns
|
97
|
+
clk <= 1
|
98
|
+
my_dff.configure(:my_dff)
|
99
|
+
!10.ns
|
100
|
+
clk <= 0
|
101
|
+
d <= 0
|
102
|
+
!10.ns
|
103
|
+
clk <= 1
|
104
|
+
!10.ns
|
102
105
|
end
|
103
106
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
# A benchmark for testing the terminate statement.
|
3
|
+
system :with_terminate do
|
4
|
+
[8].constant cst0: 127
|
5
|
+
constant cst1: _1
|
6
|
+
[8].inner sig0: _10000000
|
7
|
+
inner sig1: _1
|
8
|
+
[8].inner :sig2
|
9
|
+
[8].inner count: 0
|
10
|
+
|
11
|
+
timed do
|
12
|
+
!20.ns
|
13
|
+
100.times do
|
14
|
+
count <= count + 1
|
15
|
+
!20.ns
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
timed do
|
20
|
+
!10.ns
|
21
|
+
sig2 <= cst0 + cst1
|
22
|
+
sig0 <= sig0 + sig1
|
23
|
+
!10.ns
|
24
|
+
sig2 <= sig2 + sig1
|
25
|
+
!10.ns
|
26
|
+
terminate
|
27
|
+
sig0 <= sig0 + sig0
|
28
|
+
!10.ns
|
29
|
+
sig0 <= sig0 + sig0
|
30
|
+
!10.ns
|
31
|
+
end
|
32
|
+
end
|
data/lib/HDLRuby/hdrcc.rb
CHANGED
@@ -1,5 +1,41 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
|
3
|
+
|
4
|
+
# Check if run in interactive mode.
|
5
|
+
if ARGV.include?("-I") || ARGV.include?("--interactive") then
|
6
|
+
# Yes, first check which repl to use.
|
7
|
+
idx = ARGV.index("-I")
|
8
|
+
idx = ARGV.index("--interactive") unless idx
|
9
|
+
if ARGV[idx+1] == "irb" || ARGV[idx+1] == nil then
|
10
|
+
repl = :irb
|
11
|
+
elsif ARGV[idx+1] == "pry" then
|
12
|
+
repl = :pry
|
13
|
+
else
|
14
|
+
raise "Unknown repl: #{ARGV[idx+1]}"
|
15
|
+
end
|
16
|
+
# Look for the interactive Ruby library.
|
17
|
+
libpath = ""
|
18
|
+
$:.each do |dir|
|
19
|
+
if File.exist?(dir + "/hdrlib.rb") then
|
20
|
+
libpath = dir + "/hdrlib.rb"
|
21
|
+
break
|
22
|
+
end
|
23
|
+
end
|
24
|
+
ARGV.clear
|
25
|
+
ARGV.concat(['-r', libpath])
|
26
|
+
case repl
|
27
|
+
when :irb
|
28
|
+
require 'irb'
|
29
|
+
IRB.start
|
30
|
+
when :pry
|
31
|
+
require 'pry'
|
32
|
+
require libpath
|
33
|
+
# Pry.start(binding)
|
34
|
+
Pry.start()
|
35
|
+
end
|
36
|
+
abort
|
37
|
+
end
|
38
|
+
|
3
39
|
require 'fileutils'
|
4
40
|
require 'tempfile'
|
5
41
|
require 'HDLRuby'
|
@@ -267,6 +303,9 @@ def which(cmd)
|
|
267
303
|
end
|
268
304
|
|
269
305
|
|
306
|
+
# Used standalone, check the files given in the standard input.
|
307
|
+
include HDLRuby
|
308
|
+
|
270
309
|
|
271
310
|
if __FILE__ == $0 then
|
272
311
|
# From hdrcc.rb
|
@@ -278,9 +317,6 @@ else
|
|
278
317
|
end
|
279
318
|
|
280
319
|
require 'optparse'
|
281
|
-
# Used standalone, check the files given in the standard input.
|
282
|
-
include HDLRuby
|
283
|
-
|
284
320
|
# Process the command line options
|
285
321
|
$options = {}
|
286
322
|
$optparse = OptionParser.new do |opts|
|
@@ -293,7 +329,10 @@ $optparse = OptionParser.new do |opts|
|
|
293
329
|
opts.separator "* `<output file>` is the output file"
|
294
330
|
opts.separator ""
|
295
331
|
opts.separator "Options:"
|
296
|
-
|
332
|
+
|
333
|
+
opts.on("-I", "--interactive") do |repl|
|
334
|
+
raise "Internal error: the --interactive option should have been processed earlier."
|
335
|
+
end
|
297
336
|
opts.on("-y", "--yaml", "Output in YAML format") do |y|
|
298
337
|
$options[:yaml] = y
|
299
338
|
end
|
@@ -647,12 +686,19 @@ elsif $options[:clang] then
|
|
647
686
|
init_visualizer = $options[:vcd] ? "init_vcd_visualizer" :
|
648
687
|
"init_default_visualizer"
|
649
688
|
|
689
|
+
# Gather the system to generate and sort them in the right order
|
690
|
+
# to ensure references are generated before being used.
|
691
|
+
# Base: reverse order of the tree.
|
692
|
+
# Then, multiple configuration of a system instance must be
|
693
|
+
# reverversed so that the base configuration is generated first.
|
694
|
+
c_systems = $top_system.each_systemT_deep_ref
|
650
695
|
# Generate the code of the main function.
|
651
696
|
# HDLRuby start code
|
652
697
|
$main << HDLRuby::Low::Low2C.main("hruby_simulator",
|
653
698
|
init_visualizer,
|
654
699
|
$top_system,
|
655
|
-
|
700
|
+
c_systems,
|
701
|
+
$hnames)
|
656
702
|
$main.close
|
657
703
|
|
658
704
|
$top_system.each_systemT_deep do |systemT|
|