HDLRuby 3.1.0 → 3.3.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/HDLRuby.gemspec +1 -0
- data/README.html +2330 -2670
- data/README.md +400 -100
- data/ext/hruby_sim/hruby_rcsim_build.c +402 -3
- data/ext/hruby_sim/hruby_sim.h +2 -1
- data/ext/hruby_sim/hruby_sim_calc.c +34 -7
- data/ext/hruby_sim/hruby_sim_core.c +15 -5
- data/ext/hruby_sim/hruby_sim_tree_calc.c +112 -23
- data/lib/HDLRuby/hdr_samples/c_program/echo.c +33 -0
- data/lib/HDLRuby/hdr_samples/comparison_bench.rb +2 -2
- data/lib/HDLRuby/hdr_samples/counter_bench.rb +1 -1
- data/lib/HDLRuby/hdr_samples/counter_dff_bench.rb +8 -7
- data/lib/HDLRuby/hdr_samples/dff_properties.rb +2 -0
- data/lib/HDLRuby/hdr_samples/enum_as_param.rb +52 -0
- data/lib/HDLRuby/hdr_samples/linear_test.rb +2 -0
- data/lib/HDLRuby/hdr_samples/logic_bench.rb +6 -0
- data/lib/HDLRuby/hdr_samples/mei8.rb +6 -6
- data/lib/HDLRuby/hdr_samples/mei8_bench.rb +6 -6
- data/lib/HDLRuby/hdr_samples/memory_test.rb +2 -0
- data/lib/HDLRuby/hdr_samples/named_sub.rb +9 -5
- data/lib/HDLRuby/hdr_samples/ram.rb +7 -6
- data/lib/HDLRuby/hdr_samples/ruby_fir_hw.rb +2 -0
- data/lib/HDLRuby/hdr_samples/ruby_program/echo.rb +9 -0
- data/lib/HDLRuby/hdr_samples/ruby_program/stdrw.rb +6 -0
- data/lib/HDLRuby/hdr_samples/ruby_program/sw_cpu_terminal.rb +614 -0
- data/lib/HDLRuby/hdr_samples/ruby_program/sw_inc_mem.rb +32 -0
- data/lib/HDLRuby/hdr_samples/ruby_program/sw_log.rb +33 -0
- data/lib/HDLRuby/hdr_samples/struct.rb +15 -3
- data/lib/HDLRuby/hdr_samples/with_board.rb +63 -0
- data/lib/HDLRuby/hdr_samples/with_bram.rb +1 -1
- data/lib/HDLRuby/hdr_samples/with_bram_frame_stack.rb +1 -1
- data/lib/HDLRuby/hdr_samples/with_bram_stack.rb +1 -1
- data/lib/HDLRuby/hdr_samples/with_channel.rb +2 -0
- data/lib/HDLRuby/hdr_samples/with_channel_other.rb +2 -0
- data/lib/HDLRuby/hdr_samples/with_class.rb +3 -1
- data/lib/HDLRuby/hdr_samples/with_clocks.rb +42 -0
- data/lib/HDLRuby/hdr_samples/with_connector.rb +2 -0
- data/lib/HDLRuby/hdr_samples/with_connector_memory.rb +2 -0
- data/lib/HDLRuby/hdr_samples/with_fixpoint.rb +6 -0
- data/lib/HDLRuby/hdr_samples/with_fixpoint_adv.rb +73 -0
- data/lib/HDLRuby/hdr_samples/with_leftright.rb +1 -1
- data/lib/HDLRuby/hdr_samples/with_of.rb +1 -1
- data/lib/HDLRuby/hdr_samples/with_program_c.rb +28 -0
- data/lib/HDLRuby/hdr_samples/with_program_ruby.rb +28 -0
- data/lib/HDLRuby/hdr_samples/with_program_ruby_cpu.rb +234 -0
- data/lib/HDLRuby/hdr_samples/with_program_ruby_io.rb +23 -0
- data/lib/HDLRuby/hdr_samples/with_program_ruby_mem.rb +58 -0
- data/lib/HDLRuby/hdr_samples/with_program_ruby_threads.rb +56 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer.rb +17 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer_channel.rb +58 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer_enumerable.rb +10 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer_enumerator.rb +18 -4
- data/lib/HDLRuby/hdr_samples/with_sequencer_func.rb +2 -4
- data/lib/HDLRuby/hdr_samples/with_sequencer_sync.rb +2 -1
- data/lib/HDLRuby/hdrcc.rb +72 -21
- data/lib/HDLRuby/hruby_error.rb +13 -0
- data/lib/HDLRuby/hruby_high.rb +125 -26
- data/lib/HDLRuby/hruby_low.rb +171 -3
- data/lib/HDLRuby/hruby_low2programs.rb +47 -0
- data/lib/HDLRuby/hruby_low_resolve.rb +3 -2
- data/lib/HDLRuby/hruby_low_without_namespace.rb +133 -5
- data/lib/HDLRuby/hruby_low_without_subsignals.rb +1 -1
- data/lib/HDLRuby/hruby_rcsim.rb +113 -6
- data/lib/HDLRuby/hruby_serializer.rb +2 -1
- data/lib/HDLRuby/hruby_verilog.rb +94 -20
- data/lib/HDLRuby/hruby_verilog_name.rb +3 -17
- data/lib/HDLRuby/std/clocks.rb +118 -50
- data/lib/HDLRuby/std/fixpoint.rb +2 -2
- data/lib/HDLRuby/std/function_generator.rb +1 -1
- data/lib/HDLRuby/std/linear.rb +7 -7
- data/lib/HDLRuby/std/sequencer.rb +263 -13
- data/lib/HDLRuby/std/sequencer_channel.rb +90 -0
- data/lib/HDLRuby/std/sequencer_func.rb +28 -15
- data/lib/HDLRuby/std/std.rb +6 -0
- data/lib/HDLRuby/ui/hruby_board.rb +1079 -0
- data/lib/HDLRuby/version.rb +1 -1
- data/lib/c/Rakefile +8 -0
- data/lib/c/cHDL.h +12 -0
- data/lib/c/extconf.rb +7 -0
- data/lib/rubyHDL.rb +33 -0
- data/tuto/gui_accum.png +0 -0
- data/tuto/gui_board.png +0 -0
- data/tuto/tutorial_sw.html +2263 -1890
- data/tuto/tutorial_sw.md +957 -62
- metadata +43 -5
- data/README.pdf +0 -0
- data/tuto/tutorial_sw.pdf +0 -0
|
@@ -122,10 +122,17 @@ module HDLRuby::Low
|
|
|
122
122
|
# Extract the connections of the sub scopes.
|
|
123
123
|
cnxs = self.each_scope.map(&:extract_connections!).flatten
|
|
124
124
|
# Reinsert them to self.
|
|
125
|
-
cnxs.each { |
|
|
125
|
+
cnxs.each { |cnx| self.add_connection(cnx) }
|
|
126
|
+
|
|
127
|
+
# The fix the RefName using sub scopes since their target have
|
|
128
|
+
# been deplaced to current scope and renamed.
|
|
129
|
+
self_scopes = self.each_scope.to_a
|
|
130
|
+
self.each_behavior { |beh| beh.fix_scope_refnames!(self_scopes) }
|
|
131
|
+
self.each_connection { |cnx| cnx.fix_scope_refnames!(self_scopes) }
|
|
126
132
|
|
|
127
133
|
# Now can delete the sub scopes since they are empty.
|
|
128
|
-
self.each_scope.to_a.each { |scope| self.delete_scope!(scope) }
|
|
134
|
+
# self.each_scope.to_a.each { |scope| self.delete_scope!(scope) }
|
|
135
|
+
self_scopes.each { |scope| self.delete_scope!(scope) }
|
|
129
136
|
end
|
|
130
137
|
|
|
131
138
|
# Extract the behaviors from the scope and returns them into an array.
|
|
@@ -219,9 +226,10 @@ module HDLRuby::Low
|
|
|
219
226
|
# in the internals.
|
|
220
227
|
def replace_names_subs!(former,nname)
|
|
221
228
|
# puts "replace_names_subs! for #{self} with former=#{former} and nname=#{nname}"
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
229
|
+
# No need?
|
|
230
|
+
# self.each_type do |type|
|
|
231
|
+
# type.replace_names!(former,nname)
|
|
232
|
+
# end
|
|
225
233
|
self.each_systemT do |systemT|
|
|
226
234
|
systemT.replace_names!(former,nname)
|
|
227
235
|
end
|
|
@@ -460,6 +468,13 @@ module HDLRuby::Low
|
|
|
460
468
|
# Recurse on the block.
|
|
461
469
|
self.block.replace_names!(former,nname)
|
|
462
470
|
end
|
|
471
|
+
|
|
472
|
+
# Fix the references names using scopes given in +scopes + list (they
|
|
473
|
+
# are marked to be deleted).
|
|
474
|
+
def fix_scope_refnames!(scopes)
|
|
475
|
+
self.block.fix_scope_refnames!(scopes)
|
|
476
|
+
return self
|
|
477
|
+
end
|
|
463
478
|
end
|
|
464
479
|
|
|
465
480
|
|
|
@@ -498,6 +513,34 @@ module HDLRuby::Low
|
|
|
498
513
|
node.break_types!(types)
|
|
499
514
|
end
|
|
500
515
|
end
|
|
516
|
+
|
|
517
|
+
# Fix the references names using scopes given in +scopes + list (they
|
|
518
|
+
# are marked to be deleted).
|
|
519
|
+
def fix_scope_refnames!(scopes)
|
|
520
|
+
# By default, does nothing.
|
|
521
|
+
return self
|
|
522
|
+
end
|
|
523
|
+
end
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
class Transmit
|
|
527
|
+
# Fix the references names using scopes given in +scopes + list (they
|
|
528
|
+
# are marked to be deleted).
|
|
529
|
+
def fix_scope_refnames!(scopes)
|
|
530
|
+
self.set_left!(self.left.fix_scope_refnames!(scopes))
|
|
531
|
+
self.set_right!(self.right.fix_scope_refnames!(scopes))
|
|
532
|
+
return self
|
|
533
|
+
end
|
|
534
|
+
end
|
|
535
|
+
|
|
536
|
+
class Connection
|
|
537
|
+
# Fix the references names using scopes given in +scopes + list (they
|
|
538
|
+
# are marked to be deleted).
|
|
539
|
+
def fix_scope_refnames!(scopes)
|
|
540
|
+
self.set_left!(self.left.fix_scope_refnames!(scopes))
|
|
541
|
+
self.set_right!(self.right.fix_scope_refnames!(scopes))
|
|
542
|
+
return self
|
|
543
|
+
end
|
|
501
544
|
end
|
|
502
545
|
|
|
503
546
|
|
|
@@ -527,6 +570,16 @@ module HDLRuby::Low
|
|
|
527
570
|
end
|
|
528
571
|
end
|
|
529
572
|
end
|
|
573
|
+
|
|
574
|
+
# Fix the references names using scopes given in +scopes + list (they
|
|
575
|
+
# are marked to be deleted).
|
|
576
|
+
def fix_scope_refnames!(scopes)
|
|
577
|
+
# By default: recurse.
|
|
578
|
+
self.map_nodes! do |node|
|
|
579
|
+
node.fix_scope_refnames!(scopes)
|
|
580
|
+
end
|
|
581
|
+
return self
|
|
582
|
+
end
|
|
530
583
|
end
|
|
531
584
|
|
|
532
585
|
|
|
@@ -578,6 +631,24 @@ module HDLRuby::Low
|
|
|
578
631
|
# Recurse on the no if any.
|
|
579
632
|
self.no.replace_names!(former,nname) if self.no
|
|
580
633
|
end
|
|
634
|
+
|
|
635
|
+
# Fix the references names using scopes given in +scopes + list (they
|
|
636
|
+
# are marked to be deleted).
|
|
637
|
+
def fix_scope_refnames!(scopes)
|
|
638
|
+
# Fix the condition.
|
|
639
|
+
self.set_condition!(self.condition.fix_scope_refnames!(scopes))
|
|
640
|
+
# Recurse on the yes.
|
|
641
|
+
self.yes.fix_scope_refnames!(scopes)
|
|
642
|
+
# Recurse on the alternate ifs.
|
|
643
|
+
self.map_noifs! do |cond,stmnt|
|
|
644
|
+
cond = cond.fix_scope_refnames!(scopes)
|
|
645
|
+
stmnt = stmnt.fix_scope_refnames!(scopes)
|
|
646
|
+
[cond,stmnt]
|
|
647
|
+
end
|
|
648
|
+
# Recruse on the no if any.
|
|
649
|
+
self.no.fix_scope_refnames!(scopes) if self.no
|
|
650
|
+
return self
|
|
651
|
+
end
|
|
581
652
|
end
|
|
582
653
|
|
|
583
654
|
|
|
@@ -618,6 +689,16 @@ module HDLRuby::Low
|
|
|
618
689
|
end
|
|
619
690
|
end
|
|
620
691
|
end
|
|
692
|
+
|
|
693
|
+
# Fix the references names using scopes given in +scopes + list (they
|
|
694
|
+
# are marked to be deleted).
|
|
695
|
+
def fix_scope_refnames!(scopes)
|
|
696
|
+
# Fix the match.
|
|
697
|
+
self.set_match!(self.match.fix_scope_refnames!(scopes))
|
|
698
|
+
# Recurse on the statement.
|
|
699
|
+
self.statement.fix_scope_refnames!(scopes)
|
|
700
|
+
return self
|
|
701
|
+
end
|
|
621
702
|
end
|
|
622
703
|
|
|
623
704
|
|
|
@@ -655,6 +736,18 @@ module HDLRuby::Low
|
|
|
655
736
|
# Recurse on the default.
|
|
656
737
|
self.default.replace_names!(former,nname) if self.default
|
|
657
738
|
end
|
|
739
|
+
|
|
740
|
+
# Fix the references names using scopes given in +scopes + list (they
|
|
741
|
+
# are marked to be deleted).
|
|
742
|
+
def fix_scope_refnames!(scopes)
|
|
743
|
+
# Fix the value.
|
|
744
|
+
self.set_value!(self.value.fix_scope_refnames!(scopes))
|
|
745
|
+
# Recurse on the whens.
|
|
746
|
+
self.each_when {|w| w.fix_scope_refnames!(scopes) }
|
|
747
|
+
# Recurse on the default.
|
|
748
|
+
self.default.fix_scope_refnames!(scopes) if self.default
|
|
749
|
+
return self
|
|
750
|
+
end
|
|
658
751
|
end
|
|
659
752
|
|
|
660
753
|
|
|
@@ -681,6 +774,14 @@ module HDLRuby::Low
|
|
|
681
774
|
# Recurse on the statement.
|
|
682
775
|
self.statement.replace_names!(former,nname)
|
|
683
776
|
end
|
|
777
|
+
|
|
778
|
+
# Fix the references names using scopes given in +scopes + list (they
|
|
779
|
+
# are marked to be deleted).
|
|
780
|
+
def fix_scope_refnames!(scopes)
|
|
781
|
+
# Recurse on the statement.
|
|
782
|
+
self.statement.fix_scope_refnames!(scopes)
|
|
783
|
+
return self
|
|
784
|
+
end
|
|
684
785
|
end
|
|
685
786
|
|
|
686
787
|
|
|
@@ -738,6 +839,33 @@ module HDLRuby::Low
|
|
|
738
839
|
# Recurse on the sub scopes and behaviors.
|
|
739
840
|
replace_names_subs!(former,nname)
|
|
740
841
|
end
|
|
842
|
+
|
|
843
|
+
# Fix the references names using scopes given in +scopes + list (they
|
|
844
|
+
# are marked to be deleted).
|
|
845
|
+
def fix_scope_refnames!(scopes)
|
|
846
|
+
self.each_statement {|stmnt| stmnt.fix_scope_refnames!(scopes) }
|
|
847
|
+
return self
|
|
848
|
+
end
|
|
849
|
+
end
|
|
850
|
+
|
|
851
|
+
|
|
852
|
+
class RefName
|
|
853
|
+
include ForceName
|
|
854
|
+
|
|
855
|
+
# Fix the references names using scopes given in +scopes + list (they
|
|
856
|
+
# are marked to be deleted).
|
|
857
|
+
def fix_scope_refnames!(scopes)
|
|
858
|
+
return self unless self.ref.is_a?(RefName)
|
|
859
|
+
# puts "fix_scope_refnames! with self.name=#{name} and self.ref=#{self.ref}"
|
|
860
|
+
# Recurse on the ref.
|
|
861
|
+
self.set_ref!(self.ref.fix_scope_refnames!(scopes))
|
|
862
|
+
# Rename and curt the subref if referening to one of the scopes.
|
|
863
|
+
if scopes.find {|scope| scope.name == self.ref.name } then
|
|
864
|
+
self.ref.extend_name!(self)
|
|
865
|
+
self.set_ref!(RefThis.new)
|
|
866
|
+
end
|
|
867
|
+
return self
|
|
868
|
+
end
|
|
741
869
|
end
|
|
742
870
|
|
|
743
871
|
end
|
|
@@ -243,7 +243,6 @@ module HDLRuby::Low
|
|
|
243
243
|
# Flatten a reference to a list of reference to leaf signals
|
|
244
244
|
# from signal +sig+ and add to result to +subrefs+
|
|
245
245
|
def flatten_to(sig,subrefs)
|
|
246
|
-
# puts "flatten_to with sig name=#{sig.name}"
|
|
247
246
|
# Shall we decompose 2d vectors, and is the current signal
|
|
248
247
|
# for one of them?
|
|
249
248
|
if SystemT.decompose_vec2d? and sig.type.is_a?(TypeVector) and
|
|
@@ -294,6 +293,7 @@ module HDLRuby::Low
|
|
|
294
293
|
# Decompose the hierarchical signals in the statements.
|
|
295
294
|
def signal2subs!
|
|
296
295
|
# puts "signal2subs! for RefName: #{self.name}"
|
|
296
|
+
return self if self.type == void # Not a singal anyway.
|
|
297
297
|
# Decompose it to a list of reference to each leaf sub signal.
|
|
298
298
|
subrefs = []
|
|
299
299
|
self.flatten_to(self.resolve,subrefs)
|
data/lib/HDLRuby/hruby_rcsim.rb
CHANGED
|
@@ -3,6 +3,8 @@ require 'HDLRuby'
|
|
|
3
3
|
require 'hruby_high_fullname'
|
|
4
4
|
require 'hruby_sim/hruby_sim'
|
|
5
5
|
|
|
6
|
+
require 'rubyHDL'
|
|
7
|
+
|
|
6
8
|
|
|
7
9
|
module HDLRuby::High
|
|
8
10
|
|
|
@@ -189,7 +191,6 @@ module HDLRuby::High
|
|
|
189
191
|
rcbehs = self.each_behavior.map {|beh| beh.to_rcsim(subowner)} # +
|
|
190
192
|
# self.each_connection.map {|cxt| cxt.to_rcsim(subowner) }
|
|
191
193
|
self.each_connection do |cnx|
|
|
192
|
-
# ICIICI
|
|
193
194
|
if !cnx.right.is_a?(RefObject) then
|
|
194
195
|
rcbehs << cnx.to_rcsim(subowner)
|
|
195
196
|
else
|
|
@@ -209,8 +210,11 @@ module HDLRuby::High
|
|
|
209
210
|
RCSim.rcsim_add_scope_behaviors(@rcscope,rcbehs)
|
|
210
211
|
end
|
|
211
212
|
|
|
212
|
-
# Create and add the
|
|
213
|
-
|
|
213
|
+
# Create and add the programs.
|
|
214
|
+
rcprogs = self.each_program.map {|prog| prog.to_rcsim(subowner)}
|
|
215
|
+
if rcprogs.any? then
|
|
216
|
+
RCSim.rcsim_add_scope_codes(@rcscope,rcprogs);
|
|
217
|
+
end
|
|
214
218
|
|
|
215
219
|
return @rcscope
|
|
216
220
|
end
|
|
@@ -512,12 +516,92 @@ module HDLRuby::High
|
|
|
512
516
|
|
|
513
517
|
class Chunk
|
|
514
518
|
## Extends the Chunk class for hybrid Ruby-C simulation.
|
|
515
|
-
#
|
|
519
|
+
# Deprecated!!
|
|
516
520
|
end
|
|
517
521
|
|
|
518
522
|
class Code
|
|
519
523
|
## Extends the Code class for hybrid Ruby-C simulation.
|
|
520
|
-
#
|
|
524
|
+
# Deprecated!!
|
|
525
|
+
end
|
|
526
|
+
|
|
527
|
+
class Program
|
|
528
|
+
## Extends the Program class for hybrid Ruby-C simulation.
|
|
529
|
+
# NOTE: produce a low-level Code, and not program. For now,
|
|
530
|
+
# Program is a high-level interface for software description and
|
|
531
|
+
# is not ment to be simulated as is. It may hcange in the future
|
|
532
|
+
# though.
|
|
533
|
+
|
|
534
|
+
attr_reader :rccode # The access to the C version of the code.
|
|
535
|
+
|
|
536
|
+
# Generate the C description of the code comming from object
|
|
537
|
+
# whose C description is +rcowner+.
|
|
538
|
+
# NOTE: also update the table of signals accessed from software
|
|
539
|
+
# code.
|
|
540
|
+
def to_rcsim(rcowner)
|
|
541
|
+
# puts "to_rcsim for program=#{self}"
|
|
542
|
+
|
|
543
|
+
# Create the code C object.
|
|
544
|
+
# puts "make code with self.class=#{self.class}"
|
|
545
|
+
@rccode = RCSim.rcsim_make_code(self.language.to_s, self.function.to_s)
|
|
546
|
+
|
|
547
|
+
# Set the owner.
|
|
548
|
+
RCSim.rcsim_set_owner(@rccode,rcowner)
|
|
549
|
+
|
|
550
|
+
# Create and add the events.
|
|
551
|
+
if self.each_actport.any? then
|
|
552
|
+
RCSim.rcsim_add_code_events(@rccode, self.each_actport.map do|ev|
|
|
553
|
+
ev.to_rcsim(@rccode)
|
|
554
|
+
end)
|
|
555
|
+
end
|
|
556
|
+
|
|
557
|
+
# Create the software interface.
|
|
558
|
+
if self.language == :ruby then
|
|
559
|
+
# Loads the code files.
|
|
560
|
+
self.each_code do |code|
|
|
561
|
+
Kernel.require("./"+code.to_s)
|
|
562
|
+
end
|
|
563
|
+
# Add the input ports.
|
|
564
|
+
self.each_inport do |sym, sig|
|
|
565
|
+
RubyHDL.inport(sym,sig.rcsignalI)
|
|
566
|
+
end
|
|
567
|
+
# Add the output ports.
|
|
568
|
+
self.each_outport do |sym, sig|
|
|
569
|
+
RubyHDL.outport(sym,sig.rcsignalI)
|
|
570
|
+
end
|
|
571
|
+
elsif self.language == :c then
|
|
572
|
+
# Loads the code file: only the last one remains.
|
|
573
|
+
self.each_code do |code|
|
|
574
|
+
code = code.to_s
|
|
575
|
+
# Check if the file exists.
|
|
576
|
+
unless File.file?(code) then
|
|
577
|
+
# The code name may be not complete,
|
|
578
|
+
# try ".so", ".bundle" or ".dll" extensions.
|
|
579
|
+
if File.file?(code+".so") then
|
|
580
|
+
code += ".so"
|
|
581
|
+
elsif File.file?(code + ".bundle") then
|
|
582
|
+
code += ".bundle"
|
|
583
|
+
elsif File.file?(code + ".dll") then
|
|
584
|
+
code += ".dll"
|
|
585
|
+
else
|
|
586
|
+
# Code not found.
|
|
587
|
+
raise "C code library not found: " + code
|
|
588
|
+
end
|
|
589
|
+
end
|
|
590
|
+
RCSim.rcsim_load_c(@rccode,code,self.function.to_s)
|
|
591
|
+
end
|
|
592
|
+
# Add the input ports.
|
|
593
|
+
self.each_inport do |sym, sig|
|
|
594
|
+
RCSim::CPorts[sym] = sig.rcsignalI
|
|
595
|
+
end
|
|
596
|
+
# Add the output ports.
|
|
597
|
+
self.each_outport do |sym, sig|
|
|
598
|
+
RCSim::CPorts[sym] = sig.rcsignalI
|
|
599
|
+
end
|
|
600
|
+
end
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
return @rccode
|
|
604
|
+
end
|
|
521
605
|
end
|
|
522
606
|
|
|
523
607
|
|
|
@@ -1000,7 +1084,30 @@ module HDLRuby::High
|
|
|
1000
1084
|
|
|
1001
1085
|
class RefName
|
|
1002
1086
|
## Extends the RefName class for hybrid Ruby-C simulation.
|
|
1003
|
-
#
|
|
1087
|
+
# Converted to RefRange.
|
|
1088
|
+
|
|
1089
|
+
# Generate the C description of the reference range (not ref name!).
|
|
1090
|
+
def to_rcsim
|
|
1091
|
+
# Convert the base to a bit vector.
|
|
1092
|
+
type_base = Bit[self.ref.type.width]
|
|
1093
|
+
# self.ref.parent = nil
|
|
1094
|
+
# bit_base = Cast.new(type_base,self.ref)
|
|
1095
|
+
bit_base = RCSim.rcsim_make_cast(type_base.to_rcsim,self.ref.to_rcsim)
|
|
1096
|
+
# Compute range in bits of the field.
|
|
1097
|
+
last = 0
|
|
1098
|
+
self.ref.type.each.detect do |name,typ|
|
|
1099
|
+
last += typ.width
|
|
1100
|
+
name == self.name
|
|
1101
|
+
end
|
|
1102
|
+
first = last-self.type.width
|
|
1103
|
+
last -= 1
|
|
1104
|
+
# puts "name=#{self.name} first=#{first} last=#{last}"
|
|
1105
|
+
type_int = Bit[type_base.width.width]
|
|
1106
|
+
return RCSim.rcsim_make_refRange(self.type.to_rcsim,
|
|
1107
|
+
Value.new(type_int,last).to_rcsim,
|
|
1108
|
+
Value.new(type_int,first).to_rcsim,
|
|
1109
|
+
bit_base)
|
|
1110
|
+
end
|
|
1004
1111
|
end
|
|
1005
1112
|
|
|
1006
1113
|
|
|
@@ -23,7 +23,8 @@ module HDLRuby
|
|
|
23
23
|
Low::TypeSigned, Low::TypeUnsigned, Low::TypeFloat,
|
|
24
24
|
Low::TypeTuple, Low::TypeStruct,
|
|
25
25
|
Low::Behavior, Low::TimeBehavior,
|
|
26
|
-
Low::Event, Low::Block, Low::TimeBlock,
|
|
26
|
+
Low::Event, Low::Block, Low::TimeBlock,
|
|
27
|
+
Low::Program, Low::Code,
|
|
27
28
|
Low::SignalI, Low::SignalC,
|
|
28
29
|
Low::SystemI, Low::Connection,
|
|
29
30
|
Low::Transmit, Low::If, Low::Case, Low::When, Low::Cast,
|
|
@@ -169,7 +169,17 @@ module HDLRuby::Low
|
|
|
169
169
|
|
|
170
170
|
# Converts the system to Verilog code.
|
|
171
171
|
def to_verilog
|
|
172
|
-
|
|
172
|
+
# In HDLRuby if on term is signed and the other is not, the
|
|
173
|
+
# computation is signed.
|
|
174
|
+
if self.left.type.signed? and self.right.type.unsigned? then
|
|
175
|
+
return "(#{self.left.to_verilog} #{self.operator} " +
|
|
176
|
+
"$signed({1'b0,#{self.right.to_verilog}}))"
|
|
177
|
+
elsif self.left.type.unsigned? and right.type.signed? then
|
|
178
|
+
return "($signed({1'b0,#{self.left.to_verilog}})" +
|
|
179
|
+
" #{self.operator} #{self.right.to_verilog})"
|
|
180
|
+
else
|
|
181
|
+
return "(#{self.left.to_verilog} #{self.operator} #{self.right.to_verilog})"
|
|
182
|
+
end
|
|
173
183
|
end
|
|
174
184
|
|
|
175
185
|
# Method called when two or more expression terms are present.
|
|
@@ -262,7 +272,6 @@ module HDLRuby::Low
|
|
|
262
272
|
# Declaration of "inner" part within "always".
|
|
263
273
|
block.each_inner do |inner|
|
|
264
274
|
if HDLRuby::Low::VERILOG_REGS.include?(inner.to_verilog) then
|
|
265
|
-
# code << " reg"
|
|
266
275
|
code << "#{" " * (spc+3)}reg"
|
|
267
276
|
else
|
|
268
277
|
code << "#{" " * (spc+3)}wire"
|
|
@@ -1501,7 +1510,14 @@ module HDLRuby::Low
|
|
|
1501
1510
|
|
|
1502
1511
|
# Converts the system to Verilog code using +renamer+ for producing Verilog-compatible names.
|
|
1503
1512
|
def to_verilog
|
|
1504
|
-
|
|
1513
|
+
if (self.ref.is_a?(RefThis)) then
|
|
1514
|
+
# End reference.
|
|
1515
|
+
vname = name_to_verilog(self.name)
|
|
1516
|
+
else
|
|
1517
|
+
# Not end reference, recurse.
|
|
1518
|
+
# vname = name_to_verilog(self.name) + "." + self.ref.to_verilog
|
|
1519
|
+
vname = self.ref.to_verilog + "." + name_to_verilog(self.name)
|
|
1520
|
+
end
|
|
1505
1521
|
# self.properties[:verilog_name] = vname
|
|
1506
1522
|
return "#{vname}"
|
|
1507
1523
|
end
|
|
@@ -1565,8 +1581,11 @@ module HDLRuby::Low
|
|
|
1565
1581
|
return "#{self.ref.to_verilog}[#{self.range.first.to_getrange}:#{self.range.last.to_getrange}]"
|
|
1566
1582
|
else
|
|
1567
1583
|
# No a pure signal, need to use a function for accessing.
|
|
1568
|
-
sr = self.range.first.to_i..self.range.last.to_i
|
|
1569
|
-
cr = (self.type.width-1)..0
|
|
1584
|
+
# sr = self.range.first.to_i..self.range.last.to_i
|
|
1585
|
+
# cr = (self.type.width-1)..0
|
|
1586
|
+
sr = (self.range.first.to_i+1)*self.ref.type.base.width-1..
|
|
1587
|
+
self.range.last.to_i*self.ref.type.base.width
|
|
1588
|
+
cr = (self.ref.type.width-1)..0
|
|
1570
1589
|
TruncersI.add(cr,sr)
|
|
1571
1590
|
return "#{TruncersI.truncer_name(cr,sr)}(#{self.ref.to_verilog})"
|
|
1572
1591
|
end
|
|
@@ -1735,9 +1754,11 @@ module HDLRuby::Low
|
|
|
1735
1754
|
if self.default then
|
|
1736
1755
|
result << " " * (spc+3) + "default: "
|
|
1737
1756
|
if self.default.each_statement.count >= 1 then
|
|
1757
|
+
result << "begin\n"
|
|
1738
1758
|
result << self.default.each_statement.map do |stmnt|
|
|
1739
|
-
stmnt.to_verilog(spc+
|
|
1759
|
+
stmnt.to_verilog(spc+6)
|
|
1740
1760
|
end.join("\n") << "\n"
|
|
1761
|
+
result << " " * (spc+3) + "end\n"
|
|
1741
1762
|
else
|
|
1742
1763
|
result << ";\n"
|
|
1743
1764
|
end
|
|
@@ -2027,11 +2048,60 @@ module HDLRuby::Low
|
|
|
2027
2048
|
end
|
|
2028
2049
|
|
|
2029
2050
|
|
|
2051
|
+
# Get the signals that can be declared as reg.
|
|
2052
|
+
# If +vname+ is given, use as base for reference name.
|
|
2053
|
+
def self.get_regs(expr,vname = nil)
|
|
2054
|
+
if expr.is_a?(RefConcat) then
|
|
2055
|
+
return expr.each_ref.map {|ref| self.get_regs(ref,vname) }.flatten
|
|
2056
|
+
elsif expr.is_a?(RefName) then
|
|
2057
|
+
if vname then
|
|
2058
|
+
puts "vname=#{vname} expr.name=#{expr.name}"
|
|
2059
|
+
if expr.ref && name_to_verilog(expr.name) == vname then
|
|
2060
|
+
return get_regs(expr.ref)
|
|
2061
|
+
else
|
|
2062
|
+
return []
|
|
2063
|
+
end
|
|
2064
|
+
else
|
|
2065
|
+
return [expr]
|
|
2066
|
+
end
|
|
2067
|
+
else
|
|
2068
|
+
return get_regs(expr.ref,vname)
|
|
2069
|
+
end
|
|
2070
|
+
end
|
|
2071
|
+
|
|
2072
|
+
# Get signals indirectly refered that have to become reg in
|
|
2073
|
+
# a sub system. +vname+ is the name of the system whose signals
|
|
2074
|
+
# are to be processed.
|
|
2075
|
+
def self.get_indirect_verilog_regs(systemI,vname)
|
|
2076
|
+
# Get the sub systemT.
|
|
2077
|
+
sub_systemT = systemI.systemT
|
|
2078
|
+
# Get the indirect reg inside it.
|
|
2079
|
+
sub_systemT.each_behavior do |behavior|
|
|
2080
|
+
behavior.each_block_deep do |block|
|
|
2081
|
+
block.each_statement do |statement|
|
|
2082
|
+
if statement.is_a?(Transmit) &&
|
|
2083
|
+
statement.left.to_verilog.include?(vname + ".")
|
|
2084
|
+
puts "hierachical=#{statement.left.to_verilog}"
|
|
2085
|
+
# HDLRuby::Low::VERILOG_REGS << SystemT.get_regs(statement.left.ref).to_verilog
|
|
2086
|
+
HDLRuby::Low::VERILOG_REGS.concat( SystemT.get_regs(statement.left,vname).map(&:to_verilog))
|
|
2087
|
+
end
|
|
2088
|
+
end
|
|
2089
|
+
end
|
|
2090
|
+
end
|
|
2091
|
+
# And recurse on its systemIs.
|
|
2092
|
+
sub_systemT.each_systemI do |sub_systemI|
|
|
2093
|
+
SystemT.get_indirect_verilog_regs(sub_systemI,vname)
|
|
2094
|
+
end
|
|
2095
|
+
end
|
|
2096
|
+
|
|
2030
2097
|
|
|
2031
2098
|
# Converts the system to Verilog code.
|
|
2032
2099
|
# NOTE: if +vcd+ is true, generate verilog code whose simulation
|
|
2033
2100
|
# produces a vcd file.
|
|
2034
2101
|
def to_verilog(vcd = false)
|
|
2102
|
+
# Create the name of the module.
|
|
2103
|
+
vname = name_to_verilog(self.name)
|
|
2104
|
+
# puts "Processing systemT named=#{vname}"
|
|
2035
2105
|
# Detect the registers
|
|
2036
2106
|
HDLRuby::Low::VERILOG_REGS.clear
|
|
2037
2107
|
# The left values.
|
|
@@ -2039,11 +2109,15 @@ module HDLRuby::Low
|
|
|
2039
2109
|
behavior.each_block_deep do |block|
|
|
2040
2110
|
block.each_statement do |statement|
|
|
2041
2111
|
if statement.is_a?(Transmit)
|
|
2042
|
-
HDLRuby::Low::VERILOG_REGS << statement.left.to_verilog
|
|
2112
|
+
# HDLRuby::Low::VERILOG_REGS << SystemT.get_regs(statement.left).to_verilog
|
|
2113
|
+
HDLRuby::Low::VERILOG_REGS.concat(SystemT.get_regs(statement.left).map(&:to_verilog))
|
|
2043
2114
|
end
|
|
2044
2115
|
end
|
|
2045
2116
|
end
|
|
2046
2117
|
end
|
|
2118
|
+
self.each_systemI do |systemI|
|
|
2119
|
+
SystemT.get_indirect_verilog_regs(systemI,vname)
|
|
2120
|
+
end
|
|
2047
2121
|
# And the initialized signals.
|
|
2048
2122
|
self.each_output do |output|
|
|
2049
2123
|
# regs << output.to_verilog if output.value
|
|
@@ -2053,17 +2127,18 @@ module HDLRuby::Low
|
|
|
2053
2127
|
# regs << inner.to_verilog if inner.value
|
|
2054
2128
|
HDLRuby::Low::VERILOG_REGS << inner.to_verilog if inner.value
|
|
2055
2129
|
end
|
|
2056
|
-
#
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
end
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
end
|
|
2130
|
+
# Actual NOT...
|
|
2131
|
+
# # And the array types signals.
|
|
2132
|
+
# self.each_signal do |sig|
|
|
2133
|
+
# if sig.type.vector? && sig.type.base.vector? then
|
|
2134
|
+
# HDLRuby::Low::VERILOG_REGS << sig.to_verilog
|
|
2135
|
+
# end
|
|
2136
|
+
# end
|
|
2137
|
+
# self.each_inner do |sig|
|
|
2138
|
+
# if sig.type.vector? && sig.type.base.vector? then
|
|
2139
|
+
# HDLRuby::Low::VERILOG_REGS << sig.to_verilog
|
|
2140
|
+
# end
|
|
2141
|
+
# end
|
|
2067
2142
|
|
|
2068
2143
|
# Code generation
|
|
2069
2144
|
inputs = 0
|
|
@@ -2077,7 +2152,6 @@ module HDLRuby::Low
|
|
|
2077
2152
|
# Spelling necessary for simulation.
|
|
2078
2153
|
code = "`timescale 1ps/1ps\n\n"
|
|
2079
2154
|
|
|
2080
|
-
vname = name_to_verilog(self.name)
|
|
2081
2155
|
# self.properties[:verilog_name] = vname
|
|
2082
2156
|
# Output the module name.
|
|
2083
2157
|
code << "module #{vname}("
|
|
@@ -2315,7 +2389,7 @@ module HDLRuby::Low
|
|
|
2315
2389
|
codeC << " initial "
|
|
2316
2390
|
else
|
|
2317
2391
|
# Generate a standard process.
|
|
2318
|
-
codeC << " always @( "
|
|
2392
|
+
codeC << "\n always @( "
|
|
2319
2393
|
# If there is no "always" condition, it is always @("*").
|
|
2320
2394
|
if behavior.each_event.to_a.empty? then
|
|
2321
2395
|
codeC << "*"
|
|
@@ -8,26 +8,11 @@ module HDLRuby::Verilog
|
|
|
8
8
|
# puts n
|
|
9
9
|
# name = n.split("")
|
|
10
10
|
|
|
11
|
-
@@hdr2verilog = {}
|
|
11
|
+
@@hdr2verilog = { "buf" => "_v0_buf", "table" => "_v1_table", "time" => "_v2_time" }
|
|
12
12
|
|
|
13
13
|
# Since it is possible to use $ and numbers other than the beginning of the character string, it is divided.
|
|
14
14
|
def name_to_verilog(name)
|
|
15
|
-
#
|
|
16
|
-
# # Convert special characters.
|
|
17
|
-
# name = name.each_char.map do |c|
|
|
18
|
-
# if c=~ /[a-z0-9]/ then
|
|
19
|
-
# c
|
|
20
|
-
# elsif c == "_" then
|
|
21
|
-
# "__"
|
|
22
|
-
# else
|
|
23
|
-
# "_" + c.ord.to_s
|
|
24
|
-
# end
|
|
25
|
-
# end.join
|
|
26
|
-
# # First character: only letter is possible.
|
|
27
|
-
# unless name[0] =~ /[a-z_]/ then
|
|
28
|
-
# name = "_" + name
|
|
29
|
-
# end
|
|
30
|
-
# return name
|
|
15
|
+
# puts "name_to_verilog with name=#{name}"
|
|
31
16
|
name = name.to_s
|
|
32
17
|
vname = @@hdr2verilog[name]
|
|
33
18
|
unless vname then
|
|
@@ -41,6 +26,7 @@ module HDLRuby::Verilog
|
|
|
41
26
|
end
|
|
42
27
|
@@hdr2verilog[name] = vname
|
|
43
28
|
end
|
|
29
|
+
# puts "result vname=#{vname}"
|
|
44
30
|
return vname
|
|
45
31
|
end
|
|
46
32
|
|