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

Subversion Repositories t6507lp

[/] [t6507lp/] [trunk/] [fv/] [alu_chk.e] - Diff between revs 134 and 135

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 134 Rev 135
Line 5... Line 5...
unit alu_chk_u {
unit alu_chk_u {
        reg_a : byte;
        reg_a : byte;
        reg_x : byte;
        reg_x : byte;
        reg_y : byte;
        reg_y : byte;
        reg_status : byte;
        reg_status : byte;
 
        reg_result : byte;
 
 
        inst : alu_input_s;
        inst : alu_input_s;
        next_inst : alu_input_s;
        next_inst : alu_input_s;
 
 
        count_cycles : int;
        count_cycles : int;
Line 43... Line 44...
                        first_cycle = FALSE;
                        first_cycle = FALSE;
                        reg_x = alu_x;
                        reg_x = alu_x;
                        reg_y = alu_y;
                        reg_y = alu_y;
                        reg_status = alu_status;
                        reg_status = alu_status;
                        reg_a = 0; // TODO: check this
                        reg_a = 0; // TODO: check this
 
                        reg_result = 0;
                }
                }
                else {
                else {
 
 
                        out ("CYCLE ", count_cycles, " COMPARE:");
                        out ("CYCLE ", count_cycles, " COMPARE:");
                        print inst;
                        print inst;
 
 
                        case inst.input_kind {
                        case inst.input_kind {
                                ENABLED_VALID: {
                                ENABLED_VALID: {
Line 63... Line 64...
                                        dut_error("error at e code");
                                        dut_error("error at e code");
                                };
                                };
                        };
                        };
 
 
                        // here i have already calculated. must compare!
                        // here i have already calculated. must compare!
                        if (reg_a != alu_result) {
                        if (reg_result != alu_result) {
                                print reg_a;
                                print inst;
 
                                print me;
                                print alu_result;
                                print alu_result;
 
                                print alu_status;
 
                                print alu_x;
 
                                print alu_y;
 
 
                                dut_error("WRONG!");
                                dut_error("WRONG!");
                        };
                        };
 
 
                        if (reg_x != alu_x) {
                        if (reg_x != alu_x) {
                                dut_error("WRONG!");
                                dut_error("WRONG!");
Line 103... Line 109...
                        AND_ABX: { exec_and(); };
                        AND_ABX: { exec_and(); };
                        AND_ABY: { exec_and(); };
                        AND_ABY: { exec_and(); };
                        AND_IDX: { exec_and(); };
                        AND_IDX: { exec_and(); };
                        AND_IDY: { exec_and(); };
                        AND_IDY: { exec_and(); };
 
 
 
                        ASL_ACC: { exec_asl_acc(); }; // A,Z,C,N = M*2
 
 
 
                        ASL_ZPG: { exec_asl_mem(); }; // M,Z,C,N = M*2
 
                        ASL_ZPX: { exec_asl_mem(); };
 
                        ASL_ABS: { exec_asl_mem(); };
 
                        ASL_ABX: { exec_asl_mem(); };
 
 
                        default: {
                        default: {
                                //dut_error("unknown opcode");
                                //dut_error("unknown opcode");
                        }
                        }
                };
                };
        };
        };
 
 
 
        exec_asl_acc() is {
 
                reg_status[0:0] = reg_a[7:7];
 
                reg_a = reg_a * 2;
 
                update_z(reg_a);
 
                update_n(reg_a);
 
                reg_result = reg_a;
 
        };
 
 
 
        exec_asl_mem() is {
 
                reg_status[0:0] = inst.alu_a[7:7];
 
                reg_result = inst.alu_a * 2;
 
                update_z(reg_result);
 
                update_n(reg_result);
 
        };
 
 
        exec_and() is {
        exec_and() is {
                reg_a = reg_a & inst.alu_a; // TODO: this is probably wrong
                reg_a = reg_a & inst.alu_a; // TODO: this is probably wrong
                update_z(reg_a);
                update_z(reg_a);
                update_n(reg_a);
                update_n(reg_a);
 
                reg_result = reg_a;
        };
        };
 
 
        exec_sum() is {
        exec_sum() is {
                update_c(reg_a, inst.alu_a);
                update_c(reg_a, inst.alu_a);
                reg_a = reg_a + inst.alu_a;
                reg_a = reg_a + inst.alu_a;
                update_z(reg_a);
                update_z(reg_a);
                update_n(reg_a);
                update_n(reg_a);
 
                reg_result = reg_a;
                print me;
                //print me;
 
 
                //dut_error();
                //dut_error();
        };
        };
 
 
        update_z(arg : byte) is {
        update_z(arg : byte) is {
                if (arg == 0) {
                if (arg == 0) {

powered by: WebSVN 2.1.0

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