0
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?

量子コンパイラを作る。 その18

Last updated at Posted at 2025-01-03

概要

量子コンパイラを作る。
elixirで論理回路アセンブラをコンパイルして、qiskitを生成できるが、結局、論理回路が書けるのかが、問題になる。(人材の問題、それなりの人の育成、、、)
そっちに、対策を取る。
論理回路アセンブラから、論理回路を生成して、ビジュアルでシュミレーションするエディタを開発する。どうだ。
構想編

方針

  • simcirjsを使う。
  • レイアウトエンジンを導入する。
    縦に長くなるので、横に広げる。
  • 主なデバイス
    電源
    トグルスイッチ
    LED
    端子
  • 論理回路
    and
    xor
    or
  • セーブ機能
    無し。
  • 設置
    plunker

論理回路アセンブラ

左から make in 論理デバイス out の順に表示する。

make 18
in 0 5
wire 6 13
xor 0 3 14
and 0 3 6
xor 1 4 7
and 1 4 8
xor 6 7 15
and 6 7 9
or 8 9 10
xor 2 5 11
and 2 5 12
xor 10 11 16
and 10 11 13
or 12 13 17
out 14 17

simcirjsのリバースエンジニアリング

デバイスにID譜って、xyでレイアウトする。
コネクトで繋ぐ。

	"devices":[
		{"type":"DC",	"id":"dev0",	"x":24,		"y":160,	"label":"DC"},
		{"type":"LED",	"id":"dev1",	"x":496,	"y":120,	"label":"LED"},
		{"type":"LED",	"id":"dev2",	"x":504,	"y":208,	"label":"LED"},
		{"type":"In",	"id":"dev3",	"x":168,	"y":112,	"label":"A"},
		{"type":"In",	"id":"dev4",	"x":168,	"y":192,	"label":"B"},
		{"type":"Out",	"id":"dev5",	"x":424,	"y":112,	"label":"Sum"},
		{"type":"Out",	"id":"dev6",	"x":424,	"y":200,	"label":"Carry"},
		{"type":"Toggle","id":"dev7",	"x":96,		"y":192,	"label":"Toggle",	"state":{"on":true}},
		{"type":"XOR",	"id":"dev8",	"x":288,	"y":120,	"label":"XOR"},
		{"type":"Toggle","id":"dev9",	"x":88,		"y":112,	"label":"Toggle",	"state":{"on":true}},
		{"type":"AND",	"id":"dev10",	"x":288,	"y":192,	"label":"AND"}
	],
	"connectors":[
		{"from":"dev1.in0",		"to":"dev5.out0"},
		{"from":"dev2.in0",		"to":"dev6.out0"},
		{"from":"dev3.in0",		"to":"dev9.out0"},
		{"from":"dev4.in0",		"to":"dev7.out0"},
		{"from":"dev5.in0",		"to":"dev8.out0"},
		{"from":"dev6.in0",		"to":"dev10.out0"},
		{"from":"dev7.in0",		"to":"dev0.out0"},
		{"from":"dev8.in0",		"to":"dev3.out0"},
		{"from":"dev8.in1",		"to":"dev4.out0"},
		{"from":"dev9.in0",		"to":"dev0.out0"},
		{"from":"dev10.in0",	"to":"dev3.out0"},
		{"from":"dev10.in1",	"to":"dev4.out0"}
	]

以上。

0
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
0
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?