⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 r2000_cpu_pipe.v

📁 这是一个MIPS架构的开发的CPU软核OR2000
💻 V
📖 第 1 页 / 共 3 页
字号:
//////////////////////////////////////////////////////////////////////////                                                              //////// r2000_cpu_pipe.v				                              ////////                                                              //////// This file is part of the r2000pl Pipelined				      ////////	opencores effort.										  ////////	Simple Pipelined Mips 32 bits processor				      //////// <http://www.opencores.org/projects.cgi/web/r2000/>           ////////                                                              //////// Module Description:                                          //////// The top level module of the r2000pl cpu.                     ////////	- 5 stage pipeline mips-I ISA compatible processor		  ////////	- harvard architecture                                    ////////	- I-cache ans D-Cache implemented                         ////////	- one delay slot is used		                          ////////	- the CP0 is implemented (without MMU)                 	  //////// 	- unaligned instruction are not implemented               ////////	- tested ok for C langage programms:                      ////////		- 800 digits of pi                                    ////////		- reed-solomon algorithm                              ////////		- dhrystone test Version 2.1                          ////////                                                              ////////                                                              //////// To Do:                                                       ////////                                                              //////// Author(s):                                                   //////// - Abdallah Meziti El-Ibrahimi   abdallah.meziti@gmail.com    ////////                                                              //////////////////////////////////////////////////////////////////////////////                                                              //////// Copyright (C) 2001 Abdallah Meziti and OPENCORES.ORG         ////////                                                              //////// This source file may be used and distributed without         //////// restriction provided that this copyright statement is not    //////// removed from the file and that any derivative work contains  //////// the original copyright notice and the associated disclaimer. ////////                                                              //////// This source file is free software; you can redistribute it   //////// and/or modify it under the terms of the GNU Lesser General   //////// Public License as published by the Free Software Foundation; //////// either version 2.1 of the License, or (at your option) any   //////// later version.                                               ////////                                                              //////// This source is distributed in the hope that it will be       //////// useful, but WITHOUT ANY WARRANTY; without even the implied   //////// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //////// PURPOSE. See the GNU Lesser General Public License for more  //////// details.                                                     ////////                                                              //////// You should have received a copy of the GNU Lesser General    //////// Public License along with this source; if not, download it   //////// from <http://www.opencores.org/lgpl.shtml>                   ////////                                                              //////////////////////////////////////////////////////////////////////////`include "timescale.v"`include "define.h"//`define BREAK_PT/* ====================	module definition   ==================== */module r2000_cpu_pipe	(		mem_code_addr_o	,	// Programm Memory Address		mem_code_inst_i	,	// Programm Memory Instruction		mem_code_hit_i	,	// I-Cache hit signal				mem_data_addr_o	,	// Data Memory Address		mem_data_data_i	,	// Data Memory in the processor		mem_data_data_o	,	// Data Memory out of the processor		mem_data_hit_i	,	// D-Cache hit signal //Data Memory Stop the processor		mem_data_wr_o	,	// Data Memory Write		mem_data_rd_o	,	// Data Memory Read				mem_data_en_o	,`ifdef DCACHE		mem_data_width_o,	// Byte Memory Width`else// DCACHE		mem_data_blel_o	,	// Byte Memory Low enable		mem_data_bhel_o	,	// Byte Memory High Enable		mem_data_bleh_o	,	// Byte Memory Low enable		mem_data_bheh_o	,	// Byte Memory High Enable`endif// DCACHE		`ifdef	CP0		sig_int_i		,	// Interrupt exception		sig_si_i		,	// Software Interrupt`endif	//CP0			clk_i			,	// Clock		rst_i				// Reset	);/* --------------------------------------------------------------	in, out declaration   ------------------- */	output [`dw-1:0]		mem_code_addr_o	;	input  [`dw-1:0]		mem_code_inst_i	;	input					mem_code_hit_i	;			output [`dw-1:0]		mem_data_addr_o	;	input  [`dw-1:0]		mem_data_data_i ;	output [`dw-1:0]		mem_data_data_o ;	input					mem_data_hit_i	;		output 					mem_data_wr_o	;	output 					mem_data_rd_o	;	output 					mem_data_en_o	;`ifdef DCACHE	output	[1:0]			mem_data_width_o;`else// DCACHE	output					mem_data_bhel_o	;	output					mem_data_blel_o	;	output					mem_data_bheh_o	;	output					mem_data_bleh_o	;`endif// DCACHE		`ifdef	CP0	input[5:0]				sig_int_i		;	input[1:0]				sig_si_i		;`endif	//CP0		input					clk_i			;	input					rst_i			;	/* --------------------------------------------------------------	registers, wires declaration   ------------------- */	// programm counter	wire [`dw-1:0]		wPC					;	wire [`dw-1:0]		IF_PCplus4			,	ID_PCplus4		,	ID_PCplus8	,	EX_PCplus8;	wire [`dw-1:0]		ID_mux_pc_out;  		wire [`aw-1:0]		wTargetBranch		;	wire [`aw-1:0]		wTargetJump			;	                                    		// decode unit                      		wire [`dw-1:0]		ID_inst				,	EX_inst`ifdef DEBUG											,	MEM_inst		,	WB_inst`endif//DEBUG											;	wire [4:0]			ID_rs_index			,						ID_rt_index			,	EX_rt_index		,						ID_rd_index			,	EX_rd_index		,	MEM_rd_index		,	WB_rd_index;	wire [4:0]			EX_shamt			;	wire [5:0]			EX_funct			;                                        		wire [15:0] 		ID_im				;	wire [`dw-1:0] 		ID_imup				,	EX_imup			;	wire [`dw-1:0]		ID_signextend		,	EX_signextend	;	wire [`dw-1:0]		ID_zeroextend		,	EX_zeroextend	;	// branch function	wire [15:0] 		wAdresse16			;	wire [25:0] 		wAdresse26			;	wire [1:0]			ID_ctl_branch_type	;	wire [3:0]			ID_ctl_branch_cond	;	wire [3:0]			ID_cmp_status		;	wire [`SELWIDTH-1:0]ID_mux_branch_sel	`ifdef	CP0											,	EX_mux_branch_sel	,	MEM_mux_branch_sel	;	reg					MEM_branch_Slot			// Detect branch slot when exception`endif	//CP0												;		// alu unit	wire [1:0]			ID_ctl_alu_src_b	, 	EX_ctl_alu_src_b	;	wire [2:0]			ID_ctl_alu_op		,	EX_ctl_alu_op		;	wire [3:0]			EX_alu_cmd			;	wire [`dw-1:0]		EX_mux_src_b_out	;	wire [`dw-1:0]		EX_alu_out			,	MEM_alu_out			;	wire [3:0]			EX_AluStatus		;	// Alu Status	wire				ID_ctl_alu_status	,	EX_ctl_alu_status	;		// forward	wire [1:0]			rs_sel				,						rt_sel				;	wire [`dw-1:0]		ID_reg_rs_forward	,						ID_reg_rt_forward	;	// hazard	wire				wInterlock			,						wRaw_Hazard			;	// register file unit	wire [`dw-1:0]		ID_reg_rs			,	EX_reg_rs			,								ID_reg_rt			,	EX_reg_rt			, MEM_reg_rt			;	wire [1:0]			ID_ctl_reg_dst		;	wire 				ID_ctl_reg_rt		,						ID_ctl_reg_write	, 	EX_ctl_reg_write	,	MEM_ctl_reg_write	,	WB_ctl_reg_write;	wire [2:0]			ID_ctl_execution_op	,	EX_ctl_execution_op	;	wire [4:0]			ID_mux_rd_index_out	,							ID_mux_rt_index_out	;	wire [`dw-1:0]		EX_result_operation	,	MEM_result_operation,						MEM_RegDatain		,	WB_RegDatain		;	wire				ID_clt_reg_src		,	EX_clt_reg_src		,	MEM_clt_reg_src		;		// shifter unit	wire				ID_ctl_shift_var	,	EX_ctl_shift_var, 						ID_ctl_shift_lr		,	EX_ctl_shift_lr	,						ID_ctl_shift_la		,	EX_ctl_shift_la	;	wire [`dw-1:0]		EX_shifter_out		;	wire [4:0]			EX_shifter_amount	;	// multiplication/division unit							wire				ID_ctl_multdiv_sign	,	EX_ctl_multdiv_sign	, 						ID_ctl_multdiv_op	,	EX_ctl_multdiv_op	,  						ID_ctl_multdiv_start,	EX_ctl_multdiv_start,						ID_ctl_multdiv_hiw	,	EX_ctl_multdiv_hiw	, 							ID_ctl_multdiv_low	,	EX_ctl_multdiv_low	; 	wire				EX_multdiv_ready	;	wire				wMultDiv_Interlock	;	wire [`dw-1:0]		EX_hi				,						EX_lo				;		// Memory bus interface		wire [1:0]			ID_ctl_mem_tail		,	EX_ctl_mem_tail	,	MEM_ctl_mem_tail	;  	wire				ID_ctl_mem_write	,	EX_ctl_mem_write,	MEM_ctl_mem_write	,						ID_ctl_mem_read		,	EX_ctl_mem_read	,	MEM_ctl_mem_read	,  						ID_ctl_mem_sign		,	EX_ctl_mem_sign	,	MEM_ctl_mem_sign	,  							ID_ctl_mem_oe		,	EX_ctl_mem_oe	,	MEM_ctl_mem_oe		;    		wire [`dw-1:0]		MemDataInterDin		,						MemDataInterDout	,						MemDataAddrInt		;		wire				MEM_MemDataBlew1	,						MEM_MemDataBler1	,						MEM_MemDataBhew1	,						MEM_MemDataBher1	,						MEM_MemDataBlew2	,						MEM_MemDataBler2	,						MEM_MemDataBhew2	,						MEM_MemDataBher2	;		// Pipeline Control	wire				EX_freeze			,	MEM_freeze		,	WB_freeze			;	wire				IFID_flush			,	IDEX_flush		,	EXMEM_flush			,	MEMWB_flush	;	wire				IF_stall			;	wire				IFID_stall			,	IDEX_stall		,	EXMEM_stall			,	MEMWB_stall	;	// co-processor 0	wire				ID_sig_clt_sys		,	EX_sig_clt_sys	,	MEM_sig_clt_sys		;	wire				ID_sig_clt_brk		,	EX_sig_clt_brk	,	MEM_sig_clt_brk		;	wire				ID_clt_rfe			,	EX_clt_rfe		,	MEM_clt_rfe			;	wire				ID_clt_CoMf			;	wire				ID_clt_CoMt			,	EX_clt_CoMt		,	MEM_clt_CoMt		;`ifdef	CP0	wire [`dw-1:0]		IF_EPC				,	ID_EPC			,	EX_EPC				,	MEM_EPC		;	reg	 [4:0]			IF_EXC				,	ID_EXC			,	EX_EXC				,	MEM_EXC		;	wire [`dw-1:0]		wEPC_Vector			;		wire 				EX_ovf				,						EX_Carry			,						EX_Zero				,						EX_Neg				;	wire 				EX_sig_ovf			,	MEM_sig_ovf		;	wire [5:0]			MEM_sig_int			;	wire [1:0]			MEM_sig_si			;		wire				wException			;	wire [`dw-1:0]		MEM_cp0_dout		;`endif	//CP0		/* --------------------------------------------------------------	instances, statements   ------------------- */   	/* ********************* */	/* PIPELINE CONTROL UNIT */	/* ********************* */	// ---------------------------------------------- //	// When (RAW hazard) or (mult/div interlock) or (I-cache miss)	then	=>	: stall[PC, IF/ID], flush[ID/EX]	// When (D-cache miss)											then	=>	: stall[PC, IF/ID, ID/EX, EX/MEM, MEM/WB], freeze[EX, MEM, WB]	// When (eXception)												then	=>	: 	// ---------------------------------------------- //	// STALL : stop do not update the pipe	// FLUSH : clear the pipe	// FREEZE : don't enable write to the unit	// ---------------------------------------------- //		r2000_pipe_ctrl	unit_pipe_ctrl	(		/* Input */		.d_cache_hit_i		(mem_data_hit_i),		.i_cache_hit_i		(mem_code_hit_i),				.Exception_i		(wException)	,		                    		.id_rs_i			(ID_rs_index)	,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -