HDLRuby 2.3.1 → 2.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb0edfa902fbbc4e330f9a7fd8c26dcfc745f8ce5eb8cd73e4c2047cfef7dc68
4
- data.tar.gz: 5ddc2948c53b905fb25c0683fc31be5300a2aabff31384c9187dc784c9e66a76
3
+ metadata.gz: 73fbfcef7b930ac266b56380159ffd3af64f84ce712f937f764559d8abe78ded
4
+ data.tar.gz: 2c7ad1ac7fac5639f70278f28dce24cdfa4328797b2b031f698421a849ee5141
5
5
  SHA512:
6
- metadata.gz: 93f86b91bf94ad22b4558ac912f950e79ec9373fafcdcaf2d33e8f1c34f3b77d30beec308f591d95f7ddafdcfda5bd283586216a98c882e12983fbe7301f43df
7
- data.tar.gz: 60503ed5b5d45406827329bd6f42b961b9b6c74f47c630f7f0f21bd4d51bcbabffb380608c2287ee7dd8b60b5bb2039eaddd82357920eff3f6b437b40d59d34a
6
+ metadata.gz: 4112497c5716f1dd13ae9f45a4806773ae7f521b586415c2b0be4a735357765a45c2f524d33bff509f0dfc103ed47fc3aceee19e7eea98ec8d0c720d88af3153
7
+ data.tar.gz: 1852065b8f05fb474f6f392df45cf08269196f2f481a55d84d1a5d20ad66713a5138eb739e0146ce1761fe3f22eccb01bcea06d19e94a19b3693a01dbba4e165
@@ -113,12 +113,9 @@ module HDLRuby
113
113
  return
114
114
  end
115
115
  # Get its required files.
116
- requires = @checks[-1].get_all_requires
116
+ requires = @checks[-1].get_all_requires +
117
+ @checks[-1].get_all_require_relatives
117
118
  requires.each do |file|
118
- # if file != "HDLRuby" &&
119
- # !@std_files.find { |std| std.include?(file) } then
120
- # read_all(file)
121
- # end
122
119
  read_all(file)
123
120
  end
124
121
  @requires += requires
@@ -45,11 +45,20 @@ module HDLRuby
45
45
  (code[1][1] == "require")
46
46
  end
47
47
 
48
+ # Tells if +code+ is require_relative description.
49
+ def is_require_relative?(code)
50
+ # return code[0] && (code[0][0] == :command) &&
51
+ # (code[0][1][1] == "require_relative")
52
+ return code && (code[0] == :command) &&
53
+ (code[1][1] == "require_relative")
54
+ end
55
+
48
56
  # Gets the required file from +code+.
49
57
  def get_require(code)
50
58
  # return (code[0][2][1][0][1][1][1])
51
59
  return (code[2][1][0][1][1][1])
52
60
  end
61
+ alias_method :get_require_relative, :get_require
53
62
 
54
63
  # Gets all the required files of +code+.
55
64
  def get_all_requires(code = @code)
@@ -66,6 +75,21 @@ module HDLRuby
66
75
  end
67
76
  end
68
77
 
78
+ # Gets all the require_relative files of +code+.
79
+ def get_all_require_relatives(code = @code)
80
+ if code.is_a?(Array) then
81
+ require_relatives = (code.select { |sub| is_require_relative?(sub) }).map! do |sub|
82
+ get_require_relative(sub)
83
+ end
84
+ code.each do |sub|
85
+ require_relatives += get_all_require_relatives(sub)
86
+ end
87
+ return require_relatives
88
+ else
89
+ return []
90
+ end
91
+ end
92
+
69
93
  # Tells if +code+ is a system description.
70
94
  def is_system?(code)
71
95
  return code.is_a?(Array) && (code[0] == :command) &&
@@ -77,7 +101,7 @@ module HDLRuby
77
101
  return code[2][1][0][1][1][1]
78
102
  end
79
103
 
80
- # Gets all the required files of +code+.
104
+ # Gets all the systems of +code+.
81
105
  def get_all_systems(code = @code)
82
106
  return [] unless code.is_a?(Array)
83
107
  return code.reduce([]) {|ar,sub| ar + get_all_systems(sub) } +
@@ -15,51 +15,53 @@ module HDLRuby::High::Std
15
15
  def self.included(base)
16
16
  # Performs the previous included
17
17
  res = self.send(:_included_fixpoint,base)
18
- # Now modify the Type class
19
- ::HDLRuby::High::Type.class_eval do
20
- # Saves the former type generation method.
21
- alias_method :"_[]_fixpoint", :[]
18
+ # Now modify the Type class if not already modified.
19
+ unless ::HDLRuby::High::Type.instance_methods.include?(:"_[]_fixpoint") then
20
+ ::HDLRuby::High::Type.class_eval do
21
+ # Saves the former type generation method.
22
+ alias_method :"_[]_fixpoint", :[]
22
23
 
23
- # Redefine the type generation method for supporting fixed point
24
- # type generation.
25
- def [](*args)
26
- if args.size == 1 then
27
- return self.send(:"_[]_fixpoint",*args)
28
- else
29
- # Handle the arguments and compute the fix point sizes.
30
- arg0,arg1 = *args
31
- if arg0.respond_to?(:to_i) then
32
- isize = arg0
24
+ # Redefine the type generation method for supporting fixed point
25
+ # type generation.
26
+ def [](*args)
27
+ if args.size == 1 then
28
+ return self.send(:"_[]_fixpoint",*args)
33
29
  else
34
- isize = (arg0.first-arg0.last).abs+1
30
+ # Handle the arguments and compute the fix point sizes.
31
+ arg0,arg1 = *args
32
+ if arg0.respond_to?(:to_i) then
33
+ isize = arg0
34
+ else
35
+ isize = (arg0.first-arg0.last).abs+1
36
+ end
37
+ if arg1.respond_to?(:to_i) then
38
+ fsize = arg1
39
+ else
40
+ fsize = (arg1.first-arg1.last).abs+1
41
+ end
42
+ # Build the type.
43
+ case(self.name)
44
+ when :bit
45
+ typ = bit[isize+fsize].typedef(::HDLRuby.uniq_name)
46
+ when :unsigned
47
+ typ = unsigned[isize+fsize].typedef(::HDLRuby.uniq_name)
48
+ when :signed
49
+ typ = signed[isize+fsize].typedef(::HDLRuby.uniq_name)
50
+ else
51
+ raise "Invalid type for generating a fixed point type: #{self.name}"
52
+ end
53
+ # Redefine the multiplication and division for fixed point.
54
+ typ.define_operator(:*) do |left,right|
55
+ (left.as([isize+fsize*2])*right) >> fsize
56
+ end
57
+ typ.define_operator(:/) do |left,right|
58
+ (left.as([isize+fsize*2]) << fsize) / right
59
+ end
60
+ typ
35
61
  end
36
- if arg1.respond_to?(:to_i) then
37
- fsize = arg1
38
- else
39
- fsize = (arg1.first-arg1.last).abs+1
40
- end
41
- # Build the type.
42
- case(self.name)
43
- when :bit
44
- typ = bit[isize+fsize].typedef(::HDLRuby.uniq_name)
45
- when :unsigned
46
- typ = unsigned[isize+fsize].typedef(::HDLRuby.uniq_name)
47
- when :signed
48
- typ = signed[isize+fsize].typedef(::HDLRuby.uniq_name)
49
- else
50
- raise "Invalid type for generating a fixed point type: #{self.name}"
51
- end
52
- # Redefine the multiplication and division for fixed point.
53
- typ.define_operator(:*) do |left,right|
54
- (left.as([isize+fsize*2])*right) >> fsize
55
- end
56
- typ.define_operator(:/) do |left,right|
57
- (left.as([isize+fsize*2]) << fsize) / right
58
- end
59
- typ
60
62
  end
63
+ return res
61
64
  end
62
- return res
63
65
  end
64
66
  end
65
67
 
@@ -1,3 +1,3 @@
1
1
  module HDLRuby
2
- VERSION = "2.3.1"
2
+ VERSION = "2.3.2"
3
3
  end
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.3.1
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lovic Gauthier
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-23 00:00:00.000000000 Z
11
+ date: 2020-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler