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

Subversion Repositories openverifla

[/] [openverifla/] [trunk/] [openverifla_2.4/] [vhdl/] [verifla/] [u_xmit_of_verifla.vhd] - Blame information for rev 46

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 46 laurentiud
-- 20180816-1600
2
-- author: Laurentiu Duca
3
-- license: GNU GPL
4
-----------------------------------------------------
5
 
6
library IEEE;
7
use IEEE.STD_LOGIC_1164.ALL;
8
use IEEE.NUMERIC_STD.ALL;
9
--use ieee.std_logic_arith.all;  
10
--use ieee.std_logic_unsigned.all;
11
 
12
-----------------------------------------------------
13
 
14
 
15
entity u_xmit_of_verifla is
16
port(   clk_i, rst_i, baud_clk_posedge: in std_logic;
17
                data_i:in std_logic_vector(7 downto 0);
18
                wen_i: in std_logic;
19
                txd_o, tre_o: out std_logic
20
);
21
end u_xmit_of_verifla;
22
 
23
-----------------------------------------------------
24
 
25
architecture u_xmit_of_verifla_arch of u_xmit_of_verifla is
26
 
27
        type state_type is (STA_IDLE, STA_TRANS, STA_FINISH);
28
        signal txd_o_reg, tre_o_reg: std_logic;
29
        signal tsr: std_logic_vector(7 downto 0); -- transmitting shift register
30
        signal num_of_trans: std_logic_vector(3 downto 0);
31
   signal reg_sta: state_type;
32
        signal count: std_logic_vector(4 downto 0); -- the counter to count the clk in
33
        --signal count_c: std_logic; -- the carry of count
34
 
35
begin
36
 
37
        txd_o <= txd_o_reg;
38
        tre_o <= tre_o_reg;
39
 
40
   state_reg: process(clk_i, rst_i)
41
   begin
42
                if (rst_i='1') then
43
                        tsr          <= x"00";
44
                        txd_o_reg        <= '1';
45
                        tre_o_reg        <= '1';
46
                        num_of_trans <= "0000";
47
                        --count_c      <= '0';
48
                        count        <= "00000";
49
                        reg_sta      <= STA_IDLE;
50
                elsif (rising_edge(clk_i)) then
51
                        if(baud_clk_posedge = '1') then
52
                                case reg_sta is
53
                                when STA_IDLE =>
54
                                        num_of_trans    <= "0000";
55
                                        count           <= "00000";
56
                                        --count_c         <= '0';
57
                                        if (wen_i = '1') then
58
                                                tsr <= data_i;
59
                                                tre_o_reg <= '0';
60
                                                txd_o_reg <= '0';
61
                                                reg_sta <= STA_TRANS;
62
                                        else
63
                                                reg_sta <= STA_IDLE;
64
                                  end if;
65
                                when STA_TRANS =>
66
                                        count <= std_logic_vector(unsigned('0' & count(3 downto 0)) + "00001");
67
                                        if(count(4) = '1') then
68
                                                if(num_of_trans <= x"8") then
69
                                                        -- note ,when num_of_trans==8 ,we transmit the stop bit
70
                                                        tsr <= '1' & tsr(7 downto 1);
71
                                                        txd_o_reg <= tsr(0);
72
                                                        num_of_trans <= std_logic_vector(unsigned(num_of_trans) + "0001");
73
                                                        reg_sta <= STA_TRANS;
74
                                                else
75
                                                        txd_o_reg <= '1';
76
                                                        tre_o_reg <= '1';
77
                                                        reg_sta <= STA_IDLE;
78
                                                end if;
79
                                        end if;
80
                                when others =>
81
                                        -- this is forced by the vhdl compiler
82
                                end case;
83
                        end if;
84
                end if;
85
   end process;
86
 
87
end u_xmit_of_verifla_arch;

powered by: WebSVN 2.1.0

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