Results 1 to 7 of 7

Thread: flop-flop simulation in ModelSim

  1. #1
    Join Date
    Mar 2018
    Posts
    13
    Rep Power
    1

    Default flop-flop simulation in ModelSim

    i try to simulate [1:0]flip-flop in ModelSim and i see one normal signal(out_inf[0]) and one blue signal(out_inf[1]). What is it?
    Attached Images Attached Images
    Last edited by demsp; May 16th, 2018 at 09:57 PM.

  2. #2
    Tricky is offline Moderator **Forum Master**
    Join Date
    Oct 2008
    Posts
    6,031
    Rep Power
    1

    Default Re: flop-flop simulation in ModelSim

    Blue means 1'bZ. We will need to code to understand the problem.

  3. #3
    Join Date
    Mar 2018
    Posts
    13
    Rep Power
    1

    Default Re: flop-flop simulation in ModelSim

    dff code
    Code:
    module dff(clk, din, dout); 
      input clk; 
      input [1:0] din; 
      output [1:0] dout; 
    reg dout; 
     always @ (posedge clk) 
      begin 
       dout <= din; 
    end 
    endmodule
    testbench
    Code:
    module top; 
       reg clk; 
       reg [1:0] in_inf; 
       wire [1:0] out_inf;
    dff D1 (clk, in_inf, out_inf); 
    
    initial // Clock generator
      begin
        clk = 0;
        forever #10 clk = !clk;
      end
    
    initial //in_inf[0]    
      begin
        in_inf[0] = 0;
        #28 in_inf[0] = 1;
        #5 in_inf[0] = 0;
      end
    initial    //in_inf[1]    
      begin
        in_inf[1] = 0;
        #48 in_inf[1] = 1;
        #5 in_inf[1] = 0;
      end
    endmodule
    i want to see normal (not blue) signal as out_inf[1]
    Last edited by demsp; May 17th, 2018 at 12:15 AM.

  4. #4
    Join Date
    Dec 2007
    Location
    Bochum Germany
    Posts
    6,319
    Rep Power
    1

    Default Re: flop-flop simulation in ModelSim

    You should always look sharp at the Modelsim warnings. They tell about problem with reg dout declaration. Must be reg [1:0] dout. Or include reg in the output definition.

  5. #5
    Join Date
    Mar 2018
    Posts
    13
    Rep Power
    1

    Default Re: flop-flop simulation in ModelSim

    whys out_inf[0] is h'x (in the beginning), not zero?
    Last edited by demsp; May 17th, 2018 at 06:10 PM.

  6. #6
    Tricky is offline Moderator **Forum Master**
    Join Date
    Oct 2008
    Posts
    6,031
    Rep Power
    1

    Default Re: flop-flop simulation in ModelSim

    Because you dont have an initial or reset value for them. They wont be assigned a value until the first clock

  7. #7
    Join Date
    Mar 2018
    Posts
    13
    Rep Power
    1

    Default Re: flop-flop simulation in ModelSim

    can i initialize value before first clock?
    Last edited by demsp; May 18th, 2018 at 06:28 AM.

Similar Threads

  1. Unreliable D-FLOP
    By volvogv in forum FPGA, Hardcopy, and CPLD Discussion
    Replies: 3
    Last Post: March 8th, 2017, 11:00 PM
  2. D flip flop trouble
    By volvogv in forum FPGA, Hardcopy, and CPLD Discussion
    Replies: 2
    Last Post: February 27th, 2017, 12:10 PM
  3. Simulation Problem about a D filp flop by modelsim ALTERA 10.1d
    By hyx0408 in forum Verilog and System Verilog
    Replies: 4
    Last Post: September 16th, 2015, 03:15 AM
  4. Can you tell me what's kind of this flip-flop???
    By trikhang2904 in forum Quartus II and EDA Tools Discussion
    Replies: 1
    Last Post: May 30th, 2013, 05:55 AM
  5. D Flip Flop
    By digitalee in forum VHDL
    Replies: 3
    Last Post: April 13th, 2013, 10:08 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •