Last active
November 1, 2016 14:20
Revisions
-
katogiso revised this gist
Nov 1, 2016 . 1 changed file with 15 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,6 +3,8 @@ [CPUの創りかた]で定義されている TD4 を参考にして、モックを作成する。 ## 主な仕様 | | data | |:---------:|:--------:| | 汎用レジスタ | 4bit x 2 | | アドレス空間 | 4bit | @@ -31,13 +33,15 @@ | JNC Im | 1 | 1 | 1 | 0 | Im| Im| Im| Im| | JMP Im | 1 | 1 | 1 | 1 | Im| Im| Im| Im| ### ADD A,Im ``` A <- A + Im ``` |bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |:---:|:--:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| |value| 0 | 0 | 0 | 0 | Im| Im| Im| Im| @@ -48,6 +52,7 @@ A <- B ``` |bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |:---:|:--:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| |value| 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | @@ -58,6 +63,7 @@ A <- (input port) ``` |bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |:---:|:--:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| |value| 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | @@ -68,6 +74,7 @@ A <- Im ``` |bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |:---:|:--:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| |value| 0 | 0 | 1 | 1 | Im| Im| Im| Im| @@ -78,6 +85,7 @@ B <- A ``` |bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |:---:|:--:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| |value| 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | @@ -88,6 +96,7 @@ B <- B + Im ``` |bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |:---:|:--:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| |value| 0 | 1 | 0 | 1 | Im| Im| Im| Im| @@ -98,6 +107,7 @@ B <- (input port) ``` |bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |:---:|:--:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| |value| 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | @@ -109,6 +119,7 @@ B <- (input port) ``` |bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |:---:|:--:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| |value| 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | @@ -119,6 +130,7 @@ B <- (input port) ``` |bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |:---:|:--:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| |value| 1 | 0 | 1 | 1 | Im| Im| Im| Im| @@ -129,6 +141,7 @@ PC <- Im , If Not Carry ``` |bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |:---:|:--:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| |value| 1 | 1 | 1 | 0 | Im| Im| Im| Im| @@ -139,4 +152,6 @@ PC <- Im ``` |bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |:---:|:--:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| |value| 1 | 1 | 1 | 1 | Im| Im| Im| Im| -
katogiso revised this gist
Nov 1, 2016 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,20 +3,22 @@ [CPUの創りかた]で定義されている TD4 を参考にして、モックを作成する。 ## 主な仕様 |:---------:|:--------:| | 汎用レジスタ | 4bit x 2 | | アドレス空間 | 4bit | | PC | 4bit | | フラグレジスタ| 1bit | | 算術演算 | 加算(4bit)| ## データ 処理できるデータは 4bit のみで、オペランドも 4bit です。 ## 命令(機械語) | | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |:--------:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| | ADD A,Im | 0 | 0 | 0 | 0 | Im| Im| Im| Im| | MOV A,B | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | | IN A | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | -
katogiso created this gist
Nov 1, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,140 @@ # TD4 [CPUの創りかた]で定義されている TD4 を参考にして、モックを作成する。 ## 主な仕様 | 汎用レジスタ | 4bit x 2 | | アドレス空間 | 4bit | | PC | 4bit | | フラグレジスタ| 1bit | | 算術演算 | 加算(4bit)| ## データ 処理できるデータは 4bit のみで、オペランドも 4bit です。 ## 命令(機械語) | | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | ADD A,Im | 0 | 0 | 0 | 0 | Im| Im| Im| Im| | MOV A,B | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | | IN A | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | | MOV A,Im | 0 | 0 | 1 | 1 | Im| Im| Im| Im| | MOV B,A | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | | ADD B,Im | 0 | 1 | 0 | 1 | Im| Im| Im| Im| | IN B | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | | OUT B | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | | OUT Im | 1 | 0 | 1 | 1 | Im| Im| Im| Im| | JNC Im | 1 | 1 | 1 | 0 | Im| Im| Im| Im| | JMP Im | 1 | 1 | 1 | 1 | Im| Im| Im| Im| ### ADD A,Im ``` A <- A + Im ``` |bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |value| 0 | 0 | 0 | 0 | Im| Im| Im| Im| ### MOV A,B ``` A <- B ``` |bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |value| 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | ### IN A ``` A <- (input port) ``` |bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |value| 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | ### MOV A,Im ``` A <- Im ``` |bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |value| 0 | 0 | 1 | 1 | Im| Im| Im| Im| ### MOV B,A ``` B <- A ``` |bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |value| 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | ### ADD B,Im ``` B <- B + Im ``` |bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |value| 0 | 1 | 0 | 1 | Im| Im| Im| Im| ### IN B ``` B <- (input port) ``` |bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |value| 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | ### OUT B ``` (output port) <- B ``` |bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |value| 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | ### OUT Im ``` (output port) <- Im ``` |bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |value| 1 | 0 | 1 | 1 | Im| Im| Im| Im| ### JNC Im ``` PC <- Im , If Not Carry ``` |bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |value| 1 | 1 | 1 | 0 | Im| Im| Im| Im| ### JMP Im ``` PC <- Im ``` |bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |value| 1 | 1 | 1 | 1 | Im| Im| Im| Im|