Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

verilog-module instantiation

hi all... currently working on a project, i have a top level module (module A), with a module instantiated in it ,module B. I just have one question. When does the system know when to start running module B ?

in module A, i have all the input to module B declared and assigned. However, at certain point of the codes, where there are supposed to have output from module B, the system just seems not running module B. When i simulated using modelsim, all the variables in module B are 'x'.

any clue why is this happening ? or did i make any mistakes anywhere ? please advice...thanks...

p/s: sorry if i make my question complicated...i am still new to verilog...:confused:

15 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    ok...then how am i going to control when to execute the submodule ?

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Modules are instantiated in concurrent code and unconditionally "executed".

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Your module contains only combinational logic. How do you want to make it conditional? A clocked module can be designed conditional with a clock enable.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I highly recommend you copy the entire submodule into the post. You put "codes here" which leaves us guessing what you have coded in there making it difficult to give you suggestions of what might not be driven/initialized.

    Here is an example of what FvM and I are talking about:

    always @ (posedge clk)

    begin

    if (enable)

    my_register <= input_data;

    end

    In that simple code fragment I have a register that captures input_data when enable is high. What is missing is the reset condition so until the enable signal is driven high 'my_register' will drive out unknown contents if I were to simulate this.