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

Subversion Repositories aemb

[/] [aemb/] [tags/] [AEMB_7_05/] [rtl/] [verilog/] [aeMB_aslu.v] - Diff between revs 5 and 7

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

Rev 5 Rev 7
Line 1... Line 1...
//                              -*- Mode: Verilog -*-
//                              -*- Mode: Verilog -*-
// Filename        : aeMB_aslu.v
// Filename        : aeMB_aslu.v
// Description     : AEMB Arithmetic Shift Logic Unit
// Description     : AEMB Arithmetic Shift Logic Unit
// Author          : Shawn Tan Ser Ngiap <shawn.tan@aeste.net>
// Author          : Shawn Tan Ser Ngiap <shawn.tan@aeste.net>
// Created On      : Sat Dec 30 06:03:24 2006
// Created On      : Sat Dec 30 06:03:24 2006
// Last Modified By: Shawn Tan
// Last Modified By: $Author: sybreon $
// Last Modified On: 2006-12-30
// Last Modified On: $Date: 2007-04-04 06:11:05 $
// Update Count    : 0
// Update Count    : $Revision
// Status          : Unknown, Use with caution!
// Status          : $State: Exp $
 
 
/*
/*
 * $Id: aeMB_aslu.v,v 1.2 2007-04-03 14:46:26 sybreon Exp $
 * $Id: aeMB_aslu.v,v 1.3 2007-04-04 06:11:05 sybreon Exp $
 *
 *
 
 * AEMB Arithmetic Shift Logic Unit
 * Copyright (C) 2006 Shawn Tan Ser Ngiap <shawn.tan@aeste.net>
 * Copyright (C) 2006 Shawn Tan Ser Ngiap <shawn.tan@aeste.net>
 *
 *
 * This library is free software; you can redistribute it and/or modify it
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License,
 * the Free Software Foundation; either version 2.1 of the License,
Line 30... Line 31...
 * DESCRIPTION
 * DESCRIPTION
 * Arithmetic, shift and logic execution unit
 * Arithmetic, shift and logic execution unit
 *
 *
 * HISTORY
 * HISTORY
 * $Log: not supported by cvs2svn $
 * $Log: not supported by cvs2svn $
 
 * Revision 1.2  2007/04/03 14:46:26  sybreon
 
 * Fixed endian correction issues on data bus.
 
 *
 * Revision 1.1  2007/03/09 17:52:17  sybreon
 * Revision 1.1  2007/03/09 17:52:17  sybreon
 * initial import
 * initial import
 *
 *
 *
 
 */
 */
 
 
module aeMB_aslu (/*AUTOARG*/
module aeMB_aslu (/*AUTOARG*/
   // Outputs
   // Outputs
   dwb_adr_o, rRESULT,
   dwb_adr_o, rRESULT,
   // Inputs
   // Inputs
   dwb_dat_i, rBRA, rDLY, rREGA, rREGB, rSIMM, rMXSRC, rMXTGT, rMXALU,
   dwb_dat_i, rBRA, rDLY, rREGA, rREGB, rSIMM, rMXSRC, rMXTGT, rMXALU,
   rOPC, rPC, rIMM, rRD, rRA, nclk, nrst, drun, drst
   rOPC, rPC, rIMM, rRD, rRA, rMXLDST, nclk, nrst, drun, drst
   );
   );
   parameter DSIZ = 32;
   parameter DSIZ = 32;
 
 
   output [DSIZ-1:0] dwb_adr_o;
   output [DSIZ-1:0] dwb_adr_o;
   input [31:0]      dwb_dat_i;
   input [31:0]      dwb_dat_i;
Line 58... Line 61...
   input [1:0]        rMXALU;
   input [1:0]        rMXALU;
   input [5:0]        rOPC;
   input [5:0]        rOPC;
   input [31:0]      rPC;
   input [31:0]      rPC;
   input [15:0]      rIMM;
   input [15:0]      rIMM;
   input [4:0]        rRD, rRA;
   input [4:0]        rRD, rRA;
 
   input [1:0]        rMXLDST;
 
 
   input             nclk, nrst, drun, drst;
   input             nclk, nrst, drun, drst;
 
 
   reg [31:0]        rRESULT;
   reg [31:0]        rRESULT;
   reg              rMSR_C;
   reg              rMSR_C;
Line 82... Line 85...
                    (rMXTGT == 2'b10) ? rRESULT :
                    (rMXTGT == 2'b10) ? rRESULT :
                    (rMXTGT == 2'b01) ? rSIMM :
                    (rMXTGT == 2'b01) ? rSIMM :
                    rREGB;
                    rREGB;
 
 
   // ARITHMETIC
   // ARITHMETIC
 
   //wire           wADDC_ = (rOPC[1] & (rMXLDST == 2'o0)) ? rMSR_C : 1'b0;
   wire             wADDC_ = (rOPC[1]) ? rMSR_C : 1'b0;
   wire             wADDC_ = (rOPC[1]) ? rMSR_C : 1'b0;
   wire             wSUBC_ = (rOPC[1]) ? rMSR_C : 1'b1;
   wire             wSUBC_ = (rOPC[1]) ? rMSR_C : 1'b1;
   wire             wADDC, wSUBC, wRES_AC;
   wire             wADDC, wSUBC, wRES_AC,wCMPC;
   wire [31:0]       wADD,wSUB,wRES_A;
   wire             wCMPU;
 
   wire [31:0]       wADD,wSUB,wRES_A,wCMP;
 
 
 
   // TODO: verify signed compare
 
   assign           wCMPU = (rIMM[1]) ? ~(wOPB >= wOPA) :
 
                            ~(((wOPB >= wOPA) & (wOPB[31]==wOPA[31])) | (~wOPB[31] & wOPA[31]));
 
   assign           {wCMPC,wCMP} = {wSUBC,wCMPU,wSUB[30:0]};
   assign           {wADDC,wADD} = (wOPB + wOPA) + wADDC_;
   assign           {wADDC,wADD} = (wOPB + wOPA) + wADDC_;
   assign           {wSUBC,wSUB} = (wOPB + ~wOPA) + wSUBC_;
   assign           {wSUBC,wSUB} = (wOPB + ~wOPA) + wSUBC_;
 
 
   reg              rRES_AC;
   reg              rRES_AC;
   reg [31:0]        rRES_A;
   reg [31:0]        rRES_A;
   always @(/*AUTOSENSE*/rOPC or wADD or wADDC or wSUB or wSUBC)
   always @(/*AUTOSENSE*/rIMM or rOPC or wADD or wADDC or wCMP
     {rRES_AC,rRES_A} <= #1 (rOPC[0] & ~rOPC[5]) ? {~wSUBC,wSUB} : {wADDC,wADD};
            or wCMPC or wSUB or wSUBC)
 
     //{rRES_AC,rRES_A} <= #1 (rOPC[0] & ~rOPC[5]) ? {~wSUBC,wSUB} : {wADDC,wADD};   
 
     case ({rOPC[5],rOPC[3],rOPC[0],rIMM[0]})
 
       4'h2, 4'h6, 4'h7: {rRES_AC,rRES_A} <= #1 {~wSUBC,wSUB}; // SUB
 
       4'h3: {rRES_AC,rRES_A} <= #1 {~wCMPC,wCMP}; // CMP
 
       default: {rRES_AC,rRES_A} <= #1 {wADDC,wADD};
 
     endcase // case ({rOPC[5],rOPC[0]})   
 
 
   // LOGIC
   // LOGIC
   wire [31:0]       wOR = wOPA | wOPB;
   wire [31:0]       wOR = wOPA | wOPB;
   wire [31:0]       wAND = wOPA & wOPB;
   wire [31:0]       wAND = wOPA & wOPB;
   wire [31:0]       wXOR = wOPA ^ wOPB;
   wire [31:0]       wXOR = wOPA ^ wOPB;
Line 172... Line 188...
          //rMSR_C;       
          //rMSR_C;       
        endcase // case(rMXALU)
        endcase // case(rMXALU)
     end
     end
 
 
   // DWB I/F
   // DWB I/F
   assign           dwb_adr_o = rRESULT;
   //assign         dwb_adr_o = rRESULT;
   //{rRESULT[DSIZ-1:2],2'b00};
   assign dwb_adr_o = {rRESULT[DSIZ-1:2],2'b00};
 
 
endmodule // aeMB_aslu
endmodule // aeMB_aslu
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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