Python에서 FPGA/iCEcube2 사용 (L 치카로 시작)
Lattice 도구 iCEcube2 사용
오랜만에 기동하면 라이센스가 끊어지고 있다는 것. 라이센스 페이지로 가서 라이센스를 발급합니다. 확인사항 후 메일로 라이센스가 보내지므로 소정의 장소(c:\lscc\License)에 license.dat 를 둡니다.
htps //w w.ぁちせせみ. 코 m / 자 JP / 삿포 rt / 센신 g

오래간만이므로 L치카로 시작한다
그리고 시행 착오의 결과로 Lattice 도구를 사용하는 방법을 완전히 잊어 버렸다는 것을 알았습니다. 초심으로 돌아가겠습니다. L 치카에서 시작합시다.
New Project
iCE40UP용 프로젝트를 만듭니다.

L 치카 컴파일
아니, 그 전에 Python에서 실행하십시오.
blink.pyfrom polyphony import testbench, module, is_worker_running
from polyphony.io import Port
from polyphony.timing import wait_value
from polyphony.typing import bit
@module
class Blink:
def __init__(self, interval):
self.led = Port(bit, 'out')
self.interval = interval
self.append_worker(self.main)
def main(self):
led_bit:bit = 1
while is_worker_running():
self.led(led_bit)
led_bit = 1 - led_bit
self._wait()
def _wait(self):
for i in range(self.interval // 2):
pass
@testbench
def test(dut):
v = 0
for i in range(4):
print("loop:", i)
wait_value(1, dut.led)
wait_value(0, dut.led)
print("finished")
blink = Blink(125 * 1000 * 1000)
test(blink)
Python3으로 시뮬레이션
python3에서 실행> python3 blink.py
loop: 0
loop: 1
loop: 2
loop: 3
finished
컴파일
컴파일> polyphony blink.py
> ls Blink_blink.v
Blink_blink.v
Design Files에 추가

TOP 모듈도 추가
위의 그림은 이미 TOP 모듈도 추가되어 있습니다. TOP 모듈에는 LED 모듈이 추가되었습니다. 이 근처는 iCE40UP 특유의 쓰는 방법이므로 참을 수 없다고 생각해 추가합니다. RGB0, RGB1의 PWM에 1'b0을 쓰고 있기 때문에 RED와 BLUE는 빛나지 않습니다.
led_top.vmodule led_top (
input wire clk, // 27M clock
output wire RED_N,
output wire GREEN_N,
output wire BLUE_N);
//----------------------------------------------------------------
wire green_wire;
//----------------------------------------------------------------
Blink_blink U0 (
.clk(clk),
.rst(1'b0),
.led(green_wire)
);
//------------------------------
// Instantiate RGB primitives
//------------------------------
SB_RGBA_DRV RGB_DRIVER (
.RGBLEDEN (1'b1),
.RGB0PWM (1'b0),
.RGB1PWM (green_wire),
.RGB2PWM (1'b0),
.CURREN (1'b1),
.RGB0 (RED_N),
.RGB1 (GREEN_N),
.RGB2 (BLUE_N)
);
defparam RGB_DRIVER.RGB0_CURRENT = "0b000001";
defparam RGB_DRIVER.RGB1_CURRENT = "0b000001";
defparam RGB_DRIVER.RGB2_CURRENT = "0b000001";
endmodule
핀 배치도 추가
Pin Constraints Editor를 클릭하면 에디터가 나오므로 RBB의 각 핀을 설정합니다.

Bitmap 파일 만들기
나머지는 왼쪽의 Run P&R을 하나씩 클릭하면 합성할 수 있습니다.
다운로드
다운로드는 Diamond Programmer라는 다른 프로그램을 시작합니다.

보드를 연결
보드를 연결하고 J6을 PROG ICE로 설정하십시오.
프로그램 지정
Device Properties ...에서 Progarmming file을 지정합니다.

다운로드 실행
Program 버튼을 누르면 다운로드가 시작되고 훌륭하게 Green LED가 눈부시게 깜박입니다.
Reference
이 문제에 관하여(Python에서 FPGA/iCEcube2 사용 (L 치카로 시작)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/ryos36/items/90ce319851f92117d71e
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
from polyphony import testbench, module, is_worker_running
from polyphony.io import Port
from polyphony.timing import wait_value
from polyphony.typing import bit
@module
class Blink:
def __init__(self, interval):
self.led = Port(bit, 'out')
self.interval = interval
self.append_worker(self.main)
def main(self):
led_bit:bit = 1
while is_worker_running():
self.led(led_bit)
led_bit = 1 - led_bit
self._wait()
def _wait(self):
for i in range(self.interval // 2):
pass
@testbench
def test(dut):
v = 0
for i in range(4):
print("loop:", i)
wait_value(1, dut.led)
wait_value(0, dut.led)
print("finished")
blink = Blink(125 * 1000 * 1000)
test(blink)
> python3 blink.py
loop: 0
loop: 1
loop: 2
loop: 3
finished
> polyphony blink.py
> ls Blink_blink.v
Blink_blink.v
module led_top (
input wire clk, // 27M clock
output wire RED_N,
output wire GREEN_N,
output wire BLUE_N);
//----------------------------------------------------------------
wire green_wire;
//----------------------------------------------------------------
Blink_blink U0 (
.clk(clk),
.rst(1'b0),
.led(green_wire)
);
//------------------------------
// Instantiate RGB primitives
//------------------------------
SB_RGBA_DRV RGB_DRIVER (
.RGBLEDEN (1'b1),
.RGB0PWM (1'b0),
.RGB1PWM (green_wire),
.RGB2PWM (1'b0),
.CURREN (1'b1),
.RGB0 (RED_N),
.RGB1 (GREEN_N),
.RGB2 (BLUE_N)
);
defparam RGB_DRIVER.RGB0_CURRENT = "0b000001";
defparam RGB_DRIVER.RGB1_CURRENT = "0b000001";
defparam RGB_DRIVER.RGB2_CURRENT = "0b000001";
endmodule
Reference
이 문제에 관하여(Python에서 FPGA/iCEcube2 사용 (L 치카로 시작)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/ryos36/items/90ce319851f92117d71e텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)