-
Notifications
You must be signed in to change notification settings - Fork 6
/
host_intf.py
37 lines (29 loc) · 974 Bytes
/
host_intf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from myhdl import *
class HostIntf(object):
def __init__(self):
# Host side signals
self.rst_i = ResetSignal(0, active=1, async=True)
self.rd_i = Signal(bool(0))
self.wr_i = Signal(bool(0))
self.addr_i = Signal(intbv(0)[24:]) # host side address = sdram side row + col + bank
self.data_i = Signal(intbv(0)[16:])
self.data_o = Signal(intbv(0)[16:])
self.done_o = Signal(bool(0))
self.rdPending_o = Signal(bool(0))
def read(self, addr):
self.addr_i.next = addr
self.rd_i.next = 1
yield delay(2)
self.rd_i.next = 0
def write(self, addr, data):
self.addr_i.next = addr
self.data_i.next = data
yield delay(5)
self.wr_i.next = 1
def nop(self):
self.rd_i.next = 0
self.wr_i.next = 0
def wait_until_done(self):
yield self.done_o.posedge
def read_data(self):
return self.data_o.val