2006-08-26 11:35:28 +00:00
|
|
|
// DESCRIPTION: Verilator: Verilog Test module
|
|
|
|
//
|
2020-03-21 15:24:24 +00:00
|
|
|
// This file ONLY is placed under the Creative Commons Public Domain, for
|
|
|
|
// any use, without warranty, 2003-2007 by Wilson Snyder.
|
|
|
|
// SPDX-License-Identifier: CC0-1.0
|
2006-08-26 11:35:28 +00:00
|
|
|
|
2006-08-30 17:27:53 +00:00
|
|
|
module t (/*AUTOARG*/
|
2006-08-26 11:35:28 +00:00
|
|
|
// Inputs
|
|
|
|
clk
|
|
|
|
);
|
|
|
|
|
|
|
|
/*verilator public_module*/
|
|
|
|
|
|
|
|
input clk;
|
|
|
|
// No verilator_public needed, because it's outside the "" in the $c statement
|
2021-11-13 15:46:25 +00:00
|
|
|
reg [7:0] cyc; initial cyc = 0;
|
2022-05-01 14:10:00 +00:00
|
|
|
reg c_worked;
|
2006-08-26 11:35:28 +00:00
|
|
|
reg [8:0] c_wider;
|
|
|
|
|
|
|
|
wire one = 1'b1;
|
|
|
|
|
|
|
|
always @ (posedge clk) begin
|
2021-11-13 15:46:25 +00:00
|
|
|
cyc <= cyc + 8'd1;
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
|
|
// coverage testing
|
|
|
|
if (one) begin end
|
|
|
|
if (!one) begin end
|
|
|
|
if (cyc[0]) begin end if (!cyc[0]) begin end // multiple on a line
|
|
|
|
|
|
|
|
if (cyc == 8'd1) begin
|
2022-05-01 14:10:00 +00:00
|
|
|
c_worked <= 0;
|
2006-08-26 11:35:28 +00:00
|
|
|
end
|
|
|
|
if (cyc == 8'd2) begin
|
2010-01-15 02:03:06 +00:00
|
|
|
`ifdef VERILATOR
|
2022-05-01 14:10:00 +00:00
|
|
|
$c("VL_PRINTF(\"Calling $c, calling $c...\\n\");");
|
|
|
|
$c("VL_PRINTF(\"Cyc=%d\\n\",", cyc, ");");
|
|
|
|
c_worked <= $c("this->my_function()");
|
|
|
|
c_wider <= $c9("0x10");
|
2006-08-26 11:35:28 +00:00
|
|
|
`else
|
2022-05-01 14:10:00 +00:00
|
|
|
c_worked <= 1'b1;
|
|
|
|
c_wider <= 9'h10;
|
2008-06-10 01:25:10 +00:00
|
|
|
`endif
|
2006-08-26 11:35:28 +00:00
|
|
|
end
|
|
|
|
if (cyc == 8'd3) begin
|
2022-05-01 14:10:00 +00:00
|
|
|
if (c_worked !== 1'b1) $stop;
|
|
|
|
if (c_wider !== 9'h10) $stop;
|
|
|
|
$finish;
|
2006-08-26 11:35:28 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
`ifdef verilator
|
|
|
|
`systemc_header
|
|
|
|
#define DID_INT_HEADER 1
|
|
|
|
`systemc_interface
|
|
|
|
#ifndef DID_INT_HEADER
|
|
|
|
#error "`systemc_header didn't work"
|
|
|
|
#endif
|
|
|
|
bool m_did_ctor;
|
2022-03-27 19:03:25 +00:00
|
|
|
uint32_t my_function() {
|
2019-11-10 01:35:12 +00:00
|
|
|
if (!m_did_ctor) vl_fatal(__FILE__, __LINE__, __FILE__, "`systemc_ctor didn't work");
|
2006-08-26 11:35:28 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
`systemc_imp_header
|
|
|
|
#define DID_IMP_HEADER 1
|
|
|
|
`systemc_implementation
|
|
|
|
#ifndef DID_IMP_HEADER
|
|
|
|
#error "`systemc_imp_header didn't work"
|
|
|
|
#endif
|
|
|
|
`systemc_ctor
|
2008-06-10 01:25:10 +00:00
|
|
|
m_did_ctor = 1;
|
2006-08-30 17:27:53 +00:00
|
|
|
`systemc_dtor
|
|
|
|
printf("In systemc_dtor\n");
|
|
|
|
printf("*-* All Finished *-*\n");
|
2006-08-26 11:35:28 +00:00
|
|
|
`verilog
|
|
|
|
|
2008-06-11 17:09:36 +00:00
|
|
|
// Test verilator comment after a endif
|
|
|
|
`endif // verilator
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
|
|
endmodule
|