-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path41_serial_para.v
59 lines (55 loc) · 903 Bytes
/
41_serial_para.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
// one bit serial number change to four bits para
//author:WangFW
//date:2020-7-28
module test_seri_para(clk,rst_n,din,valid_in,dout,valid_out);
input clk;
input rst_n;
input din;
input valid_in;
output reg [3:0] dout;
output reg valid_out;
reg [1:0] cnt;
reg [3:0] temp;
always @(posedge clk or negedge rst_n)
begin
if(!rst_n)
begin
cnt<=2'd0;
temp<=4'd0;
end
else
begin
if(valid_in)
begin
temp[cnt]<=din;
cnt<=cnt+1'b1;
end
else
begin
temp<=temp;
cnt<=cnt;
end
end
end
always @(posedge clk or negedge rst_n)
begin
if(!rst_n)
begin
dout<=4'd0;
valid_out<=1'b0;
end
else
begin
if(cnt==2'd0)
begin
dout<=temp;
valid_out<=1'b1;
end
else
begin
dout<=4'd0;
valid_out<=1'b0;
end
end
end
endmodule