Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.35 KB | None | 0 0
  1. <?php
  2. /* * *************************************************************  
  3.  * Copyright notice  
  4.  *  
  5.  * (c) 2014 Chi Hoang (info@chihoang.de)  
  6.  *  All rights reserved  
  7.  *
  8.  *  For family 10h processor the right formula is:
  9.  *   (100*(Fid+16))/(2^Did)
  10.  *  Inverse formulas are:
  11.  *    fid = (((2^Did) * freq) / 100) - 16
  12.  *    did = log2 ((100 * (fid +16))/f)    
  13.  * **************************************************************/
  14.  
  15.     class convertFreq {
  16.      
  17.         var $fixme;
  18.         var $cpu=array();
  19.         var $input=array();
  20.              
  21.         function convertFreq ($cpu,$type,$input) {
  22.             $this->fixme=$cpu;
  23.             $this->cpu=$type;
  24.             $this->input=$input;
  25.         }
  26.          
  27.         function tofreq () {
  28.  
  29.             $fixme=($this->fixme[$this->cpu]);    
  30.             $c=0;  
  31.             foreach ($this->input as $key=>$arr)
  32.             {                
  33.                 $vid=abs(($arr["vcore"]-1.55)/0.0125);            
  34.                  
  35.                 $did=0;
  36.                 do {
  37.                     $fid = (((1 << (int) $did) * (float) $arr["freq"]) / 100) - $fixme;
  38.                     if ($fid < 0)
  39.                     {
  40.                         $did++;
  41.                     }
  42.              
  43.                 } while ($fid < 0);
  44.              
  45.                 if ($fid > 63)
  46.                 {
  47.                     $fid = 63;
  48.                 }    
  49.                 $result[$c] = array ("vid"=>$vid,
  50.                                      "fid"=>$fid,
  51.                                      "did"=>$did);
  52.                 $c++;
  53.             }
  54.              
  55.             return $result;
  56.         }        
  57.      }
  58. ?>
  59.  
  60. // -----------------------------------------------------------------------------------------------------------------------
  61.  
  62. <?php
  63. /* * *************************************************************  
  64.  * Copyright notice  
  65.  *  
  66.  * (c) 2014 Chi Hoang (info@chihoang.de)  
  67.  *  All rights reserved  
  68.  * **************************************************************/
  69.   require_once("main.php");
  70.  
  71.   $cpu=array("1"=>16,"2"=>8);
  72.   $type="2";
  73.   $input=array("0"=> array("freq"=>"2400","vcore"=>"1.175"),
  74.                "1"=> array("freq"=>"2000","vcore"=>"1.175")
  75.                );
  76.    
  77.   $convert=new convertFreq($cpu,$type,$input);
  78.   $result=$convert->tofreq();
  79.   print_r($result);
  80. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement