File size: 2,171 Bytes
78c261f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
module stack_control_tb();
    reg [1:0] instr_type;
    reg [4:0] opcode;
    reg stop_bit;
    reg [31:0] sp;
    wire push;
    wire pop;
    wire [31:0] next_sp;

    stack_control stack_control_0(
        .instr_type(instr_type),
        .opcode(opcode),
        .stop_bit(stop_bit),
        .push(push),
        .pop(pop),
        .sp(sp),
        .next_sp(next_sp)
    );

    initial begin
        instr_type = 2'b00;
        opcode = 5'b00000; // AND
        stop_bit = 0;
        sp = 32'h00000008;
        #10;
        instr_type = 2'b00;
        opcode = 5'b00001; // ADD
        stop_bit = 0;
        #10;
        instr_type = 2'b00;
        opcode = 5'b00010; // SUB
        stop_bit = 0;
        #10;
        instr_type = 2'b00;
        opcode = 5'b00011; // CMP
        stop_bit = 1;
        #10;
        instr_type = 2'b01; 
        opcode = 5'b00000;// ANDI
        stop_bit = 0;
        #10;
        instr_type = 2'b01; 
        opcode = 5'b00001; // ADDI
        stop_bit = 0;
        #10;
        instr_type = 2'b01;
        opcode = 5'b00010; // LW
        stop_bit = 0;
        #10;
        instr_type = 2'b01;
        opcode = 5'b00011; // SW
        stop_bit = 0;
        #10;
        instr_type = 2'b01;
        opcode = 5'b00100; // BEQ
        stop_bit = 0;
        #10;
        instr_type = 2'b10;
        opcode = 5'b00000; // J
        stop_bit = 0;
        #10;
        instr_type = 2'b10;
        opcode = 5'b00001; // JAL
        stop_bit = 0;
        #10;
        instr_type = 2'b11;
        opcode = 5'b00000; // SLL
        stop_bit = 1;
        #10;
        instr_type = 2'b11;
        opcode = 5'b00001; // SLR
        stop_bit = 0;
        #10;
        instr_type = 2'b11;
        opcode = 5'b00010; // SLLV
        stop_bit = 1;
        #10;
        instr_type = 2'b11;
        opcode = 5'b00011; // SLRV
        stop_bit = 1;
        #10;
        #10 $finish;
    end
    initial begin
        $monitor("instr_type = %b, opcode = %b, push = %b, pop = %b, sp = %h, next_sp = %h\n", instr_type, opcode, push, pop, sp, next_sp);
    end
endmodule