EXP5
EXP5
Operations
Aim To design and simulate a 4KB ROM memory with read and write operations using Verilog HDL
and verify the functionality through a testbench in the Vivado 2023.1 simulation environment.
Apparatus Required Vivado 2023.1 or equivalent Verilog simulation tool. Computer system with a
suitable operating system. Procedure Launch Vivado 2023.1:
Open Vivado and create a new project. Design the Verilog Code for ROM:
Write the Verilog code for a 4KB ROM memory with read and write capabilities. Create the
Testbench:
Write a testbench to simulate both the read and write operations, verifying that the data is correctly
written to and read from the memory. Add the Verilog Files:
Add the ROM Verilog module and the testbench file to the project. Run Simulation:
Run the behavioral simulation in Vivado and check the memory's read and write operations.
Observe the Waveforms:
Analyze the waveform to verify that the memory read and write operations work as expected. Save
and Document Results:
Capture the waveform and include the simulation results in the final report. Verilog Code for 4KB
ROM Memory with Read and Write Operations In this design, we will implement a 4KB ROM. Since
ROM is typically read-only, we will simulate the behavior as if it's writable, but in actual hardware,
ROM is typically pre-programmed.
4KB = 4096 Bytes = 4096 x 8 bits The address width for 4KB memory is 12 bits (2^12 = 4096).
// rom_memory.v
module rom_memory (
input wire clk,
input wire write_enable, // Signal to enable write operation
input wire [11:0] address, // 12-bit address for 4KB memory
input wire [7:0] data_in, // Data to write into ROM
output reg [7:0] data_out // Data read from ROM
);
// rom_memory_tb.v
`timescale 1ns / 1ps
module rom_memory_tb;
// Inputs
reg clk;
reg write_enable;
reg [11:0] address;
reg [7:0] data_in;
// Outputs
wire [7:0] data_out;
// Clock generation
always #5 clk = ~clk; // Toggle clock every 5 ns
// Test procedure
initial begin
// Initialize inputs
clk = 0;
write_enable = 0;
address = 0;
data_in = 0;
endmodule
Conclusion In this experiment, a 4KB ROM memory with read and write operations was designed
and successfully simulated using Verilog HDL. The testbench verified both the write and read
functionalities by simulating the memory operations and observing the output waveforms. The
experiment demonstrates how to implement memory operations in Verilog, effectively modeling
both the reading and writing processes for ROM.