The document discusses Twitter and GitHub accounts, an IPSJ conference, and hardware including an Intel Core i7, FPGA boards from Digilent and ScalableCore, and code snippets for C programs and hardware designs including for a convolutional neural network layer.
Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)Shinya Takamaeda-Y
Veriloggen is a Python library that allows users to generate Verilog HDL code from Python. It provides objects and methods to define RTL modules in Python, including module inputs/outputs, registers, assignments, always blocks, etc. When the Veriloggen object is passed to the to_verilog() method, it traverses the object and generates equivalent Verilog HDL code. This allows rapid prototyping of RTL designs in Python without having to write low-level Verilog code directly.
元は" The 90 minute Scheme to C compiler" Marc Feeley (90-min-scc.pdf) 。元の文章との整合性は保証しないよ。CPS が何かわかって、コンパイラを作ることに興味が出たら幸い。
ただし、これだけではコンパイラはできないよ。Scheme で作りたいなら、http://www.eidos.ic.i.u-tokyo.ac.jp/~tau/lecture/scheme_compiler/gen/resume/all.pdf がおすすめ。
将来的に浮動小数点を含むコンパイラを作りたいなら、あらかじめ OCaml をつかったコンパイラを目指した方がよい(らしい)。
https://esumii.github.io/min-caml/jpaper.pdf
https://github.com/esumii/min-caml
A正規形とK正規形というのもある(らしい)。
http://d.hatena.ne.jp/sumii/20071229/p1
論文のThe Essence of Compiling with Continuations には A 正規形の話があり、CPS が否定されているように思った。
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 により“動的に”回路図を自動生成