-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path19_DMUX.v
63 lines (54 loc) · 926 Bytes
/
19_DMUX.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
//DMUX used to data bits synchronization
//author:WangFW
//date:2020-5-28
module DMUX(clk,rst_n,din,dout);
input clk;
input rst_n;
input [3:0] din;
output reg dout;
reg [1:0] count;
reg [3:0] temp1;
reg [3:0] temp2;
always @(posedge clk or negedge rst_n)
begin
if(!rst_n)
begin
temp1<=4'd0;
temp2<=4'd0;
end
else
begin
temp1<=din;
temp2<=temp1;
end
end
always @(posedge clk or negedge rst_n)
begin
if(!rst_n)
begin
count<=2'd0;
dout<=1'b0;
end
else
begin
case(count)
2'd0:begin
dout<=temp2[0];
count<=count+1'b1;
end
2'd1:begin
dout<=temp2[1];
count<=count+1'b1;
end
2'd2:begin
dout<=temp2[2];
count<=count+1'b1;
end
2'd3:begin
dout<=temp2[3];
count<=count+1'b1;
end
endcase
end
end
endmodule