opentitan icon indicating copy to clipboard operation
opentitan copied to clipboard

Port prefixes for primitives

Open imphil opened this issue 7 years ago • 19 comments

Recently we had changes to prim_fifo_sync and prim_fifo_async to get from full/empty to ready/valid signals. What I completely missed in the review was our naming convention, which requires _i/_o suffixes for these ports (https://github.com/lowRISC/style-guides/blob/master/VerilogCodingStyle.md#suffixes).

@NilsGraf sorry for missing this earlier, is this something you could open a PR for? (I know it's painful to change this again.)

imphil avatar Jul 11 '19 10:07 imphil

Yeah, I noticed that too. When I made the change, I kept the style of these files, which is using _i only for clock and reset, but not for any other signals (such as data, empty/full, depth).

NilsGraf avatar Jul 11 '19 16:07 NilsGraf

should we just update fifo's to be in compliance with all other IPs? I'm guessing maybe the fifos were just designed so early that we did not really get the style guide in place yet?

tjaychen avatar Jul 11 '19 16:07 tjaychen

should we just update fifo's to be in compliance with all other IPs?

yes, that's what I'm suggesting.

imphil avatar Jul 11 '19 16:07 imphil

I noticed the same thing ... and also too late. Yes, these were written early and thus non-conforming, we should get them up to the bar.

On Thu, Jul 11, 2019 at 9:23 AM Philipp Wagner [email protected] wrote:

should we just update fifo's to be in compliance with all other IPs?

yes, that's what I'm suggesting.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/34?email_source=notifications&email_token=AJZQKVP3KBAR67N23NQKDLTP65NAVA5CNFSM4IA6FRE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZXHRZI#issuecomment-510556389, or mute the thread https://github.com/notifications/unsubscribe-auth/AJZQKVON5N7CICVY6WSCKCTP65NAVANCNFSM4IA6FREQ .

sjgitty avatar Jul 11 '19 17:07 sjgitty

In case you want to enforce this naming convention, I can turn on the input and output naming rules in ascentlint for this.

NilsGraf avatar Jul 11 '19 17:07 NilsGraf

I think there is a small amount of taste to this rule, so we probably don't need to lint-enforce it, just IMO. Something deep in your design that is inter-module communication might be not worth beating up. But for something as pervasive as primitives we should enforce. Just MO.

On Thu, Jul 11, 2019 at 10:49 AM NilsGraf [email protected] wrote:

In case you want to enforce this naming convention, I can turn on the input and output naming rules in ascentlint for this.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/34?email_source=notifications&email_token=AJZQKVNJJSHOJBZXNVWFIFTP65XCLA5CNFSM4IA6FRE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZXO6MY#issuecomment-510586675, or mute the thread https://github.com/notifications/unsubscribe-auth/AJZQKVNENPWU2EFVQ3ZJSEDP65XCLANCNFSM4IA6FREQ .

sjgitty avatar Jul 11 '19 18:07 sjgitty

Yes, I agree.

When I turn on this rule locally, I see the following blocks that don't follow this rule.

prim_subreg*.sv (used in CSRs)
*_reg_top.sv
ibex_*.sv
prim_fifo*.sv
rv_plic*.sv
spi_fwm*.sv
prim_arbiter.sv
prim_sram_arbiter.sv
prim_flop_2sync.sv
prim_secded*.sv
tlul_socket*.sv
timer_core.sv
rv_timer.sv
uart_*.sv
hmac_core.sv
sha2*.sv
usb*.sv
sram2tlul.sv
and some more

NilsGraf avatar Jul 11 '19 18:07 NilsGraf

shall we divide some of these up for modifications? I don't mind taking a few. Nils it'd be great if you can let us know which rule to turn on for checks also.. I thought the _i/o were a bit excessive at first, but after doing a bit of coding, I think i'm fully onboard because it really does make reading a bit easier (for me at least).

On Thu, Jul 11, 2019 at 11:25 AM NilsGraf [email protected] wrote:

Yes, I agree.

When I turn on this rule locally, I see the following blocks that don't follow this rule. prim_subreg*.sv (used in CSRs)

reg_top.sv http://reg_top.sv ibex.sv prim_fifo*.sv rv_plic*.sv spi_fwm*.sv prim_arbiter.sv prim_sram_arbiter.sv prim_flop_2sync.sv prim_secded*.sv tlul_socket*.sv timer_core.sv rv_timer.sv uart_

.sv hmac_core.sv http://hmac_core.sv sha2.sv usb*.sv sram2tlul.sv and some more

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/34?email_source=notifications&email_token=AAH2RSVHS6O5337DKKLQXYTP653KTA5CNFSM4IA6FRE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZXSIPI#issuecomment-510600253, or mute the thread https://github.com/notifications/unsubscribe-auth/AAH2RSTPP36XWKJVIRJFVB3P653KTANCNFSM4IA6FREQ .

tjaychen avatar Jul 11 '19 19:07 tjaychen

Sure, do we really want to enforce it for all these modules now, including really low-level ones like prim_subreg*.sv? Or do we want to make this a guideline rather than a hard rule (perhaps even say in the style guide that you may omit _i and _o suffixes if you feel it helps readability; example: we use reg2hw and hw2reg in _reg_top.sv files, which already makes the signal direction clear; similarly clk and rst_n is usually an input for most blocks). Either way is fine by me.

To turn on this in lint, do the following: cd hw/lint lintconfig & This brings up a simple GUI that lists all rules. You can search for PUT_NAME to get the rules INPUT_NAME and OUTPUT_NAME. Then enable them in the GUI and click on each rule to configure them: enter *_i and *_ni for inputs, and *_o for output exceptions.

NilsGraf avatar Jul 11 '19 20:07 NilsGraf

yeah i see yours and Scott's point. Maybe mainly io's for top level plic and the prim modules? What do you think?

On Thu, Jul 11, 2019 at 1:06 PM NilsGraf [email protected] wrote:

Sure, do we really want to enforce it for all these modules now, including really low-level ones like prim_subreg*.sv? Or do we want to make this a guideline rather than a hard rule (perhaps even say in the style guide that you may omit _i and _o suffixes if you feel it helps readability; example: we use reg2hw and hw2reg in _reg_top.sv files, which already makes the signal direction clear; similarly clk and rst_n is usually an input for most blocks). Either way is fine by me.

To turn on this in lint, do the following: cd hw/lint lintconfig & This brings up a simple GUI that lists all rules. You can search for PUT_NAME to get the rules INPUT_NAME and OUTPUT_NAME. Then enable them in the GUI and click on each rule to configure them: enter *_i and *_ni for inputs, and

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/34?email_source=notifications&email_token=AAH2RSX4HDJK527QJIX4TF3P66HCTA5CNFSM4IA6FRE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZX2TCI#issuecomment-510634377, or mute the thread https://github.com/notifications/unsubscribe-auth/AAH2RSQI7GN7ZPPEJE74LQLP66HCTANCNFSM4IA6FREQ .

tjaychen avatar Jul 11 '19 21:07 tjaychen

Yes, I agree.

When I turn on this rule locally, I see the following blocks that don't follow this rule.

prim_subreg*.sv (used in CSRs)
*_reg_top.sv
ibex_*.sv
prim_fifo*.sv
rv_plic*.sv
spi_fwm*.sv
prim_arbiter.sv
prim_sram_arbiter.sv
prim_flop_2sync.sv
prim_secded*.sv
tlul_socket*.sv
timer_core.sv
rv_timer.sv
uart_*.sv
hmac_core.sv
sha2*.sv
usb*.sv
sram2tlul.sv
and some more

One quick question. do we have to conform the port rule for internal modules too? For instance, the sublock (uart_rx.sv) for UART IP.

eunchan avatar Jul 11 '19 23:07 eunchan

probably not, IMO. I feel like this is most useful at the integration level. If the designer of the sub block also finds it useful, then it's up to the designer.

On Thu, Jul 11, 2019 at 4:15 PM Eunchan Kim [email protected] wrote:

Yes, I agree.

When I turn on this rule locally, I see the following blocks that don't follow this rule.

prim_subreg*.sv (used in CSRs) reg_top.sv ibex.sv prim_fifo*.sv rv_plic*.sv spi_fwm*.svprim_arbiter.svprim_sram_arbiter.svprim_flop_2sync.sv prim_secded*.sv tlul_socket*.svtimer_core.svrv_timer.sv uart_.svhmac_core.sv sha2.sv usb*.svsram2tlul.sv and some more

One quick question. do we have to conform the port rule for internal modules too? For instance, the sublock (uart_rx.sv) for UART IP.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/34?email_source=notifications&email_token=AAH2RSQSEDVE5HLED2UPWJ3P665IFA5CNFSM4IA6FRE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZYHPHY#issuecomment-510687135, or mute the thread https://github.com/notifications/unsubscribe-auth/AAH2RSQSRPNWVNV4NMJW46TP665IFANCNFSM4IA6FREQ .

tjaychen avatar Jul 11 '19 23:07 tjaychen

I'm generally in agreement that it is a "best effort" across the board, but close to mandatory to top-level and common primitives. Things like reg2hw already convey the direction, and stuff deep within a design feel like a taste thing for owners. Interested to hear @imphil's thoughts.

If we go with that, then from that list it feels like we need to fix the prim_ stuff (prim_subreg is self-contained within reggen, though the PR would include all the auto-gen'd results), the TLUL stuff, and rv_plic.

Let's try and come to an agreement on this tomorrow, and then we can fan out on some PRs (though I imagine they'll be a bit sequential since some have wide fingers)

On Thu, Jul 11, 2019 at 4:17 PM tjaychen [email protected] wrote:

probably not, IMO. I feel like this is most useful at the integration level. If the designer of the sub block also finds it useful, then it's up to the designer.

On Thu, Jul 11, 2019 at 4:15 PM Eunchan Kim [email protected] wrote:

Yes, I agree.

When I turn on this rule locally, I see the following blocks that don't follow this rule.

prim_subreg*.sv (used in CSRs) reg_top.sv ibex.sv prim_fifo*.sv rv_plic*.sv spi_fwm*.svprim_arbiter.svprim_sram_arbiter.svprim_flop_2sync.sv prim_secded*.sv tlul_socket*.svtimer_core.svrv_timer.sv uart_.svhmac_core.sv sha2.sv usb*.svsram2tlul.sv and some more

One quick question. do we have to conform the port rule for internal modules too? For instance, the sublock (uart_rx.sv) for UART IP.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/lowRISC/opentitan/issues/34?email_source=notifications&email_token=AAH2RSQSEDVE5HLED2UPWJ3P665IFA5CNFSM4IA6FRE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZYHPHY#issuecomment-510687135 , or mute the thread < https://github.com/notifications/unsubscribe-auth/AAH2RSQSRPNWVNV4NMJW46TP665IFANCNFSM4IA6FREQ

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/34?email_source=notifications&email_token=AJZQKVJZRQGAKMQUYSBF223P665R5A5CNFSM4IA6FRE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZYHTNI#issuecomment-510687669, or mute the thread https://github.com/notifications/unsubscribe-auth/AJZQKVPBABQEEJIMYZ2KK2TP665R5ANCNFSM4IA6FREQ .

sjgitty avatar Jul 12 '19 00:07 sjgitty

Has this issue been addressed? If so, please close. Thanks.

aytong avatar Oct 31 '19 23:10 aytong

Reviving this old issue so that we can address some of them then close. We would also have to revive the lint check to feel like we've covered enough to close it. So pinging @NilsGraf to see if he can remind us how to do that. I don't think we need to enable it for all time, but it would make sense to get a fresh accounting. This below is based upon the last run a year ago.

  • [x] prim_subreg*.sv - I'm suggesting we leave this as is, _q / _d names at least are relatively standard, and the file count to be effected here is huge.
  • [x] *_reg_top.sv - ditto above
  • [ ] ibex_*.sv - not seeing any errors here anymore, but I'm not sure how to run the rule, the scripts have changed
  • [x] prim_fifo*.sv - I think this should be fixed, am creating a PR
  • [x] rv_plic*.sv - I think this should be fixed, will create a PR
  • [x] spi_fwm*.sv - there are just three signals here, could do a quick fix, but need to go in after #2743 goes through
  • [x] prim_arbiter.sv - this doesn't exist anymore, replacements have been fixed
  • [x] prim_sram_arbiter.sv - I think this should be fixed, will create a PR
  • [x] prim_flop_2sync.sv - I think this should be fixed since prim_flop was fixed, will create a PR
  • [ ] prim_secded*.sv - uses in and out; could be fixed, but probably OK to leave
  • [x] tlul_socket*.sv - just the n1 version is missing _i on dev_select
  • [ ] timer_core.sv - internal core, could skip
  • [x] rv_timer.sv - already fixed
  • [ ] uart_*.sv- top is fixed, internals could stay, designer's discretion (@eunchan)
  • [ ] hmac_core.sv - internal file, could stay, designer's discretion (@eunchan)
  • [ ] sha2*.sv - ditto above (@eunchan)
  • [x] usb*.sv - these appear to be all fixed
  • [x] sram2tlul.sv - I think this should be fixed, will create a PR

sjgitty avatar Jul 14 '20 23:07 sjgitty

Feel free to weigh in to this or the PR (#2825) if you don't think it is worth the changes at this point.

sjgitty avatar Jul 14 '20 23:07 sjgitty

This could potentially be considered done. @eunchan the rest are your discretion, and don't need to be fixed. LMK what you are thinking there.

sjgitty avatar Jul 17 '20 23:07 sjgitty

Thanks Scott. Looks good

eunchan avatar Jul 20 '20 23:07 eunchan

I'm closing this as "sufficient" for this point. We can revisit if we get the _i/_o suffix style checker

sjgitty avatar Jul 21 '20 00:07 sjgitty