HDLRuby 2.7.11 → 2.10.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 +4 -4
- data/README.md +14 -1
- data/lib/HDLRuby/hdr_samples/adder_gen.rb +22 -0
- data/lib/HDLRuby/hdr_samples/adder_gen_gen.rb +40 -0
- data/lib/HDLRuby/hdr_samples/dff_unit.rb +1 -1
- data/lib/HDLRuby/hdr_samples/with_def.rb +29 -0
- data/lib/HDLRuby/hdr_samples/with_delay.rb +72 -0
- data/lib/HDLRuby/hdr_samples/with_handshake.rb +110 -0
- data/lib/HDLRuby/hdr_samples/with_of.rb +51 -0
- data/lib/HDLRuby/hdr_samples/with_reconf.rb +75 -72
- data/lib/HDLRuby/hdr_samples/with_terminate.rb +32 -0
- data/lib/HDLRuby/hdrcc.rb +51 -5
- data/lib/HDLRuby/hdrlib.rb +592 -0
- data/lib/HDLRuby/hruby_high.rb +221 -44
- data/lib/HDLRuby/hruby_low.rb +210 -5
- data/lib/HDLRuby/hruby_low2c.rb +98 -9
- data/lib/HDLRuby/hruby_low2vhd.rb +12 -0
- data/lib/HDLRuby/hruby_low_bool2select.rb +12 -0
- data/lib/HDLRuby/hruby_low_fix_types.rb +20 -1
- data/lib/HDLRuby/hruby_low_resolve.rb +1 -1
- data/lib/HDLRuby/hruby_low_without_connection.rb +1 -0
- data/lib/HDLRuby/hruby_low_without_select.rb +11 -1
- data/lib/HDLRuby/hruby_verilog.rb +9 -1
- data/lib/HDLRuby/sim/hruby_sim.h +23 -1
- data/lib/HDLRuby/sim/hruby_sim_calc.c +3 -2
- data/lib/HDLRuby/sim/hruby_sim_core.c +60 -6
- data/lib/HDLRuby/sim/hruby_sim_vcd.c +1 -1
- data/lib/HDLRuby/std/delays.rb +92 -0
- data/lib/HDLRuby/std/handshakes.rb +60 -0
- data/lib/HDLRuby/std/reconf.rb +3 -0
- data/lib/HDLRuby/version.rb +1 -1
- metadata +11 -2
data/lib/HDLRuby/hruby_low2c.rb
CHANGED
@@ -135,6 +135,8 @@ module HDLRuby::Low
|
|
135
135
|
objs.each { |obj| res << " " << Low2C.make_name(obj) << "();\n" }
|
136
136
|
# Sets the top systemT.
|
137
137
|
res << " top_system = " << Low2C.obj_name(top) << ";\n"
|
138
|
+
# Enable it.
|
139
|
+
res << " set_enable_system(top_system,1);\n"
|
138
140
|
# Starts the simulation.
|
139
141
|
res<< " hruby_sim_core(\"#{name}\",#{init_visualizer},-1);\n"
|
140
142
|
# Close the main.
|
@@ -170,6 +172,7 @@ module HDLRuby::Low
|
|
170
172
|
# is the list of extra h files to include.
|
171
173
|
# def to_c(level = 0, *hnames)
|
172
174
|
def to_c(res, level = 0, *hnames)
|
175
|
+
# puts "SystemT.to_c with name=#{Low2C.obj_name(self)}#{@wrapper ? " and wrapper=#{Low2C.obj_name(@wrapper)}" : ""}"
|
173
176
|
# The header
|
174
177
|
# res = Low2C.includes(*hnames)
|
175
178
|
res << Low2C.includes(*hnames)
|
@@ -179,7 +182,16 @@ module HDLRuby::Low
|
|
179
182
|
|
180
183
|
# Generate the signals of the system.
|
181
184
|
# self.each_signal { |signal| signal.to_c(level) }
|
182
|
-
|
185
|
+
if ((defined? @wrapper) && @wrapper) then
|
186
|
+
# It is a reconfiguring system, alias the signals.
|
187
|
+
wrap_signals = @wrapper.each_signal.to_a
|
188
|
+
self.each_signal.with_index do |signal,i|
|
189
|
+
signal.to_c_alias(res,wrap_signals[i],level)
|
190
|
+
end
|
191
|
+
else
|
192
|
+
# It is a single system, default generation.
|
193
|
+
self.each_signal { |signal| signal.to_c(res,level) }
|
194
|
+
end
|
183
195
|
|
184
196
|
# Generate the code for all the blocks included in the system.
|
185
197
|
self.scope.each_scope_deep do |scope|
|
@@ -686,6 +698,10 @@ module HDLRuby::Low
|
|
686
698
|
res << "behavior->owner = NULL;\n"
|
687
699
|
end
|
688
700
|
|
701
|
+
# Set the behavior as not enabled. */
|
702
|
+
res << " " * (level+1)*3
|
703
|
+
res << "behavior->enabled = 0;\n"
|
704
|
+
|
689
705
|
# Set the behavior as inactive. */
|
690
706
|
res << " " * (level+1)*3
|
691
707
|
res << "behavior->activated = 0;\n"
|
@@ -842,11 +858,8 @@ module HDLRuby::Low
|
|
842
858
|
# +level+ is the hierachical level of the object.
|
843
859
|
# def to_c(level = 0)
|
844
860
|
def to_c(res,level = 0)
|
845
|
-
#
|
846
|
-
# res = ""
|
847
|
-
|
861
|
+
# puts "Signal.to_c with name: #{Low2C.obj_name(self)}"
|
848
862
|
# Declare the global variable holding the signal.
|
849
|
-
# res << "SignalI #{self.to_c_signal(level+1)};\n\n"
|
850
863
|
res << "SignalI "
|
851
864
|
self.to_c_signal(res,level+1)
|
852
865
|
res << ";\n\n"
|
@@ -854,6 +867,7 @@ module HDLRuby::Low
|
|
854
867
|
# The header of the signal generation.
|
855
868
|
res << " " * level*3
|
856
869
|
res << "SignalI " << Low2C.make_name(self) << "() {\n"
|
870
|
+
|
857
871
|
# res << " " * level*3
|
858
872
|
# res << "Value l,r,d;\n"
|
859
873
|
# res << " " * (level+1)*3
|
@@ -866,7 +880,6 @@ module HDLRuby::Low
|
|
866
880
|
# Sets the global variable of the signal.
|
867
881
|
res << "\n"
|
868
882
|
res << " " * (level+1)*3
|
869
|
-
# res << "#{self.to_c_signal(level+1)} = signalI;\n"
|
870
883
|
self.to_c_signal(res,level+1)
|
871
884
|
res << " = signalI;\n"
|
872
885
|
|
@@ -958,6 +971,43 @@ module HDLRuby::Low
|
|
958
971
|
|
959
972
|
return res;
|
960
973
|
end
|
974
|
+
|
975
|
+
## Generates the C text of the equivalent HDLRuby code in case
|
976
|
+
# the signals is actually an alias to another signal.
|
977
|
+
# +other+ is the target signal of the alias.
|
978
|
+
# +level+ is the hierachical level of the object.
|
979
|
+
def to_c_alias(res,target,level = 0)
|
980
|
+
# puts "Signal.to_c_alias with name: #{Low2C.obj_name(self)}"
|
981
|
+
# The resulting string.
|
982
|
+
# res = ""
|
983
|
+
|
984
|
+
# Declare the global variable holding the signal.
|
985
|
+
res << "SignalI "
|
986
|
+
self.to_c_signal(res,level+1)
|
987
|
+
res << ";\n\n"
|
988
|
+
|
989
|
+
# The header of the signal generation.
|
990
|
+
res << " " * level*3
|
991
|
+
res << "SignalI " << Low2C.make_name(self) << "() {\n"
|
992
|
+
|
993
|
+
res << "SignalI signalI = #{Low2C.obj_name(target)};\n"
|
994
|
+
|
995
|
+
# Sets the global variable of the signal.
|
996
|
+
res << "\n"
|
997
|
+
res << " " * (level+1)*3
|
998
|
+
self.to_c_signal(res,level+1)
|
999
|
+
res << " = signalI;\n"
|
1000
|
+
|
1001
|
+
# Generate the return of the signal.
|
1002
|
+
res << "\n"
|
1003
|
+
res << " " * (level+1)*3
|
1004
|
+
res << "return signalI;\n"
|
1005
|
+
|
1006
|
+
# Close the signal.
|
1007
|
+
res << " " * level*3
|
1008
|
+
res << "};\n\n"
|
1009
|
+
return res
|
1010
|
+
end
|
961
1011
|
end
|
962
1012
|
|
963
1013
|
|
@@ -999,9 +1049,22 @@ module HDLRuby::Low
|
|
999
1049
|
# Set the name
|
1000
1050
|
res << " " * (level+1)*3
|
1001
1051
|
res << "systemI->name = \"#{self.name}\";\n"
|
1002
|
-
# Set the type.
|
1052
|
+
# # Set the type.
|
1053
|
+
# res << " " * (level+1)*3
|
1054
|
+
# res << "systemI->system = " << Low2C.obj_name(self.systemT) << ";\n"
|
1055
|
+
# Set the systems.
|
1056
|
+
num_sys = self.each_systemT.to_a.size
|
1003
1057
|
res << " " * (level+1)*3
|
1004
|
-
res << "systemI->
|
1058
|
+
res << "systemI->num_systems = #{num_sys};\n"
|
1059
|
+
res << " " * (level+1)*3
|
1060
|
+
res << "systemI->systems = calloc(sizeof(SystemT), #{num_sys});\n"
|
1061
|
+
self.each_systemT.with_index do |sysT,i|
|
1062
|
+
res << " " * (level+1)*3
|
1063
|
+
res << "systemI->systems[#{i}] = #{Low2C.obj_name(sysT)};\n"
|
1064
|
+
end
|
1065
|
+
|
1066
|
+
# Configure the instance to current systemT.
|
1067
|
+
res << (" " * (level*3)) << "configure(systemI,0);\n"
|
1005
1068
|
|
1006
1069
|
# Generate the return of the signal.
|
1007
1070
|
res << "\n"
|
@@ -1100,6 +1163,10 @@ module HDLRuby::Low
|
|
1100
1163
|
res << "code->owner = NULL;\n"
|
1101
1164
|
end
|
1102
1165
|
|
1166
|
+
# Set the code as enabled (for now, may change in a near future). */
|
1167
|
+
res << " " * (level+1)*3
|
1168
|
+
res << "code->enabled = 1;\n"
|
1169
|
+
|
1103
1170
|
# Set the code as inactive. */
|
1104
1171
|
res << " " * (level+1)*3
|
1105
1172
|
res << "code->activated = 0;\n"
|
@@ -1392,6 +1459,28 @@ module HDLRuby::Low
|
|
1392
1459
|
end
|
1393
1460
|
end
|
1394
1461
|
|
1462
|
+
## Extends the TimeTerminate class with generation of C text.
|
1463
|
+
class TimeTerminate
|
1464
|
+
|
1465
|
+
# Generates the C text of the equivalent HDLRuby code.
|
1466
|
+
# +level+ is the hierachical level of the object.
|
1467
|
+
def to_c(res,level = 0)
|
1468
|
+
# Save the value pool state.
|
1469
|
+
res << (" " * (level*3)) << "terminate();\n"
|
1470
|
+
end
|
1471
|
+
end
|
1472
|
+
|
1473
|
+
## Extends the Configure class with generation of C text.
|
1474
|
+
class Configure
|
1475
|
+
|
1476
|
+
# Generates the C text of the equivalent HDLRuby code.
|
1477
|
+
# +level+ is the hierachical level of the object.
|
1478
|
+
def to_c(res,level = 0)
|
1479
|
+
# Save the value pool state.
|
1480
|
+
res << (" " * (level*3)) << "configure(#{Low2C.obj_name(self.ref.resolve)},#{self.index});\n"
|
1481
|
+
end
|
1482
|
+
end
|
1483
|
+
|
1395
1484
|
|
1396
1485
|
## Extends the If class with generation of C text.
|
1397
1486
|
class If
|
@@ -1993,11 +2082,11 @@ module HDLRuby::Low
|
|
1993
2082
|
if str =~ /^[01]+$/ && str.length <= 64 then
|
1994
2083
|
# Yes, generate a numeral value.
|
1995
2084
|
res << " " * (level+1)*3
|
1996
|
-
# res << "static unsigned long long data[] = { "
|
1997
2085
|
res << "static unsigned int data[] = { "
|
1998
2086
|
res << str.scan(/.{1,#{Low2C.int_width}}/m).reverse.map do |sub|
|
1999
2087
|
sub.to_i(2).to_s # + "ULL"
|
2000
2088
|
end.join(",")
|
2089
|
+
res << ", 0" if (str.length <= 32)
|
2001
2090
|
res << " };\n"
|
2002
2091
|
# Create the value.
|
2003
2092
|
res << " " * (level+1)*3
|
@@ -925,6 +925,18 @@ module HDLRuby::Low
|
|
925
925
|
end.join(" & ") + ";\n"
|
926
926
|
end
|
927
927
|
end
|
928
|
+
|
929
|
+
## Extends the TimeTerminate class with generation of HDLRuby::High text.
|
930
|
+
class TimeTerminate
|
931
|
+
|
932
|
+
# Generates the text of the equivalent HDLRuby::High code.
|
933
|
+
# +vars+ is the list of the variables and
|
934
|
+
# +level+ is the hierachical level of the object.
|
935
|
+
def to_vhdl(vars,level = 0)
|
936
|
+
# Generate a report statement.
|
937
|
+
return " " * (level*3) + "finish;\n"
|
938
|
+
end
|
939
|
+
end
|
928
940
|
|
929
941
|
## Extends the If class with generation of HDLRuby::High text.
|
930
942
|
class If
|
@@ -75,6 +75,18 @@ module HDLRuby::Low
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
+
|
79
|
+
## Extends the TimeTerminate class with functionality for converting booleans
|
80
|
+
# in assignments to select operators.
|
81
|
+
class TimeTerminate
|
82
|
+
|
83
|
+
# Converts booleans in assignments to select operators.
|
84
|
+
def boolean_in_assign2select!
|
85
|
+
# Nothing to do.
|
86
|
+
return self
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
78
90
|
|
79
91
|
## Extends the If class with functionality for converting booleans
|
80
92
|
# in assignments to select operators.
|
@@ -71,7 +71,7 @@ module HDLRuby::Low
|
|
71
71
|
class Statement
|
72
72
|
# Explicit the types conversions in the statement.
|
73
73
|
def explicit_types!
|
74
|
-
raise "Should implement explicit_types for class #{self.class}."
|
74
|
+
raise "Should implement explicit_types! for class #{self.class}."
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
@@ -98,7 +98,26 @@ module HDLRuby::Low
|
|
98
98
|
self.map_args!(&:explicit_types)
|
99
99
|
return self
|
100
100
|
end
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
## Extends the Configure class with fixing of types and constants.
|
105
|
+
class Configure
|
106
|
+
# Explicit the types conversions in the statement.
|
107
|
+
def explicit_types!
|
108
|
+
# Nothing to do.
|
109
|
+
return self
|
110
|
+
end
|
111
|
+
end
|
101
112
|
|
113
|
+
|
114
|
+
## Extends the TimeTerminate class with fixing of types and constants.
|
115
|
+
class TimeTerminate
|
116
|
+
# Explicit the types conversions in the statement.
|
117
|
+
def explicit_types!
|
118
|
+
# Nothing to do.
|
119
|
+
return self
|
120
|
+
end
|
102
121
|
end
|
103
122
|
|
104
123
|
|
@@ -163,7 +163,7 @@ module HDLRuby::Low
|
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
166
|
-
## Extends the
|
166
|
+
## Extends the Print class with functionality for converting select
|
167
167
|
# expressions to case statements.
|
168
168
|
class Print
|
169
169
|
# Extract the Select expressions.
|
@@ -175,6 +175,16 @@ module HDLRuby::Low
|
|
175
175
|
return selects
|
176
176
|
end
|
177
177
|
end
|
178
|
+
|
179
|
+
## Extends the TimeTerminate class with functionality for converting select
|
180
|
+
# expressions to case statements.
|
181
|
+
class TimeTerminate
|
182
|
+
# Extract the Select expressions.
|
183
|
+
def extract_selects!
|
184
|
+
# Nothing to extract.
|
185
|
+
return []
|
186
|
+
end
|
187
|
+
end
|
178
188
|
|
179
189
|
## Extends the If class with functionality for converting select
|
180
190
|
# expressions to case statements.
|
@@ -171,7 +171,7 @@ module HDLRuby::Low
|
|
171
171
|
|
172
172
|
# Enhance Print with generation of verilog code.
|
173
173
|
class Print
|
174
|
-
# Converts the
|
174
|
+
# Converts the print to Verilog code.
|
175
175
|
def to_verilog(spc = 3)
|
176
176
|
code = "#{" " * spc}$write(#{self.each_arg.map do |arg|
|
177
177
|
arg.to_verilog
|
@@ -180,6 +180,14 @@ module HDLRuby::Low
|
|
180
180
|
end
|
181
181
|
end
|
182
182
|
|
183
|
+
# Enhance TimeTerminate with generation of verilog code.
|
184
|
+
class TimeTerminate
|
185
|
+
# Converts the terminate to Verilog code.
|
186
|
+
def to_verilog(spc = 3)
|
187
|
+
return "#{" " * spc}$finish;"
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
183
191
|
# To scheduling to the Block.
|
184
192
|
# Enhance Block with generation of verilog code.
|
185
193
|
class Block
|
data/lib/HDLRuby/sim/hruby_sim.h
CHANGED
@@ -467,7 +467,10 @@ typedef struct SystemIS_ {
|
|
467
467
|
Object owner; /* The owner if any. */
|
468
468
|
|
469
469
|
char* name; /* The name of the signal. */
|
470
|
-
SystemT system; /* The instantiated system. */
|
470
|
+
SystemT system; /* The currently instantiated system. */
|
471
|
+
|
472
|
+
int num_systems; /* The number of systems possibly instantiated here. */
|
473
|
+
SystemT* systems; /* The systems possibly instantiated here. */
|
471
474
|
} SystemIS;
|
472
475
|
|
473
476
|
|
@@ -499,6 +502,8 @@ typedef struct BehaviorS_ {
|
|
499
502
|
Event* events; /* The events of the behavior. */
|
500
503
|
Block block; /* The block of the behavior. */
|
501
504
|
|
505
|
+
int enabled; /* Tells if the behavior is enabled or not. */
|
506
|
+
|
502
507
|
int activated; /* Tells if the behavior is activated or not. */
|
503
508
|
|
504
509
|
int timed; /* Tell if the behavior is timed or not:
|
@@ -519,6 +524,8 @@ typedef struct CodeS_ {
|
|
519
524
|
Event* events; /* The events of the behavior. */
|
520
525
|
void (*function)(); /* The function to execute for the code. */
|
521
526
|
|
527
|
+
int enabled; /* Tells if the behavior is enabled or not. */
|
528
|
+
|
522
529
|
int activated; /* Tells if the code is activated or not. */
|
523
530
|
} CodeS;
|
524
531
|
|
@@ -623,6 +630,16 @@ extern unsigned long long make_delay(int value, Unit unit);
|
|
623
630
|
* @param func function to applie on each signal. */
|
624
631
|
extern void each_all_signal(void (*func)(SignalI));
|
625
632
|
|
633
|
+
|
634
|
+
/** Configure a system instance.
|
635
|
+
* @param systemI the system instance to configure.
|
636
|
+
* @param idx the index of the target system. */
|
637
|
+
extern void configure(SystemI systemI, int idx);
|
638
|
+
|
639
|
+
|
640
|
+
/** Terminates the simulation. */
|
641
|
+
extern void terminate();
|
642
|
+
|
626
643
|
/* Interface to the visualization engine. */
|
627
644
|
|
628
645
|
typedef struct {
|
@@ -701,6 +718,11 @@ extern void init_vcd_visualizer(char* name);
|
|
701
718
|
|
702
719
|
/* The interface to the simulator core. */
|
703
720
|
|
721
|
+
/** Sets the enable status of the behaviors of a system type.
|
722
|
+
* @param systemT the system type to process.
|
723
|
+
* @param status the enable status. */
|
724
|
+
extern void set_enable_system(SystemT systemT, int status);
|
725
|
+
|
704
726
|
/** The simulation core function.
|
705
727
|
* @param name the name of the simulation.
|
706
728
|
* @param init_vizualizer the vizualizer engine initializer.
|
@@ -1871,10 +1871,11 @@ static Value equal_value_numeric(Value src0, Value src1, Value dst) {
|
|
1871
1871
|
dst->type = src0->type;
|
1872
1872
|
dst->numeric = 1;
|
1873
1873
|
|
1874
|
-
// /* Perform the !XOR. */
|
1875
|
-
// dst->data_int = ~(src0->data_int ^ src1->data_int);
|
1876
1874
|
/* Perform the comparison. */
|
1877
1875
|
dst->data_int = (src0->data_int == src1->data_int) ? 1 : 0;
|
1876
|
+
printf("scr0->data_int=%lld\n",src0->data_int);
|
1877
|
+
printf("scr1->data_int=%lld\n",src1->data_int);
|
1878
|
+
printf("dst->data_int=%lld\n",dst->data_int);
|
1878
1879
|
return dst;
|
1879
1880
|
}
|
1880
1881
|
|
@@ -253,8 +253,8 @@ void hruby_sim_update_signals() {
|
|
253
253
|
if (obj->kind == BEHAVIOR) {
|
254
254
|
/* Behavior case. */
|
255
255
|
Behavior beh = (Behavior)obj;
|
256
|
-
/* Is the code really activated? */
|
257
|
-
if (beh->activated) {
|
256
|
+
/* Is the code really enabled and activated? */
|
257
|
+
if (beh->enabled && beh->activated) {
|
258
258
|
/* Yes, execute it. */
|
259
259
|
beh->block->function();
|
260
260
|
/* And deactivate it. */
|
@@ -264,7 +264,7 @@ void hruby_sim_update_signals() {
|
|
264
264
|
/* Other code case. */
|
265
265
|
Code cod = (Code)obj;
|
266
266
|
/* Is the code really activated? */
|
267
|
-
if (cod->activated) {
|
267
|
+
if (cod->enabled && cod->activated) {
|
268
268
|
/* Yes, execute it. */
|
269
269
|
cod->function();
|
270
270
|
/* And deactivate it. */
|
@@ -294,6 +294,35 @@ void hruby_sim_advance_time() {
|
|
294
294
|
}
|
295
295
|
|
296
296
|
|
297
|
+
/** Sets the enamble status of the behaviors of a scope.
|
298
|
+
* @param scope the scope to process.
|
299
|
+
* @param status the enable status. */
|
300
|
+
static void set_enable_scope(Scope scope, int status) {
|
301
|
+
int i;
|
302
|
+
int num_beh = scope->num_behaviors;
|
303
|
+
Behavior* behs = scope->behaviors;
|
304
|
+
int num_scp = scope->num_scopes;
|
305
|
+
Scope* scps = scope->scopes;
|
306
|
+
|
307
|
+
/* Enable the behaviors. */
|
308
|
+
for(i=0; i<num_beh; ++i) {
|
309
|
+
behs[i]->enabled = status;
|
310
|
+
}
|
311
|
+
|
312
|
+
/* Recurse on the sub scopes. */
|
313
|
+
for(i=0; i<num_scp; ++i) {
|
314
|
+
set_enable_scope(scps[i],status);
|
315
|
+
}
|
316
|
+
}
|
317
|
+
|
318
|
+
/** Sets the enable status of the behaviors of a system type.
|
319
|
+
* @param systemT the system type to process.
|
320
|
+
* @param status the enable status. */
|
321
|
+
void set_enable_system(SystemT systemT, int status) {
|
322
|
+
set_enable_scope(systemT->scope,status);
|
323
|
+
}
|
324
|
+
|
325
|
+
|
297
326
|
/** Activates a behavior.
|
298
327
|
* @param behavior the behavior to activate. */
|
299
328
|
void activate_behavior(Behavior behavior) {
|
@@ -359,7 +388,8 @@ void* behavior_run(void* arg) {
|
|
359
388
|
pthread_mutex_unlock(&hruby_sim_mutex);
|
360
389
|
// printf("#2\n");
|
361
390
|
/* Now can start the execution of the behavior. */
|
362
|
-
behavior->
|
391
|
+
if (behavior->enabled)
|
392
|
+
behavior->block->function();
|
363
393
|
// printf("#3\n");
|
364
394
|
/* Now can start the execution of the behavior. */
|
365
395
|
/* Stops the behavior. */
|
@@ -635,11 +665,35 @@ unsigned long long make_delay(int value, Unit unit) {
|
|
635
665
|
|
636
666
|
|
637
667
|
|
638
|
-
|
639
|
-
*
|
668
|
+
/** Iterates over all the signals.
|
669
|
+
* @param func function to applie on each signal. */
|
640
670
|
void each_all_signal(void (*func)(SignalI)) {
|
641
671
|
int i;
|
642
672
|
for(i = 0; i<num_all_signals; ++i) {
|
643
673
|
func(all_signals[i]);
|
644
674
|
}
|
645
675
|
}
|
676
|
+
|
677
|
+
|
678
|
+
/** Configure a system instance.
|
679
|
+
* @param systemI the system instance to configure.
|
680
|
+
* @param idx the index of the target system. */
|
681
|
+
void configure(SystemI systemI, int idx) {
|
682
|
+
int i;
|
683
|
+
// printf("Configure to: %i\n",idx);
|
684
|
+
/* Sets the current system type. */
|
685
|
+
systemI->system = systemI->systems[idx];
|
686
|
+
/* Disable all the behaviors of the system instance. */
|
687
|
+
for(i=0; i<systemI->num_systems; ++i) {
|
688
|
+
if (i != idx)
|
689
|
+
set_enable_system(systemI->systems[i],0);
|
690
|
+
}
|
691
|
+
/* Enable the current system. */
|
692
|
+
set_enable_system(systemI->systems[idx],1);
|
693
|
+
}
|
694
|
+
|
695
|
+
|
696
|
+
/** Terminates the simulation. */
|
697
|
+
void terminate() {
|
698
|
+
exit(0);
|
699
|
+
}
|
@@ -85,7 +85,7 @@ static void vcd_print_name(Object object) {
|
|
85
85
|
vcd_print("%s",name);
|
86
86
|
} else {
|
87
87
|
/* No name, use the address of the object as name generator.*/
|
88
|
-
vcd_print("$%p",(void*)object);
|
88
|
+
vcd_print("x$%p",(void*)object);
|
89
89
|
}
|
90
90
|
break;
|
91
91
|
default: /* Nothing to do */
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module HDLRuby::High::Std
|
2
|
+
|
3
|
+
##
|
4
|
+
# Standard HDLRuby::High library: delays
|
5
|
+
#
|
6
|
+
########################################################################
|
7
|
+
|
8
|
+
|
9
|
+
## Module describing a simple delay using handshake for working.
|
10
|
+
# @param num the number of clock cycles to delay.
|
11
|
+
system :delay do |num|
|
12
|
+
# Checks and process the number of clock to wait.
|
13
|
+
num = num.to_i
|
14
|
+
raise "The delay generic argument must be positive: #{num}" if (num < 0)
|
15
|
+
|
16
|
+
input :clk # The clock to make the delay on.
|
17
|
+
input :req # The handshake request.
|
18
|
+
output :ack # The handshake acknoledgment.
|
19
|
+
|
20
|
+
# The process of the delay.
|
21
|
+
if (num == 0) then
|
22
|
+
# No delay case.
|
23
|
+
ack <= req
|
24
|
+
else
|
25
|
+
# The is a delay.
|
26
|
+
inner run: 0 # Tell if the deayl is running.
|
27
|
+
[num.width+1].inner :count # The counter for computing the delay.
|
28
|
+
par(clk.posedge) do
|
29
|
+
# Is there a request to treat?
|
30
|
+
hif(req & ~run) do
|
31
|
+
# Yes, intialize the delay.
|
32
|
+
run <= 1
|
33
|
+
count <= 0
|
34
|
+
ack <= 0
|
35
|
+
end
|
36
|
+
# No, maybe there is a request in processing.
|
37
|
+
helsif(run) do
|
38
|
+
# Yes, increase the counter.
|
39
|
+
count <= count + 1
|
40
|
+
# Check if the delay is reached.
|
41
|
+
hif(count == num-1) do
|
42
|
+
# Yes, tells it and stop the count.
|
43
|
+
ack <= 1
|
44
|
+
run <= 0
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
## Module describing a pipeline delay (supporting multiple successive delays)
|
54
|
+
# using handshake for working.
|
55
|
+
# @param num the number of clock cycles to delay.
|
56
|
+
system :delayp do |num|
|
57
|
+
# Checks and process the number of clock to wait.
|
58
|
+
num = num.to_i
|
59
|
+
raise "The delay generic argument must be positive: #{num}" if (num < 0)
|
60
|
+
|
61
|
+
input :clk # The clock to make the delay on.
|
62
|
+
input :req # The handshake request.
|
63
|
+
output :ack # The handshake acknoledgment.
|
64
|
+
|
65
|
+
if (num==0) then
|
66
|
+
# No delay.
|
67
|
+
ack <= req
|
68
|
+
else
|
69
|
+
# There is a delay.
|
70
|
+
|
71
|
+
[num].inner state: 0 # The shift register containing the progression
|
72
|
+
# of each requested delay.
|
73
|
+
|
74
|
+
# The acknoledgment is directly the last bit of the state register.
|
75
|
+
ack <= state[-1]
|
76
|
+
|
77
|
+
|
78
|
+
# The process controlling the delay.
|
79
|
+
seq(clk.posedge) do
|
80
|
+
# Update the state.
|
81
|
+
if (num > 1) then
|
82
|
+
state <= state << 1
|
83
|
+
else
|
84
|
+
state <= 0
|
85
|
+
end
|
86
|
+
# Handle the input.
|
87
|
+
( state[0] <= 1 ).hif(req)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module HDLRuby::High::Std
|
2
|
+
|
3
|
+
##
|
4
|
+
# Standard HDLRuby::High library: handshake protocols.
|
5
|
+
#
|
6
|
+
########################################################################
|
7
|
+
|
8
|
+
|
9
|
+
## Module describing a simple client handshake for working.
|
10
|
+
# @param event the event to synchronize the handshake.
|
11
|
+
# @param req the signal telling a request is there.
|
12
|
+
# @param cond the condition allowing the protocol.
|
13
|
+
system :hs_client do |event, req, cond=_1|
|
14
|
+
input :reqI
|
15
|
+
output ackI: 0
|
16
|
+
|
17
|
+
# A each synchronization event.
|
18
|
+
par(event) do
|
19
|
+
# Is the protocol is allowed and a request is present.
|
20
|
+
hif(cond & reqI) do
|
21
|
+
# Yes perform the action and tell the request has been treated.
|
22
|
+
req <= 1 if req
|
23
|
+
ackI <= 1
|
24
|
+
end
|
25
|
+
helse do
|
26
|
+
# No, do not perform the action, and do not acknowledge.
|
27
|
+
req <= 0 if req
|
28
|
+
ackI <= 0
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
## Module describing a simple server handshake for working.
|
35
|
+
# @param event the event to synchronize the handshake.
|
36
|
+
# @param req the signal for asking a new request.
|
37
|
+
system :hs_server do |event, req|
|
38
|
+
output reqO: 0
|
39
|
+
input :ackO
|
40
|
+
|
41
|
+
# A each synchronization event.
|
42
|
+
par(event) do
|
43
|
+
# Shall we start the output?
|
44
|
+
hif(ackO) { reqO <= 0 }
|
45
|
+
hif(req) { reqO <= 1 }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
## Module describing a pipeline with handshakes.
|
51
|
+
# @param event the event to synchronize the handshakes.
|
52
|
+
# @param read the signal telling there is a request from the client side
|
53
|
+
# @param write the signal used for asking the server to issue a request
|
54
|
+
system :hs_pipe do |event,read,write|
|
55
|
+
inner :cond
|
56
|
+
include(hs_client(event,read,cond))
|
57
|
+
include(hs_server(event,write))
|
58
|
+
cond <= ~reqO
|
59
|
+
end
|
60
|
+
end
|