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.

windowsでiverilog その77

Last updated at Posted at 2020-10-14

概要 

windowsでiverilogやってみた。
俺cpuに、サブルーチンコールを導入した。

call命令

スタックトップに、現在のプログラムカウンタの値を積む。

ret命令

スタックトップをプログラムカウンタにセットする。

サンプルコード

mem[12'h000] = 16'h1008;//       push  8
mem[12'h001] = 16'h3010;//       set  a
mem[12'h002] = 16'h1005;//       push  5
mem[12'h003] = 16'h3011;//       set  b
mem[12'h004] = 16'ha000;//       call
mem[12'h005] = 16'h4009;//       jmp  add
mem[12'h006] = 16'h2012;//       get  c
mem[12'h007] = 16'he000;//       out
mem[12'h008] = 16'h4008;//bye:  jmp  bye
mem[12'h009] = 16'h1001;//add:  push  1
mem[12'h00a] = 16'hf000;//       +
mem[12'h00b] = 16'h2010;//       get  a
mem[12'h00c] = 16'h2011;//       get  b
mem[12'h00d] = 16'hf000;//       +
mem[12'h00e] = 16'h3012;//       set  c
mem[12'h00f] = 16'hb000;//       ret
mem[12'h010] = 16'h0000;//a:  0x0000
mem[12'h011] = 16'h0000;//b:  0x0000
mem[12'h012] = 16'h0000;//c:  0x0000


iverilog実行結果



0xxx xxxx xxx zzzz x xx
0000 0000 xxx zzzz 0 00
0000 0000 000 zzzz 0 00
0001 0000 000 zzzz 0 00
0001 0000 000 1008 0 00
0001 0000 000 0008 0 00
0001 0008 001 0008 0 00
0001 0008 001 zzzz 0 00
0002 0008 001 zzzz 0 00
0002 0008 001 3010 0 00
0002 0008 010 3010 1 00
0002 0008 010 0008 1 00
0002 0000 002 0008 0 00
0002 0000 002 zzzz 0 00
0003 0000 002 zzzz 0 00
0003 0000 002 1005 0 00
0003 0000 002 0005 0 00
0003 0005 003 0005 0 00
0003 0005 003 zzzz 0 00
0004 0005 003 zzzz 0 00
0004 0005 003 3011 0 00
0004 0005 011 3011 1 00
0004 0005 011 0005 1 00
0004 0000 004 0005 0 00
0004 0000 004 zzzz 0 00
0005 0000 004 zzzz 0 00
0005 0000 004 a000 0 00
0005 0000 005 a000 0 00
0005 0000 005 zzzz 0 00
0005 0005 005 zzzz 0 00
0006 0005 005 zzzz 0 00
0006 0005 005 4009 0 00
0006 0005 009 4009 0 00
0006 0005 009 zzzz 0 00
0009 0005 009 zzzz 0 00
000a 0005 009 zzzz 0 00
000a 0005 009 1001 0 00
000a 0005 009 0001 0 00
000a 0001 00a 0001 0 00
000a 0001 00a zzzz 0 00
000b 0001 00a zzzz 0 00
000b 0001 00a f000 0 00
000b 0001 00a f000 1 00
000b 0001 00a 0006 1 00
000b 0006 00b 0006 0 00
000b 0006 00b zzzz 0 00
000c 0006 00b zzzz 0 00
000c 0006 00b 2010 0 00
000c 0006 010 2010 0 00
000c 0006 010 zzzz 0 00
000c 0006 010 0008 0 00
000c 0008 00c 0008 0 00
000c 0008 00c zzzz 0 00
000d 0008 00c zzzz 0 00
000d 0008 00c 2011 0 00
000d 0008 011 2011 0 00
000d 0008 011 zzzz 0 00
000d 0008 011 0005 0 00
000d 0005 00d 0005 0 00
000d 0005 00d zzzz 0 00
000e 0005 00d zzzz 0 00
000e 0005 00d f000 0 00
000e 0005 00d f000 1 00
000e 0005 00d 000d 1 00
000e 000d 00e 000d 0 00
000e 000d 00e zzzz 0 00
000f 000d 00e zzzz 0 00
000f 000d 00e 3012 0 00
000f 000d 012 3012 1 00
000f 000d 012 000d 1 00
000f 0006 00f 000d 0 00
000f 0006 00f zzzz 0 00
0010 0006 00f zzzz 0 00
0010 0006 00f b000 0 00
0010 0006 00f b000 1 00
0010 0006 00f 0006 1 00
0006 0000 006 0006 0 00
0006 0000 006 zzzz 0 00
0007 0000 006 zzzz 0 00
0007 0000 006 2012 0 00
0007 0000 012 2012 0 00
0007 0000 012 zzzz 0 00
0007 0000 012 000d 0 00
0007 000d 007 000d 0 00
0007 000d 007 zzzz 0 00
0008 000d 007 zzzz 0 00
0008 000d 007 e000 0 00
0008 000d 007 e000 1 00
0008 000d 007 000d 1 00
0008 0000 008 000d 0 0d
0008 0000 008 zzzz 0 0d
0009 0000 008 zzzz 0 0d
0009 0000 008 4008 0 0d
0009 0000 008 zzzz 0 0d
0008 0000 008 zzzz 0 0d
0009 0000 008 zzzz 0 0d
0009 0000 008 4008 0 0d
0009 0000 008 zzzz 0 0d
0008 0000 008 zzzz 0 0d


以上。

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?