Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] we have trouble with RS232 TX VHDL code

Status
Not open for further replies.

Ivan-Holm

Member level 5
Member level 5
Joined
Jun 3, 2010
Messages
84
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,288
Location
Denmark
Activity points
1,894
We are trying to do some homework making a RS232 transmitter...
This is what we made so far and there is a lot of faults it it.. but we don't know what. We think its something with the way we written the states. Please rewrite it to some useful syntax

this is what we made so far


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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
 
 
entity RS232_TX is
    Port ( 
    Baud_clk_Par_Ser_Conv : in  STD_LOGIC;                          -- Baud rate CLK
                      TX  : out STD_LOGIC_VECTOR ( 10 downto 0 );   -- TX
                      Data: in  STD_LOGIC_VECTOR ( 7 downto 0  )    -- Data stream
          );  
              
end RS232_TX;
 
 
architecture RS232 of RS232_TX is
 
 
shared variable T_1 : std_logic_vector (3 downto 0);
--BEGIN MAIN PROCESS
--RS232_TX : process (Baud_clk_Par_Ser_Conv)
 
begin
 
    -- BEGIN PROCESS Counter_1
 
    Counter_1 : process (Baud_clk_Par_Ser_Conv)
    variable  T : integer range 0 to 11;
 
    begin                                                                   
 
        if Baud_clk_Par_Ser_Conv' event and (Baud_clk_Par_Ser_Conv = '1') then
 
                T := T+1;
                if T >= 11 then T := 0;
                end if;
                     T_1 := CONV_STD_LOGIC_VECTOR(T, 4);
                
        end if;
 
    end process;                                                        
 
    -- END PROCESS  Counter_1
    
    -- BEGIN PROCESS RS232_TX
 
    RS232_TX : process  (Data, Baud_clk_Par_Ser_Conv)
    variable TX_1 : STD_LOGIC_VECTOR ( 9 downto 0  );
  variable rs232 : STD_LOGIC_VECTOR ( 9 downto 0  );  
    Begin
    
        if (Baud_clk_Par_Ser_Conv ='1') then                    -- Baud rate CLK
 
            Case T_1 is
 
                When "0000"  => TX_1 <= rs232(0)<= "0";                -- Startbit
                
                --Data Stream
                When "0001"  => TX_1 <= Data(0);                       -- Data Stream 1
                When "0010"  => TX_1 <= Data(1);                       -- Data Stream 2
                When "0011"  => TX_1 <= Data(2);                       -- Data Stream 3
                When "0100"  => TX_1 <= Data(3);                       -- Data Stream 4
                When "0101"  => TX_1 <= Data(4);                       -- Data Stream 5 
                When "0110"  => TX_1 <= Data(5);                       -- Data Stream 6
                When "0111"  => TX_1 <= Data(6);                       -- Data Stream 7
                When "1000"  => TX_1 <= Data(7);                       -- Data Stream 8
        
                When "1001" => TX_1 <=  rs232(9)<="1";                 -- Stopbit (in binary)
                
                when others => null;                                   -- default state
 
            end Case;
        end if;
 
    TX <= TX_1;
 
    end process;
 
    -- END PROCESS  RS232_TX
 
--end process;
 
-- END PROCESS  Main
 
end RS232;

 
Last edited:

There are no problems with the code - perhaps the problem is with your design. But the second process isnt triggering on a clock. You need "clk'event and clk = '1' ", not just clk = '1'.
 
we have try to change whot we think that is wrong but it still make erros with the type ? how shot we do that?
the error list:
ERROR:HDLParsers:800 - "D:/UCN 2011/Digital 2sem/fpga/teatTemadigi/digitestTema.vhd" Line 66. Type of TX_1 is incompatible with type of rs232.
ERROR:HDLParsers:800 - "D:/UCN 2011/Digital 2sem/fpga/teatTemadigi/digitestTema.vhd" Line 69. Type of TX_1 is incompatible with type of Data.
ERROR:HDLParsers:800 - "D:/UCN 2011/Digital 2sem/fpga/teatTemadigi/digitestTema.vhd" Line 70. Type of TX_1 is incompatible with type of Data.
ERROR:HDLParsers:800 - "D:/UCN 2011/Digital 2sem/fpga/teatTemadigi/digitestTema.vhd" Line 71. Type of TX_1 is incompatible with type of Data.
ERROR:HDLParsers:800 - "D:/UCN 2011/Digital 2sem/fpga/teatTemadigi/digitestTema.vhd" Line 72. Type of TX_1 is incompatible with type of Data.
ERROR:HDLParsers:800 - "D:/UCN 2011/Digital 2sem/fpga/teatTemadigi/digitestTema.vhd" Line 73. Type of TX_1 is incompatible with type of Data.
ERROR:HDLParsers:800 - "D:/UCN 2011/Digital 2sem/fpga/teatTemadigi/digitestTema.vhd" Line 74. Type of TX_1 is incompatible with type of Data.
ERROR:HDLParsers:800 - "D:/UCN 2011/Digital 2sem/fpga/teatTemadigi/digitestTema.vhd" Line 75. Type of TX_1 is incompatible with type of Data.
ERROR:HDLParsers:800 - "D:/UCN 2011/Digital 2sem/fpga/teatTemadigi/digitestTema.vhd" Line 76. Type of TX_1 is incompatible with type of Data.
ERROR:HDLParsers:800 - "D:/UCN 2011/Digital 2sem/fpga/teatTemadigi/digitestTema.vhd" Line 78. Type of TX_1 is incompatible with type of <=.
ERROR:HDLParsers:800 - "D:/UCN 2011/Digital 2sem/fpga/teatTemadigi/digitestTema.vhd" Line 85. Type of TX is incompatible with type of TX_1.


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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
 
 
entity digitestTema is
    Port ( Baud_clk_Par_Ser_Conv : in  STD_LOGIC;               -- Baud rate CLK
           --Reset : in  STD_LOGIC;
           --Enable : in  STD_LOGIC;
              --Par_Data : in STD_LOGIC_VECTOR ( 7 downto 0 );
           --Ser_data : out  STD_LOGIC;
              
              --------------
              TX  : out STD_LOGIC ;   -- TX
 
              Data: in  STD_LOGIC_VECTOR ( 7 downto 0  )        -- Data stream
              );  
              
end digitestTema;
--variable T_1 : std_logic_vector (3 downto 0);
 
architecture rs232out of digitestTema is
 
 
shared variable T_1 : std_logic_vector (3 downto 0);
--BEGIN MAIN PROCESS
--RS232_TX : process (Baud_clk_Par_Ser_Conv)
 
begin
 
    -- BEGIN PROCESS Counter_1
 
    Counter_1 : process (Baud_clk_Par_Ser_Conv)
    variable  T : integer range 0 to 11;
 
    begin                                                                   
 
        if Baud_clk_Par_Ser_Conv' event and (Baud_clk_Par_Ser_Conv = '1') then
 
                T := T+1;
                if T >= 11 then T := 0;
                end if;
                     T_1 := CONV_STD_LOGIC_VECTOR(T, 4);
                --T_1 <= T;
        end if;
 
    end process;                                                        
 
    -- END PROCESS  Counter_1
    
    -- BEGIN PROCESS RS232_TX
 
    RS232_TX : process  (Data, Baud_clk_Par_Ser_Conv)
    variable TX_1 : STD_LOGIC_VECTOR ( 9 downto 0  );
  variable rs232 : STD_LOGIC_VECTOR ( 1 downto 0  );-- start stop bit
  variable Data : std_Logic_vector (7 downto 0);
 -- Data <= "01011001"; -- indsæt data
    Begin
    Data := "01100100"; -- indsæt data
     rs232 := "01";
        if (Baud_clk_Par_Ser_Conv ='1') then  -- Baud rate CLK
 
            Case T_1 is
 
                When "0000"  => TX_1 := rs232(0);   -- Startbit
                
                --Data Stream
                When "0001"  => TX_1 := Data(0);                       -- Data Stream 1
                When "0010"  => TX_1 := Data(1);                       -- Data Stream 2
                When "0011"  => TX_1 := Data(2);                       -- Data Stream 3
                When "0100"  => TX_1 := Data(3);                       -- Data Stream 4
                When "0101"  => TX_1 := Data(4);                       -- Data Stream 5 
                When "0110"  => TX_1 := Data(5);                       -- Data Stream 6
                When "0111"  => TX_1 := Data(6);                       -- Data Stream 7
                When "1000"  => TX_1 := Data(7);                       -- Data Stream 8
        
                When "1001" => TX_1 :=  rs232(1)<= '1';-- Stopbit (in binary)
                
                when others => null;                                    -- default state
 
            end Case;
        end if;
 
    TX <= TX_1;
 
    end process;
 
    
 
end rs232out;

 

we were not quite finished but with the help we got worked some of it :) thanks anyway
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top