• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC Design
  3. [Verilog-A/AMS] Using a for loop to instantiate module

Stats

  • Locked Locked
  • Replies 4
  • Subscribers 125
  • Views 10384
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

[Verilog-A/AMS] Using a for loop to instantiate module

delgsy
delgsy over 3 years ago

I need to generate multiple clocks with different delay.
So, my plan is creating a single delay module and instantiate it using for loop which apply different delay then a single clock will drive all of them.
But I still cannot make it work.
From Ken Kundert's book, it is mentioned that genvar cannot used inside the loop structure.

Is there anything that I can try?







Here is the same code for easy copy-paste.


`include "constants.vams"
`include "disciplines.vams"
`timescale 1ns/1ps

module verAMS_array_delay_v2 (IN, OUT);
    input IN;
    //electrical IN;
    wire IN; //Analog port connections in array of instances is not supported..

    output [0:1] OUT;
    logic [0:1] OUT;
    wire [0:1] OUT;

    genvar i;
    real tdelay_ns;

for (i=0; i<2; i=i+1)
begin
//tdelay_ns = (10*i) + 10;
//verAMS_delay #(.tdelay(tdelay_ns)) (IN, OUT[i]);
verAMS_delay #(.tdelay(30)) (IN, OUT[i]);
end


/* This works.
verAMS_delay #(.tdelay(30)) DUT0 (IN, OUT[0]);
verAMS_delay #(.tdelay(20)) DUT1 (IN, OUT[1]);
*/
endmodule


`include "constants.vams"
`include "disciplines.vams"
`timescale 1ns/1ps

module verAMS_delay (IN, OUT );
    input IN;
    electrical IN;

    output OUT;
    logic OUT;
    reg OUT;

    parameter real tdelay  = 20;

initial OUT = 0;

always @(cross(V(IN)-0.6,+1))
    begin
    OUT <= #tdelay 1;
    end
always @(cross(V(IN)-0.6,-1))
    begin
    OUT <= #tdelay 0;
    end
endmodule


  • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago

    You can put this in the for loop:

    verAMS_delay #(.tdelay(10*i+10)) (IN, OUT[i]);

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • delgsy
    delgsy over 3 years ago in reply to Andrew Beckett

    Hi Andrew,
    I got this error during simulation.
    It passes extraction though.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago in reply to delgsy

    Unfortunately, this is a known limitation of the netlister's hierarchy traversal, as outlined in this post and this post. These give workarounds (you need to explicitly point to the Verilog-AMS code for the lower-level block).

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • delgsy
    delgsy over 3 years ago in reply to Andrew Beckett

    Hi Andrew,
    It works.
    Thank you very much.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information