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?

windowsでiverilog その165

Posted at

概要 

windowsでiverilogやってみた。
自作cpu、見つけたので、調査してみた。
練習問題やってみた。

練習問題

elixirでzktcのディスアセンブラを書け。

サンプルコード


defmodule Dasm do
    def decode(<< 5::5, rs::3, rd::3, 0::5 >>) do
        IO.puts("or x#{rd}, x#{rs}")
    end 
    def decode(<< imm::8, rd::3, 17::5 >>) do
        IO.puts("lil  x#{rd}, #{imm}")
    end  
    def decode(<< imm::8, rd::3, 18::5 >>) do
        IO.puts("lih  x#{rd}, #{imm}")
    end 
    def decode(<< imm::5, rd::3, rs::3, 12::5 >>) do
        IO.puts("lw  x#{rd}, x#{rs}, #{imm}")
    end 
end

a = Base.decode16!("0A31")
Dasm.decode(a)
a = Base.decode16!("0052")
Dasm.decode(a)
a = Base.decode16!("2A20")
Dasm.decode(a)
a = Base.decode16!("014C")
Dasm.decode(a)
a = Base.decode16!("116C")
Dasm.decode(a)


実行結果

lil  x1, 10
lih  x2, 0
or x1, x2
lw  x1, x2, 0
lw  x1, x3, 2

成果物

以上。

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?