verilog设计8x8位ROM

一 设计思路

  1. 采用组合逻辑电路,设计掩膜式只读存储器(Mask ROM)(在制造时写入内容,以后只能读,不能写入)。
  2. 3位地址线([2:0] addr):可以实现8个存储单元(字)的寻址,8个地址及其存储的8位数据的真值表如下(下表中各地址存储的数据D是地址addr的2倍):
addr2addr1addr0D7D6D5D4D3D2D1D0
00000000000
00100000010
01000000100
01100000110
10000001000
10100001010
11000001100
11100001110
  1. 8位数据输出端([7:0] data_out)
  2. 读控制输入端R,低电平有效,R为1时输出为高阻态。
    若读控制输入端(R)为低电平,则将3位地址线([2:0] addr)寻址到的ROM单元([7:0] rom[0:7])中的数据送到输出端([7:0] data_out),否则输出高阻态。

二 verilog代码

(一)程序代码变量说明

input R, // 读控制输入端,低电平有效
input [2:0] addr, // 3位地址线
output [7:0] data_out // 8位数据输出端

wire [7:0] rom[0:7];

(二)程序代码

软件:Quartus II 9.0

module ROM(
	input R,
	input [2:0] addr,
	output [7:0] data_out);
	
	wire [7:0] rom[0:7];
	
	assign rom[0] = 8'b0;
	assign rom[1] = 8'b00000010;
	assign rom[2] = 8'b00000100;
	assign rom[3] = 8'b00000110;
	assign rom[4] = 8'b00001000;
	assign rom[5] = 8'b00001010;
	assign rom[6] = 8'b00001100;
	assign rom[7] = 8'b00001110;
	
	assign data_out = !R ? rom[addr] : 8'bz;
endmodule

(三)时序模拟图

在这里插入图片描述
读控制端R为1时,输出data_out为高阻态。
读控制端R为0时,依次输出第0-7个地址对应的rom中的数据。

  • 0
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Verilog ROM (Read-Only Memory) is a hardware construct used in digital circuit design. It is a memory module that stores data permanently and can only be read, hence the name "read-only." In Verilog, ROMs are typically implemented using lookup tables (LUTs) or case statements. To create a Verilog ROM, you can define a memory array a specific size and initialize it with the desired data values. Here's an example of a simple 8-bit ROM with 4 memory locations: ```verilog module ROM_example ( input [1:0] address, output reg [7:0] data ); reg [7:0] memory [0:3]; initial begin memory[0] = 8'b00000000; memory[1] = 8'b00000001; memory[2] = 8'b00000010; memory[3] = 8'b00000011; end always @(*) begin case (address) 2'b00: data = memory[0]; 2'b01: data = memory[1]; 2'b10: data = memory[2]; 2'b11: data = memory[3]; endcase end endmodule ``` In this example, the module `ROM_example` has an input `address` which specifies the memory location to read from, and an output `data` which holds the value stored at that location. The memory array `memory` is defined using the `reg` data type, and it is initialized with specific values in the `initial` block. Inside the `always` block, a `case` statement is used to select the appropriate memory location based on the input `address`. The corresponding data value is then assigned to the output `data`. Keep in mind that this is a basic example, and in real-world designs, ROMs can have different sizes, data widths, and initialization methods depending on the specific requirements.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值