HDLRuby 3.6.0 → 3.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 705f4b6e4835c910f62b0bced03175761ce62766d976c71123fa8756d7103714
4
- data.tar.gz: e72f192e90d3aad1fa9819988251223108011b3bd9e931d3349ed1dd6d7413f7
3
+ metadata.gz: 86a98906417747050937e8547246ff7ac1cb06e78da82ae4c63385b26dbaa97e
4
+ data.tar.gz: 1096ee8f5bf5ec44409420e6fa60969bf9798f93cec7fa3dd862abc5ac18527f
5
5
  SHA512:
6
- metadata.gz: d92f346ae79abb3a701784861d16c162a134a2f07477657e6976d569d591cbbb38f0bff20da5b2eeff6b32efdc170b539e34f807bba1d58ac770611b1582810f
7
- data.tar.gz: d84037e56a7dacfc3e43a96a8885f1813b2a708be069a128878e3cf8a54602d3a28dd0db7d04fdde976bdde6880afd7b239bd356addd37bc0bcd05abab7a45ee
6
+ metadata.gz: 824c3bf0f96d889913175fccef2d8b854c5da86221e2c70f633f91d104374c6456a1a4958eef0d68da1e3437da8b96b67558b7d563c0cf3c29a6681c8fa8fb1c
7
+ data.tar.gz: 05adeeaa6c1e7a3872d045ad876a295a58548abd610302a94d84f4ac317d84b3bc907adca05daa093cb0d9fa79163836b0d6c5269c9fbcfd83f9cca3dcc42635
data/README.md CHANGED
@@ -17,10 +17,12 @@ hdrcc --get-tuto
17
17
 
18
18
  __What's new__
19
19
 
20
- For HDLRuby version 3.6.0:
20
+ For HDLRuby version 3.6.x:
21
21
 
22
22
  * Added a new element for the GUI board that allows to assign an expression to a signal on the fly while simulating.
23
23
 
24
+ * Added a new slider element for the GUI board (from 3.6.1).
25
+
24
26
  For HDLRuby version 3.5.0:
25
27
 
26
28
  * Added direct support for Verilog HDL files as input to 'hdrcc'.
@@ -2224,9 +2226,11 @@ The list of possible elements is as follows:
2224
2226
 
2225
2227
  * `bt`: represents a set of push buttons, their number is set to match the bit-width of the attached signal.
2226
2228
 
2227
- * `text`: Represents a text input box whose content is interpreted as an expression. The syntax of the expression follows Ruby, and the available variables include the board's display objects. For example, if a set of LEDs is named `leds`, it will be accessible as a variable.
2229
+ * `slider`: represents an horizontal slider.
2230
+
2231
+ * `text`: represents a text input box whose content is interpreted as an expression. The syntax of the expression follows Ruby, and the available variables include the board's display objects. For example, if a set of LEDs is named `leds`, it will be accessible as a variable.
2228
2232
 
2229
- * `hook`: Attaches a signal to the board without displaying. It can be used as a variable in `text` expressions, similar to display objects.
2233
+ * `hook`: attaches a signal to the board without displaying. It can be used as a variable in `text` expressions, similar to display objects.
2230
2234
 
2231
2235
  * `led`: represents a set of LEDs, their number is set to match the bit-width of the attached signal.
2232
2236
 
@@ -15,6 +15,12 @@ system :with_board do
15
15
  [8].inner :counter8
16
16
  signed[8].inner :scounter8
17
17
 
18
+ bit[8][-256].inner :mem
19
+ [8].inner :addr, :din, :dout
20
+
21
+ mem[addr] <= din
22
+ dout <= mem[addr]
23
+
18
24
  # Description of the board.
19
25
  # It is updated at each rising edge of +clk2+.
20
26
  board(:some_board) do
@@ -24,12 +30,16 @@ system :with_board do
24
30
  hook sw_bi: sw_b
25
31
  row
26
32
  sw sw_a: sw_a
27
- sw sw_b: sw_b
33
+ slider sw_b: sw_b
28
34
  led led_z: led_z
29
35
  row
30
36
  text expr: expr
31
37
  digit show: show
32
38
  row
39
+ text addr: addr
40
+ hexa dout: dout
41
+ text din: din
42
+ row
33
43
  digit cnt_d: counter
34
44
  hexa cnt_h: counter
35
45
  digit cnt_s: scounter8
@@ -34,7 +34,7 @@ module HDLRuby::High::Std
34
34
  '<label class="sw"><input type="checkbox" data-bit="' +
35
35
  (self.size-i-1).to_s + '" ' +
36
36
  'onchange="sw_change(this)">' +
37
- '<span class="slider"></span></label>\n'
37
+ '<span class="sw_slider"></span></label>\n'
38
38
  end.join + "</div>\\n"
39
39
  end
40
40
  end
@@ -52,6 +52,22 @@ module HDLRuby::High::Std
52
52
  end.join + "</div>\\n"
53
53
  end
54
54
  end
55
+
56
+ ## Class describing an "analog" slide switch.
57
+ SLIDER = Struct.new(:id, :min, :max, :hwrite) do
58
+ def to_html
59
+ # Prepare the min, max and blank strings.
60
+ min = self.min.to_s
61
+ max = self.max.to_s
62
+ return "<div class=\"sliderset\" id=\"#{self.id}\" data-value=\"0\">\\n" +
63
+ '<span class="name">' + self.hwrite.to_s.chop + '</span>' +
64
+ '<span>&nbsp;&nbsp;</span>' +
65
+ '<input type="range" min="' + min + '" max="' + max +
66
+ '" value="' + min + '" ' +
67
+ 'class="slider" oninput="slider_change(this)">' +
68
+ "</div>\\n"
69
+ end
70
+ end
55
71
 
56
72
  ## Class describing a text-based input.
57
73
  TEXT = Struct.new(:id, :size, :hwrite) do
@@ -272,6 +288,16 @@ Content-Type: text/html
272
288
  height: 40px;
273
289
  }
274
290
 
291
+ .sliderset {
292
+ display: flex;
293
+ flex-direction: row;
294
+ justify-content: center;
295
+ align-items: center;
296
+ margin-left: 8px;
297
+ margin-right: 8px;
298
+ height: 40px;
299
+ }
300
+
275
301
  .ledset {
276
302
  display: flex;
277
303
  flex-direction: row;
@@ -454,7 +480,7 @@ Content-Type: text/html
454
480
  height: 0;
455
481
  }
456
482
 
457
- .slider {
483
+ .sw_slider {
458
484
  position: absolute;
459
485
  cursor: pointer;
460
486
  top: 0;
@@ -467,7 +493,7 @@ Content-Type: text/html
467
493
  border: solid 2px #505050;
468
494
  }
469
495
 
470
- .slider:before {
496
+ .sw_slider:before {
471
497
  position: absolute;
472
498
  content: "";
473
499
  height: 16px;
@@ -479,16 +505,48 @@ Content-Type: text/html
479
505
  transition: .2s;
480
506
  }
481
507
 
482
- input:checked + .slider {
508
+ input:checked + .sw_slider {
483
509
  background-color: yellow;
484
510
  }
485
511
 
486
- input:checked + .slider:before {
512
+ input:checked + .sw_slider:before {
487
513
  -webkit-transform: translateY(-16px);
488
514
  -ms-transform: translateY(-16px);
489
515
  transform: translateY(-16px);
490
516
  }
491
517
 
518
+ .slider {
519
+ -webkit-appearance: none;
520
+ width: 100%;
521
+ height: 25px;
522
+ background-color: #ccc;
523
+ -webkit-transition: .2s;
524
+ transition: .2s;
525
+ border: solid 2px #505050;
526
+ margin: 2px;
527
+ box-shadow: -1px -1px 1px white, 1px 1px 1px #101010;
528
+ -moz-box-shadow: -1px -1px 1px white, 1px 1px 1px #101010;
529
+ -webkit-shadow: -1px -1px 1px white, 1px 1px 1px #101010;
530
+ }
531
+
532
+ .slider::-webkit-slider-thumb {
533
+ -webkit-appearance: none;
534
+ appearance: none;
535
+ width: 25px;
536
+ height: 25px;
537
+ background: black;
538
+ border: solid 2px #505050;
539
+ cursor: pointer;
540
+ }
541
+
542
+ .slider::-moz-range-thumb {
543
+ width: 25px;
544
+ height: 25px;
545
+ background: black;
546
+ border: solid 2px #505050;
547
+ cursor: pointer;
548
+ }
549
+
492
550
  .matrix {
493
551
  font-size: 26px;
494
552
  font-family: "Lucida Console", "Courier New", monospace;
@@ -622,6 +680,7 @@ Content-Type: text/html
622
680
  // Depending of the kind of element.
623
681
  if (element.classList.contains('swset') ||
624
682
  element.classList.contains('btset') ||
683
+ element.classList.contains('sliderset') ||
625
684
  element.classList.contains('textset') ) {
626
685
  // Input element.
627
686
  input_ids.push(element.id);
@@ -664,6 +723,14 @@ Content-Type: text/html
664
723
  // console.log("sw value=" + swset.dataset.value);
665
724
  }
666
725
 
726
+ // Handler of slider change.
727
+ function slider_change(slider) {
728
+ // Get the set holding slider.
729
+ const sliderset = slider.parentElement;
730
+ sliderset.dataset.value = slider.value;
731
+ // console.log("slider value=" + sliderset.dataset.value);
732
+ }
733
+
667
734
  // Set the aspect of a button to clicked.
668
735
  function bt_on(bt) {
669
736
  bt.innerHTML = '<i class="bt_on"></i>';
@@ -979,6 +1046,27 @@ HTMLRESPONSE
979
1046
  @elements << BT.new(@elements.size,hport[1].type.width,:"#{hport[0]}=")
980
1047
  end
981
1048
 
1049
+ # Add a new slider element attached to HDLRuby port +hport+
1050
+ def slider(hport)
1051
+ if !hport.is_a?(Hash) or hport.size != 1 then
1052
+ raise UIError.new("Malformed HDLRuby port declaration: #{hport}")
1053
+ end
1054
+ # Create the HDLRuby program port.
1055
+ @program.outport(hport)
1056
+ hport = hport.first
1057
+ # Compute the min and max values.
1058
+ width = hport[1].type.width
1059
+ if hport[1].type.signed? then
1060
+ min = -2**(width-1)
1061
+ max = 2**(width-1) - 1
1062
+ else
1063
+ min = 0
1064
+ max = 2**width - 1
1065
+ end
1066
+ # Create the UI component.
1067
+ @elements << SLIDER.new(@elements.size,min,max,:"#{hport[0]}=")
1068
+ end
1069
+
982
1070
  # Add a new text input element attached to HDLRuby port +hport+
983
1071
  def text(hport)
984
1072
  if !hport.is_a?(Hash) or hport.size != 1 then
@@ -1111,9 +1199,6 @@ HTMLRESPONSE
1111
1199
  val = "0" unless val
1112
1200
  val = val.gsub("%20"," ")
1113
1201
  # Replace the names by the corresponding ports read result.
1114
- # val = val.gsub(/([^0-9\.A-Z][_a-z][_a-zA-Z0-9]*)/) do |str|
1115
- # RubyHDL.send(Regexp.last_match[1]).to_s rescue 0
1116
- # end
1117
1202
  val = val.gsub(/([\._a-zA-Z0-9]+)/) do |str|
1118
1203
  if str[0] >= "a" && str[0] <= "z" then
1119
1204
  # Variable identifier, process it if recognized.
@@ -1130,6 +1215,7 @@ HTMLRESPONSE
1130
1215
  $SAFE = 2
1131
1216
  res = eval(val).to_i
1132
1217
  rescue SyntaxError => se
1218
+ rescue StandardError => se
1133
1219
  end
1134
1220
  $SAFE = safe
1135
1221
  return res
@@ -1,3 +1,3 @@
1
1
  module HDLRuby
2
- VERSION = "3.6.0"
2
+ VERSION = "3.6.1"
3
3
  end
@@ -3047,9 +3047,11 @@ end
3047
3047
  </li>
3048
3048
  <li><p><code>led</code>: represents a set of LEDs, their number is set to match the bit-width of the attached signal.</p>
3049
3049
  </li>
3050
- <li><p><code>text</code>: Represents a text input box whose content is interpreted as an expression. The syntax of the expression follows Ruby, and the available variables include the board's display objects. For example, if a set of LEDs is named <code>leds</code>, it will be accessible as a variable.</p>
3050
+ <li><p><code>slider</code>: represents an horizontal slider.</p>
3051
3051
  </li>
3052
- <li><p><code>hook</code>: Attaches a signal to the board without displaying. It can be used as a variable in <code>text</code> expressions, similar to display objects.</p>
3052
+ <li><p><code>text</code>: represents a text input box whose content is interpreted as an expression. The syntax of the expression follows Ruby, and the available variables include the board's display objects. For example, if a set of LEDs is named <code>leds</code>, it will be accessible as a variable.</p>
3053
+ </li>
3054
+ <li><p><code>hook</code>: attaches a signal to the board without displaying. It can be used as a variable in <code>text</code> expressions, similar to display objects.</p>
3053
3055
  </li>
3054
3056
  <li><p><code>hexa</code>: represents a hexadecimal number display, its character width is set to match the width of the largest possible value of the attached signal.</p>
3055
3057
  </li>
data/tuto/tutorial_sw.md CHANGED
@@ -3750,9 +3750,11 @@ And the comprise the following:
3750
3750
 
3751
3751
  * `led`: represents a set of LEDs, their number is set to match the bit-width of the attached signal.
3752
3752
 
3753
- * `text`: Represents a text input box whose content is interpreted as an expression. The syntax of the expression follows Ruby, and the available variables include the board's display objects. For example, if a set of LEDs is named `leds`, it will be accessible as a variable.
3753
+ * `slider`: represents an horizontal slider.
3754
3754
 
3755
- * `hook`: Attaches a signal to the board without displaying. It can be used as a variable in `text` expressions, similar to display objects.
3755
+ * `text`: represents a text input box whose content is interpreted as an expression. The syntax of the expression follows Ruby, and the available variables include the board's display objects. For example, if a set of LEDs is named `leds`, it will be accessible as a variable.
3756
+
3757
+ * `hook`: attaches a signal to the board without displaying. It can be used as a variable in `text` expressions, similar to display objects.
3756
3758
 
3757
3759
  * `hexa`: represents a hexadecimal number display, its character width is set to match the width of the largest possible value of the attached signal.
3758
3760
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: HDLRuby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.0
4
+ version: 3.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lovic Gauthier
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-01-05 00:00:00.000000000 Z
10
+ date: 2025-01-09 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: bundler