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

Subversion Repositories m32632

[/] [m32632/] [trunk/] [rtl/] [ADDR_UNIT.v] - Diff between revs 9 and 11

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

Rev 9 Rev 11
Line 33... Line 33...
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//
//      Modules contained in this file:
//      Modules contained in this file:
//      ADDR_UNIT       generates data access addresses and controls data cache operation
//      ADDR_UNIT       generates data access addresses and controls data cache operation
//
//
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
 
module ADDR_UNIT ( BCLK, BRESET, READ, WRITE, LDEA, NEWACC, CLRMSW, POST, DISP_OK, FULLACC, SRC2SEL,
module ADDR_UNIT ( BCLK, BRESET, READ, WRITE, LDEA, NEWACC, CLRMSW, POST, DISP_OK, FULLACC, SRC2SEL, INDEX, ASIZE, SRC1, SRC2, BWD,
                                   DISP, PC_ARCHI, PC_ICACHE, IO_READY, ACC_STAT, MMU_UPDATE, IC_TEX, ABO_STAT, ADIVAR, RWVAL_1,
                                   DISP, PC_ARCHI, PC_ICACHE, IO_READY, ACC_STAT, MMU_UPDATE, IC_TEX, ABO_STAT, ADIVAR, RWVAL_1, OP_RMW, PHASE_17,
                                   NO_TRAP, FPU_TRAP, READ_OUT, WRITE_OUT, ZTEST, RMW, VADR, ADDR, SIZE, PACKET, ACC_DONE, ABORT
                                   NO_TRAP, FPU_TRAP, READ_OUT, WRITE_OUT, ZTEST, RMW, VADR, ADDR, SIZE, PACKET, ACC_DONE, ABORT, REG_OUT, BITSEL );
 
 
        input                   BCLK,BRESET;
        input                   BCLK,BRESET;
        input                   READ,WRITE,LDEA;
        input                   READ,WRITE,LDEA;
        input                   NEWACC;
        input                   NEWACC;
        input                   CLRMSW,POST,FULLACC;
        input                   CLRMSW,POST,FULLACC;
Line 129... Line 129...
        assign acc_ok   = ACC_STAT[0] & ~pg_op;
        assign acc_ok   = ACC_STAT[0] & ~pg_op;
        assign acc_pass = ACC_STAT[0] & ZTEST;
        assign acc_pass = ACC_STAT[0] & ZTEST;
 
 
        always @(posedge BCLK) ABORT <= acc_err;        // Signal to Steuerung - only a pulse
        always @(posedge BCLK) ABORT <= acc_err;        // Signal to Steuerung - only a pulse
 
 
        always @(posedge BCLK) if (acc_err) tex_feld <= ACC_STAT[3] ? 2'b11 : {~ACC_STAT[2],ACC_STAT[2]};       /
        always @(posedge BCLK) if (acc_err) tex_feld <= ACC_STAT[3] ? 2'b11 : {~ACC_STAT[2],ACC_STAT[2]};       // for MSR
        always @(posedge BCLK) if (acc_err) u_ddt        <= {RMW,ABO_STAT[1],(WRITE_OUT | ZTEST)};
        always @(posedge BCLK) if (acc_err) u_ddt        <= {RMW,ABO_STAT[1],(WRITE_OUT | ZTEST)};
 
 
        // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
 
        always @(SRC2SEL or CLRMSW or SRC2 or PC_ARCHI or ea_reg)
        always @(SRC2SEL or CLRMSW or SRC2 or PC_ARCHI or ea_reg)
                case (SRC2SEL)
                case (SRC2SEL)
                  2'b00 : source2 = {(CLRMSW ? 16'h0000 : SRC2[31:16]),SRC2[15:0]};      // base reg, External Addressi
                  2'b00 : source2 = {(CLRMSW ? 16'h0000 : SRC2[31:16]),SRC2[15:0]};      // base reg, External Addressing with MOD 
                  2'b01 : source2 = PC_ARCHI;           // PC relative
                  2'b01 : source2 = PC_ARCHI;           // PC relative
                  2'b10 : source2 = 32'h0;                      // Absolute Addressing
                  2'b10 : source2 = 32'h0;                      // Absolute Addressing
                  2'b11 : source2 = ea_reg;                     // REUSE : 2. TOS
                  2'b11 : source2 = ea_reg;                     // REUSE : 2. TOS
                endcase
                endcase
 
 
        assign index_sel = POST ? 4'h0 : INDEX; // Alternative application of Index for POST Adder : POP fr
        assign index_sel = POST ? 4'h0 : INDEX; // Alternative application of Index for POST Adder : POP from Stack
 
 
        always @(BWD or SRC1)
        always @(BWD or SRC1)
                casex (BWD)
                casex (BWD)
                        2'b00 : sign_ext_src1 = {{24{SRC1[7]}}, SRC1[7:0]};              // Byte
                        2'b00 : sign_ext_src1 = {{24{SRC1[7]}}, SRC1[7:0]};              // Byte
                        2'b01 : sign_ext_src1 = {{16{SRC1[15]}},SRC1[15:0]};     // Word
                        2'b01 : sign_ext_src1 = {{16{SRC1[15]}},SRC1[15:0]};     // Word
Line 166... Line 166...
 
 
        assign reg_adder = source2 + index_val; // SRC2 allows simple MOV with SRC1
        assign reg_adder = source2 + index_val; // SRC2 allows simple MOV with SRC1
 
 
        assign final_addr = reg_adder + DISP;   // That's the final access address
        assign final_addr = reg_adder + DISP;   // That's the final access address
 
 
        always @(posedge BCLK) if (LDEA && (index_sel[3:2] == 2'b11)) BITSEL <= SRC1[2:0];       // for Bit Opcod
        always @(posedge BCLK) if (LDEA && (index_sel[3:2] == 2'b11)) BITSEL <= SRC1[2:0];       // for Bit Opcodes in I_PFAD
 
 
        always @(INDEX) // SP POP Operation & String Backward
        always @(INDEX) // SP POP Operation & String Backward
                case (INDEX[2:0])
                case (INDEX[2:0])
                  3'b000 : tos_offset = 32'h0000_0001;
                  3'b000 : tos_offset = 32'h0000_0001;
                  3'b001 : tos_offset = 32'h0000_0002;
                  3'b001 : tos_offset = 32'h0000_0002;
Line 207... Line 207...
                  end
                  end
 
 
        assign ADDR = ea_reg;   // used for ADDR opcode and TOS Addressing
        assign ADDR = ea_reg;   // used for ADDR opcode and TOS Addressing
 
 
        // This pulse stores all parameters of access
        // This pulse stores all parameters of access
        assign init_acc = ((FULLACC ? (NEWACC & acc_ende) : acc_ende) | ~acc_run) & DISP_OK & (READ | WRITE
        assign init_acc = ((FULLACC ? (NEWACC & acc_ende) : acc_ende) | ~acc_run) & DISP_OK & (READ | WRITE) & ~ABORT & NO_TRAP;
 
 
        assign fa_out = init_acc | ADIVAR;      // special case for LMR IVAR,...
        assign fa_out = init_acc | ADIVAR;      // special case for LMR IVAR,...
 
 
        always @(fa_out or acc_ok or final_addr or qw_align or pg_op or pg_areg or vadr_reg or next_vadr)
        always @(fa_out or acc_ok or final_addr or qw_align or pg_op or pg_areg or vadr_reg or next_vadr)
                casex ({fa_out,acc_ok})
                casex ({fa_out,acc_ok})
Line 247... Line 247...
                        READ_OUT  <= init_acc ? (READ & ~RWVAL_1) : (READ_OUT  & ~acc_ende & ~acc_err);
                        READ_OUT  <= init_acc ? (READ & ~RWVAL_1) : (READ_OUT  & ~acc_ende & ~acc_err);
 
 
        always @(posedge BCLK or negedge BRESET)
        always @(posedge BCLK or negedge BRESET)
                if (!BRESET) write_reg <= 1'b0;
                if (!BRESET) write_reg <= 1'b0;
                  else
                  else
                        write_reg <= (init_acc ? (WRITE & ~RWVAL_1 & ~pg_test) : (write_reg & ~acc_ende & ~acc_err & ~FPU
                        write_reg <= (init_acc ? (WRITE & ~RWVAL_1 & ~pg_test) : (write_reg & ~acc_ende & ~acc_err & ~FPU_TRAP)) | do_wr;
 
 
        assign WRITE_OUT = write_reg & ~FPU_TRAP;
        assign WRITE_OUT = write_reg & ~FPU_TRAP;
 
 
        // Special case for RDVAL and WRVAL
        // Special case for RDVAL and WRVAL
        always @(posedge BCLK or negedge BRESET)
        always @(posedge BCLK or negedge BRESET)
                if (!BRESET) ZTEST <= 1'b0;
                if (!BRESET) ZTEST <= 1'b0;
                  else
                  else
                        ZTEST <= pg_op ? (~ZTEST | (~acc_pass & ~acc_err)) : (init_acc ? RWVAL_1  : (ZTEST  & ~acc_ende &
                        ZTEST <= pg_op ? (~ZTEST | (~acc_pass & ~acc_err)) : (init_acc ? RWVAL_1  : (ZTEST  & ~acc_ende & ~acc_err));
 
 
        always @(posedge BCLK or negedge BRESET)
        always @(posedge BCLK or negedge BRESET)
                if (!BRESET) RMW <= 1'b0;
                if (!BRESET) RMW <= 1'b0;
                  else
                  else
                        RMW <= init_acc ? (OP_RMW & PHASE_17) : (RMW  & ~acc_ende & ~acc_err);
                        RMW <= init_acc ? (OP_RMW & PHASE_17) : (RMW  & ~acc_ende & ~acc_err);
Line 276... Line 276...
 
 
        always @(posedge BCLK) if (init_acc) SIZE <= ASIZE;
        always @(posedge BCLK) if (init_acc) SIZE <= ASIZE;
 
 
        assign inc_pack = (PACKET[1:0] == 2'b00) ? 2'b10 : {(SIZE[1] ^ SIZE[0]),(SIZE[1] & SIZE[0])};
        assign inc_pack = (PACKET[1:0] == 2'b00) ? 2'b10 : {(SIZE[1] ^ SIZE[0]),(SIZE[1] & SIZE[0])};
 
 
        // Counter for data packets 1 to 3 : special case aligned QWORD : only 2 packets. Additionally star
        // Counter for data packets 1 to 3 : special case aligned QWORD : only 2 packets. Additionally start address in bits 1 und 0.
        // special coding (00) -> [01] -> (10) , [01] optional by QWORD and (10) shows always the end
        // special coding (00) -> [01] -> (10) , [01] optional by QWORD and (10) shows always the end
        always @(posedge BCLK)
        always @(posedge BCLK)
                if (init_acc) PACKET <= {2'b00,final_addr[1:0]};
                if (init_acc) PACKET <= {2'b00,final_addr[1:0]};
                  else
                  else
                        if (acc_ok) PACKET <= PACKET + {inc_pack,2'b00};
                        if (acc_ok) PACKET <= PACKET + {inc_pack,2'b00};
Line 296... Line 296...
                  5'b10_1_xx : acc_ende = acc_ok;       //                      2 packets
                  5'b10_1_xx : acc_ende = acc_ok;       //                      2 packets
                  5'b11_1_xx : acc_ende = acc_ok;       // QWord        at least 2 packets
                  5'b11_1_xx : acc_ende = acc_ok;       // QWord        at least 2 packets
                  default    : acc_ende = 1'b0;
                  default    : acc_ende = 1'b0;
                endcase
                endcase
 
 
        assign in_page = (vadr_reg[11:3] != 9'h1FF);    // Access inside a page ? During WRITE address is incr
        assign in_page = (vadr_reg[11:3] != 9'h1FF);    // Access inside a page ? During WRITE address is increasing : 1. LSD 2. MSD
 
 
        always @(SIZE or vadr_reg or in_page or PACKET)
        always @(SIZE or vadr_reg or in_page or PACKET)
                casex (SIZE)
                casex (SIZE)
                  2'b01 : frueh_ok = (vadr_reg[3:2] != 2'b11);  //Word
                  2'b01 : frueh_ok = (vadr_reg[3:2] != 2'b11);  //Word
                  2'b10 : frueh_ok = (vadr_reg[3:2] != 2'b11);  //DWord
                  2'b10 : frueh_ok = (vadr_reg[3:2] != 2'b11);  //DWord
                  2'b11 : frueh_ok = (PACKET[1:0] == 2'b00) ? (~vadr_reg[3] | ~vadr_reg[2]) : ((PACKET[3:2] == 2'b
                  2'b11 : frueh_ok = (PACKET[1:0] == 2'b00) ? (~vadr_reg[3] | ~vadr_reg[2]) : ((PACKET[3:2] == 2'b01) & (vadr_reg[3:2] != 2'b11));
                default : frueh_ok = 1'b1;                                              // Byte don't case
                default : frueh_ok = 1'b1;                                              // Byte don't case
                endcase
                endcase
 
 
        assign all_ok = SIZE[1] ? (PACKET[1:0] == 2'b00) : (PACKET[1:0] != 2'b11);        // for DWord : Word
        assign all_ok = SIZE[1] ? (PACKET[1:0] == 2'b00) : (PACKET[1:0] != 2'b11);        // for DWord : Word
 
 
        always @(SIZE or READ_OUT or frueh_ok or PACKET or all_ok or io_acc or acc_ok or qwa_flag or io_rdy
        always @(SIZE or READ_OUT or frueh_ok or PACKET or all_ok or io_acc or acc_ok or qwa_flag or io_rdy or ca_hit)
                casex ({SIZE,READ_OUT,frueh_ok,PACKET[3],io_acc,all_ok})
                casex ({SIZE,READ_OUT,frueh_ok,PACKET[3],io_acc,all_ok})
                  7'b00_xxxx_x : acc_step = acc_ok;     // Byte, all ok
                  7'b00_xxxx_x : acc_step = acc_ok;     // Byte, all ok
                //
                //
                  7'b01_xxxx_1 : acc_step = acc_ok;     // Word :       aligned access , only 1 packet
                  7'b01_xxxx_1 : acc_step = acc_ok;     // Word :       aligned access , only 1 packet
                  7'b01_1x1x_0 : acc_step = acc_ok;     //                      READ must wait for all data
                  7'b01_1x1x_0 : acc_step = acc_ok;     //                      READ must wait for all data
Line 324... Line 324...
                  7'b10_001x_0 : acc_step = acc_ok;     //                      WRITE Adr. ist not perfect and waits for last packet
                  7'b10_001x_0 : acc_step = acc_ok;     //                      WRITE Adr. ist not perfect and waits for last packet
                  7'b10_01xx_0 : acc_step = acc_ok;     //                      WRITE Adr. perfect - acc_step after 1. packet
                  7'b10_01xx_0 : acc_step = acc_ok;     //                      WRITE Adr. perfect - acc_step after 1. packet
                // fast QWord READ : there would be a 2. acc_step if not ~PACK... 
                // fast QWord READ : there would be a 2. acc_step if not ~PACK... 
                  7'b11_1xxx_x : acc_step = acc_ok & ( (qwa_flag & ~io_rdy & ca_hit) ? ~PACKET[3] : PACKET[3] );
                  7'b11_1xxx_x : acc_step = acc_ok & ( (qwa_flag & ~io_rdy & ca_hit) ? ~PACKET[3] : PACKET[3] );
                  7'b11_0x1x_x : acc_step = acc_ok;
                  7'b11_0x1x_x : acc_step = acc_ok;
                  7'b11_0100_x : acc_step = acc_ok;     //                      WRITE Adr. perfect - acc_step after 1. packet if not io_a
                  7'b11_0100_x : acc_step = acc_ok;     //                      WRITE Adr. perfect - acc_step after 1. packet if not io_acc
                  default      : acc_step = 1'b0;
                  default      : acc_step = 1'b0;
                endcase
                endcase
 
 
        // There is a 2. acc_step if packet (10) - this must be suppressed
        // There is a 2. acc_step if packet (10) - this must be suppressed
        always @(posedge BCLK or negedge BRESET)
        always @(posedge BCLK or negedge BRESET)
Line 336... Line 336...
                  else no_done <= (~acc_ende & acc_step) | (no_done & ~(acc_run & acc_ende));
                  else no_done <= (~acc_ende & acc_step) | (no_done & ~(acc_run & acc_ende));
 
 
        // The final DONE Multiplexer
        // The final DONE Multiplexer
        assign ACC_DONE = acc_run ? (acc_step & ~no_done) : ea_ok;
        assign ACC_DONE = acc_run ? (acc_step & ~no_done) : ea_ok;
 
 
        always @(posedge BCLK) reg_out_i <= ~acc_step & BRESET & ((qwa_flag & (io_rdy | ~ca_hit) & acc_ok)
        always @(posedge BCLK) reg_out_i <= ~acc_step & BRESET & ((qwa_flag & (io_rdy | ~ca_hit) & acc_ok) | reg_out_i);
 
 
        always @(posedge BCLK) io_rdy  <= IO_READY & (WRITE_OUT | READ_OUT);
        always @(posedge BCLK) io_rdy  <= IO_READY & (WRITE_OUT | READ_OUT);
 
 
        always @(posedge BCLK) next_reg <= (acc_step & ~qwa_flag) & (SIZE == 2'b11);
        always @(posedge BCLK) next_reg <= (acc_step & ~qwa_flag) & (SIZE == 2'b11);
        assign REG_OUT = reg_out_i | next_reg;
        assign REG_OUT = reg_out_i | next_reg;

powered by: WebSVN 2.1.0

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