OpenCores
URL https://opencores.org/ocsvn/6809_6309_compatible_core/6809_6309_compatible_core/trunk

Subversion Repositories 6809_6309_compatible_core

[/] [6809_6309_compatible_core/] [trunk/] [rtl/] [verilog/] [regblock.v] - Diff between revs 4 and 5

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

Rev 4 Rev 5
Line 7... Line 7...
module regblock(
module regblock(
        input wire clk_in,
        input wire clk_in,
        input wire [3:0] path_left_addr,
        input wire [3:0] path_left_addr,
        input wire [3:0] path_right_addr,
        input wire [3:0] path_right_addr,
        input wire [3:0] write_reg_addr,
        input wire [3:0] write_reg_addr,
 
        input wire [3:0] exg_dest_r,
        input wire [7:0] eapostbyte, // effective address post byte
        input wire [7:0] eapostbyte, // effective address post byte
        input wire [15:0] offset16, // up to 16 bit offset for effective address calculation
        input wire [15:0] offset16, // up to 16 bit offset for effective address calculation
        input wire write_reg,
        input wire write_reg,
        input wire write_post,
        input wire write_post,
        input wire write_pc,
        input wire write_pc,
 
        input wire write_tfr,
 
        input wire write_exg,
        input wire inc_pc,
        input wire inc_pc,
        input wire inc_su, /* increments S or U */
        input wire inc_su, /* increments S or U */
        input wire dec_su, /* decrements s or u */
        input wire dec_su, /* decrements s or u */
        input wire use_s, /* increments S or U */
        input wire use_s, /* increments S or U */
        input wire [15:0] data_w,
        input wire [15:0] data_w,
Line 55... Line 58...
assign reg_su = (use_s) ? SS:SU; /* stack pointer */
assign reg_su = (use_s) ? SS:SU; /* stack pointer */
// left path output, always 16 bits
// left path output, always 16 bits
always @(*)
always @(*)
        begin
        begin
                case (path_left_addr)
                case (path_left_addr)
                        `RN_ACCA:       path_left_data = { 8'h0, ACCA };
                        `RN_ACCA:       path_left_data = { 8'hff, ACCA };
                        `RN_ACCB:       path_left_data = { 8'h0, ACCB };
                        `RN_ACCB:       path_left_data = { 8'hff, ACCB };
                        `RN_ACCD:       path_left_data = `ACCD;
                        `RN_ACCD:       path_left_data = `ACCD;
                        `RN_IX:         path_left_data = IX;
                        `RN_IX:         path_left_data = IX;
                        `RN_IY:         path_left_data = IY;
                        `RN_IY:         path_left_data = IY;
                        `RN_U:          path_left_data = SU;
                        `RN_U:          path_left_data = SU;
                        `RN_S:          path_left_data = SS;
                        `RN_S:          path_left_data = SS;
                        `RN_PC:         path_left_data = PC;
                        `RN_PC:         path_left_data = PC;
                        `RN_DP:         path_left_data = { 8'h0, DP };
                        `RN_DP:         path_left_data = { DP, DP };
 
                        `RN_CC:         path_left_data = { `CCR, `CCR };
                        default:
                        default:
                                path_left_data = 16'hBEEF;
                                path_left_data = 16'hFFFF;
                endcase
                endcase
        end
        end
 
 
// right path output, always 16 bits
// right path output, always 16 bits
always @(*)
always @(*)
        begin
        begin
                case (path_right_addr)
                case (path_right_addr)
                        `RN_ACCA: path_right_data = { 8'h0, ACCA };
                        `RN_ACCA:       path_right_data = { 8'hff, ACCA };
                        `RN_ACCB: path_right_data = { 8'h0, ACCB };
                        `RN_ACCB:       path_right_data = { 8'hff, ACCB };
                        `RN_ACCD: path_right_data = `ACCD;
                        `RN_ACCD: path_right_data = `ACCD;
                        `RN_IX: path_right_data = IX;
                        `RN_IX: path_right_data = IX;
                        `RN_IY: path_right_data = IY;
                        `RN_IY: path_right_data = IY;
                        `RN_U: path_right_data = SU;
                        `RN_U: path_right_data = SU;
                        `RN_S: path_right_data = SS;
                        `RN_S: path_right_data = SS;
                        `RN_DP: path_right_data = { 8'h0, DP };
                        `RN_DP:         path_right_data = { DP, DP };
 
                        `RN_CC:         path_right_data = { `CCR, `CCR };
                        default:
                        default:
                                path_right_data = 16'hBEEF;
                                path_right_data = 16'hFFFF;
                endcase
                endcase
        end
        end
 
 
always @(*)
always @(*)
        begin
        begin
Line 163... Line 168...
                        8'b1xx_x_1101: // n,PC
                        8'b1xx_x_1101: // n,PC
                                eamem_addr = PC + offset16;
                                eamem_addr = PC + offset16;
                endcase
                endcase
        end
        end
 
 
 
wire [15:0] left;
 
 
 
assign left = (write_tfr | write_exg) ? path_left_data:data_w;
 
 
 
wire [15:0] new_su, old_su;
 
 
 
assign old_su = (use_s) ? SS:SU;
 
assign new_su = (inc_su) ? old_su + 16'h1:(dec_su) ? old_su - 16'h1:old_su;
 
 
always @(posedge clk_in)
always @(posedge clk_in)
        begin
        begin
                if (write_reg)
                if (write_exg)
 
                        case (exg_dest_r)
 
                                0: `ACCD <= path_right_data;
 
                                1: IX <= path_right_data;
 
                                2: IY <= path_right_data;
 
                                3: SU <= path_right_data;
 
                                4: SS <= path_right_data;
 
                                5: PC <= path_right_data;
 
                                8: ACCA <= path_right_data[7:0];
 
                                9: ACCB <= path_right_data[7:0];
 
                                10: `CCR <= path_right_data[7:0];
 
                                11: DP <= path_right_data[7:0];
 
                        endcase
 
                if (write_tfr | write_exg | write_reg)
                        case (write_reg_addr)
                        case (write_reg_addr)
                                0: `ACCD <= data_w;
                                0: `ACCD <= left;
                                1: IX <= data_w;
                                1: IX <= left;
                                2: IY <= data_w;
                                2: IY <= left;
                                3: SU <= data_w;
                                3: SU <= left;
                                4: SS <= data_w;
                                4: SS <= left;
                                5: PC <= data_w;
                                5: PC <= left;
                                8: ACCA <= data_w[7:0];
                                8: ACCA <= left[7:0];
                                9: ACCB <= data_w[7:0];
                                9: ACCB <= left[7:0];
                                10: `CCR <= data_w[7:0];
                                10: `CCR <= left[7:0];
                                11: DP <= data_w[7:0];
                                11: DP <= left[7:0];
                        endcase
                        endcase
                if (write_post) // write back predecrement/postincremented values
                if (write_post) // write back predecrement/postincremented values
                        begin
                        begin
                                case (eapostbyte[6:5])
                                case (eapostbyte[6:5])
                                        2'b00: IX <= ea_reg_post;
                                        2'b00: IX <= ea_reg_post;
Line 191... Line 218...
                        end
                        end
                if (write_flags)
                if (write_flags)
                        begin
                        begin
                                `CCR <= CCR_in;
                                `CCR <= CCR_in;
                        end
                        end
                if (set_e)
                if (set_e) eflag <= 1;
                        eflag <= 1;
                if (clear_e) eflag <= 0;
                if (clear_e)
 
                        eflag <= 0;
 
                if (write_pc) PC <= new_pc;
                if (write_pc) PC <= new_pc;
                if (inc_pc) PC <= PC + 16'h1;
                if (inc_pc) PC <= PC + 16'h1;
                if (inc_su)
 
                        if (use_s) SS <= SS + 16'h1;
                if (inc_su | dec_su)
                        else SU <= SU + 16'h1;
                        begin
                if (dec_su)
                                if (use_s) SS <= new_su;
                        if (use_s) SS <= SS - 16'h1;
                                else SU <= new_su;
                        else SU <= SU - 16'h1;
                        end
 
/*
 
                if (inc_su)
 
                        if (use_s) SS <= SS + 16'h1;
 
                        else SU <= SU + 16'h1;
 
                if (dec_su)
 
                        if (use_s) SS <= SS - 16'h1;
 
                        else SU <= SU - 16'h1;
 
*/
        end
        end
 
 
`ifdef SIMULATION
`ifdef SIMULATION
initial
initial
        begin
        begin

powered by: WebSVN 2.1.0

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