HDLRuby 2.4.1 → 2.4.6
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/bstr_bench.rb +14 -0
- data/lib/HDLRuby/hdr_samples/with_multi_channels.rb +21 -11
- data/lib/HDLRuby/hruby_bstr.rb +5 -2
- data/lib/HDLRuby/hruby_low2c.rb +14 -2
- data/lib/HDLRuby/sim/hruby_sim.h +9 -5
- data/lib/HDLRuby/sim/hruby_sim_core.c +3 -0
- data/lib/HDLRuby/sim/hruby_sim_vcd.c +191 -26
- data/lib/HDLRuby/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c3f6418748c0552d8c5d8544ae64ebdc287646b95ffec70d50c66d131529a6a
|
4
|
+
data.tar.gz: c2c55a5b9defc62bbb387072dd318918f9dc802065eb764303cacac3cfbf5f91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 619d787d2f4f621591f37b06d4cf048c39a1a652a810835b18aa12610c69a17d2587a06fee10a3f2ff4406b744b567d2aed5d2dc21b2a5201676057c58a24b26
|
7
|
+
data.tar.gz: a5d2677dd07c54224dfb189d28c5c82015c4b099b7b204049402d1df940ac19e9051f9e199e56e6f2d043134697b307873b53e80dc86728bca2ebdc1087ce39f
|
@@ -174,13 +174,22 @@ channel(:handshake) do |typ|
|
|
174
174
|
end
|
175
175
|
|
176
176
|
|
177
|
-
$mode = :prodcons
|
178
177
|
# $mode = :sync
|
179
178
|
# $mode = :nsync
|
180
179
|
# $mode = :async
|
180
|
+
# $mode = :proco # Producter / Consummer
|
181
181
|
# $channel = :register
|
182
182
|
# $channel = :handshake
|
183
|
-
$channel = :queue
|
183
|
+
# $channel = :queue
|
184
|
+
|
185
|
+
# The configuration scenarii
|
186
|
+
$scenarii = [ [:sync, :register], [:sync, :handshake], [:sync, :queue],
|
187
|
+
[:nsync, :register], [:nsync, :handshake], [:nsync, :queue],
|
188
|
+
[:async, :register], [:async, :handshake], [:async, :queue],
|
189
|
+
[:proco, :register], [:proco, :handshake], [:proco, :queue] ]
|
190
|
+
|
191
|
+
# The configuration
|
192
|
+
$mode, $channel = $scenarii[11]
|
184
193
|
|
185
194
|
# Testing the queue channel.
|
186
195
|
system :test_queue do
|
@@ -199,7 +208,7 @@ system :test_queue do
|
|
199
208
|
ev = $mode == :sync ? clk.posedge :
|
200
209
|
$mode == :nsync ? clk.negedge : clk2.posedge
|
201
210
|
|
202
|
-
if $mode != :
|
211
|
+
if $mode != :proco then
|
203
212
|
# Sync/Neg sync and async tests mode
|
204
213
|
par(ev) do
|
205
214
|
hif(rst) do
|
@@ -263,27 +272,28 @@ system :test_queue do
|
|
263
272
|
rst <= 1
|
264
273
|
!3.ns
|
265
274
|
clk2 <= 1
|
266
|
-
!
|
267
|
-
clk3 <=
|
268
|
-
!
|
275
|
+
!3.ns
|
276
|
+
clk3 <= 0
|
277
|
+
!4.ns
|
269
278
|
clk <= 1
|
270
279
|
!10.ns
|
271
280
|
clk <= 0
|
272
|
-
rst <= 0
|
273
281
|
!3.ns
|
274
282
|
clk2 <= 0
|
275
|
-
!
|
283
|
+
!3.ns
|
276
284
|
clk3 <= 1
|
277
|
-
!
|
285
|
+
!2.ns
|
286
|
+
rst <= 0
|
287
|
+
!2.ns
|
278
288
|
64.times do
|
279
289
|
clk <= 1
|
280
290
|
!10.ns
|
281
291
|
clk <= 0
|
282
292
|
!3.ns
|
283
293
|
clk2 <= ~clk2
|
284
|
-
!
|
294
|
+
!3.ns
|
285
295
|
hif (clk2 == 0) { clk3 <= ~ clk3 }
|
286
|
-
!
|
296
|
+
!4.ns
|
287
297
|
end
|
288
298
|
end
|
289
299
|
end
|
data/lib/HDLRuby/hruby_bstr.rb
CHANGED
@@ -35,10 +35,13 @@ module HDLRuby
|
|
35
35
|
# Maybe str is an numeric.
|
36
36
|
if str.is_a?(Numeric) then
|
37
37
|
# Yes, convert it to a binary string.
|
38
|
-
|
38
|
+
num = str
|
39
|
+
str = num.to_s(2)
|
39
40
|
# And fix the sign.
|
40
41
|
if str[0] == "-" then
|
41
|
-
str = str[1..-1]
|
42
|
+
# str = str[1..-1]
|
43
|
+
str = (2**str.size+num).to_s(2)
|
44
|
+
puts "str=#{str}"
|
42
45
|
sign = "-"
|
43
46
|
else
|
44
47
|
sign = "+"
|
data/lib/HDLRuby/hruby_low2c.rb
CHANGED
@@ -111,6 +111,8 @@ module HDLRuby::Low
|
|
111
111
|
res << "int main(int argc, char* argv[]) {\n"
|
112
112
|
# Build the objects.
|
113
113
|
objs.each { |obj| res << " #{Low2C.make_name(obj)}();\n" }
|
114
|
+
# Sets the top systemT.
|
115
|
+
res << " top_system = #{Low2C.obj_name(top)};\n"
|
114
116
|
# Starts the simulation.
|
115
117
|
res<< " hruby_sim_core(\"#{name}\",#{init_visualizer},-1);\n"
|
116
118
|
# Close the main.
|
@@ -1329,6 +1331,10 @@ module HDLRuby::Low
|
|
1329
1331
|
res << "block->owner = NULL;\n"
|
1330
1332
|
end
|
1331
1333
|
|
1334
|
+
# The name
|
1335
|
+
res << " " * (level+1)*3
|
1336
|
+
res << "block->name = \"#{self.name}\";\n"
|
1337
|
+
|
1332
1338
|
# Add the inner signals declaration.
|
1333
1339
|
res << " " * (level+1)*3
|
1334
1340
|
res << "block->num_inners = #{self.each_inner.to_a.size};\n"
|
@@ -1439,8 +1445,14 @@ module HDLRuby::Low
|
|
1439
1445
|
str = self.content.is_a?(BitString) ?
|
1440
1446
|
self.content.to_s : self.content.to_s(2).rjust(32,"0")
|
1441
1447
|
else
|
1442
|
-
sign = self.content>=0 ? "0" : "1"
|
1443
|
-
str = self.content.abs.to_s(2).rjust(width,sign).upcase
|
1448
|
+
# sign = self.content>=0 ? "0" : "1"
|
1449
|
+
# str = self.content.abs.to_s(2).rjust(width,sign).upcase
|
1450
|
+
if self.content >= 0 then
|
1451
|
+
str = self.content.to_s(2).rjust(width,"0").upcase
|
1452
|
+
else
|
1453
|
+
str = (2**width+self.content).to_s(2).upcase
|
1454
|
+
end
|
1455
|
+
# puts "content=#{self.content} str=#{str}"
|
1444
1456
|
end
|
1445
1457
|
# Is it a fully defined number?
|
1446
1458
|
if str =~ /^[01]+$/ then
|
data/lib/HDLRuby/sim/hruby_sim.h
CHANGED
@@ -474,6 +474,7 @@ typedef struct BlockS_ {
|
|
474
474
|
Kind kind; /* The kind of object. */
|
475
475
|
Object owner; /* The owner if any. */
|
476
476
|
|
477
|
+
char* name; /* The name of the block. */
|
477
478
|
int num_inners; /* The number of inners. */
|
478
479
|
SignalI* inners; /* The inners of the scope. */
|
479
480
|
void (*function)(); /* The function to execute for the block. */
|
@@ -496,6 +497,9 @@ typedef struct EventS_ {
|
|
496
497
|
/* The time units. */
|
497
498
|
typedef enum { S, MS, US, NS, PS, FS } Unit;
|
498
499
|
|
500
|
+
/** The top system. */
|
501
|
+
extern SystemT top_system;
|
502
|
+
|
499
503
|
/** Adds a timed behavior for processing.
|
500
504
|
* @param behavior the timed behavior to register */
|
501
505
|
extern void register_timed_behavior(Behavior behavior);
|
@@ -574,17 +578,17 @@ typedef struct {
|
|
574
578
|
void (*print_signal)(SignalI);
|
575
579
|
} PrinterS;
|
576
580
|
|
577
|
-
PrinterS printer;
|
581
|
+
extern PrinterS printer;
|
578
582
|
|
579
583
|
/** Initializes the visualization printer engine.
|
580
584
|
* @param print_time the time printer
|
581
585
|
* @param print_name the name printer
|
582
586
|
* @param print_value the value printer
|
583
587
|
* @param print_signal the signal state printer. */
|
584
|
-
void init_visualizer(void (*print_time)(unsigned long long),
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
+
extern void init_visualizer(void (*print_time)(unsigned long long),
|
589
|
+
void (*print_name)(Object),
|
590
|
+
void (*print_value)(Value),
|
591
|
+
void (*print_signal)(SignalI));
|
588
592
|
|
589
593
|
// /** Prints the time.
|
590
594
|
// * @param time the time to show. */
|
@@ -64,35 +64,49 @@ static void vcd_print_time(unsigned long long time) {
|
|
64
64
|
}
|
65
65
|
|
66
66
|
|
67
|
-
/** Prints the name of an object.
|
67
|
+
/** Prints the name of an object without its hierarchy.
|
68
68
|
* @param object the object to print the name. */
|
69
69
|
static void vcd_print_name(Object object) {
|
70
|
-
/* Recurse on the owner if any. */
|
71
|
-
// printf("owner=%p\n",object->owner);
|
72
|
-
if (object->owner != NULL) {
|
73
|
-
vcd_print_name(object->owner);
|
74
|
-
vcd_print("$");
|
75
|
-
}
|
76
70
|
/* Depending on the kind of object. */
|
77
71
|
switch(object->kind) {
|
78
72
|
case SYSTEMT:
|
79
73
|
case SIGNALI:
|
80
74
|
case SCOPE:
|
81
75
|
case SYSTEMI:
|
76
|
+
case BLOCK:
|
82
77
|
/* Print the name if name. */
|
83
78
|
/* Trick: SystemT, SignalI, Scope and SystemI have the
|
84
79
|
* field name at the same place. */
|
85
|
-
if (((
|
80
|
+
if ((((Block)object)->name != NULL) &&
|
81
|
+
strlen(((Block)object)->name)>0) {
|
86
82
|
char name[256];
|
87
|
-
strncpy(name,((
|
83
|
+
strncpy(name,((Block)object)->name,256);
|
88
84
|
replace_char(name,':','$');
|
89
85
|
vcd_print("%s",name);
|
86
|
+
} else {
|
87
|
+
/* No name, use the address of the object as name generator.*/
|
88
|
+
vcd_print("$%p",(void*)object);
|
90
89
|
}
|
90
|
+
break;
|
91
91
|
default: /* Nothing to do */
|
92
92
|
break;
|
93
93
|
}
|
94
94
|
}
|
95
95
|
|
96
|
+
|
97
|
+
/** Prints the name of an object incluing its heirarchy.
|
98
|
+
* @param object the object to print the name. */
|
99
|
+
static void vcd_print_full_name(Object object) {
|
100
|
+
/* Recurse on the owner if any. */
|
101
|
+
// printf("owner=%p\n",object->owner);
|
102
|
+
if (object->owner != NULL) {
|
103
|
+
vcd_print_full_name(object->owner);
|
104
|
+
vcd_print("$");
|
105
|
+
}
|
106
|
+
/* Print the name of the object. */
|
107
|
+
vcd_print_name(object);
|
108
|
+
}
|
109
|
+
|
96
110
|
/** Prints a value.
|
97
111
|
* @param value the value to print */
|
98
112
|
static void vcd_print_value(Value value) {
|
@@ -127,23 +141,169 @@ static void vcd_print_value(Value value) {
|
|
127
141
|
* @param signal the signal to declare */
|
128
142
|
static void vcd_print_var(SignalI signal) {
|
129
143
|
vcd_print("$var wire %d ",type_width(signal->type));
|
130
|
-
|
144
|
+
vcd_print_full_name((Object)signal);
|
131
145
|
vcd_print(" ");
|
132
146
|
vcd_print_name((Object)signal);
|
133
147
|
vcd_print(" $end\n");
|
134
148
|
}
|
135
149
|
|
136
150
|
|
137
|
-
/** Prints a signal.
|
151
|
+
/** Prints a signal with its future value if any.
|
138
152
|
* @param signal the signal to show */
|
139
|
-
static void
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
153
|
+
static void vcd_print_signal_fvalue(SignalI signal) {
|
154
|
+
if (signal->f_value) {
|
155
|
+
vcd_print_value(signal->f_value);
|
156
|
+
vcd_print(" ");
|
157
|
+
vcd_print_full_name((Object)signal);
|
158
|
+
vcd_print("\n");
|
159
|
+
}
|
160
|
+
}
|
161
|
+
|
162
|
+
|
163
|
+
/** Prints a signal with its current value if any
|
164
|
+
* @param signal the signal to show */
|
165
|
+
static void vcd_print_signal_cvalue(SignalI signal) {
|
166
|
+
if (signal->c_value) {
|
167
|
+
vcd_print_value(signal->c_value);
|
168
|
+
vcd_print(" ");
|
169
|
+
vcd_print_full_name((Object)signal);
|
170
|
+
vcd_print("\n");
|
171
|
+
}
|
172
|
+
}
|
173
|
+
|
174
|
+
|
175
|
+
/** Prints the hierarchy content of a system type.
|
176
|
+
* @param system the system to print. */
|
177
|
+
static void vcd_print_systemT_content(SystemT system);
|
178
|
+
|
179
|
+
/** Prints the hierarchy of a scope.
|
180
|
+
* @param scope the scope to print. */
|
181
|
+
static void vcd_print_scope(Scope scope);
|
182
|
+
|
183
|
+
|
184
|
+
/** Prints the hierarchy of a block.
|
185
|
+
* @param block the block to print. */
|
186
|
+
static void vcd_print_block(Block block) {
|
187
|
+
int i;
|
188
|
+
/* Do not print block with no declaration. */
|
189
|
+
if (block->num_inners == 0) return;
|
190
|
+
|
191
|
+
/* Declares the block if named. */
|
192
|
+
vcd_print("$scope module ");
|
193
|
+
vcd_print_name((Object)block);
|
194
|
+
vcd_print(" $end\n");
|
195
|
+
|
196
|
+
/* Declare the inners of the systems. */
|
197
|
+
for(i=0; i<block->num_inners; ++i) {
|
198
|
+
vcd_print_var(block->inners[i]);
|
199
|
+
}
|
200
|
+
|
201
|
+
/* Close the hierarchy. */
|
202
|
+
vcd_print("$upscope $end\n");
|
144
203
|
}
|
145
204
|
|
146
205
|
|
206
|
+
/** Prints the hierarchy of a system instances.
|
207
|
+
* @param scope the scope to print. */
|
208
|
+
static void vcd_print_systemI(SystemI systemI) {
|
209
|
+
/* Declares the systemI. */
|
210
|
+
vcd_print("$scope module ");
|
211
|
+
vcd_print_name((Object)systemI);
|
212
|
+
vcd_print(" $end\n");
|
213
|
+
|
214
|
+
/* Declares its content. */
|
215
|
+
vcd_print_systemT_content(systemI->system);
|
216
|
+
|
217
|
+
/* Close the hierarchy. */
|
218
|
+
vcd_print("$upscope $end\n");
|
219
|
+
}
|
220
|
+
|
221
|
+
|
222
|
+
/** Prints the hierarchy inside a scope.
|
223
|
+
* @param scope the scope to print the inside. */
|
224
|
+
static void vcd_print_scope_content(Scope scope) {
|
225
|
+
int i;
|
226
|
+
|
227
|
+
/* Declare the inners of the systems. */
|
228
|
+
for(i=0; i<scope->num_inners; ++i) {
|
229
|
+
vcd_print_var(scope->inners[i]);
|
230
|
+
}
|
231
|
+
|
232
|
+
/* Recurse on the system instances. */
|
233
|
+
for(i=0; i<scope->num_systemIs; ++i) {
|
234
|
+
vcd_print_systemI(scope->systemIs[i]);
|
235
|
+
}
|
236
|
+
|
237
|
+
/* Recurse on the sub scopes. */
|
238
|
+
for(i=0; i<scope->num_scopes; ++i) {
|
239
|
+
vcd_print_scope(scope->scopes[i]);
|
240
|
+
}
|
241
|
+
|
242
|
+
/* Recurse on the behaviors. */
|
243
|
+
for(i=0; i<scope->num_behaviors; ++i) {
|
244
|
+
vcd_print_block(scope->behaviors[i]->block);
|
245
|
+
}
|
246
|
+
}
|
247
|
+
|
248
|
+
|
249
|
+
/** Prints the hierarchy of a scope.
|
250
|
+
* @param scope the scope to print. */
|
251
|
+
static void vcd_print_scope(Scope scope) {
|
252
|
+
/* Do not print block with no declaration. */
|
253
|
+
if (scope->num_inners == 0 && scope->num_scopes == 0 && scope->num_behaviors == 0) return;
|
254
|
+
/* Declares the scope. */
|
255
|
+
vcd_print("$scope module ");
|
256
|
+
vcd_print_name((Object)scope);
|
257
|
+
vcd_print(" $end\n");
|
258
|
+
|
259
|
+
/* Declares its content. */
|
260
|
+
vcd_print_scope_content(scope);
|
261
|
+
|
262
|
+
/* Close the hierarchy. */
|
263
|
+
vcd_print("$upscope $end\n");
|
264
|
+
}
|
265
|
+
|
266
|
+
|
267
|
+
/** Prints the hierarchy content of a system type.
|
268
|
+
* @param system the system to print. */
|
269
|
+
static void vcd_print_systemT_content(SystemT system) {
|
270
|
+
int i;
|
271
|
+
|
272
|
+
/* Declare the inputs of the systems. */
|
273
|
+
for(i = 0; i<system->num_inputs; ++i) {
|
274
|
+
vcd_print_var(system->inputs[i]);
|
275
|
+
}
|
276
|
+
/* Declare the outputs of the systems. */
|
277
|
+
for(i = 0; i<system->num_outputs; ++i) {
|
278
|
+
vcd_print_var(system->outputs[i]);
|
279
|
+
}
|
280
|
+
/* Declare the inouts of the systems. */
|
281
|
+
for(i = 0; i<system->num_inouts; ++i) {
|
282
|
+
vcd_print_var(system->inouts[i]);
|
283
|
+
}
|
284
|
+
/* Recurse on the content of the scope (the scope header is the system).*/
|
285
|
+
vcd_print_scope_content(system->scope);
|
286
|
+
}
|
287
|
+
|
288
|
+
|
289
|
+
/** Prints the hierarchy of a system type.
|
290
|
+
* @param system the system to print. */
|
291
|
+
static void vcd_print_systemT(SystemT system) {
|
292
|
+
int i;
|
293
|
+
/* Declares the module. */
|
294
|
+
vcd_print("$scope module ");
|
295
|
+
vcd_print_name((Object)system);
|
296
|
+
vcd_print(" $end\n");
|
297
|
+
|
298
|
+
/* Declares the content. */
|
299
|
+
vcd_print_systemT_content(system);
|
300
|
+
|
301
|
+
/* Close the hierarchy. */
|
302
|
+
vcd_print("$upscope $end\n");
|
303
|
+
}
|
304
|
+
|
305
|
+
|
306
|
+
|
147
307
|
|
148
308
|
|
149
309
|
/* high-end print functions. */
|
@@ -164,7 +324,7 @@ static void vcd_print_header() {
|
|
164
324
|
/* The version section. */
|
165
325
|
vcd_print("$version\n");
|
166
326
|
vcd_print(" Generated from HDLRuby simulator\n");
|
167
|
-
vcd_print("$end");
|
327
|
+
vcd_print("$end\n");
|
168
328
|
|
169
329
|
/* The comment section. */
|
170
330
|
vcd_print("$comment\n");
|
@@ -174,20 +334,25 @@ static void vcd_print_header() {
|
|
174
334
|
/* The time scale section: for now 1ps only. */
|
175
335
|
vcd_print("$timescale 1ps $end\n");
|
176
336
|
|
177
|
-
/* The scope section: nothing specific. */
|
178
|
-
vcd_print("$scope module logic $end\n");
|
337
|
+
// /* The scope section: nothing specific. */
|
338
|
+
// vcd_print("$scope module logic $end\n");
|
179
339
|
|
180
|
-
/* The variables declaration. */
|
181
|
-
each_all_signal(&vcd_print_var);
|
340
|
+
// /* The variables declaration. */
|
341
|
+
// each_all_signal(&vcd_print_var);
|
182
342
|
|
343
|
+
// /* Ends the declarations. */
|
344
|
+
// vcd_print("$upscope $end\n");
|
345
|
+
// vcd_print("$enddefinitions $end\n");
|
346
|
+
|
347
|
+
/* The declaration of the hierarchy and the variables
|
348
|
+
* from the top system. */
|
349
|
+
vcd_print_systemT(top_system);
|
183
350
|
/* Ends the declarations. */
|
184
|
-
vcd_print("$upscope $end\n");
|
185
351
|
vcd_print("$enddefinitions $end\n");
|
186
352
|
|
187
353
|
/* Display the initializations. */
|
188
354
|
vcd_print("$dumpvars\n");
|
189
|
-
|
190
|
-
// each_all_init_signal(&vcd_print_signal);
|
355
|
+
each_all_signal(&vcd_print_signal_cvalue);
|
191
356
|
vcd_print("$end\n");
|
192
357
|
}
|
193
358
|
|
@@ -206,9 +371,9 @@ extern void init_vcd_visualizer(char* name) {
|
|
206
371
|
|
207
372
|
/* Initialize the vizualizer printer engine. */
|
208
373
|
init_visualizer(&vcd_print_time,
|
209
|
-
&
|
374
|
+
&vcd_print_full_name,
|
210
375
|
&vcd_print_value,
|
211
|
-
&
|
376
|
+
&vcd_print_signal_fvalue);
|
212
377
|
|
213
378
|
/* Prints the header of the vcd file. */
|
214
379
|
vcd_print_header();
|
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.4.
|
4
|
+
version: 2.4.6
|
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-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -75,6 +75,7 @@ files:
|
|
75
75
|
- lib/HDLRuby/hdr_samples/addsub.rb
|
76
76
|
- lib/HDLRuby/hdr_samples/addsubz.rb
|
77
77
|
- lib/HDLRuby/hdr_samples/alu.rb
|
78
|
+
- lib/HDLRuby/hdr_samples/bstr_bench.rb
|
78
79
|
- lib/HDLRuby/hdr_samples/calculator.rb
|
79
80
|
- lib/HDLRuby/hdr_samples/counter_bench.rb
|
80
81
|
- lib/HDLRuby/hdr_samples/dff.rb
|