LOGIN   :::   RECOVER PASS   :::   GET ACCOUNT    
Browse
  • Projects
  • Code (CVS)
  • Forums
  • News
  • Articles
  • Polls
  •  
    OpenCores
  • FAQ
  • CVS HowTo
  • Mission
  • Media
  • Tools
  • Advertise
  • Mirrors
  • Logos
  • Contact us
  • Find Resources
  • Job Opportunity
  •  
    Tools
  • Search
      
  • Download Cores (CVSGet)
  •  
    More
  • Wishbone
  • Perlilog
  • EDA tools
  • OpenTech CD
  •  
    Navigation: All forums > Openrisc > Message List > Message Post

    Message

    Reply | Reply all
    Date Prev | Date Next | Thread Prev | Thread Next Date Index | Thread Index

    From: Victor<victor.lopez@a...>
    Date: Thu May 13 14:34:18 CEST 2004
    Subject: [openrisc] 1 bit condition code register
    Top
    Hello Ben

    I am not an authority in this subject but if I am not mistaken the
    condition codes that you mention are Z for Zero, N for Negative, C for
    Carry and V? I guess it stands for Overflow, anyways the thing is that
    maybe this 1 bit condition code is a bit uneffective as many
    comparisons in a software program involve checking at least two of the
    condition codes. Let's just take a look at comparisons between numbers:

    We have number A and number B both are 2's complement signed integers.
    The comparisons in the lowest level are usually done by substracting
    one number from the other and doing the comparison of the result with
    zero:

    A > B? ====> (A-B) > 0? (See? it is the same comparison)

    This way the comparison would be true if bit Z=0 and bit N=0 (the
    result of the substraction is not zero (as it has to be greater than
    zero) and it is not negative)

    Another example which only needs one comparison code bit:

    A < B? ====> (A-B) < 0?

    To be True, the comparison ought to check only the N bit to be 1, as
    this indicates that the result is negative (that is, less than zero).

    And the same goes with A >= B which requires N=0
    and with A <= B which requires (N=1 OR (Z=1 AND N=0)) which is the same
    as, in simplified form, (N=1 OR Z=1)

    A=B and A!=B imply only checking the Z bit (after the substraction A-B)
    but as you can see there are cases in which it is wiser to have all the
    condition code bits at hand, as we are not messing with a picky program
    that checks first if there has been an Overflow (quite a natural thing
    to do) or the carry bit. You must have in mind that if you have just
    one bit then the programs will have to repeat the operations that are
    checked as many times as bits in the complete comparison codes are
    needed (that is two times for a A<B) and also many branches inside this
    code... just try to assemble by hand any simple program which has to
    make integer comparisons and you will see how performance can be
    affected. I hope this helped. Regards,

    Victor Lopez




    Follow upAuthor
    [openrisc] 1 bit condition code registerWilliam Stoye

     
    Copyright (c) 1999 OPENCORES.ORG. All rights reserved.