Skip to content

Commit

Permalink
build/efinix/ifacewriter: adding internal Ti60F100 SPI Flash support
Browse files Browse the repository at this point in the history
Signed-off-by: Gwenhael Goavec-Merou <[email protected]>
  • Loading branch information
trabucayre committed Oct 25, 2023
1 parent 69dc666 commit ba2913f
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions litex/build/efinix/ifacewriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,54 @@ def generate_hyperram(self, block, verbose=True):

return '\n'.join(cmd) + '\n'

def generate_spiflash(self, block, verbose=True):
pads = block["pads"]
name = block["name"]
location = block["location"]
mode = block["mode"]

assert mode in ["x1"] # FIXME: support x4
assert location == "SPI_FLASH0"

dq0 = pads.mosi.name
dq1 = pads.miso.name
dq2 = pads.wp.name
dq3 = pads.hold.name

cmd = []
cmd.append('design.create_block("{}", "SPI_FLASH")'.format(name))
cmd.append('design.set_property("{}", "MULT_CTRL_EN","0","SPI_FLASH")'.format(name))
cmd.append('design.set_property("{}", "REG_EN","0","SPI_FLASH")'.format(name))
cmd.append('design.set_property("{}", "CLK_PIN","","SPI_FLASH")'.format(name)) # only required when REG_EN==1
cmd.append('design.set_property("{}", "RW_WIDTH","{}","SPI_FLASH")'.format(name, mode))

cmd.append('design.set_property("{}", "CS_N_OUT_PIN","{}","SPI_FLASH")'.format(name, pads.cs_n.name))
cmd.append('design.set_property("{}", "SCLK_OUT_PIN","{}","SPI_FLASH")'.format(name, pads.clk.name))
cmd.append('design.set_property("{}", "MOSI_OUT_PIN","{}","SPI_FLASH")'.format(name, dq0))
cmd.append('design.set_property("{}", "MISO_IN_PIN","{}","SPI_FLASH")'.format(name, dq1))
cmd.append('design.set_property("{}", "WP_N_OUT_PIN","{}","SPI_FLASH")'.format(name, dq2))
cmd.append('design.set_property("{}", "HOLD_N_OUT_PIN","{}","SPI_FLASH")'.format(name, dq3))

if mode == "x4":
cmd.append('design.set_property("{}", "HOLD_N_IN_PIN","{}","SPI_FLASH")'.format(name, dq3_i))
cmd.append('design.set_property("{}", "HOLD_N_OE_PIN","{}","SPI_FLASH")'.format(name, dq3_oe))
cmd.append('design.set_property("{}", "MISO_OUT_PIN","{}","SPI_FLASH")'.format(name, dq1_o))
cmd.append('design.set_property("{}", "MISO_OE_PIN","{}","SPI_FLASH")'.format(name, dq1_oe))
cmd.append('design.set_property("{}", "MOSI_IN_PIN","{}","SPI_FLASH")'.format(name, dq0_i))
cmd.append('design.set_property("{}", "MOSI_OE_PIN","{}","SPI_FLASH")'.format(name, dq0_oe))
cmd.append('design.set_property("{}", "WP_N_IN_PIN","{}","SPI_FLASH")'.format(name, dq2_i))
cmd.append('design.set_property("{}", "WP_N_OE_PIN","{}","SPI_FLASH")'.format(name, dq2_oe))

# mult ctrl en only
#cmd.append('design.set_property("{}", "CS_N_OE_PIN","{}","SPI_FLASH")'.format(name, cs_n_oe))
#cmd.append('design.set_property("{}", "SCLK_OE_PIN","{}","SPI_FLASH")'.format(name, clk_oe))

cmd.append('design.assign_resource("{}", "{}","SPI_FLASH")\n'.format(name, location))

cmd.append('design.set_device_property("ext_flash","EXT_FLASH_CTRL_EN","0","EXT_FLASH")')

return '\n'.join(cmd) + '\n'

def generate(self, partnumber):
output = ""
for block in self.blocks:
Expand All @@ -502,6 +550,8 @@ def generate(self, partnumber):
output += self.generate_hyperram(block)
if block["type"] == "JTAG":
output += self.generate_jtag(block)
if block["type"] == "SPI_FLASH":
output += self.generate_spiflash(block)
return output

def footer(self):
Expand Down

0 comments on commit ba2913f

Please sign in to comment.