forked from ashishrana160796/verilog-starter-tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDecoder3x8.v
68 lines (54 loc) · 1.18 KB
/
Decoder3x8.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
module dec(in,ou);
input [2:0]in;
output [7:0]ou;
reg [7:0]ou;
always@(*)
begin
case(in)
3'b000:
ou = 8'b00000001;
3'b001:
ou = 8'b00000010;
3'b010:
ou = 8'b00000100;
3'b011:
ou = 8'b00001000;
3'b100:
ou = 8'b00010000;
3'b101:
ou = 8'b00100000;
3'b110:
ou = 8'b01000000;
3'b111:
ou = 8'b10000000;
endcase
end
endmodule
module test;
reg [2:0] inl;
wire [7:0] ol;
dec d(inl,ol);
initial begin
$display("decoder show");
$monitor("%b,%b,%b,\t %b,%b,%b,%b,%b,%b,%b,%b",inl[2],inl[1],inl[0],ol[7],ol[6],ol[5],ol[4],ol[3],ol[2],ol[1],ol[0]);
$dumpfile("vcd/Decoder.vcd");
$dumpvars(1,test);
inl = 3'b000;
#10
inl = 3'b001;
#10
inl = 3'b010;
#10
inl = 3'b011;
#10
inl = 3'b100;
#10
inl = 3'b101;
#10
inl = 3'b110;
#10
inl = 3'b111;
#10
$finish;
end
endmodule