HDLRuby 2.5.0 → 2.5.1
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/dff_unit.rb +54 -0
- data/lib/HDLRuby/hdrcc.rb +68 -19
- data/lib/HDLRuby/hruby_high.rb +1 -1
- data/lib/HDLRuby/hruby_unit.rb +43 -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: 53e83131d2fb3a3f03c085a3139a69d70f4422ade7be950d009e97e17bb92490
|
4
|
+
data.tar.gz: dcbbcbf3bd1e5aa43ac359e502dc0da6dec886d115371f3b2fceead01bcaa9d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1656a5763fef86bd1b8c01eff8d377cc94ff3145889fd486fac99ac7d86b6f6671a30e040679f81da6a76bc08ee09ff5babd11cae72fc8adb721f0258e724fb9
|
7
|
+
data.tar.gz: 8f83372948477da9374abf302ab3910d73b434b22aa020b25071f2ed9127dc7ee95b3c6959952bd9ec008f1ff17327c7edc9e1b9584d1437a530a753b0886f4d
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Testing HDLRuby unit test.
|
2
|
+
# require 'hruby_unit.rb'
|
3
|
+
|
4
|
+
# Declare multiple simple dff-systems and their corresponding test.
|
5
|
+
|
6
|
+
1.times do |i|
|
7
|
+
|
8
|
+
# A simple D-FF
|
9
|
+
system:"dff#{i}" do
|
10
|
+
input :clk, :rst, :d
|
11
|
+
output :q, :qb
|
12
|
+
|
13
|
+
qb <= ~q
|
14
|
+
|
15
|
+
par(clk.posedge) { q <= d & ~rst }
|
16
|
+
end
|
17
|
+
|
18
|
+
# Code for testing it.
|
19
|
+
Unit.system :"test_dff#{i}" do
|
20
|
+
inner :clk, :rst, :d, :q, :qb
|
21
|
+
|
22
|
+
send(:"dff#{i}",:dffI).(clk,rst,d,q,qb)
|
23
|
+
|
24
|
+
timed do
|
25
|
+
clk <= 0
|
26
|
+
rst <= 0
|
27
|
+
d <= 0
|
28
|
+
!10.ns
|
29
|
+
clk <= 1
|
30
|
+
!10.ns
|
31
|
+
clk <= 0
|
32
|
+
rst <= 1
|
33
|
+
!10.ns
|
34
|
+
clk <= 1
|
35
|
+
!10.ns
|
36
|
+
clk <= 0
|
37
|
+
rst <= 0
|
38
|
+
!10.ns
|
39
|
+
clk <= 1
|
40
|
+
!10.ns
|
41
|
+
clk <= 0
|
42
|
+
d <= 1
|
43
|
+
!10.ns
|
44
|
+
clk <= 1
|
45
|
+
!10.ns
|
46
|
+
clk <= 0
|
47
|
+
d <= 0
|
48
|
+
!10.ns
|
49
|
+
clk <= 1
|
50
|
+
!10.ns
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
data/lib/HDLRuby/hdrcc.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
|
3
3
|
require 'fileutils'
|
4
|
+
require 'tempfile'
|
4
5
|
require 'HDLRuby'
|
5
6
|
require 'HDLRuby/hruby_check.rb'
|
6
7
|
# require 'ripper'
|
@@ -50,12 +51,21 @@ module HDLRuby
|
|
50
51
|
# The required files.
|
51
52
|
attr_reader :requires
|
52
53
|
|
53
|
-
# Creates a new loader for a +top_system+ system in file +
|
54
|
+
# Creates a new loader for a +top_system+ system in file +top_file_name+
|
54
55
|
# from directory +dir+ with generic parameters +params+.
|
56
|
+
#
|
57
|
+
# NOTE: +top_file+ can either be a file or a file name.
|
55
58
|
def initialize(top_system,top_file,dir,*params)
|
56
59
|
# Sets the top and the looking directory.
|
57
60
|
@top_system = top_system.to_s
|
58
|
-
@top_file
|
61
|
+
# @top_file can either be a file or a string giving the file name.
|
62
|
+
if top_file.respond_to?(:path) then
|
63
|
+
@top_file = top_file
|
64
|
+
@top_file_name = top_file.path
|
65
|
+
else
|
66
|
+
@top_file = nil
|
67
|
+
@top_file_name = top_file.to_s
|
68
|
+
end
|
59
69
|
@dir = dir.to_s
|
60
70
|
@params = params
|
61
71
|
|
@@ -82,31 +92,48 @@ module HDLRuby
|
|
82
92
|
end
|
83
93
|
|
84
94
|
# Loads a single +file+.
|
95
|
+
#
|
96
|
+
# NOTE: +file+ can either be a file or a file name.
|
85
97
|
def read(file)
|
86
98
|
# Resolve the file.
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
99
|
+
if file.respond_to?(:read) then
|
100
|
+
found = file
|
101
|
+
else
|
102
|
+
found = File.join(@dir,file)
|
103
|
+
unless File.exist?(found) then
|
104
|
+
founds = Dir.glob(@std_dirs.map do |path|
|
105
|
+
File.join(path,file)
|
106
|
+
end)
|
107
|
+
if founds.empty? then
|
108
|
+
# No standard file with this name, this is an error.
|
109
|
+
raise "Unknown required file: #{file}."
|
110
|
+
else
|
111
|
+
# A standard file is found, skip it since it does not
|
112
|
+
# need to be read.
|
113
|
+
# puts "Standard files: #{founds}"
|
114
|
+
return false
|
115
|
+
end
|
98
116
|
end
|
99
117
|
end
|
100
118
|
# Load the file.
|
101
|
-
# @texts << File.read(File.join(@dir,file) )
|
102
119
|
@texts << File.read(found)
|
103
|
-
|
104
|
-
|
120
|
+
if found.respond_to?(:path) then
|
121
|
+
@checks << Checker.new(@texts[-1],found.path)
|
122
|
+
else
|
123
|
+
@checks << Checker.new(@texts[-1])
|
124
|
+
end
|
105
125
|
return true
|
106
126
|
end
|
107
127
|
|
108
128
|
# Loads all the files from +file+.
|
109
|
-
def read_all(file =
|
129
|
+
def read_all(file = nil)
|
130
|
+
unless file then
|
131
|
+
if @top_file then
|
132
|
+
file = @top_file
|
133
|
+
else
|
134
|
+
file = @top_file_name
|
135
|
+
end
|
136
|
+
end
|
110
137
|
# puts "read_all with file=#{file}"
|
111
138
|
# Read the file
|
112
139
|
# read(file)
|
@@ -174,7 +201,7 @@ module HDLRuby
|
|
174
201
|
# Maybe it is a parse error, look for it.
|
175
202
|
bind = TOPLEVEL_BINDING.clone
|
176
203
|
eval("require 'HDLRuby'\n\nconfigure_high\n\n",bind)
|
177
|
-
eval(@texts[0],bind,@
|
204
|
+
eval(@texts[0],bind,@top_file_name,1)
|
178
205
|
# No parse error found.
|
179
206
|
raise "Cannot find a top system." unless @top_system
|
180
207
|
end
|
@@ -183,7 +210,7 @@ module HDLRuby
|
|
183
210
|
bind = TOPLEVEL_BINDING.clone
|
184
211
|
eval("require 'HDLRuby'\n\nconfigure_high\n\n",bind)
|
185
212
|
# Process it.
|
186
|
-
eval(@texts[0],bind,@
|
213
|
+
eval(@texts[0],bind,@top_file_name,1)
|
187
214
|
# Get the resulting instance
|
188
215
|
if @params.empty? then
|
189
216
|
# There is no generic parameter
|
@@ -310,6 +337,9 @@ $optparse = OptionParser.new do |opts|
|
|
310
337
|
opts.on("-D", "--debug","Set the HDLRuby debug mode") do |d|
|
311
338
|
$options[:debug] = d
|
312
339
|
end
|
340
|
+
opts.on("-T","--test","Compile the unit tests.") do |t|
|
341
|
+
$options[:test] = t
|
342
|
+
end
|
313
343
|
opts.on("-t", "--top system", "Specify the top system to process") do|t|
|
314
344
|
$options[:top] = t
|
315
345
|
end
|
@@ -370,6 +400,19 @@ if $input == nil then
|
|
370
400
|
exit
|
371
401
|
end
|
372
402
|
|
403
|
+
if ($options[:test]) then
|
404
|
+
$top = "__test__"
|
405
|
+
# Generate the unit test file.
|
406
|
+
$test_file = Tempfile.new('tester.rb',Dir.getwd)
|
407
|
+
$test_file.write("require 'hruby_unit.rb'\nrequire_relative '#{$input}'\n\n" +
|
408
|
+
"HDLRuby::Unit.test(\"#{$top}\")\n")
|
409
|
+
# $test_file.rewind
|
410
|
+
# puts $test_file.read
|
411
|
+
$test_file.rewind
|
412
|
+
# It is the new input file.
|
413
|
+
$input = $test_file
|
414
|
+
end
|
415
|
+
|
373
416
|
# Open the output.
|
374
417
|
if $output then
|
375
418
|
if $options[:multiple] then
|
@@ -394,6 +437,12 @@ $loader = HDRLoad.new($top,$input,$options[:directory].to_s,*$params)
|
|
394
437
|
$loader.read_all
|
395
438
|
$loader.check_all
|
396
439
|
|
440
|
+
# Remove the test file if any, it is not needed any longer.
|
441
|
+
if $test_file then
|
442
|
+
$test_file.close
|
443
|
+
$test_file.unlink
|
444
|
+
end
|
445
|
+
|
397
446
|
if $options[:syntax] then
|
398
447
|
if $options[:multiple] then
|
399
448
|
raise "Multiple files generation mode not supported for syntax tree output."
|
data/lib/HDLRuby/hruby_high.rb
CHANGED
@@ -3810,7 +3810,7 @@ module HDLRuby::High
|
|
3810
3810
|
timeBehaviorL = HDLRuby::Low::TimeBehavior.new(blockL)
|
3811
3811
|
# For debugging: set the source high object
|
3812
3812
|
timeBehaviorL.properties[:low2high] = self.hdr_id
|
3813
|
-
eventLs.each(&
|
3813
|
+
eventLs.each(&timeBehaviorL.method(:add_event))
|
3814
3814
|
return timeBehaviorL
|
3815
3815
|
end
|
3816
3816
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "HDLRuby/hruby_high"
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
##
|
6
|
+
# Library for building unit test systems.
|
7
|
+
#
|
8
|
+
########################################################################
|
9
|
+
module HDLRuby::Unit
|
10
|
+
|
11
|
+
## The HDLRuby unit test error class.
|
12
|
+
class UnitError < ::StandardError
|
13
|
+
end
|
14
|
+
|
15
|
+
# The set of the unit systems by name.
|
16
|
+
@@unit_systems = {}
|
17
|
+
|
18
|
+
# Declares system +name+ for unit testing.
|
19
|
+
# The system is built by executing +ruby_block+.
|
20
|
+
#
|
21
|
+
# NOTE: the name of the system is not registered within the HDLRuby
|
22
|
+
# namespace since it is not meant to be used directly.
|
23
|
+
def self.system(name,&ruby_block)
|
24
|
+
# Ensure name is a symbol.
|
25
|
+
name = name.to_s.to_sym
|
26
|
+
# Check if the name is already used or not.
|
27
|
+
if @@unit_systems.key?(name) then
|
28
|
+
raise UnitError, "Unit test system #{name} already declared."
|
29
|
+
end
|
30
|
+
@@unit_systems[name] = HDLRuby::High.system(&ruby_block)
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
# Create a system named +test_name+ executing all the unit tests.
|
35
|
+
def self.test(test_name = "test")
|
36
|
+
# Declare the system.
|
37
|
+
HDLRuby::High.system test_name do
|
38
|
+
@@unit_systems.each do |name,sys|
|
39
|
+
sys.instantiate(name)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
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.5.
|
4
|
+
version: 2.5.1
|
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-03-
|
11
|
+
date: 2021-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- lib/HDLRuby/hdr_samples/dff_bench.rb
|
89
89
|
- lib/HDLRuby/hdr_samples/dff_counter.rb
|
90
90
|
- lib/HDLRuby/hdr_samples/dff_properties.rb
|
91
|
+
- lib/HDLRuby/hdr_samples/dff_unit.rb
|
91
92
|
- lib/HDLRuby/hdr_samples/include.rb
|
92
93
|
- lib/HDLRuby/hdr_samples/instance_open.rb
|
93
94
|
- lib/HDLRuby/hdr_samples/linear_test.rb
|
@@ -231,6 +232,7 @@ files:
|
|
231
232
|
- lib/HDLRuby/hruby_serializer.rb
|
232
233
|
- lib/HDLRuby/hruby_tools.rb
|
233
234
|
- lib/HDLRuby/hruby_types.rb
|
235
|
+
- lib/HDLRuby/hruby_unit.rb
|
234
236
|
- lib/HDLRuby/hruby_values.rb
|
235
237
|
- lib/HDLRuby/hruby_verilog.rb
|
236
238
|
- lib/HDLRuby/hruby_verilog_name.rb
|