Question: / / Testbench module test; reg clk _ write; reg [ 4 : 0 ] address _ write; reg [ 7 : 0 ] data
Testbench
module test;
reg clkwrite;
reg : addresswrite;
reg : datawrite;
reg writeenable;
reg clkread;
reg : addressread;
wire : dataread;
Instantiate design under test
DWIDTH
AWIDTH
AMAX AWIDTH
ram # RAM
clkwriteclkwrite
addresswriteaddresswrite
datawritedatawrite
writeenablewriteenable
clkreadclkread
addressreadaddressread
datareaddataread
;
initial begin
Dump waves
$dumpfiledumpvcd;
$dumpvars test;
clkwrite ;
clkread ;
writeenable ;
addressread b; Fixed binary format
addresswrite b; Fixed binary format
Read initial data
$displayRead initial data.";
toggleclkread;
$displaydatah: h addressread, dataread;
Write new data
$displayWrite new data.";
writeenable ;
datawrite hF;
toggleclkwrite;
writeenable ;
Read new data
$displayRead new data.";
toggleclkread;
$displaydatah: h addressread, dataread;
end
task toggleclkwrite;
begin
# clkwrite ~clkwrite;
# clkwrite ~clkwrite;
end
endtask
task toggleclkread;
begin
# clkread ~clkread;
# clkread ~clkread;
end
endtask
endmodule
Random Access Memory RAM with
read port and write port
module ram clkwrite, addresswrite,datawrite, writeenable,
clkread, addressread, dataread;
parameter DWIDTH ;
parameter AWIDTH ;
parameter AMAX ; AWIDTH
Write port
input clkwrite;
input AWIDTH: addresswrite;
input DWIDTH: datawrite;
input writeenable;
Read port
input clkread;
input AWIDTH: addressread;
output DWIDTH: dataread;
reg DWIDTH: dataread;
Memory as an array of register variables
reg DWIDTH: memory AMAX:;
Write data to memory
always @posedge clkwrite begin
if writeenable begin
memoryaddresswrite datawrite;
end
end
Read data from memory
always @posedge clkread begin
dataread memoryaddressread;
end
endmodule can you fix this code for me
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
