I saw this 'quick&very dirty way' solution wich enable to create you own library. I find the idea good but the code is limited to a small amount of characters and its quite tiresome to add the other characters.
Here is a small Matlab script to generate the "case" structure with the whole ASCII characters.
FileID = fopen('transcoderASCII2Binary.h','w');
fprintf(FileID, '\t\tcase char is\n');
for i=32:127
fprintf(FileID, '\t\t when ''%s''=> \n\t\t\t data <= "%s"; \n',char(i), dec2bin(i,8)); end fprintf(FileID, '\t\t when others => \n\t\t\t data <= "00000000"; \n'); fprintf(FileID, 'end case;'); fclose(FileID); And here is the result :
case char is
when ' '=>
data <= "00100000";
when '!'=>
data <= "00100001";
when '"'=>
data <= "00100010";
when '#'=>
data <= "00100011";
when '$'=>
data <= "00100100";
[............]
when '~'=>
data <= "01111110";
when ''=>
data <= "01111111";
when others =>
data <= "00000000";
end case;
No comments:
Post a Comment