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

📄 icache.v

📁 arm10-behavioral的行为仿真代码verilogHDL
💻 V
字号:
/*****************************************************************************$RCSfile: icache.v,v $$Revision: 1.17 $$Author: kohlere $$Date: 2000/04/16 19:32:28 $$State: Exp $$Source: /home/lefurgy/tmp/ISC-repository/isc/hardware/ARM10/behavioral/pipelined/icache.v,v $Description:  I-Cache Controller Unit for the ARM Microprocessor.  This	provides the next 3 instruction to the ARM fetch unit.  When a 	miss is triggered, it accepts the data from the MMD and a signal	from MMU indicating the arrival of data.	Notes: Tag = D,V,tag*****************************************************************************/`timescale 1ns/10ps`include "pardef.v"module icache (nGCLK, nRESET, IA, ID, InMREQ, MMD, mmd_valid, IABORT,		dmiss, imiss_addr, imiss, doublehold, newline, DABORT,		useMini, swic, swic_addr, swic_data, initializing);/*------------------------------------------------------------------------        Ports------------------------------------------------------------------------*/input   [31:0]  IA;             //Instruction Address Businput	[31:0]	swic_data;	//SWIC Word to Storeinput	[31:2]	swic_addr;	//SWIC Addr to Storeinput		nGCLK;		//Global Clockinput		nRESET;		//Global Resetinput		InMREQ;		//Not Instruction Memory Requestinput		IABORT;		//Instruction ABORT (no Miss)input		DABORT;		//Data Access ABORTinput		mmd_valid;	//MMD is Valid, Increment Counterinput		dmiss;		//DCache Missinput		doublehold;	//Hold Cycle for Double Loadinput		newline;	//New Line Requiredinput		useMini;	//Use Small Lock-Down Cacheinput		swic;		//SWIC Requestedinput	[31:0]	MMD;		//Main Memory Data Busoutput	[95:0]	ID;		//Instruction Data Busoutput	[31:0]	imiss_addr;	//Miss Addr to MMUoutput		imiss;		//Instruction Cache Missoutput		initializing;	//Initializing Tag Ram/*------------------------------------------------------------------------        Signal Declarations------------------------------------------------------------------------*/reg	[`ILS-1:0] next_line;		//Next Value for Buffer on Missreg	[`ILS-1:0] line_mux;		//Mux Between Cache Linesreg	[`ILS-1:0] din_cache;		//Store Multiplexorreg	[95:0]	ID;			//Instruction Data Busreg	[31:0]	swic_d;			//Latched SWIC Datareg	[31:2]	swic_a;			//Latched SWIC Addrreg	[`ITS-1:0] din_tag;		//Mux Between Tag and SWICreg	[`IPSH+1:0] page_sel;		//Page Select Bits (V,tag)reg	[`ILSS-1:0] line_sel;		//Line Select Bitsreg	[15:0]	miniwarm;		//Line Present Bit Vector for Minireg	[15:0]	nextminiwarm;		//Next Bit Vectorreg	[2:0]	word_sel;		//Word Select Bitsreg	[2:0]	load_word;		//Which word?reg		swic_store;		//Store Enable for SWICreg		nMiss_active;		//Miss is Active (active_low)wire		imiss;			//Cache Missreg		minihit;		//Hit In the Mini Cachereg		init_on;		//Initialization in Progressreg		access;			//Accessing Ramwire	[`ILS-1:0] cache_line;		//Line In Cache (Read Port)wire	[`ILS-1:0] miniline;		//Line in Cache (Read Port)wire	[31:0]	imiss_addr;		//Address of Misswire	[`ITS-1:0] tag_line;		//Tagwire	[`IPSH+1:0] cache_tag;		//Cache V,Tagwire    [`ILSS-1:0] ls_mux;             //Mux Between Line and SWICwire	[3:0] 	inc_loadword;		//Incremented Line Selectwire		wr_ena_c;		//Write Enable to I$wire		wr_ena_t;		//Write Enable to Tag$wire		wrmini_ena;		//Write Enable to MiniCachewire		wrmini_t;		//Write Enable to MiniTagwire		initializing;		//Initializing Tag Ramwire		init_done;		//Done/*------------------------------------------------------------------------        Memory Declarations------------------------------------------------------------------------*/ram #(`ILSS, `INL) xicache (.nGCLK(nGCLK), .write_sel(ls_mux),		.read_sel(ls_mux), .write_port(din_cache),		.read_port(cache_line), .wr_ena(wr_ena_c));tag #(`INL, `ILSS, `ILSH, `IPSL, `ITS) xitag (.nGCLK(nGCLK),		.write_sel(ls_mux), .read_sel(ls_mux),		.write_port(din_tag), .read_port(tag_line),		.wr_ena(wr_ena_t));/* Mini Cache, 16 Lines Deep */miniram xmini (.nGCLK(nGCLK), .write_sel(line_sel[3:0]), 		.read_sel(line_sel[3:0]), .write_port(next_line),		.read_port(miniline), .wr_ena(wrmini_ena));/*------------------------------------------------------------------------        Signal Assignments------------------------------------------------------------------------*/assign cache_tag = tag_line[`IPSH+1:0];assign imiss_addr = {page_sel[`IPSH:0],line_sel,5'h00};assign wr_ena_c = ((mmd_valid) & ~useMini) | swic_store;assign wr_ena_t = ((load_word == 3'h7) & ~useMini) | swic_store | init_on;assign wrmini_t = (load_word == 3'h7 & useMini);assign wrmini_ena = (mmd_valid) & useMini;assign wrmini_t = ((load_word == 3'h7) & useMini);assign ls_mux = (swic_store) ? swic_a[`ILSH:5] : line_sel;assign init_done = (& line_sel);assign initializing = init_on & !init_done;assign imiss = ((cache_tag != page_sel) & ~useMini & ~init_on & ~DABORT) |(useMini&~minihit);/*------------------------------------------------------------------------        Combinational Always Block------------------------------------------------------------------------*///Mux out the Proper Words to the Processoralways @(word_sel or line_mux or IABORT or DABORT)  begin    if (IABORT | DABORT) //Move PC to Link Register      ID <= #1 96'he1a0e00fe1a0e00fe1a0e00f;    else      begin        case (word_sel) //synopsys full_case parallel_case          3'b000: ID <= #1 line_mux[95:0];          3'b001: ID <= #1 line_mux[127:32];          3'b010: ID <= #1 line_mux[159:64];          3'b011: ID <= #1 line_mux[191:96];          3'b100: ID <= #1 line_mux[223:128];          3'b101: ID <= #1 line_mux[255:160];          3'b110: ID <= #1 {32'h0,line_mux[255:192]};          3'b111: ID <= #1 {64'h0,line_mux[255:224]};        endcase      end  end//Mux Out the Proper Tag to Storealways @(swic_store or swic_a or tag_line or init_on or load_word		or page_sel)  begin    if (swic_store)      din_tag <= {2'b01, swic_a[31:`IPSL]};    else      begin	if (init_on)          din_tag <= {`DTS{1'b0}};	else if (load_word == 3'h7)	  din_tag <= {1'b0, page_sel};	else	  din_tag <= tag_line;      end  end//Mux Out the Proper Word to the I$ for SWICalways @(next_line or swic_store or swic_d or cache_line or swic_a)  begin    if (swic_store)      begin        case(swic_a[4:2])          3'h0: din_cache = {cache_line[255:32],swic_d};          3'h1: din_cache = {cache_line[255:64],swic_d,cache_line[31:0]};	  3'h2: din_cache = {cache_line[255:96],swic_d,cache_line[63:0]};          3'h3: din_cache = {cache_line[255:128],swic_d,cache_line[95:0]};          3'h4: din_cache = {cache_line[255:160],swic_d,cache_line[127:0]};          3'h5: din_cache = {cache_line[255:192],swic_d,cache_line[159:0]};          3'h6: din_cache = {cache_line[255:224],swic_d,cache_line[191:0]};          3'h7: din_cache = {swic_d,cache_line[223:0]};        endcase      end    else      din_cache = next_line;  end//Determine what to put in the line buffer on a missalways @(load_word or line_mux or MMD)  begin    case (load_word) //synopsys full_case parallel_case      3'h0: next_line = {line_mux[255:32], MMD};      3'h1: next_line = {line_mux[255:64], MMD, line_mux[31:0]};      3'h2: next_line = {line_mux[255:96], MMD, line_mux[63:0]};      3'h3: next_line = {line_mux[255:128], MMD, line_mux[95:0]};      3'h4: next_line = {line_mux[255:160], MMD, line_mux[127:0]};      3'h5: next_line = {line_mux[255:192], MMD, line_mux[159:0]};      3'h6: next_line = {line_mux[255:224], MMD, line_mux[191:0]};      3'h7: next_line = {MMD, line_mux[223:0]};    endcase  end//Determine what to Put into Bit Vectoralways @(miniwarm or line_sel)  begin    case(line_sel[3:0])  //synopsys full_case parallel_case      4'h0: nextminiwarm = miniwarm | {16'h0001};      4'h1: nextminiwarm = miniwarm | {16'h0002};      4'h2: nextminiwarm = miniwarm | {16'h0004};      4'h3: nextminiwarm = miniwarm | {16'h0008};      4'h4: nextminiwarm = miniwarm | {16'h0010};      4'h5: nextminiwarm = miniwarm | {16'h0020};      4'h6: nextminiwarm = miniwarm | {16'h0040};      4'h7: nextminiwarm = miniwarm | {16'h0080};      4'h8: nextminiwarm = miniwarm | {16'h0100};      4'h9: nextminiwarm = miniwarm | {16'h0200};      4'hA: nextminiwarm = miniwarm | {16'h0400};      4'hB: nextminiwarm = miniwarm | {16'h0800};      4'hC: nextminiwarm = miniwarm | {16'h1000};      4'hD: nextminiwarm = miniwarm | {16'h2000};      4'hE: nextminiwarm = miniwarm | {16'h4000};      4'hF: nextminiwarm = miniwarm | {16'h8000};    endcase  end//Check for MiniCache Hitalways @(miniwarm or line_sel)  begin    case(line_sel[3:0])      4'h0: minihit = miniwarm[0];      4'h1: minihit = miniwarm[1];      4'h2: minihit = miniwarm[2];      4'h3: minihit = miniwarm[3];      4'h4: minihit = miniwarm[4];      4'h5: minihit = miniwarm[5];      4'h6: minihit = miniwarm[6];      4'h7: minihit = miniwarm[7];      4'h8: minihit = miniwarm[8];      4'h9: minihit = miniwarm[9];      4'hA: minihit = miniwarm[10];      4'hB: minihit = miniwarm[11];      4'hC: minihit = miniwarm[12];      4'hD: minihit = miniwarm[13];      4'hE: minihit = miniwarm[14];      4'hF: minihit = miniwarm[15];    endcase  endalways @(useMini or cache_line or miniline)  begin    if (useMini)      line_mux <= miniline;    else      line_mux <= cache_line;  end/*------------------------------------------------------------------------        Sequential Always Block------------------------------------------------------------------------*///Catch the reset and initialize the tag ramalways @(posedge nGCLK or negedge nRESET)  begin    if (~nRESET)      init_on <= 1'b1;    else if (init_done)      init_on <= 1'b0;  end//Latch the Address Bits to Appropriate Regswire nNewread = ~(((~InMREQ & newline) | init_on) & nMiss_active & ~dmiss & ~doublehold);always @(posedge nGCLK or negedge nRESET)  begin    if (~nRESET)      begin        page_sel <= {`IPSH+2{1'b0}};        line_sel <= {`DTS{1'b0}};      end    else if (~nNewread | init_on | DABORT)      begin	page_sel <= #1 {1'b1, IA[31:`IPSL]};	line_sel <= #1 (init_on) ? (line_sel + 1) : IA[`ILSH:5];      end  endalways @(posedge nGCLK)  begin    if ((~InMREQ & nMiss_active & ~dmiss & ~doublehold) | DABORT)      begin        word_sel <= #1 IA[4:2];      end  end//Latch the Busses for SWIC Instructionsalways @(posedge nGCLK or negedge nRESET)  begin    if (~nRESET)      begin        swic_d <= 32'h0;        swic_a <= 30'h0;      end    else if (swic)      begin        swic_d <= swic_data;        swic_a <= swic_addr;      end  end//Latch the SWIC signalalways @(posedge nGCLK or negedge nRESET)  begin    if (~nRESET)      swic_store <= 1'b0;    else      swic_store <= swic;  end//Stall the Processor on a cache miss//synopsys async_set_reset "nRESET"always @(nGCLK or imiss or nRESET or IABORT)  begin    if (!nRESET)      nMiss_active <= #1 1'b1;    else if (~nGCLK)      nMiss_active <= #1 ~(imiss & ~IABORT);  end//Cache Miss Word Load Count//synopsys async_set_reset "nRESET"wire [2:0] temp_ldw;assign inc_loadword = load_word + 1;nb1s2 xbuf1 (.DIN(inc_loadword[0]), .Q(temp_ldw[0]));nb1s2 xbuf2 (.DIN(inc_loadword[1]), .Q(temp_ldw[1]));nb1s2 xbuf3 (.DIN(inc_loadword[2]), .Q(temp_ldw[2]));always @(posedge nGCLK or negedge nRESET)  begin    if (~nRESET)      load_word <= #1 3'h0;    else if (~nMiss_active & mmd_valid)      load_word <= #1 temp_ldw;    else      load_word <= #1 3'h0;  end//Store Which Lines are Valid in the Mini-Cachealways @(posedge nGCLK or negedge nRESET)  begin    if (~nRESET)      miniwarm <= 16'h0;    else if (wrmini_t)      miniwarm <= nextminiwarm;  endendmodule

⌨️ 快捷键说明

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