2021-02-15 22:40:12 +01:00
|
|
|
module tb_top ();
|
|
|
|
|
|
|
|
logic clk;
|
|
|
|
logic nreset;
|
|
|
|
|
2021-02-15 23:55:09 +01:00
|
|
|
clkgen clkgen_inst (
|
|
|
|
.clk_o (clk),
|
|
|
|
.nreset_o(nreset)
|
|
|
|
);
|
|
|
|
|
2021-02-15 22:40:12 +01:00
|
|
|
gb gb_inst (
|
|
|
|
.clk_i (clk),
|
|
|
|
.nreset_i(nreset)
|
|
|
|
);
|
|
|
|
|
2021-02-17 23:40:24 +01:00
|
|
|
// Testbench code
|
|
|
|
logic instr_undef;
|
|
|
|
logic [15:0] last_pc;
|
|
|
|
logic [ 7:0] last_opcode;
|
|
|
|
|
|
|
|
assign instr_undef = gb_inst.cpu_inst.control_inst.is_undef;
|
|
|
|
assign last_pc = gb_inst.cpu_inst.control_inst.instr_pc_r;
|
|
|
|
assign last_opcode = gb_inst.cpu_inst.control_inst.instr_r;
|
|
|
|
|
|
|
|
always @(posedge clk) begin
|
|
|
|
if (nreset && instr_undef) begin
|
|
|
|
$info($sformatf("[%t] %X: Undefined opcode %X", $time(), last_pc, last_opcode));
|
|
|
|
$fatal(0);
|
|
|
|
end
|
|
|
|
end
|
2021-02-15 22:40:12 +01:00
|
|
|
|
|
|
|
endmodule : tb_top
|