HDLRuby 2.2.0 → 2.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8f74ac40d2f3ddc8ec9eb5a17c8d48b091068288a4bdb37adad8008c9b29e78
4
- data.tar.gz: '084b85f61816a823c92b736e1d203274f3e1beb2b2278f240bee36218665afe7'
3
+ metadata.gz: ce1d3b652bf8a3590f023acab0e74ec08d6062df5ccbc38fb1e1cbeb2cd41028
4
+ data.tar.gz: 52461928e01080214a4fb6ce0f1f852c6403d26bfd152579755e6b2990c396d2
5
5
  SHA512:
6
- metadata.gz: ef3418dda3d976fe68beb65a305c6163da94cdecf398ddd9bbc06786abc3c130b8df6ecd3a94064ecc0ffc64105a63838c455bd0709c3f64c83f2e40d7406a2b
7
- data.tar.gz: 8c9284a2c34be1f2e39b55cac6419ea858dd4972f9715bf2e39317bdcc4d7fcdcffae4d5c76ff3bbfabd77acd1a295a2cbba651568c569e144900e47814fc072
6
+ metadata.gz: 193afd5d38ef5159a89630f9f44be2e43c95925f9d6f0d037616e26fb9dc5538fce721be53ebfc7c08ce303e6937f7eddf6bf6493cb741c485ec878c538c28a6
7
+ data.tar.gz: d666fca088c1c737f81cccbbc58982e194ee0cff2fcd801e2ac9f13d504de04f3be4f3dae66dd6408af1c9d079b3f9c7dad0334c08bd77ad20daaae513058f92
@@ -0,0 +1,7 @@
1
+ system :adder do
2
+ [4].input :a,:b
3
+ [4].output :x
4
+ output :carry
5
+
6
+ [x,carry] <= a.as([5])+b
7
+ end
@@ -3696,6 +3696,16 @@ module HDLRuby::Low
3696
3696
  def hash
3697
3697
  return super
3698
3698
  end
3699
+
3700
+ # Gets the top block, i.e. the first block of the current behavior.
3701
+ def top_block
3702
+ raise AnyError, "Connections are not within blocks."
3703
+ end
3704
+
3705
+ # Gets the top scope, i.e. the first scope of the current system.
3706
+ def top_scope
3707
+ return self.parent.is_a?(Scope) ? self.parent : self.parent.top_scope
3708
+ end
3699
3709
  end
3700
3710
 
3701
3711
 
@@ -41,7 +41,8 @@ module HDLRuby::Low
41
41
  if nconnection.is_a?(Block) then
42
42
  # The connection has been broken, remove the former
43
43
  # version and add the generated block as a behavior.
44
- self.remove_connection(connection)
44
+ # self.remove_connection(connection)
45
+ self.delete_connection!(connection)
45
46
  self.add_behavior(Behavior.new(nconnection))
46
47
  end
47
48
  end
@@ -159,4 +160,89 @@ module HDLRuby::Low
159
160
  return self
160
161
  end
161
162
  end
163
+
164
+
165
+ ## Extends the Connection class with functionality for breaking assingments
166
+ # to concats.
167
+ class Connection
168
+ # Break the assignments to concats.
169
+ #
170
+ # NOTE: when breaking generates a new Block containing the broken
171
+ # assignments.
172
+ def break_concat_assigns
173
+ # puts "break_concat_assigns with self=#{self}"
174
+ # Is the left value a RefConcat?
175
+ self.left.each_node_deep do |node|
176
+ if node.is_a?(RefConcat) then
177
+ # Yes, must break. Create the resulting sequential
178
+ # block that will contain the new assignements.
179
+ block = Block.new(:seq)
180
+ # Create an intermediate signal for storing the
181
+ # right value. Put it in the top scope.
182
+ top_scope = self.top_scope
183
+ aux = top_scope.add_inner(
184
+ SignalI.new(HDLRuby.uniq_name,self.right.type) )
185
+ # puts "new signal: #{aux.name}"
186
+ aux = RefName.new(aux.type,RefThis.new,aux.name)
187
+ # Set a default value to avoid latch generation.
188
+ block.insert_statement!(0,
189
+ Transmit.new(aux.clone,Value.new(aux.type,0)))
190
+ # Replace the concat in the copy of the left value.
191
+ if left.eql?(node) then
192
+ # node was the top of left, replace here.
193
+ nleft = aux
194
+ else
195
+ # node was inside left, replace within left.
196
+ nleft = self.left.clone
197
+ nleft.each_node_deep do |ref|
198
+ ref.map_nodes! do |sub|
199
+ sub.eql?(node) ? aux.clone : sub
200
+ end
201
+ end
202
+ end
203
+ # Recreate the transmit and add it to the block.
204
+ block.add_statement(
205
+ Transmit.new(nleft,self.right.clone) )
206
+ # And assign its part to each reference of the
207
+ # concat.
208
+ pos = 0
209
+ node.each_ref.reverse_each do |ref|
210
+ # Compute the range to assign.
211
+ range = ref.type.width-1+pos .. pos
212
+ # Single or multi-bit range?
213
+ sbit = range.first == range.last
214
+ # Convert the range to an HDLRuby range for
215
+ # using is the resulting statement.
216
+ # Create and add the statement.
217
+ if sbit then
218
+ # Single bit.
219
+ # Generate the index.
220
+ idx = Value.new(Integer,range.first)
221
+ # Generate the assignment.
222
+ block.add_statement(
223
+ Transmit.new(ref.clone,
224
+ RefIndex.new(aux.type.base, aux.clone, idx)))
225
+ else
226
+ # Multi-bits.
227
+ # Compute the type of the right value.
228
+ rtype = TypeVector.new(:"",aux.type.base,range)
229
+ # Generate the range.
230
+ range = Value.new(Integer,range.first) ..
231
+ Value.new(Integer,range.last)
232
+ # Generate the assignment.
233
+ block.add_statement(
234
+ Transmit.new(ref.clone,
235
+ RefRange.new(rtype, aux.clone, range)))
236
+ end
237
+ pos += ref.type.width
238
+ end
239
+ # puts "Resulting block=#{block.to_vhdl}"
240
+ # Return the resulting block
241
+ return block
242
+ end
243
+ end
244
+ # No, nothing to do.
245
+ return self
246
+ end
247
+ end
162
248
  end
@@ -1537,8 +1537,15 @@ end
1537
1537
  # Used when casting expressions.
1538
1538
  class Cast
1539
1539
  # Converts the system to Verilog code.
1540
+ # NOTE: the cast is rounded up size bit-width cast is not supported
1541
+ # by traditional verilog.
1540
1542
  def to_verilog
1541
- return "#{self.type.to_verilog}'(#{self.child.to_verilog})"
1543
+ # return "#{self.type.to_verilog}'(#{self.child.to_verilog})"
1544
+ if self.type.signed? then
1545
+ return "$signed(#{self.child.to_verilog})"
1546
+ else
1547
+ return "$unsigned(#{self.child.to_verilog})"
1548
+ end
1542
1549
  end
1543
1550
  end
1544
1551
 
@@ -1,3 +1,3 @@
1
1
  module HDLRuby
2
- VERSION = "2.2.0"
2
+ VERSION = "2.2.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.2.0
4
+ version: 2.2.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-03-08 00:00:00.000000000 Z
11
+ date: 2020-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -70,6 +70,7 @@ files:
70
70
  - lib/HDLRuby/hdr_samples/adder_assign_error.rb
71
71
  - lib/HDLRuby/hdr_samples/adder_bench.rb
72
72
  - lib/HDLRuby/hdr_samples/adder_gen.rb
73
+ - lib/HDLRuby/hdr_samples/adder_kadai.rb
73
74
  - lib/HDLRuby/hdr_samples/adder_nodef_error.rb
74
75
  - lib/HDLRuby/hdr_samples/addsub.rb
75
76
  - lib/HDLRuby/hdr_samples/addsubz.rb