Advertisement
AbraaoAllysson

extensor sinal

Jun 15th, 2016
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "genpat.h"
  4.  
  5. unsigned int cur_vect = 0;
  6.  
  7. char *inttostr(entier)
  8.     int entier;
  9. {
  10.     char *str;
  11.     str = (char*)mbkalloc(32*sizeof(char));
  12.     sprintf(str, "%d",entier);
  13.     return(str);
  14. }
  15.  
  16. char *inttoHstr(entier)
  17.     int entier;
  18. {
  19.     char *str;
  20.     str = (char*)mbkalloc(32*sizeof(char));
  21.     sprintf(str, "0x%X",entier);
  22.     return(str);
  23. }
  24.  
  25.  
  26. void sign_extension(int number)
  27. {
  28.     int result = number;
  29.     number >>= 15;
  30.     if(number == 1)
  31.     {
  32.       result += 0xFFFF0000;
  33.       AFFECT(inttostr(cur_vect),"out",inttoHstr(result));
  34.     }
  35.     else
  36.     {
  37.        AFFECT(inttostr(cur_vect),"out",inttoHstr(result));
  38.     }      
  39. }
  40.  
  41. int main()
  42. {
  43. DEF_GENPAT("EXTENSOR");
  44. int i;
  45.  int size_16 = 65535;
  46.  
  47.  
  48.  
  49.  
  50. DECLAR("in",":2","B",IN,"15 downton 0","");
  51. DECLAR("out",":2","B",OUT,"31 downton 0","");
  52. DECLAR("vdd",":2","B",IN,"","");
  53. DECLAR("vss",":2","B",IN,"","");
  54.  
  55. AFFECT("0","vdd","0b1");
  56. AFFECT("0","vss","0b0");
  57.  
  58.  
  59.     for(i=0; i <= size_16; i++){
  60.    
  61.        AFFECT(inttostr(cur_vect),"in",inttostr(i));
  62.        LABEL("sinal");
  63.        sign_extension(i);
  64.        cur_vect++;
  65.        
  66.     }
  67.    
  68.     printf("\nFIM\n");
  69.     SAV_GENPAT();
  70.  
  71.  
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement