/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
//// Author: Liwei ////
|
//// Author: Liwei ////
|
//// ////
|
//// ////
|
//// ////
|
//// ////
|
//// If you encountered any problem, please contact : ////
|
//// If you encountered any problem, please contact : ////
|
//// Email: mcupro@yahoo.com.hk or mcupro@opencores.org ////
|
//// Email: mcupro@yahoo.com.hk or mcupro@opencores.org ////
|
//// ////
|
//// ////
|
//// Downloaded from: ////
|
//// Downloaded from: ////
|
//// http://www.opencores.org/pdownloads.cgi/list/mips789 ////
|
//// http://www.opencores.org/pdownloads.cgi/list/mips789 ////
|
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// Copyright (C) 2006-2007 Liwei ////
|
//// Copyright (C) 2006-2007 Liwei ////
|
//// mcupro@yahoo.com.hk ////
|
//// mcupro@yahoo.com.hk ////
|
//// ////
|
//// ////
|
//// ////
|
//// ////
|
//// This source file may be used and distributed freely without ////
|
//// This source file may be used and distributed freely without ////
|
//// restriction provided that this copyright statement is not ////
|
//// restriction provided that this copyright statement is not ////
|
//// removed from the file and any derivative work contains the ////
|
//// removed from the file and any derivative work contains the ////
|
//// original copyright notice and the associated disclaimer. ////
|
//// original copyright notice and the associated disclaimer. ////
|
//// ////
|
//// ////
|
//// Please let the author know if it is used ////
|
//// Please let the author know if it is used ////
|
//// for commercial purpose. ////
|
//// for commercial purpose. ////
|
//// ////
|
//// ////
|
//// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY ////
|
//// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY ////
|
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED ////
|
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED ////
|
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ////
|
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ////
|
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR ////
|
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR ////
|
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ////
|
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ////
|
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ////
|
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ////
|
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ////
|
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ////
|
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ////
|
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ////
|
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ////
|
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ////
|
//// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ////
|
//// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ////
|
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ////
|
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ////
|
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ////
|
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ////
|
//// POSSIBILITY OF SUCH DAMAGE. ////
|
//// POSSIBILITY OF SUCH DAMAGE. ////
|
//// ////
|
//// ////
|
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// ////
|
//// ////
|
//// Date of Creation: 2007.8.1 ////
|
//// Date of Creation: 2007.8.1 ////
|
//// ////
|
//// ////
|
//// Version: 0.0.1 ////
|
//// Version: 0.0.1 ////
|
//// ////
|
//// ////
|
//// Description: ////
|
//// Description: ////
|
//// ////
|
//// ////
|
//// ////
|
//// ////
|
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// Change log: ////
|
//// Change log: ////
|
//// ////
|
//// ////
|
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
|
|
`define EXT_SIGN 1
|
`define EXT_SIGN 1
|
`define EXT_UNSIGN 2
|
`define EXT_UNSIGN 2
|
`define EXT_J 3
|
`define EXT_J 3
|
`define EXT_B 4
|
`define EXT_B 4
|
`define EXT_SA 5
|
`define EXT_SA 5
|
`define EXT_S2H 6
|
`define EXT_S2H 6
|
`define EXT_NOP 0
|
`define EXT_NOP 0
|
|
|
module ext(
|
module ext(
|
input [31:0] ins_i ,
|
input [31:0] ins_i ,
|
output reg [31:0] res ,
|
output reg [31:0] res ,
|
input [2:0]ctl);
|
input [2:0]ctl);
|
|
|
wire [25:0] instr25_0;
|
wire [25:0] instr25_0;
|
assign instr25_0 = ins_i[25:0] ;
|
assign instr25_0 = ins_i[25:0] ;
|
|
|
wire[15:0] sign = {instr25_0[15],instr25_0[15],instr25_0[15],instr25_0[15],instr25_0[15],instr25_0[15],instr25_0[15],instr25_0[15],instr25_0[15],instr25_0[15],instr25_0[15],instr25_0[15],instr25_0[15],instr25_0[15],instr25_0[15],instr25_0[15]} ;
|
wire[15:0] sign = {instr25_0[15],instr25_0[15],instr25_0[15],instr25_0[15],instr25_0[15],instr25_0[15],instr25_0[15],instr25_0[15],instr25_0[15],instr25_0[15],instr25_0[15],instr25_0[15],instr25_0[15],instr25_0[15],instr25_0[15],instr25_0[15]} ;
|
|
|
always @ (*)
|
always @ (*)
|
case (ctl)
|
case (ctl)
|
`EXT_SIGN :res ={sign,instr25_0[15:0]};//sign
|
`EXT_SIGN :res ={sign,instr25_0[15:0]};//sign
|
`EXT_UNSIGN :res ={16'b0,instr25_0[15:0]};//zeroext
|
`EXT_UNSIGN :res ={16'b0,instr25_0[15:0]};//zeroext
|
`EXT_J :res ={4'b0,instr25_0[25:0],2'b0};//jmp
|
`EXT_J :res ={4'b0,instr25_0[25:0],2'b0};//jmp
|
`EXT_B :res ={sign[13:0],instr25_0[15:0],2'B0};//brach
|
`EXT_B :res ={sign[13:0],instr25_0[15:0],2'B0};//brach
|
`EXT_SA :res ={27'b0,instr25_0[10:6]} ;//sll,srl
|
`EXT_SA :res ={27'b0,instr25_0[10:6]} ;//sll,srl
|
`EXT_S2H :res ={instr25_0[15:0],16'B0};//shift to high
|
`EXT_S2H :res ={instr25_0[15:0],16'B0};//shift to high
|
default: res=0;
|
default: res=0;
|
endcase
|
endcase
|
endmodule
|
endmodule
|
|
|