Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)

Using RAM for register

Altera_Forum
Honored Contributor II
1,472 Views

Hello everyone. 

I'm testing the examples of “Embedded SoPC design...” by Pong P. Chu. In the code below Ineed the table to be located in RAM. After compilation the memory usage is zero. What did I do wrong? 

Thanks. 

Tool: Quartus II 13.0.1 

Device: Cyclone II (EP2C5T144C6) 

 

 

module adder (a, b, data, clk); input a, b; output data; input clk; reg data_reg; (* ramstyle = "M4K" *) reg rom_data; wire addr; always @(posedge clk) data_reg <= rom_data; always @* begin case (addr) 8'b00000000 : rom_data <= 4'b0000; 8'b00000001 : rom_data <= 4'b0001; 8'b00000010 : rom_data <= 4'b0010; ................................ 8'b11111101 : rom_data <= 4'b1100; 8'b11111110 : rom_data <= 4'b1101; endcase end assign data = data_reg; assign addr = {a, b}; endmodule
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
508 Views

You didn't create a rom, you created an address decoder as the rom_data variable is only big enough for a single value. It needs to be an array of 256 values ask set on the init block, with the address selecting the correct value. 

 

reg rom_data Initial foreach(rom_data) rom_data = i; Always @(posedge clk) data <= rom_data;
0 Kudos
Altera_Forum
Honored Contributor II
508 Views

Thank you for the answer. But why can't I use this technique? http://quartushelp.altera.com/15.0/mergedprojects/hdl/vlog/vlog_file_dir_romstyle.htm

0 Kudos
Altera_Forum
Honored Contributor II
508 Views

There is the difference that the quartus design is clocked - yours is not. To go into a ram, you need an output data register.

0 Kudos
Altera_Forum
Honored Contributor II
508 Views

I recommend you go to the template option in the Quartus mens (under edit I think) and look at the ROM and RAM templates, they show you exactly what to type and you can just click the insert button to have the RTL dropped in directly.

0 Kudos
Reply