This document describes the general functionality of flash. As the final feature set will largely depend on how similar flash IPs are, it is at the moment unclear where the open-source / proprietary boundaries should lie. This document thus makes a best effort estimate as to what that boundary should be and breaks the functionality down accordingly.
This document assumes flash functionality shall be divided into two partitions.
The Flash Protocol Controller sits between the host software interface and the physical flash. Its primary function is to translate software requests into a high level protocol for the actual flash block. Importantly, the flash protocol controller shall not be responsible for the detailed timing and waveform control of the flash. Instead, it shall maintain FIFOs / interrupts for the software to process data.
The Flash Physical Controller is the wrapper module that contains the actual flash memory instantiation. It is responsible for converting high level protocol commands (such as read, program, erase) into low level signaling and timing specific to a particular flash IP. It is also responsible for any BIST, redundancy handling, remapping features or custom configurations required for the flash memory.
The diagram below summarizes a high level breakdown.
As the flash physical controller is highly dependent on flash memory selected, the default flash physical controller simply emulates real flash behavior with on-chip memories. The goal of the emulated flash is to provide software developers with a reasonable representation of a well-behaving flash operating under nominal conditions.
Below are the emulated properties
The flash physical controller does NOT emulate the following properties
Depending on need, it may be necessary to add controller logic to perform the following functions
The flash protocol controller uses a simple FIFO interface to communicate between the software and flash physical controller. There is a read fifo for read operations, and a program fifo for program operations. Note, this means flash can be read both through the controller and the main bus interface. This may prove useful if the controller wishes to allocate specific regions to HW FSMs only, but is not a necessary feature.
When software initiates a read transaction of a programmable number of flash words, the flash controller will fill up the read FIFO for software to consume. Likewise, when software initiates a program transaction, software will fill up the program FIFO for the controller to consume.
The controller is designed such that the overall number of words in a transaction can significantly exceed the FIFO depth. In the case of read, once the FIFO is full, the controller will cease writing more entries and wait for software to consume the contents (an interrupt will be triggered to the software to alert it to such an event). In the case of program, the controller will stop writing to flash once all existing data is consumed - it will likewise trigger an interrupt to software to prepare more data. See detailed steps in theory of operation. The following is a diagram of the controller construction as well as its over connectivity with the flash module.
The table below lists the flash protocol controller signals.
Signal | Direction | Description |
---|---|---|
tl_i | input | TileLink-UL input for register access |
tl_o | output | TileLink-UL output for register access |
flash_i | input | Inputs from physical controller, connects to flash_ctrl_o of physical controller |
flash_o | output | Outputs to physical controller, connects to flash_ctrl_i of physical controller |
intr_prog_empty_o | output | Interrupt indicating program fifo is empty |
intr_prog_lvl_o | output | Interrupt indicating program fifo has reached configurable threshold |
intr_rd_full_o | output | Interrupt indicating read fifo is full |
intr_rd_lvl_o | output | Interrupt indicating read fifo has reached configurable threshold |
intr_op_done_o | output | Interrupt indicating flash operation is complete |
intr_op_error_o | output | Interrupt indicating there is a flash operation error |
Each of flash_i
and flash_o
is a struct that packs together additional signals, as shown below
Signal | Source | Destination | Description |
---|---|---|---|
req | protocol controller | physical controller | Protocol controller initiated transaction |
addr | protocol controller | physical controller | Protocol controller initiated transaction address |
rd | protocol controller | physical controller | Protocol controller initiated read |
prog | protocol controller | physical controller | Protocol controller initiated program |
pg_erase | protocol controller | physical controller | Protocol controller initiated page erase |
prog_data | protocol controller | physical controller | Protocol controller initiated program data, 1 flash word wide |
bk_erase | protocol controller | physical controller | Protocol controller initiated bank erase |
rd_done | physical controller | protocol controller | Physical controller read done |
prog_done | physical controller | protocol controller | Physical controller program done |
erase_done | physical controller | protocol controller | Physical controller erase done |
init_busy | physical controller | protocol controller | Physical controller reset release initialization in progress |
rd_data | physical controller | protocol controller | Physical Controller read data, 1 flash word wide |
As the physical controller is IP specific, this section will only try to describe the connecting protocol signals, its function, and the memory allocation of configuration registers.
Signal | Direction | Description |
---|---|---|
host_req_i | input | Host initiated direct read, should always be highest priority. Host is only able to perform direct reads |
host_addr_i | input | Address of host initiated direct read |
host_req_rdy_o | output | Host request ready, ‘1’ implies transaction has been accepted, but not necessarily finished |
host_req_done_o | output | Host request completed |
host_rdata_o | output | Host read data, 1 flash word wide |
flash_ctrl_i | input | Inputs from protocol controller, connects to flash_o of protocol controller |
flash_ctrl_o | output | Outputs to protocol controller, connects to flash_i of protcol controller |
The operation section describes the detailed signaling from the perspective of the physical controller interface
Unlike controller initiated reads, host reads have separate rdy / done signals to ensure transactions can be properly pipelined. As host reads are usually tied to host execution upstream, additional latency can severely harm performance and is not desired. The protocol expected waveform is shown below.
{{< wavejson >}} {signal: [ {name: ‘clk_i’, wave: ‘p..............’}, {name: ‘rst_ni’, wave: ‘0.1............’}, {name: ‘host_req_i’, wave: ‘0..10.1...0....’}, {name: ‘host_addr_i’, wave: ‘x..3x.3.33x....’, data: [‘Adr0’, ‘Adr1’, ‘Adr2’, ‘Adr3’]}, {name: ‘host_req_rdy_o’, wave: ‘1...0..1.......’}, {name: ‘host_req_done_o’, wave: ‘0...10..1110...’}, {name: ‘host_rdata_o’, wave: ‘x...4x..444x...’,data: [‘Dat0’, ‘Dat1’, ‘Dat2’, ‘Dat3’]}, ]} {{< /wavejson >}}
The host_req_done_o
is always single cycle pulsed and upstream logic is expected to always accept and correctly handle the return. The same cycle the return data is posted a new command / address can be accepted. While the example shows flash reads completing in back to back cycles, this is typically not the case.
Unlike host reads, controller reads are not as performance critical and do not have command / data pipeline requirements. Instead, the protocol controller will hold the read request and address lines until the done is seen. Once the done is seen, the controller then transitions to the next read operation. See expected waveform below.
{{< wavejson >}} {signal: [ {name: ‘clk_i’, wave: ‘p..............’}, {name: ‘rst_ni’, wave: ‘0.1............’}, {name: ‘flash_ctrl_i.req’, wave: ‘0..1.....0.....’}, {name: ‘flash_ctrl_i.addr’, wave: ‘x..3..3..x.3..x’, data: [‘Adr0’, ‘Adr1’, ‘Adr2’]}, {name: ‘flash_ctrl_i.rd’, wave: ‘0..1.....0.1..0’}, {name: ‘flash_ctrl_o.rd_done’, wave: ‘0....10.10...10’}, {name: ‘flash_ctrl_o.rdata’, wave: ‘x....4x.4x...4x’, data: [‘Dat0’, ‘Dat1’, ‘Dat2’]}, ]} {{< /wavejson >}}
Program behavior is similar to reads. The protocol controller will hold the request, address and data lines until the programming is complete.
{{< wavejson >}} {signal: [ {name: ‘clk_i’, wave: ‘p..............’}, {name: ‘rst_ni’, wave: ‘0.1............’}, {name: ‘flash_ctrl_i.req’, wave: ‘0..1.....0.....’}, {name: ‘flash_ctrl_i.addr’, wave: ‘x..3..3..x.3..x’, data: [‘Adr0’, ‘Adr1’, ‘Adr2’]}, {name: ‘flash_ctrl_i.prog’, wave: ‘0..1.....0.1..0’}, {name: ‘flash_ctrl_o.prog_data’, wave: ‘x..4..4..x.4..x’, data: [‘Dat0’, ‘Dat1’, ‘Dat2’]}, {name: ‘flash_ctrl_o.prog_done’, wave: ‘0....10.10...10’}, ]} {{< /wavejson >}}
To issue a flash read, the programmer must
The above fields can be set in the {{< regref “CONTROL” >}} and {{< regref “ADDR” >}} registers. See library code for implementation.
It is acceptable for total number of flash words to be significantly greater than the depth of the read FIFO. In this situation, the read FIFO will fill up (or hit programmable fill value), pause the flash read and trigger an interrupt to software. Once there is space inside the FIFO, the controller will resume reading until the appropriate number of words have been read. Once the total count has been reached, the flash controller will post OP_DONE in the {{< regref “OP_STATUS” >}} register.
To program flash, the same procedure as read is followed. However, instead of setting the {{< regref “CONTROL” >}} register for read operation, a program operation is selected instead. Software will then fill the program FIFO and wait for the controller to consume this data. Similar to the read case, the controller will automatically stall when there is insufficient data in the FIFO. When all desired words have been programmed, the controller will post OP_DONE in the {{< regref “OP_STATUS” >}} register.
The flash protocol controller maintains two separate access windows for the FIFO. It is implemented this way because the access window supports transaction back-pressure should the FIFO become full (in case of write) or empty (in case of read).
{{< registers “hw/ip/flash_ctrl/data/flash_ctrl.hjson” >}}