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?

More than 1 year has passed since last update.

#概要 

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;

以上。

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?