-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMAINFILE.v.bak
105 lines (78 loc) · 2.05 KB
/
MAINFILE.v.bak
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//=======================================================
// This code is generated by Terasic System Builder
//=======================================================
module MAINFILE(
//////////// CLOCK //////////
input FPGA_CLK1_50,
input FPGA_CLK2_50,
input FPGA_CLK3_50,
//////////// KEY //////////
input [1:0] KEY,
// input [1:0] KEYMOTOR,
//////////// LED //////////
output reg [7:0] LED,
//////////// SW //////////
input [3:0] SW,
//////////// GPIO_0, GPIO connect to RFS //////////
inout BT_KEY,
input BT_UART_RX,
output BT_UART_TX,
//////////// Motor Control //////////
inout [5:0] GPIO_1
);
//=======================================================
// REG/WIRE declarations
//=======================================================
wire rts; // request to send
wire cts; // clear to send
wire rxd;
wire txd;
wire [7:0] uart_data;
wire rdempty;
wire write;
reg read;
reg cnt;
wire [7:0] LEDFake;
reg [7:0] command; // output from bluetooth to input to motor module
//=======================================================
// Structural coding
//=======================================================
// UART Controller
uart_control UART0(
.clk(FPGA_CLK1_50),
.reset_n(KEY[0]),
// rx
.read(read),
.readdata(uart_data),
.rdempty(rdempty),
//
.uart_clk_25m(cnt),
.uart_rx(BT_UART_RX)
);
//read
always@(posedge FPGA_CLK1_50)
begin
if (~rdempty)
read <= 1;
else
read <= 0;
end
assign write = ( read & (~rdempty) );
commandSelector c0 (FPGA_CLK1_50,
KEY[0],
write,
uart_data,
LED,
command
);
ServoControl S0(FPGA_CLK1_50,
FPGA_CLK2_50,
FPGA_CLK3_50,
command,
LEDFake,
SW,
GPIO_1
);
always@(posedge FPGA_CLK1_50)
cnt <= cnt + 1;
endmodule