diff options
-rw-r--r-- | verilator_example_systemc/.gitignore | 1 | ||||
-rw-r--r-- | verilator_example_systemc/Makefile | 12 | ||||
-rw-r--r-- | verilator_example_systemc/hello.v | 6 | ||||
-rw-r--r-- | verilator_example_systemc/sc_main.cc | 19 |
4 files changed, 38 insertions, 0 deletions
diff --git a/verilator_example_systemc/.gitignore b/verilator_example_systemc/.gitignore new file mode 100644 index 0000000..d38e9f1 --- /dev/null +++ b/verilator_example_systemc/.gitignore @@ -0,0 +1 @@ +/obj_dir diff --git a/verilator_example_systemc/Makefile b/verilator_example_systemc/Makefile new file mode 100644 index 0000000..d2925ac --- /dev/null +++ b/verilator_example_systemc/Makefile @@ -0,0 +1,12 @@ +all: obj_dir/Vhello + +check: all + obj_dir/Vhello + +clean: + rm -fr obj_dir + +.PHONY: all check clean + +obj_dir/Vhello: hello.v sc_main.cc + verilator --sc --exe --build -j 0 -Wall sc_main.cc hello.v diff --git a/verilator_example_systemc/hello.v b/verilator_example_systemc/hello.v new file mode 100644 index 0000000..2afa266 --- /dev/null +++ b/verilator_example_systemc/hello.v @@ -0,0 +1,6 @@ +module hello(input clk); + always @(posedge clk) begin + $display("hello."); + $finish; + end +endmodule diff --git a/verilator_example_systemc/sc_main.cc b/verilator_example_systemc/sc_main.cc new file mode 100644 index 0000000..0634207 --- /dev/null +++ b/verilator_example_systemc/sc_main.cc @@ -0,0 +1,19 @@ +#include <cstdio> + +#include "Vhello.h" + +using namespace sc_core; + +int +sc_main(int argc, char **argv) +{ + Verilated::commandArgs(argc, argv); + sc_clock clk{"clk", 10, SC_NS, 0.5, 3, SC_NS, true}; + + Vhello *top = new Vhello{"top"}; + top->clk(clk); + while (!Verilated::gotFinish()) + sc_start(1, SC_NS); + fprintf(stderr, "it finished.\n"); + return 0; +} |