Files
iverilog/ivtest/ivltests/memsynth5.v
T
Stephen Williams cea237b407 Add ivtest to the iverilog source tree
By adding ivtest to the iverilog source tree, it is easier to keep
the regression test synchronized with the source that is being tested.
This should be especially helpful for PRs that add a new feature, and
have a matching ivtest PR with the regression test for that feature.
2022-01-15 10:18:50 -08:00

63 lines
1.0 KiB
Verilog

module main;
reg [7:0] mem [7:0], D;
reg [2:0] radr, wadr;
reg wr, rst, clk;
/*
* This implements the synchronous write port to the memory.
*/
always @(posedge clk)
if (rst) begin
mem[0] <= 0;
mem[1] <= 0;
mem[2] <= 0;
mem[3] <= 8'h33;
mem[5] <= 8'h55;
mem[6] <= 0;
mem[7] <= 0;
end else
if (wr) begin
mem[wadr] <= D;
end
// This is the asynchronous read port from the memory.
wire[7:0] Q = mem[radr];
initial begin
wr = 0;
rst = 1;
clk = 0;
#1 clk = 1;
#1 clk = 0;
radr = 3;
#1 if (Q !== 8'h33) begin
$display("FAILED -- mem[3] == 'b%b", Q);
$finish;
end
radr = 5;
#1 if (Q !== 8'h55) begin
$display("FAILED == mem[5] == 'b%b", Q);
$finish;
end
wadr = 4;
wr = 1;
rst = 0;
D = 'h44;
#1 clk = 1;
#1 clk = 0;
radr = 4;
#1 if (Q !== 8'h44) begin
$display("FAILED -- mem[4] == 'b%b", Q);
$finish;
end
$display("PASSED");
end
endmodule