• 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. Functional Verification
  3. SystemVerilog modport question

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 65
  • Views 17117
  • 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

SystemVerilog modport question

SCollins
SCollins over 13 years ago

Hi All,

I'm new to using interfaces and would like to implement an interface that connects a master module to 2 other identical slave modules. The interface simply contains a 2 bit data bus that is driven by the master. I would like the interface to split the bus such that one slave is driven by the LSB and the other slave is driven by the MSB of the bus.

I believe the easiest way of doing this is to use modports - a master modport and a different modport for each slave. The interface code would then look something like this (modports are on single lines for compactness):

interface data_bus_if

logic [1:0] data;

modport master (output data);

modport slave0 (input .data_bit(data[0]));

modport slave1 (input .data_bit(data[1]));

endinterface : data_bus_if

I'd imagine this scenario is quite common but Incisive doesn't appear to support modport expressions. How can I implement the interface so that it compiles with Incisive?

Many thanks!

  • Cancel
  • StephenH
    StephenH over 12 years ago

    Hi Sean (?)

    Although Cadence has occasionally had requests to support that style of modport expression, it's not been of of the more popular features and as such hasn't been implemented yet. If you care to file a support request for the same, we can get you added to the list of people officially requesting it, which can help us when planning which features to implement next.

    The following adaptation of your code does work in Incisive. Eventually you'd be able to replace the separate sub-interfaces with modports, as per the examples in the LRM.

     

    interface slave_if ( input data_bit );

    endinterface

    interface data_bus_if;

    logic [1:0] data;

    modport master (output data);

    slave_if slave0 (.data_bit(data[0]));

    slave_if slave1 (.data_bit(data[1]));

    endinterface : data_bus_if

     
    Even if we did support the exact syntax that you're requesting, it still has the limitation that you would have to declare a new modport for each slave, which would be a nuisance if the number were variable. You can make this more generic by using a generate block:
     
    interface slave_if ( input data_bit );
    endinterface

    interface data_bus_if;
    parameter NUM_SLAVES = 2;
    logic [NUM_SLAVES-1:0] data;

    modport master (output data);

    generate 
    for(genvar i = 0; i < NUM_SLAVES; i++) begin : slave_gen
      slave_if slave (.data_bit(data[i]));
    end
    endgenerate

    endinterface : data_bus_if
     
     
    Hope this helps! 

     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • SCollins
    SCollins over 12 years ago

    Hi Steve,

    Thanks for responding, your workaround seems a good solution, however, I'm having problems elaborating my example design when I use a generate statement to create the slave sub-interface instances.

    My code for a slave is:

    module slave (slave_sub_if port);

    <slave code>

    endmodule 

    In my top level where I instantiate each slave, I've used the following code:

    slave slave_inst0 (.port data_bus_if_inst.slave_gen[0].slave_sub_if_inst);

    Incisive reports the following error during elaboration (highlighting the slave_sub_if_inst name):

    ncelab: *E,CUIOAI (...etc): Illegal interface port connection through a generate or array instance

    The block within my generate statement is named "slave_gen", which is the same as the block in your code.

    How should I specify the name of my sub-interface instance to ensure that my design elaborates?

    BTW, I should mention that my design elaborated when I simply instantiated 2 instances of my slave (without a generate statement).

    Thanks!

    • 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