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

Subversion Repositories t6507lp

[/] [t6507lp/] [trunk/] [rtl/] [verilog/] [t6507lp_fsm.v] - Diff between revs 108 and 109

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

Rev 108 Rev 109
Line 94... Line 94...
        localparam PULL_STATUS = 5'b10110;
        localparam PULL_STATUS = 5'b10110;
        localparam PULL_PCL = 5'b10111;
        localparam PULL_PCL = 5'b10111;
        localparam PULL_PCH = 5'b11000;
        localparam PULL_PCH = 5'b11000;
        localparam INCREMENT_PC = 5'b11001;
        localparam INCREMENT_PC = 5'b11001;
        localparam PUSH_REGISTER = 5'b11010;
        localparam PUSH_REGISTER = 5'b11010;
 
        localparam PULL_REGISTER = 5'b11011;
 
 
        localparam RESET = 5'b11111;
        localparam RESET = 5'b11111;
 
 
        // OPCODES TODO: verify how this get synthesised
        // OPCODES TODO: verify how this get synthesised
        `include "../T6507LP_Package.v"
        `include "../T6507LP_Package.v"
Line 139... Line 140...
        reg break;
        reg break;
        reg rti;
        reg rti;
        reg rts;
        reg rts;
        reg pha;
        reg pha;
        reg php;
        reg php;
 
        reg pla;
 
        reg plp;
 
 
        wire [ADDR_SIZE_:0] next_pc;
        wire [ADDR_SIZE_:0] next_pc;
        assign next_pc = pc + 13'b0000000000001;
        assign next_pc = pc + 13'b0000000000001;
 
 
        reg [ADDR_SIZE_:0] address_plus_index; // this would update more times than actually needed, consuming power.
        reg [ADDR_SIZE_:0] address_plus_index; // this would update more times than actually needed, consuming power.
Line 291... Line 294...
                                                        pc <= pc;
                                                        pc <= pc;
                                                        address <= sp;
                                                        address <= sp;
                                                        data_out <= (pha) ? alu_result : alu_status;
                                                        data_out <= (pha) ? alu_result : alu_status;
                                                        control <= MEM_WRITE;
                                                        control <= MEM_WRITE;
                                                end
                                                end
 
                                                else if (pla || plp) begin
 
                                                        pc <= pc;
 
                                                        address <= sp;
 
                                                        control <= MEM_READ;
 
                                                end
                                        end
                                        end
                                end
                                end
                                FETCH_HIGH_CALC_INDEX: begin
                                FETCH_HIGH_CALC_INDEX: begin
                                        pc <= next_pc;
                                        pc <= next_pc;
                                        temp_addr[12:8] <= data_in[4:0];
                                        temp_addr[12:8] <= data_in[4:0];
Line 531... Line 539...
                                PUSH_REGISTER: begin
                                PUSH_REGISTER: begin
                                        pc <= pc;
                                        pc <= pc;
                                        address <= pc;
                                        address <= pc;
                                        sp <= sp_minus_one;
                                        sp <= sp_minus_one;
                                        control <= MEM_READ;
                                        control <= MEM_READ;
 
                                        temp_data <= data_in;
 
                                end
 
                                PULL_REGISTER: begin
 
                                        pc <= pc;
 
                                        address <= pc;
 
                                        temp_data <= data_in;
                                end
                                end
                                default: begin
                                default: begin
                                        $write("unknown state"); // TODO: check if synth really ignores this 2 lines. Otherwise wrap it with a `ifdef 
                                        $write("unknown state"); // TODO: check if synth really ignores this 2 lines. Otherwise wrap it with a `ifdef 
                                        $finish(0);
                                        $finish(0);
                                end
                                end
Line 626... Line 640...
                                                next_state = PUSH_REGISTER;
                                                next_state = PUSH_REGISTER;
                                        end
                                        end
                                        else if (php) begin
                                        else if (php) begin
                                                next_state = PUSH_REGISTER;
                                                next_state = PUSH_REGISTER;
                                        end
                                        end
 
                                        else if (pla || plp) begin
 
                                                next_state = INCREMENT_SP;
 
                                        end
                                end
                                end
                        end
                        end
                        READ_FROM_POINTER: begin
                        READ_FROM_POINTER: begin
                                if (indirectx) begin
                                if (indirectx) begin
                                        next_state = READ_FROM_POINTER_X;
                                        next_state = READ_FROM_POINTER_X;
Line 766... Line 783...
                        end
                        end
                        INCREMENT_SP: begin
                        INCREMENT_SP: begin
                                if (rti) begin
                                if (rti) begin
                                        next_state = PULL_STATUS;
                                        next_state = PULL_STATUS;
                                end
                                end
 
                                else if (pla || plp) begin
 
                                        next_state = PULL_REGISTER;
 
                                end
                                else begin // rts
                                else begin // rts
                                        next_state = PULL_PCL;
                                        next_state = PULL_PCL;
                                end
                                end
                        end
                        end
                        PULL_STATUS: begin
                        PULL_STATUS: begin
Line 793... Line 813...
                                next_state = FETCH_OP;
                                next_state = FETCH_OP;
                        end
                        end
                        PUSH_REGISTER: begin
                        PUSH_REGISTER: begin
                                next_state = FETCH_OP;
                                next_state = FETCH_OP;
                        end
                        end
 
                        PULL_REGISTER: begin
 
                                next_state = FETCH_OP_CALC_PARAM;
 
                        end
                        default: begin
                        default: begin
                                next_state = RESET;
                                next_state = RESET;
                        end
                        end
                endcase
                endcase
        end
        end
Line 826... Line 849...
                break = 1'b0;
                break = 1'b0;
                rti = 1'b0;
                rti = 1'b0;
                rts = 1'b0;
                rts = 1'b0;
                pha = 1'b0;
                pha = 1'b0;
                php = 1'b0;
                php = 1'b0;
 
                pla = 1'b0;
 
                plp = 1'b0;
 
 
                case (ir)
                case (ir)
                        CLC_IMP, CLD_IMP, CLI_IMP, CLV_IMP, DEX_IMP, DEY_IMP, INX_IMP, INY_IMP, NOP_IMP,
                        CLC_IMP, CLD_IMP, CLI_IMP, CLV_IMP, DEX_IMP, DEY_IMP, INX_IMP, INY_IMP, NOP_IMP,
                        SEC_IMP, SED_IMP, SEI_IMP, TAX_IMP, TAY_IMP, TSX_IMP, TXA_IMP, TXS_IMP, TYA_IMP: begin
                        SEC_IMP, SED_IMP, SEI_IMP, TAX_IMP, TAY_IMP, TSX_IMP, TXA_IMP, TXS_IMP, TYA_IMP: begin
                                implied = 1'b1;
                                implied = 1'b1;
Line 982... Line 1007...
                                pha = 1'b1;
                                pha = 1'b1;
                        end
                        end
                        PHP_IMP: begin
                        PHP_IMP: begin
                                php = 1'b1;
                                php = 1'b1;
                        end
                        end
 
                        PLA_IMP: begin
 
                                pla = 1'b1;
 
                        end
 
                        PLP_IMP: begin
 
                                plp = 1'b1;
 
                        end
                        default: begin
                        default: begin
                                $write("state : %b", state);
                                $write("state : %b", state);
                                if (reset_n == 1 && state != FETCH_OP_FIX_PC) begin // the processor is NOT being reset neither it is fixing the pc
                                if (reset_n == 1 && state != FETCH_OP_FIX_PC) begin // the processor is NOT being reset neither it is fixing the pc
                                        $write("\nunknown OPCODE!!!!! 0x%h\n", ir);
                                        $write("\nunknown OPCODE!!!!! 0x%h\n", ir);
                                        $finish();
                                        $finish();

powered by: WebSVN 2.1.0

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