-
Notifications
You must be signed in to change notification settings - Fork 3
/
bufferRx.sv
133 lines (124 loc) · 2.41 KB
/
bufferRx.sv
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
`timescale 1ns/100ps
// ============================================================================= //
// Designer: Jose Iuri B. de Brito - [email protected] // //
//
// Design Name: Buffer for Reception //
// Module Name: bebufferRx //
// //
// ============================================================================= //
//
// This file contains the debuffer for Reception, used to convert 8 bits mensage
// to 32 bits mensage.
module bufferRx (
input logic clk, // Clock
input logic rst,
output logic rxValid,
input logic empty,
input logic rxReady,
output logic outReady,
input logic outValid,
output logic [31:0] data_out,
input logic [7:0] data_in
);
typedef enum logic[2:0] {
cleanup,
first,
second,
third,
fourth,
send
} BUFFER_STATE;
BUFFER_STATE STATE_buffer;
logic [31:0] register;
always_ff @(posedge clk or negedge rst)
begin
if (!rst)
begin
STATE_buffer <= cleanup;
register <= 0;
data_out <= 0;
rxValid <= 1'b0;
end
else
begin
unique case (STATE_buffer)
cleanup:
begin
rxValid <= 1'b0;
outReady <= 1'b1;
STATE_buffer <= first;
end
first:
begin
if(!empty && outValid)
begin
rxValid <= 1'b0;
register[7:0] <= data_in;
outReady <= 1'b1;
STATE_buffer <= second;
end
else
begin
STATE_buffer <= first;
end
end
second:
begin
if(!empty && outValid)
begin
rxValid <= 1'b0;
register[15:8] <= data_in;
outReady <= 1'b1;
STATE_buffer <= third;
end
else
begin
STATE_buffer <= second;
end
end
third:
begin
if(!empty && outValid)
begin
rxValid <= 1'b0;
register[23:16] <= data_in;
outReady <= 1'b1;
STATE_buffer <= fourth;
end
else
begin
STATE_buffer <= third;
end
end
fourth:
begin
if(!empty && outValid)
begin
rxValid <= 1'b0;
register[31:24] <= data_in;
outReady <= 1'b0;
STATE_buffer <= send;
end
else
begin
STATE_buffer <= fourth;
end
end
send:
begin
if(rxReady)
begin
data_out <= register;
rxValid <= 1'b1;
outReady <= 1'b0;
STATE_buffer <= cleanup;
end
else
begin
STATE_buffer <= send;
end
end
endcase // STATE_buffer
end
end
endmodule