HDLRuby 2.9.0 → 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 +13 -0
- data/lib/HDLRuby/hdr_samples/with_delay.rb +72 -0
- data/lib/HDLRuby/hdr_samples/with_handshake.rb +110 -0
- data/lib/HDLRuby/hdrcc.rb +43 -4
- data/lib/HDLRuby/hdrlib.rb +592 -0
- data/lib/HDLRuby/hruby_high.rb +105 -40
- data/lib/HDLRuby/hruby_low.rb +5 -2
- data/lib/HDLRuby/hruby_low2c.rb +1 -1
- data/lib/HDLRuby/hruby_low_without_connection.rb +1 -0
- data/lib/HDLRuby/sim/hruby_sim_calc.c +3 -2
- data/lib/HDLRuby/std/delays.rb +92 -0
- data/lib/HDLRuby/std/handshakes.rb +60 -0
- data/lib/HDLRuby/version.rb +1 -1
- metadata +7 -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
|
|
@@ -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
|
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
|