vista에서 quartus 그 21

5259 단어 FPGAquartusPolyphony

개요



vista에서 quartus 해 보았다.
7seg led, 빛나게 해 보았다.
polyphony로 써 보았다.
0을 표시해 보았다.

환경



windows vista 32bit
quartus ii v13.0
polyphony v0.3.6
ep2c5t144 보드
qyf-tm1638 보드

사진





연결


vcc -- 5v 
dio -- pin25
clk -- pin24
stb -- pin8
gnd -- gnd

샘플 코드


from polyphony import module, testbench, is_worker_running
from polyphony.io import Port
from polyphony.typing import bit, bit8
from polyphony.timing import clksleep, clkfence, wait_value

@module
class boss:
    def __init__(self):
        self.busy = Port(bit, 'in')
        self.stb = Port(bit, 'out', 1)
        self.start = Port(bit, 'out', 0)
        self.data = Port(bit8, 'out', 1)
        self.h = [0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00]
        self.append_worker(self.main_worker)
    def main_worker(self):
        i = 0
        while is_worker_running():
            self.start.wr(0)
            if (i < 1):
                wait_value(0, self.busy)
                self.start.wr(0)
                self.stb.wr(1)

                self.data(0x88)
                self.stb.wr(0)
                self.start.wr(1)
                clksleep(3)
                wait_value(0, self.busy)
                self.start.wr(0)
                self.stb.wr(1)

                self.data(0x40)
                self.stb.wr(0)
                self.start.wr(1)
                clksleep(3)
                wait_value(0, self.busy)
                self.start.wr(0)
                self.stb.wr(1)

                self.data(0xc0)
                self.stb.wr(0)
                self.start.wr(1)
                clksleep(3)
                wait_value(0, self.busy)
                self.start.wr(0)

                self.data(self.h[0])
                self.start.wr(1)
                clksleep(3)
                wait_value(0, self.busy)
                self.start.wr(0)

                self.data(0x01)
                self.start.wr(1)
                clksleep(3)
                wait_value(0, self.busy)
                self.start.wr(0)

                self.data(self.h[1])
                self.start.wr(1)
                clksleep(3)
                wait_value(0, self.busy)
                self.start.wr(0)

                self.data(0x01)
                self.start.wr(1)
                clksleep(3)
                wait_value(0, self.busy)
                self.start.wr(0)

                self.data(self.h[2])
                self.start.wr(1)
                clksleep(3)
                wait_value(0, self.busy)
                self.start.wr(0)

                self.data(0x01)
                self.start.wr(1)
                clksleep(3)
                wait_value(0, self.busy)
                self.start.wr(0)

                self.data(self.h[3])
                self.start.wr(1)
                clksleep(3)
                wait_value(0, self.busy)
                self.start.wr(0)

                self.data(0x01)
                self.start.wr(1)
                clksleep(3)
                wait_value(0, self.busy)
                self.start.wr(0)

                self.data(self.h[4])
                self.start.wr(1)
                clksleep(3)
                wait_value(0, self.busy)
                self.start.wr(0)

                self.data(0x01)
                self.start.wr(1)
                clksleep(3)
                wait_value(0, self.busy)
                self.start.wr(0)

                self.data(self.h[5])
                self.start.wr(1)
                clksleep(3)
                wait_value(0, self.busy)
                self.start.wr(0)

                self.data(0x01)
                self.start.wr(1)
                clksleep(3)
                wait_value(0, self.busy)
                self.start.wr(0)

                self.data(self.h[6])
                self.start.wr(1)
                clksleep(3)
                wait_value(0, self.busy)
                self.start.wr(0)

                self.data(0x01)
                self.start.wr(1)
                clksleep(3)
                wait_value(0, self.busy)
                self.start.wr(0)

                self.data(self.h[7])
                self.start.wr(1)
                clksleep(3)
                wait_value(0, self.busy)
                self.start.wr(0)

                self.data(0x01)
                self.start.wr(1)
                clksleep(3)
                wait_value(0, self.busy)
                self.stb.wr(1)
                self.start.wr(0)

                self.data(0x88)
                self.stb.wr(0)
                self.start.wr(1)
                clksleep(3)
                wait_value(0, self.busy)
                self.stb.wr(1)
                self.start.wr(0)
                i = i + 1

m = boss()

@testbench
def test(m):
    m.busy.wr(0)
    for i in range(20):
        wait_value(1, m.start)
        m.busy.wr(1)
        data = m.data.rd()
        print(data)
        m.busy.wr(0)

test(m)






이상.

좋은 웹페이지 즐겨찾기