当前位置:首页 > 代码 > 正文

cacheverilog代码(cache verilog)

admin 发布:2022-12-19 22:44 137


本篇文章给大家谈谈cacheverilog代码,以及cache verilog对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

这段verilog代码为什么cache里面赋不了值,在modelsim里面是红线,难道因为是input就不能给其他赋值了吗

cache都是reg类型的,reg类型的都要驱动才能赋值,你用wire试试,前面加assign 如assign cache4={addr,insmem0};

verilog 代码问题

module clock(

input clk_50m,

output clk_2Hz

);

reg clk = 0;

reg [24:0] count = 0;

always @(clk_50m)

begin

if(count==25000000) begin clk = ~clk; count = 0; end

else begin count = count + 1; end

end

assign clk_2Hz = clk;

endmodule

这样应该没问题了,欢迎追问~~(从警告上来看,貌似你之前把clk_2Hz搞成input了)

verilog 代码修改

生成ip核后在相应工程文件夹下找到ip文件夹,里面的.v文件就是其代码。

求cache的verilog代码

/* $Author: karu $ */

/* $LastChangedDate: 2009-03-04 23:09:45 -0600 (Wed, 04 Mar 2009) $ */

/* $Rev: 45 $ */

//

// Cache module for CS/ECE 552 Project

// Written by Andy Phelps

// 4 May 2006

//

// Modified by Derek Hower

// 30 Oct 2006

// Changed to 4-word lines, byte addressable

//

// See the documentation on the class web page.

// Although this module has been tested, it is not guaranteed to work.

// Please report errors to the TA.

//

module cache (

input enable,

input clk,

input rst,

input createdump,

input [4:0] tag_in,

input [7:0] index,

input [2:0] offset,

input [15:0] data_in,

input comp,

input write,

input valid_in,

output [4:0] tag_out,

output [15:0] data_out,

output hit,

output dirty,

output valid,

output err

);

parameter cache_id = 0; // overridden for each cache instance

wire [4:0] ram0_id = (cache_id3) + 0; // These allow each memory to create a unique dump file

wire [4:0] ram1_id = (cache_id3) + 1;

wire [4:0] ram2_id = (cache_id3) + 2;

wire [4:0] ram3_id = (cache_id3) + 3;

wire [4:0] ram4_id = (cache_id3) + 4;

wire [4:0] ram5_id = (cache_id3) + 5;

wire [15:0] w0, w1, w2, w3;

assign go = enable ~rst;

assign match = (tag_in == tag_out);

assign err = offset[0]; //word aligned; odd address is invalid

assign wr_word0 = go write ~offset[2] ~offset[1] (match | ~comp);

assign wr_word1 = go write ~offset[2] offset[1] (match | ~comp);

assign wr_word2 = go write offset[2] ~offset[1] (match | ~comp);

assign wr_word3 = go write offset[2] offset[1] (match | ~comp);

assign wr_dirty = go write (match | ~comp);

assign wr_tag = go write ~comp;

assign wr_valid = go write ~comp;

assign dirty_in = comp; // a compare-and-write sets dirty; a cache-fill clears it

memc #(16) mem_w0 (w0, index, data_in, wr_word0, clk, rst, createdump, ram0_id);

memc #(16) mem_w1 (w1, index, data_in, wr_word1, clk, rst, createdump, ram1_id);

memc #(16) mem_w2 (w2, index, data_in, wr_word2, clk, rst, createdump, ram2_id);

memc #(16) mem_w3 (w3, index, data_in, wr_word3, clk, rst, createdump, ram3_id);

memc #( 5) mem_tg (tag_out, index, tag_in, wr_tag, clk, rst, createdump, ram4_id);

memc #( 1) mem_dr (dirtybit,index, dirty_in, wr_dirty, clk, rst, createdump, ram5_id);

memv mem_vl (validbit,index, valid_in, wr_valid, clk, rst, createdump, ram0_id);

assign hit = go match;

assign dirty = go (~write | (comp ~match)) dirtybit;

assign data_out = (write | ~go)? 16'h0000 :

offset[2] ? (offset[1] ? w3 : w2) : (offset[1] ? w1 : w0) ;

assign valid = go validbit (~write | comp);

endmodule

怎样快速看懂一个较大的verilog模块代码

读懂一个Verilog工程代码主要通过以下方面:1、区分好结构,一个工程是由基本的顶层、模块、约束等部分组成的,通常模块都是在顶层中逐一实例化,所以,了解一个工程的结构就是从顶层逐一向下延伸,相当于植物的根系,最底层的模块往往是被“引用”最多的,也是最基础的构成。2、通过代码注释来辅助阅读,一段好的代码必须有70%~80%的注释,方便进行工作交接,以及多人讨论。重点通过代码结合注释,看懂工程师的意图,查找设计不严谨的地方。3、verilog代码实际上就是在画电路图,是一种硬件描述语言,在读代码的同时,头脑中要有电路的概念,知道电路的大概结构是什么样的,每个模块的扇入扇出等。当然,最基本的还是对语法和原理要有较好的基础,否则,很难看懂一些大规模的电路描述。

关于cacheverilog代码和cache verilog的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/28292.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载