signal AND with a constant of '1'

Discussion in 'VHDL' started by fl, Nov 19, 2012.

  1. fl

    fl Guest

    Hi,

    I use Matlab HDL Coder generated VHDL code in my project. I find there is a line in which a signal AND with a constant '1'. Does that make sense in that writing? I can ignore such writing to a signal setting without AND the constant?


    Thanks,

    ..............
    CONSTANT const_one : std_logic := '1'; -- boolean

    SIGNAL phase_0 : std_logic; -- boolean
    SIGNAL phase_temp : std_logic; -- boolean

    begin
    phase_temp <= phase_0 AND const_one;
    ....
    end
    fl, Nov 19, 2012
    #1
    1. Advertising

  2. fl

    rickman Guest

    On 11/19/2012 5:09 PM, fl wrote:
    > Hi,
    >
    > I use Matlab HDL Coder generated VHDL code in my project. I find there is a line in which a signal AND with a constant '1'. Does that make sense in that writing? I can ignore such writing to a signal setting without AND the constant?
    >
    >
    > Thanks,
    >
    > ..............
    > CONSTANT const_one : std_logic := '1'; -- boolean
    >
    > SIGNAL phase_0 : std_logic; -- boolean
    > SIGNAL phase_temp : std_logic; -- boolean
    >
    > begin
    > phase_temp<= phase_0 AND const_one;
    > ....
    > end


    Certainly this won't make a difference logically. So you have to ask
    why they would do this. If this were to be translated into hardware, it
    is possible it would use a LUT in an FPGA or a gate in an ASIC, but all
    the tools I know of will optimize this out automatically unless you turn
    off the optimizations.

    I can't see it hurting anything.

    Rick
    rickman, Nov 19, 2012
    #2
    1. Advertising

  3. fl

    KJ Guest

    On Monday, November 19, 2012 5:09:09 PM UTC-5, fl wrote:
    > Hi, I use Matlab HDL Coder generated VHDL code in my project.
    > I find there is a line in which a signal AND with a constant '1'.
    > Does that make sense in that writing?


    Machine generated code often contains things that look odd to human readers.. If you want to know the reason they define the constant in this instancethen you should contact the folks at Matlab.

    > I can ignore such writing
    > to a signal setting without AND the constant?


    What does you mean by 'ignore such writing'?
    - Don't look at it, accept it 'as-is' and move on? If so, then the answer is 'yes'
    - Get rid of the constant and it's usage by editing the machine generated code to 'clean up' something you don't like? If so, then the answer is 'no'.. At best, all you can hope to accomplish with any edits is to not break working code. At worst, you break that working code. So don't bother editing.

    Kevin Jennings
    KJ, Nov 20, 2012
    #3
  4. fl

    Tricky Guest

    On Monday, November 19, 2012 10:09:09 PM UTC, fl wrote:
    > Hi,
    >
    >
    >
    > I use Matlab HDL Coder generated VHDL code in my project. I find there isa line in which a signal AND with a constant '1'. Does that make sense in that writing? I can ignore such writing to a signal setting without AND theconstant?
    >
    >
    >
    >
    >
    > Thanks,
    >
    >
    >
    > .............
    >
    > CONSTANT const_one : std_logic := '1'; -- boolean
    >
    >
    >
    > SIGNAL phase_0 : std_logic; -- boolean
    >
    > SIGNAL phase_temp : std_logic; -- boolean
    >
    >
    >
    > begin
    >
    > phase_temp <= phase_0 AND const_one;
    >
    > ...
    >
    > end


    I bet someone did that in the original matlab/simulink model. They may haveintended to have something other than 1 connected to the other input of the AND gate at some point. I get to see this style of coding all over the legacy AHDL/schematic designs here.
    Tricky, Nov 20, 2012
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ved
    Replies:
    3
    Views:
    4,714
  2. Michael Pronath
    Replies:
    1
    Views:
    1,166
    Diez B. Roggisch
    Jan 3, 2005
  3. Jack Orenstein

    threading.Thread vs. signal.signal

    Jack Orenstein, Sep 18, 2005, in forum: Python
    Replies:
    0
    Views:
    464
    Jack Orenstein
    Sep 18, 2005
  4. Replies:
    4
    Views:
    338
    Keith Thompson
    Dec 14, 2006
  5. G G
    Replies:
    3
    Views:
    91
    Ben Bacarisse
    Apr 20, 2014
Loading...

Share This Page