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

Subversion Repositories modbus

[/] [modbus/] [trunk/] [enlace/] [bin_ascii.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 guanucolui
library IEEE;
2
use IEEE.STD_LOGIC_1164.ALL;
3
use IEEE.STD_LOGIC_ARITH.ALL;
4
use IEEE.STD_LOGIC_UNSIGNED.ALL;
5
 
6
--  Uncomment the following lines to use the declarations that are
7
--  provided for instantiating Xilinx primitive components.
8
--library UNISIM;
9
--use UNISIM.VComponents.all;
10
 
11
entity bin_ascii is
12
        port(
13
                clk             :in std_logic;
14
                reset   :in std_logic;
15
                bin             :in std_logic_vector(7 downto 0);
16
                ascii_h :out std_logic_vector(7 downto 0);
17
                ascii_l :out std_logic_vector(7 downto 0));
18
end bin_ascii;
19
 
20
architecture Behavioral of bin_ascii is
21
 
22
signal  Sa_L                            :std_logic;
23
signal  Sb_L                            :std_logic;
24
signal  Sc_L                            :std_logic;
25
signal  Sd_L                            :std_logic;
26
signal  Sconvinacional_L        :std_logic;
27
signal  Ssuma_L                 :std_logic_vector(7 downto 0);
28
 
29
signal  Sa_H                            :std_logic;
30
signal  Sb_H                            :std_logic;
31
signal  Sc_H                            :std_logic;
32
signal  Sd_H                            :std_logic;
33
signal  Sconvinacional_H        :std_logic;
34
signal  Ssuma_H                 :std_logic_vector(7 downto 0);
35
 
36
begin
37
 
38
 
39
--**************************************************************
40
-- Obtención código ascii de la parte baja
41
--**************************************************************
42
mayor_cero_L:process(clk)
43
begin
44
   if (clk'event and clk ='1') then
45
      if ( bin(3 downto 0) >= "0000" ) then --si es mayor que 0 binario
46
         Sa_L <= '1';
47
      else
48
         Sa_L <= '0';
49
      end if;
50
   end if;
51
end process;
52
 
53
menor_nueve_L:process(clk)
54
begin
55
   if (clk'event and clk ='1') then
56
      if ( bin(3 downto 0) <= "1001" ) then --si es menor que 9  binario
57
         Sb_L <= '1';
58
      else
59
         Sb_L <= '0';
60
      end if;
61
   end if;
62
end process;
63
 
64
mayor_10_L:process(clk)
65
begin
66
   if (clk'event and clk ='1') then
67
      if ( bin(3 downto 0) >= "1010" ) then --si es mayor que 10 binario
68
         Sc_L <= '1';
69
      else
70
         Sc_L <= '0';
71
      end if;
72
   end if;
73
end process;
74
 
75
menor_F_L:process(clk)
76
begin
77
   if (clk'event and clk ='1') then
78
      if ( bin(3 downto 0) <= "1111" ) then --si es menor que 15 binario
79
         Sd_L <= '1';
80
      else
81
         Sd_L <= '0';
82
      end if;
83
   end if;
84
end process;
85
 
86
--**************************************************************
87
-- Obtención código ascii de la parte alta
88
--**************************************************************
89
mayor_cero_H:process(clk)
90
begin
91
   if (clk'event and clk ='1') then
92
      if ( bin(7 downto 4) >= "0000" ) then --si es mayor que 0 binario
93
         Sa_H <= '1';
94
      else
95
         Sa_H <= '0';
96
      end if;
97
   end if;
98
end process;
99
 
100
menor_nueve_H:process(clk)
101
begin
102
   if (clk'event and clk ='1') then
103
      if ( bin(7 downto 4) <= "1001" ) then --si es menor que 9  binario
104
         Sb_H <= '1';
105
      else
106
         Sb_H <= '0';
107
      end if;
108
   end if;
109
end process;
110
 
111
mayor_10_H:process(clk)
112
begin
113
   if (clk'event and clk ='1') then
114
      if ( bin(7 downto 4) >= "1010" ) then --si es mayor que 10 binario
115
         Sc_H <= '1';
116
      else
117
         Sc_H <= '0';
118
      end if;
119
   end if;
120
end process;
121
 
122
menor_15_H:process(clk)
123
begin
124
   if (clk'event and clk ='1') then
125
      if ( bin(7 downto 4) <= "1111" ) then --si es menor que 15 binario
126
         Sd_H <= '1';
127
      else
128
         Sd_H <= '0';
129
      end if;
130
   end if;
131
end process;
132
 
133
 
134
--**************************************************************
135
-- Logica convinacional para la obtención del código ascii bajo
136
--**************************************************************
137
Sconvinacional_L<= (not(Sa_L and not Sb_L and Sc_L and Sd_L)) or (Sa_L and Sb_L and not Sc_L and Sd_L); --controla cual es el sustraendo (0 o A-10)
138
 
139
Ssuma_L <= "00110000" WHEN Sconvinacional_L ='1' ELSE --es el mutiplexor controlado por Sconvinacional para definir lo sumado
140
             "00110111";  -- valor equivalente a el ascii 'A'
141
 
142
ascii_L <= bin(3 downto 0) + Ssuma_L;
143
 
144
--**************************************************************
145
-- Logica convinacional para la obtención del código ascii alto
146
--**************************************************************
147
Sconvinacional_H<= (not(Sa_H and not Sb_H and Sc_H and Sd_H)) or (Sa_H and Sb_H and not Sc_H and Sd_H); --controla cual es el sustraendo (0 o A-10)
148
 
149
Ssuma_H <= "00110000" WHEN Sconvinacional_H ='1' ELSE --es el mutiplexor controlado por Sconvinacional para definir lo sumado
150
             "00110111";  -- valor equivalente a el ascii 'A'
151
 
152
ascii_H <= bin(7 downto 4) + Ssuma_H;
153
 
154
 
155
 
156
 
157
 
158
 
159
 
160
 
161
end Behavioral;

powered by: WebSVN 2.1.0

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