logicuit 0.3.2 → 0.4.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/README.md +24 -0
- data/lib/logicuit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 801a574ecce49e94ff390ae3e648fab2184766c7b3543226fa4d6543146e73f0
|
4
|
+
data.tar.gz: 76187c318d7e1b0852e07612ab3692ab9721213b7fb02383222567b03af6063c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c43600503050602054a4d9c43db01a645cbd019ae97cfc47db6ba17791fb4dbe10c0b98fe67140e5cfd31a2d855634f363ba735c6caad26cf9fea24b5fdfbab2
|
7
|
+
data.tar.gz: 849923282c18476e4cf8dafef57d342f1d8826ea9c5d2814c8d9b4d3d2861cde4a5899b0b4ef1765c0f0212d5bd056e4df0ee3472c88fb7085f42cba4391f325
|
data/README.md
CHANGED
@@ -68,9 +68,13 @@ You can define inputs, outputs, and even a visual diagram — all within a Ruby
|
|
68
68
|
Here is an example of a simple 2-input AND gate:
|
69
69
|
|
70
70
|
```ruby
|
71
|
+
# rbs_inline: enabled
|
72
|
+
|
71
73
|
require "logicuit"
|
72
74
|
|
73
75
|
class MyAndGate < Logicuit::DSL
|
76
|
+
attr_reader :a, :b, :y #: Logicuit::Signals::Signal
|
77
|
+
|
74
78
|
inputs :a, :b
|
75
79
|
|
76
80
|
outputs y: -> { a & b }
|
@@ -133,9 +137,13 @@ This approach gives you more control and expressiveness when building complex ci
|
|
133
137
|
Here's an example of a 2-to-1 multiplexer:
|
134
138
|
|
135
139
|
```ruby
|
140
|
+
# rbs_inline: enabled
|
141
|
+
|
136
142
|
require "logicuit"
|
137
143
|
|
138
144
|
class MyMultiplexer < Logicuit::DSL
|
145
|
+
attr_reader :c0, :c1, :a, :y #: Logicuit::Signals::Signal
|
146
|
+
|
139
147
|
inputs :c0, :c1, :a
|
140
148
|
|
141
149
|
outputs :y
|
@@ -268,9 +276,13 @@ In addition to combinational circuits, Logicuit also supports sequential circuit
|
|
268
276
|
For example, here’s a D flip-flop:
|
269
277
|
|
270
278
|
```ruby
|
279
|
+
# rbs_inline: enabled
|
280
|
+
|
271
281
|
require "logicuit"
|
272
282
|
|
273
283
|
class MyDFlipFlop < Logicuit::DSL
|
284
|
+
attr_reader :d, :q #: Logicuit::Signals::Signal
|
285
|
+
|
274
286
|
inputs :d, clock: :ck
|
275
287
|
|
276
288
|
outputs q: -> { d }
|
@@ -339,9 +351,13 @@ You can build sequential circuits out of smaller components using the `assemblin
|
|
339
351
|
Here’s an example of a 4-bit register that stores its input when the load signal `ld` is not active:
|
340
352
|
|
341
353
|
```ruby
|
354
|
+
# rbs_inline: enabled
|
355
|
+
|
342
356
|
require "logicuit"
|
343
357
|
|
344
358
|
class MyRegister4bit < Logicuit::DSL
|
359
|
+
attr_reader :a, :b, :c, :d, :ld, :qa, :qb, :qc, :qd #: Logicuit::Signals::Signal
|
360
|
+
|
345
361
|
inputs :a, :b, :c, :d, :ld, clock: :ck
|
346
362
|
|
347
363
|
outputs :qa, :qb, :qc, :qd
|
@@ -402,9 +418,13 @@ inputs ..., clock: :ck
|
|
402
418
|
You can attach a truth table to your circuit class using the `#truth_table`. The truth table should be written in Markdown table format.
|
403
419
|
|
404
420
|
```ruby
|
421
|
+
# rbs_inline: enabled
|
422
|
+
|
405
423
|
require "logicuit"
|
406
424
|
|
407
425
|
class MyAndGate < Logicuit::DSL
|
426
|
+
attr_reader :a, :b, :y #: Logicuit::Signals::Signal
|
427
|
+
|
408
428
|
inputs :a, :b
|
409
429
|
|
410
430
|
outputs y: -> { a & b }
|
@@ -445,7 +465,11 @@ Sequential circuits can also be verified using truth tables. When verifying a se
|
|
445
465
|
Here’s an example for a D flip-flop:
|
446
466
|
|
447
467
|
```ruby
|
468
|
+
# rbs_inline: enabled
|
469
|
+
|
448
470
|
class MyDFlipFlop < Logicuit::DSL
|
471
|
+
attr_reader :d, :q #: Logicuit::Signals::Signal
|
472
|
+
|
449
473
|
inputs :d, clock: :ck
|
450
474
|
|
451
475
|
outputs q: -> { d }
|
data/lib/logicuit/version.rb
CHANGED