Skip to content

Commit a86e771

Browse files
author
Oron Port
committed
only include global parameters when they are used in verilog 95/2001
1 parent a06db79 commit a86e771

File tree

16 files changed

+130
-92
lines changed

16 files changed

+130
-92
lines changed

compiler/stages/src/main/scala/dfhdl/compiler/stages/BackendPrepStage.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ package dfhdl.compiler.stages
33
case object BackendPrepStage
44
extends BundleStage(
55
DropUserOpaques, BreakOpsNoAssignments, DropUnreferencedAnons,
6-
NamedAnonMultiref, ExplicitRomVar, DropStructsVecs, NamedVerilogSelection, NamedVHDLSelection,
7-
ToED, MatchToIf, SimplifyMatchSel, DropDomains, DropMagnets, VHDLProcToVerilog,
6+
NamedAnonMultiref, ExplicitRomVar, NamedVerilogSelection, NamedVHDLSelection,
7+
ToED, DropStructsVecs, MatchToIf, SimplifyMatchSel, DropDomains, DropMagnets,
8+
VHDLProcToVerilog,
89
ExplicitNamedVars, DropLocalDcls, DropOutportRead, GlobalizePortVectorParams,
910
LocalToDesignParams, DropDesignParamDeps, DropBAssignFromSeqProc, DropProcessAll,
1011
SimpleOrderMembers, ViaConnection

compiler/stages/src/main/scala/dfhdl/compiler/stages/verilog/VerilogOwnerPrinter.scala

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import DFVal.*
77
import dfhdl.compiler.ir.ProcessBlock.Sensitivity
88
import dfhdl.compiler.ir.DFConditional.DFCaseBlock.Pattern
99
import DFVal.Func.Op as FuncOp
10+
import scala.collection.mutable
1011

1112
protected trait VerilogOwnerPrinter extends AbstractOwnerPrinter:
1213
type TPrinter <: VerilogPrinter
@@ -36,6 +37,17 @@ protected trait VerilogOwnerPrinter extends AbstractOwnerPrinter:
3637
printer.dialect match
3738
case VerilogDialect.v95 | VerilogDialect.v2001 => false
3839
case _ => true
40+
lazy val globalUsage: Map[DFDesignBlock, Set[DFVal]] =
41+
val globalUsage = mutable.Map.empty[DFDesignBlock, Set[DFVal]]
42+
getSet.designDB.membersGlobals.foreach { m =>
43+
if (!m.isAnonymous) m.originMembersNoTypeRef.foreach {
44+
case o: DFVal.CanBeGlobal if !o.isGlobal =>
45+
val owner = o.getOwnerDesign
46+
globalUsage += owner -> (globalUsage.getOrElse(owner, Set()) + m)
47+
case _ =>
48+
}
49+
}
50+
globalUsage.toMap
3951
def csModuleDcl(design: DFDesignBlock): String =
4052
val designMembers = design.members(MemberView.Folded)
4153
val ports = designMembers.view.collect { case p @ DclPort() =>
@@ -110,8 +122,14 @@ protected trait VerilogOwnerPrinter extends AbstractOwnerPrinter:
110122
else "#(" + designParamList.mkString("\n", ",\n", "\n").hindent(2) + ")"
111123
val includeModuleDefs =
112124
if (printer.allowTypeDef) "" else s"""\n `include "${printer.globalFileName}""""
125+
// include parameter definitions only when parameters are used in the design
126+
val paramDefines =
127+
if (printer.supportGlobalParameters) ""
128+
else globalUsage.getOrElse(design, Set()).view.map(m =>
129+
s"`${m.getName}_def"
130+
).toList.sorted.mkString("\n ").emptyOr("\n " + _)
113131
s"""module ${moduleName(design)}$designParamCS$portBlock;
114-
| `include "dfhdl_defs.${printer.verilogFileHeaderSuffix}"$includeModuleDefs$declarations
132+
| `include "dfhdl_defs.${printer.verilogFileHeaderSuffix}"$includeModuleDefs$paramDefines$declarations
115133
|${statements.hindent}
116134
|endmodule""".stripMargin
117135
end csModuleDcl

compiler/stages/src/main/scala/dfhdl/compiler/stages/verilog/VerilogValPrinter.scala

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ protected trait VerilogValPrinter extends AbstractValPrinter:
1414
printer.dialect match
1515
case VerilogDialect.v95 | VerilogDialect.v2001 => false
1616
case _ => true
17+
// under verilog 95/2001 we use concatenation because of the lack of support for
18+
// array literals.
19+
val literalGroupOpen =
20+
printer.dialect match
21+
case VerilogDialect.v95 | VerilogDialect.v2001 => "{"
22+
case _ => "'{"
1723
def csConditionalExprRel(csExp: String, ch: DFConditional.Header): String = printer.unsupported
1824
def csDFValDclConst(dfVal: DFVal.CanBeExpr): String =
1925
val arrRange = printer.csDFVectorRanges(dfVal.dfType)
@@ -30,7 +36,10 @@ protected trait VerilogValPrinter extends AbstractValPrinter:
3036
case _ => csDFValExpr(dfVal)
3137
val csType = printer.csDFType(dfVal.dfType).emptyOr(_ + " ")
3238
val csTypeNoLogic = if (supportLogicType) csType else csType.replace("logic ", "")
33-
s"parameter ${csTypeNoLogic}${dfVal.getName}${arrRange} = $default$endOfStatement"
39+
val csParam = s"parameter ${csTypeNoLogic}${dfVal.getName}${arrRange} = $default$endOfStatement"
40+
if (dfVal.isGlobal && !supportGlobalParameters)
41+
s"`define ${dfVal.getName}_def ${csParam.linesIterator.mkString("\\\n")}"
42+
else csParam
3443
end csDFValDclConst
3544

3645
def csDFValDclWithoutInit(dfVal: Dcl): String =
@@ -102,7 +111,7 @@ protected trait VerilogValPrinter extends AbstractValPrinter:
102111
case argL :: argR :: Nil if dfVal.op == Func.Op.repeat =>
103112
dfVal.dfType match
104113
case _: DFVector =>
105-
s"'{default: ${argL.refCodeString}}"
114+
s"${literalGroupOpen}default: ${argL.refCodeString}}"
106115
case _ =>
107116
s"{${argR.refCodeString.applyBrackets()}{${argL.refCodeString}}}"
108117
// infix func
@@ -170,7 +179,7 @@ protected trait VerilogValPrinter extends AbstractValPrinter:
170179
case DFVector(_, _) =>
171180
printer.csDFVectorElemCS(args.map(_.refCodeString))
172181
case DFStruct(_, _) =>
173-
args.map(_.refCodeString).csList("'{", ",", "}")
182+
args.map(_.refCodeString).csList(literalGroupOpen, ",", "}")
174183
// all args are the same ==> repeat function
175184
case _ if args.view.map(_.get).allElementsAreEqual =>
176185
s"{${args.length}{${args.head.refCodeString}}}"
@@ -243,12 +252,12 @@ protected trait VerilogValPrinter extends AbstractValPrinter:
243252
case cellType: DFVector =>
244253
List.tabulate(vecLength)(i =>
245254
to_vector_conv(cellType, relHighIdx - i * cellType.width)
246-
).csList("'{", ",", "}")
255+
).csList(literalGroupOpen, ",", "}")
247256
case cellType: DFBits =>
248257
val cellWidth = cellType.width
249258
List.tabulate(vecLength)(i =>
250259
s"$relValStr[${relHighIdx - i * cellWidth}:${relHighIdx - (i + 1) * cellWidth + 1}]"
251-
).csList("'{", ",", "}")
260+
).csList(literalGroupOpen, ",", "}")
252261
case x =>
253262
println(x)
254263
printer.unsupported

compiler/stages/src/test/scala/StagesSpec/PrintVerilogCodeSpec.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -800,8 +800,8 @@ class PrintVerilogCodeSpec extends StageSpec:
800800
val top = (new Foo).getCompiledCodeString
801801
assertNoDiff(
802802
top,
803-
"""|parameter integer width = 8;
804-
|parameter integer length = 10;
803+
"""|`define width_def parameter integer width = 8;
804+
|`define length_def parameter integer length = 10;
805805
|`default_nettype none
806806
|`timescale 1ns/1ps
807807
|`include "Foo_defs.vh"
@@ -820,6 +820,8 @@ class PrintVerilogCodeSpec extends StageSpec:
820820
|);
821821
| `include "dfhdl_defs.vh"
822822
| `include "Foo_defs.vh"
823+
| `length_def
824+
| `width_def
823825
| parameter integer width5 = 8;
824826
| parameter integer length5 = 10;
825827
| input wire [width * length - 1:0] x1;
@@ -1134,7 +1136,7 @@ class PrintVerilogCodeSpec extends StageSpec:
11341136
| $display("These are the values: %d", param3, ", %d", param4, ", %h", param5, ", %h", param6, ", %d", param7, ", %b", param8, ", %s", param9 ? "true" : "false", ", %s", param10.name(), "");
11351137
| $info(
11361138
| "Debug at Foo\n",
1137-
| "compiler/stages/src/test/scala/StagesSpec/PrintVerilogCodeSpec.scala:1086:9\n",
1139+
| "compiler/stages/src/test/scala/StagesSpec/PrintVerilogCodeSpec.scala:1088:9\n",
11381140
| "param3 = %d\n", param3,
11391141
| "param4 = %d\n", param4,
11401142
| "param5 = %h\n", param5,
@@ -1204,7 +1206,7 @@ class PrintVerilogCodeSpec extends StageSpec:
12041206
| $display("These are the values: %d", param3, ", %d", param4, ", %h", param5, ", %h", param6, ", %d", param7, ", %b", param8, ", %s", param9 ? "true" : "false", ", %s", MyEnum_to_string(param10), "");
12051207
| $display("INFO: ",
12061208
| "Debug at Foo\n",
1207-
| "compiler/stages/src/test/scala/StagesSpec/PrintVerilogCodeSpec.scala:1086:9\n",
1209+
| "compiler/stages/src/test/scala/StagesSpec/PrintVerilogCodeSpec.scala:1088:9\n",
12081210
| "param3 = %d\n", param3,
12091211
| "param4 = %d\n", param4,
12101212
| "param5 = %h\n", param5,

lib/src/test/resources/ref/AES.CipherSpecNoOpaques/verilog.v2001/hdl/CipherNoOpaques_defs.vh

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@
44
`ifndef CIPHERNOOPAQUES_DEFS_MODULE
55
`define CIPHERNOOPAQUES_DEFS_MODULE
66
`else
7-
parameter [2047:0] sboxLookupTable = {
8-
8'h63, 8'h7c, 8'h77, 8'h7b, 8'hf2, 8'h6b, 8'h6f, 8'hc5, 8'h30, 8'h01, 8'h67, 8'h2b, 8'hfe, 8'hd7, 8'hab, 8'h76,
9-
8'hca, 8'h82, 8'hc9, 8'h7d, 8'hfa, 8'h59, 8'h47, 8'hf0, 8'had, 8'hd4, 8'ha2, 8'haf, 8'h9c, 8'ha4, 8'h72, 8'hc0,
10-
8'hb7, 8'hfd, 8'h93, 8'h26, 8'h36, 8'h3f, 8'hf7, 8'hcc, 8'h34, 8'ha5, 8'he5, 8'hf1, 8'h71, 8'hd8, 8'h31, 8'h15,
11-
8'h04, 8'hc7, 8'h23, 8'hc3, 8'h18, 8'h96, 8'h05, 8'h9a, 8'h07, 8'h12, 8'h80, 8'he2, 8'heb, 8'h27, 8'hb2, 8'h75,
12-
8'h09, 8'h83, 8'h2c, 8'h1a, 8'h1b, 8'h6e, 8'h5a, 8'ha0, 8'h52, 8'h3b, 8'hd6, 8'hb3, 8'h29, 8'he3, 8'h2f, 8'h84,
13-
8'h53, 8'hd1, 8'h00, 8'hed, 8'h20, 8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h28, 8'hdf,
23-
8'h8c, 8'ha1, 8'h89, 8'h0d, 8'hbf, 8'he6, 8'h42, 8'h68, 8'h41, 8'h99, 8'h2d, 8'h0f, 8'hb0, 8'h54, 8'hbb, 8'h16
7+
`define sboxLookupTable_def parameter [2047:0] sboxLookupTable = {\
8+
8'h63, 8'h7c, 8'h77, 8'h7b, 8'hf2, 8'h6b, 8'h6f, 8'hc5, 8'h30, 8'h01, 8'h67, 8'h2b, 8'hfe, 8'hd7, 8'hab, 8'h76,\
9+
8'hca, 8'h82, 8'hc9, 8'h7d, 8'hfa, 8'h59, 8'h47, 8'hf0, 8'had, 8'hd4, 8'ha2, 8'haf, 8'h9c, 8'ha4, 8'h72, 8'hc0,\
10+
8'hb7, 8'hfd, 8'h93, 8'h26, 8'h36, 8'h3f, 8'hf7, 8'hcc, 8'h34, 8'ha5, 8'he5, 8'hf1, 8'h71, 8'hd8, 8'h31, 8'h15,\
11+
8'h04, 8'hc7, 8'h23, 8'hc3, 8'h18, 8'h96, 8'h05, 8'h9a, 8'h07, 8'h12, 8'h80, 8'he2, 8'heb, 8'h27, 8'hb2, 8'h75,\
12+
8'h09, 8'h83, 8'h2c, 8'h1a, 8'h1b, 8'h6e, 8'h5a, 8'ha0, 8'h52, 8'h3b, 8'hd6, 8'hb3, 8'h29, 8'he3, 8'h2f, 8'h84,\
13+
8'h53, 8'hd1, 8'h00, 8'hed, 8'h20, 8'hfc, 8'hb1, 8'h5b, 8'h6a, 8'hcb, 8'hbe, 8'h39, 8'h4a, 8'h4c, 8'h58, 8'hcf,\
14+
8'hd0, 8'hef, 8'haa, 8'hfb, 8'h43, 8'h4d, 8'h33, 8'h85, 8'h45, 8'hf9, 8'h02, 8'h7f, 8'h50, 8'h3c, 8'h9f, 8'ha8,\
15+
8'h51, 8'ha3, 8'h40, 8'h8f, 8'h92, 8'h9d, 8'h38, 8'hf5, 8'hbc, 8'hb6, 8'hda, 8'h21, 8'h10, 8'hff, 8'hf3, 8'hd2,\
16+
8'hcd, 8'h0c, 8'h13, 8'hec, 8'h5f, 8'h97, 8'h44, 8'h17, 8'hc4, 8'ha7, 8'h7e, 8'h3d, 8'h64, 8'h5d, 8'h19, 8'h73,\
17+
8'h60, 8'h81, 8'h4f, 8'hdc, 8'h22, 8'h2a, 8'h90, 8'h88, 8'h46, 8'hee, 8'hb8, 8'h14, 8'hde, 8'h5e, 8'h0b, 8'hdb,\
18+
8'he0, 8'h32, 8'h3a, 8'h0a, 8'h49, 8'h06, 8'h24, 8'h5c, 8'hc2, 8'hd3, 8'hac, 8'h62, 8'h91, 8'h95, 8'he4, 8'h79,\
19+
8'he7, 8'hc8, 8'h37, 8'h6d, 8'h8d, 8'hd5, 8'h4e, 8'ha9, 8'h6c, 8'h56, 8'hf4, 8'hea, 8'h65, 8'h7a, 8'hae, 8'h08,\
20+
8'hba, 8'h78, 8'h25, 8'h2e, 8'h1c, 8'ha6, 8'hb4, 8'hc6, 8'he8, 8'hdd, 8'h74, 8'h1f, 8'h4b, 8'hbd, 8'h8b, 8'h8a,\
21+
8'h70, 8'h3e, 8'hb5, 8'h66, 8'h48, 8'h03, 8'hf6, 8'h0e, 8'h61, 8'h35, 8'h57, 8'hb9, 8'h86, 8'hc1, 8'h1d, 8'h9e,\
22+
8'he1, 8'hf8, 8'h98, 8'h11, 8'h69, 8'hd9, 8'h8e, 8'h94, 8'h9b, 8'h1e, 8'h87, 8'he9, 8'hce, 8'h55, 8'h28, 8'hdf,\
23+
8'h8c, 8'ha1, 8'h89, 8'h0d, 8'hbf, 8'he6, 8'h42, 8'h68, 8'h41, 8'h99, 8'h2d, 8'h0f, 8'hb0, 8'h54, 8'hbb, 8'h16\
2424
};
25-
parameter [351:0] Rcon = {
26-
32'h00000000, 32'h01000000, 32'h02000000, 32'h04000000, 32'h08000000, 32'h10000000, 32'h20000000, 32'h40000000, 32'h80000000, 32'h1b000000,
27-
32'h36000000
25+
`define Rcon_def parameter [351:0] Rcon = {\
26+
32'h00000000, 32'h01000000, 32'h02000000, 32'h04000000, 32'h08000000, 32'h10000000, 32'h20000000, 32'h40000000, 32'h80000000, 32'h1b000000,\
27+
32'h36000000\
2828
};
2929

3030
`undef CIPHERNOOPAQUES_DEFS_MODULE

lib/src/test/resources/ref/AES.CipherSpecNoOpaques/verilog.v2001/hdl/keyExpansion.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module keyExpansion(
88
);
99
`include "dfhdl_defs.vh"
1010
`include "CipherNoOpaques_defs.vh"
11+
`Rcon_def
1112
wire [31:0] w_0;
1213
wire [31:0] w_1;
1314
wire [31:0] w_2;

lib/src/test/resources/ref/AES.CipherSpecNoOpaques/verilog.v2001/hdl/sbox.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module sbox(
88
);
99
`include "dfhdl_defs.vh"
1010
`include "CipherNoOpaques_defs.vh"
11+
`sboxLookupTable_def
1112
reg [7:0] sboxLookupTable_rom [0:255];
1213
initial begin : sboxLookupTable_rom_init
1314
sboxLookupTable_rom[0] = sboxLookupTable[2047:2040];

lib/src/test/resources/ref/AES.CipherSpecNoOpaques/verilog.v95/hdl/CipherNoOpaques_defs.vh

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@
44
`ifndef CIPHERNOOPAQUES_DEFS_MODULE
55
`define CIPHERNOOPAQUES_DEFS_MODULE
66
`else
7-
parameter [2047:0] sboxLookupTable = {
8-
8'h63, 8'h7c, 8'h77, 8'h7b, 8'hf2, 8'h6b, 8'h6f, 8'hc5, 8'h30, 8'h01, 8'h67, 8'h2b, 8'hfe, 8'hd7, 8'hab, 8'h76,
9-
8'hca, 8'h82, 8'hc9, 8'h7d, 8'hfa, 8'h59, 8'h47, 8'hf0, 8'had, 8'hd4, 8'ha2, 8'haf, 8'h9c, 8'ha4, 8'h72, 8'hc0,
10-
8'hb7, 8'hfd, 8'h93, 8'h26, 8'h36, 8'h3f, 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
20-
8'hba, 8'h78, 8'h25, 8'h2e, 8'h1c, 8'ha6, 8'hb4, 8'hc6, 8'he8, 8'hdd, 8'h74, 8'h1f, 8'h4b, 8'hbd, 8'h8b, 8'h8a,
21-
8'h70, 8'h3e, 8'hb5, 8'h66, 8'h48, 8'h03, 8'hf6, 8'h0e, 8'h61, 8'h35, 8'h57, 8'hb9, 8'h86, 8'hc1, 8'h1d, 8'h9e,
22-
8'he1, 8'hf8, 8'h98, 8'h11, 8'h69, 8'hd9, 8'h8e, 8'h94, 8'h9b, 8'h1e, 8'h87, 8'he9, 8'hce, 8'h55, 8'h28, 8'hdf,
23-
8'h8c, 8'ha1, 8'h89, 8'h0d, 8'hbf, 8'he6, 8'h42, 8'h68, 8'h41, 8'h99, 8'h2d, 8'h0f, 8'hb0, 8'h54, 8'hbb, 8'h16
7+
`define sboxLookupTable_def parameter [2047:0] sboxLookupTable = {\
8+
8'h63, 8'h7c, 8'h77, 8'h7b, 8'hf2, 8'h6b, 8'h6f, 8'hc5, 8'h30, 8'h01, 8'h67, 8'h2b, 8'hfe, 8'hd7, 8'hab, 8'h76,\
9+
8'hca, 8'h82, 8'hc9, 8'h7d, 8'hfa, 8'h59, 8'h47, 8'hf0, 8'had, 8'hd4, 8'ha2, 8'haf, 8'h9c, 8'ha4, 8'h72, 8'hc0,\
10+
8'hb7, 8'hfd, 8'h93, 8'h26, 8'h36, 8'h3f, 8'hf7, 8'hcc, 8'h34, 8'ha5, 8'he5, 8'hf1, 8'h71, 8'hd8, 8'h31, 8'h15,\
11+
8'h04, 8'hc7, 8'h23, 8'hc3, 8'h18, 8'h96, 8'h05, 8'h9a, 8'h07, 8'h12, 8'h80, 8'he2, 8'heb, 8'h27, 8'hb2, 8'h75,\
12+
8'h09, 8'h83, 8'h2c, 8'h1a, 8'h1b, 8'h6e, 8'h5a, 8'ha0, 8'h52, 8'h3b, 8'hd6, 8'hb3, 8'h29, 8'he3, 8'h2f, 8'h84,\
13+
8'h53, 8'hd1, 8'h00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h87, 8'he9, 8'hce, 8'h55, 8'h28, 8'hdf,\
23+
8'h8c, 8'ha1, 8'h89, 8'h0d, 8'hbf, 8'he6, 8'h42, 8'h68, 8'h41, 8'h99, 8'h2d, 8'h0f, 8'hb0, 8'h54, 8'hbb, 8'h16\
2424
};
25-
parameter [351:0] Rcon = {
26-
32'h00000000, 32'h01000000, 32'h02000000, 32'h04000000, 32'h08000000, 32'h10000000, 32'h20000000, 32'h40000000, 32'h80000000, 32'h1b000000,
27-
32'h36000000
25+
`define Rcon_def parameter [351:0] Rcon = {\
26+
32'h00000000, 32'h01000000, 32'h02000000, 32'h04000000, 32'h08000000, 32'h10000000, 32'h20000000, 32'h40000000, 32'h80000000, 32'h1b000000,\
27+
32'h36000000\
2828
};
2929

3030
`undef CIPHERNOOPAQUES_DEFS_MODULE

lib/src/test/resources/ref/AES.CipherSpecNoOpaques/verilog.v95/hdl/keyExpansion.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module keyExpansion(
88
);
99
`include "dfhdl_defs.vh"
1010
`include "CipherNoOpaques_defs.vh"
11+
`Rcon_def
1112
input wire [127:0] key;
1213
output wire [1407:0] o;
1314
wire [31:0] w_0;

lib/src/test/resources/ref/AES.CipherSpecNoOpaques/verilog.v95/hdl/sbox.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module sbox(
88
);
99
`include "dfhdl_defs.vh"
1010
`include "CipherNoOpaques_defs.vh"
11+
`sboxLookupTable_def
1112
input wire [7:0] lhs;
1213
output wire [7:0] o;
1314
reg [7:0] sboxLookupTable_rom [0:255];

0 commit comments

Comments
 (0)