@@ -133,12 +133,16 @@ def _verilator_cc_library(ctx):
133133 args = ctx .actions .args ()
134134 args .add (verilator_toolchain .verilator )
135135 args .add ("--no-std" )
136- args .add ("--cc" )
137136 args .add ("--Mdir" , verilator_output .path )
138137 args .add ("--top-module" , ctx .attr .module_top )
139138 args .add ("--prefix" , prefix )
140139 if ctx .attr .trace :
141140 args .add ("--trace" )
141+ if ctx .attr .systemc :
142+ args .add ("--sc" )
143+ else :
144+ args .add ("--cc" )
145+
142146 args .add_all (all_includes , format_each = "-I%s" )
143147 args .add_all (verilog_files , expand_directories = True , map_each = _only_sv )
144148 args .add_all (verilator_toolchain .extra_vopts )
@@ -186,7 +190,7 @@ def _verilator_cc_library(ctx):
186190 defines = defines ,
187191 runfiles = runfiles ,
188192 includes = [verilator_output_hpp .path ],
189- deps = verilator_toolchain .deps ,
193+ deps = ( verilator_toolchain . deps + [ verilator_toolchain . systemc ]) if ctx . attr . systemc else verilator_toolchain .deps ,
190194 )
191195
192196verilator_cc_library = rule (
@@ -205,6 +209,10 @@ verilator_cc_library = rule(
205209 doc = "The name of the verilog module to verilate." ,
206210 mandatory = True ,
207211 ),
212+ "systemc" : attr .bool (
213+ doc = "Generate SystemC code." ,
214+ default = False ,
215+ ),
208216 "trace" : attr .bool (
209217 doc = "Enable tracing for Verilator" ,
210218 default = False ,
@@ -246,6 +254,7 @@ def _verilator_toolchain_impl(ctx):
246254
247255 return [platform_common .ToolchainInfo (
248256 verilator = ctx .executable .verilator ,
257+ systemc = ctx .attr .systemc ,
249258 deps = ctx .attr .deps ,
250259 extra_vopts = ctx .attr .extra_vopts ,
251260 all_files = all_files ,
@@ -266,6 +275,11 @@ verilator_toolchain = rule(
266275 "extra_vopts" : attr .string_list (
267276 doc = "Extra flags to pass to Verilator compile actions." ,
268277 ),
278+ "systemc" : attr .label (
279+ doc = "SystemC dependency to link into downstream targets." ,
280+ providers = [CcInfo ],
281+ mandatory = True ,
282+ ),
269283 "verilator" : attr .label (
270284 doc = "The Verilator binary." ,
271285 executable = True ,
0 commit comments