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

📄 or1200_du.v

📁 LEON(sparc)微处理器的源代码
💻 V
📖 第 1 页 / 共 3 页
字号:
//////////////////////////////////////////////////////////////////////////                                                              ////////  OR1200's Debug Unit                                         ////////                                                              ////////  This file is part of the OpenRISC 1200 project              ////////  http://www.opencores.org/cores/or1k/                        ////////                                                              ////////  Description                                                 ////////  Basic OR1200 debug unit.                                    ////////                                                              ////////  To Do:                                                      ////////   - make it smaller and faster                               ////////                                                              ////////  Author(s):                                                  ////////      - Damjan Lampret, lampret@opencores.org                 ////////                                                              //////////////////////////////////////////////////////////////////////////////                                                              //////// Copyright (C) 2000 Authors 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                     ////////                                                              ////////////////////////////////////////////////////////////////////////////// CVS Revision History//// $Log: or1200_du.v,v $// Revision 1.12  2005/10/19 11:37:56  jcastillo// Added support for RAMB16 Xilinx4/Spartan3 primitives//// Revision 1.11  2005/01/07 09:35:08  andreje// du_hwbkpt disabled when debug unit not implemented//// Revision 1.10  2004/04/05 08:29:57  lampret// Merged branch_qmem into main tree.//// Revision 1.9.4.4  2004/02/11 01:40:11  lampret// preliminary HW breakpoints support in debug unit (by default disabled). To enable define OR1200_DU_HWBKPTS.//// Revision 1.9.4.3  2004/01/18 10:08:00  simons// Error fixed.//// Revision 1.9.4.2  2004/01/17 21:14:14  simons// Errors fixed.//// Revision 1.9.4.1  2004/01/15 06:46:38  markom// interface to debug changed; no more opselect; stb-ack protocol//// Revision 1.9  2003/01/22 03:23:47  lampret// Updated sensitivity list for trace buffer [only relevant for Xilinx FPGAs]//// Revision 1.8  2002/09/08 19:31:52  lampret// Fixed a typo, reported by Taylor Su.//// Revision 1.7  2002/07/14 22:17:17  lampret// Added simple trace buffer [only for Xilinx Virtex target]. Fixed instruction fetch abort when new exception is recognized.//// Revision 1.6  2002/03/14 00:30:24  lampret// Added alternative for critical path in DU.//// Revision 1.5  2002/02/11 04:33:17  lampret// Speed optimizations (removed duplicate _cyc_ and _stb_). Fixed D/IMMU cache-inhibit attr.//// Revision 1.4  2002/01/28 01:16:00  lampret// Changed 'void' nop-ops instead of insn[0] to use insn[16]. Debug unit stalls the tick timer. Prepared new flag generation for add and and insns. Blocked DC/IC while they are turned off. Fixed I/D MMU SPRs layout except WAYs. TODO: smart IC invalidate, l.j 2 and TLB ways.//// Revision 1.3  2002/01/18 07:56:00  lampret// No more low/high priority interrupts (PICPR removed). Added tick timer exception. Added exception prefix (SR[EPH]). Fixed single-step bug whenreading NPC.//// Revision 1.2  2002/01/14 06:18:22  lampret// Fixed mem2reg bug in FAST implementation. Updated debug unit to work with new genpc/if.//// Revision 1.1  2002/01/03 08:16:15  lampret// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.//// Revision 1.12  2001/11/30 18:58:00  simons// Trap insn couses break after exits ex_insn.//// Revision 1.11  2001/11/23 08:38:51  lampret// Changed DSR/DRR behavior and exception detection.//// Revision 1.10  2001/11/20 21:25:44  lampret// Fixed dbg_is_o assignment width.//// Revision 1.9  2001/11/20 18:46:14  simons// Break point bug fixed//// Revision 1.8  2001/11/18 08:36:28  lampret// For GDB changed single stepping and disabled trap exception.//// Revision 1.7  2001/10/21 18:09:53  lampret// Fixed sensitivity list.//// Revision 1.6  2001/10/14 13:12:09  lampret// MP3 version.////// synopsys translate_off`include "timescale.v"// synopsys translate_on`include "or1200_defines.v"//// Debug unit//module or1200_du(	// RISC Internal Interface	clk, rst,	dcpu_cycstb_i, dcpu_we_i, dcpu_adr_i, dcpu_dat_lsu,	dcpu_dat_dc, icpu_cycstb_i,	ex_freeze, branch_op, ex_insn, id_pc,	spr_dat_npc, rf_dataw,	du_dsr, du_stall, du_addr, du_dat_i, du_dat_o,	du_read, du_write, du_except, du_hwbkpt,	spr_cs, spr_write, spr_addr, spr_dat_i, spr_dat_o,	// External Debug Interface	dbg_stall_i, dbg_ewt_i,	dbg_lss_o, dbg_is_o, dbg_wp_o, dbg_bp_o,	dbg_stb_i, dbg_we_i, dbg_adr_i, dbg_dat_i, dbg_dat_o, dbg_ack_o);parameter dw = `OR1200_OPERAND_WIDTH;parameter aw = `OR1200_OPERAND_WIDTH;//// I/O////// RISC Internal Interface//input				clk;		// Clockinput				rst;		// Resetinput				dcpu_cycstb_i;	// LSU statusinput				dcpu_we_i;	// LSU statusinput	[31:0]			dcpu_adr_i;	// LSU addrinput	[31:0]			dcpu_dat_lsu;	// LSU store datainput	[31:0]			dcpu_dat_dc;	// LSU load datainput	[`OR1200_FETCHOP_WIDTH-1:0]	icpu_cycstb_i;	// IFETCH unit statusinput				ex_freeze;	// EX stage freezeinput	[`OR1200_BRANCHOP_WIDTH-1:0]	branch_op;	// Branch opinput	[dw-1:0]		ex_insn;	// EX insninput	[31:0]			id_pc;		// insn fetch EAinput	[31:0]			spr_dat_npc;	// Next PC (for trace)input	[31:0]			rf_dataw;	// ALU result (for trace)output	[`OR1200_DU_DSR_WIDTH-1:0]     du_dsr;		// DSRoutput				du_stall;	// Debug Unit Stalloutput	[aw-1:0]		du_addr;	// Debug Unit Addressinput	[dw-1:0]		du_dat_i;	// Debug Unit Data Inoutput	[dw-1:0]		du_dat_o;	// Debug Unit Data Outoutput				du_read;	// Debug Unit Read Enableoutput				du_write;	// Debug Unit Write Enableinput	[12:0]			du_except;	// Exception masked by DSRoutput				du_hwbkpt;	// Cause trap exception (HW Breakpoints)input				spr_cs;		// SPR Chip Selectinput				spr_write;	// SPR Read/Writeinput	[aw-1:0]		spr_addr;	// SPR Addressinput	[dw-1:0]		spr_dat_i;	// SPR Data Inputoutput	[dw-1:0]		spr_dat_o;	// SPR Data Output//// External Debug Interface//input			dbg_stall_i;	// External Stall Inputinput			dbg_ewt_i;	// External Watchpoint Trigger Inputoutput	[3:0]		dbg_lss_o;	// External Load/Store Unit Statusoutput	[1:0]		dbg_is_o;	// External Insn Fetch Statusoutput	[10:0]		dbg_wp_o;	// Watchpoints Outputsoutput			dbg_bp_o;	// Breakpoint Outputinput			dbg_stb_i;      // External Address/Data Strobeinput			dbg_we_i;       // External Write Enableinput	[aw-1:0]	dbg_adr_i;	// External Address Inputinput	[dw-1:0]	dbg_dat_i;	// External Data Inputoutput	[dw-1:0]	dbg_dat_o;	// External Data Outputoutput			dbg_ack_o;	// External Data Acknowledge (not WB compatible)//// Some connections go directly from the CPU through DU to Debug I/F//`ifdef OR1200_DU_STATUS_UNIMPLEMENTEDassign dbg_lss_o = 4'b0000;reg	[1:0]			dbg_is_o;//// Show insn activity (temp, must be removed)//always @(posedge clk or posedge rst)	if (rst)		dbg_is_o <= #1 2'b00;	else if (!ex_freeze &		~((ex_insn[31:26] == `OR1200_OR32_NOP) & ex_insn[16]))		dbg_is_o <= #1 ~dbg_is_o;`ifdef UNUSEDassign dbg_is_o = 2'b00;`endif`elseassign dbg_lss_o = dcpu_cycstb_i ? {dcpu_we_i, 3'b000} : 4'b0000;assign dbg_is_o = {1'b0, icpu_cycstb_i};`endifassign dbg_wp_o = 11'b000_0000_0000;assign dbg_dat_o = du_dat_i;//// Some connections go directly from Debug I/F through DU to the CPU//assign du_stall = dbg_stall_i;assign du_addr = dbg_adr_i;assign du_dat_o = dbg_dat_i;assign du_read = dbg_stb_i && !dbg_we_i;assign du_write = dbg_stb_i && dbg_we_i;//// Generate acknowledge -- just delay stb signal//reg dbg_ack_o;always @(posedge clk or posedge rst)	if (rst)		dbg_ack_o <= #1 1'b0;	else		dbg_ack_o <= #1 dbg_stb_i;`ifdef OR1200_DU_IMPLEMENTED//// Debug Mode Register 1//`ifdef OR1200_DU_DMR1reg	[24:0]			dmr1;		// DMR1 implemented`elsewire	[24:0]			dmr1;		// DMR1 not implemented`endif//// Debug Mode Register 2//`ifdef OR1200_DU_DMR2reg	[23:0]			dmr2;		// DMR2 implemented`elsewire	[23:0]			dmr2;		// DMR2 not implemented`endif//// Debug Stop Register//`ifdef OR1200_DU_DSRreg	[`OR1200_DU_DSR_WIDTH-1:0]	dsr;		// DSR implemented`elsewire	[`OR1200_DU_DSR_WIDTH-1:0]	dsr;		// DSR not implemented`endif//// Debug Reason Register//`ifdef OR1200_DU_DRRreg	[13:0]			drr;		// DRR implemented`elsewire	[13:0]			drr;		// DRR not implemented`endif//// Debug Value Register N//`ifdef OR1200_DU_DVR0reg	[31:0]			dvr0;`elsewire	[31:0]			dvr0;`endif//// Debug Value Register N//`ifdef OR1200_DU_DVR1reg	[31:0]			dvr1;`elsewire	[31:0]			dvr1;`endif//// Debug Value Register N//`ifdef OR1200_DU_DVR2reg	[31:0]			dvr2;`elsewire	[31:0]			dvr2;`endif//// Debug Value Register N//`ifdef OR1200_DU_DVR3reg	[31:0]			dvr3;`elsewire	[31:0]			dvr3;`endif//// Debug Value Register N//`ifdef OR1200_DU_DVR4reg	[31:0]			dvr4;`elsewire	[31:0]			dvr4;`endif//// Debug Value Register N//`ifdef OR1200_DU_DVR5reg	[31:0]			dvr5;`elsewire	[31:0]			dvr5;`endif//// Debug Value Register N//`ifdef OR1200_DU_DVR6reg	[31:0]			dvr6;`elsewire	[31:0]			dvr6;`endif//// Debug Value Register N//`ifdef OR1200_DU_DVR7reg	[31:0]			dvr7;`elsewire	[31:0]			dvr7;`endif//// Debug Control Register N//`ifdef OR1200_DU_DCR0reg	[7:0]			dcr0;`elsewire	[7:0]			dcr0;`endif//// Debug Control Register N//`ifdef OR1200_DU_DCR1reg	[7:0]			dcr1;`elsewire	[7:0]			dcr1;`endif//// Debug Control Register N//`ifdef OR1200_DU_DCR2reg	[7:0]			dcr2;`elsewire	[7:0]			dcr2;`endif//// Debug Control Register N//`ifdef OR1200_DU_DCR3reg	[7:0]			dcr3;`elsewire	[7:0]			dcr3;`endif//// Debug Control Register N//`ifdef OR1200_DU_DCR4reg	[7:0]			dcr4;`elsewire	[7:0]			dcr4;`endif//// Debug Control Register N//`ifdef OR1200_DU_DCR5reg	[7:0]			dcr5;`elsewire	[7:0]			dcr5;`endif//// Debug Control Register N//`ifdef OR1200_DU_DCR6reg	[7:0]			dcr6;`elsewire	[7:0]			dcr6;`endif//// Debug Control Register N//`ifdef OR1200_DU_DCR7reg	[7:0]			dcr7;`elsewire	[7:0]			dcr7;`endif//// Debug Watchpoint Counter Register 0//`ifdef OR1200_DU_DWCR0reg	[31:0]			dwcr0;`elsewire	[31:0]			dwcr0;`endif//// Debug Watchpoint Counter Register 1//`ifdef OR1200_DU_DWCR1reg	[31:0]			dwcr1;`elsewire	[31:0]			dwcr1;`endif//// Internal wires//wire				dmr1_sel; 	// DMR1 selectwire				dmr2_sel; 	// DMR2 selectwire				dsr_sel; 	// DSR selectwire				drr_sel; 	// DRR selectwire				dvr0_sel,				dvr1_sel,				dvr2_sel,				dvr3_sel,				dvr4_sel,				dvr5_sel,				dvr6_sel,				dvr7_sel; 	// DVR selectswire				dcr0_sel,				dcr1_sel,				dcr2_sel,				dcr3_sel,				dcr4_sel,				dcr5_sel,				dcr6_sel,				dcr7_sel; 	// DCR selectswire				dwcr0_sel,				dwcr1_sel; 	// DWCR selectsreg				dbg_bp_r;`ifdef OR1200_DU_HWBKPTSreg	[31:0]			match_cond0_ct;reg	[31:0]			match_cond1_ct;reg	[31:0]			match_cond2_ct;reg	[31:0]			match_cond3_ct;reg	[31:0]			match_cond4_ct;reg	[31:0]			match_cond5_ct;reg	[31:0]			match_cond6_ct;reg	[31:0]			match_cond7_ct;reg				match_cond0_stb;reg				match_cond1_stb;reg				match_cond2_stb;reg				match_cond3_stb;reg				match_cond4_stb;reg				match_cond5_stb;reg				match_cond6_stb;reg				match_cond7_stb;reg				match0;reg				match1;reg				match2;reg				match3;reg				match4;reg				match5;reg				match6;reg				match7;reg				wpcntr0_match;reg				wpcntr1_match;reg				incr_wpcntr0;reg				incr_wpcntr1;reg	[10:0]			wp;`endifwire				du_hwbkpt;`ifdef OR1200_DU_READREGSreg	[31:0]			spr_dat_o;`endifreg	[13:0]			except_stop;	// Exceptions that stop because of DSR`ifdef OR1200_DU_TB_IMPLEMENTEDwire				tb_enw;reg	[7:0]			tb_wadr;reg [31:0]			tb_timstmp;`endifwire	[31:0]			tbia_dat_o;wire	[31:0]			tbim_dat_o;wire	[31:0]			tbar_dat_o;wire	[31:0]			tbts_dat_o;//// DU registers address decoder//`ifdef OR1200_DU_DMR1assign dmr1_sel = (spr_cs && (spr_addr[`OR1200_DUOFS_BITS] == `OR1200_DU_DMR1));`endif`ifdef OR1200_DU_DMR2assign dmr2_sel = (spr_cs && (spr_addr[`OR1200_DUOFS_BITS] == `OR1200_DU_DMR2));`endif`ifdef OR1200_DU_DSRassign dsr_sel = (spr_cs && (spr_addr[`OR1200_DUOFS_BITS] == `OR1200_DU_DSR));`endif`ifdef OR1200_DU_DRRassign drr_sel = (spr_cs && (spr_addr[`OR1200_DUOFS_BITS] == `OR1200_DU_DRR));`endif`ifdef OR1200_DU_DVR0assign dvr0_sel = (spr_cs && (spr_addr[`OR1200_DUOFS_BITS] == `OR1200_DU_DVR0));`endif`ifdef OR1200_DU_DVR1assign dvr1_sel = (spr_cs && (spr_addr[`OR1200_DUOFS_BITS] == `OR1200_DU_DVR1));`endif`ifdef OR1200_DU_DVR2assign dvr2_sel = (spr_cs && (spr_addr[`OR1200_DUOFS_BITS] == `OR1200_DU_DVR2));`endif`ifdef OR1200_DU_DVR3assign dvr3_sel = (spr_cs && (spr_addr[`OR1200_DUOFS_BITS] == `OR1200_DU_DVR3));`endif`ifdef OR1200_DU_DVR4assign dvr4_sel = (spr_cs && (spr_addr[`OR1200_DUOFS_BITS] == `OR1200_DU_DVR4));`endif`ifdef OR1200_DU_DVR5assign dvr5_sel = (spr_cs && (spr_addr[`OR1200_DUOFS_BITS] == `OR1200_DU_DVR5));`endif`ifdef OR1200_DU_DVR6assign dvr6_sel = (spr_cs && (spr_addr[`OR1200_DUOFS_BITS] == `OR1200_DU_DVR6));`endif`ifdef OR1200_DU_DVR7assign dvr7_sel = (spr_cs && (spr_addr[`OR1200_DUOFS_BITS] == `OR1200_DU_DVR7));`endif`ifdef OR1200_DU_DCR0assign dcr0_sel = (spr_cs && (spr_addr[`OR1200_DUOFS_BITS] == `OR1200_DU_DCR0));`endif`ifdef OR1200_DU_DCR1assign dcr1_sel = (spr_cs && (spr_addr[`OR1200_DUOFS_BITS] == `OR1200_DU_DCR1));`endif`ifdef OR1200_DU_DCR2assign dcr2_sel = (spr_cs && (spr_addr[`OR1200_DUOFS_BITS] == `OR1200_DU_DCR2));`endif`ifdef OR1200_DU_DCR3assign dcr3_sel = (spr_cs && (spr_addr[`OR1200_DUOFS_BITS] == `OR1200_DU_DCR3));`endif`ifdef OR1200_DU_DCR4assign dcr4_sel = (spr_cs && (spr_addr[`OR1200_DUOFS_BITS] == `OR1200_DU_DCR4));`endif`ifdef OR1200_DU_DCR5assign dcr5_sel = (spr_cs && (spr_addr[`OR1200_DUOFS_BITS] == `OR1200_DU_DCR5));`endif`ifdef OR1200_DU_DCR6assign dcr6_sel = (spr_cs && (spr_addr[`OR1200_DUOFS_BITS] == `OR1200_DU_DCR6));`endif`ifdef OR1200_DU_DCR7assign dcr7_sel = (spr_cs && (spr_addr[`OR1200_DUOFS_BITS] == `OR1200_DU_DCR7));`endif`ifdef OR1200_DU_DWCR0assign dwcr0_sel = (spr_cs && (spr_addr[`OR1200_DUOFS_BITS] == `OR1200_DU_DWCR0));`endif`ifdef OR1200_DU_DWCR1assign dwcr1_sel = (spr_cs && (spr_addr[`OR1200_DUOFS_BITS] == `OR1200_DU_DWCR1));`endif//// Decode started exception//always @(du_except) begin	except_stop = 14'b0000_0000_0000;	casex (du_except)		13'b1_xxxx_xxxx_xxxx:			except_stop[`OR1200_DU_DRR_TTE] = 1'b1;		13'b0_1xxx_xxxx_xxxx: begin			except_stop[`OR1200_DU_DRR_IE] = 1'b1;		end		13'b0_01xx_xxxx_xxxx: begin			except_stop[`OR1200_DU_DRR_IME] = 1'b1;		end		13'b0_001x_xxxx_xxxx:			except_stop[`OR1200_DU_DRR_IPFE] = 1'b1;

⌨️ 快捷键说明

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