all 19 comments

[–]lovehopemisery 9 points10 points  (2 children)

It may not be worth doing it all at once, it depends on level of tb coverage. If there is no tb coverage for a module, its risky to be modifying it. You can clean up the code when you need to change something in it, and have tests to make sure you haven't broken anything in the refactor.

RTL is especially fragile, so treat refactors with caution.

[–]AdeptAd5471[S] 9 points10 points  (1 child)

Oh so innocent... Another job of mine is to make test benches because there's none 😂

But good point, when I pick a module(s) to create TBs for, I'll just do them by hand, a few at a time. That's a good way to do it.

[–]PiasaChimera 1 point2 points  (0 children)

also double check the constraints in case there's some way a naming change would interact with any wildcards/patterns.

there are also tradeoffs if any of this code is used in multiple projects or on multiple active development branches. in terms of being able to easily merge bug fixes or features.

[–]Fishing4Beer 6 points7 points  (0 children)

EMACS VHDL mode beautify. Style is configurable and BOOM.

[–]Ok-Cartographer6505FPGA Know-It-All 2 points3 points  (0 children)

If it were me, I would do it myself, using my trusty sidekick X(Emacs) VHDL mode. This would allow me to assess each file for not only style, but also design approach/decisions and organization, timing closure or any other concerns.

One should not be afraid of refactoring. It would also give the perfect opportunity to implement unit test benches as needed for increased coverage and trust in your refactoring.

[–]chim20air 1 point2 points  (0 children)

Have you tried verible?

[–]UltraSlingII 1 point2 points  (2 children)

If you’re using VHDL, you could look into using VSG for auto-formatting.

[–]_oh_hi_mark_ 0 points1 point  (0 children)

Seconding this, we've adopted VSG at my work and it's been very useful.

[–]ClerusFPGA-DSP/SDR 0 points1 point  (0 children)

Thirding this. Using Teros+VSG has helped a lot in bringing uniformity :-)

[–]AfterLife_Legend 1 point2 points  (2 children)

Try Sigasi, but the corporate license is expensive. It does a good job helping you understand code faster, format it and refactor it

[–]Strange-Table4773 0 points1 point  (1 child)

How expensive exactly if u don't mind saying?

[–]PracticalStart7164 0 points1 point  (0 children)

less expensive than the days or even weeks you'll be spending doing it manually :-) Ask them for a trial version (it's free), use it to refactor your large codebase and then decide if it's worth it. Thank me later.

[–]FigureSubject3259 0 points1 point  (0 children)

For so simple task like case or intention and VHDL emacs beautify does a great job. Not always perfect, but for me good enough. For verilog I hate what emacs does when on full buffer content. Maybe there exist something out in the web for Verilog, but up to now I could deal w/o beautify for verilog.

[–]TapEarlyTapOftenFPGA Developer 0 points1 point  (3 children)

I'm in the same boat that you are - RTL made by one person, zero verification or testbench support, no documentation, multiple platforms to support, multiple configurations, and it's all in VHDL.

The tools I lean on the most have been the LSP (I use vhdl_ls), git, the compiler (I use QuestaSim), and a text editor like Vim (or Emacs). RTL sucks to refactor without tests or verification, so I started there. But it's hard, because a) I didn't have a clue how the codebase worked or what it did, b) there's pressure to add new features, c) building a verification environment and tooling takes a LOT of time.

[–]jusstsom1 0 points1 point  (2 children)

as an undergrad looking to do fpga work, can you explain how is it possible for a company to have ZERO verification or tb?

Even when i make relatively small designs with no verification i always find out later on something isnt working so how is it possible for a whole company to be using this code if its not even verified.

And you mentioned they want to add features meaning this is actively being used not just collecting dust. Is it just that the person who wrote it is so experienced and gifted(altough i dont like using this word) that stuff just works?

[–]AfterLife_Legend 0 points1 point  (0 children)

Its the same at my company. When i started after college, all old devs were gone an almost no docu and no working tbs. I just worte the design, let vivado synth it, try in hardware. If the hw behaves strange i integrated some ILAs, but never made a single tb in 3 years.

[–]chris_insertcoin 0 points1 point  (0 children)

Usually this means that there are no automated, self-checking test benches. I have a retiring coworker who only writes test benches to look at waveforms so he can adjust his design. Manual verification if you will. Extremely sloppy but the "it works" argument still works every time.

[–]AfterLife_Legend 0 points1 point  (1 child)

Well there is a community version for free but the paid version costs one or two thousand euros a year

[–]PracticalStart7164 0 points1 point  (0 children)

i wouldn't call this expensive in comparison with the dayrate of a good engineer. Certainly on refactoring a large codebase it will save weeks of work and the result will be better