summaryrefslogtreecommitdiff
path: root/alu/v0.1/testbench_alu.v
blob: 9902e5bc35feb2afc13f4058918bf7cc5e625d90 (plain) (blame)
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
`timescale 1ns/1ps

module testbench_alu;

reg [7:0]var_1=0;
reg [7:0]var_2=0;
reg [3:0]op_sel;
reg carry;

//wire  val;
//wire  out;
wire  [7:0]out;

//assign val=data;
alu uut (
    .a(var_1),
    .b(var_2),
    .alu_sel(op_sel),
    .alu_out(out),
    .carry_out(carry)
);


initial begin
    $display("addition");
    $dumpfile("test_alu.vcd");
    $dumpvars(0,testbench_alu);
    var_1=0;
    var_2=0;
    op_sel=0;
    #10 var_1=1;
    var_2=0;

    #10 var_1=0;
    var_2=1;

    #10 var_1=16;
    var_2=16;

    #10 var_1=64;
    var_2=64;

    $display("substraction");
    $display("multiplication");
    $display("division");
    $display("logical shift left");
    $display("logical shift right");
    $display("rotate right");
    $display("rotate left");
    $display("and");
    $display("or");
    $display("xor");
    $display("nor");
    $display("nand");
    $display("xnor");
    $display("greater comparison");
    $display("equal comparison");
end

initial begin
    $monitor("At time %t d1=%h(%0d) d2=%h(%0d) op_sel=%0d out=%h(%0d)",$time,var_1,var_1,var_2,var_2,op_sel,out,out);
end 

endmodule