-
Notifications
You must be signed in to change notification settings - Fork 4
/
Uart8.v
73 lines (64 loc) · 1.42 KB
/
Uart8.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
`include "BaudRateGenerator.v"
`include "Uart8Receiver.v"
`include "Uart8Transmitter.v"
/*
* Simple 8-bit UART realization
*
* Able to transmit and receive 8 bits of serial data, one start bit,
* one stop bit
*/
module Uart8 #(
parameter CLOCK_RATE = 100000000, // board clock (default 100MHz)
parameter BAUD_RATE = 9600,
parameter TURBO_FRAMES = 0 // see Uart8Transmitter
)(
input wire clk, // board clock (*note: at the {CLOCK_RATE} rate)
// rx interface
input wire rxEn,
input wire rx,
output wire rxBusy,
output wire rxDone,
output wire rxErr,
output wire [7:0] out,
// tx interface
input wire txEn,
input wire txStart,
input wire [7:0] in,
output wire txBusy,
output wire txDone,
output wire tx
);
// this value cannot be changed in the current implementation
parameter RX_OVERSAMPLE_RATE = 16;
wire rxClk;
wire txClk;
BaudRateGenerator #(
.CLOCK_RATE(CLOCK_RATE),
.BAUD_RATE(BAUD_RATE),
.RX_OVERSAMPLE_RATE(RX_OVERSAMPLE_RATE)
) generatorInst (
.clk(clk),
.rxClk(rxClk),
.txClk(txClk)
);
Uart8Receiver rxInst (
.clk(rxClk),
.en(rxEn),
.in(rx),
.busy(rxBusy),
.done(rxDone),
.err(rxErr),
.out(out)
);
Uart8Transmitter #(
.TURBO_FRAMES(TURBO_FRAMES)
) txInst (
.clk(txClk),
.en(txEn),
.start(txStart),
.in(in),
.busy(txBusy),
.done(txDone),
.out(tx)
);
endmodule