Skip to content

Commit 12b4b27

Browse files
authored
reset the default_nettype to wire at the end of the generated verilog (#3005)
1 parent be91e18 commit 12b4b27

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CHANGED: when generating (System)Verilog, Clash now resets the default net type from none to the verilog default after the generated module

clash-lib/src/Clash/Backend/SystemVerilog.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,17 @@ genSystemVerilog opts _ sp seen us c = do
228228
where
229229
cName = componentName c
230230
verilog = commentHeader <> line <>
231-
nettype <> line <>
231+
nettypeNone <> line <>
232232
timescale <> line <>
233-
module_ c
233+
module_ c <> line <>
234+
nettypeDefault
235+
234236
commentHeader
235237
= "/* AUTOMATICALLY GENERATED SYSTEMVERILOG-2005 SOURCE CODE."
236238
<> line <> "** GENERATED BY CLASH " <> string (Text.pack clashVer) <> ". DO NOT MODIFY."
237239
<> line <> "*/"
238-
nettype = "`default_nettype none"
240+
nettypeNone = "`default_nettype none"
241+
nettypeDefault = "`default_nettype wire"
239242
timescale = "`timescale 100fs/" <> string (Text.pack precision)
240243
precision = periodToString (opt_timescalePrecision opts)
241244

clash-lib/src/Clash/Backend/Verilog.hs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,11 @@ genVerilog opts _ sp seen usage c = do
225225
usages .= usage
226226
setSrcSpan sp
227227

228-
v <- commentHeader <> line <> nettype <> line <> timescale <> line <> module_ c
228+
v <- commentHeader <> line <>
229+
nettypeNone <> line <>
230+
timescale <> line <>
231+
module_ c <> line <>
232+
nettypeDefault
229233
incs <- Ap $ use includes
230234
return ((TextS.unpack (Id.toText cName), v), incs)
231235
where
@@ -234,7 +238,8 @@ genVerilog opts _ sp seen usage c = do
234238
= "/* AUTOMATICALLY GENERATED VERILOG-2001 SOURCE CODE."
235239
<> line <> "** GENERATED BY CLASH " <> string (Text.pack clashVer) <> ". DO NOT MODIFY."
236240
<> line <> "*/"
237-
nettype = "`default_nettype none"
241+
nettypeNone = "`default_nettype none"
242+
nettypeDefault = "`default_nettype wire"
238243
timescale = "`timescale 100fs/" <> string (Text.pack precision)
239244
precision = periodToString (opt_timescalePrecision opts)
240245

0 commit comments

Comments
 (0)