Subversion Repositories programming

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
197 ira 1
/* Test module for ALU1.v */
2
module test_alu1;
3
 
4
    reg a, b, cin;
5
    reg[0:1] op;
6
    wire cout, result;
7
 
8
    ALU1 alu1 (a, b, cin, op, cout, result);
9
 
10
    initial begin
11
        $monitor ("time=%0d a=%b b=%b op=%b cin=%b cout=%b result=%b",
12
            $time, a, b, op, cin, cout, result);
13
    end
14
 
15
    initial begin
16
           a=0; b=0; cin=0; op=00; $display; $display("AND");
17
        #1 a=0; b=0; cin=1; op=00;
18
        #1 a=0; b=1; cin=0; op=00;
19
        #1 a=0; b=1; cin=1; op=00;
20
        #1 a=1; b=0; cin=0; op=00;
21
        #1 a=1; b=0; cin=1; op=00;
22
        #1 a=1; b=1; cin=0; op=00;
23
        #1 a=1; b=1; cin=1; op=00;
24
 
25
        #1 a=0; b=0; cin=0; op=01; $display; $display ("OR");
26
        #1 a=0; b=0; cin=1; op=01;
27
        #1 a=0; b=1; cin=0; op=01;
28
        #1 a=0; b=1; cin=1; op=01;
29
        #1 a=1; b=0; cin=0; op=01;
30
        #1 a=1; b=0; cin=1; op=01;
31
        #1 a=1; b=1; cin=0; op=01;
32
        #1 a=1; b=1; cin=1; op=01;
33
 
34
        #1 a=0; b=0; cin=0; op=10; $display; $display ("ADD");
35
        #1 a=0; b=0; cin=1; op=10;
36
        #1 a=0; b=1; cin=0; op=10;
37
        #1 a=0; b=1; cin=1; op=10;
38
        #1 a=1; b=0; cin=0; op=10;
39
        #1 a=1; b=0; cin=1; op=10;
40
        #1 a=1; b=1; cin=0; op=10;
41
        #1 a=1; b=1; cin=1; op=10;
42
 
43
        #1 a=0; b=0; cin=0; op=11; $display; $display ("SUB");
44
        #1 a=0; b=0; cin=1; op=11;
45
        #1 a=0; b=1; cin=0; op=11;
46
        #1 a=0; b=1; cin=1; op=11;
47
        #1 a=1; b=0; cin=0; op=11;
48
        #1 a=1; b=0; cin=1; op=11;
49
        #1 a=1; b=1; cin=0; op=11;
50
        #1 a=1; b=1; cin=1; op=11;
51
    end
52
 
53
endmodule
54