2
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?

rp2040のpio

Last updated at Posted at 2024-12-06

概要

ラズパイpicoのpioは、小さいcpuです。
verilogが手に入ったのでやってみた。

参考にしたページ

rp2040のpio

PIOにはステートマシンという小さなRISC CPUが4つ内蔵されており、ステートマシンのためのプログラムを書くことにより、プロトコルを実装します。
image.png

cpuの仕様

  • 命令
    命令は、9個
    命令長は、16bit
    メモリーは、32語
  • レジスタ
    受信シフトレジスタ
    送信シフトレジスタ
    受信バッファ
    送信バッファ
    プログラムカウンタ
    アキュムレータ
命令 命令コード 内容
JMP 0 0 0 Delay/side-set Condition Address 条件分岐。
WAIT 0 0 1 Delay/side-set Pol Source Index 一定の条件が成立するまで停止。
IN 0 1 0 Delay/side-set Source Bit count 受信シフトレジスタへビット列を読み込む。
OUT 0 1 1 Delay/side-set Destination Bit count 送信シフトレジスタからビット列を書き出す。
PUSH 1 0 0 Delay/side-set 0 IfF Blk 0 0 0 0 0 受信シフトレジスタから受信バッファへデータを読み出す。
PULL 1 0 0 Delay/side-set 1 IfE Blk 0 0 0 0 0 送信バッファから送信シフトレジスタへデータを書き出す。
MOV 1 0 1 Delay/side-set Destination Op Source レジスタ等の間でデータをコピーする。
IRQ 1 1 0 Delay/side-set 0 Clr Wait Index 割り込みフラグの読み書き。
SET 1 1 1 Delay/side-set Destination Data GPIOピンやレジスタに即値を書き込む。

ディスアセンブラを書いた。

アセンブラを書いた。

アセンブラ
      .wrap_target
      0: set    pins, 1                    
      1: set    pins, 0                    
      .wrap


バイナリー
e101
e100


逆アセンブル
.program test
    set pins 1 [1]
    set pins 0 [1]

以上。

2
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
2
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?