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

Subversion Repositories modbus

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 guanucolui
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date:    13:17:44 03/31/2010 
6
-- Design Name: 
7
-- Module Name:    ascii_bin - 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.STD_LOGIC_ARITH.ALL;
23
use IEEE.STD_LOGIC_UNSIGNED.ALL;
24
 
25
---- Uncomment the following library declaration if instantiating
26
---- any Xilinx primitives in this code.
27
--library UNISIM;
28
--use UNISIM.VComponents.all;
29
 
30
entity ascii_bin is
31
        port(
32
                        clk                     :in std_logic;
33
                        reset           :in std_logic;
34
                        ascii           :in std_logic_vector(7 downto 0);
35
                        new_data                :in std_logic;
36
                        Nnew_data               :out std_logic;
37
                        bin                     :out std_logic_vector(7 downto 0));
38
end ascii_bin;
39
 
40
architecture Behavioral of ascii_bin is
41
signal  Sa      :std_logic:='0';
42
signal  Sb      :std_logic:='0';
43
signal  Sc      :std_logic:='0';
44
signal  Sd      :std_logic:='0';
45
signal  Ssustraendo:std_logic_vector(7 downto 0):=(others => '0');
46
signal  Sconvinacional:std_logic:='0';
47
signal  Q1      :std_logic:='0';
48
 
49
begin
50
 
51
mayor_cero:process(clk)
52
begin
53
   if (clk'event and clk ='1') then
54
      if ( ascii >= "00110000" ) then --si es mayor que 0 (ASCII)
55
         Sa <= '1';
56
      else
57
         Sa <= '0';
58
      end if;
59
   end if;
60
end process;
61
 
62
menor_nueve:process(clk)
63
begin
64
   if (clk'event and clk ='1') then
65
      if ( ascii <= "00111001" ) then --si es menor que 9 (ASCII)
66
         Sb <= '1';
67
      else
68
         Sb <= '0';
69
      end if;
70
   end if;
71
end process;
72
 
73
mayor_A:process(clk)
74
begin
75
   if (clk'event and clk ='1') then
76
      if ( ascii >= "01000001" ) then --si es mayor que A (ASCII)
77
         Sc <= '1';
78
      else
79
         Sc <= '0';
80
      end if;
81
   end if;
82
end process;
83
 
84
menor_F:process(clk)
85
begin
86
   if (clk'event and clk ='1') then
87
      if ( ascii <= "01000110" ) then --si es menor que 9 (ASCII)
88
         Sd <= '1';
89
      else
90
         Sd <= '0';
91
      end if;
92
   end if;
93
end process;
94
 
95
Sconvinacional<= (not(Sa and not Sb and Sc and Sd)) or (Sa and Sb and not Sc and Sd); --controla cual es el sustraendo (0 o A-10)
96
 
97
Ssustraendo<= "00110000" WHEN Sconvinacional ='1' ELSE --es el mutiplexor controlado por Sconvinacional para definir el sustraendo en la resta
98
                        "00110111";
99
bin <= ascii - Ssustraendo;
100
 
101
process(clk, reset)
102
begin
103
  if (reset = '1') then
104
    Q1 <= '0';
105
  elsif (clk'event and clk = '1') then
106
    Q1 <= new_data;
107
    Nnew_data <= Q1;
108
  end if;
109
end process;
110
 
111
end Behavioral;
112
 

powered by: WebSVN 2.1.0

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