1 /* ****************************************************************************
\r
2 -- Source file: mesa_phy.v
\r
3 -- Date: October 2015
\r
5 -- Description: Interface the Byte binary stream of the internal Mesa-Bus with
\r
6 -- the physical layer. For this case, using UARTs.
\r
7 -- This instantiates the UARTs and takes care of the binary to
\r
8 -- ASCII conversions for all directions.
\r
9 -- Language: Verilog-2001 and VHDL-1993
\r
10 -- Simulation: Mentor-Modelsim
\r
11 -- Synthesis: Lattice
\r
12 -- License: This project is licensed with the CERN Open Hardware Licence
\r
13 -- v1.2. You may redistribute and modify this project under the
\r
14 -- terms of the CERN OHL v.1.2. (http://ohwr.org/cernohl).
\r
15 -- This project is distributed WITHOUT ANY EXPRESS OR IMPLIED
\r
16 -- WARRANTY, INCLUDING OF MERCHANTABILITY, SATISFACTORY QUALITY
\r
17 -- AND FITNESS FOR A PARTICULAR PURPOSE. Please see the CERN OHL
\r
18 -- v.1.2 for applicable Conditions.
\r
20 -- Revision History:
\r
21 -- Ver# When Who What
\r
22 -- ---- -------- -------- ---------------------------------------------------
\r
23 -- 0.1 10.04.15 khubbard Creation
\r
24 -- ***************************************************************************/
\r
25 `default_nettype none // Strictly enforce all nets to be declared
\r
31 input wire disable_chain,
\r
32 input wire clr_baudlock,
\r
33 output wire mesa_wi_baudlock,
\r
36 output wire mesa_wo,
\r
38 output wire mesa_ro,
\r
40 output wire mesa_wi_nib_en,
\r
41 output wire [3:0] mesa_wi_nib_d,
\r
42 input wire mesa_wo_byte_en,
\r
43 input wire [7:0] mesa_wo_byte_d,
\r
44 output wire mesa_wo_busy,
\r
45 input wire mesa_ro_byte_en,
\r
46 input wire [7:0] mesa_ro_byte_d,
\r
47 output wire mesa_ro_busy,
\r
48 input wire mesa_ro_done
\r
49 );// module mesa_phy
\r
53 wire [7:0] wi_char_d;
\r
55 wire [7:0] ro_char_d;
\r
59 wire [7:0] wo_char_d;
\r
62 wire [15:0] baud_rate;
\r
64 assign mesa_wi_baudlock = baud_lock;
\r
66 //-----------------------------------------------------------------------------
\r
67 // UART to convert serial streams to/from ASCII bytes for Wi and Ro.
\r
68 //-----------------------------------------------------------------------------
\r
69 mesa_uart u_mesa_uart
\r
73 .clr_baudlock ( clr_baudlock ),
\r
74 .en_autobaud ( 1'b1 ),
\r
75 //.en_autobaud ( 1'b0 ),
\r
80 .rx_rdy ( wi_char_en ),
\r
81 .rx_byte ( wi_char_d[7:0] ),
\r
83 .tx_en ( ro_char_en ),
\r
84 .tx_byte ( ro_char_d[7:0] ),
\r
85 .tx_busy ( ro_uart_busy ),
\r
86 .tx_idle ( ro_uart_idle ),
\r
88 .baud_rate ( baud_rate[15:0] ),
\r
89 .baud_lock ( baud_lock )
\r
90 ); // module mesa_uart
\r
93 //-----------------------------------------------------------------------------
\r
94 // TX Only UART. Sends Wo data. When 1st UART goes to lock, sends "\n" out,
\r
95 // otherwise just echos the binary stream from decode block ( Wi->Wo ).
\r
96 //-----------------------------------------------------------------------------
\r
97 mesa_tx_uart u_mesa_tx_uart
\r
100 .reset ( reset | disable_chain ),
\r
102 .tx_en ( wo_char_en ),
\r
103 .tx_byte ( wo_char_d[7:0] ),
\r
104 .tx_busy ( wo_uart_busy ),
\r
105 .baud_rate ( baud_rate[15:0] ),
\r
106 .baud_lock ( baud_lock )
\r
107 ); // module mesa_uart
\r
110 //-----------------------------------------------------------------------------
\r
111 // Convert Wi ASCII to Binary Nibbles. Decoder figures out nibble/byte phase
\r
112 //-----------------------------------------------------------------------------
\r
113 mesa_ascii2nibble u_mesa_ascii2nibble
\r
116 .rx_char_en ( wi_char_en ),
\r
117 .rx_char_d ( wi_char_d[7:0] ),
\r
118 .rx_nib_en ( mesa_wi_nib_en ),
\r
119 .rx_nib_d ( mesa_wi_nib_d[3:0] )
\r
120 );// module mesa_ascii2nibble
\r
123 //-----------------------------------------------------------------------------
\r
124 // Convert Ro Binary Bytes to ASCII
\r
125 //-----------------------------------------------------------------------------
\r
126 mesa_byte2ascii u0_mesa_byte2ascii
\r
130 .tx_byte_en ( mesa_ro_byte_en ),
\r
131 .tx_byte_d ( mesa_ro_byte_d[7:0] ),
\r
132 .tx_byte_busy ( mesa_ro_busy ),
\r
133 .tx_byte_done ( mesa_ro_done ),
\r
134 .tx_char_en ( ro_char_en ),
\r
135 .tx_char_d ( ro_char_d[7:0] ),
\r
136 .tx_char_busy ( ro_uart_busy ),
\r
137 .tx_char_idle ( ro_uart_idle )
\r
138 );// module mesa_byte2ascii
\r
141 //-----------------------------------------------------------------------------
\r
142 // Convert Wo Binary Bytes to ASCII
\r
143 //-----------------------------------------------------------------------------
\r
144 mesa_byte2ascii u1_mesa_byte2ascii
\r
147 .reset ( reset | disable_chain ),
\r
148 .tx_byte_en ( mesa_wo_byte_en ),
\r
149 .tx_byte_d ( mesa_wo_byte_d[7:0] ),
\r
150 .tx_byte_busy ( mesa_wo_busy ),
\r
151 .tx_byte_done ( 1'b0 ),
\r
152 .tx_char_en ( wo_char_en ),
\r
153 .tx_char_d ( wo_char_d[7:0] ),
\r
154 .tx_char_busy ( wo_uart_busy )
\r
155 );// module mesa_byte2ascii
\r
158 endmodule // mesa_phy.v
\r