Example #1
0
 def main(self):
     #print('main')
     while is_worker_running():
         wait_rising(self.clk1)
         wait_rising(self.clk2)
         msg('rising', self.clk1(), self.clk2())
         self.out1.wr(1)
Example #2
0
def pow(idata, ivalid, odata, ovalid):
    while is_worker_running():
        wait_rising(ivalid)
        d = idata.rd()
        odata.wr(d * d)
        clkfence()
        ovalid.wr(True)
        ovalid.wr(False)
Example #3
0
def test(m):
    m.idata.wr(2)
    m.ivalid.wr(True)
    m.ivalid.wr(False)
    wait_rising(m.ovalid)
    assert m.odata.rd() == 256

    m.idata.wr(4)
    m.ivalid.wr(True)
    m.ivalid.wr(False)
    wait_rising(m.ovalid)
    assert m.odata.rd() == 65536
Example #4
0
def test(spic):
    datas = (0xdead, 0xbeef, 0xffff, 0x0000, 0x800)
    for data in datas:
        print(data)
        wait_falling(spic.convst_n)
        print('convst_n fall', spic.convst_n())
        wait_rising(spic.convst_n)
        print('convst_n rise', spic.convst_n())
        wait_falling(spic.cs_n)
        print('cs_n fall', spic.cs_n())
        spic.din.wr(0b1111000011110000)
        for i in range(16):
            databit = 1 if data & (1 << (15 - i)) else 0
            spic.sdo.wr(databit)
            wait_rising(spic.sclk)

        wait_rising(spic.cs_n)
        wait_rising(spic.data_ready)
        clksleep(1)
        assert spic.dout() == data & 0x0fff
        assert spic.chout() == (data & 0x7000) >> 12
 def w(self, p):
     p.wr(1)
     wait_rising(p)
Example #6
0
 def w(self, p):
     wait_rising(p)
     p.wr(1)
 def w(self, p):
     wait_rising()