Naming
Reserved Names
When translating from Verilog, signal and module names may conflict with names already in scope from Scala or DFHDL. There are two categories of conflicts:
Scala Reserved Keywords
Scala keywords cannot be used directly as identifiers. Use backtick escaping:
val, var, def, type, class, object, trait, enum, match, case, if, else, for, while, do, return, throw, try, catch, finally, yield, import, export, new, this, super, true, false, null, then, end, given, using, extension, with, abstract, final, override, sealed, lazy, private, protected
1 2 3 | |
DFHDL Built-in Names
import dfhdl.* brings DFHDL built-in functions and types into scope. If a user-defined class has the same name as a built-in, the built-in shadows the class. Known built-ins that commonly conflict with Verilog module names:
abs, clog2, max, min, all, Bit, Bits, UInt, SInt
1 2 3 4 5 6 7 8 | |
Resolution Patterns
Backtick Escaping
For Scala keywords used as signal names:
1 2 | |
@targetName Annotation
When a Scala-side name must differ from the generated HDL name, use @targetName to set the hardware name explicitly. This is useful when:
- A port name conflicts with a sub-module class name in the same design
- You want to rename a Scala identifier but preserve the original Verilog port name
1 2 3 4 5 6 7 8 9 | |
Type Alias for Class Name Conflicts
When a class name conflicts with a DFHDL built-in function:
1 2 | |