xschem-2.8.1/0000755000175100017510000000000013400743706011215 5ustar svnsvnxschem-2.8.1/README0000644000175100017510000000224713366600356012106 0ustar svnsvnXSCHEM : schematic capture and netlisting EDA tool Xschem is a schematic capture program, it allows creation of hierarchical representation of circuits with a top down approach . By focusing on interfaces, hierarchy and instance properties a complex system can be described in terms of simpler building blocks. A VHDL or Verilog or Spice netlist can be generated from the drawn schematic, allowing the simulation of the circuit. Key feature of the program is its drawing engine written in C and using directly the Xlib drawing primitives; this gives very good speed performance, even on very big circuits. The user interface is built with the Tcl-Tk toolkit, tcl is also the extension language used. DOCUMENTATION AND MANUAL https://xschem.sourceforge.io/stefan/xschem.html BUILDING & INSTALLING Please read the instructions in file INSTALL. SUBDIRECTORIES doc: xschem homepage, reference manual and man pages scconfig: the whole ./configure system (all dependencies included) src: C source for the xschem executable and scripts for GUI and I/O utile: stimuli generator/converter script xschem_library: standard symbol libs and example libs xschem-2.8.1/Makefile0000644000175100017510000000137213366575636012700 0ustar svnsvnall: FORCE cd src && $(MAKE) cd xschem_library && $(MAKE) cd doc && $(MAKE) cd utile && $(MAKE) clean: FORCE cd src && $(MAKE) clean cd xschem_library && $(MAKE) clean cd doc && $(MAKE) clean cd utile && $(MAKE) clean distclean: FORCE $(MAKE) clean ; true cd src && $(MAKE) distclean cd xschem_library && $(MAKE) distclean cd doc && $(MAKE) distclean cd utile && $(MAKE) distclean rm -f Makefile.conf config.h src/Makefile cd scconfig && make distclean install: FORCE cd src && $(MAKE) install cd xschem_library && $(MAKE) install cd doc && $(MAKE) install cd utile && $(MAKE) install uninstall: FORCE cd src && $(MAKE) uninstall cd xschem_library && $(MAKE) uninstall cd doc && $(MAKE) uninstall cd utile && $(MAKE) uninstall FORCE: xschem-2.8.1/xschem_library/0000755000175100017510000000000013400743706014230 5ustar svnsvnxschem-2.8.1/xschem_library/devices/0000755000175100017510000000000013400743706015652 5ustar svnsvnxschem-2.8.1/xschem_library/devices/ipin.sym0000644000175100017510000000044513347721520017346 0ustar svnsvnG {type=ipin format="*.ipin @lab" template="name=p1 lab=xxx" } V {} S {} E {} B 5 -0.009765619999999999 -0.009765619999999999 0.009765619999999999 0.009765619999999999 {name=p dir=out} T {@lab} -18.75 -8.75 0 1 0.4 0.33 {} P 5 6 -0 -0 -6.25 -5 -14.375 -5 -14.375 5 -6.25 5 0 0 {fill=true} xschem-2.8.1/xschem_library/devices/parax_cap.sym0000644000175100017510000000070713023243556020345 0ustar svnsvnG {type=parax_cap format="@name @pinlist @gnd @value m=@m" verilog_ignore=true template="name=c1 gnd=0 value=4f m=1"} V {} S {} L 4 0 -10 0 0 {} L 4 -5 0 5 0 {} L 4 -5 5 5 5 {} L 4 0 5 0 12.5 {} L 4 -2.5 12.5 2.5 12.5 {} L 4 -2.5 12.5 0 15 {} L 4 0 15 2.5 12.5 {} B 5 -2.5 -12.5 2.5 -7.5 {name=p dir=in} T {@value} 10 13.75 0 0 0.2 0.15 {} T {@name} 10 3.75 0 0 0.2 0.15 {} T {@gnd} -5 7.5 0 1 0.2 0.15 {} T {m=@m} 10 -6.25 0 0 0.2 0.15 {} xschem-2.8.1/xschem_library/devices/netlist_at_end.sym0000644000175100017510000000032513023243556021377 0ustar svnsvnG {type=netlist_commands place=end template="name=s1 value=blabla" format=" @value "} V {} S {} L 4 0 -10 70 -10 {} L 4 0 -10 0 10 {} T {NETLIST AT END} 5 -25 0 0 0.3 0.3 {} T {@value} 15 -5 0 0 0.3 0.3 {} xschem-2.8.1/xschem_library/devices/package.sym0000644000175100017510000000156313023243556020003 0ustar svnsvnG {type=package template=" library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; package aaa is type real_vector is array(natural range <>) of real; constant dx : real := 0.001 ; procedure assegna( signal A : inout real; signal A_OLD : in real; A_VAL : in real ); end aaa; -- end package declaration package body aaa is procedure assegna( signal A : inout real; signal A_OLD : in real; A_VAL : in real ) is constant tdelay: time := 0.01 ns; begin if (A /= A_VAL) then A <= A_OLD+dx, A_VAL after tdelay; end if; end assegna; end aaa; -- end package body "} L 4 0 -10 355 -10 {} T {PACKAGE} 5 -25 0 0 0.3 0.3 {} T {@prop_ptr} 25 5 0 0 0.18 0.12 {} xschem-2.8.1/xschem_library/devices/vcr.sym0000644000175100017510000000150513023243556017176 0ustar svnsvnG {type=isource format="@name @@p @@m @function @@cp @@cm @TABLE" template="name=G1 function=\\"vcr pwl(1)\\" TABLE=\\"1 0 2 3\\"" } V {} S {} L 4 -5 15 5 15 {} L 4 15 -5 15 5 {} L 4 -5 -15 5 -15 {} L 4 -15 -5 -15 5 {} L 4 5 -15 11.25 -11.25 {} L 4 11.25 -11.25 15 -5 {} L 4 11.25 11.25 15 5 {} L 4 5 15 11.25 11.25 {} L 4 -11.25 11.25 -5 15 {} L 4 -15 5 -11.25 11.25 {} L 4 -15 -5 -11.25 -11.25 {} L 4 -11.25 -11.25 -5 -15 {} L 4 0 -30 0 -15 {} L 4 0 15 0 30 {} L 4 0 -15 0 15 {} L 4 -20 -20 -10 -20 {} L 4 -15 -25 -15 -15 {} B 5 -2.5 -32.5 2.5 -27.5 {name=p dir=inout} B 5 -2.5 27.5 2.5 32.5 {name=m dir=inout} B 5 -42.5 17.5 -37.5 22.5 {name=cm dir=in} B 5 -42.5 -22.5 -37.5 -17.5 {name=cp dir=in} T {pwl(1)=@TABLE} 20 0 0 0 0.2 0.2 {} T {@function} 20 -12.5 0 0 0.2 0.2 {} T {@name} 20 -25 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/vsource.sym0000644000175100017510000000051113362731551020071 0ustar svnsvnG {type=vsource format="@name @pinlist @value" template="name=v0 value=3"} V {} S {} E {} L 4 2.5 -22.5 7.5 -22.5 {} L 4 5 -25 5 -20 {} L 4 -0 -30 -0 30 {} B 5 -2.5 -32.5 2.5 -27.5 {name=p dir=inout} B 5 -2.5 27.5 2.5 32.5 {name=m dir=inout} A 4 0 0 15 270 360 {} T {@value} 20 0 0 0 0.2 0.2 {} T {@name} 20 -17.5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/verilog_delay.sym0000644000175100017510000000073513023243556021235 0ustar svnsvnG {type=subcircuit format="@name @pinlist @symname" template="name=d1 del=200"} V {} L 4 -40 0 -30 0 {} L 4 -30 -5 -30 5 {} L 4 -30 5 30 5 {} L 4 30 -5 30 5 {} L 4 -30 -5 30 -5 {} L 4 30 -0 40 -0 {} L 6 -0 -2.5 20 -0 {} L 6 -0 -2.5 0 2.5 {} L 6 0 2.5 20 -0 {} L 6 -25 0 -0 -0 {} B 5 -42.5 -2.5 -37.5 2.5 {name=inp dir=in} B 5 37.5 -2.5 42.5 2.5 {name=outp dir=out verilog_type=wire} T {del=@del} -37.5 6.25 0 0 0.15 0.12 {} T {@name} -20 -12.5 0 0 0.12 0.12 {} xschem-2.8.1/xschem_library/devices/diode.sym0000644000175100017510000000063113362731551017472 0ustar svnsvnG {type=diode format="@name @pinlist @model area=@area" template="name=d1 model=dnwpsu area=1"} V {} S {} E {} L 4 0 5 0 30 {} L 4 0 -30 0 -5 {} L 4 -10 5 10 5 {} B 5 -2.5 -32.5 2.5 -27.5 {name=p dir=inout propagate_to=1} B 5 -2.5 27.5 2.5 32.5 {name=m dir=inout} T {area=@area} 12.5 0 0 0 0.25 0.2 {} T {@name} 2.5 -20 0 0 0.2 0.2 {} T {@model} 5 12.5 0 0 0.25 0.2 {} P 4 4 -0 5 -10 -5 10 -5 0 5 {fill=true} xschem-2.8.1/xschem_library/devices/zener.sym0000644000175100017510000000073313357507037017540 0ustar svnsvnG {type=diode format="@name @pinlist @model area=@area" template="name=D1 model=d1n755 area=1"} V {} S {} E {} L 4 0 5 0 30 {} L 4 0 -30 0 -5 {} L 4 -20 5 20 5 {} L 4 20 -5 20 5 {} L 4 -20 5 -20 15 {} L 4 -20 15 -15 15 {} L 4 15 -5 20 -5 {} B 5 -2.5 -32.5 2.5 -27.5 {name=p dir=inout} B 5 -2.5 27.5 2.5 32.5 {name=m dir=inout} T {area=@area} 27.5 0 0 0 0.25 0.2 {} T {@name} 2.5 -20 0 0 0.2 0.2 {} T {@model} 2.5 12.5 0 0 0.25 0.2 {} P 4 4 -0 5 -10 -5 10 -5 -0 5 {fill=true} xschem-2.8.1/xschem_library/devices/generic_pin.sym0000644000175100017510000000035613023243556020671 0ustar svnsvnG {type=generic template="name=g1 generic_type=time value=\\"2 ns\\" lab=xxx"} L 8 -15 -5 -5 -5 {} L 8 -5 -5 0 0 {} L 8 -5 5 0 0 {} L 8 -15 5 -5 5 {} L 8 -15 -5 -15 5 {} T {@lab : @generic_type := @value} -17.5 -7.5 0 1 0.3 0.3 {} xschem-2.8.1/xschem_library/devices/nmos.sym0000644000175100017510000000113113203675434017357 0ustar svnsvnG {type=pmos format="@name @pinlist 0 @model w=@w l=@l m=@m " template="name=m1 model=enbsim3 m=1 w=1u l=0.18u" verilog_format="@symname #@del @name ( @@d , @@s , @@g );"} V {} S {} L 4 5 -20 20 -20 {} L 4 20 -30 20 -20 {} L 4 5 20 20 20 {} L 4 20 20 20 30 {} L 4 -5 -15 -5 15 {} L 4 -5 0 -5 5 {} L 4 -20 0 -12.5 0 {} L 4 -20 0 -5 0 {} L 4 5 -27.5 5 27.5 {} B 5 17.5 -32.5 22.5 -27.5 {name=d dir=inout} B 5 -22.5 -2.5 -17.5 2.5 {name=g dir=in} B 5 17.5 27.5 22.5 32.5 {name=s dir=inout} T {@w/@l/@m} 7.5 -10 0 0 0.25 0.2 {} T {@name} 7.5 5 0 0 0.2 0.2 {} T {D} 22.5 -25 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/param.sym0000644000175100017510000000023113023243556017477 0ustar svnsvnG {type=spice_parameters template="name=s1 value=\\"w=10u\\"" format=".param @value"} L 4 0 -10 90 -10 {} T {PARAMETER @value} 5 -25 0 0 0.3 0.3 {} xschem-2.8.1/xschem_library/devices/vccs.sym0000644000175100017510000000143113023243556017340 0ustar svnsvnG {type=vccs format="@name @pinlist @value" template="name=G1 value=1e-6"} V {} S {} L 4 2.5 -22.5 7.5 -22.5 {} L 4 5 -25 5 -20 {} L 4 -20 -0 -0 -20 {} L 4 -20 -0 -0 20 {} L 4 -0 20 20 0 {} L 4 0 -20 20 0 {} L 4 -40 -20 -35 -20 {} L 4 -30 -20 -25 -20 {} L 4 -20 -20 -15 -20 {} L 4 -40 20 -35 20 {} L 4 -30 20 -25 20 {} L 4 -20 20 -15 20 {} L 4 0 20 0 30 {} L 4 0 -30 0 -20 {} L 4 -5 5 0 10 {} L 4 -5 5 5 5 {} L 4 0 10 5 5 {} L 4 0 -5 0 5 {} L 4 -37.5 -12.5 -32.5 -12.5 {} L 4 -35 -15 -35 -10 {} L 4 -37.5 12.5 -32.5 12.5 {} B 5 -2.5 -32.5 2.5 -27.5 {name=p dir=inout} B 5 -2.5 27.5 2.5 32.5 {name=m dir=inout} B 5 -42.5 -22.5 -37.5 -17.5 {name=cp dir=in} B 5 -42.5 17.5 -37.5 22.5 {name=cm dir=in} T {@value} 20 5 0 0 0.2 0.2 {} T {@name} 20 -17.5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/delay.sym0000644000175100017510000000057413023243556017507 0ustar svnsvnG {type=delay_eldo format="del@name @pinlist @del" template="name=d1 del=2e-9"} V {} L 4 -40 0 -30 0 {} L 4 -30 -10 -30 10 {} L 4 -30 10 30 10 {} L 4 30 -10 30 10 {} L 4 -30 -10 30 -10 {} L 4 30 -0 40 -0 {} B 5 -42.5 -2.5 -37.5 2.5 {name=inp dir=in} B 5 37.5 -2.5 42.5 2.5 {name=outp dir=out} T {del=@del} -27.5 -3.75 0 0 0.15 0.15 {} T {@name} -25 -22.5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/switch_hsp_pwl.sym0000644000175100017510000000111513023243556021436 0ustar svnsvnG {type=switch format="@name @@p @@m VCR pwl(1) @@cp @@cm @pwl m=@m" template="name=G1 pwl=\\"0.0 1G 1.0 0.1\\" m=1"} V {} S {} L 4 2.5 -22.5 7.5 -22.5 {} L 4 5 -25 5 -20 {} L 4 -0 -30 0 -10 {} L 4 -10 -10 -0 10 {} L 4 -0 10 -0 30 {} L 4 -40 0 -5 0 {} L 4 -35 -5 -30 -5 {} L 4 -32.5 -7.5 -32.5 -2.5 {} B 5 -2.5 -32.5 2.5 -27.5 {name=p dir=inout} B 5 -2.5 27.5 2.5 32.5 {name=m dir=inout} B 5 -42.5 -2.5 -37.5 2.5 {name=cp dir=in} B 5 37.5 -2.5 42.5 2.5 {name=cm dir=in} T {@name} 10 -17.5 0 0 0.2 0.2 {} T {R=@pwl } 5 12.5 0 0 0.12 0.16 {} T {VCR} -20 10 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/pnp.sym0000644000175100017510000000070513357507037017211 0ustar svnsvnG {type=pnp format="@name @pinlist @model area=@area" template="name=Q1 model=DPNP area=1"} V {} S {} E {} L 4 0 -30 0 30 {} L 4 -20 0 0 0 {} L 4 10 -20 20 -30 {} L 4 0 10 20 30 {} B 5 17.5 27.5 22.5 32.5 {name=c dir=inout} B 5 -22.5 -2.5 -17.5 2.5 {name=b dir=in} B 5 17.5 -32.5 22.5 -27.5 {name=e dir=inout} T {area=@area} 20 -20 0 0 0.2 0.2 {} T {@model} 20 -5 0 0 0.2 0.2 {} T {@name} 20 10 0 0 0.2 0.2 {} P 4 4 0 -10 15 -15 5 -25 0 -10 {fill=true} xschem-2.8.1/xschem_library/devices/isource_pwl.sym0000644000175100017510000000147013023243556020740 0ustar svnsvnG {type=isource format="@name @@p @@m pwl(1) @@cp @@cm @TABLE" template="name=G1 TABLE=\\"1 0 2 1m\\"" } V {} S {} L 4 2.5 -22.5 7.5 -22.5 {} L 4 5 -25 5 -20 {} L 4 -20 0 0 -20 {} L 4 -20 0 0 20 {} L 4 0 20 20 0 {} L 4 0 -20 20 0 {} L 4 -40 -20 -35 -20 {} L 4 -30 -20 -25 -20 {} L 4 -20 -20 -15 -20 {} L 4 -40 20 -35 20 {} L 4 -30 20 -25 20 {} L 4 -20 20 -15 20 {} L 4 0 20 0 30 {} L 4 0 -30 0 -20 {} L 4 -5 5 0 10 {} L 4 -5 5 5 5 {} L 4 0 10 5 5 {} L 4 0 -5 0 5 {} L 4 -37.5 -12.5 -32.5 -12.5 {} L 4 -35 -15 -35 -10 {} L 4 -37.5 12.5 -32.5 12.5 {} B 5 -2.5 -32.5 2.5 -27.5 {name=p dir=inout} B 5 -2.5 27.5 2.5 32.5 {name=m dir=inout} B 5 -42.5 17.5 -37.5 22.5 {name=cm dir=in} B 5 -42.5 -22.5 -37.5 -17.5 {name=cp dir=in} T {pwl(1)=@TABLE} 20 0 0 0 0.2 0.2 {} T {@name} 20 -15 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/attributes.sym0000644000175100017510000000027513023243556020575 0ustar svnsvnG {type=attributes template=" attribute async_set_reset of RPTL : signal is "true"; "} L 4 -0 -10 355 -10 {} T {VHDL ATTRIBUTES} 5 -25 0 0 0.3 0.3 {} T {@prop_ptr} 45 5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/vcvs.sym0000644000175100017510000000115213023243556017363 0ustar svnsvnG {type=vcvs format="@name @pinlist @value" template="name=E1 value=3"} V {} S {} L 4 2.5 -22.5 7.5 -22.5 {} L 4 5 -25 5 -20 {} L 4 -0 -30 -0 30 {} L 4 -20 -0 -0 -20 {} L 4 -20 -0 -0 20 {} L 4 -0 20 20 0 {} L 4 0 -20 20 0 {} L 4 -40 -20 -35 -20 {} L 4 -30 -20 -25 -20 {} L 4 -20 -20 -15 -20 {} L 4 -40 20 -35 20 {} L 4 -30 20 -25 20 {} L 4 -20 20 -15 20 {} B 5 -2.5 -32.5 2.5 -27.5 {name=p dir=inout} B 5 -2.5 27.5 2.5 32.5 {name=m dir=inout} B 5 -42.5 -22.5 -37.5 -17.5 {name=cp dir=in} B 5 -42.5 17.5 -37.5 22.5 {name=cm dir=in} T {@value} 20 5 0 0 0.2 0.2 {} T {@name} 20 -17.5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/title.sym0000644000175100017510000000067313357507037017541 0ustar svnsvnG {type=logo template="name=l1 author=\\"Stefan Schippers\\"" verilog_ignore=true vhdl_ignore=true spice_ignore=true tedax_ignore=true} V {} S {} E {} L 6 270 0 1020 0 {} L 6 -160 0 -60 0 {} T {@schname} 290 -30 0 0 0.4 0.4 {} T {@author} 290 5 0 0 0.4 0.4 {} T {@time_last_modified} 1020 -20 0 1 0.4 0.3 {} T {SCHEM} 40 -25 0 0 1 1 {} P 5 13 40 -30 10 0 40 30 20 30 -0 10 -20 30 -40 30 -10 -0 -40 -30 -20 -30 -0 -10 20 -30 40 -30 {fill=true} xschem-2.8.1/xschem_library/devices/code.sym0000644000175100017510000000100013347721520017305 0ustar svnsvnG {type=netlist_commands template="name=s1 only_toplevel=false value=blabla" tedax_ignore=true format=" @value "} V {} S {} L 3 20 30 60 30 {} L 3 20 40 40 40 {} L 3 20 50 60 50 {} L 3 20 60 50 60 {} L 3 20 70 50 70 {} L 3 20 80 90 80 {} L 3 20 90 40 90 {} L 3 20 20 70 20 {} L 3 20 10 40 10 {} L 5 100 10 110 10 {} L 5 110 10 110 110 {} L 5 20 110 110 110 {} L 5 20 100 20 110 {} L 5 100 0 100 100 {} L 5 10 100 100 100 {} L 5 10 0 10 100 {} L 5 10 0 100 0 {} T {@name} 15 -25 0 0 0.3 0.3 {} xschem-2.8.1/xschem_library/devices/delay_line.sym0000644000175100017510000000077113023243556020515 0ustar svnsvnG {type=transmission_line format="@name @pinlist z0=@z0 td=@td" template="name=t1 z0=50 td=10n"} L 4 -70 -15 70 -15 {} L 4 -70 -5 70 -5 {} L 4 -70 -5 -70 10 {} L 4 -80 10 -70 10 {} L 4 70 -5 70 10 {} L 4 70 10 80 10 {} L 4 -80 -10 80 -10 {} B 5 -82.5 -12.5 -77.5 -7.5 {name=nap dir=in} B 5 -82.5 7.5 -77.5 12.5 {name=nam dir=in} B 5 77.5 -12.5 82.5 -7.5 {name=nbp dir=out} B 5 77.5 7.5 82.5 12.5 {name=nbm dir=out} T {z0=@z0 delay=@td} -60 -30 0 0 0.25 0.2 {} T {@name} -40 -47.5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/opin.sym0000644000175100017510000000043213347721520017350 0ustar svnsvnG {type=opin format="*.opin @lab" template="name=p1 lab=xxx" } V {} S {} E {} B 5 -0.009765619999999999 -0.009765619999999999 0.009765619999999999 0.009765619999999999 {name=p dir=in} T {@lab} 20 -8.75 0 0 0.4 0.33 {} P 5 6 -0 -5 0 5 8.125 5 14.375 0 8.125 -5 -0 -5 {fill=true} xschem-2.8.1/xschem_library/devices/arch_declarations.sym0000644000175100017510000000027113023243556022050 0ustar svnsvnG {type=arch_declarations template=" signal AAA: std_logic; "} V {} S {} L 4 -0 -10 355 -10 {} T {ARCHITECTURE DECLARATIONS} 5 -25 0 0 0.3 0.3 {} T {HIDDEN} 45 5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/capa.sym0000644000175100017510000000110313343566006017305 0ustar svnsvnG {type=capacitor format="@name @pinlist @value m=@m" tedax_format="footprint @name @footprint value @name @value device @name @device" verilog_ignore=true template="name=c0 m=1 value=1p footprint=1206 device=\\"ceramic capacitor\\""} V {} S {} L 4 0 5 0 30 {} L 4 0 -30 0 -5 {} L 4 -10 -5 10 -5 {} L 4 -10 5 10 5 {} L 4 2.5 -22.5 7.5 -22.5 {} L 4 5 -25 5 -20 {} B 5 -2.5 -32.5 2.5 -27.5 {name=p dir=in pinnumber=1} B 5 -2.5 27.5 2.5 32.5 {name=m dir=in pinnumber=2} T {@value} 15 -5 0 0 0.25 0.2 {} T {@name} 15 -18.75 0 0 0.2 0.2 {} T {m=@m} 15 10 0 0 0.25 0.2 {} xschem-2.8.1/xschem_library/devices/pmos4.sym0000644000175100017510000000142113205374625017447 0ustar svnsvnG {type=pmos format="@name @pinlist @model w=@w l=@l m=@m" template="name=m1 model=pmos w=5u l=0.18u m=1"} V {} S {} L 4 5 -30 5 30 {11} L 4 5 20 20 20 {} L 4 20 20 20 30 {} L 4 5 -20 20 -20 {} L 4 20 -30 20 -20 {} L 4 -5 -15 -5 15 {} L 4 -5 -5 -5 -0 {} L 4 -7.5 -5 -5 -2.5 {} L 4 -10 -5 -7.5 -5 {} L 4 -12.5 -2.5 -10 -5 {} L 4 -12.5 -2.5 -12.5 2.5 {} L 4 -12.5 2.5 -10 5 {} L 4 -10 5 -7.5 5 {} L 4 -7.5 5 -5 2.5 {} L 4 -20 0 -12.5 -0 {} L 4 10 0 20 0 {} L 4 5 -5 10 0 {} L 4 5 5 10 -0 {} B 5 17.5 27.5 22.5 32.5 {name=d dir=inout} B 5 -22.5 -2.5 -17.5 2.5 {name=g dir=in} B 5 17.5 -32.5 22.5 -27.5 {name=s dir=inout} B 5 17.5 -2.5 22.5 2.5 {name=b dir=in} T {@w/@l/@m} 7.5 -15 0 0 0.2 0.2 {} T {@name} 7.5 8.75 0 0 0.2 0.2 {999} T {D} 25 20 0 0 0.15 0.15 {} xschem-2.8.1/xschem_library/devices/launcher.sym0000644000175100017510000000042713362731551020212 0ustar svnsvnG {type=launcher format="** @descr : @url" verilog_ignore=true vhdl_ignore=true spice_ignore=true template="name=h1 descr=google url=www.google.com"} V {} S {} E {} T {@descr} 10 -10 0 0 0.4 0.4 {} P 4 9 -0 -0 -30 -12.5 -30 -5 -60 -5 -50 0 -60 5 -30 5 -30 12.5 -0 0 {fill=true} xschem-2.8.1/xschem_library/devices/pmos3.sym0000644000175100017510000000115013023243556017441 0ustar svnsvnG {type=pmos format="@name @pinlist @model" template="name=x1 model=irf5305"} L 4 5 -30 5 30 {11} L 4 5 20 20 20 {} L 4 20 20 20 30 {} L 4 5 -20 20 -20 {} L 4 20 -30 20 -20 {} L 4 -5 -15 -5 15 {} L 4 -5 -5 -5 -0 {} L 4 -7.5 -5 -5 -2.5 {} L 4 -10 -5 -7.5 -5 {} L 4 -12.5 -2.5 -10 -5 {} L 4 -12.5 -2.5 -12.5 2.5 {} L 4 -12.5 2.5 -10 5 {} L 4 -10 5 -7.5 5 {} L 4 -7.5 5 -5 2.5 {} L 4 -20 0 -12.5 -0 {} B 5 17.5 27.5 22.5 32.5 {name=d dir=inout} B 5 -22.5 -2.5 -17.5 2.5 {name=g dir=in} B 5 17.5 -32.5 22.5 -27.5 {name=s dir=inout} T {@model} 7.5 -17.5 0 0 0.2 0.2 {} T {@name} 7.5 5 0 0 0.2 0.2 {999} xschem-2.8.1/xschem_library/devices/nmos4.sym0000644000175100017510000000116613205374625017453 0ustar svnsvnG {type=nmos format="@name @pinlist @model w=@w l=@l m=@m" template="name=m1 model=nmos w=5u l=0.18u m=1"} V {} S {} L 4 5 -30 5 30 {} L 4 5 -20 20 -20 {} L 4 20 -30 20 -20 {} L 4 5 20 20 20 {} L 4 20 20 20 30 {} L 4 -5 -15 -5 15 {} L 4 -5 0 -5 5 {} L 4 -20 0 -12.5 0 {} L 4 -20 0 -5 0 {} L 4 10 0 20 0 {} L 4 5 -5 10 0 {} L 4 5 5 10 -0 {} B 5 17.5 -32.5 22.5 -27.5 {name=d dir=inout} B 5 -22.5 -2.5 -17.5 2.5 {name=g dir=in} B 5 17.5 27.5 22.5 32.5 {name=s dir=inout} B 5 17.5 -2.5 22.5 2.5 {name=b dir=in} T {@w/@l/@m} 7.5 -15 0 0 0.2 0.2 {} T {@name} 7.5 8.75 0 0 0.2 0.2 {} T {D} 25 -27.5 0 0 0.15 0.15 {} xschem-2.8.1/xschem_library/devices/nmos3.sym0000644000175100017510000000073513023243556017447 0ustar svnsvnG {type=nmos format="@name @pinlist @model m=@m" template="name=x1 model=irf540 m=1"} V {} S {} L 4 5 -30 5 30 {} L 4 5 -20 20 -20 {} L 4 20 -30 20 -20 {} L 4 5 20 20 20 {} L 4 20 20 20 30 {} L 4 -5 -15 -5 15 {} L 4 -20 0 -5 0 {} B 5 17.5 -32.5 22.5 -27.5 {name=d dir=inout} B 5 -22.5 -2.5 -17.5 2.5 {name=g dir=in} B 5 17.5 27.5 22.5 32.5 {name=s dir=inout} T {D} 25 -27.5 0 0 0.2 0.2 {} T {@name} 7.5 5 0 0 0.2 0.2 {} T {@model x @m} 7.5 -12.5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/verilog_timescale.sym0000644000175100017510000000043213023243556022077 0ustar svnsvnG {type=timescale spice_ignore=true template="name=s1 timestep=\\"100ps\\" precision=\\"100ps\\" " format="`timescale @timestep/@precision"} V {} L 4 0 -10 70 -10 {} L 4 0 -10 0 10 {} T {TIMESCALE} 5 -25 0 0 0.3 0.3 {} T {`timescale @timestep/@precision} 15 -5 0 0 0.3 0.3 {} xschem-2.8.1/xschem_library/devices/use.sym0000644000175100017510000000036313023243556017201 0ustar svnsvnG {type=use template=" library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; "} L 4 -0 -10 355 -10 {} T {VHDL USE} 5 -25 0 0 0.3 0.3 {} T {@prop_ptr} 45 5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/k.sym0000644000175100017510000000041213023243556016632 0ustar svnsvnG {type=coupler format="@name @L1 @L2 @K" template="name=K1 K=0.9 L1=L1 L2=L2"} V {} S {} L 4 5 -30 5 30 {} L 4 -5 -30 -5 30 {} T {K=@K} -20 60 0 0 0.25 0.2 {} T {@name} -20 42.5 0 0 0.2 0.2 {} T {@L1} -10 -10 0 1 0.25 0.2 {} T {@L2} 10 -10 0 0 0.25 0.2 {} xschem-2.8.1/xschem_library/devices/noconn.sym0000644000175100017510000000066313023243556017702 0ustar svnsvnG {type=noconn format="* noconn " vhdl_ignore=true verilog_ignore=true spice_ignore=true template="name=l1"} V {} L 4 -3.75 0 0 -0 {} L 4 -6.25 -3.75 -3.75 -1.25 {} L 4 -8.75 -3.75 -6.25 -3.75 {} L 4 -11.25 -1.25 -8.75 -3.75 {} L 4 -11.25 -1.25 -11.25 1.25 {} L 4 -11.25 1.25 -8.75 3.75 {} L 4 -8.75 3.75 -6.25 3.75 {} L 4 -6.25 3.75 -3.75 1.25 {} L 4 -3.75 -1.25 -3.75 1.25 {} B 5 -1.25 -1.25 1.25 1.25 {name=p dir=inout} xschem-2.8.1/xschem_library/devices/connect.sym0000644000175100017510000000101213232362134020022 0ustar svnsvnG {type=resistor format="@name @pinlist 0.01 m=@m" template="name=r1 m=1"} V {} S {} L 4 2.5 -22.5 7.5 -22.5 {} L 4 5 -25 5 -20 {} L 4 0 -30 -0 -15 {} L 4 0 -15 5 -15 {} L 4 5 -15 5 15 {} L 4 -5 15 5 15 {} L 4 -5 -15 -5 15 {} L 4 -5 -15 0 -15 {} L 4 -0 15 -0 30 {} L 4 -5 -10 -0 -15 {} L 4 -5 -5 5 -15 {} L 4 -5 -0 5 -10 {} L 4 -5 5 5 -5 {} L 4 -5 10 5 0 {} L 4 -5 15 5 5 {} L 4 0 15 5 10 {} B 5 -2.5 -32.5 2.5 -27.5 {name=p dir=out propagate_to=1} B 5 -2.5 27.5 2.5 32.5 {name=m dir=in propagate_to=0} xschem-2.8.1/xschem_library/devices/package_not_shown.sym0000644000175100017510000000170213023243556022074 0ustar svnsvnG {type=package template=" -- THIS IS A TEMPLATE, REPLACE WITH ACTUAL CODE OR REMOVE INSTANCE!! library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; package aaa is type real_vector is array(natural range <>) of real; constant dx : real := 0.001 ; procedure assegna( signal A : inout real; signal A_OLD : in real; A_VAL : in real ); end aaa; -- end package declaration package body aaa is procedure assegna( signal A : inout real; signal A_OLD : in real; A_VAL : in real ) is constant tdelay: time := 0.01 ns; begin if (A /= A_VAL) then A <= A_OLD+dx, A_VAL after tdelay; end if; end assegna; end aaa; -- end package body "} V {} S {} L 4 0 -10 355 -10 {} T {PACKAGE} 5 -25 0 0 0.3 0.3 {} T {HIDDEN} 135 -5 0 0 0.3 0.3 {} xschem-2.8.1/xschem_library/devices/res.sym0000644000175100017510000000133113343566006017175 0ustar svnsvnG {type=resistor format="@name @pinlist @value m=@m" tedax_format="value @name @value device @name @device" template="name=r0 m=1 value=1k footprint=res10 device=resistor"} V {} S {} L 4 0 20 0 30 {} L 4 0 20 7.5 17.5 {} L 4 -7.5 12.5 7.5 17.5 {} L 4 -7.5 12.5 7.5 7.5 {} L 4 -7.5 2.5 7.5 7.5 {} L 4 -7.5 2.5 7.5 -2.5 {} L 4 -7.5 -7.5 7.5 -2.5 {} L 4 -7.5 -7.5 7.5 -12.5 {} L 4 -7.5 -17.5 7.5 -12.5 {} L 4 -7.5 -17.5 0 -20 {} L 4 0 -30 0 -20 {} L 4 2.5 -22.5 7.5 -22.5 {} L 4 5 -25 5 -20 {} B 5 -2.5 -32.5 2.5 -27.5 {name=p dir=inout propagate_to=1} B 5 -2.5 27.5 2.5 32.5 {name=m dir=inout propagate_to=0} T {@name} 15 -18.75 0 0 0.2 0.2 {} T {@value} 15 -3.75 0 0 0.2 0.2 {} T {m=@m} 15 11.25 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/assign.sym0000644000175100017510000000103013343566006017664 0ustar svnsvnG {type=delay verilog_format="assign #@delay @@d = @@s ;" vhdl_format=" @@d <= @@s after @delay ns;" format="@name @pinlist 0" template="name=v1 delay=1" } V {} S {} L 4 -30 0 30 0 {} L 4 -10 -5 10 0 {type=subcircuit verilog_format="assign #@delay @@d =@@s ;" format="@name .connect @pinlist" template="name=x1 delay=1" } L 4 -10 5 10 0 {} B 5 27.5 -2.5 32.5 2.5 {name=d dir=out verilog_type=wire propagate_to=1} B 5 -32.5 -2.5 -27.5 2.5 {name=s dir=in verilog_type=wire propagate_to=0} T {@name @delay} -25 -10 0 0 0.1 0.1 {} xschem-2.8.1/xschem_library/devices/lab_wire.sym0000644000175100017510000000026113215056040020157 0ustar svnsvnG {type=label format="*.alias @lab" template="name=l1 sig_type=std_logic lab=xxx"} V {} S {} B 5 -1.25 -1.25 1.25 1.25 {name=p dir=in} T {@lab} -3.75 -18.75 0 1 0.33 0.27 {} xschem-2.8.1/xschem_library/devices/pmosnat.sym0000644000175100017510000000124713023243556020070 0ustar svnsvnG {type=pmos format="@name @pinlist vdd @model number=@m w=@w l=@l" template="name=x1 model=npbsim3 m=1 w=5u l=2u"} L 4 5 20 20 20 {} L 4 20 20 20 30 {} L 4 5 -20 20 -20 {} L 4 20 -30 20 -20 {} L 4 -5 -15 -5 15 {} L 4 -5 -5 -5 -0 {} L 4 -7.5 -5 -5 -2.5 {} L 4 -10 -5 -7.5 -5 {} L 4 -12.5 -2.5 -10 -5 {} L 4 -12.5 -2.5 -12.5 2.5 {} L 4 -12.5 2.5 -10 5 {} L 4 -10 5 -7.5 5 {} L 4 -7.5 5 -5 2.5 {} L 4 -20 0 -12.5 -0 {} L 4 10 -20 10 20 {} L 4 5 -27.5 5 27.5 {} B 5 17.5 27.5 22.5 32.5 {name=d dir=inout} B 5 -22.5 -2.5 -17.5 2.5 {name=g dir=in} B 5 17.5 -32.5 22.5 -27.5 {name=s dir=inout} T {@w/@l/@m} 12.5 -17.5 0 0 0.25 0.2 {} T {@name} 12.5 5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/iopin.sym0000644000175100017510000000046013347721520017522 0ustar svnsvnG {type=iopin format="*.iopin @lab" template="name=p1 lab=xxx" } V {} S {} E {} B 5 -0.0098 -0.009765619999999999 0.0098 0.009765619999999999 {name=p dir=inout} T {@lab} 19.8438 -8.75 0 0 0.4 0.33 {} P 5 7 0 0 5.625 -4.84375 10.7812 -4.84375 16.4062 -0 10.7812 4.84375 5.625 4.84375 -0 0 {fill=true} xschem-2.8.1/xschem_library/devices/pmos.sym0000644000175100017510000000150313203675434017364 0ustar svnsvnG {type=pmos format="@name @pinlist VDD @model w=@w l=@l number=@m nfing=@nfing srcefirst=@srcefirst mismatch=1" template="name=x1 model=epbsim3 m=1 w=2u l=0.18u nfing=1 srcefirst=1 del=10" verilog_format="@symname #@del @name ( @@d , @@s , @@g );"} V {} S {} L 4 5 -27.5 5 27.5 {} L 4 5 20 20 20 {} L 4 20 20 20 30 {} L 4 5 -20 20 -20 {} L 4 20 -30 20 -20 {} L 4 -5 -15 -5 15 {} L 4 -5 -5 -5 -0 {} L 4 -7.5 -5 -5 -2.5 {} L 4 -10 -5 -7.5 -5 {} L 4 -12.5 -2.5 -10 -5 {} L 4 -12.5 -2.5 -12.5 2.5 {} L 4 -12.5 2.5 -10 5 {} L 4 -10 5 -7.5 5 {} L 4 -7.5 5 -5 2.5 {} L 4 -20 0 -12.5 -0 {} B 5 17.5 27.5 22.5 32.5 {name=d dir=inout} B 5 -22.5 -2.5 -17.5 2.5 {name=g dir=in} B 5 17.5 -32.5 22.5 -27.5 {name=s dir=inout} T {@w/@l/@m} 7.5 -17.5 0 0 0.25 0.2 {} T {@name} 7.5 0 0 0 0.2 0.2 {} T {D} 22.5 12.5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/switch_hsp.sym0000644000175100017510000000115613023243556020561 0ustar svnsvnG {type=switch format="@name @@p @@m VCR @@cp @@cm @v_to_r max=@max min=@min m=@m" template="name=G1 v_to_r=1G max=1G min=1 m=1"} V {} S {} L 4 2.5 -22.5 7.5 -22.5 {} L 4 5 -25 5 -20 {} L 4 -0 -30 0 -10 {} L 4 -10 -10 -0 10 {} L 4 -0 10 -0 30 {} L 4 -40 0 -5 0 {} L 4 -35 -5 -30 -5 {} L 4 -32.5 -7.5 -32.5 -2.5 {} B 5 -2.5 -32.5 2.5 -27.5 {name=p dir=inout} B 5 -2.5 27.5 2.5 32.5 {name=m dir=inout} B 5 -42.5 -2.5 -37.5 2.5 {name=cp dir=in} B 5 37.5 -2.5 42.5 2.5 {name=cm dir=in} T {@name} 10 -17.5 0 0 0.2 0.2 {} T {GAIN=@v_to_r MAX=@max MIN=@min} 10 12.5 0 0 0.2 0.2 {} T {VCR} -20 10 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/cccs.sym0000644000175100017510000000070413023243556017317 0ustar svnsvnG {type=vcvs format="@name @pinlist @vnam @value" template="name=f1 vnam=v1 value=1"} L 4 0 -20 20 -0 {} L 4 -20 0 0 -20 {} L 4 -20 0 0 20 {} L 4 0 20 20 0 {} L 4 0 20 0 30 {} L 4 0 -30 -0 -20 {} L 4 -5 5 0 10 {} L 4 -5 5 5 5 {} L 4 0 10 5 5 {} L 4 0 -5 0 5 {} B 5 -2.5 -32.5 2.5 -27.5 {name=p dir=in} B 5 -2.5 27.5 2.5 32.5 {name=m dir=in} T {@value} 25 10 0 0 0.2 0.2 {} T {@name} 25 -15 0 0 0.2 0.2 {} T {@vnam} 25 -2.5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/isource.sym0000644000175100017510000000060113362731551020054 0ustar svnsvnG {type=isource format="@name @pinlist @value" template="name=i0 value=1m"} V {} S {} E {} L 4 0 -30 0 -15 {} L 4 0 15 0 30 {} L 4 2.5 -22.5 7.5 -22.5 {} L 4 5 -25 5 -20 {} L 4 -5 5 0 10 {} L 4 -5 5 5 5 {} L 4 0 10 5 5 {} L 4 0 -5 0 5 {} B 5 -2.5 -32.5 2.5 -27.5 {name=p dir=inout} B 5 -2.5 27.5 2.5 32.5 {name=m dir=inout} A 4 0 0 15 270 360 {} T {@name @value} 20 -10 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/vsource_pwl.sym0000644000175100017510000000070413362731551020757 0ustar svnsvnG {type=isource format="@name @@p @@m pwl(1) @@cp @@cm @TABLE" template="name=E1 TABLE=\\"1 0 2 3\\"" } V {} S {} E {} L 4 -20 -20 -10 -20 {} L 4 -15 -25 -15 -15 {} L 4 -0 -30 -0 30 {} B 5 -2.5 -32.5 2.5 -27.5 {name=p dir=inout} B 5 -2.5 27.5 2.5 32.5 {name=m dir=inout} B 5 -42.5 17.5 -37.5 22.5 {name=cm dir=in} B 5 -42.5 -22.5 -37.5 -17.5 {name=cp dir=in} A 4 0 0 15 270 360 {} T {pwl(1)=@TABLE} 20 0 0 0 0.2 0.2 {} T {@name} 20 -15 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/spice_probe_vdiff.sym0000644000175100017510000000075113105134716022054 0ustar svnsvnG {type=probe format=".probe @analysis v( @@p , @@m )" template="name=p1 analysis=tran"} V {} S {} L 4 0 -17.5 0 -12.5 {} L 4 -2.5 -15 2.5 -15 {} L 4 -2.5 15 2.5 15 {} L 5 -5 0 0 0 {} L 5 0 -3.75 0 0 {} L 5 0 -3.75 3.75 -3.75 {} L 5 3.75 -3.75 3.75 0 {} L 5 3.75 0 7.5 0 {} L 5 7.5 -3.75 7.5 0 {} L 5 7.5 -3.75 10.3125 -3.75 {} L 18 -7.5 -7.5 -7.5 6.25 {} L 18 -10 3.75 11.25 3.75 {} B 5 -1.25 -21.25 1.25 -18.75 {name=p dir=in} B 5 -1.25 18.75 1.25 21.25 {name=m dir=in} xschem-2.8.1/xschem_library/devices/bus_connect.sym0000644000175100017510000000030413023243556020702 0ustar svnsvnG {type=label format=".alias @lab" template="name=l1 lab=xxx"} V {} L 1 10 -10 20 -0 {} L 1 0 -0 10 -10 {} B 5 8.75 -11.25 11.25 -8.75 {name=p dir=inout} T {@lab} 13.75 -21.25 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/bus_connect_not_shown.sym0000644000175100017510000000023713023243556023005 0ustar svnsvnG {type=label format=".alias @lab" template="name=l1 lab=xxx"} V {} L 1 10 -10 20 -0 {} L 1 0 -0 10 -10 {} B 5 8.75 -11.25 11.25 -8.75 {name=p dir=inout} xschem-2.8.1/xschem_library/devices/pmoshv4.sym0000644000175100017510000000122613362731551020007 0ustar svnsvnG {type=pmos format="@name @pinlist @model w=@w l=@l number=@m" template="name=x1 model=tepbsim3 m=1 w=5u l=0.7u"} V {} S {} E {} L 4 5 -27.5 5 27.5 {11} L 4 5 20 20 20 {} L 4 5 -20 20 -20 {} L 4 20 -30 20 -20 {} L 4 -5 -15 -5 15 {} L 4 -20 0 -12.5 -0 {} L 4 10 0 20 0 {} L 4 5 -5 10 0 {} L 4 5 5 10 -0 {} L 4 20 20 20 30 {} B 5 17.5 27.5 22.5 32.5 {name=d dir=inout} B 5 -22.5 -2.5 -17.5 2.5 {name=g dir=in} B 5 17.5 -32.5 22.5 -27.5 {name=s dir=inout} B 5 17.5 -2.5 22.5 2.5 {name=b dir=in} A 4 -8.75 -0 3.75 180 360 {} T {@w/@l/@m} 7.5 5 0 0 0.25 0.2 {} T {@name} 7.5 -17.5 0 0 0.2 0.2 {999} T {HV} -20 -20 0 0 0.2 0.2 {} T {D} 11.875 23.125 0 0 0.15 0.15 {} xschem-2.8.1/xschem_library/devices/ccvs.sym0000644000175100017510000000065313023243556017345 0ustar svnsvnG {type=vcvs format="@name @pinlist @vnam @value" template="name=h1 vnam=v1 value=1"} V {} S {} L 4 0 -20 20 -0 {} L 4 -20 0 0 -20 {} L 4 -20 0 0 20 {} L 4 0 20 20 0 {} L 4 0 -30 0 30 {} L 4 10 -20 20 -20 {} L 4 15 -25 15 -15 {} B 5 -2.5 -32.5 2.5 -27.5 {name=p dir=inout} B 5 -2.5 27.5 2.5 32.5 {name=m dir=inout} T {@value} 25 10 0 0 0.2 0.2 {} T {@name} 25 -15 0 0 0.2 0.2 {} T {@vnam} 25 -2.5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/flash_cell.sym0000644000175100017510000000117513023243556020503 0ustar svnsvnG {type=flash vhdl_stop=true format="@name @pinlist @model dvt=@dvt width=@width length=@length m=1" template="name=x1 model=flash1 dvt=0 width=0.16u length=0.3u m=1"} L 4 -15 -30 -15 30 {} L 4 -15 -20 0 -20 {} L 4 0 -30 0 -20 {} L 4 -15 20 0 20 {} L 4 0 20 0 30 {} L 4 -30 -15 -30 15 {} L 4 -30 0 -30 5 {} L 4 -40 0 -32.5 0 {} L 4 -40 0 -30 0 {} L 4 -15 0 0 0 {} L 8 -22.5 -15 -22.5 15 {} B 5 -2.5 -32.5 2.5 -27.5 {name=D dir=inout} B 5 -42.5 -2.5 -37.5 2.5 {name=G dir=in} B 5 -2.5 27.5 2.5 32.5 {name=S dir=inout} B 5 -2.5 -2.5 2.5 2.5 {name=B dir=in} T {DVT=@dvt} -11 4 0 0 0.2 0.2 {} T {@name} -10 -12 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/npn.sym0000644000175100017510000000076113357507037017211 0ustar svnsvnG {type=npn format="@name @pinlist @model area=@area" template="name=Q1 model=T11 area=1"} V {} S {} E {} L 4 0 -30 0 30 {} L 4 -20 0 -12.5 0 {} L 4 -20 0 0 0 {} L 4 -0 10 8.75 18.75 {} L 4 0 -10 20 -30 {} B 5 17.5 -32.5 22.5 -27.5 {name=c dir=inout} B 5 -22.5 -2.5 -17.5 2.5 {name=b dir=in} B 5 17.5 27.5 22.5 32.5 {name=e dir=inout} T {area=@area} 20 -20 0 0 0.2 0.2 {} T {@model} 20 -5 0 0 0.2 0.2 {} T {@name} 20 10 0 0 0.2 0.2 {} P 4 4 17.5 27.5 13.75 13.75 3.75 23.75 17.5 27.5 {fill=true} xschem-2.8.1/xschem_library/devices/spice_probe.sym0000644000175100017510000000075513362731551020707 0ustar svnsvnG {type=probe vhdl_ignore=true verilog_ignore=true format=".probe @analysis v( @@p )" template="name=p1 analysis=tran"} V {} S {} E {} L 3 10 -27.5 10 -13.75 {} L 3 7.5 -16.25 28.75 -16.25 {} L 4 3.75 -8.75 10 -16.25 {} L 4 0 -0 3.75 -8.75 {} L 5 12.5 -20 17.5 -20 {} L 5 17.5 -23.75 17.5 -20 {} L 5 17.5 -23.75 21.25 -23.75 {} L 5 21.25 -23.75 21.25 -20 {} L 5 21.25 -20 25 -20 {} L 5 25 -23.75 25 -20 {} L 5 25 -23.75 27.8125 -23.75 {} B 5 -0.15625 -0.15625 0.15625 0.15625 {name=p dir=xxx} xschem-2.8.1/xschem_library/devices/port_attributes.sym0000644000175100017510000000030713023243556021635 0ustar svnsvnG {type=port_attributes template=" attribute async_set_reset of RPTL : signal is "true"; "} L 4 -0 -10 355 -10 {} T {VHDL PORT ATTRIBUTES} 5 -25 0 0 0.3 0.3 {} T {@prop_ptr} 45 5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/ammeter.sym0000644000175100017510000000046713235315461020044 0ustar svnsvnG {type=vsource format="@name @pinlist 0 .probe i( @name )" template="name=vmeasure"} V {} S {} L 4 -7.5 0 -0 10 {} L 4 -0 10 7.5 0 {} L 13 0 -30 0 30 {} B 5 -2.5 -32.5 2.5 -27.5 {name=p dir=inout propagate_to=1} B 5 -2.5 27.5 2.5 32.5 {name=m dir=inout propagate_to=0} T {@name} 10 -17.5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/verilog_delay.sch0000644000175100017510000000034613023243556021200 0ustar svnsvnG {} V {// This is a transport (non inertial) delay reg x; always @(inp) x <= #del inp; assign outp = x; } S {} C {devices/ipin} 60 -50 0 0 {name=p1 lab=inp} C {devices/opin} 160 -50 0 0 {name=p2 lab=outp verilog_type=wire} xschem-2.8.1/xschem_library/devices/tline_hsp.sym0000644000175100017510000000111613023243556020367 0ustar svnsvnG {type=tline format="@name @pinlist TD=@TD Z0=@Z0" template="name=t1 TD=4n Z0=50"} V {} S {} L 4 -30 0 -20 0 {} L 4 -20 -10 -20 0 {} L 4 -20 -10 20 -10 {} L 4 20 -10 20 0 {} L 4 20 0 30 0 {} L 4 20 0 20 10 {} L 4 -20 10 20 10 {} L 4 -20 0 -20 10 {} L 4 0 -5 10 -0 {} L 4 0 -5 10 -0 {} L 4 0 5 10 -0 {} L 4 -10 -0 10 0 {} B 5 -32.5 -2.5 -27.5 2.5 {name=cp dir=in} B 5 -32.5 17.5 -27.5 22.5 {name=cm dir=in} B 5 27.5 -2.5 32.5 2.5 {name=p dir=inout} B 5 27.5 17.5 32.5 22.5 {name=m dir=inout} T {@name} -20 -27.5 0 0 0.2 0.2 {} T {TD=@TD Z0=@Z0} -20 32.5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/netlist.sym0000644000175100017510000000027613023243556020072 0ustar svnsvnG {type=netlist_commands template="name=s1 value=blabla" format=" @value "} V {} L 4 0 -10 70 -10 {} L 4 0 -10 0 10 {} T {NETLIST} 5 -25 0 0 0.3 0.3 {} T {@value} 15 -5 0 0 0.3 0.3 {} xschem-2.8.1/xschem_library/devices/architecture.sym0000644000175100017510000000034413023243556021066 0ustar svnsvnG {type=architecture template=" nothing here, use global schematic properties "} V {} S {} L 4 0 -10 355 -10 {} T {ARCHITECTURE} 5 -25 0 0 0.3 0.3 {} T {@schprop ---- @schverilogprop ---- @schvhdlprop} 45 5 0 0 0.3 0.3 {} xschem-2.8.1/xschem_library/devices/netlist_not_shown.sym0000644000175100017510000000075613232362134022167 0ustar svnsvnG {type=netlist_commands template="name=s1 only_toplevel=false value=blabla" format=" @value "} V {} S {} L 3 20 30 60 30 {} L 3 20 40 40 40 {} L 3 20 50 60 50 {} L 3 20 60 50 60 {} L 3 20 70 50 70 {} L 3 20 80 90 80 {} L 3 20 90 40 90 {} L 3 20 20 70 20 {} L 3 20 10 40 10 {} L 5 100 10 110 10 {} L 5 110 10 110 110 {} L 5 20 110 110 110 {} L 5 20 100 20 110 {} L 5 100 0 100 100 {} L 5 10 100 100 100 {} L 5 10 0 10 100 {} L 5 10 0 100 0 {} T {@name} 15 -25 0 0 0.3 0.3 {} xschem-2.8.1/xschem_library/devices/vdd.sym0000644000175100017510000000032713023243556017162 0ustar svnsvnG {type=label global=1 format="*.alias @lab" template="name=l1 lab=VDD"} V {} L 4 0 -20 0 0 {} L 4 -10 -20 10 -20 {} B 5 -2.5 -2.5 2.5 2.5 {name=p dir=inout verilog_type=wire} T {@lab} -12.5 -35 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/vsource_arith.sym0000644000175100017510000000061513362731551021265 0ustar svnsvnG {type=isource format="@name @pinlist VOL=' @VOL ' MIN=' @MIN ' MAX=' @MAX '" template="name=E1 VOL=cos(V(IN)) MAX=1.8 MIN=0" } V {} S {} E {} L 4 -20 -20 -10 -20 {} L 4 -15 -25 -15 -15 {} L 4 0 -30 0 30 {} B 5 -2.5 -32.5 2.5 -27.5 {name=p dir=inout} B 5 -2.5 27.5 2.5 32.5 {name=m dir=inout} A 4 0 0 15 270 360 {} T {@VOL MIN=@MIN MAX=@MAX} 20 0 0 0 0.2 0.2 {} T {@name} 20 -17.5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/generic.sym0000644000175100017510000000023613023243556020020 0ustar svnsvnG {type=label format=".alias @lab" template="name=l1 lab=lll value=xxx"} B 5 -1.25 -1.25 1.25 1.25 {name=p dir=in} T {@lab = @value} -7.5 -5 0 1 0.3 0.3 {} xschem-2.8.1/xschem_library/devices/ind.sym0000644000175100017510000000301313362731551017155 0ustar svnsvnG {type=inductor format="@name @pinlist @value" template="name=l1 value=10n"} V {} S {} E {} L 4 -5 -18.75 0 -21.25 {} L 4 -7.5 -16.25 -5 -18.75 {} L 4 -7.5 -16.25 -7.5 -13.75 {} L 4 -7.5 -13.75 -5 -11.25 {} L 4 -5 -11.25 0 -8.75 {} L 4 -5 -11.25 0 -13.75 {} L 4 -7.5 -8.75 -5 -11.25 {} L 4 -7.5 -8.75 -7.5 -6.25 {} L 4 -7.5 -6.25 -5 -3.75 {} L 4 -5 -3.75 0 -1.25 {} L 4 -5 -3.75 0 -6.25 {} L 4 -7.5 -1.25 -5 -3.75 {} L 4 -7.5 -1.25 -7.5 1.25 {} L 4 -7.5 1.25 -5 3.75 {} L 4 -5 3.75 0 6.25 {} L 4 -5 3.75 0 1.25 {} L 4 -7.5 6.25 -5 3.75 {} L 4 -7.5 6.25 -7.5 8.75 {} L 4 -7.5 8.75 -5 11.25 {} L 4 -5 11.25 0 13.75 {} L 4 -5 11.25 0 8.75 {} L 4 -7.5 13.75 -5 11.25 {} L 4 -7.5 13.75 -7.5 16.25 {} L 4 -7.5 16.25 -5 18.75 {} L 4 -5 18.75 0 21.25 {} L 4 0 -30 -0 -21.25 {} L 4 0 21.25 0 30 {} L 4 0 -13.75 2.5 -15 {} L 4 2.5 -15 6.5625 -14.0625 {} L 4 6.5625 -14.0625 7.5 -11.5625 {} L 4 6.25 -10 7.5 -11.5625 {} L 4 0 -8.75 6.25 -10 {} L 4 0 -6.25 2.5 -7.5 {} L 4 2.5 -7.5 6.5625 -6.5625 {} L 4 6.5625 -6.5625 7.5 -4.0625 {} L 4 6.25 -2.5 7.5 -4.0625 {} L 4 0 -1.25 6.25 -2.5 {} L 4 0 1.25 2.5 0 {} L 4 2.5 0 6.5625 0.9375 {} L 4 6.5625 0.9375 7.5 3.4375 {} L 4 6.25 5 7.5 3.4375 {} L 4 0 6.25 6.25 5 {} L 4 0 8.75 2.5 7.5 {} L 4 2.5 7.5 6.5625 8.4375 {} L 4 6.5625 8.4375 7.5 10.9375 {} L 4 6.25 12.5 7.5 10.9375 {} L 4 0 13.75 6.25 12.5 {} L 4 7.5 -26.25 7.5 -21.25 {} L 4 5 -23.75 10 -23.75 {} B 5 -2.5 -32.5 2.5 -27.5 {name=p dir=inout} B 5 -2.5 27.5 2.5 32.5 {name=m dir=inout} T {@value} 20 0 0 0 0.25 0.2 {} T {@name} 20 -17.5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/gnd.sym0000644000175100017510000000035713023243556017160 0ustar svnsvnG {type=label global=1 format="*.alias @lab" template="name=l1 lab=GND"} V {} L 4 0 0 0 12.5 {} L 4 -5 12.5 5 12.5 {} L 4 0 17.5 5 12.5 {} L 4 -5 12.5 0 17.5 {} B 5 -2.5 -2.5 2.5 2.5 {name=p dir=inout} T {@lab} 7.5 5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/delay_hsp.sym0000644000175100017510000000116713023243556020360 0ustar svnsvnG {type=delay format="@name @@p @@m DELAY @@cp @@cm TD=' @DEL ' SCALE=' @SCALE '" template="name=E1 DEL=1n SCALE=1"} V {} S {} L 4 -30 0 -20 0 {} L 4 -20 -10 -20 0 {} L 4 -20 -10 20 -10 {} L 4 20 -10 20 0 {} L 4 20 0 30 0 {} L 4 20 0 20 10 {} L 4 -20 10 20 10 {} L 4 -20 0 -20 10 {} L 4 0 -5 10 -0 {} L 4 0 -5 10 -0 {} L 4 0 5 10 -0 {} L 4 -10 -0 10 0 {} B 5 27.5 -2.5 32.5 2.5 {name=p dir=inout} B 5 27.5 17.5 32.5 22.5 {name=m dir=inout} B 5 -32.5 -2.5 -27.5 2.5 {name=cp dir=in} B 5 -32.5 17.5 -27.5 22.5 {name=cm dir=in} T {@name} -20 -27.5 0 0 0.2 0.2 {} T {DEL=@DEL SCALE=@SCALE} -20 32.5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/lab_pin.sym0000644000175100017510000000025613203675434020016 0ustar svnsvnG {type=label format="*.alias @lab" template="name=l1 sig_type=std_logic lab=xxx"} V {} S {} B 5 -1.25 -1.25 1.25 1.25 {name=p dir=in} T {@lab} -7.5 -7.5 0 1 0.36 0.33 {} xschem-2.8.1/xschem_library/devices/param_agauss.sym0000644000175100017510000000040013023243556021040 0ustar svnsvnG {type=spice_parameters template="name=s1 sigma=1u param=W value=10u " format=".param @param = agauss(@value , @sigma , 1)"} V {} S {} L 4 0 -10 140 -10 {} T { PARAMETER name: @param value: @value 1-sigma: @sigma} 5 -25 0 0 0.3 0.3 {} xschem-2.8.1/xschem_library/devices/switch.sym0000644000175100017510000000112113025347746017707 0ustar svnsvnG {type=switch format="@name @@P @@M vcr pwl(1) @@CP @@CM @TABLE" template="name=G1 TABLE=\\"1.0 1G 2.0 10\\"" } V {} S {} L 4 0 10 0 30 {} L 4 -10 -10 0 10 {} L 4 0 -30 0 -10 {} L 4 -40 0 -5 0 {} L 4 -5 -25 -5 -20 {} L 4 -7.5 -22.5 -2.5 -22.5 {} L 4 -10 0 -10 20 {} L 4 -40 20 -10 20 {} L 4 -32.5 -7.5 -32.5 -2.5 {} L 4 -35 -5 -30 -5 {} B 5 -42.5 -2.5 -37.5 2.5 {name=CP dir=in } B 5 -2.5 -32.5 2.5 -27.5 {name=P dir=inout } B 5 -2.5 27.5 2.5 32.5 {name=M dir=inout } B 5 -42.5 17.5 -37.5 22.5 {name=CM dir=in } T {@name} 5 -13 2 1 0.2 0.2 {} T {@TABLE} 5 2 2 1 0.2 0.2 {} xschem-2.8.1/xschem_library/devices/isource_arith.sym0000644000175100017510000000074013362731551021247 0ustar svnsvnG {type=isource format="@name @pinlist CUR=' @CUR ' MIN=' @MIN ' MAX=' @MAX ' " template="name=G1 CUR=cos(V(IN)) MIN=-2 MAX=2"} V {} S {} E {} L 4 0 -30 0 -15 {} L 4 -10 0 10 0 {} L 4 -20 12.5 -17.5 5 {} L 4 -22.5 5 -17.5 5 {} L 4 -22.5 5 -20 12.5 {} L 4 0 15 0 30 {} L 4 -20 -12.5 -20 5 {} B 5 -2.5 -32.5 2.5 -27.5 {name=p dir=inout} B 5 -2.5 27.5 2.5 32.5 {name=m dir=inout} A 4 0 0 15 270 360 {} T {@name} 20 -17.5 0 0 0.2 0.2 {} T {@CUR MIN=@MIN MAX=@MAX} 20 0 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/0000755000175100017510000000000013400743706016046 5ustar svnsvnxschem-2.8.1/xschem_library/examples/greycnt.sym0000644000175100017510000000037613031170513020247 0ustar svnsvnG {type=subcircuit format="@name @pinlist @symname" verilog_stop=true template="name=x1" } T {@symname} -27 -6 0 0 0.3 0.3 {} T {@name} 135 -22 0 0 0.2 0.2 {} L 4 -130 -10 130 -10 {} L 4 -130 10 130 10 {} L 4 -130 -10 -130 10 {} L 4 130 -10 130 10 {} xschem-2.8.1/xschem_library/examples/lm337.sch0000644000175100017510000000022613023243556017411 0ustar svnsvnG {} V {} C {devices/ipin} -500 20 0 0 {name=p0 lab=IN} C {devices/ipin} -500 40 0 0 {name=p1 lab=ADJ} C {devices/opin} -200 20 0 0 {name=p2 lab=OUT} xschem-2.8.1/xschem_library/examples/lm317.sch0000644000175100017510000000022613023243556017407 0ustar svnsvnG {} V {} C {devices/ipin} -500 20 0 0 {name=p0 lab=IN} C {devices/ipin} -500 40 0 0 {name=p1 lab=ADJ} C {devices/opin} -200 20 0 0 {name=p2 lab=OUT} xschem-2.8.1/xschem_library/examples/real_capa.sym0000644000175100017510000000077713161011201020500 0ustar svnsvnG {type=subcircuit format="@name @pinlist @symname" template="name=x1 cap=10.0" generic_type="cap=real" } V {} L 4 0 5 0 30 {} L 4 0 -30 0 -5 {} L 4 -10 -5 10 -5 {} L 4 -10 5 10 5 {} L 4 2.5 -22.5 7.5 -22.5 {} L 4 5 -25 5 -20 {} L 4 -5 30 5 30 {} L 4 0 35 5 30 {} L 4 -5 30 0 35 {} B 5 -2.5 -32.5 2.5 -27.5 {name=USC sig_type=rreal verilog_type=wire dir=inout } T {@symname} 14.5 -6 0 0 0.3 0.3 {} T {@name} 15 -17 0 0 0.2 0.2 {} T {USC} -5 -24 0 1 0.2 0.2 {} T {@cap pF} 14.5 14 0 0 0.3 0.3 {} xschem-2.8.1/xschem_library/examples/test_lm324.sch0000644000175100017510000000206613232362134020444 0ustar svnsvnG {} V {} S {} T {LM324 OPAMP EXAMPLE} 450 -510 0 0 0.4 0.4 {} N 520 -340 560 -340 {lab=P} N 640 -400 640 -370 {lab=VCC} N 640 -230 640 -200 {lab=VSS} N 770 -300 960 -300 {lab=Q} N 900 -300 900 -280 {lab=Q} N 820 -300 820 -280 {lab=Q} N 770 -300 770 -150 {lab=Q} N 560 -150 770 -150 {lab=Q} N 560 -260 560 -150 {lab=Q} C {devices/code} 320 -210 0 0 {name=STIMULI value=" .option RUNLVL=5 post .param VCC=10 .param VSS=0 .temp 25 vvcc vcc 0 dc VCC vvss vss 0 dc VSS vp p 0 pwl 0 0 100n 2 200u 2 201u 3 400u 3 401u 1 .tran 0.1u 500u "} C {examples/lm324} 640 -300 0 0 {name=x1} C {devices/lab_pin} 640 -200 0 0 {name=p10 lab=VSS} C {devices/lab_pin} 640 -400 0 0 {name=p1 lab=VCC} C {devices/lab_pin} 960 -300 0 1 {name=p2 lab=Q} C {devices/lab_pin} 520 -340 0 0 {name=p3 lab=P} C {devices/res} 900 -250 0 0 {name=r1 m=1 value=10k} C {devices/capa} 820 -250 0 0 {name=c1 m=1 value=1n} C {devices/lab_pin} 820 -220 0 0 {name=p5 lab=VSS} C {devices/lab_pin} 900 -220 0 0 {name=p6 lab=VSS} C {devices/title} 160 -30 0 0 {name=l1 author="Stefan Schippers"} xschem-2.8.1/xschem_library/examples/sr_flop.sym0000644000175100017510000000123113023243556020240 0ustar svnsvnG {type=subcircuit format="@name @pinlist @symname VTH=@VTH VHI=@VHI" template="name=x1 VTH=1.5 VHI=3.0" } V {} S {} L 4 -70 -20 70 -20 {} L 4 -70 40 70 40 {} L 4 -70 -20 -70 40 {} L 4 70 -20 70 40 {} L 4 -90 -10 -70 -10 {} L 4 70 -10 90 -10 {} L 4 -90 10 -70 10 {} L 4 -90 30 -70 30 {} B 5 -92.5 -12.5 -87.5 -7.5 {name=S dir=in } B 5 87.5 -12.5 92.5 -7.5 {name=Q dir=out } B 5 -92.5 7.5 -87.5 12.5 {name=R dir=in } B 5 -92.5 27.5 -87.5 32.5 {name=VSS dir=in } T {@symname} -31.5 -6 0 0 0.3 0.3 {} T {@name} 75 -32 0 0 0.2 0.2 {} T {S} -65 -14 0 0 0.2 0.2 {} T {Q} 65 -14 0 1 0.2 0.2 {} T {R} -65 6 0 0 0.2 0.2 {} T {VSS} -65 26 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/dlatch.sch0000644000175100017510000000172513023243556020010 0ustar svnsvnG {} V {} S {} N 160 -280 240 -280 {lab=#net1} N 300 -280 400 -280 {lab=#net2} C {devices/ipin} 100 -150 0 0 {name=p0 lab=D} C {devices/opin} 400 -150 0 0 {name=p2 lab=Q} C {devices/ipin} 100 -100 0 0 {name=p4 lab=VSS} C {devices/switch} 270 -280 1 0 {name=G5 TABLE="'VTH-0.1' 10G 'VTH+0.1' 10"} C {devices/capa} 300 -250 0 0 {name=c1 m=1 value=1p} C {devices/lab_pin} 250 -320 0 0 {name=p6 lab=VSS} C {devices/lab_pin} 300 -220 0 1 {name=p7 lab=VSS} C {devices/ipin} 100 -130 0 0 {name=p1 lab=G} C {devices/lab_pin} 270 -320 0 1 {name=p3 lab=G} C {examples/buf} 120 -280 0 0 {name=E5 TABLE="'VTH-0.1' 0 'VTH+0.1' VHI"} C {examples/buf} 440 -280 0 0 {name=E1 TABLE="'VTH-0.1' 0 'VTH+0.1' VHI"} C {devices/lab_pin} 120 -250 0 0 {name=p5 lab=VSS} C {devices/lab_pin} 440 -250 0 0 {name=p8 lab=VSS} C {devices/lab_pin} 480 -280 0 1 {name=p9 lab=Q} C {devices/lab_pin} 80 -280 0 0 {name=p10 lab=D} C {devices/title} 160 -30 0 0 {name=l1 author="Stefan Schippers"} xschem-2.8.1/xschem_library/examples/or2.sym0000644000175100017510000000140213362731551017301 0ustar svnsvnG {type=primitive vhdl_stop=true format="@name @@Z @@VSS or(2) @@A @@VSS @@B @@VSS @TABLE" template="name=E1 TABLE=\\"1.4 0.0 1.6 3.0\\""} V {} S {} E {} L 4 45 0 60 0 {} L 4 -40 -20 -19.21875 -20 {} L 4 -40 20 -19.21875 20 {} L 4 -25 -30 -5 -30 {} L 4 -25 30 -5 30 {} L 4 0 30 0 40 {} B 5 57.5 -2.5 62.5 2.5 {name=Z dir=out} B 5 -42.5 -22.5 -37.5 -17.5 {name=A dir=in} B 5 -42.5 17.5 -37.5 22.5 {name=B dir=in} B 5 -2.5 37.5 2.5 42.5 {name=VSS dir=in} A 4 40 0 5 180 360 {} A 4 -65 0 50 323.130102354156 73.7397952916881 {} A 4 -9.642857142857142 17.85714285714286 48.0818286351295 21.80140948635181 62.65738573560834 {} A 4 -4.6875 -11.25 41.25118369513777 269.5659493678606 74.60789655596687 {} T {@name} -11.25 2.5 0 0 0.2 0.2 {} T {OR2} -12.5 -17.5 0 0 0.3 0.3 {} xschem-2.8.1/xschem_library/examples/ao21.sym0000644000175100017510000000207313362731551017346 0ustar svnsvnG {type=ao21 vhdl_stop=true verilog_stop=true verilog_format="and #aa#@name ( #xx#@name , @@A , @@B ); nor #(@risedel , @falldel ) #bb#@name (@@Z , #xx#@name , @@C );" format="@name @pinlist @symname" template="name=x1 risedel=100 falldel=100" } V {} S {} E {} L 4 -109.6875 20 -22.65625 20 {} L 4 45 0 60 0 {} L 4 -25 30 -5 30 {} L 4 -25 -30 -5 -30 {} L 4 -110 -20 -95 -20 {} L 4 -110 -60 -95 -60 {} L 4 -95 -65 -95 -15 {} L 4 -95 -15 -70 -15 {} L 4 -95 -65 -70 -65 {} L 4 -45 -40 -35 -40 {} L 4 -35 -40 -35 -20 {} L 4 -35 -20 -22.5 -20 {} B 5 57.5 -2.5 62.5 2.5 {name=Z dir=out verilog_type=wire} B 5 -112.5 -62.5 -107.5 -57.5 {name=A dir=in} B 5 -112.5 -22.5 -107.5 -17.5 {name=B dir=in} B 5 -112.5 17.5 -107.5 22.5 {name=C dir=in} A 4 40 0 5 180 360 {} A 4 -9.64285714285711 17.85714285714289 48.0818286351295 21.80140948635181 62.65738573560834 {} A 4 -4.6875 -11.25 41.25118369513777 269.5659493678606 74.60789655596687 {} A 4 -112.5 0 92.5 341.0753555839487 37.8492888321025 {} A 4 -70 -40 25 270 180 {} T {@name} -16.25 5 0 0 0.2 0.2 {} T {AO21} -17.5 -16.25 0 0 0.3 0.3 {} xschem-2.8.1/xschem_library/examples/nr2.sym0000644000175100017510000000140113362731551017277 0ustar svnsvnG {type=primitive vhdl_stop=true format="@name @@Z @@VSS nor(2) @@A @@VSS @@B @@VSS @TABLE" template="name=E1 TABLE=\\"1.4 3.0 1.6 0.0\\""} V {} S {} E {} L 4 45 0 60 0 {} L 4 -40 -20 -19.21875 -20 {} L 4 -40 20 -19.21875 20 {} L 4 -25 -30 -5 -30 {} L 4 -25 30 -5 30 {} L 4 0 30 0 40 {} B 5 57.5 -2.5 62.5 2.5 {name=Z dir=out} B 5 -42.5 -22.5 -37.5 -17.5 {name=A dir=in} B 5 -42.5 17.5 -37.5 22.5 {name=B dir=in} B 5 -2.5 37.5 2.5 42.5 {name=VSS dir=in} A 4 40 0 5 180 360 {} A 4 -65 0 50 323.130102354156 73.7397952916881 {} A 4 -9.642857142857142 17.85714285714286 48.0818286351295 21.80140948635181 62.65738573560834 {} A 4 -4.6875 -11.25 41.25118369513777 269.5659493678606 74.60789655596687 {} T {@name} -10 2.5 0 0 0.2 0.2 {} T {NR2} -11.25 -17.5 0 0 0.3 0.3 {} xschem-2.8.1/xschem_library/examples/lm324.sym0000644000175100017510000000143713023243556017445 0ustar svnsvnG {type=subcircuit format="@name @pinlist @symname" template="name=x1"} V {} S {} L 4 110 0 130 0 {} L 4 -80 -40 -60 -40 {} L 4 -80 40 -60 40 {} L 4 -60 -70 110 0 {} L 4 -60 70 110 0 {} L 4 -60 -70 -60 70 {} L 4 0 45 0 70 {} L 4 0 -70 0 -45 {} B 5 -82.5 -42.5 -77.5 -37.5 {name=1 sig_type=std_logic dir=in } B 5 -82.5 37.5 -77.5 42.5 {name=2 sig_type=std_logic dir=in } B 5 -2.5 -72.5 2.5 -67.5 {name=3 sig_type=std_logic dir=in } B 5 -2.5 67.5 2.5 72.5 {name=4 sig_type=std_logic dir=in } B 5 127.5 -2.5 132.5 2.5 {name=5 sig_type=std_logic dir=out } T {@symname} -58.5 -16 0 0 0.3 0.3 {} T {@name} -35 -72 0 0 0.2 0.2 {} T {OUT} 95 -4 0 1 0.2 0.2 {} T {PLUS} -55 -44 0 0 0.2 0.2 {} T {MINUS} -55 36 0 0 0.2 0.2 {} T {VSS} -5 31 0 0 0.2 0.2 {} T {VCC} -10 -39 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/flop.sym0000644000175100017510000000123313023243556017536 0ustar svnsvnG {type=subcircuit format="@name @pinlist @symname VTH=@VTH VHI=@VHI" template="name=x1 VTH=1.5 VHI=3.0" } V {} S {} L 4 -70 -20 70 -20 {} L 4 -70 40 70 40 {} L 4 -70 -20 -70 40 {} L 4 70 -20 70 40 {} L 4 -90 -10 -70 -10 {} L 4 70 -10 90 -10 {} L 4 -90 10 -70 10 {} L 4 -90 30 -70 30 {} B 5 -92.5 -12.5 -87.5 -7.5 {name=D dir=in } B 5 87.5 -12.5 92.5 -7.5 {name=Q dir=out } B 5 -92.5 7.5 -87.5 12.5 {name=CK dir=in } B 5 -92.5 27.5 -87.5 32.5 {name=VSS dir=in } T {@symname} -31.5 -6 0 0 0.3 0.3 {} T {@name} 75 -32 0 0 0.2 0.2 {} T {D} -65 -14 0 0 0.2 0.2 {} T {Q} 65 -14 0 1 0.2 0.2 {} T {CK} -65 6 0 0 0.2 0.2 {} T {VSS} -65 26 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/test_ne555.sym0000644000175100017510000000042113023243556020474 0ustar svnsvnG {type=subcircuit format="@name @pinlist @symname" verilog_stop=true template="name=x1" } V {} S {} L 4 -130 -10 130 -10 {} L 4 -130 10 130 10 {} L 4 -130 -10 -130 10 {} L 4 130 -10 130 10 {} T {@symname} -58.5 -6 0 0 0.3 0.3 {} T {@name} 135 -22 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/poweramp.sch0000644000175100017510000005177713370707253020423 0ustar svnsvnG {} V {} S {} E {} L 18 845 -530 880 -530 {} L 18 845 -530 845 -450 {} L 18 845 -450 880 -450 {} L 18 880 -450 900 -400 {} L 18 900 -400 910 -400 {} L 18 910 -580 910 -400 {} L 18 900 -580 910 -580 {} L 18 880 -530 900 -580 {} L 18 880 -530 880 -450 {} L 18 900 -580 900 -400 {} N 160 -1250 160 -1230 {lab=#net1} N 160 -1110 160 -1090 {lab=#net2} N 280 -1170 340 -1170 {lab=VSS} N 710 -700 860 -700 {lab=OUTM} N 510 -1200 580 -1200 {lab=VSS} N 580 -1200 580 -1190 {lab=VSS} N 580 -1190 620 -1190 {lab=VSS} N 550 -1240 580 -1240 {lab=IN} N 620 -1250 710 -1250 {lab=REFP} N 280 -1180 280 -1170 {lab=VSS} N 280 -1250 280 -1240 {lab=VPP} N 270 -1100 270 -1090 {lab=VNN} N 270 -1170 270 -1160 {lab=VSS} N 160 -1090 190 -1090 {lab=#net2} N 270 -1090 340 -1090 {lab=VNN} N 160 -1250 190 -1250 {lab=#net1} N 280 -1250 340 -1250 {lab=VPP} N 270 -1170 280 -1170 {lab=VSS} N 250 -1250 280 -1250 {lab=VPP} N 250 -1090 270 -1090 {lab=VNN} N 160 -1170 270 -1170 {lab=VSS} N 550 -950 710 -950 {lab=OUTM} N 400 -890 550 -890 {lab=FBN} N 550 -770 550 -750 {lab=IN} N 350 -890 350 -700 {lab=FBN} N 710 -950 710 -700 {lab=OUTM} N 710 -240 860 -240 {lab=OUTP} N 260 -220 350 -220 {lab=INX} N 550 -490 710 -490 {lab=OUTP} N 400 -430 550 -430 {lab=FB} N 350 -430 350 -240 {lab=FB} N 710 -490 710 -240 {lab=OUTP} N 240 -370 240 -350 {lab=VPP} N 240 -290 240 -220 {lab=INX} N 260 -220 260 -190 {lab=INX} N 260 -130 260 -110 {lab=VSS} N 510 -1120 580 -1120 {lab=VSS} N 550 -1160 580 -1160 {lab=IN} N 620 -1170 710 -1170 {lab=REFM} N 200 -220 240 -220 {lab=INX} N 550 -310 550 -290 {lab=VSS} N 650 -700 710 -700 {lab=OUTM} N 650 -240 710 -240 {lab=OUTP} N 240 -220 260 -220 {lab=INX} N 260 -680 350 -680 {lab=VSSX} N 240 -830 240 -810 {lab=VPP} N 240 -750 240 -680 {lab=VSSX} N 260 -680 260 -650 {lab=VSSX} N 260 -590 260 -570 {lab=VSS} N 240 -680 260 -680 {lab=VSSX} N 180 -680 240 -680 {lab=VSSX} N 880 -1250 900 -1250 {lab=#net3} N 880 -1250 880 -1220 {lab=#net3} N 400 -1000 400 -980 {lab=VPP} N 400 -920 400 -890 {lab=FBN} N 400 -540 400 -520 {lab=VPP} N 400 -460 400 -430 {lab=FB} N 860 -700 860 -520 {lab=OUTM} N 860 -460 860 -240 {lab=OUTP} N 350 -890 400 -890 {lab=FBN} N 350 -430 400 -430 {lab=FB} N 580 -1110 620 -1110 {lab=VSS} N 580 -1120 580 -1110 {lab=VSS} C {devices/code} 1050 -540 0 0 {name=STIMULI only_toplevel=true tclcommand="xschem edit_vi_prop" value=".option PARHIER=LOCAL RUNLVL=6 post MODMONTE=1 warn maxwarns=400 .option sampling_method = SRS .option method=gear vvss vss 0 dc 0 .temp 30 .param freq=20k .param gain=48 .tran '0.2m/freq' '3m + 80/freq' .FOUR 20k v(outm,outp) .probe i(*) .probe p(r*) p(v*) "} C {devices/launcher} 1120 -800 0 0 {name=h2 descr="BJT MODELS" url="http://www.zen22142.zen.co.uk/ltspice/standard.bjt"} C {devices/launcher} 1120 -750 0 0 {name=h1 descr="NPN MODELS" url="http://web.mit.edu/Magic/Public/ckt/npn.mod"} C {devices/launcher} 1120 -850 0 0 {name=h3 descr="COIL CALCULATION" url="http://hamwaves.com/antennas/inductance.html"} C {devices/launcher} 1120 -900 0 0 {name=h4 descr="ltwiki BJT MODELS" url="http://ltwiki.org/?title=Standard.bjt"} C {devices/launcher} 1120 -400 0 0 {name=h5 descr="hspice manual" program=evince url="/home/schippes/hspice_2013/docs_help/hspice_sa.pdf" } C {devices/launcher} 1120 -350 0 0 {name=h6 descr="hspice cmdref" program=evince url="/home/schippes/hspice_2013/docs_help/hspice_cmdref.pdf" } C {devices/launcher} 1120 -300 0 0 {name=h7 descr="hspice aasa" program=evince url="/home/schippes/hspice_2013/docs_help/hspice_aasa.pdf" } C {devices/vsource} 160 -1200 0 0 {name=v1 value=50} C {devices/vsource} 160 -1140 0 0 {name=v0 value=50} C {devices/lab_pin} 340 -1250 0 1 {name=p5 lab=VPP} C {devices/lab_pin} 340 -1090 0 1 {name=p6 lab=VNN} C {devices/lab_pin} 340 -1170 0 1 {name=p3 lab=VSS} C {devices/launcher} 1120 -950 0 0 {name=h8 descr="DIODE LIB" url="/home/schippes/simulations/diode.lib" } C {devices/lab_pin} 860 -240 0 1 {name=p14 lab=OUTP} C {devices/res} 860 -490 0 1 {name=r1 m=1 value=8} C {devices/lab_pin} 510 -1200 0 0 {name=p26 lab=VSS} C {devices/lab_pin} 550 -1240 0 0 {name=p31 lab=IN} C {devices/vcvs} 620 -1220 0 0 {name=E3 value='gain*0.99'} C {devices/lab_pin} 710 -1250 0 1 {name=p32 lab=REFP} C {devices/capa} 280 -1210 0 0 {name=c2 m=1 value=100u} C {devices/capa} 270 -1130 0 0 {name=c3 m=1 value=100u} C {devices/res} 220 -1250 1 1 {name=r11 m=1 value=0.3} C {devices/res} 220 -1090 1 1 {name=r9 m=1 value=0.3} C {devices/res} 550 -920 0 1 {name=r19 m=1 value='100k'} C {devices/res} 550 -860 0 1 {name=r0 m=1 value="'100k/gain'"} C {devices/lab_pin} 550 -750 0 0 {name=p108 lab=IN} C {examples/mos_power_ampli} 500 -660 0 0 {name=x1} C {devices/lab_pin} 350 -640 0 0 {name=p2 lab=VPP} C {devices/lab_pin} 350 -620 0 0 {name=p4 lab=VNN} C {devices/lab_pin} 860 -700 0 1 {name=p9 lab=OUTM} C {examples/mos_power_ampli} 500 -200 0 0 {name=x0} C {devices/lab_pin} 350 -180 0 0 {name=p12 lab=VPP} C {devices/lab_pin} 350 -160 0 0 {name=p13 lab=VNN} C {devices/res} 240 -320 0 1 {name=r6 m=1 value=100k} C {devices/lab_pin} 240 -370 0 0 {name=p7 lab=VPP} C {devices/res} 260 -160 0 1 {name=r7 m=1 value=100k} C {devices/lab_pin} 260 -110 0 0 {name=p15 lab=VSS} C {devices/lab_pin} 510 -1120 0 0 {name=p20 lab=VSS} C {devices/lab_pin} 550 -1160 0 0 {name=p21 lab=IN} C {devices/vcvs} 620 -1140 0 0 {name=E0 value='-gain*0.99'} C {devices/lab_pin} 710 -1170 0 1 {name=p23 lab=REFM} C {devices/lab_pin} 240 -250 0 0 {name=p8 lab=INX} C {devices/lab_pin} 880 -1100 0 0 {name=p126 lab=VSS} C {devices/lab_pin} 960 -1250 0 1 {name=p127 lab=IN} C {devices/capa} 550 -800 0 0 {name=c5 m=1 value=50u} C {devices/lab_pin} 550 -290 0 0 {name=p11 lab=VSS} C {devices/capa} 550 -340 0 0 {name=c6 m=1 value=50u} C {devices/lab_pin} 350 -200 0 0 {name=p28 lab=VSS} C {devices/lab_pin} 350 -660 0 0 {name=p1 lab=VSS} C {devices/res} 550 -460 0 1 {name=r2 m=1 value='100k'} C {devices/res} 550 -400 0 1 {name=r3 m=1 value="'100k/(gain-2)'"} C {devices/vsource} 880 -1190 0 0 {name=v3 xvalue="pulse -.1 .1 1m .1u .1u 10.1u 20u" value="sin 0 1 freq 1m" } C {devices/res} 240 -780 0 1 {name=r4 m=1 value=100k} C {devices/lab_pin} 240 -830 0 0 {name=p18 lab=VPP} C {devices/res} 260 -620 0 1 {name=r5 m=1 value=100k} C {devices/lab_pin} 260 -570 0 0 {name=p10 lab=VSS} C {devices/res} 400 -950 0 1 {name=r8 m=1 value=100k} C {devices/capa} 170 -220 1 0 {name=c4 m=1 value=50u} C {devices/lab_pin} 140 -220 0 0 {name=p0 lab=IN} C {devices/capa} 150 -680 1 0 {name=c1 m=1 value=50u} C {devices/lab_pin} 120 -680 0 0 {name=p17 lab=VSS} C {devices/lab_pin} 240 -710 0 0 {name=p22 lab=VSSX} C {devices/res} 930 -1250 1 1 {name=r10 m=1 value=200} C {devices/lab_pin} 400 -1000 0 0 {name=p24 lab=VPP} C {devices/res} 400 -490 0 1 {name=r13 m=1 value=100k} C {devices/lab_pin} 400 -540 0 0 {name=p16 lab=VPP} C {devices/launcher} 1120 -1000 0 0 {name=h9 descr="REGULATORS LIB" url="http://ltwiki.org/files/LTspiceIV/lib/sub/regulators.lib" program=firefox} C {devices/lab_pin} 260 -110 0 0 {name=p30 lab=VSS} C {devices/lab_pin} 260 -110 0 0 {name=p33 lab=VSS} C {devices/vsource} 880 -1130 0 0 {name=v4 value=0 xvalue="pwl 0 .1 1m .1 1.01m 0" } C {devices/lab_pin} 350 -270 0 0 {name=p19 lab=FB} C {devices/lab_pin} 350 -730 0 0 {name=p25 lab=FBN} C {devices/title} 160 -30 0 0 {name=l2 author="Stefan Schippers"} C {devices/code} 1050 -690 0 0 {name=MODELS only_toplevel=true value=".MODEL bd139_2 npn +IS=1e-09 BF=222.664 NF=0.85 VAF=36.4079 +IKF=0.166126 ISE=5.03418e-09 NE=1.45313 BR=1.35467 +NR=1.33751 VAR=142.931 IKR=1.66126 ISC=5.02557e-09 +NC=3.10227 RB=26.9143 IRB=0.1 RBM=0.1 +RE=0.000472454 RC=1.04109 XTB=0.727762 XTI=1.04311 +EG=1.05 CJE=1e-11 VJE=0.75 MJE=0.33 +TF=1e-09 XTF=1 VTF=10 ITF=0.01 +CJC=1e-11 VJC=0.75 MJC=0.33 XCJC=0.9 +FC=0.5 CJS=0 VJS=0.75 MJS=0.5 +TR=1e-07 PTF=0 KF=0 AF=1 .MODEL BD139 NPN ( +IS=2.3985E-13 Vceo=80 Icrating=1500m +BF=244.9 NF=1.0 BR=78.11 NR=1.007 ISE=1.0471E-14 +NE=1.2 ISC=1.9314E-11 NC=1.45 VAF=98.5 VAR=7.46 +IKF=1.1863 IKR=0.1445 RB=2.14 RBM=0.001 IRB=0.031 +RE=0.0832 RC=0.01 CJE=2.92702E-10 VJE=0.67412 +MJE=0.3300 FC=0.5 CJC=4.8831E-11 VJC=0.5258 +MJC=0.3928 XCJC=0.5287 XTB=1.1398 EG=1.2105 XTI=3.0) .MODEL BD140 PNP(IS=1e-09 BF=650.842 NF=0.85 VAF=10 +IKF=0.0950125 ISE=1e-08 NE=1.54571 BR=56.177 +NR=1.5 VAR=2.11267 IKR=0.950125 ISC=1e-08 +NC=3.58527 RB=41.7566 IRB=0.1 RBM=0.108893 +RE=0.000347052 RC=1.32566 XTB=19.5239 XTI=1 +EG=1.05 CJE=1e-11 VJE=0.75 MJE=0.33 +TF=1e-09 XTF=1 VTF=10 ITF=0.01 +CJC=1e-11 VJC=0.75 MJC=0.33 XCJC=0.9 +FC=0.5 CJS=0 VJS=0.75 MJS=0.5 TR=1e-07 PTF=0 KF=0 AF=10 + VCEO=80 ICRATING=1A ) .MODEL Q2N2222A NPN IS =3.0611E-14 NF =1.00124 BF =220 IKF=0.52 + VAF=104 ISE=7.5E-15 NE =1.41 NR =1.005 BR =4 IKR=0.24 + VAR=28 ISC=1.06525E-11 NC =1.3728 RB =0.13 RE =0.22 + RC =0.12 CJC=9.12E-12 MJC=0.3508 VJC=0.4089 + CJE=27.01E-12 TF =0.325E-9 TR =100E-9 + vce_max=45 vbe_max=6 .MODEL Q2N2222 NPN ( + IS = 3.97589E-14 BF = 195.3412 NF = 1.0040078 VAF = 53.081 IKF = 0.976 ISE = 1.60241E-14 + NE = 1.4791931 BR = 1.1107942 NR = 0.9928261 VAR = 11.3571702 IKR = 2.4993953 ISC = 1.88505E-12 + NC = 1.1838278 RB = 56.5826472 IRB = 1.50459E-4 RBM = 5.2592283 RE = 0.0402974 RC = 0.4208 + CJE = 2.56E-11 VJE = 0.682256 MJE = 0.3358856 TF = 3.3E-10 XTF = 6 VTF = 0.574 + ITF = 0.32 PTF = 25.832 CJC = 1.40625E-11 VJC = 0.5417393 MJC = 0.4547893 XCJC = 1 + TR = 3.2E-7 CJS = 0 VJS = .75 MJS = 0 XTB = 1.6486 EG = 1.11 + XTI = 5.8315 KF = 0 AF = 1 FC = 0.83 + vce_max=45 vbe_max=6 ) * 2n2222 p complementary .MODEL Q2N2907P PNP(IS=650.6E-18 ISE=54.81E-15 ISC=0 XTI=3 + BF=231.7 BR=3.563 IKF=1.079 IKR=0 XTB=1.5 + VAF=115.7 VAR=35 VJE=0.65 VJC=0.65 + RE=0.15 RC=0.715 RB=10 + CJE=19.82E-12 CJC=14.76E-12 XCJC=0.75 FC=0.5 + NF=1 NR=1 NE=1.829 NC=2 MJE=0.3357 MJC=0.5383 + TF=603.7E-12 TR=111.3E-9 ITF=0.65 VTF=5 XTF=1.7 + EG=1.11 KF=1E-9 AF=1 + VCEO=45 ICRATING=100M + vce_max=45 vbe_max=6 ) .MODEL Q2N2907S PNP(IS=2.32E-13 ISE=6.69E-16 ISC=1.65E-13 XTI=3.00 + BF=3.08E2 BR=2.18E1 IKF=8.42E-1 IKR=1.00 XTB=1.5 + VAF=1.41E2 VAR=1.35E1 VJE=3.49E-1 VJC=3.00E-1 + RE=1.00E-2 RC=8.46E-1 RB=4.02E1 RBM=1.00E-2 IRB=1.25E-2 + CJE=2.66E-11 CJC=1.93E-11 XCJC=1.00 FC=5.00E-1 + NF=1.04 NR=1.12 NE=1.09 NC=1.13 MJE=4.60E-1 MJC=4.65E-1 + TF=4.95E-10 TR=0 PTF=0 ITF=3.36E-1 VTF=6.54 XTF=1.87E1 + EG=1.11 KF=1E-9 AF=1 + VCEO=40 ICRATING=500M + vce_max=45 vbe_max=6 ) *MM3725 MCE 5/13/95 *Si 1W 40V 500mA 307MHz pkg:TO-39 3,2,1 .MODEL QMM3725 NPN (IS=50.7F NF=1 BF=162 VAF=113 IKF=.45 ISE=38.2P NE=2 + BR=4 NR=1 VAR=24 IKR=.675 RE=.263 RB=1.05 RC=.105 XTB=1.5 + CJE=62.2P VJE=1.1 MJE=.5 CJC=14.6P VJC=.3 MJC=.3 TF=518P TR=45.9N) *MPS651 MCE 5/12/95 *Si 625mW 60V 2A 110MHz pkg:TO-92 1,2,3 .MODEL QMPS651 NPN (IS=72.1F NF=1 BF=260 VAF=139 IKF=2.5 ISE=67.1P NE=2 + BR=4 NR=1 VAR=20 IKR=3.75 RE=28.2M RB=.113 RC=11.3M XTB=1.5 + CJE=212P VJE=1.1 MJE=.5 CJC=68.6P VJC=.3 MJC=.3 TF=1.44N TR=1U) *FCX649 ZETEX Spice model Last revision 17/7/90 Medium Power *ZTX Si 1.5W 25V 2A 240MHz pkg:SOT-89 2,1,3 .MODEL QFCX649 NPN(IS=3E-13 BF=225 VAF=80 IKF=2.8 ISE=1.1E-13 NE=1.37 + BR=110 NR=0.972 VAR=28 IKR=0.8 ISC=6.5E-13 NC=1.372 RB=0.3 RE=0.063 + RC=0.07 CJE=3.25E-10 TF=1E-9 CJC=7E-11 TR=1E-8 ) *MPSW01A MCE 5/12/95 *Si 1W 40V 1A 210MHz pkg:TO-92 1,2,3 .MODEL QMPSW01A NPN (IS=18.1F NF=1 BF=273 VAF=113 IKF=.6 ISE=15.7P NE=2 + BR=4 NR=1 VAR=20 IKR=.9 RE=96.5M RB=.386 RC=38.6M XTB=1.5 + CJE=78.7P VJE=1.1 MJE=.5 CJC=17.3P VJC=.3 MJC=.3 TF=757P TR=526N) *BC546 ZETEX Spice model Last revision 4/90 General Purpose *ZTX Si 500mW 65V 200mA 300MHz pkg:TO-92 1,2,3 .MODEL BC546 NPN(IS=1.8E-14 BF=400 NF=0.9955 VAF=80 IKF=0.14 ISE=5E-14 + NE=1.46 BR=35.5 NR=1.005 VAR=12.5 IKR=0.03 ISC=1.72E-13 NC=1.27 RB=0.56 + RE=0.6 RC=0.25 CJE=1.3E-11 TF=6.4E-10 CJC=4E-12 VJC=0.54 TR=5.072E-8 + vce_max=65 vbe_max=6 ) .MODEL BC556 PNP( + IS=2.059E-14 + NF=1.003 + ISE=2.971E-15 + NE=1.316 + BF=227.3 + IKF=0.08719 + VAF=37.2 + NR=1.007 + ISC=1.339E-14 + NC=1.15 + BR=7.69 + IKR=0.07646 + VAR=11.42 + RB=1 + IRB=1E-06 + RBM=1 + RE=0.688 + RC=0.6437 + XTB=0 + EG=1.11 + XTI=3 + CJE=1.4E-11 + VJE=0.5912 + MJE=0.3572 + TF=7.046E-10 + XTF=4.217 + VTF=5.367 + ITF=0.1947 + PTF=0 + CJC=1.113E-11 + VJC=0.1 + MJC=0.3414 + XCJC=0.6288 + TR=1E-32 + CJS=0 + VJS=0.75 + MJS=0.333 + FC=0.7947 + vce_max=65 vbe_max=6 ) * * NXP Semiconductors * * Medium power NPN transistor * IC = 1 A * VCEO = 20 V * hFE = 85 - 375 @ 2V/500mA * * * * * Package pinning does not match Spice model pinning. * Package: SOT 223 * * Package Pin 1: Base * Package Pin 2: Collector * Package Pin 3: Emitter * Package Pin 4: Collector * * Extraction date (week/year): 13/2008 * Simulator: Spice 3 * ********************************************************** *# .SUBCKT BCP68 1 2 3 * Q1 1 2 3 BCP68 D1 2 1 DIODE * *The diode does not reflect a *physical device but improves *only modeling in the reverse *mode of operation. * .MODEL BCP68 NPN + IS = 2.312E-013 + NF = 0.988 + ISE = 8.851E-014 + NE = 2.191 + BF = 273 + IKF = 5.5 + VAF = 50 + NR = 0.9885 + ISC = 6.808E-014 + NC = 3 + BR = 155.6 + IKR = 4 + VAR = 17 + RB = 15 + IRB = 2E-006 + RBM = 0.65 + RE = 0.073 + RC = 0.073 + XTB = 0 + EG = 1.11 + XTI = 3 + CJE = 2.678E-010 + VJE = 0.732 + MJE = 0.3484 + TF = 5.8E-010 + XTF = 1.5 + VTF = 2.5 + ITF = 1 + PTF = 0 + CJC = 3.406E-011 + VJC = 2 + MJC = 0.3142 + XCJC = 1 + TR = 6.5E-009 + CJS = 0 + VJS = 0.75 + MJS = 0.333 + FC = 0.95 .MODEL DIODE D + IS = 2.702E-015 + N = 1.2 + BV = 1000 + IBV = 0.001 + RS = 0.1 + CJO = 0 + VJ = 1 + M = 0.5 + FC = 0 + TT = 0 + EG = 1.11 + XTI = 3 .ENDS .model D1N4007 D(IS=7.02767n RS=0.0341512 N=1.80803 EG=1.05743 XTI=5 BV=1000 IBV=5e-08 CJO=1e-11 VJ=0.7 M=0.5 FC=0.5 TT=1e-07 ) .MODEL D1N4148 D + IS = 4.352E-9 + N = 1.906 + BV = 110 + IBV = 0.0001 + RS = 0.6458 + CJO = 7.048E-13 + VJ = 0.869 + M = 0.03 + FC = 0.5 + TT = 3.48E-9 .MODEL D1n5400 d +IS=2.61339e-12 RS=0.0110501 N=1.20576 EG=0.6 +XTI=3.1271 BV=50 IBV=1e-05 CJO=1e-11 +VJ=0.7 M=0.5 FC=0.5 TT=1e-09 +KF=0 AF=1 * Model generated on October 12, 2003 * Model format: PSpice *1N758 *Ref: Motorola *10V 500mW Si Zener pkg:DIODE0.4 1,2 .MODEL D1N758 D(IS=1E-11 RS=8.483 N=1.27 TT=5E-8 CJO=2.334E-10 VJ=0.75 + M=0.33 BV=9.83 IBV=0.01 ) *1N4744 *Ref: Motorola *15V 1W Si Zener pkg:DIODE0.4 1,2 .MODEL D1N4744 D(IS=5.32E-14 RS=6.47 TT=5.01E-8 CJO=7.83E-11 M=0.33 + BV=14.89 IBV=0.017 ) *1N755 *Ref: Motorola *7.5V 500mW Si Zener pkg:DIODE0.4 1,2 .MODEL D1N755 D(IS=1E-11 RS=3.359 N=1.27 TT=5E-8 CJO=2.959E-10 VJ=0.75 + M=0.33 BV=7.433 IBV=0.01 ) ** node order * 1: gnd * 2: trig * 3: out * 4: reset# * 5: ctrl * 6: thres * 7: dis * 8: vcc .SUBCKT ne555 34 32 30 19 23 33 1 21 * G TR O R F TH D V Q4 25 2 3 QP Q5 34 6 3 QP Q6 6 6 8 QP R1 9 21 4.7K R2 3 21 830 R3 8 21 4.7K Q7 2 33 5 QN Q8 2 5 17 QN Q9 6 4 17 QN Q10 6 23 4 QN Q11 12 20 10 QP R4 10 21 1K Q12 22 11 12 QP Q13 14 13 12 QP Q14 34 32 11 QP Q15 14 18 13 QP R5 14 34 100K R6 22 34 100K R7 17 34 10K Q16 1 15 34 QN Q17 15 19 31 QP R8 18 23 5K R9 18 34 5K R10 21 23 5K Q18 27 20 21 QP Q19 20 20 21 QP R11 20 31 5K D1 31 24 DA Q20 24 25 34 QN Q21 25 22 34 QN Q22 27 24 34 QN R12 25 27 4.7K R13 21 29 6.8K Q23 21 29 28 QN Q24 29 27 16 QN Q25 30 26 34 QN Q26 21 28 30 QN D2 30 29 DA R14 16 15 100 R15 16 26 220 R16 16 34 4.7K R17 28 30 3.9K Q3 2 2 9 QP .MODEL DA D (RS=40 IS=1.0E-14 CJO=1PF) .MODEL QP PNP (level=1 BF=20 BR=0.02 RC=4 RB=25 IS=1.0E-14 VA=50 NE=2) + CJE=12.4P VJE=1.1 MJE=.5 CJC=4.02P VJC=.3 MJC=.3 TF=229P TR=159N) .MODEL QN NPN (level=1 IS=5.07F NF=1 BF=100 VAF=161 IKF=30M ISE=3.9P NE=2 + BR=4 NR=1 VAR=16 IKR=45M RE=1.03 RB=4.12 RC=.412 XTB=1.5 + CJE=12.4P VJE=1.1 MJE=.5 CJC=4.02P VJC=.3 MJC=.3 TF=229P TR=959P) .ENDS .SUBCKT BS250P 3 4 5 * D G S M1 3 2 5 5 MBS250 RG 4 2 160 RL 3 5 1.2E8 C1 2 5 47E-12 C2 3 2 10E-12 D1 3 5 DBS250 * .MODEL MBS250 PMOS VTO=-3.193 RS=2.041 RD=0.697 IS=1E-15 KP=0.277 +CBD=105E-12 PB=1 LAMBDA=1.2E-2 .MODEL DBS250 D IS=2E-13 RS=0.309 .ENDS BS250P .SUBCKT BS170 3 4 5 * D G S M1 3 2 5 5 N3306M RG 4 2 270 RL 3 5 1.2E8 C1 2 5 28E-12 C2 3 2 3E-12 D1 5 3 N3306D * .MODEL N3306M NMOS VTO=1.824 RS=1.572 RD=1.436 IS=1E-15 KP=.1233 +CBD=35E-12 PB=1 .MODEL N3306D D IS=5E-12 RS=.768 .ENDS BS170 * *$ .SUBCKT PTON_TOFF_U4_S1 1 2 3 4 G_Switch 3 4 VCR PWL(1) 1 2 0.2 100e6 0.8 1m RS_U4_S1 1 2 1G .ENDS PTON_TOFF_U4_S1 *$ .SUBCKT PTON_TOFF_U4_S2 1 2 3 4 G_Switch 3 4 VCR PWL(1) 1 2 0.2 100e6 0.8 1m RS_U4_S2 1 2 1G .ENDS PTON_TOFF_U4_S2 *$ .SUBCKT MTON_TOFF_U2_S2 1 2 3 4 G_Switch 3 4 VCR PWL(1) 1 2 0.2 100e6 0.8 1m RS_U2_S2 1 2 1G .ENDS MTON_TOFF_U2_S2 *$ .SUBCKT MTON_TOFF_U2_S1 1 2 3 4 G_Switch 3 4 VCR PWL(1) 1 2 0.2 100e6 0.8 1m RS_U2_S1 1 2 1G .ENDS MTON_TOFF_U2_S1 *$ ****************************** Basic Components ************************** .SUBCKT D_D1 1 2 D1 1 2 DD1 .MODEL DD1 D (IS=1e-15 Rs=0.001 N=0.1 TT=10p) .ENDS D_D1 *$ .SUBCKT BUF_BASIC_GEN A Y VDD=1 VSS=0 VTHRESH=0.5 * E_ABMGATE YINT 0 vol='V(A) > VTHRESH? VDD:VSS' E_ABMGATE YINT 0 pwl(1) A 0 'VTHRESH-0.01' VSS 'VTHRESH+0.01' VDD RINT YINT Y 1 CINT Y 0 1n .ENDS BUF_BASIC_GEN *$ .MODEL NMOS01 NMOS (VTO = 2 KP = 1.005 LAMBDA = 0.001) *$ .MODEL PMOS01 PMOS (VTO = -2 KP = 1.77 LAMBDA = 0.001) *$ .MODEL NMOS02 NMOS (VTO = 2 KP = 0.1814 LAMBDA = 0.001) *$ .MODEL PMOS02 PMOS (VTO = -2 KP = 0.2497 LAMBDA = 0.001) *$ .SUBCKT COMPHYS_BASIC_GEN INP INM HYS OUT VDD=1 VSS=0 VTHRESH=0.5 EIN INP1 INM1 INP INM 1 * EHYS INP1 INP2 vol='V(1) > VTHRESH? -V(HYS):0' EHYS INP1 INP2 pwl(1) 1 0 'VTHRESH-0.01' 0 'VTHRESH+0.01' '-V(HYS)' EOUT OUT 0 vol='V(INP2)>V(INM1)? VDD : VSS' R1 OUT 1 1 C1 1 0 5n RINP1 INP1 0 1K .ENDS COMPHYS_BASIC_GEN *$ .SUBCKT AND2_BASIC_GEN A B Y VDD=1 VSS=0 VTHRESH=0.5 E_ABMGATE YINT 0 vol= 'V(A) > VTHRESH && V(B) > VTHRESH ? VDD:VSS' RINT YINT Y 1 CINT Y 0 1n .ENDS AND2_BASIC_GEN *$ .SUBCKT NOR2_BASIC_GEN A B Y VDD=1 VSS=0 VTHRESH=0.5 E_ABMGATE YINT 0 vol= 'V(A) > VTHRESH || V(B) > VTHRESH ? VSS:VDD' RINT YINT Y 1 CINT Y 0 1n .ENDS NOR2_BASIC_GEN *$ .SUBCKT AND3_BASIC_GEN A B C Y VDD=1 VSS=0 VTHRESH=0.5 E_ABMGATE YINT 0 vol= 'V(A) > VTHRESH && V(B) > VTHRESH && V(C) > VTHRESH ? VDD:VSS' RINT YINT Y 1 CINT Y 0 1n .ENDS AND3_BASIC_GEN *$ .SUBCKT INV_BASIC_GEN A Y VDD=1 VSS=0 VTHRESH=0.5 * E_ABMGATE YINT 0 vol='V(A) > VTHRESH ? VSS : VDD' E_ABMGATE YINT 0 pwl(1) A 0 'VTHRESH-0.01' VDD 'VTHRESH+0.01' VSS RINT YINT Y 1 CINT Y 0 1n .ENDS INV_BASIC_GEN *$ .SUBCKT RVAR 101 102 201 202 RREF=1 * nodes : 101 102 : nodes between which variable resistance is placed * 201 202 : nodes to whose voltage the resistance is proportional * parameters : rref : reference value of the resistance rin 201 202 1G $$ input resistance r 301 0 rref fcopy 0 301 vsense 1 $$ copy output current thru Z eout 101 106 poly(2) 201 202 301 0 0 0 0 0 1 $$ multiply VoverZ with Vctrl vsense 106 102 0 $$ sense iout .ENDS RVAR *$ *LM317 TI voltage regulator - pin order: In, Adj, Out *TI adjustable voltage regulator pkg:TO-3 .SUBCKT LM317 1 2 3 **Changes my be required on this line** J1 1 3 4 JN Q2 5 5 6 QPL .1 Q3 5 8 9 QNL .2 Q4 8 5 7 QPL .1 Q5 81 8 3 QNL .2 Q6 3 81 10 QPL .2 Q7 12 81 13 QNL .2 Q8 10 5 11 QPL .2 Q9 14 12 10 QPL .2 Q10 16 5 17 QPL .2 Q11 16 14 15 QNL .2 Q12 3 20 16 QPL .2 Q13 1 19 20 QNL .2 Q14 19 5 18 QPL .2 Q15 3 21 19 QPL .2 Q16 21 22 16 QPL .2 Q17 21 3 24 QNL .2 Q18 22 22 16 QPL .2 Q19 22 3 241 QNL 2 Q20 3 25 16 QPL .2 Q21 25 26 3 QNL .2 Q22A 35 35 1 QPL 2 Q22B 16 35 1 QPL 2 Q23 35 16 30 QNL 2 Q24A 27 40 29 QNL .2 Q24B 27 40 28 QNL .2 Q25 1 31 41 QNL 5 Q26 1 41 32 QNL 50 D1 3 4 DZ D2 33 1 DZ D3 29 34 DZ R1 1 6 310 R2 1 7 310 R3 1 11 190 R4 1 17 82 R5 1 18 5.6K R6 4 8 100K R7 8 81 130 R8 10 12 12.4K R9 9 3 180 R10 13 3 4.1K R11 14 3 5.8K R12 15 3 72 R13 20 3 5.1K R14 2 24 12K R15 24 241 2.4K R16 16 25 6.7K R17 16 40 12K R18 30 41 130 R19 16 31 370 R20 26 27 13K R21 27 40 400 R22 3 41 160 R23 33 34 18K R24 28 29 160 R25 28 32 3 R26 32 3 .1 C1 21 3 30PF C2 21 2 30PF C3 25 26 5PF CBS1 5 3 2PF CBS2 35 3 1PF CBS3 22 3 1PF .MODEL JN NJF(BETA=1E-4 VTO=-7) .MODEL DZ D(BV=6.3) .MODEL QNL NPN(EG=1.22 BF=80 RB=100 CCS=1.5PF TF=.3NS TR=6NS CJE=2PF + CJC=1PF VAF=100) .MODEL QPL PNP(BF=40 RB=20 TF=.6NS TR=10NS CJE=1.5PF CJC=1PF VAF=50) .ENDS .SUBCKT xxxxLM317 1 3 2 * IN ADJ OUT IADJ 1 4 50U VREF 4 3 1.25 RC 1 14 0.742 DBK 14 13 D1 CBC 13 15 2.479N RBC 15 5 247 QP 13 5 2 Q1 RB2 6 5 124 DSC 6 11 D1 ESC 11 2 POLY(2) (13,5) (6,5) 2.85 + 0 0 0 -70.1M DFB 6 12 D1 EFB 12 2 POLY(2) (13,5) (6,5) 3.92 + -135M 0 1.21M -70.1M RB1 7 6 1 EB 7 2 8 2 2.56 CPZ 10 2 0.796U DPU 10 2 D1 RZ 8 10 0.104 RP 9 8 100 EP 9 2 4 2 103.6 RI 2 4 100MEG .MODEL Q1 NPN (IS=30F BF=100 + VAF=14.27 NF=1.604) .MODEL D1 D (IS=30F N=1.604) .ENDS .SUBCKT LM337 8 1 19 *Connections Input Adj. Output *LM337 negative voltage regulator .MODEL QN NPN (BF=50 TF=1N CJC=1P) .MODEL QPOUT PNP (BF=50 TF=1N RE=.2 CJC=1P) .MODEL QP PNP CJC=1P TF=2N .MODEL DN D .MODEL D2 D BV=12 IBV=100U R10 25 6 1K Q3 8 17 16 QPOUT Q4 8 25 17 QP R18 19 17 250 R19 19 16 .3 G1 8 6 1 18 .1 C7 6 2 .04U R24 2 8 100 I_ADJ 0 1 65U R26 8 25 200K Q5 25 4 19 QP R27 16 4 200 R28 7 4 7K D1 8 7 D2 D2 8 6 DN V1 18 19 1.25 .ENDS "} xschem-2.8.1/xschem_library/examples/mos_power_ampli.sym0000644000175100017510000000157413023243556022002 0ustar svnsvnG {type=subcircuit format="@name @pinlist @symname" template="name=x1" } V {} S {} L 4 -130 -50 130 -50 {} L 4 -130 50 130 50 {} L 4 -130 -50 -130 50 {} L 4 130 -50 130 50 {} L 4 150 -40 130 -40 {} L 4 -150 -20 -130 -20 {} L 4 -150 -40 -130 -40 {} L 4 -150 20 -130 20 {} L 4 -150 40 -130 40 {} L 4 -150 0 -130 0 {} B 5 147.5 -42.5 152.5 -37.5 {name=OUT dir=out } B 5 -152.5 -22.5 -147.5 -17.5 {name=PLUS dir=in } B 5 -152.5 -42.5 -147.5 -37.5 {name=MINUS dir=in } B 5 -152.5 17.5 -147.5 22.5 {name=VPP dir=in } B 5 -152.5 37.5 -147.5 42.5 {name=VNN dir=in } B 5 -152.5 -2.5 -147.5 2.5 {name=VSS dir=in } T {@symname} -67.5 -6 0 0 0.3 0.3 {} T {@name} 135 -62 0 0 0.2 0.2 {} T {OUT} 125 -44 0 1 0.2 0.2 {} T {PLUS} -125 -24 0 0 0.2 0.2 {} T {MINUS} -125 -44 0 0 0.2 0.2 {} T {VPP} -125 16 0 0 0.2 0.2 {} T {VNN} -125 36 0 0 0.2 0.2 {} T {VSS} -125 -4 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/inv.sym0000644000175100017510000000072213362731551017377 0ustar svnsvnG {type=primitive vhdl_stop=true format="@name @@Z @@VSS pwl(1) @@A @@VSS @TABLE" template="name=E1 TABLE=\\"1.4 3.0 1.6 0.0\\""} V {} S {} E {} L 4 -40 0 -27.5 0 {} L 4 -27.5 -20 -27.5 20 {} L 4 -27.5 -20 16.25 0 {} L 4 -27.5 20 16.25 0 {} L 4 0 7.5 0 30 {} L 4 26.25 0 40 0 {} B 5 -42.5 -2.5 -37.5 2.5 {name=A dir=in } B 5 37.5 -2.5 42.5 2.5 {name=Z dir=out } B 5 -2.5 27.5 2.5 32.5 {name=VSS dir=in} A 4 21.25 -0 5 180 360 {} T {@name} -26.25 -5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/LM5134A.sch0000644000175100017510000000044513023243556017475 0ustar svnsvnG {} V {} C {devices/ipin} -500 20 0 0 {name=p0 lab=VDD} C {devices/ipin} -500 40 0 0 {name=p1 lab=PILOT} C {devices/ipin} -500 60 0 0 {name=p2 lab=OUT} C {devices/opin} -200 20 0 0 {name=p3 lab=IN} C {devices/opin} -200 40 0 0 {name=p4 lab=INB} C {devices/opin} -200 60 0 0 {name=p5 lab=VSS} xschem-2.8.1/xschem_library/examples/switch_rreal.sch0000644000175100017510000000605713161011201021221 0ustar svnsvnG { -- process -- variable t : time; -- variable C : rreal; -- begin -- wait on A'transaction , B'transaction , ENAB'transaction until t /= now; -- t := now; -- -- A<=rreal'(0.0,0.0,0.0); -- B<=rreal'(0.0,0.0,0.0); -- for i in 1 to 6 loop -- wait for 0 ns; -- end loop; -- -- if ENAB = '1' then -- for i in 1 to 6 loop -- C := resolved_real( (A, B) ); -- B <= C; -- A <= C; -- wait for 0 ns; -- end loop; -- end if; -- -- end process; process variable last : time; variable aa,bb : rreal; begin wait until ( SCHEDULE'transaction'event or A'event or B'event or ENAB'event ) and now>last; last := now; print(switch_rreal'PATH_NAME & " start switch process: " & time'image(now) ); if now= 0 ns then aa:=rreal'(0.0,0.0,0.0); bb:=rreal'(0.0,0.0,0.0); A <= aa ; B <= bb ; elsif ENAB'event and ENAB='1' then SCHEDULE <= 4 after del; elsif ENAB'event and ENAB='0' then SCHEDULE <= 3 after del; elsif B'event and ENAB='1' then SCHEDULE <= 2 after del; elsif A'event and ENAB='1' then SCHEDULE <= 1 after del; elsif SCHEDULE'transaction'event and SCHEDULE=3 then -- ENAB=0 event print(switch_rreal'PATH_NAME & " release outputs: " & time'image(now) ); aa:=rreal'(0.0,0.0,0.0); bb:=rreal'(0.0,0.0,0.0); A <= aa ; B <= bb ; elsif SCHEDULE'transaction'event and SCHEDULE=4 then -- ENAB=1 event aa := B; bb := A; A <= aa ; print(switch_rreal'PATH_NAME & " enab forcing A, done: " & time'image(now) ); print2(A); B <= bb ; print(switch_rreal'PATH_NAME & " enab forcing B, done: " & time'image(now) ); print2(B); elsif SCHEDULE'transaction'event and SCHEDULE=2 then -- B event print(switch_rreal'PATH_NAME & " B'event: " & time'image(now) ); aa.conduct := B.conduct - bb.conduct; aa.cap := B.cap - bb.cap; if aa.conduct /= 0.0 then aa.value := ( B.value * B.conduct - bb.value * bb.conduct) / aa.conduct; else aa.value := B.value; end if; A <= aa ; elsif SCHEDULE'transaction'event and SCHEDULE=1 then -- A event print(switch_rreal'PATH_NAME & " A'event: " & time'image(now) ); bb.conduct := A.conduct - aa.conduct; bb.cap := A.cap - aa.cap; if bb.conduct /= 0.0 then bb.value := ( A.value * A.conduct - aa.value * aa.conduct) / bb.conduct; else bb.value := A.value; end if; B <= bb ; end if; -- now = 0 end process; } V {} S {} C {devices/use} 0 -310 0 0 { library ieee,work; use ieee.std_logic_1164.all; use work.rrreal.all; use std.textio.all; } C {devices/ipin} 80 -120 0 0 {name=p3 lab=ENAB} C {devices/iopin} 170 -40 0 0 {name=p1 lab=B sig_type=rreal} C {devices/iopin} 40 -40 0 1 {name=p2 lab=A sig_type=rreal} C {devices/arch_declarations} 20 -190 0 0 { signal SCHEDULE : integer ; procedure print2( signal x : in rreal) is begin print(" " & x'SIMPLE_NAME & ".value=" & real'image(x.value)& " t= " & time'image(now) ); print(" " & x'SIMPLE_NAME & ".cap=" & real'image(x.cap) & " t= " & time'image(now)); print(" " & x'SIMPLE_NAME & ".conduct=" & real'image(x.conduct) & " t= " & time'image(now)); end print2; } xschem-2.8.1/xschem_library/examples/tesla2.sym0000644000175100017510000000042113023243556017766 0ustar svnsvnG {type=subcircuit format="@name @pinlist @symname" verilog_stop=true template="name=x1" } V {} S {} L 4 -130 -10 130 -10 {} L 4 -130 10 130 10 {} L 4 -130 -10 -130 10 {} L 4 130 -10 130 10 {} T {@symname} -58.5 -6 0 0 0.3 0.3 {} T {@name} 135 -22 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/diode.sch0000644000175100017510000000052113023243556017626 0ustar svnsvnG {} V {} S {} N 110 -90 110 -20 {lab=m} N 110 -240 110 -150 {lab=p} N 70 -150 70 -120 {} N 70 -150 110 -150 {} N 70 -100 70 -90 {} N 70 -90 110 -90 {} C {devices/iopin} 110 -240 0 0 {name=p0 lab=p} C {devices/iopin} 110 -20 0 0 {name=p1 lab=m} C {examples/switch} 110 -120 0 0 {name=G2 TABLE="'VTH-0.1' ROFF 'VTH+0.1' RON"} xschem-2.8.1/xschem_library/examples/osc.sch0000644000175100017510000003636413370707253017350 0ustar svnsvnG {} V {} S {} E {} T {COLPITTS OSCILLATOR EXAMPLE} 460 -480 0 0 0.4 0.4 {} N 240 -270 340 -270 {lab=B} N 380 -300 690 -300 {lab=OUT} N 250 -460 380 -460 {lab=VCC} N 380 -100 380 -80 {lab=VSS} N 380 -100 550 -100 {lab=VSS} N 380 -340 380 -300 {lab=OUT} N 380 -240 380 -220 {lab=E} N 380 -220 380 -160 {lab=E} N 550 -240 550 -200 {lab=E} N 550 -140 550 -100 {lab=VSS} N 380 -210 400 -210 {lab=E} N 400 -210 550 -210 {lab=E} C {devices/code} 750 -190 0 0 { name=STIMULI value=".option RUNLVL=6 post vvss vss 0 dc 0 .temp 30 .tran 1n 100u .probe tran i1(Q1) i2(Q1) i3(Q1) i(L1) i(c1) i(c2) i(r1) i(r2) i(r3)"} C {devices/npn} 360 -270 0 0 {name=Q1 model=q2n2222a area=1 } C {devices/vsource} 250 -430 0 1 {name=v2 value="5 pwl 0 5 1n 6 2n 6 3n 5"} C {devices/lab_pin} 250 -400 0 0 {name=p0 lab=VSS} C {devices/lab_pin} 690 -300 0 1 {name=p3 lab=OUT} C {devices/lab_pin} 380 -80 0 0 {name=p5 lab=VSS} C {devices/lab_pin} 250 -460 0 0 {name=p6 lab=VCC} C {devices/ind} 380 -430 2 0 {name=L1 value=100u} C {devices/capa} 550 -270 0 1 {name=c1 m=1 value=100p} C {devices/lab_pin} 380 -230 0 0 {name=p2 lab=E} C {devices/vsource} 240 -240 0 1 {name=v1 value=1} C {devices/lab_pin} 240 -210 0 0 {name=p1 lab=VSS} C {devices/lab_pin} 240 -270 0 0 {name=p4 lab=B} C {devices/res} 380 -130 0 1 {name=r1 m=1 value=1k} C {devices/res} 380 -370 0 1 {name=r2 m=1 value=2} C {devices/capa} 550 -170 0 1 {name=c2 m=1 value=100p} C {devices/code} 750 -340 0 0 {name=MODELS only_toplevel=true value=".MODEL bd139_2 npn +IS=1e-09 BF=222.664 NF=0.85 VAF=36.4079 +IKF=0.166126 ISE=5.03418e-09 NE=1.45313 BR=1.35467 +NR=1.33751 VAR=142.931 IKR=1.66126 ISC=5.02557e-09 +NC=3.10227 RB=26.9143 IRB=0.1 RBM=0.1 +RE=0.000472454 RC=1.04109 XTB=0.727762 XTI=1.04311 +EG=1.05 CJE=1e-11 VJE=0.75 MJE=0.33 +TF=1e-09 XTF=1 VTF=10 ITF=0.01 +CJC=1e-11 VJC=0.75 MJC=0.33 XCJC=0.9 +FC=0.5 CJS=0 VJS=0.75 MJS=0.5 +TR=1e-07 PTF=0 KF=0 AF=1 .MODEL BD139 NPN ( +IS=2.3985E-13 Vceo=80 Icrating=1500m +BF=244.9 NF=1.0 BR=78.11 NR=1.007 ISE=1.0471E-14 +NE=1.2 ISC=1.9314E-11 NC=1.45 VAF=98.5 VAR=7.46 +IKF=1.1863 IKR=0.1445 RB=2.14 RBM=0.001 IRB=0.031 +RE=0.0832 RC=0.01 CJE=2.92702E-10 VJE=0.67412 +MJE=0.3300 FC=0.5 CJC=4.8831E-11 VJC=0.5258 +MJC=0.3928 XCJC=0.5287 XTB=1.1398 EG=1.2105 XTI=3.0) .MODEL BD140 PNP(IS=1e-09 BF=650.842 NF=0.85 VAF=10 +IKF=0.0950125 ISE=1e-08 NE=1.54571 BR=56.177 +NR=1.5 VAR=2.11267 IKR=0.950125 ISC=1e-08 +NC=3.58527 RB=41.7566 IRB=0.1 RBM=0.108893 +RE=0.000347052 RC=1.32566 XTB=19.5239 XTI=1 +EG=1.05 CJE=1e-11 VJE=0.75 MJE=0.33 +TF=1e-09 XTF=1 VTF=10 ITF=0.01 +CJC=1e-11 VJC=0.75 MJC=0.33 XCJC=0.9 +FC=0.5 CJS=0 VJS=0.75 MJS=0.5 TR=1e-07 PTF=0 KF=0 AF=10 + VCEO=80 ICRATING=1A ) .MODEL Q2N2222A NPN IS =3.0611E-14 NF =1.00124 BF =220 IKF=0.52 + VAF=104 ISE=7.5E-15 NE =1.41 NR =1.005 BR =4 IKR=0.24 + VAR=28 ISC=1.06525E-11 NC =1.3728 RB =0.13 RE =0.22 + RC =0.12 CJC=9.12E-12 MJC=0.3508 VJC=0.4089 + CJE=27.01E-12 TF =0.325E-9 TR =100E-9 + vce_max=45 vbe_max=6 .MODEL Q2N2222 NPN ( + IS = 3.97589E-14 BF = 195.3412 NF = 1.0040078 VAF = 53.081 IKF = 0.976 ISE = 1.60241E-14 + NE = 1.4791931 BR = 1.1107942 NR = 0.9928261 VAR = 11.3571702 IKR = 2.4993953 ISC = 1.88505E-12 + NC = 1.1838278 RB = 56.5826472 IRB = 1.50459E-4 RBM = 5.2592283 RE = 0.0402974 RC = 0.4208 + CJE = 2.56E-11 VJE = 0.682256 MJE = 0.3358856 TF = 3.3E-10 XTF = 6 VTF = 0.574 + ITF = 0.32 PTF = 25.832 CJC = 1.40625E-11 VJC = 0.5417393 MJC = 0.4547893 XCJC = 1 + TR = 3.2E-7 CJS = 0 VJS = .75 MJS = 0 XTB = 1.6486 EG = 1.11 + XTI = 5.8315 KF = 0 AF = 1 FC = 0.83 + vce_max=45 vbe_max=6 ) * 2n2222 p complementary .MODEL Q2N2907P PNP(IS=650.6E-18 ISE=54.81E-15 ISC=0 XTI=3 + BF=231.7 BR=3.563 IKF=1.079 IKR=0 XTB=1.5 + VAF=115.7 VAR=35 VJE=0.65 VJC=0.65 + RE=0.15 RC=0.715 RB=10 + CJE=19.82E-12 CJC=14.76E-12 XCJC=0.75 FC=0.5 + NF=1 NR=1 NE=1.829 NC=2 MJE=0.3357 MJC=0.5383 + TF=603.7E-12 TR=111.3E-9 ITF=0.65 VTF=5 XTF=1.7 + EG=1.11 KF=1E-9 AF=1 + VCEO=45 ICRATING=100M + vce_max=45 vbe_max=6 ) .MODEL Q2N2907S PNP(IS=2.32E-13 ISE=6.69E-16 ISC=1.65E-13 XTI=3.00 + BF=3.08E2 BR=2.18E1 IKF=8.42E-1 IKR=1.00 XTB=1.5 + VAF=1.41E2 VAR=1.35E1 VJE=3.49E-1 VJC=3.00E-1 + RE=1.00E-2 RC=8.46E-1 RB=4.02E1 RBM=1.00E-2 IRB=1.25E-2 + CJE=2.66E-11 CJC=1.93E-11 XCJC=1.00 FC=5.00E-1 + NF=1.04 NR=1.12 NE=1.09 NC=1.13 MJE=4.60E-1 MJC=4.65E-1 + TF=4.95E-10 TR=0 PTF=0 ITF=3.36E-1 VTF=6.54 XTF=1.87E1 + EG=1.11 KF=1E-9 AF=1 + VCEO=40 ICRATING=500M + vce_max=45 vbe_max=6 ) *MM3725 MCE 5/13/95 *Si 1W 40V 500mA 307MHz pkg:TO-39 3,2,1 .MODEL QMM3725 NPN (IS=50.7F NF=1 BF=162 VAF=113 IKF=.45 ISE=38.2P NE=2 + BR=4 NR=1 VAR=24 IKR=.675 RE=.263 RB=1.05 RC=.105 XTB=1.5 + CJE=62.2P VJE=1.1 MJE=.5 CJC=14.6P VJC=.3 MJC=.3 TF=518P TR=45.9N) *MPS651 MCE 5/12/95 *Si 625mW 60V 2A 110MHz pkg:TO-92 1,2,3 .MODEL QMPS651 NPN (IS=72.1F NF=1 BF=260 VAF=139 IKF=2.5 ISE=67.1P NE=2 + BR=4 NR=1 VAR=20 IKR=3.75 RE=28.2M RB=.113 RC=11.3M XTB=1.5 + CJE=212P VJE=1.1 MJE=.5 CJC=68.6P VJC=.3 MJC=.3 TF=1.44N TR=1U) *FCX649 ZETEX Spice model Last revision 17/7/90 Medium Power *ZTX Si 1.5W 25V 2A 240MHz pkg:SOT-89 2,1,3 .MODEL QFCX649 NPN(IS=3E-13 BF=225 VAF=80 IKF=2.8 ISE=1.1E-13 NE=1.37 + BR=110 NR=0.972 VAR=28 IKR=0.8 ISC=6.5E-13 NC=1.372 RB=0.3 RE=0.063 + RC=0.07 CJE=3.25E-10 TF=1E-9 CJC=7E-11 TR=1E-8 ) *MPSW01A MCE 5/12/95 *Si 1W 40V 1A 210MHz pkg:TO-92 1,2,3 .MODEL QMPSW01A NPN (IS=18.1F NF=1 BF=273 VAF=113 IKF=.6 ISE=15.7P NE=2 + BR=4 NR=1 VAR=20 IKR=.9 RE=96.5M RB=.386 RC=38.6M XTB=1.5 + CJE=78.7P VJE=1.1 MJE=.5 CJC=17.3P VJC=.3 MJC=.3 TF=757P TR=526N) *BC546 ZETEX Spice model Last revision 4/90 General Purpose *ZTX Si 500mW 65V 200mA 300MHz pkg:TO-92 1,2,3 .MODEL BC546 NPN(IS=1.8E-14 BF=400 NF=0.9955 VAF=80 IKF=0.14 ISE=5E-14 + NE=1.46 BR=35.5 NR=1.005 VAR=12.5 IKR=0.03 ISC=1.72E-13 NC=1.27 RB=0.56 + RE=0.6 RC=0.25 CJE=1.3E-11 TF=6.4E-10 CJC=4E-12 VJC=0.54 TR=5.072E-8 + vce_max=65 vbe_max=6 ) .MODEL BC556 PNP( + IS=2.059E-14 + NF=1.003 + ISE=2.971E-15 + NE=1.316 + BF=227.3 + IKF=0.08719 + VAF=37.2 + NR=1.007 + ISC=1.339E-14 + NC=1.15 + BR=7.69 + IKR=0.07646 + VAR=11.42 + RB=1 + IRB=1E-06 + RBM=1 + RE=0.688 + RC=0.6437 + XTB=0 + EG=1.11 + XTI=3 + CJE=1.4E-11 + VJE=0.5912 + MJE=0.3572 + TF=7.046E-10 + XTF=4.217 + VTF=5.367 + ITF=0.1947 + PTF=0 + CJC=1.113E-11 + VJC=0.1 + MJC=0.3414 + XCJC=0.6288 + TR=1E-32 + CJS=0 + VJS=0.75 + MJS=0.333 + FC=0.7947 + vce_max=65 vbe_max=6 ) * * NXP Semiconductors * * Medium power NPN transistor * IC = 1 A * VCEO = 20 V * hFE = 85 - 375 @ 2V/500mA * * * * * Package pinning does not match Spice model pinning. * Package: SOT 223 * * Package Pin 1: Base * Package Pin 2: Collector * Package Pin 3: Emitter * Package Pin 4: Collector * * Extraction date (week/year): 13/2008 * Simulator: Spice 3 * ********************************************************** *# .SUBCKT BCP68 1 2 3 * Q1 1 2 3 BCP68 D1 2 1 DIODE * *The diode does not reflect a *physical device but improves *only modeling in the reverse *mode of operation. * .MODEL BCP68 NPN + IS = 2.312E-013 + NF = 0.988 + ISE = 8.851E-014 + NE = 2.191 + BF = 273 + IKF = 5.5 + VAF = 50 + NR = 0.9885 + ISC = 6.808E-014 + NC = 3 + BR = 155.6 + IKR = 4 + VAR = 17 + RB = 15 + IRB = 2E-006 + RBM = 0.65 + RE = 0.073 + RC = 0.073 + XTB = 0 + EG = 1.11 + XTI = 3 + CJE = 2.678E-010 + VJE = 0.732 + MJE = 0.3484 + TF = 5.8E-010 + XTF = 1.5 + VTF = 2.5 + ITF = 1 + PTF = 0 + CJC = 3.406E-011 + VJC = 2 + MJC = 0.3142 + XCJC = 1 + TR = 6.5E-009 + CJS = 0 + VJS = 0.75 + MJS = 0.333 + FC = 0.95 .MODEL DIODE D + IS = 2.702E-015 + N = 1.2 + BV = 1000 + IBV = 0.001 + RS = 0.1 + CJO = 0 + VJ = 1 + M = 0.5 + FC = 0 + TT = 0 + EG = 1.11 + XTI = 3 .ENDS .model D1N4007 D(IS=7.02767n RS=0.0341512 N=1.80803 EG=1.05743 XTI=5 BV=1000 IBV=5e-08 CJO=1e-11 VJ=0.7 M=0.5 FC=0.5 TT=1e-07 ) .MODEL D1N4148 D + IS = 4.352E-9 + N = 1.906 + BV = 110 + IBV = 0.0001 + RS = 0.6458 + CJO = 7.048E-13 + VJ = 0.869 + M = 0.03 + FC = 0.5 + TT = 3.48E-9 .MODEL D1n5400 d +IS=2.61339e-12 RS=0.0110501 N=1.20576 EG=0.6 +XTI=3.1271 BV=50 IBV=1e-05 CJO=1e-11 +VJ=0.7 M=0.5 FC=0.5 TT=1e-09 +KF=0 AF=1 * Model generated on October 12, 2003 * Model format: PSpice *1N758 *Ref: Motorola *10V 500mW Si Zener pkg:DIODE0.4 1,2 .MODEL D1N758 D(IS=1E-11 RS=8.483 N=1.27 TT=5E-8 CJO=2.334E-10 VJ=0.75 + M=0.33 BV=9.83 IBV=0.01 ) *1N4744 *Ref: Motorola *15V 1W Si Zener pkg:DIODE0.4 1,2 .MODEL D1N4744 D(IS=5.32E-14 RS=6.47 TT=5.01E-8 CJO=7.83E-11 M=0.33 + BV=14.89 IBV=0.017 ) *1N755 *Ref: Motorola *7.5V 500mW Si Zener pkg:DIODE0.4 1,2 .MODEL D1N755 D(IS=1E-11 RS=3.359 N=1.27 TT=5E-8 CJO=2.959E-10 VJ=0.75 + M=0.33 BV=7.433 IBV=0.01 ) ** node order * 1: gnd * 2: trig * 3: out * 4: reset# * 5: ctrl * 6: thres * 7: dis * 8: vcc .SUBCKT ne555 34 32 30 19 23 33 1 21 * G TR O R F TH D V Q4 25 2 3 QP Q5 34 6 3 QP Q6 6 6 8 QP R1 9 21 4.7K R2 3 21 830 R3 8 21 4.7K Q7 2 33 5 QN Q8 2 5 17 QN Q9 6 4 17 QN Q10 6 23 4 QN Q11 12 20 10 QP R4 10 21 1K Q12 22 11 12 QP Q13 14 13 12 QP Q14 34 32 11 QP Q15 14 18 13 QP R5 14 34 100K R6 22 34 100K R7 17 34 10K Q16 1 15 34 QN Q17 15 19 31 QP R8 18 23 5K R9 18 34 5K R10 21 23 5K Q18 27 20 21 QP Q19 20 20 21 QP R11 20 31 5K D1 31 24 DA Q20 24 25 34 QN Q21 25 22 34 QN Q22 27 24 34 QN R12 25 27 4.7K R13 21 29 6.8K Q23 21 29 28 QN Q24 29 27 16 QN Q25 30 26 34 QN Q26 21 28 30 QN D2 30 29 DA R14 16 15 100 R15 16 26 220 R16 16 34 4.7K R17 28 30 3.9K Q3 2 2 9 QP .MODEL DA D (RS=40 IS=1.0E-14 CJO=1PF) .MODEL QP PNP (level=1 BF=20 BR=0.02 RC=4 RB=25 IS=1.0E-14 VA=50 NE=2) + CJE=12.4P VJE=1.1 MJE=.5 CJC=4.02P VJC=.3 MJC=.3 TF=229P TR=159N) .MODEL QN NPN (level=1 IS=5.07F NF=1 BF=100 VAF=161 IKF=30M ISE=3.9P NE=2 + BR=4 NR=1 VAR=16 IKR=45M RE=1.03 RB=4.12 RC=.412 XTB=1.5 + CJE=12.4P VJE=1.1 MJE=.5 CJC=4.02P VJC=.3 MJC=.3 TF=229P TR=959P) .ENDS .SUBCKT BS250P 3 4 5 * D G S M1 3 2 5 5 MBS250 RG 4 2 160 RL 3 5 1.2E8 C1 2 5 47E-12 C2 3 2 10E-12 D1 3 5 DBS250 * .MODEL MBS250 PMOS VTO=-3.193 RS=2.041 RD=0.697 IS=1E-15 KP=0.277 +CBD=105E-12 PB=1 LAMBDA=1.2E-2 .MODEL DBS250 D IS=2E-13 RS=0.309 .ENDS BS250P .SUBCKT BS170 3 4 5 * D G S M1 3 2 5 5 N3306M RG 4 2 270 RL 3 5 1.2E8 C1 2 5 28E-12 C2 3 2 3E-12 D1 5 3 N3306D * .MODEL N3306M NMOS VTO=1.824 RS=1.572 RD=1.436 IS=1E-15 KP=.1233 +CBD=35E-12 PB=1 .MODEL N3306D D IS=5E-12 RS=.768 .ENDS BS170 * *$ .SUBCKT PTON_TOFF_U4_S1 1 2 3 4 G_Switch 3 4 VCR PWL(1) 1 2 0.2 100e6 0.8 1m RS_U4_S1 1 2 1G .ENDS PTON_TOFF_U4_S1 *$ .SUBCKT PTON_TOFF_U4_S2 1 2 3 4 G_Switch 3 4 VCR PWL(1) 1 2 0.2 100e6 0.8 1m RS_U4_S2 1 2 1G .ENDS PTON_TOFF_U4_S2 *$ .SUBCKT MTON_TOFF_U2_S2 1 2 3 4 G_Switch 3 4 VCR PWL(1) 1 2 0.2 100e6 0.8 1m RS_U2_S2 1 2 1G .ENDS MTON_TOFF_U2_S2 *$ .SUBCKT MTON_TOFF_U2_S1 1 2 3 4 G_Switch 3 4 VCR PWL(1) 1 2 0.2 100e6 0.8 1m RS_U2_S1 1 2 1G .ENDS MTON_TOFF_U2_S1 *$ ****************************** Basic Components ************************** .SUBCKT D_D1 1 2 D1 1 2 DD1 .MODEL DD1 D (IS=1e-15 Rs=0.001 N=0.1 TT=10p) .ENDS D_D1 *$ .SUBCKT BUF_BASIC_GEN A Y VDD=1 VSS=0 VTHRESH=0.5 * E_ABMGATE YINT 0 vol='V(A) > VTHRESH? VDD:VSS' E_ABMGATE YINT 0 pwl(1) A 0 'VTHRESH-0.01' VSS 'VTHRESH+0.01' VDD RINT YINT Y 1 CINT Y 0 1n .ENDS BUF_BASIC_GEN *$ .MODEL NMOS01 NMOS (VTO = 2 KP = 1.005 LAMBDA = 0.001) *$ .MODEL PMOS01 PMOS (VTO = -2 KP = 1.77 LAMBDA = 0.001) *$ .MODEL NMOS02 NMOS (VTO = 2 KP = 0.1814 LAMBDA = 0.001) *$ .MODEL PMOS02 PMOS (VTO = -2 KP = 0.2497 LAMBDA = 0.001) *$ .SUBCKT COMPHYS_BASIC_GEN INP INM HYS OUT VDD=1 VSS=0 VTHRESH=0.5 EIN INP1 INM1 INP INM 1 * EHYS INP1 INP2 vol='V(1) > VTHRESH? -V(HYS):0' EHYS INP1 INP2 pwl(1) 1 0 'VTHRESH-0.01' 0 'VTHRESH+0.01' '-V(HYS)' EOUT OUT 0 vol='V(INP2)>V(INM1)? VDD : VSS' R1 OUT 1 1 C1 1 0 5n RINP1 INP1 0 1K .ENDS COMPHYS_BASIC_GEN *$ .SUBCKT AND2_BASIC_GEN A B Y VDD=1 VSS=0 VTHRESH=0.5 E_ABMGATE YINT 0 vol= 'V(A) > VTHRESH && V(B) > VTHRESH ? VDD:VSS' RINT YINT Y 1 CINT Y 0 1n .ENDS AND2_BASIC_GEN *$ .SUBCKT NOR2_BASIC_GEN A B Y VDD=1 VSS=0 VTHRESH=0.5 E_ABMGATE YINT 0 vol= 'V(A) > VTHRESH || V(B) > VTHRESH ? VSS:VDD' RINT YINT Y 1 CINT Y 0 1n .ENDS NOR2_BASIC_GEN *$ .SUBCKT AND3_BASIC_GEN A B C Y VDD=1 VSS=0 VTHRESH=0.5 E_ABMGATE YINT 0 vol= 'V(A) > VTHRESH && V(B) > VTHRESH && V(C) > VTHRESH ? VDD:VSS' RINT YINT Y 1 CINT Y 0 1n .ENDS AND3_BASIC_GEN *$ .SUBCKT INV_BASIC_GEN A Y VDD=1 VSS=0 VTHRESH=0.5 * E_ABMGATE YINT 0 vol='V(A) > VTHRESH ? VSS : VDD' E_ABMGATE YINT 0 pwl(1) A 0 'VTHRESH-0.01' VDD 'VTHRESH+0.01' VSS RINT YINT Y 1 CINT Y 0 1n .ENDS INV_BASIC_GEN *$ .SUBCKT RVAR 101 102 201 202 RREF=1 * nodes : 101 102 : nodes between which variable resistance is placed * 201 202 : nodes to whose voltage the resistance is proportional * parameters : rref : reference value of the resistance rin 201 202 1G $$ input resistance r 301 0 rref fcopy 0 301 vsense 1 $$ copy output current thru Z eout 101 106 poly(2) 201 202 301 0 0 0 0 0 1 $$ multiply VoverZ with Vctrl vsense 106 102 0 $$ sense iout .ENDS RVAR *$ *LM317 TI voltage regulator - pin order: In, Adj, Out *TI adjustable voltage regulator pkg:TO-3 .SUBCKT LM317 1 2 3 **Changes my be required on this line** J1 1 3 4 JN Q2 5 5 6 QPL .1 Q3 5 8 9 QNL .2 Q4 8 5 7 QPL .1 Q5 81 8 3 QNL .2 Q6 3 81 10 QPL .2 Q7 12 81 13 QNL .2 Q8 10 5 11 QPL .2 Q9 14 12 10 QPL .2 Q10 16 5 17 QPL .2 Q11 16 14 15 QNL .2 Q12 3 20 16 QPL .2 Q13 1 19 20 QNL .2 Q14 19 5 18 QPL .2 Q15 3 21 19 QPL .2 Q16 21 22 16 QPL .2 Q17 21 3 24 QNL .2 Q18 22 22 16 QPL .2 Q19 22 3 241 QNL 2 Q20 3 25 16 QPL .2 Q21 25 26 3 QNL .2 Q22A 35 35 1 QPL 2 Q22B 16 35 1 QPL 2 Q23 35 16 30 QNL 2 Q24A 27 40 29 QNL .2 Q24B 27 40 28 QNL .2 Q25 1 31 41 QNL 5 Q26 1 41 32 QNL 50 D1 3 4 DZ D2 33 1 DZ D3 29 34 DZ R1 1 6 310 R2 1 7 310 R3 1 11 190 R4 1 17 82 R5 1 18 5.6K R6 4 8 100K R7 8 81 130 R8 10 12 12.4K R9 9 3 180 R10 13 3 4.1K R11 14 3 5.8K R12 15 3 72 R13 20 3 5.1K R14 2 24 12K R15 24 241 2.4K R16 16 25 6.7K R17 16 40 12K R18 30 41 130 R19 16 31 370 R20 26 27 13K R21 27 40 400 R22 3 41 160 R23 33 34 18K R24 28 29 160 R25 28 32 3 R26 32 3 .1 C1 21 3 30PF C2 21 2 30PF C3 25 26 5PF CBS1 5 3 2PF CBS2 35 3 1PF CBS3 22 3 1PF .MODEL JN NJF(BETA=1E-4 VTO=-7) .MODEL DZ D(BV=6.3) .MODEL QNL NPN(EG=1.22 BF=80 RB=100 CCS=1.5PF TF=.3NS TR=6NS CJE=2PF + CJC=1PF VAF=100) .MODEL QPL PNP(BF=40 RB=20 TF=.6NS TR=10NS CJE=1.5PF CJC=1PF VAF=50) .ENDS .SUBCKT xxxxLM317 1 3 2 * IN ADJ OUT IADJ 1 4 50U VREF 4 3 1.25 RC 1 14 0.742 DBK 14 13 D1 CBC 13 15 2.479N RBC 15 5 247 QP 13 5 2 Q1 RB2 6 5 124 DSC 6 11 D1 ESC 11 2 POLY(2) (13,5) (6,5) 2.85 + 0 0 0 -70.1M DFB 6 12 D1 EFB 12 2 POLY(2) (13,5) (6,5) 3.92 + -135M 0 1.21M -70.1M RB1 7 6 1 EB 7 2 8 2 2.56 CPZ 10 2 0.796U DPU 10 2 D1 RZ 8 10 0.104 RP 9 8 100 EP 9 2 4 2 103.6 RI 2 4 100MEG .MODEL Q1 NPN (IS=30F BF=100 + VAF=14.27 NF=1.604) .MODEL D1 D (IS=30F N=1.604) .ENDS .SUBCKT LM337 8 1 19 *Connections Input Adj. Output *LM337 negative voltage regulator .MODEL QN NPN (BF=50 TF=1N CJC=1P) .MODEL QPOUT PNP (BF=50 TF=1N RE=.2 CJC=1P) .MODEL QP PNP CJC=1P TF=2N .MODEL DN D .MODEL D2 D BV=12 IBV=100U R10 25 6 1K Q3 8 17 16 QPOUT Q4 8 25 17 QP R18 19 17 250 R19 19 16 .3 G1 8 6 1 18 .1 C7 6 2 .04U R24 2 8 100 I_ADJ 0 1 65U R26 8 25 200K Q5 25 4 19 QP R27 16 4 200 R28 7 4 7K D1 8 7 D2 D2 8 6 DN V1 18 19 1.25 .ENDS "} xschem-2.8.1/xschem_library/examples/pcb_test1.sch0000644000175100017510000000570213357507037020443 0ustar svnsvnG {} V {} S {} E {} B 20 270 -550 860 -290 {} T {3 of 4 NANDS of a 74ls00} 500 -580 0 0 0.4 0.4 {} T {EXPERIMENTAL schematic for generating a tEDAx netlist 1) set netlist mode to 'tEDAx' (Options menu -> tEDAx netlist) 2) press 'Netlist' button on the right 3) resulting netlist is in pcb_test1.tdx } 240 -730 0 0 0.5 0.5 {} N 230 -330 300 -330 {lab=INPUT_B} N 230 -370 300 -370 {lab=INPUT_A} N 680 -420 750 -420 {lab=B} N 680 -460 750 -460 {lab=A} N 400 -350 440 -350 {lab=B} N 850 -440 890 -440 {lab=OUTPUT_Y} N 230 -440 300 -440 {lab=INPUT_F} N 230 -480 300 -480 {lab=INPUT_E} N 400 -460 440 -460 {lab=A} N 550 -190 670 -190 {lab=VCCFILT} N 590 -130 590 -110 {lab=ANALOG_GND} N 790 -190 940 -190 {lab=VCC5} N 890 -130 890 -110 {lab=ANALOG_GND} N 730 -110 890 -110 {lab=ANALOG_GND} N 730 -160 730 -110 {lab=ANALOG_GND} N 590 -110 730 -110 {lab=ANALOG_GND} N 440 -460 680 -460 {lab=A} N 500 -420 680 -420 {lab=B} N 500 -420 500 -350 {lab=B} N 440 -350 500 -350 {lab=B} C {devices/title} 160 -30 0 0 {name=l2 author="Stefan"} C {pcb/74ls00} 340 -350 0 0 {name=U1:2 risedel=100 falldel=200} C {pcb/74ls00} 790 -440 0 0 {name=U1:1 risedel=100 falldel=200} C {devices/lab_pin} 890 -440 0 1 {name=p0 lab=OUTPUT_Y} C {pcb/capa} 590 -160 0 0 {name=C0 m=1 value=100u device="electrolitic capacitor"} C {pcb/74ls00} 340 -460 0 0 {name=U1:4 risedel=100 falldel=200 power=VCC5 url="http://www.engrcs.com/components/74LS00.pdf"} C {pcb/7805} 730 -190 0 0 {name=U0 url="https://www.sparkfun.com/datasheets/Components/LM7805.pdf"} C {devices/lab_pin} 490 -190 0 0 {name=p20 lab=VCC12} C {devices/lab_pin} 940 -190 0 1 {name=p22 lab=VCC5} C {devices/lab_pin} 590 -110 0 0 {name=p23 lab=ANALOG_GND} C {pcb/capa} 890 -160 0 0 {name=C4 m=1 value=10u device="tantalium capacitor"} C {pcb/res} 520 -190 1 0 {name=R0 m=1 value=4.7 device="carbon resistor"} C {devices/lab_wire} 620 -460 0 0 {name=l3 lab=A} C {devices/lab_wire} 620 -420 0 0 {name=l0 lab=B} C {devices/lab_wire} 650 -190 0 0 {name=l1 lab=VCCFILT} C {pcb/connector} 230 -370 0 0 {name=CONN1 lab=INPUT_A verilog_type=reg} C {pcb/connector} 230 -330 0 0 {name=CONN2 lab=INPUT_B verilog_type=reg} C {pcb/connector} 240 -190 0 0 { name=CONN3 lab=OUTPUT_Y } C {pcb/connector} 230 -480 0 0 {name=CONN6 lab=INPUT_E verilog_type=reg} C {pcb/connector} 230 -440 0 0 {name=CONN8 lab=INPUT_F verilog_type=reg} C {pcb/connector} 240 -160 0 0 { name=CONN9 lab=VCC12 } C {pcb/connector} 240 -130 0 0 { name=CONN14 lab=ANALOG_GND verilog_type=reg} C {pcb/connector} 240 -100 0 0 { name=CONN15 lab=GND verilog_type=reg} C {devices/code} 1030 -280 0 0 {name=TESTBENCH_CODE only_toplevel=false value="initial begin $dumpfile(\\"dumpfile.vcd\\"); $dumpvars; INPUT_E=0; INPUT_F=0; INPUT_A=0; INPUT_B=0; ANALOG_GND=0; #10000; INPUT_A=1; INPUT_B=1; #10000; INPUT_E=1; INPUT_F=1; #10000; INPUT_F=0; #10000; INPUT_B=0; #10000; $finish; end assign VCC12=1; "} C {devices/verilog_timescale} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns" } xschem-2.8.1/xschem_library/examples/pump.sch0000644000175100017510000000167513161011201017515 0ustar svnsvnG { process variable del: time := 0.4 ns; variable delay: time; variable last : time; variable lowvalue: real; begin wait on ING , USC.cap; last := now; delay := del * USC.cap; print("start pump process: " & pump'PATH_NAME & " " & time'image(now) ); if(now=0 ns) then USC <= RREAL_0; elsif ING'event and ING='1' then USC.conduct<=conduct; transition(USC,val,delay); elsif ING'event and ING='0' then USC.conduct<=conduct; transition(USC,0.0,delay); elsif USC.cap'event and USC.cap > USC.cap'last_value and ING='1' then lowvalue := USC.value * USC.cap'last_value / USC.cap; glitch(USC, lowvalue, val, delay); end if; end process; } V {} C {devices/iopin} 50 -90 0 0 {name=p1 lab=USC sig_type="rreal"} C {devices/ipin} -80 -90 0 0 {name=p2 lab=ING} C {devices/use} -150 -260 0 0 {library ieee; use std.TEXTIO.all; use ieee.std_logic_1164.all; use work.rrreal.all; library work; use work.rrreal.all; } xschem-2.8.1/xschem_library/examples/nd2.sym0000644000175100017510000000110013362731551017255 0ustar svnsvnG {type=primitive vhdl_stop=true format="@name @@Z @@VSS nand(2) @@A @@VSS @@B @@VSS @TABLE" template="name=E1 TABLE=\\"1.4 3.0 1.6 0.0\\""} V {} S {} E {} L 4 -25 -30 -25 30 {} L 4 -25 -30 5 -30 {} L 4 -25 30 5 30 {} L 4 45 0 60 0 {} L 4 0 30 0 40 {} L 4 -40 20 -25 20 {} L 4 -40 -20 -25 -20 {} B 5 57.5 -2.5 62.5 2.5 {name=Z dir=out} B 5 -42.5 -22.5 -37.5 -17.5 {name=A dir=in} B 5 -42.5 17.5 -37.5 22.5 {name=B dir=in} B 5 -2.5 37.5 2.5 42.5 {name=VSS dir=in} A 4 5 0 30 270 180 {} A 4 40 0 5 180 360 {} T {ND2} -17.5 -25 0 0 0.3 0.3 {} T {@name} -21.25 -5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/an2.sym0000644000175100017510000000105113362731551017257 0ustar svnsvnG {type=primitive vhdl_stop=true format="@name @@Z @@VSS and(2) @@A @@VSS @@B @@VSS @TABLE" template="name=E1 TABLE=\\"1.4 0.0 1.6 3.0\\""} V {} S {} E {} L 4 -25 -30 -25 30 {} L 4 -25 -30 5 -30 {} L 4 -25 30 5 30 {} L 4 35 0 60 0 {} L 4 0 30 0 40 {} L 4 -40 20 -25 20 {} L 4 -40 -20 -25 -20 {} B 5 57.5 -2.5 62.5 2.5 {name=Z dir=out} B 5 -42.5 -22.5 -37.5 -17.5 {name=A dir=in} B 5 -42.5 17.5 -37.5 22.5 {name=B dir=in} B 5 -2.5 37.5 2.5 42.5 {name=VSS dir=in} A 4 5 0 30 270 180 {} T {AN2} -17.5 -25 0 0 0.3 0.3 {} T {@name} -21.25 -5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/greycnt.sch0000644000175100017510000001207213357507037020230 0ustar svnsvnG {} V {} S {} E {} T {BINARY} 500 -780 0 0 0.4 0.4 {} T {GRAY} 830 -780 0 0 0.4 0.4 {} T {BINARY} 1210 -780 0 0 0.4 0.4 {} N 720 -630 830 -630 {lab=B[6]} N 570 -610 620 -610 {lab=A[6]} N 570 -530 620 -530 {lab=A[5]} N 570 -450 620 -450 {lab=A[4]} N 720 -550 830 -550 {lab=B[5]} N 720 -470 830 -470 {lab=B[4]} N 570 -690 630 -690 {lab=A[7]} N 720 -390 830 -390 {lab=B[3]} N 570 -370 620 -370 {lab=A[3]} N 570 -290 620 -290 {lab=A[2]} N 570 -210 620 -210 {lab=A[1]} N 720 -310 830 -310 {lab=B[2]} N 720 -230 830 -230 {lab=B[1]} N 570 -130 620 -130 {lab=A[0]} N 720 -150 830 -150 {lab=B[0]} N 830 -130 1020 -130 {lab=B[0]} N 830 -150 830 -130 {lab=B[0]} N 830 -210 1020 -210 {lab=B[1]} N 830 -230 830 -210 {lab=B[1]} N 830 -290 1020 -290 {lab=B[2]} N 830 -310 830 -290 {lab=B[2]} N 830 -370 1020 -370 {lab=B[3]} N 830 -390 830 -370 {lab=B[3]} N 830 -450 1020 -450 {lab=B[4]} N 830 -470 830 -450 {lab=B[4]} N 830 -530 1020 -530 {lab=B[5]} N 830 -550 830 -530 {lab=B[5]} N 830 -610 1020 -610 {lab=B[6]} N 830 -630 830 -610 {lab=B[6]} N 690 -690 830 -690 {lab=B[7]} N 830 -690 1030 -690 {lab=B[7]} N 830 -710 830 -690 {lab=B[7]} N 1120 -630 1230 -630 {lab=C[6]} N 1120 -550 1230 -550 {lab=C[5]} N 1120 -470 1230 -470 {lab=C[4]} N 1120 -390 1230 -390 {lab=C[3]} N 1120 -310 1230 -310 {lab=C[2]} N 1120 -230 1230 -230 {lab=C[1]} N 1120 -150 1230 -150 {lab=C[0]} N 1090 -690 1130 -690 {lab=C[7]} N 1130 -710 1130 -690 {lab=C[7]} N 1130 -710 1230 -710 {lab=C[7]} N 1120 -630 1120 -590 {lab=C[6]} N 1020 -590 1120 -590 {lab=C[6]} N 1020 -590 1020 -570 {lab=C[6]} N 1120 -550 1120 -510 {lab=C[5]} N 1020 -510 1120 -510 {lab=C[5]} N 1020 -510 1020 -490 {lab=C[5]} N 1120 -470 1120 -430 {lab=C[4]} N 1020 -430 1120 -430 {lab=C[4]} N 1020 -430 1020 -410 {lab=C[4]} N 1120 -390 1120 -350 {lab=C[3]} N 1020 -350 1120 -350 {lab=C[3]} N 1020 -350 1020 -330 {lab=C[3]} N 1120 -310 1120 -270 {lab=C[2]} N 1020 -270 1120 -270 {lab=C[2]} N 1020 -270 1020 -250 {lab=C[2]} N 1120 -230 1120 -190 {lab=C[1]} N 1020 -190 1120 -190 {lab=C[1]} N 1020 -190 1020 -170 {lab=C[1]} N 1130 -690 1130 -670 {lab=C[7]} N 1020 -670 1130 -670 {lab=C[7]} N 1020 -670 1020 -650 {lab=C[7]} N 620 -690 620 -650 {lab=A[7]} N 620 -610 620 -570 {lab=A[6]} N 620 -530 620 -490 {lab=A[5]} N 620 -450 620 -410 {lab=A[4]} N 620 -370 620 -330 {lab=A[3]} N 620 -290 620 -250 {lab=A[2]} N 620 -210 620 -170 {lab=A[1]} C {devices/title} 160 -30 0 0 {name=l3 author="Stefan Schippers"} C {devices/verilog_timescale} 30 -110 0 0 {name=s1 timestep="1ps" precision="1ps" } C {examples/xnor} 660 -470 0 0 {name=x2 risedel=1 falldel=1} C {examples/xnor} 660 -550 0 0 {name=x3 risedel=1 falldel=1} C {examples/xnor} 660 -630 0 0 {name=x14 risedel=1 falldel=1} C {devices/lab_pin} 570 -690 0 0 {name=p9 lab=A[7] } C {devices/lab_pin} 570 -610 0 0 {name=p1 lab=A[6] } C {devices/lab_pin} 570 -530 0 0 {name=p2 lab=A[5] } C {devices/lab_pin} 570 -450 0 0 {name=p3 lab=A[4] } C {devices/lab_pin} 830 -710 0 1 {name=p4 lab=B[7]} C {devices/lab_pin} 830 -630 0 1 {name=p0 lab=B[6]} C {devices/lab_pin} 830 -550 0 1 {name=p5 lab=B[5]} C {devices/lab_pin} 830 -470 0 1 {name=p6 lab=B[4]} C {devices/assign} 660 -690 0 0 {name=v1 delay=1} C {examples/xnor} 660 -230 0 0 {name=x1 risedel=1 falldel=1} C {examples/xnor} 660 -310 0 0 {name=x4 risedel=1 falldel=1} C {examples/xnor} 660 -390 0 0 {name=x5 risedel=1 falldel=1} C {devices/lab_pin} 570 -370 0 0 {name=p7 lab=A[3] } C {devices/lab_pin} 570 -290 0 0 {name=p8 lab=A[2] } C {devices/lab_pin} 570 -210 0 0 {name=p10 lab=A[1]} C {devices/lab_pin} 830 -390 0 1 {name=p11 lab=B[3]} C {devices/lab_pin} 830 -310 0 1 {name=p12 lab=B[2]} C {devices/lab_pin} 830 -230 0 1 {name=p13 lab=B[1]} C {examples/xnor} 660 -150 0 0 {name=x6 risedel=1 falldel=1} C {devices/lab_pin} 570 -130 0 0 {name=p14 lab=A[0]} C {devices/lab_pin} 830 -150 0 1 {name=p15 lab=B[0]} C {devices/opin} 150 -220 0 0 { name=p16 lab=B[7:0] } C {devices/lab_pin} 90 -200 0 0 { name=l17 lab=A[7:0] verilog_type=reg} C {examples/xnor} 1060 -470 0 0 {name=x7 risedel=1 falldel=1} C {examples/xnor} 1060 -550 0 0 {name=x8 risedel=1 falldel=1} C {examples/xnor} 1060 -630 0 0 {name=x9 risedel=1 falldel=1} C {devices/assign} 1060 -690 0 0 {name=v0 delay=1} C {examples/xnor} 1060 -230 0 0 {name=x10 risedel=1 falldel=1} C {examples/xnor} 1060 -310 0 0 {name=x11 risedel=1 falldel=1} C {examples/xnor} 1060 -390 0 0 {name=x12 risedel=1 falldel=1} C {examples/xnor} 1060 -150 0 0 {name=x13 risedel=1 falldel=1} C {devices/lab_pin} 1230 -710 0 1 {name=p18 lab=C[7]} C {devices/lab_pin} 1230 -630 0 1 {name=p19 lab=C[6]} C {devices/lab_pin} 1230 -550 0 1 {name=p20 lab=C[5]} C {devices/lab_pin} 1230 -470 0 1 {name=p21 lab=C[4]} C {devices/lab_pin} 1230 -390 0 1 {name=p22 lab=C[3]} C {devices/lab_pin} 1230 -310 0 1 {name=p23 lab=C[2]} C {devices/lab_pin} 1230 -230 0 1 {name=p24 lab=C[1]} C {devices/lab_pin} 1230 -150 0 1 {name=p25 lab=C[0]} C {devices/opin} 150 -190 0 0 { name=p26 lab=C[7:0] } C {devices/code} 330 -250 0 0 {name=TESTBENCH only_toplevel=false value="initial begin $dumpfile(\\"dumpfile.vcd\\"); $dumpvars; A=0; end always begin #1000; $display(\\"%08b %08b\\", A, B); A=A + 1; if(A==0) $finish; end "} xschem-2.8.1/xschem_library/examples/loading.sym0000644000175100017510000000035413161011201020175 0ustar svnsvnG {type=subcircuit format="@name @pinlist @symname" template="name=x1" } T {@symname} -31.5 -6 0 0 0.3 0.3 {} T {@name} 135 -22 0 0 0.2 0.2 {} L 4 -130 -10 130 -10 {} L 4 -130 10 130 10 {} L 4 -130 -10 -130 10 {} L 4 130 -10 130 10 {} xschem-2.8.1/xschem_library/examples/real_capa.sch0000644000175100017510000000133313161011201020432 0ustar svnsvnG { process variable buf: LINE; variable last : time; variable val : real; begin if now = 0 ns then last := now; USC.cap <=cap; USC.conduct <=0.0; USC.value <= 0.0; end if; wait on USC until last /=now; last := now; WRITE(buf,string'("start real_capa process")); WRITELINE(output,buf); USC.conduct <= 0.0; USC.cap <= cap ; val := USC.value'LAST_VALUE; if now = 0 ns then USC.value <= 0.0; else USC.value <= val; end if; end process; } V {} S {} C {devices/iopin} 50 -80 0 0 {name=p1 lab=USC sig_type=rreal} C {devices/use} -120 -340 0 0 {library ieee; use std.TEXTIO.all; use ieee.std_logic_1164.all; use work.rrreal.all; library work; use work.rrreal.all; } xschem-2.8.1/xschem_library/examples/cmos_example.sym0000644000175100017510000000042113023243556021250 0ustar svnsvnG {type=subcircuit format="@name @pinlist @symname" verilog_stop=true template="name=x1" } V {} S {} L 4 -130 -10 130 -10 {} L 4 -130 10 130 10 {} L 4 -130 -10 -130 10 {} L 4 130 -10 130 10 {} T {@symname} -58.5 -6 0 0 0.3 0.3 {} T {@name} 135 -22 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/sr_flop.sch0000644000175100017510000000417113023243556020213 0ustar svnsvnG {} V {} S {} N 780 -320 780 -280 {lab=#net1} N 750 -280 780 -280 {lab=#net1} N 780 -390 780 -360 {lab=#net2} N 750 -390 780 -390 {lab=#net2} N 300 -260 300 -220 {lab=#net3} N 300 -410 300 -370 {lab=#net4} N 300 -410 380 -410 {lab=#net4} N 380 -410 560 -410 {lab=#net4} N 560 -410 560 -380 {lab=#net4} N 560 -410 650 -410 {lab=#net4} N 560 -380 560 -300 {lab=#net4} N 560 -300 650 -300 {lab=#net4} N 620 -370 620 -260 {lab=#net5} N 620 -370 650 -370 {lab=#net5} N 880 -340 930 -340 {lab=Q} N 390 -370 390 -320 {lab=#net6} N 120 -320 390 -320 {lab=#net6} N 120 -320 120 -260 {lab=#net6} N 380 -370 390 -370 {lab=#net6} N 310 -300 310 -260 {lab=#net3} N 50 -300 310 -300 {lab=#net3} N 50 -410 50 -300 {lab=#net3} N 50 -410 120 -410 {lab=#net3} N 300 -260 310 -260 {lab=#net3} N 380 -220 580 -220 {lab=#net5} N 580 -260 580 -220 {lab=#net5} N 580 -260 650 -260 {lab=#net5} C {devices/ipin} 280 -130 0 0 {name=p0 lab=S} C {devices/opin} 580 -130 0 0 {name=p2 lab=Q} C {devices/ipin} 280 -80 0 0 {name=p4 lab=VSS} C {devices/ipin} 280 -110 0 0 {name=p1 lab=R} C {examples/flop} 210 -400 0 0 {name=x1 VTH=VTH VHI=VHI} C {examples/flop} 210 -250 0 0 {name=x2 VTH=VTH VHI=VHI} C {devices/lab_pin} 340 -190 0 0 {name=p13 lab=VSS} C {devices/lab_pin} 120 -220 0 0 {name=p3 lab=VSS} C {devices/lab_pin} 120 -370 0 0 {name=p5 lab=VSS} C {examples/an2} 690 -390 0 0 {name=E2 TABLE="'VTH-0.1' 0.0 'VTH+0.1' VHI"} C {examples/nr2} 690 -280 0 0 {name=E3 TABLE="'VTH-0.1' VHI 'VTH+0.1' 0.0"} C {examples/or2} 820 -340 0 0 {name=E4 TABLE="'VTH-0.1' 0.0 'VTH+0.1' VHI"} C {devices/lab_pin} 690 -240 0 0 {name=p6 lab=VSS} C {devices/lab_pin} 690 -350 0 0 {name=p7 lab=VSS} C {devices/lab_pin} 820 -300 0 0 {name=p8 lab=VSS} C {devices/lab_pin} 340 -340 0 0 {name=p9 lab=VSS} C {devices/lab_pin} 930 -340 0 1 {name=l2 lab=Q} C {devices/lab_pin} 120 -390 0 0 {name=l3 lab=R} C {devices/lab_pin} 120 -240 0 0 {name=l4 lab=S} C {examples/inv} 340 -370 0 0 {name=E5 TABLE="'VTH-0.1' VHI 'VTH+0.1' 0"} C {examples/inv} 340 -220 0 0 {name=E1 TABLE="'VTH-0.1' VHI 'VTH+0.1' 0"} C {devices/title} 160 -30 0 0 {name=l1 author="Stefan Schippers"} xschem-2.8.1/xschem_library/examples/tesla.sym0000644000175100017510000000042113023243556017704 0ustar svnsvnG {type=subcircuit format="@name @pinlist @symname" verilog_stop=true template="name=x1" } V {} S {} L 4 -130 -10 130 -10 {} L 4 -130 10 130 10 {} L 4 -130 -10 -130 10 {} L 4 130 -10 130 10 {} T {@symname} -58.5 -6 0 0 0.3 0.3 {} T {@name} 135 -22 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/lm324.sch0000644000175100017510000000271313023243556017410 0ustar svnsvnG {name=m4 model=enmm9 m=1 w=6u l=1u} V {} S {* LM324 OPERATIONAL AMPLIFIER "MACROMODEL" SUBCIRCUIT * CREATED USING PARTS RELEASE 4.01 ON 09/08/89 AT 10:54 * (REV N/A) SUPPLY VOLTAGE: 5V * CONNECTIONS: NON-INVERTING INPUT * | INVERTING INPUT * | | POSITIVE POWER SUPPLY * | | | NEGATIVE POWER SUPPLY * | | | | OUTPUT * | | | | | * .SUBCKT LM324 1 2 3 4 5 * C1 11 12 5.544E-12 C2 6 7 20.00E-12 DC 5 53 DX DE 54 5 DX DLP 90 91 DX DLN 92 90 DX DP 4 3 DX EGND 99 0 POLY(2) (3,0) (4,0) 0 .5 .5 FB 7 99 POLY(5) VB VC VE VLP VLN 0 15.91E6 -20E6 20E6 20E6 -20E6 GA 6 0 11 12 125.7E-6 GCM 0 6 10 99 7.067E-9 IEE 3 10 DC 10.04E-6 HLIM 90 0 VLIM 1K Q1 11 2 13 QX Q2 12 1 14 QX R2 6 9 100.0E3 RC1 4 11 7.957E3 RC2 4 12 7.957E3 RE1 13 10 2.773E3 RE2 14 10 2.773E3 REE 10 99 19.92E6 RO1 8 5 50 RO2 7 99 50 RP 3 4 30.31E3 VB 9 0 DC 0 VC 3 53 DC 2.100 VE 54 4 DC .6 VLIM 7 8 DC 0 VLP 91 0 DC 40 VLN 0 92 DC 40 .MODEL DX D(IS=800.0E-18) .MODEL QX PNP(IS=800.0E-18 BF=250) * .ENDS} C {devices/ipin} 580 -210 0 0 {name=p1 lab=1} C {devices/ipin} 580 -190 0 0 {name=p2 lab=2} C {devices/ipin} 580 -170 0 0 {name=p3 lab=3} C {devices/ipin} 580 -150 0 0 {name=p4 lab=4} C {devices/opin} 720 -190 0 0 {name=p5 lab=5} C {devices/title} 160 -30 0 0 {name=l1 author="Stefan Schippers"} xschem-2.8.1/xschem_library/examples/test_ne555.sch0000644000175100017510000003630613370707253020460 0ustar svnsvnG {} V {} S {} E {} T {NE555 TIMER IC EXAMPLE} 360 -490 0 0 0.4 0.4 {} N 130 -150 200 -150 {lab=TRIG} C {devices/code} 710 -190 0 0 { name=STIMULI value=".option SCALE=1e-6 PARHIER=LOCAL RUNLVL=6 post MODMONTE=1 .option sampling_method = SRS * .option method=gear vvss vss 0 dc 0 .temp 30 .tran 1n 1m uic"} C {examples/ne555} 490 -220 0 0 {name=x1} C {devices/res} 130 -180 0 0 {name=r3 m=1 value=2k} C {devices/capa} 130 -120 0 0 {name=c6 m=1 value=2n} C {devices/vsource} 130 -360 0 1 {name=v1 value=5} C {devices/lab_pin} 130 -330 0 0 {name=p16 lab=VSS} C {devices/lab_pin} 130 -390 0 1 {name=p6 lab=VSUPPLY} C {devices/lab_pin} 570 -340 0 1 {name=p8 lab=VSUPPLY} C {devices/lab_pin} 410 -340 0 0 {name=p9 lab=VSS} C {devices/lab_pin} 410 -260 0 0 {name=p11 lab=TRIG} C {devices/lab_pin} 410 -180 0 0 {name=p12 lab=OUT} C {devices/lab_pin} 570 -180 0 1 {name=p15 lab=TRIG} C {devices/lab_pin} 200 -150 0 1 {name=p19 lab=TRIG} C {devices/lab_pin} 130 -270 0 0 {name=p20 lab=VSUPPLY} C {devices/lab_pin} 130 -90 0 0 {name=p21 lab=VSS} C {devices/lab_pin} 570 -100 0 1 {name=p14 lab=CTRL} C {devices/lab_pin} 410 -100 0 0 {name=p13 lab=VSUPPLY} C {devices/lab_pin} 570 -260 0 1 {name=p17 lab=DIS} C {devices/res} 130 -240 0 0 {name=r5 m=1 value=2k} C {devices/lab_pin} 130 -210 0 0 {name=p18 lab=DIS} C {devices/title} 160 -30 0 0 {name=l1 author="Stefan Schippers"} C {devices/code} 710 -360 0 0 {name=MODELS only_toplevel=true value=".MODEL bd139_2 npn +IS=1e-09 BF=222.664 NF=0.85 VAF=36.4079 +IKF=0.166126 ISE=5.03418e-09 NE=1.45313 BR=1.35467 +NR=1.33751 VAR=142.931 IKR=1.66126 ISC=5.02557e-09 +NC=3.10227 RB=26.9143 IRB=0.1 RBM=0.1 +RE=0.000472454 RC=1.04109 XTB=0.727762 XTI=1.04311 +EG=1.05 CJE=1e-11 VJE=0.75 MJE=0.33 +TF=1e-09 XTF=1 VTF=10 ITF=0.01 +CJC=1e-11 VJC=0.75 MJC=0.33 XCJC=0.9 +FC=0.5 CJS=0 VJS=0.75 MJS=0.5 +TR=1e-07 PTF=0 KF=0 AF=1 .MODEL BD139 NPN ( +IS=2.3985E-13 Vceo=80 Icrating=1500m +BF=244.9 NF=1.0 BR=78.11 NR=1.007 ISE=1.0471E-14 +NE=1.2 ISC=1.9314E-11 NC=1.45 VAF=98.5 VAR=7.46 +IKF=1.1863 IKR=0.1445 RB=2.14 RBM=0.001 IRB=0.031 +RE=0.0832 RC=0.01 CJE=2.92702E-10 VJE=0.67412 +MJE=0.3300 FC=0.5 CJC=4.8831E-11 VJC=0.5258 +MJC=0.3928 XCJC=0.5287 XTB=1.1398 EG=1.2105 XTI=3.0) .MODEL BD140 PNP(IS=1e-09 BF=650.842 NF=0.85 VAF=10 +IKF=0.0950125 ISE=1e-08 NE=1.54571 BR=56.177 +NR=1.5 VAR=2.11267 IKR=0.950125 ISC=1e-08 +NC=3.58527 RB=41.7566 IRB=0.1 RBM=0.108893 +RE=0.000347052 RC=1.32566 XTB=19.5239 XTI=1 +EG=1.05 CJE=1e-11 VJE=0.75 MJE=0.33 +TF=1e-09 XTF=1 VTF=10 ITF=0.01 +CJC=1e-11 VJC=0.75 MJC=0.33 XCJC=0.9 +FC=0.5 CJS=0 VJS=0.75 MJS=0.5 TR=1e-07 PTF=0 KF=0 AF=10 + VCEO=80 ICRATING=1A ) .MODEL Q2N2222A NPN IS =3.0611E-14 NF =1.00124 BF =220 IKF=0.52 + VAF=104 ISE=7.5E-15 NE =1.41 NR =1.005 BR =4 IKR=0.24 + VAR=28 ISC=1.06525E-11 NC =1.3728 RB =0.13 RE =0.22 + RC =0.12 CJC=9.12E-12 MJC=0.3508 VJC=0.4089 + CJE=27.01E-12 TF =0.325E-9 TR =100E-9 + vce_max=45 vbe_max=6 .MODEL Q2N2222 NPN ( + IS = 3.97589E-14 BF = 195.3412 NF = 1.0040078 VAF = 53.081 IKF = 0.976 ISE = 1.60241E-14 + NE = 1.4791931 BR = 1.1107942 NR = 0.9928261 VAR = 11.3571702 IKR = 2.4993953 ISC = 1.88505E-12 + NC = 1.1838278 RB = 56.5826472 IRB = 1.50459E-4 RBM = 5.2592283 RE = 0.0402974 RC = 0.4208 + CJE = 2.56E-11 VJE = 0.682256 MJE = 0.3358856 TF = 3.3E-10 XTF = 6 VTF = 0.574 + ITF = 0.32 PTF = 25.832 CJC = 1.40625E-11 VJC = 0.5417393 MJC = 0.4547893 XCJC = 1 + TR = 3.2E-7 CJS = 0 VJS = .75 MJS = 0 XTB = 1.6486 EG = 1.11 + XTI = 5.8315 KF = 0 AF = 1 FC = 0.83 + vce_max=45 vbe_max=6 ) * 2n2222 p complementary .MODEL Q2N2907P PNP(IS=650.6E-18 ISE=54.81E-15 ISC=0 XTI=3 + BF=231.7 BR=3.563 IKF=1.079 IKR=0 XTB=1.5 + VAF=115.7 VAR=35 VJE=0.65 VJC=0.65 + RE=0.15 RC=0.715 RB=10 + CJE=19.82E-12 CJC=14.76E-12 XCJC=0.75 FC=0.5 + NF=1 NR=1 NE=1.829 NC=2 MJE=0.3357 MJC=0.5383 + TF=603.7E-12 TR=111.3E-9 ITF=0.65 VTF=5 XTF=1.7 + EG=1.11 KF=1E-9 AF=1 + VCEO=45 ICRATING=100M + vce_max=45 vbe_max=6 ) .MODEL Q2N2907S PNP(IS=2.32E-13 ISE=6.69E-16 ISC=1.65E-13 XTI=3.00 + BF=3.08E2 BR=2.18E1 IKF=8.42E-1 IKR=1.00 XTB=1.5 + VAF=1.41E2 VAR=1.35E1 VJE=3.49E-1 VJC=3.00E-1 + RE=1.00E-2 RC=8.46E-1 RB=4.02E1 RBM=1.00E-2 IRB=1.25E-2 + CJE=2.66E-11 CJC=1.93E-11 XCJC=1.00 FC=5.00E-1 + NF=1.04 NR=1.12 NE=1.09 NC=1.13 MJE=4.60E-1 MJC=4.65E-1 + TF=4.95E-10 TR=0 PTF=0 ITF=3.36E-1 VTF=6.54 XTF=1.87E1 + EG=1.11 KF=1E-9 AF=1 + VCEO=40 ICRATING=500M + vce_max=45 vbe_max=6 ) *MM3725 MCE 5/13/95 *Si 1W 40V 500mA 307MHz pkg:TO-39 3,2,1 .MODEL QMM3725 NPN (IS=50.7F NF=1 BF=162 VAF=113 IKF=.45 ISE=38.2P NE=2 + BR=4 NR=1 VAR=24 IKR=.675 RE=.263 RB=1.05 RC=.105 XTB=1.5 + CJE=62.2P VJE=1.1 MJE=.5 CJC=14.6P VJC=.3 MJC=.3 TF=518P TR=45.9N) *MPS651 MCE 5/12/95 *Si 625mW 60V 2A 110MHz pkg:TO-92 1,2,3 .MODEL QMPS651 NPN (IS=72.1F NF=1 BF=260 VAF=139 IKF=2.5 ISE=67.1P NE=2 + BR=4 NR=1 VAR=20 IKR=3.75 RE=28.2M RB=.113 RC=11.3M XTB=1.5 + CJE=212P VJE=1.1 MJE=.5 CJC=68.6P VJC=.3 MJC=.3 TF=1.44N TR=1U) *FCX649 ZETEX Spice model Last revision 17/7/90 Medium Power *ZTX Si 1.5W 25V 2A 240MHz pkg:SOT-89 2,1,3 .MODEL QFCX649 NPN(IS=3E-13 BF=225 VAF=80 IKF=2.8 ISE=1.1E-13 NE=1.37 + BR=110 NR=0.972 VAR=28 IKR=0.8 ISC=6.5E-13 NC=1.372 RB=0.3 RE=0.063 + RC=0.07 CJE=3.25E-10 TF=1E-9 CJC=7E-11 TR=1E-8 ) *MPSW01A MCE 5/12/95 *Si 1W 40V 1A 210MHz pkg:TO-92 1,2,3 .MODEL QMPSW01A NPN (IS=18.1F NF=1 BF=273 VAF=113 IKF=.6 ISE=15.7P NE=2 + BR=4 NR=1 VAR=20 IKR=.9 RE=96.5M RB=.386 RC=38.6M XTB=1.5 + CJE=78.7P VJE=1.1 MJE=.5 CJC=17.3P VJC=.3 MJC=.3 TF=757P TR=526N) *BC546 ZETEX Spice model Last revision 4/90 General Purpose *ZTX Si 500mW 65V 200mA 300MHz pkg:TO-92 1,2,3 .MODEL BC546 NPN(IS=1.8E-14 BF=400 NF=0.9955 VAF=80 IKF=0.14 ISE=5E-14 + NE=1.46 BR=35.5 NR=1.005 VAR=12.5 IKR=0.03 ISC=1.72E-13 NC=1.27 RB=0.56 + RE=0.6 RC=0.25 CJE=1.3E-11 TF=6.4E-10 CJC=4E-12 VJC=0.54 TR=5.072E-8 + vce_max=65 vbe_max=6 ) .MODEL BC556 PNP( + IS=2.059E-14 + NF=1.003 + ISE=2.971E-15 + NE=1.316 + BF=227.3 + IKF=0.08719 + VAF=37.2 + NR=1.007 + ISC=1.339E-14 + NC=1.15 + BR=7.69 + IKR=0.07646 + VAR=11.42 + RB=1 + IRB=1E-06 + RBM=1 + RE=0.688 + RC=0.6437 + XTB=0 + EG=1.11 + XTI=3 + CJE=1.4E-11 + VJE=0.5912 + MJE=0.3572 + TF=7.046E-10 + XTF=4.217 + VTF=5.367 + ITF=0.1947 + PTF=0 + CJC=1.113E-11 + VJC=0.1 + MJC=0.3414 + XCJC=0.6288 + TR=1E-32 + CJS=0 + VJS=0.75 + MJS=0.333 + FC=0.7947 + vce_max=65 vbe_max=6 ) * * NXP Semiconductors * * Medium power NPN transistor * IC = 1 A * VCEO = 20 V * hFE = 85 - 375 @ 2V/500mA * * * * * Package pinning does not match Spice model pinning. * Package: SOT 223 * * Package Pin 1: Base * Package Pin 2: Collector * Package Pin 3: Emitter * Package Pin 4: Collector * * Extraction date (week/year): 13/2008 * Simulator: Spice 3 * ********************************************************** *# .SUBCKT BCP68 1 2 3 * Q1 1 2 3 BCP68 D1 2 1 DIODE * *The diode does not reflect a *physical device but improves *only modeling in the reverse *mode of operation. * .MODEL BCP68 NPN + IS = 2.312E-013 + NF = 0.988 + ISE = 8.851E-014 + NE = 2.191 + BF = 273 + IKF = 5.5 + VAF = 50 + NR = 0.9885 + ISC = 6.808E-014 + NC = 3 + BR = 155.6 + IKR = 4 + VAR = 17 + RB = 15 + IRB = 2E-006 + RBM = 0.65 + RE = 0.073 + RC = 0.073 + XTB = 0 + EG = 1.11 + XTI = 3 + CJE = 2.678E-010 + VJE = 0.732 + MJE = 0.3484 + TF = 5.8E-010 + XTF = 1.5 + VTF = 2.5 + ITF = 1 + PTF = 0 + CJC = 3.406E-011 + VJC = 2 + MJC = 0.3142 + XCJC = 1 + TR = 6.5E-009 + CJS = 0 + VJS = 0.75 + MJS = 0.333 + FC = 0.95 .MODEL DIODE D + IS = 2.702E-015 + N = 1.2 + BV = 1000 + IBV = 0.001 + RS = 0.1 + CJO = 0 + VJ = 1 + M = 0.5 + FC = 0 + TT = 0 + EG = 1.11 + XTI = 3 .ENDS .model D1N4007 D(IS=7.02767n RS=0.0341512 N=1.80803 EG=1.05743 XTI=5 BV=1000 IBV=5e-08 CJO=1e-11 VJ=0.7 M=0.5 FC=0.5 TT=1e-07 ) .MODEL D1N4148 D + IS = 4.352E-9 + N = 1.906 + BV = 110 + IBV = 0.0001 + RS = 0.6458 + CJO = 7.048E-13 + VJ = 0.869 + M = 0.03 + FC = 0.5 + TT = 3.48E-9 .MODEL D1n5400 d +IS=2.61339e-12 RS=0.0110501 N=1.20576 EG=0.6 +XTI=3.1271 BV=50 IBV=1e-05 CJO=1e-11 +VJ=0.7 M=0.5 FC=0.5 TT=1e-09 +KF=0 AF=1 * Model generated on October 12, 2003 * Model format: PSpice *1N758 *Ref: Motorola *10V 500mW Si Zener pkg:DIODE0.4 1,2 .MODEL D1N758 D(IS=1E-11 RS=8.483 N=1.27 TT=5E-8 CJO=2.334E-10 VJ=0.75 + M=0.33 BV=9.83 IBV=0.01 ) *1N4744 *Ref: Motorola *15V 1W Si Zener pkg:DIODE0.4 1,2 .MODEL D1N4744 D(IS=5.32E-14 RS=6.47 TT=5.01E-8 CJO=7.83E-11 M=0.33 + BV=14.89 IBV=0.017 ) *1N755 *Ref: Motorola *7.5V 500mW Si Zener pkg:DIODE0.4 1,2 .MODEL D1N755 D(IS=1E-11 RS=3.359 N=1.27 TT=5E-8 CJO=2.959E-10 VJ=0.75 + M=0.33 BV=7.433 IBV=0.01 ) ** node order * 1: gnd * 2: trig * 3: out * 4: reset# * 5: ctrl * 6: thres * 7: dis * 8: vcc .SUBCKT ne555 34 32 30 19 23 33 1 21 * G TR O R F TH D V Q4 25 2 3 QP Q5 34 6 3 QP Q6 6 6 8 QP R1 9 21 4.7K R2 3 21 830 R3 8 21 4.7K Q7 2 33 5 QN Q8 2 5 17 QN Q9 6 4 17 QN Q10 6 23 4 QN Q11 12 20 10 QP R4 10 21 1K Q12 22 11 12 QP Q13 14 13 12 QP Q14 34 32 11 QP Q15 14 18 13 QP R5 14 34 100K R6 22 34 100K R7 17 34 10K Q16 1 15 34 QN Q17 15 19 31 QP R8 18 23 5K R9 18 34 5K R10 21 23 5K Q18 27 20 21 QP Q19 20 20 21 QP R11 20 31 5K D1 31 24 DA Q20 24 25 34 QN Q21 25 22 34 QN Q22 27 24 34 QN R12 25 27 4.7K R13 21 29 6.8K Q23 21 29 28 QN Q24 29 27 16 QN Q25 30 26 34 QN Q26 21 28 30 QN D2 30 29 DA R14 16 15 100 R15 16 26 220 R16 16 34 4.7K R17 28 30 3.9K Q3 2 2 9 QP .MODEL DA D (RS=40 IS=1.0E-14 CJO=1PF) .MODEL QP PNP (level=1 BF=20 BR=0.02 RC=4 RB=25 IS=1.0E-14 VA=50 NE=2) + CJE=12.4P VJE=1.1 MJE=.5 CJC=4.02P VJC=.3 MJC=.3 TF=229P TR=159N) .MODEL QN NPN (level=1 IS=5.07F NF=1 BF=100 VAF=161 IKF=30M ISE=3.9P NE=2 + BR=4 NR=1 VAR=16 IKR=45M RE=1.03 RB=4.12 RC=.412 XTB=1.5 + CJE=12.4P VJE=1.1 MJE=.5 CJC=4.02P VJC=.3 MJC=.3 TF=229P TR=959P) .ENDS .SUBCKT BS250P 3 4 5 * D G S M1 3 2 5 5 MBS250 RG 4 2 160 RL 3 5 1.2E8 C1 2 5 47E-12 C2 3 2 10E-12 D1 3 5 DBS250 * .MODEL MBS250 PMOS VTO=-3.193 RS=2.041 RD=0.697 IS=1E-15 KP=0.277 +CBD=105E-12 PB=1 LAMBDA=1.2E-2 .MODEL DBS250 D IS=2E-13 RS=0.309 .ENDS BS250P .SUBCKT BS170 3 4 5 * D G S M1 3 2 5 5 N3306M RG 4 2 270 RL 3 5 1.2E8 C1 2 5 28E-12 C2 3 2 3E-12 D1 5 3 N3306D * .MODEL N3306M NMOS VTO=1.824 RS=1.572 RD=1.436 IS=1E-15 KP=.1233 +CBD=35E-12 PB=1 .MODEL N3306D D IS=5E-12 RS=.768 .ENDS BS170 * *$ .SUBCKT PTON_TOFF_U4_S1 1 2 3 4 G_Switch 3 4 VCR PWL(1) 1 2 0.2 100e6 0.8 1m RS_U4_S1 1 2 1G .ENDS PTON_TOFF_U4_S1 *$ .SUBCKT PTON_TOFF_U4_S2 1 2 3 4 G_Switch 3 4 VCR PWL(1) 1 2 0.2 100e6 0.8 1m RS_U4_S2 1 2 1G .ENDS PTON_TOFF_U4_S2 *$ .SUBCKT MTON_TOFF_U2_S2 1 2 3 4 G_Switch 3 4 VCR PWL(1) 1 2 0.2 100e6 0.8 1m RS_U2_S2 1 2 1G .ENDS MTON_TOFF_U2_S2 *$ .SUBCKT MTON_TOFF_U2_S1 1 2 3 4 G_Switch 3 4 VCR PWL(1) 1 2 0.2 100e6 0.8 1m RS_U2_S1 1 2 1G .ENDS MTON_TOFF_U2_S1 *$ ****************************** Basic Components ************************** .SUBCKT D_D1 1 2 D1 1 2 DD1 .MODEL DD1 D (IS=1e-15 Rs=0.001 N=0.1 TT=10p) .ENDS D_D1 *$ .SUBCKT BUF_BASIC_GEN A Y VDD=1 VSS=0 VTHRESH=0.5 * E_ABMGATE YINT 0 vol='V(A) > VTHRESH? VDD:VSS' E_ABMGATE YINT 0 pwl(1) A 0 'VTHRESH-0.01' VSS 'VTHRESH+0.01' VDD RINT YINT Y 1 CINT Y 0 1n .ENDS BUF_BASIC_GEN *$ .MODEL NMOS01 NMOS (VTO = 2 KP = 1.005 LAMBDA = 0.001) *$ .MODEL PMOS01 PMOS (VTO = -2 KP = 1.77 LAMBDA = 0.001) *$ .MODEL NMOS02 NMOS (VTO = 2 KP = 0.1814 LAMBDA = 0.001) *$ .MODEL PMOS02 PMOS (VTO = -2 KP = 0.2497 LAMBDA = 0.001) *$ .SUBCKT COMPHYS_BASIC_GEN INP INM HYS OUT VDD=1 VSS=0 VTHRESH=0.5 EIN INP1 INM1 INP INM 1 * EHYS INP1 INP2 vol='V(1) > VTHRESH? -V(HYS):0' EHYS INP1 INP2 pwl(1) 1 0 'VTHRESH-0.01' 0 'VTHRESH+0.01' '-V(HYS)' EOUT OUT 0 vol='V(INP2)>V(INM1)? VDD : VSS' R1 OUT 1 1 C1 1 0 5n RINP1 INP1 0 1K .ENDS COMPHYS_BASIC_GEN *$ .SUBCKT AND2_BASIC_GEN A B Y VDD=1 VSS=0 VTHRESH=0.5 E_ABMGATE YINT 0 vol= 'V(A) > VTHRESH && V(B) > VTHRESH ? VDD:VSS' RINT YINT Y 1 CINT Y 0 1n .ENDS AND2_BASIC_GEN *$ .SUBCKT NOR2_BASIC_GEN A B Y VDD=1 VSS=0 VTHRESH=0.5 E_ABMGATE YINT 0 vol= 'V(A) > VTHRESH || V(B) > VTHRESH ? VSS:VDD' RINT YINT Y 1 CINT Y 0 1n .ENDS NOR2_BASIC_GEN *$ .SUBCKT AND3_BASIC_GEN A B C Y VDD=1 VSS=0 VTHRESH=0.5 E_ABMGATE YINT 0 vol= 'V(A) > VTHRESH && V(B) > VTHRESH && V(C) > VTHRESH ? VDD:VSS' RINT YINT Y 1 CINT Y 0 1n .ENDS AND3_BASIC_GEN *$ .SUBCKT INV_BASIC_GEN A Y VDD=1 VSS=0 VTHRESH=0.5 * E_ABMGATE YINT 0 vol='V(A) > VTHRESH ? VSS : VDD' E_ABMGATE YINT 0 pwl(1) A 0 'VTHRESH-0.01' VDD 'VTHRESH+0.01' VSS RINT YINT Y 1 CINT Y 0 1n .ENDS INV_BASIC_GEN *$ .SUBCKT RVAR 101 102 201 202 RREF=1 * nodes : 101 102 : nodes between which variable resistance is placed * 201 202 : nodes to whose voltage the resistance is proportional * parameters : rref : reference value of the resistance rin 201 202 1G $$ input resistance r 301 0 rref fcopy 0 301 vsense 1 $$ copy output current thru Z eout 101 106 poly(2) 201 202 301 0 0 0 0 0 1 $$ multiply VoverZ with Vctrl vsense 106 102 0 $$ sense iout .ENDS RVAR *$ *LM317 TI voltage regulator - pin order: In, Adj, Out *TI adjustable voltage regulator pkg:TO-3 .SUBCKT LM317 1 2 3 **Changes my be required on this line** J1 1 3 4 JN Q2 5 5 6 QPL .1 Q3 5 8 9 QNL .2 Q4 8 5 7 QPL .1 Q5 81 8 3 QNL .2 Q6 3 81 10 QPL .2 Q7 12 81 13 QNL .2 Q8 10 5 11 QPL .2 Q9 14 12 10 QPL .2 Q10 16 5 17 QPL .2 Q11 16 14 15 QNL .2 Q12 3 20 16 QPL .2 Q13 1 19 20 QNL .2 Q14 19 5 18 QPL .2 Q15 3 21 19 QPL .2 Q16 21 22 16 QPL .2 Q17 21 3 24 QNL .2 Q18 22 22 16 QPL .2 Q19 22 3 241 QNL 2 Q20 3 25 16 QPL .2 Q21 25 26 3 QNL .2 Q22A 35 35 1 QPL 2 Q22B 16 35 1 QPL 2 Q23 35 16 30 QNL 2 Q24A 27 40 29 QNL .2 Q24B 27 40 28 QNL .2 Q25 1 31 41 QNL 5 Q26 1 41 32 QNL 50 D1 3 4 DZ D2 33 1 DZ D3 29 34 DZ R1 1 6 310 R2 1 7 310 R3 1 11 190 R4 1 17 82 R5 1 18 5.6K R6 4 8 100K R7 8 81 130 R8 10 12 12.4K R9 9 3 180 R10 13 3 4.1K R11 14 3 5.8K R12 15 3 72 R13 20 3 5.1K R14 2 24 12K R15 24 241 2.4K R16 16 25 6.7K R17 16 40 12K R18 30 41 130 R19 16 31 370 R20 26 27 13K R21 27 40 400 R22 3 41 160 R23 33 34 18K R24 28 29 160 R25 28 32 3 R26 32 3 .1 C1 21 3 30PF C2 21 2 30PF C3 25 26 5PF CBS1 5 3 2PF CBS2 35 3 1PF CBS3 22 3 1PF .MODEL JN NJF(BETA=1E-4 VTO=-7) .MODEL DZ D(BV=6.3) .MODEL QNL NPN(EG=1.22 BF=80 RB=100 CCS=1.5PF TF=.3NS TR=6NS CJE=2PF + CJC=1PF VAF=100) .MODEL QPL PNP(BF=40 RB=20 TF=.6NS TR=10NS CJE=1.5PF CJC=1PF VAF=50) .ENDS .SUBCKT xxxxLM317 1 3 2 * IN ADJ OUT IADJ 1 4 50U VREF 4 3 1.25 RC 1 14 0.742 DBK 14 13 D1 CBC 13 15 2.479N RBC 15 5 247 QP 13 5 2 Q1 RB2 6 5 124 DSC 6 11 D1 ESC 11 2 POLY(2) (13,5) (6,5) 2.85 + 0 0 0 -70.1M DFB 6 12 D1 EFB 12 2 POLY(2) (13,5) (6,5) 3.92 + -135M 0 1.21M -70.1M RB1 7 6 1 EB 7 2 8 2 2.56 CPZ 10 2 0.796U DPU 10 2 D1 RZ 8 10 0.104 RP 9 8 100 EP 9 2 4 2 103.6 RI 2 4 100MEG .MODEL Q1 NPN (IS=30F BF=100 + VAF=14.27 NF=1.604) .MODEL D1 D (IS=30F N=1.604) .ENDS .SUBCKT LM337 8 1 19 *Connections Input Adj. Output *LM337 negative voltage regulator .MODEL QN NPN (BF=50 TF=1N CJC=1P) .MODEL QPOUT PNP (BF=50 TF=1N RE=.2 CJC=1P) .MODEL QP PNP CJC=1P TF=2N .MODEL DN D .MODEL D2 D BV=12 IBV=100U R10 25 6 1K Q3 8 17 16 QPOUT Q4 8 25 17 QP R18 19 17 250 R19 19 16 .3 G1 8 6 1 18 .1 C7 6 2 .04U R24 2 8 100 I_ADJ 0 1 65U R26 8 25 200K Q5 25 4 19 QP R27 16 4 200 R28 7 4 7K D1 8 7 D2 D2 8 6 DN V1 18 19 1.25 .ENDS "} xschem-2.8.1/xschem_library/examples/flop.sch0000644000175100017510000000160413023243556017505 0ustar svnsvnG {} V {} S {} N 170 -320 220 -320 {lab=#net1} N 400 -340 480 -340 {lab=#net2} C {devices/ipin} 240 -160 0 0 {name=p0 lab=D} C {devices/opin} 540 -160 0 0 {name=p2 lab=Q} C {devices/ipin} 240 -110 0 0 {name=p4 lab=VSS} C {devices/ipin} 240 -140 0 0 {name=p1 lab=CK} C {examples/inv} 130 -320 0 0 {name=E5 TABLE="'VTH-0.1' VHI 'VTH+0.1' 0"} C {devices/lab_pin} 130 -290 0 0 {name=p5 lab=VSS} C {devices/lab_pin} 220 -340 0 0 {name=p10 lab=D} C {examples/dlatch} 310 -330 0 0 {name=x5 VTH=VTH VHI=VHI} C {devices/lab_pin} 90 -320 0 0 {name=p11 lab=CK} C {devices/lab_pin} 480 -320 0 0 {name=p12 lab=CK} C {devices/lab_pin} 220 -300 0 0 {name=p13 lab=VSS} C {devices/lab_pin} 480 -300 0 0 {name=p14 lab=VSS} C {devices/lab_pin} 660 -340 0 1 {name=p15 lab=Q} C {examples/dlatch} 570 -330 0 0 {name=x1 VTH=VTH VHI=VHI} C {devices/title} 160 -30 0 0 {name=l1 author="Stefan Schippers"} xschem-2.8.1/xschem_library/examples/lm337.sym0000644000175100017510000000103513023243556017443 0ustar svnsvnG {type=primitive format="@name @pinlist @symname" template="name=x1" } V {} S {} L 4 -60 -20 60 -20 {} L 4 -60 20 60 20 {} L 4 -60 -20 -60 20 {} L 4 60 -20 60 20 {} L 4 -80 -10 -60 -10 {} L 4 60 -10 80 -10 {} L 4 0 -40 0 -20 {} B 5 -82.5 -12.5 -77.5 -7.5 {name=IN dir=in } B 5 -2.5 -42.5 2.5 -37.5 {name=ADJ dir=in } B 5 77.5 -12.5 82.5 -7.5 {name=OUT dir=out } T {@symname} -37.5 24 0 0 0.3 0.3 {} T {@name} 65 -32 0 0 0.2 0.2 {} T {IN} -55 -14 0 0 0.2 0.2 {} T {OUT} 55 -14 0 1 0.2 0.2 {} T {ADJ} -10 -19 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/lm317.sym0000644000175100017510000000103013023243556017434 0ustar svnsvnG {type=primitive format="@name @pinlist @symname" template="name=x1" } V {} S {} L 4 -60 -20 60 -20 {} L 4 -60 20 60 20 {} L 4 -60 -20 -60 20 {} L 4 60 -20 60 20 {} L 4 -80 -10 -60 -10 {} L 4 60 -10 80 -10 {} L 4 0 20 0 40 {} B 5 -82.5 -12.5 -77.5 -7.5 {name=IN dir=in } B 5 -2.5 37.5 2.5 42.5 {name=ADJ dir=in } B 5 77.5 -12.5 82.5 -7.5 {name=OUT dir=out } T {@symname} -37.5 -41 0 0 0.3 0.3 {} T {@name} 65 -32 0 0 0.2 0.2 {} T {IN} -55 -14 0 0 0.2 0.2 {} T {OUT} 55 -14 0 1 0.2 0.2 {} T {ADJ} -10 6 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/nand3.sym0000644000175100017510000000112313362731551017602 0ustar svnsvnG {type=nand3 verilog_format="nand #(@risedel , @falldel ) @name ( @@Z , @@A , @@B , @@C );" template="name=x1 risedel=100 falldel=200" } V {} S {} E {} L 4 -40 -20 -25 -20 {} L 4 -25 -30 -25 30 {} L 4 -25 -30 5 -30 {} L 4 -25 30 5 30 {} L 4 -40 0 -25 0 {} L 4 45 0 60 0 {} L 4 -40 20 -25 20 {} B 5 57.5 -2.5 62.5 2.5 {name=Z dir=out verilog_type=wire} B 5 -42.5 -22.5 -37.5 -17.5 {name=A dir=in} B 5 -42.5 -2.5 -37.5 2.5 {name=B dir=in} B 5 -42.5 17.5 -37.5 22.5 {name=C dir=in} A 4 40 0 5 180 360 {} A 4 5 0 30 270 180 {} T {@symname} -22.5 -15 0 0 0.2 0.2 {} T {@name} -22.5 0 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/and.sym0000644000175100017510000000077413362731551017354 0ustar svnsvnG {type=and verilog_format="and #(@risedel , @falldel ) @name ( @@Z , @@A , @@B );" template="name=x1 risedel=100 falldel=200" } V {} S {} E {} L 4 -40 -20 -25 -20 {} L 4 -40 20 -25 20 {} L 4 -25 -30 -25 30 {} L 4 -25 -30 5 -30 {} L 4 -25 30 5 30 {} L 4 35 0 60 0 {} B 5 57.5 -2.5 62.5 2.5 {name=Z dir=out verilog_type=wire} B 5 -42.5 -22.5 -37.5 -17.5 {name=A dir=in} B 5 -42.5 17.5 -37.5 22.5 {name=B dir=in} A 4 5 0 30 270 180 {} T {@symname} -22.5 -12.5 0 0 0.2 0.2 {} T {@name} -22.5 2.5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/loading.vhdl0000644000175100017510000003317613161011201020332 0ustar svnsvn library ieee, std; use std.textio.all; package rrreal is type rreal is record value : real; conduct : real; cap : real; end record; type rreal_vector is array (natural range <>) of rreal; function resolved_real( r: rreal_vector ) return rreal; procedure print(s : in string); subtype rrreal is resolved_real rreal; type rrreal_vector is array (natural range <>) of rrreal; CONSTANT RREAL_X : rreal := rreal'(value=> 0.0, cap=>0.0, conduct=>-1.0); CONSTANT RREAL_Z : rreal := rreal'(value=> 0.0, cap=>0.0, conduct=>0.0); CONSTANT RREAL_0 : rreal := rreal'(value=> 0.0, cap=>0.0, conduct=>10.0); CONSTANT REAL_Z : real := 20.0; CONSTANT REAL_X : real := 20.0; procedure transition( signal sig: INOUT rreal; constant endval: IN real; constant del: IN time ); procedure glitch( signal sig: INOUT rreal; constant lowval: IN real; constant endval: IN real; constant del: IN time ); end rrreal; -- end package declaration package body rrreal is procedure print(s : in string) is variable outbuf: line; begin write(outbuf, s); writeline(output, outbuf); end procedure; -- function resolved_real( r:rreal_vector) return rreal is -- VARIABLE result : rreal := RREAL_Z; -- begin -- IF (r'LENGTH = 1) THEN RETURN r(r'LOW); -- ELSE -- FOR i IN r'RANGE LOOP -- result.cap := result.cap + r(i).cap ; -- IF r(i).value /=REAL_Z THEN -- IF result.value /=REAL_Z THEN -- result.value := REAL_X ; -- ELSE -- result.value := r(i).value ; -- END IF; -- END IF ; -- END LOOP; -- END IF; -- RETURN result; -- end resolved_real; function resolved_real( r:rreal_vector) return rreal is VARIABLE result : rreal := RREAL_Z; variable vcapshare : real := 0.0; begin IF (r'LENGTH = 1) THEN RETURN r(r'LOW); ELSE FOR i IN r'RANGE LOOP if r(i).conduct = -1.0 then result := RREAL_X; exit; end if; -- only process initialized (valid) data if r(i).value > -30.0 and r(i).value < 30.0 then if r(i).cap > -1.0e12 and r(i).cap < 1.0e12 then if r(i).conduct > -1.0e12 and r(i).conduct < 1.0e12 then vcapshare := vcapshare + r(i).value * r(i).cap; result.value := result.value + r(i).value * r(i).conduct; result.cap := result.cap + r(i).cap ; if(r(i).conduct > 0.0 ) then -- result.conduct := result.conduct + 1.0/r(i).conduct ; result.conduct := result.conduct + r(i).conduct ; end if; end if; end if; end if; END LOOP; END IF; if result.conduct /= 0.0 then result.value := result.value / result.conduct ; -- conductance -- result.value := result.value * result.conduct ; -- resistance -- result.conduct := 1.0 / result.conduct; elsif result.cap >0.0 then result.value := vcapshare / result.cap; else result.value:=0.0; end if; RETURN result; end resolved_real; procedure transition( signal sig: INOUT rreal; constant endval: IN real; constant del: IN time) is variable step: real; variable startval: real; variable del2: time; begin del2 := del; if del2 = 0 fs then del2 := 1 ns; end if; startval := sig.value; step := (endval-startval); if abs(endval-startval) < 0.01 then --do not propagate events if endval very close to startval return; end if; -- sig.value <= endval after del; sig.value <= startval, startval+0.25*step after del2*0.1, startval+0.45*step after del2*0.2, startval+0.60*step after del2*0.3, startval+0.72*step after del2*0.4, startval+0.80*step after del2*0.5, startval+0.86*step after del2*0.6, startval+0.90*step after del2*0.7, startval+0.94*step after del2*0.8, startval+0.97*step after del2*0.9, endval after del2; end transition; procedure glitch( signal sig: INOUT rreal; constant lowval: IN real; constant endval: IN real; constant del: IN time) is variable step: real; variable step2: real; variable startval: real; variable del2 : time; begin del2 := del; if del2 = 0 fs then del2 := 1 ns; end if; startval := sig.value; step := (lowval-startval); step2 := (lowval-endval); if abs(lowval-startval) < 0.01 then --do not propagate events if endval very close to startval return; end if; sig.value <= -- startval, -- startval+0.25*step after del*0.05, -- startval+0.45*step after del*0.1, -- startval+0.60*step after del*0.15, -- startval+0.72*step after del*0.2, -- startval+0.80*step after del*0.25, -- startval+0.86*step after del*0.3, -- startval+0.90*step after del*0.35, -- startval+0.94*step after del*0.4, -- startval+0.97*step after del*0.45, -- lowval after del*0.5, -- lowval-0.25*step2 after del*0.55, -- lowval-0.45*step2 after del*0.6, -- lowval-0.60*step2 after del*0.65, -- lowval-0.72*step2 after del*0.7, -- lowval-0.80*step2 after del*0.75, -- lowval-0.86*step2 after del*0.8, -- lowval-0.90*step2 after del*0.85, -- lowval-0.94*step2 after del*0.9, -- lowval-0.97*step2 after del*0.95, -- endval after del; lowval, lowval-0.25*step2 after del2*0.1, lowval-0.45*step2 after del2*0.2, lowval-0.60*step2 after del2*0.3, lowval-0.72*step2 after del2*0.4, lowval-0.80*step2 after del2*0.5, lowval-0.86*step2 after del2*0.6, lowval-0.90*step2 after del2*0.7, lowval-0.94*step2 after del2*0.8, lowval-0.97*step2 after del2*0.9, endval after del2; end glitch; end rrreal; -- end package body library ieee; use std.TEXTIO.all; use ieee.std_logic_1164.all; library work; use work.rrreal.all; entity loading is end loading ; architecture arch_loading of loading is component pump generic ( val : real := 4.5 ; conduct : real := 10.0 ); port ( USC : inout rreal ; ING : in std_logic ); end component ; component switch_rreal generic ( del : time := 2 ns ); port ( ENAB : in std_logic ; B : inout rreal ; A : inout rreal ); end component ; component real_capa generic ( cap : real := 10.0 ); port ( USC : inout rreal ); end component ; signal SW : std_logic ; signal VXS : rrreal ; signal SW1 : std_logic ; signal VX : rrreal ; signal SW2 : std_logic ; signal ING1 : std_logic ; signal ING : std_logic ; signal SP : rrreal ; signal VX2 : rrreal ; begin x4 : pump generic map ( conduct => 1.0/20000.0 , val => 4.5 ) port map ( USC => VX , ING => ING ); x5 : switch_rreal generic map ( del => 2 ns ) port map ( ENAB => SW , B => VXS , A => VX ); x3 : real_capa generic map ( cap => 30.0 ) port map ( USC => VX ); x1 : real_capa generic map ( cap => 100.0 ) port map ( USC => VXS ); x2 : switch_rreal generic map ( del => 2 ns ) port map ( ENAB => SW1 , B => SP , A => VXS ); x6 : real_capa generic map ( cap => 20.0 ) port map ( USC => SP ); x7 : pump generic map ( conduct => 1.0/40000.0 , val => 3.0 ) port map ( USC => VX2 , ING => ING1 ); x8 : switch_rreal generic map ( del => 2 ns ) port map ( ENAB => SW2 , B => VXS , A => VX2 ); x9 : real_capa generic map ( cap => 40.0 ) port map ( USC => VX2 ); process begin ING<='0'; ING1<='0'; SW <= '0'; SW1<='0'; SW2<='0'; --VX <= rreal'(4.5,10.0,0.0); --VX2 <= rreal'(3.0, 5.0, 0.0); wait for 200 ns; ING1<='1'; wait for 200 ns; ING<='1'; wait for 200 ns; SW<='1'; wait for 200 ns; SW2<='1'; wait for 200 ns; SW1<='1'; wait for 200 ns; SW1<='0'; wait for 200 ns; SW2<='0'; wait for 200 ns; SW1<='1'; wait for 200 ns; SW<='1'; wait for 200 ns; ING <='0'; wait for 200 ns; SW1<= '0'; wait for 200 ns; SW<='1'; wait for 200 ns; ING<='1'; wait for 200 ns; SW <= '0'; wait for 200 ns; SW1<= '1'; wait for 200 ns; ING<='1'; wait for 200 ns; SW<='0'; wait for 200 ns; SW1<='0'; wait for 200 ns; SW<='1'; wait for 200 ns; SW1<='1'; wait for 200 ns; SW1<='0'; wait for 200 ns; SW1<='1'; wait for 200 ns; wait; end process; end arch_loading ; -- expanding symbol: templates/pump # of pins=2 library ieee; use std.TEXTIO.all; use ieee.std_logic_1164.all; use work.rrreal.all; library work; use work.rrreal.all; entity pump is generic ( val : real := 4.5 ; conduct : real := 10.0 ); port ( USC : inout rreal ; ING : in std_logic ); end pump ; architecture arch_pump of pump is begin process variable del: time := 0.4 ns; variable delay: time; variable last : time; variable lowvalue: real; begin wait on ING , USC.cap; last := now; delay := del * USC.cap; print("start pump process: " & pump'PATH_NAME & " " & time'image(now) ); if(now=0 ns) then USC <= RREAL_0; elsif ING'event and ING='1' then USC.conduct<=conduct; transition(USC,val,delay); elsif ING'event and ING='0' then USC.conduct<=conduct; transition(USC,0.0,delay); elsif USC.cap'event and USC.cap > USC.cap'last_value and ING='1' then lowvalue := USC.value * USC.cap'last_value / USC.cap; glitch(USC, lowvalue, val, delay); end if; end process; end arch_pump ; -- expanding symbol: templates/switch_rreal # of pins=3 library ieee,work; use ieee.std_logic_1164.all; use work.rrreal.all; use std.textio.all; entity switch_rreal is generic ( del : time := 2 ns ); port ( ENAB : in std_logic ; B : inout rreal ; A : inout rreal ); end switch_rreal ; architecture arch_switch_rreal of switch_rreal is signal SCHEDULE : integer ; procedure print2( signal x : in rreal) is begin print(" " & x'SIMPLE_NAME & ".value=" & real'image(x.value)& " t= " & time'image(now) ); print(" " & x'SIMPLE_NAME & ".cap=" & real'image(x.cap) & " t= " & time'image(now)); print(" " & x'SIMPLE_NAME & ".conduct=" & real'image(x.conduct) & " t= " & time'image(now)); end print2; begin process variable last : time; variable aa,bb : rreal; begin wait until ( SCHEDULE'transaction'event or A'event or B'event or ENAB'event ) and now>last; last := now; print(switch_rreal'PATH_NAME & " start switch process: " & time'image(now) ); if now= 0 ns then aa:=rreal'(0.0,0.0,0.0); bb:=rreal'(0.0,0.0,0.0); A <= aa ; B <= bb ; elsif ENAB'event and ENAB='1' then SCHEDULE <= 4 after del; elsif ENAB'event and ENAB='0' then SCHEDULE <= 3 after del; elsif B'event and ENAB='1' then SCHEDULE <= 2 after del; elsif A'event and ENAB='1' then SCHEDULE <= 1 after del; elsif SCHEDULE'transaction'event and SCHEDULE=3 then -- ENAB=0 event print(switch_rreal'PATH_NAME & " release outputs: " & time'image(now) ); aa:=rreal'(0.0,0.0,0.0); bb:=rreal'(0.0,0.0,0.0); A <= aa ; B <= bb ; elsif SCHEDULE'transaction'event and SCHEDULE=4 then -- ENAB=1 event aa := B; bb := A; A <= aa ; print(switch_rreal'PATH_NAME & " enab forcing A, done: " & time'image(now) ); print2(A); B <= bb ; print(switch_rreal'PATH_NAME & " enab forcing B, done: " & time'image(now) ); print2(B); elsif SCHEDULE'transaction'event and SCHEDULE=2 then -- B event print(switch_rreal'PATH_NAME & " B'event: " & time'image(now) ); aa.conduct := B.conduct - bb.conduct; aa.cap := B.cap - bb.cap; if aa.conduct /= 0.0 then aa.value := ( B.value * B.conduct - bb.value * bb.conduct) / aa.conduct; else aa.value := B.value; end if; A <= aa ; elsif SCHEDULE'transaction'event and SCHEDULE=1 then -- A event print(switch_rreal'PATH_NAME & " A'event: " & time'image(now) ); bb.conduct := A.conduct - aa.conduct; bb.cap := A.cap - aa.cap; if bb.conduct /= 0.0 then bb.value := ( A.value * A.conduct - aa.value * aa.conduct) / bb.conduct; else bb.value := A.value; end if; B <= bb ; end if; -- now = 0 end process; end arch_switch_rreal ; -- expanding symbol: templates/real_capa # of pins=1 library ieee; use std.TEXTIO.all; use ieee.std_logic_1164.all; use work.rrreal.all; library work; use work.rrreal.all; entity real_capa is generic ( cap : real := 10.0 ); port ( USC : inout rreal ); end real_capa ; architecture arch_real_capa of real_capa is begin process variable buf: LINE; variable last : time; variable val : real; begin if now = 0 ns then last := now; USC.cap <=cap; USC.conduct <=0.0; USC.value <= 0.0; end if; wait on USC until last /=now; last := now; WRITE(buf,string'("start real_capa process")); WRITELINE(output,buf); USC.conduct <= 0.0; USC.cap <= cap ; val := USC'LAST_VALUE.value; if now = 0 ns then USC.value <= 0.0; else USC.value <= val; end if; end process; end arch_real_capa ; xschem-2.8.1/xschem_library/examples/ne555.sym0000644000175100017510000000665213023243556017451 0ustar svnsvnG {type=primitive format="@name @pinlist @symname" template="name=x1" } V {} S {} L 4 -60 -130 -60 130 {} L 4 60 -130 60 130 {} L 4 -60 130 60 130 {} L 4 -80 40 -60 40 {} L 4 -80 -120 -60 -120 {} L 4 60 -120 80 -120 {} L 4 60 -40 80 -40 {} L 4 -80 120 -60 120 {} L 4 60 120 80 120 {} L 4 60 40 80 40 {} L 4 -80 -40 -60 -40 {} L 4 -60 -130 -20 -130 {} L 4 -20 -130 -10 -120 {} L 4 -10 -120 0 -120 {} L 4 0 -120 10 -120 {} L 4 10 -120 20 -130 {} L 4 20 -130 60 -130 {} L 4 -30 -10 -20 10 {} L 4 -30 -10 -10 -10 {} L 4 10 -10 20 10 {} L 4 10 -10 30 -10 {} L 4 20 10 30 -10 {} L 4 -20 70 -20 80 {} L 4 -45 80 -20 80 {} L 4 -45 70 -45 80 {} L 4 -55 70 -45 70 {} L 4 -55 70 -45 60 {} L 4 -45 60 -35 70 {} L 4 -45 70 -35 70 {} L 4 -45 50 -45 60 {} L 4 20 10 20 40 {} L 4 -20 10 -20 40 {} L 4 -50 -80 -40 -80 {} L 4 -40 -90 -40 -80 {} L 4 -40 -90 -30 -70 {} L 4 -30 -90 -30 -70 {} L 4 -30 -90 -20 -70 {} L 4 -20 -80 -20 -70 {} L 4 -20 -80 -10 -80 {} L 4 -10 -90 -10 -80 {} L 4 -10 -90 -0 -70 {} L 4 -0 -90 -0 -70 {} L 4 -0 -90 10 -70 {} L 4 10 -80 10 -70 {} L 4 10 -80 20 -80 {} L 4 20 -90 20 -80 {} L 4 20 -90 30 -70 {} L 4 30 -90 30 -70 {} L 4 30 -90 40 -70 {} L 4 40 -80 40 -70 {} L 4 40 -80 50 -80 {} L 4 50 -110 50 -80 {} L 4 -50 -110 -50 -80 {} L 4 -15 -80 -15 -10 {} L 4 15 -80 15 -10 {} L 4 25 -20 25 -10 {} L 4 25 -20 40 -20 {} L 4 40 -20 40 22.5 {} L 4 -25 -40 -25 -10 {} L 4 -30 -40 -25 -40 {} L 4 40 40 60 40 {} L 4 -45 40 -45 50 {} L 4 -60 40 -45 40 {} L 4 20 75 20 120 {} L 4 18.75 75 21.25 75 {} L 4 16.25 72.5 18.75 75 {} L 4 16.25 72.5 18.75 70 {} L 4 18.75 70 21.25 70 {} L 4 21.25 70 23.75 72.5 {} L 4 21.25 75 23.75 72.5 {} L 4 -60 120 20 120 {} L 4 50 120 60 120 {} L 4 50 45 50 120 {} L 4 50 -30 50 22.5 {} L 4 15 -30 50 -30 {} L 4 40 37.5 40 40 {} L 4 -60 -40 -57.5 -40 {} L 4 7.5 -40 35 -40 {} L 4 2.5 -32.5 7.5 -40 {} L 4 -5 -40 -0 -32.5 {} L 4 -5 -40 -2.5 -38.75 {} L 4 -5 -40 -5 -37.5 {} L 4 -7.5 -40 -5 -40 {} L 4 -7.5 -45 -7.5 -35 {} L 4 -10 -42.5 -10 -37.5 {} L 4 -12.5 -41.25 -12.5 -38.75 {} L 4 -20 80 1.25 80 {} L 4 -20 10 -10 -10 {} L 4 -5 -32.5 7.5 -32.5 {} L 4 -6.25 5 1.25 -7.5 {} L 4 1.25 -7.5 8.75 5 {} L 4 -6.25 5 8.75 5 {} L 4 1.25 -7.5 2.5 -7.5 {} L 4 2.5 -7.5 3.75 -8.75 {} L 4 3.75 -10 3.75 -8.75 {} L 4 2.5 -11.25 3.75 -10 {} L 4 1.25 -11.25 2.5 -11.25 {} L 4 -0 -11.25 1.25 -11.25 {} L 4 -1.25 -10 -0 -11.25 {} L 4 -1.25 -10 -1.25 -8.75 {} L 4 -1.25 -8.75 0 -7.5 {} L 4 0 -7.5 1.25 -7.5 {} L 4 1.25 -32.5 1.25 -11.25 {} L 4 1.25 5 1.25 80 {} L 15 -30 40 30 40 {} L 15 30 40 30 70 {} L 15 -30 70 30 70 {} L 15 -30 40 -30 70 {} B 5 -82.5 -122.5 -77.5 -117.5 {name=GND dir=in } B 5 -82.5 -42.5 -77.5 -37.5 {name=TRIG dir=in } B 5 -82.5 37.5 -77.5 42.5 {name=OUT dir=out } B 5 -82.5 117.5 -77.5 122.5 {name=RESETB dir=in } B 5 77.5 117.5 82.5 122.5 {name=CTRL dir=in } B 5 77.5 37.5 82.5 42.5 {name=THRES dir=in } B 5 77.5 -42.5 82.5 -37.5 {name=DIS dir=out } B 5 77.5 -122.5 82.5 -117.5 {name=VCC dir=in } T {@symname} -27.5 -111 0 0 0.3 0.3 {} T {@name} 25 -152 0 0 0.2 0.2 {} T {OUT} -35 26 0 1 0.2 0.2 {} T {GND} -55 -124 0 0 0.2 0.2 {} T {VCC} 35 -124 0 0 0.2 0.2 {} T {DIS} 55 -44 0 1 0.2 0.2 {} T {RESETB} -55 106 0 0 0.2 0.2 {} T {CTRL} 23.75 106 0 0 0.2 0.2 {} T {THRES} 25 26 0 0 0.2 0.2 {} T {TRIG} -55 -44 0 0 0.2 0.2 {} T {Q} -22.5 56.25 0 0 0.2 0.2 {} T {S} -22.5 41.25 0 0 0.2 0.2 {} T {R} 17.5 41.25 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/mos_power_ampli.sch0000644000175100017510000005431513375646205021760 0ustar svnsvnG {} V {} S { .probe v(ga,sa) v(gb,sb) .probe p(q*) p(r*) i(r*) p(xm1) p(xm2) i(d*)} E {} P 4 7 1180 -140 1140 -140 1140 -150 1120 -140 1140 -130 1140 -140 1180 -140 {fill=true} T {CURRENT MEASURE} 1040 -660 0 0 0.2 0.2 {} T {CURRENT MEASURE} 1040 -560 0 0 0.2 0.2 {} T {ANALOG AUDIO AMPLIFIER N-Channel only power stage} 430 -275 0 0 0.5 0.5 {layer=8 font="Liberation Sans"} T {IRF540 spice models are not free so can not be distributed with XSCHEM. However you can download a suitable model by clicking the following link and placing the relevant lines in the MODELS component} 1190 -300 0 0 0.5 0.5 {} N 1110 -1180 1110 -790 {lab=VPP} N 180 -500 180 -470 {lab=E9} N 260 -470 340 -470 {lab=E9} N 340 -500 340 -470 {lab=E9} N 1110 -700 1110 -670 {lab=SA} N 840 -1020 840 -980 {lab=E4} N 1110 -590 1110 -570 {lab=OUT} N 1110 -510 1110 -470 {lab=#net1} N 570 -950 800 -950 {lab=C7} N 350 -950 550 -950 {lab=C7} N 330 -950 335 -955 {lab=C7} N 335 -955 345 -955 {lab=C7} N 345 -955 350 -950 {lab=C7} N 550 -950 555 -955 {lab=C7} N 555 -955 565 -955 {lab=C7} N 565 -955 570 -950 {lab=C7} N 560 -1020 560 -820 {lab=E6} N 180 -1020 180 -980 {lab=E1} N 230 -950 330 -950 {lab=C7} N 340 -1020 340 -820 {lab=E2} N 390 -790 520 -790 {lab=C2} N 230 -950 230 -900 {lab=C7} N 180 -900 230 -900 {lab=C7} N 390 -790 390 -740 {lab=C2} N 340 -740 390 -740 {lab=C2} N 180 -920 180 -900 {lab=C7} N 220 -950 230 -950 {lab=C7} N 340 -760 340 -740 {lab=C2} N 380 -790 390 -790 {lab=C2} N 180 -1120 180 -1080 {lab=VBOOST} N 840 -1120 840 -1080 {lab=VBOOST} N 350 -1120 550 -1120 {lab=VBOOST} N 330 -1120 335 -1125 {lab=VBOOST} N 335 -1125 345 -1125 {lab=VBOOST} N 345 -1125 350 -1120 {lab=VBOOST} N 550 -1120 555 -1125 {lab=VBOOST} N 555 -1125 565 -1125 {lab=VBOOST} N 565 -1125 570 -1120 {lab=VBOOST} N 180 -1120 330 -1120 {lab=VBOOST} N 340 -1180 340 -1080 {lab=VPP} N 560 -1180 560 -1080 {lab=VPP} N 690 -1120 840 -1120 {lab=VBOOST} N 340 -1180 560 -1180 {lab=VPP} N 60 -1180 340 -1180 {lab=VPP} N 1100 -1120 1105 -1125 {lab=VBOOST} N 1105 -1125 1115 -1125 {lab=VBOOST} N 1115 -1125 1120 -1120 {lab=VBOOST} N 840 -1120 1100 -1120 {lab=VBOOST} N 560 -1180 1110 -1180 {lab=VPP} N 940 -440 1070 -440 {lab=GB} N 560 -440 880 -440 {lab=C8} N 560 -460 560 -440 {lab=C8} N 1200 -1120 1360 -1120 {lab=VBOOST} N 1200 -900 1200 -870 {lab=#net2} N 1200 -810 1200 -590 {lab=OUT} N 1110 -1180 1360 -1180 {lab=VPP} N 560 -540 560 -520 {lab=E8} N 560 -760 560 -600 {lab=C6} N 690 -730 690 -600 {lab=OUT} N 840 -780 840 -760 {lab=GA} N 690 -810 690 -790 {lab=B1} N 690 -810 800 -810 {lab=B1} N 690 -1120 690 -880 {lab=VBOOST} N 570 -1120 690 -1120 {lab=VBOOST} N 690 -820 690 -810 {lab=B1} N 260 -470 260 -460 {lab=E9} N 180 -100 260 -100 {lab=VNN} N 260 -340 260 -270 {lab=C3} N 50 -240 220 -240 {lab=B3} N 260 -210 260 -160 {lab=E3} N 180 -180 180 -100 {lab=VNN} N 50 -180 50 -100 {lab=VNN} N 50 -100 180 -100 {lab=VNN} N 690 -600 1110 -600 {lab=OUT} N 180 -470 260 -470 {lab=E9} N 1110 -610 1110 -600 {lab=OUT} N 1030 -380 1110 -380 {lab=SB} N 1030 -700 1110 -700 {lab=SA} N 1200 -1120 1200 -960 {lab=VBOOST} N 1110 -410 1110 -380 {lab=SB} N 1110 -730 1110 -700 {lab=SA} N 1120 -1120 1200 -1120 {lab=VBOOST} N 840 -760 1070 -760 {lab=GA} N 840 -920 840 -840 {lab=E11} N 340 -740 340 -690 {lab=C2} N 340 -630 340 -560 {lab=C9} N 220 -630 340 -630 {lab=C9} N 180 -900 180 -660 {lab=C7} N 180 -600 180 -560 {lab=C5} N 1110 -320 1110 -280 {lab=VNN} N 1200 -590 1460 -590 {lab=OUT} N 1110 -590 1200 -590 {lab=OUT} N 1110 -600 1110 -590 {lab=OUT} C {devices/ipin} 530 -170 0 0 {name=p0 lab=PLUS} C {devices/ipin} 530 -150 0 0 {name=p1 lab=MINUS} C {devices/ipin} 530 -130 0 0 {name=p2 lab=VPP} C {devices/ipin} 530 -110 0 0 {name=p3 lab=VNN} C {devices/ipin} 530 -90 0 0 {name=p4 lab=VSS} C {devices/opin} 600 -130 0 0 {name=p5 lab=OUT} C {devices/nmos3} 1090 -440 0 0 {name=xm2 model=irf540 m=1 url="http://www.ece.usu.edu/ece_store/spec/IRF540.pdf"} C {devices/res} 1030 -410 0 1 {name=r7 m=1 value=195} C {devices/nmos3} 1090 -760 0 0 {name=xm1 model=irf540 m=1 url="http://www.ece.usu.edu/ece_store/spec/IRF540.pdf"} C {devices/res} 1030 -730 0 1 {name=r8 m=1 value=195} C {devices/lab_pin} 1460 -590 0 1 {name=p14 lab=OUT} C {devices/lab_pin} 1110 -280 0 0 {name=p18 lab=VNN} C {devices/lab_wire} 990 -440 0 0 {name=l8 lab=GB} C {devices/res} 340 -1050 0 1 {name=r2 m=1 value=50} C {devices/res} 180 -1050 0 1 {name=r3 m=1 value=50} C {devices/lab_pin} 340 -1080 0 0 {name=p10 lab=VPP} C {devices/npn} 160 -530 0 0 {name=Q5 model=q2n2222 area=1} C {devices/pnp} 820 -950 0 0 {name=Q4 model=q2n2907p area=1} C {devices/res} 840 -1050 0 1 {name=r9 m=1 value=50} C {devices/pnp} 540 -790 0 0 {name=Q6 model=q2n2907p area=1} C {devices/res} 560 -1050 0 1 {name=r4 m=1 value=50} C {devices/lab_pin} 180 -580 0 0 {name=p15 lab=C5} C {devices/lab_pin} 340 -580 0 1 {name=p16 lab=C9} C {devices/lab_pin} 180 -1000 0 0 {name=p17 lab=E1} C {devices/lab_pin} 560 -1080 0 0 {name=p25 lab=VPP} C {devices/lab_pin} 340 -970 0 1 {name=p23 lab=E2} C {devices/lab_pin} 560 -970 0 1 {name=p28 lab=E6} C {devices/lab_pin} 840 -1000 0 1 {name=p29 lab=E4} C {devices/lab_pin} 180 -1120 0 0 {name=p34 lab=VBOOST} C {devices/ammeter} 1110 -540 0 0 {name=vd} C {devices/ammeter} 1110 -640 0 0 {name=vu} C {devices/lab_pin} 60 -1180 0 0 {name=p27 lab=VPP} C {devices/pnp} 200 -950 0 1 {name=Q1 model=q2n2907p area=1} C {devices/pnp} 360 -790 0 1 {name=Q2 model=q2n2907p area=1} C {devices/lab_pin} 140 -530 0 0 {name=p6 lab=PLUS} C {devices/lab_pin} 380 -530 0 1 {name=p24 lab=MINUS} C {devices/npn} 360 -530 0 1 {name=Q9 model=q2n2222 area=1} C {devices/lab_pin} 560 -630 0 0 {name=p9 lab=C6} C {devices/code} 780 -180 0 0 {name=STIMULI only_toplevel=true value=".option PARHIER=LOCAL RUNLVL=6 post MODMONTE=1 warn maxwarn=6000 .option sampling_method = SRS .option method=gear .temp 30 vvss vss 0 dc 0 vvpp vpp 0 dc 50 vvnn vnn 0 dc -50 rfb1 vpp minus 100k rfb2 out minus 100k rfb3 minus vdc '100k/43' vvdc vdc 0 dc 21.3 eref vref 0 plus vdc 45 vplus plus vdc dc 0 evboost vboost 0 vol='v(out)>=40 ? v(out)+10 : 50' rload out 0 4 .dc vplus '-1.5' '1.5' 0.001 .probe dc v(plus,vdc)"} C {devices/lab_wire} 990 -760 0 0 {name=l1 lab=GA} C {devices/res} 910 -440 1 1 {name=r11 m=1 value=1300} C {devices/pnp} 540 -490 0 0 {name=Q8 model=q2n2907p area=1} C {devices/capa} 1200 -930 0 0 {name=c12 m=1 value=40u} C {devices/diode} 1200 -1150 0 0 {name=D0 model=d1n4148 area=1 url="http://pdf.datasheetcatalog.com/datasheet/bytes/1N5406.pdf"} C {devices/res} 1200 -840 0 1 {name=r18 m=1 value=200} C {devices/zener} 1360 -1150 0 0 {name=D1 model=d1n758 area=1 url="http://www.futurlec.com/Datasheet/Diodes/1N746-1N759.pdf"} C {devices/res} 690 -760 0 1 {name=r14 m=1 value=4k} C {devices/pnp} 820 -810 0 0 {name=Q11 model=q2n2907p area=1} C {devices/res} 690 -850 0 1 {name=r15 m=1 value=4k r=12k R=12k val=12k} C {devices/res} 260 -430 0 1 {name=r5 m=1 value=600} C {devices/res} 260 -370 0 1 {name=r6 m=1 value=700} C {devices/zener} 180 -210 2 0 {name=D2 model=d1n755 area=1 url="http://www.futurlec.com/Datasheet/Diodes/1N746-1N759.pdf" } C {devices/npn} 240 -240 0 0 {name=Q3 model=q2n2222 area=1} C {devices/res} 180 -270 0 1 {name=r1 m=1 value=10k} C {devices/lab_pin} 180 -300 0 0 {name=p7 lab=VSS} C {devices/res} 260 -130 0 1 {name=r10 m=1 value=170} C {devices/lab_pin} 50 -100 0 0 {name=p11 lab=VNN} C {devices/capa} 50 -210 0 0 {name=c3 m=1 value=100n} C {devices/res} 560 -570 0 1 {name=r12 m=1 value=1300} C {devices/lab_pin} 690 -800 0 0 {name=p12 lab=B1} C {devices/code} 1000 -180 0 0 {name=MODELS only_toplevel=true value=".MODEL bd139_2 npn +IS=1e-09 BF=222.664 NF=0.85 VAF=36.4079 +IKF=0.166126 ISE=5.03418e-09 NE=1.45313 BR=1.35467 +NR=1.33751 VAR=142.931 IKR=1.66126 ISC=5.02557e-09 +NC=3.10227 RB=26.9143 IRB=0.1 RBM=0.1 +RE=0.000472454 RC=1.04109 XTB=0.727762 XTI=1.04311 +EG=1.05 CJE=1e-11 VJE=0.75 MJE=0.33 +TF=1e-09 XTF=1 VTF=10 ITF=0.01 +CJC=1e-11 VJC=0.75 MJC=0.33 XCJC=0.9 +FC=0.5 CJS=0 VJS=0.75 MJS=0.5 +TR=1e-07 PTF=0 KF=0 AF=1 .MODEL BD139 NPN ( +IS=2.3985E-13 Vceo=80 Icrating=1500m +BF=244.9 NF=1.0 BR=78.11 NR=1.007 ISE=1.0471E-14 +NE=1.2 ISC=1.9314E-11 NC=1.45 VAF=98.5 VAR=7.46 +IKF=1.1863 IKR=0.1445 RB=2.14 RBM=0.001 IRB=0.031 +RE=0.0832 RC=0.01 CJE=2.92702E-10 VJE=0.67412 +MJE=0.3300 FC=0.5 CJC=4.8831E-11 VJC=0.5258 +MJC=0.3928 XCJC=0.5287 XTB=1.1398 EG=1.2105 XTI=3.0) .MODEL BD140 PNP(IS=1e-09 BF=650.842 NF=0.85 VAF=10 +IKF=0.0950125 ISE=1e-08 NE=1.54571 BR=56.177 +NR=1.5 VAR=2.11267 IKR=0.950125 ISC=1e-08 +NC=3.58527 RB=41.7566 IRB=0.1 RBM=0.108893 +RE=0.000347052 RC=1.32566 XTB=19.5239 XTI=1 +EG=1.05 CJE=1e-11 VJE=0.75 MJE=0.33 +TF=1e-09 XTF=1 VTF=10 ITF=0.01 +CJC=1e-11 VJC=0.75 MJC=0.33 XCJC=0.9 +FC=0.5 CJS=0 VJS=0.75 MJS=0.5 TR=1e-07 PTF=0 KF=0 AF=10 + VCEO=80 ICRATING=1A ) .MODEL Q2N2222A NPN IS =3.0611E-14 NF =1.00124 BF =220 IKF=0.52 + VAF=104 ISE=7.5E-15 NE =1.41 NR =1.005 BR =4 IKR=0.24 + VAR=28 ISC=1.06525E-11 NC =1.3728 RB =0.13 RE =0.22 + RC =0.12 CJC=9.12E-12 MJC=0.3508 VJC=0.4089 + CJE=27.01E-12 TF =0.325E-9 TR =100E-9 + vce_max=45 vbe_max=6 .MODEL Q2N2222 NPN ( + IS = 3.97589E-14 BF = 195.3412 NF = 1.0040078 VAF = 53.081 IKF = 0.976 ISE = 1.60241E-14 + NE = 1.4791931 BR = 1.1107942 NR = 0.9928261 VAR = 11.3571702 IKR = 2.4993953 ISC = 1.88505E-12 + NC = 1.1838278 RB = 56.5826472 IRB = 1.50459E-4 RBM = 5.2592283 RE = 0.0402974 RC = 0.4208 + CJE = 2.56E-11 VJE = 0.682256 MJE = 0.3358856 TF = 3.3E-10 XTF = 6 VTF = 0.574 + ITF = 0.32 PTF = 25.832 CJC = 1.40625E-11 VJC = 0.5417393 MJC = 0.4547893 XCJC = 1 + TR = 3.2E-7 CJS = 0 VJS = .75 MJS = 0 XTB = 1.6486 EG = 1.11 + XTI = 5.8315 KF = 0 AF = 1 FC = 0.83 + vce_max=45 vbe_max=6 ) * 2n2222 p complementary .MODEL Q2N2907P PNP(IS=650.6E-18 ISE=54.81E-15 ISC=0 XTI=3 + BF=231.7 BR=3.563 IKF=1.079 IKR=0 XTB=1.5 + VAF=115.7 VAR=35 VJE=0.65 VJC=0.65 + RE=0.15 RC=0.715 RB=10 + CJE=19.82E-12 CJC=14.76E-12 XCJC=0.75 FC=0.5 + NF=1 NR=1 NE=1.829 NC=2 MJE=0.3357 MJC=0.5383 + TF=603.7E-12 TR=111.3E-9 ITF=0.65 VTF=5 XTF=1.7 + EG=1.11 KF=1E-9 AF=1 + VCEO=45 ICRATING=100M + vce_max=45 vbe_max=6 ) .MODEL Q2N2907S PNP(IS=2.32E-13 ISE=6.69E-16 ISC=1.65E-13 XTI=3.00 + BF=3.08E2 BR=2.18E1 IKF=8.42E-1 IKR=1.00 XTB=1.5 + VAF=1.41E2 VAR=1.35E1 VJE=3.49E-1 VJC=3.00E-1 + RE=1.00E-2 RC=8.46E-1 RB=4.02E1 RBM=1.00E-2 IRB=1.25E-2 + CJE=2.66E-11 CJC=1.93E-11 XCJC=1.00 FC=5.00E-1 + NF=1.04 NR=1.12 NE=1.09 NC=1.13 MJE=4.60E-1 MJC=4.65E-1 + TF=4.95E-10 TR=0 PTF=0 ITF=3.36E-1 VTF=6.54 XTF=1.87E1 + EG=1.11 KF=1E-9 AF=1 + VCEO=40 ICRATING=500M + vce_max=45 vbe_max=6 ) *MM3725 MCE 5/13/95 *Si 1W 40V 500mA 307MHz pkg:TO-39 3,2,1 .MODEL QMM3725 NPN (IS=50.7F NF=1 BF=162 VAF=113 IKF=.45 ISE=38.2P NE=2 + BR=4 NR=1 VAR=24 IKR=.675 RE=.263 RB=1.05 RC=.105 XTB=1.5 + CJE=62.2P VJE=1.1 MJE=.5 CJC=14.6P VJC=.3 MJC=.3 TF=518P TR=45.9N) *MPS651 MCE 5/12/95 *Si 625mW 60V 2A 110MHz pkg:TO-92 1,2,3 .MODEL QMPS651 NPN (IS=72.1F NF=1 BF=260 VAF=139 IKF=2.5 ISE=67.1P NE=2 + BR=4 NR=1 VAR=20 IKR=3.75 RE=28.2M RB=.113 RC=11.3M XTB=1.5 + CJE=212P VJE=1.1 MJE=.5 CJC=68.6P VJC=.3 MJC=.3 TF=1.44N TR=1U) *FCX649 ZETEX Spice model Last revision 17/7/90 Medium Power *ZTX Si 1.5W 25V 2A 240MHz pkg:SOT-89 2,1,3 .MODEL QFCX649 NPN(IS=3E-13 BF=225 VAF=80 IKF=2.8 ISE=1.1E-13 NE=1.37 + BR=110 NR=0.972 VAR=28 IKR=0.8 ISC=6.5E-13 NC=1.372 RB=0.3 RE=0.063 + RC=0.07 CJE=3.25E-10 TF=1E-9 CJC=7E-11 TR=1E-8 ) *MPSW01A MCE 5/12/95 *Si 1W 40V 1A 210MHz pkg:TO-92 1,2,3 .MODEL QMPSW01A NPN (IS=18.1F NF=1 BF=273 VAF=113 IKF=.6 ISE=15.7P NE=2 + BR=4 NR=1 VAR=20 IKR=.9 RE=96.5M RB=.386 RC=38.6M XTB=1.5 + CJE=78.7P VJE=1.1 MJE=.5 CJC=17.3P VJC=.3 MJC=.3 TF=757P TR=526N) *BC546 ZETEX Spice model Last revision 4/90 General Purpose *ZTX Si 500mW 65V 200mA 300MHz pkg:TO-92 1,2,3 .MODEL BC546 NPN(IS=1.8E-14 BF=400 NF=0.9955 VAF=80 IKF=0.14 ISE=5E-14 + NE=1.46 BR=35.5 NR=1.005 VAR=12.5 IKR=0.03 ISC=1.72E-13 NC=1.27 RB=0.56 + RE=0.6 RC=0.25 CJE=1.3E-11 TF=6.4E-10 CJC=4E-12 VJC=0.54 TR=5.072E-8 + vce_max=65 vbe_max=6 ) .MODEL BC556 PNP( + IS=2.059E-14 + NF=1.003 + ISE=2.971E-15 + NE=1.316 + BF=227.3 + IKF=0.08719 + VAF=37.2 + NR=1.007 + ISC=1.339E-14 + NC=1.15 + BR=7.69 + IKR=0.07646 + VAR=11.42 + RB=1 + IRB=1E-06 + RBM=1 + RE=0.688 + RC=0.6437 + XTB=0 + EG=1.11 + XTI=3 + CJE=1.4E-11 + VJE=0.5912 + MJE=0.3572 + TF=7.046E-10 + XTF=4.217 + VTF=5.367 + ITF=0.1947 + PTF=0 + CJC=1.113E-11 + VJC=0.1 + MJC=0.3414 + XCJC=0.6288 + TR=1E-32 + CJS=0 + VJS=0.75 + MJS=0.333 + FC=0.7947 + vce_max=65 vbe_max=6 ) * * NXP Semiconductors * * Medium power NPN transistor * IC = 1 A * VCEO = 20 V * hFE = 85 - 375 @ 2V/500mA * * * * * Package pinning does not match Spice model pinning. * Package: SOT 223 * * Package Pin 1: Base * Package Pin 2: Collector * Package Pin 3: Emitter * Package Pin 4: Collector * * Extraction date (week/year): 13/2008 * Simulator: Spice 3 * ********************************************************** *# .SUBCKT BCP68 1 2 3 * Q1 1 2 3 BCP68 D1 2 1 DIODE * *The diode does not reflect a *physical device but improves *only modeling in the reverse *mode of operation. * .MODEL BCP68 NPN + IS = 2.312E-013 + NF = 0.988 + ISE = 8.851E-014 + NE = 2.191 + BF = 273 + IKF = 5.5 + VAF = 50 + NR = 0.9885 + ISC = 6.808E-014 + NC = 3 + BR = 155.6 + IKR = 4 + VAR = 17 + RB = 15 + IRB = 2E-006 + RBM = 0.65 + RE = 0.073 + RC = 0.073 + XTB = 0 + EG = 1.11 + XTI = 3 + CJE = 2.678E-010 + VJE = 0.732 + MJE = 0.3484 + TF = 5.8E-010 + XTF = 1.5 + VTF = 2.5 + ITF = 1 + PTF = 0 + CJC = 3.406E-011 + VJC = 2 + MJC = 0.3142 + XCJC = 1 + TR = 6.5E-009 + CJS = 0 + VJS = 0.75 + MJS = 0.333 + FC = 0.95 .MODEL DIODE D + IS = 2.702E-015 + N = 1.2 + BV = 1000 + IBV = 0.001 + RS = 0.1 + CJO = 0 + VJ = 1 + M = 0.5 + FC = 0 + TT = 0 + EG = 1.11 + XTI = 3 .ENDS .model D1N4007 D(IS=7.02767n RS=0.0341512 N=1.80803 EG=1.05743 XTI=5 BV=1000 IBV=5e-08 CJO=1e-11 VJ=0.7 M=0.5 FC=0.5 TT=1e-07 ) .MODEL D1N4148 D + IS = 4.352E-9 + N = 1.906 + BV = 110 + IBV = 0.0001 + RS = 0.6458 + CJO = 7.048E-13 + VJ = 0.869 + M = 0.03 + FC = 0.5 + TT = 3.48E-9 .MODEL D1n5400 d +IS=2.61339e-12 RS=0.0110501 N=1.20576 EG=0.6 +XTI=3.1271 BV=50 IBV=1e-05 CJO=1e-11 +VJ=0.7 M=0.5 FC=0.5 TT=1e-09 +KF=0 AF=1 * Model generated on October 12, 2003 * Model format: PSpice *1N758 *Ref: Motorola *10V 500mW Si Zener pkg:DIODE0.4 1,2 .MODEL D1N758 D(IS=1E-11 RS=8.483 N=1.27 TT=5E-8 CJO=2.334E-10 VJ=0.75 + M=0.33 BV=9.83 IBV=0.01 ) *1N4744 *Ref: Motorola *15V 1W Si Zener pkg:DIODE0.4 1,2 .MODEL D1N4744 D(IS=5.32E-14 RS=6.47 TT=5.01E-8 CJO=7.83E-11 M=0.33 + BV=14.89 IBV=0.017 ) *1N755 *Ref: Motorola *7.5V 500mW Si Zener pkg:DIODE0.4 1,2 .MODEL D1N755 D(IS=1E-11 RS=3.359 N=1.27 TT=5E-8 CJO=2.959E-10 VJ=0.75 + M=0.33 BV=7.433 IBV=0.01 ) ** node order * 1: gnd * 2: trig * 3: out * 4: reset# * 5: ctrl * 6: thres * 7: dis * 8: vcc .SUBCKT ne555 34 32 30 19 23 33 1 21 * G TR O R F TH D V Q4 25 2 3 QP Q5 34 6 3 QP Q6 6 6 8 QP R1 9 21 4.7K R2 3 21 830 R3 8 21 4.7K Q7 2 33 5 QN Q8 2 5 17 QN Q9 6 4 17 QN Q10 6 23 4 QN Q11 12 20 10 QP R4 10 21 1K Q12 22 11 12 QP Q13 14 13 12 QP Q14 34 32 11 QP Q15 14 18 13 QP R5 14 34 100K R6 22 34 100K R7 17 34 10K Q16 1 15 34 QN Q17 15 19 31 QP R8 18 23 5K R9 18 34 5K R10 21 23 5K Q18 27 20 21 QP Q19 20 20 21 QP R11 20 31 5K D1 31 24 DA Q20 24 25 34 QN Q21 25 22 34 QN Q22 27 24 34 QN R12 25 27 4.7K R13 21 29 6.8K Q23 21 29 28 QN Q24 29 27 16 QN Q25 30 26 34 QN Q26 21 28 30 QN D2 30 29 DA R14 16 15 100 R15 16 26 220 R16 16 34 4.7K R17 28 30 3.9K Q3 2 2 9 QP .MODEL DA D (RS=40 IS=1.0E-14 CJO=1PF) .MODEL QP PNP (level=1 BF=20 BR=0.02 RC=4 RB=25 IS=1.0E-14 VA=50 NE=2) + CJE=12.4P VJE=1.1 MJE=.5 CJC=4.02P VJC=.3 MJC=.3 TF=229P TR=159N) .MODEL QN NPN (level=1 IS=5.07F NF=1 BF=100 VAF=161 IKF=30M ISE=3.9P NE=2 + BR=4 NR=1 VAR=16 IKR=45M RE=1.03 RB=4.12 RC=.412 XTB=1.5 + CJE=12.4P VJE=1.1 MJE=.5 CJC=4.02P VJC=.3 MJC=.3 TF=229P TR=959P) .ENDS .SUBCKT BS250P 3 4 5 * D G S M1 3 2 5 5 MBS250 RG 4 2 160 RL 3 5 1.2E8 C1 2 5 47E-12 C2 3 2 10E-12 D1 3 5 DBS250 * .MODEL MBS250 PMOS VTO=-3.193 RS=2.041 RD=0.697 IS=1E-15 KP=0.277 +CBD=105E-12 PB=1 LAMBDA=1.2E-2 .MODEL DBS250 D IS=2E-13 RS=0.309 .ENDS BS250P .SUBCKT BS170 3 4 5 * D G S M1 3 2 5 5 N3306M RG 4 2 270 RL 3 5 1.2E8 C1 2 5 28E-12 C2 3 2 3E-12 D1 5 3 N3306D * .MODEL N3306M NMOS VTO=1.824 RS=1.572 RD=1.436 IS=1E-15 KP=.1233 +CBD=35E-12 PB=1 .MODEL N3306D D IS=5E-12 RS=.768 .ENDS BS170 * *$ .SUBCKT PTON_TOFF_U4_S1 1 2 3 4 G_Switch 3 4 VCR PWL(1) 1 2 0.2 100e6 0.8 1m RS_U4_S1 1 2 1G .ENDS PTON_TOFF_U4_S1 *$ .SUBCKT PTON_TOFF_U4_S2 1 2 3 4 G_Switch 3 4 VCR PWL(1) 1 2 0.2 100e6 0.8 1m RS_U4_S2 1 2 1G .ENDS PTON_TOFF_U4_S2 *$ .SUBCKT MTON_TOFF_U2_S2 1 2 3 4 G_Switch 3 4 VCR PWL(1) 1 2 0.2 100e6 0.8 1m RS_U2_S2 1 2 1G .ENDS MTON_TOFF_U2_S2 *$ .SUBCKT MTON_TOFF_U2_S1 1 2 3 4 G_Switch 3 4 VCR PWL(1) 1 2 0.2 100e6 0.8 1m RS_U2_S1 1 2 1G .ENDS MTON_TOFF_U2_S1 *$ ****************************** Basic Components ************************** .SUBCKT D_D1 1 2 D1 1 2 DD1 .MODEL DD1 D (IS=1e-15 Rs=0.001 N=0.1 TT=10p) .ENDS D_D1 *$ .SUBCKT BUF_BASIC_GEN A Y VDD=1 VSS=0 VTHRESH=0.5 * E_ABMGATE YINT 0 vol='V(A) > VTHRESH? VDD:VSS' E_ABMGATE YINT 0 pwl(1) A 0 'VTHRESH-0.01' VSS 'VTHRESH+0.01' VDD RINT YINT Y 1 CINT Y 0 1n .ENDS BUF_BASIC_GEN *$ .MODEL NMOS01 NMOS (VTO = 2 KP = 1.005 LAMBDA = 0.001) *$ .MODEL PMOS01 PMOS (VTO = -2 KP = 1.77 LAMBDA = 0.001) *$ .MODEL NMOS02 NMOS (VTO = 2 KP = 0.1814 LAMBDA = 0.001) *$ .MODEL PMOS02 PMOS (VTO = -2 KP = 0.2497 LAMBDA = 0.001) *$ .SUBCKT COMPHYS_BASIC_GEN INP INM HYS OUT VDD=1 VSS=0 VTHRESH=0.5 EIN INP1 INM1 INP INM 1 * EHYS INP1 INP2 vol='V(1) > VTHRESH? -V(HYS):0' EHYS INP1 INP2 pwl(1) 1 0 'VTHRESH-0.01' 0 'VTHRESH+0.01' '-V(HYS)' EOUT OUT 0 vol='V(INP2)>V(INM1)? VDD : VSS' R1 OUT 1 1 C1 1 0 5n RINP1 INP1 0 1K .ENDS COMPHYS_BASIC_GEN *$ .SUBCKT AND2_BASIC_GEN A B Y VDD=1 VSS=0 VTHRESH=0.5 E_ABMGATE YINT 0 vol= 'V(A) > VTHRESH && V(B) > VTHRESH ? VDD:VSS' RINT YINT Y 1 CINT Y 0 1n .ENDS AND2_BASIC_GEN *$ .SUBCKT NOR2_BASIC_GEN A B Y VDD=1 VSS=0 VTHRESH=0.5 E_ABMGATE YINT 0 vol= 'V(A) > VTHRESH || V(B) > VTHRESH ? VSS:VDD' RINT YINT Y 1 CINT Y 0 1n .ENDS NOR2_BASIC_GEN *$ .SUBCKT AND3_BASIC_GEN A B C Y VDD=1 VSS=0 VTHRESH=0.5 E_ABMGATE YINT 0 vol= 'V(A) > VTHRESH && V(B) > VTHRESH && V(C) > VTHRESH ? VDD:VSS' RINT YINT Y 1 CINT Y 0 1n .ENDS AND3_BASIC_GEN *$ .SUBCKT INV_BASIC_GEN A Y VDD=1 VSS=0 VTHRESH=0.5 * E_ABMGATE YINT 0 vol='V(A) > VTHRESH ? VSS : VDD' E_ABMGATE YINT 0 pwl(1) A 0 'VTHRESH-0.01' VDD 'VTHRESH+0.01' VSS RINT YINT Y 1 CINT Y 0 1n .ENDS INV_BASIC_GEN *$ .SUBCKT RVAR 101 102 201 202 RREF=1 * nodes : 101 102 : nodes between which variable resistance is placed * 201 202 : nodes to whose voltage the resistance is proportional * parameters : rref : reference value of the resistance rin 201 202 1G $$ input resistance r 301 0 rref fcopy 0 301 vsense 1 $$ copy output current thru Z eout 101 106 poly(2) 201 202 301 0 0 0 0 0 1 $$ multiply VoverZ with Vctrl vsense 106 102 0 $$ sense iout .ENDS RVAR *$ *LM317 TI voltage regulator - pin order: In, Adj, Out *TI adjustable voltage regulator pkg:TO-3 .SUBCKT LM317 1 2 3 **Changes my be required on this line** J1 1 3 4 JN Q2 5 5 6 QPL .1 Q3 5 8 9 QNL .2 Q4 8 5 7 QPL .1 Q5 81 8 3 QNL .2 Q6 3 81 10 QPL .2 Q7 12 81 13 QNL .2 Q8 10 5 11 QPL .2 Q9 14 12 10 QPL .2 Q10 16 5 17 QPL .2 Q11 16 14 15 QNL .2 Q12 3 20 16 QPL .2 Q13 1 19 20 QNL .2 Q14 19 5 18 QPL .2 Q15 3 21 19 QPL .2 Q16 21 22 16 QPL .2 Q17 21 3 24 QNL .2 Q18 22 22 16 QPL .2 Q19 22 3 241 QNL 2 Q20 3 25 16 QPL .2 Q21 25 26 3 QNL .2 Q22A 35 35 1 QPL 2 Q22B 16 35 1 QPL 2 Q23 35 16 30 QNL 2 Q24A 27 40 29 QNL .2 Q24B 27 40 28 QNL .2 Q25 1 31 41 QNL 5 Q26 1 41 32 QNL 50 D1 3 4 DZ D2 33 1 DZ D3 29 34 DZ R1 1 6 310 R2 1 7 310 R3 1 11 190 R4 1 17 82 R5 1 18 5.6K R6 4 8 100K R7 8 81 130 R8 10 12 12.4K R9 9 3 180 R10 13 3 4.1K R11 14 3 5.8K R12 15 3 72 R13 20 3 5.1K R14 2 24 12K R15 24 241 2.4K R16 16 25 6.7K R17 16 40 12K R18 30 41 130 R19 16 31 370 R20 26 27 13K R21 27 40 400 R22 3 41 160 R23 33 34 18K R24 28 29 160 R25 28 32 3 R26 32 3 .1 C1 21 3 30PF C2 21 2 30PF C3 25 26 5PF CBS1 5 3 2PF CBS2 35 3 1PF CBS3 22 3 1PF .MODEL JN NJF(BETA=1E-4 VTO=-7) .MODEL DZ D(BV=6.3) .MODEL QNL NPN(EG=1.22 BF=80 RB=100 CCS=1.5PF TF=.3NS TR=6NS CJE=2PF + CJC=1PF VAF=100) .MODEL QPL PNP(BF=40 RB=20 TF=.6NS TR=10NS CJE=1.5PF CJC=1PF VAF=50) .ENDS .SUBCKT xxxxLM317 1 3 2 * IN ADJ OUT IADJ 1 4 50U VREF 4 3 1.25 RC 1 14 0.742 DBK 14 13 D1 CBC 13 15 2.479N RBC 15 5 247 QP 13 5 2 Q1 RB2 6 5 124 DSC 6 11 D1 ESC 11 2 POLY(2) (13,5) (6,5) 2.85 + 0 0 0 -70.1M DFB 6 12 D1 EFB 12 2 POLY(2) (13,5) (6,5) 3.92 + -135M 0 1.21M -70.1M RB1 7 6 1 EB 7 2 8 2 2.56 CPZ 10 2 0.796U DPU 10 2 D1 RZ 8 10 0.104 RP 9 8 100 EP 9 2 4 2 103.6 RI 2 4 100MEG .MODEL Q1 NPN (IS=30F BF=100 + VAF=14.27 NF=1.604) .MODEL D1 D (IS=30F N=1.604) .ENDS .SUBCKT LM337 8 1 19 *Connections Input Adj. Output *LM337 negative voltage regulator .MODEL QN NPN (BF=50 TF=1N CJC=1P) .MODEL QPOUT PNP (BF=50 TF=1N RE=.2 CJC=1P) .MODEL QP PNP CJC=1P TF=2N .MODEL DN D .MODEL D2 D BV=12 IBV=100U R10 25 6 1K Q3 8 17 16 QPOUT Q4 8 25 17 QP R18 19 17 250 R19 19 16 .3 G1 8 6 1 18 .1 C7 6 2 .04U R24 2 8 100 I_ADJ 0 1 65U R26 8 25 200K Q5 25 4 19 QP R27 16 4 200 R28 7 4 7K D1 8 7 D2 D2 8 6 DN V1 18 19 1.25 .ENDS "} C {devices/lab_pin} 340 -470 0 1 {name=p13 lab=E9} C {devices/lab_pin} 560 -440 0 0 {name=p19 lab=C8} C {devices/lab_pin} 560 -530 0 1 {name=p20 lab=E8} C {devices/lab_pin} 840 -880 0 1 {name=p21 lab=E11} C {devices/lab_pin} 260 -190 0 1 {name=p22 lab=E3} C {devices/lab_pin} 260 -300 0 1 {name=p26 lab=C3} C {devices/lab_pin} 50 -240 0 0 {name=p30 lab=B3} C {devices/lab_pin} 520 -490 0 0 {name=p33 lab=VSS} C {devices/res} 340 -660 0 1 {name=r13 m=1 value=300} C {devices/npn} 200 -630 0 1 {name=Q7 model=q2n2222 area=1} C {devices/lab_pin} 180 -690 0 0 {name=p8 lab=C7} C {devices/lab_pin} 340 -690 0 1 {name=p31 lab=C2} C {devices/title} 160 -30 0 0 {name=l2 author="Stefan Schippers"} C {devices/lab_pin} 1030 -700 0 0 {name=p32 lab=SA} C {devices/ammeter} 1110 -350 0 0 {name=v0} C {devices/lab_pin} 1030 -380 0 0 {name=p35 lab=SB} C {devices/launcher} 1390 -90 0 0 {name=h1 descr="IRF540 model" url="http://espice.ugr.es/espice/src/modelos_subckt/spice_complete/other_models/ir_lib/irf540.spi" } xschem-2.8.1/xschem_library/examples/test_lm324.sym0000644000175100017510000000042113023243556020474 0ustar svnsvnG {type=subcircuit format="@name @pinlist @symname" verilog_stop=true template="name=x1" } V {} S {} L 4 -130 -10 130 -10 {} L 4 -130 10 130 10 {} L 4 -130 -10 -130 10 {} L 4 130 -10 130 10 {} T {@symname} -58.5 -6 0 0 0.3 0.3 {} T {@name} 135 -22 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/not.sym0000644000175100017510000000073413362731551017406 0ustar svnsvnG {type=notif0 verilog_format="not ( @str1 , @str0 ) #( @risedel , @falldel ) @name ( @@Z , @@A );" template="name=b1 str1=strong1 str0=strong0 risedel=100 falldel=100"} V {} S {} E {} L 4 -40 0 -25 0 {} L 4 -25 -20 -25 20 {} L 4 -25 -20 15 0 {} L 4 -25 20 15 0 {} L 4 25 0 40 0 {} B 5 37.5 -2.5 42.5 2.5 {name=Z verilog_type=wire dir=out} B 5 -42.5 -2.5 -37.5 2.5 {name=A dir=in} A 4 20 0 5 180 360 {} T {@symname} 7.5 -22.5 0 0 0.2 0.2 {} T {@name} -23.75 -5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/tesla2.sch0000644000175100017510000005440213370707253017747 0ustar svnsvnG {} V {} S {} E {} L 4 40 -1110 860 -1110 {} L 4 860 -1110 860 -1060 {} L 4 40 -1110 40 -1060 {} L 4 930 -1110 1800 -1110 {} L 4 1800 -1110 1800 -1060 {} L 4 930 -1110 930 -1060 {} T {BEHAVIORAL PART} 200 -1190 0 0 1 1 {} T {REAL DISCRETE COMPONENTS} 1010 -1190 0 0 1 1 {} N 1320 -570 1440 -570 {lab=#net1} N 1010 -570 1010 -550 {lab=D} N 1010 -700 1010 -670 {lab=VPP} N 1010 -460 1010 -400 {lab=VNN} N 310 -990 310 -970 {lab=#net2} N 310 -850 310 -830 {lab=#net3} N 1230 -640 1230 -570 {lab=D} N 1010 -700 1230 -700 {lab=VPP} N 1210 -570 1210 -530 {lab=D} N 1010 -470 1210 -470 {lab=VNN} N 370 -220 370 -190 {lab=CURSENSE2} N 320 -220 370 -220 {lab=CURSENSE2} N 1440 -510 1440 -480 {lab=#net4} N 1410 -420 1440 -420 {lab=VSS} N 1380 -510 1380 -420 {lab=VSS} N 1410 -230 1680 -230 {lab=VSS} N 1230 -570 1260 -570 {lab=D} N 1010 -750 1010 -700 {lab=VPP} N 1010 -490 1010 -470 {lab=VNN} N 1210 -570 1230 -570 {lab=D} N 1010 -570 1210 -570 {lab=D} N 1010 -580 1010 -570 {lab=D} N 1650 -510 1650 -480 {lab=#net5} N 1680 -570 1710 -570 {lab=HV} N 1680 -420 1710 -420 {lab=#net6} N 1710 -510 1710 -420 {lab=#net6} N 1680 -610 1680 -570 {lab=HV} N 1700 -610 1780 -610 {lab=HV} N 1650 -570 1680 -570 {lab=HV} N 1650 -420 1680 -420 {lab=#net6} N 600 -220 600 -190 {lab=CURSENSE1} N 550 -220 600 -220 {lab=CURSENSE1} N 600 -350 600 -320 {lab=CURSENSE} N 550 -350 600 -350 {lab=CURSENSE} N 190 -640 190 -590 {lab=#net7} N 190 -640 250 -640 {lab=#net7} N 190 -440 250 -440 {lab=#net8} N 190 -490 190 -440 {lab=#net8} N 430 -660 430 -640 {lab=#net9} N 430 -480 430 -440 {lab=#net10} N 1380 -420 1410 -420 {lab=VSS} N 1230 -230 1410 -230 {lab=VSS} N 1780 -610 1780 -510 {lab=HV} N 1780 -450 1780 -230 {lab=VSS} N 1680 -230 1780 -230 {lab=VSS} N 410 -910 500 -910 {lab=VSS} N 400 -840 400 -830 {lab=VNN} N 400 -990 400 -980 {lab=VPP} N 390 -910 400 -900 {lab=VSS} N 400 -920 410 -910 {lab=VSS} N 310 -990 330 -990 {lab=#net2} N 400 -990 500 -990 {lab=VPP} N 310 -830 330 -830 {lab=#net3} N 400 -830 500 -830 {lab=VNN} N 530 -680 590 -680 {lab=VSS} N 590 -700 640 -700 {lab=#net11} N 470 -700 530 -700 {lab=#net9} N 470 -700 470 -640 {lab=#net9} N 620 -660 640 -660 {lab=#net9} N 620 -660 620 -640 {lab=#net9} N 310 -910 390 -910 {lab=VSS} N 390 -910 410 -910 {lab=VSS} N 390 -830 400 -830 {lab=VNN} N 390 -990 400 -990 {lab=VPP} N 430 -640 470 -640 {lab=#net9} N 470 -640 620 -640 {lab=#net9} N 530 -520 590 -520 {lab=VSS} N 590 -540 640 -540 {lab=#net12} N 470 -540 530 -540 {lab=#net10} N 470 -540 470 -480 {lab=#net10} N 620 -500 640 -500 {lab=#net10} N 620 -500 620 -480 {lab=#net10} N 430 -480 470 -480 {lab=#net10} N 470 -480 620 -480 {lab=#net10} N 810 -460 1010 -460 {lab=VNN} N 810 -580 1010 -580 {lab=D} N 740 -680 740 -630 {lab=GH} N 740 -630 770 -630 {lab=GH} N 740 -520 740 -510 {lab=GL} N 740 -510 770 -510 {lab=GL} N 810 -640 910 -640 {lab=#net13} N 810 -520 910 -520 {lab=#net14} N 1010 -470 1010 -460 {lab=VNN} N 1010 -610 1010 -580 {lab=D} N 1680 -610 1700 -610 {lab=HV} N 1410 -260 1410 -230 {lab=VSS} N 1380 -630 1380 -570 {lab=#net1} N 1410 -420 1410 -380 {lab=VSS} N 1670 -420 1670 -350 {lab=#net6} N 1410 -390 1410 -260 {lab=VSS} C {devices/code} 1850 -510 0 0 { name=STIMULI value=".option PARHIER=LOCAL RUNLVL=6 post MODMONTE=1 .option sampling_method = SRS .option method=gear vvss vss 0 dc 0 .temp 30 .tran 20n 1m uic $$ sweep CTUNE 1.5n 8.5n 0.1n * .meas tran pavg_gatedrv AVG p(xgatedrv) from=950u to=990u * .meas tran pavg_mos1 AVG p(xmos1) from=950u to=990u * .meas tran pavg_mos2 AVG p(xmos2) from=950u to=990u * .probe tran p(xgatedrv) p(xmos1) p(xmos2) i(d1) I(L1) I(L2) .include stimuli.cir .probe tran i(l1) i(l2) p(xm1) p(xm2) p(d1) p(d2) .meas tran pavg_mos1 AVG p(xm1) from=950u to=990u .meas tran pavg_mos2 AVG p(xm2) from=950u to=990u .meas tran pavg_d1 AVG p(d1) from=950u to=990u .meas tran pavg_d2 AVG p(d2) from=950u to=990u"} C {devices/launcher} 1920 -770 0 0 {name=h2 descr="BJT MODELS" url="http://www.zen22142.zen.co.uk/ltspice/standard.bjt"} C {devices/launcher} 1920 -720 0 0 {name=h1 descr="NPN MODELS" url="http://web.mit.edu/Magic/Public/ckt/npn.mod"} C {devices/launcher} 1920 -820 0 0 {name=h3 descr="COIL CALCULATION" url="http://hamwaves.com/antennas/inductance.html"} C {devices/launcher} 1920 -870 0 0 {name=h4 descr="ltwiki BJT MODELS" url="http://ltwiki.org/?title=Standard.bjt"} C {devices/lab_pin} 1230 -230 0 0 {name=p1 lab=VSS} C {devices/ammeter} 1290 -570 3 0 {name=vmeasure} C {devices/vsource} 310 -940 0 0 {name=v1 value=12} C {devices/lab_pin} 310 -910 0 0 {name=p4 lab=VSS} C {devices/vsource} 310 -880 0 0 {name=v2 value=12} C {devices/lab_pin} 500 -990 0 1 {name=p5 lab=VPP} C {devices/lab_pin} 500 -830 0 1 {name=p6 lab=VNN} C {devices/lab_pin} 1010 -750 0 0 {name=p7 lab=VPP} C {devices/lab_pin} 1010 -400 0 0 {name=p9 lab=VNN} C {devices/lab_pin} 1010 -560 0 0 {name=p11 lab=D} C {devices/vsource_arith} 370 -160 0 0 {name=E1 VOL=(i(rfb)-v(offset))*200 MAX=5 MIN=0} C {devices/lab_pin} 370 -130 0 0 {name=p15 lab=VSS} C {devices/lab_pin} 320 -220 0 0 {name=p16 lab=CURSENSE2} C {devices/ind} 1440 -540 2 1 {name=L1 value=9.8u} C {devices/res} 1440 -450 0 1 {name=r1 m=1 value=0.22} C {devices/capa} 1380 -540 0 0 {name=c5 m=1 value=13p} C {devices/ind} 1650 -540 0 1 {name=L2 value=9.1m} C {devices/k} 1540 -540 0 0 {name=K1 K=0.15 L1=L1 L2=L2} C {devices/res} 1650 -450 0 0 {name=r4 m=1 value=.32} C {devices/capa} 1710 -540 0 1 {name=c7 m=1 value=4.1p} C {devices/lab_pin} 1780 -610 0 1 {name=p71 lab=HV} C {devices/vsource_arith} 600 -160 0 0 {name=E11 VOL=(i(rfb)+v(offset))*20000 MAX=5 MIN=0} C {devices/lab_pin} 600 -130 0 0 {name=p0 lab=VSS} C {devices/lab_pin} 550 -220 0 0 {name=p8 lab=CURSENSE1} C {devices/vsource} 350 -290 0 0 {name=v3 value="pwl 0 0 280u 0 600u 1.2" } C {devices/lab_pin} 350 -260 0 0 {name=p25 lab=VSS} C {devices/lab_pin} 350 -320 0 0 {name=p27 lab=OFFSET} C {devices/vsource_arith} 600 -290 0 0 {name=E2 VOL=i(rfb)*20000 MAX=5 MIN=0} C {devices/lab_pin} 600 -260 0 0 {name=p13 lab=VSS} C {devices/lab_pin} 550 -350 0 0 {name=p17 lab=CURSENSE} C {examples/sr_flop} 340 -430 0 0 {name=x8 VTH=2.5 VHI=5} C {devices/lab_pin} 740 -520 0 1 {name=p28 lab=GL} C {devices/lab_pin} 250 -420 0 0 {name=p29 lab=CURSENSE1} C {devices/lab_pin} 250 -400 0 0 {name=p30 lab=VSS} C {examples/inv} 150 -490 0 0 {name=E7 TABLE="2.3 5 2.7 0.0"} C {devices/lab_pin} 150 -460 0 0 {name=p35 lab=VSS} C {devices/lab_pin} 110 -490 0 0 {name=p36 lab=CURSENSE} C {examples/sr_flop} 340 -650 0 0 {name=x5 VTH=2.5 VHI=5} C {devices/lab_pin} 740 -680 0 1 {name=p37 lab=GH} C {devices/lab_pin} 250 -660 0 0 {name=p38 lab=CURSENSE} C {examples/inv} 150 -590 0 0 {name=E12 TABLE="2.3 5 2.7 0.0"} C {devices/lab_pin} 150 -560 0 0 {name=p39 lab=VSS} C {devices/lab_pin} 250 -620 0 0 {name=p40 lab=VSS} C {devices/lab_pin} 110 -590 0 0 {name=p41 lab=CURSENSE2} C {devices/diode} 1210 -500 2 1 {name=D1 model=d1n5400 area=1 url="http://pdf.datasheetcatalog.com/datasheet/bytes/1N5406.pdf"} C {devices/diode} 1230 -670 2 0 {name=D2 model=d1n5400 area=1 url="http://pdf.datasheetcatalog.com/datasheet/bytes/1N5406.pdf"} C {devices/capa} 1780 -480 0 1 {name=c1 m=1 value=1p} C {devices/capa} 400 -950 0 0 {name=c2 m=1 value=10n} C {devices/capa} 400 -870 0 0 {name=c3 m=1 value=10n} C {devices/lab_pin} 500 -910 0 1 {name=p3 lab=VSS} C {devices/res} 360 -990 1 1 {name=r5 m=1 value=0.3} C {devices/res} 360 -830 1 1 {name=r6 m=1 value=0.3} C {examples/an2} 680 -680 0 0 {name=E6 TABLE="2 0 6 8"} C {devices/lab_pin} 680 -640 0 0 {name=p19 lab=VSS} C {devices/delay_hsp} 560 -700 0 0 {name=E4 DEL=5n SCALE=1} C {devices/lab_pin} 530 -680 0 0 {name=p20 lab=VSS} C {examples/an2} 680 -520 0 0 {name=E5 TABLE="2 0 6 8"} C {devices/lab_pin} 680 -480 0 0 {name=p21 lab=VSS} C {devices/delay_hsp} 560 -540 0 0 {name=E9 DEL=5n SCALE=1} C {devices/lab_pin} 530 -520 0 0 {name=p22 lab=VSS} C {devices/nmos3} 990 -640 0 0 {name=xm2 model=irf540 m=1} C {devices/nmos3} 990 -520 0 0 {name=xm1 model=irf540 m=1} C {devices/lab_pin} 770 -590 0 0 {name=p2 lab=VSS} C {devices/lab_pin} 770 -470 0 0 {name=p10 lab=VSS} C {devices/res} 940 -640 1 1 {name=r2 m=1 value=1.5} C {devices/res} 940 -520 1 1 {name=r3 m=1 value=1.5} C {devices/vsource_pwl} 810 -490 0 0 {name=E10 TABLE="1 0 7 8"} C {devices/vsource_pwl} 810 -610 0 0 {name=E3 TABLE="1 0 7 8"} C {devices/res} 1670 -260 0 1 {name=rfb m=1 value=10} C {devices/isource} 1380 -660 0 0 {name=i1 value="pwl 0 0 1u 3 2u 3 3u 0"} C {devices/lab_pin} 1380 -690 0 0 {name=p12 lab=VSS} C {devices/ammeter} 1670 -320 0 0 {name=vr} C {devices/title} 160 -30 0 0 {name=l1 author="Stefan Schippers"} C {devices/code} 1850 -660 0 0 {name=MODELS only_toplevel=true value=".MODEL bd139_2 npn +IS=1e-09 BF=222.664 NF=0.85 VAF=36.4079 +IKF=0.166126 ISE=5.03418e-09 NE=1.45313 BR=1.35467 +NR=1.33751 VAR=142.931 IKR=1.66126 ISC=5.02557e-09 +NC=3.10227 RB=26.9143 IRB=0.1 RBM=0.1 +RE=0.000472454 RC=1.04109 XTB=0.727762 XTI=1.04311 +EG=1.05 CJE=1e-11 VJE=0.75 MJE=0.33 +TF=1e-09 XTF=1 VTF=10 ITF=0.01 +CJC=1e-11 VJC=0.75 MJC=0.33 XCJC=0.9 +FC=0.5 CJS=0 VJS=0.75 MJS=0.5 +TR=1e-07 PTF=0 KF=0 AF=1 .MODEL BD139 NPN ( +IS=2.3985E-13 Vceo=80 Icrating=1500m +BF=244.9 NF=1.0 BR=78.11 NR=1.007 ISE=1.0471E-14 +NE=1.2 ISC=1.9314E-11 NC=1.45 VAF=98.5 VAR=7.46 +IKF=1.1863 IKR=0.1445 RB=2.14 RBM=0.001 IRB=0.031 +RE=0.0832 RC=0.01 CJE=2.92702E-10 VJE=0.67412 +MJE=0.3300 FC=0.5 CJC=4.8831E-11 VJC=0.5258 +MJC=0.3928 XCJC=0.5287 XTB=1.1398 EG=1.2105 XTI=3.0) .MODEL BD140 PNP(IS=1e-09 BF=650.842 NF=0.85 VAF=10 +IKF=0.0950125 ISE=1e-08 NE=1.54571 BR=56.177 +NR=1.5 VAR=2.11267 IKR=0.950125 ISC=1e-08 +NC=3.58527 RB=41.7566 IRB=0.1 RBM=0.108893 +RE=0.000347052 RC=1.32566 XTB=19.5239 XTI=1 +EG=1.05 CJE=1e-11 VJE=0.75 MJE=0.33 +TF=1e-09 XTF=1 VTF=10 ITF=0.01 +CJC=1e-11 VJC=0.75 MJC=0.33 XCJC=0.9 +FC=0.5 CJS=0 VJS=0.75 MJS=0.5 TR=1e-07 PTF=0 KF=0 AF=10 + VCEO=80 ICRATING=1A ) .MODEL Q2N2222A NPN IS =3.0611E-14 NF =1.00124 BF =220 IKF=0.52 + VAF=104 ISE=7.5E-15 NE =1.41 NR =1.005 BR =4 IKR=0.24 + VAR=28 ISC=1.06525E-11 NC =1.3728 RB =0.13 RE =0.22 + RC =0.12 CJC=9.12E-12 MJC=0.3508 VJC=0.4089 + CJE=27.01E-12 TF =0.325E-9 TR =100E-9 + vce_max=45 vbe_max=6 .MODEL Q2N2222 NPN ( + IS = 3.97589E-14 BF = 195.3412 NF = 1.0040078 VAF = 53.081 IKF = 0.976 ISE = 1.60241E-14 + NE = 1.4791931 BR = 1.1107942 NR = 0.9928261 VAR = 11.3571702 IKR = 2.4993953 ISC = 1.88505E-12 + NC = 1.1838278 RB = 56.5826472 IRB = 1.50459E-4 RBM = 5.2592283 RE = 0.0402974 RC = 0.4208 + CJE = 2.56E-11 VJE = 0.682256 MJE = 0.3358856 TF = 3.3E-10 XTF = 6 VTF = 0.574 + ITF = 0.32 PTF = 25.832 CJC = 1.40625E-11 VJC = 0.5417393 MJC = 0.4547893 XCJC = 1 + TR = 3.2E-7 CJS = 0 VJS = .75 MJS = 0 XTB = 1.6486 EG = 1.11 + XTI = 5.8315 KF = 0 AF = 1 FC = 0.83 + vce_max=45 vbe_max=6 ) * 2n2222 p complementary .MODEL Q2N2907P PNP(IS=650.6E-18 ISE=54.81E-15 ISC=0 XTI=3 + BF=231.7 BR=3.563 IKF=1.079 IKR=0 XTB=1.5 + VAF=115.7 VAR=35 VJE=0.65 VJC=0.65 + RE=0.15 RC=0.715 RB=10 + CJE=19.82E-12 CJC=14.76E-12 XCJC=0.75 FC=0.5 + NF=1 NR=1 NE=1.829 NC=2 MJE=0.3357 MJC=0.5383 + TF=603.7E-12 TR=111.3E-9 ITF=0.65 VTF=5 XTF=1.7 + EG=1.11 KF=1E-9 AF=1 + VCEO=45 ICRATING=100M + vce_max=45 vbe_max=6 ) .MODEL Q2N2907S PNP(IS=2.32E-13 ISE=6.69E-16 ISC=1.65E-13 XTI=3.00 + BF=3.08E2 BR=2.18E1 IKF=8.42E-1 IKR=1.00 XTB=1.5 + VAF=1.41E2 VAR=1.35E1 VJE=3.49E-1 VJC=3.00E-1 + RE=1.00E-2 RC=8.46E-1 RB=4.02E1 RBM=1.00E-2 IRB=1.25E-2 + CJE=2.66E-11 CJC=1.93E-11 XCJC=1.00 FC=5.00E-1 + NF=1.04 NR=1.12 NE=1.09 NC=1.13 MJE=4.60E-1 MJC=4.65E-1 + TF=4.95E-10 TR=0 PTF=0 ITF=3.36E-1 VTF=6.54 XTF=1.87E1 + EG=1.11 KF=1E-9 AF=1 + VCEO=40 ICRATING=500M + vce_max=45 vbe_max=6 ) *MM3725 MCE 5/13/95 *Si 1W 40V 500mA 307MHz pkg:TO-39 3,2,1 .MODEL QMM3725 NPN (IS=50.7F NF=1 BF=162 VAF=113 IKF=.45 ISE=38.2P NE=2 + BR=4 NR=1 VAR=24 IKR=.675 RE=.263 RB=1.05 RC=.105 XTB=1.5 + CJE=62.2P VJE=1.1 MJE=.5 CJC=14.6P VJC=.3 MJC=.3 TF=518P TR=45.9N) *MPS651 MCE 5/12/95 *Si 625mW 60V 2A 110MHz pkg:TO-92 1,2,3 .MODEL QMPS651 NPN (IS=72.1F NF=1 BF=260 VAF=139 IKF=2.5 ISE=67.1P NE=2 + BR=4 NR=1 VAR=20 IKR=3.75 RE=28.2M RB=.113 RC=11.3M XTB=1.5 + CJE=212P VJE=1.1 MJE=.5 CJC=68.6P VJC=.3 MJC=.3 TF=1.44N TR=1U) *FCX649 ZETEX Spice model Last revision 17/7/90 Medium Power *ZTX Si 1.5W 25V 2A 240MHz pkg:SOT-89 2,1,3 .MODEL QFCX649 NPN(IS=3E-13 BF=225 VAF=80 IKF=2.8 ISE=1.1E-13 NE=1.37 + BR=110 NR=0.972 VAR=28 IKR=0.8 ISC=6.5E-13 NC=1.372 RB=0.3 RE=0.063 + RC=0.07 CJE=3.25E-10 TF=1E-9 CJC=7E-11 TR=1E-8 ) *MPSW01A MCE 5/12/95 *Si 1W 40V 1A 210MHz pkg:TO-92 1,2,3 .MODEL QMPSW01A NPN (IS=18.1F NF=1 BF=273 VAF=113 IKF=.6 ISE=15.7P NE=2 + BR=4 NR=1 VAR=20 IKR=.9 RE=96.5M RB=.386 RC=38.6M XTB=1.5 + CJE=78.7P VJE=1.1 MJE=.5 CJC=17.3P VJC=.3 MJC=.3 TF=757P TR=526N) *BC546 ZETEX Spice model Last revision 4/90 General Purpose *ZTX Si 500mW 65V 200mA 300MHz pkg:TO-92 1,2,3 .MODEL BC546 NPN(IS=1.8E-14 BF=400 NF=0.9955 VAF=80 IKF=0.14 ISE=5E-14 + NE=1.46 BR=35.5 NR=1.005 VAR=12.5 IKR=0.03 ISC=1.72E-13 NC=1.27 RB=0.56 + RE=0.6 RC=0.25 CJE=1.3E-11 TF=6.4E-10 CJC=4E-12 VJC=0.54 TR=5.072E-8 + vce_max=65 vbe_max=6 ) .MODEL BC556 PNP( + IS=2.059E-14 + NF=1.003 + ISE=2.971E-15 + NE=1.316 + BF=227.3 + IKF=0.08719 + VAF=37.2 + NR=1.007 + ISC=1.339E-14 + NC=1.15 + BR=7.69 + IKR=0.07646 + VAR=11.42 + RB=1 + IRB=1E-06 + RBM=1 + RE=0.688 + RC=0.6437 + XTB=0 + EG=1.11 + XTI=3 + CJE=1.4E-11 + VJE=0.5912 + MJE=0.3572 + TF=7.046E-10 + XTF=4.217 + VTF=5.367 + ITF=0.1947 + PTF=0 + CJC=1.113E-11 + VJC=0.1 + MJC=0.3414 + XCJC=0.6288 + TR=1E-32 + CJS=0 + VJS=0.75 + MJS=0.333 + FC=0.7947 + vce_max=65 vbe_max=6 ) * * NXP Semiconductors * * Medium power NPN transistor * IC = 1 A * VCEO = 20 V * hFE = 85 - 375 @ 2V/500mA * * * * * Package pinning does not match Spice model pinning. * Package: SOT 223 * * Package Pin 1: Base * Package Pin 2: Collector * Package Pin 3: Emitter * Package Pin 4: Collector * * Extraction date (week/year): 13/2008 * Simulator: Spice 3 * ********************************************************** *# .SUBCKT BCP68 1 2 3 * Q1 1 2 3 BCP68 D1 2 1 DIODE * *The diode does not reflect a *physical device but improves *only modeling in the reverse *mode of operation. * .MODEL BCP68 NPN + IS = 2.312E-013 + NF = 0.988 + ISE = 8.851E-014 + NE = 2.191 + BF = 273 + IKF = 5.5 + VAF = 50 + NR = 0.9885 + ISC = 6.808E-014 + NC = 3 + BR = 155.6 + IKR = 4 + VAR = 17 + RB = 15 + IRB = 2E-006 + RBM = 0.65 + RE = 0.073 + RC = 0.073 + XTB = 0 + EG = 1.11 + XTI = 3 + CJE = 2.678E-010 + VJE = 0.732 + MJE = 0.3484 + TF = 5.8E-010 + XTF = 1.5 + VTF = 2.5 + ITF = 1 + PTF = 0 + CJC = 3.406E-011 + VJC = 2 + MJC = 0.3142 + XCJC = 1 + TR = 6.5E-009 + CJS = 0 + VJS = 0.75 + MJS = 0.333 + FC = 0.95 .MODEL DIODE D + IS = 2.702E-015 + N = 1.2 + BV = 1000 + IBV = 0.001 + RS = 0.1 + CJO = 0 + VJ = 1 + M = 0.5 + FC = 0 + TT = 0 + EG = 1.11 + XTI = 3 .ENDS .model D1N4007 D(IS=7.02767n RS=0.0341512 N=1.80803 EG=1.05743 XTI=5 BV=1000 IBV=5e-08 CJO=1e-11 VJ=0.7 M=0.5 FC=0.5 TT=1e-07 ) .MODEL D1N4148 D + IS = 4.352E-9 + N = 1.906 + BV = 110 + IBV = 0.0001 + RS = 0.6458 + CJO = 7.048E-13 + VJ = 0.869 + M = 0.03 + FC = 0.5 + TT = 3.48E-9 .MODEL D1n5400 d +IS=2.61339e-12 RS=0.0110501 N=1.20576 EG=0.6 +XTI=3.1271 BV=50 IBV=1e-05 CJO=1e-11 +VJ=0.7 M=0.5 FC=0.5 TT=1e-09 +KF=0 AF=1 * Model generated on October 12, 2003 * Model format: PSpice *1N758 *Ref: Motorola *10V 500mW Si Zener pkg:DIODE0.4 1,2 .MODEL D1N758 D(IS=1E-11 RS=8.483 N=1.27 TT=5E-8 CJO=2.334E-10 VJ=0.75 + M=0.33 BV=9.83 IBV=0.01 ) *1N4744 *Ref: Motorola *15V 1W Si Zener pkg:DIODE0.4 1,2 .MODEL D1N4744 D(IS=5.32E-14 RS=6.47 TT=5.01E-8 CJO=7.83E-11 M=0.33 + BV=14.89 IBV=0.017 ) *1N755 *Ref: Motorola *7.5V 500mW Si Zener pkg:DIODE0.4 1,2 .MODEL D1N755 D(IS=1E-11 RS=3.359 N=1.27 TT=5E-8 CJO=2.959E-10 VJ=0.75 + M=0.33 BV=7.433 IBV=0.01 ) ** node order * 1: gnd * 2: trig * 3: out * 4: reset# * 5: ctrl * 6: thres * 7: dis * 8: vcc .SUBCKT ne555 34 32 30 19 23 33 1 21 * G TR O R F TH D V Q4 25 2 3 QP Q5 34 6 3 QP Q6 6 6 8 QP R1 9 21 4.7K R2 3 21 830 R3 8 21 4.7K Q7 2 33 5 QN Q8 2 5 17 QN Q9 6 4 17 QN Q10 6 23 4 QN Q11 12 20 10 QP R4 10 21 1K Q12 22 11 12 QP Q13 14 13 12 QP Q14 34 32 11 QP Q15 14 18 13 QP R5 14 34 100K R6 22 34 100K R7 17 34 10K Q16 1 15 34 QN Q17 15 19 31 QP R8 18 23 5K R9 18 34 5K R10 21 23 5K Q18 27 20 21 QP Q19 20 20 21 QP R11 20 31 5K D1 31 24 DA Q20 24 25 34 QN Q21 25 22 34 QN Q22 27 24 34 QN R12 25 27 4.7K R13 21 29 6.8K Q23 21 29 28 QN Q24 29 27 16 QN Q25 30 26 34 QN Q26 21 28 30 QN D2 30 29 DA R14 16 15 100 R15 16 26 220 R16 16 34 4.7K R17 28 30 3.9K Q3 2 2 9 QP .MODEL DA D (RS=40 IS=1.0E-14 CJO=1PF) .MODEL QP PNP (level=1 BF=20 BR=0.02 RC=4 RB=25 IS=1.0E-14 VA=50 NE=2) + CJE=12.4P VJE=1.1 MJE=.5 CJC=4.02P VJC=.3 MJC=.3 TF=229P TR=159N) .MODEL QN NPN (level=1 IS=5.07F NF=1 BF=100 VAF=161 IKF=30M ISE=3.9P NE=2 + BR=4 NR=1 VAR=16 IKR=45M RE=1.03 RB=4.12 RC=.412 XTB=1.5 + CJE=12.4P VJE=1.1 MJE=.5 CJC=4.02P VJC=.3 MJC=.3 TF=229P TR=959P) .ENDS .SUBCKT BS250P 3 4 5 * D G S M1 3 2 5 5 MBS250 RG 4 2 160 RL 3 5 1.2E8 C1 2 5 47E-12 C2 3 2 10E-12 D1 3 5 DBS250 * .MODEL MBS250 PMOS VTO=-3.193 RS=2.041 RD=0.697 IS=1E-15 KP=0.277 +CBD=105E-12 PB=1 LAMBDA=1.2E-2 .MODEL DBS250 D IS=2E-13 RS=0.309 .ENDS BS250P .SUBCKT BS170 3 4 5 * D G S M1 3 2 5 5 N3306M RG 4 2 270 RL 3 5 1.2E8 C1 2 5 28E-12 C2 3 2 3E-12 D1 5 3 N3306D * .MODEL N3306M NMOS VTO=1.824 RS=1.572 RD=1.436 IS=1E-15 KP=.1233 +CBD=35E-12 PB=1 .MODEL N3306D D IS=5E-12 RS=.768 .ENDS BS170 * *$ .SUBCKT PTON_TOFF_U4_S1 1 2 3 4 G_Switch 3 4 VCR PWL(1) 1 2 0.2 100e6 0.8 1m RS_U4_S1 1 2 1G .ENDS PTON_TOFF_U4_S1 *$ .SUBCKT PTON_TOFF_U4_S2 1 2 3 4 G_Switch 3 4 VCR PWL(1) 1 2 0.2 100e6 0.8 1m RS_U4_S2 1 2 1G .ENDS PTON_TOFF_U4_S2 *$ .SUBCKT MTON_TOFF_U2_S2 1 2 3 4 G_Switch 3 4 VCR PWL(1) 1 2 0.2 100e6 0.8 1m RS_U2_S2 1 2 1G .ENDS MTON_TOFF_U2_S2 *$ .SUBCKT MTON_TOFF_U2_S1 1 2 3 4 G_Switch 3 4 VCR PWL(1) 1 2 0.2 100e6 0.8 1m RS_U2_S1 1 2 1G .ENDS MTON_TOFF_U2_S1 *$ ****************************** Basic Components ************************** .SUBCKT D_D1 1 2 D1 1 2 DD1 .MODEL DD1 D (IS=1e-15 Rs=0.001 N=0.1 TT=10p) .ENDS D_D1 *$ .SUBCKT BUF_BASIC_GEN A Y VDD=1 VSS=0 VTHRESH=0.5 * E_ABMGATE YINT 0 vol='V(A) > VTHRESH? VDD:VSS' E_ABMGATE YINT 0 pwl(1) A 0 'VTHRESH-0.01' VSS 'VTHRESH+0.01' VDD RINT YINT Y 1 CINT Y 0 1n .ENDS BUF_BASIC_GEN *$ .MODEL NMOS01 NMOS (VTO = 2 KP = 1.005 LAMBDA = 0.001) *$ .MODEL PMOS01 PMOS (VTO = -2 KP = 1.77 LAMBDA = 0.001) *$ .MODEL NMOS02 NMOS (VTO = 2 KP = 0.1814 LAMBDA = 0.001) *$ .MODEL PMOS02 PMOS (VTO = -2 KP = 0.2497 LAMBDA = 0.001) *$ .SUBCKT COMPHYS_BASIC_GEN INP INM HYS OUT VDD=1 VSS=0 VTHRESH=0.5 EIN INP1 INM1 INP INM 1 * EHYS INP1 INP2 vol='V(1) > VTHRESH? -V(HYS):0' EHYS INP1 INP2 pwl(1) 1 0 'VTHRESH-0.01' 0 'VTHRESH+0.01' '-V(HYS)' EOUT OUT 0 vol='V(INP2)>V(INM1)? VDD : VSS' R1 OUT 1 1 C1 1 0 5n RINP1 INP1 0 1K .ENDS COMPHYS_BASIC_GEN *$ .SUBCKT AND2_BASIC_GEN A B Y VDD=1 VSS=0 VTHRESH=0.5 E_ABMGATE YINT 0 vol= 'V(A) > VTHRESH && V(B) > VTHRESH ? VDD:VSS' RINT YINT Y 1 CINT Y 0 1n .ENDS AND2_BASIC_GEN *$ .SUBCKT NOR2_BASIC_GEN A B Y VDD=1 VSS=0 VTHRESH=0.5 E_ABMGATE YINT 0 vol= 'V(A) > VTHRESH || V(B) > VTHRESH ? VSS:VDD' RINT YINT Y 1 CINT Y 0 1n .ENDS NOR2_BASIC_GEN *$ .SUBCKT AND3_BASIC_GEN A B C Y VDD=1 VSS=0 VTHRESH=0.5 E_ABMGATE YINT 0 vol= 'V(A) > VTHRESH && V(B) > VTHRESH && V(C) > VTHRESH ? VDD:VSS' RINT YINT Y 1 CINT Y 0 1n .ENDS AND3_BASIC_GEN *$ .SUBCKT INV_BASIC_GEN A Y VDD=1 VSS=0 VTHRESH=0.5 * E_ABMGATE YINT 0 vol='V(A) > VTHRESH ? VSS : VDD' E_ABMGATE YINT 0 pwl(1) A 0 'VTHRESH-0.01' VDD 'VTHRESH+0.01' VSS RINT YINT Y 1 CINT Y 0 1n .ENDS INV_BASIC_GEN *$ .SUBCKT RVAR 101 102 201 202 RREF=1 * nodes : 101 102 : nodes between which variable resistance is placed * 201 202 : nodes to whose voltage the resistance is proportional * parameters : rref : reference value of the resistance rin 201 202 1G $$ input resistance r 301 0 rref fcopy 0 301 vsense 1 $$ copy output current thru Z eout 101 106 poly(2) 201 202 301 0 0 0 0 0 1 $$ multiply VoverZ with Vctrl vsense 106 102 0 $$ sense iout .ENDS RVAR *$ *LM317 TI voltage regulator - pin order: In, Adj, Out *TI adjustable voltage regulator pkg:TO-3 .SUBCKT LM317 1 2 3 **Changes my be required on this line** J1 1 3 4 JN Q2 5 5 6 QPL .1 Q3 5 8 9 QNL .2 Q4 8 5 7 QPL .1 Q5 81 8 3 QNL .2 Q6 3 81 10 QPL .2 Q7 12 81 13 QNL .2 Q8 10 5 11 QPL .2 Q9 14 12 10 QPL .2 Q10 16 5 17 QPL .2 Q11 16 14 15 QNL .2 Q12 3 20 16 QPL .2 Q13 1 19 20 QNL .2 Q14 19 5 18 QPL .2 Q15 3 21 19 QPL .2 Q16 21 22 16 QPL .2 Q17 21 3 24 QNL .2 Q18 22 22 16 QPL .2 Q19 22 3 241 QNL 2 Q20 3 25 16 QPL .2 Q21 25 26 3 QNL .2 Q22A 35 35 1 QPL 2 Q22B 16 35 1 QPL 2 Q23 35 16 30 QNL 2 Q24A 27 40 29 QNL .2 Q24B 27 40 28 QNL .2 Q25 1 31 41 QNL 5 Q26 1 41 32 QNL 50 D1 3 4 DZ D2 33 1 DZ D3 29 34 DZ R1 1 6 310 R2 1 7 310 R3 1 11 190 R4 1 17 82 R5 1 18 5.6K R6 4 8 100K R7 8 81 130 R8 10 12 12.4K R9 9 3 180 R10 13 3 4.1K R11 14 3 5.8K R12 15 3 72 R13 20 3 5.1K R14 2 24 12K R15 24 241 2.4K R16 16 25 6.7K R17 16 40 12K R18 30 41 130 R19 16 31 370 R20 26 27 13K R21 27 40 400 R22 3 41 160 R23 33 34 18K R24 28 29 160 R25 28 32 3 R26 32 3 .1 C1 21 3 30PF C2 21 2 30PF C3 25 26 5PF CBS1 5 3 2PF CBS2 35 3 1PF CBS3 22 3 1PF .MODEL JN NJF(BETA=1E-4 VTO=-7) .MODEL DZ D(BV=6.3) .MODEL QNL NPN(EG=1.22 BF=80 RB=100 CCS=1.5PF TF=.3NS TR=6NS CJE=2PF + CJC=1PF VAF=100) .MODEL QPL PNP(BF=40 RB=20 TF=.6NS TR=10NS CJE=1.5PF CJC=1PF VAF=50) .ENDS .SUBCKT xxxxLM317 1 3 2 * IN ADJ OUT IADJ 1 4 50U VREF 4 3 1.25 RC 1 14 0.742 DBK 14 13 D1 CBC 13 15 2.479N RBC 15 5 247 QP 13 5 2 Q1 RB2 6 5 124 DSC 6 11 D1 ESC 11 2 POLY(2) (13,5) (6,5) 2.85 + 0 0 0 -70.1M DFB 6 12 D1 EFB 12 2 POLY(2) (13,5) (6,5) 3.92 + -135M 0 1.21M -70.1M RB1 7 6 1 EB 7 2 8 2 2.56 CPZ 10 2 0.796U DPU 10 2 D1 RZ 8 10 0.104 RP 9 8 100 EP 9 2 4 2 103.6 RI 2 4 100MEG .MODEL Q1 NPN (IS=30F BF=100 + VAF=14.27 NF=1.604) .MODEL D1 D (IS=30F N=1.604) .ENDS .SUBCKT LM337 8 1 19 *Connections Input Adj. Output *LM337 negative voltage regulator .MODEL QN NPN (BF=50 TF=1N CJC=1P) .MODEL QPOUT PNP (BF=50 TF=1N RE=.2 CJC=1P) .MODEL QP PNP CJC=1P TF=2N .MODEL DN D .MODEL D2 D BV=12 IBV=100U R10 25 6 1K Q3 8 17 16 QPOUT Q4 8 25 17 QP R18 19 17 250 R19 19 16 .3 G1 8 6 1 18 .1 C7 6 2 .04U R24 2 8 100 I_ADJ 0 1 65U R26 8 25 200K Q5 25 4 19 QP R27 16 4 200 R28 7 4 7K D1 8 7 D2 D2 8 6 DN V1 18 19 1.25 .ENDS "} xschem-2.8.1/xschem_library/examples/dlatch.sym0000644000175100017510000000123113023243556020033 0ustar svnsvnG {type=subcircuit format="@name @pinlist @symname VTH=@VTH VHI=@VHI" template="name=x1 VTH=1.5 VHI=3.0" } V {} S {} L 4 -70 -20 70 -20 {} L 4 -70 40 70 40 {} L 4 -70 -20 -70 40 {} L 4 70 -20 70 40 {} L 4 -90 -10 -70 -10 {} L 4 70 -10 90 -10 {} L 4 -90 10 -70 10 {} L 4 -90 30 -70 30 {} B 5 -92.5 -12.5 -87.5 -7.5 {name=D dir=in } B 5 87.5 -12.5 92.5 -7.5 {name=Q dir=out } B 5 -92.5 7.5 -87.5 12.5 {name=G dir=in } B 5 -92.5 27.5 -87.5 32.5 {name=VSS dir=in } T {@symname} -31.5 -6 0 0 0.3 0.3 {} T {@name} 75 -32 0 0 0.2 0.2 {} T {D} -65 -14 0 0 0.2 0.2 {} T {Q} 65 -14 0 1 0.2 0.2 {} T {G} -65 6 0 0 0.2 0.2 {} T {VSS} -65 26 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/poweramp.sym0000644000175100017510000000042113023243556020426 0ustar svnsvnG {type=subcircuit format="@name @pinlist @symname" verilog_stop=true template="name=x1" } V {} S {} L 4 -130 -10 130 -10 {} L 4 -130 10 130 10 {} L 4 -130 -10 -130 10 {} L 4 130 -10 130 10 {} T {@symname} -58.5 -6 0 0 0.3 0.3 {} T {@name} 135 -22 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/buck.sch0000644000175100017510000001520713362731551017500 0ustar svnsvnG {} V {} S {} E {} T {PARAX} 680 -190 0 0 0.5 0.5 {} T {PARAX} 800 -310 0 0 0.5 0.5 {} N 930 -140 1010 -140 {lab=VSS} N 580 -270 730 -270 {lab=A} N 660 -140 930 -140 {lab=VSS} N 1010 -270 1110 -270 {lab=VOUT} N 290 -270 390 -270 {lab=VCC} N 450 -270 520 -270 {lab=#net1} N 120 -850 220 -850 {lab=CTRL} N 220 -850 360 -850 {lab=CTRL} N 290 -870 290 -850 {lab=CTRL} N 250 -480 390 -480 {lab=VREF} N 870 -610 870 -530 {lab=FB} N 840 -610 910 -610 {lab=FB} N 970 -610 1080 -610 {lab=SW} N 1080 -610 1080 -490 {lab=SW} N 660 -150 660 -140 {lab=VSS} N 930 -210 930 -140 {lab=VSS} N 1010 -210 1010 -140 {lab=VSS} N 850 -270 1010 -270 {lab=VOUT} N 690 -280 690 -270 {lab=A} N 890 -630 890 -610 {lab=FB} N 1200 -750 1200 -730 {lab=VSS} N 1200 -830 1200 -810 {lab=HYST} N 1100 -800 1160 -800 {lab=HYSTD} N 1060 -890 1120 -890 {lab=HYSTD} N 1180 -890 1200 -890 {lab=HYST} N 1200 -890 1200 -830 {lab=HYST} N 900 -1150 1000 -1150 {lab=CTRL2} N 1610 -490 1610 -430 {lab=#net2} N 1610 -630 1610 -550 {lab=#net3} N 1610 -640 1610 -630 {lab=#net3} N 1610 -460 1740 -460 {lab=#net2} N 1340 -600 1610 -600 {lab=#net3} N 1340 -600 1340 -430 {lab=#net3} N 1610 -670 1740 -670 {lab=#net3} N 1610 -670 1610 -640 {lab=#net3} N 1800 -670 1840 -670 {lab=CAP2} N 1840 -670 1840 -460 {lab=CAP2} N 1800 -460 1840 -460 {lab=CAP2} N 1940 -460 1940 -420 {lab=CAP2} N 1840 -460 1940 -460 {lab=CAP2} C {library_t9/micron} 170 -10 0 0 {name=l3 author="Stefan Schippers"} C {devices/code} 30 -190 0 0 {name=STIMULI value=" ** eldo *.OPTION EPS=1e-6 SMOOTH AMMETER ** model hspice 1.5 * .lib '/home/schippes/hspice/pcm100s_1.5/PCM100s_1.5.lib' ssss ** model hspice 1.5b * .lib '/home/schippes/hspice/pcm100s_1.5b/PCM100s_1.5.lib' ssss * .lib '/home/schippes/hspice/pcm100s_1.5b/pcm100s_1.5_ic.lib' typ ** model hspice 1.6 * .lib '/home/schippes/hspice/pcm100s_1.6/PCM100s_1.6.lib' ssss * .lib \\"./model_100s_1.6_montecarlo\\" ttttt ** model hspice 1.9.2 * .lib '/home/schippes/hspice/pcm100s_1.9.2/pcm100s_1.9.2.lib' ssss * .lib \\"./model_100s_1.9.2_montecarlo\\" ttttt * .lib \\"./model_100s_1.9.2_naox_montecarlo\\" ttttt * .lib \\"./model_100s_1.9.2_paox_montecarlo\\" ttttt ** model hspice 2.0.0_stef * .lib /home/schippes/hspice/pcm100s_2.0.0/mlib ss ** model hspice 2.0.0 .... ss, tt, ff, ss_spec ff_spec * .lib /home/schippes/hspice/pcm100s_2.0.0/mlib ss ** model hspice 2.3.1 .... ss, tt, ff, ss_spec ff_spec *.lib /home/schippes/hspice/pcm100s_2.3.1/mlib ss .param VCC=24 .temp 25 * hspice .option post captab RUNLVL=5 $ probe .OPTION METHOD=GEAR vvss vss 0 0 vvcc vcc 0 VCC pwl 0 0 100u VCC * .check setup ( C rise 800p fall ) B ( VCC 0 'VCC/2' 'VCC/2' ) * .include stimuli.cir .probe tran i1(r1) .probe tran i1(l1) *.op ALL 4n *.dc vvcc 0 2 0.1 .tran 0.05m 80m uic $$ sweep monte=list 4" } C {pcm100s/ideal_switch_hsp} 550 -270 0 0 {name=x1 V_TO_R=1G MIN=1 MAX=1G VCTRL=1.8 m=1} C {pcm100s/ideal_diode_hsp} 660 -240 2 0 {name=x2 VON=0.5} C {devices/ind} 760 -270 3 0 {name=l1 value=10u} C {devices/capa} 930 -240 0 0 {name=c1 m=1 value=100u} C {devices/res} 1010 -240 0 0 {name=r1 m=1 value=40} C {devices/lab_pin} 660 -140 0 0 {name=p1 lab=VSS} C {devices/lab_pin} 1110 -270 0 1 {name=p2 lab=VOUT} C {devices/lab_pin} 290 -270 0 0 {name=p3 lab=VCC} C {devices/lab_pin} 550 -310 0 0 {name=p4 lab=SW} C {devices/vsource} 420 -270 3 0 {name=vsupply value=0} C {devices/lab_pin} 560 -850 0 1 {name=p1166 lab=F1} C {devices/lab_pin} 560 -830 0 1 {name=p1167 lab=F2} C {devices/lab_pin} 560 -810 0 1 {name=p1183 lab=F1N} C {devices/lab_pin} 560 -790 0 1 {name=p1184 lab=F2N} C {devices/vsource} 120 -820 0 0 {name=v1 value="pwl 0 0 10u 1.5"} C {devices/lab_pin} 120 -790 0 0 {name=p6 lab=VSS} C {devices/lab_pin} 290 -870 0 0 {name=p8 lab=CTRL} C {pcm100s/ideal_vco_phasegen_hsp} 460 -820 0 0 {name=x3 V_TO_FREQ=100K MIN=0 MAX=VCC} C {devices/lab_pin} 560 -770 0 1 {name=p5 lab=CAP} C {library_t9/ampli_ideale_hsp} 470 -520 0 0 {name=x453 offset=0.0 gain=500 vmin="0" vmax="VCC" rout=0.01 rc=1e-6} C {devices/vsource} 250 -450 0 0 {name=v2 value="pwl 0 0 10u 10"} C {devices/lab_pin} 250 -420 0 0 {name=p0 lab=VSS} C {devices/lab_pin} 250 -480 0 0 {name=p7 lab=VREF} C {devices/lab_pin} 390 -560 0 0 {name=p9 lab=VOUT} C {library_t9/ampli_ideale_hsp} 950 -490 0 0 {name=x4 offset=0.0 gain=5000 vmin="0" vmax="VCC" rout=0.01 rc=1e-11} C {devices/lab_pin} 780 -610 0 0 {name=p10 lab=CAP} C {devices/lab_pin} 600 -520 0 1 {name=p11 lab=PWMCTRL} C {devices/lab_pin} 870 -450 0 0 {name=p12 lab=PWMCTRL} C {devices/lab_pin} 1080 -490 0 1 {name=p13 lab=SW} C {devices/res} 810 -610 1 1 {name=r2 m=1 value=100K} C {devices/res} 940 -610 1 1 {name=r3 m=1 value=600K} C {devices/res} 820 -270 1 0 {name=r4 m=1 value=2} C {devices/res} 660 -180 2 0 {name=r5 m=1 value=5} C {devices/lab_pin} 690 -280 0 0 {name=p14 lab=A} C {devices/lab_pin} 890 -630 0 0 {name=p15 lab=FB} C {devices/vcvs} 1200 -780 0 0 {name=e1 value="100 MAX=VCC MIN=0"} C {devices/lab_pin} 1200 -730 0 0 {name=p16 lab=VSS} C {devices/lab_pin} 950 -980 0 0 {name=p17 lab=VSS} C {devices/lab_pin} 1160 -760 0 0 {name=p21 lab=CAP2} C {devices/lab_pin} 1200 -830 0 1 {name=p22 lab=HYST} C {devices/vsource} 950 -1010 0 0 {name=v3 value="pwl 0 0 10u 12"} C {devices/lab_pin} 950 -1040 0 0 {name=p24 lab=REF2} C {devices/lab_pin} 1060 -890 0 0 {name=p27 lab=HYSTD} C {devices/capa} 1060 -860 0 0 {name=c3 m=1 value=100f} C {devices/res} 1150 -890 1 1 {name=r6 m=1 value=3000} C {devices/lab_pin} 1060 -830 0 0 {name=p23 lab=VSS} C {devices/lab_pin} 1100 -800 0 0 {name=p28 lab=HYSTD} C {devices/vsource} 900 -1120 0 0 {name=v4 value="pwl 0 0 1000u 12"} C {devices/lab_pin} 900 -1090 0 0 {name=p29 lab=VSS} C {devices/lab_pin} 1000 -1150 0 1 {name=p31 lab=CTRL2} C {devices/switch_hsp} 1610 -400 0 0 {name=g1 v_to_r=2G max=10G min=0.1 m=1} C {devices/isource_arith} 1610 -520 0 0 {name=Gp value="1e-3*v(ctrl2)" } C {devices/switch_hsp} 1770 -460 1 0 {name=g2 v_to_r=2G max=10G min=0.1 m=1} C {devices/switch_hsp} 1770 -670 1 0 {name=g3 v_to_r=2G max=10G min=0.1 m=1} C {devices/switch_hsp} 1340 -400 0 0 {name=g4 v_to_r=2G max=10G min=0.1 m=1} C {devices/lab_pin} 1340 -370 0 0 {name=p30 lab=VSS} C {devices/lab_pin} 1610 -370 0 0 {name=p32 lab=VSS} C {devices/lab_pin} 1380 -400 0 1 {name=p33 lab=HYST} C {devices/lab_pin} 1770 -420 0 1 {name=p34 lab=HYST} C {devices/lab_pin} 1570 -400 0 0 {name=p35 lab=HYST} C {devices/lab_pin} 1770 -710 0 0 {name=p36 lab=HYST} C {devices/lab_pin} 1300 -400 0 0 {name=p37 lab=REF2} C {devices/lab_pin} 1770 -630 0 1 {name=p38 lab=REF2} C {devices/lab_pin} 1770 -500 0 1 {name=p39 lab=REF2} C {devices/lab_pin} 1650 -400 0 1 {name=p40 lab=REF2} C {devices/capa} 1940 -390 0 0 {name=c4 m=1 value=1n} C {devices/lab_pin} 1940 -360 0 0 {name=p41 lab=VSS} C {devices/lab_pin} 1940 -440 0 1 {name=p42 lab=CAP2} xschem-2.8.1/xschem_library/examples/xnor.sym0000644000175100017510000000140513362731551017570 0ustar svnsvnG {type=xnor verilog_format="xnor #(@risedel , @falldel ) @name ( @#0 , @#1 , @#2 );" template="name=x1 risedel=100 falldel=200" } V {} S {} E {} L 4 45 0 60 0 {} L 4 -40 -20 -26.875 -20 {} L 4 -40 20 -26.875 20 {} L 4 -25 -30 -5 -30 {} L 4 -25 30 -5 30 {} B 5 57.5 -2.5 62.5 2.5 {name=Z dir=out verilog_type=wire} B 5 -42.5 -22.5 -37.5 -17.5 {name=A dir=in} B 5 -42.5 17.5 -37.5 22.5 {name=B dir=in} A 4 40 0 5 180 360 {} A 4 -9.642857142857142 17.85714285714286 48.0818286351295 21.80140948635181 62.65738573560834 {} A 4 -4.6875 -11.25 41.25118369513777 269.5659493678606 74.60789655596687 {} A 4 -65 0 50 323.130102354156 73.7397952916881 {} A 4 -72.5 0 50 323.130102354156 73.7397952916881 {} T {@symname} -12.5 -12.5 0 0 0.2 0.2 {} T {@name} -12.5 2.5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/switch_rreal.sym0000644000175100017510000000117313161011201021246 0ustar svnsvnG {type=subcircuit format="@name @pinlist @symname" template="name=x1 del=\\"2 ns\\"" generic_type="del=time"} V {} S {} L 4 -130 -20 130 -20 {} L 4 -130 20 130 20 {} L 4 -130 -20 -130 20 {} L 4 130 -20 130 20 {} L 4 -150 10 -130 10 {} L 4 150 -10 130 -10 {} L 4 -150 -10 -130 -10 {} B 5 -152.5 7.5 -147.5 12.5 {name=ENAB dir=in } B 5 147.5 -12.5 152.5 -7.5 {name=B sig_type=rreal dir=inout } B 5 -152.5 -12.5 -147.5 -7.5 {name=A sig_type=rreal dir=inout } T {@symname} -49.5 -6 0 0 0.3 0.3 {} T {@name} 135 -32 0 0 0.2 0.2 {} T {ENAB} -125 6 0 0 0.2 0.2 {} T {B} 125 -14 0 1 0.2 0.2 {} T {A} -125 -14 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/LM5134A.sym0000644000175100017510000000171613023243556017532 0ustar svnsvnG {type=primitive format="@name @pinlist @symname" template="name=x1" } V {} S {} L 4 -60 130 60 130 {} L 4 -60 -130 -60 130 {} L 4 60 -130 60 130 {} L 4 -80 -120 -60 -120 {} L 4 60 -120 80 -120 {} L 4 -80 0 -60 0 {} L 4 60 0 80 0 {} L 4 60 120 80 120 {} L 4 -80 120 -60 120 {} L 4 -60 -130 -20 -130 {} L 4 -20 -130 -10 -120 {} L 4 -10 -120 10 -120 {} L 4 10 -120 20 -130 {} L 4 20 -130 60 -130 {} B 5 -82.5 -122.5 -77.5 -117.5 {name=VDD dir=inout } B 5 -82.5 -2.5 -77.5 2.5 {name=PILOT dir=inout } B 5 -82.5 117.5 -77.5 122.5 {name=OUT dir=inout } B 5 77.5 -122.5 82.5 -117.5 {name=IN dir=inout } B 5 77.5 -2.5 82.5 2.5 {name=INB dir=inout } B 5 77.5 117.5 82.5 122.5 {name=VSS dir=inout } T {@symname} -27 14 0 0 0.3 0.3 {} T {@name} 65 -142 0 0 0.2 0.2 {} T {VDD} -55 -124 0 0 0.2 0.2 {} T {IN} 55 -124 0 1 0.2 0.2 {} T {PILOT} -55 -4 0 0 0.2 0.2 {} T {INB} 55 -4 0 1 0.2 0.2 {} T {VSS} 55 116 0 1 0.2 0.2 {} T {OUT} -55 116 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/pcb_test1.sym0000644000175100017510000000042413357507037020472 0ustar svnsvnG {type=subcircuit format="@name @pinlist @symname" verilog_stop=true template="name=x1" } V {} S {} E {} L 4 -130 -10 130 -10 {} L 4 -130 10 130 10 {} L 4 -130 -10 -130 10 {} L 4 130 -10 130 10 {} T {@symname} -58.5 -6 0 0 0.3 0.3 {} T {@name} 135 -22 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/osc.sym0000644000175100017510000000042113023243556017360 0ustar svnsvnG {type=subcircuit format="@name @pinlist @symname" verilog_stop=true template="name=x1" } V {} S {} L 4 -130 -10 130 -10 {} L 4 -130 10 130 10 {} L 4 -130 -10 -130 10 {} L 4 130 -10 130 10 {} T {@symname} -58.5 -6 0 0 0.3 0.3 {} T {@name} 135 -22 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/diode.sym0000644000175100017510000000062413023243556017665 0ustar svnsvnG {type=subcircuit format="@name @pinlist @symname VTH=@VTH RON=@RON ROFF=@ROFF" template="name=x1 VTH=0.6 RON=10 ROFF=1G" } V {} S {} L 4 0 5 0 30 {} L 4 0 -30 0 -5 {} L 4 -10 5 10 5 {} L 4 0 5 10 -5 {} L 4 -10 -5 10 -5 {} L 4 -10 -5 0 5 {} B 5 -2.5 -32.5 2.5 -27.5 {name=p dir=inout} B 5 -2.5 27.5 2.5 32.5 {name=m dir=inout} T {@name} 5 -22 0 0 0.2 0.2 {} T {VTH=@VTH} 5 8 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/loading.sch0000644000175100017510000002456013232362134020164 0ustar svnsvnG {} V {// test} S {* test} T {rrreal type: ----------- rreal is a record type containing voltage value, drive strength and capacitive loading of an electrical node. rrreal is a resolved subtype of rreal. The resolution function invoked by the simulator updates voltages, strengths and capacitive loading of all nodes. this allows to simulate voltage transients, charge sharing, floating conditions and more. the example uses bidirectional analog switches and simulates charge pumps which have a finite driving capability (output impedance)} 10 -410 0 0 0.3 0.3 {} T {VHDL DESIGN EXAMPLE} 140 -1290 0 0 1 1 {} T {set netlist mode to VHDL - create netlist - simulate with ghdl - view waveforms} 110 -1200 0 0 0.6 0.6 {} N 830 -680 900 -680 {lab=VXS} N 450 -680 510 -680 {lab=VX} N 450 -680 450 -570 {lab=VX} N 1230 -680 1240 -680 {lab=SP} N 340 -680 450 -680 {lab=VX} N 830 -680 830 -570 {lab=VXS} N 1230 -680 1230 -570 {lab=SP} N 470 -800 480 -800 {lab=VX2} N 810 -800 810 -680 {lab=VXS} N 780 -800 810 -800 {lab=VXS} N 350 -910 470 -910 {lab=VX2} N 470 -910 470 -800 {lab=VX2} N 810 -680 830 -680 {lab=VXS} N 1200 -680 1230 -680 {lab=SP} N 340 -800 470 -800 {lab=VX2} C {devices/code} 600 -200 0 0 {name=CODE vhdl_ignore=false value=" -- these assignments are done to have the voltage values available -- in the waveform file V_VX <= VX.value; V_VX2 <= VX2.value; V_VXS <= VXS.value; V_SP <= SP.value; process begin ING<='0'; ING1<='0'; SW <= '0'; SW1<='0'; SW2<='0'; --VX <= rreal'(4.5,10.0,0.0); --VX2 <= rreal'(3.0, 5.0, 0.0); wait for 200 ns; ING1<='1'; wait for 200 ns; ING<='1'; wait for 200 ns; SW<='1'; wait for 200 ns; SW2<='1'; wait for 200 ns; SW1<='1'; wait for 200 ns; SW1<='0'; wait for 200 ns; SW2<='0'; wait for 200 ns; SW1<='1'; wait for 200 ns; SW<='1'; wait for 200 ns; ING <='0'; wait for 200 ns; SW1<= '0'; wait for 200 ns; SW<='1'; wait for 200 ns; ING<='1'; wait for 200 ns; SW <= '0'; wait for 200 ns; SW1<= '1'; wait for 200 ns; ING<='1'; wait for 200 ns; SW<='0'; wait for 200 ns; SW1<='0'; wait for 200 ns; SW<='1'; wait for 200 ns; SW1<='1'; wait for 200 ns; SW1<='0'; wait for 200 ns; SW1<='1'; wait for 200 ns; wait; end process; " } C {devices/use} 840 -220 0 0 {library ieee; use std.TEXTIO.all; use ieee.std_logic_1164.all; library work; use work.rrreal.all; } C {examples/pump} 250 -680 0 0 {name=x4 conduct="1.0/20000.0" val=4.5} C {devices/lab_pin} 150 -680 0 0 {name=l4 lab=ING} C {examples/switch_rreal} 660 -670 0 0 {name=x5 del="2 ns"} C {devices/lab_pin} 510 -660 0 0 {name=l5 lab=SW} C {examples/real_capa} 450 -540 0 0 {name=x3 cap=30.0} C {examples/real_capa} 830 -540 0 0 {name=x1 cap=100.0} C {examples/switch_rreal} 1050 -670 0 0 {name=x2 del="2 ns"} C {devices/lab_pin} 900 -660 0 0 {name=l2 lab=SW1} C {devices/lab_pin} 1240 -680 0 1 {name=l3 lab=SP sig_type=rrreal} C {examples/real_capa} 1230 -540 0 0 {name=x6 cap=20.0} C {devices/lab_wire} 860 -680 0 1 {name=l6 lab=VXS sig_type=rrreal } C {examples/pump} 250 -800 0 0 {name=x7 conduct="1.0/40000.0" val=3.0} C {devices/lab_pin} 150 -800 0 0 {name=l7 lab=ING1} C {examples/switch_rreal} 630 -790 0 0 {name=x8 del="2 ns"} C {devices/lab_pin} 480 -780 0 0 {name=l0 lab=SW2} C {devices/lab_wire} 400 -800 0 1 {name=l8 lab=VX2 sig_type=rrreal } C {examples/real_capa} 350 -880 0 0 {name=x9 cap=40.0} C {devices/package_not_shown} 830 -340 0 0 { library ieee, std; use std.textio.all; package rrreal is type rreal is record value : real; conduct : real; cap : real; end record; type rreal_vector is array (natural range <>) of rreal; function resolved_real( r: rreal_vector ) return rreal; procedure print(s : in string); subtype rrreal is resolved_real rreal; type rrreal_vector is array (natural range <>) of rrreal; CONSTANT RREAL_X : rreal := rreal'(value=> 0.0, cap=>0.0, conduct=>-1.0); CONSTANT RREAL_Z : rreal := rreal'(value=> 0.0, cap=>0.0, conduct=>0.0); CONSTANT RREAL_0 : rreal := rreal'(value=> 0.0, cap=>0.0, conduct=>10.0); CONSTANT REAL_Z : real := 20.0; CONSTANT REAL_X : real := 20.0; procedure transition( signal sig: INOUT rreal; constant endval: IN real; constant del: IN time ); procedure glitch( signal sig: INOUT rreal; constant lowval: IN real; constant endval: IN real; constant del: IN time ); end rrreal; -- end package declaration package body rrreal is procedure print(s : in string) is variable outbuf: line; begin write(outbuf, s); writeline(output, outbuf); end procedure; -- function resolved_real( r:rreal_vector) return rreal is -- VARIABLE result : rreal := RREAL_Z; -- begin -- IF (r'LENGTH = 1) THEN RETURN r(r'LOW); -- ELSE -- FOR i IN r'RANGE LOOP -- result.cap := result.cap + r(i).cap ; -- IF r(i).value /=REAL_Z THEN -- IF result.value /=REAL_Z THEN -- result.value := REAL_X ; -- ELSE -- result.value := r(i).value ; -- END IF; -- END IF ; -- END LOOP; -- END IF; -- RETURN result; -- end resolved_real; function resolved_real( r:rreal_vector) return rreal is VARIABLE result : rreal := RREAL_Z; variable vcapshare : real := 0.0; begin IF (r'LENGTH = 1) THEN RETURN r(r'LOW); ELSE FOR i IN r'RANGE LOOP if r(i).conduct = -1.0 then result := RREAL_X; exit; end if; -- only process initialized (valid) data if r(i).value > -30.0 and r(i).value < 30.0 then if r(i).cap > -1.0e12 and r(i).cap < 1.0e12 then if r(i).conduct > -1.0e12 and r(i).conduct < 1.0e12 then vcapshare := vcapshare + r(i).value * r(i).cap; result.value := result.value + r(i).value * r(i).conduct; result.cap := result.cap + r(i).cap ; if(r(i).conduct > 0.0 ) then -- result.conduct := result.conduct + 1.0/r(i).conduct ; result.conduct := result.conduct + r(i).conduct ; end if; end if; end if; end if; END LOOP; END IF; if result.conduct /= 0.0 then result.value := result.value / result.conduct ; -- conductance -- result.value := result.value * result.conduct ; -- resistance -- result.conduct := 1.0 / result.conduct; elsif result.cap >0.0 then result.value := vcapshare / result.cap; else result.value:=0.0; end if; RETURN result; end resolved_real; procedure transition( signal sig: INOUT rreal; constant endval: IN real; constant del: IN time) is variable step: real; variable startval: real; variable del2: time; begin del2 := del; if del2 = 0 fs then del2 := 1 ns; end if; startval := sig.value; step := (endval-startval); if abs(endval-startval) < 0.01 then --do not propagate events if endval very close to startval return; end if; -- sig.value <= endval after del; sig.value <= startval, startval+0.25*step after del2*0.1, startval+0.45*step after del2*0.2, startval+0.60*step after del2*0.3, startval+0.72*step after del2*0.4, startval+0.80*step after del2*0.5, startval+0.86*step after del2*0.6, startval+0.90*step after del2*0.7, startval+0.94*step after del2*0.8, startval+0.97*step after del2*0.9, endval after del2; end transition; procedure glitch( signal sig: INOUT rreal; constant lowval: IN real; constant endval: IN real; constant del: IN time) is variable step: real; variable step2: real; variable startval: real; variable del2 : time; begin del2 := del; if del2 = 0 fs then del2 := 1 ns; end if; startval := sig.value; step := (lowval-startval); step2 := (lowval-endval); if abs(lowval-startval) < 0.01 then --do not propagate events if endval very close to startval return; end if; sig.value <= -- startval, -- startval+0.25*step after del*0.05, -- startval+0.45*step after del*0.1, -- startval+0.60*step after del*0.15, -- startval+0.72*step after del*0.2, -- startval+0.80*step after del*0.25, -- startval+0.86*step after del*0.3, -- startval+0.90*step after del*0.35, -- startval+0.94*step after del*0.4, -- startval+0.97*step after del*0.45, -- lowval after del*0.5, -- lowval-0.25*step2 after del*0.55, -- lowval-0.45*step2 after del*0.6, -- lowval-0.60*step2 after del*0.65, -- lowval-0.72*step2 after del*0.7, -- lowval-0.80*step2 after del*0.75, -- lowval-0.86*step2 after del*0.8, -- lowval-0.90*step2 after del*0.85, -- lowval-0.94*step2 after del*0.9, -- lowval-0.97*step2 after del*0.95, -- endval after del; lowval, lowval-0.25*step2 after del2*0.1, lowval-0.45*step2 after del2*0.2, lowval-0.60*step2 after del2*0.3, lowval-0.72*step2 after del2*0.4, lowval-0.80*step2 after del2*0.5, lowval-0.86*step2 after del2*0.6, lowval-0.90*step2 after del2*0.7, lowval-0.94*step2 after del2*0.8, lowval-0.97*step2 after del2*0.9, endval after del2; end glitch; end rrreal; -- end package body } C {devices/title} 160 -40 0 0 {name=l9 author="Stefan Schippers"} C {devices/arch_declarations} 830 -280 0 0 { signal V_VX, V_VX2, V_VXS, V_SP: real; } C {devices/lab_wire} 430 -680 0 1 {name=l1 lab=VX sig_type=rrreal } xschem-2.8.1/xschem_library/examples/pump.sym0000644000175100017510000000114213161011201017535 0ustar svnsvnG {type=subcircuit format="@name @pinlist @symname" template="name=x1 val=4.5 conduct=10.0" generic_type="conduct=real val=real"} V {} L 4 -80 -10 70 -10 {} L 4 -80 10 70 10 {} L 4 -80 -10 -80 10 {} L 4 70 -10 70 10 {} L 4 70 0 90 0 {} L 4 -100 0 -80 0 {} B 5 87.5 -2.5 92.5 2.5 {name=USC sig_type=rreal verilog_type=wire dir=inout } B 5 -102.5 -2.5 -97.5 2.5 {name=ING sig_type=std_logic verilog_type=wire dir=in } T {@symname} -45 -6 0 0 0.3 0.3 {} T {@name} 75 -22 0 0 0.2 0.2 {} T {USC} 65 -4 0 1 0.2 0.2 {} T {ING} -75 -4 0 0 0.2 0.2 {} T {conduct=@conduct val=@val} -65 -36 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/cmos_example.sch0000644000175100017510000001677313232362134021232 0ustar svnsvnG {} V {} S {} T {CMOS DIFFERENTIAL AMPLIFIER EXAMPLE} 810 -570 0 0 0.4 0.4 {} N 60 -240 60 -210 {lab=VCC} N 60 -240 90 -240 {lab=VCC} N 240 -260 240 -210 {lab=GN} N 240 -210 280 -210 {lab=GN} N 280 -210 280 -180 {lab=GN} N 280 -180 460 -180 {lab=GN} N 500 -250 500 -210 {lab=SN} N 430 -280 450 -280 {lab=0} N 550 -280 570 -280 {lab=0} N 430 -250 570 -250 {lab=SN} N 370 -280 390 -280 {lab=PLUS} N 610 -280 630 -280 {lab=MINUS} N 570 -430 590 -430 {lab=VCC} N 410 -430 430 -430 {lab=VCC} N 470 -430 530 -430 {lab=GP} N 470 -430 470 -400 {lab=GP} N 430 -400 470 -400 {lab=GP} N 430 -400 430 -310 {lab=GP} N 570 -400 570 -310 {lab=DIFFOUT} N 570 -500 570 -460 {lab=VCC} N 430 -500 570 -500 {lab=VCC} N 430 -500 430 -460 {lab=VCC} N 500 -520 500 -500 {lab=VCC} N 570 -360 690 -360 {lab=DIFFOUT} N 60 -370 60 -340 {lab=PLUS} N 60 -370 90 -370 {lab=PLUS} N 60 -520 60 -490 {lab=MINUS} N 60 -520 90 -520 {lab=MINUS} N 500 -150 500 -120 {} N 500 -150 520 -150 {} N 520 -180 520 -150 {} N 500 -180 520 -180 {} N 240 -150 240 -120 {} N 220 -150 240 -150 {} N 220 -180 220 -150 {} N 220 -180 240 -180 {} C {devices/code} 870 -190 0 0 {name=STIMULI only_toplevel=true value=".option PARHIER=LOCAL RUNLVL=6 post MODMONTE=1 warn maxwarns=400 .option sampling_method = SRS .option method=gear .temp 30 .dc VPLUS 1.3 1.7 0.001 .probe i(*) "} C {devices/lab_pin} 60 -150 0 0 {name=p17 lab=0} C {devices/title} 160 -30 0 0 {name=l1 author="Stefan Schippers"} C {devices/code} 1010 -190 0 0 {name=MOSIS_MODELS value=" * hdif = 0.5e-6 .MODEL CMOSN NMOS ( +LEVEL = 49 acm = 3 +VERSION = 3.1 TNOM = 27 TOX = 7.7E-9 +XJ = 1E-7 NCH = 2.3579E17 VTH0 = 0.5048265 +K1 = 0.5542796 K2 = 0.0155863 K3 = 2.3475646 +K3B = -3.3142916 W0 = 4.145888E-5 NLX = 1.430868E-7 +DVT0W = 0 DVT1W = 0 DVT2W = 0 +DVT0 = -0.0150839 DVT1 = 1.51022E-3 DVT2 = 0.170688 +U0 = 415.8570638 UA = 5.057324E-11 UB = 1.496793E-18 +UC = 2.986268E-11 VSAT = 1.237033E5 A0 = 0.9098788 +AGS = 0.2120181 B0 = 1.683612E-6 B1 = 5E-6 +KETA = -4.011887E-4 A1 = 0 A2 = 1 +RDSW = 1.156967E3 PRWG = -8.468558E-3 PRWB = -7.678669E-3 +WR = 1 WINT = 5.621821E-8 LINT = 1.606205E-8 +XL = -2E-8 XW = 0 DWG = -6.450939E-9 +DWB = 6.530228E-9 VOFF = -0.1259348 NFACTOR = 0.3344887 +CIT = 0 CDSC = 1.527511E-3 CDSCD = 0 +CDSCB = 0 ETA0 = 1.21138E-3 ETAB = -1.520242E-4 +DSUB = 0.1259886 PCLM = 0.8254768 PDIBLC1 = 0.4211084 +PDIBLC2 = 6.081164E-3 PDIBLCB = -5.865856E-6 DROUT = 0.7022263 +PSCBE1 = 7.238634E9 PSCBE2 = 5E-10 PVAG = 0.6261655 +DELTA = 0.01 MOBMOD = 1 PRT = 0 +UTE = -1.5 KT1 = -0.11 KT1L = 0 +KT2 = 0.022 UA1 = 4.31E-9 UB1 = -7.61E-18 +UC1 = -5.6E-11 AT = 3.3E4 WL = 0 +WLN = 1 WW = -1.22182E-15 WWN = 1.137 +WWL = 0 LL = 0 LLN = 1 +LW = 0 LWN = 1 LWL = 0 +CAPMOD = 2 XPART = 0.4 CGDO = 1.96E-10 +CGSO = 1.96E-10 CGBO = 0 CJ = 8.829973E-4 +PB = 0.7946332 MJ = 0.3539285 CJSW = 2.992362E-10 +PBSW = 0.9890846 MJSW = 0.1871372 PVTH0 = -0.0148617 +PRDSW = -114.7860236 PK2 = -5.151187E-3 WKETA = 5.687313E-3 +LKETA = -0.018518 ) * * hdif = 0.5e-6 .MODEL CMOSP PMOS ( +LEVEL = 49 acm = 3 +VERSION = 3.1 TNOM = 27 TOX = 7.7E-9 +XJ = 1E-7 NCH = 8.52E16 VTH0 = -0.6897992 +K1 = 0.4134289 K2 = -5.342989E-3 K3 = 24.8361788 +K3B = -1.4390847 W0 = 2.467689E-6 NLX = 3.096223E-7 +DVT0W = 0 DVT1W = 0 DVT2W = 0 +DVT0 = 1.3209807 DVT1 = 0.4695965 DVT2 = -8.790762E-4 +U0 = 150.6275733 UA = 2.016943E-10 UB = 1.714919E-18 +UC = -1.36948E-11 VSAT = 9.559222E4 A0 = 0.9871247 +AGS = 0.3541967 B0 = 3.188091E-6 B1 = 5E-6 +KETA = -0.0169877 A1 = 0 A2 = 1 +RDSW = 2.443009E3 PRWG = 0.0260616 PRWB = 0.141561 +WR = 1 WINT = 5.038936E-8 LINT = 1.650588E-9 +XL = -2E-8 XW = 0 DWG = -1.535456E-8 +DWB = 1.256904E-8 VOFF = -0.15 NFACTOR = 1.5460516 +CIT = 0 CDSC = 1.413317E-4 CDSCD = 0 +CDSCB = 0 ETA0 = 0.3751392 ETAB = 2.343374E-3 +DSUB = 0.8877574 PCLM = 5.8638076 PDIBLC1 = 1.05224E-3 +PDIBLC2 = 3.481753E-5 PDIBLCB = 2.37525E-3 DROUT = 0.0277454 +PSCBE1 = 3.013379E10 PSCBE2 = 3.608179E-8 PVAG = 3.9564294 +DELTA = 0.01 MOBMOD = 1 PRT = 0 +UTE = -1.5 KT1 = -0.11 KT1L = 0 +KT2 = 0.022 UA1 = 4.31E-9 UB1 = -7.61E-18 +UC1 = -5.6E-11 AT = 3.3E4 WL = 0 +WLN = 1 WW = -5.22182E-16 WWN = 1.125 +WWL = 0 LL = 0 LLN = 1 +LW = 0 LWN = 1 LWL = 0 +CAPMOD = 2 XPART = 0.4 CGDO = 2.307E-10 +CGSO = 2.307E-10 CGBO = 0 CJ = 1.397645E-3 +PB = 0.99 MJ = 0.5574537 CJSW = 3.665392E-10 +PBSW = 0.99 MJSW = 0.3399328 PVTH0 = 0.0114364 +PRDSW = 52.7951169 PK2 = 9.714153E-4 WKETA = 0.0109418 +LKETA = 7.702974E-3 ) " } C {devices/nmos4} 480 -180 0 0 {name=m1 model=cmosn w=5u l=2u m=1} C {devices/pmos4} 550 -430 0 0 {name=m2 model=cmosp w=5u l=2u m=1} C {devices/vsource} 60 -180 0 0 {name=VVCC value=3} C {devices/lab_pin} 500 -120 0 0 {name=p1 lab=0} C {devices/lab_pin} 90 -240 0 1 {name=p2 lab=VCC} C {devices/nmos4} 260 -180 0 1 {name=m3 model=cmosn w=5u l=2u m=1} C {devices/lab_pin} 240 -120 0 0 {name=p3 lab=0} C {devices/isource} 240 -290 0 0 {name=IBIAS value=10u} C {devices/lab_pin} 240 -320 0 0 {name=p4 lab=0} C {devices/nmos4} 410 -280 0 0 {name=m4 model=cmosn w=10u l=1u m=1} C {devices/lab_pin} 450 -280 0 1 {name=p5 lab=0} C {devices/nmos4} 590 -280 0 1 {name=m5 model=cmosn w=10u l=1u m=1} C {devices/lab_pin} 550 -280 0 0 {name=p0 lab=0} C {devices/lab_pin} 590 -430 0 1 {name=p6 lab=VCC} C {devices/pmos4} 450 -430 0 1 {name=m6 model=cmosp w=5u l=2u m=1} C {devices/lab_pin} 410 -430 0 0 {name=p7 lab=VCC} C {devices/lab_pin} 500 -520 0 0 {name=p8 lab=VCC} C {devices/lab_pin} 370 -280 0 0 {name=p9 lab=PLUS} C {devices/lab_pin} 630 -280 0 1 {name=p10 lab=MINUS} C {devices/lab_pin} 690 -360 0 1 {name=p11 lab=DIFFOUT} C {devices/lab_pin} 430 -380 0 0 {name=p12 lab=GP} C {devices/lab_pin} 240 -230 0 0 {name=p13 lab=GN} C {devices/lab_pin} 60 -280 0 0 {name=p14 lab=0} C {devices/vsource} 60 -310 0 0 {name=VPLUS value=1.5} C {devices/lab_pin} 90 -370 0 1 {name=p15 lab=PLUS} C {devices/lab_pin} 60 -430 0 0 {name=p16 lab=0} C {devices/vsource} 60 -460 0 0 {name=V1 value=1.5} C {devices/lab_pin} 90 -520 0 1 {name=p18 lab=MINUS} C {devices/lab_pin} 500 -230 0 0 {name=p19 lab=SN} xschem-2.8.1/xschem_library/examples/nand.sym0000644000175100017510000000102113362731551017514 0ustar svnsvnG {type=nand verilog_format="nand #(@risedel , @falldel ) @name ( @@Z , @@A , @@B );" template="name=x1 risedel=100 falldel=200" } V {} S {} E {} L 4 -40 -20 -25 -20 {} L 4 -25 -30 -25 30 {} L 4 -25 -30 5 -30 {} L 4 -25 30 5 30 {} L 4 -40 20 -25 20 {} L 4 45 0 60 0 {} B 5 57.5 -2.5 62.5 2.5 {name=Z dir=out verilog_type=wire} B 5 -42.5 -22.5 -37.5 -17.5 {name=A dir=in} B 5 -42.5 17.5 -37.5 22.5 {name=B dir=in} A 4 40 0 5 180 360 {} A 4 5 0 30 270 180 {} T {@symname} -22.5 -20 0 0 0.2 0.2 {} T {@name} -22.5 -5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/examples/tesla.sch0000644000175100017510000004633113370707253017667 0ustar svnsvnG {} V {} S {} E {} T {PARASITIC CAP} 1020 -510 0 0 0.25 0.2 {} T {TESLA COIL HIGH VOLTAGE GENERATOR EXAMPLE} 420 -740 0 0 0.4 0.4 {} N 140 -550 140 -500 {lab=VCCS} N 140 -640 140 -610 {lab=VCC} N 230 -640 230 -500 {lab=VCC} N 870 -530 1010 -530 {lab=HV} N 1010 -420 1010 -250 {lab=VSS} N 1010 -530 1010 -480 {lab=HV} N 870 -340 870 -140 {lab=FB} N 870 -580 870 -530 {lab=HV} N 860 -580 870 -580 {lab=HV} N 845 -590 860 -580 {lab=HV} N 840 -600 845 -590 {lab=HV} N 840 -610 840 -600 {lab=HV} N 840 -620 845 -630 {lab=HV} N 845 -630 860 -640 {lab=HV} N 870 -640 880 -640 {lab=HV} N 870 -580 880 -580 {lab=HV} N 880 -580 895 -590 {lab=HV} N 895 -590 900 -600 {lab=HV} N 900 -610 900 -600 {lab=HV} N 895 -630 900 -620 {lab=HV} N 880 -640 895 -630 {lab=HV} N 840 -610 860 -600 {lab=HV} N 860 -600 880 -600 {lab=HV} N 880 -600 900 -610 {lab=HV} N 870 -640 880 -620 {lab=HV} N 880 -600 880 -590 {lab=HV} N 870 -580 880 -590 {lab=HV} N 860 -620 870 -640 {lab=HV} N 860 -600 860 -590 {lab=HV} N 860 -590 870 -580 {lab=HV} N 840 -620 860 -610 {lab=HV} N 860 -610 880 -610 {lab=HV} N 880 -610 900 -620 {lab=HV} N 845 -630 860 -620 {lab=HV} N 860 -620 880 -620 {lab=HV} N 880 -620 895 -630 {lab=HV} N 840 -600 860 -590 {lab=HV} N 860 -590 880 -590 {lab=HV} N 880 -590 900 -600 {lab=HV} N 895 -630 907.5 -642.5 {lab=HV} N 907.5 -642.5 907.5 -637.5 {lab=HV} N 907.5 -637.5 930 -660 {lab=HV} N 922.5 -655 930 -660 {lab=HV} N 925 -652.5 930 -660 {lab=HV} N 832.5 -642.5 845 -630 {lab=HV} N 832.5 -642.5 832.5 -637.5 {lab=HV} N 810 -660 832.5 -637.5 {lab=HV} N 810 -660 817.5 -655 {lab=HV} N 810 -660 815 -652.5 {lab=HV} N 832.5 -577.5 845 -590 {lab=HV} N 832.5 -582.5 832.5 -577.5 {lab=HV} N 810 -560 832.5 -582.5 {lab=HV} N 810 -560 817.5 -565 {lab=HV} N 810 -560 815 -567.5 {lab=HV} N 895 -590 907.5 -577.5 {lab=HV} N 907.5 -582.5 907.5 -577.5 {lab=HV} N 907.5 -582.5 930 -560 {lab=HV} N 922.5 -565 930 -560 {lab=HV} N 925 -567.5 930 -560 {lab=HV} N 840 -620 840 -610 {lab=HV} N 860 -640 870 -640 {lab=HV} N 900 -620 900 -610 {lab=HV} N 860 -610 860 -600 {lab=HV} N 880 -610 880 -600 {lab=HV} N 860 -620 860 -610 {lab=HV} N 880 -620 880 -610 {lab=HV} N 810 -430 810 -400 {lab=#net1} N 810 -490 870 -490 {lab=HV} N 580 -430 580 -400 {lab=#net2} N 520 -430 520 -340 {lab=#net3} N 520 -340 720 -340 {lab=#net3} N 810 -340 870 -340 {lab=FB} N 520 -490 580 -490 {lab=VCC} N 580 -640 580 -490 {lab=VCC} N 870 -530 870 -490 {lab=HV} N 870 -430 870 -340 {lab=FB} N 580 -170 580 -150 {lab=VSS} N 140 -640 230 -640 {lab=VCC} N 140 -420 230 -420 {lab=VSS} N 800 -220 800 -200 {lab=VCC} N 800 -140 870 -140 {lab=FB} N 230 -440 230 -420 {lab=VSS} N 140 -440 140 -420 {lab=VSS} N 460 -200 540 -200 {lab=FB} N 580 -280 580 -230 {lab=D} N 230 -640 580 -640 {lab=VCC} N 470 -280 470 -260 {lab=VCC} N 460 -420 460 -400 {lab=VCC} N 460 -340 520 -340 {lab=#net3} N 720 -280 720 -260 {lab=VSS} C {devices/code} 1140 -170 0 0 { name=STIMULI value=".option SCALE=1e-6 PARHIER=LOCAL RUNLVL=6 post MODMONTE=1 .option sampling_method = SRS .option method=gear vvss vss 0 dc 0 .temp 30 .tran 1n 1m uic .meas tran iavg AVG i(vc) from=950u to=990u .probe tran p(q1) i(d2) i(d1) i(d3) i(l1) i(l2) i(L3) .meas tran pavg AVG p(q1) from=950u to=990u"} C {devices/lab_pin} 140 -640 0 0 {name=p1 lab=VCC} C {devices/res} 140 -580 0 1 {name=rs m=1 value=1} C {devices/vsource} 140 -470 0 1 {name=vvcc value="pwl 0 0 1u 12"} C {devices/lab_pin} 140 -420 0 0 {name=p7 lab=VSS} C {devices/capa} 230 -470 0 0 {name=cvcc m=1 value=10u} C {devices/launcher} 1180 -530 0 0 {name=h2 descr="BJT MODELS" url="http://www.zen22142.zen.co.uk/ltspice/standard.bjt"} C {devices/launcher} 1180 -480 0 0 {name=h1 descr="NPN MODELS" url="http://web.mit.edu/Magic/Public/ckt/npn.mod"} C {devices/launcher} 1180 -580 0 0 {name=h3 descr="COIL CALCULATION" url="http://hamwaves.com/antennas/inductance.html"} C {devices/launcher} 1180 -630 0 0 {name=h4 descr="ltwiki BJT MODELS" url="http://ltwiki.org/?title=Standard.bjt"} C {devices/lab_pin} 140 -530 0 0 {name=p6 lab=VCCS} C {devices/lab_pin} 870 -560 0 1 {name=p4 lab=HV} C {devices/capa} 1010 -450 0 0 {name=c1 m=1 value=1p} C {devices/lab_pin} 1010 -250 0 0 {name=p3 lab=VSS} C {devices/ind} 580 -460 2 1 {name=L1 value=9.8u} C {devices/ind} 810 -460 0 1 {name=L2 value=9.1m} C {devices/k} 700 -460 0 0 {name=K0 K=0.15 L1=L1 L2=L2} C {devices/res} 810 -370 0 0 {name=r0 m=1 value=.32} C {devices/capa} 870 -460 0 1 {name=c0 m=1 value=4.1p} C {devices/res} 580 -370 0 1 {name=r3 m=1 value=0.22} C {devices/capa} 520 -460 0 0 {name=c5 m=1 value=13p} C {devices/lab_pin} 580 -260 0 1 {name=p5 lab=D} C {devices/lab_pin} 870 -170 0 1 {name=p0 lab=FB} C {devices/diode} 800 -110 2 0 {name=D2 model=d1n4148 area=1 } C {devices/lab_pin} 580 -150 0 1 {name=p10 lab=VSS} C {devices/diode} 800 -170 2 0 {name=D1 model=d1n4148 area=1 } C {devices/lab_pin} 800 -220 0 1 {name=p16 lab=VCC} C {devices/lab_pin} 460 -200 0 0 {name=p11 lab=FB} C {devices/lab_pin} 800 -80 0 0 {name=p12 lab=VSS} C {devices/npn} 560 -200 0 0 {name=Q5 model=bd139 area=1} C {devices/res} 470 -230 0 0 {name=r1 m=1 value=100k} C {devices/lab_pin} 470 -280 0 0 {name=p8 lab=VCC} C {devices/diode} 460 -370 2 0 {name=D3 model=d1n5400 area=1 } C {devices/lab_pin} 460 -420 0 0 {name=p13 lab=VCC} C {devices/ammeter} 580 -310 0 0 {name=vmeasure} C {devices/diode} 720 -310 2 0 {name=D4 model=d1n5400 area=1 } C {devices/lab_pin} 720 -260 0 0 {name=p14 lab=VSS} C {devices/title} 160 -30 0 0 {name=l1 author="Stefan Schippers"} C {devices/code} 1140 -330 0 0 {name=MODELS only_toplevel=true value=".MODEL bd139_2 npn +IS=1e-09 BF=222.664 NF=0.85 VAF=36.4079 +IKF=0.166126 ISE=5.03418e-09 NE=1.45313 BR=1.35467 +NR=1.33751 VAR=142.931 IKR=1.66126 ISC=5.02557e-09 +NC=3.10227 RB=26.9143 IRB=0.1 RBM=0.1 +RE=0.000472454 RC=1.04109 XTB=0.727762 XTI=1.04311 +EG=1.05 CJE=1e-11 VJE=0.75 MJE=0.33 +TF=1e-09 XTF=1 VTF=10 ITF=0.01 +CJC=1e-11 VJC=0.75 MJC=0.33 XCJC=0.9 +FC=0.5 CJS=0 VJS=0.75 MJS=0.5 +TR=1e-07 PTF=0 KF=0 AF=1 .MODEL BD139 NPN ( +IS=2.3985E-13 Vceo=80 Icrating=1500m +BF=244.9 NF=1.0 BR=78.11 NR=1.007 ISE=1.0471E-14 +NE=1.2 ISC=1.9314E-11 NC=1.45 VAF=98.5 VAR=7.46 +IKF=1.1863 IKR=0.1445 RB=2.14 RBM=0.001 IRB=0.031 +RE=0.0832 RC=0.01 CJE=2.92702E-10 VJE=0.67412 +MJE=0.3300 FC=0.5 CJC=4.8831E-11 VJC=0.5258 +MJC=0.3928 XCJC=0.5287 XTB=1.1398 EG=1.2105 XTI=3.0) .MODEL BD140 PNP(IS=1e-09 BF=650.842 NF=0.85 VAF=10 +IKF=0.0950125 ISE=1e-08 NE=1.54571 BR=56.177 +NR=1.5 VAR=2.11267 IKR=0.950125 ISC=1e-08 +NC=3.58527 RB=41.7566 IRB=0.1 RBM=0.108893 +RE=0.000347052 RC=1.32566 XTB=19.5239 XTI=1 +EG=1.05 CJE=1e-11 VJE=0.75 MJE=0.33 +TF=1e-09 XTF=1 VTF=10 ITF=0.01 +CJC=1e-11 VJC=0.75 MJC=0.33 XCJC=0.9 +FC=0.5 CJS=0 VJS=0.75 MJS=0.5 TR=1e-07 PTF=0 KF=0 AF=10 + VCEO=80 ICRATING=1A ) .MODEL Q2N2222A NPN IS =3.0611E-14 NF =1.00124 BF =220 IKF=0.52 + VAF=104 ISE=7.5E-15 NE =1.41 NR =1.005 BR =4 IKR=0.24 + VAR=28 ISC=1.06525E-11 NC =1.3728 RB =0.13 RE =0.22 + RC =0.12 CJC=9.12E-12 MJC=0.3508 VJC=0.4089 + CJE=27.01E-12 TF =0.325E-9 TR =100E-9 + vce_max=45 vbe_max=6 .MODEL Q2N2222 NPN ( + IS = 3.97589E-14 BF = 195.3412 NF = 1.0040078 VAF = 53.081 IKF = 0.976 ISE = 1.60241E-14 + NE = 1.4791931 BR = 1.1107942 NR = 0.9928261 VAR = 11.3571702 IKR = 2.4993953 ISC = 1.88505E-12 + NC = 1.1838278 RB = 56.5826472 IRB = 1.50459E-4 RBM = 5.2592283 RE = 0.0402974 RC = 0.4208 + CJE = 2.56E-11 VJE = 0.682256 MJE = 0.3358856 TF = 3.3E-10 XTF = 6 VTF = 0.574 + ITF = 0.32 PTF = 25.832 CJC = 1.40625E-11 VJC = 0.5417393 MJC = 0.4547893 XCJC = 1 + TR = 3.2E-7 CJS = 0 VJS = .75 MJS = 0 XTB = 1.6486 EG = 1.11 + XTI = 5.8315 KF = 0 AF = 1 FC = 0.83 + vce_max=45 vbe_max=6 ) * 2n2222 p complementary .MODEL Q2N2907P PNP(IS=650.6E-18 ISE=54.81E-15 ISC=0 XTI=3 + BF=231.7 BR=3.563 IKF=1.079 IKR=0 XTB=1.5 + VAF=115.7 VAR=35 VJE=0.65 VJC=0.65 + RE=0.15 RC=0.715 RB=10 + CJE=19.82E-12 CJC=14.76E-12 XCJC=0.75 FC=0.5 + NF=1 NR=1 NE=1.829 NC=2 MJE=0.3357 MJC=0.5383 + TF=603.7E-12 TR=111.3E-9 ITF=0.65 VTF=5 XTF=1.7 + EG=1.11 KF=1E-9 AF=1 + VCEO=45 ICRATING=100M + vce_max=45 vbe_max=6 ) .MODEL Q2N2907S PNP(IS=2.32E-13 ISE=6.69E-16 ISC=1.65E-13 XTI=3.00 + BF=3.08E2 BR=2.18E1 IKF=8.42E-1 IKR=1.00 XTB=1.5 + VAF=1.41E2 VAR=1.35E1 VJE=3.49E-1 VJC=3.00E-1 + RE=1.00E-2 RC=8.46E-1 RB=4.02E1 RBM=1.00E-2 IRB=1.25E-2 + CJE=2.66E-11 CJC=1.93E-11 XCJC=1.00 FC=5.00E-1 + NF=1.04 NR=1.12 NE=1.09 NC=1.13 MJE=4.60E-1 MJC=4.65E-1 + TF=4.95E-10 TR=0 PTF=0 ITF=3.36E-1 VTF=6.54 XTF=1.87E1 + EG=1.11 KF=1E-9 AF=1 + VCEO=40 ICRATING=500M + vce_max=45 vbe_max=6 ) *MM3725 MCE 5/13/95 *Si 1W 40V 500mA 307MHz pkg:TO-39 3,2,1 .MODEL QMM3725 NPN (IS=50.7F NF=1 BF=162 VAF=113 IKF=.45 ISE=38.2P NE=2 + BR=4 NR=1 VAR=24 IKR=.675 RE=.263 RB=1.05 RC=.105 XTB=1.5 + CJE=62.2P VJE=1.1 MJE=.5 CJC=14.6P VJC=.3 MJC=.3 TF=518P TR=45.9N) *MPS651 MCE 5/12/95 *Si 625mW 60V 2A 110MHz pkg:TO-92 1,2,3 .MODEL QMPS651 NPN (IS=72.1F NF=1 BF=260 VAF=139 IKF=2.5 ISE=67.1P NE=2 + BR=4 NR=1 VAR=20 IKR=3.75 RE=28.2M RB=.113 RC=11.3M XTB=1.5 + CJE=212P VJE=1.1 MJE=.5 CJC=68.6P VJC=.3 MJC=.3 TF=1.44N TR=1U) *FCX649 ZETEX Spice model Last revision 17/7/90 Medium Power *ZTX Si 1.5W 25V 2A 240MHz pkg:SOT-89 2,1,3 .MODEL QFCX649 NPN(IS=3E-13 BF=225 VAF=80 IKF=2.8 ISE=1.1E-13 NE=1.37 + BR=110 NR=0.972 VAR=28 IKR=0.8 ISC=6.5E-13 NC=1.372 RB=0.3 RE=0.063 + RC=0.07 CJE=3.25E-10 TF=1E-9 CJC=7E-11 TR=1E-8 ) *MPSW01A MCE 5/12/95 *Si 1W 40V 1A 210MHz pkg:TO-92 1,2,3 .MODEL QMPSW01A NPN (IS=18.1F NF=1 BF=273 VAF=113 IKF=.6 ISE=15.7P NE=2 + BR=4 NR=1 VAR=20 IKR=.9 RE=96.5M RB=.386 RC=38.6M XTB=1.5 + CJE=78.7P VJE=1.1 MJE=.5 CJC=17.3P VJC=.3 MJC=.3 TF=757P TR=526N) *BC546 ZETEX Spice model Last revision 4/90 General Purpose *ZTX Si 500mW 65V 200mA 300MHz pkg:TO-92 1,2,3 .MODEL BC546 NPN(IS=1.8E-14 BF=400 NF=0.9955 VAF=80 IKF=0.14 ISE=5E-14 + NE=1.46 BR=35.5 NR=1.005 VAR=12.5 IKR=0.03 ISC=1.72E-13 NC=1.27 RB=0.56 + RE=0.6 RC=0.25 CJE=1.3E-11 TF=6.4E-10 CJC=4E-12 VJC=0.54 TR=5.072E-8 + vce_max=65 vbe_max=6 ) .MODEL BC556 PNP( + IS=2.059E-14 + NF=1.003 + ISE=2.971E-15 + NE=1.316 + BF=227.3 + IKF=0.08719 + VAF=37.2 + NR=1.007 + ISC=1.339E-14 + NC=1.15 + BR=7.69 + IKR=0.07646 + VAR=11.42 + RB=1 + IRB=1E-06 + RBM=1 + RE=0.688 + RC=0.6437 + XTB=0 + EG=1.11 + XTI=3 + CJE=1.4E-11 + VJE=0.5912 + MJE=0.3572 + TF=7.046E-10 + XTF=4.217 + VTF=5.367 + ITF=0.1947 + PTF=0 + CJC=1.113E-11 + VJC=0.1 + MJC=0.3414 + XCJC=0.6288 + TR=1E-32 + CJS=0 + VJS=0.75 + MJS=0.333 + FC=0.7947 + vce_max=65 vbe_max=6 ) * * NXP Semiconductors * * Medium power NPN transistor * IC = 1 A * VCEO = 20 V * hFE = 85 - 375 @ 2V/500mA * * * * * Package pinning does not match Spice model pinning. * Package: SOT 223 * * Package Pin 1: Base * Package Pin 2: Collector * Package Pin 3: Emitter * Package Pin 4: Collector * * Extraction date (week/year): 13/2008 * Simulator: Spice 3 * ********************************************************** *# .SUBCKT BCP68 1 2 3 * Q1 1 2 3 BCP68 D1 2 1 DIODE * *The diode does not reflect a *physical device but improves *only modeling in the reverse *mode of operation. * .MODEL BCP68 NPN + IS = 2.312E-013 + NF = 0.988 + ISE = 8.851E-014 + NE = 2.191 + BF = 273 + IKF = 5.5 + VAF = 50 + NR = 0.9885 + ISC = 6.808E-014 + NC = 3 + BR = 155.6 + IKR = 4 + VAR = 17 + RB = 15 + IRB = 2E-006 + RBM = 0.65 + RE = 0.073 + RC = 0.073 + XTB = 0 + EG = 1.11 + XTI = 3 + CJE = 2.678E-010 + VJE = 0.732 + MJE = 0.3484 + TF = 5.8E-010 + XTF = 1.5 + VTF = 2.5 + ITF = 1 + PTF = 0 + CJC = 3.406E-011 + VJC = 2 + MJC = 0.3142 + XCJC = 1 + TR = 6.5E-009 + CJS = 0 + VJS = 0.75 + MJS = 0.333 + FC = 0.95 .MODEL DIODE D + IS = 2.702E-015 + N = 1.2 + BV = 1000 + IBV = 0.001 + RS = 0.1 + CJO = 0 + VJ = 1 + M = 0.5 + FC = 0 + TT = 0 + EG = 1.11 + XTI = 3 .ENDS .model D1N4007 D(IS=7.02767n RS=0.0341512 N=1.80803 EG=1.05743 XTI=5 BV=1000 IBV=5e-08 CJO=1e-11 VJ=0.7 M=0.5 FC=0.5 TT=1e-07 ) .MODEL D1N4148 D + IS = 4.352E-9 + N = 1.906 + BV = 110 + IBV = 0.0001 + RS = 0.6458 + CJO = 7.048E-13 + VJ = 0.869 + M = 0.03 + FC = 0.5 + TT = 3.48E-9 .MODEL D1n5400 d +IS=2.61339e-12 RS=0.0110501 N=1.20576 EG=0.6 +XTI=3.1271 BV=50 IBV=1e-05 CJO=1e-11 +VJ=0.7 M=0.5 FC=0.5 TT=1e-09 +KF=0 AF=1 * Model generated on October 12, 2003 * Model format: PSpice *1N758 *Ref: Motorola *10V 500mW Si Zener pkg:DIODE0.4 1,2 .MODEL D1N758 D(IS=1E-11 RS=8.483 N=1.27 TT=5E-8 CJO=2.334E-10 VJ=0.75 + M=0.33 BV=9.83 IBV=0.01 ) *1N4744 *Ref: Motorola *15V 1W Si Zener pkg:DIODE0.4 1,2 .MODEL D1N4744 D(IS=5.32E-14 RS=6.47 TT=5.01E-8 CJO=7.83E-11 M=0.33 + BV=14.89 IBV=0.017 ) *1N755 *Ref: Motorola *7.5V 500mW Si Zener pkg:DIODE0.4 1,2 .MODEL D1N755 D(IS=1E-11 RS=3.359 N=1.27 TT=5E-8 CJO=2.959E-10 VJ=0.75 + M=0.33 BV=7.433 IBV=0.01 ) ** node order * 1: gnd * 2: trig * 3: out * 4: reset# * 5: ctrl * 6: thres * 7: dis * 8: vcc .SUBCKT ne555 34 32 30 19 23 33 1 21 * G TR O R F TH D V Q4 25 2 3 QP Q5 34 6 3 QP Q6 6 6 8 QP R1 9 21 4.7K R2 3 21 830 R3 8 21 4.7K Q7 2 33 5 QN Q8 2 5 17 QN Q9 6 4 17 QN Q10 6 23 4 QN Q11 12 20 10 QP R4 10 21 1K Q12 22 11 12 QP Q13 14 13 12 QP Q14 34 32 11 QP Q15 14 18 13 QP R5 14 34 100K R6 22 34 100K R7 17 34 10K Q16 1 15 34 QN Q17 15 19 31 QP R8 18 23 5K R9 18 34 5K R10 21 23 5K Q18 27 20 21 QP Q19 20 20 21 QP R11 20 31 5K D1 31 24 DA Q20 24 25 34 QN Q21 25 22 34 QN Q22 27 24 34 QN R12 25 27 4.7K R13 21 29 6.8K Q23 21 29 28 QN Q24 29 27 16 QN Q25 30 26 34 QN Q26 21 28 30 QN D2 30 29 DA R14 16 15 100 R15 16 26 220 R16 16 34 4.7K R17 28 30 3.9K Q3 2 2 9 QP .MODEL DA D (RS=40 IS=1.0E-14 CJO=1PF) .MODEL QP PNP (level=1 BF=20 BR=0.02 RC=4 RB=25 IS=1.0E-14 VA=50 NE=2) + CJE=12.4P VJE=1.1 MJE=.5 CJC=4.02P VJC=.3 MJC=.3 TF=229P TR=159N) .MODEL QN NPN (level=1 IS=5.07F NF=1 BF=100 VAF=161 IKF=30M ISE=3.9P NE=2 + BR=4 NR=1 VAR=16 IKR=45M RE=1.03 RB=4.12 RC=.412 XTB=1.5 + CJE=12.4P VJE=1.1 MJE=.5 CJC=4.02P VJC=.3 MJC=.3 TF=229P TR=959P) .ENDS .SUBCKT BS250P 3 4 5 * D G S M1 3 2 5 5 MBS250 RG 4 2 160 RL 3 5 1.2E8 C1 2 5 47E-12 C2 3 2 10E-12 D1 3 5 DBS250 * .MODEL MBS250 PMOS VTO=-3.193 RS=2.041 RD=0.697 IS=1E-15 KP=0.277 +CBD=105E-12 PB=1 LAMBDA=1.2E-2 .MODEL DBS250 D IS=2E-13 RS=0.309 .ENDS BS250P .SUBCKT BS170 3 4 5 * D G S M1 3 2 5 5 N3306M RG 4 2 270 RL 3 5 1.2E8 C1 2 5 28E-12 C2 3 2 3E-12 D1 5 3 N3306D * .MODEL N3306M NMOS VTO=1.824 RS=1.572 RD=1.436 IS=1E-15 KP=.1233 +CBD=35E-12 PB=1 .MODEL N3306D D IS=5E-12 RS=.768 .ENDS BS170 * *$ .SUBCKT PTON_TOFF_U4_S1 1 2 3 4 G_Switch 3 4 VCR PWL(1) 1 2 0.2 100e6 0.8 1m RS_U4_S1 1 2 1G .ENDS PTON_TOFF_U4_S1 *$ .SUBCKT PTON_TOFF_U4_S2 1 2 3 4 G_Switch 3 4 VCR PWL(1) 1 2 0.2 100e6 0.8 1m RS_U4_S2 1 2 1G .ENDS PTON_TOFF_U4_S2 *$ .SUBCKT MTON_TOFF_U2_S2 1 2 3 4 G_Switch 3 4 VCR PWL(1) 1 2 0.2 100e6 0.8 1m RS_U2_S2 1 2 1G .ENDS MTON_TOFF_U2_S2 *$ .SUBCKT MTON_TOFF_U2_S1 1 2 3 4 G_Switch 3 4 VCR PWL(1) 1 2 0.2 100e6 0.8 1m RS_U2_S1 1 2 1G .ENDS MTON_TOFF_U2_S1 *$ ****************************** Basic Components ************************** .SUBCKT D_D1 1 2 D1 1 2 DD1 .MODEL DD1 D (IS=1e-15 Rs=0.001 N=0.1 TT=10p) .ENDS D_D1 *$ .SUBCKT BUF_BASIC_GEN A Y VDD=1 VSS=0 VTHRESH=0.5 * E_ABMGATE YINT 0 vol='V(A) > VTHRESH? VDD:VSS' E_ABMGATE YINT 0 pwl(1) A 0 'VTHRESH-0.01' VSS 'VTHRESH+0.01' VDD RINT YINT Y 1 CINT Y 0 1n .ENDS BUF_BASIC_GEN *$ .MODEL NMOS01 NMOS (VTO = 2 KP = 1.005 LAMBDA = 0.001) *$ .MODEL PMOS01 PMOS (VTO = -2 KP = 1.77 LAMBDA = 0.001) *$ .MODEL NMOS02 NMOS (VTO = 2 KP = 0.1814 LAMBDA = 0.001) *$ .MODEL PMOS02 PMOS (VTO = -2 KP = 0.2497 LAMBDA = 0.001) *$ .SUBCKT COMPHYS_BASIC_GEN INP INM HYS OUT VDD=1 VSS=0 VTHRESH=0.5 EIN INP1 INM1 INP INM 1 * EHYS INP1 INP2 vol='V(1) > VTHRESH? -V(HYS):0' EHYS INP1 INP2 pwl(1) 1 0 'VTHRESH-0.01' 0 'VTHRESH+0.01' '-V(HYS)' EOUT OUT 0 vol='V(INP2)>V(INM1)? VDD : VSS' R1 OUT 1 1 C1 1 0 5n RINP1 INP1 0 1K .ENDS COMPHYS_BASIC_GEN *$ .SUBCKT AND2_BASIC_GEN A B Y VDD=1 VSS=0 VTHRESH=0.5 E_ABMGATE YINT 0 vol= 'V(A) > VTHRESH && V(B) > VTHRESH ? VDD:VSS' RINT YINT Y 1 CINT Y 0 1n .ENDS AND2_BASIC_GEN *$ .SUBCKT NOR2_BASIC_GEN A B Y VDD=1 VSS=0 VTHRESH=0.5 E_ABMGATE YINT 0 vol= 'V(A) > VTHRESH || V(B) > VTHRESH ? VSS:VDD' RINT YINT Y 1 CINT Y 0 1n .ENDS NOR2_BASIC_GEN *$ .SUBCKT AND3_BASIC_GEN A B C Y VDD=1 VSS=0 VTHRESH=0.5 E_ABMGATE YINT 0 vol= 'V(A) > VTHRESH && V(B) > VTHRESH && V(C) > VTHRESH ? VDD:VSS' RINT YINT Y 1 CINT Y 0 1n .ENDS AND3_BASIC_GEN *$ .SUBCKT INV_BASIC_GEN A Y VDD=1 VSS=0 VTHRESH=0.5 * E_ABMGATE YINT 0 vol='V(A) > VTHRESH ? VSS : VDD' E_ABMGATE YINT 0 pwl(1) A 0 'VTHRESH-0.01' VDD 'VTHRESH+0.01' VSS RINT YINT Y 1 CINT Y 0 1n .ENDS INV_BASIC_GEN *$ .SUBCKT RVAR 101 102 201 202 RREF=1 * nodes : 101 102 : nodes between which variable resistance is placed * 201 202 : nodes to whose voltage the resistance is proportional * parameters : rref : reference value of the resistance rin 201 202 1G $$ input resistance r 301 0 rref fcopy 0 301 vsense 1 $$ copy output current thru Z eout 101 106 poly(2) 201 202 301 0 0 0 0 0 1 $$ multiply VoverZ with Vctrl vsense 106 102 0 $$ sense iout .ENDS RVAR *$ *LM317 TI voltage regulator - pin order: In, Adj, Out *TI adjustable voltage regulator pkg:TO-3 .SUBCKT LM317 1 2 3 **Changes my be required on this line** J1 1 3 4 JN Q2 5 5 6 QPL .1 Q3 5 8 9 QNL .2 Q4 8 5 7 QPL .1 Q5 81 8 3 QNL .2 Q6 3 81 10 QPL .2 Q7 12 81 13 QNL .2 Q8 10 5 11 QPL .2 Q9 14 12 10 QPL .2 Q10 16 5 17 QPL .2 Q11 16 14 15 QNL .2 Q12 3 20 16 QPL .2 Q13 1 19 20 QNL .2 Q14 19 5 18 QPL .2 Q15 3 21 19 QPL .2 Q16 21 22 16 QPL .2 Q17 21 3 24 QNL .2 Q18 22 22 16 QPL .2 Q19 22 3 241 QNL 2 Q20 3 25 16 QPL .2 Q21 25 26 3 QNL .2 Q22A 35 35 1 QPL 2 Q22B 16 35 1 QPL 2 Q23 35 16 30 QNL 2 Q24A 27 40 29 QNL .2 Q24B 27 40 28 QNL .2 Q25 1 31 41 QNL 5 Q26 1 41 32 QNL 50 D1 3 4 DZ D2 33 1 DZ D3 29 34 DZ R1 1 6 310 R2 1 7 310 R3 1 11 190 R4 1 17 82 R5 1 18 5.6K R6 4 8 100K R7 8 81 130 R8 10 12 12.4K R9 9 3 180 R10 13 3 4.1K R11 14 3 5.8K R12 15 3 72 R13 20 3 5.1K R14 2 24 12K R15 24 241 2.4K R16 16 25 6.7K R17 16 40 12K R18 30 41 130 R19 16 31 370 R20 26 27 13K R21 27 40 400 R22 3 41 160 R23 33 34 18K R24 28 29 160 R25 28 32 3 R26 32 3 .1 C1 21 3 30PF C2 21 2 30PF C3 25 26 5PF CBS1 5 3 2PF CBS2 35 3 1PF CBS3 22 3 1PF .MODEL JN NJF(BETA=1E-4 VTO=-7) .MODEL DZ D(BV=6.3) .MODEL QNL NPN(EG=1.22 BF=80 RB=100 CCS=1.5PF TF=.3NS TR=6NS CJE=2PF + CJC=1PF VAF=100) .MODEL QPL PNP(BF=40 RB=20 TF=.6NS TR=10NS CJE=1.5PF CJC=1PF VAF=50) .ENDS .SUBCKT xxxxLM317 1 3 2 * IN ADJ OUT IADJ 1 4 50U VREF 4 3 1.25 RC 1 14 0.742 DBK 14 13 D1 CBC 13 15 2.479N RBC 15 5 247 QP 13 5 2 Q1 RB2 6 5 124 DSC 6 11 D1 ESC 11 2 POLY(2) (13,5) (6,5) 2.85 + 0 0 0 -70.1M DFB 6 12 D1 EFB 12 2 POLY(2) (13,5) (6,5) 3.92 + -135M 0 1.21M -70.1M RB1 7 6 1 EB 7 2 8 2 2.56 CPZ 10 2 0.796U DPU 10 2 D1 RZ 8 10 0.104 RP 9 8 100 EP 9 2 4 2 103.6 RI 2 4 100MEG .MODEL Q1 NPN (IS=30F BF=100 + VAF=14.27 NF=1.604) .MODEL D1 D (IS=30F N=1.604) .ENDS .SUBCKT LM337 8 1 19 *Connections Input Adj. Output *LM337 negative voltage regulator .MODEL QN NPN (BF=50 TF=1N CJC=1P) .MODEL QPOUT PNP (BF=50 TF=1N RE=.2 CJC=1P) .MODEL QP PNP CJC=1P TF=2N .MODEL DN D .MODEL D2 D BV=12 IBV=100U R10 25 6 1K Q3 8 17 16 QPOUT Q4 8 25 17 QP R18 19 17 250 R19 19 16 .3 G1 8 6 1 18 .1 C7 6 2 .04U R24 2 8 100 I_ADJ 0 1 65U R26 8 25 200K Q5 25 4 19 QP R27 16 4 200 R28 7 4 7K D1 8 7 D2 D2 8 6 DN V1 18 19 1.25 .ENDS "} xschem-2.8.1/xschem_library/examples/buf.sym0000644000175100017510000000067313023633056017357 0ustar svnsvnG {type=buff vhdl_stop=true format="@name @@Z @@VSS pwl(1) @@A @@VSS @TABLE" template="name=E1 TABLE=\\"1.4 0.0 1.6 3.0\\""} V {} S {} L 4 -40 0 -27.5 0 {} L 4 -27.5 -20 -27.5 20 {} L 4 -27.5 -20 16.25 0 {} L 4 -27.5 20 16.25 0 {} L 4 16.25 0 40 0 {} L 4 0 7.5 0 30 {} B 5 -42.5 -2.5 -37.5 2.5 {name=A dir=in } B 5 37.5 -2.5 42.5 2.5 {name=Z dir=out } B 5 -2.5 27.5 2.5 32.5 {name=VSS dir=in} T {@name} -26.25 -5 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/Makefile0000644000175100017510000000050613366730421015672 0ustar svnsvnall: include ../Makefile.conf install: FORCE mkdir -p $(XSHAREDIR)/xschem_library cp -ru mylib $(XSHAREDIR)/xschem_library cp -ru devices $(XSHAREDIR)/xschem_library cp -ru examples $(XSHAREDIR)/xschem_library cp -ru pcb $(XSHAREDIR)/xschem_library uninstall: FORCE rm -rf $(XDOCDIR)/doc clean: distclean: FORCE: xschem-2.8.1/xschem_library/mylib/0000755000175100017510000000000013400743706015344 5ustar svnsvnxschem-2.8.1/xschem_library/mylib/nand2.sch0000644000175100017510000000262213025347746017056 0ustar svnsvnG {} V {} S {} N 290 -280 290 -220 {lab=#net1} N 290 -410 290 -340 {lab=#net2} N 290 -380 440 -380 {lab=#net2} N 440 -410 440 -380 {lab=#net2} N 440 -500 440 -470 {lab=#net3} N 290 -500 440 -500 {lab=#net3} N 290 -500 290 -470 {lab=#net3} N 290 -160 290 -130 {lab=#net4} N 210 -190 250 -190 {lab=#net5} N 400 -440 400 -400 {lab=#net6} N 240 -400 400 -400 {lab=#net6} N 240 -400 240 -310 {lab=#net6} N 210 -440 210 -190 {lab=#net5} N 210 -440 250 -440 {lab=#net5} N 160 -310 250 -310 {lab=#net6} N 160 -190 210 -190 {lab=#net5} N 440 -380 500 -380 {} C {devices/ipin} 160 -310 0 0 {name=p1 lab=A} C {devices/opin} 500 -380 0 0 {name=p2 lab=Z} C {devices/ipin} 160 -190 0 0 {name=p3 lab=B} C {devices/nmos4} 270 -310 0 0 {name=m1 model=nmos w=WN l=LN m=1} C {devices/pmos4} 270 -440 0 0 {name=m2 model=pmos w=WP l=LP m=1} C {devices/pmos4} 420 -440 0 0 {name=m3 model=pmos w=WP l=LP m=1} C {devices/nmos4} 270 -190 0 0 {name=m4 model=nmos w=WN l=LN m=1} C {devices/vdd} 290 -500 0 0 {name=l1 lab=VCC} C {devices/gnd} 290 -130 0 0 {name=l2 lab=VSS} C {devices/lab_pin} 290 -310 0 1 {name=l3 sig_type=std_logic lab=VSS} C {devices/lab_pin} 290 -190 0 1 {name=l4 sig_type=std_logic lab=VSS} C {devices/lab_pin} 290 -440 0 1 {name=l5 sig_type=std_logic lab=VCC} C {devices/lab_pin} 440 -440 0 1 {name=l6 sig_type=std_logic lab=VCC} C {devices/title} 160 -30 0 0 {name=l7 author="Stefan Schippers"} xschem-2.8.1/xschem_library/mylib/test2.sch0000644000175100017510000000067713025347746017125 0ustar svnsvnG {} V {} S {} N 100 -800 150 -800 {lab=#net1} N 150 -800 150 -780 {lab=#net1} N 150 -780 210 -780 {lab=#net1} C {mylib/nand2} 260 -760 0 0 {name=x1 WP=12u LP=0.4u WN=8u LN=0.6u} C {mylib/nand2} 50 -800 0 0 {name=x2 WP=5u LP=1u WN=3u LN=1.5u} C {devices/lab_pin} 0 -820 0 0 {name=p1 lab=A} C {devices/lab_pin} 0 -780 0 0 {name=p2 lab=B} C {devices/lab_pin} 310 -760 0 1 {name=p3 lab=Z} C {devices/lab_pin} 210 -740 0 0 {name=p4 lab=C} xschem-2.8.1/xschem_library/mylib/0_top.sch0000644000175100017510000000644313362731551017075 0ustar svnsvnG {} V {} S {} E {} L 3 910 -560 960 -540 {} L 3 880 -680 1200 -680 {} L 8 900 -540 950 -560 {} L 11 900 -550 950 -530 {} L 16 910 -530 960 -550 {} B 4 940 -510 960 -450 {} B 7 900 -490 970 -470 {} B 8 910 -510 930 -450 {} A 4 925 -95 35.35533905932738 8.13010235415598 360 {} A 6 990 -150 70.71067811865476 188.130102354156 89.99999999999997 {} A 7 934.1666666666666 -90 39.58991173406564 210.3432488842396 198.9246444160511 {} P 1 10 930 -370 920 -430 1000 -410 960 -390 990 -360 970 -360 960 -340 940 -380 930 -360 930 -370 {} P 4 6 880 -350 880 -440 870 -390 870 -430 860 -400 860 -370 {} P 15 11 920 -400 930 -440 950 -410 960 -430 970 -400 990 -410 970 -370 940 -380 910 -360 890 -410 920 -400 {fill=true} T {Welcome to XSCHEM!} 60 -950 0 0 1 1 {layer=5} T {This is the start schematic window specified in your .xschem file. You may change this to any different schematic file or even start with an empty window. Just set the XSCHEM_START_WINDOW variable: - set XSCHEM_START_WINDOW \{mylib/0_top\} or, if you want to start with an empty window: - set XSCHEM_START_WINDOW \{\} On the left you see some sample circuits. You may descend into any of these by selecting one with a left mouse button click and pressing the 'e' key, or by menu 'Edit -> Push Schematic'. You can return here after descending into a schematic by hitting '-e' or by menu 'Edit -> Pop'. } 10 -880 0 0 0.4 0.4 {} T {Select the components here under and press'-h' or -click them to visit xschem websites or local docs} 400 -420 0 0 0.3 0.3 {} T {Lines} 1010 -560 0 0 0.6 0.6 {layer=4} T {Rectangles} 1010 -500 0 0 0.6 0.6 {layer=4} T {Polygons} 1010 -410 0 0 0.6 0.6 {layer=4} T {Electrical wires} 1010 -330 0 0 0.6 0.6 {layer=4} T {XSCHEM OBJECTS} 910 -720 0 0 0.6 0.6 {layer=7} T {Components} 1010 -210 0 0 0.6 0.6 {layer=4} T {TEXT} 890 -620 0 0 0.5 0.5 {layer=8} T {TEXT} 890 -670 1 0 0.7 0.7 {layer=6 font=FreeMono} T {Text} 900 -660 0 0 0.5 0.5 {layer=7 font="Times"} T {TEXT} 990 -660 1 0 0.5 0.5 {} T {Text} 1010 -650 0 0 0.6 0.6 {layer=4} T {Arcs/Circles} 1010 -120 0 0 0.6 0.6 {layer=4} N 870 -300 990 -300 {lab=#net1} N 910 -340 910 -250 {lab=#net2} N 910 -270 970 -270 {lab=#net2} N 930 -310 960 -300 {lab=#net1} C {examples/poweramp} 160 -310 0 0 {name=x1} C {examples/tesla} 160 -230 0 0 {name=x2} C {examples/test_ne555} 160 -190 0 0 {name=x3} C {examples/test_lm324} 160 -150 0 0 {name=x4} C {examples/osc} 160 -270 0 0 {name=x5} C {examples/tesla2} 160 -110 0 0 {name=x7} C {devices/title} 160 -30 0 0 {name=l1 author="Stefan Schippers"} C {devices/launcher} 450 -290 0 0 {name=h8 descr="XSCHEM WEBSITE" url="https://xschem.sourceforge.io/stefan/xschem.html" program=x-www-browser} C {devices/launcher} 450 -190 0 0 {name=h1 descr="XSCHEM ON SOURCEFORGE" url="https://sourceforge.net/projects/xschem/" program=x-www-browser} C {examples/cmos_example} 160 -350 0 0 {name=x6} C {devices/launcher} 450 -240 0 0 {name=h2 descr="LOCAL DOCUMENTATION" url="$env(HOME)/share/doc/xschem/xschem.html" program=x-www-browser } C {examples/greycnt} 160 -390 0 0 {name=x8} C {examples/loading} 160 -430 0 0 {name=x9} C {devices/launcher} 450 -140 0 0 {name=h3 descr="Toggle light/dark colorscheme" tclcommand="xschem toggle_colorscheme" } C {examples/inv} 930 -200 0 0 {name=E1 TABLE="1.4 3.0 1.6 0.0"} C {examples/pcb_test1} 160 -470 0 0 {name=x0} xschem-2.8.1/xschem_library/mylib/test.sch0000644000175100017510000000116713025347746017036 0ustar svnsvnG {} V {} S {} N 220 -470 260 -470 {lab=SET_BAR} N 220 -290 260 -290 {lab=CLEAR_BAR} N 360 -450 390 -450 {lab=Q} N 360 -310 390 -310 {lab=QBAR} N 260 -430 260 -410 {lab=QBAR} N 260 -410 360 -360 {lab=QBAR} N 360 -360 360 -310 {lab=QBAR} N 260 -350 260 -330 {lab=Q} N 260 -350 360 -400 {lab=Q} N 360 -450 360 -400 {lab=Q} C {mylib/nand2} 310 -450 0 0 {name=x1} C {devices/lab_pin} 390 -450 0 1 {name=p1 lab=Q} C {devices/lab_pin} 220 -470 0 0 {name=p2 lab=SET_BAR} C {devices/lab_pin} 220 -290 0 0 {name=p3 lab=CLEAR_BAR} C {mylib/nand2} 310 -310 2 1 {name=x2} C {devices/lab_pin} 390 -310 0 1 {name=p4 lab=QBAR} xschem-2.8.1/xschem_library/mylib/nand2.sym0000644000175100017510000000207413025347746017112 0ustar svnsvnG {type=subcircuit format="@name @pinlist @symname WP=@WP LP=@LP WN=@WN LN=@LN" template="name=x1 WP=8u LP=0.18u WN=5u LN=0.18u" } V {} S {} L 4 -50 -20 -35 -20 {} L 4 25 -2.5 25 2.5 {} L 4 25 -2.5 27.5 -5 {} L 4 27.5 -5 32.5 -5 {} L 4 32.5 -5 35 -2.5 {} L 4 35 -2.5 35 2.5 {} L 4 32.5 5 35 2.5 {} L 4 27.5 5 32.5 5 {} L 4 25 2.5 27.5 5 {} L 4 35 0 50 0 {} L 4 -35 -30 -35 30 {} L 4 -35 -30 -10 -30 {} L 4 -35 30 -10 30 {} L 4 -50 20 -35 20 {} L 4 2.5 -27.5 12.5 -22.5 {} L 4 -10 -30 2.5 -27.5 {} L 4 2.5 27.5 12.5 22.5 {} L 4 -10 30 2.5 27.5 {} L 4 12.5 22.5 20 15 {} L 4 20 15 23.75 7.5 {} L 4 23.75 7.5 25 0 {} L 4 12.5 -22.5 20 -15 {} L 4 20 -15 23.75 -7.5 {} L 4 23.75 -7.5 25 0 {} B 5 47.5 -2.5 52.5 2.5 {name=Z dir=out } B 5 -52.5 -22.5 -47.5 -17.5 {name=A dir=in } B 5 -52.5 17.5 -47.5 22.5 {name=B dir=in } T {@symname} 17.5 19 0 0 0.3 0.3 {} T {@name} 10 -37 0 0 0.2 0.2 {} T {Z} 20 -4 0 1 0.2 0.2 {} T {A} -30 -26.5 0 0 0.2 0.2 {} T {B} -30 13.5 0 0 0.2 0.2 {} T {P: @WP/@LP} -40 -65 0 0 0.4 0.4 {} T {N: @WN/@LN} -40 40 0 0 0.4 0.4 {} xschem-2.8.1/xschem_library/pcb/0000755000175100017510000000000013400743705014773 5ustar svnsvnxschem-2.8.1/xschem_library/pcb/connector.sym0000644000175100017510000000060313362731551017521 0ustar svnsvnG {type=label format="*.ipin @lab" tedax_format="footprint @name @footprint" template="name=C1 lab=xxx footprint=connector(1,1)" } V {} S {} E {} L 4 -45 0 0 -0 {} B 5 -2.5 -2.5 2.5 2.5 {name=CONN dir=inout pinnumber=1} T {@lab} -66.25 -8.75 0 1 0.33 0.33 {} T {@name} -38.75 -13.75 0 0 0.2 0.2 {} T {@#0:pinnumber} -5 5 0 1 0.1 0.1 {} P 4 5 -50 -5 -40 -5 -40 5 -50 5 -50 -5 {fill=true} xschem-2.8.1/xschem_library/pcb/res.sym0000644000175100017510000000161413347721520016321 0ustar svnsvnG {type=resistor format="@name @pinlist @value m=@m" verilog_format="tran @name ( @#0 , @#1 ) ;" tedax_format="footprint @name @footprint value @name @value device @name @device" template="name=R0 m=1 value=1k footprint=1206 device=resistor"} V {} S {} L 4 0 20 0 30 {} L 4 0 20 7.5 17.5 {} L 4 -7.5 12.5 7.5 17.5 {} L 4 -7.5 12.5 7.5 7.5 {} L 4 -7.5 2.5 7.5 7.5 {} L 4 -7.5 2.5 7.5 -2.5 {} L 4 -7.5 -7.5 7.5 -2.5 {} L 4 -7.5 -7.5 7.5 -12.5 {} L 4 -7.5 -17.5 7.5 -12.5 {} L 4 -7.5 -17.5 0 -20 {} L 4 0 -30 0 -20 {} L 4 2.5 -22.5 7.5 -22.5 {} L 4 5 -25 5 -20 {} B 5 -2.5 -32.5 2.5 -27.5 {name=p dir=inout propagate_to=1 pinnumber=1} B 5 -2.5 27.5 2.5 32.5 {name=m dir=inout propagate_to=0 pinnumber=2} T {@name} 15 -18.75 0 0 0.2 0.2 {} T {@value} 15 -3.75 0 0 0.2 0.2 {} T {m=@m} 15 11.25 0 0 0.2 0.2 {} T {@#0:pinnumber} -5 -25 0 1 0.12 0.12 {} T {@#1:pinnumber} -5 20 0 1 0.12 0.12 {} xschem-2.8.1/xschem_library/pcb/pcb_test1.sch0000644000175100017510000000570213362731551017365 0ustar svnsvnG {} V {} S {} E {} B 20 270 -550 860 -290 {} T {3 of 4 NANDS of a 74ls00} 500 -580 0 0 0.4 0.4 {} T {EXPERIMENTAL schematic for generating a tEDAx netlist 1) set netlist mode to 'tEDAx' (Options menu -> tEDAx netlist) 2) press 'Netlist' button on the right 3) resulting netlist is in pcb_test1.tdx } 240 -730 0 0 0.5 0.5 {} N 230 -330 300 -330 {lab=INPUT_B} N 230 -370 300 -370 {lab=INPUT_A} N 680 -420 750 -420 {lab=B} N 680 -460 750 -460 {lab=A} N 400 -350 440 -350 {lab=B} N 850 -440 890 -440 {lab=OUTPUT_Y} N 230 -440 300 -440 {lab=INPUT_F} N 230 -480 300 -480 {lab=INPUT_E} N 400 -460 440 -460 {lab=A} N 550 -190 670 -190 {lab=VCCFILT} N 590 -130 590 -110 {lab=ANALOG_GND} N 790 -190 940 -190 {lab=VCC5} N 890 -130 890 -110 {lab=ANALOG_GND} N 730 -110 890 -110 {lab=ANALOG_GND} N 730 -160 730 -110 {lab=ANALOG_GND} N 590 -110 730 -110 {lab=ANALOG_GND} N 440 -460 680 -460 {lab=A} N 500 -420 680 -420 {lab=B} N 500 -420 500 -350 {lab=B} N 440 -350 500 -350 {lab=B} C {devices/title} 160 -30 0 0 {name=l2 author="Stefan"} C {pcb/74ls00} 340 -350 0 0 {name=U1:2 risedel=100 falldel=200} C {pcb/74ls00} 790 -440 0 0 {name=U1:1 risedel=100 falldel=200} C {devices/lab_pin} 890 -440 0 1 {name=p0 lab=OUTPUT_Y} C {pcb/capa} 590 -160 0 0 {name=C0 m=1 value=100u device="electrolitic capacitor"} C {pcb/74ls00} 340 -460 0 0 {name=U1:4 risedel=100 falldel=200 power=VCC5 url="http://www.engrcs.com/components/74LS00.pdf"} C {pcb/7805} 730 -190 0 0 {name=U0 url="https://www.sparkfun.com/datasheets/Components/LM7805.pdf"} C {devices/lab_pin} 490 -190 0 0 {name=p20 lab=VCC12} C {devices/lab_pin} 940 -190 0 1 {name=p22 lab=VCC5} C {devices/lab_pin} 590 -110 0 0 {name=p23 lab=ANALOG_GND} C {pcb/capa} 890 -160 0 0 {name=C4 m=1 value=10u device="tantalium capacitor"} C {pcb/res} 520 -190 1 0 {name=R0 m=1 value=4.7 device="carbon resistor"} C {devices/lab_wire} 620 -460 0 0 {name=l3 lab=A} C {devices/lab_wire} 620 -420 0 0 {name=l0 lab=B} C {devices/lab_wire} 650 -190 0 0 {name=l1 lab=VCCFILT} C {pcb/connector} 230 -370 0 0 {name=CONN1 lab=INPUT_A verilog_type=reg} C {pcb/connector} 230 -330 0 0 {name=CONN2 lab=INPUT_B verilog_type=reg} C {pcb/connector} 240 -190 0 0 { name=CONN3 lab=OUTPUT_Y } C {pcb/connector} 230 -480 0 0 {name=CONN6 lab=INPUT_E verilog_type=reg} C {pcb/connector} 230 -440 0 0 {name=CONN8 lab=INPUT_F verilog_type=reg} C {pcb/connector} 240 -160 0 0 { name=CONN9 lab=VCC12 } C {pcb/connector} 240 -130 0 0 { name=CONN14 lab=ANALOG_GND verilog_type=reg} C {pcb/connector} 240 -100 0 0 { name=CONN15 lab=GND verilog_type=reg} C {devices/code} 1030 -280 0 0 {name=TESTBENCH_CODE only_toplevel=false value="initial begin $dumpfile(\\"dumpfile.vcd\\"); $dumpvars; INPUT_E=0; INPUT_F=0; INPUT_A=0; INPUT_B=0; ANALOG_GND=0; #10000; INPUT_A=1; INPUT_B=1; #10000; INPUT_E=1; INPUT_F=1; #10000; INPUT_F=0; #10000; INPUT_B=0; #10000; $finish; end assign VCC12=1; "} C {devices/verilog_timescale} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns" } xschem-2.8.1/xschem_library/pcb/74ls00.sym0000644000175100017510000000156313362731551016466 0ustar svnsvnG {type=nand verilog_format="nand #(@risedel , @falldel ) @name ( @#2 , @#0 , @#1 );" tedax_format="footprint @name @footprint device @name @symname" template="name=U1 footprint=\\"dip(14)\\" risedel=100 falldel=200 numslots=4 power=VCC ground=GND" extra="power ground" extra_pinnumber="14 7"} V {} S {} E {} L 4 -40 -20 -25 -20 {} L 4 -25 -30 -25 30 {} L 4 -25 -30 5 -30 {} L 4 -25 30 5 30 {} L 4 -40 20 -25 20 {} L 4 45 0 60 0 {} B 5 -42.5 -22.5 -37.5 -17.5 {name=A dir=in pinnumber=1:4:9:12} B 5 -42.5 17.5 -37.5 22.5 {name=B dir=in pinnumber=2:5:10:13} B 5 57.5 -2.5 62.5 2.5 {name=Z dir=out verilog_type=wire pinnumber=3:6:8:11} A 4 5 0 30 270 180 {} A 4 40 0 5 0 360 {} T {@name} -20 -15 0 0 0.2 0.2 {} T {@symname} -22.5 0 0 0 0.2 0.2 {} T {@#0:pinnumber} -22.5 -22.5 0 0 0.12 0.12 {} T {@#1:pinnumber} -22.5 17.5 0 0 0.12 0.12 {} T {@#2:pinnumber} 32.5 -2.5 0 1 0.12 0.12 {} xschem-2.8.1/xschem_library/pcb/pcb_test1.sym0000644000175100017510000000042413362731551017414 0ustar svnsvnG {type=subcircuit format="@name @pinlist @symname" verilog_stop=true template="name=x1" } V {} S {} E {} L 4 -130 -10 130 -10 {} L 4 -130 10 130 10 {} L 4 -130 -10 -130 10 {} L 4 130 -10 130 10 {} T {@symname} -58.5 -6 0 0 0.3 0.3 {} T {@name} 135 -22 0 0 0.2 0.2 {} xschem-2.8.1/xschem_library/pcb/capa.sym0000644000175100017510000000123413347721520016432 0ustar svnsvnG {type=capacitor format="@name @pinlist @value m=@m" tedax_format="footprint @name @footprint value @name @value device @name @device" verilog_ignore=true template="name=C0 m=1 value=1p footprint=1206 device=\\"ceramic capacitor\\""} V {} S {} L 4 0 5 0 30 {} L 4 0 -30 0 -5 {} L 4 -10 -5 10 -5 {} L 4 -10 5 10 5 {} L 4 2.5 -22.5 7.5 -22.5 {} L 4 5 -25 5 -20 {} B 5 -2.5 -32.5 2.5 -27.5 {name=p dir=in pinnumber=1} B 5 -2.5 27.5 2.5 32.5 {name=m dir=in pinnumber=2} T {@value} 15 -5 0 0 0.25 0.2 {} T {@name} 15 -18.75 0 0 0.2 0.2 {} T {m=@m} 15 10 0 0 0.25 0.2 {} T {@#0:pinnumber} -2.5 -25 0 1 0.12 0.12 {} T {@#1:pinnumber} -2.5 20 0 1 0.12 0.12 {} xschem-2.8.1/xschem_library/pcb/7805.sym0000644000175100017510000000133013347721520016126 0ustar svnsvnG {type=regulator format="x@name @pinlist r@symname" verilog_format="assign @#2 = @#0 ;" tedax_format="footprint @name @footprint device @name @symname" template="name=U1 footprint=TO220"} V {} S {} E {} L 4 -60 0 -50 0 {} L 4 50 0 60 0 {} L 4 -50 -20 50 -20 {} L 4 50 -20 50 20 {} L 4 -50 20 50 20 {} L 4 -50 -20 -50 20 {} L 4 0 20 0 30 {} B 5 -62.5 -2.5 -57.5 2.5 {name=IN dir=in pinnumber=1} B 5 -2.5 27.5 2.5 32.5 {name=GND dir=inout pinnumber=2} B 5 57.5 -2.5 62.5 2.5 {name=OUT dir=out pinnumber=3} T {@name} -17.5 -15 0 0 0.2 0.2 {} T {@symname} -17.5 0 0 0 0.2 0.2 {} T {@#0:pinnumber} -47.5 -2.5 0 0 0.12 0.12 {} T {@#1:pinnumber} -2.5 12.5 0 0 0.12 0.12 {} T {@#2:pinnumber} 47.5 -2.5 0 1 0.12 0.12 {} xschem-2.8.1/xschem_library/pcb/notes.txt0000644000175100017510000000563513347721520016676 0ustar svnsvnIgor2 simplest approach I can think of: have an user configurable search list of directories, and insert the File's path in front of it after load (File being the file the user wanted to open) that way any relative reference embedded in the File is always relative to wherever the File was on the filesystem when you loaded it so if you copied the File together with the stuff it referenced to, keeping whatever dir structure that worked on one system, will automatically work on the other plus, because of the search path list, you can keep the /lib approach for the system installed central xschem libs plus as an user I can build my own, non-project, user-level, shared library somewhere and put it on the search path list too (almost every gschem user I've ever met does this) so if File references to /home/foo/bar, that's an absolute path starting with / meaning you wouldn't apply any search path, just open the path as is if it doesn't start with /, e.g. it is ../foo/bar, you'd just take each item from the search path list, in order, and glue the reference path at the end of the search path item and try that e.g. if you search path list is /home/foo (the File's path you inserted on load), /home/user/libs (the lib the user configured) and /usr/share/xschem/lib (the system installed lib) stefan_xschem ok got it Igor2 then you'd try to open /home/foo/../foo/bar, if that fail go on and try /home/user/libs/../foo/bar, etc I think this would be very flexible yet pertty much compatible with the current setup (but I don't insist doing it this way, it's just an idea) tEDAx v1 begin netlist v1 linear_stab conn gnd U1 2 conn gnd CONN1 1 conn gnd CONN2 1 conn in U1 1 conn in CONN1 2 conn out U1 3 conn out CONN2 2 conn gnd C1 1 conn in C1 2 conn gnd C2 1 conn out C2 2 nettag in max_current 0.5A nettag out max_current 1A footprint CONN1 SIP2 footprint CONN2 SIP2 footprint U1 TO220 footprint C1 1206 footprint C2 1206 value C1 100 nf value C2 100 nf device C1 ceramic\ capacitor device C2 ceramic\ capacitor device U1 7805 comptag U1 heatsink yes end netlist tEDAx v1 begin netlist v1 NANDs device U5 74LS00 footprint U5 dip(14) conn gnd U5 7 conn vcc U5 14 conn gnd U5 1 conn gnd U5 2 conn gnd U5 4 conn gnd U5 5 conn gnd U5 9 conn gnd U5 10 conn gnd U5 12 conn gnd U5 13 pinname U5 7 ground pinname U5 14 power pinname U5 1 A pinname U5 2 B pinname U5 3 Y pinname U5 4 A pinname U5 5 B pinname U5 6 Y pinname U5 9 A pinname U5 10 B pinname U5 8 Y pinname U5 12 A pinname U5 13 B pinname U5 11 Y pinslot U5 1 1 pinslot U5 2 1 pinslot U5 3 1 pinidx U5 1 1 pinidx U5 2 2 pinidx U5 3 3 pinslot U5 4 2 pinslot U5 5 2 pinslot U5 6 2 pinidx U5 4 1 pinidx U5 5 2 pinidx U5 6 3 pinslot U5 9 3 pinslot U5 10 3 pinslot U5 8 3 pinidx U5 9 1 pinidx U5 10 2 pinidx U5 8 3 pinslot U5 12 4 pinslot U5 13 4 pinslot U5 11 4 pinidx U5 12 1 pinidx U5 13 2 pinidx U5 11 3 end netlist xschem-2.8.1/scconfig/0000755000175100017510000000000013400743705013007 5ustar svnsvnxschem-2.8.1/scconfig/Makefile0000644000175100017510000000651513372040355014455 0ustar svnsvn# --- configuration part -- # - generic configuration - # where scconfig source is; this is a path to a partial or full checkout of # svn://repo.hu/scconfig/trunk/src SRC=src/ # where compiled binaries (e.g. objects) should land; should be the same as # $(SRC) the project has its own copy of scconfig embedded BIN=src/ # what cflags to use to compile scconfig # If -DRUNTIME is specified, hooks.c should have the detect hook for runtime USER_CFLAGS = -DGENCALL -DRUNTIME -g # what ldflags to use to link scconfig USER_LDFLAGS = # in case hooks.c needs to link to something local USER_OBJS = # what to build - a ./configure all: configure # This line imports scconfig core and default tests include $(SRC)/default/Makefile.plugin # # - PLUGINS - # # Comment this line if you are not interested in c99 features #include $(SRC)/c99/Makefile.plugin # Comment this line if you do not need script libs to be detected include $(SRC)/scripts/Makefile.plugin # Comment this line if you do not need parser libs to be detected #include $(SRC)/parser/Makefile.plugin # Comment this line if you do not need to detect parser generators include $(SRC)/parsgen/Makefile.plugin # Comment this line if you do not need math related libs #include $(SRC)/math/Makefile.plugin # Comment this line if you do not need socket/networking #include $(SRC)/socket/Makefile.plugin # Comment this line if you do not need user/password API detection #include $(SRC)/userpass/Makefile.plugin # Comment this line if you do not need gui (X11, toolkits) include $(SRC)/gui/Makefile.plugin # Comment this line if you do not need tty (nurses, slang, pty-related calls) #include $(SRC)/tty/Makefile.plugin # Comment this line if you do not need software utility libs (gen*, glib) #include $(SRC)/sul/Makefile.plugin # Comment this line if you do not need to detect POSIX calls #include $(SRC)/posix/Makefile.plugin # Uncomment this line if you need menus #include $(SRC)/menulib/Makefile.plugin # Comment this line if you do not need tmpasm (templating); conflicts with generator include $(SRC)/tmpasm/Makefile.plugin # Uncomment this line if you need generator (deprecated templating); conflicts with tmpasm #include $(SRC)/generator/Makefile.plugin # --- you shouldn't edit the lines below --- OBJS = $(USER_OBJS) hooks.o $(DEFAULT_NOMAIN_OBJS) $(SCRIPT_OBJS) $(PARSER_OBJS) $(GENERATOR_OBJS) $(TMPASM_OBJS) $(C99_OBJS) $(PARSGEN_OBJS) $(MATH_OBJS) $(SOCKET_OBJS) $(USERPASS_OBJS) $(GUI_OBJS) $(TTY_OBJS) $(SUL_OBJS) $(POSIX_OBJS) CFLAGS = $(USER_CFLAGS) $(DEFAULT_CFLAGS) $(SCRIPT_CFLAGS) $(PARSER_CFLAGS) $(GENERATOR_CFLAGS) $(TMPASM_CFLAGS) $(C99_CFLAGS) $(PARSGEN_CFLAGS) $(MATH_CFLAGS) $(SOCKET_CFLAGS) $(USERPASS_CFLAGS) $(GUI_CFLAGS) $(TTY_CFLAGS) $(SUL_CFLAGS) $(POSIX_CFLAGS) $(MENULIB_CFLAGS) -I$(SRC)/default LDFLAGS = $(USER_LDFLAGS) $(DEFAULT_LDFLAGS) $(SCRIPT_LDFLAGS) $(PARSER_LDFLAGS) $(GENERATOR_LDFLAGS) $(TMPASM_LDFLAGS) $(C99_LDFLAGS) $(PARSGEN_LDFLAGS) $(MATH_LDFLAGS) $(SOCKET_LDFLAGS) $(USERPASS_LDFLAGS) $(GUI_LDFLAGS) $(TTY_LDFLAGS) $(SUL_LDFLAGS) $(POSIX_LDFLAGS) $(MENULIB_LDFLAGS) configure: $(OBJS) $(DEFAULT_MAIN_OBJS) $(CC) -o configure $(OBJS) $(DEFAULT_MAIN_OBJS) menuconfig: $(OBJS) $(MENULIB_OBJS) $(CC) -o configure $(OBJS) $(MENULIB_OBJS) clean: rm $(OBJS) $(DEFAULT_MAIN_OBJS) configure distclean: $(MAKE) clean ; true rm -f config.cache config.log xschem-2.8.1/scconfig/src/0000755000175100017510000000000013400743710013572 5ustar svnsvnxschem-2.8.1/scconfig/src/util/0000755000175100017510000000000013400743710014547 5ustar svnsvnxschem-2.8.1/scconfig/src/util/cquote.c0000644000175100017510000000641313304164013016213 0ustar svnsvn/* scconfig - quote file and pack it in a C string (ANSI C code) Copyright (C) 2016, 2018 Tibor 'Igor2' Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include void copy_strlit(const char *inds, const char *varname, const char *dprefix) { int c, nl = 0, qt = 1, ind = 1; const char *spc = (*dprefix == '\0') ? "" : " "; printf("#define NL \"\\n\"\n"); printf("%s%sconst char *%s = \\\n", dprefix, spc, varname); while((c = getc(stdin)) != EOF) { if (ind) { printf("%s", inds); if (!nl) printf(" "); ind = 0; } if (nl) { printf("NL "); nl = 0; } if (qt) { printf("\""); qt = 0; } switch(c) { case '\t': printf(" "); break; case '\n': printf("\"\n"); nl = qt = ind = 1; break; case '\r': break; case '\\': printf("\\\\"); break; case '"': printf("\\\""); break; default: if ((c < 32) || (c>126)) printf("\\%3o", c); else putc(c, stdout); } } if (!qt) printf("\""); if (nl) { if (ind) printf("%s", inds); printf("NL"); } printf(";\n"); } void copy_chrarr(const char *inds, const char *varname, const char *dprefix) { int c, col = 16000; const char *spc = (*dprefix == '\0') ? "" : " "; printf("/* (Using character array instead of string literal for long strings) */\n"); printf("%s%sconst char %s_arr[] = {", dprefix, spc, varname); while((c = getc(stdin)) != EOF) { if (col > 60) { printf("\n%s", inds); col = 0; } switch(c) { case '\t': col+=printf("'\\t',"); break; case '\r': break; case '\\': col+=printf("'\\\\',"); break; case '\'': col+=printf("'\\\'',"); break; case '\n': col+=printf("'\\n',"); col = 16000; break; default: if ((c < 32) || (c>126)) col+=printf("%d,", c); else col+=printf("'%c',", c); break; } } printf("\n%s0};\n", inds); printf("%s%sconst char *%s = %s_arr;\n", dprefix, spc, varname, varname); } int main(int argc, char *argv[]) { char *varname = "quoted_file"; char *inds = "\t"; char *banner = "/* Autogenerated by cquote.c - DO NOT EDIT */\n"; char *cmd, *arg, *dprefix = ""; int n, lit = 0; for(n = 1; n < argc; n++) { cmd = argv[n]; arg = argv[n+1]; while(*cmd == '-') cmd++; switch(*cmd) { case 'n': varname = arg; n++; break; case 'i': inds = arg; n++; break; case 'l': lit = 1; break; case 'p': dprefix = arg; n++; break; } } printf("%s", banner); if (lit) copy_strlit(inds, varname, dprefix); else copy_chrarr(inds, varname, dprefix); return 0; } xschem-2.8.1/scconfig/src/util/ls.c0000644000175100017510000000335011257357714015347 0ustar svnsvn/* scconfig - ls built on dirent Copyright (C) 2009 Szabolcs Nagy This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #ifdef _WIN32 #include static int ls(char *arg) { WIN32_FIND_DATA fd; HANDLE h; char p[MAX_PATH]; int i; for (i = 0; i+2 < MAX_PATH; i++) if (arg[i]) p[i] = arg[i]; if (i+2 < MAX_PATH) { p[i] = '\\'; p[i+1] = '*'; p[i+2] = 0; } else return -1; h = FindFirstFile(p, &fd); if (h == INVALID_HANDLE_VALUE) return -1; printf("%s\n", fd.cFileName); while (FindNextFile(h, &fd) != 0); printf("%s\n", fd.cFileName); FindClose(h); return 0; } #else #include static int ls(char *arg) { DIR *dirp; struct dirent *dp; if ((dirp = opendir(arg)) == 0) return -1; while ((dp = readdir(dirp)) != 0) printf("%s\n", dp->d_name); closedir(dirp); return 0; } #endif int main(int argc, char *argv[]) { int i; char *p = "."; if (argc > 1) p = argv[1]; return ls(p); } xschem-2.8.1/scconfig/src/util/arg_auto_set.c0000644000175100017510000000475613026416716017412 0ustar svnsvn/* scconfig - set nodes from tables upon user CLI arguments Copyright (C) 2015 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include "log.h" #include "libs.h" #include "db.h" #include "arg_auto_set.h" const arg_auto_set_node_t arg_lib_nodes[] = { {"presents", sfalse}, {"cflags", ""}, {"ldflags", ""}, {NULL, NULL} }; const arg_auto_set_node_t arg_true[] = { {"", strue}, {NULL, NULL} }; const arg_auto_set_node_t arg_false[] = { {"", sfalse}, {NULL, NULL} }; int arg_auto_set(const char *key, const char *value, const arg_auto_set_t *table) { const arg_auto_set_t *lib; const arg_auto_set_node_t *node; for(lib = table; lib->arg_key != NULL; lib++) { if (strcmp(key, lib->arg_key) == 0) { report("Executing lib table: %s\n", lib->arg_key); for(node = lib->subvals; node->name != NULL; node++) { char *s; const char *setval; setval = node->value; if (strcmp(setval, "$") == 0) setval = value; if (*node->name != '\0') { s = str_concat("/", lib->subtree, node->name, NULL); put(s, setval); free(s); } else put(lib->subtree, setval); } return 1; } } return 0; } void arg_auto_print_options(FILE *fout, const char *line_prefix, const char *padding, const arg_auto_set_t *table) { const arg_auto_set_t *t; int pl; pl = strlen(padding); for(t = table; t->arg_key != NULL; t++) { if (t->help_txt == NULL) continue; if (*t->help_txt == '$') { int kl = strlen(t->arg_key); if (kl > pl) kl = pl; fprintf(fout, "%s--%s%s%s\n", line_prefix, t->arg_key, padding+kl, t->help_txt+1); } else fprintf(fout, "%s%s\n", line_prefix, t->help_txt); } } xschem-2.8.1/scconfig/src/util/Makefile0000644000175100017510000000015513031705302016203 0ustar svnsvn#CC=i586-mingw32msvc-gcc #CFLAGS = -Wall -g sccbox: sccbox.c Makefile $(CC) $(CFLAGS) sccbox.c -o sccbox xschem-2.8.1/scconfig/src/util/arg_auto_menu.h0000644000175100017510000000054112661013253017545 0ustar svnsvn#include "util/arg_auto_set.h" /* An optional bridge between auto_set and menulib: create a submenu from an arg_auto_set_t table using regex key matching. */ void append_settings_auto_set(scm_menu_entry_t *me, int max, const arg_auto_set_t *as, const char *include, const char *exclude, const char *remove_prefix, int entry_type, void *entry_data); xschem-2.8.1/scconfig/src/util/arg_auto_menu.c0000644000175100017510000000441712661013253017546 0ustar svnsvn#include #include #include "regex.h" #include "libs.h" #include "db.h" #include "menulib/scmenu.h" #include "arg_auto_menu.h" static const char *get_entry_val(const arg_auto_set_t *as) { char *path; const char *v, *res; if (as->subvals == arg_lib_nodes) { path = str_concat("/", as->subtree, "presents", NULL); v = get(path); if ((v != NULL) && (strcmp(v, sfalse) == 0)) res = "disable"; else res = "enable"; free(path); return res; } } #define next_word(curr, next) \ do { \ next = strchr(curr, '|'); \ if (next != NULL) { \ *next = '\0'; \ next++; \ } \ } while(0) void append_settings_auto_set(scm_menu_entry_t *me, int max, const arg_auto_set_t *as, const char *include, const char *exclude, const char *remove_prefix, int entry_type, void *entry_data) { const arg_auto_set_t *a; scm_menu_entry_t *e; int numa, n, ei; char *accept; /* count number of all settings, allocate accept[] */ numa = 0; for(a = as; a->arg_key != NULL; a++) numa++; accept = calloc(numa, 1); /* mark entries included in accept[] */ if (include != NULL) { char *all = strclone(include), *next = all, *curr = all; do { next_word(curr, next); re_comp(curr); for(a = as, n = 0; a->arg_key != NULL; a++,n++) if (re_exec(a->arg_key)) accept[n] = 1; curr = next; } while((next != NULL) && (*next != '\0')); free(all); } else memset(accept, 1, numa); /* mark entries excluded in accept[] */ if (exclude != NULL) { char *all = strclone(exclude), *next = all, *curr = all; do { next_word(curr, next); re_comp(curr); for(a = as, n = 0; a->arg_key != NULL; a++,n++) if (re_exec(a->arg_key)) accept[n] = 0; curr = next; } while((next != NULL) && (*next != '\0')); free(all); } /* find the terminator */ for(e = me, ei = 0; e->key != SCM_TERMINATOR; e++, ei++) ; re_comp(remove_prefix); printf("exclude:\n"); for(n = 0; n < numa; n++) { if (accept[n]) { char *sd; if (re_exec(as[n].arg_key)) sd = re_subs_dup(""); else sd = strclone(as[n].arg_key); e->type = entry_type; e->key = sd; e->value = get_entry_val(&as[n]); e->user_data = &as[n]; e->auto_data = entry_data; e++; ei++; if (ei > max - 2) break; } } e->type = SCM_TERMINATOR; free(accept); } xschem-2.8.1/scconfig/src/util/sccbox.c0000644000175100017510000005556413376201211016210 0ustar svnsvn/* scconfig - sccbox: portable copy, link, mkdir and remove Copyright (C) 2016, 2017 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include #include #include /*********************** DOCUMENTATION **************************/ static void help_generic(const char *prg) { printf("sccbox - Makefile helper\n\n"); printf("Invocation: %s cmd [switches] [paths]\n\n", prg); printf("sccbox and provides a basic set of file-system utilities as a single,\n"); printf("static linkable executable with dependency only on libc. It is implemented\n"); printf("in C89 and uses only a very thin layer of non-C89 OS calls that trace\n"); printf("back to early BSD days and are widely available on all platforms.\n\n"); printf("The intention is to replace 'mkdir -p' and 'rm -f' and similar,\n"); printf("non-portable commands with a less efficient, but more portable local\n"); printf("implementation. Using sccbox for mkdir/install/uninstall exclusively also\n"); printf("simplifies the Makefile rules because the semantics of uninstall\n"); printf("matches the semantics of install and the same list of source files\n"); printf("and destination can be passed and source files are not removed.\n\n"); printf("For more info read the following help topics using --help topic:\n"); printf(" error error handling\n"); printf(" rm remove files (e.g. for make clean)\n"); printf(" mkdir create directories (e.g. for make *install)\n"); printf(" ln create symlink (e.g. for make *install)\n"); printf(" install copy-install files (e.g. for make install)\n"); printf(" linstall symlink-install files (e.g. for make linstall)\n"); printf(" uninstall remove files (e.g. for make uninstall)\n"); printf(" touch touch files (open for append)\n"); printf(" touchnew touch non-existing files, ignore existing files\n"); printf("\n"); } static void help_error(const char *prg) { printf("sccbox - error handling (all commands)\n\n"); printf("Any sccbox command by default will try to carry out the requested\n"); printf("operation assuming no errors, e.g. an mkdir will assume the target\n"); printf("directory does not exists but all parent directories are in place.\n"); printf("If such a command fails, the exit status is non-zero and error messages\n"); printf("are printed to stderr.\n\n"); printf("If the --quiet switch is specified, the command will try to do the same\n"); printf("but never prints error messages and always returns 0. This is useful\n"); printf("in situations when failure is expected (note: 2>/dev/null is not portable)\n\n"); printf("If the --force switch is specified, the command will make extre efforts,\n"); printf("sometimes even destructive ones, to fulfill the request. If it fails,\n"); printf("error messages are printed (unless --quiet).\n\n"); } static void help_rm_common(void) { printf(" --quiet don't print error messages and set exit status to 0\n"); printf(" --force a non-existing file is not an error\n"); } static void help_rm(const char *prg) { printf("sccbox rm [switches] paths\n\n"); printf("Remove one or more paths from the file system. Paths can be\n"); printf("files, symlinks and empty directories. Recursive removal is not\n"); printf("supported. If multiple paths specified, attempt to remove them all\n"); printf("even if some can not be removed.\n\n"); printf("Switches:\n"); help_rm_common(); printf("\n"); } static void help_mkdir(const char *prg) { printf("sccbox mkdir [switches] paths\n\n"); printf("Create one or more directories.\n\n"); printf("Switches:\n"); printf(" --quiet don't print error messages and set exit status to 0\n"); printf(" --force ignored (there's nothing to force)\n"); printf(" -p create parent directories automatically\n"); printf(" -i ignored\n"); printf(" -l ignored\n"); printf(" -c ignored\n"); printf(" -u do not do anyhting, exit 0\n"); printf(" -r do not do anyhting, exit 0\n\n"); } static void help_ln_common(void) { printf(" --quiet don't print error messages and set exit status to 0\n"); printf(" --force attempt to remove target if it exists\n"); } static void help_ln(const char *prg) { printf("sccbox ln [switches] existing new\n"); printf("sccbox ln [switches] existing1 existing2 ... dir\n\n"); printf("Create one or more symlinks. Intended for linking installed paths\n"); printf("to other installed paths.\n\n"); printf("Switches:\n"); help_ln_common(); printf(" --absolute convert existing paths to absolute paths\n\n"); printf(" --relative make single symlink point to relative path\n\n"); } static void help_install(const char *prg) { printf("sccbox install [switches] src_file dst_file\n"); printf("sccbox install [switches] src_file1 src_file2 ... dir\n\n"); printf("Copies (or links or removes) one or more files. Intended to install\n"); printf("files from the source or build tree to the installation root.\n\n"); printf("Switches:\n"); printf(" --quiet don't print error messages and set exit status to 0\n"); printf(" --force install: attempt to remove destination\n"); printf(" --absolute convert existing paths to absolute paths\n"); printf(" --relative make single symlink point to relative path\n\n"); printf(" -d force destination to be a directory (even remove old dest)\n"); printf(" -i install (copy) files\n"); printf(" -c install (copy) files\n"); printf(" -u uninstall (remove) files - see --help uninstall\n"); printf(" -r uninstall (remove) files - see --help uninstall\n"); printf(" -l linstall (symlink) files - see --help linstall\n\n"); } static void help_linstall(const char *prg) { printf("sccbox linstall [switches] src_file dst_file\n"); printf("sccbox linstall [switches] src_file1 src_file2 ... dir\n\n"); printf("Installs (a) file(s) using symlinks. Automatically convert src_file\n"); printf("paths to absolute paths. Intended for developers: if a package is\n"); printf("symlink-installed, it can be run from the installation after a\n"); printf("recompilation without needing to reinstall.\n\n"); printf("Switches:\n"); help_ln_common(); printf(" --preserve do not convert source paths to absolute\n\n"); } static void help_uninstall(const char *prg) { printf("sccbox uninstall [switches] src_file dst_file\n"); printf("sccbox uninstall [switches] src_file1 src_file2 ... dir\n\n"); printf("Remove (an) installed file(s). In the first form, src_file is ignored.\n"); printf("In the second form dir is used to calculate destination paths.\n\n"); printf("The purpose of this command is to unify install and uninstall rules:\n"); printf("unlike cp and rm, an 'sccbox install' and 'sccbox uninstall' can\n"); printf("be used with the same parameter list to install and uninstall a set of files\n\n"); printf("Switches:\n"); help_rm_common(); printf("\n"); } static void help_touch(const char *prg) { printf("sccbox touch file1 file2 ... fileN\n"); printf("sccbox touchnew file1 file2 ... fileN\n\n"); printf("Open all files listed, for append, and close them immedately.\n"); printf("This makes sure the files exist and also bumps their modification date.\n"); printf("Command touchnew ignores existing files; its primary use is to make\n"); printf("sure a file exists without making changes to already existing files.\n"); } static int help(const char *prg, const char *topic) { if (topic == NULL) help_generic(prg); else if (strcmp(topic, "error") == 0) help_error(prg); else if (strcmp(topic, "rm") == 0) help_rm(prg); else if (strcmp(topic, "mkdir") == 0) help_mkdir(prg); else if (strcmp(topic, "ln") == 0) help_ln(prg); else if (strcmp(topic, "install") == 0) help_install(prg); else if (strcmp(topic, "linstall") == 0) help_linstall(prg); else if (strcmp(topic, "uninstall") == 0) help_uninstall(prg); else if (strcmp(topic, "touch") == 0) help_touch(prg); else if (strcmp(topic, "touchnew") == 0) help_touch(prg); else { printf("No such help topic: %s\n", topic); return 1; } return 0; } /*********************** IMPLEMENTATION: low level **************************/ #ifdef PATH_MAX # define MY_PATH_MAX PATH_MAX #else # define MY_PATH_MAX 32768 #endif typedef enum { INSTALL, /* install with cp */ LINSTALL, /* install with symlinks */ UNINSTALL /* remove installed files */ } scc_mode_t; #define kill_flag argv[n] = NULL #define load_flags(code) \ do { \ int n, flags = 1; \ for(n = 1; n < argc; n++) { \ char *arg = argv[n]; \ if ((*arg == '-') && (flags)) { \ if ((arg[1] == '-') && (arg[2] == '\0')) { \ kill_flag; \ flags = 0; \ continue; \ } \ while(*arg == '-') arg++; \ { code; } \ } \ } \ } while(0) \ #define load_args_minus(delta, code) \ do { \ int n; \ for(n = 1; n < argc-delta; n++) {\ char *arg = argv[n]; \ if (arg != NULL) \ { code; } \ } \ } while(0); #define load_args(code) load_args_minus(0, code)\ static int safe_isdir(const char *path) { struct stat st; if (stat(path, &st) != 0) return 0; return S_ISDIR(st.st_mode); } static int safe_isfile(const char *path) { struct stat st; if (stat(path, &st) != 0) return 0; return S_ISREG(st.st_mode); } static int safe_remove(const char *src, int need_existing_fd, int quiet) { struct stat st; int exists; if (quiet) return remove(src); exists = stat(src, &st) == 0; if ((need_existing_fd) && (!exists)) { fprintf(stderr, "sccbox: Can't remove %s: no such file or directory\n", src); return 1; } if (exists && (remove(src) != 0)) { perror("sccbox"); fprintf(stderr, "sccbox: Can't remove %s\n", src); return 1; } return 0; } #define issep(chr) (((chr) == '/') || ((chr) == '\\')) static char *my_basename(const char *path) { const char *s = path + strlen(path); for(s--; s >= path; s--) { if (issep(*s)) return (char *)s+1; } return (char *)path; } static int path_concat(char *out, size_t out_len, const char *dir, const char *file) { char *bn = my_basename(file); size_t dlen = strlen(dir), blen = strlen(bn); if (dlen+blen+2 > out_len) return 1; memcpy(out, dir, dlen); out[dlen] = '/'; dlen++; memcpy(out+dlen, bn, blen+1); return 0; } static int safe_mkdir_p(const char *path); static int safe_copy(const char *src, const char *dst, int force, int quiet, int dst_is_dir) { char buff[16384], dst2[MY_PATH_MAX]; const char *dst_name = NULL; FILE *fd, *fs; struct stat st, dst_st; int err = 0, remove_dst = 1; if (stat(src, &st) != 0) { if (!quiet) fprintf(stderr, "sccbox: can't stat %s\n", src); return 1; } /* make sure symlinks/sockets/etc. are not copied into: remove any dst that's not a dir or a regular file */ if (stat(dst, &dst_st) == 0) { int try_remove = dst_is_dir ? (!S_ISDIR(dst_st.st_mode)) : (!S_ISDIR(dst_st.st_mode) || !S_ISREG(dst_st.st_mode)); if (try_remove) { if (remove(dst) != 0) { if (!quiet) fprintf(stderr, "sccbox: filed to remove non-regular/non-directory target %s\n", dst); return 1; } } } if (dst_is_dir) { remove_dst = 0; if (safe_mkdir_p(dst) != 0) { if (!quiet) fprintf(stderr, "sccbox: filed to create target directory %s\n", dst); return 1; } } fs = fopen(src, "rb"); if (fs == NULL) { if (!quiet) fprintf(stderr, "sccbox: can't copy %s to %s: can not open source for write\n", src, dst2); return 1; } if ((force) && (remove_dst)) remove(dst); fd = fopen(dst, "wb"); if (fd == NULL) { /* no luck opening the dest file, maybe dst is a directory, try to create a file under it */ if (path_concat(dst2, sizeof(dst2), dst, src) != 0) { if (!quiet) fprintf(stderr, "sccbox: can't copy %s to %s: resulting path is too long\n", src, dst); fclose(fs); return 1; } fd = fopen(dst2, "wb"); if ((fd == NULL) && (force)) { remove(dst2); fd = fopen(dst2, "wb"); if (fd == NULL) { /* dest was not a directory or couldn't host our new file; if force, try to overwrite whatever dst was */ remove(dst); fd = fopen(dst, "wb"); if (fd == NULL) { if (!quiet) fprintf(stderr, "sccbox: can't copy %s to %s: destination can not be overwritten\n", src, dst2); fclose(fs); return 1; } dst_name = dst; } } if (fd == NULL) { if (!quiet) fprintf(stderr, "sccbox: can't copy %s to %s: can not open destination for write\n", src, dst2); fclose(fs); return 1; } if (dst_name == NULL) dst_name = dst2; } else dst_name = dst; /* manual copy - the only portable way */ for(;;) { size_t len = fread(buff, 1, sizeof(buff), fs); if (len == 0) break; if (fwrite(buff, 1, len, fd) != len) { if (!quiet) { perror("sccbox"); fprintf(stderr, "sccbox: can't copy %s to %s\n", src, dst_name); } err = 1; if (!force) break; } } chmod(dst_name, st.st_mode); /* this may fail on windows or on strange FS, don't check the return value */ fclose(fs); fclose(fd); return err; } static const char *safe_get_pwd(int quiet) { static char pwd_buff[MY_PATH_MAX]; static int valid = 0; if (!valid) { FILE *f; char *end; f = popen("pwd", "r"); if (f == NULL) { if (!quiet) perror("sccbox: running pwd"); return NULL; } if (fgets(pwd_buff, sizeof(pwd_buff), f) == NULL) { if (!quiet) perror("sccbox: reading pwd's output"); pclose(f); return NULL; } pclose(f); end = pwd_buff + strlen(pwd_buff) - 1; while((end >= pwd_buff) && ((*end == '/') || (*end == '\n') || (*end == '\r'))) { *end = '\0'; end--; } if (*pwd_buff != '/') { if (!quiet) fprintf(stderr, "sccbox: invalid pwd: '%s'\n", pwd_buff); return NULL; } valid = 1; } return pwd_buff; } /* Both 'path' and 'from' are absolute paths; recalculate path to be a relative path from 'from' and copy the result to buf. Returns buf. */ char *relativize(char *buf, const char *path, const char *from) { const char *p, *f, *c, *lastp, *lastf; char *end = buf; int cnt = 0, rem = MY_PATH_MAX-1, len; for(lastp = p = path, lastf = f = from; *p == *f; p++,f++) { /* skip double separators */ if (issep(p[0])) { while(issep(p[0]) && issep(p[1])) p++; lastp = p+1; } if (issep(f[0])) { while(issep(f[0]) && issep(f[1])) f++; lastf = f+1; } } p = lastp; f = lastf; for(c = f; *c != '\0'; c++) { if (issep(c[0])) { cnt++; while(issep(c[0]) && issep(c[1])) c++; } } while(cnt > 0) { if (rem < 3) return NULL; strcpy(end, "../"); end += 3; rem -= 3; cnt--; } len = strlen(p); if (len >= rem) return NULL; strcpy(end, p); return buf; } /* create a symlink - needs to work only on UNIX but needs to compile on win32, so use system("ln -s") and avoid link-related syscalls */ static int safe_link(const char *src, const char *dst, int absolute, int relative, int force, int quiet, int dst_is_dir) { char cmd[MY_PATH_MAX*2+16], full_src_tmp[MY_PATH_MAX], rel_src_tmp[MY_PATH_MAX]; const char *full_src, *supp; int remove_dst = 1; if ((absolute) && (*src != '/')) { /* fix up relative source paths */ const char *pwd = safe_get_pwd(quiet); if (pwd == NULL) { if (!quiet) fprintf(stderr, "sccbox: can't figure current working directory for relative symlink %s to %s\n", src, dst); return 1; } if (path_concat(full_src_tmp, sizeof(full_src_tmp), pwd, src) != 0) { if (!quiet) fprintf(stderr, "sccbox: can't link %s to %s: resulting path is too long\n", src, dst); return 1; } full_src = full_src_tmp; } else full_src = src; if (dst_is_dir) { struct stat dst_st; if ((stat(dst, &dst_st) == 0) && (!S_ISDIR(dst_st.st_mode))) { if (remove(dst) != 0) { if (!quiet) fprintf(stderr, "sccbox: filed to remove non-directory target %s\n", dst); return 1; } } remove_dst = 0; if (safe_mkdir_p(dst) != 0) { if (!quiet) fprintf(stderr, "sccbox: filed to create target directory %s\n", dst); return 1; } } if (force) remove(dst); supp = quiet ? " 2>/dev/null" : ""; if (relative) { const char *fdst; char full_dst_tmp[MY_PATH_MAX]; if (*dst != '/') { const char *pwd = safe_get_pwd(quiet); if (pwd == NULL) { if (!quiet) fprintf(stderr, "sccbox: can't figure current working directory for relative path '%s'\n", dst); return 1; } if (path_concat(full_dst_tmp, sizeof(full_dst_tmp), pwd, dst) != 0) { if (!quiet) fprintf(stderr, "sccbox: can't link %s to %s: resulting path is too long\n", src, dst); return 1; } fdst = full_dst_tmp; } else fdst = dst; full_src = relativize(rel_src_tmp, full_src, fdst); } sprintf(cmd, "ln -s \"%s\" \"%s\"%s", full_src, dst, supp); return system(cmd); } static int safe_mkdir_p(const char *path) { char *curr, *next, *s; int res = 1, len = strlen(path); char *p = malloc(len+1); memcpy(p, path, len+1); /* do not create existing directories */ if (safe_isdir(path)) return 0; curr = p; if ((isalpha(p[0]) && (p[1] == ':') && issep(p[2]))) { /* windows special case: c:\ */ curr += 3; } /* remove trailing path separators so we don't create empty dirs at the end */ s = p+len-1; while((s >= p) && (issep(*s))) { *s = '\0'; s--; } for(next = curr; next != NULL; curr = next) { char old; next = strpbrk(curr, "/\\"); if (next != NULL) { old = *next; *next = '\0'; } res = mkdir(p, 0755); if (next != NULL) { *next = old; next++; } } if (res != 0) { perror("sccbox"); fprintf(stderr, "sccbox: failed to make directory with parents: %s\n", path); } free(p); return res; /* return the result of the last mkdir only, previous failures probably meant existing parents */ } static int safe_touch(const char *fn) { FILE *f; f = fopen(fn, "a"); if (f == NULL) return -1; fclose(f); return 0; } /*********************** IMPLEMENTATION: high level **************************/ int cmd_rm(int argc, char *argv[]) { int err = 0, quiet = 0, need_existing_fd = 1; load_flags( switch(*arg) { case 'f': need_existing_fd = 0; kill_flag; break; /* nop: can't do more than remove() */ case 'q': quiet = 1; kill_flag; break; } ); load_args( err |= safe_remove(arg, need_existing_fd, quiet); ); if (quiet) return 0; return err; } int cmd_install(int argc, char *argv[], scc_mode_t mode, int absolute) { int force = 0, err = 0, quiet = 0, dst_is_dir, force_dst_dir = 0, relative = 0; const char *last; load_flags( if ((arg[0] == 'r') && (arg[1] == 'e')) arg[0] = 'R'; /* --relative */ switch(*arg) { case 'c': /* --copy */ case 'i': /* --install */ mode = INSTALL; kill_flag; break; case 'l': /* --ln or --linstall */ mode = LINSTALL; kill_flag; break; case 'r': /* --rm */ case 'u': /* --uninstall */ mode = UNINSTALL; kill_flag; break; case 'f': /* --force */ force = 1; kill_flag; break; case 'd': /* --directory */ force_dst_dir = 1; kill_flag; break; case 'q': /* --quiet */ quiet = 1; kill_flag; break; case 'p': /* --preserve */ absolute = 0; kill_flag; break; case 'a': /* --absolute */ absolute = 1; kill_flag; break; case 'R': /* --relative */ relative = 1; kill_flag; break; } ); last = argv[argc-1]; dst_is_dir = safe_isdir(last); load_args_minus(1, /*printf("arg=%s last=%s force=%d q=%d d=%d\n", arg, last, force, quiet, force_dst_dir);*/ switch(mode) { case INSTALL: err |= safe_copy(arg, last, force, quiet, force_dst_dir); break; case LINSTALL: err |= safe_link(arg, last, absolute, relative, force, quiet, force_dst_dir); break; case UNINSTALL: if (dst_is_dir) { char path[MY_PATH_MAX]; if (path_concat(path, sizeof(path), last, arg) != 0) { if (!quiet) { fprintf(stderr, "sccbox: can't remove %s/%s: resulting path is too long\n", last, arg); err |= 1; } } else err |= safe_remove(path, !force, quiet); } break; } if ((mode == UNINSTALL) && (!dst_is_dir)) err |= safe_remove(last, !force, quiet); ); if (quiet) return 0; return err; } int cmd_mkdir(int argc, char *argv[]) { int parents = 0, err = 0, quiet = 0; load_flags( switch(*arg) { case 'q': /* --quiet */ quiet = 1; kill_flag; break; case 'f': kill_flag; break; case 'i': case 'l': case 'c': kill_flag; break; /* ignore these for compatibility with install */ case 'r': /* --rm */ case 'u': /* --uninstall */ return 0; /* don't do anything for uninstall */ case 'p': parents = 1; kill_flag; break; } ); if (!parents) { load_args( if ((mkdir(arg, 0755) != 0) && (!quiet)) { perror("sccbox"); fprintf(stderr, "sccbox: failed to make directory %s\n", arg); err |= 1; } ) } else { load_args( err |= safe_mkdir_p(arg); ); } if (quiet) return 0; return err; } int cmd_touch(int argc, char *argv[], int only_new) { int n, res = 0; for(n = 1; n < argc; n++) { if ((only_new) && (safe_isfile(argv[n]))) continue; /* skip existing file in touchnew */ if (safe_touch(argv[n]) != 0) { res = 1; fprintf(stderr, "sccbox: failed to touch %s\n", argv[n]); } } return res; } int main(int argc, char *argv[]) { const char *prg = argv[0]; if (argc > 1) { if (strstr(argv[0], "sccbox") != NULL) { argv++; argc--; } if (strcmp(argv[0], "--help") == 0) return help(prg, argv[1]); if (strcmp(argv[0], "help") == 0) return help(prg, argv[1]); if (strcmp(argv[0], "-h") == 0) return help(prg, argv[1]); if (strcmp(argv[0], "rm") == 0) return cmd_rm(argc, argv); if (strcmp(argv[0], "install") == 0) return cmd_install(argc, argv, INSTALL, 1); if (strcmp(argv[0], "linstall") == 0) return cmd_install(argc, argv, LINSTALL, 1); if (strcmp(argv[0], "uninstall") == 0) return cmd_install(argc, argv, UNINSTALL, 1); if (strcmp(argv[0], "mkdir") == 0) return cmd_mkdir(argc, argv); if (strcmp(argv[0], "ln") == 0) return cmd_install(argc, argv, LINSTALL, 0); if (strcmp(argv[0], "touch") == 0) return cmd_touch(argc, argv, 0); if (strcmp(argv[0], "touchnew") == 0) return cmd_touch(argc, argv, 1); fprintf(stderr, "sccbox: unknown command %s\n", argv[0]); } else fprintf(stderr, "sccbox: need arguments\n"); fprintf(stderr, "sccbox: try --help\n"); return 1; } xschem-2.8.1/scconfig/src/util/arg_auto_set.h0000644000175100017510000000401512750535606017406 0ustar svnsvn#ifndef ARG_AUTO_SET_H #define ARG_AUTO_SET_H /* Handle a list of --disable-LIBs automatically. The user sets up a table like: static const arg_auto_set_t disable_libs[] = { {"disable-gtk", "libs/gui/gtk2", arg_lib_nodes}, {"disable-lesstif", "libs/gui/lesstif2", arg_lib_nodes}, {NULL, NULL, NULL} }; and at the end of hook_custom_arg() executes: return arg_auto_set(key, value, disable_libs); The call will set all nodes listed in arg_lib_nodes to disable gtk or lesstif. Mechanism: this happens before require()s on these nodes; require() will find them already set and won't run the detection. Thus it is suitable for disabling features (but not for enabling them). */ /* A table of node name-values to be set under a subtree */ typedef struct { const char *name; const char *value; } arg_auto_set_node_t; /* A table of argument->subtree->subtree_values */ typedef struct { const char *arg_key; /* command line argument without the -- prefix */ const char *subtree; /* subtree path affected, e.g. libs/gui/gtk2 */ const arg_auto_set_node_t *subvals; /* a set of values to be put() under the subtree */ const char *help_txt; } arg_auto_set_t; /* node set table for resetting the usual nodes under a library subtree: presents, cflags, ldflags */ extern const arg_auto_set_node_t arg_lib_nodes[]; /* set the node true or false */ extern const arg_auto_set_node_t arg_true[]; extern const arg_auto_set_node_t arg_false[]; /* Execute table: find a match on key and set all subvals of the match */ int arg_auto_set(const char *key, const char *value, const arg_auto_set_t *table); /* Print options help from the table, one entry per line; if help text starts with $, replace that with --arg_key and insert padding after that; padding should be a string filled with spaces, as long as the longest argument key plus the separator spaces. */ void arg_auto_print_options(FILE *fout, const char *line_prefix, const char *padding, const arg_auto_set_t *table); #endif xschem-2.8.1/scconfig/src/parsgen/0000755000175100017510000000000013400743710015231 5ustar svnsvnxschem-2.8.1/scconfig/src/parsgen/INIT.h0000644000175100017510000000003211310146553016140 0ustar svnsvnvoid deps_parsgen_init(); xschem-2.8.1/scconfig/src/parsgen/INIT.c0000644000175100017510000000002711310146553016137 0ustar svnsvn deps_parsgen_init(); xschem-2.8.1/scconfig/src/parsgen/find_parsgen.c0000644000175100017510000000744113371077006020047 0ustar svnsvn/* scconfig - parser generator detection Copyright (C) 2009 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include "libs.h" #include "log.h" #include "db.h" #include "dep.h" int find_parsgen_flex(const char *name, int logdepth, int fatal) { const char *test_flex = NL "%%" NL "foo { return 1; }" NL "%%" NL ; char *out, *temp_in, *temp_in_esc, *cmd; int ret; char *lexfile = "lex.yy.c"; (void) fatal; /* not used */ report("Checking for flex... "); logprintf(logdepth, "find_flex: trying to find flex...\n"); logdepth++; if (is_file(lexfile)) { report("ERROR: %s exists, and I don't dare to delete it. Can't test flex, please remove the file by hand.\n", lexfile); logprintf(logdepth, "ERROR: %s exists, and I don't dare to delete it. Can't test flex, please remove the file by hand.\n", lexfile); exit(1); } temp_in = tempfile_dump(test_flex, ".lex"); temp_in_esc = shell_escape_dup(temp_in); cmd = malloc(strlen(temp_in_esc) + 16); sprintf(cmd, "flex %s", temp_in_esc); free(temp_in_esc); ret = run(logdepth, cmd, &out); remove(temp_in); free(temp_in); if (out != NULL) free(out); if (is_file(lexfile)) { remove(lexfile); if (ret == 0) { put("parsgen/flex", "flex"); put("parsgen/flex/presents", strue); report("Found.\n"); return 0; } } put("parsgen/flex/presents", sfalse); report("Not found.\n"); return 1; } int find_parsgen_bison(const char *name, int logdepth, int fatal) { const char *test_bison = NL "%union { char *str; double num;}" NL "%%" NL "%token TOK1;" NL "%token TOK2;" NL "root: one | two;" NL "one: TOK1;" NL "two: TOK2;" NL ; char *out, *temp_in, *temp_in_esc, *cmd; int ret; char *bisfile, *s; (void) fatal; /* not used */ report("Checking for bison... "); logprintf(logdepth, "find_bison: trying to find bison...\n"); logdepth++; temp_in = tempfile_dump(test_bison, ".y"); bisfile = malloc(strlen(temp_in) + 32); strcpy(bisfile, temp_in); s = strrchr(bisfile+1, '.'); strcpy(s, ".tab.c"); if (is_file(bisfile)) { report("ERROR: %s exists, and I don't dare to delete it. Can't test bison, please remove the file by hand.\n", bisfile); logprintf(logdepth, "ERROR: %s exists, and I don't dare to delete it. Can't test bison, please remove the file by hand.\n", bisfile); exit(1); } temp_in_esc = shell_escape_dup(temp_in); cmd = malloc(strlen(temp_in_esc) + 16); sprintf(cmd, "bison %s", temp_in_esc); free(temp_in_esc); ret = run(logdepth, cmd, &out); remove(temp_in); free(temp_in); if (out != NULL) free(out); if (is_file(bisfile)) { remove(bisfile); if (ret == 0) { put("parsgen/bison", "bison"); put("parsgen/bison/presents", strue); report("Found.\n"); return 0; } } put("parsgen/bison/presents", sfalse); report("Not found.\n"); return 1; } void deps_parsgen_init() { dep_add("parsgen/flex/*", find_parsgen_flex); dep_add("parsgen/bison/*", find_parsgen_bison); } xschem-2.8.1/scconfig/src/parsgen/Makefile.plugin0000644000175100017510000000034412740411267020174 0ustar svnsvnPARSGEN_CFLAGS = -DPLUGIN_PARSGEN PARSGEN_OBJS = \ $(BIN)/parsgen/find_parsgen.o $(BIN)/parsgen/find_parsgen.o: $(SRC)/parsgen/find_parsgen.c $(CC) $(CFLAGS) -c $(SRC)/parsgen/find_parsgen.c -o $(BIN)/parsgen/find_parsgen.o xschem-2.8.1/scconfig/src/gui/0000755000175100017510000000000013400743710014356 5ustar svnsvnxschem-2.8.1/scconfig/src/gui/find_gtk3.h0000644000175100017510000000007313240634424016402 0ustar svnsvnint find_gtk3(const char *name, int logdepth, int fatal); xschem-2.8.1/scconfig/src/gui/find_gtk2.h0000644000175100017510000000027313240634424016403 0ustar svnsvnint find_gtk2(const char *name, int logdepth, int fatal); int find_gtk2gl(const char *name, int logdepth, int fatal); int find_gtk2_modversion(const char *name, int logdepth, int fatal); xschem-2.8.1/scconfig/src/gui/find_x.h0000644000175100017510000000066713370514772016021 0ustar svnsvnint find_xinerama(const char *name, int logdepth, int fatal); int find_xrender(const char *name, int logdepth, int fatal); int find_xopendisplay(const char *name, int logdepth, int fatal); int find_xcb(const char *name, int logdepth, int fatal); int find_xcb_render(const char *name, int logdepth, int fatal); int find_xgetxcbconnection(const char *name, int logdepth, int fatal); int find_xpm(const char *name, int logdepth, int fatal); xschem-2.8.1/scconfig/src/gui/find_gtk3.c0000644000175100017510000000516213240634424016401 0ustar svnsvn/* scconfig - gui lib detection - gtk3 Copyright (C) 2017 Alain Vigne This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include "libs.h" #include "log.h" #include "db.h" #include "dep.h" int find_gtk3(const char *name, int logdepth, int fatal, const char *call, const char *arg) { const char *test_c = NL "#include " NL NL "static void" NL "activate (GtkApplication* app," NL " gpointer user_data)" NL "{" NL " GtkWidget *window;" NL NL " window = gtk_application_window_new (app);" NL " gtk_window_set_title (GTK_WINDOW (window), \"Window\");" NL " gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);" NL " gtk_widget_show_all (window);" NL "}" NL NL "int" NL "main (int argc," NL " char **argv)" NL "{" NL " GtkApplication *app;" NL " int status;" NL NL " app = gtk_application_new (\"org.gtk.example\", G_APPLICATION_FLAGS_NONE);" NL " g_signal_connect (app, \"activate\", G_CALLBACK (activate), NULL);" NL " status = g_application_run (G_APPLICATION (app), argc, argv);" NL " g_object_unref (app);" NL NL " return status;" NL "}"; const char *node = "libs/gui/gtk3"; const char *pkgname = "gtk+-3.0"; char *cflags; char *ldflags; (void) call; /* not used */ (void) arg; /* not used */ if (require("cc/cc", logdepth, fatal)) return try_fail(logdepth, node); report("Checking for gtk+3... "); logprintf(logdepth, "find_gtk3: running pkg-config...\n"); logdepth++; if (run_pkg_config(logdepth, pkgname, &cflags, &ldflags) != 0) { return try_fail(logdepth, node); } if (try_icl_norun(logdepth, node, test_c, NULL, cflags, ldflags) == 0) { free(cflags); free(ldflags); return try_fail(logdepth, node); } free(cflags); free(ldflags); return 0; } xschem-2.8.1/scconfig/src/gui/INIT.h0000644000175100017510000000002612212564735015300 0ustar svnsvnvoid deps_gui_init(); xschem-2.8.1/scconfig/src/gui/find_gtk2.c0000644000175100017510000000663213240634424016403 0ustar svnsvn/* scconfig - gui lib detection - gtk2 Copyright (C) 2013 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include "libs.h" #include "log.h" #include "db.h" #include "dep.h" static const char *node = "libs/gui/gtk2"; static const char *nodegl = "libs/gui/gtk2gl"; static const char *pkgname = "gtk+-2.0"; static const char *pkgnamegl = "gtkglext-x11-1.0"; int find_gtk2(const char *name, int logdepth, int fatal, const char *call, const char *arg) { const char *test_c = NL "#include " NL "#include " NL NL "int main(int argc, char *argv[])" NL "{" NL " GtkWidget* mainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);" NL " gtk_window_set_default_size(GTK_WINDOW(mainWindow), 500, 500);" NL " gtk_window_set_title(GTK_WINDOW(mainWindow), \"foobar\");" NL " gtk_widget_show_all(mainWindow);" NL " gtk_main();" NL " return EXIT_SUCCESS;" NL "}"; char *cflags; char *ldflags; (void) call; /* not used */ (void) arg; /* not used */ if (require("cc/cc", logdepth, fatal)) return try_fail(logdepth, node); report("Checking for gtk+2... "); logprintf(logdepth, "find_gtk2: running pkg-config...\n"); logdepth++; if (run_pkg_config(logdepth, pkgname, &cflags, &ldflags) != 0) { return try_fail(logdepth, node); } if (try_icl_norun(logdepth, node, test_c, NULL, cflags, ldflags) == 0) { free(cflags); free(ldflags); return try_fail(logdepth, node); } free(cflags); free(ldflags); return 0; } int find_gtk2gl(const char *name, int logdepth, int fatal, const char *call, const char *arg) { const char *test_c = NL "#include " NL "#include " NL "#include " NL NL "int main(int argc, char *argv[])" NL "{" NL " gtk_gl_init(&argc, &argv);" NL " return EXIT_SUCCESS;" NL "}"; char *cflags; char *ldflags; (void) call; /* not used */ (void) arg; /* not used */ if (require("cc/cc", logdepth, fatal)) return try_fail(logdepth, nodegl); report("Checking for gtk+2 with GL... "); logprintf(logdepth, "find_gtk2gl: running pkg-config...\n"); logdepth++; if (run_pkg_config(logdepth, pkgnamegl, &cflags, &ldflags) != 0) { return try_fail(logdepth, nodegl); } if (try_icl_norun(logdepth, nodegl, test_c, NULL, cflags, ldflags) == 0) { free(cflags); free(ldflags); return try_fail(logdepth, nodegl); } free(cflags); free(ldflags); return 0; } int find_gtk2_modversion(const char *name, int logdepth, int fatal) { if (run_pkg_config_modversion_db(logdepth, node, pkgname) != 0) return try_fail(logdepth, node); return 0; } xschem-2.8.1/scconfig/src/gui/find_gl.h0000644000175100017510000000035013240634424016132 0ustar svnsvnint find_gl(const char *name, int logdepth, int fatal); int find_glu(const char *name, int logdepth, int fatal); int find_glut(const char *name, int logdepth, int fatal); int find_gui_wgl(const char *name, int logdepth, int fatal); xschem-2.8.1/scconfig/src/gui/find_x.c0000644000175100017510000002167413371462406016012 0ustar svnsvn/* scconfig - gui lib detection - lesstif Copyright (C) 2015 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include "libs.h" #include "log.h" #include "db.h" #include "dep.h" int find_xopendisplay(const char *name, int logdepth, int fatal) { const char *test_c = NL "#include " NL "#include " NL "int main()" NL "{" NL " Display *d = XOpenDisplay(NULL);" NL " return 0;" NL "}"; const char *node = "libs/gui/xopendisplay"; char **cflags, *cflags_arr[] = {"", "-I/opt/X11/include", "-I/usr/X11R6/include", NULL}; char **ldflags, *ldflags_arr[] = {"-lX11", "-L/opt/X11/lib -lX11", "-L/usr/X11R6/lib -lX11", NULL}; char **Lflags, *Lflags_arr[] = {"", "-L/opt/X11/lib", "-L/usr/X11R6/lib", NULL}; if (require("cc/cc", logdepth, fatal)) return 1; report("Checking for XOpenDisplay... "); logprintf(logdepth, "find_xopendisplay:\n"); logdepth++; for(cflags = cflags_arr; *cflags != NULL; cflags++) { for(ldflags = ldflags_arr, Lflags = Lflags_arr; *ldflags != NULL; ldflags++,Lflags++) { if (try_icl_norun(logdepth, node, test_c, NULL, *cflags, *ldflags) != 0) { put("libs/gui/xopendisplay/Lflags", *Lflags); return 0; } } } return try_fail(logdepth, node); } int find_xinerama(const char *name, int logdepth, int fatal) { const char *test_c = NL "#include " NL "#include " NL "int main()" NL "{" NL " Display *d = XOpenDisplay(NULL);" NL " if (d != NULL)" NL " XineramaIsActive(d);" NL " return 0;" NL "}"; const char *node = "libs/gui/xinerama"; char **cflags, *cflags_arr[] = {"", NULL}; char **ldflags, *ldflags_arr[] = {"-lXinerama", NULL}; const char *xincludes, *xcflags, *xldflags; if (require("cc/cc", logdepth, fatal)) return 1; if (require("libs/gui/xopendisplay/*", logdepth, fatal)) return 1; xincludes = get("libs/gui/xopendisplay/includes"); xcflags = get("libs/gui/xopendisplay/cflags"); xldflags = get("libs/gui/xopendisplay/ldflags"); report("Checking for Xinerama... "); logprintf(logdepth, "find_xinerama:\n"); logdepth++; for(cflags = cflags_arr; *cflags != NULL; cflags++) { for(ldflags = ldflags_arr; *ldflags != NULL; ldflags++) { if (try_icl_with_deps(logdepth, node, test_c, NULL, *cflags, *ldflags, xincludes, xcflags, xldflags, 0) != 0) { return 0; } } } return try_fail(logdepth, node); } int find_xrender(const char *name, int logdepth, int fatal) { const char *test_c = NL "#include " NL "#include " NL "#include " NL "int main()" NL "{" NL " Display *d = XOpenDisplay(NULL);" NL " XRenderFreePicture (d, 0);" NL " return 0;" NL "}"; const char *node = "libs/gui/xrender"; char **cflags, *cflags_arr[] = {"", NULL}; char **ldflags, *ldflags_arr[] = {"-lXrender", NULL}; const char *xincludes, *xcflags, *xldflags; if (require("cc/cc", logdepth, fatal)) return 1; if (require("libs/gui/xopendisplay/*", logdepth, fatal)) return 1; xincludes = get("libs/gui/xopendisplay/includes"); xcflags = get("libs/gui/xopendisplay/cflags"); xldflags = get("libs/gui/xopendisplay/ldflags"); report("Checking for Xrender... "); logprintf(logdepth, "find_xrender:\n"); logdepth++; for(cflags = cflags_arr; *cflags != NULL; cflags++) { for(ldflags = ldflags_arr; *ldflags != NULL; ldflags++) { if (try_icl_with_deps(logdepth, node, test_c, NULL, *cflags, *ldflags, xincludes, xcflags, xldflags, 0) != 0) { return 0; } } } return try_fail(logdepth, node); } int find_xcb(const char *name, int logdepth, int fatal) { const char *test_c = NL "#include " NL "#include " NL "#include " NL "int main()" NL "{" NL " char *host;" NL " int display, screen;" NL " if (xcb_parse_display(\"ford:42.8\", &host, &display, &screen) == 0) return 0;" NL " if ((strcmp(host, \"ford\") == 0) && (display == 42) && (screen == 8))" NL " puts(\"OK\");" NL " return 0;" NL "}"; const char *node = "libs/gui/xcb"; char **cflags, *cflags_arr[] = {"", NULL}; char **ldflags, *ldflags_arr[] = {"-lxcb", NULL}; const char *xincludes, *xcflags, *xldflags; if (require("cc/cc", logdepth, fatal)) return 1; if (require("libs/gui/xopendisplay/*", logdepth, fatal)) return 1; xincludes = get("libs/gui/xopendisplay/includes"); xcflags = get("libs/gui/xopendisplay/cflags"); xldflags = get("libs/gui/xopendisplay/ldflags"); report("Checking for xcb... "); logprintf(logdepth, "find_xcb:\n"); logdepth++; for(cflags = cflags_arr; *cflags != NULL; cflags++) { for(ldflags = ldflags_arr; *ldflags != NULL; ldflags++) { if (try_icl_with_deps(logdepth, node, test_c, NULL, *cflags, *ldflags, xincludes, xcflags, xldflags, 1) != 0) { return 0; } } } return try_fail(logdepth, node); } int find_xgetxcbconnection(const char *name, int logdepth, int fatal) { const char *test_c = NL "#include " NL "#include " NL "#include " NL "int main()" NL "{" NL " XGetXCBConnection(NULL);" NL " puts(\"OK\");" NL " return 0;" NL "}"; const char *node = "libs/gui/xgetxcbconnection"; char **cflags, *cflags_arr[] = {"", NULL}; char **ldflags, *ldflags_arr[] = {"-lX11-xcb", NULL}; const char *xincludes, *xcflags, *xldflags; if (require("cc/cc", logdepth, fatal)) return 1; if (require("libs/gui/xopendisplay/*", logdepth, fatal)) return 1; xincludes = get("libs/gui/xopendisplay/includes"); xcflags = get("libs/gui/xopendisplay/cflags"); xldflags = get("libs/gui/xopendisplay/ldflags"); report("Checking for xgetxcbconnection... "); logprintf(logdepth, "find_xgetxcbconnection:\n"); logdepth++; for(cflags = cflags_arr; *cflags != NULL; cflags++) { for(ldflags = ldflags_arr; *ldflags != NULL; ldflags++) { if (try_icl_with_deps(logdepth, node, test_c, NULL, *cflags, *ldflags, xincludes, xcflags, xldflags, 0) != 0) { return 0; } } } return try_fail(logdepth, node); } int find_xcb_render(const char *name, int logdepth, int fatal) { const char *test_c = NL "#include " NL "#include " NL "#include " NL "int main()" NL "{" NL " xcb_render_query_pict_formats_formats(NULL);" NL " puts(\"OK\");" NL " return 0;" NL "}"; const char *node = "libs/gui/xcb_render"; char **cflags, *cflags_arr[] = {"", NULL}; char **ldflags, *ldflags_arr[] = {"-lxcb-render", NULL}; const char *xincludes, *xcflags, *xldflags; if (require("cc/cc", logdepth, fatal)) return 1; if (require("libs/gui/xopendisplay/*", logdepth, fatal)) return 1; xincludes = get("libs/gui/xopendisplay/includes"); xcflags = get("libs/gui/xopendisplay/cflags"); xldflags = get("libs/gui/xopendisplay/ldflags"); report("Checking for xcb_render... "); logprintf(logdepth, "find_xcb_render:\n"); logdepth++; for(cflags = cflags_arr; *cflags != NULL; cflags++) { for(ldflags = ldflags_arr; *ldflags != NULL; ldflags++) { if (try_icl_with_deps(logdepth, node, test_c, NULL, *cflags, *ldflags, xincludes, xcflags, xldflags, 0) != 0) { return 0; } } } return try_fail(logdepth, node); } int find_xpm(const char *name, int logdepth, int fatal) { const char *test_c = NL "#include " NL "#include " NL "int main()" NL "{" NL " if (XpmLibraryVersion() == XpmIncludeVersion)" NL " puts(\"OK\");" NL " return 0;" NL "}"; const char *node = "libs/gui/xpm"; char **cflags, *cflags_arr[] = {"", NULL}; char **ldflags, *ldflags_arr[] = {"-lXpm", NULL}; const char *xincludes, *xcflags, *xldflags; if (require("cc/cc", logdepth, fatal)) return 1; if (require("libs/gui/xopendisplay/*", logdepth, fatal)) return 1; xincludes = get("libs/gui/xopendisplay/includes"); xcflags = get("libs/gui/xopendisplay/cflags"); xldflags = get("libs/gui/xopendisplay/ldflags"); report("Checking for xpm... "); logprintf(logdepth, "find_xpm:\n"); logdepth++; for(cflags = cflags_arr; *cflags != NULL; cflags++) { for(ldflags = ldflags_arr; *ldflags != NULL; ldflags++) { if (try_icl_with_deps(logdepth, node, test_c, NULL, *cflags, *ldflags, xincludes, xcflags, xldflags, 1) != 0) { return 0; } } } return try_fail(logdepth, node); } xschem-2.8.1/scconfig/src/gui/INIT.c0000644000175100017510000000002312212564735015270 0ustar svnsvn deps_gui_init(); xschem-2.8.1/scconfig/src/gui/find_cairo.h0000644000175100017510000000007413240634424016630 0ustar svnsvnint find_cairo(const char *name, int logdepth, int fatal); xschem-2.8.1/scconfig/src/gui/find_gl.c0000644000175100017510000001547713333551725016152 0ustar svnsvn/* scconfig - gui lib detection - opengl related calls Copyright (C) 2017 Tibor Palinkas Copyright (C) 2018 Aron Barath This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include "libs.h" #include "log.h" #include "db.h" #include "dep.h" int find_gl(const char *name, int logdepth, int fatal, const char *call, const char *arg) { char test_c[256]; const char *test_c_templ = NL "#include <%s/gl.h>" NL "#include " NL "int main()" NL "{" NL " GLenum err = glGetError();" NL " if (err == 0 || err == GL_INVALID_OPERATION)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; const char *node = "libs/gui/gl"; char **id, *incdirs[] = {"GL", "OpenGL", NULL}; char **cf, *cflgs[] = {"", "-I/usr/include/libdrm", NULL}; const char **lf, *ldflgs[] = {"-lGL", "-lopengl32", NULL}; char *cflags = NULL; char *ldflags = NULL; (void) call; /* not used */ (void) arg; /* not used */ if (require("cc/cc", logdepth, fatal)) return try_fail(logdepth, node); report("Checking for gl... "); logprintf(logdepth, "find_gl: running pkg-config...\n"); logdepth++; if (run_pkg_config(logdepth, "gl", &cflags, &ldflags) == 0) { for(id = incdirs; *id != NULL; id++) { sprintf(test_c, test_c_templ, *id); if (try_icl(logdepth, node, test_c, NULL, cflags, ldflags) != 0) goto success; } } logdepth--; logprintf(logdepth, "find_gl: manual tries...\n"); logdepth++; for(lf = ldflgs; *lf != NULL; lf++) { ldflags = strclone(*lf); for(cf = cflgs; *cf != NULL; cf++) { for(id = incdirs; *id != NULL; id++) { sprintf(test_c, test_c_templ, *id); if (try_icl(logdepth, node, test_c, NULL, *cf, ldflags) != 0) goto success; } } free(ldflags); } return try_fail(logdepth, node); success:; put("libs/gui/gl/include_prefix", *id); if (cflags != NULL) free(cflags); if (ldflags != NULL) free(ldflags); return 0; } int find_glu(const char *name, int logdepth, int fatal, const char *call, const char *arg) { char test_c[256]; const char *test_c_templ = NL "#include <%s/gl.h>" NL "#include <%s/glu.h>" NL "#include " NL "int main()" NL "{" NL " GLUtesselator *g = gluNewTess();" NL " if (g != NULL)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; const char *node = "libs/gui/glu", *ipr; char **cf, *cflgs[] = {"", "-I/usr/include/libdrm", NULL}; char *cflags = NULL; char *ldflags = NULL; (void) call; /* not used */ (void) arg; /* not used */ if (require("cc/cc", logdepth, fatal)) return try_fail(logdepth, node); if (require("libs/gui/gl/include_prefix", logdepth, fatal)) return try_fail(logdepth, node); ipr = get("libs/gui/gl/include_prefix"); if (ipr == NULL) return try_fail(logdepth, node); sprintf(test_c, test_c_templ, ipr, ipr); report("Checking for glu... "); logprintf(logdepth, "find_glu: running pkg-config...\n"); logdepth++; if (run_pkg_config(logdepth, "glu", &cflags, &ldflags) == 0) { if (try_icl(logdepth, node, test_c, NULL, cflags, ldflags) != 0) goto success; } logdepth--; logprintf(logdepth, "find_glu: manual tries...\n"); logdepth++; ldflags = strclone("-lGLU"); for(cf = cflgs; *cf != NULL; cf++) if (try_icl(logdepth, node, test_c, NULL, *cf, ldflags) != 0) goto success; free(ldflags); ldflags = strclone("-lglu32"); for(cf = cflgs; *cf != NULL; cf++) if (try_icl(logdepth, node, test_c, NULL, *cf, ldflags) != 0) goto success; free(ldflags); return try_fail(logdepth, node); success:; if (cflags != NULL) free(cflags); if (ldflags != NULL) free(ldflags); return 0; } int find_glut(const char *name, int logdepth, int fatal, const char *call, const char *arg) { const char *test_c = NL "#include " NL "int main()" NL "{" NL " glutGet(GLUT_ELAPSED_TIME);" NL " if (glutGet!=NULL)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; const char *node = "libs/gui/glut", *ipr; char freeglut[4096]; char **inc, *incs[] = {"", "#include ", NULL}; char *cflags = NULL; char *ldflags = NULL; (void) call; /* not used */ (void) arg; /* not used */ incs[0] = freeglut; if (require("cc/cc", logdepth, fatal)) return try_fail(logdepth, node); report("Checking for glut... "); logprintf(logdepth, "find_glut: running pkg-config...\n"); logdepth++; if (run_pkg_config(logdepth, "glut", &cflags, &ldflags) == 0) { if (try_icl(logdepth, node, test_c, NULL, cflags, ldflags) != 0) goto success; } if (require("libs/gui/gl/include_prefix", logdepth, fatal)) return try_fail(logdepth, node); ipr = get("libs/gui/gl/include_prefix"); if (ipr == NULL) return try_fail(logdepth, node); if (cflags != NULL) { free(cflags); cflags = NULL; } if (ldflags != NULL) { free(ldflags); ldflags = NULL; } logdepth--; logprintf(logdepth, "find_glut: manual tries...\n"); logdepth++; sprintf(freeglut, "#include <%s/freeglut.h>", ipr); ldflags = strclone("-lglut"); for(inc = incs; *inc != NULL; inc++) if (try_icl(logdepth, node, test_c, *inc, NULL, ldflags) != 0) goto success; free(ldflags); sprintf(freeglut, "#include \n#include <%s/glut.h>", ipr); ldflags = strclone("-lglut32"); for(inc = incs; *inc != NULL; inc++) if (try_icl(logdepth, node, test_c, *inc, NULL, ldflags) != 0) goto success; free(ldflags); return try_fail(logdepth, node); success:; if (cflags != NULL) free(cflags); if (ldflags != NULL) free(ldflags); return 0; } int find_gui_wgl(const char *name, int logdepth, int fatal) { const char *test_c = NL "#include " NL "int main()" NL "{" NL " if(wglGetCurrentDC() == NULL)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; const char *node = "libs/gui/wgl"; require("cc/cc", logdepth, fatal); report("Checking for wgl()... "); logprintf(logdepth, "find_gui_wgl: trying to find wgl...\n"); logdepth++; /* wgl exists only on windows, so try what the documentation says */ /* ("wgl" stands for "Windows GL" oslt) */ if (try_icl(logdepth, node, test_c, "#include ", NULL, "-lopengl32")) return 0; return try_fail(logdepth, node); } xschem-2.8.1/scconfig/src/gui/find_misc.h0000644000175100017510000000007713240634424016471 0ustar svnsvnint find_libstroke(const char *name, int logdepth, int fatal); xschem-2.8.1/scconfig/src/gui/find_lesstif2.h0000644000175100017510000000007713240634424017271 0ustar svnsvnint find_lesstif2(const char *name, int logdepth, int fatal); xschem-2.8.1/scconfig/src/gui/find_gd.h0000644000175100017510000000037113240634424016125 0ustar svnsvnint find_gd(const char *name, int logdepth, int fatal); int find_gdimagepng(const char *name, int logdepth, int fatal); int find_gdimagegif(const char *name, int logdepth, int fatal); int find_gdimagejpeg(const char *name, int logdepth, int fatal); xschem-2.8.1/scconfig/src/gui/find_cairo.c0000644000175100017510000000371213240634424016625 0ustar svnsvn/* scconfig - gui lib detection - cairo Copyright (C) 2017 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include "libs.h" #include "log.h" #include "db.h" #include "dep.h" int find_cairo(const char *name, int logdepth, int fatal) { const char *test_c = NL "#include " NL "#include " NL "#include \"cairo.h\"" NL "int main() {" NL " cairo_t *ctx;" NL " cairo_surface_t *surf;" NL NL " if (cairo_image_surface_create(CAIRO_FORMAT_RGB24, 100, 100) != NULL)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; const char *node = "libs/gui/cairo"; char *cflags = NULL; char *ldflags = NULL; if (require("cc/cc", logdepth, fatal)) return try_fail(logdepth, node); report("Checking for cairo... "); logprintf(logdepth, "find_cairo: running pkg-config...\n"); logdepth++; if (run_pkg_config(logdepth, "cairo", &cflags, &ldflags) == 0) { if (try_icl(logdepth, node, test_c, NULL, cflags, ldflags) != 0) goto success; } return try_fail(logdepth, node); success:; if (cflags != NULL) free(cflags); if (ldflags != NULL) free(ldflags); return 0; } xschem-2.8.1/scconfig/src/gui/find_misc.c0000644000175100017510000000370213240634424016462 0ustar svnsvn/* scconfig - gui lib detection - misc libs Copyright (C) 2016 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include "libs.h" #include "log.h" #include "db.h" #include "dep.h" int find_libstroke(const char *name, int logdepth, int fatal) { const char *test_c = NL "#include " NL "#include " NL "int main()" NL "{" NL " char msg[256];" NL " int n;" NL " stroke_init();" NL " for(n = 1000; n < 2000; n+=123)" NL " stroke_record(n, 1000);" NL " stroke_trans(msg);" NL " return !(atoi(msg) == 456);" NL "}"; const char *node = "libs/gui/libstroke"; char **cflags, *cflags_arr[] = {"", NULL}; char **ldflags, *ldflags_arr[] = {"-lstroke", NULL}; if (require("cc/cc", logdepth, fatal)) return 1; report("Checking for libstroke... "); logprintf(logdepth, "find_libstroke:\n"); logdepth++; for(cflags = cflags_arr; *cflags != NULL; cflags++) { for(ldflags = ldflags_arr; *ldflags != NULL; ldflags++) { if (try_icl_norun(logdepth, node, test_c, NULL, *cflags, *ldflags) != 0) { return 0; } } } return try_fail(logdepth, node); } xschem-2.8.1/scconfig/src/gui/find_lesstif2.c0000644000175100017510000000441013240634424017257 0ustar svnsvn/* scconfig - gui lib detection - lesstif Copyright (C) 2015 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include "libs.h" #include "log.h" #include "db.h" #include "dep.h" int find_lesstif2(const char *name, int logdepth, int fatal, const char *call, const char *arg) { const char *test_c = NL "#include " NL "int main(int argc, char *argv[])" NL "{" NL " XtAppContext context;" NL " Display *dsp;" NL " Colormap cmap;" NL " XColor color;" NL " Widget toplevel;" NL " toplevel = XtAppInitialize(& context, \"\", NULL, 0, &argc, argv, NULL, NULL, 0);" NL " XAllocColor(dsp, cmap, &color);" NL " return toplevel != NULL;" NL "}"; const char *node = "libs/gui/lesstif2"; char **cflags, *cflags_arr[] = {"", "-I/opt/X11/include", NULL}; char **ldflags, *ldflags_arr[] = {"-lXm -lX11", "-lXm -lXt", "-L/opt/X11/lib -lXm -lXt -lX11", NULL}; /* note: -lXt must be after -lXm else lesstif fails to init with runtime error */ (void) call; /* not used */ (void) arg; /* not used */ if (require("cc/cc", logdepth, fatal)) return 1; report("Checking for lesstif2... "); logprintf(logdepth, "find_lesstif:\n"); logdepth++; for(cflags = cflags_arr; *cflags != NULL; cflags++) { for(ldflags = ldflags_arr; *ldflags != NULL; ldflags++) { if (try_icl_norun(logdepth, node, test_c, NULL, *cflags, *ldflags) != 0) { return 0; } } } return try_fail(logdepth, node); } xschem-2.8.1/scconfig/src/gui/find_gd.c0000644000175100017510000001233113240634424016117 0ustar svnsvn/* scconfig - gui lib detection - libgd Copyright (C) 2013 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include "libs.h" #include "log.h" #include "db.h" #include "dep.h" int find_gd(const char *name, int logdepth, int fatal, const char *call, const char *arg) { const char *test_c = NL "#include \"gd.h\"" NL "int main() {" NL " gdImagePtr imtype;" NL NL " if (gdImageCreateTrueColor(32, 32) != NULL)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; const char *node = "libs/gui/gd"; char *cflags = NULL; char *ldflags = NULL; (void) call; /* not used */ (void) arg; /* not used */ if (require("cc/cc", logdepth, fatal)) return try_fail(logdepth, node); report("Checking for gd... "); logprintf(logdepth, "find_gd: running pkg-config...\n"); logdepth++; if (run_pkg_config(logdepth, "gdlib", &cflags, &ldflags) == 0) { if (try_icl(logdepth, node, test_c, NULL, cflags, ldflags) != 0) goto success; } if ((run_gen_config(logdepth, "gdlib-config", "", &cflags, &ldflags) == 0) || (run_pkg_config(logdepth, "gdlib", &cflags, &ldflags) == 0)) { char *tmp; if (try_icl(logdepth, node, test_c, NULL, cflags, ldflags) != 0) goto success; /* Some versions of gdlib-config --libs is broken and does not return -lgd */ tmp = ldflags; ldflags = str_concat(" ", ldflags, "-lgd", NULL); free(tmp); if (try_icl(logdepth, node, test_c, NULL, cflags, ldflags) != 0) goto success; /* none of the above worked, fail */ free(cflags); free(ldflags); return try_fail(logdepth, node); } return try_fail(logdepth, node); success:; if (cflags != NULL) free(cflags); if (ldflags != NULL) free(ldflags); return 0; } int find_gdimagepng(const char *name, int logdepth, int fatal) { const char *test_c = NL "#include " NL "#include \"gd.h\"" NL "int main() {" NL " gdImagePtr img;" NL NL " if ((img = gdImageCreateTrueColor(32, 32)) == NULL)" NL " return 1;" NL " gdImagePng(img, stderr);" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; const char *node = "libs/gui/gd/gdImagePng"; const char *cflags, *ldflags; if (require("cc/cc", logdepth, fatal)) return 1; if (require("libs/gui/gd/presents", logdepth, fatal)) return 1; if (!istrue(get("libs/gui/gd/presents"))) return 1; cflags = get("libs/gui/gd/cflags"); ldflags = get("libs/gui/gd/ldflags"); report("Checking for gdImagePng... "); logprintf(logdepth, "find_gdimagepng: running pkg-config...\n"); logdepth++; if (try_icl(logdepth, node, test_c, NULL, cflags, ldflags) == 0) return try_fail(logdepth, node); return 0; } int find_gdimagejpeg(const char *name, int logdepth, int fatal) { const char *test_c = NL "#include " NL "#include \"gd.h\"" NL "int main() {" NL " gdImagePtr img;" NL NL " if ((img = gdImageCreateTrueColor(32, 32)) == NULL)" NL " return 1;" NL " gdImageJpeg(img, stderr, 0.5);" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; const char *node = "libs/gui/gd/gdImageJpeg"; const char *cflags, *ldflags; if (require("cc/cc", logdepth, fatal)) return 1; if (require("libs/gui/gd/presents", logdepth, fatal)) return 1; if (!istrue(get("libs/gui/gd/presents"))) return 1; cflags = get("libs/gui/gd/cflags"); ldflags = get("libs/gui/gd/ldflags"); report("Checking for gdImageJpeg... "); logprintf(logdepth, "find_gdimagejpeg: running pkg-config...\n"); logdepth++; if (try_icl(logdepth, node, test_c, NULL, cflags, ldflags) == 0) return try_fail(logdepth, node); return 0; } int find_gdimagegif(const char *name, int logdepth, int fatal) { const char *test_c = NL "#include " NL "#include \"gd.h\"" NL "int main() {" NL " gdImagePtr img;" NL NL " if ((img = gdImageCreateTrueColor(32, 32)) == NULL)" NL " return 1;" NL " gdImageGif(img, stderr);" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; const char *node = "libs/gui/gd/gdImageGif"; const char *cflags, *ldflags; if (require("cc/cc", logdepth, fatal)) return 1; if (require("libs/gui/gd/presents", logdepth, fatal)) return 1; if (!istrue(get("libs/gui/gd/presents"))) return 1; cflags = get("libs/gui/gd/cflags"); ldflags = get("libs/gui/gd/ldflags"); report("Checking for gdImageGif... "); logprintf(logdepth, "find_gdimagegif: running pkg-config...\n"); logdepth++; if (try_icl(logdepth, node, test_c, NULL, cflags, ldflags) == 0) return try_fail(logdepth, node); return 0; } xschem-2.8.1/scconfig/src/gui/Makefile.plugin0000644000175100017510000000241613220744415017321 0ustar svnsvnGUI_CFLAGS = -DPLUGIN_GUI GUI_OBJS = \ $(BIN)/gui/find_gtk2.o \ $(BIN)/gui/find_gtk3.o \ $(BIN)/gui/find_lesstif2.o \ $(BIN)/gui/find_x.o \ $(BIN)/gui/find_gd.o \ $(BIN)/gui/find_cairo.o \ $(BIN)/gui/find_misc.o \ $(BIN)/gui/find_gl.o \ $(BIN)/gui/gui.o $(BIN)/gui/find_gtk2.o: $(SRC)/gui/find_gtk2.c $(CC) $(CFLAGS) -c $(SRC)/gui/find_gtk2.c -o $(BIN)/gui/find_gtk2.o $(BIN)/gui/find_gtk3.o: $(SRC)/gui/find_gtk3.c $(CC) $(CFLAGS) -c $(SRC)/gui/find_gtk3.c -o $(BIN)/gui/find_gtk3.o $(BIN)/gui/find_lesstif2.o: $(SRC)/gui/find_lesstif2.c $(CC) $(CFLAGS) -c $(SRC)/gui/find_lesstif2.c -o $(BIN)/gui/find_lesstif2.o $(BIN)/gui/find_x.o: $(SRC)/gui/find_x.c $(CC) $(CFLAGS) -c $(SRC)/gui/find_x.c -o $(BIN)/gui/find_x.o $(BIN)/gui/find_gd.o: $(SRC)/gui/find_gd.c $(CC) $(CFLAGS) -c $(SRC)/gui/find_gd.c -o $(BIN)/gui/find_gd.o $(BIN)/gui/find_misc.o: $(SRC)/gui/find_misc.c $(CC) $(CFLAGS) -c $(SRC)/gui/find_misc.c -o $(BIN)/gui/find_misc.o $(BIN)/gui/find_gl.o: $(SRC)/gui/find_gl.c $(CC) $(CFLAGS) -c $(SRC)/gui/find_gl.c -o $(BIN)/gui/find_gl.o $(BIN)/gui/find_cairo.o: $(SRC)/gui/find_cairo.c $(CC) $(CFLAGS) -c $(SRC)/gui/find_cairo.c -o $(BIN)/gui/find_cairo.o $(BIN)/gui/gui.o: $(SRC)/gui/gui.c $(CC) $(CFLAGS) -c $(SRC)/gui/gui.c -o $(BIN)/gui/gui.o xschem-2.8.1/scconfig/src/gui/gui.c0000644000175100017510000000275313370514772015327 0ustar svnsvn#include "libs.h" #include "log.h" #include "db.h" #include "dep.h" #include "find_x.h" #include "find_gtk2.h" #include "find_gtk3.h" #include "find_lesstif2.h" #include "find_gd.h" #include "find_cairo.h" #include "find_misc.h" #include "find_gl.h" void deps_gui_init() { dep_add("libs/gui/xopendisplay/*", find_xopendisplay); dep_add("libs/gui/xinerama/*", find_xinerama); dep_add("libs/gui/xrender/*", find_xrender); dep_add("libs/gui/xcb/*", find_xcb); dep_add("libs/gui/xcb_render/*", find_xcb_render); dep_add("libs/gui/xgetxcbconnection/*", find_xgetxcbconnection); dep_add("libs/gui/xpm/*", find_xpm); dep_add("libs/gui/gtk2/*", find_gtk2); dep_add("libs/gui/gtk2gl/*", find_gtk2gl); dep_add("libs/gui/gtk2/modversion", find_gtk2_modversion); dep_add("libs/gui/gtk3/*", find_gtk3); dep_add("libs/gui/lesstif2/*", find_lesstif2); dep_add("libs/gui/libstroke/*", find_libstroke); dep_add("libs/gui/gd/gdImagePng/*", find_gdimagepng); dep_add("libs/gui/gd/gdImageGif/*", find_gdimagegif); dep_add("libs/gui/gd/gdImageJpeg/*", find_gdimagejpeg); dep_add("libs/gui/gd/*", find_gd); dep_add("libs/gui/cairo/*", find_cairo); dep_add("libs/gui/gl/*", find_gl); dep_add("libs/gui/glu/*", find_glu); dep_add("libs/gui/glut/*", find_glut); dep_add("libs/gui/wgl/*", find_gui_wgl); } xschem-2.8.1/scconfig/src/scripts/0000755000175100017510000000000013400743710015261 5ustar svnsvnxschem-2.8.1/scconfig/src/scripts/find_stutter.c0000644000175100017510000000513213302027731020137 0ustar svnsvn/* scconfig - stutter lib detection Copyright (C) 2009 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include "scripts.h" #include int find_script_stutter(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "int main() {" NL " varctx *global;" NL " global = varctx_create(NULL, 256);" NL NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for stutter... "); logprintf(logdepth, "find_stutter: trying to find stutter...\n"); logdepth++; /* TODO: do we need -ldl? */ if ( try_icl(logdepth, "libs/script/stutter", test_c, NULL, NULL, "-lstutter") || try_icl(logdepth, "libs/script/stutter", test_c, NULL, "-I/usr/include/stutter", "-lstutter") || try_icl(logdepth, "libs/script/stutter", test_c, NULL, "-I/usr/local/include/stutter", "-lstutter") ) return 0; return try_fail(logdepth, "libs/script/stutter"); } int find_script_estutter(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "int main() {" NL " stt_ctx_t stt;" NL " stt.next_serial = 4242;" NL " stt_init(&stt);" NL " if (stt.next_serial != 4242)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for estutter... "); logprintf(logdepth, "find_estutter: trying to find estutter...\n"); logdepth++; /* TODO: do we need -ldl? */ if ( try_icl(logdepth, "libs/script/estutter", test_c, NULL, NULL, "-lestutter") || try_icl(logdepth, "libs/script/estutter", test_c, NULL, "-I/usr/include/estutter", "-lestutter") || try_icl(logdepth, "libs/script/estutter", test_c, NULL, "-I/usr/local/include/estutter", "-lestutter") ) return 0; return try_fail(logdepth, "libs/script/estutter"); } xschem-2.8.1/scconfig/src/scripts/INIT.h0000644000175100017510000000003211255324267016200 0ustar svnsvnvoid deps_scripts_init(); xschem-2.8.1/scconfig/src/scripts/find_guile.c0000644000175100017510000000365213246534262017550 0ustar svnsvn/* scconfig - guile lib detection Copyright (C) 2009 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include "scripts.h" #include int find_script_guile(const char *name, int logdepth, int fatal) { char *cflags, *ldflags; /* temp hack: guile/gh makes sure we have the old, 1.8 version */ char *test_c = NL "#include " NL "#include " NL "int main(int argc, char *argv[]) {" NL " scm_init_guile();" NL NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for guile... "); logprintf(logdepth, "find_guile: trying to find guile...\n"); logdepth++; if (run(logdepth, "guile-config compile", &cflags) + run(logdepth, "guile-config link", &ldflags) > 0) { free(cflags); free(ldflags); put("libs/script/guile/presents", sfalse); report("FAILED (guile-config failed)\n"); return 1; } /* TODO: do we need -ldl? */ if (try_icl(logdepth, "libs/script/guile", test_c, NULL, cflags, ldflags)) { free(ldflags); free(cflags); return 0; } free(ldflags); free(cflags); return try_fail(logdepth, "libs/script/guile"); } xschem-2.8.1/scconfig/src/scripts/INIT.c0000644000175100017510000000002711255324267016177 0ustar svnsvn deps_scripts_init(); xschem-2.8.1/scconfig/src/scripts/find_perl.c0000644000175100017510000000460413240634424017376 0ustar svnsvn/* scconfig - perl lib detection Copyright (C) 2009 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include "scripts.h" int find_script_perl(const char *name, int logdepth, int fatal) { char *cflags, *ldflags, *s; int res; char *test_c = NL "#include " NL "#include " NL "int main() {" NL " PerlInterpreter *interp;" NL NL " interp = perl_alloc();" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("sys/class", logdepth, fatal); require("cc/cc", logdepth, fatal); require("/internal/filelist/method", logdepth, fatal); report("Checking for perl... "); logprintf(logdepth, "find_perl: trying to find perl...\n"); logdepth++; res = run(logdepth, "perl -MExtUtils::Embed -e ccopts", &cflags); if (res) { logprintf(logdepth, "perl executable not found or broken (%d) at cflags\n", res); report("FAILED (perl exec fail)\n"); return 1; } res = run(logdepth, "perl -MExtUtils::Embed -e ldopts", &ldflags); if (res) { logprintf(logdepth, "perl executable not found or broken (%d) aat ldflags\n", res); report("FAILED (perl exec fail)\n"); free(cflags); return 1; } /* workarounds for windows [TODO] */ if (strcmp(get("sys/class"), "win32") == 0) { for(s = cflags; *s != '\0'; s++) if (*s == '\\') *s = '/'; for(s = ldflags; *s != '\0'; s++) if (*s == '\\') *s = '/'; /* TODO: do we need to remove double quotes as well? */ } res = try_icl(logdepth, "libs/script/perl", test_c, NULL, strip(cflags), strip(ldflags)); free(cflags); free(ldflags); if (res) return 0; return try_fail(logdepth, "libs/script/perl"); } xschem-2.8.1/scconfig/src/scripts/find_mawk.c0000644000175100017510000000316513246534262017401 0ustar svnsvn/* scconfig - mawk lib detection Copyright (C) 2009 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include "scripts.h" #include int find_script_mawk(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "#include " NL "#include " NL "int main() {" NL " int argc = 1;" NL " char *argv[] = {" NL " \"mawk\"," NL " NULL" NL " };" NL " libmawk_initialize(argc, argv);" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for mawk... "); logprintf(logdepth, "find_mawk: trying to find mawk...\n"); logdepth++; /* Look at the standard place */ if (try_icl(logdepth, "libs/script/mawk", test_c, NULL, NULL, "-lmawk")) return 0; return try_fail(logdepth, "libs/script/mawk"); } xschem-2.8.1/scconfig/src/scripts/find_mruby.c0000644000175100017510000000315413246534262017576 0ustar svnsvn/* scconfig - ruby lib detection Copyright (C) 2015 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include "scripts.h" int find_script_mruby(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "int main() {" NL " mrb_state *ctx = mrb_open();" NL " mrb_close(ctx);" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for mruby... "); logprintf(logdepth, "find_mruby: trying to find mruby...\n"); logdepth++; if (try_icl_pkg_config(logdepth, "libs/script/mruby", test_c, NULL, "mruby-*", get("/arg/mruby-version"))) return 0; /* Look at the most standard place */ if (try_icl(logdepth, "libs/script/mruby", test_c, NULL, NULL, "-lmruby -lm")) return 0; return try_fail(logdepth, "libs/script/ruby"); } xschem-2.8.1/scconfig/src/scripts/find_duktape.c0000644000175100017510000000305013277575616020104 0ustar svnsvn/* scconfig - duktape lib detection Copyright (C) 2018 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include "scripts.h" #include int find_script_duktape(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "int main() {" NL " duk_context *ctx = duk_create_heap_default();" NL " if (ctx != NULL)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for duktape... "); logprintf(logdepth, "find_duktape: trying to find duktape...\n"); logdepth++; /* Look at the standard place */ if (try_icl(logdepth, "libs/script/duktape", test_c, NULL, NULL, "-lduktape -lm")) return 0; return try_fail(logdepth, "libs/script/duktape"); } xschem-2.8.1/scconfig/src/scripts/find_gpmi.c0000644000175100017510000000517413240634424017373 0ustar svnsvn/* scconfig - libgpmi detection Copyright (C) 2015 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include "scripts.h" #include int find_script_gpmi(const char *name, int logdepth, int fatal) { char *out, *cmd, *end, **cfg; const char *usr; char *cfgs[] = { NULL, "gpmi-config", "/usr/bin/gpmi-config", "/usr/local/bin/gpmi-config", "~/bin/gpmi-config", NULL }; (void) fatal; /* not used */ report("Checking for gpmi... "); logprintf(logdepth, "find_gpmi: trying to find gpmi...\n"); logdepth++; /* Try the config script */ logprintf(logdepth, "running config tcl\n"); cmd = malloc(128); usr = get("/arg/gpmi/prefix"); if (usr != NULL) { const char *rp1 = NULL; require("cc/wlrpath", logdepth, 0); rp1 = get("cc/wlrpath"); cfgs[0] = str_concat("/", usr, "bin/gpmi-config", NULL); put("libs/script/gpmi/ldflags", str_concat("", "-L", usr, "/lib", " -lgpmi ", rp1, usr, "/lib", NULL)); put("libs/script/gpmi/cflags", str_concat("", "-I", usr, "/include", NULL)); cfg = cfgs; } else { cfg = cfgs+1; put("libs/script/gpmi/cflags", ""); put("libs/script/gpmi/ldflags", "-lgpmi"); } for(; *cfg != NULL; cfg++) { sprintf(cmd, "%s --version", *cfg); if (run(logdepth+1, cmd, &out) == 0) { put("libs/script/gpmi/gpmi-config", *cfg); put("libs/script/gpmi/presents", strue); end = strrchr(out, ' '); if (end != NULL) put("libs/script/gpmi/version", strip(end)); free(out); sprintf(cmd, "%s --id", *cfg); if (run(logdepth+1, cmd, &out) == 0) { end = strrchr(out, ' '); if (end != NULL) put("libs/script/gpmi/configapi", strip(end)); free(out); } free(cmd); if (cfgs[0] != NULL) free(cfgs[0]); return 0; } } free(cmd); if (out != NULL) free(out); if (cfg[0] != NULL) free(cfg[0]); return try_fail(logdepth, "libs/script/gpmi"); } xschem-2.8.1/scconfig/src/scripts/scripts.h0000644000175100017510000000246513366524476017151 0ustar svnsvn#include #include #include #include "libs.h" #include "log.h" #include "db.h" #include "dep.h" int brute_force_include(int logdepth, const char *language, const char *test_c, const char *ldflags_base, const char *basedir); /* script detection */ int find_script_gpmi(const char *name, int logdepth, int fatal); int find_script_tcl(const char *name, int logdepth, int fatal); int find_script_tk(const char *name, int logdepth, int fatal); int find_script_ruby(const char *name, int logdepth, int fatal); int find_script_mruby(const char *name, int logdepth, int fatal); int find_script_python(const char *name, int logdepth, int fatal); int find_script_perl(const char *name, int logdepth, int fatal); int find_script_mawk(const char *name, int logdepth, int fatal); int find_script_lua(const char *name, int logdepth, int fatal); int find_script_guile(const char *name, int logdepth, int fatal); int find_script_stutter(const char *name, int logdepth, int fatal); int find_script_estutter(const char *name, int logdepth, int fatal); int find_script_funlisp(const char *name, int logdepth, int fatal); int find_script_duktape(const char *name, int logdepth, int fatal); int find_script_fungw(const char *name, int logdepth, int fatal); int find_script_m4(const char *name, int logdepth, int fatal); xschem-2.8.1/scconfig/src/scripts/Makefile.plugin0000644000175100017510000000552113345253344020230 0ustar svnsvnSCRIPT_CFLAGS = -DPLUGIN_SCRIPTS SCRIPT_OBJS = \ $(BIN)/scripts/scripts.o \ $(BIN)/scripts/find_gpmi.o \ $(BIN)/scripts/find_tcl.o \ $(BIN)/scripts/find_ruby.o \ $(BIN)/scripts/find_mruby.o \ $(BIN)/scripts/find_python.o \ $(BIN)/scripts/find_perl.o \ $(BIN)/scripts/find_mawk.o \ $(BIN)/scripts/find_lua.o \ $(BIN)/scripts/find_guile.o \ $(BIN)/scripts/find_stutter.o \ $(BIN)/scripts/find_funlisp.o \ $(BIN)/scripts/find_duktape.o \ $(BIN)/scripts/find_fungw.o \ $(BIN)/scripts/find_m4.o $(BIN)/scripts/scripts.o: $(SRC)/scripts/scripts.c $(CC) $(CFLAGS) -c $(SRC)/scripts/scripts.c -o $(BIN)/scripts/scripts.o $(BIN)/scripts/find_tcl.o: $(SRC)/scripts/find_tcl.c $(SRC)/scripts/scripts.h $(CC) $(CFLAGS) -c $(SRC)/scripts/find_tcl.c -o $(BIN)/scripts/find_tcl.o $(BIN)/scripts/find_gpmi.o: $(SRC)/scripts/find_gpmi.c $(SRC)/scripts/scripts.h $(CC) $(CFLAGS) -c $(SRC)/scripts/find_gpmi.c -o $(BIN)/scripts/find_gpmi.o $(BIN)/scripts/find_ruby.o: $(SRC)/scripts/find_ruby.c $(SRC)/scripts/scripts.h $(CC) $(CFLAGS) -c $(SRC)/scripts/find_ruby.c -o $(BIN)/scripts/find_ruby.o $(BIN)/scripts/find_mruby.o: $(SRC)/scripts/find_mruby.c $(SRC)/scripts/scripts.h $(CC) $(CFLAGS) -c $(SRC)/scripts/find_mruby.c -o $(BIN)/scripts/find_mruby.o $(BIN)/scripts/find_python.o: $(SRC)/scripts/find_python.c $(SRC)/scripts/scripts.h $(CC) $(CFLAGS) -c $(SRC)/scripts/find_python.c -o $(BIN)/scripts/find_python.o $(BIN)/scripts/find_perl.o: $(SRC)/scripts/find_perl.c $(SRC)/scripts/scripts.h $(CC) $(CFLAGS) -c $(SRC)/scripts/find_perl.c -o $(BIN)/scripts/find_perl.o $(BIN)/scripts/find_mawk.o: $(SRC)/scripts/find_mawk.c $(SRC)/scripts/scripts.h $(CC) $(CFLAGS) -c $(SRC)/scripts/find_mawk.c -o $(BIN)/scripts/find_mawk.o $(BIN)/scripts/find_lua.o: $(SRC)/scripts/find_lua.c $(SRC)/scripts/scripts.h $(CC) $(CFLAGS) -c $(SRC)/scripts/find_lua.c -o $(BIN)/scripts/find_lua.o $(BIN)/scripts/find_guile.o: $(SRC)/scripts/find_guile.c $(SRC)/scripts/scripts.h $(CC) $(CFLAGS) -c $(SRC)/scripts/find_guile.c -o $(BIN)/scripts/find_guile.o $(BIN)/scripts/find_stutter.o: $(SRC)/scripts/find_stutter.c $(SRC)/scripts/scripts.h $(CC) $(CFLAGS) -c $(SRC)/scripts/find_stutter.c -o $(BIN)/scripts/find_stutter.o $(BIN)/scripts/find_m4.o: $(SRC)/scripts/find_m4.c $(SRC)/scripts/scripts.h $(CC) $(CFLAGS) -c $(SRC)/scripts/find_m4.c -o $(BIN)/scripts/find_m4.o $(BIN)/scripts/find_duktape.o: $(SRC)/scripts/find_duktape.c $(SRC)/scripts/scripts.h $(CC) $(CFLAGS) -c $(SRC)/scripts/find_duktape.c -o $(BIN)/scripts/find_duktape.o $(BIN)/scripts/find_funlisp.o: $(SRC)/scripts/find_funlisp.c $(SRC)/scripts/scripts.h $(CC) $(CFLAGS) -c $(SRC)/scripts/find_funlisp.c -o $(BIN)/scripts/find_funlisp.o $(BIN)/scripts/find_fungw.o: $(SRC)/scripts/find_fungw.c $(SRC)/scripts/scripts.h $(CC) $(CFLAGS) -c $(SRC)/scripts/find_fungw.c -o $(BIN)/scripts/find_fungw.o xschem-2.8.1/scconfig/src/scripts/scripts.c0000644000175100017510000000616713366524476017147 0ustar svnsvn/* scconfig - helper functions for detecting script libs Copyright (C) 2009 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include "scripts.h" #include #include "find.h" void deps_scripts_init() { dep_add("libs/script/gpmi/*", find_script_gpmi); dep_add("libs/script/tcl/*", find_script_tcl); dep_add("libs/script/tk/*", find_script_tk); dep_add("libs/script/ruby/*", find_script_ruby); dep_add("libs/script/mruby/*", find_script_mruby); dep_add("libs/script/python/*", find_script_python); dep_add("libs/script/perl/*", find_script_perl); dep_add("libs/script/mawk/*", find_script_mawk); dep_add("libs/script/lua/*", find_script_lua); dep_add("libs/script/guile/*", find_script_guile); dep_add("libs/script/stutter/*", find_script_stutter); dep_add("libs/script/estutter/*", find_script_estutter); dep_add("libs/script/funlisp/*", find_script_funlisp); dep_add("libs/script/duktape/*", find_script_duktape); dep_add("libs/script/fungw/*", find_script_fungw); dep_add("libs/script/m4/bin/*", find_script_m4); } int brute_force_include(int logdepth, const char *language, const char *test_c, const char *ldflags_base, const char *basedir) { char **files, *cflags, *ldflags; char nodename[1024], deflink[sizeof(nodename)]; int fileno, n, res; size_t llen; if (ldflags_base == NULL) ldflags_base = ""; llen = strlen(language); assert(llen < sizeof(nodename) - 16); sprintf(nodename, "libs/script/%s", language); sprintf(deflink, "-l%s", language); res = 0; filelist(logdepth, basedir, &fileno, &files); if (fileno > 0) { for(n = 0; (n < fileno) && !res; n++) { if (strncmp(files[n], language, llen) == 0) { ldflags = malloc(strlen(files[n]) + strlen(ldflags_base) + 16); sprintf(ldflags, "%s -l%s", ldflags_base, files[n]); cflags = malloc(strlen(files[n]) + strlen(basedir) + 16); sprintf(cflags, "-I%s/%s", basedir, files[n]); if (try_icl(logdepth, nodename, test_c, NULL, cflags, ldflags) || try_icl(logdepth, nodename, test_c, NULL, cflags, deflink)) { filelist_free(&fileno, &files); free(cflags); free(ldflags); return 1; } free(cflags); free(ldflags); } } filelist_free(&fileno, &files); } return res; } xschem-2.8.1/scconfig/src/scripts/find_fungw.c0000644000175100017510000000315313312363550017557 0ustar svnsvn/* scconfig - lua lib detection Copyright (C) 2018 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include "scripts.h" #include int find_script_fungw(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "int main() {" NL " fgw_ctx_t ctx;" NL " fgw_obj_t *obj;" NL " fgw_init(&ctx, \"host\");" NL " obj = fgw_obj_reg(&ctx, \"foo\");" NL " if (obj != NULL)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for fungw... "); logprintf(logdepth, "find_fungw: trying to find fungw...\n"); logdepth++; /* Look at some standard place */ if (try_icl(logdepth, "libs/script/fungw", test_c, NULL, NULL, "-lfungw -lm -lgenht")) return 0; return try_fail(logdepth, "libs/script/fungw"); } xschem-2.8.1/scconfig/src/scripts/find_tcl.c0000644000175100017510000001651113371457012017217 0ustar svnsvn/* scconfig - tcl lib detection Copyright (C) 2009 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include "scripts.h" #include static int all_vers[] = { 86, 85, 84, 0, -1 }; int find_script_tcl_(const char *name, int logdepth, int fatal, int *vers, int fallback) { char *out, *temp, *temp2, *cmd, *I, *L, *end, **tclsh; int *v; char *tclshs[] = { "tclsh", "tclsh86", "tclsh85", "tclsh84", "tclsh8.6", "tclsh8.5", "tclsh8.4", NULL }; char *test_c = NL "#include " NL "int main() {" NL " Tcl_Obj *res;" NL " Tcl_Interp *interp;" NL " interp = Tcl_CreateInterp();" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; char *tcl_config = NL "proc tclConfigFile {} {" NL " set d [info library]" NL " set f [file join $d \"tclConfig.sh\"]" NL " if {[file exists $f]} {return $f}" NL "" NL " set d [file dirname $d]" NL " set f [file join $d \"tclConfig.sh\"]" NL " if {[file exists $f]} {return $f}" NL "" NL " set d [file dirname $d]" NL " set f [file join $d \"tclConfig.sh\"]" NL " if {[file exists $f]} {return $f}" NL "" NL " set d [file dirname $d]" NL " set f [file join $d \"tclConfig.sh\"]" NL " if {[file exists $f]} {return $f}" NL "}" NL "" NL "puts [tclConfigFile]" NL; /* Look at some standard places */ for(v = vers; *v != -1; v++) { int major = *v / 10, minor = *v % 10; char ifl[64], lfl[64]; if (*v == 0) { report("plain... "); if (try_icl(logdepth, "libs/script/tcl", test_c, NULL, NULL, "-ltcl")) return 0; continue; } report("%d.%d... ", major, minor); sprintf(lfl, "-ltcl%d", *v); if (try_icl(logdepth, "libs/script/tcl", test_c, NULL, NULL, lfl)) return 0; sprintf(lfl, "-ltcl%d.%d", major, minor); if (try_icl(logdepth, "libs/script/tcl", test_c, NULL, NULL, lfl)) return 0; sprintf(lfl, "-ltcl%d", *v); sprintf(ifl, "-I/usr/include/tcl%d", *v); if (try_icl(logdepth, "libs/script/tcl", test_c, NULL, ifl, lfl)) return 0; sprintf(lfl, "-ltcl%d.%d", major, minor); sprintf(ifl, "-I/usr/include/tcl%d.%d", major, minor); if (try_icl(logdepth, "libs/script/tcl", test_c, NULL, ifl, lfl)) return 0; } if (!fallback) return 1; report(" not found by version, trying tclsh.\n"); /* Try the config script */ logprintf(logdepth, "running config tcl\n"); temp = tempfile_dump(tcl_config, ".tcl"); cmd = malloc(strlen(temp) + 16); for(tclsh = tclshs; *tclsh != NULL; tclsh++) { sprintf(cmd, "%s %s", *tclsh, temp); report("Trying: %s\n", cmd); if (run(logdepth+1, cmd, &out) == 0) { free(cmd); cmd = malloc(strlen(out) + 256); sprintf(cmd, "#!/bin/sh\n. %s\necho $TCL_INCLUDE_SPEC\necho $TCL_LIB_SPEC\n", out); temp2 = tempfile_dump(cmd, ".sh"); free(out); out = malloc(strlen(temp2) + 32); sprintf(out, "chmod +x %s", temp2); system(out); free(out); if (run(logdepth+1, temp2, &out) == 0) { remove(temp2); I = out; L = strchr(I, '\n'); if (L != NULL) { *L = '\0'; L++; end = strchr(L, '\n'); if (end != NULL) *end = '\0'; } if (try_icl(logdepth, "libs/script/tcl", test_c, NULL, I, L)) { remove(temp); free(cmd); if (out != NULL) free(out); return 0; } } remove(temp2); } } remove(temp); free(cmd); if (out != NULL) free(out); return 1; } int find_script_tcl(const char *name, int logdepth, int fatal) { int res, rver[2], *vers = all_vers, fallback = 1; const char *reqver; require("cc/cc", logdepth, fatal); report("Checking for tcl... "); logprintf(logdepth, "find_tcl: trying to find tcl...\n"); logdepth++; reqver = get("/arg/tcl-version"); if ((reqver != NULL) && (reqver[0] != '\0')) { if (reqver[1] == '.') rver[0] = (reqver[0] - '0') * 10 + (reqver[2] - '0'); else rver[0] = atoi(reqver); rver[1] = -1; vers = rver; fallback = 0; } res = find_script_tcl_(name, logdepth, fatal, vers, fallback); if (res == 0) return 0; return try_fail(logdepth, "libs/script/tcl"); } static int try_icl_tk(int logdepth, const char *prefix, const char *test_c_in, const char *includes, const char *cflags, const char *ldflags, int ver) { const char *XL = get("libs/gui/xopendisplay/Lflags"); const char *Xc = get("libs/gui/xopendisplay/cflags"); const char *tl, *tc; char *tmpl, *tmpc; int res; tl = get("libs/script/tcl/ldflags"); tc = get("libs/script/tcl/cflags"); if (XL == NULL) XL = ""; if (Xc == NULL) Xc = ""; if (tl == NULL) tl = ""; if (tc == NULL) tc = ""; if ((*XL == '\0') && (*Xc == '\0') && (*tl == '\0') && (*tc == '\0')) return try_icl(logdepth, prefix, test_c_in, includes, cflags, ldflags); tmpl = str_concat(" ", tl, XL, ldflags, NULL); tmpc = str_concat(" ", tc, Xc, cflags, NULL); res = try_icl(logdepth, prefix, test_c_in, includes, tmpc, tmpl); free(tmpl); free(tmpc); return res; } int find_script_tk(const char *name, int logdepth, int fatal) { int *v, rver[2], *vers = all_vers; const char *reqver, *tclreqver; char *test_c = NL "#include " NL "#include " NL "int main() {" NL " if (Tk_GetNumMainWindows() == 0)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); require("libs/gui/xopendisplay/cflags", logdepth, fatal); require("libs/gui/xopendisplay/Lflags", logdepth, fatal); report("Checking for tk... "); logprintf(logdepth, "find_tk: trying to find tk...\n"); logdepth++; reqver = get("/arg/tk-version"); if ((reqver != NULL) && (reqver[0] != '\0')) { tclreqver = get("/arg/tcl-version"); if ((tclreqver != NULL) && (tclreqver[0] != '\0')) { if (strcmp(tclreqver, reqver) != 0) { report("\n\nFatal argument error: if both tcl and tk version are forced, they must match\n\n"); exit(1); } } if (reqver[1] == '.') rver[0] = (reqver[0] - '0') * 10 + (reqver[2] - '0'); else rver[0] = atoi(reqver); rver[1] = -1; vers = rver; } /* Look at some standard places, per version */ for(v = vers; *v != -1; v++) { int major = *v / 10, minor = *v % 10; char lfl[64]; int tvers[2]; tvers[0] = *v; tvers[1] = -1; if (find_script_tcl_("libs/script/tcl", logdepth+1, 0, tvers, 0) != 0) { report("(no tcl) "); continue; } if (*v == 0) { if (try_icl_tk(logdepth, "libs/script/tk", test_c, NULL, NULL, "-ltk", 0)) return 0; continue; } sprintf(lfl, "-ltk%d", *v); if (try_icl_tk(logdepth, "libs/script/tk", test_c, NULL, NULL, lfl, *v)) return 0; sprintf(lfl, "-ltk%d.%d", major, minor); if (try_icl_tk(logdepth, "libs/script/tk", test_c, NULL, NULL, lfl, *v)) return 0; } return try_fail(logdepth, "libs/script/tk"); } xschem-2.8.1/scconfig/src/scripts/find_ruby.c0000644000175100017510000000715313246534262017424 0ustar svnsvn/* scconfig - ruby lib detection Copyright (C) 2009..2015 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include "scripts.h" static int brute_force(int logdepth, const char *test_c, const char *basedir) { char **files, **ifiles, *tmp, *ldflags; int fileno, n, m, ifileno, res; res = 0; filelist(logdepth, basedir, &fileno, &files); if (fileno <= 0) return res; for(n = 0; (n < fileno) && !res; n++) { tmp = malloc(strlen(basedir) + strlen(files[n]) + 4); sprintf(tmp, "%s/%s", basedir, files[n]); filelist(logdepth+1, tmp, &ifileno, &ifiles); free(tmp); for(m = 0; (m < ifileno) && !res; m++) { tmp = malloc(strlen(basedir) + strlen(files[n]) + strlen(ifiles[m]) + 16); sprintf(tmp, "%s/%s/%s/ruby.h", basedir, files[n], ifiles[m]); if (is_file(tmp)) { sprintf(tmp, "-I%s/%s/%s", basedir, files[n], ifiles[m]); ldflags = malloc(strlen(files[n]) + 16); sprintf(ldflags, "-lruby%s", files[n]); res = try_icl(logdepth, "libs/script/ruby", test_c, NULL, tmp, ldflags); free(ldflags); } free(tmp); } filelist_free(&ifileno, &ifiles); } filelist_free(&fileno, &files); return res; } int find_script_ruby(const char *name, int logdepth, int fatal) { int require18; const char *require18s; char *test_c = NL "#include " NL "int main() {" NL " ruby_init();" NL " ruby_finalize();" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; char *test_c18 = NL "#include " NL "#include " NL "int main() {" NL " ruby_init();" NL " ruby_frame->orig_func;" NL " ruby_finalize();" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for ruby... "); logprintf(logdepth, "find_ruby: trying to find ruby...\n"); logdepth++; require18s = get("libs/script/ruby/require_18"); if (require18s != NULL) require18 = istrue(require18s); else require18 = 0; if ((!require18) && (try_icl_pkg_config(logdepth, "libs/script/ruby", test_c, NULL, "ruby-*", get("/arg/ruby-version")))) return 0; if (try_icl_pkg_config(logdepth, "libs/script/ruby", test_c18, NULL, "ruby-*", get("/arg/ruby-version"))) return 0; /* Look at some standard places */ if ((!require18) && (try_icl(logdepth, "libs/script/ruby", test_c, NULL, NULL, "-lruby"))) return 0; if (try_icl(logdepth, "libs/script/ruby", test_c18, NULL, NULL, "-lruby")) return 0; require("/internal/filelist/method", logdepth, fatal); /* no luck - try to find by brute force, listing directory names */ if ((!require18) && (brute_force(logdepth, test_c, "/usr/lib/ruby") || brute_force(logdepth, test_c, "/usr/local/lib/ruby"))) { return 0; } if (brute_force(logdepth, test_c18, "/usr/lib/ruby") || brute_force(logdepth, test_c18, "/usr/local/lib/ruby")) { return 0; } return try_fail(logdepth, "libs/script/ruby"); } xschem-2.8.1/scconfig/src/scripts/find_python.c0000644000175100017510000000603213367743403017762 0ustar svnsvn/* scconfig - python lib detection Copyright (C) 2009 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include "scripts.h" int find_script_python(const char *name, int logdepth, int fatal) { char *ldflags_base, *cflags, *ldflags; int iswin32, res; char *test_c = NL "#include " NL "#include " NL "int main() {" NL " char *s;" NL " Py_Initialize();" NL NL " s = PY_VERSION;" NL " if (s[0] != '2') return 1;" NL " if ((s[2] >= '3') && (s[2] <= '9')) puts(\"OK\");" NL " return 0;" NL "}" NL; char *inc_py = NL "import distutils.sysconfig;" NL "print '-I' + distutils.sysconfig.get_python_inc().replace('\\\\','/')" NL; char *lib_py = NL "import distutils.sysconfig;" NL "print '-L' + distutils.sysconfig.PREFIX.replace('\\\\','/') + '/libs',;" NL "import sys;" NL "print '-lpython' + str(sys.version_info[0]) + str(sys.version_info[1])" NL; require("sys/class", logdepth, fatal); iswin32 = strcmp(get("sys/class"), "win32") == 0; if (iswin32) require("libs/lpthread", logdepth, fatal); require("cc/cc", logdepth, fatal); require("/internal/filelist/method", logdepth, fatal); report("Checking for python... "); logprintf(logdepth, "find_python: trying to find python...\n"); logdepth++; if (iswin32) ldflags_base = strclone(get("libs/lpthread")); else ldflags_base = strclone("-L/usr/bin -L/usr/local/bin"); /* Look at some standard places */ if (try_icl(logdepth, "libs/script/python", test_c, NULL, NULL, "-lpython")) return 0; /* Ask python using the python executables on path; use + so both runs and can free out of both */ if (run_script(logdepth, "python", inc_py, ".py", &cflags) + run_script(logdepth, "python", lib_py, ".py", &ldflags) == 0) res = try_icl(logdepth, "libs/script/python", test_c, NULL, strip(cflags), strip(ldflags)); else res = 0; free(cflags); free(ldflags); if (res) return 0; /* no luck - try to find by brute force, listing directory names */ if (brute_force_include(logdepth, "python", test_c, ldflags_base, "/usr/include") || brute_force_include(logdepth, "python", test_c, ldflags_base, "/usr/local/include")) { free(ldflags_base); return 0; } free(ldflags_base); return try_fail(logdepth, "libs/script/python"); } xschem-2.8.1/scconfig/src/scripts/find_lua.c0000644000175100017510000000531713246534262017224 0ustar svnsvn/* scconfig - lua lib detection Copyright (C) 2009 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include "scripts.h" #include int find_script_lua(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "#include " NL "int main() {" NL " lua_State *state;" NL " state = luaL_newstate();" NL " luaL_loadfile(state, \"nothing\");" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); require("/internal/filelist/method", logdepth, fatal); report("Checking for lua... "); logprintf(logdepth, "find_lua: trying to find lua...\n"); logdepth++; /* Look at some standard places */ /* TODO: do we need -ldl? */ if (try_icl(logdepth, "libs/script/lua", test_c, NULL, NULL, "-llua -llualib -lm")) return 0; /* lualib doesn't exist in lua 5.1.1 */ if (try_icl(logdepth, "libs/script/lua", test_c, NULL, NULL, "-llua -lm")) return 0; /* OS specific include dir */ if (try_icl(logdepth, "libs/script/lua", test_c, NULL, "-I/usr/include", "-llua -llualib -lm")) return 0; if (try_icl(logdepth, "libs/script/lua", test_c, NULL, "-I/usr/include/lua5.2", "-llua5.2 -lm")) return 0; if (try_icl(logdepth, "libs/script/lua", test_c, NULL, "-I/usr/local/include", "-llua -llualib -lm")) return 0; if (try_icl(logdepth, "libs/script/lua", test_c, NULL, "-I/usr/include", "-llua -lm")) return 0; if (try_icl(logdepth, "libs/script/lua", test_c, NULL, "-I/usr/local/include", "-llua -lm")) return 0; /* This one is for OSX (by Bjarni) */ if (try_icl(logdepth, "libs/script/lua", test_c, NULL, "-I/sw/include", "-llua -llualib -lm")) return 0; /* no luck - try to find by brute force, listing directory names */ if (brute_force_include(logdepth, "lua", test_c, NULL, "/usr/include") || brute_force_include(logdepth, "lua", test_c, NULL, "/usr/local/include")) { return 0; } return try_fail(logdepth, "libs/script/lua"); } xschem-2.8.1/scconfig/src/scripts/find_m4.c0000644000175100017510000000431113240634424016747 0ustar svnsvn/* scconfig - m4 binary detection Copyright (C) 2015 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include "scripts.h" #include static int test_m4(const char *name, int logdepth, int fatal, char *bin) { char *script = NL "define(baz, foo)" NL "baz bar" NL; char *out, *cmd, *tmpf, *tmpf_esc; (void) fatal; /* not used */ tmpf = tempfile_dump(script, ".m4"); tmpf_esc = shell_escape_dup(tmpf); cmd = str_concat(" ", bin, tmpf_esc, NULL); free(tmpf_esc); run(logdepth, cmd, &out); if (out != NULL) { char *s = out; while((*s == ' ') || (*s == '\r') || (*s == '\n')) s++; if (strncmp(s, "foo bar", 7) == 0) { unlink(tmpf); free(tmpf); free(out); report("found (%s)\n", bin); logprintf(logdepth, "found (%s)", bin); put("libs/script/m4/bin/presents", strue); put("libs/script/m4/bin/path", bin); return 1; } free(out); } unlink(tmpf); free(tmpf); free(cmd); return 0; } int find_script_m4(const char *name, int logdepth, int fatal) { char *m4_paths[] = { "/usr/bin/m4", "/usr/local/bin/m4", "/bin/m4", "/usr/bin/gm4", "/usr/local/bin/gm4", "/bin/gm4", NULL }; char **s; report("Checking for m4 binary... "); logprintf(logdepth, "find_m4: trying to find m4 binary...\n"); logdepth++; for(s = m4_paths; *s != NULL; s++) if (test_m4(name, logdepth, fatal, *s)) return 0; return try_fail(logdepth, "libs/script/m4/bin"); } xschem-2.8.1/scconfig/src/scripts/find_funlisp.c0000644000175100017510000000316113335542345020116 0ustar svnsvn/* scconfig - stutter lib detection Copyright (C) 2018 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include "scripts.h" #include int find_script_funlisp(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "int main() {" NL " lisp_runtime *rt = lisp_runtime_new();" NL " if (rt != NULL)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for funlisp... "); logprintf(logdepth, "find_funlisp: trying to find funlisp...\n"); logdepth++; if ( try_icl(logdepth, "libs/script/funlisp", test_c, NULL, NULL, "/usr/local/lib/libfunlisp.a") || try_icl(logdepth, "libs/script/funlisp", test_c, NULL, NULL, "/usr/lib/libfunlisp.a") ) return 0; return try_fail(logdepth, "libs/script/funlisp"); } xschem-2.8.1/scconfig/src/tmpasm/0000755000175100017510000000000013400743707015101 5ustar svnsvnxschem-2.8.1/scconfig/src/tmpasm/tmpasm_scconfig.h0000644000175100017510000000047213366254556020443 0ustar svnsvn#include #include "tmpasm.h" int tmpasm(const char *wdir, const char *input, const char *output); void scc_tmpasm_parse(tmpasm_t *ctx, const char *cwd, FILE *fin, FILE *fout); FILE *tmpasm_fout(tmpasm_t *ctx); tmpasm_instr *scc_resolve(tmpasm_t *ctx, const char *name); extern tmpasm_cb_t scc_cb; xschem-2.8.1/scconfig/src/tmpasm/tmpasm.c0000644000175100017510000004575213342530154016556 0ustar svnsvn#include #include #include #include #include "tmpasm.h" #include "debug.h" #define is_space(c) (((c) == ' ') || ((c) == '\t')) #define is_sep(c) (((c) == '\n') || ((c) == '\r') || ((c) == ';')) #define is_addr(c) ( (((c) >= '0') && ((c) <= '9')) || (((c) >= 'a') && ((c) <= 'z')) || (((c) >= 'A') && ((c) <= 'Z')) || ((c) == '_') || ((c) == '?') || ((c) == '.') || ((c) == ',') || ((c) == ',') || ((c) == '-') || ((c) == '/') || ((c) == '&') ) /* this local copy is to make tmpasm compile independently */ static char *strclone(const char *str) { int l; char *ret; if (str == NULL) return NULL; l = strlen(str)+1; ret = malloc(l); memcpy(ret, str, l); return ret; } #define TOP ctx->st static const char *kw_names[] = {"-", "if", "then", "else", "end", "foreach", "in", "switch", "case", "default", "nop", NULL }; static tmpasm_kw_t kw_lookup(const char *str) { const char **k; tmpasm_kw_t i; /* slow linear search is enough: we have only a few keywords */ for(k = kw_names, i = KW_none; *k != NULL; k++,i++) if (strcmp(*k, str) == 0) return i; return KW_none; } tmpasm_exec_t *code_new(tmpasm_kw_t kw) { tmpasm_exec_t *c; c = calloc(sizeof(tmpasm_exec_t), 1); c->kw = kw; return c; } /*tmpasm_exec_t *code_end(tmpasm_exec_t *start) { while(start->next != NULL) start = start->next; return start; }*/ tmpasm_exec_t *code_append(tmpasm_t *ctx, tmpasm_kw_t kw) { tmpasm_exec_t *c; /* c = code_end(TOP->code);*/ c = TOP->last_code; if (TOP->last_code->kw != KW_NOP) { c->next = code_new(kw); return c->next; } c->kw = kw; return c; } static void error(tmpasm_t *ctx, char c, char *msg) { fprintf(stderr, "error: %s at %d:%d\n", msg, ctx->line, ctx->col); if (c != 0) fprintf(stderr, " character last seen: %c\n", c); ctx->dead = 1; } static void push(tmpasm_t *ctx, tmpasm_kw_t kw, tmpasm_state_t st, tmpasm_exec_t *code) { tmpasm_stack_t *new; new = calloc(sizeof(tmpasm_stack_t), 1); new->kw = kw; new->state = st; new->next = ctx->st; new->last_code = code; ctx->st = new; } static void pop_(tmpasm_t *ctx, int chk_underfl) { tmpasm_stack_t *old; old = ctx->st; ctx->st = old->next; /* stack underflow? */ if (chk_underfl) { if (TOP == NULL) { error(ctx, 0, "Excess \"end\""); TOP = old; return; } } if (old->argv != NULL) free(old->argv); if (old->argend != NULL) free(old->argend); if (old->arg_used != NULL) free(old->arg_used); if (old->arg_alloced != NULL) free(old->arg_alloced); free(old); } static void pop(tmpasm_t *ctx) { pop_(ctx, 1); } #define grow(arr, size) arr = realloc(arr, sizeof((arr)[0]) * size) static void arg_new(tmpasm_t *ctx, int is_addr) { if (TOP->args_used >= TOP->args_alloced) { TOP->args_alloced = TOP->args_alloced + 16; grow(TOP->argv, TOP->args_alloced); grow(TOP->argend, TOP->args_alloced); grow(TOP->arg_alloced, TOP->args_alloced); grow(TOP->arg_used, TOP->args_alloced); } TOP->arg_alloced[TOP->args_used] = 64; TOP->arg_used[TOP->args_used] = 0; TOP->argv[TOP->args_used] = malloc(TOP->arg_alloced[TOP->args_used]+sizeof(tmpasm_arg_t)); TOP->argv[TOP->args_used]->is_addr = is_addr; TOP->argv[TOP->args_used]->next = NULL; TOP->argend[TOP->args_used] = TOP->argv[TOP->args_used]; TOP->args_used++; } static void arg_append(tmpasm_t *ctx, char c) { int i = TOP->args_used - 1; if (TOP->arg_used[i] >= TOP->arg_alloced[i]) { tmpasm_arg_t *prev, *last; /* since argend[i] is also in the ->next pointer of the previous item in a block chain, we need to look it up */ for(prev = NULL, last = TOP->argv[i]; last->next != NULL; last = last->next) prev = last; TOP->arg_alloced[i] += 64; last = realloc(last, TOP->arg_alloced[i]+sizeof(tmpasm_arg_t)); if (prev == NULL) TOP->argv[i] = last; else prev->next = last; TOP->argend[i] = last; } TOP->argend[i]->data[TOP->arg_used[i]] = c; TOP->arg_used[i]++; } static void arg_free(tmpasm_arg_t *a) { tmpasm_arg_t *next; if (a == NULL) return; next = a->next; free(a); if (next != NULL) arg_free(next); } static void arg_new_next(tmpasm_t *ctx, int is_addr) { tmpasm_arg_t *a; int id; arg_append(ctx, '\0'); id = TOP->args_used - 1; assert(id>=0); TOP->arg_alloced[id] = 64; TOP->arg_used[id] = 0; a = malloc(TOP->arg_alloced[id]+sizeof(tmpasm_arg_t)); strcpy(a->data, "QWERT"); a->is_addr = is_addr; a->next = NULL; TOP->argend[id]->next = a; TOP->argend[id] = a; } static void arg_remove(tmpasm_t *ctx) { assert(TOP->args_used == 1); TOP->args_used = 0; TOP->argv[0] = NULL; TOP->argend[0] = NULL; TOP->arg_alloced[0] = 0; TOP->arg_used[0] = 0; } static int arg_is_addr(tmpasm_arg_t *a) { return (a->next == NULL) && (a->is_addr); } static void arg_end(tmpasm_t *ctx, int cmd_ctx) { tmpasm_arg_t *a; arg_append(ctx, '\0'); a = TOP->argv[TOP->args_used-1]; if (cmd_ctx) { /* when argument ends in a command context (not in a block inline), we may may need to switch back to command mode; example: after the cond of an "if cond then"*/ switch(TOP->kw) { case KW_IF: TOP->state = ST_PRECMD; break; case KW_FOREACH: if (!arg_is_addr(a)) { error(ctx, 0, "variable of a foreach must be an address"); return; } TOP->last_code->payload.fc_foreach.loop_var = strclone(a->data); arg_free(a); arg_remove(ctx); TOP->state = ST_PRECMD; break; case KW_IN: /* pop will free the argv[] array, but not the elements so "a" is safe to use after this line */ pop(ctx); /* in foreach context, after the IN-data */ TOP->last_code->payload.fc_foreach.data = a; /* we are in the body now, TOP is the foreach context, last_code is body */ TOP->last_code->payload.fc_foreach.code_body = code_new(KW_NOP); push(ctx, KW_none, ST_PRECMD, TOP->last_code->payload.fc_foreach.code_body); break; case KW_CASE: ctx->st->next->last_code->payload.fc_switch.last->data = a; arg_remove(ctx); push(ctx, KW_none, ST_PRECMD, TOP->last_code); break; case KW_SWITCH: TOP->last_code->payload.fc_switch.cond = a; arg_remove(ctx); TOP->state = ST_PRECMD; break; default: TOP->state = ST_PREDATA; } } } /* end of statement; update kw state for a composite control kw; for the rest just call the lib */ static void end_of_statement(tmpasm_t *ctx) { switch(TOP->kw) { case KW_none: case KW_THEN: case KW_ELSE: case KW_CASE: case KW_DEFAULT: TOP->last_code->payload.instr.argc = TOP->args_used; TOP->last_code->payload.instr.argv = TOP->argv; TOP->argv = NULL; free(TOP->argend); TOP->argend = NULL; TOP->args_used = 0; TOP->args_alloced = 0; break; default: /* don't mess with the payload */ ; } TOP->state = ST_PRECMD; } #define loc_update() \ do { \ TOP->last_code->line = TOP->kwline; \ TOP->last_code->col = TOP->kwcol; \ } while(0) static void got_kw(tmpasm_t *ctx, tmpasm_kw_t kw, int terminated) { switch(kw) { case KW_END: /* then-else threads have their own subcontext within the if subcontext; end needs to pop the innermost subcontext before terminating the if context */ if (TOP->kw == KW_IF) { error(ctx, 0, "unexpected \"end\" in \"if\" - expected \"then\""); goto bind_if_cond; } if ((TOP->kw == KW_ELSE) || (TOP->kw == KW_THEN)) pop(ctx); if (TOP->kw == KW_SWITCH) TOP->kw = TOP->old_kw; else { pop(ctx); if ((TOP->kw == KW_CASE) || (TOP->kw == KW_DEFAULT)) pop(ctx); } TOP->state = ST_PRECMD; /* have to restore context keyword after these */ if (TOP->kw == KW_FOREACH) TOP->kw = TOP->old_kw; break; case KW_IF: if (terminated) { error(ctx, 0, "unexpected end of if statement; expected a condition"); return; } TOP->last_code = code_append(ctx, KW_IF); TOP->last_code->payload.fc_if.code_then = code_new(KW_NOP); TOP->last_code->payload.fc_if.code_else = code_new(KW_NOP); loc_update(); TOP->state = ST_PRECMD; /* prepare for reading a condition */ push(ctx, KW_IF, ST_PREDATA, TOP->last_code); break; case KW_THEN: /* we are in an if context, right after reading a condition */ if (TOP->kw != KW_IF) { error(ctx, 0, "unexpected 'then' - must be in an 'if' after the condition"); return; } bind_if_cond:; TOP->last_code->payload.fc_if.cond = TOP->argv[0]; loc_update(); arg_remove(ctx); push(ctx, KW_THEN, ST_PRECMD, TOP->last_code->payload.fc_if.code_then); break; case KW_ELSE: /* we are in an if context, after and end */ if (TOP->kw != KW_THEN) { error(ctx, 0, "unexpected 'else' - must be in a 'then' block before an else"); return; } pop(ctx); /* that was the then branch */ push(ctx, KW_ELSE, ST_PRECMD, TOP->last_code->payload.fc_if.code_else); break; case KW_FOREACH: if (terminated) { error(ctx, 0, "unexpected end of if foreach statement; expected an address"); return; } TOP->last_code = code_append(ctx, KW_FOREACH); loc_update(); TOP->state = ST_PREDATA; TOP->old_kw = TOP->kw; TOP->kw = KW_FOREACH; break; case KW_IN: if (TOP->kw != KW_FOREACH) error(ctx, 0, "unexpected \"in\"; should be after the address in foreach"); else push(ctx, KW_IN, ST_PREDATA, NULL); break; case KW_SWITCH: if (terminated) { error(ctx, 0, "unexpected end of if switch statement; expected a data"); return; } TOP->last_code = code_append(ctx, KW_SWITCH); TOP->state = ST_PREDATA; TOP->old_kw = TOP->kw; TOP->kw = KW_SWITCH; loc_update(); break; case KW_CASE: case KW_DEFAULT: if (TOP->kw == KW_SWITCH) { tmpasm_case_t *c; c = malloc(sizeof(tmpasm_case_t)); c->body = code_new(KW_NOP); c->data = NULL; c->next = NULL; if (TOP->last_code->payload.fc_switch.last == NULL) { TOP->last_code->payload.fc_switch.first = c; TOP->last_code->payload.fc_switch.last = c; } else { TOP->last_code->payload.fc_switch.last->next = c; TOP->last_code->payload.fc_switch.last = c; } if (kw == KW_DEFAULT) { push(ctx, KW_DEFAULT, ST_PRECMD, c->body); push(ctx, KW_none, ST_PRECMD, c->body); c->data = NULL; } else push(ctx, KW_CASE, ST_PREDATA, c->body); } else error(ctx, 0, "unexpected \"case\" or \"default\"; should be in a switch (is the last case terminated by an \"end\"?)"); break; default: TOP->last_code = code_append(ctx, KW_none); TOP->last_code->payload.instr.call_name = strclone(TOP->cmd_buff); if (TOP->last_code->payload.instr.call_name != NULL) { TOP->last_code->payload.instr.call = ctx->cb->resolve(ctx, TOP->last_code->payload.instr.call_name); loc_update(); } if (terminated) TOP->state = ST_PRECMD; else TOP->state = ST_PREDATA; } } static void comment_start(tmpasm_t *ctx) { push(ctx, KW_none, ST_COMMENT, NULL); } int tmpasm_gotchar(tmpasm_t *ctx, char c) { if (ctx->dead) return -1; switch(TOP->state) { case ST_COMMENT: if ((c == '\n') || (c == '\r')) { pop(ctx); if (TOP->state == ST_PREDATA) end_of_statement(ctx); } break; case ST_PRECMD: if (c == '#') { comment_start(ctx); break; } if (is_space(c) || is_sep(c)) break; TOP->cmdi = 0; TOP->state = ST_CMD; TOP->kwline = ctx->line; TOP->kwcol = ctx->col; /* fall thru */ case ST_CMD: /* end of command or keyword */ if (is_space(c) || is_sep(c)) { TOP->cmd_buff[TOP->cmdi] = '\0'; got_kw(ctx, kw_lookup(TOP->cmd_buff), is_sep(c)); } else { TOP->cmd_buff[TOP->cmdi] = c; TOP->cmdi++; if (TOP->cmdi >= sizeof(TOP->cmd_buff)) error(ctx, 0, "keyword or instruction name is too long"); } break; case ST_PREDATA: if (c == '#') { comment_start(ctx); break; } if (is_space(c)) break; if (is_sep(c)) end_of_statement(ctx); else if (c == '{') { TOP->state = ST_STRING; arg_new(ctx, 0); } else if (c == '[') { TOP->state = ST_PREBLOCKSEP; arg_new(ctx, 0); } else if (is_addr(c)) { TOP->state = ST_ADDRESS; arg_new(ctx, 1); arg_append(ctx, c); } else error(ctx, c, "unexpected character; expected '{' for starting a string or an address"); break; case ST_PREBLOCKSEP: TOP->block_sep = c; TOP->state = ST_BLOCK; break; case ST_BLOCK: if (c == TOP->block_sep) TOP->state = ST_BLOCKSEP; else arg_append(ctx, c); break; case ST_BLOCKSEP: if (c != ']') { arg_new_next(ctx, 1); arg_append(ctx, c); TOP->state = ST_BLOCK_INLINE; } else arg_end(ctx, 1); break; case ST_BLOCK_INLINE: if (c == TOP->block_sep) { arg_new_next(ctx, 0); TOP->state = ST_BLOCK; } else arg_append(ctx, c); break; case ST_STRING: if (c == '}') arg_end(ctx, 1); else if (c == '\\') TOP->state = ST_STRING_ESCAPE; else arg_append(ctx, c); break; case ST_STRING_ESCAPE: { char co; switch(c) { case 'n': co = '\n'; break; case 'r': co = '\r'; break; case 't': co = '\t'; break; case '\\': co = '\\'; break; case 'o': co = '{'; break; case 'c': co = '}'; break; default: co = c; } arg_append(ctx, co); TOP->state = ST_STRING; } break; case ST_ADDRESS: if (is_space(c)) arg_end(ctx, 1); else if (is_sep(c)) { arg_end(ctx, 1); end_of_statement(ctx); } else if (is_addr(c)) arg_append(ctx, c); else error(ctx, c, "unexpected character; expected next character of the address"); break; } if (c == '\n') { ctx->line++; ctx->col = 1; } else ctx->col++; return 0; } tmpasm_t *tmpasm_init(const tmpasm_cb_t *cb) { tmpasm_t *ctx; ctx = calloc(sizeof(tmpasm_t), 1); ctx->line = 1; ctx->col = 1; ctx->code = code_new(KW_NOP); ctx->cb = cb; push(ctx, KW_none, ST_PRECMD, ctx->code); return ctx; } static void free_exec(tmpasm_exec_t *e) { int n; tmpasm_case_t *c, *c_next; tmpasm_exec_t *e_next; for(; e != NULL; e = e_next) { e_next = e->next; switch(e->kw) { case KW_none: if (e->payload.instr.call_name != NULL) free(e->payload.instr.call_name); for(n = 0; n < e->payload.instr.argc; n++) arg_free(e->payload.instr.argv[n]); free(e->payload.instr.argv); break; case KW_IF: arg_free(e->payload.fc_if.cond); free_exec(e->payload.fc_if.code_then); free_exec(e->payload.fc_if.code_else); break; case KW_FOREACH: free(e->payload.fc_foreach.loop_var); arg_free(e->payload.fc_foreach.data); free_exec(e->payload.fc_foreach.code_body); break; case KW_SWITCH: arg_free(e->payload.fc_switch.cond); for(c = e->payload.fc_switch.first; c != NULL; c = c_next) { c_next = c->next; if (c->data != NULL) arg_free(c->data); free_exec(c->body); free(c); } break; default:; } free(e); } } void tmpasm_uninit(tmpasm_t *ctx) { free_exec(ctx->code); while (ctx->st != NULL) pop_(ctx, 0); if (ctx->runtime_error_data != NULL) free(ctx->runtime_error_data); free(ctx); } /****************** runtime ********************/ static const char *tmpasm_runtime_error_fmts[] = { "success %s", "variable '%s' does not exist", "empty argument (broken AST)%s", "compilation error: control block without an \"end\"; premature end of script%s", "attempt to call unresolved instruction '%s'", NULL }; void tmpasm_runtime_error(tmpasm_t *ctx, int code, const char *data) { ctx->runtime_error = code; if (ctx->runtime_error_data != NULL) free(ctx->runtime_error_data); ctx->runtime_error_data = strclone(data); if (ctx->executing != NULL) { ctx->runtime_error_line = ctx->executing->line; ctx->runtime_error_col = ctx->executing->col; } else { ctx->runtime_error_line = 0; ctx->runtime_error_col = 0; } } const char *tmpasm_runtime_error_fmt(tmpasm_t *ctx) { if (ctx->runtime_error == 0) return NULL; if ((ctx->runtime_error < 0) && (ctx->cb->runtime_error_fmt != NULL)) { const char *fmt; fmt = ctx->cb->runtime_error_fmt(ctx); if (fmt != NULL) return fmt; } if ((ctx->runtime_error < 0) || ((size_t)ctx->runtime_error > (sizeof(tmpasm_runtime_error_fmts)/sizeof(char *)))) return "invalid error code %s"; return tmpasm_runtime_error_fmts[ctx->runtime_error]; } char *tmpasm_arg2str(tmpasm_t *ctx, tmpasm_arg_t *a, int keep_addr) { if (a == NULL) { tmpasm_runtime_error(ctx, 2, NULL); return strclone(""); } if (a->next != NULL) { /* block mode */ int alloced = 0, used = 0; char *s = NULL; const char *i; for(;a != NULL; a = a->next) { int l; if (a->is_addr) { i = ctx->cb->get(ctx, a->data); if (i == NULL) { i = ""; tmpasm_runtime_error(ctx, 1, strclone(a->data)); } } else i = a->data; l = strlen(i); if (used + l >= alloced) { alloced = used + l + 256; s = realloc(s, alloced); } memcpy(s+used, i, l); used += l; } s[used] = '\0'; return s; } /* non-block */ if (a->is_addr) { const char *i; if (keep_addr) i = a->data; else i = ctx->cb->get(ctx, a->data); if (i == NULL) { i = ""; tmpasm_runtime_error(ctx, 1, strclone(a->data)); } return strclone(i); } return strclone(a->data); } static void execute(tmpasm_t *ctx, tmpasm_exec_t *e) { tmpasm_case_t *c; void *state; char *cond, *list; const char *i; while((e != NULL) && (ctx->runtime_error == 0) && (ctx->halt == 0)) { ctx->executing = e; switch(e->kw) { case KW_none: if (e->payload.instr.call != NULL) e->payload.instr.call(ctx, e->payload.instr.call_name, e->payload.instr.argc, e->payload.instr.argv); else tmpasm_runtime_error(ctx, 4, e->payload.instr.call_name); break; case KW_IF: cond = tmpasm_arg2str(ctx, e->payload.fc_if.cond, 0); if (ctx->cb->is_true(ctx, cond)) execute(ctx, e->payload.fc_if.code_then); else execute(ctx, e->payload.fc_if.code_else); free(cond); break; case KW_FOREACH: list = tmpasm_arg2str(ctx, e->payload.fc_foreach.data, 0); for(i = ctx->cb->first(ctx, &state, list); i != NULL; i = ctx->cb->next(ctx, &state)) { ctx->cb->set(ctx, e->payload.fc_foreach.loop_var, i); execute(ctx, e->payload.fc_foreach.code_body); } free(list); break; case KW_SWITCH: cond = tmpasm_arg2str(ctx, e->payload.fc_switch.cond, 0); for(c = e->payload.fc_switch.first; c != NULL; c = c->next) { char *cv = NULL; if (c->data != NULL) cv = tmpasm_arg2str(ctx, c->data, 0); if ((c->data == NULL) || (ctx->cb->match(ctx, cond, cv))) { execute(ctx, c->body); if (cv != NULL) free(cv); break; } if (cv != NULL) free(cv); } free(cond); break; default:; } e = e->next; } } void tmpasm_execute(tmpasm_t *ctx) { if (TOP->next != NULL) { ctx->executing = TOP->next->last_code; tmpasm_runtime_error(ctx, 3, NULL); return; } if ((TOP->state != ST_PRECMD) || (TOP->kw != KW_none)) { ctx->executing = TOP->last_code; tmpasm_runtime_error(ctx, 3, NULL); return; } ctx->halt = 0; ctx->runtime_error = 0; if (ctx->runtime_error_data != NULL) { free(ctx->runtime_error_data); ctx->runtime_error_data = NULL; } if (ctx->cb->preexec != NULL) ctx->cb->preexec(ctx); execute(ctx, ctx->code); if (ctx->cb->postexec != NULL) ctx->cb->postexec(ctx); } xschem-2.8.1/scconfig/src/tmpasm/regression/0000755000175100017510000000000013400743707017261 5ustar svnsvnxschem-2.8.1/scconfig/src/tmpasm/regression/err_switch_nocond.ref0000644000175100017510000000011312217260230023451 0ustar svnsvnerror: unexpected end of if switch statement; expected a data at 1:7 (NOP) xschem-2.8.1/scconfig/src/tmpasm/regression/then.gasm0000644000175100017510000000011212215755502021061 0ustar svnsvn# test if without an else if cnd then print a1 a2 a3 end print a1 a2 a3 xschem-2.8.1/scconfig/src/tmpasm/regression/Tutor07_sub.gasm0000644000175100017510000000173212750535606022276 0ustar svnsvn# The following regex sub utils are scconfig specific. # Regex: substitute the first match of a pattern with str in a variable: # sub address pattern str put myvar {Hello world!\n} sub myvar {l} {2} print myvar # Address must resolve to an existing variable, pattern and str are data; # this means address can be a string that holds a variable name, it's the # same as if it was an addreess: sub {myvar} {l} {3} print myvar # Or it can be a block, which makes indirect addressing possible: # in [@@pointer@@] the @pointer@ part will be substituted with # the value of pointer, which is "myvar". put pointer {myvar} sub [@@pointer@@] {l} {4} print myvar # Since pattern and str are also data, address and blocks work there as well # (but this is _not_ a regex backreference): put punctuation {[!?.]} sub [@@pointer@@] punctuation [@ PUNCT:@punctuation@@] print myvar # gsub does the same, but substutites all matches, not only the first: gsub [@@pointer@@] {o} {_0_} print myvar xschem-2.8.1/scconfig/src/tmpasm/regression/foreach.ref0000644000175100017510000000100612217241351021354 0ustar svnsvnput [at 1:1] arg: a arg: {1} put [at 2:1] arg: foo arg: {example-FOO} put [at 3:1] arg: bar arg: {example-BAR} put [at 4:1] arg: baz arg: {example-BAZ} put [at 5:1] arg: hah arg: {haha} foreach n in [~foo ~bar~ baz~] [at 9:1] print [at 10:2] arg: {n=} arg: n arg: { } print [at 11:2] arg: {a11} arg: [~a12 ~hah~ a14~] arg: { } print [at 12:2] arg: {a21} arg: {a22 a23} arg: { } print [at 13:2] arg: {a31 } print [at 15:1] arg: {a41} arg: {a42} arg: {a43} arg: { } print [at 16:1] xschem-2.8.1/scconfig/src/tmpasm/regression/Makefile.in0000644000175100017510000000155613256100515021326 0ustar svnsvn# list of tests put tests [@ Tutor01_hello Tutor02_vars Tutor03_blocks Tutor04_if Tutor05_switch Tutor06_foreach Tutor07_sub Tutor08_uniq Tutor09_ui Tutor10_include_redir Tutor11_missing Tutor12_halt comment foreach if switch test then append order err_if_end err_if_else err_excess_end err_switch_end err_switch_nocond err_no_end @] uniq tests put test_diffs tests gsub test_diffs {[ \t\r\n]+} { } gsub test_diffs {\\>} {.diff} # TODO: replace this with wrap sub test_diffs {^ *} {} sub test_diffs { *$} {} print [@### PLEASE DO NOT EDIT THIS FILE, it has been generated from Makefile.in. ### TESTER=../tester all: @test_diffs@ # Explicit test rules @] foreach test in tests print [@ @test@.out: @test@.gasm $(TESTER) Makefile $(TESTER) < @test@.gasm > @test@.out 2>&1 @test@.diff: @test@.ref @test@.out diff -u @test@.ref @test@.out @] end xschem-2.8.1/scconfig/src/tmpasm/regression/Tutor05_switch.ref0000644000175100017510000000171412217241351022616 0ustar svnsvnput [at 15:1] arg: myvar arg: {foobar} switch myvar [at 16:1] case {baz} put [at 17:14] arg: res arg: {1} print [at 17:27] arg: {this is baz. } case {^oob} put [at 18:14] arg: res arg: {2} print [at 18:27] arg: {did you mean out-of-band? } case {^f} put [at 19:14] arg: res arg: {3} print [at 19:27] arg: {starts with f. } case {oob} put [at 20:14] arg: res arg: {4} print [at 20:27] arg: {OOB! } default put [at 21:14] arg: res arg: {0} print [at 21:27] arg: {none. } print [at 24:1] arg: {result is: } arg: res arg: { } put [at 28:1] arg: patt arg: {^number$} put [at 29:1] arg: REF arg: {3} switch [~num ~res~ ber~] [at 30:1] case patt print [at 31:23] arg: {empty } case [~^num ~REF~~] print [at 32:23] arg: {reference } put [at 38:1] arg: cond arg: {blobb} switch cond [at 39:1] case {lob} print [at 40:15] arg: {"then" } default print [at 41:15] arg: {"else" } xschem-2.8.1/scconfig/src/tmpasm/regression/Tutor11_missing.out0000644000175100017510000000017412752771512023030 0ustar svnsvnif ?a [at 5:7] then: print [at 6:2] arg: {empty} else: print [at 8:2] arg: {not empty} put [at 11:1] arg: b arg: ?a xschem-2.8.1/scconfig/src/tmpasm/regression/Tutor12_halt.gasm0000644000175100017510000000061713256100515022417 0ustar svnsvn# Instruction "halt" breaks the execution of the current script file # (returning from the C call to tmpasm() or stop processing an "include", # returning to executing the parent script). It is useful for cheap # termination of the script file from deep inside nested loops/ifs. put tmp {true} if tmp then foreach item in {foo bar true baz} print item {\n} if item then halt end end end xschem-2.8.1/scconfig/src/tmpasm/regression/comment.ref0000644000175100017510000000006612217241351021414 0ustar svnsvnprint [at 1:1] arg: data1 print [at 2:1] arg: data2 xschem-2.8.1/scconfig/src/tmpasm/regression/switch.ref0000644000175100017510000000122412217241351021250 0ustar svnsvnput [at 1:1] arg: swdata arg: {lol} switch swdata [at 2:1] case data1 print [at 3:24] arg: {1a} arg: {11} print [at 3:41] arg: {1b} arg: 12 print [at 3:56] arg: {1c} arg: 13 print [at 3:71] arg: {1d} arg: 14 case [~data2 ~a~~] print [at 4:24] arg: {2a} arg: 21 print [at 4:41] arg: {2b} arg: 22 print [at 4:56] arg: {2c} arg: 23 print [at 4:71] arg: {2d} arg: 24 default print [at 5:24] arg: {3a} arg: 31 print [at 5:41] arg: {3b} arg: 32 print [at 5:56] arg: {3c} arg: 33 print [at 5:71] arg: {3d} arg: 34 print [at 7:1] arg: {i1} print [at 8:1] arg: {i2} xschem-2.8.1/scconfig/src/tmpasm/regression/Tutor01_hello.ref0000644000175100017510000000030612217241351022410 0ustar svnsvnprint [at 7:1] arg: {hello world! } print [at 11:1] arg: {hello} arg: {world!} arg: { } print [at 14:1] print [at 17:1] arg: {HELLO} print [at 17:16] arg: { WORLD!} print [at 17:36] arg: { } xschem-2.8.1/scconfig/src/tmpasm/regression/err_switch_end.ref0000644000175100017510000000011312217260230022737 0ustar svnsvnerror: unexpected end of if switch statement; expected a data at 1:7 (NOP) xschem-2.8.1/scconfig/src/tmpasm/regression/if.ref0000644000175100017510000000027412217241351020351 0ustar svnsvnput [at 1:1] arg: a arg: 1 if a [at 2:6] then: if b [at 3:7] then: print [at 4:3] arg: {then-then} else: print [at 6:3] arg: {then-else} else: print [at 9:2] arg: {else} xschem-2.8.1/scconfig/src/tmpasm/regression/Tutor07_sub.ref0000644000175100017510000000106112217243651022110 0ustar svnsvnput [at 6:1] arg: myvar arg: {Hello world! } sub [at 7:1] arg: myvar arg: {l} arg: {2} print [at 8:1] arg: myvar sub [at 13:1] arg: {myvar} arg: {l} arg: {3} print [at 14:1] arg: myvar put [at 19:1] arg: pointer arg: {myvar} sub [at 20:1] arg: [~~pointer~~] arg: {l} arg: {4} print [at 21:1] arg: myvar put [at 25:1] arg: punctuation arg: {[!?.]} sub [at 26:1] arg: [~~pointer~~] arg: punctuation arg: [~ PUNCT:~punctuation~~] print [at 27:1] arg: myvar gsub [at 30:1] arg: [~~pointer~~] arg: {o} arg: {_0_} print [at 31:1] arg: myvar xschem-2.8.1/scconfig/src/tmpasm/regression/err_if_end.ref0000644000175100017510000000014112217256047022050 0ustar svnsvnerror: unexpected "end" in "if" - expected "then" at 2:4 if v [at 2:1] then: (NOP) else: (NOP) xschem-2.8.1/scconfig/src/tmpasm/regression/Tutor08_uniq.gasm0000644000175100017510000000330613216664404022456 0ustar svnsvn# The following string util is scconfig specific. # Uniq: filter a list of words and remove duplicate items. This instruction # is useful for using text nodes as lists. # The simplest syntax is "uniq address" which will do the filtering on # the content of a database address. The default separator is \n put list [@this is a list of words, a list of words. @] print {original:\n} list {\n} uniq list print {uniq:\n} list {\n} # If the original list needs to be left intact, the alternative syntax is # "uniq dest-addr src-addr": put foo [@this foo is a this foo @] uniq tmp foo print {original:\n} foo {\nuniq:\n} tmp {\n} # Note: the algorithm of uniq is slow, and will not be efficient for very long # lists. Uniq preserves the order of words (by their first appearance). # Sortuniq performs the same action, except it also orders the list using # qsort() (so it is even slower on big lists). sortuniq tmp foo print {\nsortuniq:\n} tmp {\n} # A typical use case is having #defines and #includes on a list; #defines # should end up on the top, but order of #incldues should be preserved, so # sortuniq is not an option. When uniq is called with more than 2 argument,s # the extra arguments specify group regexps; the input is first organized into # groups then uniq is ran on these groups. Anything that doesn't match the # groups listed are put in a "misc" group that ends up as the last group. put list [@#define foo #include "foo20.h" #include "foo10.h" /* misc1 */ #define bar #include "bar1.h" #include "bar2.h" /* misc2 */ @] # set input field separator to \n so uniq is splitting by lines, not by # words put /tmpasm/IFS {\n} uniq tmp list {^#define} {^#include} print {original:\n} list {\ngrouped uniq:\n} tmp {\n} xschem-2.8.1/scconfig/src/tmpasm/regression/test.gasm0000644000175100017510000000176312750535606021124 0ustar svnsvn### set up internal variables ### put /local/cflags {-std=c99 -Wall} put /local/ldflags {-lm} put /local/objs {main.o foo.o bar.o} # turn off optimization and add -g in debug mode if /local/debug then append /local/cflags {-g} else append /local/cflags {-O2} end # if somelib is selected, add -I and -l isempty /local/r /local/somelib invert /local/r if /local/r then append /local/cflags { -I/usr/include/somelib} append /local/ldflags { -lsomelib} end ### Generate the Makefile ### print [@ # Makefile generated by scconfig - DO NOT EDIT - please edit Makefile.in CFLAGS=@/local/cflags@ LDFLAGS=@/local/ldflags@ OBJS=@/local/objs@ all: main main: $(OBJS) $(CC) $(LDFLAGS) @] # loop over each object and generate an explicit rule # (we are generating a dumb Makefile that would work with any # old version of make) foreach /local/o in /local/objs put /local/c /local/o sub /local/c {.o$} {.c} print [@ @/local/o@: @/local/c@ $(CC) -c $(CFLAGS) @/local/c@ -o @/local/o@ @] end print {#end\n} xschem-2.8.1/scconfig/src/tmpasm/regression/err_excess_end.ref0000644000175100017510000000010512217257260022742 0ustar svnsvnerror: Excess "end" at 3:4 if {1} [at 1:8] then: (NOP) else: (NOP) xschem-2.8.1/scconfig/src/tmpasm/regression/Tutor06_foreach.gasm0000644000175100017510000000240212216217543023100 0ustar svnsvn# The only loop tmpasm implements is a foreach that iterates on a list. # How the list is split into items is up to the environment. In scconfig # the list is white space separated by default. The word following foreach # must be the name of a variable (that will be set to the next item before # each iteration). The word after "in" is data (string, variable, block). foreach item in {this is a list of words} print item {\n} end # Like any other control, foreach can be nested. The following # example will iterate item on foo, bar and baz, printing 3 words # for each from a block: {next:}, the item and a newline. The newline # is specified as a vairable since \ escaping does not work in blocks. put nl {\n} foreach item in {foo bar baz} foreach w in [@next: @item@@nl@@] print w end end # Foreach makes a copy of the list before the first iteration. This # is relevant if the list is a variable that may change during the # loop. The following exmaple takes a list of libs and if -lsdl is # present on the list, appends -lsvga to the list and inserts -lm; # these changes to "libs" will not alter the loop. put libs {-lsdl -ltcl8.4} foreach l in libs print {l=} l {\n} switch l case {^-lsdl} put libs [@-lm @libs@ -lsvga@]; end end end print {libs=} libs {\n} xschem-2.8.1/scconfig/src/tmpasm/regression/append.gasm0000644000175100017510000000013412217512074021373 0ustar svnsvnappend tmp {foo} append tmp {bar} append tmp {baz} foreach n in tmp print {-> } n {\n} end xschem-2.8.1/scconfig/src/tmpasm/regression/Tutor08_uniq.ref0000644000175100017510000000150313216663535022304 0ustar svnsvnput [at 7:1] arg: list arg: {this is a list of words, a list of words. } print [at 18:1] arg: {original: } arg: list arg: { } uniq [at 19:1] arg: list print [at 20:1] arg: {uniq: } arg: list arg: { } put [at 24:1] arg: foo arg: {this foo is a this foo } uniq [at 31:1] arg: tmp arg: foo print [at 32:1] arg: {original: } arg: foo arg: { uniq: } arg: tmp arg: { } sortuniq [at 39:1] arg: tmp arg: foo print [at 40:1] arg: { sortuniq: } arg: tmp arg: { } put [at 49:1] arg: list arg: {#define foo #include "foo20.h" #include "foo10.h" /* misc1 */ #define bar #include "bar1.h" #include "bar2.h" /* misc2 */ } put [at 61:1] arg: /tmpasm/IFS arg: { } uniq [at 63:1] arg: tmp arg: list arg: {^#define} arg: {^#include} print [at 64:1] arg: {original: } arg: list arg: { grouped uniq: } arg: tmp arg: { } xschem-2.8.1/scconfig/src/tmpasm/regression/test.ref0000644000175100017510000000202712750535606020743 0ustar svnsvnput [at 2:1] arg: /local/cflags arg: {-std=c99 -Wall} put [at 3:1] arg: /local/ldflags arg: {-lm} put [at 4:1] arg: /local/objs arg: {main.o foo.o bar.o} if /local/debug [at 7:17] then: append [at 8:2] arg: /local/cflags arg: {-g} else: append [at 10:2] arg: /local/cflags arg: {-O2} isempty [at 14:1] arg: /local/r arg: /local/somelib invert [at 15:1] arg: /local/r if /local/r [at 16:13] then: append [at 17:2] arg: /local/cflags arg: { -I/usr/include/somelib} append [at 18:2] arg: /local/ldflags arg: { -lsomelib} else: (NOP) print [at 22:1] arg: [~ # Makefile generated by scconfig - DO NOT EDIT - please edit Makefile.in CFLAGS=~/local/cflags~ LDFLAGS=~/local/ldflags~ OBJS=~/local/objs~ all: main main: $(OBJS) $(CC) $(LDFLAGS) ~] foreach /local/o in /local/objs [at 38:1] put [at 39:2] arg: /local/c arg: /local/o sub [at 40:2] arg: /local/c arg: {.o$} arg: {.c} print [at 41:2] arg: [~ ~/local/o~: ~/local/c~ $(CC) -c $(CFLAGS) ~/local/c~ -o ~/local/o~ ~] print [at 47:1] arg: {#end } xschem-2.8.1/scconfig/src/tmpasm/regression/err_if_else.ref0000644000175100017510000000020512217256676022243 0ustar svnsvnerror: unexpected 'else' - must be in a 'then' block before an else at 2:5 if *NULL - broken AST* [at 1:1] then: (NOP) else: (NOP) xschem-2.8.1/scconfig/src/tmpasm/regression/comment.gasm0000644000175100017510000000015012215756762021600 0ustar svnsvnprint data1 # this is a comment; until the end of this line print data2 # this shall be a second print xschem-2.8.1/scconfig/src/tmpasm/regression/err_no_end.ref0000644000175100017510000000013412217263041022060 0ustar svnsvnpritn [at 1:1] arg: {foo} switch {cond} [at 2:1] case {1} print [at 3:11] arg: {foo} xschem-2.8.1/scconfig/src/tmpasm/regression/Tutor04_if.gasm0000644000175100017510000000122612216005033022055 0ustar svnsvnput myvar {true} # The simplest flow control is an if. It takes its first argument and # calls the environment to decide if it is true or false. If it's true # the "then" branch is executed, if it's false, the "else" branch runs. if myvar then print {myvar is true (1)\n} else print {myvar is false (1)\n} end # it is possible to omit the else branch if myvar then print {myvar is true (2)\n} end # the then branch may be empty: if myvar then else print {myvar is false (3)\n} end # embedding controls is legal: put foo {false} if myvar then if foo then print {myvar and bar are true (4)\n} else print {myvar is true, bar is false (4)\n} end end xschem-2.8.1/scconfig/src/tmpasm/regression/Tutor02_vars.ref0000644000175100017510000000072213237242446022274 0ustar svnsvnput [at 4:1] arg: myvar arg: {Hello world! } print [at 7:1] arg: myvar print [at 11:1] arg: {Hello universe! } arg: myvar put [at 15:1] arg: str arg: {cats raining from the sky} put [at 16:1] arg: tmp arg: str print [at 17:1] arg: str arg: {==} arg: tmp arg: { } print [at 21:1] arg: {safe get: '} arg: ?nonexist arg: {' } print [at 25:1] arg: {exists (no): } arg: &nonexist arg: { } print [at 26:1] arg: {exists (yes): } arg: &myvar arg: { } xschem-2.8.1/scconfig/src/tmpasm/regression/if.gasm0000644000175100017510000000014712215755502020531 0ustar svnsvnput a 1 if a then if b then print {then-then} else print {then-else} end else print {else} end xschem-2.8.1/scconfig/src/tmpasm/regression/Tutor11_missing.ref0000644000175100017510000000017412752771512022775 0ustar svnsvnif ?a [at 5:7] then: print [at 6:2] arg: {empty} else: print [at 8:2] arg: {not empty} put [at 11:1] arg: b arg: ?a xschem-2.8.1/scconfig/src/tmpasm/regression/err_if_end.gasm0000644000175100017510000000001112217256047022217 0ustar svnsvnif v end xschem-2.8.1/scconfig/src/tmpasm/regression/append.ref0000644000175100017510000000027512217512074021226 0ustar svnsvnappend [at 1:1] arg: tmp arg: {foo} append [at 2:1] arg: tmp arg: {bar} append [at 3:1] arg: tmp arg: {baz} foreach n in tmp [at 4:1] print [at 5:2] arg: {-> } arg: n arg: { } xschem-2.8.1/scconfig/src/tmpasm/regression/Tutor10_include_redir.ref0000644000175100017510000000053412217253432024123 0ustar svnsvnprint [at 14:1] arg: {this goes to the default output } redir [at 18:1] arg: {Tutor10.inc} print [at 19:1] arg: {# this is a generated file.} print [at 20:1] arg: { print {hello world from my include!\n} } redir [at 25:1] print [at 26:1] arg: {back at default output. } print [at 45:1] arg: {Include: } include [at 46:1] arg: {Tutor10.inc} xschem-2.8.1/scconfig/src/tmpasm/regression/err_excess_end.gasm0000644000175100017510000000002412217257260023115 0ustar svnsvnif {1} then end end xschem-2.8.1/scconfig/src/tmpasm/regression/Tutor04_if.ref0000644000175100017510000000105112217241351021704 0ustar svnsvnput [at 1:1] arg: myvar arg: {true} if myvar [at 6:10] then: print [at 7:2] arg: {myvar is true (1) } else: print [at 9:2] arg: {myvar is false (1) } if myvar [at 14:10] then: print [at 15:2] arg: {myvar is true (2) } else: (NOP) if myvar [at 19:10] then: (NOP) else: print [at 20:2] arg: {myvar is false (3) } put [at 24:1] arg: foo arg: {false} if myvar [at 25:10] then: if foo [at 26:9] then: print [at 27:3] arg: {myvar and bar are true (4) } else: print [at 29:3] arg: {myvar is true, bar is false (4) } else: (NOP) xschem-2.8.1/scconfig/src/tmpasm/regression/then.ref0000644000175100017510000000017312217241351020707 0ustar svnsvnif cnd [at 2:8] then: print [at 3:2] arg: a1 arg: a2 arg: a3 else: (NOP) print [at 6:1] arg: a1 arg: a2 arg: a3 xschem-2.8.1/scconfig/src/tmpasm/regression/Tutor09_ui.gasm0000644000175100017510000000115512217250705022113 0ustar svnsvn# The following user interface utils are scconfig specific. # The report infrstructure is the main UI in scconfig. It prints # messages to the console. The "report" instruction works similar # to print, but its output is always the console, immune to # redirections and default file output (tmpasm is most commonly # used for generating files, so the default output file is not # the console but a file being generated) put myvar {!\n} report {hello } {world} myvar report [@hello world@myvar@@] # If an error is detected during generation of a file, the script should abort. # This is a direct call to abort(2). abort xschem-2.8.1/scconfig/src/tmpasm/regression/err_if_else.gasm0000644000175100017510000000003412217256676022416 0ustar svnsvnif v else print {else} end xschem-2.8.1/scconfig/src/tmpasm/regression/Tutor03_blocks.gasm0000644000175100017510000000175312216003062022740 0ustar svnsvn# Blocks are special syntax to make it easier to handle large, # to-be-printed-verbatim blocks of data, which is essential in a template # language. Blocks are enclosed in [$ $], where $ is an arbitrary character # that shall be chosen by the programmer, per block; once a characher is # chosen, it can not appear in the string. There is no backslash escaping # in blocks. Blocks can be used anywhere where strings could be used. print [@this is a string@] {\n} print {--\n} put myblk [!a block of multiline data. !] print myblk # A special feature of the block is inline variable substitution using the same # separator character chosen at the opening brace. In the example below # myvar is substituted because it is sorrounded by the separator (@ in # the first case and $ in the second case). Whitespace and newlines # are preserved in the block, even in the inline variable name! put myvar {world} print {--\n} print [@ hello @myvar@! @] {\n} print {--\n} print [$ hi @myvar@! $] print {--\n} xschem-2.8.1/scconfig/src/tmpasm/regression/Tutor12_halt.ref0000644000175100017510000000033613256100515022242 0ustar svnsvnput [at 6:1] arg: tmp arg: {true} if tmp [at 7:8] then: foreach item in {foo bar true baz} [at 8:2] print [at 9:3] arg: item arg: { } if item [at 10:11] then: halt [at 11:4] else: (NOP) else: (NOP) xschem-2.8.1/scconfig/src/tmpasm/regression/order.gasm0000644000175100017510000000163713155152146021252 0ustar svnsvn# test if without an else put list {one two three four} print list {\n} print {\nnothing:\n} # do nothing: order matches order out list {one} {before} {two} print out {\n} order out list {one} {before} {one} print out {\n} order out list {one} {after} {one} print out {\n} order out list {two} {after} {one} print out {\n} # do nothing: not on list matches order out list {nine} {after} {one} print out {\n} order out list {one} {after} {nine} print out {\n} print {\nbefore:\n} order out list {two} {before} {one} print out {\n} order out list {four} {before} {one} print out {\n} order out list {four} {before} {three} print out {\n} order out list {three} {before} {two} print out {\n} print {\nafter:\n} order out list {one} {after} {two} print out {\n} order out list {one} {after} {four} print out {\n} order out list {two} {after} {three} print out {\n} order out list {two} {after} {four} print out {\n} xschem-2.8.1/scconfig/src/tmpasm/regression/Tutor02_vars.gasm0000644000175100017510000000157113237242401022441 0ustar svnsvn# Variables are stored in a hash. Variable names follow the normal # identifier rules with less restrictions (can start with number) # To set the value of a variable, use: put var value put myvar {Hello world!\n} # Referencing the variable is done by using its name print myvar # In most context arguments are data; data can be both string literal and # variable reference: print {Hello universe! } myvar # the second var of put is just data, can be string or variable; copying # a variable: put str {cats raining from the sky} put tmp str print str {==} tmp {\n} # the ? prefix results in empty string if a variable doesnt exist, instead # of throwing a runtime error print {safe get: '} ?nonexist {'\n} # the & prefix evaluates to "true" or "false" depending on whether the node # exists in the tree or not print {exists (no): } &nonexist {\n} print {exists (yes): } &myvar {\n} xschem-2.8.1/scconfig/src/tmpasm/regression/err_no_end.gasm0000644000175100017510000000006512217263041022236 0ustar svnsvnpritn {foo} switch {cond} case {1} print {foo}; end xschem-2.8.1/scconfig/src/tmpasm/regression/err_switch_nocond.gasm0000644000175100017510000000004612217260230023631 0ustar svnsvnswitch case data print {foo}; end end xschem-2.8.1/scconfig/src/tmpasm/regression/Tutor11_missing.gasm0000644000175100017510000000031713155152514023140 0ustar svnsvn# conditional/safe variable reference: name prefixed by ? # if the variable does not exist, no error is thrown but empty # string is returned if ?a then print {empty} else print {not empty} end put b ?a xschem-2.8.1/scconfig/src/tmpasm/regression/Tutor09_ui.ref0000644000175100017510000000023412217250705021735 0ustar svnsvnput [at 9:1] arg: myvar arg: {! } report [at 10:1] arg: {hello } arg: {world} arg: myvar report [at 11:1] arg: [~hello world~myvar~~] abort [at 15:1] xschem-2.8.1/scconfig/src/tmpasm/regression/foreach.gasm0000644000175100017510000000053412215771633021545 0ustar svnsvnput a {1} put foo {example-FOO} put bar {example-BAR} put baz {example-BAZ} put hah {haha} # should set n to the string foo, the value of bar and the string baz # per iteration foreach n in [~foo ~bar~ baz~] print {n=} n {\n} print {a11} [@a12 @hah@ a14@] {\n} print {a21} {a22 a23} {\n} print {a31\n} end print {a41} {a42} {a43} {\n} print xschem-2.8.1/scconfig/src/tmpasm/regression/Tutor10_include_redir.gasm0000644000175100017510000000400512217253432024273 0ustar svnsvn# NOTE: THIS EXAMPLE WILL NOT WORK IN THE ON-LINE WEB VERSION # These features are scconfig specific. # There is a default output file coming from the environment; this # is the file being generated. In the most common cases this is the # only file the script will ever write. Any "print" instruction will # write this file by default. However, sometimes it is handy # to generate a small misc file during generating a large file. Thus # the output file that "print" writes is not hardwired. Instead, there # is the default output file and the current output file. Instruction # "redir" can change the current output file. print {this goes to the default output\n} # redirect to Tutor10.inc; any "print" until the next "redir" will # write that file redir {Tutor10.inc} print {# this is a generated file.} print [@ print {hello world from my include!\n} @] # switch back to the default output redir print {back at default output.\n} # Dynamic include: the script may include another script, runtime. When # an include instruction is executed, the referred file is open, read, # parsed and executed, recusively. # # Include being dynamic (or runtime) is unusual, but has the following # advantages: # - file name for inclusion can be calculated # - conditional include is easily possible without an extra preprocessing layer # - it is possible to generate a script on the fly and include it (sort of eval) # Drawbacks: # - it is possible to end up in an infinite loop that will only stop when # resources run out (open fds or memory) # - it is slow, e.g. if the body of a foreach contains include, the whole # read-parse-execute procedure is repeated for each item # Redir files are overwritten when first open from an execution. print {Include:\n} include {Tutor10.inc} # NOTE: the above script works only because "redir" has a side effect: # whenever redirection switches away from a file, that file is flushed. # This happens even if the new current output is the same as the old # current output (no actual switch takes place). xschem-2.8.1/scconfig/src/tmpasm/regression/Tutor05_switch.gasm0000644000175100017510000000306112216215046022767 0ustar svnsvn# Switch is similar to case in posix shell and switch in C. It takes a # data argument and matches is against cases until the first match. It # executes the code for that match and stops executing the switch (unlike # in C, and like in sh, there is no fall-thru). A default case can be # defined as a catch-all rule. # # Scconfig uses regex matching (unlike sh (shell globbing) and C (integer)). # # The first word after the switch keyword is the string that is matched # against case patterns; the first word after a case is the pattern # the string is matched against. Each branch must be terminated by an "end", # just as the whole switch. Default doesn't have pattern, instructions start # immediately. put myvar {foobar} switch myvar case {baz} put res {1}; print {this is baz.\n}; end; case {^oob} put res {2}; print {did you mean out-of-band?\n}; end; case {^f} put res {3}; print {starts with f.\n}; end; case {oob} put res {4}; print {OOB!\n}; end; default put res {0}; print {none.\n}; end; end; print {result is: } res {\n} # data is data - can be block as well, anywhere, in switch or case: put patt {^number$} put REF {3} switch [@num @res@ ber@] case patt print {empty\n}; end; case [!^num !REF!!] print {reference\n}; end; end # one of the uses of switch is to construct an if-then-else that uses # matching instead of checking for true/false; the following example # demonstrates how an "if cond matches {lob}" is done with switch. put cond {blobb} switch cond case {lob} print {"then"\n}; end default print {"else"\n}; end end xschem-2.8.1/scconfig/src/tmpasm/regression/Tutor03_blocks.ref0000644000175100017510000000057712217241351022576 0ustar svnsvnprint [at 7:1] arg: {this is a string} arg: { } print [at 9:1] arg: {-- } put [at 11:1] arg: myblk arg: {a block of multiline data. } print [at 16:1] arg: myblk put [at 24:1] arg: myvar arg: {world} print [at 25:1] arg: {-- } print [at 26:1] arg: [~ hello ~myvar~! ~] arg: { } print [at 27:1] arg: {-- } print [at 28:1] arg: { hi @myvar@! } print [at 31:1] arg: {-- } xschem-2.8.1/scconfig/src/tmpasm/regression/Tutor01_hello.gasm0000644000175100017510000000113012216005160022552 0ustar svnsvn# Comments start with # and end at the end of the line; comments # can be started anywhere outside of strings and blocks # Print will print each argument without appending a newline. An argument # is a data, string literals are written in brace. Escape sequences # are as usual print {hello world!\n} # Print doesn't have any hidden side effect: no separators printed # between arguments print {hello} {world!} {\n} # Print works without an argument as well: it just prints nothing print # instructions are separated by newlines and/or semicolons: print {HELLO}; print { WORLD!};;;; print {\n}; xschem-2.8.1/scconfig/src/tmpasm/regression/switch.gasm0000644000175100017510000000051012215755502021426 0ustar svnsvnput swdata {lol} switch swdata case data1 print {1a} {11}; print {1b} 12; print {1c} 13; print {1d} 14; end; case [~data2 ~a~~] print {2a} 21; print {2b} 22; print {2c} 23; print {2d} 24; end; default print {3a} 31; print {3b} 32; print {3c} 33; print {3d} 34; end; end; print {i1} print {i2} xschem-2.8.1/scconfig/src/tmpasm/regression/order.ref0000644000175100017510000000333713155152617021101 0ustar svnsvnput [at 2:1] arg: list arg: {one two three four} print [at 4:1] arg: list arg: { } print [at 6:1] arg: { nothing: } order [at 9:1] arg: out arg: list arg: {one} arg: {before} arg: {two} print [at 10:1] arg: out arg: { } order [at 12:1] arg: out arg: list arg: {one} arg: {before} arg: {one} print [at 13:1] arg: out arg: { } order [at 15:1] arg: out arg: list arg: {one} arg: {after} arg: {one} print [at 16:1] arg: out arg: { } order [at 18:1] arg: out arg: list arg: {two} arg: {after} arg: {one} print [at 19:1] arg: out arg: { } order [at 22:1] arg: out arg: list arg: {nine} arg: {after} arg: {one} print [at 23:1] arg: out arg: { } order [at 24:1] arg: out arg: list arg: {one} arg: {after} arg: {nine} print [at 25:1] arg: out arg: { } print [at 27:1] arg: { before: } order [at 28:1] arg: out arg: list arg: {two} arg: {before} arg: {one} print [at 29:1] arg: out arg: { } order [at 31:1] arg: out arg: list arg: {four} arg: {before} arg: {one} print [at 32:1] arg: out arg: { } order [at 34:1] arg: out arg: list arg: {four} arg: {before} arg: {three} print [at 35:1] arg: out arg: { } order [at 37:1] arg: out arg: list arg: {three} arg: {before} arg: {two} print [at 38:1] arg: out arg: { } print [at 40:1] arg: { after: } order [at 41:1] arg: out arg: list arg: {one} arg: {after} arg: {two} print [at 42:1] arg: out arg: { } order [at 44:1] arg: out arg: list arg: {one} arg: {after} arg: {four} print [at 45:1] arg: out arg: { } order [at 47:1] arg: out arg: list arg: {two} arg: {after} arg: {three} print [at 48:1] arg: out arg: { } order [at 50:1] arg: out arg: list arg: {two} arg: {after} arg: {four} print [at 51:1] arg: out arg: { } xschem-2.8.1/scconfig/src/tmpasm/regression/Tutor06_foreach.ref0000644000175100017510000000077712217241351022735 0ustar svnsvnforeach item in {this is a list of words} [at 7:1] print [at 8:2] arg: item arg: { } put [at 15:1] arg: nl arg: { } foreach item in {foo bar baz} [at 16:1] foreach w in [~next: ~item~~nl~~] [at 17:2] print [at 18:3] arg: w put [at 27:1] arg: libs arg: {-lsdl -ltcl8.4} foreach l in libs [at 28:1] print [at 29:2] arg: {l=} arg: l arg: { } switch l [at 30:2] case {^-lsdl} put [at 31:19] arg: libs arg: [~-lm ~libs~ -lsvga~] print [at 34:1] arg: {libs=} arg: libs arg: { } xschem-2.8.1/scconfig/src/tmpasm/regression/err_switch_end.gasm0000644000175100017510000000001312217260230023111 0ustar svnsvnswitch end xschem-2.8.1/scconfig/src/tmpasm/tmpasm_scconfig.c0000644000175100017510000003344513366254556020444 0ustar svnsvn#include #include #include #include "tmpasm.h" #include "db.h" #include "regex.h" #include "openfiles.h" #include "libs.h" #include "tmpasm_scconfig.h" #include "log.h" #include "regex.h" #ifndef TMPASM_PATH #define TMPASM_PATH "/tmpasm" #endif #ifndef IFS_PATH #define IFS_PATH TMPASM_PATH "/IFS" #endif #ifndef IFS_DEFAULT #define IFS_DEFAULT " \t\r\n" #endif #ifndef OFS_PATH #define OFS_PATH TMPASM_PATH "/OFS" #endif #ifndef OFS_DEFAULT #define OFS_DEFAULT "\n" #endif typedef struct scc_s { openfiles_t ofl; FILE *fout, *default_fout; const char *cwd; } scc_t; static const char *scc_runtime_error_fmts[] = { /* -0 */ "success scc %s", /* -1 */ "\"put\" requires exactly two arguments (got %s)", /* -2 */ "not enough arguments for sub; should be \"sub node pattern str\"%s", /* -3 */ "regex syntax error: %s", /* -4 */ "not enough arguments for uniq; should be \"uniq destnode\" or \"uniq destnode src\"%s", /* -5 */ "redir: too many arguments%s", /* -6 */ "redir: can't open %s", /* -7 */ "exiting due to a previous runtime error occurred in included file %s", /* -8 */ "can't include '%s': can't open file", /* -9 */ "\"put\" requires two or three arguments (got %s)", /* -10 */ "\"order\" requires 4 or 5 arguments: \"order destnode word before|after word\" or \"order destnode src word before|after word\"", /* -11 */ "\"uniq\" got too many grouping regular expressions", NULL }; static int print_runtime_error(tmpasm_t *ctx, const char *ifn) { if (ctx->runtime_error != 0) { const char *fmt = tmpasm_runtime_error_fmt(ctx); fprintf(stderr, "Runtime error at %s %d:%d: ", ifn, ctx->runtime_error_line, ctx->runtime_error_col); fprintf(stderr, fmt, (ctx->runtime_error_data == NULL ? "" : ctx->runtime_error_data)); fprintf(stderr, "\n"); return -1; } return 0; } /* allocate and build a full path using ud->cwd and fn */ static char *scc_path(scc_t *ud, const char *fn) { if (ud->cwd == NULL) return strclone(fn); return str_concat("", ud->cwd, "/", fn, NULL); } /******** db binding ********/ static const char *scc_get(tmpasm_t *ctx, const char *addr) { (void) ctx; /* not used */ if (*addr == '&') { /* return whether exists */ if (get(addr+1) != NULL) return strue; return sfalse; } if (*addr == '?') { /* safe get: return "" instead of NULL to avoid runtime error */ const char *res = get(addr+1); if (res == NULL) return ""; return res; } return get(addr); } static void scc_set(tmpasm_t *ctx, const char *addr, const char *data) { (void) ctx; /* not used */ put(addr, data); } static int scc_is_true(tmpasm_t *ctx, const char *data) { (void) ctx; /* not used */ return ((strcmp(data, "1") == 0) || istrue(data)); } static int scc_match(tmpasm_t *ctx, const char *str, const char *pat) { (void) ctx; /* not used */ re_comp(pat); return re_exec(str); } static const char *scc_ifs(tmpasm_t *ctx) { const char *ifs = get(IFS_PATH); (void) ctx; /* not used */ if (ifs == NULL) return IFS_DEFAULT; return ifs; } static const char *scc_ofs(tmpasm_t *ctx) { const char *ofs = get(OFS_PATH); (void) ctx; /* not used */ if (ofs == NULL) return OFS_DEFAULT; return ofs; } static const char *scc_next(tmpasm_t *ctx, void **state) { char **s = (char **)state; char *start; const char *IFS; IFS = scc_ifs(ctx); /* strip leading whitespace */ while(chr_inset(**s, IFS)) (*s)++; /* at the end of the string, no more tokens */ if (**s == '\0') return NULL; start = *s; /* skip non-whitespace */ while(!(chr_inset(**s, IFS)) && (**s != '\0')) (*s)++; if (**s != '\0') { **s = '\0'; (*s)++; } return start; } static const char *scc_first(tmpasm_t *ctx, void **state, char *list) { *state = list; return scc_next(ctx, state); } /******** instructions ********/ static void instr_put(tmpasm_t *ctx, char *iname, int argc, tmpasm_arg_t *argv[]) { char *addr, *val; (void) iname; /* not used */ if (argc != 2) { char str[16]; sprintf(str, "%d", argc); tmpasm_runtime_error(ctx, -1, str); return; } addr = tmpasm_arg2str(ctx, argv[0], 1); val = tmpasm_arg2str(ctx, argv[1], 0); if (*addr != '\0') put(addr, val); free(addr); free(val); } static void instr_append(tmpasm_t *ctx, char *iname, int argc, tmpasm_arg_t *argv[]) { char *addr, *val; char *sep; (void) iname; /* not used */ if ((argc < 2) || (argc > 3)) { char str[16]; sprintf(str, "%d", argc); tmpasm_runtime_error(ctx, -9, str); return; } addr = tmpasm_arg2str(ctx, argv[0], 1); val = tmpasm_arg2str(ctx, argv[1], 0); if (argc >= 3) sep = tmpasm_arg2str(ctx, argv[2], 0); else sep = strclone(scc_ofs(ctx)); if (*addr != '\0') { append(addr, sep); append(addr, val); } free(addr); free(val); free(sep); } static void instr_report(tmpasm_t *ctx, char *iname, int argc, tmpasm_arg_t *argv[]) { int n; (void) iname; /* not used */ for(n = 0; n < argc; n++) { char *val; val = tmpasm_arg2str(ctx, argv[n], 0); report("%s", val); free(val); } } static void instr_abort(tmpasm_t *ctx, char *iname, int argc, tmpasm_arg_t *argv[]) { scc_t *ud = (scc_t *)ctx->user_data; (void) iname; /* not used */ (void) argc; /* not used */ (void) argv; /* not used */ report("Abort requested by template.\n"); if (ud->fout) fflush(ud->fout); fflush(stdout); fflush(stderr); abort(); } static void instr_halt(tmpasm_t *ctx, char *iname, int argc, tmpasm_arg_t *argv[]) { (void) iname; /* not used */ (void) argc; /* not used */ (void) argv; /* not used */ ctx->halt = 1; } static void instr_sub(tmpasm_t *ctx, char *iname, int argc, tmpasm_arg_t *argv[]) { char *node, *pat, *err, *csub, *buff, *end; const char *start; const char *val; int score, slen, global; if (argc < 3) { tmpasm_runtime_error(ctx, -2, NULL); return; } node = tmpasm_arg2str(ctx, argv[0], 1); pat = tmpasm_arg2str(ctx, argv[1], 0); csub = tmpasm_arg2str(ctx, argv[2], 0); global = (*iname == 'g'); val = get(node); if (val == NULL) val=""; err = re_comp(pat); if (err != NULL) { tmpasm_runtime_error(ctx, -3, err); return; } slen = strlen(csub); if (global) buff = malloc(strlen(val)*(slen+3)+32); /* big enough for worst case, when every letter and $ and ^ are replaced with sub */ else buff = malloc(strlen(val)+slen+32); /* only one replacement will be done */ strcpy(buff, val); start = buff; do { score = re_exec(start); if (score == 0) break; end = buff + strlen(buff); if (eopat[0] - bopat[0] != slen) { int mlen = end - eopat[0]+1; if (mlen > 0) memmove((char *)(bopat[0] + slen), eopat[0], mlen); } memcpy((char *)bopat[0], csub, slen); start = bopat[0] + slen; } while(global); buff = realloc(buff, strlen(buff)+1); put(node, buff); free(buff); free(node); free(pat); free(csub); } #define UNIQ_ERE_MAX 16 static char *uniq_eres[UNIQ_ERE_MAX]; static void instr_uniq(tmpasm_t *ctx, char *iname, int argc, tmpasm_arg_t *argv[]) { char *node, *strlist, *buff; int eres = 0; if (argc < 1) { tmpasm_runtime_error(ctx, -4, NULL); return; } node = tmpasm_arg2str(ctx, argv[0], 1); if (argc > 1) { int offs = 2; strlist = tmpasm_arg2str(ctx, argv[1], 0); if ((argc-offs) >= UNIQ_ERE_MAX) { tmpasm_runtime_error(ctx, -11, NULL); return; } while(argc > offs) uniq_eres[eres++] = tmpasm_arg2str(ctx, argv[offs++], 0); if (eres > 0) uniq_eres[eres++] = ".*"; } else strlist = strclone(get(node)); buff = uniq_inc_str(strlist, scc_ifs(ctx), scc_ofs(ctx), (*iname == 's'), eres, uniq_eres); put(node, buff); free(buff); free(strlist); free(node); } static void instr_order(tmpasm_t *ctx, char *iname, int argc, tmpasm_arg_t *argv[]) { char *node, *strlist, *buff, *w1, *dirs, *w2; int offs, dir; if ((argc != 4) && (argc != 5)) { tmpasm_runtime_error(ctx, -10, NULL); return; } node = tmpasm_arg2str(ctx, argv[0], 1); if (argc > 4) { strlist = tmpasm_arg2str(ctx, argv[1], 0); offs = 2; } else { strlist = strclone(get(node)); offs = 1; } w1 = tmpasm_arg2str(ctx, argv[offs], 0); dirs = tmpasm_arg2str(ctx, argv[offs+1], 0); w2 = tmpasm_arg2str(ctx, argv[offs+2], 0); if (strcmp(dirs, "before") == 0) dir = -1; else if (strcmp(dirs, "after") == 0) dir = +1; else { tmpasm_runtime_error(ctx, -10, NULL); return; } buff = order_inc_str(strlist, scc_ifs(ctx), w1, dir, w2); put(node, buff); free(buff); free(strlist); free(node); } static void instr_print(tmpasm_t *ctx, char *iname, int argc, tmpasm_arg_t *argv[]) { int n; scc_t *ud = (scc_t *)ctx->user_data; (void) iname; /* not used */ for(n = 0; n < argc; n++) { char *val; val = tmpasm_arg2str(ctx, argv[n], 0); fprintf(ud->fout, "%s", val); free(val); } } static void instr_print_ternary(tmpasm_t *ctx, char *iname, int argc, tmpasm_arg_t *argv[]) { char *s_cond, *s; scc_t *ud = (scc_t *)ctx->user_data; (void) iname; /* not used */ if ((argc < 2) || (argc > 3)) { char str[16]; sprintf(str, "%d", argc); tmpasm_runtime_error(ctx, -1, str); return; } s_cond = tmpasm_arg2str(ctx, argv[0], 0); if (ctx->cb->is_true(ctx, s_cond)) s = tmpasm_arg2str(ctx, argv[1], 0); else s = tmpasm_arg2str(ctx, argv[2], 0); fprintf(ud->fout, "%s", s); free(s_cond); free(s); } static void scc_tmpasm_parse_(tmpasm_t *ctx, const char *cwd, FILE *fin, FILE *default_fout, FILE *fout) { scc_t *ud = malloc(sizeof(scc_t)); memset(&ud->ofl, 0, sizeof(ud->ofl)); ctx->user_data = ud; ud->default_fout = default_fout; ud->fout = fout; ud->cwd = cwd; for(;;) { int c; c = fgetc(fin); if (c == EOF) break; tmpasm_gotchar(ctx, c); } } void scc_tmpasm_parse(tmpasm_t *ctx, const char *cwd, FILE *fin, FILE *fout) { scc_tmpasm_parse_(ctx, cwd, fin, fout, fout); } #ifndef NO_FILE_IO static void instr_include(tmpasm_t *ctx, char *iname, int argc, tmpasm_arg_t *argv[]) { scc_t *ud = (scc_t *)ctx->user_data; int n; (void) iname; /* not used */ for(n = 0; n < argc; n++) { char *fn, *path; FILE *fin; tmpasm_t *child; fn = tmpasm_arg2str(ctx, argv[n], 0); path = scc_path(ud, fn); fin = fopen(path, "r"); if (fin == NULL) { tmpasm_runtime_error(ctx, -8, path); free(fn); free(path); return; } child = tmpasm_init(ctx->cb); scc_tmpasm_parse_(child, ud->cwd, fin, ud->default_fout, ud->fout); tmpasm_execute(child); if (print_runtime_error(child, path) != 0) tmpasm_runtime_error(ctx, -7, path); tmpasm_uninit(child); fclose(fin); free(fn); free(path); } } static void instr_redir(tmpasm_t *ctx, char *iname, int argc, tmpasm_arg_t *argv[]) { char *path, *fn, *mode; scc_t *ud = (scc_t *)ctx->user_data; (void) iname; /* not used */ fflush(ud->fout); switch(argc) { case 0: ud->fout = ud->default_fout; return; /* set redirection to default */ case 1: mode = strclone("w"); break; case 2: mode = tmpasm_arg2str(ctx, argv[1], 0); break; default: tmpasm_runtime_error(ctx, -5, NULL); return; } fn = tmpasm_arg2str(ctx, argv[0], 0); path = scc_path(ud, fn); ud->fout = openfile_open(&ud->ofl, path, mode); if (ud->fout == NULL) { char *err = malloc(strlen(fn) + strlen(path) + strlen(mode) + 16); sprintf(err, "%s (%s) for %s", path, fn, mode); tmpasm_runtime_error(ctx, -6, err); free(err); free(path); return; } free(fn); free(mode); free(path); } #endif #ifdef TMPASM_TESTER static void instr_unknown(tmpasm_t *ctx, char *iname, int argc, tmpasm_arg_t *argv[]) { printf("ERROR: unknown instruction '%s'\n", iname); } #endif /******** interface ********/ tmpasm_instr *scc_resolve(tmpasm_t *ctx, const char *name) { (void) ctx; /* not used */ /* TODO: make this a hash */ if (strcmp(name, "put") == 0) return instr_put; if (strcmp(name, "append") == 0) return instr_append; if (strcmp(name, "print") == 0) return instr_print; if (strcmp(name, "print_ternary") == 0) return instr_print_ternary; #ifndef TMPASM_NO_FILE_IO if (strcmp(name, "redir") == 0) return instr_redir; if (strcmp(name, "include") == 0) return instr_include; #endif if (strcmp(name, "report") == 0) return instr_report; if (strcmp(name, "abort") == 0) return instr_abort; if (strcmp(name, "halt") == 0) return instr_halt; if (strcmp(name, "uniq") == 0) return instr_uniq; if (strcmp(name, "order") == 0) return instr_order; if (strcmp(name, "sortuniq") == 0) return instr_uniq; if ((strcmp(name, "sub") == 0) || (strcmp(name, "gsub") == 0)) return instr_sub; #ifndef TMPASM_TESTER return NULL; #else return instr_unknown; #endif } static const char *scc_err_fmt(tmpasm_t *ctx) { int code; code = -ctx->runtime_error; if ((code < 0) || ((size_t)code > (sizeof(scc_runtime_error_fmts)/sizeof(char *)))) return NULL; return scc_runtime_error_fmts[code]; } static void scc_preexec(tmpasm_t *ctx) { (void) ctx; /* not used */ db_mkdir(TMPASM_PATH); } static void scc_postexec(tmpasm_t *ctx) { scc_t *ud = (scc_t *)ctx->user_data; openfile_free(&ud->ofl); free(ud); } tmpasm_cb_t scc_cb = { scc_get, scc_set, scc_is_true, scc_match, scc_first, scc_next, scc_resolve, scc_preexec, scc_postexec, scc_err_fmt }; int tmpasm(const char *wdir, const char *input, const char *output) { tmpasm_t *ctx; FILE *fin, *fout; int ret; scc_t ud_tmp; char *path; ud_tmp.cwd = wdir; path = scc_path(&ud_tmp, input); fin = fopen(path, "r"); if (fin == NULL) { fprintf(stderr, "ERROR: tmpasm: can not open script '%s' (%s in %s)\n", path, input, wdir); free(path); return -1; } free(path); path = scc_path(&ud_tmp, output); fout = fopen(path, "w"); if (fout == NULL) { fprintf(stderr, "ERROR: tmpasm: can not open output '%s' (%s in %s)\n", path, output, wdir); free(path); return -1; } free(path); ctx = tmpasm_init(&scc_cb); scc_tmpasm_parse_(ctx, wdir, fin, fout, fout); if (!ctx->dead) tmpasm_execute(ctx); fclose(fin); fclose(fout); ret = print_runtime_error(ctx, input); tmpasm_uninit(ctx); return ret; } FILE *tmpasm_fout(tmpasm_t *ctx) { scc_t *ud = (scc_t *)ctx->user_data; return ud->fout; } xschem-2.8.1/scconfig/src/tmpasm/Makefile0000644000175100017510000000071313366471752016553 0ustar svnsvnCFLAGS = -Wall -g \ -I../default -DTMPASM_TESTER \ tester: tester.o tmpasm.o debug.o tmpasm_scconfig.o openfiles.o \ ../default/db.o ../default/ht.o ../default/str.o ../default/log.o \ ../default/regex.o ../default/lib_uniqinc.o tmpasm.o: tmpasm.c tmpasm.h test: regression/Makefile cd regression && make regression/Makefile: regression/Makefile.in tester ./tester -e < regression/Makefile.in > regression/Makefile debug.o: debug.c debug.h tmpasm.h xschem-2.8.1/scconfig/src/tmpasm/debug.h0000644000175100017510000000005312215001565016326 0ustar svnsvnvoid tmpasm_dump(tmpasm_t *ctx, FILE *f); xschem-2.8.1/scconfig/src/tmpasm/openfiles.h0000644000175100017510000000066613366471752017257 0ustar svnsvn#include #include #include #include typedef struct openfile_s { FILE *f; /* identify the file: */ dev_t dev; ino_t ino; char *mode; } openfile_t; typedef struct openfiles_s { int alloced, used; openfile_t *files; } openfiles_t; FILE *openfile_open(openfiles_t *of, const char *fn, const char *mode); void openfile_closeall(openfiles_t *of); void openfile_free(openfiles_t *of); xschem-2.8.1/scconfig/src/tmpasm/Makefile.plugin0000644000175100017510000000131513366471752020047 0ustar svnsvnTMPASM_OBJS = \ $(BIN)/tmpasm/tmpasm.o \ $(BIN)/tmpasm/tmpasm_scconfig.o \ $(BIN)/tmpasm/openfiles.o TMPASM_CFLAGS = -I$(SRC)/tmpasm $(BIN)/tmpasm/tmpasm.o: $(SRC)/tmpasm/tmpasm.c $(SRC)/tmpasm/tmpasm.h $(SRC)/default/dep.h $(SRC)/default/log.h $(SRC)/default/regex.h $(CC) $(CFLAGS) -c $(SRC)/tmpasm/tmpasm.c -o $(BIN)/tmpasm/tmpasm.o $(BIN)/tmpasm/tmpasm_scconfig.o: $(SRC)/tmpasm/tmpasm_scconfig.c $(SRC)/tmpasm/tmpasm.h $(SRC)/default/libs.h $(SRC)/default/log.h $(SRC)/default/regex.h $(CC) $(CFLAGS) -c $(SRC)/tmpasm/tmpasm_scconfig.c -o $(BIN)/tmpasm/tmpasm_scconfig.o $(BIN)/tmpasm/openfiles.o: $(SRC)/tmpasm/openfiles.c $(CC) $(CFLAGS) -c $(SRC)/tmpasm/openfiles.c -o $(BIN)/tmpasm/openfiles.o xschem-2.8.1/scconfig/src/tmpasm/tmpasm.h0000644000175100017510000001317313342530154016553 0ustar svnsvn#ifndef TMPASM_H #define TMPASM_H #ifndef TMPASM_INSTR_MAXLEN #define TMPASM_INSTR_MAXLEN 32 #endif typedef struct tmpasm_s tmpasm_t; typedef struct tmpasm_arg_s tmpasm_arg_t; struct tmpasm_arg_s { tmpasm_arg_t *next; /* block: the resulting string is a list of strings and addresses */ char is_addr; /* 1: arg is a node address; 0: arg is a string immediate */ char data[1]; /* arg string - obviously longer than 1 char (but there's not special hack for that in C89), \0 terminated */ }; /* user specified instruction prototype */ typedef void tmpasm_instr(tmpasm_t *ctx, char *iname, int argc, tmpasm_arg_t *argv[]); typedef struct tmpasm_cb_s { /* return the value of a node at addr - NULL is an error */ const char *(*get)(tmpasm_t *ctx, const char *addr); /* set the value of a node at addr to data; data may be NULL */ void (*set)(tmpasm_t *ctx, const char *addr, const char *data); /* return 1 if data is true, 0 otherwise; data may be NULL (if an unknown variable is referenced) */ int (*is_true)(tmpasm_t *ctx, const char *data); /* return 1 if str matches pat, 0 otherwise; str and pat may be NULL */ int (*match)(tmpasm_t *ctx, const char *str, const char *pat); /* first iteration over list; return the first element (or NULL to end); the string returned is not free'd by the caller */ const char *(*first)(tmpasm_t *ctx, void **state, char *list); /* return next element of a list or NULL on end (in which case state shall be also free'd by the caller); the string returned is not free'd by the caller */ const char *(*next)(tmpasm_t *ctx, void **state); /* resolve an instruction name to a function pointer */ tmpasm_instr *(*resolve)(tmpasm_t *ctx, const char *name); /* optional: called once before execution of a context starts */ void (*preexec)(tmpasm_t *ctx); /* optional: called once before execution of a context starts */ void (*postexec)(tmpasm_t *ctx); /* optional: resolve the current runtime error, called only for negative error codes; should return a format string with exactly one %s in it or NULL. */ const char *(*runtime_error_fmt)(tmpasm_t *ctx); } tmpasm_cb_t; int tmpasm_gotchar(tmpasm_t *ctx, char c); tmpasm_t *tmpasm_init(const tmpasm_cb_t *cb); void tmpasm_uninit(tmpasm_t *ctx); /* return the string version of an arg in a newly malloc()'d string if keep_addr is non-zero and a is a single address, no get() is run but the address is returned as a string */ char *tmpasm_arg2str(tmpasm_t *ctx, tmpasm_arg_t *a, int keep_addr); /* execute the code recursively until it exits */ void tmpasm_execute(tmpasm_t *ctx); /* Set or get the runtime error of a context. 0 means no error, negative codes are user errors handled by the runtime_error_fmt() callback and positive codes are internal error. */ void tmpasm_runtime_error(tmpasm_t *ctx, int code, const char *data); const char *tmpasm_runtime_error_fmt(tmpasm_t *ctx); /* --- internals: not required for normal use --- */ typedef enum { ST_PRECMD, /* waiting for a command to start - ignore whitespace */ ST_CMD, ST_PREDATA, /* waiting for data */ ST_PREBLOCKSEP, /* waiting for a block sep when opening a block */ ST_BLOCKSEP, /* found a block sep within the block - either an address or a termination follows */ ST_BLOCK, /* in [@ @] block, text part */ ST_BLOCK_INLINE, /* in [@ @] block, within inline @@ part */ ST_STRING, /* in {} string */ ST_STRING_ESCAPE, /* in {} string, right after a \ */ ST_ADDRESS, /* shifting address bytes */ ST_COMMENT /* after #, until the next newline */ } tmpasm_state_t; typedef enum { KW_none, KW_IF, KW_THEN, KW_ELSE, KW_END, KW_FOREACH, KW_IN, KW_SWITCH, KW_CASE, KW_DEFAULT, KW_NOP /* virtual instruction */ } tmpasm_kw_t; /* execution structs */ typedef struct tmpasm_exec_s tmpasm_exec_t; typedef struct tmpasm_case_s tmpasm_case_t; struct tmpasm_case_s { tmpasm_arg_t *data; tmpasm_exec_t *body; tmpasm_case_t *next; }; struct tmpasm_exec_s { tmpasm_kw_t kw; /* kw_none means a hook instruction */ union { struct { /* normal instruction */ tmpasm_instr *call; char *call_name; /* temporary */ int argc; tmpasm_arg_t **argv; } instr; struct { tmpasm_arg_t *cond; tmpasm_exec_t *code_then; tmpasm_exec_t *code_else; } fc_if; struct { char *loop_var; /* must be a single address */ tmpasm_arg_t *data; /* what to loop in */ tmpasm_exec_t *code_body; } fc_foreach; struct { tmpasm_arg_t *cond; tmpasm_case_t *first; tmpasm_case_t *last; } fc_switch; } payload; int line, col; tmpasm_exec_t *next; }; /* parser structs */ typedef struct stack_s tmpasm_stack_t; struct stack_s { tmpasm_state_t state; /* tmpasm_state_t kwstate; internal states of composite keywords like switch */ char cmd_buff[TMPASM_INSTR_MAXLEN+1]; unsigned int cmdi; tmpasm_kw_t kw, old_kw; char block_sep; int kwcol, kwline; int args_used, args_alloced; /* number of arguments in argv[] */ tmpasm_arg_t **argv; /* an array of linked lists */ tmpasm_arg_t **argend; /* each argv[] is a linked list (for blocks); argend points to the tail */ int *arg_alloced; /* of argend */ int *arg_used; /* of argend */ tmpasm_exec_t *last_code; /* tail of the code list */ tmpasm_stack_t *next; }; struct tmpasm_s { tmpasm_stack_t *st; int dead; int col, line; tmpasm_exec_t *code; tmpasm_exec_t *executing; /* points to the code most recently executed (or being executed when in callbacks) */ const tmpasm_cb_t *cb; int halt; int runtime_error; char *runtime_error_data; int runtime_error_line; int runtime_error_col; void *user_data; }; #endif xschem-2.8.1/scconfig/src/tmpasm/tester.c0000644000175100017510000000224412220223061016536 0ustar svnsvn#include #include #include "tmpasm.h" #include "tmpasm_scconfig.h" #include "debug.h" #include "db.h" tmpasm_t *ctx; void re_fail(char *s, char c) { fprintf(stderr, "Regex error: %s [opcode %o]\n", s, c); abort(); } static void do_dump() { tmpasm_dump(ctx, stdout); } static void do_exec() { if (ctx->dead) fprintf(stderr, "Can not execute the script due to the above compilation error.\n"); else tmpasm_execute(ctx); } static void scc_init(void) { db_init(); db_mkdir("/local"); db_cd("/local"); } int main(int argc, char *argv[]) { scc_init(); ctx = tmpasm_init(&scc_cb); scc_tmpasm_parse(ctx, NULL, stdin, stdout); if (argc > 1) { char *cmd; cmd = argv[1]; while(*cmd == '-') cmd++; switch(*cmd) { case 'd': do_dump(); break; case 'e': do_exec(); break; } } else do_dump(); if (ctx->runtime_error != 0) { const char *fmt = tmpasm_runtime_error_fmt(ctx); fprintf(stderr, "Runtime error at %d:%d: ", ctx->runtime_error_line, ctx->runtime_error_col); fprintf(stderr, fmt, (ctx->runtime_error_data == NULL ? "" : ctx->runtime_error_data)); fprintf(stderr, "\n"); } tmpasm_uninit(ctx); db_uninit(); return 0; } xschem-2.8.1/scconfig/src/tmpasm/debug.c0000644000175100017510000000456412217255460016343 0ustar svnsvn#include #include "tmpasm.h" static void indent(FILE *f, int depth) { for(;depth > 0; depth--) fputc(' ', f); } static void print_arg(FILE *f, tmpasm_arg_t *a) { if (a == NULL) { fprintf(f, "*NULL - broken AST*"); return; } if (a->next != NULL) { /* block mode */ fprintf(f, "[~"); for(;a != NULL; a = a->next) { if (a->is_addr) fprintf(f, "~%s~", a->data); else fprintf(f, "%s", a->data); } fprintf(f, "~]"); } else { if (a->is_addr) fprintf(f, "%s", a->data); else fprintf(f, "{%s}", a->data); } } static void print_loc(FILE *f, tmpasm_exec_t *c) { if ((c->line != 0) || (c->col != 0)) fprintf(f, " [at %d:%d]\n", c->line, c->col); else fprintf(f, "\n"); } static void dump(FILE *f, int depth, tmpasm_exec_t *c) { tmpasm_case_t *cc; int n; for(; c != NULL; c = c->next) { switch(c->kw) { case KW_NOP: indent(f, depth); fprintf(f, "(NOP)"); print_loc(f, c); break; case KW_none: indent(f, depth); fprintf(f, "%s", c->payload.instr.call_name); print_loc(f, c); for(n = 0; n < c->payload.instr.argc; n++) { indent(f, depth+1); fprintf(f, "arg: "); print_arg(f, c->payload.instr.argv[n]); fprintf(f, "\n"); } break; case KW_IF: indent(f, depth); fprintf(f, "if "); print_arg(f, c->payload.fc_if.cond); print_loc(f, c); indent(f, depth); fprintf(f, "then:\n"); dump(f, depth+1, c->payload.fc_if.code_then); indent(f, depth); fprintf(f, "else:\n"); dump(f, depth+1, c->payload.fc_if.code_else); break; case KW_FOREACH: indent(f, depth); fprintf(f, "foreach %s in ", c->payload.fc_foreach.loop_var); print_arg(f, c->payload.fc_foreach.data); print_loc(f, c); dump(f, depth+1, c->payload.fc_foreach.code_body); break; case KW_SWITCH: indent(f, depth); fprintf(f, "switch "); print_arg(f, c->payload.fc_switch.cond); print_loc(f, c); for(cc = c->payload.fc_switch.first; cc != NULL; cc = cc->next) { indent(f, depth+1); if (cc->data != NULL) { fprintf(f, "case "); print_arg(f, cc->data); fprintf(f, "\n"); } else printf("default\n"); dump(f, depth+2, cc->body); } break; default: indent(f, depth); fprintf(f, "invalid kw "); print_loc(f, c); } } } void tmpasm_dump(tmpasm_t *ctx, FILE *f) { dump(f, 0, ctx->code); } xschem-2.8.1/scconfig/src/tmpasm/openfiles.c0000644000175100017510000000374013366471752017246 0ustar svnsvn#include #include #include "openfiles.h" #include "libs.h" static openfile_t *find_file_by_name(openfiles_t *of, const char *name, int alloc, const char *mode, int recursion) { int n; struct stat buf; FILE *f; if (recursion > 4) { fprintf(stderr, "scconfig internal error: openfiles infinite recursion for %s\n", name); abort(); } if (stat(name, &buf) != 0) { /* File does not exist - try to create it or return NULL */ if (*mode == 'w') { f = fopen(name, "w"); if (f == NULL) return NULL; fclose(f); return find_file_by_name(of, name, alloc, mode, recursion + 1); } return NULL; } /* look for an existing open file in the list */ for(n = 0; n < of->used; n++) if ((of->files[n].dev == buf.st_dev) && (of->files[n].ino == buf.st_ino) && (strcmp(of->files[n].mode, mode) == 0)) return &(of->files[n]); if (!alloc) return NULL; /* File exists but not on the list yet, allocate a new slot for it */ /* TODO: try to find an empty slot first */ if (of->used >= of->alloced) { of->alloced += 16; of->files = realloc(of->files, sizeof(openfile_t) * of->alloced); } n = of->used; of->files[n].dev = buf.st_dev; of->files[n].ino = buf.st_ino; of->files[n].f = NULL; of->files[n].mode = strclone(mode); of->used++; return &(of->files[n]); } void release(openfile_t *o) { if (o->mode != NULL) { free(o->mode); o->mode = NULL; } if (o->f != NULL) { fclose(o->f); o->f = NULL; } o->dev = -1; o->ino = -1; } FILE *openfile_open(openfiles_t *of, const char *fn, const char *mode) { openfile_t *o; o = find_file_by_name(of, fn, 1, mode, 0); if (o == NULL) return NULL; o->f = fopen(fn, mode); if (o->f == NULL) { release(o); return NULL; } return o->f; } void openfile_closeall(openfiles_t *of) { int n; if (of->files == NULL) return; for(n = 0; n < of->used; n++) release(&(of->files[n])); } void openfile_free(openfiles_t *of) { openfile_closeall(of); if (of->files != NULL) free(of->files); } xschem-2.8.1/scconfig/src/tmpasm/TODO0000644000175100017510000000053512220203631015556 0ustar svnsvn- regression test syntax errors and improve syntax error reporting - switch: - data instead of case - multiple defaults - deafult must be at end of the list - case out of switch - default out of switch - forarch - tutorial - append - [[]] eval? what's the output? -> generate and include scripts (may need mktemp binding) - update docs xschem-2.8.1/scconfig/src/default/0000755000175100017510000000000013400743706015223 5ustar svnsvnxschem-2.8.1/scconfig/src/default/arg.c0000644000175100017510000000735613323012037016141 0ustar svnsvn/* scconfig - command line argument processing Copyright (C) 2009..2012 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include "db.h" #include "arg.h" #include "dep.h" #include "log.h" #include "libs.h" argtbl_t main_argument_table[] = { {"import", NULL, import_args, "Import saved config (sub)tree"}, {"target", "/arg/sys/target", NULL, "set cross compilation target (prefix)"}, {"target-name", "/arg/sys/target-name", NULL, "set cross compilation target (system name)"}, {"target-shell","/arg/sys/target-shell",NULL, "set the shell on cross compilation target"}, {"emu", "/arg/sys/emu", NULL, "emulator for testing cross compiled executables with"}, {"pkg-config", "/arg/sys/pkg-config", NULL, "path to pkg-config to use"}, {"pkg-config-zap","/arg/sys/pkg-config-zap",NULL, "ignore pkg-config results by this regex pattern"}, /* wildcard rules for icl() control */ {"^ldflags/", NULL, import_icl, NULL}, {"^cflags/", NULL, import_icl, NULL}, {"^includes/", NULL, import_icl, NULL}, {"^prefix/", NULL, import_icl, NULL}, /* the followings are autoconf compatibility translations */ {"CC", "/arg/cc/cc", NULL, "Force using a C compiler (command line)"}, {"CFLAGS", "/arg/cc/cflags", NULL, "Force using a CFLAGS for C compilation"}, {"LDFLAGS", "/arg/cc/ldflags", NULL, "Force using a LDFLAGS for linking"}, {"LDL", "/arg/libs/ldl", NULL, "Force using -ldl string"}, {"gpmi-prefix", "/arg/gpmi/prefix", NULL, NULL}, {NULL, NULL, NULL, NULL} }; void process_args(int argc, char *argv[]) { int n; char *key, *value; argtbl_t *a; int found, tainted = 0; db_mkdir("/arg"); logprintf(0, "CLI arg 0: '%s'\n", argv[0]); for(n = 1; n < argc; n++) { key = argv[n]; logprintf(0, "CLI arg %d: '%s'\n", n, key); while(*key == '-') key++; value = str_chr(key, '='); found = 0; if (value != NULL) { *value = '\0'; value++; /* Look in the argument translate table */ for(a = main_argument_table; a->arg != NULL; a++) { if (((a->arg[0] == '^') && (strncmp(a->arg+1, key, strlen(a->arg+1)) == 0)) || (strcmp(a->arg, key) == 0)) { found = 1; if (a->callback != NULL) { if (a->callback(key, value) != 0) { error("Processing argument '%s' failed in the callback\n", argv[n]); abort(); } } if (a->path != NULL) put(a->path, value); } } /* Look in known deps table or /arg */ if (found == 0) { if ((is_dep_known(key)) || (strncmp(key, "/arg/", 5) == 0)) { put(key, value); found = 1; } } } if (found == 0) { if (custom_arg(key, value) == 0) { error("Unknown argument '%s'\n", key); tainted++; } } } if (tainted) exit(1); } xschem-2.8.1/scconfig/src/default/find_str.c0000644000175100017510000000440613240634424017201 0ustar svnsvn/* scconfig - detection of standard library features: strings Copyright (C) 2017 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include #include "libs.h" #include "log.h" #include "db.h" #include "dep.h" int find_strcasecmp(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "#include " NL "int main() {" NL " if ((strcasecmp(\"foo\", \"FoO\") == 0) && (strcasecmp(\"foo\", \"bar\") != 0))" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for strcasecmp()... "); logprintf(logdepth, "find_fs_strcasecmp: trying to find strcasecmp...\n"); logdepth++; if (try_icl(logdepth, "str/strcasecmp", test_c, NULL, NULL, NULL)) return 0; return try_fail(logdepth, "str/strcasecmp"); } int find_strncasecmp(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "#include " NL "int main() {" NL " if ((strncasecmp(\"foo1\", \"FoO2\", 3) == 0) && (strncasecmp(\"foo1\", \"bar2\", 3) != 0))" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for strncasecmp()... "); logprintf(logdepth, "find_fs_strncasecmp: trying to find strncasecmp...\n"); logdepth++; if (try_icl(logdepth, "str/strncasecmp", test_c, NULL, NULL, NULL)) return 0; return try_fail(logdepth, "str/strncasecmp"); } xschem-2.8.1/scconfig/src/default/find_thread.c0000644000175100017510000001321013246537450017640 0ustar svnsvn/* scconfig - detection of standard library features Copyright (C) 2009,2017 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include "libs.h" #include "log.h" #include "db.h" #include "dep.h" int find_lib_lpthread(const char *name, int logdepth, int fatal) { const char *lpthread; char *s; int ret = 0; char *test_c_recursive = NL "#define _GNU_SOURCE 1 /* Needed for recursive thread-locking */" NL "#include " NL "pthread_mutex_t mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;" NL "int main() {" NL " pthread_attr_t a;" NL " if (pthread_attr_init(&a) == 0)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL ; char *test_c_simple = NL "#include " NL "int main() {" NL " pthread_attr_t a;" NL " if (pthread_attr_init(&a) == 0)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL ; require("cc/cc", logdepth, fatal); report("Checking for -lpthread... "); logprintf(logdepth, "find_lib_lpthread: trying to find lpthread...\n"); logdepth++; lpthread = get("/arg/libs/lpthread"); if (lpthread != NULL) { put("libs/lpthread", lpthread); report("User provided... "); s = strclone(lpthread); } else s = strclone("-lpthread"); if (try_icl(logdepth, NULL, test_c_recursive, NULL, NULL, s)) { put("libs/lpthread", s); put("libs/lpthread-recursive", strue); report("OK, recursive (%s)\n", s); } else if (try_icl(logdepth, NULL, test_c_simple, NULL, NULL, s)) { put("libs/lpthread", s); put("libs/lpthread-recursive", sfalse); report("OK, NOT RECURSIVE (%s)\n", s); } else ret = 1; free(s); return ret; } int find_thread_semget(const char *name, int logdepth, int fatal) { const char *test_c = NL "#include " NL "int main()" NL "{" NL " int semid = semget(IPC_PRIVATE, 1, IPC_CREAT);" NL " if (semid < 0) return 0;" NL " if(semctl(semid, 0, IPC_RMID) < 0) return 0;" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; const char *node = "thread/semget"; char **inc, *incs[] = {"#include \n#include \n#include ", "#include \n#include ", "#include \n#include ", NULL}; if (require("cc/cc", logdepth, fatal)) return try_fail(logdepth, node); report("Checking for semget... "); logprintf(logdepth, "find_semget:\n"); logdepth++; for(inc = incs; *inc != NULL; inc++) if (try_icl(logdepth, node, test_c, *inc, NULL, NULL) != 0) return 0; return try_fail(logdepth, node); } int find_thread_pthread_create(const char *name, int logdepth, int fatal) { const char *test_c = NL "#include " NL "void* test_thread(void* param)" NL "{" NL " return NULL;" NL "}" NL "int main()" NL "{" NL " pthread_t pt;" NL " if (pthread_create(&pt, NULL, test_thread, NULL) == 0)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; const char *node = "thread/pthread_create"; char **inc, *incs[] = {"#include ", "#include \n#include ", NULL}; const char *lpthread; char* s; if (require("cc/cc", logdepth, fatal)) return try_fail(logdepth, node); report("Checking for pthread_create... "); logprintf(logdepth, "find_pthread_create:\n"); logdepth++; lpthread = get("/arg/libs/lpthread"); if (lpthread != NULL) { report("User provided... "); s = strclone(lpthread); } else s = strclone("-lpthread"); for(inc = incs; *inc != NULL; inc++) if (try_icl(logdepth, node, test_c, *inc, NULL, s) != 0) { free(s); return 0; } free(s); return try_fail(logdepth, node); } int find_thread_CreateSemaphore(const char *name, int logdepth, int fatal) { const char *test_c = NL "#include " NL "int main()" NL "{" NL " if (CreateSemaphore(NULL, 1, 1, NULL))" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; const char *node = "thread/CreateSemaphore"; if (require("cc/cc", logdepth, fatal)) return try_fail(logdepth, node); report("Checking for CreateSemaphore... "); logprintf(logdepth, "find_thread_CreateSemaphore:\n"); logdepth++; if (try_icl(logdepth, node, test_c, "#include ", NULL, NULL) != 0) return 0; return try_fail(logdepth, node); } int find_thread_CreateThread(const char *name, int logdepth, int fatal) { const char *test_c = NL "#include " NL "DWORD WINAPI test_thread(void* param)" NL "{" NL " return 0;" NL "}" NL "int main()" NL "{" NL " if (CreateThread(NULL, 0, test_thread, NULL, 0, NULL))" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; const char *node = "thread/CreateThread"; if (require("cc/cc", logdepth, fatal)) return try_fail(logdepth, node); report("Checking for CreateThread... "); logprintf(logdepth, "find_thread_CreateThread:\n"); logdepth++; if (try_icl(logdepth, node, test_c, "#include ", NULL, NULL) != 0) return 0; return try_fail(logdepth, node); } xschem-2.8.1/scconfig/src/default/lib_file.c0000644000175100017510000001133213234567512017140 0ustar svnsvn/* scconfig - library to query files and directories Copyright (C) 2009..2012 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include #include #include "db.h" #include "libs.h" #include "log.h" #include "dep.h" int file_size(const char *name) { struct stat buf; if (stat(name, &buf) != 0) return -1; return buf.st_size; } char *tempdir_new(int logdepth, const char *suffix) { char s[1024]; char *cmd; const char *tmp; const char *mkdir, *emu; unsigned int rn, n; require("sys/tmp", logdepth+1, 1); tmp = get("sys/tmp"); if (strlen(suffix) > sizeof(s) - strlen(tmp) - 32) { fprintf(stderr, "Not enough room for creating temporary file name\n"); abort(); } require("fstools/mkdir", logdepth+1, 1); mkdir = get("fstools/mkdir"); emu = get("sys/emu"); if (emu == NULL) emu = ""; for(n = 0; n < 128; n++) { rn = rand() % 100000; sprintf(s, "%sscc_%u%s", tmp, rn, suffix); if (!exists(s)) { char *s_esc = shell_escape_dup(s); cmd = malloc(strlen(s_esc) + strlen(mkdir) + 16); sprintf(cmd, "%s %s", mkdir, s_esc); run_shell(logdepth+1, cmd, NULL); free(s_esc); free(cmd); if (is_dir(s)) return strclone(s); } } error("Couldn't find a suitable temp dir name\n"); abort(); } char *tempfile_new_noabort(const char *suffix) { char s[1024]; const char *tmp; unsigned int rn, n; FILE *f; require("/host/sys/tmp", 0, 1); tmp = get("/host/sys/tmp"); if (strlen(suffix) > sizeof(s) - strlen(tmp) - 32) { fprintf(stderr, "tempfile_new_noabort(): not enough room for creating temporary file name\n"); abort(); } for(n = 0; n < 128; n++) { rn = rand() % 100000; sprintf(s, "%sscc_%u%s", tmp, rn, suffix); if (!is_file(s)) { /* can not test for exists() because that would recurse is_dir */ f = fopen(s, "w"); if (f != NULL) { fclose(f); return strclone(s); } } } return NULL; } char *tempfile_new(const char *suffix) { char *tmp; tmp = tempfile_new_noabort(suffix); if (tmp == NULL) { error("Couldn't find a suitable temp file name\n"); abort(); } return tmp; } char *tempfile_dump(const char *testcode, const char *suffix) { char *fn; FILE *f; fn = tempfile_new(suffix); f = fopen(fn, "w"); fprintf(f, "%s", testcode); fclose(f); return fn; } char *load_file(const char *name) { int size; char *content; FILE *f; size = file_size(name); if (size > 0) { content = malloc(size+1); *content = '\0'; f = fopen(name, "r"); if (f != NULL) { int len = fread(content, 1, size, f); if (len < 0) len = 0; content[len] = '\0'; fclose(f); } } else { content = malloc(1); *content = '\0'; } return content; } int is_dir(const char *path) { char *tmp, *path_esc; int ret; require("sys/shell", 0, 1); path_esc = shell_escape_dup(path); tmp = malloc(strlen(path_esc) + 16); sprintf(tmp, "cd %s", path_esc); ret = run_shell(0, tmp, NULL); free(tmp); free(path_esc); return !ret; } int is_file(const char *path) { return file_size(path) >= 0; } int exists(const char *path) { return is_file(path) || is_dir(path); } int exists_in(const char *dir, const char *file) { char *path; int ret; path = malloc(strlen(dir) + strlen(file) + 5); sprintf(path, "%s/%s", dir, file); ret = is_file(path) || is_dir(path); free(path); return ret; } const char *file_name_ptr(const char *path) { const char *s; s = str_rchr((char *)path, '/'); if (s == NULL) s = str_rchr((char *)path, '\\'); return s; } char *file_name(const char *path) { const char *s; s = file_name_ptr(path); if (s == NULL) return strclone(path); s++; return strclone(s); } char *dir_name(const char *path) { char *s, *r; s = strclone(path); r = (char *)file_name_ptr(s); if (r == NULL) { free(s); return strclone(""); } *r = '\0'; return s; } int touch_file(const char *path) { FILE *f; f = fopen(path, "a"); if (f == NULL) return -1; fclose(f); return 0; } xschem-2.8.1/scconfig/src/default/lib_try.c0000644000175100017510000002632513370510646017044 0ustar svnsvn#include #include #include #include "libs.h" #include "log.h" #include "db.h" #include "dep.h" /* Returns true if the first 2 characters of the output is OK */ static int try_icl_accept_ok(char *stdout_str) { return (strncmp(stdout_str, "OK", 2) == 0); } #define is_ctrl_prefix(ch) (((ch) == '!') || ((ch) == '^')) static int try_icl__(int logdepth, const char *prefix, const char *test_c_in, const char *includes, const char *cflags, const char *ldflags, const char *db_includes, const char *db_cflags, const char *db_ldflags, int run, int (*accept_res)(char *stdout_str)) { char *out = NULL; char *tmp, *inc; const char *test_c; char c[1024]; int l, compres; if (includes != NULL) { l = strlen(includes); memcpy(c, includes, l); c[l] = '\n'; l++; strcpy(c+l, test_c_in); test_c = c; } else test_c = test_c_in; logprintf(logdepth, "trying '%s' and '%s' and '%s', %s\n", str_null(db_includes), str_null(db_cflags), str_null(db_ldflags), run ? "with a run" : "with no run"); if (run) compres = compile_run(logdepth+1, test_c, NULL, cflags, ldflags, &out); else { char *fn_output = NULL; compres = compile_code(logdepth+1, test_c, &fn_output, NULL, cflags, ldflags); if (fn_output != NULL) { unlink(fn_output); free(fn_output); } } if (compres == 0) { if (!run || target_emu_fail(out) || accept_res(out)) { free(out); /* no prefix: don't modify the database, the caller will do that */ if (prefix == NULL) return 1; tmp = malloc(strlen(prefix) + 32); if ((db_includes == NULL) || (*db_includes == '\0')) inc = strclone(""); else inc = uniq_inc_str(db_includes, NULL, "\\n", 0, 0, NULL); sprintf(tmp, "%s/includes", prefix); put(tmp, inc); if (db_cflags == NULL) db_cflags = ""; sprintf(tmp, "%s/cflags", prefix); put(tmp, db_cflags); if (db_ldflags == NULL) db_ldflags = ""; sprintf(tmp, "%s/ldflags", prefix); put(tmp, db_ldflags); if (inc != NULL) { report("OK ('%s', '%s' and '%s')\n", str_null(inc), str_null(db_cflags), str_null(db_ldflags)); free(inc); } else report("OK ('%s' and '%s')\n", str_null(db_cflags), str_null(db_ldflags)); sprintf(tmp, "%s/presents", prefix); put(tmp, strue); free(tmp); return 1; } free(out); } return 0; } #define LOAD(node) \ do { \ if (u ## node != NULL) break; \ strcpy(apath_end, #node); \ u ## node = get(apath); \ } while(0) #define SET(dst, src, is_flag) \ do { \ char *__sep__ = is_flag ? " " : "\n"; \ const char *__dst__ = dst == NULL ? "" : dst; \ char *__out__; \ if (is_ctrl_prefix(*__dst__)) __dst__++; \ if (*src == '!') \ __out__ = strclone(src+1); \ else if (*src == '^') {\ if (src[1] != '\0') \ __out__ = str_concat("", src+1, __sep__, __dst__, NULL); \ else \ __out__ = strclone(__dst__); \ } \ else { \ if (*__dst__ != '\0') \ __out__ = str_concat("", __dst__, __sep__, src, NULL); \ else \ __out__ = strclone(src); \ } \ free(dst); \ dst = __out__; \ if (is_flag) { \ char *__s__; \ for(__s__ = dst; *__s__ != '\0'; __s__++) \ if ((*__s__ == '\n') || (*__s__ == '\r')) \ *__s__ = ' '; \ } \ } while(0) /* Figure user overrides and call try_icl__() accordingly */ int try_icl_(int logdepth, const char *prefix, const char *test_c_in, const char *includes, const char *cflags, const char *ldflags, int run, int (*accept_res)(char *stdout_str)) { char apath[1024], *apath_end; int l, res; const char *uincludes = NULL, *ucflags = NULL, *uldflags = NULL, *uprefix = NULL; /* user specified */ char *rincludes, *rcflags, *rldflags; /* real */ char *dbincludes = NULL, *dbcflags = NULL, *dbldflags = NULL; /* what to add in the db at the end */ /* load uincludes, uclfags, uldflags and uprefix - LOAD() inserts the u */ l = sprintf(apath, "/arg/icl/%s/", prefix); apath_end = apath+l; LOAD(includes); LOAD(cflags); LOAD(ldflags); LOAD(prefix); l = sprintf(apath, "/arg/icl/%s/%s/", db_cwd, prefix); apath_end = apath+l; LOAD(includes); LOAD(cflags); LOAD(ldflags); LOAD(prefix); /* special case: all three specified by the user - ignore what the detector wanted, but run only once per node prefix */ if ((uincludes != NULL) && (ucflags != NULL) && (uldflags != NULL)) { const char *am; sprintf(apath, "%s/icl/all_manual_result", prefix); am = get(apath); if (am != NULL) return istrue(am); /* return cached result if available */ res = try_icl__(logdepth, prefix, test_c_in, uincludes, ucflags, uldflags, uincludes, ucflags, uldflags, run, accept_res); put(apath, res ? strue : sfalse); return res; } /* TODO: get default cflags here */ rincludes = NULL; rcflags = strclone(get("cc/cflags")); rldflags = strclone(get("cc/ldflags")); /* override base/default values with detection requested ones */ if (includes != NULL) SET(rincludes, includes, 0); if (cflags != NULL) SET(rcflags, cflags, 1); if (ldflags != NULL) SET(rldflags, ldflags, 1); if (includes != NULL) SET(dbincludes, includes, 0); if (cflags != NULL) SET(dbcflags, cflags, 1); if (ldflags != NULL) SET(dbldflags, ldflags, 1); /* override detection with user specified ICL values */ if (uincludes != NULL) SET(rincludes, uincludes, 0); if (ucflags != NULL) SET(rcflags, ucflags, 1); if (uldflags != NULL) SET(rldflags, uldflags, 1); if (uincludes != NULL) SET(dbincludes, uincludes, 0); if (ucflags != NULL) SET(dbcflags, ucflags, 1); if (uldflags != NULL) SET(dbldflags, uldflags, 1); /* insert prefix as needed */ if (uprefix != NULL) { char *old, *prfx; old = rcflags; if ((rcflags != NULL) && (*rcflags == '^')) { rcflags++; prfx = "^"; } else prfx = ""; rcflags = str_concat("", prfx, "-I", uprefix, "/include ", rcflags, NULL); if (old != cflags) free(old); old = rldflags; if ((rldflags != NULL) && (*rldflags == '^')) { rldflags++; prfx = "^"; } else prfx = ""; rldflags = str_concat("", prfx, "-L", uprefix, "/lib ", rldflags, NULL); if (old != ldflags) free(old); } res = try_icl__(logdepth, prefix, test_c_in, rincludes, rcflags, rldflags, dbincludes, dbcflags, dbldflags, run, accept_res); /* if we had to alloc, free here */ free(rincludes); free(rcflags); free(rldflags); free(dbincludes); free(dbcflags); free(dbldflags); return res; } #undef LOAD #undef SET int try_icl(int logdepth, const char *prefix, const char *test_c_in, const char *includes, const char *cflags, const char *ldflags) { return try_icl_(logdepth, prefix, test_c_in, includes, cflags, ldflags, 1, try_icl_accept_ok); } int try_icl_with_deps(int logdepth, const char *prefix, const char *test_c_in, const char *includes, const char *cflags, const char *ldflags, const char *dep_includes, const char *dep_cflags, const char *dep_ldflags, int run) { int res; if ((dep_includes != NULL) && (*dep_includes == '\0')) dep_includes = NULL; if ((dep_cflags != NULL) && (*dep_cflags == '\0')) dep_cflags = NULL; if ((dep_ldflags != NULL) && (*dep_ldflags == '\0')) dep_ldflags = NULL; if (dep_includes != NULL) includes = str_concat(" ", dep_includes, includes, NULL); if (dep_cflags != NULL) cflags = str_concat(" ", dep_cflags, cflags, NULL); if (dep_ldflags != NULL) ldflags = str_concat(" ", dep_ldflags, ldflags, NULL); res = try_icl_(logdepth, prefix, test_c_in, includes, cflags, ldflags, run, try_icl_accept_ok); if (dep_includes != NULL) free((char *)includes); if (dep_cflags != NULL) free((char *)cflags); if (dep_ldflags != NULL) free((char *)ldflags); return res; } int try_icl_norun(int logdepth, const char *prefix, const char *test_c_in, const char *includes, const char *cflags, const char *ldflags) { return try_icl_(logdepth, prefix, test_c_in, includes, cflags, ldflags, 0, try_icl_accept_ok); } int try_fail(int logdepth, const char *prefix) { char *tmp; tmp = malloc(strlen(prefix) + 32); sprintf(tmp, "%s/presents", prefix); put(tmp, sfalse); free(tmp); report("not found\n"); logprintf(logdepth, "NOT FOUND."); return 1; } static int try_pkg_config_(int logdepth, char *pkgname, const char *prefix, const char *test_c) { char *cflags, *ldflags; int res; logprintf(logdepth, "Trying pkg-config %s\n", pkgname); if (run_pkg_config(logdepth+1, pkgname, &cflags, &ldflags) == 0) res = try_icl(logdepth+1, prefix, test_c, NULL, cflags, ldflags); else res = 0; free(cflags); free(ldflags); return res; } int try_icl_pkg_config(int logdepth, const char *prefix, const char *test_c, char *includes, const char *pkgpat, const char *reqver) { char **pkg_ver, **s; int num_pkg_ver; int res; (void) includes; /* not used */ run_pkg_config_lst(logdepth, pkgpat, &num_pkg_ver, &pkg_ver); if (pkg_ver == NULL) return 0; if (reqver != NULL) { /* search the list for the preferred version */ for(s = pkg_ver; *s != NULL; s+=2) { if (strcmp(s[1], reqver) == 0) { if (try_pkg_config_(logdepth, s[0], prefix, test_c)) { res = 1; report("Found version required (%s) using pkg_config.\n", reqver); goto out; } else { report("The version required (%s) is found (via pkg_config) but does not work\n", reqver); goto out; } } } goto out; } for(s = pkg_ver; *s != NULL; s+=2) { if (try_pkg_config_(logdepth, s[0], prefix, test_c)) { res = 1; goto out; } } out:; filelist_free(&num_pkg_ver, &pkg_ver); return res; } int import_icl(const char *key, const char *fn) { char path[1024]; switch(*key) { case 'l': sprintf(path, "/arg/icl/%s/ldflags", key+8); break; case 'c': sprintf(path, "/arg/icl/%s/cflags", key+7); break; case 'i': sprintf(path, "/arg/icl/%s/includes", key+9); break; case 'p': sprintf(path, "/arg/icl/%s/prefix", key+7); break; default: return 1; } printf("path='%s' fn='%s'\n", path, fn); return put(path, fn) == NULL; } static long field_accept_len; static int field_accept_res(char *stdout_str) { char *end; field_accept_len = strtol(stdout_str, &end, 10); if (((*end == '\0') || (*end == '\r') || (*end == '\n')) && (field_accept_len > 0)) return 1; return 0; } int try_icl_sfield(int logdepth, const char *prefix, const char *structn, const char *fieldn, const char *includes, const char *cflags, const char *ldflags) { int res; char test_c[512]; char ls[16]; const char *test_c_in = NL "#include " NL "int main()" NL "{" NL " %s s;" NL " printf(\"%%ld\\n\", (long)sizeof(s.%s));" NL "}" NL; sprintf(test_c, test_c_in, structn, fieldn); res = try_icl_(logdepth, prefix, test_c, includes, cflags, ldflags, 1, field_accept_res); if (res) { sprintf(test_c, "%s/sizeof", prefix); sprintf(ls, "%ld", field_accept_len); put(test_c, ls); } return res; } int try_icl_sfields(int logdepth, const char *prefix, const char *structn, const char **fields, const char *includes, const char *cflags, const char *ldflags, int silent_exit_first_fail) { int succ = 0, first = 1; require("cc/cc", logdepth, 1); for(; *fields != NULL; fields++) { report("Checking for %s.%s... ", structn, *fields); logprintf(logdepth, "%s: checking for field %s...\n", structn, *fields); logdepth++; if (try_icl_sfield(logdepth, prefix, structn, *fields, includes, cflags, ldflags)) { succ = 1; } else if ((silent_exit_first_fail) && (first)) { return 1; } logdepth--; first = 0; } if (!succ) try_fail(logdepth, "libs/fsmount/next_dev"); return 0; } xschem-2.8.1/scconfig/src/default/find_proc.c0000644000175100017510000000705113240634424017333 0ustar svnsvn/* scconfig - detection of standard library features (processes) Copyright (C) 2016 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include "libs.h" #include "log.h" #include "db.h" #include "dep.h" int find_proc__spawnvp(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "int main() {" NL " const char *a[3] = {\"/c\", \"echo OK\", NULL};" NL " _spawnvp(_P_WAIT, \"cmd\", a);" NL " return 0;" NL "}" NL ; require("cc/cc", logdepth, fatal); report("Checking for _spawnvp... "); logprintf(logdepth, "find_proc__spawnvp: trying to find _spawnvp...\n"); logdepth++; if (try_icl(logdepth, "libs/proc/_spawnvp", test_c, "#include ", NULL, NULL)) return 0; return try_fail(logdepth, "libs/proc/_spawnvp"); } int find_proc_fork(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "#include " NL "int main() {" NL " if (fork() == 0) { return 0; }" NL " puts(\"OK\");" NL " return 0;" NL "}" NL ; /* NOTE: can't print OK from the child process because of a possible race with the parent immediately exiting without wait(). */ require("cc/cc", logdepth, fatal); report("Checking for fork... "); logprintf(logdepth, "find_proc_fork: trying to find fork...\n"); logdepth++; if (try_icl(logdepth, "libs/proc/fork", test_c, "#include ", NULL, NULL)) return 0; return try_fail(logdepth, "libs/proc/fork"); } int find_proc_wait(const char *name, int logdepth, int fatal) { char *inc; const char *inc1; char test_c[1024]; char *test_c_in = NL "%s\n" NL "#include " NL "#include " NL "int main() {" NL " int st = 0;" NL " if (fork() == 0) {" NL " printf(\"O\");" NL " return 42;" NL " }" NL " wait(&st);" NL " if (WIFEXITED(st) && (WEXITSTATUS(st) == 42))" NL " printf(\"K\");" NL " else" NL " printf(\"%%d\", st);" NL " printf(\"\\n\");" NL " return 0;" NL "}" NL ; require("cc/cc", logdepth, fatal); if (require("libs/proc/fork", logdepth, fatal)) return try_fail(logdepth, "libs/proc/wait"); report("Checking for wait... "); logprintf(logdepth, "find_proc_wait: trying to find wait...\n"); logdepth++; inc1 = get("libs/proc/fork/includes"); if (inc1 != NULL) { char *i, *o; inc = strclone(inc1); for(i = o = inc; *i != '\0'; i++,o++) { if ((i[0] == '\\') && (i[1] == 'n')) { *o = '\n'; i++; } else *o = *i; } *o = '\0'; sprintf(test_c, test_c_in, inc); free(inc); } else sprintf(test_c, test_c_in, ""); if (try_icl(logdepth, "libs/proc/wait", test_c, "#include \n#include ", NULL, NULL)) return 0; return try_fail(logdepth, "libs/proc/wait"); } xschem-2.8.1/scconfig/src/default/libs.h0000644000175100017510000002074313370510646016334 0ustar svnsvn#define NL "\n" /* main.c */ extern int no_autodetect_sys; /* set this to 1 to suppress system and cross detection */ extern int no_save_cache; /* set this to 1 to avoid saving config.cache */ /* lib_try.c: try to compile and run a test code; save results under prefix, if worked */ /* include, compile-flags, link-flags; NULL includes, cflags, *ldflags means don't put anything in the db; cflags and ldflags may be prefixed with "+" to include standard flags; the test code has to print "OK" if it worked. If prefix is NULL, do not modify the db or announce the output, silently return 0 or 1. Returns 1 if worked, 0 if not */ int try_icl(int logdepth, const char *prefix, const char *test_c_in, const char *includes, const char *cflags, const char *ldflags); /* same as try_icl(), but does not execute the code, only compiles. Useful for test programs with undesirable side effects (e.g. gtk: would open a window) */ int try_icl_norun(int logdepth, const char *prefix, const char *test_c_in, const char *includes, const char *cflags, const char *ldflags); /* same as try_icl, but also insert flags picked up from deps (if not NULL); useful for detecting features that depend on other detected features. If run is 0, do not run the test program, compile only */ int try_icl_with_deps(int logdepth, const char *prefix, const char *test_c_in, const char *includes, const char *cflags, const char *ldflags, const char *dep_includes, const char *dep_cflags, const char *dep_ldflags, int run); /* Low level function for the same, giving more control to the caller */ int try_icl_(int logdepth, const char *prefix, const char *test_c_in, const char *includes, const char *cflags, const char *ldflags, int run, int (*accept_res)(char *stdout_str)); /* use try_icl() on a list of packages found by pkg-config. Stick to the version required if reqver is non-NULL, else try them in the order pkg-config returned them. */ int try_icl_pkg_config(int logdepth, const char *prefix, const char *test_c, char *includes, const char *pkgpat, const char *reqver); /* call this when failed to find the feature (after multiple try_*() calls); always returns 1 (so that return try_fail() does the Right Thing) */ int try_fail(int logdepth, const char *prefix); /* Import an argument for controlling try_icl() */ int import_icl(const char *key, const char *fn); /* Determine the sizeof() of a struct field; works the same way as icl() but also sets prefix/sizeof */ int try_icl_sfield(int logdepth, const char *prefix, const char *structn, const char *fieldn, const char *includes, const char *cflags, const char *ldflags); int try_icl_sfields(int logdepth, const char *prefix, const char *structn, const char **fields, const char *includes, const char *cflags, const char *ldflags, int silent_exit_first_fail); /* lib_compile.c */ extern int cross_blind; /* 1 if crosscompiling is blind (no emulator to test with) */ char *shell_escape_dup(const char *in); /* strdup in and escape any special char for the shell */ int compile_file(int logdepth, const char *fn_input, char **fn_output, const char *cc, const char *cflags, const char *ldflags); int compile_code(int logdepth, const char *testcode, char **fn_output, const char *cc, const char *cflags, const char *ldflags); /* same as above, but do not add cc/cflags and cc/ldfags */ int compile_file_raw(int logdepth, const char *fn_input, char **fn_output, const char *cc, const char *cflags, const char *ldflags); int compile_code_raw(int logdepth, const char *testcode, char **fn_output, const char *cc, const char *cflags, const char *ldflags); int run(int logdepth, const char *cmd_, char **stdout_saved); int run_shell(int logdepth, const char *cmd_, char **stdout_saved); int compile_run(int logdepth, const char *testcode, const char *cc, const char *cflags, const char *ldflags, char **stdout_saved); int run_script(int logdepth, const char *interpreter, const char *script, const char *suffix, char **out); /* lib_file.c */ int file_size(const char *name); char *tempdir_new(int logdepth, const char *suffix); char *tempfile_new(const char *suffix); char *tempfile_dump(const char *testcode, const char *suffix); char *load_file(const char *name); int is_dir(const char *path); int is_file(const char *path); int exists(const char *path); int exists_in(const char *dir, const char *file); char *file_name(const char *path); /* returns malloc'd buffer */ char *dir_name(const char *path); /* returns malloc'd buffer */ char *tempfile_new_noabort(const char *suffix); /* for internal use - returns NULL instead of aborting when temp file can not be created */ int touch_file(const char *path); /* lib_filelist.c */ void filelist(int logdepth, const char *dir, int *argc, char ***argv); void filelist_free(int *argc, char ***argv); /* lib_pkg_config.c */ /** run pkg config on @pkgname: - with `--cflags` if cflags is not NULL, storing the result in cflags (malloc()'d) - with `--libs` if ldflags is not NULL, storing the result in ldflags (malloc()'d) Returns 0 on success. */ int run_pkg_config(int logdepth, const char *pkgname, char **cflags, char **ldflags); /** same as run_pkg_config(), but runs a generic config tool (e.g. gdconfig) passed in confname */ int run_gen_config(int logdepth, const char *confname, const char *pkgname, char **cflags, char **ldflags); int run_pkg_config_modversion(int logdepth, const char *pkgname, char **modversion); int run_pkg_config_modversion_db(int logdepth, const char *node, const char *pkgname); /** run pkg-config --list-all and keep lines matching regex pkgpat. argc/argv is a filelist output, each item pair is package name returned by pkg_config (odd items are full package names, even items are suffixes: pkgpath match removed) */ void run_pkg_config_lst(int logdepth, const char *pkgpat, int *argc, char ***argv); /* lib_uniqinc.c */ char **uniq_inc_arr(const char *includes, int indirect, const char *sep, int *numlines); /* split includes by sep; includes is a list of nodes to get() if indirect is non-zero; return a NULL-terminated array of unique include strings and set *numlines if numlines is not NULL */ void uniq_inc_free(char **arr); /* free an array returned by uniq_inc_arr() */ char *uniq_inc_str(const char *includes, const char *isep, const char *osep, int sort, int eren, char **eres); /* take a long list of includes separated by isep and emit an uniq list separated by osep */ char *order_inc_str(const char *includes, const char *isep, const char *word1, int dir, const char *word2); /* take a long list of includes separated by isep and emit a new list where word1 is moved before/after of word2 if dir < 0 or dir > 0 */ /* find_types.c */ int find_types_something_t(const char *name, int logdepth, int fatal, const char* prefix, const char *typ, const char* define, const char *try_include); /* str.c */ char *strclone(const char *str); char *trim_left(char *str); char *trim_right(char *str); char *strip(char *str); char *str_chr(char *str, char c); char *str_rchr(char *str, char c); char *str_subsn(const char *str); /* advanced strdup that also interprets \n */ char *str_concat(const char *sep, ...); /* concat a list of strings into a newly allocated buffer, putting sep between them */ char *esc_interpret(const char *str); int chr_inset(char c, const char *set); /* returns whether c is in set */ /* srctree.c */ /* Run svn info on dir and extract the value for key; key is case sensitive. The first match is returned or NULL if not found or on error. */ char *svn_info(int logdepth, const char *dir, const char *key); #define isblind(root) ((strncmp((root), "/target", 7) == 0) && cross_blind) #define istarget(root) (strncmp((root), "/target", 7) == 0) #define target_emu_fail(out) ((isblind(db_cwd)) && (out == NULL)) #define safeNULL(s) ((s) == NULL ? "(NULL)" : (s)) #define str_null(s) ((s) == NULL ? "" : (s)) /* Test program helper: generate code that ensures a given FUNCT exists and is a function; can be turned off by defining SCCONFIG_ACCEPT_IMPLICIT on scconfig compilation time */ /* Both FUNCT1 and FUNCT2 argument *must* be used exactly once! In some cases FUNCT1 and FUNCT2 is a format string parameter. We expect, however, both arguments will substituted to the same value. */ #ifdef SCCONFIG_ACCEPT_IMPLICIT # define no_implicit(RET_TYPE, FUNCT1, FUNCT2) \ "/* accept implicit (" FUNCT1 ", " FUNCT2 ") */\n" #else # define no_implicit(RET_TYPE, FUNCT1, FUNCT2) \ "#ifndef " FUNCT1 "\n" \ "{ " #RET_TYPE " (*tmp)() = " FUNCT2 "; if (tmp) {}}\n" \ "#endif\n" #endif xschem-2.8.1/scconfig/src/default/find_time.c0000644000175100017510000001470513314203157017327 0ustar svnsvn/* scconfig - detection of standard library features: time/date/sleep related calls Copyright (C) 2011..2012 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include "libs.h" #include "log.h" #include "db.h" #include "dep.h" int find_time_usleep(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "int main() {" NL " if (usleep(1) == 0)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for usleep()... "); logprintf(logdepth, "find_time_usleep: trying to find usleep...\n"); logdepth++; if (try_icl(logdepth, "libs/time/usleep", test_c, NULL, NULL, NULL)) return 0; return try_fail(logdepth, "libs/time/usleep"); } int find_time_Sleep(const char *name, int logdepth, int fatal) { char *test_c = NL "int main() {" NL " Sleep(1);" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for Sleep()... "); logprintf(logdepth, "find_time_Sleep: trying to find Sleep...\n"); logdepth++; if (try_icl(logdepth, "libs/time/Sleep", test_c, "#include ", NULL, NULL)) return 0; return try_fail(logdepth, "libs/time/Sleep"); } int find_time_gettimeofday(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "int main() {" NL " struct timeval tv;" NL " if (gettimeofday(&tv, NULL) == 0)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for gettimeofday()... "); logprintf(logdepth, "find_time_gettimeofday: trying to find gettimeofday...\n"); logdepth++; if (try_icl(logdepth, "libs/time/gettimeofday", test_c, "#include ", NULL, NULL)) return 0; return try_fail(logdepth, "libs/time/gettimeofday"); } int find_time_ftime(const char *name, int logdepth, int fatal) { char *test_c = NL "int main() {" NL " struct timeb tb;" NL " if (ftime(&tb) == 0)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for ftime()... "); logprintf(logdepth, "find_time_ftime: trying to find ftime...\n"); logdepth++; if (try_icl(logdepth, "libs/time/ftime", test_c, "#include ", NULL, NULL)) return 0; return try_fail(logdepth, "libs/time/ftime"); } static const char timegm_test_c_template[] = NL "void my_puts(const char *s);" NL "int main() {" NL " struct tm tm;" NL " tm.tm_sec = 50;" NL " tm.tm_min = 30;" NL " tm.tm_hour = 6;" NL " tm.tm_mday = 1;" NL " tm.tm_mon = 11;" NL " tm.tm_year = 2018 - 1900;" NL " tm.tm_wday = 0;" NL " tm.tm_yday = 0;" NL " if (%s(&tm) != (time_t)(-1))" NL " my_puts(\"OK\");" NL " return 0;" NL "}" NL "#include " NL "void my_puts(const char *s)" NL "{" NL " puts(s);" NL "}" NL; int find_time_timegm(const char *name, int logdepth, int fatal) { char test_c[1000]; sprintf(test_c, timegm_test_c_template, "timegm"); require("cc/cc", logdepth, fatal); report("Checking for timegm()... "); logprintf(logdepth, "find_time_timegm: trying to find timegm...\n"); logdepth++; if (try_icl(logdepth, "libs/time/timegm", test_c, "#include ", NULL, NULL)) return 0; return try_fail(logdepth, "libs/time/timegm"); } int find_time_mkgmtime(const char *name, int logdepth, int fatal) { char test_c[1000]; const char *ldflags[] = {"","-lmsvcr120","-lmsvcr110","-lmsvcr100","-lmsvcr90","-lmsvcr80","-lmsvcr71","-lmsvcr70",NULL}; const char **ldf; sprintf(test_c, timegm_test_c_template, "_mkgmtime"); require("cc/cc", logdepth, fatal); report("Checking for _mkgmtime()... "); logprintf(logdepth, "find_time_mkgmtime: trying to find _mkgmtime...\n"); logdepth++; for (ldf = ldflags; *ldf; ++ldf) if (try_icl(logdepth, "libs/time/_mkgmtime", test_c, "#include ", NULL, *ldf)) return 0; return try_fail(logdepth, "libs/time/_mkgmtime"); } int find_time_gmtime_r(const char *name, int logdepth, int fatal) { const char test_c[] = NL "void my_puts(const char *s);" NL "int main() {" NL " time_t tim = 1543645850;" NL " struct tm tm;" NL " if (gmtime_r(&tim, &tm)" /* returns '&tm' */ NL " && 50==tm.tm_sec" NL " && 30==tm.tm_min" NL " && 6==tm.tm_hour" NL " && 1==tm.tm_mday" NL " && 11==tm.tm_mon" NL " && (2018-1900)==tm.tm_year)" NL " my_puts(\"OK\");" NL " return 0;" NL "}" NL "#include " NL "void my_puts(const char *s)" NL "{" NL " puts(s);" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for gmtime_r()... "); logprintf(logdepth, "find_time_gmtime_r: trying to find gmtime_r...\n"); logdepth++; if (try_icl(logdepth, "libs/time/gmtime_r", test_c, "#include ", NULL, NULL)) return 0; return try_fail(logdepth, "libs/time/gmtime_r"); } int find_time_gmtime_s(const char *name, int logdepth, int fatal) { const char test_c[] = NL "void my_puts(const char *s);" NL "int main() {" NL " time_t tim = 1543645850;" NL " struct tm tm;" NL " if (0==gmtime_s(&tm, &tim)" /* returns errno */ NL " && 50==tm.tm_sec" NL " && 30==tm.tm_min" NL " && 6==tm.tm_hour" NL " && 1==tm.tm_mday" NL " && 11==tm.tm_mon" NL " && (2018-1900)==tm.tm_year)" NL " my_puts(\"OK\");" NL " return 0;" NL "}" NL "#include " NL "void my_puts(const char *s)" NL "{" NL " puts(s);" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for gmtime_s()... "); logprintf(logdepth, "find_time_gmtime_s: trying to find gmtime_s...\n"); logdepth++; if (try_icl(logdepth, "libs/time/gmtime_s", test_c, "#include ", NULL, NULL)) return 0; return try_fail(logdepth, "libs/time/gmtime_s"); } xschem-2.8.1/scconfig/src/default/lib_srctree.c0000644000175100017510000000367312673161611017675 0ustar svnsvn/* scconfig - library to explore the source tree Copyright (C) 2015 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include "db.h" #include "libs.h" #include "log.h" #include "dep.h" char *svn_info(int logdepth, const char *dir, const char *key) { char *cmd, *stdo = NULL; char *res = NULL; int keylen = strlen(key); cmd = str_concat(" ", "svn info", dir, NULL); if (run_shell(logdepth, cmd, &stdo) == 0) { char *line, *nline; /* check key against each line */ for(line = stdo; line != NULL; line = nline) { /* split line */ nline = strpbrk(line, "\r\n"); if (nline != NULL) { *nline = '\0'; nline++; while((*nline == '\n') || (*nline == '\r')) nline++; } /* compare key */ if (strncmp(line, key, keylen) == 0) { char *val; /* extract value */ val = strchr(line, ':'); if (val != NULL) { val++; while((*val == ' ') || (*val == '\t')) val++; } else val = line; /* produce output */ res = strclone(val); goto found; } } } found:; if (stdo != NULL) free(stdo); free(cmd); return res; } xschem-2.8.1/scconfig/src/default/lib_uniqinc.c0000644000175100017510000001670013216026724017666 0ustar svnsvn/* scconfig - library for making includes on a list unique Copyright (C) 2012, 2017 Tibor Palinkas Copyright (C) 2017 Aron Barath This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include "libs.h" #include "db.h" #include "regex.h" #define grow \ if (used >= alloced) { \ alloced += 16; \ list = realloc(list, alloced * sizeof(char *)); \ } char **uniq_inc_arr(const char *includes, int indirect, const char *sep_, int *numlines) { char *node, *next, *cw, *nw, *snode, *orig_node; char *sep; char **list; int alloced, used, n; orig_node = strclone(includes); node = orig_node; if (sep_ == NULL) sep = strclone("\r\n"); else sep = strclone(sep_); /* reset list */ alloced = used = 0; list = NULL; /* take arguments one by one */ while(node != NULL) { if (indirect) { while((*node == ' ') || (*node == '\t')) node++; next = strpbrk(node, " \t"); } else { for(;;) { next = strpbrk(node, sep); if ((next > node) || (next == NULL)) break; node = next+1; } } if (next != NULL) { *next = '\0'; next++; } if (indirect) snode = str_subsn(get(node)); else snode = node; cw = snode; /* split node value (s) by sep */ /* fprintf(stderr, "nodename=%s snode=%s next=%s\n", node, snode, next);*/ while(cw != NULL) { nw = strpbrk(cw, sep); if (nw != NULL) { *nw = '\0'; nw++; } if (*cw != '\0') { /* try to find cw in the existing list - this is a slow linear search for now */ for(n = 0; n < used; n++) { if (strcmp(list[n], cw) == 0) goto already_on_list; } /* not found, append */ grow; list[used] = strclone(cw); used++; } already_on_list:; cw = nw; } if (indirect) free(snode); node = next; } grow; list[used] = NULL; if (numlines != NULL) *numlines = used; free(orig_node); free(sep); return list; } void uniq_inc_free(char **arr) { char **s; for(s = arr; *s != NULL; s++) free(*s); free(arr); } static int uniq_inc_str_cmp(const void *a_, const void *b_) { char **a = (char **)a_, **b = (char **)b_; return strcmp(*a, *b); } static void uniq_inc_assemble_normal(char* const ret, int numelem, char **arr, const char *osep, const int oseplen) { char *end; int len; for(end = ret; 0 < numelem; ++arr, --numelem) { if (!*arr) continue; len = strlen(*arr); memcpy(end, *arr, len); end += len; memcpy(end, osep, oseplen); end += oseplen; free(*arr); } *end = '\0'; } static void uniq_inc_assemble_groups(char* const ret, int numelem, char **arr, const char *osep, const int oseplen, int eren, char **eres) { char *end = ret; int erei, ndx, len; /* re_comp() uses a global variable to store the compiler regex! */ for (erei = 0; erei < eren; ++erei) { if (re_comp(eres[erei])) abort(); for (ndx = 0; ndx < numelem; ++ndx) { if (!arr[ndx]) continue; if (re_exec(arr[ndx])) { len = strlen(arr[ndx]); memcpy(end, arr[ndx], len); end += len; memcpy(end, osep, oseplen); end += oseplen; free(arr[ndx]); arr[ndx] = NULL; } } } /* collect remaining elements */ uniq_inc_assemble_normal(end, numelem, arr, osep, oseplen); } char *uniq_inc_str(const char *includes, const char *isep, const char *osep, int sort, int eren, char **eres) { char **arr, **s, *ret; int len, numelem, oseplen; /* split and uniq */ oseplen = strlen(osep); arr = uniq_inc_arr(includes, 0, isep, NULL); /* calculate the required amount of memory */ len = 4; /* safety margin, for terminator \0, etc. */ numelem = 0; for(s = arr; *s != NULL; s++) { len += strlen(*s) + oseplen + 1; numelem++; } /* sort if needed */ if (sort) qsort(arr, numelem, sizeof(char *), uniq_inc_str_cmp); /* allocate memory to assemble into */ ret = malloc(len); /* assemble the output */ if (0>=eren) uniq_inc_assemble_normal(ret, numelem, arr, osep, oseplen); else uniq_inc_assemble_groups(ret, numelem, arr, osep, oseplen, eren, eres); /* done */ free(arr); return ret; } char *order_inc_str(const char *includes, const char *isep, const char *word1, int dir, const char *word2) { const char *s, *next, *pre, *mid, *post; char *out, *end; long w1o = -1, w2o = -1; long w1len = strlen(word1), w2len = strlen(word2), tlen; long pre_len, mid_len, post_len; if (dir == 0) return NULL; if ((w1len == 0) || (w2len == 0)) return strclone(includes); if ((w1len == w2len) && (strcmp(word1, word2) == 0)) return strclone(includes); /* search the starting offset of the first occurence of word1 and word2 */ for(s = includes; (s != NULL) && ((w1o < 0) || (w2o < 0)); s = next) { next = strpbrk(s, isep); if (next == NULL) tlen = strlen(s); else tlen = next-s; if ((w1o < 0) && (w1len == tlen) && (memcmp(s, word1, tlen) == 0)) w1o = s - includes; if ((w2o < 0) && (w2len == tlen) && (memcmp(s, word2, tlen) == 0)) w2o = s - includes; if (next != NULL) next += strspn(next, isep); } /* one of the words is not on the list, the list is ordered */ if ((w1o < 0) || (w2o < 0)) return strclone(includes); /* both words are not on the list, but the list is ordered */ if (((dir < 0) && (w1o < w2o)) || ((dir > 0) && (w1o > w2o))) return strclone(includes); /* split up the input at word1 and word2 */ tlen = strlen(includes); if (dir < 0) { /* input is: 'pre w2 mid w1 post', goal is mowing w1 before w2 */ pre = includes; pre_len = w2o; mid = includes + w2o + w2len + 1; mid_len = (includes + w1o) - mid; post = includes + w1o + w1len + 1; post_len = (includes + tlen) - post + 1; } else { /* input is: 'pre w1 mid w2 post' goal is moving w1 after w2*/ pre = includes; pre_len = w1o; mid = includes + w1o + w1len + 1; mid_len = (includes + w2o) - mid; post = includes + w2o + w2len + 1; post_len = (includes + tlen) - post + 1; } /* truncate trailing separator, if present */ if ((pre_len > 0) && (strchr(isep, pre[pre_len-1]))) pre_len--; if ((mid_len > 0) && (strchr(isep, mid[mid_len-1]))) mid_len--; if ((post_len > 0) && (strchr(isep, post[mid_len-1]))) post_len--; /* allocate extra space for a trailing separator and/or \0 */ end = out = malloc(tlen+2); /* build the string by appending the parts */ #define append(str, len) \ if (len > 0) { \ memcpy(end, str, len); \ end += len; \ *end = *isep; \ end++; \ } append(pre, pre_len); if (dir < 0) { append(word1, w1len); append(word2, w2len); } append(mid, mid_len); if (dir > 0) { append(word2, w2len); append(word1, w1len); } append(post, post_len); #undef append /* replace the last separator with \0 or just add a \0 at the end */ if ((end > out) && (strchr(isep, end[-1]))) end[-1] = '\0'; else end[0] = '\0'; return out; } xschem-2.8.1/scconfig/src/default/find_fstools.c0000644000175100017510000004740613246533654020102 0ustar svnsvn/* scconfig - detection of file system tools Copyright (C) 2009..2012 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include #include "libs.h" #include "log.h" #include "db.h" #include "dep.h" #include "dep.h" static int test_cp_ln(int logdepth, const char *command, int link) { char *src, *dst, *src_esc, *dst_esc; char *cmd, *result; char *test_string = "works."; int ret; logprintf(logdepth, "trying '%s'\n", command); src = tempfile_dump(test_string, ""); dst = tempfile_new(""); if (link) unlink(dst); src_esc = shell_escape_dup(src); dst_esc = shell_escape_dup(dst); cmd = malloc(strlen(command) + strlen(src_esc) + strlen(dst_esc) + 32); sprintf(cmd, "%s %s %s", command, src_esc, dst_esc); run_shell(logdepth, cmd, NULL); free(cmd); free(src_esc); free(dst_esc); result = load_file(dst); ret = !strcmp(result, test_string); logprintf(logdepth+1, "result: '%s' == '%s' (%d)\n", result, test_string, ret); free(result); unlink(src); free(src); result = load_file(dst); if (link) { if (strcmp(result, test_string) == 0) { report("Warning: link is copy (or hard link). "); logprintf(logdepth+1, "Warning: link is copy (or hard link).\n"); } } else { if (strcmp(result, test_string) != 0) { report("Warning: copy is symlink. "); logprintf(logdepth+1, "Warning: copy is symlink.\n"); } } free(result); if (ret) { if (link) put("fstools/ln", command); else put("fstools/cp", command); report("OK (%s)\n", command); } unlink(dst); free(dst); return ret; } static int test_mv(int logdepth, const char *command) { char *src, *dst, *src_esc, *dst_esc; char *cmd, *result; char *test_string = "works."; int ret; logprintf(logdepth, "trying '%s'\n", command); src = tempfile_dump(test_string, ""); dst = tempfile_new(""); unlink(dst); src_esc = shell_escape_dup(src); dst_esc = shell_escape_dup(dst); cmd = malloc(strlen(command) + strlen(src_esc) + strlen(dst_esc) + 32); sprintf(cmd, "%s %s %s", command, src_esc, dst_esc); run_shell(logdepth, cmd, NULL); free(cmd); free(src_esc); free(dst_esc); result = load_file(dst); ret = !strcmp(result, test_string); logprintf(logdepth+1, "result: '%s' == '%s' (%d)\n", result, test_string, ret); free(result); if (file_size(src) > 0) { report("Warning: mv is copy. "); logprintf(logdepth+1, "Warning: mv is copy.\n"); } if (ret) { put("fstools/mv", command); report("OK (%s)\n", command); } unlink(dst); unlink(src); free(dst); free(src); return ret; } static int test_mkdir(int logdepth, const char *command) { char *dir, *file; char *dir_esc; char *cmd, *result; char *test_string = "works."; int ret = 0, had_p; FILE *f; logprintf(logdepth, "trying '%s'\n", command); dir = tempfile_new(""); dir_esc = shell_escape_dup(dir); unlink(dir); had_p = is_dir("-p"); cmd = malloc(strlen(command) + strlen(dir_esc) + 32); sprintf(cmd, "%s %s", command, dir_esc); run_shell(logdepth, cmd, NULL); free(cmd); file = malloc(strlen(dir) + 32); sprintf(file, "%s/test", dir); f = fopen(file, "w"); if (f != NULL) { fputs(test_string, f); fclose(f); result = load_file(file); if (strcmp(result, test_string) == 0) ret = 1; free(result); } unlink(file); unlink(dir); cmd = malloc(strlen(dir) + 32); sprintf(cmd, "rmdir %s", dir_esc); run_shell(logdepth, cmd, NULL); free(cmd); free(file); free(dir); free(dir_esc); /* This is a bit ugly, but on win32 or other systems where mkdir works but -p doesn't have an effect, a directory called -p may be left over... */ if ((!had_p) && (is_dir("-p"))) { unlink("-p"); return 0; } if (ret != 0) { put("fstools/mkdir", command); report("OK (%s)\n", command); } return ret; } static int test_rm(int logdepth, const char *command) { char *src, *src_esc, *cmd, *test_string = "works."; int ret; logprintf(logdepth, "trying '%s'\n", command); src = tempfile_dump(test_string, ""); if (file_size(src) < 0) { report("error: can't create temp file\n"); free(src); return 0; } src_esc = shell_escape_dup(src); cmd = malloc(strlen(command) + strlen(src_esc) + 32); sprintf(cmd, "%s %s", command, src_esc); run_shell(logdepth, cmd, NULL); free(cmd); free(src_esc); ret = file_size(src) < 0; if (ret) { put("fstools/rm", command); report("OK (%s)\n", command); } else unlink(src); free(src); return ret; } static int test_ar(int logdepth, const char *command) { char *src, *dst, *src_esc, *dst_esc; char *cmd, *result, *expected; char *test_string = "works."; const char *path_sep; int ret = 0; logprintf(logdepth, "trying '%s'\n", command); path_sep = get("sys/path_sep"); src = tempfile_dump(test_string, ""); dst = tempfile_new(""); unlink(dst); src_esc = shell_escape_dup(src); dst_esc = shell_escape_dup(dst); cmd = malloc(strlen(command) + strlen(src_esc) + strlen(dst_esc) + 32); sprintf(cmd, "%s ru %s %s", command, dst_esc, src_esc); run_shell(logdepth, cmd, NULL); sprintf(cmd, "%s t %s", command, dst_esc); run_shell(logdepth, cmd, &result); free(cmd); free(dst_esc); free(src_esc); if (result != NULL) { expected = str_rchr(src, *path_sep); if (expected == NULL) expected = src; else expected++; ret = strncmp(expected, result, strlen(expected)) == 0; if (ret) { put("fstools/ar", command); report("OK (%s)\n", command); } free(result); } unlink(src); unlink(dst); free(src); free(dst); return ret; } static int test_ranlib(int logdepth, const char *command, const char *obj) { char *cmd, *archive, *archive_esc, *obj_esc; const char *ar; int ret; ar = get("fstools/ar"); logprintf(logdepth, "trying '%s'\n", command); archive = tempfile_new(".a"); archive_esc = shell_escape_dup(archive); obj_esc = shell_escape_dup(obj); cmd = malloc(strlen(command) + strlen(obj_esc) + strlen(archive_esc) + 64); sprintf(cmd, "%s r %s %s", ar, archive_esc, obj_esc); unlink(archive); ret = run_shell(logdepth, cmd, NULL) == 0; if (!ret) goto fin; sprintf(cmd, "%s %s", command, archive_esc); ret = run_shell(logdepth, cmd, NULL) == 0; if (ret) { put("fstools/ranlib", command); report("OK (%s)\n", command); } fin:; unlink(archive); free(archive); free(cmd); free(archive_esc); free(obj_esc); return ret; } static int test_awk(int logdepth, const char *command) { char cmd[1024]; char *out; int ret = 0; char *script, *script_esc; /* For some reason windows awk doesn't like the code with NLs */ char *test_awk = "BEGIN {" " gsub(\"b\", \"B\", t);" " print t;" "}"; logprintf(logdepth, "trying '%s'\n", command); script = tempfile_dump(test_awk, ".awk"); script_esc = shell_escape_dup(script); sprintf(cmd, "%s -v \"t=blobb\" -f %s", command, script_esc); free(script_esc); run_shell(logdepth, cmd, &out); unlink(script); free(script); if ((out != NULL) && (strncmp(out, "BloBB", 5) == 0)) { put("fstools/awk", command); report("OK (%s)\n", command); ret = 1; } free(out); return ret; } static int test_cat(int logdepth, const char *command) { char cmd[1024]; char *out; int ret = 0; char *fn, *fn_esc; const char *test_str = "hello world"; logprintf(logdepth, "trying '%s'\n", command); fn = tempfile_dump(test_str, ".txt"); fn_esc = shell_escape_dup(fn); sprintf(cmd, "%s %s", command, fn_esc); run_shell(logdepth, cmd, &out); unlink(fn); free(fn); free(fn_esc); if ((out != NULL) && (strncmp(out, test_str, strlen(test_str)) == 0)) { put("fstools/cat", command); report("OK (%s)\n", command); ret = 1; } free(out); return ret; } static int test_sed(int logdepth, const char *command) { char cmd[1024]; char *out; int ret = 0; char *fn, *fn_esc; const char *test_str_in = "hello world"; const char *test_str_out = "he11o wor1d"; logprintf(logdepth, "trying '%s'\n", command); fn = tempfile_dump(test_str_in, ".txt"); fn_esc = shell_escape_dup(fn); sprintf(cmd, "%s \"s/l/1/g\" < %s", command, fn_esc); run_shell(logdepth, cmd, &out); unlink(fn); free(fn); free(fn_esc); if ((out != NULL) && (strncmp(out, test_str_out, strlen(test_str_out)) == 0)) { put("fstools/sed", command); report("OK (%s)\n", command); ret = 1; } free(out); return ret; } static int test_chmodx(int logdepth, const char *command) { char *cmd, *tmp, *tmp_esc, *out, *s; int ret; logprintf(logdepth, "trying '%s'\n", command); tmp = tempfile_dump("#!/bin/sh\necho OK\n", ".bat"); tmp_esc = shell_escape_dup(tmp); cmd = malloc(strlen(command) + strlen(tmp_esc) + 16); sprintf(cmd, "%s %s", command, tmp_esc); ret = run_shell(logdepth, cmd, NULL) == 0; free(cmd); if (!ret) { free(tmp_esc); return ret; } ret = run(logdepth+1, tmp_esc, &out); free(tmp_esc); if (ret == 0) { for(s = out; s != NULL; s = str_chr(s, '\n')) { logprintf(logdepth+1, "chmod line to test: '%s'\n", s); if ((s[0] == 'O') && (s[1] == 'K')) { logprintf(logdepth+2, "(OK)\n"); ret = 1; break; } s++; } } else ret = 0; free(out); if (ret) { put("fstools/chmodx", command); logprintf(logdepth, "chmodx command validated: '%s'\n", command); report("OK (%s)\n", command); } unlink(tmp); return ret; } static int test_file(int logdepth, const char *node, const char *command) { char cmd[1024]; char *out; int ret = 0; char *fn, *fn_esc; logprintf(logdepth, "trying '%s'\n", command); fn = tempfile_dump("plain text file\r\n", ".txt"); fn_esc = shell_escape_dup(fn); sprintf(cmd, "%s %s", command, fn_esc); run_shell(logdepth, cmd, &out); unlink(fn); free(fn); free(fn_esc); if ((out != NULL) && (strstr(out, "text") != NULL)) { put(node, command); report("OK (%s)\n", command); ret = 1; } free(out); return ret; } int find_fstools_cp(const char *name, int logdepth, int fatal) { const char *cp; (void) fatal; /* to suppress compiler warnings about not using fatal */ report("Checking for cp... "); logprintf(logdepth, "find_fstools_cp: trying to find cp...\n"); logdepth++; cp = get("/arg/fstools/cp"); if (cp == NULL) { if (test_cp_ln(logdepth, "cp -rp", 0)) return 0; if (test_cp_ln(logdepth, "cp -r", 0)) return 0; if (test_cp_ln(logdepth, "copy /r", 0)) return 0; /* wine */ } else { report(" user provided (%s)...", cp); if (test_cp_ln(logdepth, cp, 0)) return 0; } return 1; } int find_fstools_ln(const char *name, int logdepth, int fatal) { const char *ln; (void) fatal; /* to suppress compiler warnings about not using fatal */ report("Checking for ln... "); logprintf(logdepth, "find_fstools_ln: trying to find ln...\n"); logdepth++; ln = get("/arg/fstools/ln"); if (ln == NULL) { if (test_cp_ln(logdepth, "ln -sf",1 )) return 0; if (test_cp_ln(logdepth, "ln -s",1 )) return 0; if (test_cp_ln(logdepth, "ln", 1)) return 0; /* "mklink /H" -> win32 equivalent to "ln" */ /* "cp -s" -> same as "ln -s" */ /* "cp -l" -> same as "ln" */ if (test_cp_ln(logdepth, "cp", 1)) return 0; } else { report(" user provided (%s)...", ln); if (test_cp_ln(logdepth, ln, 1)) return 0; } return 1; } int find_fstools_mv(const char *name, int logdepth, int fatal) { const char *mv; (void) fatal; /* to suppress compiler warnings about not using fatal */ report("Checking for mv... "); logprintf(logdepth, "find_fstools_mv: trying to find mv...\n"); logdepth++; mv = get("/arg/fstools/mv"); if (mv == NULL) { if (test_mv(logdepth, "mv")) return 0; if (test_mv(logdepth, "move")) return 0; /* win32 */ if (test_mv(logdepth, "cp")) return 0; } else { report(" user provided (%s)...", mv); if (test_mv(logdepth, mv)) return 0; } return 1; } int find_fstools_rm(const char *name, int logdepth, int fatal) { const char *rm; (void) fatal; /* to suppress compiler warnings about not using fatal */ report("Checking for rm... "); logprintf(logdepth, "find_fstools_rm: trying to find rm...\n"); logdepth++; rm = get("/arg/fstools/rm"); if (rm == NULL) { if (test_rm(logdepth, "rm -rf")) return 0; if (test_rm(logdepth, "rm -f")) return 0; if (test_rm(logdepth, "rm")) return 0; if (test_rm(logdepth, "del")) return 0; /* for win32 */ } else { report(" user provided (%s)...", rm); if (test_rm(logdepth, rm)) return 0; } return 1; } int find_fstools_mkdir(const char *name, int logdepth, int fatal) { const char *mkdir; (void) fatal; /* to suppress compiler warnings about not using fatal */ report("Checking for mkdir... "); logprintf(logdepth, "find_fstools_mkdir: trying to find mkdir...\n"); logdepth++; mkdir = get("/arg/fstools/mkdir"); if (mkdir == NULL) { if (test_mkdir(logdepth, "mkdir -p")) return 0; if (test_mkdir(logdepth, "md")) return 0; /* for win32 */ } else { report(" user provided (%s)...", mkdir); if (test_mkdir(logdepth, mkdir)) return 0; } return 1; } int find_fstools_ar(const char *name, int logdepth, int fatal) { const char *ar, *target; char *targetar; int len; (void) fatal; /* to suppress compiler warnings about not using fatal */ require("sys/path_sep", logdepth, fatal); report("Checking for ar... "); logprintf(logdepth, "find_fstools_ar: trying to find ar...\n"); logdepth++; ar = get("/arg/fstools/ar"); if (ar == NULL) { target = get("/arg/sys/target"); if (target != NULL) { logprintf(logdepth+1, "find_ar: crosscompiling for '%s', looking for target ar\n", target); len = strlen(target); targetar = malloc(len + 8); memcpy(targetar, target, len); strcpy(targetar + len, "-ar"); if (test_ar(logdepth, targetar)) { free(targetar); return 0; } free(targetar); } if (test_ar(logdepth, "ar")) return 0; if (test_ar(logdepth, "/usr/bin/ar")) return 0; } else { report(" user provided (%s)...", ar); if (test_ar(logdepth, ar)) return 0; } return 1; } int find_fstools_ranlib(const char *name, int logdepth, int fatal) { const char *ranlib, *target; char *targetranlib; int len; char *test_code = NL "int zero() { return 0; }" NL; char *obj = ".o"; (void) fatal; /* to suppress compiler warnings about not using fatal */ require("fstools/ar", logdepth, fatal); require("cc/cc", logdepth, fatal); report("Checking for ranlib... "); logprintf(logdepth, "find_fstools_ranlib: trying to find ranlib...\n"); logdepth++; logprintf(logdepth, "compiling test object...\n"); if (compile_code(logdepth+1, test_code, &obj, NULL, "-c", NULL) != 0) { logprintf(logdepth, "ERROR: Can't compile test object\n"); report("ERROR: Can't compile test object\n"); abort(); } ranlib = get("/arg/fstools/ranlib"); if (ranlib == NULL) { target = get("/arg/sys/target"); if (target != NULL) { logprintf(logdepth+1, "find_ranlib: crosscompiling for '%s', looking for target ranlib\n", target); len = strlen(target); targetranlib = malloc(len + 16); memcpy(targetranlib, target, len); strcpy(targetranlib + len, "-ranlib"); if (test_ranlib(logdepth, targetranlib, obj)) { free(targetranlib); return 0; } free(targetranlib); } if (test_ranlib(logdepth, "ranlib", obj)) goto found; if (test_ranlib(logdepth, "/usr/bin/ranlib", obj)) goto found; if (test_ranlib(logdepth, "ar -s", obj)) goto found; if (test_ranlib(logdepth, "/usr/bin/ar -s", obj)) goto found; /* some systems (for example IRIX) can't run s without doing something else; t is harmless */ if (test_ranlib(logdepth, "ar ts", obj)) goto found; if (test_ranlib(logdepth, "/usr/bin/ar ts", obj)) goto found; /* final fallback: some systems (for example minix3) simply do not have ranlib or ar equivalent; it's easier to detect a dummy command than to force conditions into Makefiles */ if (test_ranlib(logdepth, "true", obj)) goto found; } else { report(" user provided (%s)...", ranlib); if (test_ranlib(logdepth, ranlib, obj)) goto found; } unlink(obj); free(obj); return 1; found:; unlink(obj); free(obj); return 0; } int find_fstools_awk(const char *name, int logdepth, int fatal) { const char *awk; (void) fatal; /* to suppress compiler warnings about not using fatal */ report("Checking for awk... "); logprintf(logdepth, "find_fstools_awk: trying to find awk...\n"); logdepth++; awk = get("/arg/fstools/awk"); if (awk == NULL) { if (test_awk(logdepth, "awk")) return 0; if (test_awk(logdepth, "gawk")) return 0; if (test_awk(logdepth, "mawk")) return 0; if (test_awk(logdepth, "nawk")) return 0; } else { report(" user provided (%s)...", awk); if (test_awk(logdepth, awk)) return 0; } return 1; } int find_fstools_chmodx(const char *name, int logdepth, int fatal) { const char *chmod; (void) fatal; /* to suppress compiler warnings about not using fatal */ report("Checking for chmod to executable... "); logprintf(logdepth, "find_fstools_awk: trying to find chmod to executable...\n"); logdepth++; chmod = get("/arg/fstools/chmodx"); if (chmod == NULL) { if (test_chmodx(logdepth, "chmod +x")) return 0; if (test_chmodx(logdepth, "chmod 755")) return 0; if (test_chmodx(logdepth, "")) return 0; /* on some systems we don't need to do anything */ } else { report(" user provided (%s)...", chmod); if (test_chmodx(logdepth, chmod)) return 0; } return 1; } int find_fstools_cat(const char *name, int logdepth, int fatal) { const char *cat; (void) fatal; /* to suppress compiler warnings about not using fatal */ report("Checking for cat... "); logprintf(logdepth, "find_fstools_cat: trying to find cat...\n"); logdepth++; cat = get("/arg/fstools/cat"); if (cat == NULL) { if (test_cat(logdepth, "cat")) return 0; if (test_cat(logdepth, "type")) return 0; } else { report(" user provided (%s)...", cat); if (test_cat(logdepth, cat)) return 0; } return 1; } int find_fstools_sed(const char *name, int logdepth, int fatal) { const char *sed; (void) fatal; /* to suppress compiler warnings about not using fatal */ report("Checking for sed... "); logprintf(logdepth, "find_fstools_sed: trying to find sed...\n"); logdepth++; sed = get("/arg/fstools/sed"); if (sed == NULL) { if (test_sed(logdepth, "sed")) return 0; } else { report(" user provided (%s)...", sed); if (test_sed(logdepth, sed)) return 0; } return 1; } int find_fstools_file_l(const char *name, int logdepth, int fatal) { const char *file; (void) fatal; /* to suppress compiler warnings about not using fatal */ report("Checking for file... "); logprintf(logdepth, "find_fstools_file_l: trying to find file -L...\n"); logdepth++; file = get("/arg/fstools/file_l"); if (file == NULL) { if (test_file(logdepth, "fstools/file_l", "file -L")) return 0; if (test_file(logdepth, "fstools/file_l", "file")) return 0; } else { report(" user provided (%s)...", file); if (test_file(logdepth, "fstools/file_l", file)) return 0; } return 1; } int find_fstools_file(const char *name, int logdepth, int fatal) { const char *file; (void) fatal; /* to suppress compiler warnings about not using fatal */ report("Checking for file... "); logprintf(logdepth, "find_fstools_file: trying to find file...\n"); logdepth++; file = get("/arg/fstools/file"); if (file == NULL) { if (test_file(logdepth, "fstools/file", "file")) return 0; } else { report(" user provided (%s)...", file); if (test_file(logdepth, "fstools/file", file)) return 0; } return 1; } xschem-2.8.1/scconfig/src/default/hooks.h0000644000175100017510000000233413367045120016516 0ustar svnsvn/* Runs when a custom command line argument is found returns true if no further argument processing should be done */ int hook_custom_arg(const char *key, const char *value); /* If any of the int hooks return non-zero, that means failure and stops the whole process */ /* Runs before anything else */ int hook_preinit(void); /* Runs after initialization */ int hook_postinit(void); /* Runs after all arguments are read and parsed */ int hook_postarg(void); /* Runs when things should be detected for the host system (tools compiled for and/or run on compilation host) */ int hook_detect_host(void); /* Runs when things should be detected for the target system (tools compiled on the compilation host but running on the target)*/ int hook_detect_target(void); /* Runs when things should be detected for the runtime system (tools that will run only on the target, production runtime, not during compilation or installation) */ int hook_detect_runtime(void); /* Runs after detection hooks, should generate the output (Makefiles, etc.) */ int hook_generate(void); /* Runs before everything is uninitialized */ void hook_preuninit(void); /* Runs at the very end, when everything is already uninitialized */ void hook_postuninit(void); xschem-2.8.1/scconfig/src/default/log.h0000644000175100017510000000066011400625735016156 0ustar svnsvn#include #include #define max_spaces 64 extern char *spaces; #define logprefix(n) (((n) > max_spaces) ? spaces : (spaces+max_spaces-(n))) void logprintf(int depth, const char *format, ...); void error(const char *format, ...); void report(const char *format, ...); void log_merge(int logdepth, const char *fn); extern FILE *logfile; extern void log_init(void); void log_uninit(void); extern char *fn_log; xschem-2.8.1/scconfig/src/default/find.h0000644000175100017510000002046613400723626016323 0ustar svnsvn/* cc */ int find_cc(const char *name, int logdepth, int fatal); int find_cc_argstd(const char *name, int logdepth, int fatal); int find_cc_argmachine(const char *name, int logdepth, int fatal); int find_cc_fpie(const char *name, int logdepth, int fatal); int find_cc_fnopie(const char *name, int logdepth, int fatal); int find_cc_fnopic(const char *name, int logdepth, int fatal); int find_inline(const char *name, int logdepth, int fatal); int find_varargmacro(const char *name, int logdepth, int fatal); int find_funcmacro(const char *name, int logdepth, int fatal); int find_constructor(const char *name, int logdepth, int fatal); int find_destructor(const char *name, int logdepth, int fatal); int find_fattr_unused(const char *name, int logdepth, int fatal); int find_declspec_dllimport(const char *name, int logdepth, int fatal); int find_declspec_dllexport(const char *name, int logdepth, int fatal); int find_rdynamic(const char *name, int logdepth, int fatal); int find_soname(const char *name, int logdepth, int fatal); int find_wlrpath(const char *name, int logdepth, int fatal); int find_cc_wloutimplib(const char *name, int logdepth, int fatal); int find_cc_wloutputdef(const char *name, int logdepth, int fatal); int find_fpic(const char *name, int logdepth, int fatal); int find_ldflags_dynlib(const char *name, int logdepth, int fatal); int find_ldflags_dll(const char *name, int logdepth, int fatal); int find_ldflags_so(const char *name, int logdepth, int fatal); int find_alloca(const char *name, int logdepth, int fatal); int find__exit(const char *name, int logdepth, int fatal); int find_cc_pragma_message(const char *name, int logdepth, int fatal); /* libs */ int find_lib_ldl(const char *name, int logdepth, int fatal); int find_lib_LoadLibrary(const char *name, int logdepth, int fatal); int find_lib_errno(const char *name, int logdepth, int fatal); /* thread */ int find_lib_lpthread(const char *name, int logdepth, int fatal); int find_thread_semget(const char *name, int logdepth, int fatal); int find_thread_pthread_create(const char *name, int logdepth, int fatal); int find_thread_CreateSemaphore(const char *name, int logdepth, int fatal); int find_thread_CreateThread(const char *name, int logdepth, int fatal); /* fscalls */ int find_fs_realpath(const char *name, int logdepth, int fatal); int find_fs__fullpath(const char *name, int logdepth, int fatal); int find_fs_readdir(const char *name, int logdepth, int fatal); int find_fs_findnextfile(const char *name, int logdepth, int fatal); int find_fs_access(const char *name, int logdepth, int fatal); int find_fs_access_macros(const char *name, int logdepth, int fatal); int find_fs_stat_macros(const char *name, int logdepth, int fatal); int find_fs_stat_fields(const char *name, int logdepth, int fatal); int find_fs_lstat(const char *name, int logdepth, int fatal); int find_fs_statlstat(const char *name, int logdepth, int fatal); int find_fs_getcwd(const char *name, int logdepth, int fatal); int find_fs__getcwd(const char *name, int logdepth, int fatal); int find_fs_getwd(const char *name, int logdepth, int fatal); int find_fs_mkdir(const char *name, int logdepth, int fatal); int find_fs__mkdir(const char *name, int logdepth, int fatal); int find_fs_mkdtemp(const char *name, int logdepth, int fatal); int find_fs_mmap(const char *name, int logdepth, int fatal); int find_fsmount_next_dev(const char *name, int logdepth, int fatal); int find_fsmount_fsstat_fields(const char *name, int logdepth, int fatal); int find_fsmount_statfs_fields(const char *name, int logdepth, int fatal); int find_fsmount_statvfs_fields(const char *name, int logdepth, int fatal); int find_fs_ustat(const char *name, int logdepth, int fatal); int find_fs_statfs(const char *name, int logdepth, int fatal); int find_fs_statvfs(const char *name, int logdepth, int fatal); int find_fs_flock(const char *name, int logdepth, int fatal); /* printf */ int find_printf_x(const char *name, int logdepth, int fatal); int find_printf_ptrcast(const char *name, int logdepth, int fatal); int find_snprintf(const char *name, int logdepth, int fatal); int find_dprintf(const char *name, int logdepth, int fatal); int find_vdprintf(const char *name, int logdepth, int fatal); int find_vsnprintf(const char *name, int logdepth, int fatal); /* proc */ int find_proc__spawnvp(const char *name, int logdepth, int fatal); int find_proc_fork(const char *name, int logdepth, int fatal); int find_proc_wait(const char *name, int logdepth, int fatal); /* fstools */ int find_fstools_cp(const char *name, int logdepth, int fatal); int find_fstools_ln(const char *name, int logdepth, int fatal); int find_fstools_mv(const char *name, int logdepth, int fatal); int find_fstools_rm(const char *name, int logdepth, int fatal); int find_fstools_mkdir(const char *name, int logdepth, int fatal); int find_fstools_ar(const char *name, int logdepth, int fatal); int find_fstools_ranlib(const char *name, int logdepth, int fatal); int find_fstools_awk(const char *name, int logdepth, int fatal); int find_fstools_cat(const char *name, int logdepth, int fatal); int find_fstools_sed(const char *name, int logdepth, int fatal); int find_fstools_file(const char *name, int logdepth, int fatal); int find_fstools_file_l(const char *name, int logdepth, int fatal); int find_fstools_chmodx(const char *name, int logdepth, int fatal); /* uname */ int find_uname(const char *name, int logdepth, int fatal); int find_triplet(const char *name, int logdepth, int fatal); int find_sysid(const char *name, int logdepth, int fatal); /* find_target */ int find_target(const char *name, int logdepth, int fatal); /* filelist */ int find_filelist(const char *name, int logdepth, int fatal); /* find_str.c */ int find_strcasecmp(const char *name, int logdepth, int fatal); int find_strncasecmp(const char *name, int logdepth, int fatal); /* find_sys.c */ int find_sys_ptrwidth(const char *name, int logdepth, int fatal); int find_sys_byte_order(const char *name, int logdepth, int fatal); int find_tmp(const char *name, int logdepth, int fatal); int find_shell(const char *name, int logdepth, int fatal); /* find_io.c */ int find_io_pipe(const char *name, int logdepth, int fatal); int find_io_dup2(const char *name, int logdepth, int fatal); int find_io_fileno(const char *name, int logdepth, int fatal); int find_io_lseek(const char *name, int logdepth, int fatal); int find_io_popen(const char *name, int logdepth, int fatal); /* find_time.c */ int find_time_usleep(const char *name, int logdepth, int fatal); int find_time_Sleep(const char *name, int logdepth, int fatal); int find_time_gettimeofday(const char *name, int logdepth, int fatal); int find_time_ftime(const char *name, int logdepth, int fatal); int find_time_timegm(const char *name, int logdepth, int fatal); int find_time_mkgmtime(const char *name, int logdepth, int fatal); int find_time_gmtime_s(const char *name, int logdepth, int fatal); int find_time_gmtime_r(const char *name, int logdepth, int fatal); /* find_types.c */ int find_types_stdint(const char *name, int logdepth, int fatal); int find_types_sizes(const char *name, int logdepth, int fatal); int find_types_size_t(const char *name, int logdepth, int fatal); int find_types_off_t(const char *name, int logdepth, int fatal); int find_types_off64_t(const char *name, int logdepth, int fatal); int find_types_gid_t(const char *name, int logdepth, int fatal); int find_types_uid_t(const char *name, int logdepth, int fatal); int find_types_pid_t(const char *name, int logdepth, int fatal); int find_types_dev_t(const char *name, int logdepth, int fatal); int find_types_dev_t(const char *name, int logdepth, int fatal); int find_types_mode_t(const char *name, int logdepth, int fatal); int find_types_nlink_t(const char *name, int logdepth, int fatal); int find_types_ptrdiff_t(const char *name, int logdepth, int fatal); int find_types_dev_t(const char *name, int logdepth, int fatal); int find_types_ino_t(const char *name, int logdepth, int fatal); int find_types_void_ptr(const char *name, int logdepth, int fatal); /* find_signal.c */ int find_signal_names(const char *name, int logdepth, int fatal); int find_signal_raise(const char *name, int logdepth, int fatal); /* environ.c */ int find_main_arg3(const char *name, int logdepth, int fatal); int find_putenv(const char *name, int logdepth, int fatal); int find_setenv(const char *name, int logdepth, int fatal); int find_environ(const char *name, int logdepth, int fatal); xschem-2.8.1/scconfig/src/default/main.c0000644000175100017510000000506513334271760016323 0ustar svnsvn/* scconfig - test code for default and scripts Copyright (C) 2009..2016 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include "db.h" #include "find.h" #include "log.h" #include "arg.h" #include "dep.h" #include "deps_default.h" #include "libs.h" #include "hooks.h" #include "regex.h" #include "main_custom_args.h" #include "main_lib.h" void re_fail(char *s, char c) { fprintf(stderr, "Regex error: %s [opcode %o]\n", s, c); abort(); } int no_autodetect_sys = 0; int no_save_cache = 0; int main(int argc, char *argv[]) { int blind_save; if (main_init() != 0) return 1; if (main_process_args(argc, argv) != 0) return 1; if (!no_autodetect_sys) { find_target("", 0, 1); blind_save = cross_blind; cross_blind = 0; printf("--- Detecting host\n"); require("sys/name", 0, 1); } if (hook_detect_host()) { fprintf(stderr, "hook_detect_host failed, exiting\n"); return 1; } cross_blind = blind_save; if (!no_autodetect_sys) { if (!iscross) printf("--- Detecting target (same as host)\n"); else printf("--- Detecting target (differs from host)\n"); } db_cd("/target"); run_custom_reqs(); if (hook_detect_target()) { fprintf(stderr, "hook_detect_target failed, exiting\n"); return 1; } #ifdef RUNTIME if (!no_autodetect_sys) { if (!iscross) printf("--- Detecting runtime (same as host)\n"); else printf("--- Detecting runtime (differs from host)\n"); } db_cd("/runtime"); if (hook_detect_runtime()) { fprintf(stderr, "hook_detect_runtime failed, exiting\n"); return 1; } #endif if (hook_generate()) { fprintf(stderr, "hook_generate failed, exiting\n"); return 1; } if (!no_save_cache) export("config.cache", 1, "/"); main_uninit(); return 0; } xschem-2.8.1/scconfig/src/default/log.c0000644000175100017510000000577012757462723016174 0ustar svnsvn/* scconfig - logging Copyright (C) 2009 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include "log.h" #include #include #include #include char *spaces = " "; FILE *logfile = NULL; char *fn_log = "config.log"; void log_init(void) { if (fn_log != NULL) { /* double open for truncate - for extreme portability, please do not "fix" */ logfile = fopen(fn_log, "w"); assert(logfile != NULL); fclose(logfile); logfile = fopen(fn_log, "a"); assert(logfile != NULL); } } void log_uninit(void) { if (logfile != NULL) fclose(logfile); } void logprintf(int depth, const char *format, ...) { va_list ap; va_start(ap, format); if (logfile != NULL) { fprintf(logfile, "%s", logprefix(depth)); vfprintf(logfile, format, ap); fflush(logfile); } va_end(ap); } void error(const char *format, ...) { va_list ap; va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap); va_start(ap, format); if (logfile != NULL) { fprintf(logfile, "###error### "); vfprintf(logfile, format, ap); fflush(logfile); } va_end(ap); } void report(const char *format, ...) { va_list ap; va_start(ap, format); vprintf(format, ap); fflush(stdout); va_end(ap); va_start(ap, format); if (logfile != NULL) { fprintf(logfile, "###report### "); vfprintf(logfile, format, ap); fflush(logfile); } va_end(ap); } void log_merge(int logdepth, const char *fn) { FILE *f; char line[2048]; int lines; if (logfile == NULL) return; f = fopen(fn, "r"); if (f == NULL) { logprintf(logdepth, "scconfig error: couldn't open %s for merging.\n", fn); return; } lines = 0; while(!(feof(f))) { *line = '\0'; fgets(line, sizeof(line), f); if (*line != '\0') { if (lines == 0) logprintf(logdepth, "========= output dump start ============\n"); lines++; logprintf(logdepth, "%s", line); /* Make sure we have newline at the end of each line */ if (line[strlen(line)-1] != '\n') logprintf(0, "\n"); } } if (lines == 0) logprintf(logdepth, "========= empty stderr =================\n"); else logprintf(logdepth, "========= output dump end ==============\n"); fclose(f); } xschem-2.8.1/scconfig/src/default/find_environ.c0000644000175100017510000001077313240634424020055 0ustar svnsvn/* scconfig - detection of environmental variable access features Copyright (C) 2014 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include "libs.h" #include "log.h" #include "db.h" #include "dep.h" int find_main_arg3(const char *name, int logdepth, int fatal) { char *out; char *test_c = NL "#include " NL "#include " NL "int main(int argc, char *argv[], char *env[])" NL "{" NL " char **e;" NL " int cnt;" NL " for(e = env, cnt = 0; *e != NULL; e++, cnt++) ;" NL " printf(\"%d\\n\", cnt);" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for main() with 3 arguments... "); logprintf(logdepth, "find_main_3args: checking for main() with 3 arguments\n"); if (compile_run(logdepth+1, test_c, NULL, NULL, NULL, &out) == 0) { if (atoi(out) > 1) { put("libs/env/main_3arg", strue); report("OK\n"); free(out); return 0; } free(out); report("not found (broken output).\n"); } else { report("not found (no output).\n"); } put("libs/env/main_3arg", sfalse); return 1; } int find_environ(const char *name, int logdepth, int fatal) { char *out; char *test_c = NL "#include " NL "#include " NL "extern char **environ;" NL "int main(int argc, char *argv[])" NL "{" NL " char **e;" NL " int cnt;" NL " for(e = environ, cnt = 0; *e != NULL; e++, cnt++) ;" NL " printf(\"%d\\n\", cnt);" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for extern environ... "); logprintf(logdepth, "find_environ: checking for extern environ\n"); if (compile_run(logdepth+1, test_c, NULL, NULL, NULL, &out) == 0) { if (atoi(out) > 1) { put("libs/env/environ", strue); report("OK\n"); free(out); return 0; } free(out); report("not found (broken output).\n"); } else { report("not found (no output).\n"); } put("libs/env/environ", sfalse); return 1; } int find_putenv(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "#include " NL "int main(int argc, char *argv[])" NL "{" NL " putenv(\"SCCONFIG_TEST=bad\");" NL " putenv(\"SCCONFIG_TEST=OK\");" NL " printf(\"%s\\n\", getenv(\"SCCONFIG_TEST\"));" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for putenv()... "); logprintf(logdepth, "find_putenv: trying to find putenv...\n"); logdepth++; if (try_icl(logdepth, "libs/env/putenv", test_c, "", NULL, NULL)) return 0; if (try_icl(logdepth, "libs/env/putenv", test_c, "#define _XOPEN_SOURCE", NULL, NULL)) return 0; if (try_icl(logdepth, "libs/env/putenv", test_c, "#define _SVID_SOURCE", NULL, NULL)) return 0; return try_fail(logdepth, "libs/env/putenv"); } int find_setenv(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "#include " NL "int main(int argc, char *argv[])" NL "{" NL " setenv(\"SCCONFIG_TEST\", \"bad\", 1);" NL " setenv(\"SCCONFIG_TEST\", \"OK\", 1);" NL " printf(\"%s\\n\", getenv(\"SCCONFIG_TEST\"));" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for setenv()... "); logprintf(logdepth, "find_setenv: trying to find setenv...\n"); logdepth++; if (try_icl(logdepth, "libs/env/setenv", test_c, "", NULL, NULL)) return 0; if (try_icl(logdepth, "libs/env/setenv", test_c, "#define _BSD_SOURCE", NULL, NULL)) return 0; if (try_icl(logdepth, "libs/env/setenv", test_c, "#define _POSIX_C_SOURCE 200112L", NULL, NULL)) return 0; if (try_icl(logdepth, "libs/env/setenv", test_c, "#define _XOPEN_SOURCE 600", NULL, NULL)) return 0; return try_fail(logdepth, "libs/env/setenv"); } xschem-2.8.1/scconfig/src/default/ht.h0000644000175100017510000000276111375674401016021 0ustar svnsvn#ifndef STR_HT_H #define STR_HT_H /* char * -> void * open addressing hashtable */ /* keys and values are strdupped (strcloned) */ #define ht_deleted_key ((char *)1) #define ht_isused(e) ((e)->key && (e)->key != ht_deleted_key) #define ht_isempty(e) (((e)->key == NULL) || (e)->key == ht_deleted_key) #define ht_isdeleted(e) ((e)->key == ht_deleted_key) typedef struct { unsigned int hash; char *key; void *value; } ht_entry_t; typedef struct { unsigned int mask; unsigned int fill; unsigned int used; int isstr; ht_entry_t *table; int refcount; } ht_t; ht_t *ht_alloc(int isstr); void ht_free(ht_t *ht); ht_t *ht_clear(ht_t *ht); ht_t *ht_resize(ht_t *ht, unsigned int hint); /* value of ht[key], NULL if key is empty or deleted */ void *ht_get(ht_t *ht, const char *key); /* ht[key] = value and return NULL or return ht[key] if key is already used */ void *ht_insert(ht_t *ht, const char *key, void *value); /* ht[key] = value and return a pointer to the strdupped key */ const char *ht_set(ht_t *ht, const char *key, void *value); /* delete key and return ht_deleted_key or NULL if key was not used */ const char *ht_del(ht_t *ht, const char *key); /* iteration */ #define foreach(ht, e) \ for (e = (ht)->table; e != (ht)->table + (ht)->mask + 1; e++) \ if (ht_isused(e)) /* first used (useful for iteration) NULL if empty */ ht_entry_t *ht_first(const ht_t *ht); /* next used (useful for iteration) NULL if there is no more used */ ht_entry_t *ht_next(const ht_t *ht, ht_entry_t *entry); #endif xschem-2.8.1/scconfig/src/default/regex.h0000644000175100017510000000036312562533767016524 0ustar svnsvn#ifndef REGEX_H #define REGEX_H extern const char *bopat[]; extern const char *eopat[]; extern char *re_comp(const char *); extern int re_exec(const char *); extern void re_modw(char *); char *re_subs_dup(char *sub); #endif /* REGEX_H */ xschem-2.8.1/scconfig/src/default/find_sys.c0000644000175100017510000003102313316714305017203 0ustar svnsvn/* scconfig - detect features of the system or the host/target computer Copyright (C) 2009..2012 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include #include #include "libs.h" #include "log.h" #include "db.h" #include "dep.h" int find_sys_ptrwidth(const char *name, int logdepth, int fatal) { char *end, W[32]; char *out = NULL; int w; char *test_c = NL "#include " NL "int main() {" NL " void *ptr;" NL " printf(\"%d\\n\", sizeof(ptr));" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for pointer width... "); logprintf(logdepth, "find_sys_ptrwidth: trying to find pointer width...\n"); logdepth++; if (compile_run(logdepth, test_c, NULL, NULL, NULL, &out) == 0) { w = strtol(out, &end, 10); if ((*end != '\0') && (*end != '\n') && (*end != '\r')) { report("FAILED (test code failed)\n"); logprintf(logdepth+1, "FAILED: returned '%s' which is not a valid decimal number (at '%s')\n", out, end); return 1; } sprintf(W, "%d", w * 8); report("OK (%s bits)\n", W); put("sys/ptrwidth", W); logprintf(logdepth+1, "OK (%s bits)\n", W); } return 0; } int find_sys_byte_order(const char *name, int logdepth, int fatal) { const char *test_c = NL "#include " NL "int main() {" NL " long int i = 8;" NL " char *s = (char *)&i;" NL " printf(\"%d\\n\", s[0]);" NL " return 0;" NL "}" NL; const char* test_c_blind_template = NL "#include " NL "#include " NL "#ifndef __BYTE_ORDER" NL "#error \"ERROR 1\"" NL "void void *;" NL "#endif" NL "#ifndef __%s_ENDIAN" NL "#error \"ERROR 2\"" NL "char char *;" NL "#endif" NL "#if __BYTE_ORDER != __%s_ENDIAN" NL "#error \"ERROR 3\"" NL "int int *;" NL "#endif" NL "int main() {" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; const char *key = "sys/byte_order"; const char *endians1[] = { "LITTLE", "BIG", NULL }; const char *endians2[] = { "LSB", "MSB", NULL }; int index; char test_c_blind[1024]; char *end; const char *W; char *out = NULL; int w; require("cc/cc", logdepth, fatal); report("Checking for byte order... "); logprintf(logdepth, "find_sys_byte_order: trying to find byte order...\n"); logdepth++; if ((!isblind(db_cwd)) && compile_run(logdepth, test_c, NULL, NULL, NULL, &out) == 0) { w = strtol(out, &end, 10); if (((*end != '\0') && (*end != '\n') && (*end != '\r')) || ((w != 0) && (w != 8))) { report("FAILED (test code failed)\n"); logprintf(logdepth+1, "FAILED: returned '%s' which is not a valid decimal number (at '%s')\n", out, end); return 1; } if (w == 0) W = "MSB"; else W = "LSB"; report("OK (%s first)\n", W); put("sys/byte_order", W); logprintf(logdepth+1, "OK (%s first)\n", W); return 0; } for (index=0; endians1[index]!=NULL; ++index) { sprintf(test_c_blind, test_c_blind_template, endians1[index], endians1[index]); if (compile_run(logdepth, test_c_blind, NULL, NULL, NULL, NULL) == 0) { W = endians2[index]; report("OK (%s first)\n", W); put(key, W); return 0; } } report("FAILED (cannot determine byte order, you must supply it)\n"); return try_fail(logdepth, key); } static int test_shell_eats_backslash(int logdepth) { char *test = "echo c:\\n"; char *out; logprintf(logdepth, "testing if shell eats \\...\n"); run_shell(logdepth+1, test, &out); if (out == NULL) { logprintf(logdepth+1, "oops, couldn't run shell?! (returned NULL)\n"); report("ERROR: shell fails."); abort(); } if (out[2] == '\\') { logprintf(logdepth, "shell does NOT eat \\...\n"); put("sys/shell_eats_backslash", sfalse); free(out); return 0; } free(out); logprintf(logdepth, "shell eats \\...\n"); put("sys/shell_eats_backslash", strue); return 1; } static int try_get_cwd(int logdepth, const char *cmd) { char *cwd, *end; run_shell(logdepth+1, cmd, &cwd); if (cwd != NULL) { end = strpbrk(cwd, "\r\n"); if (end != NULL) *end = '\0'; if (*cwd != '\0') { end = cwd + strlen(cwd) - 1; while((*end == ' ') || (*end == '\t')) { *end = '\0'; end--; } put("sys/tmp", cwd); /* ugly hack for win32: paths there start as c:\ */ if ((cwd[1] == ':') && (cwd[2] == '\\')) append("sys/tmp", "\\"); else append("sys/tmp", "/"); logprintf(logdepth, "cwd is '%s'\n", get("sys/tmp")); free(cwd); return 1; } else free(cwd); } return 0; } static int try_tmp(int logdepth) { char *fn; logprintf(logdepth, "validating temp dir '%s'\n", get("sys/tmp")); fn = tempfile_new_noabort(""); if (fn != NULL) { unlink(fn); free(fn); logprintf(logdepth, "temp dir works!\n"); return 1; } logprintf(logdepth, "temp dir fails\n"); return 0; } /* test temp dir with all sort of workarounds */ static int try_tmp_all(int logdepth) { const char *tmp, *si; char c; char *t, *so, *old_tmp; int eats, n; tmp = get("sys/tmp"); /* path must end in path separator */ c = tmp[strlen(tmp)-1]; if ((c != '/') && (c != '\\')) { append("sys/tmp", "/"); tmp = get("sys/tmp"); } logprintf(logdepth, "trying detected temp dir '%s'\n", tmp); if (try_tmp(logdepth+1)) return 1; /* try msys-on-windows hack: if path starts with /d/something, try d:/ instead */ if ((tmp[0] == '/') && (isalpha(tmp[1])) && (tmp[2] == '/')) { /* for the next test we shouldn't use our half-detected tmp path but go with . */ old_tmp = strclone(tmp); put("sys/tmp", ""); eats = istrue(get("sys/shell_eats_backslash")); tmp = old_tmp; logprintf(logdepth, "tmp2='%s' eats=%d\n", tmp, eats); t = malloc(strlen(tmp) * 2); t[0] = tmp[1]; t[1] = ':'; for(si = tmp + 2, so = t + 2; *si != '\0'; si++, so++) { if (*si == '/') { *so = '\\'; if (eats) { for(n = 0; n < 3; n++) { so++; *so = '\\'; } } } else *so = *si; } *so = '\0'; free(old_tmp); logprintf(logdepth, "trying windows fix: '%s'\n", t); put("sys/tmp", t); free(t); if (try_tmp(logdepth+1)) { if (eats) put("sys/path_sep", "\\\\\\\\"); else put("sys/path_sep", "\\"); return 1; } tmp = get("sys/tmp"); } /* fail. Set back tmp to empty so next command has a chance to run */ put("sys/tmp", ""); return 0; } int find_tmp(const char *name, int logdepth, int fatal) { const char *usertmp; if (in_cross_target) { report("Temp dir for cross compilation target is the same as for host..."); logprintf(logdepth, "Copying temp dir from host to target\n"); require("/host/sys/tmp", logdepth, fatal); usertmp = get("/host/sys/tmp"); if (usertmp == NULL) { report("Host temp dir not found.\n"); logprintf(logdepth, "Host temp dir not found.\n"); return 1; } put("sys/tmp", usertmp); return 0; } /* we need shell for later tests; do this detection in . */ put("sys/tmp", ""); require("sys/shell", logdepth, fatal); put("sys/path_sep", "/"); report("Detecting temp dir..."); logprintf(logdepth, "Finding temp dir (current working directory)...\n"); usertmp = get("/arg/sys/tmp"); /* . as tmp would fail for commands including a "cd" - this would cause temporary files left in the target dir. We start out with empty string (which is ., but on windows ./ would fail), and run pwd (without cd) to find out the current directory (as getcwd() is not portable). If pwd fails, we stay with ./ */ put("sys/tmp", ""); /* we need to know about shell backslash problem regardless of how we end up with tmp - currently tmp is ., where the test could run safely */ test_shell_eats_backslash(logdepth+1); /* Special case: cross-compilation with emulator; we can not assume the emulator uses the same paths as the host system, while we mix accessing files from host and emu. If we stay in ., both emulator and host system should be (more or less) happy. */ if (istarget(db_cwd) && iscross) { if (usertmp == NULL) { report("using temp dir . for cross-compilation\n"); logprintf(logdepth, "staying with . for cross-compilation\n"); } else { put("sys/tmp", usertmp); report("using user supplied temp dir '%s' for cross-compilation\n", usertmp); logprintf(logdepth, "using user supplied temp dir '%s' for cross-compilation\n", usertmp); } return 0; } if ((usertmp != NULL)) put("sys/tmp", usertmp); if ( ((usertmp != NULL) && (try_tmp_all(logdepth+2))) || /* try user supplied temp dir */ ((try_get_cwd(logdepth+1, "pwd")) && (try_tmp_all(logdepth+2))) || /* try pwd for finding out cwd */ ((try_get_cwd(logdepth+1, "echo %cd%") && (try_tmp_all(logdepth+2))))) { /* try windows-specific way for finding out cwd */ report(" validated %s\n", get("sys/tmp")); logprintf(logdepth, "Detected temp dir '%s'\n", get("sys/tmp")); return 0; } put("sys/tmp", ""); report("using temp dir fallback .\n"); logprintf(logdepth, "all temp directories failed, using . as tmp\n"); return 0; } int test_shell(const char *shell, int logdepth, int quote) { char *test = "echo hello"; char *cmd; char *out; char *q; if (quote) q = "\""; else q = ""; logprintf(logdepth, "testing '%s' as shell\n", shell); cmd = malloc(strlen(test) + strlen(shell) + 8); sprintf(cmd, "%s %s%s%s", shell, q, test, q); run(logdepth+1, cmd, &out); free(cmd); if ((out != NULL) && (strncmp(out, "hello", 5) == 0)) { put("sys/shell", shell); if (quote) put("sys/shell_needs_quote", strue); else put("sys/shell_needs_quote", sfalse); logprintf(logdepth, "accepted.\n"); free(out); return 1; } logprintf(logdepth, "refused.\n"); free(out); return 0; } static int find_shell_escape(const char *name, int logdepth, int fatal, const char *shell) { char cmdline[256]; char **t; char *tests[] = { "\\", "\\ {}&;|", "^", "^ &", NULL, NULL }; (void) fatal; /* not used */ (void) shell; /* not used */ report("Looking for a shell escape character... "); logprintf(logdepth, "finding shell escape character...\n"); for(t = tests; *t != NULL; t += 2) { char *s, *end, *out, *start; strcpy(cmdline, "echo "); end = cmdline+5; for(s = t[1]; *s != '\0'; s++) { *end++ = *t[0]; *end++ = *s; } *end = '\0'; run(logdepth+1, cmdline, &out); if (out != NULL) { int res; if (*out == '\"') /* wine likes to wrap the output in quotes for some reason */ start = out+1; else start = out; res = strncmp(start, t[1], strlen(t[1])); free(out); if (res == 0) { report("found: '%s'\n", t[0]); logprintf(logdepth, "found shell escape char '%s'\n", t[0]); put("sys/shell_escape_char", t[0]); return 0; } } } report("NOT FOUND\n"); logprintf(logdepth, "shell escape character not found\n"); return 1; } int find_shell(const char *name, int logdepth, int fatal) { const char *shells[] = { "/bin/sh -c", "/bin/bash -c", "bash -c", "cmd.exe /c", "sh -c", "/bin/dash -c", "dash -c", "/bin/ksh -c", "ksh -c", NULL }; const char **s; if (cross_blind) { const char *shell = get("/arg/sys/target-shell"); if (shell == NULL) { report("Need to specify sys/target-shell in blind cross compiling mode, because the shell cannot be detected (note: scconfig will not attempt to run the target shell)\n"); exit(1); } put("sys/shell", shell); report("Blind cross compiling: accepting '%s' as shell\n", shell); logprintf(logdepth, "Blind cross compiling: accepting '%s' as shell\n", shell); return 0; } report("Looking for a shell... "); logprintf(logdepth, "finding a shell\n"); for(s = shells; *s != NULL; s++) { if ((test_shell(*s, logdepth+1, 0)) || (test_shell(*s, logdepth+1, 1))) { report("%s\n", *s); logprintf(logdepth, "found a shell '%s', need quote: %s\n", *s, get("sys/shell_needs_quote")); return find_shell_escape(name, logdepth, fatal, *s); } } report("NOT FOUND\n"); logprintf(logdepth, "shell not found\n"); return 1; } xschem-2.8.1/scconfig/src/default/lib_compile.c0000644000175100017510000001711513246545247017662 0ustar svnsvn/* scconfig - library functions for compiling and running test code Copyright (C) 2009 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include #include #include #include "log.h" #include "libs.h" #include "db.h" #include "dep.h" /* #define KEEP_TEST_SRCS */ int cross_blind = 0; static char *clone_flags(const char *input, const char *node) { char *output; const char *s; int len; if (input != NULL) { if (*input == '+') { s = get(node); if (s != NULL) { len = strlen(s); output = malloc(len + strlen(input) + 4); memcpy(output, s, len); output[len] = ' '; strcpy(output + len + 1, input + 1); } else output = strclone(input); } else output = strclone(input); } else { s = get(node); if (s != NULL) output = strclone(s); else output = strclone(""); } return output; } int compile_file_raw(int logdepth, const char *fn_input, char **fn_output, const char *cc, const char *cflags, const char *ldflags) { char cmd[2048]; char *cc_esc, *fn_input_esc, *fn_output_esc, *temp_out_esc, *temp_out; int ret; temp_out = tempfile_new(".out"); if (*fn_output == NULL) *fn_output = tempfile_new(get("sys/ext_exe")); else *fn_output = tempfile_new(*fn_output); unlink(*fn_output); cc_esc = shell_escape_dup(cc == NULL ? get("cc/cc") : cc); fn_input_esc = shell_escape_dup(fn_input); fn_output_esc = shell_escape_dup(*fn_output); temp_out_esc = shell_escape_dup(temp_out); sprintf(cmd, "%s \"%s %s %s %s -o %s 2>&1\" >%s", get("/host/sys/shell"), cc_esc, cflags, fn_input_esc, ldflags, fn_output_esc, temp_out_esc); free(cc_esc); free(fn_input_esc); free(fn_output_esc); free(temp_out_esc); logprintf(logdepth, "compile: '%s'\n", cmd); ret = system(cmd); log_merge(logdepth + 1, temp_out); #ifndef KEEP_TEST_SRCS unlink(temp_out); #endif free(temp_out); logprintf(logdepth, "compile result: %d\n", ret); return ret; } int compile_file(int logdepth, const char *fn_input, char **fn_output, const char *cc, const char *cflags, const char *ldflags) { int ret; char *ldflags_, *cflags_; cflags_ = clone_flags(cflags, "cc/cflags"); ldflags_ = clone_flags(ldflags, "cc/ldflags"); ret = compile_file_raw(logdepth, fn_input, fn_output, cc, cflags_, ldflags_); free(cflags_); free(ldflags_); return ret; } int compile_code(int logdepth, const char *testcode, char **fn_output, const char *cc, const char *cflags, const char *ldflags) { char *temp_in; int ret; require("sys/ext_exe", logdepth, 1); assert(testcode != NULL); assert(fn_output != NULL); temp_in = tempfile_dump(testcode, ".c"); ret = compile_file(logdepth, temp_in, fn_output, cc, cflags, ldflags); #ifndef KEEP_TEST_SRCS unlink(temp_in); #endif free(temp_in); return ret; } int compile_code_raw(int logdepth, const char *testcode, char **fn_output, const char *cc, const char *cflags, const char *ldflags) { char *temp_in; int ret; require("sys/ext_exe", logdepth, 1); assert(testcode != NULL); assert(fn_output != NULL); temp_in = tempfile_dump(testcode, ".c"); ret = compile_file_raw(logdepth, temp_in, fn_output, cc, cflags, ldflags); #ifndef KEEP_TEST_SRCS unlink(temp_in); #endif free(temp_in); return ret; } char *shell_escape_dup(const char *in) { char *o, *out; const char *i; const char *esc = get("sys/shell_escape_char"); /* in the early phase, before detecting the shell, this happens */ if (esc == NULL) return strclone(in); out = malloc(strlen(in)*2+1); for(i = in, o = out; *i != '\0'; i++) { if (*i == *esc) { *o++ = *esc; } else if (!isalnum(*i)) { switch(*i) { case '/': case '_': case '-': case '.': break; default: *o++ = *esc; } } *o++ = *i; } *o = '\0'; return out; } int run(int logdepth, const char *cmd_, char **stdout_saved) { char *cmd; char *fn_out, *temp_out; char *fn_out_esc, *temp_out_esc; int ret; const char *emu; assert(cmd_ != NULL); /* blind cross compiling mode means we always assume success */ if (cross_blind) { if (stdout_saved != NULL) *stdout_saved = NULL; return 0; } emu = get("sys/emu"); /* emu == NULL means we need an emulator but we don't have one and we should pretend everything went well (and of course can't provide output.) */ if (emu == NULL) { if (stdout_saved != NULL) *stdout_saved = NULL; return 0; } /* emu == false means we need an emulator and we don't want to pretend -> fatal */ if (strcmp(emu, sfalse) == 0) { error("Trying to run unavailable emulator (db_cwd='%s')\n", db_cwd); abort(); } temp_out = tempfile_new(".out"); fn_out = tempfile_new(""); temp_out_esc = shell_escape_dup(temp_out); fn_out_esc = shell_escape_dup(fn_out); cmd = malloc(strlen(emu) + strlen(cmd_) + strlen(fn_out_esc) + strlen(temp_out_esc) + 32); sprintf(cmd, "%s %s >%s 2>>%s", emu, cmd_, fn_out_esc, temp_out_esc); free(temp_out_esc); free(fn_out_esc); logprintf(logdepth, "run: '%s'\n", cmd); ret = system(cmd); log_merge(logdepth + 1, temp_out); unlink(temp_out); free(temp_out); logprintf(logdepth, "run result: %d\n", ret); free(cmd); if (stdout_saved != NULL) { if (ret == 0) { *stdout_saved = load_file(fn_out); logprintf(logdepth, "stdout: '%s'\n", *stdout_saved); } else *stdout_saved = NULL; } unlink(fn_out); free(fn_out); return ret; } int run_shell(int logdepth, const char *cmd_, char **stdout_saved) { int ret; char *cmd, *cmd_esc; const char *emu; const char *shell; emu = get("sys/emulator"); if (emu == NULL) emu = ""; shell = get("sys/shell"); if (shell == NULL) { error("No shell was specified (db_cwd='%s')\n", db_cwd); abort(); } cmd_esc = shell_escape_dup(cmd_); cmd = malloc(strlen(emu) + strlen(shell) + strlen(cmd_esc) + 16); if (istrue(get("sys/shell_needs_quote"))) sprintf(cmd, "%s %s \"%s\"", emu, shell, cmd_); else sprintf(cmd, "%s %s %s", emu, shell, cmd_); free(cmd_esc); ret = run(logdepth, cmd, stdout_saved); free(cmd); return ret; } int compile_run(int logdepth, const char *testcode, const char *cc, const char *cflags, const char *ldflags, char **stdout_saved) { int ret; char *fn_output = NULL; ret = compile_code(logdepth+1, testcode, &fn_output, cc, cflags, ldflags); if (ret == 0) { char *fn_output_esc = shell_escape_dup(fn_output); ret = run(logdepth+1, fn_output_esc, stdout_saved); free(fn_output_esc); } if (fn_output != NULL) { unlink(fn_output); free(fn_output); } return ret; } int run_script(int logdepth, const char *interpreter, const char *script, const char *suffix, char **out) { char *temp, *cmd; int res; temp = tempfile_dump(script, suffix); cmd = malloc(strlen(temp) + strlen(interpreter) + 4); sprintf(cmd, "%s %s", interpreter, temp); res = run(logdepth, cmd, out); unlink(temp); free(temp); free(cmd); return res; } xschem-2.8.1/scconfig/src/default/dep.h0000644000175100017510000000154613272247000016143 0ustar svnsvn#include "ht.h" int is_dep_known(const char *name); int require(const char *name, int logdepth, int fatal); const char *dep_add(const char *name, int (*finder)(const char *name, int logdepth, int fatal)); void require_all(int fatal); /* Returns if dependency is a wildcard one (ending in / *) */ int is_dep_wild(const char *path); /* Almost 'basename': returns the last portion of the path, which may be '*'. Returns "" on error. */ const char *det_list_target(const char *path); /* Returns 1 if the user asked for detecting a feature; needtodo is the first argument passed to the detection function (the target the caller wants to get detected), cando is the output path of the test that the detector could do next. */ int asked_for(const char *cando, const char *needtodo); /* for internal use */ void dep_init(void); void dep_uninit(void); xschem-2.8.1/scconfig/src/default/ht.c0000644000175100017510000001335012750535606016011 0ustar svnsvn/* scconfig - hash tables Copyright (C) 2007, 2008, 2009 by Szabolcs Nagy This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include #include #include "libs.h" #include "ht.h" #define HT_MINSIZE 8 #define HT_MAXSIZE ((UINT_MAX >> 1U) + 1U) #define JUMP(i, j) i += j++ #define JUMP_FIRST(i, j) j = 1, i += j++ /* portable str hash */ #define HASH_INIT 0xbabeface static unsigned int keyhash(const char *key) { unsigned int a = HASH_INIT; while (*key) a += (a << 5) + *key++; return a; } /* fill threshold = 3/4 */ #define HT_LOG_THRES 2 static void checkfill(ht_t *ht) { if (ht->fill > ht->mask - (ht->mask >> HT_LOG_THRES) || ht->fill > ht->used << 2) ht_resize(ht, ht->used << (ht->used > 1U << 15 ? 1 : 2)); } static ht_t *ht_init(ht_t *ht, int isstr) { ht->mask = HT_MINSIZE - 1; ht->fill = 0; ht->used = 0; ht->isstr = isstr; ht->table = calloc(ht->mask + 1, sizeof(ht_entry_t)); ht->refcount = 1; return ht; } static ht_t *ht_uninit(ht_t *ht) { ht_entry_t *entry; for (entry = ht->table; entry != ht->table + ht->mask + 1; entry++) if (ht_isused(entry)) { if (ht->isstr) free(entry->value); free(entry->key); } free(ht->table); return ht; } ht_t *ht_alloc(int isstr) { ht_t *ht; ht = malloc(sizeof(ht_t)); return ht_init(ht, isstr); } void ht_free(ht_t *ht) { ht_uninit(ht); free(ht); } ht_t *ht_clear(ht_t *ht) { ht_uninit(ht); return ht_init(ht, ht->isstr); } /* one lookup function to rule them all */ static ht_entry_t *ht_lookup(ht_t *ht, const char *key, unsigned int hash) { unsigned int mask; unsigned int i; unsigned int j; ht_entry_t *table; ht_entry_t *entry; ht_entry_t *free_entry; mask = ht->mask; i = hash; table = ht->table; assert(ht->table); entry = table + (i & mask); if (ht_isempty(entry) || !strcmp(entry->key, key)) return entry; /* free_entry: first deleted entry for insert */ free_entry = ht_isdeleted(entry) ? entry : NULL; assert(ht->fill <= ht->mask); for (JUMP_FIRST(i, j); ; JUMP(i, j)) { entry = table + (i & mask); if (ht_isempty(entry)) return (free_entry == NULL) ? entry : free_entry; if (entry->hash == hash && !strcmp(entry->key, key)) return entry; if (ht_isdeleted(entry) && free_entry == NULL) free_entry = entry; } } /* for resize: no deleted entries in ht, entry->key is not in ht, no strdup */ static void cleaninsert(ht_t *ht, const ht_entry_t *entry) { unsigned int i; unsigned int j; ht_entry_t *newentry; i = entry->hash; newentry = ht->table + (i & ht->mask); if (!ht_isempty(newentry)) for (JUMP_FIRST(i, j); !ht_isempty(newentry); JUMP(i, j)) newentry = ht->table + (i & ht->mask); ++ht->fill; ++ht->used; memcpy(newentry, entry, sizeof(ht_entry_t)); } ht_t *ht_resize(ht_t *ht, unsigned int hint) { unsigned int newsize; unsigned int oldused; ht_entry_t *oldtable, *newtable, *entry; oldused = ht->used; if (hint < oldused << 1) hint = oldused << 1; assert(hint <= HT_MAXSIZE && hint > oldused); for (newsize = HT_MINSIZE; newsize < hint; newsize <<= 1); newtable = calloc(newsize, sizeof(ht_entry_t)); oldtable = ht->table; ht->mask = newsize - 1; ht->fill = 0; ht->used = 0; ht->table = newtable; for (entry = oldtable; oldused > 0; ++entry) if (ht_isused(entry)) { --oldused; cleaninsert(ht, entry); } free(oldtable); return ht; } void *ht_get(ht_t *ht, const char *key) { ht_entry_t *entry; entry = ht_lookup(ht, key, keyhash(key)); return ht_isused(entry) ? entry->value : NULL; } void *ht_insert(ht_t *ht, const char *key, void *value) { unsigned int hash; ht_entry_t *entry; hash = keyhash(key); entry = ht_lookup(ht, key, hash); if (ht_isused(entry)) return entry->value; if (ht_isempty(entry)) ++ht->fill; ++ht->used; entry->hash = hash; entry->key = strclone(key); entry->value = ht->isstr ? strclone(value) : value; checkfill(ht); return NULL; } const char *ht_set(ht_t *ht, const char *key, void *value) { unsigned int hash; ht_entry_t *entry; char *k; hash = keyhash(key); entry = ht_lookup(ht, key, hash); if (ht_isused(entry)) { if (ht->isstr) { free(entry->value); entry->value = strclone(value); } else entry->value = value; return entry->key; } if (ht_isempty(entry)) ++ht->fill; ++ht->used; entry->hash = hash; entry->key = k = strclone(key); entry->value = ht->isstr ? strclone(value) : value; checkfill(ht); return k; } const char *ht_del(ht_t *ht, const char *key) { ht_entry_t *entry; entry = ht_lookup(ht, key, keyhash(key)); if (!ht_isused(entry)) return NULL; --ht->used; free(entry->key); if (ht->isstr) free(entry->value); entry->key = ht_deleted_key; return ht_deleted_key; } ht_entry_t *ht_first(const ht_t *ht) { ht_entry_t *entry = 0; if (ht->used) for (entry = ht->table; !ht_isused(entry); ++entry); return entry; } ht_entry_t *ht_next(const ht_t *ht, ht_entry_t *entry) { while (++entry != ht->table + ht->mask + 1) if (ht_isused(entry)) return entry; return 0; } xschem-2.8.1/scconfig/src/default/regex.c0000644000175100017510000003023113325620424016475 0ustar svnsvn/* * regex - Regular expression pattern matching and replacement * * By: Ozan S. Yigit (oz) * Dept. of Computer Science * York University * * These routines are the PUBLIC DOMAIN equivalents of regex * routines as found in 4.nBSD UN*X, with minor extensions. * * These routines are derived from various implementations found * in software tools books, and Conroy's grep. They are NOT derived * from licensed/restricted software. * For more interesting/academic/complicated implementations, * see Henry Spencer's regexp routines, or GNU Emacs pattern * matching module. * * const correctness patch by Tibor 'Igor2' Palinkas in 2009..2010 * new subs code by Tibor 'Igor2' Palinkas in 2015 */ #include #include #include "regex.h" #define MAXNFA 1024 #define MAXTAG 10 #define OKP 1 #define NOP 0 #define CHR 1 #define ANY 2 #define CCL 3 #define BOL 4 #define EOL 5 #define BOT 6 #define EOT 7 #define BOW 8 #define EOW 9 #define REF 10 #define CLO 11 #define END 0 /* * The following defines are not meant to be changeable. * They are for readability only. */ #define MAXCHR 128 #define CHRBIT 8 #define BITBLK MAXCHR/CHRBIT #define BLKIND 0170 #define BITIND 07 #define ASCIIB 0177 #ifdef NO_UCHAR typedef char CHAR; #else typedef unsigned char CHAR; #endif static int tagstk[MAXTAG]; /* subpat tag stack..*/ static CHAR nfa[MAXNFA]; /* automaton.. */ static int sta = NOP; /* status of lastpat */ static CHAR bittab[BITBLK]; /* bit table for CCL */ /* pre-set bits... */ static CHAR bitarr[] = {1,2,4,8,16,32,64,128}; static void chset(CHAR c) { bittab[(CHAR) ((c) & BLKIND) >> 3] |= bitarr[(c) & BITIND]; } #define badpat(x) (*nfa = END, x) #define store(x) *mp++ = x char * re_comp(const char *pat) { register const char *p; /* pattern pointer */ register CHAR *mp=nfa; /* nfa pointer */ register CHAR *lp; /* saved pointer.. */ register CHAR *sp=nfa; /* another one.. */ register int tagi = 0; /* tag stack index */ register int tagc = 1; /* actual tag count */ register int n; register CHAR mask; /* xor mask -CCL/NCL */ int c1, c2; if (!pat || !*pat) { if (sta) return 0; else return badpat("No previous regular expression"); } sta = NOP; for (p = pat; *p; p++) { lp = mp; switch(*p) { case '.': /* match any char.. */ store(ANY); break; case '^': /* match beginning.. */ if (p == pat) store(BOL); else { store(CHR); store(*p); } break; case '$': /* match endofline.. */ if (!*(p+1)) store(EOL); else { store(CHR); store(*p); } break; case '[': /* match char class..*/ store(CCL); if (*++p == '^') { mask = 0377; p++; } else mask = 0; if (*p == '-') /* real dash */ chset(*p++); if (*p == ']') /* real brac */ chset(*p++); while (*p && *p != ']') { if (*p == '-' && *(p+1) && *(p+1) != ']') { p++; c1 = *(p-2) + 1; c2 = *p++; while (c1 <= c2) chset((CHAR)c1++); } #ifdef EXTEND else if (*p == '\\' && *(p+1)) { p++; chset(*p++); } #endif else chset(*p++); } if (!*p) return badpat("Missing ]"); for (n = 0; n < BITBLK; bittab[n++] = (char) 0) store(mask ^ bittab[n]); break; case '*': /* match 0 or more.. */ case '+': /* match 1 or more.. */ if (p == pat) return badpat("Empty closure"); lp = sp; /* previous opcode */ if (*lp == CLO) /* equivalence.. */ break; switch(*lp) { case BOL: case BOT: case EOT: case BOW: case EOW: case REF: return badpat("Illegal closure"); default: break; } if (*p == '+') for (sp = mp; lp < sp; lp++) store(*lp); store(END); store(END); sp = mp; while (--mp > lp) *mp = mp[-1]; store(CLO); mp = sp; break; case '\\': /* tags, backrefs .. */ switch(*++p) { case '(': if (tagc < MAXTAG) { tagstk[++tagi] = tagc; store(BOT); store(tagc++); } else return badpat("Too many \\(\\) pairs"); break; case ')': if (*sp == BOT) return badpat("Null pattern inside \\(\\)"); if (tagi > 0) { store(EOT); store(tagstk[tagi--]); } else return badpat("Unmatched \\)"); break; case '<': store(BOW); break; case '>': if (*sp == BOW) return badpat("Null pattern inside \\<\\>"); store(EOW); break; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': n = *p-'0'; if (tagi > 0 && tagstk[tagi] == n) return badpat("Cyclical reference"); if (tagc > n) { store(REF); store(n); } else return badpat("Undetermined reference"); break; #ifdef EXTEND case 'b': store(CHR); store('\b'); break; case 'n': store(CHR); store('\n'); break; case 'f': store(CHR); store('\f'); break; case 'r': store(CHR); store('\r'); break; case 't': store(CHR); store('\t'); break; #endif default: store(CHR); store(*p); } break; default : /* an ordinary char */ store(CHR); store(*p); break; } sp = lp; } if (tagi > 0) return badpat("Unmatched \\("); store(END); sta = OKP; return 0; } static const char *bol; const char *bopat[MAXTAG]; const char *eopat[MAXTAG]; static const char *pmatch(const char *, CHAR *, int *); /* * re_exec: * execute nfa to find a match. * * special cases: (nfa[0]) * BOL * Match only once, starting from the * beginning. * CHR * First locate the character without * calling pmatch, and if found, call * pmatch for the remaining string. * END * re_comp failed, poor luser did not * check for it. Fail fast. * * If a match is found, bopat[0] and eopat[0] are set * to the beginning and the end of the matched fragment, * respectively. * */ int re_exec(const char *lp) { register CHAR c; register const char *ep = 0; register CHAR *ap = nfa; int score = 1; bol = lp; bopat[0] = 0; bopat[1] = 0; bopat[2] = 0; bopat[3] = 0; bopat[4] = 0; bopat[5] = 0; bopat[6] = 0; bopat[7] = 0; bopat[8] = 0; bopat[9] = 0; switch(*ap) { case BOL: /* anchored: match from BOL only */ ep = pmatch(lp,ap, &score); break; case CHR: /* ordinary char: locate it fast */ c = *(ap+1); while (*lp && *lp != c) lp++; if (!*lp) /* if EOS, fail, else fall thru. */ return 0; default: /* regular matching all the way. */ #ifdef OLD while (*lp) { if ((ep = pmatch(lp,ap, &score))) break; lp++; } #else /* match null string */ do { if ((ep = pmatch(lp,ap, &score))) break; } while (*lp++); #endif break; case END: /* munged automaton. fail always */ return 0; } if (!ep) return 0; bopat[0] = lp; eopat[0] = ep; return score; } /* * pmatch: internal routine for the hard part * * This code is partly snarfed from an early grep written by * David Conroy. The backref and tag stuff, and various other * innovations are by oz. * * special case optimizations: (nfa[n], nfa[n+1]) * CLO ANY * We KNOW .* will match everything up to the * end of line. Thus, directly go to the end of * line, without recursive pmatch calls. As in * the other closure cases, the remaining pattern * must be matched by moving backwards on the * string recursively, to find a match for xy * (x is ".*" and y is the remaining pattern) * where the match satisfies the LONGEST match for * x followed by a match for y. * CLO CHR * We can again scan the string forward for the * single char and at the point of failure, we * execute the remaining nfa recursively, same as * above. * * At the end of a successful match, bopat[n] and eopat[n] * are set to the beginning and end of subpatterns matched * by tagged expressions (n = 1 to 9). * */ #ifndef re_fail extern void re_fail(char *, unsigned char); #endif /* * character classification table for word boundary operators BOW * and EOW. the reason for not using ctype macros is that we can * let the user add into our own table. see re_modw. This table * is not in the bitset form, since we may wish to extend it in the * future for other character classifications. * * TRUE for 0-9 A-Z a-z _ */ static CHAR chrtyp[MAXCHR] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; #define inascii(x) (0177&(x)) #define iswordc(x) chrtyp[inascii(x)] #define isinset(x,y) ((x)[((y)&BLKIND)>>3] & bitarr[(y)&BITIND]) /* * skip values for CLO XXX to skip past the closure */ #define ANYSKIP 2 /* [CLO] ANY END ... */ #define CHRSKIP 3 /* [CLO] CHR chr END ... */ #define CCLSKIP 18 /* [CLO] CCL 16bytes END ... */ static const char * pmatch(const char *lp, CHAR *ap, int *score) { register int op, c, n; register const char *e; /* extra pointer for CLO */ register const char *bp; /* beginning of subpat.. */ register const char *ep; /* ending of subpat.. */ const char *are; /* to save the line ptr. */ while ((op = *ap++) != END) switch(op) { case CHR: if (*lp++ != *ap++) return 0; (*score) += 100; break; case ANY: if (!*lp++) return 0; (*score)++; break; case CCL: c = *lp++; if (!isinset(ap,c)) return 0; ap += BITBLK; (*score) += 2; break; case BOL: if (lp != bol) return 0; (*score) += 10; break; case EOL: if (*lp) return 0; (*score) += 10; break; case BOT: bopat[*ap++] = lp; break; case EOT: eopat[*ap++] = lp; break; case BOW: if ((lp!=bol && iswordc(lp[-1])) || !iswordc(*lp)) return 0; (*score) += 5; break; case EOW: if (lp==bol || !iswordc(lp[-1]) || iswordc(*lp)) return 0; (*score) += 5; break; case REF: n = *ap++; bp = bopat[n]; ep = eopat[n]; while (bp < ep) { if (*bp++ != *lp++) return 0; (*score) += 2; } break; case CLO: are = lp; switch(*ap) { case ANY: while (*lp) lp++; n = ANYSKIP; (*score)++; break; case CHR: c = *(ap+1); while (*lp && c == *lp) lp++; n = CHRSKIP; (*score) += 100; break; case CCL: while ((c = *lp) && isinset(ap+1,c)) lp++; n = CCLSKIP; (*score) += 2; break; default: re_fail("closure: bad nfa.", *ap); return 0; } ap += n; while (lp >= are) { e = pmatch(lp, ap, score); if (e) return e; --lp; } return 0; default: re_fail("re_exec: bad nfa.", op); return 0; } return lp; } /* * re_modw: * add new characters into the word table to change re_exec's * understanding of what a word should look like. Note that we * only accept additions into the word definition. * * If the string parameter is 0 or null string, the table is * reset back to the default containing A-Z a-z 0-9 _. [We use * the compact bitset representation for the default table] */ static CHAR deftab[16] = { 0, 0, 0, 0, 0, 0, 0377, 003, 0376, 0377, 0377, 0207, 0376, 0377, 0377, 007 }; void re_modw(char *s) { register int i; if (!s || !*s) { for (i = 0; i < MAXCHR; i++) if (!isinset(deftab,i)) iswordc(i) = 0; } else while(*s) iswordc(*s++) = 1; } /* Substitute the matching part in the last re_exec call with sub. The result is returned in a newly allocated string. */ char *re_subs_dup(char *sub) { char *dst; const char *end; int l1, l2, l3; end = bol + strlen(bol); l1 = bopat[0] - bol; if (sub != NULL) l2 = strlen(sub); else l2 = 0; l3 = end - eopat[0]; if (l3 < 0) l3 = 0; dst = malloc(l1+l2+l3+1); memcpy(dst, bol, l1); if (l2 != 0) memcpy(dst+l1, sub, l2); memcpy(dst+l1+l2, eopat[0], l3+1); return dst; } xschem-2.8.1/scconfig/src/default/dep.c0000644000175100017510000001302013272247000016124 0ustar svnsvn/* scconfig - dependencies Copyright (C) 2009 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include "dep.h" #include "db.h" #include "log.h" #include "libs.h" typedef struct { int (*fn)(const char *name, int logdepth, int fatal); } fn_wrap_t; static ht_t *deps = NULL; /* find name_ and decide if it was a wildcard request; NOTE: there are requests and servers, both can be wildcard independently. - if a request ends with a / *, it is an explicit wildcard request (*wild=1) - if a request names a "directory" that is wildcard-server, that's a wildcard request (*wild=1) - else the request is a normal request (*wild=0). For normal requests, a required node was explicitly named; if that node is not created by the detection function, that's a failure. For wildcard requests we don't look for any specific node to be created. TODO: we may still check if at least the directory is created */ fn_wrap_t *get_wrap(const char *name_, int *wild, int *missing) { fn_wrap_t *w; char *name, *sep; int len; len = strlen(name_); *wild = name_[len-1] == '*'; if (*wild) { char *pres; pres = malloc(len+16); memcpy(pres, name_, len-1); strcpy(pres+len-1, "presents"); *missing = get(pres) == NULL; if (*missing) { /* if there's no /presents, it may be a non-directory node with an actual non-empty string value */ const char *val; pres[len-2] = '\0'; val = get(pres); if (val != NULL) *missing = !strlen(val); } free(pres); if (!(*missing)) /* already detected, won't be detected again */ return NULL; } *missing = 1; /* try full match first */ w = ht_get(deps, name_); if (w != NULL) return w; /* try substituting the last part of the path with * for wildcard matches */ name = malloc(len+3); /* worst case: ends in a / and we need to append *\0; allocate a bit more */ memcpy(name, name_, len+1); /* make a copy we can modify */ if (name[len-1] != '/') { name[len] = '/'; /* append a / - if name_ was a "directory", this will result in name/ * */ name[len+1] = '\0'; } *wild = 1; /* if we append a / *, then it's a wildcard request */ for(;;) { sep = str_rchr(name, '/'); if (sep == NULL) goto error; sep[1] = '*'; sep[2] = '\0'; w = ht_get(deps, name); if (w != NULL) { free(name); return w; } *sep = '\0'; *wild = 0; /* cutting back the second layer - not wildcard request anymore, but a request to a specific node served by a wildcard */ } /* no match, exit with error */ error:; *wild = 0; free(name); return NULL; } int require(const char *name, int logdepth, int fatal) { fn_wrap_t *w; int wild, missing; if (get(name) == NULL) { w = get_wrap(name, &wild, &missing); if (!missing) return 0; if ((w == NULL) || (w->fn == NULL)) { error("Node %s is required but I don't know how to detect it.\n", name); abort(); } logprintf(logdepth, "(Required node: '%s')\n", name); if (w->fn(name, logdepth+1, fatal) != 0) { if (fatal) { error("Node %s is required but provided detection callback fails to find that feature on that system.\n", name); abort(); } else { logprintf(logdepth, "(Feature not found, but it is not fatal)"); return 1; } } if ((!wild) && (get(name) == NULL)) { error("Node %s is required but provided detection callback didn't create it (looks like an internal error in scconfig). (db_cwd='%s')\n", name, db_cwd); abort(); } } return 0; } const char *dep_add(const char *name, int (*finder)(const char *name, int logdepth, int fatal)) { fn_wrap_t *w; w = malloc(sizeof(fn_wrap_t)); w->fn = finder; return ht_set(deps, name, w); } int asked_for(const char *cando, const char *needtodo) { int len; /* foo/bar/baz matches /foo/bar/baz */ if (strcmp(cando, needtodo) == 0) goto yes; len = strlen(needtodo); if (len == 0) return 0; /* foo/bar/baz matches /foo/bar/ * */ if ((needtodo[len-1] == '*') && (strncmp(cando, needtodo, len-1) == 0)) goto yes; return 0; yes:; /* asked for it, but have to see if it's already detected */ if (get(cando) != NULL) return 0; return 1; } int is_dep_wild(const char *path) { int len = strlen(path); if (len == 0) return 0; return (path[len-1] == '*'); } const char *det_list_target(const char *path) { const char *res; if (path == NULL) goto unk; res = strrchr(path, '/'); if (res == NULL) goto unk; return res + 1; unk:; return ""; } void dep_init(void) { deps = ht_resize(ht_alloc(0), 128); } void dep_uninit(void) { ht_free(deps); } int is_dep_known(const char *name) { return (ht_get(deps, name) != NULL); } void require_all(int fatal) { ht_entry_t *h; for(h = ht_first(deps); h != NULL; h = ht_next(deps, h)) require(h->key, 0, fatal); } xschem-2.8.1/scconfig/src/default/str.c0000644000175100017510000000677612750535606016224 0ustar svnsvn/* scconfig - non-standard string manipulation routines Copyright (C) 2009 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include char *strclone(const char *str) { int l; char *ret; if (str == NULL) return NULL; l = strlen(str)+1; ret = malloc(l); memcpy(ret, str, l); return ret; } #define SPACE(c) (((c) == '\r') || ((c) == '\n') || ((c) == '\t') || ((c) == ' ')) char *trim_left(char *str) { while(SPACE(*str)) str++; return str; } char *trim_right(char *str) { char *end; end = str + strlen(str) - 1; while((end >= str) && SPACE(*end)) { *end = '\0'; end--; } return str; } char *strip(char *str) { return trim_left(trim_right(str)); } char *str_chr(char *str, char c) { char *s; for(s = str; *s != '\0'; s++) if (*s == c) return s; return NULL; } char *str_rchr(char *str, char c) { char *s, *last; last = NULL; for(s = str; *s != '\0'; s++) if (*s == c) last = s; return last; } char *str_subsn(const char *str) { char *out, *o; const char *i; if (str == NULL) return strclone(""); o = out = malloc(strlen(str)+1); for(i = str; *i != '\0'; i++, o++) { if ((i[0] == '\\') && (i[1] == 'n')) { i++; *o = '\n'; } else *o = *i; } *o = '\0'; return out; } char *str_concat(const char *sep, ...) { # define CONCAT_MAX 64 int len[CONCAT_MAX]; const char *str[CONCAT_MAX]; int n, v, sum, sl; char *out, *o; va_list ap; va_start(ap, sep); if (sep == NULL) sep = ""; /* load all strings into an array, measure their lengths */ sum = 0; for(v = 0; ;v++) { if (v >= CONCAT_MAX) { fprintf(stderr, "Internal error: str_concat got more strings than CONCAT_MAX\n"); abort(); } str[v] = va_arg(ap, const char *); if (str[v] == NULL) { len[v] = 0; break; } len[v] = strlen(str[v]); sum += len[v]; } sl = strlen(sep); sum += (v-1) * sl + 1; /* + a sep between each two strings and a terminator at the end */ o = out = malloc(sum); for(n = 0; n < v; n++) { if ((n > 0) && (sl > 0)) { memcpy(o, sep, sl); o += sl; } if (len[n] > 0) { memcpy(o, str[n], len[n]); o += len[n]; } } *o = '\0'; va_end(ap); return out; } char *esc_interpret(const char *str) { char *out, *si, *so; out = strclone(str); /* replace (interpret) \ sequences in seq */ for(si = so = out; *si != '\0'; si++,so++) { if (si[0] == '\\') { switch(si[1]) { case 'n': *so = '\n'; break; case 't': *so = '\t'; break; case 's': *so = ' '; break; case '\\': *so = '\\'; break; } si++; } else *so = *si; } *so = '\0'; return out; } int chr_inset(char c, const char *set) { while (*set != '\0') { if (c == *set) return 1; set++; } return 0; } xschem-2.8.1/scconfig/src/default/find_io.c0000644000175100017510000001202313371171224016771 0ustar svnsvn/* scconfig - detect I/O features of the system Copyright (C) 2010 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include #include "libs.h" #include "log.h" #include "db.h" #include "dep.h" int find_io_pipe(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "int main() {" NL " int fd[2];" NL " if (pipe(fd) == 0)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for pipe(2)... "); logprintf(logdepth, "find_io_pipe: trying to find pipe(2)...\n"); logdepth++; if (try_icl(logdepth, "libs/io/pipe", test_c, NULL, NULL, NULL)) return 0; return try_fail(logdepth, "libs/io/pipe"); } int find_io_dup2(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "int main() {" NL " int fd;" NL " if (dup2(1, 4) == 4)" NL " write(4, \"OK\\n\", 3); " NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for dup2(2)... "); logprintf(logdepth, "find_io_dup2: trying to find dup2(2)...\n"); logdepth++; if (try_icl(logdepth, "libs/io/dup2", test_c, NULL, NULL, NULL)) return 0; return try_fail(logdepth, "libs/io/dup2"); } int find_io_fileno(const char *name, int logdepth, int fatal) { char test_c[256]; char *test_c_ = NL "#include " NL "int main() {" NL no_implicit(int, "%s", "%s") NL " if (%s(stdout) >= 0)" NL " puts(\"OK\"); " NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for fileno(3)... "); logprintf(logdepth, "find_io_fileno: trying to find fileno(3)...\n"); logdepth++; /* UNIX */ sprintf(test_c, test_c_, "fileno", "fileno", "fileno"); if (try_icl(logdepth, "libs/io/fileno", test_c, "#include \n", NULL, NULL)) { put("libs/io/fileno/call", "fileno"); return 0; } sprintf(test_c, test_c_, "fileno", "fileno", "fileno"); if (try_icl(logdepth, "libs/io/fileno", test_c, "#define _XOPEN_SOURCE\n#include \n", NULL, NULL)) { put("libs/io/fileno/call", "fileno"); return 0; } /* windows */ sprintf(test_c, test_c_, "_fileno", "_fileno", "_fileno"); if (try_icl(logdepth, "libs/io/fileno", test_c, "#include \n", NULL, NULL)) { put("libs/io/fileno/call", "_fileno"); return 0; } return try_fail(logdepth, "libs/io/fileno"); } int find_io_lseek(const char *name, int logdepth, int fatal) { #define NODE "libs/io/lseek" char test_c[3256]; const char *test_c_template = NL "#include " NL "#include " NL "int main() {" NL " const char *filename = \"%s\";" NL no_implicit(int, "%s", "%s") NL " int fd = open(filename, O_WRONLY);" NL " if (write(fd, \"abc\", 3) == 3 && %s(fd, 1, SEEK_SET) == 1)" NL " puts(\"OK\"); " NL " return 0;" NL "}" NL; char *tmpf; const char *incs[] = {"#include ","#include ",NULL}; const char *fns[] = {"lseek", "_lseek", NULL}; const char **inc; const char **fn; require("cc/cc", logdepth, fatal); report("Checking for lseek(2)... "); logprintf(logdepth, "find_io_lseek: trying to find lseek(2)...\n"); logdepth++; tmpf = tempfile_new(".psx"); for (inc = incs, fn = fns; *fn; ++inc, ++fn) { sprintf(test_c, test_c_template, tmpf, *fn, *fn, *fn); if (try_icl(logdepth, NODE, test_c, *inc, NULL, NULL)) { put(NODE "/call", *fn); return 0; } } return try_fail(logdepth, NODE); #undef NODE } int find_io_popen(const char *name, int logdepth, int fatal) { const char **i, *incs[] = {"#define _XOPEN_SOURCE", "#define _BSD_SOURCE", "#define _POSIX_C_SOURCE 2", NULL}; char *test_c = NL "#include " NL "#include " NL "int main() {" NL " FILE *f = popen(\"echo OK\", \"r\");" NL " char line[16];" NL " if (f == NULL) return 0;" NL " if (fgets(line, sizeof(line)-1, f) == NULL) return 0;" NL " puts(line);" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for popen(3)... "); logprintf(logdepth, "find_io_popen: trying to find popen(3)...\n"); logdepth++; for(i = incs; *i != NULL; i++) if (try_icl(logdepth, "libs/io/popen", test_c, *i, NULL, NULL)) return 0; return try_fail(logdepth, "libs/io/popen"); } xschem-2.8.1/scconfig/src/default/find_uname.c0000644000175100017510000002341613240634424017500 0ustar svnsvn/* scconfig - evaluate uname and classify the system Copyright (C) 2009 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include "regex.h" #include "log.h" #include "db.h" #include "libs.h" #include "dep.h" static void sys_unix(void) { put("sys/ext_exe", ""); put("sys/ext_dynlib", ".so"); put("sys/ext_stalib", ".a"); put("sys/ext_dynlib_native", ".so"); } static void sys_netbsd(void) { sys_unix(); put("cc/ldflags", "-Wl,-R/usr/pkg/lib -L/usr/pkg/lib"); /* TODO: is this the best way? */ } static void sys_win32dlc(void) { put("sys/ext_exe", ".exe"); put("sys/ext_dynlib", ".dlc"); put("sys/ext_stalib", ".a"); put("sys/ext_dynlib_native", ".dll"); } typedef void (*callback_t)(void); typedef struct { char *uname_regex; char *name; char *class; callback_t callback; } uname_t; typedef struct { char *file_name; char *name; char *class; callback_t callback; } magic_file_t; /* Guess system class by uname; class is informative, nothing important should depend on it. Order *does* matter */ uname_t unames[] = { {"[Nn]et[Bb][Ss][Dd]", "NetBSD", "UNIX", sys_netbsd}, {"[Ll]inux", "Linux", "UNIX", sys_unix}, {"[Bb][Ss][Dd]", "BSD", "UNIX", sys_unix}, {"SunOS", "SunOS", "UNIX", sys_unix}, {"OSF1", "OSF", "UNIX", sys_unix}, /* TODO: note the difference in cflags for debugging ("-ms -g") */ {"IRIX", "IRIX", "UNIX", sys_unix}, {"SunOS", "SunOS", "UNIX", sys_unix}, {"[Mm]inix", "Minix", "UNIX", sys_unix}, {"[Aa][Rr][Oo][Ss]", "Aros", "UNIX", sys_unix}, {"^Darwin", "MacOSX", "UNIX", sys_unix}, {"[Th]hreos", "Threos", "UNIX", sys_unix}, {"[Cc]ygwin", "cygwin", "WIN32", sys_win32dlc}, {"[Mm][Ii][Nn][Gg][Ww]", "mingw", "WIN32", sys_win32dlc}, {"win32", "win32", "WIN32", sys_win32dlc}, /* vanilla windows */ {NULL, NULL, NULL, NULL} }; /* Fallback: extract machine name from uname -a if uname -m fails */ static const char *machine_names[] = { "i[0-9]86[^ ]*", "x86_[^ ]*", "amd[0-9]*", "armv[0-9][^ ]*", "ppc[0-9]+", "sparc[0-9]*", "BePC", "ia64", "x86", "IP[0-9]*", "k1om", "sun4u", "RM600", "R4000", "alpha", NULL }; /* Fallback: extract system name from uname -a if uname -s fails */ static const char *system_names[] = { "[Ll]inux", "sn5[0-9]*", "CYGWIN_NT[^ ]*", "GNU[^ ]*", "DragonFly", "[^ ]*BSD[^ ]*", "Haiku", "HP-UX", "AIX", "OS4000", "Interix", "IRIX[0-9]*", "Darwin", "Minix", "MINGW[^ ]*", "ReliantUNIX[^ ]*", "SunOS", "OSF1", "ULTRIX", "UWIN-W7", "IS/WB", "OS/390", "SCO[^ ]*", "QNX", NULL }; /* Fallback: if uname -a fails, guess system by looking at "magic file names" */ magic_file_t magic_files[] = { {"/dev/null", "UNIX", "UNIX", sys_unix}, {"c:\\config.sys", "win32", "WIN32", sys_win32dlc}, {"c:\\windows\\system.ini", "win32", "WIN32", sys_win32dlc}, {"c:\\windows\\win.ini", "win32", "WIN32", sys_win32dlc}, {"c:\\windows\\notepad.exe", "win32", "WIN32", sys_win32dlc}, {NULL, NULL, NULL, NULL} } ; static int match(const char *regex, const char *str) { re_comp(regex); return re_exec(str); } /* match uname against each pattern on the list; on a match, put() the portion of the string matched in node and return 1 */ int uname_guess(const char *node, const char *uname, const char *list[]) { const char **l; if (uname == NULL) return 0; for(l = list; *l != NULL; l++) { if (match(*l, uname)) { char *s; int len = eopat[0] - bopat[0]; s = malloc(len+1); memcpy(s, bopat[0], len); s[len] = '\0'; put(node, s); return 1; } } return 0; } /* Don't worry about linear search or matching regexes all the time - this function will be run at most two times */ static callback_t lookup_uname(char **uname, const char **name, const char **class) { uname_t *u; for(u = unames; u->uname_regex != NULL; u++) { if ( ((*uname != NULL) && (match(u->uname_regex, *uname))) /* uname match */ || ((*name != NULL) && ((strcmp(u->name, *name) == 0))) /* name match */ || ((*class != NULL) && ((strcmp(u->class, *class) == 0))) /* class match */ ) { if (*name == NULL) *name = u->name; if (*class == NULL) *class = u->class; return u->callback; } } return NULL; } static callback_t lookup_magic_file(int logdepth, const char **name, const char **class) { magic_file_t *u; for(u = magic_files; u->file_name != NULL; u++) { if (is_file(u->file_name)) { logprintf(logdepth, "%s -> %s\n", u->file_name, u->class); if (*name == NULL) *name = u->name; if (*class == NULL) *class = u->class; return u->callback; } } return NULL; } int find_uname(const char *rname, int logdepth, int fatal) { const char *name, *class, *tname, *uname_orig; char *s, *uname, *mname, *sname; void (*callback)(void); require("sys/tmp", logdepth, fatal); if (istarget(db_cwd)) require("/target/sys/target", logdepth, fatal); report("Checking for system type... "); logprintf(logdepth, "[find_uname] checking for sys/name\n"); logdepth++; tname = get("/arg/sys/target-name"); if (istarget(db_cwd) && (tname != NULL)) put("sys/name", tname); tname = get("/arg/sys/target-uname"); if (istarget(db_cwd) && (tname != NULL)) put("sys/uname", tname); name = get("sys/name"); uname_orig = get("sys/uname"); if (name == NULL) { if (uname_orig == NULL) { logprintf(logdepth, "not set, running\n"); run_shell(logdepth, "uname -a", (char **)&uname); if (uname != NULL) { for(s = uname; *s != '\0'; s++) if ((*s == '\n') || (*s == '\r')) *s = ' '; put("sys/uname", uname); } else put("sys/uname", ""); if (run_shell(logdepth, "uname -m", (char **)&mname) == 0) put("sys/machine_name", strip(mname)); else put("sys/machine_name", NULL); if (mname != NULL) free(mname); if (run_shell(logdepth, "uname -o", (char **)&sname) == 0) put("sys/system_name", strip(sname)); else if (run_shell(logdepth, "uname -s", (char **)&sname) == 0) put("sys/system_name", strip(sname)); else put("sys/system_name", NULL); if (sname != NULL) free(sname); } /* we have uname by now, set sys/name */ name = NULL; class = NULL; callback = lookup_uname(&uname, &name, &class); if (name == NULL) { /* no uname or unknown system by uname - fallback: check for cross target */ const char *target = get("/arg/sys/target"); if ((target != NULL) && (strstr(target, "mingw") != NULL)) { name = "WIN32"; report("(detected mingw cross compilation to WIN32)\n"); } else { report("Warning: unknown system\n"); name = "unknown"; } } put("sys/name", name); } else { /* we had sys/name, that should be enough */ uname = NULL; class = name; callback = lookup_uname(&uname, &name, &class); } /* predefined and/or detected uname failed, try magic file method */ if (callback == NULL) { logprintf(logdepth, "System class is unknown by uname, running heuristics...\n"); report("System class is unknown by uname, running heuristics... "); callback = lookup_magic_file(logdepth + 1, &name, &class); } if (callback == NULL) { /* System unknown. */ error("Unknown system '%s'\n", get("sys/uname")); abort(); } callback(); report("OK (name: %s; class: %s)\n", name, class); put("sys/class", class); /* fallbacks */ if (get("sys/machine_name") == NULL) uname_guess("sys/machine_name", uname, machine_names); if (get("sys/system_name") == NULL) uname_guess("sys/system_name", uname, system_names); /* on windows, overwrite the path sep with the right amount of \ (the tmp finder may have left / in it) */ if (strcmp(class, "WIN32") == 0) { int eats = istrue(get("sys/shell_eats_backslash")); if (eats) put("sys/path_sep", "\\\\\\\\"); else put("sys/path_sep", "\\"); } return 0; } static int find_triplet_(const char *name, int logdepth, int fatal, const char *nodename, int include_vendor, char *sep, char *esc) { const char *machine, *vendor, *os; char *triplet, *s; char fake_sep[2]; fake_sep[0] = 1; fake_sep[1] = 0; require("sys/uname", logdepth, fatal); machine = get("sys/machine_name"); if (machine == NULL) machine = "unknown"; vendor = "unknown"; os = get("sys/system_name"); if (os == NULL) os = "unknown"; if (include_vendor) triplet = str_concat(fake_sep, machine, vendor, os, NULL); else triplet = str_concat(fake_sep, machine, os, NULL); for(s = triplet; *s != '\0'; s++) { if ((esc != NULL) && (*s == *sep)) *s = *esc; if (isalnum(*s)) *s = tolower(*s); else { if (*s == *fake_sep) *s = *sep; else if (esc != NULL) *s = *esc; else *s = '-'; } } put(nodename, triplet); free(triplet); return 0; } int find_triplet(const char *name, int logdepth, int fatal) { return find_triplet_(name, logdepth, fatal, "sys/triplet", 1, "-", NULL); } int find_sysid(const char *name, int logdepth, int fatal) { return find_triplet_(name, logdepth, fatal, "sys/sysid", 0, "-", "_"); } xschem-2.8.1/scconfig/src/default/find_types.c0000644000175100017510000003134713265320657017550 0ustar svnsvn/* scconfig - detection of types and type sizes Copyright (C) 2012 Tibor Palinkas Copyright (C) 2017-2018 Aron Barath This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include "libs.h" #include "log.h" #include "db.h" #include "dep.h" /* assume there is no integer that is at least this wide, in bytes */ #define MAX_INT_WIDTH 9 /* ('long double' can be 16 bytes; see https://en.wikipedia.org/wiki/Long_double) */ #define MAX_FLT_WIDTH 17 static int try_size(int logdepth, char *cflags, char *ldflags, const char *type, int use_stdint, const char *path, const char **sizearr, unsigned char *inc_stdint, const int max_width) { char *out = NULL; const char *test_c_template = NL "#include " NL "int main() {" NL " printf(\"OK %%d\\n\", sizeof(%s));" NL " return 0;" NL "}" NL; char test_c[512], *start; const char *inc = "#include \n"; int size; if (use_stdint) { strcpy(test_c, inc); start = test_c + strlen(inc); } else start = test_c; sprintf(start, test_c_template, type); report("Testing size of type %25s... ", type); logprintf(logdepth, "trying size with ldflags '%s'\n", ldflags == NULL ? get("cc/ldflags") : ldflags); if (compile_run(logdepth+1, test_c, NULL, cflags, ldflags, &out) == 0) { if (target_emu_fail(out)) { report(" FAIL (emulator)\n"); free(out); return -1; } if (strncmp(out, "OK", 2) == 0) { size = atoi(out+3); if ((size > 0) && (size < max_width)) { sprintf(test_c, "%d", size); put(path, test_c); sizearr[size] = type; if (inc_stdint != NULL) inc_stdint[size] = use_stdint; report(" OK, size %d byte%s\n", size, (size > 1) ? "s" : ""); } else { report(" FAIL, size %d bytes\n", size); size = -1; } free(out); return size; } free(out); } report(" FAIL (compile)\n"); return -1; } int find_types_stdint(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "int main() {" NL " if (sizeof(uint8_t) == 1)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for stdint.h... "); logprintf(logdepth, "find_types_stdint: trying to find stdint.h...\n"); logdepth++; if (try_icl(logdepth, "libs/types/stdint", test_c, NULL, NULL, NULL)) return 0; return try_fail(logdepth, "libs/types/stdint"); } int find_types_sizes(const char *name, int logdepth, int fatal) { const char *stdint; const char *sizearr_u[MAX_INT_WIDTH]; const char *sizearr_s[MAX_INT_WIDTH]; const char *sizearr_f[MAX_FLT_WIDTH]; unsigned char inc_stdint_u[MAX_INT_WIDTH]; unsigned char inc_stdint_s[MAX_INT_WIDTH]; int n; const char *includes = ""; const char *path_template = "sys/types/size/%d_%c_int"; const char *path_template_f = "sys/types/size/%d_float"; char path[64]; require("cc/cc", logdepth, fatal); require("libs/types/stdint/presents", logdepth, 0); stdint = get("libs/types/stdint/presents"); for(n = 0; n < MAX_INT_WIDTH; n++) { sizearr_u[n] = NULL; sizearr_s[n] = NULL; inc_stdint_u[n] = 0; inc_stdint_s[n] = 0; } for(n = 0; n < MAX_FLT_WIDTH; n++) sizearr_f[n] = NULL; try_size(logdepth+1, NULL, NULL, "unsigned long long int", 0, "sys/types/size/unsigned_long_long_int", sizearr_u, NULL, MAX_INT_WIDTH); try_size(logdepth+1, NULL, NULL, "unsigned char", 0, "sys/types/size/unsigned_char", sizearr_u, NULL, MAX_INT_WIDTH); try_size(logdepth+1, NULL, NULL, "unsigned short int", 0, "sys/types/size/unsigned_short_int", sizearr_u, NULL, MAX_INT_WIDTH); try_size(logdepth+1, NULL, NULL, "unsigned int", 0, "sys/types/size/unsigned_int", sizearr_u, NULL, MAX_INT_WIDTH); try_size(logdepth+1, NULL, NULL, "unsigned long int", 0, "sys/types/size/unsigned_long_int", sizearr_u, NULL, MAX_INT_WIDTH); try_size(logdepth+1, NULL, NULL, "signed long long int", 0, "sys/types/size/signed_long_long_int", sizearr_s, NULL, MAX_INT_WIDTH); try_size(logdepth+1, NULL, NULL, "signed char", 0, "sys/types/size/signed_char", sizearr_s, NULL, MAX_INT_WIDTH); try_size(logdepth+1, NULL, NULL, "signed short int", 0, "sys/types/size/signed_short_int", sizearr_s, NULL, MAX_INT_WIDTH); try_size(logdepth+1, NULL, NULL, "signed int", 0, "sys/types/size/signed_int", sizearr_s, NULL, MAX_INT_WIDTH); try_size(logdepth+1, NULL, NULL, "signed long int", 0, "sys/types/size/signed_long_int", sizearr_s, NULL, MAX_INT_WIDTH); if ((stdint != NULL) && (istrue(stdint))) { try_size(logdepth+1, NULL, NULL, "uint8_t", 1, "sys/types/size/uint8_t", sizearr_u, inc_stdint_u, MAX_INT_WIDTH); try_size(logdepth+1, NULL, NULL, "uint16_t", 1, "sys/types/size/uint16_t", sizearr_u, inc_stdint_u, MAX_INT_WIDTH); try_size(logdepth+1, NULL, NULL, "uint32_t", 1, "sys/types/size/uint32_t", sizearr_u, inc_stdint_u, MAX_INT_WIDTH); try_size(logdepth+1, NULL, NULL, "uint64_t", 1, "sys/types/size/uint64_t", sizearr_u, inc_stdint_u, MAX_INT_WIDTH); try_size(logdepth+1, NULL, NULL, "int8_t", 1, "sys/types/size/int8_t", sizearr_s, inc_stdint_s, MAX_INT_WIDTH); try_size(logdepth+1, NULL, NULL, "int16_t", 1, "sys/types/size/int16_t", sizearr_s, inc_stdint_s, MAX_INT_WIDTH); try_size(logdepth+1, NULL, NULL, "int32_t", 1, "sys/types/size/int32_t", sizearr_s, inc_stdint_s, MAX_INT_WIDTH); try_size(logdepth+1, NULL, NULL, "int64_t", 1, "sys/types/size/int64_t", sizearr_s, inc_stdint_s, MAX_INT_WIDTH); } try_size(logdepth+1, NULL, NULL, "float", 0, "sys/types/size/float", sizearr_f, NULL, MAX_FLT_WIDTH); try_size(logdepth+1, NULL, NULL, "double", 0, "sys/types/size/double", sizearr_f, NULL, MAX_FLT_WIDTH); try_size(logdepth+1, NULL, NULL, "long double", 0, "sys/types/size/long_double", sizearr_f, NULL, MAX_FLT_WIDTH); for(n = 0; n < MAX_INT_WIDTH; n++) { if (sizearr_u[n] != NULL) { report("Found best fit %d bytes wide uint: %s\n", n, sizearr_u[n]); sprintf(path, path_template, n, 'u'); put(path, sizearr_u[n]); if (inc_stdint_u[n]) includes = "#include "; } if (sizearr_s[n] != NULL) { report("Found best fit %d bytes wide sint: %s\n", n, sizearr_s[n]); sprintf(path, path_template, n, 's'); put(path, sizearr_s[n]); if (inc_stdint_s[n]) includes = "#include "; } } for(n = 0; n < MAX_FLT_WIDTH; n++) { if (sizearr_f[n] != NULL) { report("Found best fit %d bytes wide float: %s\n", n, sizearr_f[n]); sprintf(path, path_template_f, n); put(path, sizearr_f[n]); } } put("sys/types/size/presents", strue); /* to avoid redetection */ put("sys/types/size/includes", includes); return 0; } int find_types_something_t(const char *name, int logdepth, int fatal, const char *prefix, const char *typ, const char *define, const char *try_include) { char *out = NULL; int res; char test_c[512]; char node[256], *nodeend; const char **include, *includes[] = {"", "#include ", "#include ", "#include ", "#include ", "#include ", "#include ", NULL}; const char ** const first_include = (try_include && *try_include) ? includes : (includes+1); char *test_c_include = NL "%s" NL "int my_puts(const char *s);" NL "%s" NL "int main() {" NL " %s s;" NL " my_puts(\"OK\");" NL " return 0;" NL "}" NL "#include " NL "int my_puts(const char *s)" NL "{" NL " return puts(s);" NL "}" NL; char *test_c_size = NL "%s" NL "#include " NL "%s" NL "int main() {" NL " printf(\"%%d\", sizeof(%s));" NL " return 0;" NL "}" NL; char *test_c_broken = NL "%s" NL "int my_puts(const char *s);" NL "%s" NL "int main() {" NL " %s s;" NL " void *v;" NL " if (sizeof(v) != sizeof(s)) my_puts(\"yes\");" NL " else my_puts(\"no\");" NL " return 0;" NL "}" NL "#include " NL "int my_puts(const char *s)" NL "{" NL " return puts(s);" NL "}" NL; includes[0] = try_include; require("cc/cc", logdepth, fatal); report("Checking for type %s... ", typ); logprintf(logdepth, "find_types_something_t: Checking for %s...\n", typ); logdepth++; sprintf(node, "%s/%s", prefix, typ); nodeend = node + strlen(node); /* replace '*' at the end of the node path with _ptr so it can be saved in the tree */ if (nodeend[-1] == '*') { nodeend--; while((nodeend > node) && (*nodeend == ' ')) nodeend--; strcpy(nodeend-1, "_ptr"); nodeend+=4; } nodeend[0] = '/'; nodeend[1] = '\0'; nodeend++; if (define == NULL) define = ""; for(include = first_include; *include != NULL; include++) { sprintf(test_c, test_c_include, define, *include, typ); if ((compile_run(logdepth, test_c, NULL, NULL, NULL, &out) == 0) && (strncmp(out, "OK", 2) == 0)) { report("Found; "); logprintf(logdepth+1, "include %s works\n", *include); sprintf(nodeend, "includes"); if (define) { put(node, define); append(node, "\\n"); append(node, *include); } else put(node, *include); break; } logprintf(logdepth+1, "include %s fails\n", *include); if (out != NULL) free(out); } if (*include == NULL) { report("Not found\n"); return 1; } sprintf(nodeend, "presents"); put(node, strue); /* check if typ is broken (smaller than void *) */ sprintf(test_c, test_c_broken, define, *include, typ); if (compile_run(logdepth, test_c, NULL, NULL, NULL, &out) == 0) { if ((out != NULL) && (strncmp(out, "yes", 3) == 0)) { report("(%s is narrower than void *)\n", typ); sprintf(nodeend, "broken"); put(node, strue); res = 0; } else if ((out != NULL) && (strncmp(out, "no", 2) == 0)) { report("(%s is not narrower than void *)\n", typ); sprintf(nodeend, "broken"); put(node, sfalse); res = 0; } else { report("ERROR: test failed (%s)\n", out); res = 1; } } if (out != NULL) free(out); if (res == 0) { report("Checking for size of %s... ", typ); sprintf(test_c, test_c_size, define, *include, typ); if (compile_run(logdepth, test_c, NULL, NULL, NULL, &out) == 0) { if (out != NULL) { report("(sizeof %s is %s)\n", typ, out); sprintf(nodeend, "size"); put(node, out); } } if (out != NULL) free(out); } return res; } int find_types_size_t(const char *name, int logdepth, int fatal) { return find_types_something_t(name, logdepth, fatal, "sys/types", "size_t", NULL, NULL); } int find_types_off_t(const char *name, int logdepth, int fatal) { return find_types_something_t(name, logdepth, fatal, "sys/types", "off_t", NULL, NULL); } int find_types_off64_t(const char *name, int logdepth, int fatal) { return find_types_something_t(name, logdepth, fatal, "sys/types", "off64_t", NULL, NULL) && find_types_something_t(name, logdepth, fatal, "sys/types", "off64_t", "#define _LARGEFILE64_SOURCE", NULL); } int find_types_gid_t(const char *name, int logdepth, int fatal) { return find_types_something_t(name, logdepth, fatal, "sys/types", "gid_t", NULL, NULL); } int find_types_uid_t(const char *name, int logdepth, int fatal) { return find_types_something_t(name, logdepth, fatal, "sys/types", "uid_t", NULL, NULL); } int find_types_pid_t(const char *name, int logdepth, int fatal) { return find_types_something_t(name, logdepth, fatal, "sys/types", "pid_t", NULL, NULL); } int find_types_mode_t(const char *name, int logdepth, int fatal) { return find_types_something_t(name, logdepth, fatal, "sys/types", "mode_t", NULL, NULL); } int find_types_nlink_t(const char *name, int logdepth, int fatal) { return find_types_something_t(name, logdepth, fatal, "sys/types", "nlink_t", NULL, NULL); } int find_types_ptrdiff_t(const char *name, int logdepth, int fatal) { return find_types_something_t(name, logdepth, fatal, "sys/types", "ptrdiff_t", NULL, NULL); } int find_types_dev_t(const char *name, int logdepth, int fatal) { return find_types_something_t(name, logdepth, fatal, "sys/types", "dev_t", NULL, NULL); } int find_types_ino_t(const char *name, int logdepth, int fatal) { return find_types_something_t(name, logdepth, fatal, "sys/types", "ino_t", NULL, NULL); } int find_types_void_ptr(const char *name, int logdepth, int fatal) { return find_types_something_t(name, logdepth, fatal, "sys/types", "void *", NULL, NULL); } xschem-2.8.1/scconfig/src/default/deps_default.h0000644000175100017510000000003611260021745020024 0ustar svnsvnvoid deps_default_init(void); xschem-2.8.1/scconfig/src/default/find_printf.c0000644000175100017510000001704513240634424017676 0ustar svnsvn/* scconfig - detection of printf-related features Copyright (C) 2009 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include "libs.h" #include "log.h" #include "db.h" #include "dep.h" static int tryx(int logdepth, const char *test_c, const char *trying, const char *expected) { char *out = NULL; char buff[512]; logprintf(logdepth, "trying '%s'\n", trying); sprintf(buff, test_c, trying, trying); if (compile_run(logdepth+1, buff, NULL, NULL, NULL, &out) == 0) { if (strncmp(out, expected, strlen(expected)) == 0) { free(out); return 1; } free(out); } return 0; } static int tryc(int logdepth, const char *test_c, const char *trying) { char *out = NULL; char buff[512]; char *spc, *end; logprintf(logdepth, "trying '%s'\n", trying); sprintf(buff, test_c, trying); if (compile_run(logdepth+1, buff, NULL, NULL, NULL, &out) == 0) { spc = str_chr(out, ' '); if (spc == NULL) return 0; *spc = '\0'; spc++; end = str_chr(spc, ' '); if (end == NULL) return 0; *end = '\0'; if (strcmp(out, spc) == 0) { free(out); put("libs/printf_ptrcast", trying); report("OK (%s)\n", trying); return 1; } free(out); } return 0; } int find_printf_x(const char *name, int logdepth, int fatal) { const char *pfx; char *test_c = NL "#include " NL "#include " NL "int main() {" NL " printf(\"'%s%%x'/'%s%%x'\\n\", (size_t)0x1234, NULL);" NL " return 0;" NL "}" NL; char *expected = "'0x1234'/'0x0'"; require("cc/cc", logdepth, fatal); report("Checking for printf %%x prefix... "); logprintf(logdepth, "find_printf_x: trying to find printf %%x prefix...\n"); logdepth++; pfx = get("/arg/libs/printf_x"); if (pfx == NULL) { if (tryx(logdepth, test_c, "", expected)) { put("libs/printf_x", ""); report("OK ()\n"); return 0; } if (tryx(logdepth, test_c, "0x", expected)) { put("libs/printf_x", "0x"); report("OK (0x)\n"); return 0; } } else { report("User provided... "); if (tryx(logdepth, test_c, pfx, expected)) { put("libs/printf_x", pfx); report("OK (%s)\n", pfx); return 0; } } return 1; } int find_printf_ptrcast(const char *name, int logdepth, int fatal) { const char *cast; char *test_c = NL "#include " NL "#include " NL "int main() {" NL " printf(\"%%d %%d \\n\", sizeof(void *), sizeof(%s));" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for printf %%x pointer cast... "); logprintf(logdepth, "find_printf_ptrcast: trying to find printf %%x pointer cast...\n"); logdepth++; cast = get("/arg/libs/printf_ptrcast"); if (cast == NULL) { if (tryc(logdepth, test_c, "unsigned int")) return 0; if (tryc(logdepth, test_c, "unsigned long")) return 0; if (tryc(logdepth, test_c, "unsigned long long")) return 0; } else { report("User provided... "); if (tryc(logdepth, test_c, cast)) return 0; } return 1; } int find_snprintf(const char *name, int logdepth, int fatal) { char *out; char *test_c = NL "#include " NL "#include " NL "int main() {" NL " char buff[9];" NL " char *s = buff+2;" NL NL " /* build a fence */" NL " buff[0] = 0;" NL " buff[1] = 65;" NL " buff[7] = 66;" NL " buff[8] = 0;" NL NL " snprintf(s, 4, \"%d\", 123456);" NL " if ((buff[0] == 0) && (buff[1] == 65) && (buff[7] == 65) && (buff[8] == 0))" NL " printf(\"%s\\n\", s);" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for snprintf... "); logprintf(logdepth, "find_snprintf_works: trying to find snprintf...\n"); logdepth++; logprintf(logdepth, "trying snprintf...\n"); if (compile_run(logdepth+1, test_c, NULL, NULL, NULL, &out) == 0) { if (cross_blind) { put("libs/snprintf", strue); report("OK (can't check if safe)\n"); free(out); return 0; } if (strcmp(out, "123")) { put("libs/snprintf", strue); put("libs/snprintf_safe", strue); report("OK (safe)\n"); free(out); return 0; } if (strcmp(out, "1234")) { put("libs/snprintf", strue); put("libs/snprintf_safe", sfalse); report("OK (UNSAFE)\n"); free(out); return 0; } free(out); report("not found (broken output).\n"); } else { report("not found (no output).\n"); } put("libs/snprintf", sfalse); return 1; } int find_dprintf(const char *name, int logdepth, int fatal) { char *out; char *test_c = NL "#include " NL "#include " NL "int main() {" NL " dprintf(1, \"OK\\n\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for dprintf... "); logprintf(logdepth, "find_dprintf: trying to find dprintf...\n"); logdepth++; logprintf(logdepth, "trying dprintf...\n"); if ((compile_run(logdepth+1, test_c, NULL, NULL, NULL, &out) == 0) && (strcmp(out, "OK"))) { put("libs/dprintf", strue); report("found\n"); free(out); return 0; } put("libs/dprintf", sfalse); report("not found\n"); return 1; } int find_vdprintf(const char *name, int logdepth, int fatal) { char *out; char *test_c = NL "#include " NL "#include " NL "#include " NL "void local_dprintf(int fd, const char *fmt, ...)" NL "{" NL " va_list ap;" NL " va_start(ap, fmt);" NL " vdprintf(fd, fmt, ap);" NL "}" NL "int main() {" NL " local_dprintf(1, \"OK\\n\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for vdprintf... "); logprintf(logdepth, "find_vdprintf: trying to find vdprintf...\n"); logdepth++; logprintf(logdepth, "trying vdprintf...\n"); if ((compile_run(logdepth+1, test_c, NULL, NULL, NULL, &out) == 0) && (strcmp(out, "OK"))) { put("libs/vdprintf", strue); report("found\n"); free(out); return 0; } put("libs/vdprintf", sfalse); report("not found\n"); return 1; } int find_vsnprintf(const char *name, int logdepth, int fatal) { char *out; char *test_c = NL "#include " NL "#include " NL "#include " NL "void local_vsnprintf(char *s, int len, const char *fmt, ...)" NL "{" NL " va_list ap;" NL " va_start(ap, fmt);" NL " vsnprintf(s, len, fmt, ap);" NL "}" NL "int main() {" NL " char s[16];" NL " *s = '\\0';" NL " local_vsnprintf(s, 14, \"OK\\n\");" NL " printf(\"%s\", s);" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for vsnprintf... "); logprintf(logdepth, "find_vsnprintf: trying to find vsnprintf...\n"); logdepth++; logprintf(logdepth, "trying vsnprintf...\n"); if ((compile_run(logdepth+1, test_c, NULL, NULL, NULL, &out) == 0) && (strcmp(out, "OK"))) { put("libs/vsnprintf", strue); report("found\n"); free(out); return 0; } put("libs/vsnprintf", sfalse); report("not found\n"); return 1; } xschem-2.8.1/scconfig/src/default/lib_filelist.c0000644000175100017510000001776413240634424020045 0ustar svnsvn/* scconfig - library for listing files in a directory Copyright (C) 2009..2012 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include "db.h" #include "libs.h" #include "log.h" #include "dep.h" static void destroy_testdir(int logdepth, char *dir) { const char *rm; char *cmd, *dir_esc; rm = get("fstools/rm"); if (rm == NULL) { logprintf(logdepth, "CAN NOT delete test directory '%s': no rm available\n", dir); return; } if (dir == NULL) return; logprintf(logdepth, "deleting test directory '%s'\n", dir); cmd = malloc(strlen(dir) + strlen(rm) + 4); dir_esc = shell_escape_dup(dir); sprintf(cmd, "%s %s", rm, dir_esc); run_shell(0, cmd, NULL); free(cmd); free(dir); free(dir_esc); } static char *create_testdir(int logdepth) { char *dir, *fn, *cmd; const char *mkdir; int n; logprintf(logdepth, "creating test directory\n"); dir = tempdir_new(logdepth+1, ""); logprintf(logdepth, "sandbox is: '%s'\n", dir); fn = malloc(strlen(dir) + 32); for(n = 0; n < 2; n++) { FILE *f; sprintf(fn, "%s%sfile%d", dir, get("sys/path_sep"), n+1); f = fopen(fn, "w"); if (f != NULL) { fclose(f); if (!is_file(fn)) { logprintf(logdepth, "Can not create file %s\n", fn); free(fn); destroy_testdir(logdepth, dir); return NULL; } } } mkdir = get("fstools/mkdir"); cmd = malloc(strlen(dir) + 64); for(n = 0; n < 2; n++) { char *fn_esc; sprintf(fn, "%s%sdir%d", dir, get("sys/path_sep"), n+1); fn_esc = shell_escape_dup(fn); sprintf(cmd, "%s %s", mkdir, fn_esc); free(fn_esc); if (run_shell(logdepth+1, cmd, NULL) || (!is_dir(fn))) { logprintf(logdepth, "Can not create directory %s\n", fn); free(fn); free(cmd); destroy_testdir(logdepth, dir); return NULL; } } free(cmd); free(fn); return dir; } static int test(int logdepth, int argc, char *argv[]) { int dir[2], file[2], n; int *arr, idx; for(n = 0; n < 2; n++) { dir[n] = 0; file[n] = 0; } /* count the list of files, increase arrays by hit */ for(n = 0; n < argc; n++) { arr = NULL; if (strncmp(argv[n], "dir", 3) == 0) { arr = dir; idx = atoi(argv[n]+3); } if (strncmp(argv[n], "file", 4) == 0) { arr = file; idx = atoi(argv[n]+4); } if (arr == NULL) { logprintf(logdepth, "test fails: unknown existing file on the list: '%s'\n", argv[n]); return 0; } idx--; if ((idx < 0) || (idx > 1)) { logprintf(logdepth, "test fails: file name changed: '%s'\n", argv[n]); return 0; } arr[idx]++; } /* check if every item was found exactly once */ for(n = 0; n < 2; n++) { if ((dir[n] != 1) || (file[n] != 1)) { logprintf(logdepth, "test fails: %s%d not found \n", dir[n] ? "file" : "dir", n); return 0; } } return 1; } static void filelist_extract(char *out, const char *dir, const char *method, int *argc, char ***argv) { char *s, sep, *start, *end; int len, allocated = 0, count = 0; char **arr = NULL; const char *psep; psep = get("sys/path_sep"); len = strlen(dir); /* uniform separator */ if (*method == 'w') { /* if word splitting then convert newlines to spaces and convert tabs to spaces */ for(s = out; *s != '\0'; s++) { if ((*s == '\n') || (*s == '\r') || (*s == '\t')) *s = ' '; } sep = ' '; } else { for(s = out; *s != '\0'; s++) { if (*s == '\r') *s = '\n'; } sep = '\n'; } start = out; while((s = str_chr(start, sep)) != NULL) { *s = '\0'; if (strncmp(dir, start, len) == 0) start += len; while(*start == *psep) start++; if (*start != '\0') { end = str_chr(start, *psep); if (end != NULL) *end = '\0'; /* add only if not the same as previous and exists */ if ((!((count > 0) && (strcmp(arr[count - 1], start) == 0))) && (exists_in(dir, start))) { if (count >= allocated) { allocated = count + 32; arr = realloc(arr, sizeof(char *) * allocated); } arr[count] = strclone(start); count++; } } start = s+1; while(*start == sep) start++; } *argc = count; *argv = arr; } void filelist_free(int *argc, char ***argv) { int n; if (*argv == NULL) return; for(n = 0; n < *argc; n++) free((*argv)[n]); free(*argv); *argc = 0; } static char *filelist_asmcmd(const char *dir, const char *list_cmd) { char *cmd; cmd = malloc(strlen(dir) + strlen(list_cmd) + 32); sprintf(cmd, list_cmd, dir); return cmd; } static int try(int logdepth, const char *dir, const char *list_cmd, const char *method) { char *cmd, *out, *dir_esc; int argc, res; char **argv; dir_esc = shell_escape_dup(dir); cmd = filelist_asmcmd(dir_esc, list_cmd); free(dir_esc); logprintf(logdepth, "trying '%s'...\n", cmd); run_shell(logdepth+1, cmd, &out); if (out != NULL) { filelist_extract(out, dir, method, &argc, &argv); res = test(logdepth+1, argc, argv); filelist_free(&argc, &argv); free(out); } if (res) { logprintf(logdepth+1, "Works.", cmd); put("/internal/filelist/cmd", list_cmd); put("/internal/filelist/method", method); report("OK ('%s' with %s split)\n", list_cmd, method); } free(cmd); return res; } int find_filelist(const char *name, int logdepth, int fatal) { char *dir; char *old_cwd; int ret; old_cwd = strclone(db_cwd); db_cd("/host"); require("fstools/mkdir", logdepth, fatal); require("fstools/rm", logdepth, fatal); report("Checking for filelist... "); logprintf(logdepth, "find_filelist: trying to find file listing...\n"); logdepth++; dir = create_testdir(logdepth); if (dir == NULL) { report("Failed to creat sandbox\n"); ret = 1; goto end; } if ( try(logdepth, dir, "ls %s", "line") || /* should return one file name per line since the output is redirected */ try(logdepth, dir, "ls -1 %s", "line") || /* try to force one file name per line */ try(logdepth, dir, "ls --format=single-column %s", "line") || /* for gnu ls */ try(logdepth, dir, "find %s", "line") || /* if ls fails, we try find */ try(logdepth, dir, "ls %s", "word") || /* if that fails too, ls may still have a list in multiple columns */ try(logdepth, dir, "dir %s", "word") || /* or we are on windows where we need to use dir maybe */ try(logdepth, dir, "echo %s/*", "word")) { /* or on a system without ls, dir or anything alike, but shell globbing may still work */ destroy_testdir(logdepth, dir); ret = 0; goto end; } destroy_testdir(logdepth, dir); ret = 1; end:; db_cd(old_cwd); free(old_cwd); return ret; } void filelist(int logdepth, const char *dir, int *argc, char ***argv) { const char *list_cmd, *method; char *cmd, *out, *dir_esc; char *old_cwd; old_cwd = strclone(db_cwd); db_cd("/host"); /* make sure these are set to invalid for easier return in case we fail anywhere later */ *argc = -1; *argv = NULL; if (!is_dir(dir)) goto end; require("/internal/filelist/cmd", logdepth, 1); require("/internal/filelist/method", logdepth, 1); list_cmd = get("/internal/filelist/cmd"); method = get("/internal/filelist/method"); dir_esc = shell_escape_dup(dir); cmd = filelist_asmcmd(dir_esc, list_cmd); free(dir_esc); run_shell(logdepth+1, cmd, &out); if (out != NULL) { filelist_extract(out, dir, method, argc, argv); logprintf(logdepth, "filelist: Getting list of files in %s\n", dir); free(out); } free(cmd); end:; db_cd(old_cwd); free(old_cwd); } xschem-2.8.1/scconfig/src/default/deps_default.c0000644000175100017510000002072413400723626020032 0ustar svnsvn/* scconfig - dependency list of default tests Copyright (C) 2009..2012 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include "dep.h" #include "find.h" void deps_default_init(void) { dep_add("cc/cc", find_cc); dep_add("cc/argstd/*", find_cc_argstd); dep_add("cc/cflags", find_cc); dep_add("cc/ldflags", find_cc); dep_add("cc/inline", find_inline); dep_add("cc/varargmacro", find_varargmacro); dep_add("cc/funcmacro", find_funcmacro); dep_add("cc/constructor", find_constructor); dep_add("cc/destructor", find_destructor); dep_add("cc/rdynamic", find_rdynamic); dep_add("cc/soname", find_soname); dep_add("cc/wlrpath", find_wlrpath); dep_add("cc/wloutimplib", find_cc_wloutimplib); dep_add("cc/wloutputdef", find_cc_wloutputdef); dep_add("cc/fpic", find_fpic); dep_add("cc/fpie/*", find_cc_fpie); dep_add("cc/fnopie/*", find_cc_fnopie); dep_add("cc/fnopic/*", find_cc_fnopic); dep_add("cc/alloca/*", find_alloca); dep_add("cc/_exit/*", find__exit); dep_add("cc/ldflags_dynlib", find_ldflags_dynlib); dep_add("cc/ldflags_dll", find_ldflags_dll); dep_add("cc/ldflags_so", find_ldflags_so); dep_add("cc/func_attr/unused/*", find_fattr_unused); dep_add("cc/declspec/dllimport/*", find_declspec_dllimport); dep_add("cc/declspec/dllexport/*", find_declspec_dllexport); dep_add("cc/argmachine/*", find_cc_argmachine); dep_add("cc/pragma_message/*", find_cc_pragma_message); dep_add("libs/ldl", find_lib_ldl); dep_add("libs/LoadLibrary/*", find_lib_LoadLibrary); dep_add("libs/lpthread", find_lib_lpthread); dep_add("libs/lpthread-recursive", find_lib_lpthread); dep_add("thread/semget/*", find_thread_semget); dep_add("thread/pthread_create/*", find_thread_pthread_create); dep_add("thread/CreateSemaphore/*", find_thread_CreateSemaphore); dep_add("thread/CreateThread/*", find_thread_CreateThread); dep_add("libs/errno/*", find_lib_errno); dep_add("libs/printf_x", find_printf_x); dep_add("libs/printf_ptrcast", find_printf_ptrcast); dep_add("libs/snprintf", find_snprintf); dep_add("libs/snprintf_safe", find_snprintf); dep_add("libs/dprintf", find_dprintf); dep_add("libs/vdprintf", find_vdprintf); dep_add("libs/vsnprintf", find_vsnprintf); dep_add("libs/proc/_spawnvp/*", find_proc__spawnvp); dep_add("libs/proc/fork/*", find_proc_fork); dep_add("libs/proc/wait/*", find_proc_wait); dep_add("libs/fs/realpath/*", find_fs_realpath); dep_add("libs/fs/_fullpath/*", find_fs__fullpath); dep_add("libs/fs/readdir/*", find_fs_readdir); dep_add("libs/fs/findnextfile/*", find_fs_findnextfile); dep_add("libs/fs/stat/macros/*", find_fs_stat_macros); dep_add("libs/fs/stat/fields/*", find_fs_stat_fields); dep_add("libs/fs/access/*", find_fs_access); dep_add("libs/fs/access/macros/*", find_fs_access_macros); dep_add("libs/fs/lstat/*", find_fs_lstat); dep_add("libs/fs/statlstat/*", find_fs_statlstat); dep_add("libs/fs/getcwd/*", find_fs_getcwd); dep_add("libs/fs/_getcwd/*", find_fs__getcwd); dep_add("libs/fs/getwd/*", find_fs_getwd); dep_add("libs/fs/mkdir/*", find_fs_mkdir); dep_add("libs/fs/_mkdir/*", find_fs__mkdir); dep_add("libs/fs/mkdtemp/*", find_fs_mkdtemp); dep_add("libs/fs/mmap/*", find_fs_mmap); dep_add("libs/fsmount/next_dev/*", find_fsmount_next_dev); dep_add("libs/fsmount/struct_fsstat/*",find_fsmount_fsstat_fields); dep_add("libs/fsmount/struct_statfs/*",find_fsmount_statfs_fields); dep_add("libs/fsmount/struct_statvfs/*",find_fsmount_statvfs_fields); dep_add("libs/fs/ustat/*", find_fs_ustat); dep_add("libs/fs/statfs/*", find_fs_statfs); dep_add("libs/fs/statvfs/*", find_fs_statvfs); dep_add("libs/fs/flock/*", find_fs_flock); dep_add("libs/io/pipe/*", find_io_pipe); dep_add("libs/io/dup2/*", find_io_dup2); dep_add("libs/io/fileno/*", find_io_fileno); dep_add("libs/io/lseek/*", find_io_lseek); dep_add("libs/io/popen/*", find_io_popen); dep_add("libs/time/usleep/*", find_time_usleep); dep_add("libs/types/stdint/*", find_types_stdint); dep_add("sys/types/size/*", find_types_sizes); dep_add("libs/time/Sleep/*", find_time_Sleep); dep_add("libs/time/gettimeofday/*", find_time_gettimeofday); dep_add("libs/time/ftime/*", find_time_ftime); dep_add("libs/time/timegm/*", find_time_timegm); dep_add("libs/time/_mkgmtime/*", find_time_mkgmtime); dep_add("libs/time/gmtime_r/*", find_time_gmtime_r); dep_add("libs/time/gmtime_s/*", find_time_gmtime_s); dep_add("libs/env/main_3arg/*", find_main_arg3); dep_add("libs/env/putenv/*", find_putenv); dep_add("libs/env/setenv/*", find_setenv); dep_add("libs/env/environ/*", find_environ); dep_add("signal/raise/*", find_signal_raise); dep_add("signal/names/*", find_signal_names); dep_add("fstools/cp", find_fstools_cp); dep_add("fstools/ln", find_fstools_ln); dep_add("fstools/mv", find_fstools_mv); dep_add("fstools/rm", find_fstools_rm); dep_add("fstools/mkdir", find_fstools_mkdir); dep_add("fstools/ar", find_fstools_ar); dep_add("fstools/ranlib", find_fstools_ranlib); dep_add("fstools/awk", find_fstools_awk); dep_add("fstools/cat", find_fstools_cat); dep_add("fstools/sed", find_fstools_sed); dep_add("fstools/file_l", find_fstools_file_l); dep_add("fstools/file", find_fstools_file); dep_add("fstools/chmodx", find_fstools_chmodx); dep_add("sys/name", find_uname); dep_add("sys/uname", find_uname); dep_add("sys/triplet", find_triplet); dep_add("sys/sysid", find_sysid); dep_add("sys/shell", find_shell); dep_add("sys/shell_needs_quote", find_shell); dep_add("sys/tmp", find_tmp); dep_add("sys/shell_eats_backslash", find_tmp); dep_add("sys/ext_exe", find_uname); dep_add("sys/ext_dynlib", find_uname); dep_add("sys/ext_dynlib_native", find_uname); dep_add("sys/ext_stalib", find_uname); dep_add("sys/class", find_uname); dep_add("sys/path_sep", find_uname); dep_add("sys/ptrwidth", find_sys_ptrwidth); dep_add("sys/byte_order", find_sys_byte_order); dep_add("sys/types/size_t/*", find_types_size_t); dep_add("sys/types/off_t/*", find_types_off_t); dep_add("sys/types/off64_t/*", find_types_off64_t); dep_add("sys/types/gid_t/*", find_types_gid_t); dep_add("sys/types/uid_t/*", find_types_uid_t); dep_add("sys/types/pid_t/*", find_types_pid_t); dep_add("sys/types/mode_t/*", find_types_mode_t); dep_add("sys/types/nlink_t/*", find_types_nlink_t); dep_add("sys/types/ptrdiff_t/*", find_types_ptrdiff_t); dep_add("sys/types/dev_t/*", find_types_dev_t); dep_add("sys/types/ino_t/*", find_types_ino_t); dep_add("sys/types/void_ptr/*", find_types_void_ptr); dep_add("str/strcasecmp/*", find_strcasecmp); dep_add("str/strncasecmp/*", find_strncasecmp); dep_add("/internal/filelist/cmd", find_filelist); dep_add("/internal/filelist/method", find_filelist); } xschem-2.8.1/scconfig/src/default/main_custom_args.h0000644000175100017510000000023012660127205020716 0ustar svnsvn#define MAX_CUSTOM_REQS 32 extern char *custom_reqs[MAX_CUSTOM_REQS]; extern int num_custom_reqs; int custom_arg(const char *key, const char *value); xschem-2.8.1/scconfig/src/default/lib_pkg_config.c0000644000175100017510000001021713216416024020317 0ustar svnsvn#include #include #include #include #include #include #include "log.h" #include "libs.h" #include "db.h" #include "dep.h" #include "regex.h" static void zap(char **str) { const char *pat = get("/arg/sys/pkg-config-zap"); char *n; if (pat == NULL) return; if (re_comp(pat) != NULL) return; while (re_exec(*str)) { n = re_subs_dup(""); free(*str); *str = n; } } int run_gen_config(int logdepth, const char *confname, const char *pkgname, char **cflags, char **ldflags) { char cmd[256]; assert(strlen(pkgname) < sizeof(cmd) - 64); if (cflags != NULL) { sprintf(cmd, "%s --cflags %s", confname, pkgname); if (run(logdepth, cmd, cflags) != 0) { report("not found: %s --cflags failed.", confname); logprintf(logdepth, "not found: %s --cflags failed.\n", confname); return -1; } if (*cflags != NULL) { zap(cflags); strip(*cflags); } } if (ldflags != NULL) { sprintf(cmd, "%s --libs %s", confname, pkgname); if (run(logdepth, cmd, ldflags) != 0) { report("not found: %s --libs failed.", confname); logprintf(logdepth, "not found: %s --libs failed.\n", confname); if (cflags != NULL) free(*cflags); return -1; } if (*ldflags != NULL) { zap(ldflags); strip(*ldflags); } } return 0; } const char *pkg_config_name() { const char *name; name = get("/arg/sys/pkg-config"); if (name != NULL) return name; return "pkg-config"; /* fallback */ } /** run_pkg_config_modversion: run `pkg-config` on @pkgname: - with `--modversion` if @modversion is not NULL, storing the result in @modversion (malloc()'d) Returns 0 on success. */ int run_pkg_config_modversion(int logdepth, const char *pkgname, char **modversion) { char cmd[256]; const char *confname = pkg_config_name(); assert(strlen(pkgname) < sizeof(cmd) - 64); if (modversion != NULL) { sprintf(cmd, "%s --modversion %s", confname, pkgname); if (run(logdepth, cmd, modversion) != 0) { /*report("Module version not found: %s --modversion %s failed.", confname, pkgname); logprintf(logdepth, "Module version not found: %s --modversion %s failed.\n", confname, pkgname); */ return -1; } zap(modversion); strip(*modversion); } return 0; } /** run_pkg_config_modversion_db: run `pkg-config --modversion` on @pkgname to find module (or package) version and store the result in @node/modversion Returns 0 on success. */ int run_pkg_config_modversion_db(int logdepth, const char *node, const char *pkgname /*, char **modversion */ ) { char *modversion; char *tmp; if (run_pkg_config_modversion(logdepth, pkgname, &modversion) != 0) { return -1; } /* Store the module version in node */ tmp = str_concat("/", node, "modversion", NULL); put(tmp, modversion); free(tmp); free(modversion); return 0; } int run_pkg_config(int logdepth, const char *pkgname, char **cflags, char **ldflags) { return run_gen_config(logdepth, pkg_config_name(), pkgname, cflags, ldflags); } void run_pkg_config_lst(int logdepth, const char *pkgpat, int *argc, char ***argv) { char *end, *s, *next; int n = 0, a = 0; char **sf = NULL; static const char *pkg_cfg_cache = NULL; static char no_pkg_cfg; char *list; if (pkg_cfg_cache == &no_pkg_cfg) goto error; if (pkg_cfg_cache == NULL) { char *cmd = str_concat(" ", pkg_config_name(), "--list-all", NULL); run(logdepth, cmd, (char **) &pkg_cfg_cache); free(cmd); if (pkg_cfg_cache == NULL) { pkg_cfg_cache = &no_pkg_cfg; goto error; } } if (re_comp(pkgpat) != NULL) goto error; s = list = strclone(pkg_cfg_cache); for (;;) { while (isspace(*s)) s++; if (*s == '\0') break; next = strpbrk(s, "\r\n"); if (next != NULL) *next = '\0'; if (re_exec(s)) { if ((n + 2) >= a) { /* n+2: make sure there's always room for the NULL at the end */ a += 16; sf = realloc(sf, sizeof(char *) * a); } end = strpbrk(s, " \t"); if (end != NULL) *end = '\0'; sf[n] = strclone(s); sf[n + 1] = re_subs_dup(""); /* report("\ns='%s' sf='%s'\n", s, sf[n]);*/ n += 2; } s = next + 1; } if (sf != NULL) sf[n] = NULL; free(list); error:; *argc = n; *argv = sf; return; } xschem-2.8.1/scconfig/src/default/db.h0000644000175100017510000000206513216413253015760 0ustar svnsvn#include "ht.h" #define strue "true" #define sfalse "false" #define istrue(s) ((s != NULL) && (*s == 't')) #define isfalse(s) ((s != NULL) && (*s == 'f')) /* the 3rd option is "unknown" */ /* accessors */ const char *get(const char *key); const char *put(const char *key, const char *data); void append(const char *key, const char *value); char *concat_nodes(const char *prefix, ...); int node_istrue(const char *key); /* init/uninit */ void db_init(void); void db_uninit(void); /* export/import */ int export(const char *fn, int export_empty, const char *root); int import(const char *fn); int import_args(const char *key, const char *fn); /* file system features */ extern char *db_cwd; void db_cd(const char *path); void db_mkdir(const char *path); void db_link(const char *existing, const char *new); void db_rmdir(const char *path); extern ht_t *DBs; #define iscross (ht_get(DBs, "target") != ht_get(DBs, "host")) #define in_cross_target (iscross && (strcmp(db_cwd, "/target") == 0)) #define in_cross_host (iscross && (strcmp(db_cwd, "/host") == 0)) xschem-2.8.1/scconfig/src/default/main_custom_args.c0000644000175100017510000000304012660127205020713 0ustar svnsvn/* scconfig - default way to handle custom args (save them in an array) Copyright (C) 2016 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include "libs.h" #include "log.h" #include "hooks.h" #include "main_custom_args.h" char *custom_reqs[MAX_CUSTOM_REQS]; int num_custom_reqs = 0; int custom_arg(const char *key, const char *value) { if (hook_custom_arg(key, value)) return 1; if (strcmp(key, "detect") == 0) { printf("Will detect: %s\n", value); if (num_custom_reqs >= MAX_CUSTOM_REQS) { report("Too many custom reqs from the command line, exiting\n"); exit(1); } custom_reqs[num_custom_reqs] = strclone(value); num_custom_reqs++; return 1; } return 0; } xschem-2.8.1/scconfig/src/default/Makefile.plugin0000644000175100017510000001554713220743067020174 0ustar svnsvnDEFAULT_NOMAIN_OBJS = \ $(BIN)/default/find_cc.o \ $(BIN)/default/lib_compile.o \ $(BIN)/default/lib_uniqinc.o \ $(BIN)/default/lib_file.o \ $(BIN)/default/lib_try.o \ $(BIN)/default/str.o \ $(BIN)/default/ht.o \ $(BIN)/default/log.o \ $(BIN)/default/arg.o \ $(BIN)/default/db.o \ $(BIN)/default/dep.o \ $(BIN)/default/deps_default.o \ $(BIN)/default/find_libs.o \ $(BIN)/default/find_fscalls.o \ $(BIN)/default/find_printf.o \ $(BIN)/default/find_proc.o \ $(BIN)/default/find_fstools.o \ $(BIN)/default/find_uname.o \ $(BIN)/default/find_target.o \ $(BIN)/default/find_thread.o \ $(BIN)/default/find_io.o \ $(BIN)/default/find_time.o \ $(BIN)/default/find_types.o \ $(BIN)/default/find_signal.o \ $(BIN)/default/find_environ.o \ $(BIN)/default/regex.o \ $(BIN)/default/lib_filelist.o \ $(BIN)/default/lib_srctree.o \ $(BIN)/default/lib_pkg_config.o \ $(BIN)/default/find_str.o \ $(BIN)/default/find_sys.o DEFAULT_MAIN_OBJS = \ $(BIN)/default/main.o \ $(BIN)/default/main_custom_args.o \ $(BIN)/default/main_lib.o DEFAULT_OBJS = $(DEFAULT_NOMAIN_OBJS) $(DEFAULT_MAIN_OBJS) $(BIN)/default/lib_compile.o: $(SRC)/default/lib_compile.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/lib_compile.c -o $(BIN)/default/lib_compile.o $(BIN)/default/lib_file.o: $(SRC)/default/lib_file.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/lib_file.c -o $(BIN)/default/lib_file.o $(BIN)/default/lib_try.o: $(SRC)/default/lib_try.c $(SRC)/default/log.h $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/lib_try.c -o $(BIN)/default/lib_try.o $(BIN)/default/str.o: $(SRC)/default/str.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/str.c -o $(BIN)/default/str.o $(BIN)/default/ht.o: $(SRC)/default/ht.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/ht.c -o $(BIN)/default/ht.o $(BIN)/default/log.o: $(SRC)/default/log.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/log.c -o $(BIN)/default/log.o $(BIN)/default/arg.o: $(SRC)/default/arg.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/arg.c -o $(BIN)/default/arg.o $(BIN)/default/db.o: $(SRC)/default/db.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/db.c -o $(BIN)/default/db.o $(BIN)/default/dep.o: $(SRC)/default/dep.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/dep.c -o $(BIN)/default/dep.o $(BIN)/default/deps_default.o: $(SRC)/default/deps_default.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/deps_default.c -o $(BIN)/default/deps_default.o $(BIN)/default/find_libs.o: $(SRC)/default/find_libs.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/find_libs.c -o $(BIN)/default/find_libs.o $(BIN)/default/find_fscalls.o: $(SRC)/default/find_fscalls.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/find_fscalls.c -o $(BIN)/default/find_fscalls.o $(BIN)/default/find_signal.o: $(SRC)/default/find_signal.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/find_signal.c -o $(BIN)/default/find_signal.o $(BIN)/default/find_printf.o: $(SRC)/default/find_printf.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/find_printf.c -o $(BIN)/default/find_printf.o $(BIN)/default/find_proc.o: $(SRC)/default/find_proc.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/find_proc.c -o $(BIN)/default/find_proc.o $(BIN)/default/find_fstools.o: $(SRC)/default/find_fstools.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/find_fstools.c -o $(BIN)/default/find_fstools.o $(BIN)/default/find_uname.o: $(SRC)/default/find_uname.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/find_uname.c -o $(BIN)/default/find_uname.o $(BIN)/default/find_target.o: $(SRC)/default/find_target.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/find_target.c -o $(BIN)/default/find_target.o $(BIN)/default/regex.o: $(SRC)/default/regex.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/regex.c -o $(BIN)/default/regex.o $(BIN)/default/lib_filelist.o: $(SRC)/default/lib_filelist.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/lib_filelist.c -o $(BIN)/default/lib_filelist.o $(BIN)/default/lib_srctree.o: $(SRC)/default/lib_srctree.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/lib_srctree.c -o $(BIN)/default/lib_srctree.o $(BIN)/default/lib_pkg_config.o: $(SRC)/default/lib_pkg_config.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/lib_pkg_config.c -o $(BIN)/default/lib_pkg_config.o $(BIN)/default/lib_uniqinc.o: $(SRC)/default/lib_uniqinc.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/lib_uniqinc.c -o $(BIN)/default/lib_uniqinc.o $(BIN)/default/find_sys.o: $(SRC)/default/find_sys.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/find_sys.c -o $(BIN)/default/find_sys.o $(BIN)/default/find_str.o: $(SRC)/default/find_str.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/find_str.c -o $(BIN)/default/find_str.o $(BIN)/default/find_cc.o: $(SRC)/default/find_cc.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/find_cc.c -o $(BIN)/default/find_cc.o $(BIN)/default/find_environ.o: $(SRC)/default/find_environ.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/find_environ.c -o $(BIN)/default/find_environ.o $(BIN)/default/find_io.o: $(SRC)/default/find_io.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/find_io.c -o $(BIN)/default/find_io.o $(BIN)/default/find_time.o: $(SRC)/default/find_time.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/find_time.c -o $(BIN)/default/find_time.o $(BIN)/default/find_types.o: $(SRC)/default/find_types.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/find_types.c -o $(BIN)/default/find_types.o $(BIN)/default/main.o: $(SRC)/default/main.c $(SRC)/default/dep.h $(SRC)/default/libs.h Makefile $(CC) $(CFLAGS) -c $(SRC)/default/main.c -o $(BIN)/default/main.o $(BIN)/default/main_custom_args.o: $(SRC)/default/main_custom_args.c $(CC) $(CFLAGS) -c $(SRC)/default/main_custom_args.c -o $(BIN)/default/main_custom_args.o $(BIN)/default/main_lib.o: $(SRC)/default/main_lib.c $(CC) $(CFLAGS) -c $(SRC)/default/main_lib.c -o $(BIN)/default/main_lib.o $(BIN)/default/find_thread.o: $(SRC)/default/find_thread.c $(SRC)/default/dep.h $(SRC)/default/libs.h $(CC) $(CFLAGS) -c $(SRC)/default/find_thread.c -o $(BIN)/default/find_thread.o xschem-2.8.1/scconfig/src/default/find_libs.c0000644000175100017510000001257013246537330017327 0ustar svnsvn/* scconfig - detection of standard library features Copyright (C) 2009 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include "libs.h" #include "log.h" #include "db.h" #include "dep.h" static int trydlc(int logdepth, const char *test_c_dlc, const char *cflagsf, const char *ldflagsf, const char *dlc) { char *cflags, *ldflags; cflags = malloc(strlen(dlc) + 64); ldflags = malloc(strlen(dlc)*2 + 256); sprintf(cflags, cflagsf, dlc); sprintf(ldflags, ldflagsf, dlc, dlc); if (try_icl(logdepth, NULL, test_c_dlc, NULL, cflags, ldflags)) { *cflags = ' '; append("cc/cflags", cflags); put("libs/ldl", ldflags); put("libs/dl-compat", strue); report("OK (%s and %s)\n", cflags, ldflags); free(cflags); free(ldflags); return 1; } free(cflags); free(ldflags); return 0; } int find_lib_ldl(const char *name, int logdepth, int fatal) { const char *ldl, *dlc; char *s; char *test_c = NL "#include " NL "#include " NL "int main() {" NL " void *handle;" NL " handle = dlopen(\"/this file does not exist.\", RTLD_NOW);" NL " if (handle == NULL) printf(\"OK\\n\");" NL " return 0;" NL "}" NL; char *test_c_dlc = NL "#include " NL "#include " NL "int main() {" NL " void *handle;" NL " handle = dlopen(\"/this file does not exist.\", RTLD_NOW);" NL " if (handle == NULL) printf(\"OK\\n\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for -ldl... "); logprintf(logdepth, "find_lib_ldl: trying to find ldl...\n"); logdepth++; ldl = get("/arg/libs/ldl"); if (ldl == NULL) { dlc = get("/arg/libs/dl-compat"); if (dlc == NULL) { /* If dlc is not explicitly requested by the user, try standard dl (see whether we need -ldl for dlopen()) */ if (try_icl(logdepth, NULL, test_c, NULL, NULL, NULL)) { put("libs/ldl", ""); put("libs/ldl/includes", "#include \\n"); report("OK ()\n"); return 0; } if (try_icl(logdepth, NULL, test_c, NULL, NULL, "-ldl")) { put("libs/ldl", "-ldl"); put("libs/ldl/includes", "#include \\n"); report("OK (-ldl)\n"); return 0; } } /* try dl-compat (dl compatibility lib) */ if (dlc != NULL) { /* test at user supplied dlc prefix: - first assume the linker will find it - next assume gcc and pass rpath to the linker - finally try static linking */ if (trydlc(logdepth, test_c_dlc, "-I%s/include", "-L%s/lib -ldl-compat\000%s", dlc)) { put("libs/ldl/includes", "#include \\n"); return 0; } if (trydlc(logdepth, test_c_dlc, "-I%s/include", "-L%s/lib -Wl,-rpath=%s/lib -ldl-compat", dlc)) { put("libs/ldl/includes", "#include \\n"); return 0; } if (trydlc(logdepth, test_c_dlc, "-I%s/include", "%s/lib/libdl-compat.a\000%s", dlc)) { put("libs/ldl/includes", "#include \\n"); return 0; } } else if (try_icl(logdepth, NULL, test_c_dlc, NULL, NULL, "-ldl-compat")) { /* check at normal system installation */ put("libs/ldl", "-ldl-compat"); put("libs/ldl/includes", "#include \\n"); report("OK (-ldl-compat)\n"); return 0; } } else { report("User provided... "); s = strclone(ldl); if (try_icl(logdepth, NULL, test_c, NULL, NULL, s)) { put("libs/ldl", ldl); put("libs/ldl/includes", "#include \\n"); report("OK (%s)\n", ldl); free(s); return 0; } free(s); } report("Not found\n"); return 1; } int find_lib_LoadLibrary(const char *name, int logdepth, int fatal) { /*char *s;*/ char *test_c = NL "#include " NL "int main() {" NL " void *handle;" NL " handle = LoadLibrary(\"/this file does not exist.\");" NL " if (handle == NULL) printf(\"OK\\n\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for LoadLibrary... "); logprintf(logdepth, "find_lib_LoadLibrary: trying to find LoadLibrary...\n"); logdepth++; if (try_icl(logdepth, "libs/LoadLibrary", test_c, "#include ", NULL, NULL)) return 0; return try_fail(logdepth, "libs/LoadLibrary"); } int find_lib_errno(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "int main() {" NL " errno = 0;" NL " puts(\"OK\");" NL " return 0;" NL "}" NL ; require("cc/cc", logdepth, fatal); report("Checking for errno.h... "); logprintf(logdepth, "find_lib_errno: trying to find errno...\n"); logdepth++; if (try_icl(logdepth, "libs/errno", test_c, NULL, NULL, NULL)) return 0; return try_fail(logdepth, "libs/errno"); } xschem-2.8.1/scconfig/src/default/find_fscalls.c0000644000175100017510000005115513256370327020031 0ustar svnsvn/* scconfig - detection of standard library features: file system specific calls Copyright (C) 2010 Tibor Palinkas Copyright (C) 2018 Aron Barath This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include #include "libs.h" #include "log.h" #include "db.h" #include "dep.h" int find_fs_realpath(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "#include " NL "#include " NL "#ifdef PATH_MAX" NL "char out_buf[PATH_MAX];" NL "#else" NL "char out_buf[32768];" NL "#endif" NL "int main() {" NL " if (realpath(\".\", out_buf) == out_buf)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for realpath()... "); logprintf(logdepth, "find_fs_realpath: trying to find realpath...\n"); logdepth++; if (try_icl(logdepth, "libs/fs/realpath", test_c, NULL, NULL, NULL)) return 0; if (try_icl(logdepth, "libs/fs/realpath", test_c, "#define _DEFAULT_SOURCE", NULL, NULL)) return 0; if (try_icl(logdepth, "libs/fs/realpath", test_c, "#define _BSD_SOURCE", NULL, NULL)) return 0; return try_fail(logdepth, "libs/fs/realpath"); } int find_fs__fullpath(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "#include " NL "#include " NL "#include " NL "int main() {" NL " char full[_MAX_PATH];" NL " if (_fullpath(full, \".\", _MAX_PATH) != NULL)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for _fullpath()... "); logprintf(logdepth, "find_fs__fullpath: trying to find _fullpath...\n"); logdepth++; if (try_icl(logdepth, "libs/fs/_fullpath", test_c, NULL, NULL, NULL)) return 0; return try_fail(logdepth, "libs/fs/_fullpath"); } int find_fs_readdir(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "#include " NL "int main() {" NL " DIR *dirp;" NL " struct dirent *dp;" NL " int found = 0;" NL " if ((dirp = opendir(\".\")) == 0)" NL " return -1;" NL " while ((dp = readdir(dirp)) != 0)" NL " if (strcmp(dp->d_name, \"configure\") == 0)" NL " found++;" NL " closedir(dirp);" NL " if (found == 1)" NL " puts(\"OK\");" NL " return 0;" NL "}"; char *includes[] = { "#include ", "#include ", /* 4.2BSD */ NULL }; char **i; require("cc/cc", logdepth, fatal); report("Checking for readdir()... "); logprintf(logdepth, "find_fs_readdir: trying to find readdir...\n"); logdepth++; for (i = includes; *i != NULL; i++) if (try_icl(logdepth, "libs/fs/readdir", test_c, *i, NULL, NULL)) return 0; return try_fail(logdepth, "libs/fs/readdir"); } int find_fs_findnextfile(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "#include " NL "#include " NL "int main(int argc, char *argv[]) {" NL " WIN32_FIND_DATA fd;" NL " HANDLE h;" NL " int found=0;" NL " h = FindFirstFile(argv[0], &fd);" NL " if (h == INVALID_HANDLE_VALUE)" NL " return -1;" NL " while (FindNextFile(h, &fd) != 0);" NL " found++;" NL " FindClose(h);" NL " if (found > 0)" NL " puts(\"OK\");" NL " return 0;" NL "}"; require("cc/cc", logdepth, fatal); report("Checking for FindNextFile()... "); logprintf(logdepth, "find_fs_findnextfile: trying to find FindNextFile...\n"); logdepth++; if (try_icl(logdepth, "libs/fs/findnextfile", test_c, NULL, NULL, NULL)) return 0; return try_fail(logdepth, "libs/fs/findnextfile"); } int find_fs_access(const char *name, int logdepth, int fatal) { char *test_c = NL "int my_test() { return access(\".\", 0); }" NL "#include " NL "int main() {" NL " if (my_test() == 0)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; const char* includes[] = { "#include ", "#include \n#include ", "#include ", NULL }; const char** inc; require("cc/cc", logdepth, fatal); report("Checking for access()... "); logprintf(logdepth, "find_fs_access: trying to find access...\n"); logdepth++; for (inc=includes; *inc; ++inc) if (try_icl(logdepth, "libs/fs/access", test_c, *inc, NULL, NULL)) return 0; return try_fail(logdepth, "libs/fs/access"); } int find_fs_access_macros(const char *rname, int logdepth, int fatal) { char *test_c_templ = NL "%s" NL "void my_test() { int a = %s; }" NL "#include " NL "int main() {" NL " my_test();" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; char test_c[256]; char *names[][3] = { {"F_OK", "F_OK", NULL}, {"R_OK", "R_OK", NULL}, {"W_OK", "W_OK", NULL}, {"X_OK", "X_OK", NULL}, {NULL, NULL, NULL} }; char **n; const char* access_includes; int name, pr; char nodename[128]; require("cc/cc", logdepth, fatal); if (require("libs/fs/access/*", logdepth, fatal)!=0 || !istrue(get("libs/fs/access/presents"))) { put("libs/fs/access/macros/presents", sfalse); return 1; } access_includes = get("libs/fs/access/includes"); report("Checking for access macros:\n"); logprintf(logdepth, "find_fs_access_macros: trying to find access macros...\n"); logdepth++; pr = 0; for(name = 0; *names[name] != NULL; name++) { report(" %s...\t", names[name][0]); for(n = &names[name][0]; *n != NULL; n++) { sprintf(test_c, test_c_templ, access_includes, *n); if (try_icl(logdepth, NULL, test_c, NULL, NULL, NULL)) { sprintf(nodename, "libs/fs/access/macros/%s", names[name][0]); put(nodename, *n); report("found as %s\n", *n); pr++; goto found; } } report("not found\n"); found:; } put("libs/fs/access/macros/presents", ((pr > 0) ? (strue) : (sfalse))); return (pr == 0); } int find_fs_stat_macros(const char *rname, int logdepth, int fatal) { char *test_c_templ = NL "#include " NL "#include " NL "void my_test() { int a = %s(0); }" NL "#include " NL "int main() {" NL " my_test();" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; char test_c[256]; char *names[][3] = { {"S_ISREG", "S_IFREG", NULL}, {"S_ISDIR", "S_IFDIR", NULL}, {"S_ISCHR", "S_IFCHR", NULL}, {"S_ISBLK", "S_IFBLK", NULL}, {"S_ISFIFO", "S_IFFIFO", NULL}, {"S_ISLNK", "S_IFLNK", NULL}, {"S_ISCHR", "S_IFCHR", NULL}, {"S_ISSOCK", "S_IFSOCK", NULL}, {NULL, NULL, NULL} }; char **n; int name, pr; char nodename[128]; require("cc/cc", logdepth, fatal); report("Checking for stat macros:\n"); logprintf(logdepth, "find_fs_stat_macros: trying to find stat macros...\n"); logdepth++; pr = 0; for(name = 0; *names[name] != NULL; name++) { report(" %s...\t", names[name][0]); for(n = &names[name][0]; *n != NULL; n++) { sprintf(test_c, test_c_templ, *n); if (try_icl(logdepth, NULL, test_c, NULL, NULL, NULL)) { sprintf(nodename, "libs/fs/stat/macros/%s", names[name][0]); put(nodename, *n); report("found as %s\n", *n); pr++; goto found; } } report("not found\n"); found:; } put("libs/fs/stat/macros/presents", ((pr > 0) ? (strue) : (sfalse))); return (pr == 0); } int find_fs_stat_fields(const char *rname, int logdepth, int fatal) { char *test_c_templ = NL "#include " NL "#include " NL "#include " NL "int main() {" NL " struct stat st;" NL " (void)st.%s;" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; char test_c[256]; char *names[] = {"st_blksize", "st_blocks", "st_rdev", "st_mtim", "st_mtime", "st_birthtim", "st_birthtime", NULL }; int name, pr; char nodename[128]; require("cc/cc", logdepth, fatal); report("Checking for stat macros:\n"); logprintf(logdepth, "find_fs_stat_fields: trying to find stat macros...\n"); logdepth++; pr = 0; for(name = 0; names[name] != NULL; name++) { report(" %s...\t", names[name]); sprintf(test_c, test_c_templ, names[name]); sprintf(nodename, "libs/fs/stat/fields/%s/presents", names[name]); if (try_icl(logdepth, NULL, test_c, NULL, NULL, NULL)) { put(nodename, strue); report("found\n"); pr++; } else { report("not found\n"); put(nodename, sfalse); } } return (pr == 0); } static int find_fs_any_lstat(const char *name, int logdepth, int fatal, char *fn) { /* make sure does not affect our lstat() detection */ const char *test_c_in = NL "void my_puts(const char *s);" NL "int main() {" NL " struct stat buf;" NL " if (%s(\".\", &buf) == 0)" NL " my_puts(\"OK\");" NL " return 0;" NL "}" NL "#include " NL "void my_puts(const char *s)" NL "{" NL " puts(s);" NL "}" NL; char test_c[384], node[64]; const char *incs[] = {"#include ", "#include ", "#include \n#include \n#include ", NULL}; const char **inc; require("cc/cc", logdepth, fatal); sprintf(node, "libs/fs/%s", fn); sprintf(test_c, test_c_in, fn); report("Checking for %s... ", fn); logprintf(logdepth, "find_fs_%s: trying to find lstat()...\n", fn); logdepth++; for (inc = incs; *inc; ++inc) { if (try_icl(logdepth, node, test_c, *inc, NULL, NULL)) return 0; } return try_fail(logdepth, node); } int find_fs_lstat(const char *name, int logdepth, int fatal) { return find_fs_any_lstat(name, logdepth, fatal, "lstat"); } int find_fs_statlstat(const char *name, int logdepth, int fatal) { return find_fs_any_lstat(name, logdepth, fatal, "statlstat"); } int find_fs_getcwd(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "int main() {" NL " char b[1024];" NL " if (getcwd(b, sizeof(b)) != NULL)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for getcwd... "); logprintf(logdepth, "find_fs_getcwd: trying to find getcwd()...\n"); logdepth++; if (try_icl(logdepth, "libs/fs/getcwd", test_c, NULL, NULL, NULL)) return 0; return try_fail(logdepth, "libs/fs/getcwd"); } int find_fs__getcwd(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "int main() {" NL " char b[1024];" NL " if (_getcwd(b, sizeof(b)) != NULL)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for _getcwd... "); logprintf(logdepth, "find_fs__getcwd: trying to find _getcwd()...\n"); logdepth++; if (try_icl(logdepth, "libs/fs/_getcwd", test_c, "#include ", NULL, NULL)) return 0; return try_fail(logdepth, "libs/fs/_getcwd"); } int find_fs_getwd(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "int main() {" NL " char b[8192];" NL " if (getwd(b) != NULL)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for getwd... "); logprintf(logdepth, "find_fs_getwd: trying to find getwd()...\n"); logdepth++; if (try_icl(logdepth, "libs/fs/getwd", test_c, NULL, NULL, NULL)) return 0; return try_fail(logdepth, "libs/fs/getwd"); } int find_fs_mkdir(const char *name, int logdepth, int fatal) { char *dir; char test_c[1024]; char *test_c_in = NL "#include " NL "int main() {" NL no_implicit(int, "mkdir", "mkdir") NL " if (mkdir(\"%s\"%s) == 0)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); dir = tempfile_new(""); unlink(dir); report("Checking for mkdir... "); logprintf(logdepth, "find_fs_mkdir: trying to find mkdir()...\n"); logdepth++; /* POSIX, 2 arguments, standard includes */ sprintf(test_c, test_c_in, dir, ", 0755"); if (try_icl(logdepth, "libs/fs/mkdir", test_c, "#include \n#include \n", NULL, NULL)) { if (!is_dir(dir)) goto oops1; put("libs/fs/mkdir/num_args", "2"); rmdir(dir); return 0; } /* POSIX, 2 arguments, no includes */ oops1:; sprintf(test_c, test_c_in, dir, ", 0755"); if (try_icl(logdepth, "libs/fs/mkdir", test_c, NULL, NULL, NULL)) { if (!is_dir(dir)) goto oops2; put("libs/fs/mkdir/num_args", "2"); rmdir(dir); return 0; } /* win32, 1 argument, with */ oops2:; sprintf(test_c, test_c_in, dir, ""); if (try_icl(logdepth, "libs/fs/mkdir", test_c, "#include \n", NULL, NULL)) { if (!is_dir(dir)) goto oops3; put("libs/fs/mkdir/num_args", "1"); rmdir(dir); return 0; } oops3:; put("libs/fs/mkdir/includes", ""); put("libs/fs/mkdir/ldflags", ""); put("libs/fs/mkdir/cdflags", ""); rmdir(dir); return try_fail(logdepth, "libs/fs/mkdir"); } int find_fs__mkdir(const char *name, int logdepth, int fatal) { char *dir; char test_c[1024]; char *test_c_in = NL "#include " NL "int main() {" NL " if (_mkdir(\"%s\"%s) == 0)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); dir = tempfile_new(""); unlink(dir); report("Checking for _mkdir... "); logprintf(logdepth, "find_fs__mkdir: trying to find _mkdir()...\n"); logdepth++; /* win32, 2 arguments, standard includes */ sprintf(test_c, test_c_in, dir, ", 0755"); if (try_icl(logdepth, "libs/fs/_mkdir", test_c, "#include \n", NULL, NULL)) { if (!is_dir(dir)) goto oops1; put("libs/fs/_mkdir/num_args", "2"); rmdir(dir); return 0; } oops1:; /* win32, 1 argument, standard includes */ sprintf(test_c, test_c_in, dir, ""); if (try_icl(logdepth, "libs/fs/_mkdir", test_c, "#include \n", NULL, NULL)) { if (!is_dir(dir)) goto oops2; put("libs/fs/_mkdir/num_args", "1"); rmdir(dir); return 0; } oops2:; put("libs/fs/_mkdir/includes", ""); put("libs/fs/_mkdir/ldflags", ""); put("libs/fs/_mkdir/cdflags", ""); rmdir(dir); return try_fail(logdepth, "libs/fs/_mkdir"); } int find_fs_mkdtemp(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "#include " NL "#include " NL "int main() {" NL " char fn[32], *o;" NL " strcpy(fn, \"scc.XXXXXX\");" NL " o = mkdtemp(fn);" NL " if ((o != NULL) && (strstr(o, \"scc.\") != NULL)) {" NL " remove(o);" NL " puts(\"OK\");" NL " }" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for mkdtemp... "); logprintf(logdepth, "find_fs_mkdtemp: trying to find mkdtemp()...\n"); logdepth++; if (try_icl(logdepth, "libs/fs/mkdtemp", test_c, "#include \n", NULL, NULL)) return 0; if (try_icl(logdepth, "libs/fs/mkdtemp", test_c, "#define _BSD_SOURCE\n#include \n", NULL, NULL)) return 0; return try_fail(logdepth, "libs/fs/mkdtemp"); } int find_fs_mmap(const char *name, int logdepth, int fatal) { char test_c[1024]; char *tmp; FILE *f; char *test_c_in = NL "#include " NL "#include " NL "#include " NL "#include " NL "#include " NL "#include " NL "int main() {" NL " int fd, size = 11;" NL " void *p;" NL " fd = open(\"%s\", O_RDONLY);" NL " p = mmap(0, size, PROT_READ, MAP_FILE | MAP_PRIVATE, fd, 0);" NL " if (p == NULL) {" NL " puts(\"mmap fail\");" NL " return 0;" NL " }" NL " if (strcmp(p, \"hello world\") != 0) {" NL " puts(\"strcmp fail\");" NL " return 0;" NL " }" NL " if (munmap(p, size) != 0) {" NL " puts(\"munmap fail\");" NL " return 0;" NL " }" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); tmp = tempfile_new(""); f = fopen(tmp, "w"); fprintf(f, "hello world"); fclose(f); sprintf(test_c, test_c_in, tmp); report("Checking for mmap... "); logprintf(logdepth, "find_fs_mmap: trying to find mmap()...\n"); logdepth++; if (try_icl(logdepth, "libs/fs/mmap", test_c, "#include \n", NULL, NULL)) { unlink(tmp); free(tmp); return 0; } unlink(tmp); free(tmp); return try_fail(logdepth, "libs/fs/mmap"); } /* Haiku/BeOS next_dev */ int find_fsmount_next_dev(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "int main()" NL "{" NL " int32 pos = 0;" NL " dev_t res = next_dev(&pos);" NL " if (res >= 0)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for next_dev... "); logprintf(logdepth, "find_fsmount_next_dev: trying to find next_dev()...\n"); logdepth++; if (try_icl(logdepth, "libs/fsmount/next_dev", test_c, "#include \n", NULL, NULL)) return 0; return try_fail(logdepth, "libs/fsmount/next_dev"); } int find_fsmount_fsstat_fields(const char *name, int logdepth, int fatal) { const char *fields[] = {"f_fstypename", NULL}; return try_icl_sfields(logdepth, "libs/fsmount/struct_fsstat", "struct fsstat", fields, "#include ", NULL, NULL, 0); } int find_fsmount_statfs_fields(const char *name, int logdepth, int fatal) { const char *fields[] = {"f_fstypename", "f_type", NULL}; return try_icl_sfields(logdepth, "libs/fsmount/struct_statfs", "struct statfs", fields, "#include ", NULL, NULL, 0); } int find_fsmount_statvfs_fields(const char *name, int logdepth, int fatal) { const char *fields[] = {"f_fstypename", "f_type", "f_basetype", NULL}; return try_icl_sfields(logdepth, "libs/fsmount/struct_statvfs", "struct statvfs", fields, "#include ", NULL, NULL, 0); } int find_fs_ustat(const char *name, int logdepth, int fatal) { const char *key = "libs/fs/ustat"; const char *test_c = NL "#include " NL "#include " NL "int main()" NL "{" NL " struct stat stat_buf;" NL " struct ustat ustat_buf;" NL " if (stat(\".\", &stat_buf) == 0 &&" NL " ustat(stat_buf.st_dev, &ustat_buf) == 0)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for ustat... "); logprintf(logdepth, "find_fs_ustat: trying to find ustat()...\n"); logdepth++; if (try_icl(logdepth, key, test_c, "#include ", NULL, NULL)) return 0; if (try_icl(logdepth, key, test_c, "#include ", NULL, NULL)) return 0; if (try_icl(logdepth, key, test_c, "#include \n#include ", NULL, NULL)) return 0; if (try_icl(logdepth, key, test_c, "#include \n#include \n#include ", NULL, NULL)) return 0; return try_fail(logdepth, key); } int find_fs_statfs(const char *name, int logdepth, int fatal) { const char *key = "libs/fs/statfs"; const char *test_c = NL "#include " NL "int main()" NL "{" NL " struct statfs statfs_buf;" NL " if (statfs(\".\", &statfs_buf) == 0)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for statfs... "); logprintf(logdepth, "find_fs_statfs: trying to find statfs()...\n"); logdepth++; if (try_icl(logdepth, key, test_c, "#include ", NULL, NULL)) return 0; if (try_icl(logdepth, key, test_c, "#include ", NULL, NULL)) return 0; return try_fail(logdepth, key); } int find_fs_statvfs(const char *name, int logdepth, int fatal) { const char *key = "libs/fs/statvfs"; const char *test_c = NL "#include " NL "int main()" NL "{" NL " struct statvfs statvfs_buf;" NL " if (statvfs(\".\", &statvfs_buf) == 0)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for statvfs... "); logprintf(logdepth, "find_fs_statvfs: trying to find statvfs()...\n"); logdepth++; if (try_icl(logdepth, key, test_c, "#include ", NULL, NULL)) return 0; return try_fail(logdepth, key); } int find_fs_flock(const char *name, int logdepth, int fatal) { const char *key = "libs/fs/flock"; const char *test_c = NL "#include " NL "int main()" NL "{" NL " if (flock(1, LOCK_UN) == 0)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for flock... "); logprintf(logdepth, "find_fs_flock: trying to find flock()...\n"); logdepth++; if (try_icl(logdepth, key, test_c, "#include ", NULL, NULL)) return 0; return try_fail(logdepth, key); } xschem-2.8.1/scconfig/src/default/find_target.c0000644000175100017510000000351613334271760017664 0ustar svnsvn/* scconfig - glue layer for proper crosscompiling to target Copyright (C) 2009 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include "db.h" #include "libs.h" int find_target(const char *name, int logdepth, int fatal) { const char *target = get("/arg/sys/target"); const char *emu = get("/arg/sys/emu"); (void) logdepth; /* to suppress compiler warnings about not using logdepth */ (void) fatal; /* to suppress compiler warnings about not using fatal */ /* Does target differ from host? */ if (target == NULL) { db_link("/host", "/target"); #ifdef RUNTIME db_link("/host", "/runtime"); #endif put("/target/sys/cross", sfalse); put("/target/sys/cross_blind", sfalse); return 0; } else db_mkdir("/target"); put("/target/sys/target", target); put("/target/sys/cross", strue); if (emu != NULL) put("/target/sys/emu", emu); /* If so, check if emulator is provided */ cross_blind = ((emu == NULL) || (*emu == '\0')); put("/target/sys/cross_blind", cross_blind ? strue : sfalse); return 0; } xschem-2.8.1/scconfig/src/default/find_cc.c0000644000175100017510000006767213400723626016775 0ustar svnsvn/* scconfig - detection of cc and compiler features Copyright (C) 2009..2012 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include #include "libs.h" #include "log.h" #include "db.h" #include "dep.h" static int try_flags(int logdepth, const char *cc, const char *test_c, const char *cflags, const char *ldflags, const char *expected) { char *out; logprintf(logdepth, "trying cc:try_flags with cc='%s' cflags='%s' ldflags='%s'\n", (cc == NULL ? get("cc/cc") : cc), cflags == NULL ? "" : cflags, ldflags == NULL ? "" : ldflags); if (compile_run(logdepth+1, test_c, cc, cflags, ldflags, &out) == 0) { if (((out == NULL) && (iscross)) || (strncmp(out, expected, strlen(expected)) == 0)) { free(out); return 1; } free(out); } return 0; } static int try_flags_inv(int logdepth, const char *cc, const char *test_c, const char *cflags, const char *ldflags, const char *expected_bad) { char *out; logprintf(logdepth, "trying cc:try_flags with cc='%s' cflags='%s' ldflags='%s'\n", (cc == NULL ? get("cc/cc") : cc), cflags == NULL ? "" : cflags, ldflags == NULL ? "" : ldflags); if (compile_run(logdepth+1, test_c, cc, cflags, ldflags, &out) == 0) { if (((out == NULL) && (iscross)) || (strncmp(out, expected_bad, strlen(expected_bad)) != 0)) { free(out); return 1; } free(out); } return 0; } static int try(int logdepth, const char *cc, const char *test_c, const char *expected) { return try_flags(logdepth, cc, test_c, NULL, NULL, expected); } static int trycc(int logdepth, const char *cc, const char *test_c) { int ret; if (cc == NULL) return 0; ret = try(logdepth, cc, test_c, "OK"); if (ret) put("cc/cc", cc); return ret; } int find_cc(const char *name, int logdepth, int fatal) { char *test_c = "#include \nint main() { printf(\"OK\\n\");\nreturn 0;}\n"; char *out = NULL, *targetcc; const char *cc, *cflags, *ldflags, *target, *sys; int len; require("sys/name", logdepth, fatal); sys = istarget(db_cwd) ? "target" : "host"; report("Checking for cc (%s)... ", sys); logprintf(logdepth, "find_cc: trying to find cc (%s)...\n", sys); logdepth++; /* cflags */ cflags = get("/arg/cc/cflags"); if (cflags != NULL) { logprintf(logdepth+1, "using user supplied cflags '%s'\n", cflags); put("cc/cflags", cflags); } /* ldflags */ ldflags = get("/arg/cc/ldflags"); if (ldflags != NULL) { logprintf(logdepth+1, "using user supplied ldflags '%s'\n", ldflags); put("cc/ldflags", ldflags); } cc = get("/arg/cc/cc"); if (cc == NULL) { target = get("sys/target"); if (target != NULL) { logprintf(logdepth+1, "find_cc: crosscompiling for '%s', looking for target cc\n", target); len = strlen(target); targetcc = malloc(len + 8); memcpy(targetcc, target, len); strcpy(targetcc + len, "-gcc"); if (!trycc(logdepth+1, targetcc, test_c)) { strcpy(targetcc + len, "-cc"); if (!trycc(logdepth+1, targetcc, test_c)) { report("FAILED: failed to find crosscompiler for target '%s'\n", target); logprintf(logdepth, "find_cc: FAILED to find a crosscompiler for target '%s'\n", target); return 1; } } put("cc/cc", targetcc); } else { cc = getenv("CC"); logprintf(logdepth, "find_cc: Detecting cc (host)\n"); /* Find a working cc (no arguments) */ if (!(((cc != NULL) && (trycc(logdepth+1, cc, test_c))) || trycc(logdepth+1, "gcc", test_c) || trycc(logdepth+1, "cc", test_c))) { report("FAILED to find a compiler\n"); logprintf(logdepth, "find_cc: FAILED to find a compiler\n"); return 1; } } } else { put("cc/cc", cc); logprintf(logdepth+1, "using user supplied '%s' (will test later)\n", cc); } /* cflags (again) */ if (cflags == NULL) { logprintf(logdepth, "find_cc: Detecting -pipe\n"); if (compile_run(logdepth+1, test_c, NULL, "-pipe", "", &out) == 0) { if (target_emu_fail(out) || (strncmp(out, "OK", 2) == 0)) { append("cc/cflags", " -pipe"); } free(out); } } if (get("cc/cflags") == NULL) put("cc/cflags", ""); /* ldflags (again) */ if (get("cc/ldflags") == NULL) put("cc/ldflags", ""); /* Final test of all arguments together */ logprintf(logdepth, "find_cc: final test on cc and all flags \n"); if (compile_run(logdepth+1, test_c, NULL, NULL, NULL, &out) != 0) { report("FAILED to get the compiler and all flags to work together\n"); logprintf(logdepth, "find_cc: the compiler and all the flags don't work well together, aborting\n"); if (out != NULL) free(out); return 1; } report("OK ('%s', '%s', '%s')\n", get("cc/cc"), get("cc/cflags"), get("cc/ldflags")); logprintf(logdepth, "find_cc: conclusion: cc='%s' cflags='%s' ldflags='%s'\n", get("cc/cc"), get("cc/cflags"), get("cc/ldflags")); if (out != NULL) free(out); return 0; } int find_cc_argstd(const char *det_name, int logdepth, int fatal) { char *test_c = "#include \nint main() { printf(\"OK\\n\");\nreturn 0;}\n"; char *out = NULL; char **flg, *flags[] = {"-ansi", "-pedantic", "-Wall", "-std=c89", "-std=c99", "-Werror", "-Wextra", "-W", "-pg", "-no-pie", "-static-pie", NULL}; const char *det_target = det_list_target(det_name); require("cc/cc", logdepth, fatal); logprintf(logdepth, "find_cc: Detecting CC args %s\n", det_target); report("Checking for cc args for std %s... ", det_target); for(flg = flags; *flg != NULL; flg++) { char name[128], *end; const char *found = ""; sprintf(name, "cc/argstd/%s", (*flg)+1); end = strchr(name, '='); if (end != NULL) *end = '_'; if (!asked_for(name, det_name)) continue; if (compile_run(logdepth+1, test_c, NULL, *flg, "", &out) == 0) { if (target_emu_fail(out) || (strncmp(out, "OK", 2) == 0)) { found = *flg; report(" "); report(found); } free(out); } put(name, found); } if (is_dep_wild(det_name)) put("cc/argstd/presents", strue); /* to avoid re-detection*/ report("\n"); return 0; } int find_cc_argmachine(const char *name, int logdepth, int fatal) { #define ARGM(flag) "-m" #flag , "-mno-" #flag const char *test_c = "#include \nint main() { printf(\"OK\\n\");\nreturn 0;}\n"; char *out = NULL; const char **flg, *flags[] = { ARGM(mmx), ARGM(sse), ARGM(sse2), ARGM(sse3), ARGM(ssse3), ARGM(sse4), ARGM(sse4.1), ARGM(sse4.2), ARGM(avx), ARGM(avx2), NULL}; require("cc/cc", logdepth, fatal); logprintf(logdepth, "find_cc: Detecting CC machine args\n"); report("Checking for cc args for machine... "); for(flg = flags; *flg != NULL; flg++) { char name[128], *end; const char *found = ""; { const char* ptr = (*flg) + 1; strcpy(name, "cc/argmachine/"); end = name + strlen(name); while(*ptr) { if('.'!=*ptr && '-'!=*ptr) *end++ = *ptr; ++ptr; } *end = '\0'; } end = strchr(name, '='); if (end != NULL) *end = '_'; if (compile_run(logdepth+1, test_c, NULL, *flg, "", &out) == 0) { if (target_emu_fail(out) || (strncmp(out, "OK", 2) == 0)) { found = *flg; report(" "); report(found); } free(out); } put(name, found); } report("\n"); return 0; #undef ARGM } int find_inline(const char *name, int logdepth, int fatal) { const char *test_c = NL "#include " NL "static inline void test_inl()" NL "{" NL " puts(\"OK\");" NL "}" NL "int main() {" NL " test_inl();" NL " return 0;" NL "}" NL ; require("cc/cc", logdepth, fatal); report("Checking for inline... "); logprintf(logdepth, "find_inline: trying to find inline...\n"); logdepth++; if (try(logdepth, NULL, test_c, "OK")) { put("cc/inline", strue); report("Found.\n"); return 0; } put("cc/inline", sfalse); report("Not found.\n"); return 1; } int find_varargmacro(const char *name, int logdepth, int fatal) { const char *test_c = NL "#include " NL "#define pr(fmt, x...) {printf(\"PR \"); printf(fmt, x); }" NL "int main() {" NL " pr(\"%d %d %s\", 42, 8192, \"test\");" NL " puts(\"\");" NL " return 0;" NL "}" NL ; require("cc/cc", logdepth, fatal); report("Checking for vararg macro... "); logprintf(logdepth, "find_varargmacro: trying to find vararg macro...\n"); logdepth++; if (try(logdepth, NULL, test_c, "PR 42 8192 test")) { put("cc/varargmacro", strue); report("Found.\n"); return 0; } put("cc/varargmacro", sfalse); report("Not found.\n"); return 1; } int find_funcmacro(const char *name, int logdepth, int fatal) { const char *test_c = NL "#include " NL "int main() {" NL " printf(\"%s\\n\", __func__);" NL " return 0;" NL "}" NL ; require("cc/cc", logdepth, fatal); report("Checking for __func__ macro... "); logprintf(logdepth, "find_funcmacro: trying to find __func__ macro...\n"); logdepth++; if (try(logdepth, NULL, test_c, "main")) { put("cc/funcmacro", strue); report("Found.\n"); return 0; } put("cc/funcmacro", sfalse); report("Not found.\n"); return 1; } int find_constructor(const char *name, int logdepth, int fatal) { const char *test_c = NL "#include " NL "void startup() __attribute__ ((constructor));" NL "void startup()" NL "{" NL " puts(\"OK\");" NL "}" NL "int main() {" NL " return 0;" NL "}" NL ; require("cc/cc", logdepth, fatal); report("Checking for constructor... "); logprintf(logdepth, "find_constructor: trying to find constructor...\n"); logdepth++; if (try(logdepth, NULL, test_c, "OK")) { put("cc/constructor", strue); report("Found.\n"); return 0; } put("cc/constructor", sfalse); report("Not found.\n"); return 1; } int find_destructor(const char *name, int logdepth, int fatal) { const char *test_c = NL "#include " NL "void startup() __attribute__ ((destructor));" NL "void startup()" NL "{" NL " puts(\"OK\");" NL "}" NL "int main() {" NL " return 0;" NL "}" NL ; require("cc/cc", logdepth, fatal); report("Checking for destructor... "); logprintf(logdepth, "find_destructor: trying to find destructor...\n"); logdepth++; if (try(logdepth, NULL, test_c, "OK")) { put("cc/destructor", strue); report("Found.\n"); return 0; } put("cc/destructor", sfalse); report("Not found.\n"); return 1; } static int test_fattr(const char *name, int logdepth, int fatal, const char *fattr) { char path[64]; char test_c[256]; const char *test_c_tmp = NL "#include " NL "static void test1() __attribute__ ((%s));" NL "static void test1()" NL "{" NL " puts(\"OK\");" NL "}" NL "int main() {" NL " puts(\"OK\");" NL " return 0;" NL "}" NL ; require("cc/cc", logdepth, fatal); sprintf(test_c, test_c_tmp, fattr); sprintf(path, "cc/func_attr/%s/presents", fattr); report("Checking for function attribute %s... ", fattr); logprintf(logdepth, "test_fattr: trying to find %s...\n", fattr); logdepth++; if (try(logdepth, NULL, test_c, "OK")) { put(path, strue); report("Found.\n"); return 0; } put(path, sfalse); report("Not found.\n"); return 1; } int find_fattr_unused(const char *name, int logdepth, int fatal) { return test_fattr(name, logdepth, fatal, "unused"); } static int test_declspec(const char *name, int logdepth, int fatal, const char *dspec) { char path[64]; char test_c[256]; const char *test_c_tmp = NL "#include " NL "void __declspec (%s) test1();" NL "void test1()" NL "{" NL " puts(\"OK\");" NL "}" NL "int main() {" NL " test1();" NL " return 0;" NL "}" NL ; require("cc/cc", logdepth, fatal); sprintf(test_c, test_c_tmp, dspec); sprintf(path, "cc/declspec/%s/presents", dspec); report("Checking for declspec %s... ", dspec); logprintf(logdepth, "test_declspec: trying to find %s...\n", dspec); logdepth++; if (try(logdepth, NULL, test_c, "OK")) { put(path, strue); report("Found.\n"); return 0; } put(path, sfalse); report("Not found.\n"); return 1; } int find_declspec_dllimport(const char *name, int logdepth, int fatal) { return test_declspec(name, logdepth, fatal, "dllimport"); } int find_declspec_dllexport(const char *name, int logdepth, int fatal) { return test_declspec(name, logdepth, fatal, "dllexport"); } static int test_dll_auxfile(const char *name, int logdepth, int fatal, const char *path, const char *ldflag, const char *filename) { char *ldflags; char test_c[256]; const char *test_c_template = NL "#include " NL "void %s test1();" NL "void test1()" NL "{" NL " puts(\"OK\");" NL "}" NL "int main() {" NL " test1();" NL " return 0;" NL "}" NL ; const char *dspec; require("cc/cc", logdepth, fatal); require("cc/declspec/dllexport/*", logdepth, 0); if (istrue("cc/declspec/dllexport/presents")) dspec = " __declspec(dllexport) "; else dspec = ""; sprintf(test_c, test_c_template, dspec); report("Checking for DLL flag %s... ", ldflag); logprintf(logdepth, "test_dll_auxfile: trying to find %s...\n", ldflag); logdepth++; ldflags = str_concat("", ldflag, ",", filename, " ", get("cc/ldflags"), NULL); if (try_flags(logdepth, NULL, test_c, NULL, ldflags, "OK")) { unlink(filename); put(path, ldflag); free(ldflags); report("Found.\n"); return 0; } unlink(filename); free(ldflags); report("Not found.\n"); return 1; } int find_cc_wloutimplib(const char *name, int logdepth, int fatal) { return test_dll_auxfile(name, logdepth, fatal, "cc/wloutimplib", "-Wl,--out-implib", "libscconfig_0.a"); } int find_cc_wloutputdef(const char *name, int logdepth, int fatal) { return test_dll_auxfile(name, logdepth, fatal, "cc/wloutputdef", "-Wl,--output-def", "libscconfig_0.def"); } /* Hello world program to test compiler flags */ static const char *test_hello_world = NL "#include " NL "int main() {" NL " puts(\"OK\");" NL " return 0;" NL "}" NL ; static int try_hello(int logdepth, const char *cflags, const char *ldflags, const char *name, const char *value) { if (try_flags(logdepth, NULL, test_hello_world, cflags, ldflags, "OK")) { put(name, value); report("OK (%s)\n", value); return 1; } return 0; } int find_rdynamic(const char *name, int logdepth, int fatal) { const char *node = "cc/rdynamic"; require("cc/cc", logdepth, fatal); report("Checking for rdynamic... "); logprintf(logdepth, "find_rdynamic: trying to find rdynamic...\n"); logdepth++; if (try_hello(logdepth, NULL, "-rdynamic", node, "-rdynamic")) return 0; if (try_hello(logdepth, NULL, "-Wl,-export-dynamic", node, "-Wl,-export-dynamic")) return 0; if (try_hello(logdepth, NULL, NULL, node, "")) return 0; report("Not found.\n"); return 1; } int find_cc_fpie(const char *name, int logdepth, int fatal) { const char *test_c = test_hello_world; require("cc/cc", logdepth, fatal); /* TODO: what about -fpic? */ report("Checking for -fpie... "); logprintf(logdepth, "find_cc_fpie: trying to find -fpie...\n"); logdepth++; /* NOTE: some gcc configuration might not pass the -pie flag to the linker, so */ /* try to detect whether we can force it to the linker */ if (try_icl(logdepth, "cc/fpie", test_c, NULL, "-fpie", "-pie -Wl,-pie")) return 0; if (try_icl(logdepth, "cc/fpie", test_c, NULL, "-fPIE", "-pie -Wl,-pie")) return 0; if (try_icl(logdepth, "cc/fpie", test_c, NULL, "-fpie", "-pie")) return 0; if (try_icl(logdepth, "cc/fpie", test_c, NULL, "-fPIE", "-pie")) return 0; if (try_icl(logdepth, "cc/fpie", test_c, NULL, NULL, NULL)) return 0; return try_fail(logdepth, "cc/fpie"); } int find_cc_fnopie(const char *name, int logdepth, int fatal) { const char *test_c = test_hello_world; require("cc/cc", logdepth, fatal); report("Checking for -fno-pie... "); logprintf(logdepth, "find_cc_fnopie: trying to find -fno-pie...\n"); logdepth++; if (try_icl(logdepth, "cc/fnopie", test_c, NULL, "-fno-pie", NULL)) return 0; if (try_icl(logdepth, "cc/fnopie", test_c, NULL, "-fno-pie", "-static")) return 0; if (try_icl(logdepth, "cc/fnopie", test_c, NULL, NULL, NULL)) return 0; return try_fail(logdepth, "cc/fnopie"); } int find_cc_fnopic(const char *name, int logdepth, int fatal) { const char *test_c = test_hello_world; require("cc/cc", logdepth, fatal); report("Checking for -fno-pic... "); logprintf(logdepth, "find_cc_fnopic: trying to find -fno-pic...\n"); logdepth++; if (try_icl(logdepth, "cc/fnopic", test_c, NULL, "-fno-pic", NULL)) return 0; if (try_icl(logdepth, "cc/fnopic", test_c, NULL, "-fno-pic", "-static")) return 0; if (try_icl(logdepth, "cc/fnopic", test_c, NULL, NULL, NULL)) return 0; return try_fail(logdepth, "cc/fnopic"); } int find_soname(const char *name, int logdepth, int fatal) { require("cc/cc", logdepth, fatal); report("Checking for soname... "); logprintf(logdepth, "find_soname: trying to find soname...\n"); logdepth++; if (try_hello(logdepth, NULL, "-Wl,-soname,libscconfig.0", "cc/soname", "-Wl,-soname,")) return 0; if (try_hello(logdepth, NULL, NULL, "cc/soname", "")) return 0; report("Not found.\n"); return 1; } int find_wlrpath(const char *name, int logdepth, int fatal) { require("cc/cc", logdepth, fatal); report("Checking for rpath... "); logprintf(logdepth, "find_wlrpath: trying to find rpath...\n"); logdepth++; if (try_hello(logdepth, NULL, "-Wl,-rpath=.", "cc/wlrpath", "-Wl,-rpath=")) return 0; report("Not found.\n"); return 1; } int find_fpic(const char *name, int logdepth, int fatal) { require("cc/cc", logdepth, fatal); report("Checking for -fpic... "); logprintf(logdepth, "find_fpic: trying to find -fpic...\n"); logdepth++; if (try_hello(logdepth, NULL, "-fPIC", "cc/fpic", "-fPIC")) return 0; if (try_hello(logdepth, NULL, "-fpic", "cc/fpic", "-fpic")) return 0; if (try_hello(logdepth, NULL, NULL, "cc/fpic", "")) return 0; report("Not found.\n"); return 1; } /* Hello world lib... */ static const char *test_lib = NL "#include " NL "int hello() {" NL " puts(\"OK\");" NL " return 0;" NL "}" NL ; /* ...and the corresponding host application */ static const char *test_host = NL "#include " NL "#include " NL "#include %s" NL "int main() {" NL " void *handle = NULL;" NL " void (*func)() = NULL;" NL " char *error;" NL NL " handle = dlopen(\"%s\", RTLD_NOW);" NL " if (handle == NULL) {" NL " printf(\"dlopen fails: \", dlerror());" NL " return 1;" NL " }" NL " func = dlsym(handle, \"hello\");" NL " if (func == NULL) {" NL " printf(\"dlsym fails: \", dlerror());" NL " return 1;" NL " }" NL " func();" NL " return 0;" NL "}" NL ; static int try_dynlib(int logdepth, const char *cflags, char *concated_ldflags, const char *name, const char *value, const char *host_app_cflags, const char *host_app_ldflags) { char test_host_app[1024]; const char *fpic; const char *ld_include; const char *dlc; char *libname, *libname_dyn; char *cflags_c; char *oname = ".o"; int ret = 0; dlc = get("libs/dl-compat"); if ((dlc != NULL) && (strcmp(dlc, strue) == 0)) ld_include = ""; else ld_include = ""; fpic = get("cc/fpic"); if (fpic == NULL) fpic = ""; if (cflags == NULL) cflags=""; cflags_c = malloc(strlen(cflags) + 8 + strlen(fpic)); sprintf(cflags_c, "%s -c %s", cflags, fpic); libname_dyn = libname = (char *)get("sys/ext_dynlib"); if ((compile_code(logdepth, test_lib, &oname, NULL, cflags_c, NULL) != 0) || (compile_file(logdepth, oname, &libname_dyn, NULL, NULL, concated_ldflags) != 0)) { report("FAILED (compiling dynlib)\n"); } else { sprintf(test_host_app, test_host, ld_include, libname_dyn); if (try_flags(logdepth, NULL, test_host_app, host_app_cflags, host_app_ldflags, "OK")) { put(name, value); report("OK (%s)\n", value); ret = 1; } } unlink(libname_dyn); unlink(oname); if (libname != libname_dyn) free(libname_dyn); free(oname); free(concated_ldflags); free(cflags_c); return ret; } int find_ldflags_dynlib(const char *name, int logdepth, int fatal) { require("cc/cc", logdepth, fatal); require("cc/rdynamic", logdepth, fatal); require("cc/fpic", logdepth, fatal); require("libs/ldl", logdepth, fatal); report("Checking for dynamic library ldflags... "); logprintf(logdepth, "find_ldflags_dynlib: trying to find dynamic library ldflags...\n"); logdepth++; if (try_dynlib(logdepth, NULL, concat_nodes("-dynamic -shared", "cc/rdynamic", "libs/ldl", NULL), "cc/ldflags_dynlib", "-dynamic -shared", NULL, get("libs/ldl"))) return 0; if (try_dynlib(logdepth, NULL, concat_nodes("-shared", "cc/rdynamic", "libs/ldl", NULL), "cc/ldflags_dynlib", "-shared", NULL, get("libs/ldl"))) return 0; report("Not found.\n"); return 1; } static int try_dll_or_so(int logdepth, int is_dll, const char *lib_ldflags, const char *name, const char *value, const char *dspec_dllexport, const char *dspec_dllimport, const char *app_cflags, const char *app_ldflags) { static const char *test_lib_template = NL "#include " NL "%s void hello();" NL "void hello() {" NL " puts(\"OK\");" NL "}" NL ; static const char *test_app_template = NL "%s void hello();" NL "int main() {" NL " hello();" NL " return 0;" NL "}" NL ; char test_lib[1024]; char test_app[1024]; const char *fpic; char *cflags_c; char *oname, *oname_ext; char *libname, *libname_ext; char *appname = NULL, *appname_ext = NULL; char *lib_filename = NULL, *lib_dirname = NULL; char *lib_ldflags_new = NULL; char *app_ldflags_new = NULL; size_t len, ii; int ret = 0; ++logdepth; require("cc/cc", logdepth, 0); require("cc/cflags", logdepth, 0); require("cc/ldflags", logdepth, 0); require("cc/fpic", logdepth, 0); require("sys/ext_exe", logdepth, 0); require("sys/ext_dynlib_native", logdepth, 0); fpic = get("cc/fpic"); if (fpic == NULL) fpic = ""; if (app_cflags == NULL) app_cflags = ""; if (app_ldflags == NULL) app_ldflags = ""; cflags_c = str_concat(" ", get("cc/cflags"), "-c", fpic, NULL); oname = oname_ext = ".o"; libname = libname_ext = (char *)get("sys/ext_dynlib_native"); sprintf(test_lib, test_lib_template, dspec_dllexport); lib_ldflags_new = str_concat(" ", get("cc/ldflags"), lib_ldflags, NULL); if ((compile_code(logdepth, test_lib, &oname, NULL, cflags_c, NULL) != 0) || (compile_file(logdepth, oname, &libname, NULL, NULL, lib_ldflags_new) != 0)) { report("FAILED (compiling %s)\n", (is_dll?"DLL":"SO")); } else { lib_filename = file_name(libname); lib_dirname = dir_name(libname); if (!is_dll) { len = strlen(lib_filename) - strlen(libname_ext); for (ii=3; ii" NL "int main() {" NL " char *s;" NL " s = alloca(128);" NL " if (s != NULL)" NL " puts(\"OK\");" NL " return 0;" NL "}" NL ; static int try_alloca(int logdepth, const char *cflags, const char *ldflags, const char *name, const char *value) { if (try_flags(logdepth, NULL, test_alloca, cflags, ldflags, "OK")) { put(name, value); report("OK (%s)\n", value); return 1; } return 0; } int find_alloca(const char *name, int logdepth, int fatal) { require("cc/cc", logdepth, fatal); report("Checking for alloca()... "); logprintf(logdepth, "find_alloca: trying to find alloca()...\n"); logdepth++; if (try_alloca(logdepth, NULL, NULL, "cc/alloca/presents", "true")) return 0; put("cc/alloca/presents", "false"); report("Not found.\n"); return 1; } int find__exit(const char *name, int logdepth, int fatal) { const char *test_c = NL "#include " NL "int main() {" NL " _exit(0);" NL " puts(\"BAD\");" NL " return 0;" NL "}" NL ; require("cc/cc", logdepth, fatal); report("Checking for _exit()... "); logprintf(logdepth, "find__exit: trying to find _exit()...\n"); logdepth++; if (try_flags_inv(logdepth, NULL, test_c, NULL, NULL, "BAD")) { put("cc/_exit/presents", strue); report("found\n"); return 0; } put("cc/_exit/presents", sfalse); report("Not found.\n"); return 1; } int find_cc_pragma_message(const char *name, int logdepth, int fatal) { const char *test_c = NL "#include " NL "#define DO_PRAGMA(arg) _Pragma(#arg)" NL "#define TODO(x) DO_PRAGMA(message(\"TODO: \" #x))" NL "TODO(test)" NL "int main()" NL "{" NL " puts(\"OK\");" NL "}"; require("cc/cc", logdepth, fatal); report("Checking for _Pragma(message)... "); logprintf(logdepth, "find_cc_pragma_message: trying to find pragma_message...\n"); logdepth++; if (try(logdepth, NULL, test_c, "OK")) { put("cc/pragma_message", strue); report("Found.\n"); return 0; } put("cc/pragma_message", sfalse); report("Not found.\n"); return 1; } xschem-2.8.1/scconfig/src/default/db.c0000644000175100017510000002205013246530251015750 0ustar svnsvn/* scconfig - database Copyright (C) 2009..2012 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include #include #include "db.h" #include "log.h" #include "libs.h" ht_t *DBs = NULL; char *db_cwd = NULL; void append(const char *key, const char *value) { const char *orig; char *new; int l1, l2; assert(key != NULL); assert(value != NULL); if (*value == '\0') return; orig = get(key); if (orig == NULL) { put(key, value); return; } l1 = strlen(orig); l2 = strlen(value); new = malloc(l1 + l2 + 1); memcpy(new, orig, l1); memcpy(new + l1, value, l2); new[l1+l2] = '\0'; put(key, new); } static const char *db_split_path(const char *key, ht_t **ht, char **fld) { size_t fld_len; const char *path; char first_level_dir[32]; path = str_chr((char *)(key+1), '/'); assert(path != NULL); fld_len = path - key; path++; if (*path == '\0') { *ht = NULL; if (fld != NULL) *fld = NULL; return NULL; } assert(fld_len < sizeof(first_level_dir)); strncpy(first_level_dir, key, fld_len); first_level_dir[fld_len] = '\0'; *ht = ht_get(DBs, first_level_dir+1); if (fld != NULL) *fld = first_level_dir; return path; } static void export_qs(FILE *f, const char *s) { fputc('"', f); for(;*s != '\0';s++) { switch(*s) { case '"': fputc('\\', f); fputc('"', f); break; case '\n': fputc('\\', f); fputc('n', f); break; case '\r': fputc('\\', f); fputc('r', f); break; case '\t': fputc('\\', f); fputc('t', f); break; default: fputc(*s, f); } } fputc('"', f); fputc('\n', f); } static int needs_quote(const char *s) { for(; *s != '\0'; s++) if ((*s < 32) || (*s > 126) || (*s == '"')) return 1; return 0; } int export_(FILE *f, int export_empty, ht_t *table, const char *fld) { ht_entry_t *h; for(h = ht_first(table); h != NULL; h = ht_next(table, h)) if (export_empty || ((h->value != NULL) && (*(char *)h->value != '\0'))) { fprintf(f, "/%s/%s=", fld, h->key); if (h->value != NULL) { if (needs_quote((char *)h->value)) export_qs(f, (const char *)h->value); else fprintf(f, "%s\n", (char *)h->value); } else fprintf(f, "\n"); } return 0; } int export(const char *fn, int export_empty, const char *root) { FILE *f; int ret; /* ht_t *table; */ ht_entry_t *h; if (fn != NULL) { f = fopen(fn, "w"); if (f == NULL) return -1; } else f = stdout; if ((root == NULL) || ((root[0] == '/') && (root[1] == '\0'))) { /* export all directories */ for(h = ht_first(DBs); h != NULL; h = ht_next(DBs, h)) ret += export_(f, export_empty, h->value, h->key); } else { error("not yet implemented\n"); abort(); /* db_split_path(); */ } if (f != stdout) fclose(f); return ret; } /* append a single character, grow the buffer as needed */ #define qappend(chr) \ do { \ if (used >= alloced) { \ alloced += 256; \ res = realloc(res, alloced); \ } \ res[used] = chr; \ used++; \ } while(0) /* read until end of quote and interpret backslash sequences if do_esc is non-zero */ static char *readq(FILE *f, char *str, long strmax, int quote, int do_esc, int *num_lines, const char *fn) { int bs = 0; long used = 0, alloced = 0; char *res = NULL, *s; for(;;) { for(s = str; *s != '\0'; s++) { if (*s == '\n') (*num_lines)++; if (bs) { /* character escaped by backslash */ switch(*s) { case '\\': qappend('\\'); break; case 'n': qappend('\n'); break; case 'r': qappend('\r'); break; case 't': qappend('\t'); break; default: qappend(*s); break; } bs = 0; } else if (*s == quote) { /* end */ qappend('\0'); if ((s[1] != '\r') && (s[1] != '\n') && (s[1] != '\0')) fprintf(stderr, "Warning: trailing text after quote ignored in %s:%d\n", fn, (*num_lines)+1); return res; } else if (do_esc && (*s == '\\')) bs = 1; /* backslash start */ else qappend(*s); /* plain character */ } /* get the next chunk */ fgets(str, strmax, f); } return NULL; /* can't get here */ } int import(const char *fn) { char line[1024]; char *key, *value, *nl, *slash; int num_records, num_lines; FILE *f; f = fopen(fn, "r"); if (f == NULL) return -1; for(num_records = 0, num_lines = 0; !feof(f); num_lines++) { *line = '\0'; fgets(line, sizeof(line) - 1, f); if ((*line != '#') && (*line != '\n') && (*line != '\r') && (*line != '\0')) { int quote, do_esc=0; key = line; value = str_chr(key, '='); if (value == NULL) { error("Error importing: missing '=' in line %d in file %s.\n", num_lines, fn); abort(); } num_records++; *value = '\0'; value++; if (*value == '"') { quote=*value; value++; do_esc=1; } else if (*value == '\'') { quote=*value; value++; } else quote=0; if (!quote) { nl = str_chr(value, '\n'); if (nl != NULL) *nl = '\0'; } else value = readq(f, value, sizeof(line) - (value - line) - 4, quote, do_esc, &num_lines, fn); slash = str_chr(key+1, '/'); if (slash == NULL) { error("Error importing: no directory name for %s.\n", key); abort(); } *slash = '\0'; db_mkdir(key); *slash = '/'; put(key, value); logprintf(0, "(Import from '%s': '%s'='%s')\n", fn, key, value); if (quote) free(value); } } fclose(f); return num_records; } int import_args(const char *key, const char *fn) { (void) key; /* suppress compiler warnings for unused key; needed because function pointers to this function from arg.c */ db_mkdir("/target"); db_mkdir("/host"); return import(fn) < 0; } static const char *db_get(const char *key) { const char *path; ht_t *ht; path = db_split_path(key, &ht, NULL); if (ht == NULL) return NULL; return ht_get(ht, path); } static const char *db_put(const char *key, const char *value) { const char *path; ht_t *ht; path = db_split_path(key, &ht, NULL); if (ht == NULL) { error("db_put: can't find top level hash for '%s'\n", key); abort(); } return ht_set(ht, path, (void *)value); } #define assamble_path \ assert(strlen(key) + strlen(db_cwd) < sizeof(tmp)-1); \ sprintf(tmp, "%s/%s", db_cwd, key); const char *get(const char *key) { char tmp[256]; if (*key == '/') return db_get(key); assamble_path; return db_get(tmp); } const char *put(const char *key, const char *value) { char tmp[256]; if (*key == '/') return db_put(key, value); assamble_path; return db_put(tmp, value); } void db_init(void) { DBs = ht_resize(ht_alloc(0), 16); } void db_uninit(void) { ht_entry_t *h; ht_t *dir; for(h = ht_first(DBs); h != NULL; h = ht_next(DBs, h)) { dir = h->value; dir->refcount--; if (dir->refcount == 0) ht_free(dir); } ht_free(DBs); if (db_cwd != NULL) free(db_cwd); /* Just in case someone calls db_init again... */ db_cwd = NULL; DBs = NULL; } void db_cd(const char *path) { assert(*path == '/'); if (db_cwd != NULL) free(db_cwd); db_cwd = strclone(path); } void db_mkdir(const char *path) { ht_t *ht, *target; assert(*path == '/'); target = ht_get(DBs, path+1); if (target == NULL) { ht = ht_resize(ht_alloc(1), 256); ht_set(DBs, path+1, ht); } } void db_rmdir(const char *path) { ht_t *ht; assert(*path == '/'); ht = ht_get(DBs, path+1); if (ht == NULL) return; ht_del(DBs, path+1); /* ht_free(ht); */ } void db_link(const char *existing, const char *new) { ht_t *ht; assert(*new == '/'); ht = ht_get(DBs, existing+1); assert(ht != NULL); ht_set(DBs, new+1, ht); ht->refcount++; } char *concat_nodes(const char *prefix, ...) { char *buff; const char *node, *value; int allocated = 256, len, totallen; va_list ap; va_start(ap, prefix); buff = malloc(allocated); if (prefix != NULL) { strcpy(buff, prefix); totallen = strlen(prefix); buff[totallen] = ' '; totallen++; } else totallen = 0; while((node = va_arg(ap, const char *)) != NULL) { value = get(node); if (value != NULL) { len = strlen(value); if (totallen + len >= allocated) { allocated = totallen + len + 256; buff = realloc(buff, allocated); } memcpy(buff + totallen, value, len); totallen += len; buff[totallen] = ' '; totallen++; buff[totallen] = '\0'; } } buff[totallen - 1] = '\0'; va_end(ap); return buff; } int node_istrue(const char *key) { const char *s = get(key); if (s == NULL) return 0; return istrue(s); } xschem-2.8.1/scconfig/src/default/main_lib.h0000644000175100017510000000025412661010062017135 0ustar svnsvnint main_init(void); int main_process_args(int argc, char *argv[]); void main_uninit(void); /* internal */ void init(void); void uninit(void); void run_custom_reqs(void); xschem-2.8.1/scconfig/src/default/arg.h0000644000175100017510000000054313323012037016135 0ustar svnsvn#ifndef SCC_ARG_H #define SCC_ARG_H typedef struct { char *arg; char *path; int (*callback)(const char *key, const char *value); char *help; } argtbl_t; extern argtbl_t main_argument_table[]; void process_args(int argc, char *argv[]); /* main.c: */ extern int custom_arg(const char *key, const char *value); extern int num_custom_reqs; #endif xschem-2.8.1/scconfig/src/default/find_signal.c0000644000175100017510000000736113371256503017654 0ustar svnsvn/* scconfig - detection of standard library features Copyright (C) 2009 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include "libs.h" #include "log.h" #include "db.h" #include "dep.h" static int try_bad(int logdepth, const char *test_c, char *cflags, char *ldflags) { char *out = NULL; logprintf(logdepth, "trying signal (neg) with ldflags '%s'\n", ldflags == NULL ? get("cc/ldflags") : ldflags); if (compile_run(logdepth+1, test_c, NULL, cflags, ldflags, &out) == 0) { if (target_emu_fail(out) || (strncmp(out, "BAD", 3) == 0)) { free(out); return 0; } free(out); } return 1; } int find_signal_raise(const char *name, int logdepth, int fatal) { char *test_c = NL "#include " NL "#include " NL "int main(int argc, char *argv[]) {" NL " printf(\"OK\\n\");" NL " if (argc == 16)" NL " raise(1);" NL " return 0;" NL "}" NL; require("cc/cc", logdepth, fatal); report("Checking for raise()... "); logprintf(logdepth, "find_signal_raise: trying to find raise()...\n"); logdepth++; if (try_icl(logdepth, "signal/raise", test_c, NULL, NULL, NULL)) return 0; return try_fail(logdepth, "signal/raise"); } int find_signal_names(const char *rname, int logdepth, int fatal) { char *test_c_exists = NL "#include " NL "#include " NL "int main(int argc, char *argv[]) {" NL " printf(\"OK\\n\");" NL " if (argc == 16)" NL " raise(%s);" NL " return 0;" NL "}" NL; char *test_c_terms = NL "#include " NL "#include " NL "int main() {" NL " raise(%s);" NL " printf(\"BAD\\n\");" NL " return 0;" NL "}" NL; char test_c[256]; const char *names[] = {"SIGINT", "SIGABRT", "SIGKILL", "SIGTERM", "SIGQUIT", "SIGHUP", "SIGFPE", "SIGSEGV", "SIGPIPE", NULL}; const char **name; char path[256], *pathend; const char *prefix = "signal/names/"; require("cc/cc", logdepth, fatal); require("signal/raise/*", logdepth, fatal); strcpy(path, prefix); pathend = path + strlen(prefix); for(name = names; *name != NULL; name++) { /* check whether it exists */ report("Checking whether %s exists... ", *name); logprintf(logdepth, "find_signal_names: checking whether %s exists\n", *name); logdepth++; sprintf(test_c, test_c_exists, *name); strcpy(pathend, *name); if (!try_icl(logdepth, path, test_c, NULL, NULL, NULL)) { logdepth--; continue; } /* check whether it exists */ logdepth--; report("Checking whether %s terminates... ", *name); logprintf(logdepth, "find_signal_names: checking whether %s terminates\n", *name); logdepth++; sprintf(test_c, test_c_terms, *name); sprintf(pathend, "%s/terminates", *name); if (try_bad(logdepth, test_c, NULL, "")) { put(path, strue); report("terminates\n"); } else { report("does not terminate\n"); put(path, sfalse); } logdepth--; } /* to avoid redetection */ put("signal/names/presents", strue); return 0; } xschem-2.8.1/scconfig/src/default/main_lib.c0000644000175100017510000000730113174300143017132 0ustar svnsvn/* scconfig - helpers for a main() Copyright (C) 2009..2016 Tibor Palinkas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Project page: http://repo.hu/projects/scconfig Contact via email: scconfig [at] igor2.repo.hu */ #include #include #include #include "db.h" #include "find.h" #include "log.h" #include "arg.h" #include "dep.h" #include "deps_default.h" #include "libs.h" #include "hooks.h" #include "regex.h" #include "main_custom_args.h" #ifdef PLUGIN_SCRIPTS #include "../scripts/INIT.h" #endif #ifdef PLUGIN_PARSER #include "../parser/INIT.h" #endif #ifdef PLUGIN_C99 #include "../c99/INIT.h" #endif #ifdef PLUGIN_PARSGEN #include "../parsgen/INIT.h" #endif #ifdef PLUGIN_MATH #include "../math/INIT.h" #endif #ifdef PLUGIN_SOCKET #include "../socket/INIT.h" #endif #ifdef PLUGIN_USERPASS #include "../userpass/INIT.h" #endif #ifdef PLUGIN_GUI #include "../gui/INIT.h" #endif #ifdef PLUGIN_TTY #include "../tty/INIT.h" #endif #ifdef PLUGIN_SUL #include "../sul/INIT.h" #endif #ifdef PLUGIN_POSIX #include "../posix/INIT.h" #endif #ifdef PLUGIN_GENERATOR #include "generator.h" #endif void init(void) { db_init(); log_init(); dep_init(); deps_default_init(); /* common internal directory */ db_mkdir("/internal"); /* We have a host system for sure - also make it the default */ db_mkdir("/host"); db_cd("/host"); /* emulator for the host system is empty string */ put("sys/emu", ""); #ifdef PLUGIN_SCRIPTS #include "../scripts/INIT.c" #endif #ifdef PLUGIN_PARSER #include "../parser/INIT.c" #endif #ifdef PLUGIN_C99 #include "../c99/INIT.c" #endif #ifdef PLUGIN_PARSGEN #include "../parsgen/INIT.c" #endif #ifdef PLUGIN_MATH #include "../math/INIT.c" #endif #ifdef PLUGIN_SOCKET #include "../socket/INIT.c" #endif #ifdef PLUGIN_USERPASS #include "../userpass/INIT.c" #endif #ifdef PLUGIN_GUI #include "../gui/INIT.c" #endif #ifdef PLUGIN_TTY #include "../tty/INIT.c" #endif #ifdef PLUGIN_SUL #include "../sul/INIT.c" #endif #ifdef PLUGIN_POSIX #include "../posix/INIT.c" #endif #ifdef PLUGIN_GENERATOR #include "../generator/INIT.c" #endif } void uninit(void) { log_uninit(); dep_uninit(); db_uninit(); } void run_custom_reqs(void) { int n; if (num_custom_reqs > 0) { printf("Running custom requirements\n"); for(n = 0; n < num_custom_reqs; n++) { if (custom_reqs[n] == NULL) { fprintf(stderr, "Error: requested detection of empty string - please check your command line, syntax is --detect=node\n"); exit(1); } require(custom_reqs[n], 1, 1); } } } int main_init(void) { re_modw("./\\"); if (hook_preinit()) { fprintf(stderr, "hook_preinit failed, exiting\n"); return 1; } init(); if (hook_postinit()) { fprintf(stderr, "hook_postinit failed, exiting\n"); return 1; } return 0; } int main_process_args(int argc, char *argv[]) { process_args(argc, argv); if (hook_postarg()) { fprintf(stderr, "hook_postarg failed, exiting\n"); return 1; } return 0; } void main_uninit(void) { hook_preuninit(); uninit(); hook_postuninit(); } xschem-2.8.1/scconfig/hooks.c0000644000175100017510000002117313373443265014311 0ustar svnsvn#include #include #include "arg.h" #include "db.h" #include "libs.h" #include "log.h" #include "dep.h" #include "tmpasm_scconfig.h" #define version "2.0.1" static void help(void) { printf("./configure: configure xschem.\n"); printf("\n"); printf("Usage: ./configure [options]\n"); printf("\n"); printf("options are:\n"); printf(" --prefix=path change installation prefix from /usr/local to path\n"); printf(" --debug build full debug version (-g -O0)\n"); printf(" --profile build profiling version if available (-pg)\n"); printf(" --symbols include symbols (add -g, but no -O0)\n"); printf(" --user-conf-dir change the user conf dir (e.g. ~/.xschem)\n"); printf(" --user-lib-path set the user library path\n"); printf(" --sys-lib-path set the system library path\n"); printf(" --xschem-lib-path overrides the final list of library search paths\n"); printf(" /arg/tk-version=8.x force detecting a specific version of tcl/tk\n"); } /* Runs when a custom command line argument is found returns true if no further argument processing should be done */ int hook_custom_arg(const char *key, const char *value) { if (strcmp(key, "prefix") == 0) { report("Setting prefix to '%s'\n", value); put("/local/xschem/prefix", strclone(value)); return 1; } if (strcmp(key, "debug") == 0) { put("/local/xschem/debug", strue); return 1; } if (strcmp(key, "profile") == 0) { put("/local/xschem/profile", strue); return 1; } if (strcmp(key, "symbols") == 0) { put("/local/xschem/symbols", strue); return 1; } if (strcmp(key, "user-conf-dir") == 0) { put("/local/xschem/user-conf-dir", value); return 1; } if (strcmp(key, "user-lib-path") == 0) { put("/local/xschem/user-lib-path", value); return 1; } if (strcmp(key, "sys-lib-path") == 0) { put("/local/xschem/sys-lib-path", value); return 1; } if (strcmp(key, "xschem-lib-path") == 0) { put("/local/xschem/xschem-lib-path", value); return 1; } if (strcmp(key, "help") == 0) { help(); exit(0); } return 0; } /* Runs before anything else */ int hook_preinit() { return 0; } /* Runs after initialization */ int hook_postinit() { db_mkdir("/local"); db_mkdir("/local/xschem"); /* DEFAULTS */ put("/local/xschem/prefix", "/usr/local"); put("/local/xschem/debug", sfalse); put("/local/xschem/profile", sfalse); put("/local/xschem/symbols", sfalse); put("/local/xschem/user-conf-dir", "~/.xschem"); return 0; } /* Runs after all arguments are read and parsed */ int hook_postarg() { if (get("/local/xschem/user-lib-path") == NULL) { put("/local/xschem/user-lib-path", get("/local/xschem/user-conf-dir")); append("/local/xschem/user-lib-path", "/xschem_library"); } if (get("/local/xschem/sys-lib-path") == NULL) { put("/local/xschem/sys-lib-path", get("/local/xschem/prefix")); append("/local/xschem/sys-lib-path", "/"); append("/local/xschem/sys-lib-path", "share/xschem/xschem_library"); } if (get("/local/xschem/xschem-lib-path") == NULL) { put("/local/xschem/xschem-lib-path", get("/local/xschem/user-lib-path")); append("/local/xschem/xschem-lib-path", ":"); append("/local/xschem/xschem-lib-path", get("/local/xschem/sys-lib-path")); } return 0; } /* Runs when things should be detected for the compilation host system (commands that will be executed on host and will produce files to be used on host) */ int hook_detect_host() { return 0; } static void disable_xcb(void) { put("libs/gui/xcb/presents", ""); put("libs/gui/xcb/includes", ""); put("libs/gui/xcb/cflags", ""); put("libs/gui/xcb/ldflags", ""); put("libs/gui/xcb_render/presents", ""); put("libs/gui/xcb_render/includes", ""); put("libs/gui/xcb_render/cflags", ""); put("libs/gui/xcb_render/ldflags", ""); put("libs/gui/xgetxcbconnection/presents", ""); put("libs/gui/xgetxcbconnection/includes", ""); put("libs/gui/xgetxcbconnection/cflags", ""); put("libs/gui/xgetxcbconnection/ldflags", ""); } /* Runs when things should be detected for the host->target system (commands that will be executed on host but will produce files to be used on target) */ int hook_detect_target() { require("cc/fpic", 0, 0); { /* need to set debug flags here to make sure libs are detected with the modified cflags; -ansi matters in what #defines we need for some #includes */ const char *tmp, *fpic, *debug; fpic = get("/target/cc/fpic"); if (fpic == NULL) fpic = ""; debug = get("/arg/debug"); if (debug == NULL) debug = ""; tmp = str_concat(" ", fpic, debug, NULL); put("/local/global_cflags", tmp); /* for --debug mode, use -ansi -pedantic for all detection */ if (istrue(get("/local/xschem/debug"))) { append("cc/cflags", " -g -O0"); if (require("cc/argstd/Wall", 0, 0) == 0) { append("cc/cflags", " "); append("cc/cflags", get("cc/argstd/Wall")); } if (require("cc/argstd/std_c89", 0, 0) == 0) { append("cc/cflags", " "); append("cc/cflags", get("cc/argstd/std_c89")); } if (require("cc/argstd/pedantic", 0, 0) == 0) { append("cc/cflags", " "); append("cc/cflags", get("cc/argstd/pedantic")); } } else { append("cc/cflags", " -O2"); if (istrue(get("/local/xschem/symbols"))) append("cc/cflags", " -g"); } if (istrue(get("/local/xschem/profile"))) { if (require("cc/argstd/pg", 0, 0) == 0) { append("cc/cflags", " "); append("cc/cflags", get("cc/argstd/pg")); } if (require("cc/argstd/no-pie", 0, 0) == 0) { append("cc/cflags", " "); append("cc/cflags", get("cc/argstd/no-pie")); } } } if (require("libs/io/popen/*", 0, 0) != 0) { if (require("libs/proc/fork/*", 0, 0) == 0) /* pipe is used together with fork, both needed */ require("libs/io/pipe/*", 0, 0); } require("parsgen/flex/presents", 0, 1); require("parsgen/bison/presents", 0, 1); require("libs/script/tk/*", 0, 1); /* this will also bring libs/script/tcl/* */ require("fstools/awk", 0, 1); require("libs/gui/xpm/*", 0, 1); require("libs/gui/cairo/*", 0, 0); require("libs/gui/xrender/*", 0, 0); if (require("libs/gui/xcb/*", 0, 0) == 0) { /* if xcb is used, the code requires these: */ require("libs/gui/xgetxcbconnection/*", 0, 0); if (!istrue(get("libs/gui/xgetxcbconnection/presents"))) { report("Disabling xcb because xgetxcbconnection is not found...\n"); disable_xcb(); } else { require("libs/gui/xcb_render/*", 0, 0); if (!istrue(get("libs/gui/xcb_render/presents"))) { report("Disabling xcb because xcb_render is not found...\n"); disable_xcb(); } } } return 0; } /* Runs when things should be detected for the runtime system (commands that will be executed only on the target, never on host) */ int hook_detect_runtime() { return 0; } static const char *isok(int retval, int *accumulator) { *accumulator |= retval; return (retval == 0) ? "ok" : "ERROR"; } /* Runs after detection hooks, should generate the output (Makefiles, etc.) */ int hook_generate() { int generr = 0; printf("\n--- Generating build and config files\n"); printf("config.h: %s\n", isok(tmpasm("..", "config.h.in", "config.h"), &generr)); printf("Makefile.conf: %s\n", isok(tmpasm("..", "Makefile.conf.in", "Makefile.conf"), &generr)); printf("src/Makefile: %s\n", isok(tmpasm("../src", "Makefile.in", "Makefile"), &generr)); if (!generr) { printf("\n\n"); printf("=====================\n"); printf("Configuration summary\n"); printf("=====================\n"); printf("\nCompilation:\n"); printf(" CC: %s\n", get("/target/cc/cc")); printf(" debug: %s\n", istrue(get("/local/xschem/debug")) ? "yes" : "no"); printf(" profiling: %s\n", istrue(get("/local/xschem/profile")) ? "yes" : "no"); printf("\nPaths:\n"); printf(" prefix: %s\n", get("/local/xschem/prefix")); printf(" user-conf-dir: %s\n", get("/local/xschem/user-conf-dir")); printf(" user-lib-path: %s\n", get("/local/xschem/user-lib-path")); printf(" sys-lib-path: %s\n", get("/local/xschem/sys-lib-path")); printf("\nLibs & features:\n"); printf(" tcl: %s\n", get("/target/libs/script/tcl/ldflags")); printf(" tk: %s\n", get("/target/libs/script/tk/ldflags")); printf(" cairo: %s\n", istrue(get("/target/libs/gui/cairo/presents")) ? "yes" : "no"); printf(" xrender: %s\n", istrue(get("/target/libs/gui/xrender/presents")) ? "yes" : "no"); printf(" xcb: %s\n", istrue(get("/target/libs/gui/xcb/presents")) ? "yes" : "no"); printf("\nConfiguration complete, ready to compile.\n\n"); } return 0; } /* Runs before everything is uninitialized */ void hook_preuninit() { } /* Runs at the very end, when everything is already uninitialized */ void hook_postuninit() { } xschem-2.8.1/COPYING0000644000175100017510000004310313365020432012243 0ustar svnsvn GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. xschem-2.8.1/src/0000755000175100017510000000000013400743705012003 5ustar svnsvnxschem-2.8.1/src/node_hash.c0000644000175100017510000003121513377077322014111 0ustar svnsvn/* File: node_hash.c * * This file is part of XSCHEM, * a schematic capture and Spice/Vhdl/Verilog netlisting tool for circuit * simulation. * Copyright (C) 1998-2018 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 */ #include "xschem.h" #define SPACE(c) (c=='=' || c=='\n' || c==' ' || c=='\t' || \ c=='\0' || c==';' || c=='/') static struct node_hashentry *table[HASHSIZE]; static unsigned int hash(char *tok) { unsigned int hash = 0; int c; while ( (c = *tok++) ) hash = c + (hash << 6) + (hash << 16) - hash; return hash; } struct node_hashentry **get_node_table_ptr(void) { return table; } void print_vhdl_signals(FILE *fd) { struct node_hashentry *ptr; int i, found; int mult,j; static char *class=NULL; found=0; for(i=0;id.port == 0 ) { found = 1; if(ptr->token[0]=='#') { mult=get_unnamed_node(3, 0, strtol((ptr->token)+4, NULL,10) ); } else { mult=1; } if(debug_var>=2) fprintf(errfp, " print_vhdl_signals(): node: %s mult: %d value=%s \n\n", ptr->token,mult, ptr->value?ptr->value:"NULL"); if( ptr->class && ptr->class[0] ) my_strdup(277, &class, ptr->class); else my_strdup(278, &class, "signal"); if(mult>1) { for(j=mult-1;j>=0;j--) { fprintf(fd, "%s %s[%d] : ", class, ptr->token[0]=='#' ? ptr->token+1 : ptr->token,j); if(ptr->sig_type && ptr->sig_type[0]) { fprintf(fd, "%s", ptr->sig_type); } else fprintf(fd, "std_logic"); if(ptr->value && ptr->value[0]) fprintf(fd, " := %s ", ptr->value); fprintf(fd, " ; %s\n", ptr->orig_tok); } } else { fprintf(fd, "%s %s : ", class, ptr->token[0]=='#' ? ptr->token+1 : ptr->token); if(ptr->sig_type && ptr->sig_type[0]) { fprintf(fd, "%s", ptr->sig_type); } else fprintf(fd, "std_logic"); if(ptr->value && ptr->value[0]) fprintf(fd, " := %s ", ptr->value); fprintf(fd, " ; %s\n", ptr->orig_tok); } } ptr = ptr->next; } } if(found) fprintf(fd, "\n" ); } void print_verilog_signals(FILE *fd) { struct node_hashentry *ptr; int i, found; int mult,j; if(debug_var>=2) fprintf(errfp, " print_verilog_signals(): entering routine\n"); found=0; for(i=0;id.port == 0 ) { found = 1; if(ptr->token[0]=='#') { mult=get_unnamed_node(3, 0, strtol((ptr->token)+4, NULL,10) ); } else { mult=1; } if(debug_var>=2) fprintf(errfp, " print_verilog_signals(): node: %s mult: %d value=%s \n\n", ptr->token,mult, ptr->value?ptr->value:"NULL"); if(mult>1) { for(j=mult-1;j>=0;j--) { if(ptr->verilog_type && ptr->verilog_type[0]) /*09112003 */ { fprintf(fd, "%s ", ptr->verilog_type); } else fprintf(fd, "wire "); fprintf(fd, "%s[%d] ", ptr->token[0]=='#' ? ptr->token+1 : ptr->token,j); if(ptr->value && ptr->value[0]) fprintf(fd, "= %s ", ptr->value); fprintf(fd, "; // %s\n", ptr->orig_tok); } } else { if(ptr->verilog_type && ptr->verilog_type[0]) /*09112003 */ { fprintf(fd, "%s ", ptr->verilog_type); } else fprintf(fd, "wire "); fprintf(fd, "%s ", ptr->token[0]=='#' ? ptr->token+1 : ptr->token); if(ptr->value && ptr->value[0]) fprintf(fd, "= %s ", ptr->value); fprintf(fd, "; // %s\n", ptr->orig_tok); } } ptr = ptr->next; } } if(found) fprintf(fd, "\n" ); } /* wrapper to node_hash_lookup that handles buses */ /* warning, in case of buses return only pointer to first bus element */ struct node_hashentry *bus_hash_lookup(char *token, char *dir,int remove,int port, char *sig_type,char *verilog_type, char *value, char *class) { char *start, *string_ptr, c; int mult; char *string=NULL; struct node_hashentry *ptr1=NULL, *ptr2=NULL; if(token==NULL) return NULL; if( token[0] == '#') { my_strdup(279, &string, token); } else { if(debug_var >=3) fprintf(errfp, "bus_hash_lookup(): expanding node: %s\n", token); my_strdup(280, &string, expandlabel(token,&mult)); if(debug_var >=3) fprintf(errfp, "bus_hash_lookup(): done expanding node: %s\n", token); } if(string==NULL) return NULL; string_ptr = start = string; while(1) { c=(*string_ptr); if(c==','|| c=='\0') { *string_ptr='\0'; /* set end string at comma position.... */ /* insert one bus element at a time in hash table */ ptr1=node_hash_lookup(start, dir, remove,port, sig_type, verilog_type, value, class, token); if(!ptr2) ptr2=ptr1; if(debug_var >=3) fprintf(errfp, "bus_hash_lookup(): processing node: %s\n", start); *string_ptr=c; /* ....restore original char */ start=string_ptr+1; } if(c==0) break; string_ptr++; } /* if something found return first pointer */ my_free(&string); return ptr2; } struct node_hashentry *node_hash_lookup(char *token, char *dir,int remove,int port, char *sig_type, char *verilog_type, char *value, char *class, char *orig_tok) /* token dir remove ... what ... */ /* -------------------------------------------------------------------------- */ /* "whatever" "in"/"out" 0 insert in hash table if not in and return NULL */ /* if already present just return entry address */ /* and update in/out fields sum up port field */ /* return NULL otherwise */ /* */ /* "whatever" whatever 1 delete entry if found return NULL */ /* "whatever" whatever 2 only look up element, dont insert */ { unsigned int hashcode, index; struct node_hashentry *entry, *saveptr, **preventry; char *ptr; int s ; struct drivers d; if(debug_var>=3) fprintf(errfp, "node_hash_lookup(): called with: %s dir=%s remove=%d port=%d\n", token, dir, remove, port); d.in=d.out=d.inout=0; if(!strcmp(dir,"in") ) d.in=1; else if(!strcmp(dir,"out") ) d.out=1; else if(!strcmp(dir,"inout") ) d.inout=1; d.port=port; if(token==NULL || token[0]==0 ) return NULL; hashcode=hash(token); index=hashcode % HASHSIZE; entry=table[index]; preventry=&table[index]; while(1) { if( !entry ) /* empty slot */ { if( (remove==0) ) /* insert data */ { s=sizeof( struct node_hashentry ); ptr= my_malloc(281, s ); entry=(struct node_hashentry *)ptr; entry->next = NULL; entry->token = entry->sig_type = entry->verilog_type = entry->value = entry->class = entry->orig_tok = NULL; my_strdup(282, &(entry->token),token); if(sig_type &&sig_type[0]) my_strdup(283, &(entry->sig_type), sig_type); /* 24092001 */ if(verilog_type &&verilog_type[0]) my_strdup(284, &(entry->verilog_type), verilog_type); /* 09112003 */ if(class && class[0]) my_strdup(285, &(entry->class), class); /* 07102001 */ if(orig_tok && orig_tok[0]) my_strdup(286, &(entry->orig_tok), orig_tok); /* 08102001 */ if(value && value[0]) my_strdup(287, &(entry->value), value); /* 27092001 */ entry->d.port=d.port; entry->d.in=d.in; entry->d.out=d.out; entry->d.inout=d.inout; entry->hash=hashcode; *preventry=entry; if(debug_var>=3) fprintf(errfp, "node_hash_lookup(): hashing %s : value=%s\n\n", entry->token, entry->value? entry->value:"NULL"); if(debug_var>=3) fprintf(errfp, "node_hash_lookup(): hashing %s in=%d out=%d inout=%d port=%d\n", token, d.in, d.out, d.inout, d.port); } return NULL; /* whether inserted or not return NULL since it was not in */ } if( entry -> hash==hashcode && strcmp(token,entry->token)==0 ) /* found matching tok */ { if(remove==1) /* remove token from the hash table ... */ { saveptr=entry->next; if(entry->token) my_free(& entry->token); if(entry->verilog_type) my_free(& entry->verilog_type); /* 09112003 */ if(entry->sig_type) my_free(& entry->sig_type); /* 24092001 */ if(entry->class) my_free(& entry->class); /* 07102001 */ if(entry->orig_tok) my_free(& entry->orig_tok); /* 07102001 */ if(entry->value) my_free(& entry->value); /* 27092001 */ my_free(&entry); *preventry=saveptr; return NULL; } else /* found matching entry, return the address and update in/out count */ { entry->d.port+=port; entry->d.in+=d.in; entry->d.out+=d.out; entry->d.inout+=d.inout; if(sig_type && sig_type[0] !='\0') my_strdup(288, &(entry->sig_type), sig_type); /* 24092001 */ if(verilog_type && verilog_type[0] !='\0') my_strdup(289, &(entry->verilog_type), verilog_type); /* 09112003 */ if(value && value[0] !='\0') my_strdup(290, &(entry->value), value); /* 27092001 */ if(debug_var>=3) fprintf(errfp, "node_hash_lookup(): hashing %s : value=%s\n\n", entry->token, entry->value? entry->value:"NULL"); return entry; } } preventry=&entry->next; /* descend into the list. */ entry = entry->next; } } void traverse_node_hash() { int i; struct node_hashentry *entry; char str[2048]; /* 20161122 overflow safe */ if(!show_erc)return; for(i=0;id.out + entry->d.inout + entry->d.in == 1) { my_snprintf(str, S(str), "open net: %s", entry->token); if(!netlist_count) bus_hilight_lookup(entry->token, hilight_color,0); if(incr_hilight) hilight_color++; statusmsg(str,2); } else if(entry->d.out ==0 && entry->d.inout == 0) { my_snprintf(str, S(str), "undriven node: %s", entry->token); if(!netlist_count) bus_hilight_lookup(entry->token, hilight_color,0); if(incr_hilight) hilight_color++; statusmsg(str,2); } else if(entry->d.out >=2 && entry->d.port>=0) /* era d.port>=2 03102001 */ { my_snprintf(str, S(str), "shorted output node: %s", entry->token); if(!netlist_count) bus_hilight_lookup(entry->token, hilight_color,0); if(incr_hilight) hilight_color++; statusmsg(str,2); } else if(entry->d.in ==0 && entry->d.inout == 0) { my_snprintf(str, S(str), "node: %s goes nowhere", entry->token); if(!netlist_count) bus_hilight_lookup(entry->token, hilight_color,0); if(incr_hilight) hilight_color++; statusmsg(str,2); } else if(entry->d.out >=2 && entry->d.inout == 0 && entry->d.port>=0) /* era d.port>=2 03102001 */ { my_snprintf(str, S(str), "shorted output node: %s", entry->token); if(!netlist_count) bus_hilight_lookup(entry->token, hilight_color,0); if(incr_hilight) hilight_color++; statusmsg(str,2); } if(debug_var>=1) fprintf(errfp, "traverse_node_hash(): node: %s in=%d out=%d inout=%d port=%d\n", entry->token, entry->d.in, entry->d.out, entry->d.inout, entry->d.port); entry = entry->next; } } } static int collisions, max_collisions=0, n_elements=0; static struct node_hashentry *free_hash_entry(struct node_hashentry *entry) { struct node_hashentry *tmp; while(entry) { n_elements++; collisions++; tmp = entry->next; if(entry->token) my_free(&entry->token); if(entry->verilog_type) my_free(&entry->verilog_type); /* 09112003 */ if(entry->sig_type) my_free(&entry->sig_type); /* 24092001 */ if(entry->class) my_free(&entry->class); /* 07102001 */ if(entry->orig_tok) my_free(&entry->orig_tok); /* 07102001 */ if(entry->value) my_free(&entry->value); /* 27092001 */ my_free(&entry); entry = tmp; } return NULL; } void free_node_hash(void) /* remove the whole hash table */ { int i; if(debug_var>=2) fprintf(errfp, "free_hash(): removing hash table\n"); n_elements=0; for(i=0;imax_collisions) max_collisions=collisions; } if(debug_var>=1) fprintf(errfp, "# free_node_hash(): max_collisions=%d n_elements=%d hashsize=%d\n", max_collisions, n_elements, HASHSIZE); max_collisions=0; } xschem-2.8.1/src/icon.c0000644000175100017510000000735213371731206013106 0ustar svnsvn/* File: icon.c * * This file is part of XSCHEM, * a schematic capture and Spice/Vhdl/Verilog netlisting tool for circuit * simulation. * Copyright (C) 1998-2018 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 */ /* XPM */ char *cad_icon[] = { /* columns rows colors chars-per-pixel */ "60 41 6 1", " c black", ". c #78787C7C7878", "X c #0000A8A8E8E8", "o c #B0B000000000", "O c #8888DCDC0000", "+ c None", /* pixels */ "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++", "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++", "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++", "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++", "+++++++.+++++++++++.+++++++++++.+++++++++++.+++++++++++.++++", "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++", "+++++++++++++++++++OOOO+++++++++++++++++++++OOOO++++++++++++", "++++++++++++++++++++O+++++++++++++++++++++++++O+++++++++++++", "++++++++++++++++++++o++++++++++++++++++++++++oO+++++++++++++", "++++++++++++++++++O+O++++++++++++++++++++++O++O+++++++++++++", "++++++++++++++++++OOO++++++++++++++++++++++OOOO+++++++++++++", "+++++++++++++++++OO+++++++++++++++++++++++OO++++++++++++++++", "++++++++++++++++OOO++++++++++++++++++++++OOO++++++++++++++++", "++++++++++++++oOOOO++++++++++++++++++++oOOOO++++++++++++++++", "+++++++++++++++XOOO+++++++++++++++++++++XOOO++++++++++++++++", "+++++++++++++++X+OO+++++++++++++++++++++X+OO++++++++++++++++", "+++++++.+++++++X++OOO++++++++++.++++++++X++OOOO++++++++.++++", "+++++++++++++++X++O+o+++++++++++++++++++X++O+oO+++++++++++++", "+++++++++++++++X++++X+++++++++++++++++++X+++++X+++++++++++++", "+++++++++++++++X++++X+++++++++++++++++++X+++++X+++++++++++++", "++++++ooooXXXXXX++++XXXXXXXXXXXXXXXXXXXXX+++++XXXXXXXXXXXXXX", "++++++ooo++++++X++++X+++++++++++++++++++X+++++X+++++++++++++", "+++++++++++++++X++++X+++++++++++++++++++X+++++X+++++++++++++", "+++++++++++++++X++++o+++++++++++++++++++X++++oO+++++++++++++", "+++++++++++++++X++O+O+++++++++++++++++++X++O++O+++++++++++++", "+++++++++++++++X++OOO+++++++++++++++++++X++OOOO+++++++++++++", "+++++++++++++++X+OO+++++++++++++++++++++X+OO++++++++++++++++", "+++++++++++++++X+OO+++++++++++++++++++++X+OO++++++++++++++++", "+++++++.++++++oOOOO.+++++++++++.+++++++oOOOO+++++++++++.++++", "+++++++++++++++++OO+++++++++++++++++++++++OO++++++++++++++++", "+++++++++++++++++OO+++++++++++++++++++++++OO++++++++++++++++", "++++++++++++++++++OOO++++++++++++++++++++++OOOO+++++++++++++", "++++++++++++++++++O+o++++++++++++++++++++++O+oO+++++++++++++", "++++++++++++++++++++O+++++++++++++++++++++++++O+++++++++++++", "++++++++++++++++++++O+++++++++++++++++++++++++O+++++++++++++", "++++++++++++++++++++OO+++++++++++++++++++++++OO+++++++++++++", "++++++++++++++++++++O+++++++++++++++++++++++++O+++++++++++++", "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++", "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++", "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++", "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++", "+++++++.+++++++++++.+++++++++++.+++++++++++.+++++++++++.++++" }; xschem-2.8.1/src/clip.c0000644000175100017510000001236113371731206013101 0ustar svnsvn/* File: clip.c * * This file is part of XSCHEM, * a schematic capture and Spice/Vhdl/Verilog netlisting tool for circuit * simulation. * Copyright (C) 1998-2018 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 */ #include "xschem.h" /* Cohen-Sutherland Algorithm for line clipping */ #define UP 8 #define DOWN 4 #define RIGHT 2 #define LEFT 1 static int outcode(double x,double y) { register int code=0; if(y > xschem_h) code = UP; else if(y < 0) code = DOWN; if(x > xschem_w) code |= RIGHT; else if(x < 0) code |= LEFT; return code; } int clip( double *xa,double *ya,double *xb,double *yb) { int outa, outb,outpoint; double x,y; outa=outcode(*xa, *ya); outb=outcode(*xb, *yb); while(1) { if(!(outa | outb)) return 1; /* line is all inside! */ else if(outa & outb) return 0; /* line is all outside! */ else { outpoint=outa? outa:outb; if(UP & outpoint) {x= *xa + (*xb-*xa) * (xschem_h - *ya) / (*yb - *ya); y = xschem_h;} else if(DOWN & outpoint) {x= *xa + (*xb-*xa) * (0 - *ya) / (*yb - *ya); y = 0;} else if(RIGHT & outpoint) {y= *ya + (*yb-*ya) * (xschem_w - *xa) / (*xb - *xa); x = xschem_w;} /* else if(LEFT & outpoint) */ else {y= *ya + (*yb-*ya) * (0 - *xa) / (*xb - *xa); x = 0;} if(outpoint == outa) {*xa=x; *ya=y; outa=outcode(*xa, *ya);} else {*xb=x; *yb=y; outb=outcode(*xb, *yb);} } } } int rectclip(int x1,int y1,int x2,int y2, double *xa,double *ya,double *xb,double *yb) /* coordinates should be ordered, x1x2) return 0; if(*xby2) return 0; if(*yb=1) fprintf(errfp, "dist_from_rect(): x1,y1,x2,y2=%.16g,%.16g,%.16g,%.16g\n",x1,y1,x2,y2); if(debug_var>=1) fprintf(errfp, "dist_from_rect(): mx,my==%.16g,%.16g\n",mousex,mousey); if(debug_var>=1) fprintf(errfp, "dist_from_rect(): dist=%.16g\n",dist); return dist*dist; } double dist(double x1,double y1,double x2,double y2,double xa,double ya) /* works if segments are given from left to right, i.e. x1<=x2 */ /* or y1=1) fprintf(errfp, "dist(): dist1 = %.16g dist2 = %.16g\n",distance1,distance2); if(x1x1 && xb < x2) { tmp = a*xa + b*ya + c; distance3 = tmp*tmp / denom; /* debug ... */ if(debug_var >=1) fprintf(errfp, "dist(); dist3 = %.16g\n",distance3); return distance3; } else { return MINOR(distance1,distance2); } } else /* vert. lines */ { if(yb >y1 && yb < y2) { tmp = a*xa + b*ya + c; distance3 = tmp*tmp / denom; /* debug ... */ if(debug_var >=1) fprintf(errfp, "dist(): dist3 = %.16g\n",distance3); return distance3; } else { return MINOR(distance1,distance2); } } /* debug ... */ if(debug_var>=1) {fprintf(errfp, "dist(): Internal error, \n");exit(1);} } /*obsolete, will be removed */ double rectdist(double x1,double y1,double x2,double y2,double xa,double ya) { double distance,dist; double xa1,ya1; xa1 = xa - x1; xa1*=xa1; ya1 = ya - y1; ya1*=ya1; distance = xa1 + ya1; xa1 = xa - x1; xa1*=xa1; ya1 = ya - y2; ya1*=ya1; if((dist = xa1 + ya1) < distance) distance = dist; xa1 = xa - x2; xa1*=xa1; ya1 = ya - y1; ya1*=ya1; if((dist = xa1 + ya1) < distance) distance = dist; xa1 = xa - x2; xa1*=xa1; ya1 = ya - y2; ya1*=ya1; if((dist = xa1 + ya1) < distance) distance = dist; return distance; } int touch(double x1,double y1,double x2,double y2,double xa,double ya) /* improved touch check routine, */ /* works if segments are given from left to right, i.e. x1<=x2 */ /* or y1=x1 &&xa<=x2) return 1; if(x1==x2 && ya >=y1 && ya<=y2) return 1; } return 0; } xschem-2.8.1/src/in_memory_undo.c0000644000175100017510000003121713377077322015206 0ustar svnsvn/* File: in_memory_undo.c * * This file is part of XSCHEM, * a schematic capture and Spice/Vhdl/Verilog netlisting tool for circuit * simulation. * Copyright (C) 1998-2018 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 */ #include "xschem.h" #ifdef IN_MEMORY_UNDO typedef struct { char *gptr; char *vptr; char *sptr; char *eptr; int *lines; int *boxes; int *polygons; int *arcs; int wires; int texts; int instances; Line **lptr; Box **bptr; Polygon **pptr; Arc **aptr; Wire *wptr; Text *tptr; Instance *iptr; } Undo_slot; static Undo_slot uslot[MAX_UNDO]; static int initialized=0; void init_undo() { int slot; for(slot=0;slot n == n) { saveptr = ptr->next; my_free(&ptr); *prevptr = saveptr; return; } prevptr = &ptr->next; ptr = *prevptr; } } static void instinsert(int n, int x, int y) { struct instentry *ptr, *newptr; ptr=insttable[x][y]; newptr=my_malloc(236, sizeof(struct instentry)); newptr->next=ptr; newptr->n=n; insttable[x][y]=newptr; if(debug_var>=2) fprintf(errfp, "instinsert(): inserting object %d at %d,%d\n",n,x,y); } static struct instentry *delinstentry(struct instentry *t) { struct instentry *tmp; while( t ) { tmp = t->next; my_free(&t); t = tmp; } return NULL; } void del_inst_table(void) { int i,j; for(i=0;i0) fprintf(errfp, "cleared object hash table\n"); } /* what: * 1 : add to hash * 0 : remove from hash */ void hash_inst(int what, int n) /* 20171203 insert object bbox in spatial hash table */ { int tmpi,tmpj, counti,countj,i,j; double tmpd; double x1, y1, x2, y2; int x1a, x2a, y1a, y2a; x1=inst_ptr[n].x1; x2=inst_ptr[n].x2; y1=inst_ptr[n].y1; y2=inst_ptr[n].y2; /* ordered bbox */ if( x2 < x1) { tmpd=x2;x2=x1;x1=tmpd;} if( y2 < y1) { tmpd=y2;y2=y1;y1=tmpd;} /* calculate square 4 1st bbox point of object[k] */ x1a=floor(x1/BOXSIZE); y1a=floor(y1/BOXSIZE); /* calculate square 4 2nd bbox point of object[k] */ x2a=floor(x2/BOXSIZE); y2a=floor(y2/BOXSIZE); /*loop thru all squares that intersect bbox of object[k] */ counti=0; for(i=x1a; i<=x2a && counti < NBOXES; i++) { counti++; tmpi=i%NBOXES; if(tmpi<0) tmpi+=NBOXES; countj=0; for(j=y1a; j<=y2a && countj < NBOXES; j++) { countj++; tmpj=j%NBOXES; if(tmpj<0) tmpj+=NBOXES; /* insert object_ptr[n] in region [tmpi, tmpj] */ if(what) instinsert(n, tmpi, tmpj); /* 20171203 */ else instdelete(n, tmpi, tmpj); } } } void hash_instances(void) /* 20171203 insert object bbox in spatial hash table */ { int n; if(prepared_hash_instances) return; del_inst_table(); for(n=0; nn == n && ptr->pin == pin) { saveptr = ptr->next; my_free(&ptr); *prevptr = saveptr; return; } prevptr = &ptr->next; ptr = *prevptr; } } /* --pin coordinates-- -square coord- */ static void instpininsert(int n,int pin, double x0, double y0, int x, int y) { struct instpinentry *ptr, *newptr; ptr=instpintable[x][y]; newptr=my_malloc(237, sizeof(struct instpinentry)); newptr->next=ptr; newptr->n=n; newptr->x0=x0; newptr->y0=y0; newptr->pin=pin; instpintable[x][y]=newptr; if(debug_var>=2) fprintf(errfp, "instpininsert(): inserting inst %d at %d,%d\n",n,x,y); } struct instpinentry *delinstpinentry(struct instpinentry *t) { struct instpinentry *tmp; while(t) { tmp = t->next; my_free(&t); t = tmp; } return NULL; } static void del_inst_pin_table(void) { int i,j; for(i=0;i n == n) { saveptr = ptr->next; my_free(&ptr); *prevptr = saveptr; return; } prevptr = &ptr->next; ptr = *prevptr; } } static void wireinsert(int n, int x, int y) { struct wireentry *ptr, *newptr; ptr=wiretable[x][y]; newptr=my_malloc(238, sizeof(struct wireentry)); newptr->next=ptr; newptr->n=n; wiretable[x][y]=newptr; if(debug_var>=2) fprintf(errfp, "wireinsert(): inserting wire %d at %d,%d\n",n,x,y); } static struct wireentry *delwireentry(struct wireentry *t) { struct wireentry *tmp; while( t ) { tmp = t->next; my_free(&t); t = tmp; } return NULL; } void del_wire_table(void) { int i,j; for(i=0;irects[PINLAYER] ; if(j>=rects) /* generic pins */ { rect=(inst_ptr[i].ptr+instdef)->boxptr[GENERICLAYER]; x0=(rect[j-rects].x1+rect[j-rects].x2)/2; y0=(rect[j-rects].y1+rect[j-rects].y2)/2; } else { rect=(inst_ptr[i].ptr+instdef)->boxptr[PINLAYER]; x0=(rect[j].x1+rect[j].x2)/2; y0=(rect[j].y1+rect[j].y2)/2; } rot=inst_ptr[i].rot; flip=inst_ptr[i].flip; ROTATION(0.0,0.0,x0,y0,rx1,ry1); x0=inst_ptr[i].x0+rx1; y0=inst_ptr[i].y0+ry1; get_square(x0, y0, &sqx, &sqy); if( what ) instpininsert(i, j, x0, y0, sqx, sqy); else instpindelete(i, j, sqx, sqy); } /* what: * 1 : add to hash * 0 : remove from hash */ void hash_wire(int what, int n) { int tmpi,tmpj, counti,countj,i,j; double tmpd; double x1, y1, x2, y2; int x1a, x2a, y1a, y2a; wire[n].node=NULL; wire[n].end1 = wire[n].end2=-1; x1=wire[n].x1; x2=wire[n].x2; y1=wire[n].y1; y2=wire[n].y2; /* ordered bbox */ if( x2 < x1) { tmpd=x2;x2=x1;x1=tmpd;} if( y2 < y1) { tmpd=y2;y2=y1;y1=tmpd;} /* calculate square 4 1st bbox point of wire[k] */ x1a=floor(x1/BOXSIZE) ; y1a=floor(y1/BOXSIZE) ; /* calculate square 4 2nd bbox point of wire[k] */ x2a=floor(x2/BOXSIZE); y2a=floor(y2/BOXSIZE); /*loop thru all squares that intersect bbox of wire[k] */ counti=0; for(i=x1a; i<=x2a && counti < NBOXES; i++) { counti++; tmpi=i%NBOXES; if(tmpi<0) tmpi+=NBOXES; countj=0; for(j=y1a; j<=y2a && countj < NBOXES; j++) { countj++; tmpj=j%NBOXES; if(tmpj<0) tmpj+=NBOXES; /* insert wire[n] in region [tmpi, tmpj] */ if(what==1) wireinsert(n, tmpi, tmpj); else wiredelete(n, tmpi, tmpj); } } } void hash_wires(void) { int n; if(prepared_hash_wires) return; del_wire_table(); for(n=0; n=1) fprintf(errfp, "check_lib(): %s, range=%d\n", s, range); for(i=0;i=1) fprintf(errfp, "check_lib(): xschem_libs=%s\n", Tcl_GetStringResult(interp)); if( strstr(s,Tcl_GetStringResult(interp))) found=1; } if(found) return 0; else return 1; } void print_wires(void) { int i,j; struct wireentry *ptr; for(i=0;i=1) fprintf(errfp, "print_wires(): %4d%4d :\n",i,j); ptr=wiretable[i][j]; while(ptr) { if(debug_var>=1) fprintf(errfp, "print_wires(): %6d\n", ptr->n); ptr=ptr->next; } if(debug_var>=1) fprintf(errfp, "print_wires(): \n"); } } ptr=wiretable[0][1]; while(ptr) { select_wire(ptr->n,SELECTED, 1); rebuild_selected_array(); ptr=ptr->next; } draw(); } static void signal_short( char *n1, char *n2) { char str[2048]; if( n1 && n2 && strcmp( n1, n2) ) { my_snprintf(str, S(str), "shorted: %s - %s", n1, n2); if(debug_var>=1) fprintf(errfp, "signal_short(): signal_short: shorted: %s - %s \n", n1, n2); statusmsg(str,2); if(!netlist_count) { bus_hilight_lookup(n1, hilight_color,0); if(incr_hilight) hilight_color++; bus_hilight_lookup(n2, hilight_color,0); if(incr_hilight) hilight_color++; } } } static void wirecheck(int k) /* recursive routine */ { int tmpi,tmpj, counti,countj,i,j; int touches; double x1, y1, x2, y2; int x1a, x2a, y1a, y2a; struct wireentry *ptr2; x1=wire[k].x1; x2=wire[k].x2; y1=wire[k].y1; y2=wire[k].y2; /* ordered bbox */ RECTORDER(x1, y1, x2, y2); /* calculate square 4 1st bbox point of wire[k] */ x1a=floor(x1/BOXSIZE) ; y1a=floor(y1/BOXSIZE) ; /* calculate square 4 2nd bbox point of wire[k] */ x2a=floor(x2/BOXSIZE); y2a=floor(y2/BOXSIZE); /*loop thru all squares that intersect bbox of wire[k] */ counti=0; for(i=x1a; i<=x2a && counti < NBOXES; i++) { counti++; tmpi=i%NBOXES; if(tmpi<0) tmpi+=NBOXES; countj=0; for(j=y1a; j<=y2a && countj < NBOXES; j++) { countj++; tmpj=j%NBOXES; if(tmpj<0) tmpj+=NBOXES; /*check if wire[k] touches wires in square [tmpi, tmpj] */ ptr2=wiretable[tmpi][tmpj]; while(ptr2) { if(wire[ptr2->n].node) {ptr2=ptr2->next; continue;} /* 20171207 net already checked. Move on */ if(ptr2->n != k) { /* 20171204 avoid checking wire against itself */ touches = touch(wire[k].x1,wire[k].y1,wire[k].x2,wire[k].y2, wire[ptr2->n].x1,wire[ptr2->n].y1) || touch(wire[k].x1,wire[k].y1,wire[k].x2,wire[k].y2, wire[ptr2->n].x2,wire[ptr2->n].y2) || touch(wire[ptr2->n].x1,wire[ptr2->n].y1,wire[ptr2->n].x2, wire[ptr2->n].y2, wire[k].x1,wire[k].y1) || touch(wire[ptr2->n].x1,wire[ptr2->n].y1,wire[ptr2->n].x2, wire[ptr2->n].y2, wire[k].x2,wire[k].y2); if( touches ) { my_strdup(239, &wire[ptr2->n].node, wire[k].node); my_strdup(240, &wire[ptr2->n].prop_ptr, subst_token(wire[ptr2->n].prop_ptr, "lab", wire[ptr2->n].node)); wirecheck(ptr2->n); /* recursive check */ } } ptr2=ptr2->next; } if(debug_var>=2) fprintf(errfp, "wirecheck(): %d/%d\n", tmpi,tmpj ); } if(debug_var>=2) fprintf(errfp, "wirecheck(): \n"); } } /* what==0 -> initialize */ /* what==1 -> get new node name, net## */ /* what==2 -> update multiplicity */ /* what==3 -> get node multiplicity */ int get_unnamed_node(int what, int mult,int node) { static int new_node=0; static int *node_mult=NULL; static int node_mult_size; int i; if(debug_var>=2) fprintf(errfp, "get_unnamed_node(): what=%d mult=%d node=%d\n", what, mult, node); if(what==0) /* initialize unnamed node data structures */ { new_node=0; my_free(&node_mult); node_mult_size=0; return 0; } else if(what==1) /* get a new unique unnamed node */ { ++new_node; if(new_node>= node_mult_size) /* enlarge array and zero it */ { node_mult_size += CADCHUNKALLOC; my_realloc(242, &node_mult, sizeof(int) * node_mult_size ); for(i=node_mult_size-CADCHUNKALLOC;i=2) fprintf(errfp, "get_unnamed_node(): returning mult=%d\n", node_mult[node]); return node_mult[node]; } } /*------------ */ /* store list of global nodes (global=1 set in symbol props) to be printed in netlist 28032003 */ /* what: */ /* 0: print list of global nodes and delete list */ /* 1: add entry */ /* 2: delete list only, no print */ void record_global_node(int what, FILE *fp, char *node) { static int max_globals=0; static int size_globals=0; static char **globals=NULL; int i; if( what==1) { for(i=0;i=size_globals) { size_globals+=CADCHUNKALLOC; my_realloc(243, &globals, size_globals*sizeof(char *) ); } globals[max_globals]=NULL; my_strdup(244, &globals[max_globals], node); max_globals++; } else if(what == 0 || what == 2) { for(i=0;i=1) fprintf(errfp, "prepare_netlist_structs(): resetting node hash tables\n"); hash_wires(); for(i=0;irects[PINLAYER] + (inst_ptr[i].ptr+instdef)->rects[GENERICLAYER]; if( rects > 0 ) { inst_ptr[i].node = my_malloc(247, sizeof(char *) * rects); for(j=0;j=2) fprintf(errfp, "prepare_netlist_structs(): naming pins from attrs\n"); for(i=0;itype); /* 20150409 */ if( type && inst_ptr[i].node && /* instance must have a pin! */ !(strcmp(type,"label") && strcmp(type,"ipin") && strcmp(type,"iopin") && strcmp(type,"opin") ) ) { if(!for_hilight_only) { /* 20150918 skip labels / pins if ignore property specified on instance */ if( netlist_type == CAD_VERILOG_NETLIST && strcmp(get_tok_value(inst_ptr[i].prop_ptr,"verilog_ignore",0),"true")==0 ) continue; if( netlist_type == CAD_SPICE_NETLIST && strcmp(get_tok_value(inst_ptr[i].prop_ptr,"spice_ignore",0),"true")==0 ) continue; if( netlist_type == CAD_VHDL_NETLIST && strcmp(get_tok_value(inst_ptr[i].prop_ptr,"vhdl_ignore",0),"true")==0 ) continue; if( netlist_type == CAD_TEDAX_NETLIST && strcmp(get_tok_value(inst_ptr[i].prop_ptr,"tedax_ignore",0),"true")==0 ) continue; } port=0; if( strcmp(type,"label") ){ /* instance is a port (not a label) */ port=1; /* 20071204 only define a dir property if instance is not a label */ if(for_hilight_only) my_strdup(249, &dir, ""); else my_strdup(250, &dir, get_tok_value( (inst_ptr[i].ptr+instdef)->boxptr[PINLAYER][0].prop_ptr, "dir",0) ); } else { /* handle global nodes (global=1 set as symbol property) 28032003 */ my_strdup(251, &global_node,get_tok_value((inst_ptr[i].ptr+instdef)->prop_ptr,"global",0)); /*20071204 if instance is a label dont define a dir property for more precise erc checking */ my_strdup(252, &dir,"none"); } if(!dir) my_strdup(253, &dir,"none"); /* 20100422, define dir if not alrerady defined by */ /* previous code, to avoid nasty segfaults if pins not correctly defined */ /* obtain ipin/opin/label signal type (default: std_logic) */ if(for_hilight_only) { my_strdup(254, &sig_type,""); my_strdup(255, &verilog_type,""); my_strdup(256, &value,""); my_strdup(257, &class,""); } else { my_strdup(258, &sig_type,get_tok_value(inst_ptr[i].prop_ptr,"sig_type",0)); my_strdup(259, &verilog_type,get_tok_value(inst_ptr[i].prop_ptr,"verilog_type",0)); /*09112003 */ my_strdup(260, &value,get_tok_value(inst_ptr[i].prop_ptr,"value",2)); my_strdup(261, &class,get_tok_value(inst_ptr[i].prop_ptr,"class",0)); } my_strdup(262, &inst_ptr[i].node[0], get_tok_value(inst_ptr[i].prop_ptr,"lab",0)); /* handle global nodes (global=1 set as symbol property) 28032003 */ if( !strcmp(type,"label") && global_node && global_node[0]=='1') { if(debug_var>=1) fprintf(errfp, "prepare_netlist_structs(): global node: %s\n",inst_ptr[i].node[0]); record_global_node(1,NULL, inst_ptr[i].node[0]); } /* do not count multiple labels/pins with same name */ bus_hash_lookup(inst_ptr[i].node[0], /* insert node in hash table */ dir, 0,port, sig_type, verilog_type, value, class); if(debug_var>=2) fprintf(errfp, "prepare_netlist_structs(): name=%s\n", get_tok_value( inst_ptr[i].prop_ptr, "lab",0 ) ); if(debug_var>=2) fprintf(errfp, "prepare_netlist_structs(): pin=%s\n", get_tok_value( (inst_ptr[i].ptr+instdef)->boxptr[PINLAYER][0].prop_ptr, "name",0) ); if(debug_var>=2) fprintf(errfp, "prepare_netlist_structs(): dir=%s\n", get_tok_value( (inst_ptr[i].ptr+instdef)->boxptr[PINLAYER][0].prop_ptr, "dir",0) ); /* name nets that touch ioin opin alias instances */ rect=(inst_ptr[i].ptr+instdef)->boxptr[PINLAYER]; x0=(rect[0].x1+rect[0].x2)/2; y0=(rect[0].y1+rect[0].y2)/2; rot=inst_ptr[i].rot; flip=inst_ptr[i].flip; ROTATION(0.0,0.0,x0,y0,rx1,ry1); x0=inst_ptr[i].x0+rx1; y0=inst_ptr[i].y0+ry1; get_square(x0, y0, &sqx, &sqy); wptr=wiretable[sqx][sqy]; while(wptr) { if( touch(wire[wptr->n].x1, wire[wptr->n].y1, wire[wptr->n].x2, wire[wptr->n].y2, x0,y0) ) { /* short circuit check */ if(!for_hilight_only) signal_short(wire[wptr->n].node, inst_ptr[i].node[0]); my_strdup(263, &wire[wptr->n].node, inst_ptr[i].node[0]); my_strdup(264, &wire[wptr->n].prop_ptr, subst_token(wire[wptr->n].prop_ptr, "lab", wire[wptr->n].node)); wirecheck(wptr->n); } wptr=wptr->next; } } /* if(type && ... */ } /* for(i=0;i=2) fprintf(errfp, "prepare_netlist_structs(): naming nets that dont touch labels\n"); get_unnamed_node(0,0,0); /*initializes node multiplicity data struct */ for(i=0;i=2) fprintf(errfp, "prepare_netlist_structs(): naming generics from attached labels\n"); for(i=0;itype); /* 20150409 */ if( type && strcmp(type,"label") && strcmp(type,"ipin") && strcmp(type,"opin") && strcmp(type,"iopin") ) { if( (generic_rects = (inst_ptr[i].ptr+instdef)->rects[GENERICLAYER]) > 0 ) { rects = (inst_ptr[i].ptr+instdef)->rects[PINLAYER]; for(j=rects;jboxptr[GENERICLAYER]; x0=(rect[j-rects].x1+rect[j-rects].x2)/2; y0=(rect[j-rects].y1+rect[j-rects].y2)/2; rot=inst_ptr[i].rot; flip=inst_ptr[i].flip; ROTATION(0.0,0.0,x0,y0,rx1,ry1); x0=inst_ptr[i].x0+rx1; y0=inst_ptr[i].y0+ry1; get_square(x0, y0, &sqx, &sqy); iptr=instpintable[sqx][sqy]; while(iptr) { if( iptr->n == i) { iptr=iptr->next; continue; } if( (iptr->x0==x0) && (iptr->y0==y0) ) { if(inst_ptr[iptr->n].node[iptr->pin] != NULL && !strcmp( (inst_ptr[iptr->n].ptr+instdef)->type, /* 20150409 */ "label" ) ) { if(debug_var>=2) fprintf(errfp, "prepare_netlist_structs(): naming generic %s\n", inst_ptr[iptr->n].node[iptr->pin] ); my_strdup(268, &inst_ptr[i].node[j], get_tok_value(inst_ptr[iptr->n].prop_ptr,"value",2) ); /*my_strdup(269, &inst_ptr[i].node[j], inst_ptr[iptr->n].node[iptr->pin] ); */ if(for_hilight_only) { my_strdup(270, &sig_type,""); bus_hash_lookup(inst_ptr[iptr->n].node[iptr->pin],"none", 0,1, sig_type,"", "",""); } else { my_strdup(271, &sig_type,get_tok_value( (inst_ptr[i].ptr+instdef)->boxptr[GENERICLAYER][j-rects].prop_ptr, "sig_type",0)); /* insert generic label in hash table as a port so it will not */ /* be declared as a signal in the vhdl netlist. this is a workaround */ /* that should be fixed 25092001 */ bus_hash_lookup(inst_ptr[iptr->n].node[iptr->pin], get_tok_value( (inst_ptr[i].ptr+instdef)->boxptr[GENERICLAYER][j-rects].prop_ptr, "dir",0), 0,1, sig_type,"", "",""); } } /* end if(inst_ptr[iptr->n].node[iptr->pin] != NULL) */ } /* end if( (iptr->x0==x0) && (iptr->y0==y0) ) */ iptr=iptr->next; } } /* end for(j=0;j0) */ } /* end if(type not a label nor pin)... */ } /* end for(i...) */ /* END NAME GENERICS */ /* name instance pins of non (label,pin) instances */ if(debug_var>=2) fprintf(errfp, "prepare_netlist_structs(): assigning node names on instance pins\n"); for(i=0;itype); /* 20150409 */ if( type && strcmp(type,"label") && strcmp(type,"ipin") && strcmp(type,"opin") && strcmp(type,"iopin") ) { if( (rects = (inst_ptr[i].ptr+instdef)->rects[PINLAYER]) > 0 ) { for(j=0;jboxptr[PINLAYER]; x0=(rect[j].x1+rect[j].x2)/2; y0=(rect[j].y1+rect[j].y2)/2; rot=inst_ptr[i].rot; flip=inst_ptr[i].flip; ROTATION(0.0,0.0,x0,y0,rx1,ry1); x0=inst_ptr[i].x0+rx1; y0=inst_ptr[i].y0+ry1; get_square(x0, y0, &sqx, &sqy); /* name instance nodes that touch named nets */ wptr=wiretable[sqx][sqy]; if(debug_var>=2) fprintf(errfp, "prepare_netlist_structs(): from attached nets\n"); while(wptr) { if( touch(wire[wptr->n].x1, wire[wptr->n].y1, wire[wptr->n].x2, wire[wptr->n].y2, x0,y0) ) { /* short circuit check */ if( touches ) { if(!for_hilight_only) signal_short(inst_ptr[i].node[j], wire[wptr->n].node); } if(!touches) { my_strdup(273, &inst_ptr[i].node[j], wire[wptr->n].node ); bus_hash_lookup(inst_ptr[i].node[j], get_tok_value( (inst_ptr[i].ptr+instdef)->boxptr[PINLAYER][j].prop_ptr, "dir",0), 0,0,"","","",""); if(wire[wptr->n].node[0]=='#') /* unnamed node, update its multiplicity */ { expandlabel(get_tok_value( (inst_ptr[i].ptr+instdef)->boxptr[PINLAYER][j].prop_ptr,"name",0),&pin_mult ); get_unnamed_node(2, pin_mult * inst_mult, strtol((inst_ptr[i].node[j])+4, NULL,10) ); } } /* end if(!touches) */ touches=1; } wptr=wptr->next; } if(debug_var>=2) fprintf(errfp, "prepare_netlist_structs(): from other instances\n"); touches_unnamed=0; iptr=instpintable[sqx][sqy]; while(iptr) { if( iptr->n == i) { iptr=iptr->next; continue; } if( (iptr->x0==x0) && (iptr->y0==y0) ) { if(inst_ptr[iptr->n].node[iptr->pin] != NULL) { /* short circuit check */ if(touches) { if(!for_hilight_only) signal_short(inst_ptr[i].node[j], inst_ptr[iptr->n].node[iptr->pin]); } if(!touches) { my_strdup(274, &inst_ptr[i].node[j], inst_ptr[iptr->n].node[iptr->pin] ); if(for_hilight_only) { bus_hash_lookup(inst_ptr[i].node[j], "none", 0,0,"","","",""); } else { bus_hash_lookup(inst_ptr[i].node[j], get_tok_value( (inst_ptr[i].ptr+instdef)->boxptr[PINLAYER][j].prop_ptr, "dir",0), 0,0,"","","",""); } if( (inst_ptr[i].node[j])[0] == '#') { expandlabel(get_tok_value( (inst_ptr[i].ptr+instdef)->boxptr[PINLAYER][j].prop_ptr,"name",0),&pin_mult ); /* done at beginning of for(i) loop 20171210 */ /* expandlabel(get_tok_value( */ /* inst_ptr[i].prop_ptr,"name",0), &inst_mult); */ get_unnamed_node(2, pin_mult * inst_mult, strtol((inst_ptr[i].node[j])+4, NULL,10) ); } } touches=1; } /* end if(inst_ptr[iptr->n].node[iptr->pin] != NULL) */ else /* touches instance with unnamed pins */ { touches_unnamed=1; } } /* end if( (iptr->x0==x0) && (iptr->y0==y0) ) */ iptr=iptr->next; } /* pin did not touch named pins or nets so we name it now */ if(debug_var>=2) fprintf(errfp, "prepare_netlist_structs(): naming the other pins\n"); if(!touches) { if( !(CAD_VHDL_NETLIST && !touches_unnamed)) { expandlabel(get_tok_value( (inst_ptr[i].ptr+instdef)->boxptr[PINLAYER][j].prop_ptr,"name",0), &pin_mult); /* done at beginning of for(i) loop 20171210 */ /* expandlabel(get_tok_value( */ /* inst_ptr[i].prop_ptr,"name",0), &inst_mult); */ my_snprintf( tmp_str, S(tmp_str), "#net%d", get_unnamed_node(1, pin_mult * inst_mult, 0) ); my_strdup(275, &inst_ptr[i].node[j], tmp_str ); if(for_hilight_only) { bus_hash_lookup(inst_ptr[i].node[j], "none", 0,0,"","","",""); } else { bus_hash_lookup(inst_ptr[i].node[j], get_tok_value( (inst_ptr[i].ptr+instdef)->boxptr[PINLAYER][j].prop_ptr, "dir",0), 0,0,"","","",""); } } } } /* end for(j=0;j0) */ } /* end if(type not a label nor pin)... */ } /* end for(i...) */ /*---------------------- */ rebuild_selected_array(); if(!for_hilight_only) prepared_netlist_structs=1; else prepared_hilight_structs=1; } void delete_inst_node(int i) { int j, rects; if(!inst_ptr[i].node) return; rects = (inst_ptr[i].ptr+instdef)->rects[PINLAYER] + (inst_ptr[i].ptr+instdef)->rects[GENERICLAYER]; if( rects > 0 ) { for(j=0;j< rects ;j++) my_free( &inst_ptr[i].node[j]); my_free(& inst_ptr[i].node ); } } void delete_netlist_structs(void) { int i; /* erase node data structures */ if(debug_var>=1) fprintf(errfp, "delete_netlist_structs(): begin erasing\n"); for(i=0;i=1) fprintf(errfp, "delete_netlist_structs(): end erasing\n"); prepared_netlist_structs=0; prepared_hilight_structs=0; } xschem-2.8.1/src/change_ref.awk0000755000175100017510000000255313023243556014600 0ustar svnsvn#!/bin/sh awk ' BEGIN{ lib["inv"]="cmoslib" lib["invh"]="cmoslib" lib["nand2"]="cmoslib" lib["nand3"]="cmoslib" lib["nand4"]="cmoslib" lib["nand5"]="cmoslib" lib["nd2"]="cmoslib" lib["nr2"]="cmoslib" lib["iv"]="cmoslib" lib["iv2"]="cmoslib" lib["iv3"]="cmoslib" lib["mux21t"]="cmoslib" lib["ao21"]="cmoslib" lib["ld1tq"]="cmoslib" lib["nor2"]="cmoslib" lib["nor3"]="cmoslib" lib["nor4"]="cmoslib" lib["oa21"]="cmoslib" lib["eo"]="cmoslib" lib["tg3"]="cmoslib" lib["passgate"]="cmoslib" lib["ipin"]="devices" lib["opin"]="devices" lib["lab"]="devices" lib["lab2"]="devices" lib["label"]="devices" lib["capa"]="devices" lib["cnwlva"]="devices" lib["cnwlvi"]="devices" lib["dnwpsu"]="devices" lib["res"]="devices" lib["rnx"]="devices" lib["rnx3"]="devices" lib["npn"]="devices" lib["pnp"]="devices" lib["nmos"]="devices" lib["nmos4"]="devices" lib["nmoshv"]="devices" lib["nmosnat"]="devices" lib["nmosnat4"]="devices" lib["pmos"]="devices" lib["pmos4"]="devices" lib["pmoshv"]="devices" lib["pmosnat"]="devices" lib["pmosnat4"]="devices" lib["rnwhv"]="devices" lib["vdd"]="devices" lib["vcvs"]="devices" lib["gnd"]="devices" lib["vsource"]="devices" } /^C {.*} /{ a=$2 gsub(/[{}]/,"",a) if(a in lib) $2="{" lib[a] "/" a "}" } { print $0 > "____ZZZ____" } ' $@ mv ____ZZZ____ $1 xschem-2.8.1/src/keys.help0000644000175100017510000001547413370425073013644 0ustar svnsvn XSCHEM MOUSE BINDINGS ---------------------------------------------------------------------- LeftButton Clear selection and select a graphic object (line, rectangle, symbol, wire) if clicking on blank area: clear selection shift+LeftButton Select without clearing previous selection alt+LeftButton if an 'url' or 'tclcommand' property is defined on selected instance open the url or execute the tclcommand LeftButton drag Select objects by area, clearing previous selection shift+LeftButton drag Select objects by area, without clearing previous selection Ctrl+LeftButton drag Select objects by area to perform a subsequent 'stretch' move operation shift+ Select objects by area without unselecting Ctrl+LeftButton drag to perform a subsequent 'stretch' move operation Mouse Wheel Zoom in / out MidButton drag Pan viewable area RightButton Unselect selected object shift+RightButton drag Unselect objects by area Ctrl + LeftButton Edit property of object under the mouse Double Click else edit global schematic / symbol property string LeftButton Double click Terminate Polygon placement RightButton DoubleClick Descend into component under mouse else return to parent schematic XSCHEM KEY BINDINGS ---------------------------------------------------------------------- - BackSpace Back to parent schematic - Delete Delete selected objects - Insert Insert element from library - Down Move down ctrl Enter Confirm closing dialog boxes - Escape Abort, redraw, unselect - Left Move right - Right Move left - Up Move up - '!' Break selected wires at any wire or component pin connection - ' ' Pan schematic - ' ' When drawing lines or wires toggle between manhattan H-V, manhattan V-H or oblique path. - '5' View only probes - 'a' Make symbol from pin list of current schematic ctrl 'a' Select all shift 'A' Toggle show netlist - 'b' Merge file ctrl 'b' Toggle show text in symbol - 'c' Copy selected obj. ctrl 'c' Save to clipboard shift 'C' Start arc placement shift+ctrl 'C' Start circle placement alt 'C' Toggle dim/brite background with rest of layers ctrl 'e' Back to parent schematic - 'e' Descend to schematic alt 'e' Edit selected schematic in a new window shift+alt 'F' Toggle Full screen shift 'F' Flip alt 'f' Flip objects around their anchor points ctrl 'f' Find/select by substring or regexp - 'f' Full zoom shift 'G' Double snap factor - 'g' Half snap factor ctrl 'g' Set snap factor - 'h' Constrained horizontal move/copy of objects alt 'h' create symbol pins from schematic pins ctrl 'h' Follow http link or execute command (url, tclcommand properties) shift 'H' Attach net labels to selected instance - 'i' Descend to symbol alt 'i' Edit selected symbol in a new window shift 'J' Create symbol from pin list alt+shift 'J' Create labels with 'i' prefix from highlighted nets/pins alt 'j' Create labels without 'i' prefix from highlighted nets/pins ctrl 'j' Create ports from highlight nets alt+ctrl 'j' Print list of highlighted nets/pins with label expansion - 'j' Print list of highlighted nets/pins - 'k' Hilight selected nets ctrl+shift 'K' highlight net passing through elements with 'propagate_to' property set on pins shift 'K' Unhilight all nets ctrl 'k' Unhilight selected nets - 'l' Start line ctrl 'l' Make schematic view from selected symbol ctrl 'o' Load schematic - 'm' Move selected obj. shift 'N' Hierarchical netlist - 'n' Netlist Ctrl 'n' New schematic Ctrl+Shift 'N' New symbol shift 'O' Toggle Light / Dark colorscheme ctrl 'o' Load schematic - 'p' Pan shift 'P' Pan, other way to. alt 'q' Edit schematic file (dangerous!) - 'q' Edit prop shift 'Q' Edit prop with vim ctrl+shift 'Q' View prop ctrl 'q' Exit XSCHEM alt 'r' Rotate objects around their anchor points shift 'R' Rotate - 'r' Start rect shift 'S' Change element order ctrl+shift 'S' Save as schematic ctrl 's' Save schematic alt 's' Reload current schematic from disk ctrl+alt 's' Save-as symbol - 't' Place text alt 'u' Align to current grid selected objects shift 'U' Redo - 'u' Undo - 'v' Constrained vertical move/copy of objects ctrl 'v' Paste from clipboard shift 'V' Toggle spice/vhdl/verilog netlist - 'w' Place wire ctrl 'w' Place polygon. Operation ends by placing last point over first. shift 'W' Place wire, snapping to closest pin or net endpoint ctrl 'x' Cut into clipboard - 'x' New cad session shift 'X' Highlight discrepancies between object ports and attached nets - 'y' Toggle stretching wires - 'z' Zoom box shift 'Z' Zoom in ctrl 'z' Zoom out - '?' Help - '&' Join / break / collapse wires shift '*' Postscript/pdf print ctr+shift '*' Xpm/png print alt+shift '*' Svg print '-' dim colors ctrl '-' Test mode: change line width ctrl '+' Test mode: change line width '+' brite colors - '_' Toggle change line width - '%' Toggle draw grid - '=' Toggle fill rectangles - '$' Toggle pixmap saving ctrl '$' Toggle use XCopyArea vs drawing primitives for drawing the screen - ':' Toggle flat netlist xschem-2.8.1/src/parse_synopsys_vhdl.awk0000755000175100017510000000157713023243556016642 0ustar svnsvn#!/bin/sh awk ' { $0 = tolower($0)} /port map\(/{ while($0 !~/; *$/) { a=$0 getline $0=a $0 } gsub(/ */," ",$0) gsub(/ *;/,";",$0) # print ">>>>" $0 "<<<<" } /port map\(/,/\) *;/{ sub(/--.*$/,"",$0) if($0 ~ /port map\(/) a="" a = a $0 " " if($0 ~ /\) *;/) { gsub(/ +/," ", a) $0=a } else next } /[ \t]*port\(/{ end_port_list=0 sub( /port\(/,"port(\n ",$0 ) port_list=1 } (port_list==1){ if($0 ~ /\) *;/) { sub(/\) *;/,"",$0) end_port_list=1 } gsub(/;/, ";\n ",$0 ) if(end_port_list) { $0 = $0 "\n );\n" port_list=0 } } ($2==":" && $4=="port" && $5~/^map\(/){ sub(/port map\(/,"\n port map(\n ",$0) port_map=1 end_port_map=0 } (port_map==1){ if($0 ~ /\);/) { sub(/\);/,"",$0) end_port_map=1 } gsub(/,/,",\n ",$0) if(end_port_map) { $0 = $0 "\n );\n" port_map=0 } } {print} ' $@ xschem-2.8.1/src/scheduler.c0000644000175100017510000013357013400741444014134 0ustar svnsvn/* File: scheduler.c * * This file is part of XSCHEM, * a schematic capture and Spice/Vhdl/Verilog netlisting tool for circuit * simulation. * Copyright (C) 1998-2018 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 */ #include "xschem.h" void statusmsg(char str[],int n) { static char s[2048]; if(!has_x) return; if(n==2) { my_snprintf(s, S(s), "infowindow {%s%s", str, !strcmp(str, "") ? "}" : "\n}"); if(debug_var>=3) fprintf(errfp, "statusmsg(): %s\n", s); tcleval(s); } else { my_snprintf(s, S(s), ".statusbar.1 configure -text {%s}", str); tcleval(s); } } /* can be used to reach C functions from the Tk shell. */ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * argv[]) { int i; char name[1024]; /* overflow safe 20161122 */ if(argc<2) return TCL_ERROR; if(debug_var>=3) { int i; fprintf(errfp, "xschem():"); for(i=0; i=1) fprintf(errfp, "scheduler: xschem fullscreen, fullscreen=%d\n", fullscreen); toggle_fullscreen(); } else if(!strcmp(argv[1],"windowid")) /* used by xschem.tcl for configure events */ { windowid(); } else if(!strcmp(argv[1],"paste")) { merge_file(2,".sch"); } else if(!strcmp(argv[1],"merge")) { if(argc<3) { merge_file(0,""); /* 2nd param not used for merge 25122002 */ } else { /* 20071215 */ merge_file(0,argv[2]); } } else if(!strcmp(argv[1],"attach_pins")) /* attach pins to selected component 20171005 */ { attach_labels_to_inst(); } else if(!strcmp(argv[1],"make_sch")) /* make schematic from selected symbol 20171004 */ { create_sch_from_sym(); } else if(!strcmp(argv[1],"make_symbol")) { tcleval("tk_messageBox -type okcancel -message {do you want to make symbol view ?}"); if(strcmp(Tcl_GetStringResult(interp),"ok")==0) if(current_type==SCHEMATIC) { save_schematic(schematic[currentsch]); make_symbol(); } } else if(!strcmp(argv[1],"descend")) { descend_schematic(); } else if(!strcmp(argv[1],"descend_symbol")) { descend_symbol(); } else if(!strcmp(argv[1],"go_back")) { go_back(1); } else if(!strcmp(argv[1],"zoom_full")) { zoom_full(1); } else if(!strcmp(argv[1],"zoom_box")) { ui_state|=MENUSTARTZOOM; } else if(!strcmp(argv[1],"place_symbol")) { place_symbol(-1,NULL,0.0, 0.0, 0, 0, NULL, 3, 1); move_objects(BEGIN,0,0,0); } else if(!strcmp(argv[1],"place_text")) { ui_state |= MENUSTARTTEXT; /* 20161201 */ /* place_text(0,mousex_snap, mousey_snap); */ /* move_objects(BEGIN,0,0,0); */ } else if(!strcmp(argv[1],"zoom_out")) { view_unzoom(0.0); } else if(!strcmp(argv[1],"line_width") && argc==3) { change_linewidth(atof(argv[2])); } else if(!strcmp(argv[1],"sleep") && argc==3) { /* usleep(atoi(argv[2])*1000); */ /*portability issues */ } else if(!strcmp(argv[1],"select_all")) { select_all(); } else if(!strcmp(argv[1],"zoom_in")) { view_zoom(0.0); } else if(!strcmp(argv[1],"copy_objects")) { copy_objects(BEGIN); } else if(!strcmp(argv[1],"move_objects")) { if(argc==4) { move_objects(BEGIN,0,0,0); move_objects( END,0,atof(argv[2]), atof(argv[3])); } else move_objects(BEGIN,0,0,0); } else if(!strcmp(argv[1],"log")) { static int opened=0; if(argc==3 && opened==0 ) { errfp = fopen(argv[2], "w");opened=1; } /* added check to avoid multiple open 07102004 */ else if(argc==2 && opened==1) { fclose(errfp); errfp=stderr;opened=0; } } else if(!strcmp(argv[1],"exit")) { if(modified) { tcleval("tk_messageBox -type okcancel -message {UNSAVED data: want to exit?}"); if(strcmp(Tcl_GetStringResult(interp),"ok")==0) tcleval( "exit"); } else tcleval( "exit"); } else if(!strcmp(argv[1], "rebuild_connectivity")) { prepared_hash_instances=0; prepared_hash_wires=0; prepared_netlist_structs=0; prepared_hilight_structs=0; prepare_netlist_structs(1); } else if(!strcmp(argv[1],"clear")) { int cancel; cancel=save(1); if(!cancel){ /* 20161209 */ currentsch = 0; unselect_all(); /* 20180929 */ clear_drawing(); remove_symbols(); if(argc>=3 && !strcmp(argv[2],"SYMBOL")) { /* 20171025 */ my_strncpy(schematic[currentsch], "untitled.sym", S(schematic[currentsch])); current_type=SYMBOL; } else { my_strncpy(schematic[currentsch], "untitled.sch", S(schematic[currentsch])); current_type=SCHEMATIC; } draw(); set_modify(0); /* 20171025 */ prepared_hash_instances=0; prepared_hash_wires=0; prepared_netlist_structs=0; prepared_hilight_structs=0; if(has_x) { tcleval( "wm title . \"xschem - [file tail [xschem get schname]]\""); /* 20150417 set window and icon title */ tcleval( "wm iconname . \"xschem - [file tail [xschem get schname]]\""); } } } else if(!strcmp(argv[1],"reload")) { unselect_all(); /* 20180929 */ remove_symbols(); load_schematic(1,schematic[currentsch],1); zoom_full(1); } else if(!strcmp(argv[1],"gensch")) { char str[1024]; /* overflow safe 20161122 */ if(argc==3) my_snprintf(str, S(str), "gensch {%s}", argv[2]); else if(argc==4) my_snprintf(str, S(str), "gensch {%s} {%s}", argv[2], argv[3]); tcleval(str); } else if(!strcmp(argv[1],"debug")) { if(argc==3) { debug_var=atoi(argv[2]); tclsetvar("tcl_debug",argv[2]); } } else if(!strcmp(argv[1], "setprop")) { int found=0, i, inst, fast=0; if(argc == 7) { if(!strcmp(argv[6], "fast")) { fast = 1; argc = 6; } } if(argc!=6) { Tcl_AppendResult(interp, "xschem setprop needs 4 additional arguments", NULL); return TCL_ERROR; } if(!strcmp(argv[2],"instance")) { for(i=0;i=0) { my_strdup(368, &template, (instdef+sym_number)->templ); /* 20150409 */ prefix=(get_tok_value(template, "name",0))[0]; /* get new symbol prefix */ } else prefix = 'x'; delete_inst_node(inst); /* 20180208 fix crashing bug: delete node info if changing symbol */ /* if number of pins is different we must delete these data *before* */ /* changing ysmbol, otherwise i might end up deleting non allocated data. */ my_strdup(369, &inst_ptr[inst].name,symbol); inst_ptr[inst].ptr=sym_number; bbox(ADD, inst_ptr[inst].x1, inst_ptr[inst].y1, inst_ptr[inst].x2, inst_ptr[inst].y2); hash_proplist(inst_ptr[inst].prop_ptr , 1); /* remove old props from hash table */ my_strdup(370, &name, inst_ptr[inst].instname); if(name && name[0] ) /* 30102003 */ { /* 20110325 only modify prefix if prefix not NUL */ if(prefix) name[0]=prefix; /* change prefix if changing symbol type; */ my_strdup(371, &ptr,subst_token(inst_ptr[inst].prop_ptr, "name", name) ); new_prop_string(&inst_ptr[inst].prop_ptr, ptr,0); /* set new prop_ptr */ my_strdup2(372, &inst_ptr[inst].instname, get_tok_value(inst_ptr[inst].prop_ptr, "name",0)); /* 20150409 */ type=instdef[inst_ptr[inst].ptr].type; /* 20150409 */ cond= !type || (strcmp(type,"label") && strcmp(type,"ipin") && strcmp(type,"opin") && strcmp(type,"iopin")); if(cond) inst_ptr[inst].flags|=2; else inst_ptr[inst].flags &=~2; } hash_proplist(inst_ptr[inst].prop_ptr , 0); /* put new props in hash table */ /* new symbol bbox after prop changes (may change due to text length) */ symbol_bbox(inst, &inst_ptr[inst].x1, &inst_ptr[inst].y1, &inst_ptr[inst].x2, &inst_ptr[inst].y2); bbox(ADD, inst_ptr[inst].x1, inst_ptr[inst].y1, inst_ptr[inst].x2, inst_ptr[inst].y2); /* redraw symbol */ bbox(SET,0.0,0.0,0.0,0.0); draw(); bbox(END,0.0,0.0,0.0,0.0); } } else if( !strcmp(argv[1],"getprop")) { /* 20171028 */ if(!strcmp(argv[2], "instance") || !strcmp(argv[2], "instance_n")) { int i, found=0; if(argc!=5) { Tcl_AppendResult(interp, "xschem getprop needs 3 additional arguments", NULL); return TCL_ERROR; } Tcl_ResetResult(interp); if(!strcmp(argv[2],"instance_n")) { i=atol(argv[3]); if(i<0 || i>lastinst) { Tcl_AppendResult(interp, "Index out of range", NULL); return TCL_ERROR; } found = 1; } else if(!strcmp(argv[2],"instance")) { for(i=0;i Instance not found", NULL); return TCL_ERROR; } else { if(strstr(argv[4], "cell__") ) { char *tmp; tmp = get_tok_value( (inst_ptr[i].ptr+instdef)->prop_ptr, argv[4]+6, 0); Tcl_AppendResult(interp, tmp, NULL); } else { Tcl_AppendResult(interp, get_tok_value(inst_ptr[i].prop_ptr, argv[4], 0), NULL); } } } else if( !strcmp(argv[2],"symbol")) { /* 20171028 */ int i, found=0; if(argc!=5) { Tcl_AppendResult(interp, "xschem getprop needs 3 additional arguments", NULL); return TCL_ERROR; } Tcl_ResetResult(interp); for(i=0; ilastinst) { Tcl_AppendResult(interp, "Index out of range", NULL); return TCL_ERROR; } prepare_netlist_structs(1); no_of_pins= (inst_ptr[i].ptr+instdef)->rects[PINLAYER]; for(p=0;pboxptr[PINLAYER][p].prop_ptr,"name",0), argv[4])) { /*str_ptr = inst_ptr[i].node[p] ? inst_ptr[i].node[p]: ""; */ str_ptr = pin_node(i,p,&mult, 0); break; } } /* /20171029 */ Tcl_AppendResult(interp, str_ptr, NULL); } } else if(!strcmp(argv[1],"selected_set")) { int n, i; char *res = NULL; rebuild_selected_array(); for(n=0; n < lastselected; n++) { if(selectedgroup[n].type == ELEMENT) { i = selectedgroup[n].n; my_strcat(645, &res, inst_ptr[i].instname); if(n < lastselected-1) my_strcat(646, &res, " "); } } Tcl_AppendResult(interp, res, NULL); my_free(&res); } else if(!strcmp(argv[1],"select")) { if(argc<3) return TCL_ERROR; drawtempline(gc[SELLAYER], BEGIN, 0.0, 0.0, 0.0, 0.0); drawtemprect(gc[SELLAYER], BEGIN, 0.0, 0.0, 0.0, 0.0); drawtemparc(gc[SELLAYER], BEGIN, 0.0, 0.0, 0.0, 0.0, 0.0); if(!strcmp(argv[2],"instance") && argc==4) { int n=atol(argv[3]); int i,found=0; /* 20171006 find by instance name */ for(i=0;i=6) { x1=atof(argv[2]); y1=atof(argv[3]); x2=atof(argv[4]); y2=atof(argv[5]); ORDER(x1,y1,x2,y2); pos=-1; if(argc==7) pos=atol(argv[6]); storeobject(pos, x1,y1,x2,y2,WIRE,0,0,NULL); drawline(WIRELAYER,NOW, x1,y1,x2,y2); } else ui_state |= MENUSTARTWIRE; } else if(!strcmp(argv[1],"line")) { double x1,y1,x2,y2; int pos; if(argc>=6) { x1=atof(argv[2]); y1=atof(argv[3]); x2=atof(argv[4]); y2=atof(argv[5]); ORDER(x1,y1,x2,y2); pos=-1; if(argc==7) pos=atol(argv[6]); storeobject(pos, x1,y1,x2,y2,LINE,rectcolor,0,NULL); drawline(rectcolor,NOW, x1,y1,x2,y2); } else ui_state |= MENUSTARTLINE; } else if(!strcmp(argv[1],"rect")) { double x1,y1,x2,y2; int pos; if(argc>=6) { x1=atof(argv[2]); y1=atof(argv[3]); x2=atof(argv[4]); y2=atof(argv[5]); ORDER(x1,y1,x2,y2); pos=-1; if(argc==7) pos=atol(argv[6]); storeobject(pos, x1,y1,x2,y2,RECT,rectcolor,0,NULL); drawrect(rectcolor,NOW, x1,y1,x2,y2); } else ui_state |= MENUSTARTRECT; } else if(!strcmp(argv[1],"polygon")) { ui_state |= MENUSTARTPOLYGON; } else if(!strcmp(argv[1],"align")) { push_undo(); round_schematic_to_grid(cadsnap); set_modify(1); prepared_hash_instances=0; prepared_hash_wires=0; prepared_netlist_structs=0; prepared_hilight_structs=0; draw(); } else if(!strcmp(argv[1],"saveas")) { saveas(); } else if(!strcmp(argv[1],"save")) { if(current_type==SYMBOL) { save_symbol(schematic[currentsch]); } else { if(debug_var>=1) fprintf(errfp, "xschem(): saving: current schematic\n"); if(!strcmp(schematic[currentsch],"")) { /* 20170622 check if unnamed schematic, use saveas in this case... */ saveas(); } else { save(0); } } } else if(!strcmp(argv[1],"windows")) { printf("top win:%lx\n", Tk_WindowId(Tk_Parent(Tk_MainWindow(interp)))); } else if(!strcmp(argv[1],"globals")) { printf("*******global variables:*******\n"); printf("lw=%d\n", lw); printf("lastwire=%d\n", lastwire); printf("lastinst=%d\n", lastinst); printf("lastinstdef=%d\n", lastinstdef); printf("lastselected=%d\n", lastselected); printf("lasttext=%d\n", lasttext); printf("max_texts=%d\n", max_texts); printf("max_wires=%d\n", max_wires); printf("max_instances=%d\n", max_instances); printf("max_selected=%d\n", max_selected); printf("zoom=%.16g\n", zoom); printf("xorigin=%.16g\n", xorigin); printf("yorigin=%.16g\n", yorigin); for(i=0;i"); printf("schematic[%d]=%s\n",i,schematic[i]); } printf("modified=%d\n", modified); printf("color_ps=%d\n", color_ps); printf("a3page=%d\n", a3page); printf("need_rebuild_selected_array=%d\n", need_rebuild_selected_array); printf("******* end global variables:*******\n"); } else if(!strcmp(argv[1],"help")) { printf("xschem : function used to communicate with the C program\n"); printf("Usage:\n"); printf(" xschem callback X-event_type mousex mousey Xkeysym mouse_button Xstate\n"); printf(" can be used to send any event to the application\n"); printf(" xschem netlist\n"); printf(" generates a netlist in the selected format for the current schematic\n"); printf(" xschem simulate\n"); printf(" launches the currently set simulator on the generated netlist\n"); printf(" xschem redraw\n"); printf(" Redraw the window\n"); printf(" xschem new_window library/cell\n"); printf(" start a new window optionally with specified cell\n"); printf(" xschem schematic_in_new_window \n"); printf(" start a new window with selected element schematic\n"); printf(" xschem symbol_in_new_window \n"); printf(" start a new window with selected element schematic\n"); printf(" xschem globals\n"); printf(" print information about global variables\n"); printf(" xschem inst_ptr n\n"); printf(" return inst_ptr of inst_ptr[n]\n"); printf(" xschem gensch\n"); printf(" create new schematic cell from pin names\n"); printf(" xschem netlist\n"); printf(" perform a global netlist on current schematic\n"); printf(" xschem netlist_type type\n"); printf(" set netlist type to , currently spice, vhdl, verilog or tedax\n"); printf(" xschem netlist_show yes|no\n"); printf(" show or not netlist in a window\n"); printf(" xschem save [library/name]\n"); printf(" save current schematic, optionally a lib/name can be given\n"); printf(" xschem saveas\n"); printf(" save current schematic, asking for a filename\n"); printf(" xschem load library/cell\n"); printf(" load specified cell from library\n"); printf(" xschem load_symbol library/cell\n"); printf(" load specified cell symbol view from library\n"); printf(" xschem reload\n"); printf(" reload current cell from library\n"); printf(" xschem instance library/cell x y rot flip [property string]\n"); printf(" place instance cell of the given library at x,y, rot, flip\n"); printf(" can also be given a property string\n"); printf(" xschem rect x1 y1 x2 y2 [pos]\n"); printf(" place rectangle, optionally at pos (position in database)\n"); printf(" xschem line x1 y1 x2 y2 [pos]\n"); printf(" place line, optionally at pos (position in database)\n"); printf(" xschem wire x1 y1 x2 y2 [pos]\n"); printf(" place wire, optionally at pos (position in database)\n"); printf(" xschem select instance|wire|text n\n"); printf(" select instance or text or wire number n\n"); printf(" xschem select_all\n"); printf(" select all objects\n"); printf(" xschem descend\n"); printf(" descend into schematic of selected element\n"); printf(" xschem descend_symbol\n"); printf(" descend into symbol of selected element\n"); printf(" xschem go_back\n"); printf(" back from selected element\n"); printf(" xschem unselect\n"); printf(" unselect selected objects\n"); printf(" xschem set_fill n\n"); printf(" set fill style of current layer (rectcolor) to fill pattern n (pixdata)\n"); printf(" xschem zoom_out\n"); printf(" zoom out\n"); printf(" xschem zoom_in\n"); printf(" zoom in\n"); printf(" xschem zoom_full\n"); printf(" zoom full\n"); printf(" xschem zoom_box\n"); printf(" zoom box\n"); printf(" xschem paste\n"); printf(" paste selection from clipboard\n"); printf(" xschem merge\n"); printf(" merge external file into current schematic\n"); printf(" xschem cut\n"); printf(" cut selection to clipboard\n"); printf(" xschem copy\n"); printf(" copy selection to clipboard\n"); printf(" xschem copy_objects\n"); printf(" duplicate selected objects\n"); printf(" xschem move_objects [deltax deltay]\n"); printf(" move selected objects\n"); printf(" xschem line_width n\n"); printf(" set line width to (float) n\n"); printf(" xschem delete\n"); printf(" delete selected objects\n"); printf(" xschem unhilight\n"); printf(" unlight selected nets/pins\n"); printf(" xschem hilight\n"); printf(" hilight selected nets/pins\n"); printf(" xschem delete_hilight_net\n"); printf(" unhilight all nets/pins\n"); printf(" xschem print [color]\n"); printf(" print schematic (optionally in color)\n"); printf(" xschem search [sub]token value\n"); printf(" hilight instances which match tok=val property,\n"); printf(" substring search if sub given\n"); printf(" xschem log file\n"); printf(" open a log file to write messages to\n"); printf(" xschem get variable\n"); printf(" return global variable\n"); printf(" xschem set variable value\n"); printf(" set global variable\n"); printf(" xschem clear\n"); printf(" clear current schematic\n"); printf(" xschem exit\n"); printf(" exit program gracefully\n"); printf(" xschem view_prop\n"); printf(" view properties of currently selected element\n"); printf(" xschem edit_prop\n"); printf(" edit properties of currently selected element\n"); printf(" xschem edit_vi_prop\n"); printf(" edit properties of currently selected element in a vim window\n"); printf(" xschem place_symbol\n"); printf(" place new symbol, asking filename\n"); printf(" xschem make_symbol\n"); printf(" make symbol view from current schematic\n"); printf(" xschem place_text\n"); printf(" place new text\n"); printf(" xschem sleep #ms\n"); printf(" sleep some ms\n"); printf(" xschem debug n\n"); printf(" set debug level to n: 1, 2, 3 for C Program \n"); printf(" -1,-2,-3 for Tcl frontend\n"); } else if(!strcmp(argv[1],"netlist") ) { if( set_netlist_dir(0) ) { if(netlist_type == CAD_SPICE_NETLIST) global_spice_netlist(1); /* 1 means global netlist */ else if(netlist_type == CAD_VHDL_NETLIST) global_vhdl_netlist(1); else if(netlist_type == CAD_VERILOG_NETLIST) global_verilog_netlist(1); else if(netlist_type == CAD_TEDAX_NETLIST) global_tedax_netlist(1); } } else if(!strcmp(argv[1],"simulate") ) { if( set_netlist_dir(0) ) { /* 20140404 added CAD_SPICE_NETLIST */ if(netlist_type==CAD_VERILOG_NETLIST) { my_snprintf(name, S(name), "simulate {%s.v}", skip_dir(schematic[currentsch])); tcleval(name); } else if(netlist_type==CAD_SPICE_NETLIST) { my_snprintf(name, S(name), "simulate {%s.spice}", skip_dir(schematic[currentsch])); tcleval(name); } else if(netlist_type==CAD_VHDL_NETLIST) { my_snprintf(name, S(name), "simulate {%s.vhdl}", skip_dir(schematic[currentsch])); tcleval(name); } /* /20140404 */ } } else if(!strcmp(argv[1],"fill_symbol_editprop_form") ) { fill_symbol_editprop_form(0); } else if(!strcmp(argv[1],"update_symbol") ) { update_symbol(argv[2],0); } else if(!strcmp(argv[1],"clear_netlist_dir") ) { my_strdup(373, &netlist_dir, ""); } else if(!strcmp(argv[1],"edit_file") ) { rebuild_selected_array(); if(lastselected==0 ) { save_schematic(schematic[currentsch]); /* sync data with disk file before editing file */ my_snprintf(name, S(name), "edit_file {%s}", abs_sym_path(schematic[currentsch], ".sch")); tcleval(name); } else if(selectedgroup[0].type==ELEMENT) { my_snprintf(name, S(name), "edit_file {%s}", abs_sym_path(inst_ptr[selectedgroup[0].n].name, ".sch")); tcleval(name); } } else if(!strcmp(argv[1],"print") ) { /* 20171022 added png, svg */ if(argc==2 || (argc==3 && !strcmp(argv[2],"pdf")) ) { ps_draw(); Tcl_ResetResult(interp); } else if(argc==3 && !strcmp(argv[2],"png") ) { print_image(); Tcl_ResetResult(interp); } else if(argc==3 && !strcmp(argv[2],"svg") ) { svg_draw(); Tcl_ResetResult(interp); } } else if(!strcmp(argv[1],"load_symbol") ) { if(argc==3) { if(debug_var>=1) fprintf(errfp, "xschem(): load: filename=%s\n", argv[2]); delete_hilight_net(); currentsch = 0; unselect_all(); /* 20180929 */ remove_symbols(); load_symbol(argv[2]); my_strdup(374, &sch_prefix[currentsch],"."); zoom_full(1); } } else if(!strcmp(argv[1],"load") ) { if(argc==3) { if(debug_var>=1) fprintf(errfp, "xschem(): load: filename=%s\n", argv[2]); delete_hilight_net(); currentsch = 0; unselect_all(); /* 20180929 */ remove_symbols(); load_schematic(1, argv[2],1); my_strdup(375, &sch_prefix[currentsch],"."); zoom_full(1); } else if(argc==2) { ask_new_file(); } } else if(!strcmp(argv[1],"test")) { /*XSetWMHints(display, topwindow, hints_ptr); */ } else if(!strcmp(argv[1],"set_fill") && argc==3) { set_fill(atoi(argv[2])); } else if(!strcmp(argv[1],"redraw")) { draw(); Tcl_ResetResult(interp); } else if(!strcmp(argv[1],"break_wires")) { break_wires_at_pins(); } else if(!strcmp(argv[1],"collapse_wires")) { push_undo(); /* 20150327 */ trim_wires(); draw(); Tcl_ResetResult(interp); } else if(!strcmp(argv[1],"push_undo")) { push_undo(); } else if(!strcmp(argv[1],"new_window")) { if(argc==2) new_window("",0); else new_window(argv[2],0); } else if(!strcmp(argv[1],"symbol_in_new_window")) { symbol_in_new_window(); } else if(!strcmp(argv[1],"schematic_in_new_window")) { schematic_in_new_window(); } else if(!strcmp(argv[1],"netlist_show")) { if(!strcmp(argv[2],"yes")) netlist_show=1; else netlist_show=0; } else if(!strcmp(argv[1],"netlist_type")) { if(!strcmp(argv[2],"vhdl")) { netlist_type=CAD_VHDL_NETLIST; } else if(!strcmp(argv[2],"verilog")) { netlist_type=CAD_VERILOG_NETLIST; } else if(!strcmp(argv[2],"tedax")) { netlist_type=CAD_TEDAX_NETLIST; } else { netlist_type=CAD_SPICE_NETLIST; } tclsetvar("netlist_type",argv[2]); } else if(!strcmp(argv[1],"unselect")) { if(argc==2) unselect_all(); } else if(!strcmp(argv[1],"view_prop")) { edit_property(2); } else if(!strcmp(argv[1],"edit_prop")) { edit_property(0); } else if(!strcmp(argv[1],"edit_vi_prop")) { edit_property(1); } else if(!strcmp(argv[1],"trim_wires")) /* 20171022 */ { push_undo(); trim_wires(); draw(); Tcl_ResetResult(interp); } else if(!strcmp(argv[1],"delete")) { if(argc==2) delete(); } else if(!strcmp(argv[1],"unhilight")) { unhilight_net(); draw(); Tcl_ResetResult(interp); } else if(!strcmp(argv[1],"hilight")) { hilight_net(); draw_hilight_net(1); Tcl_ResetResult(interp); } else if(!strcmp(argv[1],"delete_hilight_net")) { delete_hilight_net(); draw(); Tcl_ResetResult(interp); } else if(!strcmp(argv[1],"search")) { /* 0 1 2 3 4 5 */ /* xschem search [no]sub 0|1 tok val */ int select, what; what = NOW; if(argc == 7) { if(!strcmp(argv[6], "ADD")) what = ADD; else if(!strcmp(argv[6], "END")) what = END; else if(!strcmp(argv[6], "NOW")) what = NOW; argc = 6; } if(argc==6) { select = atoi(argv[3]); if( !strcmp(argv[2],"nosub") ) search_inst(argv[4],argv[5],0,select, what); else search_inst(argv[4],argv[5],1,select, what); } } /* * ********** xschem get subcommands */ /* 20171010 allows to retrieve name of n-th parent schematic */ else if(argc == 4 && !strcmp(argv[1],"get") && !strcmp(argv[2],"schname") ) { int x; x = atoi(argv[3]); if(x<0 && currentsch+x>=0) { Tcl_AppendResult(interp, schematic[currentsch+x], NULL); } } else if(!strcmp(argv[1],"instance_pos")) { int i; char s[30]; for(i=0;irects[PINLAYER]; for(p=0;pboxptr[PINLAYER][p].prop_ptr,"name",0); if(!pin[0]) pin = "--ERROR--"; my_strcat(376, &pins, pin); if(p< no_of_pins-1) my_strcat(377, &pins, " "); } Tcl_AppendResult(interp, pins, NULL); my_free(&pins); } else if(argc == 4 && !strcmp(argv[1],"get") && !strcmp(argv[2],"expandlabel")) { /* 20121121 */ int tmp, llen; char *result=NULL; const char *l; l = expandlabel(argv[3], &tmp); llen = strlen(l); result = my_malloc(378, llen + 30); my_snprintf(result, llen + 30, "%s %d", l, tmp); Tcl_AppendResult(interp, result, NULL); my_free(&result); } else if(!strcmp(argv[1],"get") && argc==3) { Tcl_ResetResult(interp); if(!strcmp(argv[2],"current_type")) { /* 20171025 */ if( current_type == SYMBOL ) Tcl_AppendResult(interp, "SYMBOL",NULL); else Tcl_AppendResult(interp, "SCHEMATIC",NULL); } else if(!strcmp(argv[2],"netlist_type")) { if( netlist_type == CAD_VHDL_NETLIST ) Tcl_AppendResult(interp, "vhdl",NULL); else if( netlist_type == CAD_SPICE_NETLIST ) Tcl_AppendResult(interp, "spice",NULL); else if( netlist_type == CAD_TEDAX_NETLIST ) Tcl_AppendResult(interp, "tedax",NULL); else Tcl_AppendResult(interp, "verilog",NULL); } else if(!strcmp(argv[2],"incr_hilight")) { if( incr_hilight != 0 ) Tcl_AppendResult(interp, "1",NULL); else Tcl_AppendResult(interp, "0",NULL); } else if(!strcmp(argv[2],"auto_hilight")) { /* 20160413 */ if( auto_hilight != 0 ) Tcl_AppendResult(interp, "1",NULL); else Tcl_AppendResult(interp, "0",NULL); } else if(!strcmp(argv[2],"netlist_show")) { if( netlist_show != 0 ) Tcl_AppendResult(interp, "1",NULL); else Tcl_AppendResult(interp, "0",NULL); } else if(!strcmp(argv[2],"flat_netlist")) { if( flat_netlist != 0 ) Tcl_AppendResult(interp, "1",NULL); else Tcl_AppendResult(interp, "0",NULL); } else if(!strcmp(argv[2],"split_files")) { if( split_files != 0 ) Tcl_AppendResult(interp, "1",NULL); else Tcl_AppendResult(interp, "0",NULL); } else if(!strcmp(argv[2],"hspice_netlist")) { if( hspice_netlist != 0 ) Tcl_AppendResult(interp, "1",NULL); else Tcl_AppendResult(interp, "0",NULL); } else if(!strcmp(argv[2],"enable_stretch")) { if( enable_stretch != 0 ) Tcl_AppendResult(interp, "1",NULL); else Tcl_AppendResult(interp, "0",NULL); } else if(!strcmp(argv[2],"help")) { /* 20140406 */ if( help != 0 ) Tcl_AppendResult(interp, "1",NULL); else Tcl_AppendResult(interp, "0",NULL); } else if(!strcmp(argv[2],"color_ps")) { if( color_ps != 0 ) Tcl_AppendResult(interp, "1",NULL); else Tcl_AppendResult(interp, "0",NULL); } else if(!strcmp(argv[2],"only_probes")) { /* 20110112 */ if( only_probes != 0 ) Tcl_AppendResult(interp, "1",NULL); else Tcl_AppendResult(interp, "0",NULL); } else if(!strcmp(argv[2],"a3page")) { if( a3page != 0 ) Tcl_AppendResult(interp, "1",NULL); else Tcl_AppendResult(interp, "0",NULL); } else if(!strcmp(argv[2],"draw_grid")) { if( draw_grid != 0 ) Tcl_AppendResult(interp, "1",NULL); else Tcl_AppendResult(interp, "0",NULL); } else if(!strcmp(argv[2],"sym_txt")) { if( sym_txt != 0 ) Tcl_AppendResult(interp, "1",NULL); else Tcl_AppendResult(interp, "0",NULL); } else if(!strcmp(argv[2],"schname")) { Tcl_AppendResult(interp, schematic[currentsch], NULL); } else if(!strcmp(argv[2],"cadsnap_default")) { /* 20161212 */ Tcl_AppendResult(interp, tclgetvar("snap"),NULL); } else if(!strcmp(argv[2],"cadsnap")) { /* 20161212 */ char s[30]; /* overflow safe 20161212 */ my_snprintf(s, S(s), "%.9g",cadsnap); Tcl_AppendResult(interp, s,NULL); } else if(!strcmp(argv[2],"rectcolor")) { char s[30]; /* overflow safe 20161122 */ my_snprintf(s, S(s), "%d",rectcolor); Tcl_AppendResult(interp, s,NULL); } else if(!strcmp(argv[2],"debug_var")) { char s[30]; /* overflow safe 20161122 */ my_snprintf(s, S(s), "%d",debug_var); Tcl_AppendResult(interp, s,NULL); } else if(!strcmp(argv[2],"semaphore")) { char s[30]; /* overflow safe 20161122 */ my_snprintf(s, S(s), "%d",semaphore); Tcl_AppendResult(interp, s,NULL); } else if(!strcmp(argv[2],"change_lw")) { char s[30]; /* overflow safe 20161122 */ my_snprintf(s, S(s), "%d",change_lw); Tcl_AppendResult(interp, s,NULL); } else if(!strcmp(argv[2],"draw_window")) { char s[30]; /* overflow safe 20161122 */ my_snprintf(s, S(s), "%d",draw_window); Tcl_AppendResult(interp, s,NULL); } else if(!strcmp(argv[2],"ui_state")) { char s[30]; /* overflow safe 20161122 */ my_snprintf(s, S(s), "%d",ui_state); Tcl_AppendResult(interp, s,NULL); } else if(!strcmp(argv[2],"netlist_dir")) { Tcl_AppendResult(interp, netlist_dir,NULL); } else if(!strcmp(argv[2],"sch_path")) { /* 20121121 */ Tcl_AppendResult(interp, sch_prefix[currentsch], NULL); } else if(!strcmp(argv[2],"dim")) { /* 20121121 */ char s[40]; my_snprintf(s, S(s), "%.2g", color_dim); Tcl_AppendResult(interp, s, NULL); } else if(!strcmp(argv[2],"lastinst")) { /* 20121121 */ char s[30]; /* overflow safe 20161122 */ my_snprintf(s, S(s), "%d",lastinst); Tcl_AppendResult(interp, s,NULL); } else if(!strcmp(argv[2],"pinlayer")) { /* 20121121 */ char s[30]; /* overflow safe 20161122 */ my_snprintf(s, S(s), "%d",PINLAYER); Tcl_AppendResult(interp, s,NULL); } else if(!strcmp(argv[2],"wirelayer")) { /* 20121121 */ char s[30]; /* overflow safe 20161122 */ my_snprintf(s, S(s), "%d",WIRELAYER); Tcl_AppendResult(interp, s,NULL); } else if(!strcmp(argv[2],"textlayer")) { /* 20121121 */ char s[30]; /* overflow safe 20161122 */ my_snprintf(s, S(s), "%d",TEXTLAYER); Tcl_AppendResult(interp, s,NULL); } else if(!strcmp(argv[2],"sellayer")) { /* 20121121 */ char s[30]; /* overflow safe 20161122 */ my_snprintf(s, S(s), "%d",SELLAYER); Tcl_AppendResult(interp, s,NULL); } else if(!strcmp(argv[2],"gridlayer")) { /* 20121121 */ char s[30]; /* overflow safe 20161122 */ my_snprintf(s, S(s), "%d",GRIDLAYER); Tcl_AppendResult(interp, s,NULL); } else if(!strcmp(argv[2],"backlayer")) { /* 20121121 */ char s[30]; /* overflow safe 20161122 */ my_snprintf(s, S(s), "%d",BACKLAYER); Tcl_AppendResult(interp, s,NULL); } else if(!strcmp(argv[2],"version")) { /* 20121121 */ char s[30]; /* overflow safe 20161122 */ my_snprintf(s, S(s), "XSCHEM V%s",XSCHEM_VERSION); Tcl_AppendResult(interp, s,NULL); } else if(!strcmp(argv[2],"userconfdir")) { /* 20121121 */ char s[30]; /* overflow safe 20161122 */ my_snprintf(s, S(s), "%s",USER_CONF_DIR); Tcl_AppendResult(interp, s,NULL); } else { fprintf(errfp, "xschem get %s: invalid command.\n", argv[2]); } } /* * ********** xschem set subcommands */ else if(!strcmp(argv[1],"set") && argc==3) { /* 20171023 */ if(!strcmp(argv[2],"horizontal_move")) { /* 20171023 */ horizontal_move = atoi(tclgetvar("horizontal_move")); if(horizontal_move) { vertical_move=0; tcleval("set vertical_move 0" ); } } else if(!strcmp(argv[2],"vertical_move")) { /* 20171023 */ vertical_move = atoi(tclgetvar("vertical_move")); if(vertical_move) { horizontal_move=0; tcleval("set horizontal_move 0" ); } } else { fprintf(errfp, "xschem set %s : invalid command.\n", argv[2]); } } else if(!strcmp(argv[1],"set") && argc==4) { #ifdef HAS_CAIRO if(!strcmp(argv[2],"cairo_font_name")) { if( strlen(argv[3]) < sizeof(cairo_font_name) ) { my_strncpy(cairo_font_name, argv[3], S(cairo_font_name)); cairo_select_font_face (ctx, cairo_font_name, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_select_font_face (save_ctx, cairo_font_name, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); } } else #endif if(!strcmp(argv[2],"no_undo")) { /* 20171204 */ int s = atoi(argv[3]); no_undo=s; } else if(!strcmp(argv[2],"no_draw")) { /* 20171204 */ int s = atoi(argv[3]); no_draw=s; } else if(!strcmp(argv[2],"renumber")) { /* 20171204 */ int s = atoi(argv[3]); renumber_instances=s; } else if(!strcmp(argv[2],"dim")) { double s = atof(argv[3]); color_dim = s; } else if(!strcmp(argv[2],"cairo_font_scale")) { double s = atof(argv[3]); if(s>0.1 && s<10.0) cairo_font_scale = s; } else if(!strcmp(argv[2],"cairo_font_line_spacing")) { double s = atof(argv[3]); if(s>0.1 && s<10.0) cairo_font_line_spacing = s; } else if(!strcmp(argv[2],"cairo_vert_correct")) { double s = atof(argv[3]); if(s>-20. && s<20.) cairo_vert_correct = s; } else if(!strcmp(argv[2],"netlist_type")) { if(!strcmp(argv[3],"vhdl")) { netlist_type = CAD_VHDL_NETLIST ; } else if(!strcmp(argv[3],"verilog")) { netlist_type = CAD_VERILOG_NETLIST ; } else if(!strcmp(argv[3],"tedax")) { netlist_type = CAD_TEDAX_NETLIST ; } else { netlist_type = CAD_SPICE_NETLIST ; } } else if(!strcmp(argv[2],"current_type")) { /* 20171025 */ if(!strcmp(argv[3],"SYMBOL")) { current_type=SYMBOL; } else { current_type=SCHEMATIC; } } else if(!strcmp(argv[2],"persistent_command")) { /* 20171025 */ if(!strcmp(argv[3],"1")) { persistent_command=1; } else { persistent_command=0; } } else if(!strcmp(argv[2],"netlist_dir")) { my_strdup(379, &netlist_dir, argv[3]); } else if(!strcmp(argv[2],"incr_hilight")) { incr_hilight=atoi(argv[3]); } else if(!strcmp(argv[2],"auto_hilight")) { /* 20160413 */ auto_hilight=atoi(argv[3]); } else if(!strcmp(argv[2],"netlist_show")) { netlist_show=atoi(argv[3]); } else if(!strcmp(argv[2],"semaphore")) { semaphore=atoi(argv[3]); } else if(!strcmp(argv[2],"cadsnap")) { /* 20161212 */ set_snap( atof(argv[3]) ); } else if(!strcmp(argv[2],"cadgrid")) { /* 20161212 */ set_grid( atof(argv[3]) ); } else if(!strcmp(argv[2],"flat_netlist")) { flat_netlist=atoi(argv[3]); } else if(!strcmp(argv[2],"split_files")) { split_files=atoi(argv[3]); } else if(!strcmp(argv[2],"hspice_netlist")) { hspice_netlist=atoi(argv[3]); my_snprintf(name, S(name), "%d", hspice_netlist); tclsetvar("hspice_netlist",name); } else if(!strcmp(argv[2],"enable_stretch")) { enable_stretch=atoi(argv[3]); } else if(!strcmp(argv[2],"a3page")) { a3page=atoi(argv[3]); } else if(!strcmp(argv[2],"color_ps")) { color_ps=atoi(argv[3]); } else if(!strcmp(argv[2],"only_probes")) { /* 20110112 */ only_probes=atoi(argv[3]); } else if(!strcmp(argv[2],"draw_grid")) { draw_grid=atoi(argv[3]); } else if(!strcmp(argv[2],"sym_txt")) { sym_txt=atoi(argv[3]); } else if(!strcmp(argv[2],"rectcolor")) { rectcolor=atoi(argv[3]); rebuild_selected_array(); if(lastselected) { change_layer(); } } else if(!strcmp(argv[2],"change_lw")) { change_lw=atoi(argv[3]); } else if(!strcmp(argv[2],"draw_window")) { draw_window=atoi(argv[3]); } else if(!strcmp(argv[2],"ui_state")) { ui_state=atoi(argv[3]); } else { fprintf(errfp, "xschem set %s %s : invalid command.\n", argv[2], argv[3]); } } else { fprintf(errfp, "xschem %s: invalid command.\n", argv[1]); } return TCL_OK; } const char *tclgetvar(const char *s) { if(debug_var>=2) fprintf(errfp, "tclgetvar(): %s\n", s); return Tcl_GetVar(interp,s, TCL_GLOBAL_ONLY); } void tcleval(const char str[]) { if(debug_var>=2) fprintf(errfp, "tcleval(): %s\n", str); /* if( Tcl_EvalEx(interp, str, -1, TCL_EVAL_GLOBAL) != TCL_OK) {*/ if( Tcl_Eval(interp, str) != TCL_OK) { fprintf(errfp, "tcleval(): evaluation of script: %s failed\n", str); } } void tclsetvar(const char *s, const char *value) { if(debug_var>=2) fprintf(errfp, "tclsetvar(): %s to %s\n", s, value); if(!Tcl_SetVar(interp, s, value, TCL_GLOBAL_ONLY)) { fprintf(errfp, "tclsetvar(): error setting variable %s to %s\n", s, value); } } xschem-2.8.1/src/icon.xpm0000644000175100017510000000543513023243556013470 0ustar svnsvn/* XPM */ static char *icon[] = { /* width height num_colors chars_per_pixel */ " 60 41 5 1", /* colors */ ". c #000000", "# c #00a8e8", "a c #787c78", "b c #88dc00", "c c #b00000", /* pixels */ "............................................................", "............................................................", "............................................................", "............................................................", ".......a...........a...........a...........a...........a....", "............................................................", "...................bbbb.....................bbbb............", "....................b.........................b.............", "....................c........................cb.............", "..................b.b......................b..b.............", "..................bbb......................bbbb.............", ".................bb.......................bb................", "................bbb......................bbb................", "..............cbbbb....................cbbbb................", "...............#bbb.....................#bbb................", "...............#.bb.....................#.bb................", ".......a.......#..bbb..........a........#..bbbb........a....", "...............#..b.c...................#..b.cb.............", "...............#....#...................#.....#.............", "...............#....#...................#.....#.............", "......cccc######....#####################.....##############", "......ccc......#....#...................#.....#.............", "...............#....#...................#.....#.............", "...............#....c...................#....cb.............", "...............#..b.b...................#..b..b.............", "...............#..bbb...................#..bbbb.............", "...............#.bb.....................#.bb................", "...............#.bb.....................#.bb................", ".......a......cbbbba...........a.......cbbbb...........a....", ".................bb.......................bb................", ".................bb.......................bb................", "..................bbb......................bbbb.............", "..................b.c......................b.cb.............", "....................b.........................b.............", "....................bb.......................bb.............", "....................b.........................b.............", "............................................................", "............................................................", "............................................................", "............................................................", ".......a...........a...........a...........a...........a...." }; xschem-2.8.1/src/move.c0000644000175100017510000011723413400741444013123 0ustar svnsvn/* File: move.c * * This file is part of XSCHEM, * a schematic capture and Spice/Vhdl/Verilog netlisting tool for circuit * simulation. * Copyright (C) 1998-2018 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 */ #include "xschem.h" static double rx1, rx2, ry1, ry2; static int rot = 0; static int flip = 0; static double x1=0.0, y_1=0.0, x2=0.0, y_2=0.0, deltax = 0.0, deltay = 0.0; /* static int i,c,n,k; */ static int lastsel; static int rotatelocal=0; /* 20171208 */ void rebuild_selected_array() /* can be used only if new selected set is lower */ /* that is, selectedgroup[] size can not increase */ { int i,c; if(!need_rebuild_selected_array) return; lastselected=0; for(i=0;i=1) fprintf(errfp, "copy_objects(): BEGIN copy\n"); rebuild_selected_array(); save_selection(1); deltax = deltay = 0.0; lastsel = lastselected; x1=mousex_snap;y_1=mousey_snap; flip = 0;rot = 0; ui_state|=STARTCOPY; } if(what & ABORT) /* draw objects while moving */ { draw_selection(gctiled,0); rot=flip=deltax=deltay=0; ui_state&=~STARTCOPY; my_strdup(225, &str, home_dir); my_strcat(226, &str, "/.xschem_selection.sch"); unlink(str); } if(what & RUBBER) /* draw objects while moving */ { x2=mousex_snap;y_2=mousey_snap; draw_selection(gctiled,0); deltax = x2-x1; deltay = y_2 - y_1; draw_selection(gc[SELLAYER],1); } if(what & ROTATELOCAL ) { /*20171208 */ rotatelocal=1; } if(what & ROTATE) { draw_selection(gctiled,0); rot= (rot+1) & 0x3; } if(what & FLIP) { draw_selection(gctiled,0); flip = !flip; } if(what & END) /* copy selected objects */ { int save_draw; /* 20181009 */ save_draw = draw_window; draw_window=1; /* temporarily re-enable draw to window together with pixmap */ draw_selection(gctiled,0); bbox(BEGIN, 0.0 , 0.0 , 0.0 , 0.0); /* 20181009 */ newpropcnt=0; set_modify(1); push_undo(); /* 20150327 push_undo */ prepared_hash_instances=0; /* 20171224 */ prepared_hash_wires=0; /* 20171224 */ prepared_netlist_structs=0; prepared_hilight_structs=0; for(k=0;k CADHALFDOTSIZE ? BUS_WIDTH : CADHALFDOTSIZE; if(wire[n].y1 < wire[n].y2) { y1 = wire[n].y1-ov; y2 = wire[n].y2+ov; } else { y1 = wire[n].y1+ov; y2 = wire[n].y2-ov; } bbox(ADD, wire[n].x1-ov, y1 , wire[n].x2+ov , y2 ); } else { int ov, y1, y2; ov = CADHALFDOTSIZE; if(wire[n].y1 < wire[n].y2) { y1 = wire[n].y1-ov; y2 = wire[n].y2+ov; } else { y1 = wire[n].y1+ov; y2 = wire[n].y2-ov; } bbox(ADD, wire[n].x1-ov, y1 , wire[n].x2+ov , y2 ); } if(rotatelocal) { ROTATION(wire[n].x1, wire[n].y1, wire[n].x1, wire[n].y1, rx1,ry1); ROTATION(wire[n].x1, wire[n].y1, wire[n].x2, wire[n].y2, rx2,ry2); } else { ROTATION(x1, y_1, wire[n].x1, wire[n].y1, rx1,ry1); ROTATION(x1, y_1, wire[n].x2, wire[n].y2, rx2,ry2); } if( wire[n].sel & (SELECTED|SELECTED1) ) { rx1+=deltax; ry1+=deltay; } if( wire[n].sel & (SELECTED|SELECTED2) ) { rx2+=deltax; ry2+=deltay; } tmpx=rx1; /* used as temporary storage */ tmpy=ry1; ORDER(rx1,ry1,rx2,ry2); if( tmpx == rx2 && tmpy == ry2) { if(wire[n].sel == SELECTED1) wire[n].sel = SELECTED2; else if(wire[n].sel == SELECTED2) wire[n].sel = SELECTED1; } if(wire[n].bus) /* 20171201 */ drawline(k, THICK, rx1,ry1,rx2,ry2); else drawline(k, ADD, rx1,ry1,rx2,ry2); selectedgroup[i].n=lastwire; storeobject(-1, rx1,ry1,rx2,ry2,WIRE,0,wire[n].sel,wire[n].prop_ptr); wire[n].sel=0; break; case LINE: if(c!=k) break; bbox(ADD, line[c][n].x1, line[c][n].y1, line[c][n].x2, line[c][n].y2); /* 20181009 */ if(rotatelocal) { ROTATION(line[c][n].x1, line[c][n].y1, line[c][n].x1, line[c][n].y1, rx1,ry1); ROTATION(line[c][n].x1, line[c][n].y1, line[c][n].x2, line[c][n].y2, rx2,ry2); } else { ROTATION(x1, y_1, line[c][n].x1, line[c][n].y1, rx1,ry1); ROTATION(x1, y_1, line[c][n].x2, line[c][n].y2, rx2,ry2); } if( line[c][n].sel & (SELECTED|SELECTED1) ) { rx1+=deltax; ry1+=deltay; } if( line[c][n].sel & (SELECTED|SELECTED2) ) { rx2+=deltax; ry2+=deltay; } tmpx=rx1; tmpy=ry1; ORDER(rx1,ry1,rx2,ry2); if( tmpx == rx2 && tmpy == ry2) { if(line[c][n].sel == SELECTED1) line[c][n].sel = SELECTED2; else if(line[c][n].sel == SELECTED2) line[c][n].sel = SELECTED1; } drawline(k, ADD, rx1,ry1,rx2,ry2); selectedgroup[i].n=lastline[c]; storeobject(-1, rx1, ry1, rx2, ry2, LINE, c, line[c][n].sel, line[c][n].prop_ptr); line[c][n].sel=0; break; case POLYGON: /* 20171115 */ if(c!=k) break; { double bx1, by1, bx2, by2; double *x = my_malloc(227, sizeof(double) *polygon[c][n].points); double *y = my_malloc(228, sizeof(double) *polygon[c][n].points); int j; for(j=0; j bx2) bx2 = polygon[c][n].x[j]; if(j==0 || polygon[c][n].y[j] > by2) by2 = polygon[c][n].y[j]; if( polygon[c][n].sel==SELECTED || polygon[c][n].selected_point[j]) { if(rotatelocal) { ROTATION(polygon[c][n].x[0], polygon[c][n].y[0], polygon[c][n].x[k], polygon[c][n].y[k], rx1,ry1); } else { ROTATION(x1, y_1, polygon[c][n].x[j], polygon[c][n].y[j], rx1,ry1); } x[j] = rx1+deltax; y[j] = ry1+deltay; } else { x[j] = polygon[c][n].x[j]; y[j] = polygon[c][n].y[j]; } bbox(ADD, bx1, by1, bx2, by2); /* 20181009 */ } drawpolygon(k, NOW, x, y, polygon[c][n].points, polygon[c][n].fill); /* 20180914 added fill */ selectedgroup[i].n=lastpolygon[c]; store_polygon(-1, x, y, polygon[c][n].points, c, polygon[c][n].sel, polygon[c][n].prop_ptr); polygon[c][n].sel=0; my_free(&x); my_free(&y); } break; case ARC: if(c!=k) break; arc_bbox(arc[c][n].x, arc[c][n].y, arc[c][n].r, arc[c][n].a, arc[c][n].b, &tmp.x1, &tmp.y1, &tmp.x2, &tmp.y2); bbox(ADD, tmp.x1, tmp.y1, tmp.x2, tmp.y2); if(rotatelocal) { /* rotate center wrt itself: do nothing */ rx1 = arc[c][n].x; ry1 = arc[c][n].y; } else { ROTATION(x1, y_1, arc[c][n].x, arc[c][n].y, rx1,ry1); } angle = arc[c][n].a; if(flip) { angle = 270.*rot+180.-arc[c][n].b-arc[c][n].a; } else { angle = arc[c][n].a+rot*270.; } angle = fmod(angle, 360.); if(angle<0.) angle+=360.; arc[c][n].sel=0; drawarc(k, ADD, rx1+deltax, ry1+deltay, arc[c][n].r, angle, arc[c][n].b); selectedgroup[i].n=lastarc[c]; store_arc(-1, rx1+deltax, ry1+deltay, arc[c][n].r, angle, arc[c][n].b, c, SELECTED, arc[c][n].prop_ptr); break; case RECT: if(c!=k) break; bbox(ADD, rect[c][n].x1, rect[c][n].y1, rect[c][n].x2, rect[c][n].y2); /* 20181009 */ if(rotatelocal) { ROTATION(rect[c][n].x1, rect[c][n].y1, rect[c][n].x1, rect[c][n].y1, rx1,ry1); ROTATION(rect[c][n].x1, rect[c][n].y1, rect[c][n].x2, rect[c][n].y2, rx2,ry2); } else { ROTATION(x1, y_1, rect[c][n].x1, rect[c][n].y1, rx1,ry1); ROTATION(x1, y_1, rect[c][n].x2, rect[c][n].y2, rx2,ry2); } RECTORDER(rx1,ry1,rx2,ry2); rect[c][n].sel=0; drawrect(k, ADD, rx1+deltax, ry1+deltay, rx2+deltax, ry2+deltay); filledrect(k, ADD, rx1+deltax, ry1+deltay, rx2+deltax, ry2+deltay); selectedgroup[i].n=lastrect[c]; storeobject(-1, rx1+deltax, ry1+deltay, rx2+deltax, ry2+deltay,RECT, c, SELECTED, rect[c][n].prop_ptr); break; case TEXT: if(k!=TEXTLAYER) break; check_text_storage(); /* 20181009 */ #ifdef HAS_CAIRO customfont = set_text_custom_font(&textelement[n]); #endif text_bbox(textelement[n].txt_ptr, textelement[n].xscale, textelement[n].yscale, textelement[n].rot,textelement[n].flip, textelement[n].x0, textelement[n].y0, &rx1,&ry1, &rx2,&ry2); #ifdef HAS_CAIRO if(customfont) cairo_restore(ctx); #endif bbox(ADD, rx1, ry1, rx2, ry2 ); if(rotatelocal) { ROTATION(textelement[n].x0, textelement[n].y0, textelement[n].x0, textelement[n].y0, rx1,ry1); } else { ROTATION(x1, y_1, textelement[n].x0, textelement[n].y0, rx1,ry1); } textelement[lasttext].txt_ptr=NULL; my_strdup(229, &textelement[lasttext].txt_ptr,textelement[n].txt_ptr); textelement[n].sel=0; if(debug_var>=2) fprintf(errfp, "copy_objects(): current str=%s\n", textelement[lasttext].txt_ptr); textelement[lasttext].x0=rx1+deltax; textelement[lasttext].y0=ry1+deltay; textelement[lasttext].rot=(textelement[n].rot + ( (flip && (textelement[n].rot & 1) ) ? rot+2 : rot) ) & 0x3; textelement[lasttext].flip=flip^textelement[n].flip; textelement[lasttext].sel=SELECTED; textelement[lasttext].prop_ptr=NULL; textelement[lasttext].font=NULL; my_strdup(230, &textelement[lasttext].prop_ptr, textelement[n].prop_ptr); my_strdup(231, &textelement[lasttext].font, get_tok_value(textelement[lasttext].prop_ptr, "font", 0));/*20171206 */ strlayer = get_tok_value(textelement[lasttext].prop_ptr, "layer", 0); /*20171206 */ if(strlayer[0]) textelement[lasttext].layer = atoi(strlayer); else textelement[lasttext].layer = -1; textelement[lasttext].xscale=textelement[n].xscale; textelement[lasttext].yscale=textelement[n].yscale; textlayer = TEXTLAYER; #ifdef HAS_CAIRO textlayer = textelement[lasttext].layer; /* 20171206 */ if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER; textfont = textelement[lasttext].font; /* 20171206 */ if(textfont && textfont[0]) { cairo_save(ctx); cairo_save(save_ctx); cairo_select_font_face (ctx, textfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_select_font_face (save_ctx, textfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); } #endif draw_string(textlayer, ADD, textelement[lasttext].txt_ptr, /* draw moved txt */ textelement[lasttext].rot, textelement[lasttext].flip, rx1+deltax,ry1+deltay, textelement[lasttext].xscale, textelement[lasttext].yscale); #ifdef HAS_CAIRO if(textfont && textfont[0]) { /* cairo_select_font_face (ctx, cairo_font_name, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); */ /* cairo_select_font_face (save_ctx, cairo_font_name, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); */ cairo_restore(ctx); cairo_restore(save_ctx); } #endif selectedgroup[i].n=lasttext; lasttext++; if(debug_var>=2) fprintf(errfp, "copy_objects(): done copy string\n"); break; case ELEMENT: if(k==0) { check_inst_storage(); /* 20181009 */ symbol_bbox(n, &inst_ptr[n].x1, &inst_ptr[n].y1, &inst_ptr[n].x2, &inst_ptr[n].y2 ); /* 20171201 */ bbox(ADD, inst_ptr[n].x1, inst_ptr[n].y1, inst_ptr[n].x2, inst_ptr[n].y2 ); if(rotatelocal) { ROTATION(inst_ptr[n].x0, inst_ptr[n].y0, inst_ptr[n].x0, inst_ptr[n].y0, rx1,ry1); } else { ROTATION(x1, y_1, inst_ptr[n].x0, inst_ptr[n].y0, rx1,ry1); } inst_ptr[lastinst] = inst_ptr[n]; inst_ptr[lastinst].prop_ptr=NULL; inst_ptr[lastinst].instname=NULL; /* 20150409 */ inst_ptr[lastinst].node=NULL; inst_ptr[lastinst].name=NULL; my_strdup(232, &inst_ptr[lastinst].name, inst_ptr[n].name); my_strdup(233, &inst_ptr[lastinst].prop_ptr, inst_ptr[n].prop_ptr); my_strdup2(234, &inst_ptr[lastinst].instname, get_tok_value(inst_ptr[n].prop_ptr, "name",0)); /* 20150409 */ inst_ptr[n].sel=0; inst_ptr[lastinst].x0 = rx1+deltax; inst_ptr[lastinst].y0 = ry1+deltay; inst_ptr[lastinst].sel = SELECTED; inst_ptr[lastinst].rot = (inst_ptr[lastinst].rot + ( (flip && (inst_ptr[lastinst].rot & 1) ) ? rot+2 : rot) ) & 0x3; inst_ptr[lastinst].flip = (flip? !inst_ptr[n].flip:inst_ptr[n].flip); new_prop_string(&inst_ptr[lastinst].prop_ptr, inst_ptr[n].prop_ptr,newpropcnt++); /* the final newpropcnt argument is zero for the 1st call and used in */ /* new_prop_string() for cleaning some internal caches. */ my_strdup2(235, &inst_ptr[lastinst].instname, get_tok_value(inst_ptr[lastinst].prop_ptr, "name", 0)); /* 20150409 */ hash_proplist(inst_ptr[lastinst].prop_ptr , 0); n=selectedgroup[i].n=lastinst; symbol_bbox(lastinst, &inst_ptr[lastinst].x1, &inst_ptr[lastinst].y1, &inst_ptr[lastinst].x2, &inst_ptr[lastinst].y2); lastinst++; } draw_symbol_outline(ADD,k, n,k, 0, 0, 0.0, 0.0); break; } } filledrect(k, END, 0.0, 0.0, 0.0, 0.0); drawarc(k, END, 0.0, 0.0, 0.0, 0.0, 0.0); drawrect(k, END, 0.0, 0.0, 0.0, 0.0); drawline(k, END, 0.0, 0.0, 0.0, 0.0); } /* end for(k ... */ check_collapsing_objects(); update_conn_cues(1, 1); ui_state &= ~STARTCOPY; x1=y_1=x2=y_2=rot=flip=deltax=deltay=0; bbox(SET , 0.0 , 0.0 , 0.0 , 0.0); draw(); bbox(END , 0.0 , 0.0 , 0.0 , 0.0); need_rebuild_selected_array=1; rotatelocal=0; draw_window = save_draw; } draw_selection(gc[SELLAYER], 0); } void move_objects(int what, int merge, double dx, double dy) { int c, i, n, k; Box tmp; double angle; double tx1,ty1; /* temporaries for swapping coordinates 20070302 */ int textlayer; #ifdef HAS_CAIRO int customfont; #endif /* 20171112 */ #ifdef HAS_CAIRO char *textfont; #endif if(what & BEGIN) { rotatelocal=0; /*20171208 */ deltax = deltay = 0.0; rebuild_selected_array(); lastsel = lastselected; if(merge) x1=y_1=0.0; else if(lastselected==1 && selectedgroup[0].type==ARC && arc[c=selectedgroup[0].col][n=selectedgroup[0].n].sel!=SELECTED) { x1 = arc[c][n].x; y_1 = arc[c][n].y; } else {x1=mousex_snap;y_1=mousey_snap;} flip = 0;rot = 0; ui_state|=STARTMOVE; } if(what & ABORT) /* draw objects while moving */ { draw_selection(gctiled,0); rot=flip=deltax=deltay=0; ui_state&=~STARTMOVE; } if(what & RUBBER) /* abort operation */ { x2=mousex_snap;y_2=mousey_snap; draw_selection(gctiled,0); deltax = x2-x1; deltay = y_2 - y_1; draw_selection(gc[SELLAYER],1); } if(what & ROTATELOCAL) { /*20171208 */ rotatelocal=1; } if(what & ROTATE) { draw_selection(gctiled,0); rot= (rot+1) & 0x3; } if(what & FLIP) { draw_selection(gctiled,0); flip = !flip; } if(what & END) /* move selected objects */ { int save_draw; /* 20181009 */ save_draw = draw_window; draw_window=1; /* temporarily re-enable draw to window together with pixmap */ draw_selection(gctiled,0); bbox(BEGIN, 0.0 , 0.0 , 0.0 , 0.0); set_modify(1); prepared_hash_instances=0; /* 20171224 */ prepared_hash_wires=0; /* 20171224 */ prepared_netlist_structs=0; prepared_hilight_structs=0; if(! ( ui_state & STARTMERGE) ) push_undo(); /* 20150327 push_undo */ if(dx!=0.0 || dy!=0.0) { deltax = dx; deltay = dy; } for(k=0;k CADHALFDOTSIZE ? BUS_WIDTH : CADHALFDOTSIZE; if(wire[n].y1 < wire[n].y2) { y1 = wire[n].y1-ov; y2 = wire[n].y2+ov; } else { y1 = wire[n].y1+ov; y2 = wire[n].y2-ov; } bbox(ADD, wire[n].x1-ov, y1 , wire[n].x2+ov , y2 ); } else { int ov, y1, y2; ov = CADHALFDOTSIZE; if(wire[n].y1 < wire[n].y2) { y1 = wire[n].y1-ov; y2 = wire[n].y2+ov; } else { y1 = wire[n].y1+ov; y2 = wire[n].y2-ov; } bbox(ADD, wire[n].x1-ov, y1 , wire[n].x2+ov , y2 ); } if(rotatelocal) { ROTATION(wire[n].x1, wire[n].y1, wire[n].x1, wire[n].y1, rx1,ry1); ROTATION(wire[n].x1, wire[n].y1, wire[n].x2, wire[n].y2, rx2,ry2); } else { ROTATION(x1, y_1, wire[n].x1, wire[n].y1, rx1,ry1); ROTATION(x1, y_1, wire[n].x2, wire[n].y2, rx2,ry2); } if( wire[n].sel & (SELECTED|SELECTED1) ) { rx1+=deltax; ry1+=deltay; } if( wire[n].sel & (SELECTED|SELECTED2) ) { rx2+=deltax; ry2+=deltay; } wire[n].x1=rx1; wire[n].y1=ry1; ORDER(rx1,ry1,rx2,ry2); if( wire[n].x1 == rx2 && wire[n].y1 == ry2) { if(wire[n].sel == SELECTED1) wire[n].sel = SELECTED2; else if(wire[n].sel == SELECTED2) wire[n].sel = SELECTED1; } wire[n].x1=rx1; wire[n].y1=ry1; wire[n].x2=rx2; wire[n].y2=ry2; if(wire[n].bus) /* 20171201 */ drawline(k, THICK, wire[n].x1, wire[n].y1, wire[n].x2, wire[n].y2); else drawline(k, ADD, wire[n].x1, wire[n].y1, wire[n].x2, wire[n].y2); break; case LINE: if(c!=k) break; bbox(ADD, line[c][n].x1, line[c][n].y1, line[c][n].x2, line[c][n].y2); if(rotatelocal) { ROTATION(line[c][n].x1, line[c][n].y1, line[c][n].x1, line[c][n].y1, rx1,ry1); ROTATION(line[c][n].x1, line[c][n].y1, line[c][n].x2, line[c][n].y2, rx2,ry2); } else { ROTATION(x1, y_1, line[c][n].x1, line[c][n].y1, rx1,ry1); ROTATION(x1, y_1, line[c][n].x2, line[c][n].y2, rx2,ry2); } if( line[c][n].sel & (SELECTED|SELECTED1) ) { rx1+=deltax; ry1+=deltay; } if( line[c][n].sel & (SELECTED|SELECTED2) ) { rx2+=deltax; ry2+=deltay; } line[c][n].x1=rx1; line[c][n].y1=ry1; ORDER(rx1,ry1,rx2,ry2); if( line[c][n].x1 == rx2 && line[c][n].y1 == ry2) { if(line[c][n].sel == SELECTED1) line[c][n].sel = SELECTED2; else if(line[c][n].sel == SELECTED2) line[c][n].sel = SELECTED1; } line[c][n].x1=rx1; line[c][n].y1=ry1; line[c][n].x2=rx2; line[c][n].y2=ry2; drawline(k, ADD, line[c][n].x1, line[c][n].y1, line[c][n].x2, line[c][n].y2); break; case POLYGON: /* 20171115 */ if(c!=k) break; { double bx1=0., by1=0., bx2=0., by2=0.; int k; for(k=0; k bx2) bx2 = polygon[c][n].x[k]; if(k==0 || polygon[c][n].y[k] > by2) by2 = polygon[c][n].y[k]; if( polygon[c][n].sel==SELECTED || polygon[c][n].selected_point[k]) { if(rotatelocal) { ROTATION(polygon[c][n].x[0], polygon[c][n].y[0], polygon[c][n].x[k], polygon[c][n].y[k], rx1,ry1); } else { ROTATION(x1, y_1, polygon[c][n].x[k], polygon[c][n].y[k], rx1,ry1); } polygon[c][n].x[k] = rx1+deltax; polygon[c][n].y[k] = ry1+deltay; } } bbox(ADD, bx1, by1, bx2, by2); } /* 20180914 added fill */ drawpolygon(k, NOW, polygon[c][n].x, polygon[c][n].y, polygon[c][n].points, polygon[c][n].fill); break; case ARC: if(c!=k) break; arc_bbox(arc[c][n].x, arc[c][n].y, arc[c][n].r, arc[c][n].a, arc[c][n].b, &tmp.x1, &tmp.y1, &tmp.x2, &tmp.y2); if(debug_var>=1) fprintf(errfp, "move_objects(): arc_bbox: %g %g %g %g\n", tmp.x1, tmp.y1, tmp.x2, tmp.y2); bbox(ADD, tmp.x1, tmp.y1, tmp.x2, tmp.y2); if(rotatelocal) { /* rotate center wrt itself: do nothing */ rx1 = arc[c][n].x; ry1 = arc[c][n].y; } else { ROTATION(x1, y_1, arc[c][n].x, arc[c][n].y, rx1,ry1); } angle = arc[c][n].a; if(flip) { angle = 270.*rot+180.-arc[c][n].b-arc[c][n].a; } else { angle = arc[c][n].a+rot*270.; } angle = fmod(angle, 360.); if(angle<0.) angle+=360.; if(arc[c][n].sel == SELECTED) { arc[c][n].x = rx1+deltax; arc[c][n].y = ry1+deltay; arc[c][n].a = angle; } else if(arc[c][n].sel == SELECTED1) { arc[c][n].x = rx1; arc[c][n].y = ry1; if(arc[c][n].r+deltax) arc[c][n].r = fabs(arc[c][n].r+deltax); arc[c][n].a = angle; } else if(arc[c][n].sel == SELECTED2) { angle = ROUND(fmod(atan2(-deltay, deltax)*180./XSCH_PI+angle, 360.)); if(angle<0.) angle +=360.; arc[c][n].x = rx1; arc[c][n].y = ry1; arc[c][n].a = angle; } else if(arc[c][n].sel==SELECTED3) { angle = ROUND(fmod(atan2(-deltay, deltax)*180./XSCH_PI+arc[c][n].b, 360.)); if(angle<0.) angle +=360.; if(angle==0) angle=360.; arc[c][n].x = rx1; arc[c][n].y = ry1; arc[c][n].b = angle; } drawarc(k, ADD, arc[c][n].x, arc[c][n].y, arc[c][n].r, arc[c][n].a, arc[c][n].b); break; case RECT: if(c!=k) break; bbox(ADD, rect[c][n].x1, rect[c][n].y1, rect[c][n].x2, rect[c][n].y2); if(rotatelocal) { ROTATION(rect[c][n].x1, rect[c][n].y1, rect[c][n].x1, rect[c][n].y1, rx1,ry1); ROTATION(rect[c][n].x1, rect[c][n].y1, rect[c][n].x2, rect[c][n].y2, rx2,ry2); } else { ROTATION(x1, y_1, rect[c][n].x1, rect[c][n].y1, rx1,ry1); ROTATION(x1, y_1, rect[c][n].x2, rect[c][n].y2, rx2,ry2); } if( rect[c][n].sel == SELECTED) { rx1+=deltax; ry1+=deltay; rx2+=deltax; ry2+=deltay; } else if( rect[c][n].sel == SELECTED1) { /* 20070302 stretching on rectangles */ rx1+=deltax; ry1+=deltay; } else if( rect[c][n].sel == SELECTED2) { rx2+=deltax; ry1+=deltay; } else if( rect[c][n].sel == SELECTED3) { rx1+=deltax; ry2+=deltay; } else if( rect[c][n].sel == SELECTED4) { rx2+=deltax; ry2+=deltay; } else if(rect[c][n].sel==(SELECTED1|SELECTED2)) { ry1+=deltay; } else if(rect[c][n].sel==(SELECTED3|SELECTED4)) { ry2+=deltay; } else if(rect[c][n].sel==(SELECTED1|SELECTED3)) { rx1+=deltax; } else if(rect[c][n].sel==(SELECTED2|SELECTED4)) { rx2+=deltax; } tx1 = rx1; ty1 = ry1; RECTORDER(rx1,ry1,rx2,ry2); if( rx2 == tx1) { /*20070302 */ if(rect[c][n].sel==SELECTED1) rect[c][n].sel = SELECTED2; else if(rect[c][n].sel==SELECTED2) rect[c][n].sel = SELECTED1; else if(rect[c][n].sel==SELECTED3) rect[c][n].sel = SELECTED4; else if(rect[c][n].sel==SELECTED4) rect[c][n].sel = SELECTED3; } if( ry2 == ty1) { if(rect[c][n].sel==SELECTED1) rect[c][n].sel = SELECTED3; else if(rect[c][n].sel==SELECTED3) rect[c][n].sel = SELECTED1; else if(rect[c][n].sel==SELECTED2) rect[c][n].sel = SELECTED4; else if(rect[c][n].sel==SELECTED4) rect[c][n].sel = SELECTED2; } rect[c][n].x1 = rx1; rect[c][n].y1 = ry1; rect[c][n].x2 = rx2; rect[c][n].y2 = ry2; drawrect(k, ADD, rect[c][n].x1, rect[c][n].y1, rect[c][n].x2, rect[c][n].y2); filledrect(c, ADD, rect[c][n].x1, rect[c][n].y1, rect[c][n].x2, rect[c][n].y2); break; case TEXT: if(k!=TEXTLAYER) break; #ifdef HAS_CAIRO customfont = set_text_custom_font(&textelement[n]); #endif text_bbox(textelement[n].txt_ptr, textelement[n].xscale, textelement[n].yscale, textelement[n].rot,textelement[n].flip, textelement[n].x0, textelement[n].y0, &rx1,&ry1, &rx2,&ry2); #ifdef HAS_CAIRO if(customfont) cairo_restore(ctx); #endif bbox(ADD, rx1, ry1, rx2, ry2 ); if(rotatelocal) { ROTATION(textelement[n].x0, textelement[n].y0, textelement[n].x0, textelement[n].y0, rx1,ry1); } else { ROTATION(x1, y_1, textelement[n].x0, textelement[n].y0, rx1,ry1); } textelement[n].x0=rx1+deltax; textelement[n].y0=ry1+deltay; textelement[n].rot=(textelement[n].rot + ( (flip && (textelement[n].rot & 1) ) ? rot+2 : rot) ) & 0x3; textelement[n].flip=flip^textelement[n].flip; /* 20171112 */ textlayer = TEXTLAYER; #ifdef HAS_CAIRO textlayer = textelement[n].layer; /* 20171206 */ if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER; textfont = textelement[n].font; /* 20171206 */ if(textfont && textfont[0]) { cairo_save(ctx); cairo_save(save_ctx); cairo_select_font_face (ctx, textfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_select_font_face (save_ctx, textfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); } #endif draw_string(textlayer, ADD, textelement[n].txt_ptr, /* draw moved txt */ textelement[n].rot, textelement[n].flip, textelement[n].x0, textelement[n].y0, textelement[n].xscale, textelement[n].yscale); #ifdef HAS_CAIRO if(textfont && textfont[0]) { /*cairo_select_font_face (ctx, cairo_font_name, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); */ /*cairo_select_font_face (save_ctx, cairo_font_name, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); */ cairo_restore(ctx); cairo_restore(save_ctx); } #endif break; case ELEMENT: if(k==0) { symbol_bbox(n, &inst_ptr[n].x1, &inst_ptr[n].y1, &inst_ptr[n].x2, &inst_ptr[n].y2 ); /* 20171201 */ bbox(ADD, inst_ptr[n].x1, inst_ptr[n].y1, inst_ptr[n].x2, inst_ptr[n].y2 ); if(rotatelocal) { ROTATION(inst_ptr[n].x0, inst_ptr[n].y0, inst_ptr[n].x0, inst_ptr[n].y0, rx1,ry1); } else { ROTATION(x1, y_1, inst_ptr[n].x0, inst_ptr[n].y0, rx1,ry1); } inst_ptr[n].x0 = rx1+deltax; inst_ptr[n].y0 = ry1+deltay; inst_ptr[n].rot = (inst_ptr[n].rot + ( (flip && (inst_ptr[n].rot & 1) ) ? rot+2 : rot) ) & 0x3; inst_ptr[n].flip = flip ^ inst_ptr[n].flip; symbol_bbox(n, &inst_ptr[n].x1, &inst_ptr[n].y1, &inst_ptr[n].x2, &inst_ptr[n].y2); } draw_symbol_outline(ADD,k, n,k, 0, 0, 0.0, 0.0); break; } } filledrect(k, END, 0.0, 0.0, 0.0, 0.0); drawarc(k, END, 0.0, 0.0, 0.0, 0.0, 0.0); drawrect(k, END, 0.0, 0.0, 0.0, 0.0); drawline(k, END, 0.0, 0.0, 0.0, 0.0); } /*end for(k ... */ check_collapsing_objects(); update_conn_cues(1, 1); ui_state &= ~STARTMOVE; ui_state &= ~STARTMERGE; x1=y_1=x2=y_2=rot=flip=deltax=deltay=0; bbox(SET , 0.0 , 0.0 , 0.0 , 0.0); if(debug_var>=1) fprintf(errfp, "move_objects(): bbox= %d %d %d %d\n", areax1, areay1, areaw, areah); draw(); bbox(END , 0.0 , 0.0 , 0.0 , 0.0); rotatelocal=0; draw_window =save_draw; } draw_selection(gc[SELLAYER], 0); } xschem-2.8.1/src/Makefile.in0000644000175100017510000000414513371733150014054 0ustar svnsvn# list all .c files that need to be compiled into object and linked in xschem put /local/src { icon.c callback.c actions.c move.c check.c clip.c draw.c globals.c main.c netlist.c hash_iterator.c findnet.c scheduler.c store.c xinit.c select.c font.c editprop.c save.c paste.c token.c psprint.c node_hash.c hilight.c options.c vhdl_netlist.c svgdraw.c spice_netlist.c tedax_netlist.c verilog_netlist.c parselabel.c expandlabel.c in_memory_undo.c } # list all files that need to be installed in $(XSHAREDIR) put /local/install_shares { keys.help xschem.help xschem.tcl break.awk convert_to_verilog2001.awk flatten.awk make_sym.awk order_labels.awk sort_labels.awk spice.awk tedax.awk verilog.awk vhdl.awk xschemrc } # generate a list of objects from the list of source files put /local/obj [@@/local/src@ @] gsub /local/obj {\n} { } gsub /local/obj {[.]c } {.o } print [@ ############################################################### # Generated by scconfig - DO NOT EDIT - will be overwritten # # Source: Makefile.in; to regenerate run ./configure # ############################################################### OBJ = @/local/obj@ all: xschem include ../Makefile.conf xschem: $(OBJ) $(CC) -o xschem $(OBJ) $(LDFLAGS) parselabel.c: parselabel.l expandlabel.h flex -l -oparselabel.c parselabel.l expandlabel.c expandlabel.h: expandlabel.y bison -d -o expandlabel.c expandlabel.y parselabel.o: expandlabel.h $(OBJ): xschem.h ../config.h Makefile clean: FORCE rm -rf xschem *.o expandlabel.[ch] parselabel.c netlist netlist.spice netlist.vhdl netlist.v *.da gmon.out # Explicit rule for each object: @] foreach /local/n in /local/src put /local/o /local/n sub /local/o {.c$} {.o} print [@ @/local/o@: @/local/n@ $(CC) -c $(CFLAGS) -o @/local/o@ @/local/n@ @] end print [@ install: xschem FORCE mkdir -p $(BINDIR) mkdir -p $(XSHAREDIR) cp xschem $(BINDIR)/xschem cp -r systemlib $(XSHAREDIR)@] foreach /local/n in /local/install_shares print [@ cp @/local/n@ $(XSHAREDIR)@] end print [@ distclean: clean uninstall: FORCE rm $(BINDIR)/xschem rm -rf $(XSHAREDIR) rm -rf $(XDOCDIR) FORCE: @] xschem-2.8.1/src/order_labels.awk0000755000175100017510000000556613223526356015167 0ustar svnsvn#!/usr/bin/awk -f #------------------------ BEGIN{ i=0 } NF=2 { i++ pin[i]=$1 # 20111116 dir[$1] = $2 } END{ pin["n"]=i hsort(pin, pin["n"]) compact_pinlist(pin) for(i=1;i<=pin_ret["n"];i++){ a=pin_ret[i] # gsub(/\[/,"<",a) # gsub(/\]/,">",a) printf "%s %s\n", a, dir_ret[i] } } function compact_pinlist(pin ,i,ii,base,curr,curr_n,np) { delete pin_ret delete dir_ret np=pin["n"] if(np) { ii=1 for(i=1;i<=np;i++) { base =lab_name( pin[i] ) if(i==1) {curr=base; curr_n=i} else { if(base != curr) { pin_ret[ii] = compact_label(pin,curr_n,i-1) dir_ret[ii] = dir[pin[i-1]] # 20111116 ii++ curr=base;curr_n=i } } } pin_ret[ii] = compact_label(pin,curr_n,np) dir_ret[ii] = dir[pin[np]] # 20111116 pin_ret["n"] = ii } } # 1 2 3 4 5 6 7 8 9 10 11 12 # PP A[3] A[2] A[1] B C K[10] K[9] K[5] K[4] K[3] K[1] function compact_label(ar,a,b, ret,start,i) { ret="" for(i=a;i<=b;i++) { if(i==a) {start=a} else { if(ar[i-1] !~ /\[/) { if(ar[i-1] != ar[i]) { if(start < i-1) { ret = ret (i-start) "*" ar[i-1] ","; start=i } else {ret = ret ar[i-1] ","; start=i } } } else if(lab_name(ar[i])!=lab_name(ar[i-1]) || ( lab_index(ar[i]) != lab_index(ar[i-1])-1 && lab_index(ar[i]) != lab_index(ar[i-1])+1) ) { if(start1) { rarray=array[--l] } else { rarray=array[ir] array[ir]=array[1] if(--ir==1) { array[1]=rarray return } } i=l j=l*2 while(j<=ir) { if(j lab_index(b) else return lab_name(a) > lab_name(b) } xschem-2.8.1/src/draw.c0000644000175100017510000013477713400741444013125 0ustar svnsvn/* File: draw.c * * This file is part of XSCHEM, * a schematic capture and Spice/Vhdl/Verilog netlisting tool for circuit * simulation. * Copyright (C) 1998-2018 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 */ #include "xschem.h" static double textx1,textx2,texty1,texty2; int textclip(int x1,int y1,int x2,int y2, double xa,double ya,double xb,double yb) /* check if some of (xa,ya-xb,yb) is inside (x1,y1-x2,y2) */ /* coordinates should be ordered, x1=2) fprintf(errfp, "textclip(): %.16g %.16g %.16g %.16g - %d %d %d %d\n", X_TO_SCREEN(xa),Y_TO_SCREEN(ya), X_TO_SCREEN(xb),Y_TO_SCREEN(yb),x1,y1,x2,y2); /* drawtemprect(gc[WIRELAYER],xa,ya,xb,yb); */ if (X_TO_SCREEN(xa)>x2) return 0; else if (Y_TO_SCREEN(ya)>y2) return 0; else if (X_TO_SCREEN(xb)=1) fprintf(errfp, "print_image(): Window image saved\n"); tcleval( "convert_to_png plot.xpm"); /* 20161121 */ pop_undo(0); /* 20161121 restore state */ modified=modified_save; /* 20161121 */ w=ww;h=hh; xrect[0].x = 0; xrect[0].y = 0; xrect[0].width = w; xrect[0].height = h; areax2 = w+2*lw; areay2 = h+2*lw; areax1 = -2*lw; areay1 = -2*lw; areaw = areax2-areax1; areah = areay2-areay1; XFreePixmap(display,save_pixmap); save_pixmap = XCreatePixmap(display,window,areaw,areah,depth); XSetTile(display,gctiled, save_pixmap); #ifdef HAS_CAIRO cairo_destroy(save_ctx); cairo_surface_destroy(save_sfc); #if HAS_XRENDER==1 #if HAS_XCB==1 save_sfc = cairo_xcb_surface_create_with_xrender_format(xcbconn, screen_xcb, save_pixmap, &format_rgb, w, h); #else save_sfc = cairo_xlib_surface_create_with_xrender_format (display, save_pixmap, DefaultScreenOfDisplay(display), format, w, h); #endif /*HAS_XCB */ #else save_sfc = cairo_xlib_surface_create(display, save_pixmap, visual, w, h); #endif /*HAS_XRENDER */ if(cairo_surface_status(save_sfc)!=CAIRO_STATUS_SUCCESS) { fprintf(errfp, "ERROR: invalid cairo xcb surface\n"); exit(-1); } save_ctx = cairo_create(save_sfc); cairo_set_line_width(save_ctx, 1); cairo_set_line_join(save_ctx, CAIRO_LINE_JOIN_ROUND); cairo_set_line_cap(save_ctx, CAIRO_LINE_CAP_ROUND); cairo_select_font_face (save_ctx, cairo_font_name, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_set_font_size (save_ctx, 20); #endif /*HAS_CAIRO */ for(tmp=0;tmpfont; if(textfont && textfont[0]) { cairo_save(ctx); cairo_select_font_face (ctx, textfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); return 1; } return 0; } #else int set_text_custom_font(Text *txt) { return 0; } #endif #ifdef HAS_CAIRO void cairo_draw_string_line(cairo_t *ctx, char *s, double x, double y, double size, int rot, int flip, int lineno, double fontheight, double fontascent, double fontdescent, int llength) { double ix, iy; int rot1; cairo_text_extents_t ext; int line_delta; int line_offset; double xadvance; double lines; double vc; /* 20171121 vert correct */ /*int rx1, ry1, rx2, ry2, save_rot, save_flip; */ /* GC gcclear; */ if(s==NULL) return; if(llength==0) return; cairo_text_extents(ctx, s, &ext); xadvance = ext.x_advance; line_delta = lineno*fontheight*cairo_font_line_spacing; lines = (cairo_lines-1)*fontheight*cairo_font_line_spacing; line_offset=cairo_longest_line-xadvance; /* 20171215 NO! will skip drawing of long strings */ /* if(xadvance>14000) return; */ /* too big: close to short overflow */ ix=X_TO_SCREEN(x); iy=Y_TO_SCREEN(y); if(rot&1) { rot1=3; } else rot1=0; vc = cairo_vert_correct*mooz; /* converted to device (pixel) space */ if( rot==0 && flip==0) {iy+=line_delta+fontascent-vc;} else if(rot==1 && flip==0) {iy+=xadvance+line_offset;ix=ix-fontheight+fontascent+vc-lines+line_delta;} else if(rot==2 && flip==0) {iy=iy-fontheight-lines+line_delta+fontascent+vc; ix=ix-xadvance-line_offset;} else if(rot==3 && flip==0) {ix+=line_delta+fontascent-vc;} else if(rot==0 && flip==1) {ix=ix-xadvance-line_offset;iy+=line_delta+fontascent-vc;} else if(rot==1 && flip==1) {ix=ix-fontheight+line_delta-lines+fontascent+vc;} else if(rot==2 && flip==1) {iy=iy-fontheight-lines+line_delta+fontascent+vc;} else if(rot==3 && flip==1) {iy=iy+xadvance+line_offset;ix+=line_delta+fontascent-vc;} /* clear area before drawing antialiased text. */ /* save_rot=rot; save_flip=flip; rot=rot1; flip=0; if(rot==0 || rot==2) { ROTATION(ix, iy-ext.height, ix+ext.width, iy, rx2, ry2); rx1 = ix; ry1 = iy-ext.height; } else { ROTATION(ix, iy, ix+ext.width, iy+ext.height, rx2, ry2); rx1 = ix-ext.height; rx2 = rx2-ext.height; ry1 = iy; } RECTORDER(rx1,ry1,rx2,ry2); if(hilight_nets) gcclear=gc[BACKLAYER]; else gcclear=gctiled; if(ctx == save_ctx) { XFillRectangle(display, save_pixmap, gcclear, (int)rx1, (int)ry1, (unsigned int)rx2 - (unsigned int)rx1, (unsigned int)ry2 - (unsigned int)ry1); } else { XFillRectangle(display, window, gcclear, (int)rx1, (int)ry1, (unsigned int)rx2 - (unsigned int )rx1, (unsigned int)ry2 - (unsigned int)ry1); } rot=save_rot; flip=save_flip; */ cairo_save(ctx); cairo_translate(ctx, ix, iy); cairo_rotate(ctx, XSCH_PI/2*rot1); /* fprintf(errfp, "string_line: |%s|, y_bearing: %f descent: %f ascent: %f height: %f\n", */ /* s, ext.y_bearing, fontdescent, fontascent, fontheight); */ cairo_move_to(ctx, 0,0); cairo_show_text(ctx, s); cairo_restore(ctx); } /* CAIRO version */ void draw_string(int layer, int what, char *s, int rot, int flip, double x, double y, double xscale, double yscale) { char *tt, *ss; char c; int lineno=0; double size; cairo_font_extents_t fext; int llength=0; (void)what; /* UNUSED in cairo version, avoid compiler warning */ if(s==NULL || !has_x ) return; size = (xscale+yscale)*26.*cairo_font_scale; /*fprintf(errfp, "size=%.16g\n", size*mooz); */ if(size*mooz<3.0) return; /* too small */ if(size*mooz>800) return; /* too big */ text_bbox(s, xscale, yscale, rot, flip, x,y, &textx1,&texty1,&textx2,&texty2); if(!textclip(areax1,areay1,areax2,areay2,textx1,texty1,textx2,texty2)) { return; } cairo_set_source_rgb(ctx, (double)xcolor_array[layer].red/65535.0, (double)xcolor_array[layer].green/65535.0, (double)xcolor_array[layer].blue/65535.0); cairo_set_source_rgb(save_ctx, (double)xcolor_array[layer].red/65535.0, (double)xcolor_array[layer].green/65535.0, (double)xcolor_array[layer].blue/65535.0); cairo_set_font_size (ctx, size*mooz); cairo_set_font_size (save_ctx, size*mooz); cairo_font_extents(ctx, &fext); /*fprintf(errfp, "cairo_draw_string(): s=%s lines=%d\n", s, cairo_lines); */ llength=0; tt=ss=s; for(;;) { c=*ss; if(c=='\n' || c==0) { *ss='\0'; /*fprintf(errfp, "cairo_draw_string(): tt=%s, longest line: %d\n", tt, cairo_longest_line); */ if(draw_window) cairo_draw_string_line(ctx, tt, x, y, size, rot, flip, lineno, fext.height, fext.ascent, fext.descent, llength); if(draw_pixmap) cairo_draw_string_line(save_ctx, tt, x, y, size, rot, flip, lineno, fext.height, fext.ascent, fext.descent, llength); lineno++; if(c==0) break; *ss='\n'; tt=ss+1; llength=0; } else { llength++; } ss++; } } #else /* !HAS_CAIRO */ /* no CAIRO version */ void draw_string(int layer, int what, char *str, int rot, int flip, double x1,double y1, double xscale, double yscale) { double a=0.0,yy; register double rx1=0,rx2=0,ry1=0,ry2=0; double curr_x1,curr_y1,curr_x2,curr_y2; register double zx1, invxscale; register int pos=0,pos2=0; register unsigned int cc; register double *char_ptr_x1,*char_ptr_y1,*char_ptr_x2,*char_ptr_y2; register int i,lines; if(str==NULL || !has_x ) return; if(debug_var>=2) fprintf(errfp, "draw_string(): string=%s\n",str); if(xscale*FONTWIDTH*mooz<1) { if(debug_var>=1) fprintf(errfp, "draw_string(): xscale=%.16g zoom=%.16g \n",xscale,zoom); return; } else { text_bbox(str, xscale, yscale, rot, flip, x1,y1, &textx1,&texty1,&textx2,&texty2); if(!textclip(areax1,areay1,areax2,areay2,textx1,texty1,textx2,texty2)) return; x1=textx1;y1=texty1; if(rot&1) {y1=texty2;rot=3;} else rot=0; flip = 0; yy=y1; invxscale=1/xscale; while(str[pos2]) { cc = (unsigned int)str[pos2++]; if(cc>127) cc= '?'; if(cc=='\n') { yy+=(FONTHEIGHT+FONTDESCENT+FONTWHITESPACE)* yscale; pos=0; a=0.0; continue; } lines=character[cc][0]*4; char_ptr_x1=character[cc]+1; char_ptr_y1=character[cc]+2; char_ptr_x2=character[cc]+3; char_ptr_y2=character[cc]+4; zx1=a+x1*invxscale; for(i=0;i=2) fprintf(errfp, "draw_string(): string=%s\n",str); if(!text_bbox(str, xscale, yscale, rot, flip, x1,y1, &textx1,&texty1,&textx2,&texty2)) return; drawtemprect(gctext,what, textx1,texty1,textx2,texty2); } void draw_symbol_outline(int what,int c, int n,int layer,int tmp_flip, int rot, double xoffset, double yoffset) /* draws current layer only, should be called within */ { /* a "for(i=0;i=2) fprintf(errfp, "draw_symbol_outline(): skippinginst %d\n", n); return; } flip = inst_ptr[n].flip; if(tmp_flip) flip = !flip; rot = (inst_ptr[n].rot + rot ) & 0x3; x0=inst_ptr[n].x0 + xoffset; y0=inst_ptr[n].y0 + yoffset; symptr = (inst_ptr[n].ptr+instdef); for(j=0;j< symptr->lines[layer];j++) { line = (symptr->lineptr[layer])[j]; ROTATION(0.0,0.0,line.x1,line.y1,x1,y1); ROTATION(0.0,0.0,line.x2,line.y2,x2,y2); ORDER(x1,y1,x2,y2); drawline(c,what, x0+x1, y0+y1, x0+x2, y0+y2); } for(j=0;j< symptr->polygons[layer];j++) /* 20171115 */ { polygon = (symptr->polygonptr[layer])[j]; { /* scope block so we declare some auxiliary arrays for coord transforms. 20171115 */ int k; double *x = my_malloc(34, sizeof(double) * polygon.points); double *y = my_malloc(35, sizeof(double) * polygon.points); for(k=0;karcs[layer];j++) { arc = (symptr->arcptr[layer])[j]; if(flip) { angle = 270.*rot+180.-arc.b-arc.a; } else { angle = arc.a+rot*270.; } angle = fmod(angle, 360.); if(angle<0.) angle+=360.; ROTATION(0.0,0.0,arc.x,arc.y,x1,y1); drawarc(c,what, x0+x1, y0+y1, arc.r, angle, arc.b); } for(j=0;j< symptr->rects[layer];j++) { box = (symptr->boxptr[layer])[j]; ROTATION(0.0,0.0,box.x1,box.y1,x1,y1); ROTATION(0.0,0.0,box.x2,box.y2,x2,y2); RECTORDER(x1,y1,x2,y2); drawrect(c,what, x0+x1, y0+y1, x0+x2, y0+y2); filledrect(c,what, x0+x1, y0+y1, x0+x2, y0+y2); } if( (layer==TEXTWIRELAYER && !(inst_ptr[n].flags&2) ) || (sym_txt && (layer==TEXTLAYER) && (inst_ptr[n].flags&2) ) ) { for(j=0;j< symptr->texts;j++) { text = symptr->txtptr[j]; if(text.xscale*FONTWIDTH*mooz<1) continue; text.txt_ptr= translate(n, text.txt_ptr); ROTATION(0.0,0.0,text.x0,text.y0,x1,y1); textlayer = c; #ifdef HAS_CAIRO textlayer = symptr->txtptr[j].layer; if(textlayer < 0 || textlayer >= cadlayers) textlayer = c; textfont = symptr->txtptr[j].font; if(textfont && textfont[0]) { cairo_save(ctx); cairo_save(save_ctx); cairo_select_font_face (ctx, textfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_select_font_face (save_ctx, textfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); } #endif draw_string(textlayer, what, text.txt_ptr, (text.rot + ( (flip && (text.rot & 1) ) ? rot+2 : rot) ) & 0x3, flip^text.flip, x0+x1, y0+y1, text.xscale, text.yscale); #ifdef HAS_CAIRO if(textfont && textfont[0]) { cairo_restore(ctx); cairo_restore(save_ctx); } #endif } } } void draw_temp_symbol_outline(int what, GC gc, int n,int layer,int tmp_flip, int rot, double xoffset, double yoffset) /* draws current layer only, should be called within */ { /* a "for(i=0;i=2) fprintf(errfp, "draw_symbol_outline(): skippinginst %d\n", n); return; } /* /20150424 */ flip = inst_ptr[n].flip; if(tmp_flip) flip = !flip; rot = (inst_ptr[n].rot + rot ) & 0x3; x0=inst_ptr[n].x0 + xoffset; y0=inst_ptr[n].y0 + yoffset; symptr = (inst_ptr[n].ptr+instdef); for(j=0;j< symptr->lines[layer];j++) { line = (symptr->lineptr[layer])[j]; ROTATION(0.0,0.0,line.x1,line.y1,x1,y1); ROTATION(0.0,0.0,line.x2,line.y2,x2,y2); ORDER(x1,y1,x2,y2); drawtempline(gc,what, x0+x1, y0+y1, x0+x2, y0+y2); } for(j=0;j< symptr->polygons[layer];j++) /* 20171115 */ { /*fprintf(errfp, "draw_temp_symbol_outline: polygon\n"); */ polygon = (symptr->polygonptr[layer])[j]; { /* scope block so we declare some auxiliary arrays for coord transforms. 20171115 */ int k; double *x = my_malloc(36, sizeof(double) * polygon.points); double *y = my_malloc(37, sizeof(double) * polygon.points); for(k=0;krects[layer];j++) { box = (symptr->boxptr[layer])[j]; ROTATION(0.0,0.0,box.x1,box.y1,x1,y1); ROTATION(0.0,0.0,box.x2,box.y2,x2,y2); RECTORDER(x1,y1,x2,y2); drawtemprect(gc,what, x0+x1, y0+y1, x0+x2, y0+y2); } for(j=0;j< symptr->arcs[layer];j++) { arc = (symptr->arcptr[layer])[j]; if(flip) { angle = 270.*rot+180.-arc.b-arc.a; } else { angle = arc.a+rot*270.; } angle = fmod(angle, 360.); if(angle<0.) angle+=360.; ROTATION(0.0,0.0,arc.x,arc.y,x1,y1); drawtemparc(gc, what, x0+x1, y0+y1, arc.r, angle, arc.b); } if(layer==PROPERTYLAYER && sym_txt) { for(j=0;j< symptr->texts;j++) { text = symptr->txtptr[j]; if(text.xscale*FONTWIDTH*mooz<1) continue; text.txt_ptr= translate(n, text.txt_ptr); ROTATION(0.0,0.0,text.x0,text.y0,x1,y1); #ifdef HAS_CAIRO customfont = set_text_custom_font(&text); #endif if(text.txt_ptr[0]) draw_temp_string(gc, what, text.txt_ptr, (text.rot + ( (flip && (text.rot & 1) ) ? rot+2 : rot) ) & 0x3, flip^text.flip, x0+x1, y0+y1, text.xscale, text.yscale); #ifdef HAS_CAIRO if(customfont) cairo_restore(ctx); #endif } } } void drawgrid() { double x,y; double delta,tmp; int i=0; if( !draw_grid || !has_x) return; delta=cadgrid*mooz; while(deltaareay1 && yareax1 && x=CADMAXGRIDPOINTS) { if(draw_window) XDrawPoints(display,window,gc[GRIDLAYER],gridpoint,i,CoordModeOrigin); if(draw_pixmap) XDrawPoints(display,save_pixmap,gc[GRIDLAYER],gridpoint,i,CoordModeOrigin); i=0; } gridpoint[i].x=(int)(x);gridpoint[i++].y=(int)(y); } } if(draw_window) XDrawPoints(display,window,gc[GRIDLAYER],gridpoint,i,CoordModeOrigin); if(draw_pixmap) XDrawPoints(display,save_pixmap,gc[GRIDLAYER],gridpoint,i,CoordModeOrigin); /* debug ... */ /* XFlush(display); */ } void drawline(int c, int what, double linex1, double liney1, double linex2, double liney2) { static int i=0; static XSegment r[CADDRAWBUFFERSIZE]; double x1,y1,x2,y2; register XSegment *rr; if(!has_x) return; rr=r; if(what==ADD) { if(i>=CADDRAWBUFFERSIZE) { if(draw_window) XDrawSegments(display, window, gc[c], rr,i); if(draw_pixmap) XDrawSegments(display, save_pixmap, gc[c], rr,i); i=0; } x1=X_TO_SCREEN(linex1); y1=Y_TO_SCREEN(liney1); x2=X_TO_SCREEN(linex2); y2=Y_TO_SCREEN(liney2); if(!only_probes && (x2-x1)< 0.3 && fabs(y2-y1) < 0.3) return; /* 20171206 */ if( clip(&x1,&y1,&x2,&y2) ) { rr[i].x1=(short)x1; rr[i].y1=(short)y1; rr[i].x2=(short)x2; rr[i].y2=(short)y2; i++; } } else if(what==NOW) { x1=X_TO_SCREEN(linex1); y1=Y_TO_SCREEN(liney1); x2=X_TO_SCREEN(linex2); y2=Y_TO_SCREEN(liney2); if(!only_probes && (x2-x1)< 0.3 && fabs(y2-y1)< 0.3) return; /* 20171206 */ if( clip(&x1,&y1,&x2,&y2) ) { if(draw_window) XDrawLine(display, window, gc[c], x1, y1, x2, y2); if(draw_pixmap) XDrawLine(display, save_pixmap, gc[c], x1, y1, x2, y2); } } else if(what==THICK) /* 26122004 */ { x1=X_TO_SCREEN(linex1); y1=Y_TO_SCREEN(liney1); x2=X_TO_SCREEN(linex2); y2=Y_TO_SCREEN(liney2); if(!only_probes && (x2-x1)< 0.3 && fabs(y2-y1)< 0.3) return; /* 20171206 */ if( clip(&x1,&y1,&x2,&y2) ) { XSetLineAttributes (display, gc[c], BUS_WIDTH , LineSolid, CapRound , JoinRound); if(draw_window) XDrawLine(display, window, gc[c], x1, y1, x2, y2); if(draw_pixmap) XDrawLine(display, save_pixmap, gc[c], x1, y1, x2, y2); XSetLineAttributes (display, gc[c], lw, LineSolid, CapRound , JoinRound); } } else if(what==BEGIN) i=0; else if(what==END && i) { if(draw_window) XDrawSegments(display, window, gc[c], rr,i); if(draw_pixmap) XDrawSegments(display, save_pixmap, gc[c], rr,i); i=0; } } void drawtempline(GC gc, int what, double linex1,double liney1,double linex2,double liney2) { static int i=0; static XSegment r[CADDRAWBUFFERSIZE]; double x1,y1,x2,y2; if(!has_x) return; if(what==ADD) { if(i>=CADDRAWBUFFERSIZE) { XDrawSegments(display, window, gc, r,i); i=0; } x1=X_TO_SCREEN(linex1); y1=Y_TO_SCREEN(liney1); x2=X_TO_SCREEN(linex2); y2=Y_TO_SCREEN(liney2); if( clip(&x1,&y1,&x2,&y2) ) { r[i].x1=(short)x1; r[i].y1=(short)y1; r[i].x2=(short)x2; r[i].y2=(short)y2; i++; } } else if(what==NOW) { x1=X_TO_SCREEN(linex1); y1=Y_TO_SCREEN(liney1); x2=X_TO_SCREEN(linex2); y2=Y_TO_SCREEN(liney2); if( clip(&x1,&y1,&x2,&y2) ) { XDrawLine(display, window, gc, x1, y1, x2, y2); } } else if(what==THICK) /* 26122004 */ { x1=X_TO_SCREEN(linex1); y1=Y_TO_SCREEN(liney1); x2=X_TO_SCREEN(linex2); y2=Y_TO_SCREEN(liney2); if( clip(&x1,&y1,&x2,&y2) ) { XSetLineAttributes (display, gc, BUS_WIDTH, LineSolid, CapRound , JoinRound); /* 20150410 */ XDrawLine(display, window, gc, x1, y1, x2, y2); if(gc==gctiled) XSetLineAttributes (display, gc, lw, LineSolid, CapRound , JoinRound); else XSetLineAttributes (display, gc, lw, LineSolid, CapRound , JoinRound); } } else if(what==BEGIN) i=0; else if(what==END && i) { XDrawSegments(display, window, gc, r,i); i=0; } } void drawtemparc(GC gc, int what, double x, double y, double r, double a, double b) { static int i=0; static XArc arc[CADDRAWBUFFERSIZE]; double x1, y1, x2, y2; /* arc bbox */ double xx1, yy1, xx2, yy2; /* complete circle bbox in screen coords */ if(!has_x) return; if(what==ADD) { if(i>=CADDRAWBUFFERSIZE) { XDrawArcs(display, window, gc, arc,i); i=0; } xx1=X_TO_SCREEN(x-r); yy1=Y_TO_SCREEN(y-r); xx2=X_TO_SCREEN(x+r); yy2=Y_TO_SCREEN(y+r); arc_bbox(x, y, r, a, b, &x1,&y1,&x2,&y2); x1=X_TO_SCREEN(x1); y1=Y_TO_SCREEN(y1); x2=X_TO_SCREEN(x2); y2=Y_TO_SCREEN(y2); if( rectclip(areax1,areay1,areax2,areay2,&x1,&y1,&x2,&y2) ) { arc[i].x=(short)xx1; arc[i].y=(short)yy1; arc[i].width= (unsigned short)(xx2 - xx1); arc[i].height=(unsigned short)(yy2 - yy1); arc[i].angle1 = a*64; arc[i].angle2 = b*64; i++; } } else if(what==NOW) { xx1=X_TO_SCREEN(x-r); yy1=Y_TO_SCREEN(y-r); xx2=X_TO_SCREEN(x+r); yy2=Y_TO_SCREEN(y+r); arc_bbox(x, y, r, a, b, &x1,&y1,&x2,&y2); x1=X_TO_SCREEN(x1); y1=Y_TO_SCREEN(y1); x2=X_TO_SCREEN(x2); y2=Y_TO_SCREEN(y2); if( rectclip(areax1,areay1,areax2,areay2,&x1,&y1,&x2,&y2) ) { XDrawArc(display, window, gc, xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64); } } else if(what==BEGIN) i=0; else if(what==END && i) { XDrawArcs(display, window, gc, arc,i); i=0; } } /* x1,y1: start; x2,y2: end; x3,y3: way point */ void arc_3_points(double x1, double y1, double x2, double y2, double x3, double y3, double *x, double *y, double *r, double *a, double *b) { double A, B, C; double c, s; /* s = signed_area, if > 0 : clockwise in xorg coordinate space */ s = x3*y2-x2*y3 + x2*y1 -x1*y2 + x1*y3-x3*y1; A = x1*(y2-y3) - y1*(x2-x3) + x2*y3 - x3*y2; B = (x1*x1+y1*y1)*(y3-y2)+(x2*x2+y2*y2)*(y1-y3) + (x3*x3+y3*y3)*(y2-y1); C = (x1*x1+y1*y1)*(x2-x3)+(x2*x2+y2*y2)*(x3-x1) + (x3*x3+y3*y3)*(x1-x2); /* printf("s=%g\n", s); */ *x = -B/2./A; *y = -C/2./A; *r = sqrt( (*x-x1)*(*x-x1) + (*y-y1)*(*y-y1) ); *a = fmod(atan2(*y-y1 ,x1-*x )*180./XSCH_PI, 360.); if(*a<0.) *a+=360.; *b = fmod(atan2(*y-y2 ,x2-*x )*180./XSCH_PI, 360.); if(*b<0.) *b+=360.; if(s<0.) { /* counter clockwise, P1, P3, P2 */ *b = fmod(*b-*a, 360.); if(*b<0) *b+=360.; if(*b==0) *b=360.; } else if(s>0.) { /* clockwise, P2, P3, P1 */ c = fmod(*a-*b, 360.); if(c<0) c+=360.; if(*b==0) *b=360.; *a = *b; *b = c; } else { *r = -1.0; /* no circle thru aligned points */ } } void filledarc(int c, int what, double x, double y, double r, double a, double b) { static int i=0; static XArc arc[CADDRAWBUFFERSIZE]; double x1, y1, x2, y2; /* arc bbox */ double xx1, yy1, xx2, yy2; /* complete circle bbox in screen coords */ if(!has_x) return; if(what==ADD) { if(i>=CADDRAWBUFFERSIZE) { if(draw_window) XFillArcs(display, window, gc[c], arc,i); if(draw_pixmap) XFillArcs(display, save_pixmap, gc[c], arc,i); i=0; } xx1=X_TO_SCREEN(x-r); yy1=Y_TO_SCREEN(y-r); xx2=X_TO_SCREEN(x+r); yy2=Y_TO_SCREEN(y+r); arc_bbox(x, y, r, a, b, &x1,&y1,&x2,&y2); x1=X_TO_SCREEN(x1); y1=Y_TO_SCREEN(y1); x2=X_TO_SCREEN(x2); y2=Y_TO_SCREEN(y2); if( rectclip(areax1,areay1,areax2,areay2,&x1,&y1,&x2,&y2) ) { arc[i].x=(short)xx1; arc[i].y=(short)yy1; arc[i].width =(unsigned short)(xx2 - xx1); arc[i].height=(unsigned short)(yy2 - yy1); arc[i].angle1 = a*64; arc[i].angle2 = b*64; i++; } } else if(what==NOW) { xx1=X_TO_SCREEN(x-r); yy1=Y_TO_SCREEN(y-r); xx2=X_TO_SCREEN(x+r); yy2=Y_TO_SCREEN(y+r); arc_bbox(x, y, r, a, b, &x1,&y1,&x2,&y2); x1=X_TO_SCREEN(x1); y1=Y_TO_SCREEN(y1); x2=X_TO_SCREEN(x2); y2=Y_TO_SCREEN(y2); if( rectclip(areax1,areay1,areax2,areay2,&x1,&y1,&x2,&y2) ) { if(draw_window) XFillArc(display, window, gc[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64); if(draw_pixmap) XFillArc(display, save_pixmap, gc[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64); } } else if(what==BEGIN) i=0; else if(what==END && i) { if(draw_window) XFillArcs(display, window, gc[c], arc,i); if(draw_pixmap) XFillArcs(display, save_pixmap, gc[c], arc,i); i=0; } } void drawarc(int c, int what, double x, double y, double r, double a, double b) { static int i=0; static XArc arc[CADDRAWBUFFERSIZE]; double x1, y1, x2, y2; /* arc bbox */ double xx1, yy1, xx2, yy2; /* complete circle bbox in screen coords */ if(!has_x) return; if(what==ADD) { if(i>=CADDRAWBUFFERSIZE) { if(draw_window) XDrawArcs(display, window, gc[c], arc,i); if(draw_pixmap) XDrawArcs(display, save_pixmap, gc[c], arc,i); i=0; } xx1=X_TO_SCREEN(x-r); yy1=Y_TO_SCREEN(y-r); xx2=X_TO_SCREEN(x+r); yy2=Y_TO_SCREEN(y+r); arc_bbox(x, y, r, a, b, &x1,&y1,&x2,&y2); x1=X_TO_SCREEN(x1); y1=Y_TO_SCREEN(y1); x2=X_TO_SCREEN(x2); y2=Y_TO_SCREEN(y2); if( rectclip(areax1,areay1,areax2,areay2,&x1,&y1,&x2,&y2) ) { arc[i].x=(short)xx1; arc[i].y=(short)yy1; arc[i].width =(unsigned short)(xx2 - xx1); arc[i].height=(unsigned short)(yy2 - yy1); arc[i].angle1 = a*64; arc[i].angle2 = b*64; i++; } } else if(what==NOW) { xx1=X_TO_SCREEN(x-r); yy1=Y_TO_SCREEN(y-r); xx2=X_TO_SCREEN(x+r); yy2=Y_TO_SCREEN(y+r); arc_bbox(x, y, r, a, b, &x1,&y1,&x2,&y2); x1=X_TO_SCREEN(x1); y1=Y_TO_SCREEN(y1); x2=X_TO_SCREEN(x2); y2=Y_TO_SCREEN(y2); if( rectclip(areax1,areay1,areax2,areay2,&x1,&y1,&x2,&y2) ) { if(draw_window) XDrawArc(display, window, gc[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64); if(draw_pixmap) XDrawArc(display, save_pixmap, gc[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64); } } else if(what==BEGIN) i=0; else if(what==END && i) { if(draw_window) XDrawArcs(display, window, gc[c], arc,i); if(draw_pixmap) XDrawArcs(display, save_pixmap, gc[c], arc,i); i=0; } } void filledrect(int c, int what, double rectx1,double recty1,double rectx2,double recty2) { static int i=0; static XRectangle r[CADDRAWBUFFERSIZE]; double x1,y1,x2,y2; if(!has_x) return; if(!fill || !fill_type[c]) return; if(what==NOW) { x1=X_TO_SCREEN(rectx1); y1=Y_TO_SCREEN(recty1); x2=X_TO_SCREEN(rectx2); y2=Y_TO_SCREEN(recty2); if(!only_probes && (x2-x1)< 2 && (y2-y1)< 2) return; /* 20171206 */ if( rectclip(areax1,areay1,areax2,areay2,&x1,&y1,&x2,&y2) ) { if(draw_window) XFillRectangle(display, window, gcstipple[c], (int)x1, (int)y1, (unsigned int)x2 - (unsigned int)x1, (unsigned int)y2 - (unsigned int)y1); if(draw_pixmap) XFillRectangle(display, save_pixmap,gcstipple[c], (int)x1, (int)y1, (unsigned int)x2 - (unsigned int)x1, (unsigned int)y2 - (unsigned int)y1); } } else if(what==BEGIN) i=0; else if(what==ADD) { if(i>=CADDRAWBUFFERSIZE) { if(draw_window) XFillRectangles(display, window, gcstipple[c], r,i); if(draw_pixmap) XFillRectangles(display, save_pixmap, gcstipple[c], r,i); i=0; } x1=X_TO_SCREEN(rectx1); y1=Y_TO_SCREEN(recty1); x2=X_TO_SCREEN(rectx2); y2=Y_TO_SCREEN(recty2); if(!only_probes && (x2-x1)< 2 && (y2-y1)< 2) return; /* 20171206 */ if( rectclip(areax1,areay1,areax2,areay2,&x1,&y1,&x2,&y2) ) { r[i].x=(short)x1; r[i].y=(short)y1; r[i].width=(unsigned short)x2-r[i].x; r[i].height=(unsigned short)y2-r[i].y; i++; } } else if(what==END && i) { if(draw_window) XFillRectangles(display, window, gcstipple[c], r,i); if(draw_pixmap) XFillRectangles(display, save_pixmap, gcstipple[c], r,i); i=0; } } void polygon_bbox(double *x, double *y, int points, double *bx1, double *by1, double *bx2, double *by2) { int j; for(j=0; j *bx2) *bx2 = x[j]; if(j==0 || y[j] > *by2) *by2 = y[j]; } } void arc_bbox(double x, double y, double r, double a, double b, double *bx1, double *by1, double *bx2, double *by2) { double x2, y2, x3, y3; int aa, bb, i; if(b==360.) { *bx1 = x-r; *by1 = y-r; *bx2 = x+r; *by2 = y+r; return; } a = fmod(a, 360.); if(a<0) a+=360.; aa = (int)(ceil(a/90.))*90; bb = (int)(floor((a+b)/90.))*90; /* printf("arc_bbox(): aa=%d bb=%d\n", aa, bb); */ x2 = x + r * cos(a * XSCH_PI/180.); y2 = y - r * sin(a * XSCH_PI/180.); x3 = x + r * cos((a+b) * XSCH_PI/180.); y3 = y - r * sin((a+b) * XSCH_PI/180.); /* *bx1 = (x2 < x ) ? x2 : x; */ *bx1 = x2; if(x3 < *bx1) *bx1 = x3; /* *bx2 = (x2 > x ) ? x2 : x; */ *bx2 = x2; if(x3 > *bx2) *bx2 = x3; /* *by1 = (y2 < y ) ? y2 : y; */ *by1 = y2; if(y3 < *by1) *by1 = y3; /* *by2 = (y2 > y ) ? y2 : y; */ *by2 = y2; if(y3 > *by2) *by2 = y3; for(i=aa; i<=bb; i++) { if(i%360==0) { *bx2 = x + r; } if(i%360==90) { *by1 = y - r; } if(i%360==180) { *bx1 = x - r; } if(i%360==270) { *by2 = y + r; } } /* printf("arc_bbox(): bx1=%g by1=%g bx2=%g by2=%g\n", *bx1, *by1, *bx2, *by2); */ } /* Convex Nonconvex Complex */ #define Polygontype Nonconvex /* 20180914 added fill param */ void drawpolygon(int c, int what, double *x, double *y, int points, int poly_fill) { double x1,y1,x2,y2; XPoint *p; int i; if(!has_x) return; polygon_bbox(x, y, points, &x1,&y1,&x2,&y2); x1=X_TO_SCREEN(x1); y1=Y_TO_SCREEN(y1); x2=X_TO_SCREEN(x2); y2=Y_TO_SCREEN(y2); if( !rectclip(areax1,areay1,areax2,areay2,&x1,&y1,&x2,&y2) ) { return; } if( !only_probes && (x2-x1)<0.3 && (y2-y1)<0.3) return; /* 20171206 */ p = my_malloc(38, sizeof(XPoint) * points); for(i=0;i=CADDRAWBUFFERSIZE) { if(draw_window) XDrawRectangles(display, window, gc[c], r,i); if(draw_pixmap) XDrawRectangles(display, save_pixmap, gc[c], r,i); i=0; } x1=X_TO_SCREEN(rectx1); y1=Y_TO_SCREEN(recty1); x2=X_TO_SCREEN(rectx2); y2=Y_TO_SCREEN(recty2); if(!only_probes && (x2-x1)< 0.3 && (y2-y1)< 0.3) return; /* 20171206 */ if( rectclip(areax1,areay1,areax2,areay2,&x1,&y1,&x2,&y2) ) { r[i].x=(short)x1; r[i].y=(short)y1; r[i].width=(unsigned short)x2-r[i].x; r[i].height=(unsigned short)y2-r[i].y; i++; } } else if(what==END && i) { if(draw_window) XDrawRectangles(display, window, gc[c], r,i); if(draw_pixmap) XDrawRectangles(display, save_pixmap, gc[c], r,i); i=0; } } void drawtemprect(GC gc, int what, double rectx1,double recty1,double rectx2,double recty2) { static int i=0; static XRectangle r[CADDRAWBUFFERSIZE]; double x1,y1,x2,y2; if(!has_x) return; if(what==NOW) { x1=X_TO_SCREEN(rectx1); y1=Y_TO_SCREEN(recty1); x2=X_TO_SCREEN(rectx2); y2=Y_TO_SCREEN(recty2); if( (x2-x1)< 0.3 && (y2-y1)< 0.3) return; /* 20171206 */ if( rectclip(areax1,areay1,areax2,areay2,&x1,&y1,&x2,&y2) ) { XDrawRectangle(display, window, gc, (int)x1, (int)y1, (unsigned int)x2 - (unsigned int)x1, (unsigned int)y2 - (unsigned int)y1); } } else if(what==BEGIN) i=0; else if(what==ADD) { if(i>=CADDRAWBUFFERSIZE) { XDrawRectangles(display, window, gc, r,i); i=0; } x1=X_TO_SCREEN(rectx1); y1=Y_TO_SCREEN(recty1); x2=X_TO_SCREEN(rectx2); y2=Y_TO_SCREEN(recty2); if( (x2-x1)< 0.3 && (y2-y1)< 0.3) return; /* 20171206 */ if( rectclip(areax1,areay1,areax2,areay2,&x1,&y1,&x2,&y2) ) { r[i].x=(short)x1; r[i].y=(short)y1; r[i].width=(unsigned short)x2-r[i].x; r[i].height=(unsigned short)y2-r[i].y; i++; } } else if(what==END && i) { XDrawRectangles(display, window, gc, r,i); i=0; } } void draw(void) { /* inst_ptr and wire hash iterator 20171224 */ double x1, y1, x2, y2; struct instentry *instanceptr; struct wireentry *wireptr; int ii; char *type=NULL; /* 20180109 */ int use_hash; register int c,i; register Instdef *symptr; /* 20150408 */ int textlayer; /* 20171112 */ #ifdef HAS_CAIRO char *textfont; #endif if(no_draw) return; rebuild_selected_array(); if(has_x) { if(draw_pixmap) XFillRectangle(display, save_pixmap, gc[BACKLAYER], areax1, areay1, areaw, areah); if(draw_window) XFillRectangle(display, window, gc[BACKLAYER], areax1, areay1, areaw, areah); if(debug_var>=2) fprintf(errfp, "draw(): window: %d %d %d %d\n",areax1, areay1, areax2, areay2); drawgrid(); x1 = X_TO_XSCHEM(areax1); y1 = Y_TO_XSCHEM(areay1); x2 = X_TO_XSCHEM(areax2); y2 = Y_TO_XSCHEM(areay2); use_hash = (lastwire> 2000 || lastinst > 2000 ) && (x2 - x1 < ITERATOR_THRESHOLD); if(use_hash) { hash_instances(); hash_wires(); } if(!only_probes) { /* 20110112 */ if(debug_var>=3) fprintf(errfp, "draw(): check4\n"); for(c=0;cn].ptr; if( ptr !=-1) { /* 20180921 */ symptr = ptr+instdef; if( c==0 || /*20150408 draw_symbol_outline call is needed on layer 0 to avoid redundant work (outside check) */ symptr->lines[c] || /* 20150408 */ symptr->arcs[c] || symptr->rects[c] || /* 20150408 */ symptr->polygons[c] || /* 20150408 */ ((c==TEXTWIRELAYER || c==TEXTLAYER) && symptr->texts)) { /* 20150408 */ type = symptr->type; if( (!hilight_nets || !type || (strcmp(type,"label") && strcmp(type,"ipin") && strcmp(type,"iopin") && strcmp(type,"opin")) || !bus_hilight_lookup( get_tok_value(inst_ptr[instanceptr->n].prop_ptr,"lab",0) , 0, 2 ) ) ) { draw_symbol_outline(ADD, c, instanceptr->n,c,0,0,0.0,0.0); } } /* 20150408 */ } /*if( ptr !=-1) */ } /* --------------------------------- /20171224 */ } else { for(i=0;ilines[c] || /* 20150408 */ symptr->arcs[c] || symptr->rects[c] || /* 20150408 */ symptr->polygons[c] || /* 20150408 */ ((c==TEXTWIRELAYER || c==TEXTLAYER) && symptr->texts)) { /* 20150408 */ type = (inst_ptr[i].ptr+instdef)->type; if( (!hilight_nets || !type || (strcmp(type,"label") && strcmp(type,"ipin") && strcmp(type,"iopin") && strcmp(type,"opin")) || !bus_hilight_lookup( get_tok_value(inst_ptr[i].prop_ptr,"lab",0) , 0, 2 ) ) ) { draw_symbol_outline(ADD, c, i,c,0,0,0.0,0.0); } } /* 20150408 */ } } filledrect(c, END, 0.0, 0.0, 0.0, 0.0); drawarc(c, END, 0.0, 0.0, 0.0, 0.0, 0.0); drawrect(c, END, 0.0, 0.0, 0.0, 0.0); drawline(c, END, 0.0, 0.0, 0.0, 0.0); } if(draw_single_layer==-1 || draw_single_layer==WIRELAYER){ /* 20151117 */ drawline(WIRELAYER,BEGIN, 0.0, 0.0, 0.0, 0.0); filledrect(WIRELAYER, BEGIN, 0.0, 0.0, 0.0, 0.0); if(use_hash) { if(debug_var>2) fprintf(errfp, "using spatial hash table iterator\n"); /*loop thru all squares that intersect drawing area */ for(init_wire_iterator(x1, y1, x2, y2); ( wireptr = wire_iterator_next() ) ;) { ii=wireptr->n; if(wire[ii].bus) { drawline(WIRELAYER, THICK, wire[ii].x1,wire[ii].y1,wire[ii].x2,wire[ii].y2); } else drawline(WIRELAYER, ADD, wire[ii].x1,wire[ii].y1,wire[ii].x2,wire[ii].y2); } } else { for(i=0;i=1) fprintf(errfp, "draw(): drawing string %d = %s\n",i, textelement[i].txt_ptr); #ifdef HAS_CAIRO textlayer = textelement[i].layer; /*20171206 */ if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER; textfont = textelement[i].font; /* 20171206 */ if(textfont && textfont[0]) { cairo_save(ctx); cairo_save(save_ctx); cairo_select_font_face (ctx, textfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_select_font_face (save_ctx, textfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); } #endif draw_string(textlayer, ADD, textelement[i].txt_ptr, textelement[i].rot, textelement[i].flip, textelement[i].x0,textelement[i].y0, textelement[i].xscale, textelement[i].yscale); #ifdef HAS_CAIRO if(textfont && textfont[0]) { cairo_restore(ctx); cairo_restore(save_ctx); } #endif } #ifndef HAS_CAIRO drawrect(TEXTLAYER, END, 0.0, 0.0, 0.0, 0.0); drawline(TEXTLAYER, END, 0.0, 0.0, 0.0, 0.0); #endif } } /* !only_probes, 20110112 */ draw_hilight_net(draw_window); if(!draw_window) { XCopyArea(display, save_pixmap, window, gctiled, xrect[0].x, xrect[0].y, xrect[0].width, xrect[0].height, xrect[0].x, xrect[0].y); /* 20181009 */ } draw_selection(gc[SELLAYER], 0); /* 20181009 moved outside of cadlayers loop */ if(debug_var>=1) fprintf(errfp, "draw(): lw=%d\n",lw); } /* if(has_x) */ } xschem-2.8.1/src/xinit.c0000644000175100017510000011577013400741444013313 0ustar svnsvn/* File: xinit.c * * This file is part of XSCHEM, * a schematic capture and Spice/Vhdl/Verilog netlisting tool for circuit * simulation. * Copyright (C) 1998-2018 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 */ #include "xschem.h" #include /* getpwuid */ static int init_done=0; /* 20150409 to avoid double call by Xwindows close and TclExitHandler */ static XSetWindowAttributes winattr; static int screen_number; static Tk_Window tkwindow, mainwindow; static XWMHints *hints_ptr; static Window topwindow; static XColor xcolor_exact,xcolor; typedef int myproc( ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[]); /* ----------------------------------------------------------------------- */ /* EWMH message handling routines 20071027... borrowed from wmctrl code */ /* ----------------------------------------------------------------------- */ #define _NET_WM_STATE_REMOVE 0 /* remove/unset property */ #define _NET_WM_STATE_ADD 1 /* add/set property */ #define _NET_WM_STATE_TOGGLE 2 /* toggle property */ static int client_msg(Display *disp, Window win, char *msg, /* {{{ */ unsigned long data0, unsigned long data1, unsigned long data2, unsigned long data3, unsigned long data4) { XEvent event; long mask = SubstructureRedirectMask | SubstructureNotifyMask; event.xclient.type = ClientMessage; event.xclient.serial = 0; event.xclient.send_event = True; event.xclient.message_type = XInternAtom(disp, msg, False); event.xclient.window = win; event.xclient.format = 32; event.xclient.data.l[0] = data0; event.xclient.data.l[1] = data1; event.xclient.data.l[2] = data2; event.xclient.data.l[3] = data3; event.xclient.data.l[4] = data4; if (XSendEvent(disp, DefaultRootWindow(disp), False, mask, &event)) { return EXIT_SUCCESS; } else { fprintf(errfp, "Cannot send %s event.\n", msg); return EXIT_FAILURE; } }/*}}}*/ int window_state (Display *disp, Window win, char *arg) {/*{{{*/ static char *arg_copy=NULL; unsigned long action; int i; Atom prop1 = 0; Atom prop2 = 0; char *p1, *p2; const char *argerr = "expects a list of comma separated parameters: \"(remove|add|toggle),[,]\"\n"; my_strdup(604, &arg_copy, arg); if(debug_var>=1) fprintf(errfp,"window_state() , win=0x%x arg_copy=%s\n", (int)win,arg_copy); if (!arg_copy || strlen(arg_copy) == 0) { fputs(argerr, errfp); return EXIT_FAILURE; } if ((p1 = strchr(arg_copy, ','))) { static char tmp_prop1[1024], tmp1[1024]; /* overflow safe 20161122 */ *p1 = '\0'; /* action */ if (strcmp(arg_copy, "remove") == 0) { action = _NET_WM_STATE_REMOVE; } else if (strcmp(arg_copy, "add") == 0) { action = _NET_WM_STATE_ADD; } else if (strcmp(arg_copy, "toggle") == 0) { action = _NET_WM_STATE_TOGGLE; } else { fputs("Invalid action. Use either remove, add or toggle.\n", errfp); return EXIT_FAILURE; } p1++; /* the second property */ if ((p2 = strchr(p1, ','))) { static char tmp_prop2[1024], tmp2[1024]; /* overflow safe */ *p2 = '\0'; p2++; if (strlen(p2) == 0) { fputs("Invalid zero length property.\n", errfp); return EXIT_FAILURE; } for( i = 0; p2[i]; i++) tmp2[i] = toupper( p2[i] ); my_snprintf(tmp_prop2, S(tmp_prop2), "_NET_WM_STATE_%s", tmp2); prop2 = XInternAtom(disp, tmp_prop2, False); } /* the first property */ if (strlen(p1) == 0) { fputs("Invalid zero length property.\n", errfp); return EXIT_FAILURE; } for( i = 0; p1[i]; i++) tmp1[i] = toupper( p1[i] ); my_snprintf(tmp_prop1, S(tmp_prop1), "_NET_WM_STATE_%s", tmp1); prop1 = XInternAtom(disp, tmp_prop1, False); return client_msg(disp, win, "_NET_WM_STATE", action, (unsigned long)prop1, (unsigned long)prop2, 0, 0); } else { fputs(argerr, errfp); return EXIT_FAILURE; } }/*}}}*/ /* ----------------------------------------------------------------------- */ void windowid() { int i; Display *display; Tk_Window mainwindow; unsigned int ww; Window framewin, rootwindow; Window *framewin_child_ptr; unsigned int framweindow_nchildren; mainwindow=Tk_MainWindow(interp); display = Tk_Display(mainwindow); tcleval( "winfo id ."); sscanf(Tcl_GetStringResult(interp), "0x%x", (unsigned int *) &ww); framewin = ww; XQueryTree(display, framewin, &rootwindow, &parent_of_topwindow, &framewin_child_ptr, &framweindow_nchildren); if(debug_var>=1) fprintf(errfp,"framewinID=%x\n", (unsigned int) framewin); if(debug_var>=1) fprintf(errfp,"framewin nchilds=%d\n", (unsigned int) framweindow_nchildren); if(debug_var>=1) fprintf(errfp,"framewin parentID=%x\n", (unsigned int) parent_of_topwindow); if(debug_var>=1) fprintf(errfp,"framewin child 0=%x\n", (unsigned int) framewin_child_ptr[0]); /* here I create the icon pixmap,to be used when iconified, */ /* I will use it when I know how to use it as icon :-( */ /* removed icon, ts created by tcl 31102004 */ if(!cad_icon_pixmap) { i=XpmCreatePixmapFromData(display,framewin, cad_icon,&cad_icon_pixmap, NULL, NULL); if(debug_var>=1) fprintf(errfp, "Tcl_AppInit(): creating icon pixmap returned: %d\n",i); /*this does not work (sending icon pixmap hint) */ hints_ptr = XAllocWMHints(); hints_ptr->icon_pixmap = cad_icon_pixmap ; hints_ptr->flags = IconPixmapHint ; XSetWMHints(display, parent_of_topwindow, hints_ptr); XFree(hints_ptr); } Tcl_SetResult(interp,"",TCL_STATIC); } void xwin_exit(void) { int i; if(!init_done) { if(debug_var>=1) fprintf(errfp, "xwin_exit() double call, doing nothing...\n"); return; /* 20150409 */ } delete_netlist_structs(); delete_hilight_net(); get_unnamed_node(0, 0, 0); if(has_x) { #ifdef HAS_CAIRO /* 20171105 */ cairo_destroy(ctx); cairo_destroy(save_ctx); cairo_surface_destroy(sfc); cairo_surface_destroy(save_sfc); #endif XFreePixmap(display,save_pixmap); for(i=0;i=1) fprintf(errfp, "xwin_exit(): Releasing pixmaps\n"); for(i=0;i=1) fprintf(errfp, "xwin_exit(): destroying tk windows and releasing X11 stuff\n"); Tk_DestroyWindow(mainwindow); if(cad_icon_pixmap) XFreePixmap(display, cad_icon_pixmap); } if(debug_var>=1) fprintf(errfp, "xwin_exit(): clearing drawing data structures\n"); clear_drawing(); if(debug_var>=1) fprintf(errfp, "xwin_exit(): freeing graphic primitive arrays\n"); my_free(&wire); if(debug_var>=1) fprintf(errfp, "xwin_exit(): wire\n"); my_free(&gridpoint); if(debug_var>=1) fprintf(errfp, "xwin_exit(): gridpoint\n"); my_free(&textelement); if(debug_var>=1) fprintf(errfp, "xwin_exit(): textelement\n"); for(i=0;i=1) fprintf(errfp, "xwin_exit(): freeing instances\n"); my_free(&inst_ptr); if(debug_var>=1) fprintf(errfp, "xwin_exit(): freeing selected group array\n"); my_free(&selectedgroup); if(debug_var>=1) fprintf(errfp, "xwin_exit(): removing symbols\n"); remove_symbols(); for(i=0;i=1) fprintf(errfp, "xwin_exit(): removing font\n"); for(i=0;i<127;i++) my_free(&character[i]); if(debug_var>=1) fprintf(errfp, "xwin_exit(): closed display\n"); my_free(&filename); delete_undo(); /* 20150327 */ my_free(&netlist_dir); record_global_node(2, NULL, NULL); /* delete global node array */ if(debug_var>=1) fprintf(errfp, "xwin_exit(): deleted undo buffer\n"); if(errfp!=stderr) fclose(errfp); errfp=stderr; printf("\n"); init_done=0; /* 20150409 to avoid multiple calls */ } int err(Display *display, XErrorEvent *xev) { char s[1024]; /* overflow safe 20161122 */ int l=250; XGetErrorText(display, xev->error_code, s,l); if(debug_var>=1) fprintf(errfp, "err(): Err %d :%s maj=%d min=%d\n", xev->error_code, s, xev->request_code, xev->minor_code); return 0; } unsigned int find_best_color(char colorname[]) { int i; double distance=10000000000.0, dist, r, g, b, red, green, blue; double deltar,deltag,deltab; unsigned int index; if( XAllocNamedColor(display, colormap, colorname, &xcolor_exact, &xcolor) ==0 ) { for(i=0;i<=255;i++) { xcolor_array[i].pixel=i; XQueryColor(display, colormap, xcolor_array+i); } /* debug ... */ if(debug_var>=2) fprintf(errfp, "find_best_color(): Server failed to allocate requested color, finding substitute\n"); XLookupColor(display, colormap, colorname, &xcolor_exact, &xcolor); red = xcolor.red; green = xcolor.green; blue = xcolor.blue; index=0; for(i = 0;i<=255; i++) { r = xcolor_array[i].red ; g = xcolor_array[i].green ; b = xcolor_array[i].blue; deltar = (r - red);deltag = (g - green);deltab = (b - blue); dist = deltar*deltar + deltag*deltag + deltab*deltab; if( dist <= distance ) { index = i; distance = dist; } } } else { /*XLookupColor(display, colormap, colorname, &xcolor_exact, &xcolor); */ index = xcolor.pixel; } return index; } void init_color_array(double dim) { char s[256]; /* overflow safe 20161122 */ int i; unsigned int r, g, b; /* 20171123 */ double rr, gg, bb; /* 20171123 */ for(i=0;i=2) fprintf(errfp, "init_color_array(): color:%s\n",Tcl_GetStringResult(interp)); sscanf(Tcl_GetStringResult(interp), "#%02x%02x%02x", &r, &g, &b);/* 20171123 */ rr=r; gg=g; bb=b; if( (i!=BACKLAYER) ) { if(dim>=0.) { rr +=(51.-rr/5.)*dim; gg +=(51.-gg/5.)*dim; bb +=(51.-bb/5.)*dim; } else { rr +=(rr/5.)*dim; gg +=(gg/5.)*dim; bb +=(bb/5.)*dim; } /* fprintf(errfp, "init_color_array: colors: %.16g %.16g %.16g dim=%.16g c=%d\n", rr, gg, bb, dim, i); */ r=rr;g=gg;b=bb; if(r>0xff) r=0xff; if(g>0xff) g=0xff; if(b>0xff) b=0xff; } my_snprintf(s, S(s), "#%02x%02x%02x", r, g, b); my_strdup(605, &color_array[i], s); } } void set_fill(int n) { XFreePixmap(display,pixmap[rectcolor]); pixmap[rectcolor] = XCreateBitmapFromData(display, window, (char*)(pixdata[n]),16,16); XSetStipple(display,gcstipple[rectcolor],pixmap[rectcolor]); } void init_pixdata() { int i,j, full, empty; for(i=0;i5) fill_type[i]=1; /* 20171212 solid fill style */ /*fprintf(errfp, "fill_type[%d]= %d\n", i, fill_type[i]); */ } } void alloc_data() { int i; max_texts=CADMAXTEXT; max_wires=CADMAXWIRES; max_instances=ELEMINST; max_symbols=ELEMDEF; max_selected=MAXGROUP; textelement=my_calloc(606, max_texts,sizeof(Text)); if(textelement==NULL){ fprintf(errfp, "Tcl_AppInit(): calloc error\n");tcleval( "exit"); } wire=my_calloc(607, max_wires,sizeof(Wire)); if(wire==NULL){ fprintf(errfp, "Tcl_AppInit(): calloc error\n");tcleval( "exit"); } gridpoint=(XPoint*)my_calloc(608, CADMAXGRIDPOINTS,sizeof(XPoint)); if(gridpoint==NULL){ fprintf(errfp, "Tcl_AppInit(): calloc error\n");tcleval( "exit"); } inst_ptr=my_calloc(609, max_instances , sizeof(Instance) ); if(inst_ptr==NULL){ fprintf(errfp, "Tcl_AppInit(): calloc error\n");tcleval( "exit"); } instdef=my_calloc(610, max_symbols , sizeof(Instdef) ); if(instdef==NULL){ fprintf(errfp, "Tcl_AppInit(): calloc error\n");tcleval( "exit"); } for(i=0;i=cadlayers){ tcleval("set colors $dark_colors"); } } else { tcleval("llength $light_colors"); if(atoi(Tcl_GetStringResult(interp)) >=cadlayers){ tcleval("set colors $light_colors"); } } tcleval("llength $colors"); if(atoi(Tcl_GetStringResult(interp))=1) fprintf(errfp, "tclexit() INVOKED\n"); if(init_done) xwin_exit(); } #if HAS_XCB==1 /* from xcb.freedesktop.org -- don't ask me what it does... 20171125 */ static xcb_visualtype_t *find_visual(xcb_connection_t *xcbconn, xcb_visualid_t visual) { xcb_screen_iterator_t screen_iter = xcb_setup_roots_iterator(xcb_get_setup(xcbconn)); for (; screen_iter.rem; xcb_screen_next(&screen_iter)) { xcb_depth_iterator_t depth_iter = xcb_screen_allowed_depths_iterator(screen_iter.data); for (; depth_iter.rem; xcb_depth_next(&depth_iter)) { xcb_visualtype_iterator_t visual_iter = xcb_depth_visuals_iterator(depth_iter.data); for (; visual_iter.rem; xcb_visualtype_next(&visual_iter)) { if (visual == visual_iter.data->visual_id) { return visual_iter.data; } } } } return NULL; } #endif /*HAS_XCB */ int source_tcl_file(char *s) { char tmp[1024]; if(Tcl_EvalFile(interp, s)==TCL_ERROR) { fprintf(errfp, "Tcl_AppInit() error: can not execute %s, please fix:\n", s); fprintf(errfp, Tcl_GetStringResult(interp)); fprintf(errfp, "\n"); my_snprintf(tmp, S(tmp), "tk_messageBox -icon error -type ok -message \ {Tcl_AppInit() err 1: can not execute %s, please fix:\n %s}", s, Tcl_GetStringResult(interp)); if(has_x) { tcleval( "wm withdraw ."); /* 20161217 */ tcleval( tmp); /* 20161217 */ Tcl_Exit(EXIT_FAILURE); } return TCL_ERROR; } return TCL_OK; } int Tcl_AppInit(Tcl_Interp *inter) { char name[PATH_MAX]; /* overflow safe 20161122 */ char tmp[2*PATH_MAX+100]; /* 20161122 overflow safe */ int i; struct stat buf; const char *home_buff; /* XVisualInfo vinfo; */ #if HAS_XCB==1 xcb_render_query_pict_formats_reply_t *formats_reply; xcb_render_pictforminfo_t *formats; xcb_render_query_pict_formats_cookie_t formats_cookie; #endif /* get PWD and HOME */ getcwd(pwd_dir, PATH_MAX); if ((home_buff = getenv("HOME")) == NULL) { home_buff = getpwuid(getuid())->pw_dir; } my_strncpy(home_dir, home_buff, S(home_dir)); for(i=0;i=1) fprintf(errfp, "Tcl_AppInit(): sourcing %s\n", name); source_tcl_file(name); } else { my_snprintf(tmp, S(tmp),"regsub {^~} {%s} {%s}", USER_CONF_DIR, home_dir); tcleval(tmp); my_snprintf(name, S(name), "%s/xschemrc",Tcl_GetStringResult(interp)); if(!stat(name, &buf)) { if(debug_var>=1) fprintf(errfp, "Tcl_AppInit(): sourcing %s\n", name); source_tcl_file(name); } else if(tclgetvar("XSCHEM_SHAREDIR")) { my_snprintf(name, S(name), "%s/xschemrc",tclgetvar("XSCHEM_SHAREDIR")); if(!stat(name, &buf)) { if(debug_var>=1) fprintf(errfp, "Tcl_AppInit(): sourcing %s\n", name); source_tcl_file(name); } } } } /* create USER_CONF_DIR if it was not installed */ my_snprintf(tmp, S(tmp),"regsub {^~} {%s} {%s}", USER_CONF_DIR, home_dir); tcleval(tmp); if(stat(Tcl_GetStringResult(interp), &buf)) { if(!mkdir(Tcl_GetStringResult(interp), 0700)) { if(debug_var>=1) fprintf(errfp, "Tcl_AppInit(): created %s dir\n", USER_CONF_DIR); } else { fprintf(errfp, "Tcl_AppInit(): failure creating %s\n", USER_CONF_DIR); Tcl_Exit(EXIT_FAILURE); } } /* */ /* END LOOKING FOR .xschem */ /* */ if(rainbow_colors) tclsetvar("rainbow_colors","1"); /* 20171013 */ /* */ /* START LOOKING FOR xschem.tcl */ /* */ if(!tclgetvar("XSCHEM_SHAREDIR")) { fprintf(errfp, "Tcl_AppInit() err 3: cannot find xschem.tcl\n"); if(has_x) { tcleval( "wm withdraw ."); /* 20161217 */ tcleval( "tk_messageBox -icon error -type ok -message \"Tcl_AppInit() err 3: xschem.tcl not found, " "you are probably missing XSCHEM_SHAREDIR\""); } Tcl_ResetResult(interp); Tcl_AppendResult(interp, "Tcl_AppInit() err 3: xschem.tcl not found, " "you are probably missing XSCHEM_SHAREDIR",NULL); Tcl_Exit(EXIT_FAILURE); return TCL_ERROR; /* 20121110 */ } /* */ /* END LOOKING FOR xschem.tcl */ /* */ if( !tclgetvar("XSCHEM_LIBRARY_PATH") || !tclgetvar("XSCHEM_LIBRARY_PATH")[0]) { my_snprintf(tmp, S(tmp),"regsub -all {~} {%s} {%s}", XSCHEM_LIBRARY_PATH, home_dir); tcleval(tmp); tclsetvar("XSCHEM_LIBRARY_PATH", Tcl_GetStringResult(interp)); } if(debug_var>=1) fprintf(errfp, "Tcl_AppInit(): XSCHEM_SHAREDIR=%s XSCHEM_LIBRARY_PATH=%s\n", tclgetvar("XSCHEM_SHAREDIR"), tclgetvar("XSCHEM_LIBRARY_PATH") ? tclgetvar("XSCHEM_LIBRARY_PATH") : "NULL" ); if(debug_var>=1) fprintf(errfp, "Tcl_AppInit(): done step a of xinit()\n"); /* */ /* CREATE XSCHEM 'xschem' COMMAND */ /* */ Tcl_CreateCommand(interp, "xschem", (myproc *) xschem, NULL, NULL); if(debug_var>=1) fprintf(errfp, "Tcl_AppInit(): done step a1 of xinit()\n"); /* */ /* EXECUTE xschem.tcl */ /* */ my_snprintf(name, S(name), "%s/%s", tclgetvar("XSCHEM_SHAREDIR"), "xschem.tcl"); if(stat(name, &buf) ) { fprintf(errfp, "Tcl_AppInit() err 4: cannot find %s\n", name); if(has_x) { tcleval( "wm withdraw ."); /* 20161217 */ tcleval( "tk_messageBox -icon error -type ok -message \"Tcl_AppInit() err 4: xschem.tcl not found, " "installation problem or undefined XSCHEM_SHAREDIR\""); } Tcl_ResetResult(interp); Tcl_AppendResult(interp, "Tcl_AppInit() err 4: xschem.tcl not found, " "you are probably missing XSCHEM_SHAREDIR\n",NULL); Tcl_Exit(EXIT_FAILURE); return TCL_ERROR; /* 20121110 */ } if(debug_var>=1) fprintf(errfp, "Tcl_AppInit(): sourcing %s\n", name); source_tcl_file(name); if(debug_var>=1) fprintf(errfp, "Tcl_AppInit(): done executing xschem.tcl\n"); /* */ /* END EXECUTE xschem.tcl */ /* */ /* READ COLORS */ my_snprintf(tmp, S(tmp),"regsub {^~} {%s} {%s}", USER_CONF_DIR, home_dir); tcleval(tmp); my_snprintf(name, S(name), "%s/colors",Tcl_GetStringResult(interp)); if(!stat(name, &buf)) { source_tcl_file(name); } /* set global variables fetching data from tcl code 25122002 */ if(tclgetvar("dark_colorscheme")[0] == '1') dark_colorscheme = 1; else dark_colorscheme = 0; if(netlist_type==-1) { if(!strcmp(tclgetvar("netlist_type"),"vhdl") ) netlist_type=CAD_VHDL_NETLIST; else if(!strcmp(tclgetvar("netlist_type"),"verilog") ) netlist_type=CAD_VERILOG_NETLIST; else if(!strcmp(tclgetvar("netlist_type"),"tedax") ) netlist_type=CAD_TEDAX_NETLIST; else netlist_type=CAD_SPICE_NETLIST; } else { if(netlist_type==CAD_VHDL_NETLIST) tclsetvar("netlist_type","vhdl"); else if(netlist_type==CAD_VERILOG_NETLIST) tclsetvar("netlist_type","verilog"); else if(netlist_type==CAD_TEDAX_NETLIST) tclsetvar("netlist_type","tedax"); else tclsetvar("netlist_type","spice"); } split_files=atoi(tclgetvar("split_files")); hspice_netlist=atoi(tclgetvar("hspice_netlist")); netlist_show=atoi(tclgetvar("netlist_show")); fullscreen=atoi(tclgetvar("fullscreen")); unzoom_nodrift=atoi(tclgetvar("unzoom_nodrift")); if(color_ps==-1) color_ps=atoi(tclgetvar("color_ps")); else { my_snprintf(tmp, S(tmp), "%d",color_ps); tclsetvar("color_ps",tmp); } change_lw=atoi(tclgetvar("change_lw")); draw_window=atoi(tclgetvar("draw_window")); incr_hilight=atoi(tclgetvar("incr_hilight")); if(a3page==-1) a3page=atoi(tclgetvar("a3page")); else { my_snprintf(tmp, S(tmp), "%d",a3page); tclsetvar("a3page",tmp); } enable_stretch=atoi(tclgetvar("enable_stretch")); draw_grid=atoi(tclgetvar("draw_grid")); cadlayers=atoi(tclgetvar("cadlayers")); if(debug_var==-10) debug_var=0; /* */ /* [m]allocate dynamic memory */ /* */ alloc_data(); #ifndef IN_MEMORY_UNDO /* 20150327 create undo directory */ /* 20180923 no more mkdtemp (portability issues) */ if( !my_strdup(644, &undo_dirname, create_tmpdir("xschem_undo_") )) { fprintf(errfp, "xinit(): problems creating tmp undo dir\n"); tcleval( "exit"); } if(debug_var>=1) fprintf(errfp, "undo_dirname=%s\n", undo_dirname); #endif init_pixdata(); init_color_array(0.0); my_snprintf(tmp, S(tmp), "%d",debug_var); tclsetvar("tcl_debug",tmp ); if(flat_netlist) tclsetvar("flat_netlist","1"); lw=1; xschem_w = CADWIDTH; xschem_h = CADHEIGHT; areaw = CADWIDTH+4*lw; /* clip area extends 1 pixel beyond physical window area */ areah = CADHEIGHT+4*lw; /* to avoid drawing clipped rectangle borders at window edges */ areax1 = -2*lw; areay1 = -2*lw; areax2 = areaw-2*lw; areay2 = areah-2*lw; xrect[0].x = 0; xrect[0].y = 0; xrect[0].width = CADWIDTH; xrect[0].height = CADHEIGHT; compile_font(); /* */ /* X INITIALIZATION */ /* */ if( has_x ) { mainwindow=Tk_MainWindow(interp); if(!mainwindow) { fprintf(errfp, "Tcl_AppInit() err 6: Tk_MainWindow returned NULL...\n"); return TCL_ERROR; } display = Tk_Display(mainwindow); tkwindow = Tk_NameToWindow(interp, ".drw", mainwindow); Tk_MakeWindowExist(tkwindow); window = Tk_WindowId(tkwindow); topwindow = Tk_WindowId(mainwindow); if(debug_var>=1) fprintf(errfp, "Tcl_AppInit(): drawing window ID=0x%lx\n",window); if(debug_var>=1) fprintf(errfp, "Tcl_AppInit(): top window ID=0x%lx\n",topwindow); if(debug_var>=1) fprintf(errfp, "Tcl_AppInit(): done tkinit()\n"); #if HAS_XCB==1 /* grab an existing xlib connection 20171125 */ xcbconn = XGetXCBConnection(display); if(xcb_connection_has_error(xcbconn)) { fprintf(errfp, "Could not connect to X11 server"); return 1; } screen_xcb = xcb_setup_roots_iterator(xcb_get_setup(xcbconn)).data; visual_xcb = find_visual(xcbconn, screen_xcb->root_visual); if(!visual_xcb) { fprintf(errfp, "got NULL (xcb_visualtype_t)visual"); return 1; } /*/--------------------------Xrender xcb stuff------- */ formats_cookie = xcb_render_query_pict_formats(xcbconn); formats_reply = xcb_render_query_pict_formats_reply(xcbconn, formats_cookie, 0); formats = xcb_render_query_pict_formats_formats(formats_reply); for (i = 0; i < formats_reply->num_formats; i++) { /* fprintf(errfp, "i=%d depth=%d type=%d red_shift=%d\n", i, formats[i].depth, formats[i].type, formats[i].direct.red_shift); */ if (formats[i].direct.red_mask != 0xff && formats[i].direct.red_shift != 16) continue; if (formats[i].type == XCB_RENDER_PICT_TYPE_DIRECT && formats[i].depth == 24 && formats[i].direct.red_shift == 16) format_rgb = formats[i]; if (formats[i].type == XCB_RENDER_PICT_TYPE_DIRECT && formats[i].depth == 32 && formats[i].direct.alpha_mask == 0xff && formats[i].direct.alpha_shift == 24) format_rgba = formats[i]; } my_free(&formats_reply); /*/---------------------------------------------------- */ /* /20171125 */ #endif /*HAS_XCB */ screen_number = DefaultScreen(display); colormap = DefaultColormap(display, screen_number); depth = DisplayPlanes(display, screen_number); if(debug_var>=1) fprintf(errfp, "Tcl_AppInit(): screen depth: %d\n",depth); visual = DefaultVisual(display, screen_number); /* if (!XMatchVisualInfo( display, XDefaultScreen(display), 24, TrueColor, &vinfo) ) return fprintf(stderr, "no 32 bit visual\n"); visual = vinfo.visual; */ if(debug_var>=1) fprintf(errfp, "Tcl_AppInit(): done step b of xinit()\n"); rectcolor= 4; /* this is the current layer when xschem started. */ for(i=0;i=1) fprintf(errfp, "Tcl_AppInit(): done step c of xinit()\n"); if(build_colors(0.0)) exit(-1); if(debug_var>=1) fprintf(errfp, "Tcl_AppInit(): done step e of xinit()\n"); /* save_pixmap must be created as resetwin() frees it before recreating with new size. */ save_pixmap = XCreatePixmap(display,window,CADWIDTH,CADHEIGHT,depth); XSetTile(display,gctiled,save_pixmap); XSetFillStyle(display,gctiled,FillTiled); #ifdef HAS_CAIRO /* 20171105 */ { XWindowAttributes wattr; XGetWindowAttributes(display, window, &wattr); #if HAS_XRENDER==1 #if HAS_XCB==1 sfc = cairo_xcb_surface_create_with_xrender_format(xcbconn, screen_xcb, window, &format_rgb, 1 , 1); save_sfc = cairo_xcb_surface_create_with_xrender_format(xcbconn, screen_xcb, save_pixmap, &format_rgb, 1 , 1); #else format = XRenderFindStandardFormat(display, PictStandardRGB24); sfc = cairo_xlib_surface_create_with_xrender_format (display, window, DefaultScreenOfDisplay(display), format, 1, 1); save_sfc = cairo_xlib_surface_create_with_xrender_format (display, save_pixmap, DefaultScreenOfDisplay(display), format, 1, 1); #endif #else sfc = cairo_xlib_surface_create(display, window, visual, wattr.width, wattr.height); save_sfc = cairo_xlib_surface_create(display, save_pixmap, visual, wattr.width, wattr.height); #endif if(cairo_surface_status(sfc)!=CAIRO_STATUS_SUCCESS) { fprintf(errfp, "ERROR: invalid cairo surface\n"); return 1; } if(cairo_surface_status(save_sfc)!=CAIRO_STATUS_SUCCESS) { fprintf(errfp, "ERROR: invalid cairo surface\n"); return 1; } ctx = cairo_create(sfc); save_ctx = cairo_create(save_sfc); /* load font from tcl 20171112 */ tcleval("xschem set cairo_font_name $cairo_font_name"); tclsetvar("has_cairo","1"); cairo_select_font_face (ctx, cairo_font_name, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_set_font_size (ctx, 20); cairo_select_font_face (save_ctx, cairo_font_name, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_set_font_size (save_ctx, 20); save_ctx = cairo_create(save_sfc); cairo_set_line_width(ctx, 1); cairo_set_line_width(save_ctx, 1); cairo_set_line_join(ctx, CAIRO_LINE_JOIN_ROUND); cairo_set_line_cap(ctx, CAIRO_LINE_CAP_ROUND); cairo_set_line_join(save_ctx, CAIRO_LINE_JOIN_ROUND); cairo_set_line_cap(save_ctx, CAIRO_LINE_CAP_ROUND); } #endif /* HAS_CAIRO */ change_linewidth(0.); if(debug_var>=1) fprintf(errfp, "Tcl_AppInit(): done xinit()\n"); winattr.backing_store = WhenMapped; /* winattr.backing_store = NotUseful;*/ Tk_ChangeWindowAttributes(tkwindow, CWBackingStore, &winattr); if(debug_var>=1) fprintf(errfp, "Tcl_AppInit(): sizeof Instance=%lu , sizeof Instdef=%lu\n", (unsigned long) sizeof(Instance),(unsigned long) sizeof(Instdef)); /* 20121111 */ tcleval("xschem line_width $line_width"); if(debug_var>=1) fprintf(errfp, "Tcl_AppInit(): xserver max request size: %d\n", (int)XMaxRequestSize(display)); set_snap(0); /* set default value specified in xschemrc as 'snap' else CADSNAP */ set_grid(0); /* set default value specified in xschemrc as 'grid' else CADGRID */ } /* if(has_x) */ if(debug_var>=1) fprintf(errfp, "Tcl_AppInit(): done X init\n"); /* */ /* END X INITIALIZATION */ /* */ init_done=1; /* 20171008 moved before option processing, otherwise xwin_exit will not be invoked */ /* leaving undo buffer and other garbage around. */ /* */ /* START PROCESSING USER OPTIONS */ /* */ if(filename) { if(debug_var>=1) fprintf(errfp, "Tcl_AppInit(): filename %s given, removing symbols\n", filename); remove_symbols(); if(strstr(filename,".sym")) load_symbol( filename); /* 20180925.1 */ else load_schematic(1, filename, 1); /* 20180925.1 */ } else { char * tmp; /* 20121110 */ tmp = (char *) tclgetvar("XSCHEM_START_WINDOW"); /* 20121110 */ if(debug_var>=1) fprintf(errfp, "Tcl_AppInit(): tmp=%s\n", tmp? tmp: "NULL"); load_schematic(1, tmp, 1); } zoom_full(0); /* Necessary to tell xschem the * initial area to display */ pending_fullzoom=1; /* 20121111 */ if(do_netlist) { if(debug_var>=1) { if(flat_netlist) fprintf(errfp, "xschem: flat netlist requested\n"); } if(!filename) { fprintf(errfp, "xschem: cant do a netlist without a filename\n"); tcleval( "exit"); } if(netlist_type == CAD_SPICE_NETLIST) global_spice_netlist(1); /* 1 means global netlist */ else if(netlist_type == CAD_VHDL_NETLIST) global_vhdl_netlist(1); /* 1 means global netlist */ else if(netlist_type == CAD_VERILOG_NETLIST) global_verilog_netlist(1); /* 1 means global netlist */ else if(netlist_type == CAD_TEDAX_NETLIST) global_tedax_netlist(1); /* 1 means global netlist */ } if(do_print) { if(!filename) { fprintf(errfp, "xschem: can't do a print without a filename\n"); tcleval( "exit"); } if(do_print==1) ps_draw(); else if(do_print == 2) print_image(); else svg_draw(); } if(do_simulation) { if(!filename) { fprintf(errfp, "xschem: can't do a simulation without a filename\n"); tcleval( "exit"); } tcleval( "xschem simulate"); } if(do_waves) { if(!filename) { fprintf(errfp, "xschem: can't show simulation waves without a filename\n"); tcleval( "exit"); } tcleval( "waves [file tail [xschem get schname]]"); } if(quit) { tcleval( "exit"); } /* */ /* END PROCESSING USER OPTIONS */ /* */ if(!no_readline) { tcleval( "if {![catch {package require tclreadline}]} { ::tclreadline::Loop }" ) ; } if(debug_var>=1) fprintf(errfp, "Tcl_AppInit(): returning TCL_OK\n"); return TCL_OK; } xschem-2.8.1/src/xschemrc0000644000175100017510000001060613367414403013547 0ustar svnsvn#### #### xschemrc system configuration file #### values may be overridden by user's ~/.xschem/xschemrc configuration file #### or by project-local ./xschemrc #### #### xschem installation directory #### normally there is no reason to set this variable if using standard installation. #### location of files is set at compile time but may be overridden with following line # set XSCHEM_SHAREDIR $env(HOME)/share/xschem #### xschem system-wide design library paths #### if unset xschem starts with the default set compile time, typically: #### XSCHEM_DESIGN_PATH ~/.xschem/xschem_library:${XSCHEM_SHAREDIR}/xschem_library #### you may overide the default system-wide library here and append in user's xschemrc #### (or the porject-local xschemrc) the user's libraries. # set XSCHEM_DESIGN_PATH ${XSCHEM_SHAREDIR}/xschem_library #### directory where simulations, netlist and simulator outputs are placed #### if unset xschem asks user to choose one when doing a netlist # set netlist_dir $env(HOME)/xschem_library/simulations #### Window to open on startup #set XSCHEM_START_WINDOW {mylib/0_top} #### some default behavior set netlist_type spice ;# allowed : spice, verilog, vhdl, tedax set hspice_netlist 1 set verilog_2001 1 # set line_width 2 set change_lw 1 set color_ps 1 set initial_geometry {800x600} #### Custom colors may be defined here # set cadlayers 22 # set light_colors { # "#ffffff" "#0044ee" "#aaaaaa" "#222222" "#229900" # "#bb2200" "#00ccee" "#ff0000" "#888800" "#00aaaa" # "#880088" "#00ff00" "#0000cc" "#666600" "#557755" # "#aa2222" "#7ccc40" "#00ffcc" "#ce0097" "#d2d46b" # "#ef6158" "#fdb200" } # # set dark_colors { # "#000000" "#00ccee" "#3f3f3f" "#cccccc" "#88dd00" # "#bb2200" "#00ccee" "#ff0000" "#ffff00" "#ffffff" # "#ff00ff" "#00ff00" "#0000cc" "#aaaa00" "#aaccaa" # "#ff7777" "#bfff81" "#00ffcc" "#ce0097" "#d2d46b" # "#ef6158" "#fdb200" } #### CAIRO STUFF #### scale all fonts by this number # set cairo_font_scale 1.0 #### scale line spacing by this number # set cairo_font_line_spacing 1.0 #### specify a font set cairo_font_name {Arial} #### lift up text by some zoom-corrected pixels for #### better compatibility wrt no cairo version. #### Useful values in the range [-1, 3] set cairo_vert_correct 1 #### KEYBINDINGS #### general format for specifying a replacement for a keybind #### replace Ctrl-d with Escape (so you wont kill the program) # set replace_key(Control-d) Escape #### swap w and W keybinds; Always specify Shift for capital letters # set replace_key(Shift-W) w # set replace_key(w) Shift-W set terminal {xterm -geometry 100x35 -fn 9x15 -bg black -fg white -cr white -ms white } # set terminal lxterminal # editor must not detach from launching shell (-f mandatory for gvim) set editor {gvim -f -geometry 90x28} #### alternatives: hspice, hspicerf, finesim set spice_simulator hspice set finesim_opts {} #### alternatives: iverilog, modelsim set verilog_simulator iverilog #### alternatives: ghdl, modelsim set vhdl_simulator ghdl #### command to translate xpm to png (assumes command takes source #### and dest file as arguments, example: gm convert plot.xpm plot.png) set to_png {gm convert} #### computer farm redirector #### RTDA NC # set computerfarm {nc run -Il} #### LSF BSUB # set computerfarm {bsub -Is} #### icarus verilog (open source verilog simulator) set iverilog_path $env(HOME)/verilog/bin/iverilog set vvp_path $env(HOME)/verilog/bin/vvp set iverilog_opts {-g2012} #### default analog wiewer (cosmoscope, waveview) set analog_viewer waveview #### waveview # set waveview_path $env(HOME)/waveview/bin/wv set waveview_path $env(HOME)/waveview_2013/bin/wv #### utile (stefan's spice stimuli editor) set utile_gui_path ${XSCHEM_SHAREDIR}/utile/utile3 set utile_cmd_path ${XSCHEM_SHAREDIR}/utile/utile #### gtkwave (open source digital wave viewer) set gtkwave_path $env(HOME)/gtkwave/bin/gtkwave #### modelsim set modelsim_path $env(HOME)/modelsim/modeltech/bin #### ghdl (open source vhdl simulator) set ghdl_path $env(HOME)/ghdl/bin/ghdl set ghdl_elaborate_opts {--ieee=synopsys -fexplicit} set ghdl_run_opts {} #### hspice and modelsim license files (sample syntax) # set env(LM_LICENSE_FILE) $env(HOME)/modelsim/license.dat:$env(HOME)/hspice_2008/license.dat:$env(HOME)/hspice_2013/lic.dat set hspice_path "$env(HOME)/hspice_2013/bin/hspice64 -mt 8" set hspicerf_path $env(HOME)/hspice_2013/bin/hspicerf64 set cscope_path $env(HOME)/cosmoscope/amd64/ai_bin/cscope xschem-2.8.1/src/netlist_compactor.awk0000755000175100017510000001426313227500770016251 0ustar svnsvn#!/usr/bin/awk -f ## ## Does its best to group array of instances in a spice netlist ## XA[2] ... ## XA[1] ... ## XA[0] ... ## --> XA[2:0] ... ## instances that can be grouped must be of subckts with no bussed ports ## run this script before importing a netlist into xschem with make_sch_from_spice.awk ## ## usage: ~/xschem/netlist_compactor.awk netlist > netlist.compact ## ## stefan, 20161226 BEGIN{ #print compact_label("A[3],A[3],A[3],A[4],A[5],A[6],A[6],A[6],A[6],A[8],A[7],A[7],A[9],A[8],A[7],A[11],A[13]") ## 3*A[3],A[4:6],3*A[6],A[8:7],A[7],A[9:7],A[11],A[13] #exit ########################## JOIN ########################## netlist_lines=0 first=1 while(err= (getline l) >0) { gsub(//,"]",l) if(first) { $0=l first=0 } else if(l !~/^\+/) { netlist[netlist_lines++]=$0 $0=l } else $0 = $0 " " substr(l,2) } netlist[netlist_lines++]=$0 ########################## END JOIN ########################## for(i=0;i1) { ## ---------20170308---------- if( (curr_line_arr[1] ~/^X/) && lab_name(curr_line_arr[1]) == lab_name(prev_line_arr[1]) ) { for(j=1;j<=nf;j++) { if( j0 ? a: -a } # 1 2 3 4 5 6 7 8 9 10 11 12 # PP A[3] A[2] A[1] B C K[10] K[9] K[5] K[4] K[3] K[1] function compact_label(str, a, b, ar, ret,start,i) { # print "compact_label_str(): str=" str a=1 b=split(str, ar,",") ret="" for(i=a;i<=b;i++) { if(i==a) {start=a} else { if(ar[i-1] !~ /\[/) { if(ar[i-1] != ar[i]) { if(start < i-1) { ret = ret (i-start) "*" ar[i-1] ","; start=i } else {ret = ret ar[i-1] ","; start=i } } } else if(lab_name(ar[i])!=lab_name(ar[i-1])) { # lab basename changed if(startnext; my_free(&entry->token); my_free(&entry->path); my_free(&entry); entry = tmp; } return NULL; } void free_hilight_hash(void) /* remove the whole hash table */ { int i; if(debug_var>=2) fprintf(errfp, "free_hilight_hash(): removing hash table\n"); for(i=0;i=2) fprintf(errfp, "free_hilight_hash(): : nelements=%d\n", nelements); nelements=0; /* 20161221 */ } struct hilight_hashentry *hilight_lookup(char *token, int value, int remove) /* token remove ... what ... */ /* -------------------------------------------------------------------------- */ /* "whatever" 0 insert in hash table if not in and return NULL */ /* if already present just return entry address */ /* return NULL otherwise */ /* */ /* "whatever" 1 delete entry if found return NULL */ /* "whatever" 2 only look up element, dont insert */ { unsigned int hashcode, index; struct hilight_hashentry *entry, *saveptr, **preventry; char *ptr; int s ; int depth=0; /* 20161221 */ if(token==NULL) return NULL; hashcode=hash(token); index=hashcode % HASHSIZE; entry=table[index]; preventry=&table[index]; depth=0; /* 20161221 */ while(1) { if( !entry ) /* empty slot */ { if( (remove==0) ) /* insert data */ { s=sizeof( struct hilight_hashentry ); ptr= my_malloc(137, s ); entry=(struct hilight_hashentry *)ptr; entry->next = NULL; entry->token = NULL; my_strdup(138, &(entry->token),token); entry->path = NULL; my_strdup(139, &(entry->path),sch_prefix[currentsch]); entry->value=value; entry->hash=hashcode; *preventry=entry; hilight_nets=1; /* some nets should be hilighted .... 07122002 */ nelements++; /* 20161221 */ } return NULL; /* whether inserted or not return NULL since it was not in */ } if( entry -> hash==hashcode && !strcmp(token,entry->token) && !strcmp(sch_prefix[currentsch], entry->path) ) /* found matching tok */ { if(remove==1) /* remove token from the hash table ... */ { saveptr=entry->next; my_free(&entry->token); my_free(&entry->path); my_free(&entry); *preventry=saveptr; return NULL; } else /* found matching entry, return the address */ { return entry; } } preventry=&entry->next; /* descend into the list. */ entry = entry->next; depth++; /* 20161221 */ if(debug_var>=2) if(depth>200) fprintf(errfp, "hilight_lookup(): deep into the list: %d, index=%d, token=%s, hashcode=%d\n", depth, index, token, hashcode); } } /* warning, in case of buses return only pointer to first bus element */ struct hilight_hashentry *bus_hilight_lookup(const char *token, int value, int remove) { char *start, *string_ptr, c; static char *string=NULL; struct hilight_hashentry *ptr1=NULL, *ptr2=NULL; int mult; if(token==NULL) return NULL; if( token[0] == '#') { my_strdup(140, &string, token); } else { my_strdup(141, &string, expandlabel(token,&mult)); } if(string==NULL) return NULL; string_ptr = start = string; while(1) { c=(*string_ptr); if(c==','|| c=='\0') { *string_ptr='\0'; /* set end string at comma position.... */ /* insert one bus element at a time in hash table */ if(debug_var>=2) fprintf(errfp, "bus_hilight_lookup: inserting: %s, value:%d\n", start,value); ptr1=hilight_lookup(start, value, remove); if(ptr1 && !ptr2) { ptr2=ptr1; /*return first non null entry */ if(remove==2) break; /* 20161221 no need to go any further if only looking up element */ } *string_ptr=c; /* ....restore original char */ start=string_ptr+1; } if(c==0) break; string_ptr++; } /* if something found return first pointer */ return ptr2; } void delete_hilight_net(void) { int i; free_hilight_hash(); hilight_nets=0; for(i=0;i=1) fprintf(errfp, "hilight_parent_pins(): previous_instance=%d\n", previous_instance[currentsch]); rects = (inst_ptr[i].ptr+instdef)->rects[PINLAYER]; currentsch=save_currentsch+1; for(j=0;jboxptr[PINLAYER][j].prop_ptr,"name",0); if( (entry = bus_hilight_lookup(pin_node,0,2)) ) { currentsch=save_currentsch; bus_hilight_lookup(inst_ptr[i].node[j], entry->value,0); currentsch=save_currentsch+1; } else { currentsch=save_currentsch; bus_hilight_lookup(inst_ptr[i].node[j], 0,1); currentsch=save_currentsch+1; } } currentsch=save_currentsch; } void hilight_child_pins(int i) { int j,rects; char *pin_node; struct hilight_hashentry *entry; int save_currentsch; if(!hilight_nets) return; save_currentsch=currentsch; prepare_netlist_structs(1); rects = (inst_ptr[i].ptr+instdef)->rects[PINLAYER]; for(j=0;jboxptr[PINLAYER][j].prop_ptr,"name",0); if( (entry = bus_hilight_lookup(inst_ptr[i].node[j], 0,2)) ) { currentsch++; bus_hilight_lookup(pin_node, entry->value,0); } else { currentsch++; bus_hilight_lookup(pin_node, 0,1); } } currentsch=save_currentsch; } int bus_search(const char*s) { int c, bus=0; while( (c=*s++) ) { if(c=='[') bus=1; if( (c==':') || (c==',') ) {bus=0; break;} } return bus; } void search_inst(const char *tok, const char *val, int sub, int sel, int what) { int save_draw; int i,c, col,tmp,bus=0; const char *str; char *type; int has_token; const char empty_string[] = ""; static char *tmpname=NULL; regex_t re; if(!val) { fprintf(errfp, "search_inst(): warning: null val key\n"); return; } save_draw = draw_window; draw_window=1; if(regcomp(&re, val , REG_EXTENDED)) return; if(debug_var>=1) fprintf(errfp, "search_inst():val=%s\n", val); if(sel==1) { drawtempline(gc[SELLAYER], BEGIN, 0.0, 0.0, 0.0, 0.0); drawtemprect(gc[SELLAYER], BEGIN, 0.0, 0.0, 0.0, 0.0); drawtemparc(gc[SELLAYER], BEGIN, 0.0, 0.0, 0.0, 0.0, 0.0); } if(what==ADD || what==NOW) { col=hilight_color; if(incr_hilight) hilight_color++; has_token = 0; prepare_netlist_structs(1); bus=bus_search(val); for(i=0;iprop_ptr && strstr((inst_ptr[i].ptr+instdef)->prop_ptr, tok + 6) != NULL; my_strdup(142, &tmpname,get_tok_value((inst_ptr[i].ptr+instdef)->prop_ptr,tok+6,0)); /* flexible cell__ search 20140408 */ if(tmpname) { str = tmpname; } else { str = empty_string; } } else if(!strcmp(tok,"propstring")) { /* 20170408 */ has_token = (inst_ptr[i].prop_ptr != NULL) && inst_ptr[i].prop_ptr[0]; str = inst_ptr[i].prop_ptr; } else { has_token = inst_ptr[i].prop_ptr && strstr(inst_ptr[i].prop_ptr, tok) != NULL; str = get_tok_value(inst_ptr[i].prop_ptr, tok,0); } if(debug_var>=1) fprintf(errfp, "search_inst(): inst=%d, tok=%s, val=%s \n", i,tok, str); if(bus && sub) { if(debug_var>=1) fprintf(errfp, "search_inst(): doing substr search on bus sig:%s inst=%d tok=%s val=%s\n", str,i,tok,val); str=expandlabel(str,&tmp); } if(str && has_token) { if( (!regexec(&re, str,0 , NULL, 0) && !sub) || /* 20071120 regex instead of strcmp */ (strstr(str,val) && sub) ) { type = (inst_ptr[i].ptr+instdef)->type; if( type && !(strcmp(type,"label") && strcmp(type,"ipin") && strcmp(type,"iopin") && strcmp(type,"opin")) && (str = get_tok_value(inst_ptr[i].prop_ptr, "lab",0))[0] ) { if(!bus_hilight_lookup(str, col,0)) hilight_nets = 1; if(what==NOW) for(c=0;c=1) fprintf(errfp, "search_inst(): setting hilight flag on inst %d\n",i); hilight_nets=1; inst_ptr[i].flags |= 4; if(what==NOW) for(c=0;c=2) fprintf(errfp, "search_inst(): wire=%d, tok=%s, val=%s \n", i,tok, str); if(str && str[0]) { bus_hilight_lookup(str, col,0); if(what==NOW) { drawline(col%(cadlayers-7)+7, NOW, wire[i].x1, wire[i].y1, wire[i].x2, wire[i].y2); } } if(sel) { select_wire(i,SELECTED, 1); ui_state|=SELECTION; } } else { if(debug_var>=2) fprintf(errfp, "search_inst(): not found wire=%d, tok=%s, val=%s search=%s\n", i,tok, str,val); } } } } else if(what==END) draw_hilight_net(1); if(sel) { drawtemparc(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0, 0.0); drawtemprect(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0); drawtempline(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0); } regfree(&re); draw_window = save_draw; } /* 20171211 */ /* "drill" option (pass through resistors or pass gates or whatever elements with */ /* 'propagate_to' properties set on pins) */ void drill_hilight(void) { static char *netname=NULL, *propagated_net=NULL; int mult=0; int found; Instdef *symbol; Box *rect; int i, j, npin; char *propagate_str; int propagate; struct hilight_hashentry *entry, *propag_entry; int count; prepare_netlist_structs(1); count=0; while(1) { found=0; count++; for(i=0; irects[PINLAYER]; rect=symbol->boxptr[PINLAYER]; for(j=0; jvalue, 0); /* add net to highlight list */ if(!propag_entry) { /* fprintf(errfp, "inst %s: j=%d count=%d propagate=%d --> net %s, propagate to --> %s color %d\n", */ /* inst_ptr[i].instname, j, count, propagate, netname, pin_node(i, propagate, &mult, 1), entry->value); */ found=1; /* keep looping until no more nets are found. */ } } } /* for(j...) */ } /* for(i...) */ if(!found) break; } /* while(1) */ } void hilight_net(void) { int i, n; char *str; prepare_netlist_structs(1); if(debug_var>=1) fprintf(errfp, "hilight_net(): entering\n"); rebuild_selected_array(); for(i=0;i=1) fprintf(errfp, "hilight_net(): setting hilight flag on inst %d\n",n); hilight_nets=1; inst_ptr[n].flags |= 4; } } break; default: break; } } if(enable_drill) { drill_hilight(); /*traverse_schematic(); */ } } void unhilight_net(void) { int i,n; char *str; prepare_netlist_structs(1); if(debug_var>=1) fprintf(errfp, "unhilight_net(): entering\n"); rebuild_selected_array(); for(i=0;i 2000 || lastinst > 2000 ) && (x2 - x1 < ITERATOR_THRESHOLD); if(use_hash) { hash_wires(); } if(!use_hash) for(i=0;ivalue%(cadlayers-7), THICK, wire[i].x1, wire[i].y1, wire[i].x2, wire[i].y2); else drawline(7+entry->value%(cadlayers-7), NOW, wire[i].x1, wire[i].y1, wire[i].x2, wire[i].y2); if(CADHALFDOTSIZE*mooz>=0.7) { if( wire[i].end1 >1 ) { /* 20150331 draw_dots */ filledarc(7+entry->value%(cadlayers-7), NOW, wire[i].x1, wire[i].y1, CADHALFDOTSIZE, 0, 360); } if( wire[i].end2 >1 ) { /* 20150331 draw_dots */ filledarc(7+entry->value%(cadlayers-7), NOW, wire[i].x2, wire[i].y2, CADHALFDOTSIZE, 0, 360); } } } } } else for(init_wire_iterator(x1, y1, x2, y2); ( wireptr = wire_iterator_next() ) ;) { i = wireptr->n; str = get_tok_value(wire[i].prop_ptr, "lab",0); if(str[0]) { if( (entry = bus_hilight_lookup(str, 0,2)) ) { if(wire[i].bus) /* 20171201 */ drawline(7+entry->value%(cadlayers-7), THICK, wire[i].x1, wire[i].y1, wire[i].x2, wire[i].y2); else drawline(7+entry->value%(cadlayers-7), NOW, wire[i].x1, wire[i].y1, wire[i].x2, wire[i].y2); if(CADHALFDOTSIZE*mooz>=0.7) { if( wire[i].end1 >1 ) { /* 20150331 draw_dots */ filledarc(7+entry->value%(cadlayers-7), NOW, wire[i].x1, wire[i].y1, CADHALFDOTSIZE, 0, 360); } if( wire[i].end2 >1 ) { /* 20150331 draw_dots */ filledarc(7+entry->value%(cadlayers-7), NOW, wire[i].x2, wire[i].y2, CADHALFDOTSIZE, 0, 360); } } } } } my_realloc(145, &inst_color,lastinst*sizeof(int)); for(i=0;itype; /* 20150409 */ if( type && !(strcmp(type,"label") && strcmp(type,"ipin") && strcmp(type,"iopin") && strcmp(type,"opin") ) ) { entry=bus_hilight_lookup( get_tok_value(inst_ptr[i].prop_ptr,"lab",0) , 0, 2 ); if(entry) inst_color[i]=7+entry->value%(cadlayers-7); } else if( inst_ptr[i].flags & 4) { if(debug_var>=1) fprintf(errfp, "draw_hilight_net(): instance %d flags &4 true\n", i); inst_color[i]=PINLAYER; } } for(c=0;c=1) fprintf(errfp, "draw_hilight_net(): instance:%d\n",i); drawline(inst_color[i], BEGIN, 0.0, 0.0, 0.0, 0.0); drawrect(inst_color[i], BEGIN, 0.0, 0.0, 0.0, 0.0); filledrect(inst_color[i], BEGIN, 0.0, 0.0, 0.0, 0.0); drawarc(inst_color[i], BEGIN, 0.0, 0.0, 0.0, 0.0, 0.0); /* 20160414 from draw() */ symptr = (inst_ptr[i].ptr+instdef); if( c==0 || /*draw_symbol_outline call is needed on layer 0 to avoid redundant work (outside check) */ symptr->lines[c] || symptr->rects[c] || ((c==TEXTWIRELAYER || c==TEXTLAYER) && symptr->texts)) { draw_symbol_outline(ADD, inst_color[i], i,c,0,0,0.0,0.0); } filledrect(inst_color[i], END, 0.0, 0.0, 0.0, 0.0); drawarc(inst_color[i], END, 0.0, 0.0, 0.0, 0.0, 0.0); drawrect(inst_color[i], END, 0.0, 0.0, 0.0, 0.0); drawline(inst_color[i], END, 0.0, 0.0, 0.0, 0.0); } } } draw_window = save_draw; } void xdraw_hilight_net(int on_window) { char *str; int save_draw; char *type=NULL; int i,c; struct hilight_hashentry *entry; register double x1,y1,x2,y2; /* 20150409 */ Instdef *symptr; /* 20160414 */ if(!hilight_nets) return; save_draw = draw_window; /* 20181009 */ draw_window = on_window; for(i=0;ivalue%(cadlayers-7), THICK, wire[i].x1, wire[i].y1, wire[i].x2, wire[i].y2); else drawline(7+entry->value%(cadlayers-7), NOW, wire[i].x1, wire[i].y1, wire[i].x2, wire[i].y2); } } } my_realloc(145, &inst_color,lastinst*sizeof(int)); for(i=0;itype; /* 20150409 */ if( type && !(strcmp(type,"label") && strcmp(type,"ipin") && strcmp(type,"iopin") && strcmp(type,"opin") ) ) { entry=bus_hilight_lookup( get_tok_value(inst_ptr[i].prop_ptr,"lab",0) , 0, 2 ); if(entry) inst_color[i]=7+entry->value%(cadlayers-7); } else if( inst_ptr[i].flags & 4) { if(debug_var>=1) fprintf(errfp, "draw_hilight_net(): instance %d flags &4 true\n", i); inst_color[i]=PINLAYER; } } for(c=0;c=1) fprintf(errfp, "draw_hilight_net(): instance:%d\n",i); drawline(inst_color[i], BEGIN, 0.0, 0.0, 0.0, 0.0); drawrect(inst_color[i], BEGIN, 0.0, 0.0, 0.0, 0.0); filledrect(inst_color[i], BEGIN, 0.0, 0.0, 0.0, 0.0); drawarc(inst_color[i], BEGIN, 0.0, 0.0, 0.0, 0.0, 0.0); /* 20160414 from draw() */ symptr = (inst_ptr[i].ptr+instdef); if( c==0 || /*draw_symbol_outline call is needed on layer 0 to avoid redundant work (outside check) */ symptr->lines[c] || symptr->rects[c] || ((c==TEXTWIRELAYER || c==TEXTLAYER) && symptr->texts)) { draw_symbol_outline(ADD, inst_color[i], i,c,0,0,0.0,0.0); } filledrect(inst_color[i], END, 0.0, 0.0, 0.0, 0.0); drawarc(inst_color[i], END, 0.0, 0.0, 0.0, 0.0, 0.0); drawrect(inst_color[i], END, 0.0, 0.0, 0.0, 0.0); drawline(inst_color[i], END, 0.0, 0.0, 0.0, 0.0); } } } draw_window = save_draw; } void undraw_hilight_net(int on_window) /* 20160413 */ { char *str; int save_draw; /* 20181009 */ char *type=NULL; int i,c; struct hilight_hashentry *entry; register double x1,y1,x2,y2; /* 20150409 */ Instdef *symptr; /* 20160414 */ save_draw = draw_window; /* 20181009 */ draw_window = on_window; for(i=0;i=0.7) { if( wire[i].end1 >1 ) { /* 20150331 draw_dots */ filledarc(WIRELAYER, NOW, wire[i].x1, wire[i].y1, CADHALFDOTSIZE, 0, 360); } if( wire[i].end2 >1 ) { /* 20150331 draw_dots */ filledarc(WIRELAYER, NOW, wire[i].x2, wire[i].y2, CADHALFDOTSIZE, 0, 360); } } } } } my_realloc(146, &inst_color,lastinst*sizeof(int)); for(i=0;itype; /* 20150409 */ if( type && !(strcmp(type,"label") && strcmp(type,"ipin") && strcmp(type,"iopin") && strcmp(type,"opin") ) ) { entry=bus_hilight_lookup( get_tok_value(inst_ptr[i].prop_ptr,"lab",0) , 0, 2 ); if(entry) inst_color[i]=7+entry->value%(cadlayers-7); } else if( inst_ptr[i].flags & 4) { inst_color[i]=PINLAYER; } } for(c=0;c=1) fprintf(errfp, "draw_hilight_net(): instance:%d\n",i); /* 20160414 from draw() */ symptr = (inst_ptr[i].ptr+instdef); if( c==0 || /*draw_symbol_outline call is needed on layer 0 to avoid redundant work (outside check) */ symptr->lines[c] || symptr->rects[c] || ((c==TEXTWIRELAYER || c==TEXTLAYER) && symptr->texts)) { draw_symbol_outline(ADD, c, i,c,0,0,0.0,0.0); } } } filledrect(c, END, 0.0, 0.0, 0.0, 0.0); drawarc(c, END, 0.0, 0.0, 0.0, 0.0, 0.0); drawrect(c, END, 0.0, 0.0, 0.0, 0.0); drawline(c, END, 0.0, 0.0, 0.0, 0.0); } if(ui_state & SELECTION) draw_selection(gc[SELLAYER], 0); /* 20171211 */ draw_window = save_draw; } /* show == 0 ==> create pins from highlight nets */ void print_hilight_net(int show) { int i; FILE *fd; struct hilight_hashentry *entry; struct node_hashentry *node_entry; static char *cmd = NULL; /* 20161122 overflow safe */ static char *cmd2 = NULL; /* 20161122 overflow safe */ static char *cmd3 = NULL; /* 20161122 overflow safe */ char a[] = "create_pins"; char b[] = "add_lab_prefix"; char b1[] = "add_lab_no_prefix"; static char *filetmp1 = NULL; static char *filetmp2 = NULL; char *filename_ptr; /* 20111116 20111201 */ prepare_netlist_structs(0); /* use full prepare_netlist_structs(0) to recognize pin direction */ /* when creating pins from hilight nets 20171221 */ /* 20180924 */ if(!(fd = open_tmpfile("hilight_", &filename_ptr)) ) { fprintf(errfp, "print_hilight_net(): can not create tmpfile %s\n", filename_ptr); return; } my_strdup(147, &filetmp2, filename_ptr); fclose(fd); if(!(fd = open_tmpfile("hilight_", &filename_ptr))) { fprintf(errfp, "print_hilight_net(): can not create tmpfile %s\n", filename_ptr); return; } my_strdup(148, &filetmp1, filename_ptr); if(show == 3) { tclsetvar("filetmp2",filetmp1); } else { tclsetvar("filetmp2",filetmp2); } tclsetvar("filetmp1",filetmp1); if( filetmp1[0] == 0 || filetmp2[0] == 0 ) { if(debug_var>=1) fprintf(errfp, "print_hilight_net(): problems creating tmpfiles\n"); return; } /* /20111106 */ my_strdup(149, &cmd, tclgetvar("XSCHEM_SHAREDIR")); my_strcat(150, &cmd, "/order_labels.awk"); my_strdup(151, &cmd2, cmd); my_strcat(152, &cmd2," "); my_strcat(153, &cmd2,filetmp1); my_strcat(154, &cmd2,">"); my_strcat(155, &cmd2,filetmp2); /* 20111106 */ my_strdup(156, &cmd3, tclgetvar("XSCHEM_SHAREDIR")); my_strcat(157, &cmd3, "/sort_labels.awk "); my_strcat(158, &cmd3, filetmp1); /*fd=fopen(filetmp1, "w"); */ if(fd==NULL){ if(debug_var>=1) fprintf(errfp, "print_hilight_net(): problems opening netlist file\n"); return; } for(i=0;itoken, "",2, 0, "", "", "", ""); /* 20170926 test for not null node_entry, this may happen if a hilighted net name has been changed */ /* before invoking this function, in this case --> skip */ if(node_entry && !strcmp(sch_prefix[currentsch], entry->path)) { if(show==3) { fprintf(fd, "%s%s\n", entry->path, entry->token); /* 20111106 */ } else if(show==1) { /* 20120926 */ fprintf(fd, "%s\n", entry->token); /* 20120926 */ } else { if(node_entry->d.out==0 && node_entry->d.inout==0 ) fprintf(fd, "%s %s\n", entry->token, "ipin"); else if(node_entry->d.in==0 && node_entry->d.inout==0 ) fprintf(fd, "%s %s\n", entry->token, "opin"); else fprintf(fd, "%s %s\n", entry->token, "iopin"); } } entry = entry ->next ; } } fclose(fd); system(cmd2); if(show==2) { tcleval(b); } if(show==4) { /* 20120913 create labels from hilight pins without 'i' prefix */ tcleval(b1); } if(show==1) { my_strdup(159, &cmd, "set ::retval [ read_data_nonewline "); my_strcat(160, &cmd, filetmp2); my_strcat(161, &cmd, " ]"); tcleval(cmd); tcleval("viewdata $::retval"); } if(show==3) { system(cmd3); my_strdup(162, &cmd, "set ::retval [ read_data_nonewline "); my_strcat(163, &cmd, filetmp1); my_strcat(164, &cmd, " ]"); tcleval(cmd); tcleval("viewdata $::retval"); } if(show==0) { tcleval(a); } unlink(filetmp2); unlink(filetmp1); /* 20170323 this delete_netlist_structs is necessary, without it segfaults when going back (ctrl-e) */ /* from a schematic after placing pins (ctrl-j) and changing some pin direction (ipin -->iopin) */ prepared_hilight_structs=0; /* 20171212 */ prepared_netlist_structs=0; /* 20171212 */ /* delete_netlist_structs(); */ } xschem-2.8.1/src/parselabel.l0000644000175100017510000001231313377077322014302 0ustar svnsvn/* File: parselabel.l * * This file is part of XSCHEM, * a schematic capture and Spice/Vhdl/Verilog netlisting tool for circuit * simulation. * Copyright (C) 1998-2018 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 */ %option never-interactive %option noyywrap %{ #include #include #include extern int debug_var; extern FILE *errfp; extern void my_strdup(int id, char **dest, char *src); extern void my_free(void *ptr); typedef struct /* used in expandlabel.y */ { char *str; /* label name */ int m; /* label multiplicity, number of wires */ } Stringptr; /* commented 20170412, fixes problems with older bison/flex versions */ /* #define YYPARSE_PARAM */ #include "expandlabel.h" /* Bison header file */ Stringptr dest_string={NULL,0}; /*19102004; */ static int bracket=0; extern int yyparse(void) ; const char *expandlabel(const char *s, int *m) { YY_BUFFER_STATE buf; my_free(&dest_string.str); /* 30102004 delete 'memory' of previous execution */ dest_string.str=NULL; /* 30102004 */ if(debug_var >=3) fprintf(errfp, "expandlabel(): entering\n"); buf=yy_scan_string(s); bracket=0; yyparse(); /* 20140108 */ yy_delete_buffer(buf); if(debug_var >=3) fprintf(errfp, "expandlabel(): returning %s from %s mult=%d\n",dest_string.str, s, dest_string.m); if(dest_string.str) *m = dest_string.m; else *m=-1; if(dest_string.str) return dest_string.str; else return s; } %} /* Lexical analyzer */ %x label %x next_to_alias %x rest %% ^(alias|ipin|opin)[+ \n]+[^+\n ]+/[\n +]+ { yylval.ptr.str=NULL; /*19102004 */ my_strdup(298, &yylval.ptr.str, yytext); /* these things are freed after use in expandlabel.y */ BEGIN(next_to_alias); return B_LINE; } [\n +]+ { /* get all white space and return a single separator */ BEGIN(label); yylval.val=yytext[0]; return B_CAR; } ^[^*] { if(debug_var>=3) fprintf(errfp, "yylex(): matched: ^[^*] |%s|\n",yytext); yyless(0); /* push back to input */ BEGIN(label); /* we know that a label follows. */ /* so go and process it. */ } ^\*.* { /* a comment, return as LINE token */ yylval.ptr.str=NULL; /*19102004 */ my_strdup(299, &yylval.ptr.str, yytext); /* these things are freed after use in expandlabel.y */ return B_LINE; }