Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faster SPI flash controller #29

Open
BrunoLevy opened this issue Jan 16, 2021 · 11 comments
Open

Faster SPI flash controller #29

BrunoLevy opened this issue Jan 16, 2021 · 11 comments
Labels
enhancement New feature or request

Comments

@BrunoLevy
Copy link
Owner

There is (a lot of) room for improvement in the SPI flash controller:

  • use a DDR block instead of freq/2 clock
  • use faster SPI modes
  • use dual IO SPI mode
  • check whether the pins for quadspi are wired on the IceStick
@BrunoLevy BrunoLevy added the enhancement New feature or request label Jan 16, 2021
@BrunoLevy
Copy link
Owner Author

  • Now using "fast read dual input" command.
  • Tried to use "fast read dual IO" command (faster, saves 12 cycles by inputting address on two pins), no success for now
  • Would be good to add XIP support (will save 8 additional cycles), but requires command to modify a register on the chip (will need additional logic, and can't afford the LUTs on the IceStick)

@BrunoLevy
Copy link
Owner Author

  • "fast read dual IO" command works
  • Now working on XIP (adding a "control register", will see what it gives in terms of LUTs)

@Mecrisp
Copy link
Contributor

Mecrisp commented Jan 25, 2021

Trying the latest changes gives:

  • touch firmware.hex
  • Copied icestick_spi_flash_config.v to icestick_config.v
  • make ICESTICK.synth
yosys -DICE_STICK -q -p "synth_ice40 -relut -top femtosoc -json femtosoc.json" RTL/femtosoc.v
Warning: Yosys has only limited support for tri-state logic at the moment. (RTL/DEVICES/MappedSPIFlash.v:50)
ERROR: Module `\EHXPLLL' referenced in module `\HDMI_clock' in cell `\pll_i' is not part of the design.

@BrunoLevy
Copy link
Owner Author

Hi Matthias,
This is because the currently pushed version is configured for the ULX3S
To configure it for the IceStick:
Edit RTL/femtosoc_config.v and select CONFIGS/icestick_config.v instead of CONFIGS/ulx3s_config.v

@BrunoLevy
Copy link
Owner Author

I meant CONFIGS/icestick_spi_flash_config.v
(and edit it as well to select the devices you want or not)

@Mecrisp
Copy link
Contributor

Mecrisp commented Jan 25, 2021

I see, thank you: Up and running now, feels faster !

@BrunoLevy
Copy link
Owner Author

Cool ! Thank you for letting me know (I tested again, but I'm always afraid of breaking smthg ! When you have multiple board, it is very easy to break something without noticing !).

The current version uses 44 clocks for each 32-bits access, we could go faster:

  • There is an "XIP" mode that uses 36 clocks and a configurable dummy cycles that could save another 4 cycles (32 cycles in the end), but I did not manage to activate them...

  • I could also probably need only 16 cycles for consecutive addresses (at the expense of a 22 bits reg + compare, which I probably cannot afford in terms of LUT budget).

@Mecrisp
Copy link
Contributor

Mecrisp commented Jan 25, 2021

You have a lot of configuration options, I like that ! I usually have a folder for each target separately, and common folder(s) for the parts that can be reused. Maintaining all the switches for different targets in the same target-specific files is something I would avoid. You'll end up with some duplicated glue code, but it improves readability for the ones that use one target only.

Speed is acceptable now, and you should leave a few LUTs for experiments of your students.

Did you follow the idea to change the processors register set in order to get 7 kb available RAM on Icestick ?

@Mecrisp
Copy link
Contributor

Mecrisp commented Jan 25, 2021

A good place to draw the line is between CPU+RAM in a common module, with options for size/SPI execution/reset vector, and a separate target-specific Verilog file to wire in the peripherals for each target.

In my experience with Mecrisp-Ice, I usually drop the same CPU/Memory/Forth module into my new projects and rewrite the IO part every time to fit the current use case, with the Forth core itself having a dependency on the terminal IO registers only.

@BrunoLevy
Copy link
Owner Author

Did you follow the idea to change the processors register set in order to get 7 kb available RAM on Icestick ?
Not yet, I mainly worked on the ULX3S version and its OS in the last few days.

About files organization, I'm trying different things, no organization is perfect, I'll probably reorganize everything several times. For now it works reasonably well for the different projects, but I'll probably change it when the number of supported boards will increase.

About LUTs, I have an idea that may save 40 to 50 LUTs: the SPI flash controller has a 40 bits and a 32 bits shift register, maybe I can replace them with 8-bits shift registers used several times (but I do not like it very much, it adds some complexity...)

@BrunoLevy
Copy link
Owner Author

Pushed new version, now using a single 40 bits shifter (for both send and receive), and a single 5 bits clock counter, saves 50-80 LUTs !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants