#概要
windowsでiverilogやってみた。
練習問題やってみた。
#練習問題
cpuを実装せよ。
数9を4個つかって1から15までの数を表す式をつくる。
#1
アセンブラ/コード
push 9
push 9
/
push 9
push 9
-
+
out
rom[0] <= 12'h2_09;
rom[1] <= 12'h2_09;
rom[2] <= 12'hf_03;
rom[3] <= 12'h2_09;
rom[4] <= 12'h2_09;
rom[5] <= 12'hf_01;
rom[6] <= 12'hf_00;
rom[7] <= 12'h5_00;
#2
push 9
push 9
/
push 9
push 9
/
+
out
rom[0] <= 12'h2_09;
rom[1] <= 12'h2_09;
rom[2] <= 12'hf_03;
rom[3] <= 12'h2_09;
rom[4] <= 12'h2_09;
rom[5] <= 12'hf_03;
rom[6] <= 12'hf_00;
rom[7] <= 12'h5_00;
#3
push 9
push 9
+
push 9
+
push 9
/
out
rom[0] <= 12'h2_09;
rom[1] <= 12'h2_09;
rom[2] <= 12'hf_00;
rom[3] <= 12'h2_09;
rom[4] <= 12'hf_00;
rom[5] <= 12'h2_09;
rom[6] <= 12'hf_03;
rom[7] <= 12'h5_00;
#4
push 9
push 9
push 9
+
push 9
/
dup
+
out
rom[0] <= 12'h2_09;
rom[1] <= 12'h2_09;
rom[2] <= 12'h2_09;
rom[3] <= 12'hf_00;
rom[4] <= 12'h2_09;
rom[5] <= 12'hf_03;
rom[6] <= 12'h8_00;
rom[7] <= 12'hf_00;
rom[8] <= 12'h5_00;
#5
push 9
push 9
push 9
+
push 9
/
dup
+
-
out
rom[0] <= 12'h2_09;
rom[1] <= 12'h2_09;
rom[2] <= 12'h2_09;
rom[3] <= 12'hf_00;
rom[4] <= 12'h2_09;
rom[5] <= 12'hf_03;
rom[6] <= 12'h8_00;
rom[7] <= 12'hf_00;
rom[8] <= 12'hf_01;
rom[9] <= 12'h5_00;
#6
push 9
dup
push 9
+
push 9
+
push 9
/
-
out
rom[0] <= 12'h2_09;
rom[1] <= 12'h8_00;
rom[2] <= 12'h2_09;
rom[3] <= 12'hf_00;
rom[4] <= 12'h2_09;
rom[5] <= 12'hf_00;
rom[6] <= 12'h2_09;
rom[7] <= 12'hf_03;
rom[8] <= 12'hf_01;
rom[9] <= 12'h5_00;
#7
push 9
push 9
push 9
+
push 9
/
-
out
rom[0] <= 12'h2_09;
rom[1] <= 12'h2_09;
rom[2] <= 12'h2_09;
rom[3] <= 12'hf_00;
rom[4] <= 12'h2_09;
rom[5] <= 12'hf_03;
rom[6] <= 12'hf_01;
rom[7] <= 12'h5_00;
#8
push 9
push 9
push 9
drop
push 9
/
-
out
rom[0] <= 12'h2_09;
rom[1] <= 12'h2_09;
rom[2] <= 12'h2_09;
rom[3] <= 12'h9_00;
rom[4] <= 12'h2_09;
rom[5] <= 12'hf_03;
rom[6] <= 12'hf_01;
rom[7] <= 12'h5_00;
#9
push 9
push 9
-
push 9
*
push 9
out
rom[0] <= 12'h2_09;
rom[1] <= 12'h2_09;
rom[2] <= 12'hf_01;
rom[3] <= 12'h2_09;
rom[4] <= 12'hf_04;
rom[5] <= 12'h2_09;
rom[6] <= 12'h5_00;
#10
push 9
push 9
/
push 9
dup
push 9
/
+
out
rom[0] <= 12'h2_09;
rom[1] <= 12'h2_09;
rom[2] <= 12'hf_03;
rom[3] <= 12'h2_09;
rom[4] <= 12'h8_00;
rom[5] <= 12'h2_09;
rom[6] <= 12'hf_03;
rom[7] <= 12'hf_00;
rom[8] <= 12'h5_00;
#11
push 9
push 9
push 9
+
push 9
/
+
out
end
rom[0] <= 12'h2_09;
rom[1] <= 12'h2_09;
rom[2] <= 12'h2_09;
rom[3] <= 12'hf_00;
rom[4] <= 12'h2_09;
rom[5] <= 12'hf_03;
rom[6] <= 12'hf_00;
rom[7] <= 12'h5_00;
#12
push 9
dup
push 9
push 9
+
+
push 9
/
+
out
rom[0] <= 12'h2_09;
rom[1] <= 12'h8_00;
rom[2] <= 12'h2_09;
rom[3] <= 12'h2_09;
rom[4] <= 12'hf_00;
rom[5] <= 12'hf_00;
rom[6] <= 12'h2_09;
rom[7] <= 12'hf_03;
rom[8] <= 12'hf_00;
rom[9] <= 12'h5_00;
#13
push 9
push 9
push 9
+
push 9
/
dup
+
+
out
rom[0] <= 12'h2_09;
rom[1] <= 12'h2_09;
rom[2] <= 12'h2_09;
rom[3] <= 12'hf_00;
rom[4] <= 12'h2_09;
rom[5] <= 12'hf_03;
rom[6] <= 12'h8_00;
rom[7] <= 12'hf_00;
rom[8] <= 12'hf_00;
rom[9] <= 12'h5_00;
#14
push 9
dup
push 9
push 9
+
push 9
/
dup
+
-
+
out
rom[0] <= 12'h2_09;
rom[1] <= 12'h8_00;
rom[2] <= 12'h2_09;
rom[3] <= 12'h2_09;
rom[4] <= 12'hf_00;
rom[5] <= 12'h2_09;
rom[6] <= 12'hf_03;
rom[7] <= 12'h8_00;
rom[8] <= 12'hf_00;
rom[9] <= 12'hf_01;
rom[10] <= 12'hf_00;
rom[11] <= 12'h5_00;
#15
push 9
dup
dup
push 9
+
push 9
+
push 9
/
-
+
out
rom[0] <= 12'h2_09;
rom[1] <= 12'h8_00;
rom[2] <= 12'h8_00;
rom[3] <= 12'h2_09;
rom[4] <= 12'hf_00;
rom[5] <= 12'h2_09;
rom[6] <= 12'hf_00;
rom[7] <= 12'h2_09;
rom[8] <= 12'hf_03;
rom[9] <= 12'hf_01;
rom[10] <= 12'hf_00;
rom[11] <= 12'h5_00;
以上。