HDLRuby 2.2.9 → 2.2.10

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: 19ade67ae4d1c2ae0cf6c1a5ba8bce4fb82d7026e9e902eb106401ab7c83ab82
4
- data.tar.gz: b112f3450d5846324538438ddfae966cabdcb651cf5a0d90c3dfca5f65b1030c
3
+ metadata.gz: 7b867bb3b74debaa536d2803c7646dd4bb6b1af3b9d6dfee8e2dd321137c05da
4
+ data.tar.gz: 7c6c21d6f808759241a5789993579fc49dd7acfbea2be645075044528d9d4a25
5
5
  SHA512:
6
- metadata.gz: 455b3d833372e5620ec3ba90bdc9d4b418e315a21cc61aeec3ccfe60e69ca55db152679b564c6c5568787205646541a476fe07c4ced066a977d22263a7e9ef8c
7
- data.tar.gz: 8bb1ea95785e99a3091db489f899acecd903512d6a28a0e6eaccea7b163265fcdd6e07708c1e06a8688c4172e9abe0c67bdf08281f7719ea3bd5f478cca866e6
6
+ metadata.gz: 663010998dbe51f0123d68e9fc785441e115ee54744f73b36be4bdc8de81103884933222b1a368f5c86809b71118e7b7ebd5e73f2f6e9179547a2971e501c8ef
7
+ data.tar.gz: 51d7866a4643f05cac41971be813ce43c039949fbbcdb2cfb30280b3fd27d13cbf82a378e4f1151b6b9f1e13d79d4a4a8e4e7172a072cc5e748c8327cc15cd65
@@ -1,10 +1,14 @@
1
1
 
2
2
  # Describes an 8-bit data 4-bit address ROM.
3
3
  system :rom4_8 do
4
- [3..0].input :addr
5
- [7..0].output :data
4
+ [2..0].input :addr
5
+ [7..0].output :data0,:data1,:data2
6
6
 
7
- bit[7..0][2**4].constant content: (2**4).times.to_a
7
+ bit[7..0][0..7].constant content0: [1,2,3,4,5,6,7]
8
+ bit[7..0][-8].constant content1: [1,2,3,4,5,6,7]
9
+ bit[7..0][-8].constant content2: (8).times.to_a
8
10
 
9
- data <= content[addr]
11
+ data0 <= content0[addr]
12
+ data1 <= content1[addr]
13
+ data2 <= content2[addr]
10
14
  end
@@ -576,6 +576,7 @@ elsif $options[:verilog] then
576
576
  systemT.to_global_systemTs!
577
577
  # systemT.break_types!
578
578
  # systemT.expand_types!
579
+ systemT.initial_concat_to_timed!
579
580
  systemT.with_port!
580
581
  end
581
582
  # # Verilog generation
@@ -463,14 +463,14 @@ module HDLRuby::Low
463
463
  end
464
464
  end
465
465
 
466
- # Sets the value.
466
+ # Sets the value (can also be nil for removing the value).
467
467
  def set_value!(value)
468
468
  # Check and set teh value.
469
- unless value.is_a?(Expression) then
470
- raise AnyError, "Invalid class for a constant: #{val.class}"
469
+ unless value == nil || value.is_a?(Expression) then
470
+ raise AnyError, "Invalid class for a constant: #{value.class}"
471
471
  end
472
472
  @value = value
473
- value.parent = self
473
+ value.parent = self unless value == nil
474
474
  end
475
475
 
476
476
  end
@@ -22,6 +22,15 @@ module HDLRuby::Low
22
22
  self.scope.break_concat_assigns!
23
23
  end
24
24
 
25
+ # Converts initial concat of values of signals to assignment in
26
+ # timed blocks (for making the code compatible with verilog
27
+ # translation).
28
+ #
29
+ # NOTE: Assumes such array as at the top level.
30
+ def initial_concat_to_timed!
31
+ self.scope.initial_concat_to_timed!
32
+ end
33
+
25
34
  end
26
35
 
27
36
  ## Extends the Scope class with functionality for breaking assingments
@@ -47,6 +56,48 @@ module HDLRuby::Low
47
56
  end
48
57
  end
49
58
  end
59
+
60
+ # Converts initial array of value of signals to assignment in
61
+ # timed blocks (for making the code compatible with verilog
62
+ # translation).
63
+ #
64
+ # NOTE: Assumes such array as at the top level.
65
+ def initial_concat_to_timed!
66
+ # Gather the signal with concat as initial values.
67
+ sigs = []
68
+ # For the interface signals of the upper system.
69
+ self.parent.each_signal do |sig|
70
+ sigs << sig if sig.value.is_a?(Concat)
71
+ end
72
+ # For the inner signals of the scope.
73
+ self.each_signal do |sig|
74
+ sigs << sig if sig.value.is_a?(Concat)
75
+ end
76
+ # No initial concat? End here.
77
+ return if sigs.empty?
78
+
79
+ # Create a timed block for moving the concat initialization
80
+ # to it.
81
+ initial = TimeBlock.new(:seq)
82
+ self.add_behavior(TimeBehavior.new(initial))
83
+ # Adds to it the initializations.
84
+ sigs.each do |sig|
85
+ name = sig.name
86
+ styp = sig.type
87
+ btyp = styp.base
88
+ value = sig.value
89
+ sig.value.each_expression.with_index do |expr,i|
90
+ left = RefIndex.new(btyp,
91
+ RefName.new(styp,RefThis.new,name),
92
+ i.to_expr)
93
+ initial.add_statement(Transmit.new(left,expr.clone))
94
+ end
95
+ end
96
+ # Remove the initial values from the signals.
97
+ sigs.each do |sig|
98
+ sig.set_value!(nil)
99
+ end
100
+ end
50
101
  end
51
102
 
52
103
  ## Extends the Block class with functionality for breaking assingments
@@ -317,7 +317,7 @@ module HDLRuby::Low
317
317
  # And create a new type from current type.
318
318
  # Maybe the new type already exists.
319
319
  ndef = types[self]
320
- return self if ndef # Yes, already exists.
320
+ return ndef if ndef # Yes, already exists.
321
321
  # No, create and register a new typedef.
322
322
  ndef = TypeDef.new(HDLRuby.uniq_name,self)
323
323
  types[self] = ndef
@@ -1501,6 +1501,9 @@ class Case
1501
1501
  whens.statement.each_statement do |statement|
1502
1502
  result << "#{statement.to_verilog}"
1503
1503
  end
1504
+ else
1505
+ # Empty statement case.
1506
+ result << "\n"
1504
1507
  end
1505
1508
  end
1506
1509
  # The default part is stored in default instead of when. Reads and processes in the same way as when.
@@ -1737,6 +1740,13 @@ class SystemT
1737
1740
  self.each_inner do |inner|
1738
1741
  regs << inner.to_verilog if inner.value
1739
1742
  end
1743
+ # And the array types signals.
1744
+ self.each_signal do |sig|
1745
+ regs << sig.to_verilog if sig.type.is_a?(TypeVector) && sig.type.base.is_a?(TypeVector)
1746
+ end
1747
+ self.each_inner do |sig|
1748
+ regs << sig.to_verilog if sig.type.is_a?(TypeVector) && sig.type.base.is_a?(TypeVector)
1749
+ end
1740
1750
 
1741
1751
  # Code generation
1742
1752
  inputs = 0
@@ -1851,7 +1861,6 @@ class SystemT
1851
1861
 
1852
1862
  # Declare "inner".
1853
1863
  self.each_inner do |inner|
1854
- # puts "for inner: #{inner.to_verilog}"
1855
1864
  # if regs.include?(inner.name) then
1856
1865
  if regs.include?(inner.to_verilog) then
1857
1866
  code << " reg"
@@ -1,3 +1,3 @@
1
1
  module HDLRuby
2
- VERSION = "2.2.9"
2
+ VERSION = "2.2.10"
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.2.9
4
+ version: 2.2.10
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-03-17 00:00:00.000000000 Z
11
+ date: 2020-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler