forked from M-Labs/artiq
1
0
Fork 0

soc: optimize programmable identifier

This commit is contained in:
Sebastien Bourdeauducq 2020-03-12 23:09:13 +08:00
parent 9e66dd7075
commit 4a8d361ace
1 changed files with 8 additions and 15 deletions

View File

@ -34,21 +34,14 @@ class ReprogrammableIdentifier(Module, AutoCSR):
raise ValueError("Identifier string must be 255 characters or less") raise ValueError("Identifier string must be 255 characters or less")
contents.insert(0, l) contents.insert(0, l)
init_params = {i: 0 for i in range(0x40)} for i in range(8):
for i, c in enumerate(contents): self.specials += Instance("ROM256X1", name="identifier_str"+str(i),
# 0x38 was determined empirically. Another Xilinx mystery. i_A0=self.address.storage[0], i_A1=self.address.storage[1],
row = 0x38 + i//32 i_A2=self.address.storage[2], i_A3=self.address.storage[3],
col = 8*(i % 32) i_A4=self.address.storage[4], i_A5=self.address.storage[5],
init_params[row] |= c << col i_A6=self.address.storage[6], i_A7=self.address.storage[7],
init_params = {"p_INIT_{:02X}".format(k): v for k, v in init_params.items()} o_O=self.data.status[i],
p_INIT=sum(1 << j if c & (1 << i) else 0 for j, c in enumerate(contents)))
self.specials += Instance("RAMB18E1", name="identifier_str",
i_ADDRARDADDR=Cat(C(0, 3), self.address.storage),
i_CLKARDCLK=ClockSignal(),
o_DOADO=self.data.status,
i_ENARDEN=1,
p_READ_WIDTH_A=9,
**init_params)
def add_identifier(soc, *args, **kwargs): def add_identifier(soc, *args, **kwargs):