Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include "genpat.h"
- unsigned int cur_vect = 0;
- char *inttostr(entier)
- int entier;
- {
- char *str;
- str = (char*)mbkalloc(32*sizeof(char));
- sprintf(str, "%d",entier);
- return(str);
- }
- char *inttoHstr(entier)
- int entier;
- {
- char *str;
- str = (char*)mbkalloc(32*sizeof(char));
- sprintf(str, "0x%X",entier);
- return(str);
- }
- void sign_extension(int number)
- {
- int result = number;
- number >>= 15;
- if(number == 1)
- {
- result += 0xFFFF0000;
- AFFECT(inttostr(cur_vect),"out",inttoHstr(result));
- }
- else
- {
- AFFECT(inttostr(cur_vect),"out",inttoHstr(result));
- }
- }
- int main()
- {
- DEF_GENPAT("EXTENSOR");
- int i;
- int size_16 = 65535;
- DECLAR("in",":2","B",IN,"15 downton 0","");
- DECLAR("out",":2","B",OUT,"31 downton 0","");
- DECLAR("vdd",":2","B",IN,"","");
- DECLAR("vss",":2","B",IN,"","");
- AFFECT("0","vdd","0b1");
- AFFECT("0","vss","0b0");
- for(i=0; i <= size_16; i++){
- AFFECT(inttostr(cur_vect),"in",inttostr(i));
- LABEL("sinal");
- sign_extension(i);
- cur_vect++;
- }
- printf("\nFIM\n");
- SAV_GENPAT();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement