regop.isa (7626:bdd926760470) | regop.isa (7719:f299139501f7) |
---|---|
1// Copyright (c) 2007-2008 The Hewlett-Packard Development Company 2// All rights reserved. 3// 4// The license below extends only to copyright in the software and shall 5// not be construed as granting a license to any other intellectual 6// property including but not limited to intellectual property relating 7// to a hardware implementation of the functionality of the software 8// licensed hereunder. You may use the software subject to the license --- 164 unchanged lines hidden (view full) --- 173}}; 174 175output decoder {{ 176 void 177 divide(uint64_t dividend, uint64_t divisor, 178 uint64_t "ient, uint64_t &remainder) 179 { 180 //Check for divide by zero. | 1// Copyright (c) 2007-2008 The Hewlett-Packard Development Company 2// All rights reserved. 3// 4// The license below extends only to copyright in the software and shall 5// not be construed as granting a license to any other intellectual 6// property including but not limited to intellectual property relating 7// to a hardware implementation of the functionality of the software 8// licensed hereunder. You may use the software subject to the license --- 164 unchanged lines hidden (view full) --- 173}}; 174 175output decoder {{ 176 void 177 divide(uint64_t dividend, uint64_t divisor, 178 uint64_t "ient, uint64_t &remainder) 179 { 180 //Check for divide by zero. |
181 if (divisor == 0) 182 panic("Divide by zero!\\n"); | 181 assert(divisor != 0); |
183 //If the divisor is bigger than the dividend, don't do anything. 184 if (divisor <= dividend) { 185 //Shift the divisor so it's msb lines up with the dividend. 186 int dividendMsb = findMsbSet(dividend); 187 int divisorMsb = findMsbSet(divisor); 188 int shift = dividendMsb - divisorMsb; 189 divisor <<= shift; 190 //Compute what we'll add to the quotient if the divisor isn't --- 322 unchanged lines hidden (view full) --- 513 uint64_t quotient = 0; 514 uint64_t remainder = psrc1; 515 //Similarly, this is a temporary so changing it doesn't make it 516 //a source. 517 uint64_t divisor = op2; 518 //This is a temporary just for consistency and clarity. 519 uint64_t dividend = remainder; 520 //Do the division. | 182 //If the divisor is bigger than the dividend, don't do anything. 183 if (divisor <= dividend) { 184 //Shift the divisor so it's msb lines up with the dividend. 185 int dividendMsb = findMsbSet(dividend); 186 int divisorMsb = findMsbSet(divisor); 187 int shift = dividendMsb - divisorMsb; 188 divisor <<= shift; 189 //Compute what we'll add to the quotient if the divisor isn't --- 322 unchanged lines hidden (view full) --- 512 uint64_t quotient = 0; 513 uint64_t remainder = psrc1; 514 //Similarly, this is a temporary so changing it doesn't make it 515 //a source. 516 uint64_t divisor = op2; 517 //This is a temporary just for consistency and clarity. 518 uint64_t dividend = remainder; 519 //Do the division. |
521 divide(dividend, divisor, quotient, remainder); 522 //Record the final results. 523 Remainder = remainder; 524 Quotient = quotient; 525 Divisor = divisor; | 520 if (divisor == 0) { 521 fault = new DivideByZero; 522 } else { 523 divide(dividend, divisor, quotient, remainder); 524 //Record the final results. 525 Remainder = remainder; 526 Quotient = quotient; 527 Divisor = divisor; 528 } |
526 ''' 527 528 # Step divide 529 class Div2(RegOp): 530 code = ''' 531 uint64_t dividend = Remainder; 532 uint64_t divisor = Divisor; 533 uint64_t quotient = Quotient; 534 uint64_t remainder = dividend; 535 int remaining = op2; 536 //If we overshot, do nothing. This lets us unrool division loops a 537 //little. | 529 ''' 530 531 # Step divide 532 class Div2(RegOp): 533 code = ''' 534 uint64_t dividend = Remainder; 535 uint64_t divisor = Divisor; 536 uint64_t quotient = Quotient; 537 uint64_t remainder = dividend; 538 int remaining = op2; 539 //If we overshot, do nothing. This lets us unrool division loops a 540 //little. |
538 if (remaining) { | 541 if (divisor == 0) { 542 fault = new DivideByZero; 543 } else if (remaining) { |
539 if (divisor & (ULL(1) << 63)) { 540 while (remaining && !(dividend & (ULL(1) << 63))) { 541 dividend = (dividend << 1) | 542 bits(SrcReg1, remaining - 1); 543 quotient <<= 1; 544 remaining--; 545 } 546 if (dividend & (ULL(1) << 63)) { --- 836 unchanged lines hidden --- | 544 if (divisor & (ULL(1) << 63)) { 545 while (remaining && !(dividend & (ULL(1) << 63))) { 546 dividend = (dividend << 1) | 547 bits(SrcReg1, remaining - 1); 548 quotient <<= 1; 549 remaining--; 550 } 551 if (dividend & (ULL(1) << 63)) { --- 836 unchanged lines hidden --- |