Netlist icon indicating copy to clipboard operation
Netlist copied to clipboard

Semantic Aware Conversions

Open dan-fritchman opened this issue 2 years ago • 0 comments

The data model in Netlist to date could generally be described as an abstract syntax tree. A netlist.Program consists of strongly-typed Statements and Entrys, which refer to each other through things like the identifier (Ident). At no point are these identifiers resolved to what they represent.

Recent use-cases for sake of netlist-dialect conversion indicate this will probably need some resolution, and more generally, some semantics and a more concrete tree. The primary semantic-requiring problem is that some dialects (ahem, Spectre) allow for naming primitive instances by an arbitrary identifier - while most embed the instance-type in its instance-name prefix.

For example both of these are valid spectre-format "programs":

model mything bsim4 
+ version=4.5
+ // Lots of parameters 
+ // ...

// Now make an instance of `mything`
any_instance_name_i_want (d g s b) mything // And any parameters

And:

subckt mything ( d g s b) 
+ // Parameters 
ends 

// Now make another instance of `mything`, which is now a `subckt`
any_instance_name_i_want (d g s b) mything // And any parameters

However in most SPICE-native netlist formats, a syntax-to-syntax conversion fails in one case or the other, particularly on the instance-name any_instance_name_i_want. Most SPICE dialects would require this to be called Many_instance_name_i_want_ if it is a primitive MOS transistor, and to be called Xany_instance_name_i_want_ if it is a sub-circuit instance. These prefixes essentially form the SPICE "type system".

Rolling this in would require resolving just what mything is at instantiation time. This will not always be possible to determine, without knowing the entire target netlist-program's content. Particularly the two cases above could be on different section definitions of the same library file, like so:

section=now_im_a_model 

model mything bsim4 
+ version=4.5
+ // Lots of parameters 

endsection 

section=now_im_a_subckt

subckt mything ( d g s b) 
+ // Parameters 
ends 

endsection

More generally, SPICE and Spectre use C-like "copy-paste the whole file here" style inclusion. So making these resolution-decisions will require some expected set of content in the remainder of the netlist-program.

dan-fritchman avatar Mar 28 '22 23:03 dan-fritchman