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

Subversion Repositories t6507lp

[/] [t6507lp/] [trunk/] [rtl/] [verilog/] [t6507lp_fsm.v] - Diff between revs 105 and 107

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

Rev 105 Rev 107
Line 92... Line 92...
        localparam FETCH_PCH = 5'b10100;
        localparam FETCH_PCH = 5'b10100;
        localparam INCREMENT_SP = 5'b10101;
        localparam INCREMENT_SP = 5'b10101;
        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 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 134... Line 135...
        reg jump_indirect;
        reg jump_indirect;
 
 
        // regs for the special instructions
        // regs for the special instructions
        reg break;
        reg break;
        reg rti;
        reg rti;
 
        reg rts;
 
 
        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 276... Line 278...
                                                        address <= sp;
                                                        address <= sp;
                                                        data_out <= {{3{1'b0}}, pc[12:8]};
                                                        data_out <= {{3{1'b0}}, pc[12:8]};
                                                        control <= MEM_WRITE;
                                                        control <= MEM_WRITE;
                                                        sp <= sp_minus_one;
                                                        sp <= sp_minus_one;
                                                end
                                                end
                                                else if (rti) begin
                                                else if (rti || rts) begin
                                                        address <= sp;
                                                        address <= sp;
                                                        control <= MEM_READ;
                                                        control <= MEM_READ;
                                                end
                                                end
                                        end
                                        end
                                end
                                end
Line 511... Line 513...
                                end
                                end
                                PULL_PCH: begin
                                PULL_PCH: begin
                                        pc[12:8] <= data_in[4:0];
                                        pc[12:8] <= data_in[4:0];
                                        address <= {data_in[4:0], pc[7:0]};
                                        address <= {data_in[4:0], pc[7:0]};
                                end
                                end
 
                                INCREMENT_PC: begin
 
                                        pc <= next_pc;
 
                                        address <= next_pc;
 
                                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 593... Line 599...
                                end
                                end
                                else begin // all the special instructions will fall here
                                else begin // all the special instructions will fall here
                                        if (break) begin
                                        if (break) begin
                                                next_state = PUSH_PCH;
                                                next_state = PUSH_PCH;
                                        end
                                        end
                                        else if (rti) begin
                                        else if (rti || rts) begin
                                                next_state = INCREMENT_SP;
                                                next_state = INCREMENT_SP;
                                        end
                                        end
                                end
                                end
                        end
                        end
                        READ_FROM_POINTER: begin
                        READ_FROM_POINTER: begin
Line 733... Line 739...
                        end
                        end
                        FETCH_PCH: begin
                        FETCH_PCH: begin
                                next_state = FETCH_OP;
                                next_state = FETCH_OP;
                        end
                        end
                        INCREMENT_SP: begin
                        INCREMENT_SP: begin
 
                                if (rti) begin
                                next_state = PULL_STATUS;
                                next_state = PULL_STATUS;
                        end
                        end
 
                                else begin // rts
 
                                        next_state = PULL_PCL;
 
                                end
 
                        end
                        PULL_STATUS: begin
                        PULL_STATUS: begin
                                next_state = PULL_PCL;
                                next_state = PULL_PCL;
                        end
                        end
                        PULL_PCL: begin
                        PULL_PCL: begin
                                next_state = PULL_PCH;
                                next_state = PULL_PCH;
                                alu_opcode = ir;
                                alu_opcode = ir;
                                alu_enable = 1'b1;
                                alu_enable = 1'b1;
                                alu_a = temp_data;
                                alu_a = temp_data;
                        end
                        end
                        PULL_PCH: begin
                        PULL_PCH: begin
 
                                if (rti) begin
 
                                        next_state = FETCH_OP;
 
                                end
 
                                else begin // rts
 
                                        next_state = INCREMENT_PC;
 
                                end
 
                        end
 
                        INCREMENT_PC: begin
                                next_state = FETCH_OP;
                                next_state = FETCH_OP;
                        end
                        end
                        default: begin
                        default: begin
                                next_state = RESET;
                                next_state = RESET;
                        end
                        end
Line 777... Line 796...
                jump_indirect = 1'b0;
                jump_indirect = 1'b0;
                branch = 1'b0;
                branch = 1'b0;
 
 
                break = 1'b0;
                break = 1'b0;
                rti = 1'b0;
                rti = 1'b0;
 
                rts = 1'b0;
 
 
                case (ir)
                case (ir)
                        CLC_IMP, CLD_IMP, CLI_IMP, CLV_IMP, DEX_IMP, DEY_IMP, INX_IMP, INY_IMP, NOP_IMP, PHA_IMP, PHP_IMP, PLA_IMP,
                        CLC_IMP, CLD_IMP, CLI_IMP, CLV_IMP, DEX_IMP, DEY_IMP, INX_IMP, INY_IMP, NOP_IMP, PHA_IMP, PHP_IMP, PLA_IMP,
                        PLP_IMP, RTS_IMP, SEC_IMP, SED_IMP, SEI_IMP, TAX_IMP, TAY_IMP, TSX_IMP, TXA_IMP, TXS_IMP, TYA_IMP: begin
                        PLP_IMP, 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;
                        end
                        end
                        ASL_ACC, LSR_ACC, ROL_ACC, ROR_ACC: begin
                        ASL_ACC, LSR_ACC, ROL_ACC, ROR_ACC: begin
                                accumulator = 1'b1;
                                accumulator = 1'b1;
                        end
                        end
Line 924... Line 944...
                                break = 1'b1;
                                break = 1'b1;
                        end
                        end
                        RTI_IMP: begin
                        RTI_IMP: begin
                                rti = 1'b1;
                                rti = 1'b1;
                        end
                        end
 
                        RTS_IMP: begin
 
                                rts = 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.