lowRISC / lowRISC/opentitan

[spi_device] Hardcoded flash command values

Open
#25,945 0 comments 0 reactions 0 assignees View on GitHub
IP:spi_device Type:Enhancement
Dominant language
SystemVerilog
Stars
3.6k
Forks
1.1k
Avg merge
2d 22h
Merged PRs (30d)
141

Description

### Description

It seems that the RTL code defines common 25-series flash device commands twice as
- `spi_flash_cmd_e` in `spi_cmdparse.sv`, and
- `spi_cmd_e` in `spi_deive_pkg.sv`

However those definitions are not actually referenced elsewhere in the RTL code, and are only used in the DV files.

What only seem to matter for the SPI device implementation is the [index/position of the command](https://opentitan.org/book/hw/ip/spi_device/doc/theory_of_operation.html#command-information-list) within the CMD_INFO registers, not there actual values that should be defined by the SW.

Maybe it's a left over from a previous implementation - or is it on purpose (?). It seems the definitions are duplicated anyway. It might be useful, _i.e._ help readability, to move these definitions where they are used (DV files) and only keep a single copy of them.

Contributor guide

Open the contributing guide

Research direction

Start by comparing the duplicated command definitions in spi_cmdparse.sv and spi_deive_pkg.sv, then search the RTL and DV files for their uses. Confirm whether the RTL needs the command values or only CMD_INFO positions; done means the definitions have one appropriate home without changing SPI device behavior.

Written by the indexing model from the issue text.

Assessment

Domain
embedded-iot
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.