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

Subversion Repositories ft245r_interface

[/] [ft245r_interface/] [branches/] [ft245r_avalon/] [ft245_snd.vhd] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 pradd
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.numeric_std.all;
4
 
5
 
6
entity ft245_snd is
7
        generic(clock_cycle : integer);
8
        port
9
        (
10
                clk                                     : in    std_logic;
11
                data_in                         : in    std_logic_vector(7 downto 0);
12
                n_wr                                    : out   std_logic := '0';
13
                n_txe                                   : in    std_logic;
14
 
15
                -- system interface
16
                ready                                   : out   std_logic := '0';                                                -- goes high when there's a byte available for reading
17
                wr                                              : in    std_logic;                                                              -- invalidates current byte
18
                data_out                                : out   std_logic_vector(7 downto 0)
19
        );
20
end ft245_snd;
21
 
22
 
23
architecture action of ft245_snd is
24
        constant        t7      :       integer :=      integer(100.0 / (50.0 / real(clock_cycle)));
25
        constant        t8      :       integer :=      integer(50.0 / (50.0 / real(clock_cycle)));
26
        constant        t9      :       integer :=      integer(20.0 / (50.0 / real(clock_cycle)));
27
        constant        t11:    integer :=      integer(25.0 / (50.0 / real(clock_cycle)));
28
        constant        t12:    integer :=      integer(80.0 / (50.0 / real(clock_cycle)));
29
 
30
        type state_t is
31
        (
32
                S_IDLE,
33
                S_WR_HIGH,
34
                S_WR_LOW,
35
                S_DELAY,
36
                S_END
37
        );
38
        signal state                    :       state_t :=      S_IDLE;
39
        signal n_state                  :       state_t := S_IDLE;
40
        signal delay                    :       integer :=      0;
41
begin
42
 
43
        ready   <=      '1'     when n_txe = '0' and state = S_IDLE else '0';
44
--      n_wr    <= '1'  when (state = S_WR_HIGH or n_state = S_WR_HIGH) else '0';
45
 
46
        process(clk, n_txe, wr)
47
        begin
48
                if(rising_edge(clk))then
49
                        case state is
50
                                when S_IDLE =>
51
                                        if(wr = '1' and n_txe = '0')then
52
                                                n_wr                            <= '1';
53
                                                delay                           <= t7;
54
                                                data_out                        <= data_in;
55
                                                n_state                 <= S_WR_HIGH;
56
                                                state                           <= S_DELAY;
57
                                        end if;
58
 
59
                                when S_WR_HIGH =>
60
                                        delay                                   <= t8;
61
                                        n_state                         <= S_WR_LOW;
62
                                        state                                   <= S_DELAY;
63
                                        n_wr                                    <= '0';
64
 
65
                                when S_WR_LOW =>
66
                                        delay                                   <= t12 - t8;
67
                                        n_state                         <= S_END;
68
                                        state                                   <= S_DELAY;
69
 
70
                                when S_DELAY =>
71
                                        if(delay > 0)then
72
                                                delay                           <= delay - 1;
73
                                        else
74
                                                state                           <= n_state;
75
                                        end if;
76
 
77
                                when S_END =>
78
                                        state                                   <= S_IDLE;
79
 
80
                                when others =>
81
                                        state                           <= S_IDLE;
82
                        end case;
83
                end if;
84
        end process;
85
end action;

powered by: WebSVN 2.1.0

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