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?

More than 3 years have passed since last update.

俺cpuAdvent Calendar 2020

Day 14

vistaでquartus その26

Last updated at Posted at 2020-08-17

#概要

vistaでquartusやってみた。
cpu作ってみた。

#cpuの仕様

スタックマシン
スタック長 8word
命令長 16bit
データ長 16bit
アドレス長 12bit
実装メモリー 256word

#アセンブラの作成

##push

スタックトップに、データを直接積む。

##get

メモリーから読み込んで、スタックトップに積む。アドレスを直接指示。

##set

スタックトップを、メモリーへ格納。アドレスを直接指示。

##jmp

アドレスに飛ぶ。

##jz

スタックトップが0なら、アドレスへ飛ぶ。

##out

スタックトップをシリアルへ出力。

##op

算術計算。加算と比較のみ、実装。

#アセンブラでhello_world


push 'h'
out
push 'e'
out
push 'l'
out
push 'l'
out
push 'o'
out
push ' '
out
push 'w'
out
push 'o'
out
push 'r'	
out
push 'l'
out
push 'd'
out
push '!'
out
loop:
jmp loop

#命令セット

|ニーモニック|bit15|bit14 |bit13 |bit12|bit11|bit10 |bit9 |bit8 |bit7 |bit6 |bit5 |bit4 |bit3 |bit2 |bit1 |bit0 |16進 |
|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|
|push I|0 |0 |0 |1 |I|I |I |I |I |I |I |I |I |I |I |I |1000+I |
|get A |0 |0 |1 |0 |A|A |A |A |A |A |A |A |A |A |A |A |2000+A |
|set A |0 |0 |1 |1 |A|A |A |A |A |A |A |A |A |A |A |A |3000+A |
|jp A |0 |1 |0 |0 |A|A |A |A |A |A |A |A |A |A |A |A |4000+A |
|jz A |0 |1 |0 |1 |A|A |A |A |A |A |A |A |A |A |A |A |5000+A |
|jnz A |0 |1 |1 |0 |A|A |A |A |A |A |A |A |A |A |A |A |6000+A |
|out |1 |1 |1 |0 |-|- |- |- |- |- |- |- |- |- |- |- |E000 |
|+ |1 |1 |1 |1 |-|- |- |- |- |- |- |0 |0 |0 |0 |0 |F000 |
|> |1 |1 |1 |1 |-|- |- |- |- |- |- |0 |0 |0 |0 |1 |F001 |
|< |1 |1 |1 |1 |-|- |- |- |- |- |- |0 |0 |0 |1 |0 |F002 |

#ハンドアセンブル


		mem[0]  = 16'h1068;//push 'h'
		mem[1]  = 16'he000;//out
		mem[2]  = 16'h1065;//push 'e'
		mem[3]  = 16'he000;//out
		mem[4]  = 16'h106c;//push 'l'
		mem[5]  = 16'he000;//out
		mem[6]  = 16'h106c;//push 'l'
		mem[7]  = 16'he000;//out
		mem[8]  = 16'h106f;//push 'o'
		mem[9]  = 16'he000;//out
		mem[10] = 16'h1020;//push ' '
		mem[11] = 16'he000;//out
		mem[12] = 16'h1077;//push 'w'
		mem[13] = 16'he000;//out
		mem[14] = 16'h106f;//push 'o'
		mem[15] = 16'he000;//out
		mem[16] = 16'h1072;//push 'r'	
		mem[17] = 16'he000;//out
		mem[18] = 16'h106c;//push 'l'
		mem[19] = 16'he000;//out
		mem[20] = 16'h1064;//push 'd'
		mem[21] = 16'he000;//out
		mem[22] = 16'h1021;//push '!'
		mem[23] = 16'he000;//out
		mem[24] = 16'h4018;//jmp 24

#環境

windows vista 32bit
quartus ii v13.0
ep2c5t144ボード

#コンパイル結果

無題.jpg

#実行結果

無題.jpg

以上。

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?