Electronic – Using too many Modules in Verilog affect timing

fpgahdltimingtiming-analysis

I have a straightforward quest about HDL and FPGA design.

If I seperate my code to a lot of modules, by modules I mean verilog files which do specifig things instead of writing close to the top module, does it affect clk timing?

Ill try to illustrate my question:
the first option the I write most of my code in 1 file (not a top file, I know I shouldnt write logic on the top):
enter image description here

the second option that I going deep with my modules, instead of write lot of code in 1 file, I will have seperate hdl files that does some functionality and bring back upstair the answers, something like this:
enter image description here

does it affect timings of the clock/reset etc?
does it good design to write lot of modules and going deep with the modules or I should stay close the the top?

In my opinion, I using Lattice FPGA and I "Share Resources" option in the syntesis, and than, its doesnt matter.

Best Answer

No, it doesn't affect the timing or final netlist. If you take a signal from the top level and assign it to successive modules, the compiler will recognise this is the same signal. Modules are there to allow you to:

  1. Group functionality into logical blocks.
  2. Reuse common designs.
  3. Keep design elements at a size you, as a human, can keep track of.

I try to have only assignments and very simple logic (e.g. ORing the output of two modules) at the top level. This keeps the namespace clean, and allows easy traversal of the hierarchy in the simulator.