dr. oniga istván

10
Dr. Oniga István LOGIKAI TERVEZÉS HARDVERLEÍRÓ NYELVEN

Upload: arista

Post on 23-Feb-2016

60 views

Category:

Documents


0 download

DESCRIPTION

LOGIKAI TERVEZÉS HARDVERLEÍRÓ NYELVEN. Dr. Oniga István . Memory. In this chapter we will show how to implement memory on the Nexys-2 board by using the following six examples : Example 27 - A Verilog ROM Example 28 - Distributed RAM/ROM Example 29 - A Stack Example 30 - Block RAM - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Dr. Oniga István

Dr. Oniga István

LOGIKAI TERVEZÉS HARDVERLEÍRÓ NYELVEN

Page 2: Dr. Oniga István

MemoryIn this chapter we will show how to implement memory on the Nexys-2 board byusing the following six examples:

• Example 27 - A Verilog ROM• Example 28 - Distributed RAM/ROM• Example 29 - A Stack• Example 30 - Block RAM• Example 31 - External RAM• Example 32 - External Flash Memory

- Example 27 will show how to implement a small read-only memory (ROM) using Verilog.- For larger memories you can use the Core Generator to implement either distributed RAM (or

ROM) that uses the FPGA LUTs (Example 28) or Block RAM that uses the block RAM within the FPGA (Example 30).

- For even larger memories you can access the 16 Mbytes of external RAM (Example 31) or 16 Mbytes of external flash memory (Example 32), which are on the Nexys-2 board.

- Example 29 shows how to use distributed RAM to implement a stack.

Page 3: Dr. Oniga István

A Verilog ROM- 3-bit address bus, addr[2:0], 8-bit data bus M[7:0]- For example contents of the ROM at the address

addr[2:0] = 3'b1 10 is 'h6C

To implement this ROM in Verilog it is convenient to store the eight bytes as a single 64-bit hex constant as shown below

reg [N-l: O] rom [O:N_WORDS-l];

N is the number of bits per ROM word = 8The parameter N _ WORDS is the number of N-bit words in the ROM = 8

parameter data = ' h00C8F9AF64956CD4;

Page 4: Dr. Oniga István

A Verilog ROMmodule rom8 (input wire [2:0] addr ,output wire [7:0] M) ;parameter N = 8; // no. of bits in rom wordparameter N_WORDS = 8 ; //no. of words in romreg [N-1:0] rom [0:N_WORDS-l];parameter data = 'h00C8F9AF64956CD4;parameter IXLEFT = N*N_WORDS - 1; // left index of datainteger i;initial

beginfor(i=0; i<N_WORDS; i=i+l)

rom[i] = data[(IXLEFT-N*i)-:N];endassign M = rom[addr];endmodule

Part-selector operator: • “ - : “ separates the starting bit IXLEFT-N*I from the width (N) counting down • “ + : “ would define a width counting upFor i=1 => rom[1] = data[(63-8)-:8 = data[55-:8] = data[55:48] wich selects the byte C8

Page 5: Dr. Oniga István

A Verilog ROM simulation

Page 6: Dr. Oniga István

Distributed RAM/ROMCore Generator:

Page 7: Dr. Oniga István

Distributed RAM/ROMCore Generator:

Page 8: Dr. Oniga István

Distributed RAM/ROMThe content of the ROM can be defined using a .coe file with the format:

; Example 28 Initialization file for a 16x8 distributed ROMmemory_initialization_radix = 16;memory_initialization_vector =0 C8 F9 AF64 95 6C D439 E7 5A 9684 37 28 4C;

Page 9: Dr. Oniga István

Distributed RAM/ROMThe component dist_rom16 will be created and all files will be generated.

Page 10: Dr. Oniga István

Distributed RAM/ROM simulation