summaryrefslogtreecommitdiff
path: root/verilator_example_systemc
diff options
context:
space:
mode:
authorMartin Stensgård <mastensg@mastensg.net>2025-04-26 17:56:22 +0200
committerMartin Stensgård <mastensg@mastensg.net>2025-04-26 17:56:22 +0200
commite3146a4830eeb07daf4688e1aae3690ff94db3e1 (patch)
tree2b3543e99fe510584d0d33fcb9efc775908ac98f /verilator_example_systemc
parent0925abbbe788f4b3661f5dbfc8b1597814b90c9a (diff)
verilator_example_systemc: hello
Diffstat (limited to 'verilator_example_systemc')
-rw-r--r--verilator_example_systemc/.gitignore1
-rw-r--r--verilator_example_systemc/Makefile12
-rw-r--r--verilator_example_systemc/hello.v6
-rw-r--r--verilator_example_systemc/sc_main.cc19
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;
+}