ROM stands for Read-Only Memory. It is a memory block where data is stored permanently and cannot be changed during simulation or operation.
Click to reveal answer
beginner
How do you declare a ROM in Verilog?
You declare ROM as a reg array with fixed values assigned at initialization, for example: reg [7:0] rom [0:15]; Then you assign values inside an initial block.
Click to reveal answer
beginner
Why use an initial block for ROM in Verilog?
The initial block sets the fixed data values in ROM at the start of simulation. Since ROM data doesn't change, this block loads the data once.
Click to reveal answer
intermediate
How do you read data from ROM in Verilog?
You use the address input to index the ROM array and output the stored data, usually in a combinational always block or continuous assignment.
Click to reveal answer
beginner
Can ROM contents be changed during simulation?
No, ROM contents are fixed and cannot be changed during simulation or operation. They are read-only.
Click to reveal answer
What does ROM stand for in Verilog?
ARandom-Only Memory
BRead-Only Memory
CRead-Operate Memory
DRegister-Only Memory
✗ Incorrect
ROM means Read-Only Memory, which stores fixed data.
How do you initialize ROM data in Verilog?
AUsing a function
BUsing always @(posedge clk)
CUsing an initial block
DUsing a task
✗ Incorrect
ROM data is set once at the start using an initial block.
Which Verilog data type is commonly used to declare ROM?
Areg array
Breal
Cinteger
Dwire
✗ Incorrect
ROM is declared as a reg array to hold multiple data values.
Can ROM contents be modified during simulation?
ANo, they are fixed
BYes, anytime
COnly during reset
DOnly with special commands
✗ Incorrect
ROM contents are fixed and cannot be changed during simulation.
How do you access data stored in ROM?
ABy writing to the ROM address
BBy resetting the ROM
CBy enabling the ROM write signal
DBy reading from the ROM address
✗ Incorrect
You read data from ROM by providing an address to access stored data.
Explain how to create a simple ROM in Verilog and how to read data from it.
Think about how you store fixed data and then use an address to get that data.
You got /4 concepts.
Why is ROM called 'read-only' and what does that mean in Verilog simulation?
Consider what 'read-only' means in everyday life and how it applies here.
You got /3 concepts.
Practice
(1/5)
1. What is the primary purpose of a ROM (Read-Only Memory) in Verilog?
easy
A. To store fixed data that cannot be changed during simulation or operation
B. To store data that can be written and read dynamically
C. To perform arithmetic operations
D. To generate clock signals
Solution
Step 1: Understand ROM functionality
ROM is designed to hold data that is fixed and cannot be modified during operation.
Step 2: Compare with other memory types
Unlike RAM, ROM data is read-only and does not support writing during runtime.
Final Answer:
To store fixed data that cannot be changed during simulation or operation -> Option A
Quick Check:
ROM = fixed data storage [OK]
Hint: ROM stores fixed data only, no writes allowed [OK]
Common Mistakes:
Confusing ROM with RAM (read-write memory)
Thinking ROM can perform operations
Assuming ROM generates signals
2. Which of the following is the correct way to declare a ROM using an array and initial block in Verilog?
easy
A. integer rom_mem; always @(posedge clk) rom_mem = 8'hAA;
5. You want to implement a 4-word ROM in Verilog that outputs the square of the address value (0, 1, 4, 9). Which of the following code snippets correctly implements this ROM?
hard
A. always @(addr) begin case(addr) 2'b00: data_out=8'd0; 2'b01: data_out=8'd1; 2'b10: data_out=8'd4; 2'b11: data_out=8'd9; default: data_out=8'd0; endcase end
B. reg [7:0] rom [0:3]; initial begin rom[0]=8'd0; rom[1]=8'd1; rom[2]=8'd4; rom[3]=8'd9; end always data_out = rom[addr];
C. reg [7:0] rom [0:3]; assign rom[0]=0; assign rom[1]=1; assign rom[2]=4; assign rom[3]=9; assign data_out=rom[addr];
D. reg [7:0] rom [0:3]; always @(posedge clk) begin rom[0]<=0; rom[1]<=1; rom[2]<=4; rom[3]<=9; end assign data_out=rom[addr];
Solution
Step 1: Analyze each code snippet for ROM implementation
reg [7:0] rom [0:3]; initial begin rom[0]=8'd0; rom[1]=8'd1; rom[2]=8'd4; rom[3]=8'd9; end always @(*) data_out = rom[addr]; lacks module and always block structure; data_out assignment is incomplete. always @(addr) begin case(addr) 2'b00: data_out=8'd0; 2'b01: data_out=8'd1; 2'b10: data_out=8'd4; 2'b11: data_out=8'd9; default: data_out=8'd0; endcase end uses a case statement to output fixed squares based on addr, which is a valid ROM implementation. reg [7:0] rom [0:3]; assign rom[0]=0; assign rom[1]=1; assign rom[2]=4; assign rom[3]=9; assign data_out=rom[addr]; tries to assign values to wire array elements, which is illegal. reg [7:0] rom [0:3]; always @(posedge clk) begin rom[0]<=0; rom[1]<=1; rom[2]<=4; rom[3]<=9; end assign data_out=rom[addr]; tries to assign ROM values inside a clocked always block, which is not suitable for ROM initialization.
Step 2: Confirm correct ROM behavior
always @(addr) begin case(addr) 2'b00: data_out=8'd0; 2'b01: data_out=8'd1; 2'b10: data_out=8'd4; 2'b11: data_out=8'd9; default: data_out=8'd0; endcase end correctly outputs squares for each address using a combinational case statement, matching ROM behavior.
Final Answer:
always @(addr) begin case(addr) 2'b00: data_out=8'd0; 2'b01: data_out=8'd1; 2'b10: data_out=8'd4; 2'b11: data_out=8'd9; default: data_out=8'd0; endcase end -> Option A
Quick Check:
ROM as combinational case statement = always @(addr) begin case(addr) 2'b00: data_out=8'd0; 2'b01: data_out=8'd1; 2'b10: data_out=8'd4; 2'b11: data_out=8'd9; default: data_out=8'd0; endcase end [OK]
Hint: Use case statement for fixed ROM outputs [OK]
Common Mistakes:
Assigning to wire arrays
Initializing ROM inside clocked always block
Not using combinational logic for ROM output
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.