From e86857d410a91374aee677412a777bffcf7a08b0 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Thu, 2 Nov 2023 19:23:11 +0100 Subject: [PATCH] code cleanup in make_sch_from_spice.awk and make_sym_from_spice.awk --- src/make_sch_from_spice.awk | 73 +++++++++++++++++++++++++------------ src/make_sym_from_spice.awk | 62 ++++++++++++++++++------------- 2 files changed, 86 insertions(+), 49 deletions(-) diff --git a/src/make_sch_from_spice.awk b/src/make_sch_from_spice.awk index 6e6f3354..aeaf4fc6 100755 --- a/src/make_sch_from_spice.awk +++ b/src/make_sch_from_spice.awk @@ -1,5 +1,33 @@ -#!/bin/sh -gawk ' +#!/usr/bin/awk -f +# +# File: make_sch_from_spice.awk +# +# This file is part of XSCHEM, +# a schematic capture and Spice/Vhdl/Verilog netlisting tool for circuit +# simulation. +# Copyright (C) 1998-2023 Stefan Frederik Schippers +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +# +# create xschem symbols and schematics from a spice netlist. +# Spice netlist should contain *.PININFO lines that specify the direction +# of ports otherwise inout is assumed for all symbol ports. +# Usage: +# make_sch_from_spice.awk netlist.spice +# Generated symbols and schematics should be in current directory BEGIN{ avoid_brakets=0 ## set to 1 if you want to avoid [] in inst names: x12[3] --> x12_3_ @@ -137,9 +165,11 @@ function process_subckts( j, i,name) } pin_ar[curr_subckt,"n"]=j-1 - if(skip_symbol_prefix) pin_ar[curr_subckt,"template"] = pin_ar[curr_subckt,"template"] " prefix=" skip_symbol_prefix + if(skip_symbol_prefix) + pin_ar[curr_subckt,"template"] = pin_ar[curr_subckt,"template"] " prefix=" skip_symbol_prefix get_template(template) - if(skip_symbol_prefix) pin_ar[curr_subckt,"extra"] = pin_ar[curr_subckt,"extra"] " prefix" + if(skip_symbol_prefix) + pin_ar[curr_subckt,"extra"] = pin_ar[curr_subckt,"extra"] " prefix" print "\n\n\n process_subckt() : " curr_subckt "--> " for(i=1; i<= pin_ar[curr_subckt,"n"]; i++) printf "%s ", pin_ar[curr_subckt,i]; printf "\n" } @@ -238,19 +268,28 @@ function process( i,name,param) if(i