Debian Codegraph @

hdl/fpga/ip/nuand/synthesis/uart_bridge.vhd

raw
1 -- Copyright (c) 2013 Nuand LLC
2 --
3 -- Permission is hereby granted, free of charge, to any person obtaining a copy
4 -- of this software and associated documentation files (the "Software"), to deal
5 -- in the Software without restriction, including without limitation the rights
6 -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 -- copies of the Software, and to permit persons to whom the Software is
8 -- furnished to do so, subject to the following conditions:
9 --
10 -- The above copyright notice and this permission notice shall be included in
11 -- all copies or substantial portions of the Software.
12 --
13 -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 -- THE SOFTWARE.
20
21 library ieee ;
22 use ieee.std_logic_1164.all ;
23 use ieee.numeric_std.all ;
24
25 entity uart_bridge is
26 port (
27 -- UART Interface
28 uart_clock : in std_logic ;
29 uart_reset : in std_logic ;
30 uart_enable : in std_logic ;
31 uart_rxd : out std_logic ;
32 uart_txd : out std_logic ;
33
34 -- SPI Interface
35 spi_clock : in std_logic ;
36 spi_reset : in std_logic ;
37 spi_sclk : out std_logic ;
38 spi_miso : in std_logic ;
39 spi_mosi : out std_logic ;
40 spi_csn : out std_logic
41 ) ;
42 end entity ; -- uart_bridge
43
44 architecture arch of uart_bridge is
45
46 -- UART to SPI FIFO signals
47 signal u2s_write : std_logic ;
48 signal u2s_full : std_logic ;
49 signal u2s_data : std_logic_vector(7 downto 0) ;
50
51 -- SPI to UART FIFO signals
52 signal s2u_read : std_logic ;
53 signal s2u_empty : std_logic ;
54 signal s2u_data : std_logic_vector(7 downto 0) ;
55
56 begin
57
58 -- UART interface
59 U_uart : entity work.uart
60 port map (
61 -- Control signals
62 clock => uart_clock,
63 reset => uart_reset,
64 enable => uart_enable,
65
66 -- External UART signals
67 rs232_rxd => uart_rxd,
68 rs232_txd => uart_txd,
69
70 -- FIFO signals for UART to FIFO from external interface
71 txd_we => u2s_write,
72 txd_full => u2s_full,
73 txd_wdata => u2s_data,
74
75 -- FIFO signals for FIFO to UART to be transmitted back
76 rxd_re => s2u_read,
77 rxd_empty => s2u_empty,
78 rxd_rdata => s2u_data
79 ) ;
80
81 -- Dual clock FIFO for UART -> SPI comms
82 U_u2s_fifo : entity work.async_fifo
83 port map (
84 -- Write side: UART
85 w_clock => uart_clock,
86 w_enable => u2s_write,
87 w_data => u2s_data,
88 w_empty => open,
89 w_full => u2s_full,
90
91 -- Read side: SPI
92 r_clock => spi_clock,
93 r_enable => spi_read,
94 r_data => spi_data,
95 r_empty => spi_empty,
96 r_full => open
97 ) ;
98
99 -- Dual clock FIFO for SPI -> UART comms
100 U_s2u_fifo : entity work.async_fifo
101 port map (
102 -- Write side: SPI
103 w_clock => spi_clock,
104 w_enable => spi_readback_wen,
105 w_data => spi_readback_data,
106 w_empty => open,
107 w_full => s2u_full,
108
109 -- Read side: UART
110 r_clock => uart_clock,
111 r_enable => s2u_read,
112 r_data => s2u_data,
113 r_empty => s2u_empty,
114 r_full => open
115 ) ;
116
117 -- LMS SPI interface
118 U_lms_spi : entity lms_spi
119 port map (
120 -- Control signals
121 clock => spi_clock,
122 reset => spi_reset,
123
124 -- SPI data stream
125 spi_data => spi_data,
126 spi_read => spi_read,
127 spi_empty => spi_empty,
128
129 -- SPI readback data stream
130 readback_data => spi_readback_data,
131 readback_enable => spi_readback_wen
132 ) ;
133
134 end architecture ; -- arch