当前位置:网站首页>Verilog 每日一题 (VL30 RAM的简单实现)
Verilog 每日一题 (VL30 RAM的简单实现)
2022-07-28 16:23:00 【别再出error了】
题目描述:
实现一个深度为256,位宽为4bit的双端口RAM,数据全部初始化为0000。具有两组端口,分别用于读数据和写数据,读写操作可以同时进行。当读数据指示信号read_en有效时,通过读地址信号read_addr读取相应位置的数据read_data,并输出;当写数据指示信号write_en有效时,通过写地址信号write_addr 和写数据write-data,向对应位置写入相应的数据。
程序的信号接口图如下:

`timescale 1ns/1ns
module ram_mod(
input clk,
input rst_n,
input write_en,
input [7:0]write_addr,
input [3:0]write_data,
input read_en,
input [7:0]read_addr, //地址宽度取log2(256)-1 = 7.
output reg [3:0]read_data
);
//写入数据,深度为256,可储存2^8=256个数据,声明数组array
reg [3:0] array [255:0];
integer i;
always @(posedge clk or negedge rst_n) begin
if(!rst_n) begin
for(i=0;i<=255;i=i+1)
array[i] = 0; //全部置零
end
else
array[write_addr] =(write_en)? write_data:array[write_addr];
//根据是能信号write_en,来对输入地址和数据进行声明(我的理解是定义一个指针)
end
//进行读操作,
reg [3:0] data;
always @(posedge clk or negedge rst_n) begin
if(!rst_n) read_data = 0; //异步置零
else read_data =(read_en)? array[read_addr]:read_data;
//使能信号为1时才进行读操作
end
endmodule//有空要复习一下数电里RAM这一部分的细节

边栏推荐
- Round 1A 2022 - Code jam 2022 c.weightlifting (interval DP)
- The 16th program design competition of Dalian University of Technology (Problem Solver)
- wpf命令按钮透明样式
- Hikvision responded to the impact of the 'US ban': there are options for the components currently used
- 3D modeling tool Archicad 26 newly released
- PostgreSQL weekly news - July 20, 2022
- 零基础利用Unity3D开发AR应用并远程下载3D模型
- Cf/atc/lc topic score website
- Ugui learning notes (III) summary of the use of each control
- MySQL installation tutorial
猜你喜欢

22年多校第三场(F的证明

How to protect image security during construction

The practice of beego framework developed by goweb: Section 4 database configuration and connection

Why do I choose to use go language?

Visual Studio 2012/2015发布Web应用连同.cs源码一起发布

Goweb开发之Beego框架实战:第二节 项目初始化配置

Unity shader cartoon style rendering

Games101 assignment04 job 04

How do we do full link grayscale on the database?

MySQL installation tutorial
随机推荐
Some attention code explanations
Unity3d simple implementation of water surface shader
Comprehensively design an oppe homepage -- after sales service of the page
The 16th program design competition of Dalian University of Technology (Problem Solver)
The longest substring of sword finger offer without repeated characters
线性代数及矩阵论(十)
Pytorch Foundation: similarities and differences between torch.mul, torch.mm and torch.matmul
微信小程序现金红包返回“IP地址非你在商户平台设置的可用IP地址”错误终极解决方法
Huawei mate 40 series exposure: large curvature hyperboloid screen, 5nm kylin 1020 processor! There will also be a version of Tianji 1000+
Source code of voice live broadcast app
Goweb开发之Beego框架实战:第二节 项目初始化配置
Goweb开发之Beego框架实战:第一节 Beego框架介绍
Fine-grained Fact Verification with Kernel GA Network
Unity editor learning (I) using features to change the display of fields in components
Goweb开发之Beego框架实战:第三节 程序执行流程分析
Unity shader cartoon style rendering
Net framework
Facet experience -- the development side of dragon game client
Janus series article 3 API usage guide videoroom creating a new video room
Round 1A 2022 - Code jam 2022 c.weightlifting (interval DP)