HDLRuby 2.6.2 → 2.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/HDLRuby/hdrcc.rb +27 -2
- data/lib/HDLRuby/sim/hruby_sim.h +4 -1
- data/lib/HDLRuby/sim/hruby_sim_core.c +24 -9
- data/lib/HDLRuby/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de0bd759fdbbac53ed126dac38739ef63bdbea435e59f6ebfe9fe35d08475e13
|
4
|
+
data.tar.gz: 9ddbebe786fe3f3f3b6a2db76954f1d8c118cb1913d3487251b9419c1c68c997
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d22275446a0323c9a27ff0df24d7bb6f684dec195a53f2713176908da81dfc693502bf7649cde756e81726f01dbce910befdc33a623f6022e9e448c559f8bfef
|
7
|
+
data.tar.gz: 8dd6f59d5f0c6898e3e5b71b287900ab3bac0b21154b51acbf14a5959180632d3090fd3979478a5f50bdd418ec09104fb33e4d99059dee7812a16a9aba6f42af
|
data/lib/HDLRuby/hdrcc.rb
CHANGED
@@ -252,6 +252,20 @@ module HDLRuby
|
|
252
252
|
|
253
253
|
end
|
254
254
|
|
255
|
+
# Locate an executable from cmd.
|
256
|
+
def which(cmd)
|
257
|
+
# Get the possible exetensions (for windows case).
|
258
|
+
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
259
|
+
# Look for the command within the executable paths.
|
260
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
261
|
+
exts.each do |ext|
|
262
|
+
exe = File.join(path, "#{cmd}#{ext}")
|
263
|
+
return exe if File.executable?(exe) && !File.directory?(exe)
|
264
|
+
end
|
265
|
+
end
|
266
|
+
nil
|
267
|
+
end
|
268
|
+
|
255
269
|
|
256
270
|
|
257
271
|
if __FILE__ == $0 then
|
@@ -655,8 +669,19 @@ elsif $options[:clang] then
|
|
655
669
|
end
|
656
670
|
end
|
657
671
|
Dir.chdir($output)
|
658
|
-
#
|
659
|
-
|
672
|
+
# Find the compiler.
|
673
|
+
cc_cmd = which('cc')
|
674
|
+
unless cc_cmd then
|
675
|
+
cc_cmd = which('gcc')
|
676
|
+
end
|
677
|
+
unless cc_cmd then
|
678
|
+
raise "Could not find any compiler, please compile by hand as follows:\n" +
|
679
|
+
" In folder #{$output} execute:\n" +
|
680
|
+
" <my compiler> -o hruby_simulator *.c -lpthread\n" +
|
681
|
+
" Then execute:\n hruby_simulator"
|
682
|
+
end
|
683
|
+
# Use it.
|
684
|
+
Kernel.system("#{cc_cmd} -o3 -o hruby_simulator *.c -lpthread")
|
660
685
|
Kernel.system("./hruby_simulator")
|
661
686
|
end
|
662
687
|
elsif $options[:verilog] then
|
data/lib/HDLRuby/sim/hruby_sim.h
CHANGED
@@ -451,7 +451,10 @@ typedef struct BehaviorS_ {
|
|
451
451
|
|
452
452
|
int activated; /* Tells if the behavior is activated or not. */
|
453
453
|
|
454
|
-
int timed; /* Tell if the behavior is timed or not
|
454
|
+
int timed; /* Tell if the behavior is timed or not:
|
455
|
+
- 0: not timed
|
456
|
+
- 1: timed
|
457
|
+
- 2: timed and finished. */
|
455
458
|
unsigned long long active_time; /* The next time the behavior has to be activated. */
|
456
459
|
pthread_t thread; /* The thread assotiated with the behavior (if any).*/
|
457
460
|
} BehaviorS;
|
@@ -285,7 +285,8 @@ void hruby_sim_advance_time() {
|
|
285
285
|
int i;
|
286
286
|
for(i=0; i<num_timed_behaviors; ++i) {
|
287
287
|
unsigned long long beh_time = timed_behaviors[i]->active_time;
|
288
|
-
if (
|
288
|
+
if (timed_behaviors[i]->timed == 1)
|
289
|
+
if (beh_time < next_time) next_time = beh_time;
|
289
290
|
}
|
290
291
|
/* Sets the new activation time. */
|
291
292
|
hruby_sim_time = next_time;
|
@@ -310,7 +311,9 @@ void hruby_sim_activate_behaviors_on_time() {
|
|
310
311
|
/* Count the number of behaviors that will be activated. */
|
311
312
|
for(i=0; i<num_timed_behaviors; ++i) {
|
312
313
|
Behavior beh = timed_behaviors[i];
|
313
|
-
|
314
|
+
// printf("beh->active_time=%llu\n",beh->active_time);
|
315
|
+
// if (beh->active_time == hruby_sim_time) {
|
316
|
+
if (beh->timed == 1 && beh->active_time == hruby_sim_time) {
|
314
317
|
/* Increase the number of timed behavior to wait for. */
|
315
318
|
num_active_behaviors ++;
|
316
319
|
// printf("num_active_behaviors = %d\n",num_active_behaviors);
|
@@ -318,18 +321,19 @@ void hruby_sim_activate_behaviors_on_time() {
|
|
318
321
|
}
|
319
322
|
/* Activate the behaviors .*/
|
320
323
|
behaviors_can_run = 1;
|
324
|
+
// printf("$2\n");
|
321
325
|
// pthread_cond_signal(&compute_cond); /* No behaviors. */
|
322
|
-
pthread_cond_signal(&hruby_beh_cond);
|
326
|
+
// pthread_cond_signal(&hruby_beh_cond);
|
323
327
|
pthread_mutex_unlock(&hruby_sim_mutex);
|
324
|
-
|
328
|
+
pthread_cond_broadcast(&hruby_beh_cond);
|
325
329
|
}
|
326
330
|
|
327
331
|
|
328
332
|
/** Wait for the active timed behaviors to advance. */
|
329
333
|
void hruby_sim_wait_behaviors() {
|
330
|
-
// printf("$3\n");
|
331
334
|
pthread_mutex_lock(&hruby_sim_mutex);
|
332
335
|
while(num_active_behaviors > 0) {
|
336
|
+
// printf("$3\n");
|
333
337
|
// printf("num_active_behaviors = %d\n",num_active_behaviors);
|
334
338
|
// pthread_cond_wait(&active_behaviors_cond, &hruby_sim_mutex);
|
335
339
|
pthread_cond_wait(&hruby_sim_cond, &hruby_sim_mutex);
|
@@ -349,6 +353,7 @@ void* behavior_run(void* arg) {
|
|
349
353
|
pthread_mutex_lock(&hruby_sim_mutex);
|
350
354
|
num_active_behaviors -= 1;
|
351
355
|
while(!behaviors_can_run) {
|
356
|
+
// printf("cannot run\n");
|
352
357
|
// pthread_cond_wait(&compute_cond, &hruby_sim_mutex);
|
353
358
|
pthread_cond_wait(&hruby_beh_cond, &hruby_sim_mutex);
|
354
359
|
}
|
@@ -356,12 +361,17 @@ void* behavior_run(void* arg) {
|
|
356
361
|
// printf("#2\n");
|
357
362
|
/* Now can start the execution of the behavior. */
|
358
363
|
behavior->block->function();
|
364
|
+
// printf("#3\n");
|
365
|
+
/* Now can start the execution of the behavior. */
|
359
366
|
/* Stops the behavior. */
|
360
367
|
pthread_mutex_lock(&hruby_sim_mutex);
|
361
368
|
num_active_behaviors -= 1;
|
362
369
|
num_run_behaviors -= 1;
|
363
|
-
|
370
|
+
// printf("num_run_behaviors=%d\n",num_run_behaviors);
|
371
|
+
behavior->timed = 2;
|
372
|
+
// pthread_cond_signal(&hruby_sim_cond);
|
364
373
|
pthread_mutex_unlock(&hruby_sim_mutex);
|
374
|
+
pthread_cond_signal(&hruby_sim_cond);
|
365
375
|
/* End the thread. */
|
366
376
|
pthread_exit(NULL);
|
367
377
|
}
|
@@ -374,11 +384,13 @@ void hruby_sim_start_timed_behaviors() {
|
|
374
384
|
pthread_mutex_lock(&hruby_sim_mutex);
|
375
385
|
/* Sets the end flags to 0. */
|
376
386
|
sim_end_flag = 0;
|
387
|
+
/* Tells the behavior can run. */
|
388
|
+
behaviors_can_run = 1;
|
377
389
|
/* Create and start the threads. */
|
378
390
|
for(i=0; i<num_timed_behaviors; ++i) {
|
379
391
|
num_run_behaviors += 1;
|
380
392
|
// ++num_active_behaviors;
|
381
|
-
// printf("0
|
393
|
+
// printf("0 num_run_behaviors = %d\n",num_run_behaviors);
|
382
394
|
pthread_create(&timed_behaviors[i]->thread,NULL,
|
383
395
|
&behavior_run,timed_behaviors[i]);
|
384
396
|
}
|
@@ -457,7 +469,6 @@ void hruby_sim_core(char* name, void (*init_vizualizer)(char*),
|
|
457
469
|
* @param delay the delay to wait in fs.
|
458
470
|
* @param behavior the current behavior. */
|
459
471
|
void hw_wait(unsigned long long delay, Behavior behavior) {
|
460
|
-
// printf("!1\n");
|
461
472
|
/* Maybe the thread is to end immediatly. */
|
462
473
|
if (sim_end_flag)
|
463
474
|
pthread_exit(NULL);
|
@@ -465,16 +476,20 @@ void hw_wait(unsigned long long delay, Behavior behavior) {
|
|
465
476
|
pthread_mutex_lock(&hruby_sim_mutex);
|
466
477
|
/* Indicate the behavior finished current execution. */
|
467
478
|
num_active_behaviors -= 1;
|
468
|
-
|
479
|
+
// printf("!!num_active_behaviors=%d\n",num_active_behaviors);
|
480
|
+
// pthread_cond_signal(&hruby_sim_cond);
|
469
481
|
/* Update the behavior's time. */
|
470
482
|
behavior->active_time += delay;
|
471
483
|
pthread_mutex_unlock(&hruby_sim_mutex);
|
484
|
+
pthread_cond_signal(&hruby_sim_cond);
|
472
485
|
/* Wait for being reactivated. */
|
473
486
|
while(behavior->active_time > hruby_sim_time) {
|
474
487
|
pthread_mutex_lock(&hruby_sim_mutex);
|
475
488
|
while(!behaviors_can_run) {
|
489
|
+
// printf("!1\n");
|
476
490
|
// pthread_cond_wait(&compute_cond, &hruby_sim_mutex);
|
477
491
|
pthread_cond_wait(&hruby_beh_cond, &hruby_sim_mutex);
|
492
|
+
// printf("!2\n");
|
478
493
|
}
|
479
494
|
pthread_mutex_unlock(&hruby_sim_mutex);
|
480
495
|
}
|
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.6.
|
4
|
+
version: 2.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lovic Gauthier
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|