TOPIC : Memory modeling

7
TOPIC : Memory modeling Module 4.1 : Memory modeling in Verilog

description

TOPIC : Memory modeling. Module 4.1 : Memory modeling in Verilog. Memories. In digital simulation, one often needs to model register files, RAMs, and ROMs. Memories are modeled in Verilog simply as an array of registers. - PowerPoint PPT Presentation

Transcript of TOPIC : Memory modeling

Page 1: TOPIC : Memory modeling

TOPIC : Memory modeling

Module 4.1 : Memory modeling in Verilog

Page 2: TOPIC : Memory modeling

In digital simulation, one often needs to model register files, RAMs, and ROMs. Memories are modeled in Verilog simply as an array of registers.

Each element of the array is known as a word. Each word can be one or more bits. It is important to differentiate between n 1-bit registers and one n-bit register.

A particular word in memory is obtained by using the address as a memory array subscript.

Memories

Page 3: TOPIC : Memory modeling

Different types and sizes of memory, register file, stack, etc., can be formed by extending the vector concept. Thus the declerationReg [15:0] memory[511:0];

Declared an array called memory; it has 512 locations. Each location is 16 bits wide. The value of any chosen location can be assigned to a selected register or vice-versa; this constitutes memory reading or writing. The index used to refer a memory location can be a number or an algebraic expression which reduces to an integral value – positive, zero, or negative.

B = mem[3] //data stored at mem[3] is assigned to B

Memory

Page 4: TOPIC : Memory modeling

Reg mem1bit[0:1023]//Memory mem1bit 1k 1-bit words.

Reg [7:0] membyte[0:1023];//Memory membyte with 1k 8-bit words (bytes)

Membyte [511]//Fetches 1 byte word address is 511.

Memory decleration

Page 5: TOPIC : Memory modeling

Verilog provides a very useful system task to initialize memories from a data file. Two tasks are provided to read numbers in binary or hexadecimal format. Keywords $readmemb and $readmemh are used to initialize memories :

Usage: ◦ $readmemb(“<file_name>”, <memory_name>);◦ $readmemb(“<file_name>”,<memory_name>,<s

tart_addr>,<finish_addr>);◦ NOTE : <start_addr>,<finish_addr> are optional.

Initialization Memory from file

Page 6: TOPIC : Memory modeling

Initializing memory example

Page 7: TOPIC : Memory modeling