10. FPGA vs Raspberry PI
• FPGA • Raspberry PI
ARM SoCARM SoC FPGA
u-boot & Linuxu-boot & Linux
Linux Driver Linux Driver
Python Python
やりたいこと やりたいこと
値段とか消費電力とか入手性とかを無視して、ソフト的にざっくりと比較
コミュニティの大きさ(情報の入りやすさ)もだいぶ違うけど、、、
13. VHDL を使った問題
signal x: std_logic
…
process (clk)
variable y : std_logic;
begin
if clk’event and clk = 1 then
y := x + 1
x <= x + 1
end if;
end process;
Q: x はいま 3 とします。
左辺にある y と x は
いくつになるでしょう?
14. VHDL を使った問題
signal x: std_logic
…
process (clk)
variable y : std_logic;
begin
if clk’event and clk = 1 then
y := x + 1
x <= x + 1
end if;
end process;
A:
y は 4、
x は 3のまま。
次のクロックで 4。
何を意味してい
るのか?
15. FPGA でパイプライン処理
処理 処理 処理 処理 処理
処理を細分化することで高速化が可能
x + 1
x
x + 1
x
頭の中でオーバラップする時間を
考えながら設計する!!
何を意味してい
るのか?
23. What is Polyphony?(2/3)
Python Polyphony
Verilog HDL
(synthesizable)
● Bring higher level of abstraction to your design
● Allow designers to focus on developing the algorithm
● Reduce costs for program maintenance
● Open Source (https://github.com/ktok07b6/polyphony)
25. まずは Lチカ、、、
• こんな感じでできます
from polyphony import testbench, module, is_worker_running
from polyphony.io import Bit
@module
class Blink:
def __init__(self):
self.led = Bit(0)
self.append_worker(self.main, led)
def main(self):
led = 1
while is_worker_running():
self.led.wr(led)
led = ~led
self._wait(10000000)
def _wait(self, interval):
for i in range(interval):
pass
blink = Blink()
26. Fibonacci Number(フィボナッチ数列)
#from polyphony import testbench
def fib(n):
if n <= 0: return 0
if n == 1: return 1
r0 = 0
r1 = 1
for i in range(n-1):
prev_r1 = r1
r1 = r0 + r1
r0 = prev_r1
return r1
#@testbench
def test():
expect = [0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610]
for i in range(len(expect)):
result = fib(i)
assert expect[i] == result
print(i, "=>", result)
test()
30. ちょっと脱線
@polyphony.pure
def bitonic_indices(size, blocks, offset):
for i in range(0, size):
if (i % (offset << 1)) >= offset:
continue
direction = ASCENDING if (i // blocks) % 2 == 0 else DESCENDING
ii = i + offset
yield i, ii, direction
• bitonic_sort : バイトニックソートのサンプル
特別なデコレータ
Python により“動的に”回路図を自動生成