Skip to content

Commit 25abcc2

Browse files
committed
feat: Add buffer gate implementation to boolean algebra module
1 parent 42a054f commit 25abcc2

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

boolean_algebra/buffer_gate.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"""
2+
A Buffer Gate is a logic gate in boolean algebra which outputs the same value
3+
as its input. It is used for signal isolation, increasing drive strength, or
4+
introducing propagation delay in digital circuits.
5+
6+
In digital electronics, buffers are essential for:
7+
- Isolating different circuit sections
8+
- Increasing current drive capability
9+
- Preventing signal degradation
10+
- Creating intentional delays in timing circuits
11+
12+
Following is the truth table of a Buffer Gate:
13+
----------------------
14+
| Input | Output |
15+
----------------------
16+
| 0 | 0 |
17+
| 1 | 1 |
18+
----------------------
19+
20+
Refer - https://en.wikipedia.org/wiki/Digital_buffer
21+
"""
22+
23+
24+
def buffer_gate(input_1: int) -> int:
25+
"""
26+
Calculate output of a buffer gate
27+
28+
>>> buffer_gate(0)
29+
0
30+
>>> buffer_gate(1)
31+
1
32+
"""
33+
return int(bool(input_1))
34+
35+
36+
if __name__ == "__main__":
37+
import doctest
38+
39+
doctest.testmod()

0 commit comments

Comments
 (0)