OpenCores
URL https://opencores.org/ocsvn/t6507lp/t6507lp/trunk

Subversion Repositories t6507lp

[/] [t6507lp/] [trunk/] [fv/] [alu_chk.e] - Blame information for rev 132

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 131 creep
alu_chk.e
2
<'
3
import alu_components;
4
 
5
unit alu_chk_u {
6
        reg_a : byte;
7
        reg_x : byte;
8
        reg_y : byte;
9
        reg_status : byte;
10
 
11 132 creep
        inst : alu_input_s;
12
        next_inst : alu_input_s;
13
 
14 131 creep
        count_cycles : int;
15
        first_cycle : bool;
16
 
17
        keep first_cycle == TRUE;
18
        keep count_cycles == 0;
19
 
20
        store(input : alu_input_s) is {
21 132 creep
                out ("cycle ", count_cycles, ": input stored: ");
22
                print input;
23
 
24
                if (first_cycle) {
25
                        inst = input;
26
                        next_inst = input;
27
                }
28
                else {
29
                        inst = next_inst;
30
                        next_inst = input;
31
                };
32
 
33
                count_cycles = count_cycles + 1;
34
 
35
                if (count_cycles == 10000) {
36
                        dut_error();
37
                }
38 131 creep
        };
39
 
40
        compare(alu_result:byte, alu_status:byte, alu_x:byte, alu_y:byte ) is {
41
                if (first_cycle) {
42
                        first_cycle = FALSE;
43
                        reg_x = alu_x;
44
                        reg_y = alu_y;
45
                        reg_status = alu_status;
46 132 creep
                        reg_a = 0; // TODO: check this
47 131 creep
                }
48 132 creep
                else {
49
                        case inst.input_kind {
50
                                ENABLED_VALID: {
51
                                        out("cycle ", count_cycles, ": executing and comparing");
52
                                        execute();
53
                                };
54
                                DISABLED_VALID: {
55
                                        out("cycle ", count_cycles, ": just comparing");
56
                                };
57
                                default: {
58
                                        dut_error("error at e code");
59
                                };
60
                        };
61
 
62
                        // here comes the compare!
63
                }
64 131 creep
        };
65 132 creep
 
66
        execute() is {
67
                case inst.alu_opcode {
68
                        ADC_IMM: { exec_sum(); }; // A,Z,C,N = A+M+C
69
                        ADC_ZPG: { exec_sum(); };
70
                        ADC_ZPX: { exec_sum(); };
71
                        ADC_ABS: { exec_sum(); };
72
                        ADC_ABX: { exec_sum(); };
73
                        ADC_ABY: { exec_sum(); };
74
                        ADC_IDX: { exec_sum(); };
75
                        ADC_IDY: { exec_sum(); };
76
 
77
                        AND_IMM: { exec_and(); };
78
                        AND_ZPG: { exec_and(); };
79
                        AND_ZPX: { exec_and(); };
80
                        AND_ABS: { exec_and(); };
81
                        AND_ABX: { exec_and(); };
82
                        AND_ABY: { exec_and(); };
83
                        AND_IDX: { exec_and(); };
84
                        AND_IDY: { exec_and(); };
85
 
86
 
87
                        default: {
88
                                //dut_error("unknown opcode");
89
                        }
90
                };
91
        };
92
 
93
        exec_and() is {
94
 
95
 
96
        };
97
 
98
        exec_sum() is {
99
                update_c(reg_a, inst.alu_a);
100
                reg_a = reg_a + inst.alu_a;
101
                update_z(reg_a);
102
                update_n(reg_a);
103
 
104
                print me;
105
 
106
                dut_error();
107
        };
108
 
109
        update_z(arg : byte) is {
110
                if (arg == 0) {
111
                        reg_status[1:1] = 1;
112
                }
113
                else {
114
                        reg_status[1:1] = 0;
115
                }
116
        };
117
 
118
        update_c(arg1 : byte, arg2 : byte) is {
119
                if (arg1 + arg2 > 256) {
120
                        reg_status[0:0] = 1;
121
                }
122
                else {
123
                        reg_status[0:0] = 0;
124
                }
125
        };
126
 
127
        update_n(arg : byte) is {
128
                if (arg[7:7] == 1) {
129
                        reg_status[7:7] = 1;
130
                }
131
                else {
132
                        reg_status[7:7] = 0;
133
                }
134
        };
135 131 creep
};
136
'>

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.