HDLRuby 3.9.1 → 3.9.3
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/README.html +4121 -4648
- data/README.md +9 -1
- data/ext/hruby_sim/hruby_rcsim_build.c +2 -0
- data/ext/hruby_sim/hruby_sim.h +6 -0
- data/ext/hruby_sim/hruby_sim_calc.c +67 -0
- data/lib/HDLRuby/hdr_samples/with_henumerable.rb +281 -258
- data/lib/HDLRuby/hdr_samples/with_to_svg.rb +37 -0
- data/lib/HDLRuby/hdr_samples/with_unary_reduction.rb +23 -0
- data/lib/HDLRuby/hdr_samples/with_values.rb +4 -0
- data/lib/HDLRuby/hdrcc.rb +3 -0
- data/lib/HDLRuby/hruby_bstr.rb +2 -1
- data/lib/HDLRuby/hruby_high.rb +35 -7
- data/lib/HDLRuby/hruby_low.rb +52 -87
- data/lib/HDLRuby/hruby_low_split_signals.rb +213 -0
- data/lib/HDLRuby/hruby_types.rb +6 -2
- data/lib/HDLRuby/hruby_viz.rb +359 -166
- data/lib/HDLRuby/std/hruby_enum.rb +104 -28
- data/lib/HDLRuby/std/sequencer.rb +17 -3
- data/lib/HDLRuby/verilog_hruby.rb +70 -28
- data/lib/HDLRuby/verilog_parser.rb +38 -18
- data/lib/HDLRuby/version.rb +1 -1
- metadata +5 -2
|
@@ -557,7 +557,7 @@ module HDLRuby::High::Std
|
|
|
557
557
|
if !ruby_block then
|
|
558
558
|
return HEnumeratorWrapper.new(self,:hreverse_each,*args)
|
|
559
559
|
end
|
|
560
|
-
return self.
|
|
560
|
+
return self.hto_a.reverse_each(&ruby_block)
|
|
561
561
|
end
|
|
562
562
|
|
|
563
563
|
# HW implementation of the Ruby slice_after.
|
|
@@ -786,7 +786,7 @@ module HDLRuby::High::Std
|
|
|
786
786
|
if !ruby_block then
|
|
787
787
|
return HEnumeratorWrapper.new(self,:heach_range)
|
|
788
788
|
end
|
|
789
|
-
return self.
|
|
789
|
+
return self.hto_a.each_range(rng,&ruby_block)
|
|
790
790
|
end
|
|
791
791
|
|
|
792
792
|
# Iterates with an index.
|
|
@@ -839,18 +839,26 @@ module HDLRuby::High::Std
|
|
|
839
839
|
return self unless ruby_block
|
|
840
840
|
# Create a namespace.
|
|
841
841
|
base_block = ruby_block
|
|
842
|
+
caught = false
|
|
842
843
|
ruby_block = proc do |*args|
|
|
843
844
|
HDLRuby::High.top_user.sub do
|
|
844
|
-
|
|
845
|
+
caught = true
|
|
846
|
+
catch(:HDLRubyThrow) do
|
|
847
|
+
base_block.call(*args)
|
|
848
|
+
caught = false
|
|
849
|
+
end
|
|
845
850
|
end
|
|
851
|
+
throw(:HDLRubyThrow) if caught
|
|
846
852
|
end
|
|
847
853
|
# Iterate.
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
854
|
+
catch(:HDLRubyThrow) do
|
|
855
|
+
if self.respond_to?(:[]) then
|
|
856
|
+
return self.size.htimes do |i|
|
|
857
|
+
ruby_block.call(self[i])
|
|
858
|
+
end
|
|
859
|
+
else
|
|
860
|
+
return self.hto_a.each(&ruby_block)
|
|
851
861
|
end
|
|
852
|
-
else
|
|
853
|
-
return self.hto_a.each(&ruby_block)
|
|
854
862
|
end
|
|
855
863
|
end
|
|
856
864
|
|
|
@@ -995,10 +1003,16 @@ module HDLRuby::High::Std
|
|
|
995
1003
|
# A block? Apply it on each element.
|
|
996
1004
|
# Create a namespace.
|
|
997
1005
|
base_block = ruby_block
|
|
1006
|
+
caught = false
|
|
998
1007
|
ruby_block = proc do |*args|
|
|
999
1008
|
HDLRuby::High.top_user.sub do
|
|
1000
|
-
|
|
1009
|
+
caught = true
|
|
1010
|
+
catch(:HDLRubyThrow) do
|
|
1011
|
+
base_block.call(*args)
|
|
1012
|
+
caught = false
|
|
1013
|
+
end
|
|
1001
1014
|
end
|
|
1015
|
+
throw(:HDLRubyThrow) if caught
|
|
1002
1016
|
end
|
|
1003
1017
|
# Iterate.
|
|
1004
1018
|
self.type.range.heach do |i|
|
|
@@ -1101,10 +1115,18 @@ module HDLRuby::High::Std
|
|
|
1101
1115
|
return HEnumeratorWrapper.new(self)
|
|
1102
1116
|
end
|
|
1103
1117
|
# self.each { |e| HDLRuby::High.top_user.sub { ruby_block.call(e) } }
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1118
|
+
catch(:HDLRubyThrow) do
|
|
1119
|
+
caught = false
|
|
1120
|
+
self.each do |e|
|
|
1121
|
+
HDLRuby::High.top_user.sub do
|
|
1122
|
+
caught = true
|
|
1123
|
+
catch(:HDLRubyThrow) do
|
|
1124
|
+
# HDLRuby::High.top_user.instance_exec(e,&ruby_block)
|
|
1125
|
+
ruby_block.call(e)
|
|
1126
|
+
caught = false
|
|
1127
|
+
end
|
|
1128
|
+
end
|
|
1129
|
+
throw(:HDLRubyThrow) if caught
|
|
1108
1130
|
end
|
|
1109
1131
|
end
|
|
1110
1132
|
end
|
|
@@ -1134,10 +1156,16 @@ module HDLRuby::High::Std
|
|
|
1134
1156
|
# A block is given, iterate on each element of the range
|
|
1135
1157
|
# Create a namespace.
|
|
1136
1158
|
base_block = ruby_block
|
|
1159
|
+
caught = false
|
|
1137
1160
|
ruby_block = proc do |*args|
|
|
1138
1161
|
HDLRuby::High.top_user.sub do
|
|
1139
|
-
|
|
1162
|
+
caught = true
|
|
1163
|
+
catch(:HDLRubyThrow) do
|
|
1164
|
+
base_block.call(*args)
|
|
1165
|
+
caught = false
|
|
1166
|
+
end
|
|
1140
1167
|
end
|
|
1168
|
+
throw(:HDLRubyThrow) if caught
|
|
1141
1169
|
end
|
|
1142
1170
|
# converted to values of the right type.
|
|
1143
1171
|
if first.is_a?(Value) then
|
|
@@ -1147,21 +1175,25 @@ module HDLRuby::High::Std
|
|
|
1147
1175
|
end
|
|
1148
1176
|
first = self.first.to_i
|
|
1149
1177
|
last = self.last.to_i
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1178
|
+
catch(:HDLRubyThrow) do
|
|
1179
|
+
if first <= last then
|
|
1180
|
+
(first..last).each do |i|
|
|
1181
|
+
ruby_block.call(i.as(typ))
|
|
1182
|
+
end
|
|
1183
|
+
else
|
|
1184
|
+
(last..first).reverse_each do |i|
|
|
1185
|
+
ruby_block.call(i.as(typ))
|
|
1186
|
+
end
|
|
1157
1187
|
end
|
|
1158
1188
|
end
|
|
1159
1189
|
else
|
|
1160
1190
|
# Other range cases.
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1191
|
+
catch(:HDLRubyThrow) do
|
|
1192
|
+
if self.first <= self.last then
|
|
1193
|
+
return self.each(&ruby_block)
|
|
1194
|
+
else
|
|
1195
|
+
return (self.last..self.first).reverse_each(&ruby_block)
|
|
1196
|
+
end
|
|
1165
1197
|
end
|
|
1166
1198
|
end
|
|
1167
1199
|
end
|
|
@@ -1176,13 +1208,57 @@ module HDLRuby::High::Std
|
|
|
1176
1208
|
# Enhance the Integer class with sequencer iterations.
|
|
1177
1209
|
|
|
1178
1210
|
# HW times iteration.
|
|
1179
|
-
alias_method :htimes, :times
|
|
1211
|
+
# alias_method :htimes, :times
|
|
1212
|
+
def htimes(&ruby_block)
|
|
1213
|
+
return HEnumeratorWrapper.new(self,:htimes) unless ruby_block
|
|
1214
|
+
self.times do |i|
|
|
1215
|
+
ruby_block.call(i)
|
|
1216
|
+
end
|
|
1217
|
+
end
|
|
1180
1218
|
|
|
1181
1219
|
# HW upto iteration.
|
|
1182
|
-
alias_method :hupto, :upto
|
|
1220
|
+
# alias_method :hupto, :upto
|
|
1221
|
+
def hupto(val,&ruby_block)
|
|
1222
|
+
return HEnumeratorWrapper.new(self,:hupto) unless ruby_block
|
|
1223
|
+
self.upto(val) do |i|
|
|
1224
|
+
ruby_block.call(i)
|
|
1225
|
+
end
|
|
1226
|
+
end
|
|
1183
1227
|
|
|
1184
1228
|
# HW downto iteration.
|
|
1185
|
-
alias_method :hdownto, :downto
|
|
1229
|
+
# alias_method :hdownto, :downto
|
|
1230
|
+
def hdownto(val,&ruby_block)
|
|
1231
|
+
return HEnumeratorWrapper.new(self,:hdownto) unless ruby_block
|
|
1232
|
+
self.downto(val) do |i|
|
|
1233
|
+
ruby_block.call(i)
|
|
1234
|
+
end
|
|
1235
|
+
end
|
|
1236
|
+
end
|
|
1237
|
+
|
|
1238
|
+
|
|
1239
|
+
# Handle the enumeration exits.
|
|
1240
|
+
module HEnumeratorExit
|
|
1241
|
+
# Parallel break.
|
|
1242
|
+
def hbreak
|
|
1243
|
+
throw(:"HDLRubyThrow")
|
|
1244
|
+
end
|
|
1245
|
+
|
|
1246
|
+
# Parallel continue.
|
|
1247
|
+
def hcontinue
|
|
1248
|
+
raise("hcontinue not implemented yet.")
|
|
1249
|
+
end
|
|
1250
|
+
end
|
|
1251
|
+
|
|
1252
|
+
|
|
1253
|
+
class HDLRuby::High::Scope
|
|
1254
|
+
include HEnumeratorExit
|
|
1255
|
+
end
|
|
1256
|
+
|
|
1257
|
+
module HDLRuby::High::HBlock
|
|
1258
|
+
# Also adds the methods of HEnumerable.
|
|
1259
|
+
HEnumeratorExit.instance_methods.each do |meth|
|
|
1260
|
+
define_method(meth,HEnumeratorExit.instance_method(meth))
|
|
1261
|
+
end
|
|
1186
1262
|
end
|
|
1187
1263
|
|
|
1188
1264
|
end
|
|
@@ -355,10 +355,24 @@ module HDLRuby::High::Std
|
|
|
355
355
|
def make_inners(typ,*names)
|
|
356
356
|
res = nil
|
|
357
357
|
if SequencerT.current then
|
|
358
|
-
unames = names.map {|name| HDLRuby.uniq_name(name) }
|
|
359
|
-
res = HDLRuby::High.cur_scope.make_inners(typ, *unames)
|
|
360
|
-
names.zip(unames).each do |name,uname|
|
|
358
|
+
# unames = names.map {|name| HDLRuby.uniq_name(name) }
|
|
359
|
+
# res = HDLRuby::High.cur_scope.make_inners(typ, *unames)
|
|
360
|
+
# names.zip(unames).each do |name,uname|
|
|
361
|
+
# HDLRuby::High.space_reg(name) { send(uname) }
|
|
362
|
+
# end
|
|
363
|
+
names.each do |name|
|
|
364
|
+
if name.respond_to?(:to_sym) then
|
|
365
|
+
uname = HDLRuby.uniq_name(name)
|
|
366
|
+
res = HDLRuby::High.cur_scope.make_inners(typ, uname)
|
|
361
367
|
HDLRuby::High.space_reg(name) { send(uname) }
|
|
368
|
+
elsif name.is_a?(Hash) then
|
|
369
|
+
name.each do |key,value|
|
|
370
|
+
uname = HDLRuby.uniq_name(key)
|
|
371
|
+
res = HDLRuby::High.cur_scope.make_inners(typ,
|
|
372
|
+
uname => value)
|
|
373
|
+
HDLRuby::High.space_reg(key) { send(uname) }
|
|
374
|
+
end
|
|
375
|
+
end
|
|
362
376
|
end
|
|
363
377
|
else
|
|
364
378
|
# self.old_make_inners(typ,*names)
|
|
@@ -5,6 +5,14 @@ require "HDLRuby/verilog_parser"
|
|
|
5
5
|
|
|
6
6
|
module VerilogTools
|
|
7
7
|
|
|
8
|
+
# Table for fixing the reserved names in HDLRuby.
|
|
9
|
+
RESERVED_FIX = {
|
|
10
|
+
"load" => "_load",
|
|
11
|
+
"select" => "_select",
|
|
12
|
+
"in" => "_in",
|
|
13
|
+
"sub" => "_sub"
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
# The possible levels in HDLRuby generation.
|
|
9
17
|
HDLRubyLevels = [ :top, :system, :hdef, :<=, :seq, :par, :timed, :expr ]
|
|
10
18
|
NoEventLevels = [ :hdef, :<=, :seq, :par, :timed ]
|
|
@@ -111,7 +119,10 @@ module VerilogTools
|
|
|
111
119
|
# HDLRuby names cannot start with a $ or a capital letter.
|
|
112
120
|
# To fix that add an "_", but then to avoid confusion, also
|
|
113
121
|
# convert starting "_" to "__" if any.
|
|
122
|
+
name = "_Z" if name == "Z" # _Z mean something in HDLRuby
|
|
114
123
|
return "_" + name
|
|
124
|
+
elsif RESERVED_FIX.key?(name) then
|
|
125
|
+
return RESERVED_FIX[name]
|
|
115
126
|
else
|
|
116
127
|
return name
|
|
117
128
|
end
|
|
@@ -432,17 +443,49 @@ module VerilogTools
|
|
|
432
443
|
|
|
433
444
|
|
|
434
445
|
TO_HDLRuby[:output_declaration] = lambda do |ast,state|
|
|
435
|
-
# Ignore the OUTPUTTYPE not used in HDLRuby
|
|
446
|
+
# # Ignore the OUTPUTTYPE not used in HDLRuby
|
|
447
|
+
# # Get the sign if any.
|
|
448
|
+
# sign = ast[1]
|
|
449
|
+
# sign = "" unless sign
|
|
450
|
+
# # Get the range.
|
|
451
|
+
# range = ast[2]
|
|
452
|
+
# range = range ? range.to_HDLRuby(state) + "." : ""
|
|
453
|
+
# # Get the names.
|
|
454
|
+
# names = ast[3].to_HDLRuby(state)
|
|
455
|
+
# # Genereate the resulting declaration.
|
|
456
|
+
# return state.indent + sign + range +"output " + names + "\n"
|
|
457
|
+
|
|
436
458
|
# Get the sign if any.
|
|
437
459
|
sign = ast[1]
|
|
438
460
|
sign = "" unless sign
|
|
439
461
|
# Get the range.
|
|
440
462
|
range = ast[2]
|
|
441
463
|
range = range ? range.to_HDLRuby(state) + "." : ""
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
464
|
+
res_txt = ""
|
|
465
|
+
ast[3][0].each do |reg|
|
|
466
|
+
if reg[0].type == :name_of_memory then
|
|
467
|
+
# It is a memory, it must be declared.
|
|
468
|
+
sign = "bit" if sign.empty?
|
|
469
|
+
res_txt += state.indent + sign + range[0..-2] +
|
|
470
|
+
"[" + reg[1].to_HDLRuby(state) + ".." +
|
|
471
|
+
reg[2].to_HDLRuby(state) + "].output :" +
|
|
472
|
+
reg[0].to_HDLRuby(state) + "\n"
|
|
473
|
+
else
|
|
474
|
+
# It is a standard register, it may override a previous
|
|
475
|
+
# declaration and in such case can be omitted in HDLRuby.
|
|
476
|
+
n = reg[0].to_HDLRuby(state)
|
|
477
|
+
v = reg[1]
|
|
478
|
+
v = v.to_HDLRuby(state) if v
|
|
479
|
+
unless state.port_names.include?(n) then
|
|
480
|
+
if v then
|
|
481
|
+
res_txt += state.indent + sign + range + "output " + n + ": #{v}\n"
|
|
482
|
+
else
|
|
483
|
+
res_txt += state.indent + sign + range + "output :" + n + "\n"
|
|
484
|
+
end
|
|
485
|
+
end
|
|
486
|
+
end
|
|
487
|
+
end
|
|
488
|
+
return res_txt
|
|
446
489
|
end
|
|
447
490
|
|
|
448
491
|
|
|
@@ -492,15 +535,6 @@ module VerilogTools
|
|
|
492
535
|
# Get the range.
|
|
493
536
|
range = ast[1]
|
|
494
537
|
range = range ? range.to_HDLRuby(state) + "." : ""
|
|
495
|
-
# # Get the name.
|
|
496
|
-
# names = ast[2].to_HDLRuby(state)
|
|
497
|
-
# if names.empty? then
|
|
498
|
-
# # There is actually no new inner.
|
|
499
|
-
# return ""
|
|
500
|
-
# end
|
|
501
|
-
# Registers can also be memory, so treat each name independantly.
|
|
502
|
-
# # Genereate the resulting declaration.
|
|
503
|
-
# return state.indent + sign + range +"inner " + names + "\n"
|
|
504
538
|
res_txt = ""
|
|
505
539
|
ast[2][0].each do |reg|
|
|
506
540
|
if reg[0].type == :name_of_memory then
|
|
@@ -514,12 +548,18 @@ module VerilogTools
|
|
|
514
548
|
# It is a standard register, it may override a previous
|
|
515
549
|
# declaration and in such case can be omitted in HDLRuby.
|
|
516
550
|
n = reg[0].to_HDLRuby(state)
|
|
551
|
+
v = reg[1]
|
|
552
|
+
v = v.to_HDLRuby(state) if v
|
|
517
553
|
unless state.port_names.include?(n) then
|
|
518
|
-
|
|
554
|
+
if v then
|
|
555
|
+
res_txt += state.indent + sign + range + "inner " + n + ": #{v}\n"
|
|
556
|
+
else
|
|
557
|
+
res_txt += state.indent + sign + range + "inner :" + n + "\n"
|
|
558
|
+
end
|
|
519
559
|
end
|
|
520
560
|
end
|
|
521
561
|
end
|
|
522
|
-
|
|
562
|
+
return res_txt
|
|
523
563
|
end
|
|
524
564
|
|
|
525
565
|
|
|
@@ -771,7 +811,7 @@ module VerilogTools
|
|
|
771
811
|
if !content_txt.empty? then
|
|
772
812
|
# There is a content, add it to the list.
|
|
773
813
|
seq_par_txt[-1][1] = content_txt
|
|
774
|
-
content_txt
|
|
814
|
+
content_txt = ""
|
|
775
815
|
end
|
|
776
816
|
# Add a new block.
|
|
777
817
|
seq_par_txt << [seq_par, ""]
|
|
@@ -831,7 +871,7 @@ module VerilogTools
|
|
|
831
871
|
# Generate the case items.
|
|
832
872
|
case_txt += ast[2].map do |item|
|
|
833
873
|
res_txt = ""
|
|
834
|
-
if item[0] then
|
|
874
|
+
if item[0] != "default" then
|
|
835
875
|
# hwhen case.
|
|
836
876
|
res_txt += indent + "hwhen("
|
|
837
877
|
res_txt += item[0].map {|e| e.to_HDLRuby(state) }.join(",")
|
|
@@ -868,8 +908,8 @@ module VerilogTools
|
|
|
868
908
|
|
|
869
909
|
|
|
870
910
|
TO_HDLRuby[:assignment] = lambda do |ast,state|
|
|
871
|
-
return state.indent + ast[0].to_HDLRuby(state) + " <= " +
|
|
872
|
-
ast[1].to_HDLRuby(state) + "\n"
|
|
911
|
+
return state.indent + ast[0].to_HDLRuby(state) + " <= (" +
|
|
912
|
+
ast[1].to_HDLRuby(state) + ")\n"
|
|
873
913
|
end
|
|
874
914
|
|
|
875
915
|
|
|
@@ -880,8 +920,8 @@ module VerilogTools
|
|
|
880
920
|
if ast[1] then
|
|
881
921
|
raise "Internal error: unsupported delay or event in assingment yet."
|
|
882
922
|
end
|
|
883
|
-
return state.indent + ast[0].to_HDLRuby(state) + " <= " +
|
|
884
|
-
ast[2].to_HDLRuby(state) + "\n"
|
|
923
|
+
return state.indent + ast[0].to_HDLRuby(state) + " <= (" +
|
|
924
|
+
ast[2].to_HDLRuby(state) + ")\n"
|
|
885
925
|
end
|
|
886
926
|
|
|
887
927
|
TO_HDLRuby[:non_blocking_assignment] = TO_HDLRuby[:blocking_assignment]
|
|
@@ -1001,10 +1041,12 @@ module VerilogTools
|
|
|
1001
1041
|
return VerilogTools.operator_to_HDLRuby(op) + primary_txt
|
|
1002
1042
|
when "&", "|", "^", "^|"
|
|
1003
1043
|
return primary_txt +
|
|
1004
|
-
".
|
|
1044
|
+
# ".heach.reduce(:" + VerilogTools.operator_to_HDLRuby(op) + ")"
|
|
1045
|
+
"." + VerilogTools.operator_to_HDLRuby(op) + "()"
|
|
1005
1046
|
when "~&", "~|", "~^"
|
|
1006
1047
|
return "~" + primary_txt +
|
|
1007
|
-
".
|
|
1048
|
+
# ".heach.reduce(:" + VerilogTools.operator_to_HDLRuby(op[1]) +")"
|
|
1049
|
+
"." + VerilogTools.operator_to_HDLRuby(op) + "()"
|
|
1008
1050
|
else
|
|
1009
1051
|
raise "Internal error: unknown unary operator #{op}"
|
|
1010
1052
|
end
|
|
@@ -1056,16 +1098,16 @@ module VerilogTools
|
|
|
1056
1098
|
case base
|
|
1057
1099
|
when "'b"
|
|
1058
1100
|
# Binary encoding.
|
|
1059
|
-
return "
|
|
1101
|
+
return "_u#{number0}b#{number1}"
|
|
1060
1102
|
when "'o"
|
|
1061
1103
|
# Octal encoding.
|
|
1062
|
-
return "
|
|
1104
|
+
return "_u#{number0}o#{number1}"
|
|
1063
1105
|
when "'d"
|
|
1064
1106
|
# Decimal encoding.
|
|
1065
|
-
return "
|
|
1107
|
+
return "_s#{number0}d#{number1}"
|
|
1066
1108
|
when "'h"
|
|
1067
1109
|
# Hexadecimal encoding.
|
|
1068
|
-
return "
|
|
1110
|
+
return "_u#{number0}h#{number1}"
|
|
1069
1111
|
when ""
|
|
1070
1112
|
# Simple number.
|
|
1071
1113
|
return number0
|
|
@@ -739,6 +739,7 @@ module VerilogTools
|
|
|
739
739
|
EVENT_TOK = "event"
|
|
740
740
|
DEFPARAM_TOK = "defparam"
|
|
741
741
|
PARAMETER_TOK = "parameter"
|
|
742
|
+
LOCALPARAM_TOK = "localparam"
|
|
742
743
|
SCALARED_TOK = "scalared"
|
|
743
744
|
VECTORED_TOK = "vectored"
|
|
744
745
|
|
|
@@ -979,7 +980,7 @@ module VerilogTools
|
|
|
979
980
|
REAL_REX = /\G#{S}(real)/
|
|
980
981
|
EVENT_REX = /\G#{S}(event)/
|
|
981
982
|
DEFPARAM_REX = /\G#{S}(defparam)/
|
|
982
|
-
PARAMETER_REX = /\G#{S}(parameter)/
|
|
983
|
+
PARAMETER_REX = /\G#{S}(parameter|localparam)/
|
|
983
984
|
SCALARED_REX = /\G#{S}(scalared)/
|
|
984
985
|
VECTORED_REX = /\G#{S}(vectored)/
|
|
985
986
|
|
|
@@ -1272,8 +1273,8 @@ module VerilogTools
|
|
|
1272
1273
|
EQUAL_EQUAL_EQUAL_TOK, NOT_EQUAL_EQUAL_TOK ]
|
|
1273
1274
|
EQUAL_OPERATOR_REX = /\G#{S}(#{EQUAL_OPERATOR_TOKS.join("|")})/
|
|
1274
1275
|
|
|
1275
|
-
COMPARISON_OPERATOR_TOKS = [
|
|
1276
|
-
|
|
1276
|
+
COMPARISON_OPERATOR_TOKS = [ INFERIOR_EQUAL_TOK, SUPERIOR_EQUAL_TOK,
|
|
1277
|
+
INFERIOR_TOK, SUPERIOR_TOK ]
|
|
1277
1278
|
COMPARISON_OPERATOR_REX = /\G#{S}(#{COMPARISON_OPERATOR_TOKS.join("|")})/
|
|
1278
1279
|
|
|
1279
1280
|
SHIFT_OPERATOR_TOKS = [ LEFT_SHIFT_TOK, RIGHT_SHIFT_TOK,
|
|
@@ -1515,7 +1516,7 @@ ___
|
|
|
1515
1516
|
self.parse_error("opening parenthesis expected") unless self.get_token(OPEN_PAR_REX)
|
|
1516
1517
|
self.parse_error("parameter expected") unless self.get_token(PARAMETER_REX)
|
|
1517
1518
|
list_of_param_assignments = self.list_of_param_assignments_parse
|
|
1518
|
-
self.parse_error("
|
|
1519
|
+
self.parse_error("parameter assignment expected") unless list_of_param_assignments
|
|
1519
1520
|
self.parse_error("closing parenthesis expected") unless self.get_token(CLOSE_PAR_REX)
|
|
1520
1521
|
return pre_parameter_declaration_hook(list_of_param_assignments)
|
|
1521
1522
|
end
|
|
@@ -1766,7 +1767,7 @@ ___
|
|
|
1766
1767
|
name = self.name_of_variable_parse
|
|
1767
1768
|
const0, const1 = nil, nil
|
|
1768
1769
|
if self.get_token(OPEN_BRA_REX) then
|
|
1769
|
-
const0 = self.
|
|
1770
|
+
const0 = self.constant_expression_parse
|
|
1770
1771
|
self.parse_error("constant expression expected") unless const0
|
|
1771
1772
|
if self.get_token(COLON_REX) then
|
|
1772
1773
|
const1 = self.constant_expression_parse
|
|
@@ -2622,10 +2623,10 @@ ___
|
|
|
2622
2623
|
# Auth: Verilog HDL also supports output wire, reg and so on as well
|
|
2623
2624
|
# as signed, so modified the rule as follows:
|
|
2624
2625
|
# <output_declaration>
|
|
2625
|
-
# ::= output OUTPUTTYPE? SIGNED? <range>? <
|
|
2626
|
+
# ::= output OUTPUTTYPE? SIGNED? <range>? <list_of_register_variables> ;
|
|
2626
2627
|
RULES[:output_declaration] = <<-___
|
|
2627
2628
|
<output_declaration>
|
|
2628
|
-
::= output OUTPUTTYPE? SIGNED? <range>? <
|
|
2629
|
+
::= output OUTPUTTYPE? SIGNED? <range>? <list_of_register_variables> ;
|
|
2629
2630
|
___
|
|
2630
2631
|
|
|
2631
2632
|
ORIGIN_RULES[:output_declaration] = <<-___
|
|
@@ -2641,7 +2642,7 @@ ___
|
|
|
2641
2642
|
type = self.get_token(OUTPUTTYPE_REX)
|
|
2642
2643
|
sign = self.get_token(SIGNED_REX)
|
|
2643
2644
|
range = self.range_parse
|
|
2644
|
-
list_of_variables = self.
|
|
2645
|
+
list_of_variables = self.list_of_register_variables_parse
|
|
2645
2646
|
# list_of_variables = self.list_of_output_variables_parse
|
|
2646
2647
|
# # Auth: semicolon included in list_of_output_variables!
|
|
2647
2648
|
self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
|
|
@@ -2711,7 +2712,7 @@ ___
|
|
|
2711
2712
|
expandrange = self.expandrange_parse
|
|
2712
2713
|
delay = self.delay_parse
|
|
2713
2714
|
list_of_variables = self.list_of_variables_parse
|
|
2714
|
-
self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
|
|
2715
|
+
self.parse_error("semicolon expected HERE #1") unless self.get_token(SEMICOLON_REX)
|
|
2715
2716
|
return net_declaration_hook(nettype,sign,expandrange,delay,
|
|
2716
2717
|
list_of_variables)
|
|
2717
2718
|
else
|
|
@@ -2719,7 +2720,7 @@ ___
|
|
|
2719
2720
|
expandrange = self.expandrange_parse
|
|
2720
2721
|
delay = self.delay_parse
|
|
2721
2722
|
list_of_assignments = self.list_of_assignments_parse
|
|
2722
|
-
self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
|
|
2723
|
+
self.parse_error("semicolon expected HERE #2") unless self.get_token(SEMICOLON_REX)
|
|
2723
2724
|
return net_declaration_hook(nettype,sign,expandrange,delay,
|
|
2724
2725
|
list_of_assignments)
|
|
2725
2726
|
end
|
|
@@ -2732,7 +2733,7 @@ ___
|
|
|
2732
2733
|
expandrange = self.expandrange_parse
|
|
2733
2734
|
delay = self.delay_parse
|
|
2734
2735
|
list_of_variables = self.list_of_variables_parse
|
|
2735
|
-
self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
|
|
2736
|
+
self.parse_error("semicolon expected HERE #3") unless self.get_token(SEMICOLON_REX)
|
|
2736
2737
|
return net_declaration_hook(charge_strength,sign,expandrange,delay,
|
|
2737
2738
|
list_of_variables)
|
|
2738
2739
|
end
|
|
@@ -2828,7 +2829,7 @@ ___
|
|
|
2828
2829
|
# ::= reg SIGNED? <range>? <list_of_register_variables> ;
|
|
2829
2830
|
RULES[:reg_declaration] = <<-___
|
|
2830
2831
|
<reg_declaration>
|
|
2831
|
-
::= reg SIGNED? <range>? <list_of_register_variables
|
|
2832
|
+
::= reg SIGNED? <range>? <list_of_register_variables>;
|
|
2832
2833
|
___
|
|
2833
2834
|
|
|
2834
2835
|
ORIGIN_RULES[:reg_declaration] = <<-___
|
|
@@ -2844,7 +2845,7 @@ ___
|
|
|
2844
2845
|
sign = self.get_token(SIGNED_REX)
|
|
2845
2846
|
range = self.range_parse
|
|
2846
2847
|
list_of_register_variables = self.list_of_register_variables_parse
|
|
2847
|
-
self.parse_error("semicolon exptected") unless self.get_token(SEMICOLON_REX)
|
|
2848
|
+
self.parse_error("semicolon exptected HERE #4") unless self.get_token(SEMICOLON_REX)
|
|
2848
2849
|
return reg_declaration_hook(sign,range,list_of_register_variables)
|
|
2849
2850
|
end
|
|
2850
2851
|
|
|
@@ -2860,11 +2861,16 @@ ___
|
|
|
2860
2861
|
|
|
2861
2862
|
def time_declaration_parse
|
|
2862
2863
|
# puts "time_declaration_parse"
|
|
2864
|
+
parse_state = self.state
|
|
2863
2865
|
unless self.get_token(TIME_REX) then
|
|
2864
2866
|
return nil
|
|
2865
2867
|
end
|
|
2866
2868
|
list_of_register_variables = self.list_of_register_variables_parse
|
|
2867
|
-
self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
|
|
2869
|
+
# self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
|
|
2870
|
+
unless self.get_token(SEMICOLON_REX) then
|
|
2871
|
+
self.state = parse_state
|
|
2872
|
+
return nil
|
|
2873
|
+
end
|
|
2868
2874
|
return time_declaration_hook(list_of_register_variables)
|
|
2869
2875
|
end
|
|
2870
2876
|
|
|
@@ -2952,7 +2958,7 @@ ___
|
|
|
2952
2958
|
drive_strength = self.drive_strength_parse
|
|
2953
2959
|
delay = self.delay_parse
|
|
2954
2960
|
list_of_assignments = self.list_of_assignments_parse
|
|
2955
|
-
self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
|
|
2961
|
+
self.parse_error("semicolon expected HERE #5") unless self.get_token(SEMICOLON_REX)
|
|
2956
2962
|
return continuous_assignment_hook(ASSIGN_TOK,
|
|
2957
2963
|
drive_strength,nil,
|
|
2958
2964
|
delay,list_of_assignments)
|
|
@@ -2963,7 +2969,7 @@ ___
|
|
|
2963
2969
|
expandrange = self.expandrange_parse
|
|
2964
2970
|
delay = self.delay_parse
|
|
2965
2971
|
list_of_assignments = self.list_of_assignments_parse
|
|
2966
|
-
self.parse_error("semicolon expected") unless self.get_token(SEMICOLON_REX)
|
|
2972
|
+
self.parse_error("semicolon expected HERE #6") unless self.get_token(SEMICOLON_REX)
|
|
2967
2973
|
return continuous_assignment_hook(nettype,
|
|
2968
2974
|
drive_strength,expandrange,
|
|
2969
2975
|
delay,list_of_assignments)
|
|
@@ -3059,7 +3065,14 @@ ___
|
|
|
3059
3065
|
end
|
|
3060
3066
|
|
|
3061
3067
|
|
|
3068
|
+
# Auth: there seems ot be a mistake in this rule:
|
|
3069
|
+
# initial assignments are also possible.
|
|
3062
3070
|
RULES[:register_variable] = <<-___
|
|
3071
|
+
<register_variable>
|
|
3072
|
+
::= <name_of_register> [ = <expression> ]
|
|
3073
|
+
||= <name_of_memory> [ <constant_expression> : <constant_expression> ]
|
|
3074
|
+
___
|
|
3075
|
+
ORIGIN_RULES[:register_variable] = <<-___
|
|
3063
3076
|
<register_variable>
|
|
3064
3077
|
::= <name_of_register>
|
|
3065
3078
|
||= <name_of_memory> [ <constant_expression> : <constant_expression> ]
|
|
@@ -3081,7 +3094,14 @@ ___
|
|
|
3081
3094
|
else
|
|
3082
3095
|
self.state = parse_state
|
|
3083
3096
|
name_of_register = self.name_of_register_parse
|
|
3084
|
-
|
|
3097
|
+
# Handle the initialization if any.
|
|
3098
|
+
if self.get_token(EQUAL_REX) then
|
|
3099
|
+
expression = self.expression_parse
|
|
3100
|
+
self.parse_error("expression expected") unless expression
|
|
3101
|
+
else
|
|
3102
|
+
expression = nil
|
|
3103
|
+
end
|
|
3104
|
+
return register_variable_hook(name_of_register,expression,nil)
|
|
3085
3105
|
end
|
|
3086
3106
|
end
|
|
3087
3107
|
|
|
@@ -4371,7 +4391,7 @@ ___
|
|
|
4371
4391
|
# <task_enable>
|
|
4372
4392
|
# ::= <name_of_task> ;
|
|
4373
4393
|
# ||= <name_of_task ( <expression <,<expression>>* ) ;
|
|
4374
|
-
|
|
4394
|
+
RULES[:task_enable] = <<-___
|
|
4375
4395
|
<task_enable>
|
|
4376
4396
|
::= <name_of_task> ;
|
|
4377
4397
|
||= <name_of_task> ( <expression> <,<expression>>* ) ;
|
data/lib/HDLRuby/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: HDLRuby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.9.
|
|
4
|
+
version: 3.9.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Lovic Gauthier
|
|
@@ -255,6 +255,8 @@ files:
|
|
|
255
255
|
- lib/HDLRuby/hdr_samples/with_terminate.rb
|
|
256
256
|
- lib/HDLRuby/hdr_samples/with_to_a.rb
|
|
257
257
|
- lib/HDLRuby/hdr_samples/with_to_array.rb
|
|
258
|
+
- lib/HDLRuby/hdr_samples/with_to_svg.rb
|
|
259
|
+
- lib/HDLRuby/hdr_samples/with_unary_reduction.rb
|
|
258
260
|
- lib/HDLRuby/hdr_samples/with_val_control.rb
|
|
259
261
|
- lib/HDLRuby/hdr_samples/with_values.rb
|
|
260
262
|
- lib/HDLRuby/hdr_samples/with_verilog.rb
|
|
@@ -340,6 +342,7 @@ files:
|
|
|
340
342
|
- lib/HDLRuby/hruby_low_mutable.rb
|
|
341
343
|
- lib/HDLRuby/hruby_low_resolve.rb
|
|
342
344
|
- lib/HDLRuby/hruby_low_skeleton.rb
|
|
345
|
+
- lib/HDLRuby/hruby_low_split_signals.rb
|
|
343
346
|
- lib/HDLRuby/hruby_low_with_bool.rb
|
|
344
347
|
- lib/HDLRuby/hruby_low_with_port.rb
|
|
345
348
|
- lib/HDLRuby/hruby_low_with_var.rb
|
|
@@ -499,7 +502,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
499
502
|
- !ruby/object:Gem::Version
|
|
500
503
|
version: '0'
|
|
501
504
|
requirements: []
|
|
502
|
-
rubygems_version: 3.
|
|
505
|
+
rubygems_version: 3.7.2
|
|
503
506
|
specification_version: 4
|
|
504
507
|
summary: HDLRuby is a library for describing and simulating digital electronic systems.
|
|
505
508
|
test_files: []
|