SpinalHDL / SpinalTemplateSbt

A basic SpinalHDL project
77 stars 64 forks source link

Better formatting #26

Open numero-744 opened 1 year ago

numero-744 commented 1 year ago

@Dolu1990 convinced me that even if SpinalHDL enables the user to abstract the wires, sometimes the user wants to manipulate wire-by-wire so aligning stuff would be great.

In https://github.com/numero-744/Aes there is a repository fully auto-formatted using scalafmt, with alignments (=, :=, #= and port), using port syntax for better rendering.

Also, I have added a few idioms as VSCode snippets, I wrote the full snippets as comments in the files where I would use them, but don't forget it is even shorter with auto-formatting :wink:

See the readme of the repository for more information.

I'll open a PR to merge some stuff from that repository once Spinal 1.8 has been released with the port notation. Before that, comments appreciated :smiley:

PS: We could also merge some stuff in SpinalHDL itself?

Dolu1990 commented 1 year ago

PS: We could also merge some stuff in SpinalHDL itself?

Related to the AES ?

There is also https://github.com/SpinalHDL/SpinalCrypto

So i don't know what is better. As crypto is a realy realy realy large field, maybe it is better to keep things in standalone libraries ?

numero-744 commented 1 year ago

Related to the AES ?

No, it was mainly about the scalafmt configuration.

The AES itself is just for demo, it is inspired from school work (initially done in VHDL at school with a different structure).

I only use it as a demo for SpinalHDL stuff to demonstrate features:

I don't want to merge this AES into anything ^^'

numero-744 commented 1 year ago

FYI while working on https://github.com/SpinalHDL/SpinalHDL/issues/161 I've added -> alignment on the AES repository, see the test file: numero-744/Aes/hw/spinal/aes/Rcons.scala.

Dolu1990 commented 1 year ago

No, it was mainly about the scalafmt configuration.

Ahhh sure ^^

FYI while working on https://github.com/SpinalHDL/SpinalHDL/issues/161 I've added -> alignment on the AES repository, see the test file: numero-744/Aes/hw/spinal/aes/Rcons.scala.

Hmm one question is : Is that alignement forced by the formating tool ? or allowed by it ?

numero-744 commented 1 year ago

Alignments are performed by scalafmt, but formatting can be locally disabled, for instance: https://github.com/numero-744/Aes/blob/main/hw/spinal/aes/SBox.scala#L28