vt52-fpga  1.0.0 Initial
vt52-fpga is a serial terminal implemented on a FPGA
usb_uart_ecp5.v
Go to the documentation of this file.
1 /*
2  usb_uart_ecp5
3 
4  Simple wrapper around the usb_uart which incorporates the Pin driver logic
5  so this doesn't clutter the top level circuit
6 
7  Make the signature generic (usb_uart) and rely on the file inclusion process (makefile)
8  to bring the correct architecture in
9 
10  ----------------------------------------------------
11  usb_uart u_u (
12  .clk_48mhz (clk_48mhz),
13  .reset (reset),
14 
15  // pins
16  .pin_usb_p( pin_usb_p ),
17  .pin_usb_n( pin_usb_n ),
18 
19  // uart pipeline in (w.r.t module)
20  .pipe_in( pipe_in )
21 
22  // uart pipeline out (w.r.t. module)
23  .pipe_out( pipe_out )
24  );
25 
26  Utilization
27 
28  707 LUTs?
29 
30 */
31 
32 `include "../../pipe/rtl/pipe_defs.v"
33 
34 module usb_uart #( parameter PipeSpec = `PS_d8 ) (
35  input clk_48mhz,
36  input reset,
37 
38  // USB pins
39  inout pin_usb_p,
40  inout pin_usb_n,
41 
42  inout [`P_m(PipeSpec):0] pipe_in,
43  inout [`P_m(PipeSpec):0] pipe_out,
44 
45  output [11:0] debug
46  );
47 
48  wire [`P_Data_m(PipeSpec):0] in_data;
49  wire in_valid;
50  wire in_ready;
51 
52  wire [`P_Data_m(PipeSpec):0] out_data;
53  wire out_valid;
54  wire out_ready;
55 
56  p_unpack_data #( .PipeSpec( PipeSpec ) ) in_unpack_data( .pipe(pipe_in), .data(in_data) );
57  p_unpack_valid_ready #( .PipeSpec( PipeSpec ) ) in_unpack_valid_ready( .pipe(pipe_in), .valid(in_valid), .ready(in_ready) );
58 
59  // start and stop signals are ignored - packetization has to be escaped
60  usb_uart_np u_u_np(
61  clk_48mhz, reset,
62 
63  pin_usb_p, pin_usb_n,
64 
65  in_data, in_valid, in_ready,
66  out_data, out_valid, out_ready,
67 
68  debug
69  );
70 
71  p_pack_data #( .PipeSpec( PipeSpec ) ) out_pack_d( .data(out_data), .pipe(pipe_out) );
72  p_pack_valid_ready #( .PipeSpec( PipeSpec ) ) out_pack_vr( .valid(out_valid), .ready(out_ready), .pipe(pipe_out) );
73 
74 endmodule
75 
76 module usb_uart_np (
77  input clk_48mhz,
78  input reset,
79 
80  // USB pins
81  inout pin_usb_p,
82  inout pin_usb_n,
83 
84  // uart pipeline in (out of the device, into the host)
85  input [7:0] uart_in_data,
86  input uart_in_valid,
87  output uart_in_ready,
88 
89  // uart pipeline out (into the device, out of the host)
90  output [7:0] uart_out_data,
91  output uart_out_valid,
92  input uart_out_ready,
93 
94  output [11:0] debug
95 );
96 
97  wire usb_p_tx;
98  wire usb_n_tx;
99  wire usb_p_rx;
100  wire usb_n_rx;
101  wire usb_tx_en;
102 
103  // wire [11:0] debug_dum;
104 
105  usb_uart_core_np u_u_c_np (
106  .clk_48mhz (clk_48mhz),
107  .reset (reset),
108 
109  // pins - these must be connected properly to the outside world. See below.
110  .usb_p_tx(usb_p_tx),
111  .usb_n_tx(usb_n_tx),
112  .usb_p_rx(usb_p_rx),
113  .usb_n_rx(usb_n_rx),
114  .usb_tx_en(usb_tx_en),
115 
116  // uart pipeline in
117  .uart_in_data( uart_in_data ),
118  .uart_in_valid( uart_in_valid ),
119  .uart_in_ready( uart_in_ready ),
120 
121  // uart pipeline out
122  .uart_out_data( uart_out_data ),
123  .uart_out_valid( uart_out_valid ),
124  .uart_out_ready( uart_out_ready ),
125 
126  .debug( debug )
127  );
128 
129  wire usb_p_in;
130  wire usb_n_in;
131 
132  assign usb_p_rx = usb_tx_en ? 1'b1 : usb_p_in;
133  assign usb_n_rx = usb_tx_en ? 1'b0 : usb_n_in;
134 
135  // T = TRISTATE (not transmit)
136  BB io_p( .I( usb_p_tx ), .T( !usb_tx_en ), .O( usb_p_in ), .B( pin_usb_p ) );
137  BB io_n( .I( usb_n_tx ), .T( !usb_tx_en ), .O( usb_n_in ), .B( pin_usb_n ) );
138 
139 endmodule
module usb_uart(input clk_48mhz, input reset, inout pin_usb_p, inout pin_usb_n, inout[P_m(PipeSpec):0] pipe_in, inout[P_m(PipeSpec):0] pipe_out, output[11:0] debug)
Definition: usb_uart_ecp5.v:34
module usb_uart_np(input clk_48mhz, input reset, inout pin_usb_p, inout pin_usb_n, input[8] uart_in_data, input uart_in_valid, output uart_in_ready, output[8] uart_out_data, output uart_out_valid, input uart_out_ready, output[11:0] debug)
Definition: usb_uart_ecp5.v:76