è«çåè·¯(Logic Circuit)
è«çåè·¯ã®å¾©ç¿ãããã®ã§
ã³ã³ãã¥ã¼ã¿ãµã¤ã¨ã³ã¹ã§å¦ã¶è«çåè·¯ã¨ãã®è¨è¨
- ä½è : æ´å±±æ½
- åºç社/ã¡ã¼ã«ã¼: è¿ä»£ç§å¦ç¤¾
- çºå£²æ¥: 1999/09
- ã¡ãã£ã¢: åè¡æ¬
- è³¼å ¥: 2人 ã¯ãªãã¯: 2å
- ãã®ååãå«ãããã°ãè¦ã
è«ç代æ°ï¼Logical Algebraï¼
ãã¼ã«é å(Boolean domain)
:ã\(\mathcal{B} = {0, 1}\)å¦å®(NOT/negation/inversion)
:ã\(\overline{X},\; \lnot X\)è«çç©/åæ¥/é£è¨(AND/conjunction)
:ã\(X \cdot Y,\; X \land Y\)è«çç©/é¢æ¥/é¸è¨(OR/disjunction)
:ã\(X + Y,\; X \lor Y\)æä»çè«çå(XOR/EOR/EX-OR/exclusive or[disjunction])
:ã\(X \oplus Y\)- \(X\oplus Y = \overline{X}\cdot Y + X\cdot \overline{Y} = (X + Y)(\overline{X} + \overline{Y})\)ã
- ï¼ï¼å¤æ°å¤ãåããªã0, ç°ãªããªã1ã\(X \neq Y\)
å¦å®è«çå(NAND)
:ã\(X \mid Y,\; \overline{X \cdot Y},\; \lnot (X \land Y) \) ãï¼\(\mid\): Sheffer-Strokeå¦å®è«çå(NOR)
:ã\(X \downarrow Y,\; \overline{X + Y},\; \lnot (X \lor Y) \) ãï¼\(\downarrow\): Pierce-Arrow
\(X\) | \(\overline{X}\) | |
---|---|---|
0 | 1 | |
1 | 0 |
\(X\) | \(Y\) | \(X \cdot Y\) | \(X + Y\) | \(X \oplus Y\) | |
---|---|---|---|---|---|
0 | 0 | 0 | 0 | 0 | |
0 | 1 | 0 | 1 | 1 | |
1 | 0 | 0 | 1 | 1 | |
1 | 1 | 1 | 1 | 0 |
諸å®ç
å対(dual)
:ãããè«çå¼\(L\)ã«ããã¦ãANDã¨OR, 0ã¨1ããå ¥ãæ¿ãã¦ã§ããè«çå¼ãè«çå¼\(L\)ãæç«ãã¦ããæãããã¨å対ãªè«çå¼ \(L^{d}\)ãæç«ãããã¨ãå対æ§(duality)ãããã¨è¨ãã- \(P=Q \Rightarrow P^{d}=Q^{d}\)
ï¼\(\ast\)ã¯AND ã¾ã㯠ORæ¼ç®åã¨ãã
ï¼éå¦å®(double negative elimination)
: \(\overline{\overline{X}} = X\)交æå(commutative law)
:ã\(X \ast Y = Y \ast X\)çµåå(associative law)
:ã\[\begin{cases}(X \ast Y) \ast Z = X \ast (Y \ast Z) \\(X\oplus Y)\oplus Z = X\oplus (Y\oplus Z)\end{cases}\]åé å(distribution law)
: \[\begin{cases}X \cdot (Y + Z) = (X \cdot Y) + (X \cdot Z) \\X + (Y \cdot Z) = (X + Y) \cdot (X + Z) \\X \cdot (Y\oplus Z) = (X\cdot Y)\oplus (X\cdot Z)\end{cases}\]ç¸è£å(complement law)
: \[\begin{cases}X + \overline{X} = 1 \ X \cdot \overline{X} = 0\end{cases}\]åªçå(idempotent law)
:ã\(X \ast X \ast \cdots \ast X = X\)å¸åå(absorption law)
:ã\(X = X(Y+\overline{Y})\)ã使ã£ã¦æ¶ã㨠\[ \begin{cases} X + (X \cdot Y) = X \\X \cdot (X + Y) = X \end{cases} \]De Morganã®æ³å(De Morgan's laws)
:ã\[ \begin{cases} \overline{X_{1} \cdot X_{2} \cdot \cdots \cdot X_{n}} = \overline{X_{1}} + \overline{X_{2}} + \cdots + \overline{X_{n}} \\\overline{X_{1} + X_{2} + \cdots + X_{n}} = \overline{X_{1}} \cdot \overline{X_{2}} \cdot \cdots \cdot \overline{X_{n}} \end{cases} \]
è«çé¢æ°(Logical Function)
\[L = f(X_{1}, \overline{X_{1}}, X_{2}, \overline{X_{2}}, \cdots , X_{n}, \overline{X_{n}}, \cdot ,+) \\\overline{L} = f(\overline{X_{1}}, X_{1}, \overline{X_{2}}, X_{2}, \cdots , \overline{X_{n}}, X_{n}, + ,\cdot )\]
å対é¢æ°(dual function)
:ãè«çé¢æ°\(f\)ã®ãã¹ã¦ã®å¤æ°ã®NOTãã¨ããé¢æ°å ¨ä½ã«NOTãã¨ã£ãè«çé¢æ°ã \[ \begin{eqnarray} f^{d}&=&\overline{f(\overline{X_{1}}, X_{1}, \overline{X_{2}}, X_{2}, \cdots , \overline{X_{n}}, X_{n}, \cdot, + )} \\&=& f(X_{1}, \overline{X_{1}}, X_{2}, \overline{X_{2}}, \cdots , X_{n}, \overline{X_{n}}, +, \cdot) \because \text{De Margan’s laws} \end{eqnarray}\]èªå·±å対é¢æ°(selfâdual function)
:ã\(f=f^{d}\)ã¨ãªãè«çé¢æ°ã\(x_{i}\)-residue:ã\(f(x_{1}, x_{2}, \cdots ,x_{n})\)ã«\(x_{i}=1\)ãå ¥ãããã®ã\(f_{x_{i}}, f_{i}(1)\)ã¨ãã£ã表è¨ã使ãããã \[f_{x_{i}} = f(x_{1}, \cdots, x_{i-1}, 1, x_{i+1}, \cdots, x_{n})\]
\(\overline{x_{i}}\)-residue:ã\(f(x_{1}, x_{2}, \cdots ,x_{n})\)ã«\(x_{i}=0\)ãå ¥ãããã®ã\(f_{\overline{x_{i}}}, f_{i}(0)\)ã¨ãã£ã表è¨ã使ãããã \[f_{\overline{x_{i}}} = f(x_{1}, \cdots, x_{i-1}, 0, x_{i+1}, \cdots, x_{n})\]
ãã¼ã«å¾®å(Boolean difference[derivative])
: åè1 åè2- \[\frac{\partial f}{\partial x_{i}} = f_{x_{i}} \oplus f_{\overline{x_{i}}}\]ãï¼\(x_{i}\)ã®å¤ã®å¤åã«ãã\(f\)ã®å¤ãå¤åããæ¡ä»¶
- \[\frac{\partial}{\partial x_{j}}\left(\frac{\partial f}{\partial x_{i}}\right) = f_{\overline{x_{i}}\overline{x_{j}}} \oplus f_{x_{i}\overline{x_{j}}} \oplus f_{\overline{x_{i}}x_{j}} \oplus f_{x_{i}x_{j}}\] ï¼å¾®åæ¼ç®ã¯é åºã®å ¥ãæ¿ãå¯è½ã
ãªãã©ã«(literal)
:ãè«çå¤æ°ãã®ãã®ããããã¯ããã®å¤æ°ã®å¦å®(NOT)ã- \(X\)ã®ãªãã©ã«ã\(\tilde{X}^{l}\)ã¨è¡¨ãã\(\tilde{X}^{1}=X, \tilde{X}^{0} = \overline{X}\)ã¨ããã
å±éå®ç(expansion theorem)
:ã\[ \begin{cases} X_{i} \cdot f(X_{1},X_{2}, \cdots ,X_{n}) = X_{i} \cdot f_{X_{i}} \\X_{i} + f(X_{1}, X_{2}, \cdots ,X_{n}) = X_{i} + f_{\overline{X_{i}}} \end{cases}\]Shannonã®å±éå®ç(Shannonâs expansion theorem)
:ã\[\begin{eqnarray} f(X_{1}, \cdots ,X_{i}, \cdots ,X_{n}) &=& (X_{i} \cdot f_{X_{i}}) + (\overline{X_{i}} \cdot f_{\overline{X_{i}}}) \\&=& (X_{i} + f_{\overline{X_{i}}}) \cdot (\overline{X_{i}} + f_{X_{i}}) \end{eqnarray}\]
æ¨æºå½¢(Normal[Canonical] Form)
\(f(X_{1}, X_{2}, \cdots ,X_{n})\)ã®åå¤æ°ã«ã¤ãã¦Shannnonã®å±éå®çãé©ç¨ãã¦ããã¨ã\(2^{n}\)é ã®ç©åå½¢ã¾ãã¯åç©å½¢ãå¾ãã
\[ \begin{eqnarray} f(X_{1}, X_{2}, \cdots , X_{n}) = \overline{X_{1}} \cdot \overline{X_{2}} \cdot \cdots \cdot \overline{X_{n}} &\cdot& f(0, 0, \cdots , 0) \\+ X_{1} \cdot \overline{X_{2}} \cdot \cdots \cdot \overline{X_{n}} &\cdot& f(1, 0, \cdots , 0) \\+ \overline{X_{1}} \cdot X_{2} \cdot \cdots \cdot \overline{X_{n}} &\cdot& f(0, 1, \cdots , 0) \\ &\vdots& \\+ X_{1} \cdot X_{2} \cdot \cdots \cdot X_{n} &\cdot& f(1, 1, \cdots , 1) \\= (\overline{X_{1}} + \overline{X_{2}} + \cdots + \overline{X_{n}} &+& f(1, 1, \cdots , 1)) \\\cdot (X_{1} + \overline{X_{2}} + \cdots + \overline{X_{n}} &+& f(0, 1, \cdots , 1)) \\\cdot (\overline{X_{1}} + X_{2} + \cdots + \overline{X_{n}} &+& f(1, 0, \cdots , 1)) \\ &\vdots& \\\cdot (X_{1} + X_{2} + \cdots + X_{n} &+& f(0, 0, \cdots , 0)) \end{eqnarray} \]
æå°é /極å°é (minterm)
:ã\(\tilde{X_{1}}^{l_{1}} \cdot \tilde{X_{2}}^{l_{2}} \cdot \cdots \cdot \tilde{X_{n}}^{l_{n}}\)æ大é /極大é (maxterm)
:ã\(\tilde{X_{1}}^{\overline{l_{1}}} + \tilde{X_{2}}^{\overline{l_{2}}} + \cdots + \tilde{X_{n}}^{\overline{l_{n}}}\)
ä¾) \(f(X,Y)\)ã®æå°é ãæ大é ã¯ããããï¼é ããã
\(\overline{X} \ast \overline{Y}, X \ast \overline{Y}, \overline{X} \ast Y, X \ast Y\)ãï¼ANDãªãæå°é ãORãªãæ大é
(主)å æ³æ¨æºå½¢/é¸è¨æ¨æºå½¢(DNF: (principal) disjunctive normal[canonical] form)
:- \(f(l_{1}, l_{2}, \cdots, l_{n})=1\)ã¨ãªããªãã©ã«ã®çµã«ããæå°é \(\tilde{X_{1}}^{l_{1}} \cdot \tilde{X_{2}}^{l_{2}} \cdot \cdots \cdot \tilde{X_{n}}^{l_{n}}\)ã®ãã¹ã¦ãORã§çµãã ãã®
(主)ä¹æ³æ¨æºå½¢/é£è¨æ¨æºå½¢(CNF: (principal) conjunctive normal[canonical] form)
:ã- \(f(l_{1}, l_{2}, \cdots, l_{n})=0\)ã¨ãªããªãã©ã«ã®çµã«ããæ大é \(\left( \tilde{X_{1}}^{\overline{l_{1}}} + \tilde{X_{2}}^{\overline{l_{2}}} + \cdots + \tilde{X_{n}}^{\overline{l_{n}}}\right) \)ã®ãã¹ã¦ãANDã§çµãã ãã®
ã©ã®ãããªå½¢å¼ã®è«çé¢æ°ãå¯ä¸ã®å æ³æ¨æºå½¢ã¨ä¹æ³æ¨æºå½¢ãæã¤ã
ä¸è½è«çé¢æ°éå(universal function set)
:ããã®è¦ç´ ã§ããè«çé¢æ°ãçµã¿åãããã¨ãä»»æã®è«çé¢æ°ã表ç¾ã§ããè«çé¢æ°ã®éåã次ã®éåã¯ä¸è½è«çé¢æ°éåã- AND/ORå½¢å¼:ã\(U_{0} = {NOT, AND, OR}\)
- (NOT-)ANDå½¢å¼:ã\(U_{1} = {NOT, AND} \because \text{De Morgan’s laws}\)
- (NOT-)ANDå½¢å¼:ã\(U_{2} = {NOT, OR} \because \text{De Morgan’s laws}\)
- NANDå½¢å¼:ã\(U_{3} = {NAND}\)
- \[\begin{cases}\overline{X} &=& \overline{X\cdot X} = X\mid X \\X\cdot Y &=& \overline{\overline{X \cdot Y}} = \overline{X\mid Y} = (X\mid Y)\mid (X\mid Y) \\X + Y &=& \overline{\overline{X} \cdot \overline{Y}} = \overline{X}\mid \overline{Y} = (X\mid X)\mid (Y\mid Y)\end{cases} \]
- \[\begin{eqnarray} X \oplus Y &=& X\;\overline{Y} + \overline{X}\;Y + X\;\overline{X} + Y\;\overline{Y} = (X + Y)(\overline{X} + \overline{Y}) \\&=& (X + Y)(X\mid Y) = X\cdot (X\mid Y) + Y\cdot (X\mid Y) \\&=& (X\mid (X\mid Y))\mid (Y\mid (X\mid Y))\end{eqnarray}\]
- NORå½¢å¼:ã\(U_{4} = {NOR}\)
- \[\begin{cases}\overline{X} &=& \overline{X + X} = X\downarrow X \\X\cdot Y &=& \overline{\overline{X} + \overline{Y}} = \overline{X}\downarrow \overline{Y} = (X\downarrow X)\downarrow (Y\downarrow Y) \\X + Y &=& \overline{\overline{X + Y}} = \overline{X \downarrow Y} = (X\downarrow Y)\downarrow (X\downarrow Y)\end{cases}\]
ä¸è½è«çé¢æ°(universal function)
:ãä¸è½è«çé¢æ°éåã®è¦ç´ ã§ããè«çé¢æ°ãå å«
:ãããè«çç©é \(Q\)ã®å¤ã1ã«ããå¤æ°å¤ã®çµã¿åãããã¹ã¦ã«å¯¾ãã¦ãå¥ã®è«çç©é \(P\)ã1ã«ãªãã¨ãã\(P\)ã¯\(Q\)ãå å«ããã¨ããã主é (prime implicant)
:ãæå°é ã\(t_{i}\)ã¨ããã¨ããå æ³æ¨æºå½¢ã¯\(f = t_{1} + t_{2} + \cdots + t_{n}\; (i=1,2,\cdots n)\)ã¨è¡¨ãã\(t_{i}\)ã\(t_{j}\; (i\neq j)\)ã®ãããã«ãå å«ãããªãã¨ã¨ã,\(t_{i}\)ã主é ã¨ããã- ä¾) \(f = X\,\overline{Z} + X\;Y + X\;\overline{Y}\;\overline{Z}\)ã®ãã¡ã主é ã¯\(X\,\overline{Z}\)ã¨\(X\;Y\)ã\(X\;\overline{Y}\;\overline{Z}\)ã¯\(X\,\overline{Z}\)ã«å å«ãããã®ã§ä¸»é ã§ã¯ãªãã
æå°ç©åå½¢
:ã主é ã ãã§æ§æããã主é ã®ç·æ°ãæå°ã®ç©åå½¢ãå¿ é (主)é (essential prime implicant)
:ãå æ³æ¨æºå½¢ãæ§æããæå°é ãå å«ããå¯ä¸ã®ä¸»é ãç¹ç°æå°é (singular minterm)
:ãå¿ é 主é ã«å å«ãããæå°é ã
è«çé¢æ°ã®è¡¨ç¾
Grayã³ã¼ã(Gray code)/交çªäºé²ç¬¦å·(reflected binary code)
:ãåå¾ã«é£æ¥ãã符å·éã®Hammingè·é¢(Hamming distance)ã1ã®ç¬¦å·- ï¼é²æ°ã®Grayã³ã¼ãã®ä½ãæ¹ï¼1bitå³è«çã·ãããã¦å ã®æ°ã¨ã®æä»çè«çåãã¨ã
extension Int { //swift 3.0 var grayCode: Int { return self^(self>>1) } func biaryFormat(bit n: Int) -> String { return [Int](0..<n).map { x in (self>>(n-x-1))&1 == 0 ? "0" : "1" }.joined() } } for n in 1...4 { print([Int](0..<(1<<n)).map { x in x.grayCode.biaryFormat(bit: n) }) } //["0", "1"] //["00", "01", "11", "10"] //["000", "001", "011", "010", "110", "111", "101", "100"] //["0000", "0001", "0011", "0010", "0110", "0111", "0101", "0100", "1100", "1101", "1111", "1110", "1010", "1011", "1001", "1000"]
ãã³ãã±ã¢/ä¸å®å ¨å®ç¾©/çµã¿åããç¦æ¢(don't care)
:ãè«çé¢æ°ã®å¤æ°å¤ã®çµã¿ã«å¯¾ãã¦ãè«çé¢æ°å¤ãå®ç¾©ããã¦ããªããã¨
n次å ç«æ¹ä½(N-Cube)/è¶ ç«æ¹ä½(Hypercube)
ï¼å決å®å³(BDD;Binary Decision Diagram)
Karnaughå³(Karnaugh Map)
ççå¤ã®1ã¾ãã¯ãã³ãã±ã¢\(\phi\)ã®é¨åã§å æ³æ¨æºå½¢ãä½ããã¨ãã§ããé¢ç©ã2ã®ç´¯ä¹ã«ãªãé·æ¹å½¢ãã°ã«ã¼ãã³ã°ããã¨ãã°ã«ã¼ãã³ã°ããé ã®ãã¡å ±éãªãªãã©ã«ã ããæ®ãããããå¿ é 主é ã¨ãªããæå°ç©åå½¢ãä½ããã
\(\begin{eqnarray}f(A,B,C,D) &=& \overline{A}\,B\,\overline{C}\,\overline{D} + A\,B\,\overline{C}\,\overline{D} + A\,\overline{B}\,\overline{C}\,\overline{D} + A\,B\,\overline{C}\,D + A\,\overline{B}\,\overline{C}\,D + A\,B\,C\,\overline{D} \\&=&B\,\overline{C}\,\overline{D}+A\,\overline{C}+A\,B\,\overline{D} \end{eqnarray}\)
çµã¿åããåè·¯(Combinational Circuit)
ããæå»ã®åºåä¿¡å·å¤ããã®æå»ã®å ¥åä¿¡å·å¤ã ãã§æ±ºå®ããè«çåè·¯ã
段æ°
:ãè«çåè·¯ã®å ¥å端åããåºå端åã«è³ãã¾ã§ã«ééããè«çã²ã¼ãæ°ãï¼æ®µè«çæå°å
:ãæå°ç©åå½¢ã«ãã¦æ®µæ°ã2ã«ãããã¨ãå¤æ®µè«çæå°å
:ãè«çåè·¯ãå¤æ®µã«ãªã(æéãµã¤ãºãå¢å¤§ãã)ãã¨ã許ããã¨ãåæã¨ããè«çåè·¯ã®ç©ºéæé©åãå³ããã¨ããã¡ã¯ã¿ãªã³ã°(factoring)
:ãåé åãç¨ãã¦ãè«çå¼ããå ±éé ããããåºãæä½ã \[\begin{eqnarray}f = f(W, X, Y, Z) &=& W\;X\;Z + \overline{W}\;\overline{X}\;Y+W\;X\;Y + \overline{W}\;\overline{X}\;Z \\&=& f_{1}\cdot f_{2} = (W\;X + \overline{W}\;\overline{X})\cdot(X + Z)\end{eqnarray}\]ãã¯ããã¸ãããã³ã°(technology mapping)
:ãä¸ããããè«çé¢æ°ã\(U_{0}, U_{1}, U_{2}, U_{3}, U_{4}\)ã®ããããã®å½¢å¼ã®è«çé¢æ°ã¨ãã¦è¨è¨ãããMILè¨å·
AND
OR
NOT
NAND
NOR
XOR
Q-Mæ³(Quine-McCluskey Algorithm /The Method of Prime Implicants)
ãã«ããã¬ã¯ãµ(Multiplexor)/ã»ã¬ã¯ã¿(Selector)
\(2^{n} = m\)åã®å ¥å\(D_{1}, D_{2}, \cdots ,D_{m}\)ããã\(n\)åã®é¸æå ¥å\(S_{1}, S_{2}, \cdots ,S_{n}\)ã«ãã£ã¦å¯¾å¿ããï¼ã¤ãé¸ãã§ãåºå\(Q\)ã«åãæ¿ããæ©è½ãæã¤çµã¿åããåè·¯ã\(m\times 1\)ãã«ããã¬ã¯ãµã¨ããã
ä¾) \(4\times 1\)ãã«ããã¬ã¯ãµ: \[Q = \overline{S_{1}}\;\overline{S_{0}}\;D_{0} + \overline{S_{1}}\;S_{0}\;D_{1} + S_{1}\;\overline{S_{0}}\;D_{2} + S_{1}\;S_{0}\;D_{3}\]
\(S_{1}\) | \(S_{0}\) | \(Q\) | |
---|---|---|---|
0 | 0 | \(D_{0}\) | |
0 | 1 | \(D_{1}\) | |
1 | 0 | \(D_{2}\) | |
1 | 1 | \(D_{3}\) |
ããã«ããã¬ã¯ãµ(Demultiplexor)
\(n\)æ¬ã®é¸æå ¥å\(S_{1}, S_{2}, \cdots ,S_{n}\)ã«ãã£ã¦\(2^{n}=m\)åã®åºå\(Q_{1}, Q_{2}, \cdots ,Q_{m}\)ãã対å¿ããï¼ã¤ãé¸ãã§ãããã ãã«å ¥åãåé ããæ©è½ãæã¤çµã¿åããåè·¯ã\(1\times m\)ã§ããã«ããã¬ã¯ãµã¨ããã
ä¾) \(1\times 4\)ããã«ããã¬ã¯ãµ \[\begin{cases}Q_{0} = \overline{S_{1}}\;\overline{S_{0}}\;D \\Q_{1} = \overline{S_{1}}\;S_{0}\;D \\Q_{2} = S_{1}\;\overline{S_{0}}\;D \\Q_{3} = S_{1}\;S_{0}\;D\end{cases}\]
\(S_{1}\) | \(S_{0}\) | \(Q_{3}\) | \(Q_{2}\) | \(Q_{1}\) | \(Q_{0}\) | |
---|---|---|---|---|---|---|
0 | 0 | 0 | 0 | 0 | \(D\) | |
0 | 1 | 0 | 0 | \(D\) | 0 | |
1 | 0 | 0 | \(D\) | 0 | 0 | |
1 | 1 | \(D\) | 0 | 0 | 0 |
ãã³ã¼ã(Decoder)
\(n\)å ¥åã¨\(2^{n}=m\)åºåã«ãã³ã¼ãããçµã¿åããåè·¯ã\(n\times m\)ãã³ã¼ãã¨ããã
ä¾) \(2\times 4\)ãã³ã¼ã \[\begin{cases}Q_{0} = \overline{D_{1}}\;\overline{D_{0}} \\Q_{1} = \overline{D_{1}}\;D_{0}\ \\Q_{2} = D_{1}\;\overline{D_{0}}\ \\Q_{3} = D_{1}\;D_{0}\end{cases}\]
\(D_{1}\) | \(D_{0}\) | \(Q_{3}\) | \(Q_{2}\) | \(Q_{1}\) | \(Q_{0}\) | |
---|---|---|---|---|---|---|
0 | 0 | 0 | 0 | 0 | 1 | |
0 | 1 | 0 | 0 | 1 | 0 | |
1 | 0 | 0 | 1 | 0 | 0 | |
1 | 1 | 1 | 0 | 0 | 0 |
ã¨ã³ã³ã¼ã(Encoder)
ãã³ã¼ãã®å ¥åã¨åºåãéã«ãããã®ã\(2^{n} = m\)å ¥åã\(n\)åºåã®ã¨ã³ã³ã¼ãã\(m\times n\)ã¨ã³ã³ã¼ãã¨ãããã
\(D_{3}\) | \(D_{2}\) | \(D_{1}\) | \(D_{0}\) | \(Q_{1}\) | \(Q_{0}\) | |
---|---|---|---|---|---|---|
0 | 0 | 0 | 1 | 0 | 0 | |
0 | 0 | 1 | 0 | 0 | 1 | |
0 | 1 | 0 | 0 | 1 | 0 | |
1 | 0 | 0 | 0 | 1 | 1 |
ï¼ä¸ã«ç¡ãçµã¿åããã®å ¥åã®å ´åãåºåã¯ãã³ãã±ã¢
åªå é ä½ä»ãã¨ã³ã³ã¼ã(priority encoder)
:ãå ¥åã«åªå é ä½ãä»ãããã³ãã±ã¢ãæ¸ãããã¨ã³ã³ã¼ã
ä¾) \(4\times 2\)ã¨ã³ã³ã¼ã \[\begin{cases}Q_{0} = D_{1}\;\overline{D_{2}} + D_{3} \\Q_{1} = D_{2} + D_{3}\end{cases}\]
\(D_{3}\) | \(D_{2}\) | \(D_{1}\) | \(D_{0}\) | \(Q_{1}\) | \(Q_{0}\) | |
---|---|---|---|---|---|---|
0 | 0 | 0 | 0 | \(\phi\) | \(\phi\) | |
0 | 0 | 0 | 1 | 0 | 0 | |
0 | 0 | 1 | 0 | 0 | 1 | |
0 | 0 | 1 | 1 | 0 | 1 | |
0 | 1 | 0 | 0 | 1 | 0 | |
0 | 1 | 0 | 1 | 1 | 0 | |
0 | 1 | 1 | 0 | 1 | 0 | |
0 | 1 | 1 | 1 | 1 | 0 | |
1 | 0 | 0 | 0 | 1 | 1 | |
1 | 0 | 0 | 1 | 1 | 1 | |
1 | 0 | 1 | 0 | 1 | 1 | |
1 | 0 | 1 | 1 | 1 | 1 | |
1 | 1 | 0 | 0 | 1 | 1 | |
1 | 1 | 0 | 1 | 1 | 1 | |
1 | 1 | 1 | 0 | 1 | 1 | |
1 | 1 | 1 | 1 | 1 | 1 |
å ç®å¨(Adder)
åå ç®å¨(Half Adder)
ä¸ä½ãããããã®æ¡ä¸ããå ¥åãèæ ®ããªãï¼é²æ°ï¼æ¡ã®å ç®åè·¯ã \[\begin{cases}S = X\;\overline{Y} + \overline{X}\;Y = X\oplus Y \\C = X\;Y\end{cases}\; \\(S, C) = f_{HA}(X, Y)\]
å ¨å ç®å¨(Full Adder)
åå ç®å¨ã«ä¸ä½ãããããã®æ¡ä¸ãå ¥å\(I\)ã¨ä¸ä½ãããã¸ã®æ¡ä¸ãåºå\(C\)ãä»å ãããå ç®åè·¯ã
\[\begin{cases}S = \overline{X}\;Y\;\overline{C_{in}} + X\;\overline{Y}\;\overline{C_{in}} + \overline{X}\;\overline{Y}\;C_{in} + X\;Y\;C_{in} = X\oplus Y\oplus C_{in} \\C_{out} = X\;Y + X\;C_{in} + Y\;I = X\;Y + (X\oplus Y)\;C_{in}\end{cases}\; \\(S, C_{out}) = f_{FA}(X, Y, C_{in})\]
- nãããã®å ¨å ç®å¨ãä½ãã«ã¯ã1ãããã®å ¨å ç®å¨ã®çµã¿åããã§å®ç¾ã§ããã \[(S_{n}, C_{n}) = f_{FA}(X_{n}, Y_{n}, C_{n-1})\]
ï¼\(C_{n}\)ã¯æ¡ããµãæ¤åºã«å©ç¨ã\(Y' = Y \oplus C_{SUB}, C_{-1} = C_{SUB}\)ã¨ããã°ãå æ¸ç®å¨ã¨ãªãã
æ¡ä¸ãå è¦å ç®å¨(Carry Lookahead Adder)
None
:ã\((X, Y) = (0, 0)\)ã®ã¨ããæ¡ä¸ããåºåã¯ãæ¡ä¸ããå ¥åã«ä¾åããªã\((C_{out} = 0)\)Pass
\(P_{i} = X_{i}\oplus Y_{i}\):ã\((X, Y) = (1, 0)\; or \;(0, 1)\)ã®ã¨ããæ¡ä¸ããå ¥åãããã¨æ¡ä¸ããåºåãçºçãã\((C_{out} = C_{in})\)Generate
\(G_{i} = X_{i}Y_{i}\):ã\((X, Y) = (1, 1)\)ã®ã¨ããæ¡ä¸ããå ¥åã«ä¾åããã常ã«æ¡ä¸ããåºåãçºçãã\((C_{out} = 1)\)
\[\begin{cases}S_{i} = X_{i}\oplus Y_{i}\oplus C_{i-1} = P_{i} \oplus C_{i-1} \\C_{i} = X_{i}Y_{i} + (X_{i}\oplus Y_{i})C_{i-1} = G_{i} + P_{i}C_{i-1}\end{cases}\]
1: æ¡ä¸ãçæä¼æã¦ããã:ãã¯ããã«\(G, P\)ãä½ãã \[\begin{cases}G_{i} = X_{i}Y_{i} \\P_{i} = X_{i}\oplus Y_{i}\end{cases}\]
2: CLAã¦ããã:ãæ¡ä¸ããä¿¡å·ã ãé«éã«ä½ãã \[C_{i} = G_{i} + P_{i}C_{i-1}\]
3: åã¦ããã:ãæ¡ä¸ããä¿¡å·ã¨\(P\)ãæ¼ç®ãã¦å ç®çµæãåºåããã \[S_{i} = P_{i}\oplus C_{i-1}\]
å¤æ°æ±ºåè·¯(Majority Circuit)
è¤æ°ã®å ¥åãæ票ã¨ã¿ãªãããã®å¤æ°æ±ºçµæãåä¸ã®åºåã¨ããçµã¿åããåè·¯ã
ä¾) ï¼å ¥åå¤æ°æ±ºåè·¯:ã \[M = A\;B + A\;D + A\;C + B\;C = A\;(B + C + D) +B\;C\]
é åºåè·¯(Sequential Circuit)
ããæå»ã®åºåãããã®æå»ã®å ¥åã¨ç¶æ ã«ä¾åããè«çåè·¯ãé åºåè·¯ã¨ãããç¹ã«åè·¯åä½ãã¯ããã¯(CK)ã«åæããé åºåè·¯ãåæå¼é åºåè·¯ã¨ãããã¯ããã¯å ¥åãã¨ã«ãã¡ã¢ãªã«ä¿åãã¦ããå¤ãããå ¥åã¨åºåã決ããã
ç¶æ é·ç§»é¢æ°(state transition function)
:ã\(Q^{+} = f(Q, I)\)åºåé¢æ°(output function)
:ã\(O = g(Q,I)\)- 次ç¶æ \(Q^{+}\), åºå\(O\)ã¯ãç¾ç¶æ \(Q\)ã¨å ¥å\(I\)ã«ãã£ã¦æ±ºã¾ãã
Mealyãã·ã³(Mealy machine)
:ãç¾ç¶æ ã¨å ¥åã¨ã§åºåã決ã¾ãé åºåè·¯ã \[\begin{cases}\bvec{Q}^{+} = \bvec{f}(\bvec{Q}, \bvec{I}) \\ \bvec{O} = \bvec{g}(\bvec{Q}, \bvec{I})\end{cases}\]
Mooreãã·ã³(Moore machine)
:ãç¾ç¶æ ã ãã§åºåã決ã¾ããå ¥åã¯åºåã«ç¡é¢ä¿ãªé åºåè·¯ã \[\begin{cases}\bvec{Q}^{+} = \bvec{f}(\bvec{Q}, \bvec{I}) \\ \bvec{O} = \bvec{g}(\bvec{Q})\end{cases}\]
ããªãããããã(Flip-Flop)
è«çå¤ã®0ã1ã®ãããããå®å®ç¶æ (åå®å®ç¶æ )ã¨ãã¦æã¤ï¼ãããã®ã¡ã¢ãªã ã¯ããã¯ä»ãããªããããããã¯ãã¯ããã¯(ãããã¿ã¤ã )æ¯ã«ã次ã®ï¼åä½ãåæãã¦è¡ãã
- å ¥åãåãä»ããï¼ãã§ãã¯ããï¼ã
- 1ã§åãä»ãå ¥åã¨ç¾ç¶æ ã¨ã«ãã£ã¦æ±ºã¾ãç¹æ§ã«å¾ããç¶æ é·ç§»ãèµ·ããã
- 2ã§é·ç§»ãã次ç¶æ ãåºåã¨ããã
ï¼ããªããããããã§ã¯2ã¨3ã¯åãåä½ã
ç¹æ§æ¹ç¨å¼(characteristic equation)
:ã\(Q^{+}=O=f(I, Q)\)
ä¸è¬ã«ãç¶æ æ°ã\(n\)åããã°ãå¿ è¦ãªããªããããããã¯ã\(\lceil \log_{2}n \rceil\)åã
SRããªãããããã(Set-Reset Flip-Flop)
- ç¹æ§æ¹ç¨å¼(å±éç¹æ§è¡¨ãã)
\(\begin{cases}Q^{+} = S + \overline{R}\;Q = \overline{S}\mid (\overline{R} \mid Q) = \overline{S\downarrow(R\downarrow\overline{Q})} = R\downarrow(S\downarrow Q)\ \overline{Q^{+}} = R + \overline{S}\;\overline{Q} = \overline{R}\mid (\overline{S} \mid Q) = \overline{R\downarrow(S\downarrow Q)} = S\downarrow(R\downarrow\overline{Q})\end{cases}\)
ä»ã®FFãSR-FFã使ã£ã¦ä½ãã«ã¯ãSR-FFã¸ã®å ¥å\(s, r\)ãã\(Q\)ã¨ä»ã®FFã®å ¥åã使ã£ã¦è¡¨ãã°è¯ãã
Dããªãããããã(Delayed Flip-Flop)
- ç¹æ§æ¹ç¨å¼(å±éç¹æ§è¡¨ãã):ã\(Q^{+} = D\)
- (æ¡å¤§å ¥åè¦æ±è¡¨ãã):ã\(\begin{cases}s = D \\r = \overline{D} \end{cases}\)
Tããªãããããã(Toggle Flip-Flop)
- ç¹æ§æ¹ç¨å¼(å±éç¹æ§è¡¨ãã):ã\(Q^{+} = T\;\overline{Q} + \overline{T}\;Q\)
- (æ¡å¤§å ¥åè¦æ±è¡¨ãã):ã\(\begin{cases}s = T\;\overline{Q} \\r = T\;Q\end{cases}\)
JKããªãããããã(JK Flip-Flop)
- ç¹æ§æ¹ç¨å¼(å±éç¹æ§è¡¨ãã):ã\(Q^{+} = J\;\overline{Q} + \overline{K}\;Q\)
- (æ¡å¤§å ¥åè¦æ±è¡¨ãã):ã\(\begin{cases}s = J\;\overline{Q} \\r = K\;Q\end{cases}\)
ã¯ããã¯å ¥åä»ãããªãããããã
- ã¯ããã¯ä»ãããªãããããã:ãã¯ããã¯CKã¨ã®ANDãã¨ããªã©ãã¦å
¥åãããã¨ã§åæ(å
¥åã®ãã§ãã¯)ããããªãããããã
- ãã¸ãã£ãã¨ãã¸ããªã¬:ãã¯ããã¯ã®ç«ã¡ä¸ããã§ç¶æ å¤åãã
- ãã¬ãã£ãã¨ãã¸ããªã¬:ãã¯ããã¯ã®ç«ã¡ä¸ããã§ç¶æ å¤åãã
é åºåè·¯ã®è¨è¨
ç¶æ æ°æå°å
ç価(equivalence)
:ãããç¶æ \(p\)ã¨\(q\)ã®ããããã®æã«ãä»»æã®åä¸å ¥å(ã®çµ)ç³»åãä¸ãã¦å¾ãåºå(ã®çµ)ç³»åãåä¸ã§ããå ´åã«ã\(p \equiv q\)ã¨è¡¨ãã両ç«
:ãããç¶æ \(p\)ã¨\(q\)ã¨ã«ãä»»æã®åä¸å ¥å(ã®çµ)ç³»åãä¸ãã¦å¾ãåºå(ã®çµ)ç³»åããã³ãã±ã¢ãé¤ãã¦åä¸ã§ããããã¤ãé·ç§»å ããã³ãã±ã¢ã§ãªãå ´åã«ã\(p \sim\ q\)ã¨è¡¨ããå«æ(implication)
:ãããç¶æ \(p\)ã¨\(q\)ãåä¸å ¥åã«ãã£ã¦ããããã\(r\)ã¨\(s\)ã«é·ç§»ããæãç¶æ 対\((p, q)\)ã¯ç¶æ 対\((r, s)\)ãå«æããã¨ããã両ç«éå
:ãç¶æ \(q_{1}, \cdots q_{n}\)ã«ããã¦ä»»æã®ç¶æ 対\((q_{i}, q_{j})\;(i\neq j)\)ã®ãã¹ã¦ã両ç«ãããããªç¶æ ã®éå\({q_{1}, \cdots q_{n}}\)ãããç¶æ \(q_{i}\)ãå¤ã®ã©ã®ç¶æ ã¨ã両ç«ããªãæã¯,\({q_{i}}\)ã両ç«éåã¨ããã被è¦(cover)
:ã両ç«éåã®éå\(\Pi={C_{i}}\)ãèããæããããã®ç¶æ ãã\(\Pi\)ãæ§æããããããã®ä¸¡ç«éå\(C_{i}\)ã®è¦ç´ ã«ãªã£ã¦ããããã®ãããª\(\Pi\)ã¯ãã¹ã¦ã®ç¶æ ã被è¦ãã¦ããã¨ãããéå
:ã両ç«éåã®éå\(\Pi={C_{i}}\)ãèããæãããåä¸å ¥åãä¸ãã¦å¾ãé·ç§»å ãè¦ç´ ã¨ããéåã\(C_{i}^{+}\)ã¯,\(\Pi\)ã®ããããã®ä¸¡ç«éå\(C_{i}\)ã«å å«ãã¦ãã\((C_{i}^{+}\in C_{i})\)ããã®ãããª\(\Pi\)ã¯éãã¦ãã(éå ã§ãã)ã¨ããã- æå°å½¢:ããã¹ã¦ã®ç¶æ ã被è¦ãéãã両ç«éåã®éå\(\Pi\)ã®ãã¡ãè¦ç´ æ°ãæå°ã®éå\(\Pi^{}\)ãæ§æããå両ç«éå\(C_{i}^{}\)ã®è¦ç´ ã§ããç¶æ ããã¼ã¸ããæ°ããªç¶æ åãã¤ããå½¢ã
ç¶æ ã®ä½µåæä½
ç¶æ \(q_{1}, \cdots, q_{6}\)ã®ãã¡ã両ç«ããç¶æ 対ã
\((q_{1}, q_{3}), (q_{1}, q_{5}), (q_{1}, q_{6}), (q_{2}, q_{6}), \\(q_{2}, q_{7}), (q_{3}, q_{5}), (q_{3}, q_{6}), (q_{5}, q_{6}), (q_{6}, q_{7})\)
ã ã£ãæãããããã両ç«éå
\({q_{1}, q_{3}}, {q_{1}, q_{5}}, {q_{1}, q_{6}}, {q_{2}, q_{6}}, \\{q_{2}, q_{7}}, {q_{3}, q_{5}}, {q_{3}, q_{6}}, {q_{5}, q_{6}}, {q_{6}, q_{7}}, {q_{4}}\)
ãå¾ãããã¼ã¸ã§ãããã®ããã§ãã¯ãã¦ãæ°ãã«ä¸¡ç«éå
\({q_{1}, q_{3}, q_{5}, q_{6}}, {q_{1}, q_{5}, q_{6}}, {q_{1}, q_{3}, q_{6}}, \\{q_{3}, q_{5}, q_{6}}, {q_{1}, q_{3}, q_{5}}, {q_{2}, q_{6}, q_{7}}\)
ãå¾ãã以ä¸ã16åã®ä¸¡ç«éåã®çµã¿åããã®ãã¡ãããéãã被è¦ã®çµã¿åããã§æå°åæ°3ã®ãã®ãé¸ã¶ã¨ã
\({q_{1}, q_{3}, q_{5}(, q_{6})}, {q_{2}, q_{6}, q_{7}}, {q_{4}}\)
ã¨ãªãããããã«æ°ããç¶æ åã«ä»ãæ¿ãæå°å½¢ãå¾ãã
\(r_{1} \Leftarrow {q_{1}, q_{3}, q_{5}}, r_{2} \Leftarrow {q_{2}, q_{6}, q_{7}}, r_{3} \Leftarrow {q_{4}}\)
両ç«ç¶æ 対ã®æ±ãæ¹
ãããããããã¯ä¸¡æ¹ã®åºå[é·ç§»å ]ããã³ãã±ã¢ã®å ´åã¯åä¸ã®åºå[é·ç§»å ]ã¨è¦ãªãã
- ç¶æ éå表ã®æ ãæ¸ãã両ç«æ§ã«ã¯å¯¾ç§°åãæç«ããã®ã§\(i>j\)ã¨ããã
- ãã¹ã¦ã®ç¶æ
対\((q_{i},q_{j})\)ã«å¯¾ãã¦ä¸¡ç«æ§ã調ã¹ããã®çµæã座æ¨\((q_{i}, q_{j})\)ã®ãã¹ç®ã«è¨å
¥ããã
- \((q_{i}\)ã¨\(q_{j})\)ã«ãããå ¥å(ã®çµ)ãä¸ããã¨ç¸ååºåã¨ãªãæã¯ã両ç«ããªãå°\(\times\)ãè¨å ¥ããã
- \(\times\)ãä»ããªãæã¯ç¶æ
é·ç§»ã«ã¤ãã¦èª¿ã¹ãã
- \((q_{i}, q_{j})\)ã\((q_{k}, q_{k})\)ãå«æããæã¯ã両ç«ããå°\(\bigcirc\)ãè¨å ¥ããã
- \((q_{i}, q_{j})\)ã\((q_{k}, q_{l})\;(k\neq l)\)ãå«æããæã\((q_{i},q_{j})\)ã«é·ç§»å ã®ã©ãã«\((r_{k}, r_{l})\)ãè¨å ¥ãããã\((r_{i}, r_{j})\)ã両ç«ããããã«ã¯ãããããå«æãã\((r_{k}, r_{l})\)ã両ç«ããå¿ è¦ãããã
- åãã¹ãä½ãããã®è¨å·ã§åã¾ã
- 両ç«æ§ãæªæ±ºå®ãªåº§æ¨\((q_{i}, q_{j})\)ã«ã¤ãã¦ãå«æããç¶æ
対\((q_{r}, q_{k})\)ã®ä¸¡ç«æ§ã座æ¨\((q_{r}, q_{k})\)ã«ãã£ã¦èª¿ã¹ãã
- ããã«\(\bigcirc\)ãããã°ãé·ç§»å ã®ç¶æ 対\((q_{i}, q_{j})\)ã両ç«ããã®ã§ãã©ãã«\((q_{k}, q_{l})\)ã«\(\bigcirc\)ãã¤ãããåæ§ã«ã\(\times\)ã®å ´åãèãã¦ã両ç«ããªãã©ãã«ã«\(\times\)ãã¤ããã
- é£éãã¦\(\times\)ãè¨å ¥ãããªããªãã¾ã§ç¹°ãè¿ãã
- \(\times\)ãä»ãã¦ããªã座æ¨\((q_{i}, q_{j})\)ã両ç«ç¶æ 対
両ç«ç¶æ 対\((q_{2}, q_{4}), (q_{5}, q_{8}), (q_{5}, q_{7}), (q_{7}, q_{8})\)ã¨æ®ãã®ç¶æ ã両ç«éåã«ãã¦ã両ç«éå
\({q_{2}, q_{4}}, {q_{5}, q_{8}}, {q_{5}, q_{7}}, {q_{7}, q_{8}}, {q_{1}}, {q_{3}}, {q_{6}}\)
ãå¾ãããããã§ãã¼ã¸ã§ãããã®ããã§ãã¯ãã¦ã
\({q_{2}, q_{4}}, {q_{5}, q_{7}, q_{8}}\)
ãå¾ãããããã®ä¸¡ç«éåã®çµã¿åããã®ãã¡ãããéãã被è¦ã®çµã¿åããã§æå°åæ°ã®ãã®ãé¸ãã§ã©ãã«ãã¤ããã¨
\(r_{1} \Leftarrow {q_{1}}, r_{2} \Leftarrow {q_{2}, q_{4}}, r_{3} \Leftarrow {q_{3}}, r_{4} \Leftarrow {q_{6}}, r_{5} \Leftarrow {q_{5}, q_{7}, q_{8}}\)
åæå¼é åºåè·¯(Synchronous Sequential Circuit)
ã¬ã¸ã¹ã¿[ã©ãã](register[latch])
:ãããªããããããã®ä¸æèªã¿åºã(read)ã¨ä¸ææ¸ãè¾¼ã¿(write)ãã§ããFF群ã
ã·ãã¿(shifter)
:ãåæãã¦ã·ããåä½ãè¡ãFF群ã
éåæå¼é åºåè·¯(Asynchronous Sequential Circuit)
åè·¯åä½ãä»»æã®æå»ã«çºçããå ¥åå¤åã¨ãã®é åºã ãã«ä¾åããé åºåè·¯ã éåæå¼é åºåè·¯ã§ã¯ãå ¥åå¤åãç¶æ é·ç§»ã¨åºåå¤åãå¼ãèµ·ããã
éçãã¶ã¼ã(static hazard)
:- 1ãã¶ã¼ãï¼åºåã1ã§ä¸å¤ã®æã«ä¸ç¬çºçãã0
- 0ãã¶ã¼ãï¼åºåã0ã§ä¸å¤ã®æã«ä¸ç¬çºçãã1
åçãã¶ã¼ã(dynamic hazard)
:ãå ¥åå¤åã«ãã£ã¦åºåãçºçããä¸æ£åºå競å(race)
:ãï¼ã¤(2 bit)以ä¸ã®ç¶æ å¤æ°ãåæã«å¤åãããã¨(00->11)ãã¯ãªãã£ã«ã«ã¬ã¼ã¹(critical race)
:ã競åã®éãï¼ã¤(2 bit)以ä¸ã®ç¶æ å¤æ°ãåæã§ã¯ãªããé 延ã®ã°ãã¤ãã§ä¸æ£ãªé·ç§»å ãæã¤å¯è½æ§ããã競å(00 -> 11(00 -> 01, 00 -> 10))ãã¹ã¿ã¼ã¹ã¬ã¼ãããªãããããã(master-slave flip-flop)
:ãã¯ãªãã£ã«ã«ã¬ã¼ã¹ãé¿ããããã«ããã¹ã¿ã¼ããªãããããã(1段ç®)ã¨ãã¹ã¬ã¼ãããªãããããã(2段ç®)ãç´åæ¥ç¶ãããã®- ãã¹ã¿ã¼åä½:ãï¼æ®µç®ã®ããªããããããã§å ¥åãåãè¾¼ã¿ä¿æãã
- ã¹ã¬ã¼ãåä½:ãï¼æ®µç®ã®ããªããããããã§1段ç®ã§ä¿æããå ¥åã«ããç¶æ é·ç§»ã¨åºåãè¡ãã
ãªãã«ã«ã¦ã³ã¿(ripple counter): éåæå¼ï¼é²ã«ã¦ã³ã¿(åCKå ¥åãåä¸ã®ã¯ããã¯å ¥åã«ãªã£ã¦ããªã)
ã½ããã¦ã§ã¢ã«ããè«çåè·¯è¨è¨
ã³ã³ãã¥ã¼ã¿æ´ç¨è¨è¨(CAD;Computer Aided Design)
:ãã³ã³ãã¥ã¼ã¿ãç¨ãã¦è¨è¨ãæ¯æ´ããææ³ãCADã·ã¹ãã ã¯ãHDLãã³ã³ãã¤ã«ãã¦ãICã¸ã®å®è£ ã¾ã§è¡ã£ã¦ãããã®ã§ãã·ãªã³ã³ã³ã³ãã¤ã©(silicon compiler)ã¨ãããã¨ãããããã¼ãã¦ã§ã¢è¨è¿°è¨èª(HDL;Hardware Description Language)
:ããã¼ãã¦ã§ã¢ãè«çåè·¯ã®åä½ãè¨è¿°ããããã°ã©ãã³ã°è¨èªããã¤ãã¢(behavior)
:ãåè·¯ã®åä½ãåä½ã®ç´°ããã¿ã¤ãã³ã°ã¾ã§ã¯è¦å®ããªããé åºåè·¯ã«ãããç¶æ é·ç§»å³ãããã¤ãã¢è¨è¿°ã®ä¸ã¤ãã¬ã¸ã¹ã¿ãã©ã³ã¹ãã¡ã¬ãã«(RTL;Register Transfer Level)
:ãåºæ¬çãªçµã¿åããåè·¯ãè«çãããã¯ã¨ãã¦ããã®éã®æ¥ç¶é¢ä¿ã¨ããã®åä½ã¿ã¤ãã³ã°ãè¦å®ãããè«çã²ã¼ã(logic gate)
:ãè«çã²ã¼ãã¨ãããã®çµã¿åãããè¦å®ãããåè·¯å³ãããã°ã©ã ã¨ãã¦æ¸ãç´ããã ãã®ã¬ãã«ã
- VHDL: ç±³å½å½é²çãä¸å¿ã«æ¨æºåãããHDL
ASIC(Application Specific Integrated Circuit)
:ãç¹å®ã®ç®çã»ç¨éåãã«ä½ãããéç©åè·¯ã- å©ç¹ï¼é度ã»éç©åº¦ã»æ¶è²»é»åã®ç¹ã§æå©ãéç£ããã°ã³ã¹ããä¸ããã
- æ¬ ç¹ï¼éçºã³ã¹ããæéã¯å¤§ããã
ããã°ã©ããã«è«çåè·¯(programmable logic circuit)
:ãä¸æ¦åæãããã®ãä¿®æ£ã§ããããä½åº¦ãä½ãç´ããè«çåè·¯ã- å©ç¹ï¼éçºãæ©ããåæå¾ã®ä¿®æ£ãå¯è½ã
- æ¬ ç¹ï¼é度é¢ã»éç©åº¦ã§ä¸å©ã
ããã°ã©ã å¯è½AND/ORã¢ã¬ã¤(programmable AND/OR array)
:ãé¸æãããå ¥åã ãã®AND/ORãåºåããANDã¾ãã¯ORã²ã¼ãã®ä¸¦ã³ã- ããã°ã©ã å¯è½åè·¯ã¢ã¬ã¤(PLA;Programmable Logic Array)`: ã¡ã¢ãªã«ããçµã¿åããåè·¯æ§æã®ANDã¢ã¬ã¤ãORã¢ã¬ã¤ãããã°ã©ã å¯è½ã«ããçµã¿åããåè·¯ã
ãã£ã¼ã«ãããã°ã©ã å¯è½åè·¯ã¢ã¬ã¤(FPLA;Field Programmable Logic Array)
:ã使ç¨è ã®æå ã§ããã°ã©ã å¯è½ãªPLAã- ã²ã¼ãã¢ã¬ã¤(gate array):ãNANDãããã¯NORã²ã¼ãã®ããããã«ãã¯ããã¸ãããã³ã°ã§ããåºæ¬ãã¼ãã¦ã§ã¢é¨åãè¦åæ£ãã並ã¹ãæ§é ã®ICã
- ãã£ã¼ã«ãããã°ã©ã å¯è½ã²ã¼ãã¢ã¬ã¤(FPGA;Field Programmable Gate Array):ãNAND/NORã²ã¼ãã®ä»£ããã«ããã£ã¨æ©è½ã®é«ãè«çãããã¯ãè¦åæ£ãã並ã¹ããã®ã
References
ç´ æ°å¤å® (Primality Test)
競ããçãªãã¨ãä¹ ãã¶ãã«ããã®ã§ãhttp://kanetai.hatenablog.com/entry/20110519/1305833341ã®ä¸é¨ãå°ãæ´çã
term | description |
---|---|
ç´æ°(divisor), å æ°,å å(factor) | ããèªç¶æ°ãå²ãåãæ´æ°ã |
ç´ æ°(prime number) | èªåèªèº«ã¨ï¼ä»¥å¤ã®èªç¶æ°ã§å²ãåããªã(æ£ã®ç´æ°ãã¡ããã©ï¼ã¤æã¤)èªç¶æ°ã |
åææ°(composite number) | ç´ æ°ã§ãªã2以ä¸ã®èªç¶æ°(ç´ æ°ã®ç©ã§è¡¨ããã¨ãã§ããèªç¶æ°)ã |
ç´ å æ°(prime factor) | ããèªç¶æ°ã®ç´æ°ã«ãªãç´ æ°ã |
ç´ æ´ãªå¤å®æ³
\(n\)ãç´ æ°ãã©ããå¤å®ããã«ã¯ã\([2, n)\)ã®ç¯å²ã®æ´æ°ã\(n\)ã®ç´æ°ãã©ããã確ãããã°ããããããã§\(n\)ãç´æ°\(d\)ãæã¤(åææ°)ã¨ããã¨ã
\(\frac{n}{d}\)ã\(n\)ã®ç´æ°\(\left( n=d \cdot \frac{n}{d}\right) \)ãªã®ã§ã
\(d \leq \sqrt{n} \lor \frac{n}{d} \leq \sqrt{n}\).ã(â» \( d \gt \sqrt{n} \land \frac{n}{d} \gt \sqrt{n} \) ã ã¨\(d \cdot \frac{n}{d} \gt n\)ã¨ãªã£ã¦ãã¾ã)
\[ n\text{ãåææ°}\rightarrow \sqrt{n}\text{ããå°ããç´ å æ°ãæã¤} \]
ã¤ã¾ã, \([2,\sqrt{n}]\)ã®ç¯å²ã®æ´æ°ã\(n\)ã®ç´æ°ã(\(n\)ãå²ãåããã)ã©ããã確ãããã°ãã. \(n\)ãå²ãåãããªããã®æ´æ°ã¯ç´ æ°ã§ã¯ãªã.è¨ç®éã¯\(O(\sqrt{n})\).
public static final boolean isPrime(int n){ if( n <= 1 ) return false; for(int i=2; i*i <= n;i++ ) if( n % i == 0 ) return false; return true; }
ã¨ã©ãã¹ããã¹ã®ç¯©(the sieve of Eratosthenes, Eratosthenes' sieve)
ä½åãç´ æ°å¤å®ãããããªããã°ãªããªãã¨ããä¸ã®ç´ æ°å¤å®ã§ã¯éå¹çãªã®ã§ã2以ä¸N以ä¸ã®ç´ æ°ãåæãããã¨ãèããã
- ã¾ãã2以ä¸N以ä¸ã®æ´æ°ãåæããã
- ãã®ä¸ã®æå°ã®æ°2ã¯ç´ æ°ã
- ç´ æ°ã®åæ°ã¯ç´ æ°ã§ã¯ãªãã®ã§ã2ã®åæ°ãåãé¤ãã
- 次ã«ãæ®ã£ãæå°ã®æ°ã¯ããã以ä¸ã®æ°ã§å²ãåããªãâãã®æ°ã¯ç´ æ°ã
- ç´ æ°ã®åæ°ãé¤ãã
\[\vdots\]
\([0,n]\)ã®ç´ æ°å¤å®ãã¼ãã«ãæ±ããå ´åãä¸ã§è¿°ã¹ãããã«\(i\)ã\([2, \sqrt{n} ]\)ã®ç¯å²ã§åãã°è¯ãã\(i\)ãç´ æ°ã®æããã®åæ°ã®ãã©ã°ãæããã\(2i, 3i, \cdots (i-1)iã\)ã«ã¤ãã¦ã¯æ¢ã«ãããã¦ããã¯ããªã®ã§ã\( [ i^2, n ] \)ã®ç¯å²ã§\(i\)ã®åæ°ã®ãã©ã°ãæãã°ãããâ»â©ã¯\([0,n)\)ã®ãã¼ãã«
è¨ç®éã¯\( O\left(n\log \log n \right) \)ç¨åº¦.
/** * Creates primality test table via Eratosthenes' sieve. <br> * O( nlog(log n) )<br> * @param n table_size * @return primality test table {isPrime(0), isPrime(1),..., isPrime(n-1)} */ public static final boolean[] sieve(int n){ boolean[] ret = new boolean[n]; Arrays.fill(ret, true); ret[0] = ret[1] = false; for(int i = 2; i*i < n; ++i) if(ret[i]) for(int j = i*i; j < n; j+=i) ret[j] = false; return ret; }
åºé篩(Segmented Sieve)
\(\sqrt{U}\)以ä¸ã®ç´ æ°ã使ã£ã¦ã¨ã©ãã¹ããã¹ã®ç¯©ããããã¨ã«ãã£ã¦ã \([L,U)\)ã®åºéã®ç´ æ°ãå¾ãã\(\sqrt{U}\)以ä¸ã®ç´ æ°ã¯ã¨ã©ãã¹ããã¹ã®ç¯©ãªã©ã使ã£ã¦æ±ãã¦ããã°è¯ãã\(\pi (x)\)ã\(x\)以ä¸ã®ç´ æ°ã®æ°ã¨ããã¨ãè¨ç®éã¯\( O ( (U-L)\pi (\sqrt{U}) ) \)ãç´ æ°å®çã«ããã¨ã\(\pi (x)\)ã¯\(\frac{x}{\log x}\)ç¨åº¦ãªã®ã§ã\(O((U-L)\frac{\sqrt{U}}{\log U})\)ã«ãªãã
â©ã¯\(\sqrt{U}\)以ä¸ã®ç´ æ°primeã渡ãã¦ã[L,U)ã®ç¯å²ã§ãtable[i] != 0 ãªã i+L ã¯ç´ æ°(i+L == table[i])ãªãã¼ãã«ãä½ã£ã¦ãããç´ æ°ã ã欲ããå ´åã¯, 0ã®è¦ç´ ãé¤ãã°è¯ãã空éè¨ç®éã¯\(O(\frac{\sqrt{U}}{\log U} + U-L)\)ã§ãããã(\(\sqrt{U}\)以ä¸ã®ç´ æ°ãå«ãã¦). \(L\)ã®å°ãåãããã©ã°ãæãå¿ è¦ãããã®ã§æ³¨æãå®è£ ã¯Spaghetti Sourceãåèã«ãã¦ã¾ããã»ã¨ãã©ãã®ã¾ã¾
public static final ArrayList<Integer> segmentedSieve(int L, int U, ArrayList<Integer> prime, boolean removeNonPrime) { if (!(0 <= L && L < U)) throw new IllegalArgumentException(); ArrayList<Integer> ret = new ArrayList<>(U-L); IntStream.range(L, U).forEach(i -> ret.add(i - L, i)); for(int p : prime) { if (p*p >= U) break; int j = (p >= L ? p*p : L % p == 0 ? L : L - (L % p) + p); for (; j < U; j += p) ret.set(j - L, 0); } return removeNonPrime ? ret.stream().filter(e -> e > 0).collect(Collectors.toCollection(ArrayList::new)) : ret; }
é次篩(Iterative Sieve)
é次çã«åºé篩ããè¡ããã¨ã«ãã£ã¦ãnã¾ã§ã®ç´ æ°ã空éè¨ç®éãæãã¦æ±ãããã¨ãã§ããã\(O(\frac{n}{\log n} + \sqrt{n})\)ç¨åº¦ã§æ±ãããããã競æããã°ã©ãã³ã°ã ã¨bitsetã«ããã¨ã©ãã¹ããã¹ã®ç¯©ã§ååãªã®ããç¥ããªãã
â©[0,n)ã«ã¤ãã¦ãé·ã\(\sqrt{n}\)ã®åºéãã¨ã«é次åºé篩ãããããsegmentedSieve()ã§åºéåã®ãã¼ãã«ãnewãã¦ãããæ¯ååã大ãããªã®ã§ãå®éã«ã¯ãã®åã®ãããã¡ãç¨æãã¦ä½¿ãã¾ãããæ¹ãç¡é§ãªnewãããªãã¦è¯ãããå¯èªæ§ãåªå ãã¦ããæ¸ãã¦ããªãã
public static final ArrayList<Integer> iterativeSieve(int n) { if (n <= 0) throw new IllegalArgumentException(); final int BLOCK = (int)Math.ceil(Math.sqrt(n)); ArrayList<Integer> ret = primeNumbers(BLOCK); //BLOCK以ä¸ã®ç´ æ° for (int b = BLOCK; b < n; b += BLOCK) { ArrayList<Integer> tmp = segmentedSieve(b , b+BLOCK, ret, false); ret.addAll(tmp.stream().filter(e -> 0 < e && e < n) //n以ä¸ã®ç´ æ°ãå ¥ã£ã¦ãã¾ã£ã¦ãè¯ãå ´åã¯0<eã ãã§è¯ãã .collect(Collectors.toList())); } return ret; }
åè
- spaghetti source
- wiki:ç´ æ°å®ç
- ã¨ã©ãã¹ããã¹ã®ãµããã¨ãã®è¨ç®é
- ç´ æ°åæã«ã¤ãã¦
TODO: 確çç´ æ°å¤å®ã¨ã
Node.jsç°å¢æ§ç¯ã¡ã¢
â ~ sw_vers ProductName: Mac OS X ProductVersion: 10.11.1 BuildVersion: 15B42
nodebrew
curlã§ã¤ã³ã¹ãã¼ã«ãçµãã£ããPATHãéã($HOME/.nodebrew/current/bin
)
â ~ curl -L git.io/nodebrew | perl - setup % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0 100 23642 100 23642 0 0 5900 0 0:00:04 0:00:04 --:--:-- 1154k Fetching nodebrew... Installed nodebrew in $HOME/.nodebrew ======================================== Export a path to nodebrew: export PATH=$HOME/.nodebrew/current/bin:$PATH ========================================
node, npm
â ~ nodebrew install-binary latest Fetching: http://nodejs.org/dist/v5.2.0/node-v5.2.0-darwin-x64.tar.gz ######################################################################## 100.0% Installed successfully â ~ nodebrew use latest use v5.2.0 â ~ npm version { npm: '3.3.12', ares: '1.10.1-DEV', http_parser: '2.6.0', icu: '56.1', modules: '47', node: '5.2.0', openssl: '1.0.2e', uv: '1.7.5', v8: '4.6.85.31', zlib: '1.2.8' }
npmã®ä½¿ãæ¹
https://www.npmjs.com/ãã人æ°ã®ããããã±ã¼ã¸ãæ¢ããã¨ãã§ããã
#-g: global npm install -g packagename #ããã±ã¼ã¸ã¤ã³ã¹ãã¼ã« npm list -g #ã¤ã³ã¹ãã¼ã«æ¸ã¿ããã±ã¼ã¸ä¸è¦§
ããã±ã¼ã¸
- jshint
â ~ npm install -g install jshint â ~ which jshint
CoffeeScript
â ~ npm install -g coffee-script â ~ coffee -v CoffeeScript version 1.10.0
atomããã±ã¼ã¸
試ãã«ä½¿ã£ã¦ããããã±ã¼ã¸é
pacakge name | description |
---|---|
color-picker | cmd+shift+c ã§ã«ã©ã¼ããã«ã¼ã表示ããã¦ã¯ãªãã¯ã§å
¥åãCSSã¨ãã«éãã便å©ã«ä½¿ããã |
pigments | rgb(181, 137, 0) ã¨ãæ¸ãã¦ããã¨ããã«è²ãã¤ãã¦ãããããããªãã |
jshint | ãªã¢ã«ã¿ã¤ã ã«javascriptã®è¦å jshintã表示ããããnpm install -g install jshint ã¨ãã§jshintå
¥ãã¨ãå¿
è¦ãã? |
regex-railroad-diagram | ä¸ã«é·ç§»å³ã表示ãã¦ãæ£è¦è¡¨ç¾ãã°ã©ãã£ã«ã«ã«ç¢ºèªã§ããã |
preview | CoffeeScriptãTypeScriptãªã©ã®ç¿»è¨³(JavaScript)ãå³å´ã«ä¸¦ã¹ã¦è¡¨ç¤ºããããã®ä»ã«è²ã ãªè¨èªã対å¿ãã¦ããã |
linter-coffeescript | CoffeeScriptã®linter |
åè
Playgroundã§ãã³ãã«ããéåã¨ã¸ã¥ãªã¢éåãæ¸ãã¦ã¿ã
qiita.com ã«ç§»åãã¾ããã
ããã°ã©ãã³ã°ã«é¢ãããã£ã¦ã¿ãã調ã¹ãç³»ã®ãã®ãQitaã«ç§»ãã¦ããã以å¤ãã¯ã¦ãã§ããéç¨ã«ãããã¨æãã¾ãã http://qiita.com/kanetai
Template Method ãã¿ã¼ã³
https://ja.wikipedia.org/wiki/Template_Method_%E3%83%91%E3%82%BF%E3%83%BC%E3%83%B3
ããå¦çã®ããã¾ããªã¢ã«ã´ãªãºã ãããããã決ãã¦ããã¦ããã®ã¢ã«ã´ãªãºã ã®å ·ä½çãªè¨è¨ããµãã¯ã©ã¹ã«ä»»ããã
swiftã§ã®å®è£ ä¾
ä»ã®ã¨ãããprotected
ãabstract
ãç¡ããabstract methodã«ç¸å½ããé¨åã¯ç°å¸¸çµäºããããã«ãããã¦ãµãã¯ã©ã¹ã§overrideãã¦ãããã
Apple Swift version 1.2 (swiftlang-602.0.53.1 clang-602.0.53) Target: x86_64-apple-darwin14.5.0
class TaggedMessage { func taggedMessage(msg: String) -> String { return openingTag() + msg + closingTag() } func openingTag() -> String { return abend()! } func closingTag() -> String { return abend()! } func abend() -> String? { println("pleeeeeease override!!!!!"); return nil } } class ItalicMessage : TaggedMessage { override func openingTag() -> String { return "<i>" } override func closingTag() -> String { return "</i>" } } class AlertMessage : TaggedMessage { override func openingTag() -> String { return "<font size=\"30\" color=\"#ff0000\">" } override func closingTag() -> String { return "</font>" } } for obj: TaggedMessage in [ItalicMessage(), AlertMessage()] { println(obj.taggedMessage("message!")) } TaggedMessage().taggedMessage("abendï¼")
Adapterãã¿ã¼ã³
https://ja.wikipedia.org/wiki/Adapter_%E3%83%91%E3%82%BF%E3%83%BC%E3%83%B3
æ¢åã®ã¯ã©ã¹ã«ä¿®æ£ãå ãããã¨ãªãã¤ã³ã¿ã¼ãã§ã¼ã¹ãå¤æ´ããã©ããã¼.
swiftã§å®è£ ããã«ã¯ï¼
ã¯ã©ã¹å³ã©ããå®è£ ããã ãã ããObjective-CãSwiftã«ã¯è¨èªæ©è½ã¨ãã¦æ¢åã®ã¯ã©ã¹ãæ¡å¼µã§ããæ©è½ãããã®ã§ãAdapterã¯ã©ã¹ã®å®è£ ã¯å¿ è¦ãªãã
Apple Swift version 1.2 (swiftlang-602.0.53.1 clang-602.0.53) Target: x86_64-apple-darwin14.5.0
class Adaptee1 { func oldMethod1() { println("[\(__FUNCTION__)]") } } class Adaptee2 { func oldMethod2() { println("(\(__FUNCTION__))") } } protocol Target { func requiredMethod() } extension Adaptee1 : Target { func requiredMethod() { self.oldMethod1() } } extension Adaptee2 : Target { func requiredMethod() { self.oldMethod2() } } for t: Target in [Adaptee1(), Adaptee2()] { t.requiredMethod() }
Iteratorãã¿ã¼ã³
https://ja.wikipedia.org/wiki/Iterator_%E3%83%91%E3%82%BF%E3%83%BC%E3%83%B3
âã¿ããã«è¦ç´ ãå復åæã§ããããã«ãããã¿ã¼ã³
var iterator = aggregate.iterator() while iterator.hasNext() { var element = iterator.next() }
swiftã§Iteratorãå®è£ ããã«ã¯ï¼
swiftã ã¨SequenceType
, GeneratorType
ãããã³ã«ãããããAggregate
, Iterator
ã«ç¸å½ããã
protocol SequenceType { //Aggregate func generate() -> GeneratorType //iterator() } protocol GeneratorType { //Iterator mutating func next() -> Element? //next() }
ãããã³ã«ã«ã¯hasNext()
ã¯ç¡ããã©å®è£
ããã°ããæ¸ããã
var iterator = aggregate.generate() while iterator.hasNext() { var element = iterator.next() //do something }
ããããhasNext() == false
ã®ã¨ãnext()
ãnil
ãè¿ãã®ã§ãhasNext()
ãå®è£
ããå¿
è¦ã¯ãã¾ãç¡ã
var iterator = aggregate.generate() while let element = iterator.next() { //do something }
SequenceType
ãããã³ã«ãå®è£
ãã¦ããã°é«éåæå¯è½
for element in aggregate { //do something }
ã«ã¼ããããã ããªãããããã³ã«ãç¶æ¿ãã¦ããªãã¦ããclosureãã¨ããããªforeachãå®ç¾©ãã¨ãã°ããããè¦ç´ 以å¤ã«ãããããããªæ å ±(indexã¨ã)ãä»å ãã¦ã«ã¼ãããããã¨ãã§ããã
func foreach(closure: (element: Element) -> Void) { /* ... */ } aggregate.foreach { //do something ($0 is element) }
Foundationã®ãããã³ã«ã ã¨NSFastEnumeration
, NSEnumerator
ã§é«éåæã§ãããã
swiftã§å®è£
ãããã¨ããã¨ããã¤ã³ã¿ããAnyObject?
ãããããªãã¨ãããªãã®ã§é¢åãããã
protocol NSFastEnumeration { func countByEnumeratingWithState(state: UnsafeMutablePointer<NSFastEnumerationState>, objects buffer: AutoreleasingUnsafeMutablePointer<AnyObject?>, count len: Int) -> Int } class NSEnumerator : NSObject, NSFastEnumeration { func nextObject() -> AnyObject? }
swiftã§ã®Iteratorå®è£ ä¾
swiftã§binaryTreeã®å·¦ã®æ·±ãåªå æ¢ç´¢(è¡ãããé :pre-order)ãå®è£ ãã¦ã¿ãã ã»ãã«ããéé (reverse-order)ããåªå (breadth-first)ã®ã¤ãã¬ã¼ã¿ãä½ã£ã¦ããã°ãç¶æ³ã«åããã¦å¥½ããªé ã§åæã§ããã
åä½ç¢ºèªã¯ãã¾ããã¦ãªã...
didSet
ã£ã¦ã¤ãã·ã£ã©ã¤ã¶ã®ä¸ã§ã¯åä½ããªãã®ãï¼
Apple Swift version 1.2 (swiftlang-602.0.53.1 clang-602.0.53) Target: x86_64-apple-darwin14.5.0
public class Tree : SequenceType { let root: Node public init(rootNode: Node) { self.root = rootNode } public func generate() -> Iterator { return Iterator(node: self.root) } public class func node(#val: Int, left: Node?, right: Node?) -> Node { let node: Node = Node(val: val) node.left = left node.right = right return node } // let rootNode: Node public class Node { let val: Int var parent: Node? var left: Node? { didSet { if left != nil { left?.parent = self } } } var right: Node? { didSet { if right != nil { right?.parent = self } } } public init(val: Int) { self.val = val } } public class Iterator : GeneratorType { private var node: Node? public init(node: Node) { self.node = node } public func next() -> Node? { var ret = self.node self.node = self.dynamicType.nextNodeOf(ret) return ret } public func hasNext() -> Bool { return self.node != nil } //pre-order search public class func nextNodeOf(targetNode: Node?) -> Node? { if let node: Node = targetNode { if node.left != nil { return node.left } //return node.right //if node.right is nil, access node.parent.right recursively return nextRightNodeOf(node: node, preNode: node) } else { return nil } } private class func nextRightNodeOf(#node: Node, preNode: Node) -> Node? { if node.right != nil && preNode !== node.right { return node.right } if node.parent != nil { return nextRightNodeOf(node: node.parent!, preNode: node) } return nil } } } var tree: Tree = Tree(rootNode: Tree.node(val: 0, left: Tree.node(val: 1, left: Tree.node(val: 11, left: Tree.node(val: 111, left: Tree.node(val: 1111, left: nil, right: nil), right: Tree.node(val: 1112, left: nil, right: nil)), right: nil), right: nil), right: Tree.node(val: 2, left: nil, right: nil) )) for node in tree { println("\(node.val)") }