       LINEMOD - A Transmission Line Modeling Program


                             by


                   David G. Messerschmitt
 Department of Electrical Engineering and Computer Science
                  University of California
                 Berkeley, California 94720



Documentation revised by: 
			  Atul Salvekar
	Department of Electrical Engineering and Computer Science
		      Information Systems Lab
		        Stanford University
	                Stanford, CA 94305



1.

Introduction


     LINEMOD is a program which  models  transmission  lines

containing (possibly) different gauges of wire, bridge taps,

resistive sources,  and  shunt  resistor-capacitor  termina-

tions.   Other types of circuit elements can be added readi-

ly.  This document describes how to use the program.


     The elements of a transmission line are  modeled  using

the ABCD parameter matrix model of a two-port.  The user can

add a new circuit element by simply providing  a  subroutine

which  supplies  the ABCD matrix.  The input to LINEMOD is a

file containing the specification of the  two-ports  in  the

line  in  the  order  in which they appear in the line.  One

element is a bridge tap, the circuit elements of which  must

then  be  specified.  Bridge taps can themselves contain any

elements, including more bridge taps.


     The output of LINEMOD is three  files,  one  containing

the  input impedance of the line vs. frequency, another con-

taining the frequency response of the line (magnitude of the

voltage  transfer  function  in dB), and the third including

the impulse response.  A user supplied routine can supply  a

Fourier  transform  which is placed in tandem with the line,

thereby permitting the including of  transmit  filters,  and

input pulses other than impulses.


     Internally, LINEMOD calculates the ABCD matrix  of  the

line by multiplying the ABCD matrices of the elements of the

line.  Bridge taps are handled by a recursive  call  to  the

line  modeling routine, followed by the inclusion of a shunt

impedance corresponding to the input impedance of the bridge

tap.


2.  Using the Program


     LINEMOD is written in C, and will  run  on  any  system

running  C.   The  source files for LINEMOD are in the files

type.h, linemod.c, compute.c, and propagation.c.   Auxiliary

programs which are used are an FFT routine in fft.c and com-

plex number manipulations in complex.h  and  complex.c.   In

addition  there  is a file filt_tf.c, which contains a func-

tion filt_tf().  This function can be  used  to  model  what

happens  if  the signal at the line input is not an impulse,

or  a  filter  transfer  function  is  put  at  the  output.

filt_tf()  returns a transfer function, which multiplies the

transfer function of the line.  It presently contains a dum-

my  routine  which returns unity at all frequencies, but the

user can substitute any transfer function desired.

     To run the model program, type


     linemod file


where linemod is assumed to be the object file and file is a

file  containing  the parameters of the line.  The format of

this file is described in later Section 2.2.


2.1.  Output Files


     The output is put in four files:


1.   file.data contains the parameters of  the  line  echoed

     back in a narrative mode for permanent record and to be

     sure the data was properly interpreted.


2.   file.freq contains the amplitude frequency response  of

     the line, where the first column is the frequency in Hz

     and the second is the line voltage  magnitude  transfer

     function  in dB at that frequency.  This transfer func-

     tion includes  any  transfer  function  implemented  in

     filt_tf().


3.   file.imped contains the input impedance of the line  in

     ohms.  The first column is the frequency, the second is

     the real part of the impedance, and the  third  is  the

     imaginary  part.  Note that this impedance includes any

     source impedance, so that the source  impedance  should

     be subtracted to obtain the input impedance of the line

     itself.


4.   file.time contains the impulse response  of  the  line.

     The  first  column is the time in sec and the second is

     the impulse response at that  time.   If  filt_tf()  is

     changed to return a transfer function other than unity,

     then this file  will  no  longer  contain  the  impulse

     response  of  the  line  alone,  but rather the overall

     response including filt_tf().


2.2.  Input File


     This section gives a specification of the input file.


     Each line section,  bridge  tap,  resistor,  capacitor,

etc.  is  represented by one line in the file.  In addition,

there is a first line  which  specifies  certain  parameters

controlling  the spacing of points in the time and frequency

response.  The following specifies the  different  lines  in

the file:

                           Line 1


     The format is


                        mexp nexp T


where T is a floating number which controls the  time  axis.

One  usually  thinks  of T as the time for one bit in a data

transmission system.  However, all that needs to  really  be

remembered  is that the total time that the time response is

calculated over is


                       T*2^mexp

and the spacing of points in the time response is


                     T/(2^nexp)

Thus,


                           mexp

should be chosen large enough to encompass the whole impulse

response, and should be chosen to be larger the narrower the

bandwidth.  Choosing


                            mexp

too small will result in time aliasing, which can usually be

easily recognized in the result.  Similarly,


                            nexp

should be chosen large enough to  obtain  the  desired  time

resolution.   The time resolution is directly related to the

bandwidth of the line.  In particular, the highest frequency

represented in the line is


                     (2^nexp)/T

and

                            nexp

should be chosen large enough that the  effective  bandwidth

of  the  line  is encompassed.  Choosing nexp too small will

result in frequency aliasing, which can usually be  observed

in the impulse response as "Gibbs oscillation".



                      Remaining Lines


     Each line gives one circuit element of the line in ord-

er.  The available control strings and parameters are:


series_r


                         resistance (ohms)


which is a series resistance, usually used  for  the  source

resistance,


shunt_r


                         resistance (ohms)


which is a shunt resistance,


shunt_c


                        capacitance (farads)


which is a shunt capacitance,


line


                           length (km)

 		line description ('24' for 24 gauge.
                		  '26' for 26 gauge,
		   		  '110' for DW10 aka TP3, and
		   		  '108' for DW8 aka FP) 


which specifies the length of a transmission  line  and  its

gauge (NOTE THAT WE ARE NOT SURE IF THE MODELING IS ACCURATE 

ABOVE 30 MHz, furthermore GAUGES 19 and 22 were also 

originally included, but they have been removed since the

model accuracy was known only up to 1 MHz),


bridge


which specifies the beginning of a specification of a bridge

tap, and


end


which specifies the end of a bridge tap.  The lines  between

bridge  and  end specify the circuit elements of the bridged

line, which can be any of the  elements  specified  earlier.

In  fact, end specifies the end of a line, whether it be the

main line or a bridged line.  The last line in the file must

be end.


2.3.  Examples


     This section gives some examples of input file specifi-

cations.


     The following  file  specifies  a  simple  filter  with

series  0.5  ohm resistor followed by shunt 0.5 ohm resistor

and parallel 10 microfarad capacitor:

    #line one contains time and frequency resolution parameters
    5 3 1.e-5

    #now the sections of the transmission line
    series_r 0.5
    shunt_r 0.5
    shunt_c 1.0e-5
    end


This illustrates that blank lines and comment lines  be-

ginning  with  a  "#"  can be added to the specification

file for readability.


     The following file specifies a single section of 24

gauge  line  6  km long, with source and termination 100

ohm resistors (T is chosen as the bit time corresponding

to 1.5 Mb/s):

    5 3 6.6667e-7
    series_r 100.
    line 6. 24
    shunt_r 100.
    end


     The following file specifies  an  18  km  line  (24

gauge) with a 5 km bridge tap in the center. The bridged

line is not terminated (open circuited).  The source and

termination  resistors  are  100  ohm.   T  is chosen to

correspond to 80 kb/s transmission.

    5 3 1.25e-5

    #main line
    series_r 100.
    line 9. 24

            #bridge tap
            bridge
            line 5. 24
            end

    #back to the main line
    line 9. 24
    shunt_r 100.
    end

    This specification illustrates that blanks or tabs can

    be put in front of specifications, enhancing readability

    when bridge taps are included.


     As a final example, just for fun let  us  terminate

the  bridge  tap  in 5K ohms and add a bridge tap to the

center of the bridge tap!

    5 3 1.25e-5

    #main line
    series_r 100.
    line 9. 24

            #bridge tap
            bridge
            line 2.5 24

                    #this bridge tap has its own bridge tap
                    bridge
                    line 0.5 24
                    end

            line 2.5 24
            shunt_r 5000.
            end

    #back to the main line
    line 9. 24
    shunt_r 100.
    end


This illustrates that the bridge taps can be  nested  an

arbitrary number of times; that is; bridge taps can have

bridge taps can have bridge taps, etc.


3.  Implementation


     The program works by computing a


                            2x2

"transmission" or "ABCD" matrix for each section of  the

line  at each frequency.  The ABCD matrix is then calcu-

lated for the entire line by  multiplying  the  matrices

for each section.  If a bridge tap is encountered, these

routines are called recursively to compute the ABCD  ma-

trix  of  the  bridge  tap,  and from this the input im-

pedance of the bridge tap is computed and a section con-

sisting of the bridge tap impedance in shunt is added to

the main line.


     The ABCD matrix for a transmission line section  is

computed  from the secondary parameters propagation con-

stant and  characteristic  impedance.   These  secondary

parameters  are  in  turn  calculated  from  the primary

parameters


                       R, C, G, and L
 
vs. frequency as obtained by a polynomial (in frequency)

approximation to published empirical data.


     After computing the ABCD matrix of the line, it  is

then  easy  to construct the input impedance and voltage

transfer function of the line.  The impulse response  is

then calculated by using the FFT in conjunction with the

voltage transfer function.


     If in the future other quantities, such as the  im-

pulse  response  of  the hybrid return loss, is desired,

they will be simple to add based on the ABCD matrix data

structure stored in memory.


     As mentioned above, we have only provided 5 types of

transmission lines. To add more, please look at the source 

code for the line.c. There is a subroutine, gi(), that calculates

the R, C, L, and G parameters of the system. One can add in

different frequency domain representations of the transmission 

lines in this subroutine. Line modeling parameters 

can be found in many standards (ex. the T1E1 lines above were 

modeled in the T1E1/98-117R13). It is recommended that the user 

determine whether the transmission lines are adequately modeled 

for his uses. 


     We have made a make program called makefile. This will check 

for dependencies in the program so that when a file is changed, the

object files will be updated. If any components are added that have 

some ABCD matrix representation, then the make file will have to be 

updated.


     An important note is that if a file describing the line 

characteristics has been changed, then the previously created output

files must be deleted. Otherwise, the program may not overwrite the 

old files.	
  
     Finally, we note that everything is done in the frequency domain,

so that any further signal processing can be done via another platform 

like Matlab or Mathematica by just downloading the output files, 

(filename).freq or (filename).imped.


4. PC version

   In the pc_changes directory, line_pc.c and template_pc.c may allow 

the pc user to use linemod. The pc user should rename move line_pc.c 

and template_pc.c into the line directory. Rename these line.c and

template.c respectively. Then recompile. This may not work for all 

version.












































