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

Subversion Repositories aemb

[/] [aemb/] [trunk/] [rtl/] [verilog/] [aeMB2_brcc.v] - Diff between revs 131 and 191

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 131 Rev 191
/* $Id: aeMB2_brcc.v,v 1.3 2008-04-26 01:09:05 sybreon Exp $
/* $Id: aeMB2_brcc.v,v 1.3 2008-04-26 01:09:05 sybreon Exp $
**
**
** AEMB2 EDK 6.2 COMPATIBLE CORE
** AEMB2 EDK 6.2 COMPATIBLE CORE
** Copyright (C) 2004-2008 Shawn Tan <shawn.tan@aeste.net>
** Copyright (C) 2004-2008 Shawn Tan <shawn.tan@aeste.net>
**
**
** This file is part of AEMB.
** This file is part of AEMB.
**
**
** AEMB is free software: you can redistribute it and/or modify it
** AEMB is free software: you can redistribute it and/or modify it
** under the terms of the GNU Lesser General Public License as
** under the terms of the GNU Lesser General Public License as
** published by the Free Software Foundation, either version 3 of the
** published by the Free Software Foundation, either version 3 of the
** License, or (at your option) any later version.
** License, or (at your option) any later version.
**
**
** AEMB is distributed in the hope that it will be useful, but WITHOUT
** AEMB is distributed in the hope that it will be useful, but WITHOUT
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
** or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
** or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
** Public License for more details.
** Public License for more details.
**
**
** You should have received a copy of the GNU Lesser General Public
** You should have received a copy of the GNU Lesser General Public
** License along with AEMB. If not, see <http:**www.gnu.org/licenses/>.
** License along with AEMB. If not, see <http:**www.gnu.org/licenses/>.
*/
*/
/**
/**
 * Branch Condition Checker
 * Branch Condition Checker
 * @file aeMB2_brcc.v
 * @file aeMB2_brcc.v
 
 
 * This controls the decision to branch/delay. The actualy branch
 * This controls the decision to branch/delay. The actualy branch
   target is calculated in the ALU.
   target is calculated in the ALU.
 
 
 */
 */
 
 
module aeMB2_brcc (/*AUTOARG*/
module aeMB2_brcc (/*AUTOARG*/
   // Outputs
   // Outputs
   bra_ex,
   bra_ex,
   // Inputs
   // Inputs
   opd_of, ra_of, rd_of, opc_of, gclk, grst, dena, iena, gpha
   opd_of, ra_of, rd_of, opc_of, gclk, grst, dena, iena, gpha
   );
   );
   parameter AEMB_HTX = 1;
   parameter AEMB_HTX = 1;
 
 
   input [31:0] opd_of;
   input [31:0] opd_of;
   input [4:0]   ra_of;
   input [4:0]   ra_of;
   input [4:0]   rd_of;
   input [4:0]   rd_of;
   input [5:0]   opc_of;
   input [5:0]   opc_of;
 
 
   output [1:0] bra_ex;
   output [1:0] bra_ex;
 
 
   // SYS signals
   // SYS signals
   input        gclk,
   input        gclk,
                grst,
                grst,
                dena,
                dena,
                iena,
                iena,
                gpha;
                gpha;
 
 
   /*AUTOREG*/
   /*AUTOREG*/
   // Beginning of automatic regs (for this module's undeclared outputs)
   // Beginning of automatic regs (for this module's undeclared outputs)
   reg [1:0]             bra_ex;
   reg [1:0]             bra_ex;
   // End of automatics
   // End of automatics
 
 
   // TODO: replace comparators with logic
   // TODO: replace comparators with logic
 
 
   /* Branch Control */
   /* Branch Control */
   wire         wRTD = (opc_of == 6'o55);
   wire         wRTD = (opc_of == 6'o55);
   wire         wBCC = (opc_of == 6'o47) | (opc_of == 6'o57);
   wire         wBCC = (opc_of == 6'o47) | (opc_of == 6'o57);
   wire         wBRU = (opc_of == 6'o46) | (opc_of == 6'o56);
   wire         wBRU = (opc_of == 6'o46) | (opc_of == 6'o56);
 
 
   wire         wBEQ = (opd_of == 32'd0);
   wire         wBEQ = (opd_of == 32'd0);
   wire         wBLT = opd_of[31];
   wire         wBLT = opd_of[31];
   wire         wBLE = wBLT | wBEQ;
   wire         wBLE = wBLT | wBEQ;
   wire         wBNE = ~wBEQ;
   wire         wBNE = ~wBEQ;
   wire         wBGE = ~wBLT;
   wire         wBGE = ~wBLT;
   wire         wBGT = ~wBLE;
   wire         wBGT = ~wBLE;
 
 
   reg           xcc;
   reg           xcc;
 
 
   always @(/*AUTOSENSE*/rd_of or wBEQ or wBGE or wBGT or wBLE or wBLT
   always @(/*AUTOSENSE*/rd_of or wBEQ or wBGE or wBGT or wBLE or wBLT
            or wBNE) begin
            or wBNE) begin
      case (rd_of[2:0])
      case (rd_of[2:0])
        3'o0: xcc <= wBEQ;
        3'o0: xcc <= wBEQ;
        3'o1: xcc <= wBNE;
        3'o1: xcc <= wBNE;
        3'o2: xcc <= wBLT;
        3'o2: xcc <= wBLT;
        3'o3: xcc <= wBLE;
        3'o3: xcc <= wBLE;
        3'o4: xcc <= wBGT;
        3'o4: xcc <= wBGT;
        3'o5: xcc <= wBGE;
        3'o5: xcc <= wBGE;
        default: xcc <= 1'bX;
        default: xcc <= 1'bX;
      endcase // case (rd_of[2:0])
      endcase // case (rd_of[2:0])
   end // always @ (...
   end // always @ (...
 
 
   always @(posedge gclk)
   always @(posedge gclk)
     if (grst) begin
     if (grst) begin
        /*AUTORESET*/
        /*AUTORESET*/
        // Beginning of autoreset for uninitialized flops
        // Beginning of autoreset for uninitialized flops
        bra_ex <= 2'h0;
        bra_ex <= 2'h0;
        // End of automatics
        // End of automatics
     end else if (dena) begin
     end else if (dena) begin
        bra_ex[1] <= #1 (wRTD | wBRU | (wBCC & xcc)); // branch
        bra_ex[1] <= #1 (wRTD | wBRU | (wBCC & xcc)); // branch
        bra_ex[0] <= #1 (wBRU) ? ra_of[4] : rd_of[4]; // delay   
        bra_ex[0] <= #1 (wBRU) ? ra_of[4] : rd_of[4]; // delay   
     end
     end
 
 
endmodule // aeMB2_brcc
endmodule // aeMB2_brcc
 
 
/*
/*
 $Log: not supported by cvs2svn $
 $Log: not supported by cvs2svn $
 Revision 1.2  2008/04/20 16:34:32  sybreon
 Revision 1.2  2008/04/20 16:34:32  sybreon
 Basic version with some features left out.
 Basic version with some features left out.
 
 
 Revision 1.1  2008/04/18 00:21:52  sybreon
 Revision 1.1  2008/04/18 00:21:52  sybreon
 Initial import.
 Initial import.
 
 

powered by: WebSVN 2.1.0

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