Elctgirl
Newbie level 3
Hi,
How can I convert a 12 bit binary number where each 4 bits represent a character into an 8 bit binary number?
Example: 12 bit number : "001001000011" ==> 2,4,3 and I want to convert it to 243 ==> "11110011"
any help please?
What I did but still haven't reached a right answer:
How can I convert a 12 bit binary number where each 4 bits represent a character into an 8 bit binary number?
Example: 12 bit number : "001001000011" ==> 2,4,3 and I want to convert it to 243 ==> "11110011"
any help please?
What I did but still haven't reached a right answer:
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 signal output1, output2, output3 : integer range 0 to 9; signal output11, output22 : integer range 0 to 255; begin process(clk) begin if(clk'event and clk='1') then case input(11 downto 8) is when "0000" => output1 <= 0; when "0001" => output1 <= 1; when "0010" => output1 <= 2; when "0011" => output1 <= 3; when "0100" => output1 <= 4; when "0101" => output1 <= 5; when "0110" => output1 <= 6; when "0111" => output1 <= 7; when "1000" => output1 <= 8; when "1001" => output1 <= 9; when others => output1 <= 0; end case; case input(7 downto 4) is when "0000" => output2 <= 0; when "0001" => output2 <= 1; when "0010" => output2 <= 2; when "0011" => output2 <= 3; when "0100" => output2 <= 4; when "0101" => output2 <= 5; when "0110" => output2 <= 6; when "0111" => output2 <= 7; when "1000" => output2 <= 8; when "1001" => output2 <= 9; when others => output2 <= 0; end case; case input(3 downto 0) is when "0000" => output3 <= 0; when "0001" => output3 <= 1; when "0010" => output3 <= 2; when "0011" => output3 <= 3; when "0100" => output3 <= 4; when "0101" => output3 <= 5; when "0110" => output3 <= 6; when "0111" => output3 <= 7; when "1000" => output3 <= 8; when "1001" => output3 <= 9; when others => output3 <= 0; end case; end if; end process; output11 <= output1*100; output22 <= output2*10; finaloutput <= output1+output2+output3; output<= std_logic_vector(to_unsigned(finaloutput,8));
Last edited by a moderator: