2015-04-17 07:45:01 -04:00
|
|
|
from migen.fhdl.std import *
|
|
|
|
from migen.genlib.record import *
|
2015-04-27 08:59:29 -04:00
|
|
|
from migen.genlib.misc import reverse_bytes
|
2015-04-17 07:45:01 -04:00
|
|
|
from migen.flow.actor import *
|
2015-04-27 08:59:29 -04:00
|
|
|
from migen.actorlib.packet import Arbiter, Dispatcher
|
2015-04-17 07:45:01 -04:00
|
|
|
|
|
|
|
KB = 1024
|
|
|
|
MB = 1024*KB
|
|
|
|
GB = 1024*MB
|
|
|
|
|
|
|
|
|
|
|
|
def get_bar_mask(size):
|
|
|
|
mask = 0
|
|
|
|
found = 0
|
|
|
|
for i in range(32):
|
|
|
|
if size%2:
|
|
|
|
found = 1
|
|
|
|
if found:
|
|
|
|
mask |= (1 << i)
|
|
|
|
size = size >> 1
|
|
|
|
return mask
|
|
|
|
|
|
|
|
def phy_layout(dw):
|
|
|
|
layout = [
|
|
|
|
("dat", dw),
|
|
|
|
("be", dw//8)
|
|
|
|
]
|
|
|
|
return EndpointDescription(layout, packetized=True)
|
|
|
|
|
|
|
|
|
|
|
|
def request_layout(dw):
|
|
|
|
layout = [
|
|
|
|
("we", 1),
|
|
|
|
("adr", 32),
|
|
|
|
("len", 10),
|
|
|
|
("req_id", 16),
|
|
|
|
("tag", 8),
|
|
|
|
("dat", dw),
|
|
|
|
("channel", 8), # for routing
|
|
|
|
("user_id", 8) # for packet identification
|
|
|
|
]
|
|
|
|
return EndpointDescription(layout, packetized=True)
|
|
|
|
|
|
|
|
|
|
|
|
def completion_layout(dw):
|
|
|
|
layout = [
|
|
|
|
("adr", 32),
|
|
|
|
("len", 10),
|
|
|
|
("last", 1),
|
|
|
|
("req_id", 16),
|
|
|
|
("cmp_id", 16),
|
|
|
|
("err", 1),
|
|
|
|
("tag", 8),
|
|
|
|
("dat", dw),
|
|
|
|
("channel", 8), # for routing
|
|
|
|
("user_id", 8) # for packet identification
|
|
|
|
]
|
|
|
|
return EndpointDescription(layout, packetized=True)
|
|
|
|
|
|
|
|
|
|
|
|
def interrupt_layout():
|
|
|
|
return [("dat", 8)]
|
|
|
|
|
|
|
|
|
|
|
|
def dma_layout(dw):
|
2015-07-22 15:44:53 -04:00
|
|
|
layout = [("data", dw)]
|
2015-04-17 07:45:01 -04:00
|
|
|
return EndpointDescription(layout, packetized=True)
|