일 worker "토요일 밤과 일요일 아침"
Polyphony의 worker는 불평하지 않고 상주한다. 작업자는 함수 (메소드)로 표현되며 init에서 append_worker로 작업자로 등록됩니다.
위 그림과 같이 이것만이라면 그냥 무한 루프로 아무것도 생산하지 않는다. Port 또는 Queue를 사용하여 외부 또는 다른 Worker와 통신합니다. 소프트웨어의 의미 적으로는 Port보다 Queue 쪽을 알기 쉽다. Port는 어떤 시점에서 어떤 정보가 오는지 디자이너가 파악해야 한다. HDL이 필요로하는 시계 개념에 묶여 있습니다. 고위 합성은 클럭으로부터의 해방을 향하고자 하는 기술이기 때문에, 이 손의 시간적 개념을 취급하는 인터페이스와 어울리는 궁합이 나쁘다.
여기에서는 간단한 평균 필터를 써 보자. Queue 를 사용해 입력과 출력을 하고 있다.
ave_filter.py
from polyphony import rule
import polyphony
from polyphony import is_worker_running
from polyphony.io import Port, Queue
from polyphony.typing import bit, int8, int16, int18
from polyphony.timing import clksleep, clkfence, wait_rising, wait_falling
@polyphony.module
class Filter:
def __init__(self):
self.q = Queue(int16, 'out', maxsize=10)
self.din = Queue(int16, 'in', maxsize=10)
self.append_worker(self.proc)
def proc(self):
a0:int18 = 0
a1:int18 = 0
a2:int18 = 0
a3:int18 = 0
while is_worker_running():
self.q.wr(a0 >> 2)
data:int16 = self.din.rd()
a0 = a1 + data
a1 = a2 + data
a2 = a3 + data
a3 = data
@polyphony.testbench
def test(m):
datas = (0x5ead, 0x3eef, 0x7fff, 0x0000, 0x800)
for data in datas:
m.din.wr(data)
for i in range(5):
print(m.q.rd())
clksleep(10)
if __name__ == '__main__':
filter = Filter()
test(filter)
Polyphony의 코드는 Python이므로 Python에서 실행할 수 있습니다. 본래라면 Python으로 디버깅을 완료하고 시뮬레이션하기
$ python ave_filter.py
0
6059
10087
18278
18278
생성 된 Verilog-HDL은 조금 복잡합니다. 알기 쉽게 Vivado에 그림을 그려 달라고 하자.
Fitler_filter.v
module Filter_filter
(
input wire clk,
input wire rst,
input wire signed [15:0] din_dout,
input wire din_empty,
output reg din_read,
input wire q_full,
output reg signed [15:0] q_din,
output reg q_write
);
Reference
이 문제에 관하여(일 worker "토요일 밤과 일요일 아침"), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/ryos36/items/ab382141a0564eb023ce텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)