opentitan icon indicating copy to clipboard operation
opentitan copied to clipboard

[Flash_ctrl] Make fifo backed register consistent with HMAC

Open tjaychen opened this issue 7 years ago • 11 comments

Right now, window based fifo registers are implemented slightly differently between hmac and flash.

In hmac, the entire address space is exposed on the memory map, while flash_ctrl hides them. @sriyerg prefers the handling be consistent across the design, so either hmac should shrink to 1 item like flash_ctrl, or flash should expand to the full item range like hmac.

@eunchan do you have any thoughts? I think you originally expanded it fully to cover any DMA deficiencies, so I'm thinking flash ctrl should probably do the same and also make the same clarification in the docs.

Also, for the FIFO backed register in UART, should we make it consistent as well? That one is not window based, but the same concept applies.

tjaychen avatar Aug 14 '19 17:08 tjaychen

On Wed, Aug 14, 2019 at 10:08:29AM -0700, tjaychen wrote:

Right now, window based fifo registers are implemented slightly differently between hmac and flash.

In hmac, the entire address space is exposed on the memory map, while flash_ctrl hides them. @sriyerg prefers the handling be consistent across the design, so either hmac should shrink to 1 item like flash_ctrl, or flash should expand to the full item range like hmac.

@eunchan do you have any thoughts? I think you originally expanded it fully to cover any DMA deficiencies, so I'm thinking flash ctrl should probably do the same and also make the same clarification in the docs.

Making them consistent looks good but I don't think it should be. Each IP can have its own assumption and rules. Feel free to revise or keep them as it is.

Also, for the FIFO backed register in UART, should we make it consistent as well? That one is not window based, but the same concept applies.

eunchan avatar Aug 14 '19 18:08 eunchan

I should've add a little bit more details what I thought. After discussing with Sri and Cindy, I understand that the difficulties of DV to deal with the implementation of HMAC MSG FIFO opening the whole address but pointing to the single, first entry only.

When I revise the HMAC to have window region for MSG FIFO, I had in my mind, the IP (this and all other IPs inside OpenTitan) could be used in other SoC not only OpenTitan. We can set the bar for DMA engine to support fixed address burst to write the message if the SoC is designed by ourselves. But the IP can be used in other SoC. That's why I also urge to check in the generated RTL to the repo (just copy RTL to another directory and include, then can be compiled). Having the FIFO that doesn't care the address gives more flexible to the usage. Some examples could be the DMA Tim mentioned or PCIe. By supporting this feature, PCIe host can send less TLPs with bigger payload (probably 256Byte per TLP but spec also allows 4kB payload), so that the PCIe DMA can just forward the data to the FIFO then FIFO accepts it regardless of the address. This could save unnecessary overhead over PCIe (to send 1 Word payload, PCIe link consumes 6 Words more).

However, I understand the difficulty of standardizing the DV environment. This could be exception (also flash controller FIFOs are currently in the exception I think?) or, I can revise the FIFO to have fixed address and converting it to CSR in DV uvm_reg block.

@sjgitty @tjaychen Should we also specify the FIFO implementation in the Comportability Specification? It would be better to make an agreement here and stick to it :)

Thanks for raising the issue Tim and Sri. :)

eunchan avatar Aug 15 '19 21:08 eunchan

yeah i think it makes sense to make the implementation consistent. Because if our argument is that we want to allow better DMA support for 1 IP, that should apply to the others as well. Eunchan, when you say you're going to convert it to CSR, does that mean you will no longer be exposing the window? I can't remember if the hwext approach has the back pressure function as well.

On Thu, Aug 15, 2019 at 2:32 PM Eunchan Kim [email protected] wrote:

I should've add a little bit more details what I thought. After discussing with Sri and Cindy, I understand that the difficulties of DV to deal with the implementation of HMAC MSG FIFO opening the whole address but pointing to the single, first entry only.

When I revise the HMAC to have window region for MSG FIFO, I had in my mind, the IP (this and all other IPs inside OpenTitan) could be used in other SoC not only OpenTitan. We can set the bar for DMA engine to support fixed address burst to write the message if the SoC is designed by ourselves. But the IP can be used in other SoC. That's why I also urge to check in the generated RTL to the repo (just copy RTL to another directory and include, then can be compiled). Having the FIFO that doesn't care the address gives more flexible to the usage. Some examples could be the DMA Tim mentioned or PCIe. By supporting this feature, PCIe host can send less TLPs with bigger payload (probably 256Byte per TLP but spec also allows 4kB payload), so that the PCIe DMA can just forward the data to the FIFO then FIFO accepts it regardless of the address. This could save unnecessary overhead over PCIe (to send 1 Word payload, PCIe link consumes 6 Words more).

However, I understand the difficulty of standardizing the DV environment. This could be exception (also flash controller FIFOs are currently in the exception I think?) or, I can revise the FIFO to have fixed address and converting it to CSR in DV uvm_reg block.

@sjgitty https://github.com/sjgitty @tjaychen https://github.com/tjaychen Should we also specify the FIFO implementation in the Comportability Specification? It would be better to make an agreement here and stick to it :)

Thanks for raising the issue Tim and Sri. :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/12?email_source=notifications&email_token=AAH2RSWVFC7XS6RSPFD3J7TQEXDQNA5CNFSM4ILXBQW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4NB4UQ#issuecomment-521805394, or mute the thread https://github.com/notifications/unsubscribe-auth/AAH2RSX6MQHEHXQ3AVUO5CLQEXDQNANCNFSM4ILXBQWQ .

tjaychen avatar Aug 15 '19 21:08 tjaychen

On Thu, Aug 15, 2019 at 02:39:44PM -0700, tjaychen wrote:

yeah i think it makes sense to make the implementation consistent. Because if our argument is that we want to allow better DMA support for 1 IP, that should apply to the others as well. Eunchan, when you say you're going to convert it to CSR, does that mean you will no longer be exposing the window? I can't remember if the hwext approach has the back pressure function as well.

No. The option should affect to the UVM reg class not the hardware implementation. register interface cannot back pressure the request.

On Thu, Aug 15, 2019 at 2:32 PM Eunchan Kim [email protected] wrote:

I should've add a little bit more details what I thought. After discussing with Sri and Cindy, I understand that the difficulties of DV to deal with the implementation of HMAC MSG FIFO opening the whole address but pointing to the single, first entry only.

When I revise the HMAC to have window region for MSG FIFO, I had in my mind, the IP (this and all other IPs inside OpenTitan) could be used in other SoC not only OpenTitan. We can set the bar for DMA engine to support fixed address burst to write the message if the SoC is designed by ourselves. But the IP can be used in other SoC. That's why I also urge to check in the generated RTL to the repo (just copy RTL to another directory and include, then can be compiled). Having the FIFO that doesn't care the address gives more flexible to the usage. Some examples could be the DMA Tim mentioned or PCIe. By supporting this feature, PCIe host can send less TLPs with bigger payload (probably 256Byte per TLP but spec also allows 4kB payload), so that the PCIe DMA can just forward the data to the FIFO then FIFO accepts it regardless of the address. This could save unnecessary overhead over PCIe (to send 1 Word payload, PCIe link consumes 6 Words more).

However, I understand the difficulty of standardizing the DV environment. This could be exception (also flash controller FIFOs are currently in the exception I think?) or, I can revise the FIFO to have fixed address and converting it to CSR in DV uvm_reg block.

@sjgitty https://github.com/sjgitty @tjaychen https://github.com/tjaychen Should we also specify the FIFO implementation in the Comportability Specification? It would be better to make an agreement here and stick to it :)

Thanks for raising the issue Tim and Sri. :)

eunchan avatar Aug 15 '19 21:08 eunchan

@sjgitty https://github.com/sjgitty @tjaychen https://github.com/tjaychen Should we also specify the FIFO implementation in the Comportability Specification? It would be better to make an agreement here and stick to it :)

My recommendation is the Comportability Spec shouldn't get into super-details on our IP, but instead generally recommend common utilization of IP primitives. Then, in addition, we should have a document-per or a mega-prim-doc that gives details of functionality and usability of our basic primitives, including rationale, design details, SW interfaces, usage guides, etc. That is a hole in our documentation plan that I will file an issue for. Thanks for noticing it and raising it.

sjgitty avatar Aug 16 '19 01:08 sjgitty

On Thu, Aug 15, 2019 at 06:39:48PM -0700, Scott Johnson wrote:

@sjgitty https://github.com/sjgitty @tjaychen https://github.com/tjaychen Should we also specify the FIFO implementation in the Comportability Specification? It would be better to make an agreement here and stick to it :)

My recommendation is the Comportability Spec shouldn't get into super-details on our IP, but instead generally recommend common utilization of IP primitives. Then, in addition, we should have a document-per or a mega-prim-doc that gives details of functionality and usability of our basic primitives, including rationale, design details, SW interfaces, usage guides, etc. That is a hole in our documentation plan that I will file an issue for. Thanks for noticing it and raising it.

Sorry, I didn't explain clearly again. "specify the FIFO implementation in the Comportability Specification" meant the general FIFO usage in the specification. Definitely the spec for each prim module should be documented.

For instance, general assumption of assigning FIFO to the memory space is to have single word address as we can see in flash_ctrl or uart. Or, it exposes FIFO memory then the software can freely read/write within the range of the address and the FIFO is controlled by the read/write pointer as seen in spi_device.

But in HMAC, the first entry of the FIFO is exposed to not only a word address but the range of addresses. So, what I meant was should we specify in the comportability that if FIFO is exposed to the memory-mapped space, it should give only the width of the fifo.

My thought is that this kind of design flexibility is good to have as I explained in the previous comment. For the ease of DV environment, we might be able to limit the design implementation but still the boundary isn't clear to me.

eunchan avatar Aug 16 '19 02:08 eunchan

this is just my opinion, and my thinking might be too rigid. I really like the idea of specifying general methods on how something should be done... but this is mostly because i seem to trend in the direction of a consistent programmer model and expectation. I'm not 100% sure that's a good idea for an open source project though (that's why i said it's possibly too rigid).

@Alex Bradbury [email protected] @Philipp Wagner [email protected] @Dominic Rizzo [email protected]

adding a few people to chime in.

On Thu, Aug 15, 2019 at 7:47 PM Eunchan Kim [email protected] wrote:

On Thu, Aug 15, 2019 at 06:39:48PM -0700, Scott Johnson wrote:

@sjgitty https://github.com/sjgitty @tjaychen https://github.com/tjaychen Should we also specify the FIFO implementation in the Comportability Specification? It would be better to make an agreement here and stick to it :)

My recommendation is the Comportability Spec shouldn't get into super-details on our IP, but instead generally recommend common utilization of IP primitives. Then, in addition, we should have a document-per or a mega-prim-doc that gives details of functionality and usability of our basic primitives, including rationale, design details, SW interfaces, usage guides, etc. That is a hole in our documentation plan that I will file an issue for. Thanks for noticing it and raising it.

Sorry, I didn't explain clearly again. "specify the FIFO implementation in the Comportability Specification" meant the general FIFO usage in the specification. Definitely the spec for each prim module should be documented.

For instance, general assumption of assigning FIFO to the memory space is to have single word address as we can see in flash_ctrl or uart. Or, it exposes FIFO memory then the software can freely read/write within the range of the address and the FIFO is controlled by the read/write pointer as seen in spi_device.

But in HMAC, the first entry of the FIFO is exposed to not only a word address but the range of addresses. So, what I meant was should we specify in the comportability that if FIFO is exposed to the memory-mapped space, it should give only the width of the fifo.

My thought is that this kind of design flexibility is good to have as I explained in the previous comment. For the ease of DV environment, we might be able to limit the design implementation but still the boundary isn't clear to me.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/12?email_source=notifications&email_token=AAH2RSVA54HNAIHMJJS2YT3QEYIKTA5CNFSM4ILXBQW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4NQNLY#issuecomment-521864879, or mute the thread https://github.com/notifications/unsubscribe-auth/AAH2RSVB5ICDAOE53KD7FTTQEYIKTANCNFSM4ILXBQWQ .

tjaychen avatar Aug 16 '19 17:08 tjaychen

On Fri, Aug 16, 2019 at 10:37:33AM -0700, tjaychen wrote:

this is just my opinion, and my thinking might be too rigid. I really like the idea of specifying general methods on how something should be done... but this is mostly because i seem to trend in the direction of a consistent programmer model and expectation.

This doesn't harm the software model in my opinion. Software can assume it as a single word width FIFO and can use only one address as a input port.

I think defining the type in window field inside ip.hjson is sufficient. The type could be 'fifo' or 'write_ignore' things.

I'm not 100% sure that's a good idea for an open source project though (that's why i said it's possibly too rigid).

@Alex Bradbury [email protected] @Philipp Wagner [email protected] @Dominic Rizzo [email protected]

adding a few people to chime in.

On Thu, Aug 15, 2019 at 7:47 PM Eunchan Kim [email protected] wrote:

On Thu, Aug 15, 2019 at 06:39:48PM -0700, Scott Johnson wrote:

@sjgitty https://github.com/sjgitty @tjaychen https://github.com/tjaychen Should we also specify the FIFO implementation in the Comportability Specification? It would be better to make an agreement here and stick to it :)

My recommendation is the Comportability Spec shouldn't get into super-details on our IP, but instead generally recommend common utilization of IP primitives. Then, in addition, we should have a document-per or a mega-prim-doc that gives details of functionality and usability of our basic primitives, including rationale, design details, SW interfaces, usage guides, etc. That is a hole in our documentation plan that I will file an issue for. Thanks for noticing it and raising it.

Sorry, I didn't explain clearly again. "specify the FIFO implementation in the Comportability Specification" meant the general FIFO usage in the specification. Definitely the spec for each prim module should be documented.

For instance, general assumption of assigning FIFO to the memory space is to have single word address as we can see in flash_ctrl or uart. Or, it exposes FIFO memory then the software can freely read/write within the range of the address and the FIFO is controlled by the read/write pointer as seen in spi_device.

But in HMAC, the first entry of the FIFO is exposed to not only a word address but the range of addresses. So, what I meant was should we specify in the comportability that if FIFO is exposed to the memory-mapped space, it should give only the width of the fifo.

My thought is that this kind of design flexibility is good to have as I explained in the previous comment. For the ease of DV environment, we might be able to limit the design implementation but still the boundary isn't clear to me.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/12?email_source=notifications&email_token=AAH2RSVA54HNAIHMJJS2YT3QEYIKTA5CNFSM4ILXBQW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4NQNLY#issuecomment-521864879, or mute the thread https://github.com/notifications/unsubscribe-auth/AAH2RSVB5ICDAOE53KD7FTTQEYIKTANCNFSM4ILXBQWQ .

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/lowRISC/opentitan/issues/12#issuecomment-522091234

eunchan avatar Aug 16 '19 18:08 eunchan

sounds good to me!

On Fri, Aug 16, 2019 at 11:59 AM Eunchan Kim [email protected] wrote:

On Fri, Aug 16, 2019 at 10:37:33AM -0700, tjaychen wrote:

this is just my opinion, and my thinking might be too rigid. I really like the idea of specifying general methods on how something should be done... but this is mostly because i seem to trend in the direction of a consistent programmer model and expectation.

This doesn't harm the software model in my opinion. Software can assume it as a single word width FIFO and can use only one address as a input port.

I think defining the type in window field inside ip.hjson is sufficient. The type could be 'fifo' or 'write_ignore' things.

I'm not 100% sure that's a good idea for an open source project though (that's why i said it's possibly too rigid).

@Alex Bradbury [email protected] @Philipp Wagner [email protected] @Dominic Rizzo [email protected]

adding a few people to chime in.

On Thu, Aug 15, 2019 at 7:47 PM Eunchan Kim [email protected] wrote:

On Thu, Aug 15, 2019 at 06:39:48PM -0700, Scott Johnson wrote:

@sjgitty https://github.com/sjgitty @tjaychen https://github.com/tjaychen Should we also specify the FIFO implementation in the Comportability Specification? It would be better to make an agreement here and stick to it :)

My recommendation is the Comportability Spec shouldn't get into super-details on our IP, but instead generally recommend common utilization of IP primitives. Then, in addition, we should have a document-per or a mega-prim-doc that gives details of functionality and usability of our basic primitives, including rationale, design details, SW interfaces, usage guides, etc. That is a hole in our documentation plan that I will file an issue for. Thanks for noticing it and raising it.

Sorry, I didn't explain clearly again. "specify the FIFO implementation in the Comportability Specification" meant the general FIFO usage in the specification. Definitely the spec for each prim module should be documented.

For instance, general assumption of assigning FIFO to the memory space is to have single word address as we can see in flash_ctrl or uart. Or, it exposes FIFO memory then the software can freely read/write within the range of the address and the FIFO is controlled by the read/write pointer as seen in spi_device.

But in HMAC, the first entry of the FIFO is exposed to not only a word address but the range of addresses. So, what I meant was should we specify in the comportability that if FIFO is exposed to the memory-mapped space, it should give only the width of the fifo.

My thought is that this kind of design flexibility is good to have as I explained in the previous comment. For the ease of DV environment, we might be able to limit the design implementation but still the boundary isn't clear to me.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/lowRISC/opentitan/issues/12?email_source=notifications&email_token=AAH2RSVA54HNAIHMJJS2YT3QEYIKTA5CNFSM4ILXBQW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4NQNLY#issuecomment-521864879 , or mute the thread < https://github.com/notifications/unsubscribe-auth/AAH2RSVB5ICDAOE53KD7FTTQEYIKTANCNFSM4ILXBQWQ

.

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/lowRISC/opentitan/issues/12#issuecomment-522091234

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/12?email_source=notifications&email_token=AAH2RSWAT4QWQRTGTOK2RBTQE32JRA5CNFSM4ILXBQW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4PN4WY#issuecomment-522116699, or mute the thread https://github.com/notifications/unsubscribe-auth/AAH2RSS5DKJHOTCUKG5VAODQE32JRANCNFSM4ILXBQWQ .

tjaychen avatar Aug 16 '19 20:08 tjaychen

this is just my opinion, and my thinking might be too rigid. I really like the idea of specifying general methods on how something should be done... but this is mostly because i seem to trend in the direction of a consistent programmer model and expectation. I'm not 100% sure that's a good idea for an open source project though (that's why i said it's possibly too rigid). @alex Bradbury [email protected] @philipp Wagner [email protected] @dominic Rizzo

I agree that it's good to specify common "patterns" for how to implement something, and that we'd rather have a consistent programmer model unless there's a reason not to. Many of these might be recommendations rather than requirements though - maybe living in a "recommendations" section of the comportability doc, or maybe a different doc altogether.

asb avatar Aug 19 '19 07:08 asb

i'll close this issue for now since it looks like it is okay that flash / hmac differ in their implementation in this area.

we can make updates to the spec later for recommended implementation, but it does not seem to be a critical item right now.

tjaychen avatar Sep 19 '19 21:09 tjaychen