-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpacketSende.v
104 lines (84 loc) · 1.78 KB
/
packetSende.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
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
module packetSenter(input clk,output TXD,input [7:0]data0,
input [7:0]data1,
input [7:0]data2,
input [7:0]data3,
input [7:0]data4,
input [7:0]data5,input count,output complete,output completeInner);
reg [7:0]dataForShifter;
reg dataCountShifter;
wire shifterDone;
outputShifter shifter(clk,TXD,dataForShifter,dataCountShifter,shifterDone);
reg [4:0]packetCount;
reg [3:0]state=waiting;
reg lastCount=0;
localparam waiting=4'd0,working=4'd1;
assign complete=(state==waiting);
assign completeInner=shifterDone;
reg justDid=0;
always @(posedge clk)
begin
case (state)
working:
begin
if(shifterDone==1 && justDid==0)
begin
justDid=1;
if(packetCount<4'd6)
begin
if(packetCount==4'd0)
begin
dataForShifter=data0;
packetCount=packetCount+4'd1;
end
else if(packetCount==4'd1)
begin
dataForShifter=data1;
packetCount=packetCount+4'd1;
end
else if(packetCount==4'd2)
begin
dataForShifter=data2;
packetCount=packetCount+4'd1;
end
else if(packetCount==4'd3)
begin
dataForShifter=data3;
packetCount=packetCount+4'd1;
end
else if(packetCount==4'd4)
begin
dataForShifter=data4;
packetCount=packetCount+4'd1;
end
else if(packetCount==4'd5)
begin
dataForShifter=data5;
packetCount=packetCount+4'd1;
end
dataCountShifter=!dataCountShifter;
end
else
begin
state=waiting;
end
end
else
begin
justDid=0;
end
end
default:
begin
if(lastCount!=count)
begin
lastCount=count;
if(state==waiting)
begin
state=working;
packetCount=4'd0;
end
end
end
endcase
end
endmodule