Fixed a bug in Am2900; created dlatch8/80; relayouted some components
[Mograsim.git] / net.mograsim.logic.core / src / net / mograsim / logic / core / types / LogicType.java
1 package net.mograsim.logic.core.types;
2
3 /**
4  * Interface for types that support the basic logic operations
5  *
6  * @author Christian Femers
7  *
8  * @param <T> the logic type itself, to make the operations closed in T
9  * @param <S> the operand type, may be the same as T, see {@link StrictLogicType}
10  */
11 public interface LogicType<T extends LogicType<T, S>, S>
12 {
13         /**
14          * Determines the result when two signals meet each other directly, also called resolution (IEEE 1164)
15          * 
16          * For example:
17          * 
18          * <pre>
19          * 0 joined 0 == 0
20          * 1 joined 0 == X
21          * 0 joined 1 == X
22          * 1 joined 1 == 1
23          * </pre>
24          * 
25          * @param t the second logic signal
26          * @return the resulting value
27          * @author Christian Femers
28          */
29         T join(S t);
30
31         /**
32          * Classical logic AND
33          * 
34          * For example:
35          * 
36          * <pre>
37          * 0 AND 0 == 0
38          * 1 AND 0 == 0
39          * 0 AND 1 == 0
40          * 1 AND 1 == 1
41          * </pre>
42          * 
43          * @param t the second logic signal
44          * @return the resulting value
45          * @author Christian Femers
46          */
47         T and(S t);
48
49         /**
50          * Classical logic OR
51          *
52          * For example:
53          * 
54          * <pre>
55          * 0 OR 0 == 0
56          * 1 OR 0 == 1
57          * 0 OR 1 == 1
58          * 1 OR 1 == 1
59          * </pre>
60          * 
61          * @param t the second logic signal
62          * @return the resulting value
63          * @author Christian Femers
64          */
65         T or(S t);
66
67         /**
68          * Classical logic XOR (exclusive OR)
69          * 
70          * For example:
71          * 
72          * <pre>
73          * 0 XOR 0 == 0
74          * 1 XOR 0 == 1
75          * 0 XOR 1 == 1
76          * 1 XOR 1 == 0
77          * </pre>
78          * 
79          * @param t the second logic signal
80          * @return the resulting value
81          * @author Christian Femers
82          */
83         T xor(S t);
84
85         /**
86          * Classical logic NOT (logical negation)
87          * 
88          * For example:
89          * 
90          * <pre>
91          * NOT 0 == 1
92          * NOT 1 == 0
93          * </pre>
94          * 
95          * @return the resulting value
96          * @author Christian Femers
97          */
98         T not();
99
100         /**
101          * {@link #and(Object) AND} and then {@link #not() NOT}
102          * 
103          * @author Christian Femers
104          */
105         default T nand(S t)
106         {
107                 return and(t).not();
108         }
109
110         /**
111          * {@link #or(Object) OR} and then {@link #not() NOT}
112          * 
113          * @author Christian Femers
114          */
115         default T nor(S t)
116         {
117                 return or(t).not();
118         }
119
120         /**
121          * {@link #xor(Object) XOR} and then {@link #not() NOT}<br>
122          * Used to determine equality (alias parity, consistency)
123          * 
124          * @author Christian Femers
125          */
126         default T xnor(S t)
127         {
128                 return xor(t).not();
129         }
130 }