1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

simcirjsでcpuを育てる。

1
Last updated at Posted at 2026-07-14

概要

simcirjsでcpuを育てる。
Nand2Tetris -> nandgame -> Swtch2cpuの流れで、自分はsimcirjsが合ってると思うので、実装してみる。

参考にしたページ

仕組み

simcirjsは、基本部品および既に登録された部品を組合せることができるので、設定されている部品を、置き換え・追加してカスタマイズする。
simcir-library.jsをライブラリーに置いて、CPUに必要な部品を開発、追加して行く。
Plunkerで、やる。
ゴールは、clkのみで、cpuが動くこと。

プログラムで部品の登録

部品の組み合わせで、作れるが、ROMとかRAMとか面倒。
プログラムで部品登録できないか、探る。--->
あっさり、見つけた。道は開いた。

simcir.registerDevice('CD', function(device) {
  var in0 = device.addInput();
  var out0 = device.addOutput();
  device.$ui.on('inputValueChange', function() {
    var currentInputValue = in0.getValue(); 
    out0.setValue(currentInputValue);
  });
});

image.png

成果物

cpuの部品

4bit cpuの部品は、制御装置(インストラクション・デコーダ)、ALU(4bit 加減乗除)、ROM(8bit 16word)、プログラムカウンター(pc 4bit)、4段スタック(4bit)、以上
各部品は、clkで動く。

以上。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?