OpenCores
URL https://opencores.org/ocsvn/tcp_ip_core_w_dhcp/tcp_ip_core_w_dhcp/trunk

Subversion Repositories tcp_ip_core_w_dhcp

[/] [tcp_ip_core_w_dhcp/] [trunk/] [hex_to_ascii.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 craighaywo
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date:    09:54:41 01/21/2015 
6
-- Design Name: 
7
-- Module Name:    hex_to_ascii - Behavioral 
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool versions: 
11
-- Description: 
12
--
13
-- Dependencies: 
14
--
15
-- Revision: 
16
-- Revision 0.01 - File Created
17
-- Additional Comments: 
18
--
19
----------------------------------------------------------------------------------
20
library IEEE;
21
use IEEE.STD_LOGIC_1164.ALL;
22
use IEEE.NUMERIC_STD.ALL;
23
 
24
-- Uncomment the following library declaration if instantiating
25
-- any Xilinx primitives in this code.
26
--library UNISIM;
27
--use UNISIM.VComponents.all;
28
 
29
entity hex_to_ascii is
30
    Port ( CLK_IN                       : in  STD_LOGIC;
31
           CONV_IN                      : in  STD_LOGIC;
32
           HEX_IN                       : in  STD_LOGIC_VECTOR (3 downto 0);
33
           ASCII_OUT            : out  STD_LOGIC_VECTOR (7 downto 0);
34
           CONV_DONE_OUT        : out  STD_LOGIC);
35
end hex_to_ascii;
36
 
37
architecture Behavioral of hex_to_ascii is
38
 
39
signal state : std_logic_vector(1 downto 0) := "00";
40
signal ascii : unsigned(7 downto 0);
41
 
42
begin
43
 
44
        ASCII_OUT <= std_logic_vector(ascii);
45
 
46
        process(CLK_IN)
47
        begin
48
                if rising_edge(CLK_IN) then
49
                        if state = "00" then
50
                                if CONV_IN = '1' then
51
                                        state <= "01";
52
                                end if;
53
                        elsif state = "01" then
54
                                if HEX_IN > X"9" then
55
                                        state <= "10";
56
                                else
57
                                        state <= "11";
58
                                end if;
59
                        else
60
                                state <= "00";
61
                        end if;
62
                end if;
63
        end process;
64
 
65
        process(CLK_IN)
66
        begin
67
                if rising_edge(CLK_IN) then
68
                        if state = "10" then
69
                                ascii <= RESIZE(unsigned(HEX_IN), 8) + X"37";
70
                        elsif state = "11" then
71
                                ascii <= RESIZE(unsigned(HEX_IN), 8) + X"30";
72
                        end if;
73
                        if state = "10" then
74
                                CONV_DONE_OUT <= '1';
75
                        elsif state = "11" then
76
                                CONV_DONE_OUT <= '1';
77
                        else
78
                                CONV_DONE_OUT <= '0';
79
                        end if;
80
                end if;
81
        end process;
82
 
83
end Behavioral;
84
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.