HDLRuby 2.3.0 → 2.3.5

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.
@@ -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
 
@@ -568,7 +568,7 @@ HDLRuby::High::Std.channel(:mem_dual) do |typ,size,clk,rst,br_rsts = {}|
568
568
  # using +target+ as target of access result.
569
569
  writer do |blk,target|
570
570
  # On reset the read trigger is 0.
571
- rst = send(rst_name)
571
+ rst = send(rst_name)
572
572
  top_block.unshift do
573
573
  # Initialize the address so that the next access is at address 0.
574
574
  hif(rst == 1) { abus_w <= -1 }
@@ -889,11 +889,11 @@ HDLRuby::High::Std.channel(:mem_file) do |typ,size,clk,rst,br_rsts = {}|
889
889
  rst_name = br_rsts[:winc].to_sym
890
890
  else
891
891
  rst_name = rst.name
892
- reader_input rst_name
892
+ writer_input rst_name
893
893
  end
894
894
  # Declares the address counter.
895
895
  [size.width-1].inner :abus_w
896
- reader_inout :abus_w
896
+ writer_inout :abus_w
897
897
 
898
898
  # Defines the write procedure at address +addr+
899
899
  # using +target+ as target of access result.
@@ -1,3 +1,3 @@
1
1
  module HDLRuby
2
- VERSION = "2.3.0"
2
+ VERSION = "2.3.5"
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.0
4
+ version: 2.3.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: 2020-07-18 00:00:00.000000000 Z
11
+ date: 2020-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler