+ Post New Thread
Results 1 to 4 of 4
  1. #1
    Member level 2
    Points: 2,502, Level: 11
    machael's Avatar
    Join Date
    Nov 2004
    Posts
    49
    Helped
    0 / 0
    Points
    2,502
    Level
    11

    verilog replication

    hi all,
    I found a strange problem in my design: I need to get the result of A*2^K, so I extend "A" by several 0s, like this:
    {A,{K{1'b0}}}
    K is a defined parameter in the module, it can be 0, 1, 2....
    But, I found when I set K as 0, A will still be extended by 1 bit 0, that is, {0{1'b0}} is the same as {1{1'b0}}! Can anyone tell me why and how to solve it?
    (I simulate my design by Modelsim 6.5g)
    Thanks a lot!

    •   Alt20th October 2006, 02:56

      advertising

        
       

  2. #2
    Advanced Member level 3
    Points: 9,432, Level: 23

    Join Date
    Jul 2004
    Posts
    892
    Helped
    176 / 176
    Points
    9,432
    Level
    23

    replication in verilog

    Instead of using {A,{K{1'b0}}} you can write A<<K;



    •   Alt20th October 2006, 04:39

      advertising

        
       

  3. #3
    Advanced Member level 5
    Points: 32,456, Level: 44

    Join Date
    Apr 2002
    Location
    USA
    Posts
    3,942
    Helped
    662 / 662
    Points
    32,456
    Level
    44

    replication verilog

    ModelSim 6.5g ???

    I see the same problem in ModelSim SE 6.2a. I also see a suspicious warning message: "Non-positive replication multiplier '0'"

    The Verilog 2001 standard says this, so I think ModelSim is broken:

    A replication operation may have a replication constant with a value of zero. This is useful in parameterized code. A replication with a zero replication constant is considered to have a size of zero and is ignored. Such a replication shall appear only within a concatenation in which at least one of the operands of the concatenation has a positive size.



    •   Alt20th October 2006, 05:04

      advertising

        
       

  4. #4
    Member level 2
    Points: 2,502, Level: 11
    machael's Avatar
    Join Date
    Nov 2004
    Posts
    49
    Helped
    0 / 0
    Points
    2,502
    Level
    11

    non-positive replication multiplier

    thanks nand_gate, it works!

    echo47,
    my modelsim is 5.7g, sorry for my typo! :(
    so it is clear that this is a modelsim's bug. Thank you for your verification and citation!



--[[ ]]--