2023-02-26 23:26:11 +00:00
|
|
|
`timescale 1ns / 1ps
|
|
|
|
|
|
|
|
module test_single_cycle_core ();
|
|
|
|
logic clk, rst;
|
|
|
|
always #1 clk = ~clk;
|
|
|
|
|
2023-02-27 05:45:14 +00:00
|
|
|
instr_memory_if instr_mem_if();
|
|
|
|
instr_memory #(.FILE_PATH("test-core.mem")) instr_mem (.instr_mem_if(instr_mem_if.mem));
|
2023-02-26 23:26:11 +00:00
|
|
|
|
2023-02-27 01:40:05 +00:00
|
|
|
data_memory_if data_mem_if (
|
2023-02-26 23:26:11 +00:00
|
|
|
.clk(clk),
|
|
|
|
.rst(rst)
|
|
|
|
);
|
2023-02-27 05:45:14 +00:00
|
|
|
data_memory #(.NUM_BLOCKS(128)) data_mem (.data_mem_if(data_mem_if.ram));
|
2023-02-26 23:26:11 +00:00
|
|
|
|
2023-02-27 01:40:05 +00:00
|
|
|
single_cycle_datapath dut (
|
|
|
|
.clk(clk),
|
|
|
|
.rst(rst),
|
|
|
|
.instr_mem_if(instr_mem_if.datapath),
|
|
|
|
.data_mem_if(data_mem_if.datapath)
|
|
|
|
);
|
2023-02-27 05:45:14 +00:00
|
|
|
|
|
|
|
always @(posedge clk) begin
|
|
|
|
if (data_mem_if.write_enable) begin
|
|
|
|
if(data_mem_if.addr == 'd100 && data_mem_if.write_data == 'd25) begin
|
|
|
|
$finish;
|
|
|
|
end else if (data_mem_if.addr != 'd96) // assert
|
|
|
|
$finish;
|
|
|
|
end
|
|
|
|
end
|
2023-02-26 23:26:11 +00:00
|
|
|
|
|
|
|
initial begin
|
|
|
|
$dumpfile("single_cycle.vcd");
|
|
|
|
$dumpvars(1, dut);
|
|
|
|
clk = 0;
|
|
|
|
rst = 1;
|
|
|
|
#4;
|
|
|
|
rst = 0;
|
2023-02-27 05:45:14 +00:00
|
|
|
#1000;
|
|
|
|
$display("Hello world");
|
2023-02-26 23:26:11 +00:00
|
|
|
$finish;
|
|
|
|
end
|
|
|
|
endmodule
|