-1

I'm working on a VLSI design using SystemVerilog, and I have doubts with the use of signals between negative-edge and positive-edge triggered flip-flops. I have a negative-edge triggered flip-flop (reg1), and another for a positive-edge triggered flip-flop (sum). I need to perform a calculation involving these signals, and I want to avoid using reg1 just like that, since there will be only have half of the period between the negedge and positive edge of the clock.

Pseudocode / example: (reg2 comes also from a neg-triggered module and reg3 from a positive triggered one)

module somemodule ( ... );
   always @(negedge clk) begin
      reg1 <= reg2;
   end

   always @(posedge clk) begin
      sum <= reg3 + reg1;
   end
endmodule

The problem is that reg1 is updated on the negative edge of the clock, and sum is updated on the positive edge. I foresee that this mismatch might cause timing issues.

Could someone provide guidance on how to properly synchronize these signals and perform the calculation without encountering timing problems? Any insights, code examples, or best practices would be greatly appreciated.

Additional Context:

  • I've considered using a two-stage synchronization approach for reg1 before using it in the sum calculation, as well as using a flag to manage synchronisation. However, I'm not sure about the best way to proceed.
  • I would like to avoid using a higher frequency clock (double the freq).
  • Data is coming clocked like this from Analog domain.
  • This design will be synthesised in an advanced node. There are both negative and positive edge triggered flip-flops available. In theory there shouldn't be timing issues with just have of the period because the clock is not too fast, but I want to avoid this last.
  • 1
    Welcome to StackOverflow! Please take the [tour] to learn how this site works. -- Do you think that `reg1` and `sum` are _not_ synchronized? They run on the same clock... Timing issues arise from violations of setup and hold times, and this has to do with the clock frequency, not with the edge polarity. Please [edit] your question to clarify. Do not post a comment, this is not a forum. – the busybee Aug 11 '23 at 09:38
  • " Data is coming clocked like this from Analog domain" Does this mean data is clocked from outside the and comes from outside the chip? – Mikef Aug 11 '23 at 18:01
  • @thebusybee thanks for your reply, I edited it to make it clearer. I mean exactly that with the setup and hold times since there would be only have period. And if there is any recommendation or how to ease possible violations. – stroppierhail Aug 14 '23 at 11:43
  • @Mikef yes, this data comes from outside the digital domain. The chip contains both digital and analog blocks. – stroppierhail Aug 14 '23 at 11:45
  • AFAIK tool chains are able to check timing, or to calculate the maximum clock frequency, considering supply voltage and temperature. Only if you get near the maximum, start thinking about a solution. In any development process, premature optimization is a bad idea. – the busybee Aug 14 '23 at 11:59
  • @thebusybee perfect, thank you very much. I will continue and optimise after pnr or sta – stroppierhail Aug 14 '23 at 12:04

1 Answers1

0

Since both kinds of flip flops work on the same clock, even on the different edges, they are synchronized.

You need to keep an eye on setup and hold times, and therefore the maximum possible clock frequency.

Your tool chain should be able to check the timing, and to calculate the maximum clock frequency, considering supply voltage and temperature.

Only if you get near the maximum frequency, start thinking about a solution. In any development process, premature optimization is a bad idea.

the busybee
  • 10,755
  • 3
  • 13
  • 30