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

Subversion Repositories t6507lp

[/] [t6507lp/] [trunk/] [fv/] [alu_chk.e] - Diff between revs 146 and 153

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

Rev 146 Rev 153
Line 19... Line 19...
        keep count_cycles == 0;
        keep count_cycles == 0;
 
 
        store(input : alu_input_s) is {
        store(input : alu_input_s) is {
                count_cycles = count_cycles + 1;
                count_cycles = count_cycles + 1;
 
 
                out ("CYCLE ", count_cycles, " STORE:");
                //out ("CYCLE ", count_cycles, " STORE:");
                print input;
                //print input;
 
 
                if (first_cycle) {
                if (first_cycle) {
                        inst = input;
                        inst = input;
                        next_inst = input;
                        next_inst = input;
                }
                }
                else {
                else {
                        inst = next_inst;
                        inst = next_inst;
                        next_inst = input;
                        next_inst = input;
                };
                };
 
 
 
 
                if (count_cycles == 10000) {
 
                        dut_error();
 
                }
 
        };
        };
 
 
        compare(alu_result:byte, alu_status:byte, alu_x:byte, alu_y:byte ) is {
        compare(alu_result:byte, alu_status:byte, alu_x:byte, alu_y:byte ) is {
                if (first_cycle) {
                if (first_cycle) {
                        first_cycle = FALSE;
                        first_cycle = FALSE;
Line 47... Line 43...
                        reg_status = 8'b00100010;
                        reg_status = 8'b00100010;
                        reg_a = 0; // TODO: check this
                        reg_a = 0; // TODO: check this
                        reg_result = 0;
                        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: {
                                        out("CYCLE ", count_cycles, ": executing and comparing");
                                        //out("CYCLE ", count_cycles, ": executing and comparing");
                                        execute();
                                        execute();
                                };
                                };
                                DISABLED_VALID: {
                                DISABLED_VALID: {
                                        out("CYCLE ", count_cycles, ": just comparing");
                                        //out("CYCLE ", count_cycles, ": just comparing");
                                };
                                };
                                RESET: {
                                RESET: {
                                        reg_x = 0;
                                        reg_x = 0;
                                        reg_y = 0;
                                        reg_y = 0;
                                        reg_status = 8'b00100010;
                                        reg_status = 8'b00100010;
Line 75... Line 71...
                        };
                        };
 
 
                        // here i have already calculated. must compare!
                        // here i have already calculated. must compare!
 
 
                        if ((reg_result != alu_result) || (reg_x != alu_x) or (reg_y != alu_y) or (reg_status != alu_status)) {
                        if ((reg_result != alu_result) || (reg_x != alu_x) or (reg_y != alu_y) or (reg_status != alu_status)) {
                                print inst;
                                out("#########################################################");
                                print me;
                                print me;
 
                                out("#########################################################");
                                print alu_result;
                                print alu_result;
                                print alu_status;
                                print alu_status;
                                print alu_x;
                                print alu_x;
                                print alu_y;
                                print alu_y;
 
 
Line 114... Line 111...
                        ASL_ZPG: { exec_asl_mem(); }; // M,Z,C,N = M*2
                        ASL_ZPG: { exec_asl_mem(); }; // M,Z,C,N = M*2
                        ASL_ZPX: { exec_asl_mem(); };
                        ASL_ZPX: { exec_asl_mem(); };
                        ASL_ABS: { exec_asl_mem(); };
                        ASL_ABS: { exec_asl_mem(); };
                        ASL_ABX: { exec_asl_mem(); };
                        ASL_ABX: { exec_asl_mem(); };
 
 
 
                        BCC_REL: {};
 
                        BCS_REL: {};
 
                        BEQ_REL: {};
 
 
                        default: {
                        default: {
                                //dut_error("unknown opcode");
                                //dut_error("unknown opcode");
                        }
                        }
                };
                };
        };
        };
Line 143... Line 144...
                update_n(reg_a);
                update_n(reg_a);
                reg_result = reg_a;
                reg_result = reg_a;
        };
        };
 
 
        exec_sum() is {
        exec_sum() is {
                out("adding: ", reg_a, " + ", inst.alu_a, " + ", reg_status[0:0]);
                //out("adding: ", reg_a, " + ", inst.alu_a, " + ", reg_status[0:0]);
                reg_result = reg_a + inst.alu_a + reg_status[0:0];
                reg_result = reg_a + inst.alu_a + reg_status[0:0];
                update_c(reg_a, inst.alu_a, reg_status[0:0]);
                update_c(reg_a, inst.alu_a, reg_status[0:0]);
                update_v(reg_a, inst.alu_a, reg_result);
                update_v(reg_a, inst.alu_a, reg_result);
                update_z(reg_result);
                update_z(reg_result);
                update_n(reg_result);
                update_n(reg_result);
Line 155... Line 156...
                //print me;
                //print me;
                //dut_error();
                //dut_error();
        };
        };
 
 
        update_c(arg1 : byte, arg2 : byte, arg3: bit) is {
        update_c(arg1 : byte, arg2 : byte, arg3: bit) is {
                if (arg1 + arg2 + arg3 > 256) {
                if (arg1 + arg2 + arg3 > 255) {
                        reg_status[0:0] = 1;
                        reg_status[0:0] = 1;
                }
                }
                else {
                else {
                        reg_status[0:0] = 0;
                        reg_status[0:0] = 0;
                }
                }

powered by: WebSVN 2.1.0

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