HDLRuby 2.0.18 → 2.1.0
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/with_channel.rb +6 -6
- data/lib/HDLRuby/high_samples/registers.rb +16 -5
- data/lib/HDLRuby/hruby_high.rb +134 -4
- data/lib/HDLRuby/hruby_low.rb +7 -0
- data/lib/HDLRuby/std/channel.rb +98 -10
- data/lib/HDLRuby/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c150464dc8c76fe2fdcf37ee752a8662c8d6128b
|
4
|
+
data.tar.gz: 16facc5e58f5545cf85586f541c61638ecd78733
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8402087045e3f64a50e0553a69b36dcce5b752bb16c58a0f75ffa37bddeea9b3e366f65d94abdc5abae4f9ee0532d0e8e85e8b2a254e9f18484033b17e31fa47
|
7
|
+
data.tar.gz: 406803e4c457b43b52a71eec5d121d8fa09902c7943b7611c5ffd22cca5207bfb3647ee642bdbc869a7d4aff9d07d2d69d8f29878a1fdae06fbb6d650f3257bc
|
@@ -71,7 +71,7 @@ system :producer8 do |channel|
|
|
71
71
|
# Inputs of the producer: clock and reset.
|
72
72
|
input :clk, :rst
|
73
73
|
# Instantiate the channel ports
|
74
|
-
channel.
|
74
|
+
channel.output :ch
|
75
75
|
# Inner 8-bit counter for generating values.
|
76
76
|
[8].inner :counter
|
77
77
|
|
@@ -79,7 +79,7 @@ system :producer8 do |channel|
|
|
79
79
|
par(clk.posedge) do
|
80
80
|
hif(rst) { counter <= 0 }
|
81
81
|
helse do
|
82
|
-
|
82
|
+
ch.write(counter) { counter <= counter + 1 }
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
@@ -89,13 +89,13 @@ system :consummer8 do |channel|
|
|
89
89
|
# Input of the consummer: a clock is enough.
|
90
90
|
input :clk
|
91
91
|
# Instantiate the channel ports
|
92
|
-
channel.
|
92
|
+
channel.input :ch
|
93
93
|
# Inner buffer for storing the cunsummed value.
|
94
94
|
[8].inner :buf
|
95
95
|
|
96
96
|
# The value consumption process
|
97
97
|
par(clk.posedge) do
|
98
|
-
|
98
|
+
ch.read(buf)
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
@@ -111,8 +111,8 @@ system :hs_test do
|
|
111
111
|
hs.reset.at(rst.posedge)
|
112
112
|
|
113
113
|
# Instantiate the producer.
|
114
|
-
producer8(hs).(:producerI).(clk,rst
|
114
|
+
producer8(hs).(:producerI).(clk,rst)
|
115
115
|
|
116
116
|
# Instantiate the consummer.
|
117
|
-
consummer8(hs).(:consummerI).(clk
|
117
|
+
consummer8(hs).(:consummerI).(clk)
|
118
118
|
end
|
@@ -56,22 +56,31 @@ system :regn do |n|
|
|
56
56
|
end
|
57
57
|
|
58
58
|
# Instantiate it for checking.
|
59
|
-
regn :regn8I,8
|
59
|
+
# regn :regn8I,8
|
60
|
+
regn(8).(:regn8I)
|
60
61
|
|
61
62
|
|
62
63
|
# Describes a register of generic type.
|
64
|
+
# NOTE: the input can be automatically connected from the generic argument.
|
63
65
|
system :reg do |typ|
|
64
66
|
input :clk, :rst
|
65
67
|
typ.input :d
|
68
|
+
# Now ensure typ is a type.
|
69
|
+
typ = typ.type if typ.is_a?(HExpression)
|
66
70
|
typ.output :q,:qb
|
67
71
|
|
72
|
+
|
68
73
|
qb <= ~q
|
69
74
|
(q <= d & [~rst]*typ.width).at(clk.posedge)
|
70
75
|
end
|
71
76
|
|
72
77
|
# Instantiate it for checking.
|
73
|
-
reg :regbit8I, bit[7..0]
|
78
|
+
# reg :regbit8I, bit[7..0]
|
79
|
+
reg(bit[7..0]).(:regbit8I)
|
74
80
|
|
81
|
+
# Instantiate it with infered type from connection.
|
82
|
+
bit[8].inner :sig0
|
83
|
+
reg(sig0).(:regSig0I)
|
75
84
|
|
76
85
|
|
77
86
|
# Function generating the body of a register description.
|
@@ -104,8 +113,10 @@ end
|
|
104
113
|
# Instantiate these systems for checking them.
|
105
114
|
dff_body :dff_bodyI
|
106
115
|
reg8_body :reg8_bodyI
|
107
|
-
regn_body :regn_bodyI, 8
|
108
|
-
|
116
|
+
# regn_body :regn_bodyI, 8
|
117
|
+
regn_body(8).(:regn_bodyI)
|
118
|
+
# reg_body :reg_bodyI, bit[7..0]
|
119
|
+
reg_body(bit[7..0]).(:reg_bodyI)
|
109
120
|
|
110
121
|
|
111
122
|
# Function generating a register declaration.
|
@@ -123,7 +134,7 @@ end
|
|
123
134
|
# Now let's generate the register declarations.
|
124
135
|
make_reg(:dff_make) { bit }
|
125
136
|
make_reg(:reg8_make){ bit[7..0] }
|
126
|
-
make_reg(:regn_make){ |n| bit[n-1..0] }
|
137
|
+
make_reg(:regn_make){ |n| bit[(n-1)..0] }
|
127
138
|
make_reg(:reg_make) { |typ| typ }
|
128
139
|
|
129
140
|
# Instantiate these systems for checking them.
|
data/lib/HDLRuby/hruby_high.rb
CHANGED
@@ -336,6 +336,9 @@ module HDLRuby::High
|
|
336
336
|
# Create the public namespace.
|
337
337
|
@public_namespace = Namespace.new(self.scope)
|
338
338
|
|
339
|
+
# Initialize the list of tasks to execute on the instance.
|
340
|
+
@on_instances = []
|
341
|
+
|
339
342
|
# Check and set the mixins.
|
340
343
|
mixins.each do |mixin|
|
341
344
|
unless mixin.is_a?(SystemT) then
|
@@ -543,6 +546,21 @@ module HDLRuby::High
|
|
543
546
|
return self
|
544
547
|
end
|
545
548
|
|
549
|
+
|
550
|
+
# Adds a task to apply on the instances of the system.
|
551
|
+
def on_instance(&ruby_block)
|
552
|
+
@on_instances << ruby_block
|
553
|
+
end
|
554
|
+
|
555
|
+
# Iterate over the task to apply on the instances of the system.
|
556
|
+
def each_on_instance(&ruby_block)
|
557
|
+
# No ruby block? Return an enumerator.
|
558
|
+
return to_enum(:each_on_instance) unless ruby_block
|
559
|
+
# A block? Apply it on each overload if any.
|
560
|
+
@on_instances.each(&ruby_block)
|
561
|
+
end
|
562
|
+
|
563
|
+
|
546
564
|
# Instantiate the system type to an instance named +i_name+ with
|
547
565
|
# possible arguments +args+.
|
548
566
|
def instantiate(i_name,*args)
|
@@ -560,6 +578,10 @@ module HDLRuby::High
|
|
560
578
|
# puts "instance scope= #{instance.systemT.scope}"
|
561
579
|
# Add the instance.
|
562
580
|
High.top_user.send(:add_systemI,instance)
|
581
|
+
|
582
|
+
# Execute the post instantiation tasks.
|
583
|
+
eigen.each_on_instance { |task| task.(instance) }
|
584
|
+
|
563
585
|
# Return the resulting instance
|
564
586
|
return instance
|
565
587
|
end
|
@@ -884,8 +906,6 @@ module HDLRuby::High
|
|
884
906
|
@namespace.concat_namespace(base.namespace)
|
885
907
|
High.space_push(@namespace)
|
886
908
|
# Execute the instantiation block
|
887
|
-
# instance_proc = base.parent.instance_proc if base.parent.respond_to?(:instance_proc)
|
888
|
-
# @return_value = High.top_user.instance_exec(*args,&instance_proc) if instance_proc
|
889
909
|
base.parent.each_instance_proc do |instance_proc|
|
890
910
|
@return_value = High.top_user.instance_exec(*args,&instance_proc)
|
891
911
|
end
|
@@ -1148,9 +1168,14 @@ module HDLRuby::High
|
|
1148
1168
|
export
|
1149
1169
|
end
|
1150
1170
|
end
|
1171
|
+
# Adds the task to execute on the instance.
|
1172
|
+
system.each_on_instance do |task|
|
1173
|
+
self.parent.on_instance(&task)
|
1174
|
+
end
|
1151
1175
|
end
|
1152
1176
|
# Adds it the list of includeds
|
1153
1177
|
@includes[include_name] = system
|
1178
|
+
|
1154
1179
|
end
|
1155
1180
|
|
1156
1181
|
# Casts as an included +system+.
|
@@ -1161,6 +1186,7 @@ module HDLRuby::High
|
|
1161
1186
|
return @includes[system].namespace
|
1162
1187
|
end
|
1163
1188
|
|
1189
|
+
|
1164
1190
|
include Hmux
|
1165
1191
|
|
1166
1192
|
# Fills a low level scope with self's contents.
|
@@ -1523,7 +1549,34 @@ module HDLRuby::High
|
|
1523
1549
|
|
1524
1550
|
include HbasicType
|
1525
1551
|
end
|
1526
|
-
|
1552
|
+
|
1553
|
+
# # The infer type.
|
1554
|
+
# # Unspecified, but automatically infered when connected.
|
1555
|
+
# Infer = define_type(:infer)
|
1556
|
+
# class << Infer
|
1557
|
+
# # The specified type.
|
1558
|
+
# attr_reader :type
|
1559
|
+
|
1560
|
+
# # Sets the specifed type to typ.
|
1561
|
+
# def type=(typ)
|
1562
|
+
# # Ensure typ is a type.
|
1563
|
+
# typ = typ.to_type
|
1564
|
+
# unless @type
|
1565
|
+
# @type = typ
|
1566
|
+
# else
|
1567
|
+
# unless @type.eql(typ)
|
1568
|
+
# raise AnyError.new("Invalid type for connection to auto type: expecting #{@type} but got #{typ}")
|
1569
|
+
# end
|
1570
|
+
# end
|
1571
|
+
# return self
|
1572
|
+
# end
|
1573
|
+
|
1574
|
+
# # Converts the type to HDLRuby::low.
|
1575
|
+
# # Actually returns the HDLRuby::low version of the specified type.
|
1576
|
+
# def to_low
|
1577
|
+
# return type.to_low
|
1578
|
+
# end
|
1579
|
+
# end
|
1527
1580
|
|
1528
1581
|
|
1529
1582
|
|
@@ -1839,7 +1892,8 @@ module HDLRuby::High
|
|
1839
1892
|
# in the order of declaration.
|
1840
1893
|
def call(*connects)
|
1841
1894
|
# Checks if it is a connection through is a hash.
|
1842
|
-
if connects.size == 1 and connects[0].respond_to?(:to_h)
|
1895
|
+
if connects.size == 1 and connects[0].respond_to?(:to_h) and
|
1896
|
+
!connects[0].is_a?(HRef) then
|
1843
1897
|
# Yes, perform a connection by name
|
1844
1898
|
connects = connects[0].to_h
|
1845
1899
|
# Performs the connections.
|
@@ -2167,6 +2221,66 @@ module HDLRuby::High
|
|
2167
2221
|
# The type of the expression if resolved.
|
2168
2222
|
attr_reader :type
|
2169
2223
|
|
2224
|
+
# Creates input port +name+ and connect it to the expression.
|
2225
|
+
def input(name)
|
2226
|
+
# Ensures the name is a symbol.
|
2227
|
+
name = name.to_sym
|
2228
|
+
# Get access to the current expression
|
2229
|
+
obj = self
|
2230
|
+
# Create the input.
|
2231
|
+
port = nil
|
2232
|
+
HDLRuby::High.cur_system.open do
|
2233
|
+
port = obj.type.input(name)
|
2234
|
+
end
|
2235
|
+
# Make the connection when the instance is ready.
|
2236
|
+
HDLRuby::High.cur_system.on_instance do |inst|
|
2237
|
+
obj.scope.open do
|
2238
|
+
RefObject.new(inst,port.to_ref) <= obj
|
2239
|
+
end
|
2240
|
+
end
|
2241
|
+
return port
|
2242
|
+
end
|
2243
|
+
|
2244
|
+
# Creates output port +name+ and connect it to the expression.
|
2245
|
+
def output(name)
|
2246
|
+
# Ensures the name is a symbol.
|
2247
|
+
name = name.to_sym
|
2248
|
+
# Get access to the current expression
|
2249
|
+
obj = self
|
2250
|
+
# Create the output.
|
2251
|
+
port = nil
|
2252
|
+
HDLRuby::High.cur_system.open do
|
2253
|
+
port = obj.type.output(name)
|
2254
|
+
end
|
2255
|
+
# Make the connection when the instance is ready.
|
2256
|
+
HDLRuby::High.cur_system.on_instance do |inst|
|
2257
|
+
obj.scope.open do
|
2258
|
+
obj <= RefObject.new(inst,port.to_ref)
|
2259
|
+
end
|
2260
|
+
end
|
2261
|
+
return port
|
2262
|
+
end
|
2263
|
+
|
2264
|
+
# Creates inout port +name+ and connect it to the expression.
|
2265
|
+
def inout(name)
|
2266
|
+
# Ensures the name is a symbol.
|
2267
|
+
name = name.to_sym
|
2268
|
+
# Get access to the current expression
|
2269
|
+
obj = self
|
2270
|
+
# Create the inout.
|
2271
|
+
port = nil
|
2272
|
+
HDLRuby::High.cur_system.open do
|
2273
|
+
port = obj.type.inout(name)
|
2274
|
+
end
|
2275
|
+
# Make the connection when the instance is ready.
|
2276
|
+
HDLRuby::High.cur_system.on_instance do |inst|
|
2277
|
+
obj.scope.open do
|
2278
|
+
RefObject.new(inst,port.to_ref) <= obj
|
2279
|
+
end
|
2280
|
+
end
|
2281
|
+
return port
|
2282
|
+
end
|
2283
|
+
|
2170
2284
|
# Tell if the expression can be converted to a value.
|
2171
2285
|
def to_value?
|
2172
2286
|
return false
|
@@ -3495,6 +3609,22 @@ module HDLRuby::High
|
|
3495
3609
|
top_user.is_a?(Block)
|
3496
3610
|
end
|
3497
3611
|
|
3612
|
+
# Gets the enclosing scope if any.
|
3613
|
+
#
|
3614
|
+
# NOTE: +level+ allows to get an upper scope of the currently enclosing
|
3615
|
+
# scope.
|
3616
|
+
def self.cur_scope(level = 0)
|
3617
|
+
if level < 0 then
|
3618
|
+
raise AnyError, "Not within a scope: #{Namespaces[-1].user.class}"
|
3619
|
+
end
|
3620
|
+
if Namespaces[-1-level].user.is_a?(Scope) then
|
3621
|
+
return Namespaces[-1-level].user
|
3622
|
+
else
|
3623
|
+
return cur_scope(level+1)
|
3624
|
+
end
|
3625
|
+
end
|
3626
|
+
|
3627
|
+
|
3498
3628
|
# Gets the enclosing block if any.
|
3499
3629
|
#
|
3500
3630
|
# NOTE: +level+ allows to get an upper block of the currently enclosing
|
data/lib/HDLRuby/hruby_low.rb
CHANGED
data/lib/HDLRuby/std/channel.rb
CHANGED
@@ -71,6 +71,9 @@ module HDLRuby::High::Std
|
|
71
71
|
# The name of the channel instance.
|
72
72
|
attr_reader :name
|
73
73
|
|
74
|
+
# The scope the channel has been created in.
|
75
|
+
attr_reader :scope
|
76
|
+
|
74
77
|
# The namespace associated with the current execution when
|
75
78
|
# building a channel, its reader or its writer.
|
76
79
|
attr_reader :namespace
|
@@ -80,6 +83,10 @@ module HDLRuby::High::Std
|
|
80
83
|
# Check and set the name
|
81
84
|
@name = name.to_sym
|
82
85
|
|
86
|
+
# Sets the scope.
|
87
|
+
@scope = HDLRuby::High.cur_scope
|
88
|
+
|
89
|
+
# Keep access to self.
|
83
90
|
obj = self
|
84
91
|
|
85
92
|
# The reader input ports by name.
|
@@ -253,35 +260,116 @@ module HDLRuby::High::Std
|
|
253
260
|
|
254
261
|
# Reader an writer side.
|
255
262
|
|
256
|
-
## Declares the ports for the reader.
|
257
|
-
def reader_ports
|
263
|
+
# ## Declares the ports for the reader.
|
264
|
+
# def reader_ports
|
265
|
+
# loc_inputs = @reader_inputs
|
266
|
+
# loc_outputs = @reader_outputs
|
267
|
+
# loc_inouts = @reader_inouts
|
268
|
+
# HDLRuby::High.cur_system.open do
|
269
|
+
# # The inputs
|
270
|
+
# loc_inputs.each { |name,sig| sig.type.input name }
|
271
|
+
# # The outputs
|
272
|
+
# loc_outputs.each { |name,sig| sig.type.output name }
|
273
|
+
# # The inouts
|
274
|
+
# loc_inouts.each { |name,sig| sig.type.inout name }
|
275
|
+
# end
|
276
|
+
# end
|
277
|
+
|
278
|
+
## Declares the ports for the reader and assigned them to +name+.
|
279
|
+
def input(name)
|
280
|
+
# Ensure name is a symbol.
|
281
|
+
name = name.to_sym
|
282
|
+
# Access the ports
|
258
283
|
loc_inputs = @reader_inputs
|
259
284
|
loc_outputs = @reader_outputs
|
260
285
|
loc_inouts = @reader_inouts
|
286
|
+
# The generated port with corresponding channel port pairs.
|
287
|
+
port_pairs = []
|
288
|
+
# Add them to the current system.
|
261
289
|
HDLRuby::High.cur_system.open do
|
262
290
|
# The inputs
|
263
|
-
loc_inputs.each
|
291
|
+
loc_inputs.each do |name,sig|
|
292
|
+
port_pairs << [sig, sig.type.input(name)]
|
293
|
+
end
|
264
294
|
# The outputs
|
265
|
-
loc_outputs.each
|
295
|
+
loc_outputs.each do |name,sig|
|
296
|
+
port_pairs << [sig, sig.type.output(name)]
|
297
|
+
end
|
266
298
|
# The inouts
|
267
|
-
loc_inouts.each
|
299
|
+
loc_inouts.each do |name,sig|
|
300
|
+
port_pairs << [sig, sig.type.inout(name)]
|
301
|
+
end
|
302
|
+
end
|
303
|
+
obj = self
|
304
|
+
# Make the connection of the instance.
|
305
|
+
HDLRuby::High.cur_system.on_instance do |inst|
|
306
|
+
obj.scope.open do
|
307
|
+
port_pairs.each do |sig, port|
|
308
|
+
RefObject.new(inst,port.to_ref) <= sig
|
309
|
+
end
|
310
|
+
end
|
268
311
|
end
|
312
|
+
# Give access to the ports through name.
|
313
|
+
# NOTE: for now, simply associate the channel to name.
|
314
|
+
this = self
|
315
|
+
HDLRuby::High.space_reg(name) { this }
|
269
316
|
end
|
270
317
|
|
271
|
-
## Declares the ports for the writer.
|
272
|
-
def writer_ports
|
318
|
+
# ## Declares the ports for the writer.
|
319
|
+
# def writer_ports
|
320
|
+
# loc_inputs = @writer_inputs
|
321
|
+
# loc_outputs = @writer_outputs
|
322
|
+
# loc_inouts = @writer_inouts
|
323
|
+
# HDLRuby::High.cur_system.open do
|
324
|
+
# # The inputs
|
325
|
+
# loc_inputs.each { |name,sig| sig.type.input name }
|
326
|
+
# # The outputs
|
327
|
+
# loc_outputs.each { |name,sig| sig.type.output name }
|
328
|
+
# # The inouts
|
329
|
+
# loc_inouts.each { |name,sig| sig.type.inout name }
|
330
|
+
# end
|
331
|
+
# end
|
332
|
+
|
333
|
+
## Declares the ports for the reader and assigned them to +name+.
|
334
|
+
def output(name)
|
335
|
+
# Ensure name is a symbol.
|
336
|
+
name = name.to_sym
|
337
|
+
# Access the ports
|
273
338
|
loc_inputs = @writer_inputs
|
274
339
|
loc_outputs = @writer_outputs
|
275
340
|
loc_inouts = @writer_inouts
|
341
|
+
# The generated port with corresponding channel port pairs.
|
342
|
+
port_pairs = []
|
343
|
+
# Add them to the current system.
|
276
344
|
HDLRuby::High.cur_system.open do
|
277
345
|
# The inputs
|
278
|
-
loc_inputs.each
|
346
|
+
loc_inputs.each do |name,sig|
|
347
|
+
port_pairs << [sig, sig.type.input(name)]
|
348
|
+
end
|
279
349
|
# The outputs
|
280
|
-
loc_outputs.each
|
350
|
+
loc_outputs.each do |name,sig|
|
351
|
+
port_pairs << [sig, sig.type.output(name)]
|
352
|
+
end
|
281
353
|
# The inouts
|
282
|
-
loc_inouts.each
|
354
|
+
loc_inouts.each do |name,sig|
|
355
|
+
port_pairs << [sig, sig.type.inout(name)]
|
356
|
+
end
|
283
357
|
end
|
358
|
+
obj = self
|
359
|
+
# Make the connection of the instance.
|
360
|
+
HDLRuby::High.cur_system.on_instance do |inst|
|
361
|
+
obj.scope.open do
|
362
|
+
port_pairs.each do |sig, port|
|
363
|
+
RefObject.new(inst,port.to_ref) <= sig
|
364
|
+
end
|
365
|
+
end
|
366
|
+
end
|
367
|
+
# Give access to the ports through name.
|
368
|
+
# NOTE: for now, simply associate the channel to name.
|
369
|
+
this = self
|
370
|
+
HDLRuby::High.space_reg(name) { this }
|
284
371
|
end
|
372
|
+
|
285
373
|
|
286
374
|
## Performs a read on the channel using +args+ and +ruby_block+
|
287
375
|
# as arguments.
|
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.0
|
4
|
+
version: 2.1.0
|
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-
|
11
|
+
date: 2020-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|