host/driver/reg: use burst mode to speed up upload of data (useful with Etherbone)
This commit is contained in:
parent
a802a5c535
commit
861c54760e
|
@ -12,19 +12,24 @@ class MappedReg:
|
||||||
def read(self):
|
def read(self):
|
||||||
if self.mode not in ["rw", "ro"]:
|
if self.mode not in ["rw", "ro"]:
|
||||||
raise KeyError(name + "register not readable")
|
raise KeyError(name + "register not readable")
|
||||||
r = 0
|
datas = self.readfn(self.addr, burst_length=self.length)
|
||||||
for i in range(self.length):
|
if isinstance(datas, int):
|
||||||
r |= self.readfn(self.addr + 4*i)
|
return datas
|
||||||
if i != (self.length-1):
|
else:
|
||||||
r <<= self.busword
|
data = 0
|
||||||
return r
|
for i in range(self.length):
|
||||||
|
data |= datas[i]
|
||||||
|
if i != (self.length-1):
|
||||||
|
data <<= self.busword
|
||||||
|
return data
|
||||||
|
|
||||||
def write(self, value):
|
def write(self, value):
|
||||||
if self.mode not in ["rw", "wo"]:
|
if self.mode not in ["rw", "wo"]:
|
||||||
raise KeyError(name + "register not writable")
|
raise KeyError(name + "register not writable")
|
||||||
|
datas = []
|
||||||
for i in range(self.length):
|
for i in range(self.length):
|
||||||
dat = (value >> ((self.length-1-i)*self.busword)) & (2**self.busword-1)
|
datas.append((value >> ((self.length-1-i)*self.busword)) & (2**self.busword-1))
|
||||||
self.writefn(self.addr + 4*i, dat)
|
self.writefn(self.addr, datas)
|
||||||
|
|
||||||
class MappedRegs:
|
class MappedRegs:
|
||||||
def __init__(self, d):
|
def __init__(self, d):
|
||||||
|
|
Loading…
Reference in New Issue