-
Notifications
You must be signed in to change notification settings - Fork 0
/
project-fan-controller-fpga
20607 lines (20419 loc) · 223 KB
/
project-fan-controller-fpga
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%!PS-Adobe-3.0
%%DocumentFonts: Helvetica Times-Roman Courier
%%Creator: Cadence Design Systems
%%EndComments
%%BeginProlog
%
% Start of Cadence ps.prologue -- Version 5.3.1
% Adobe Postscript Level 2 Color Version.
/setpacking where
{
/currpack currentpacking def
pop true setpacking
} if
%******************************************************************************
% Graphics initialization routine.
%
/gis {
0 setgray
save
mark
newpath
%
% Scale postscripts 72 dpi divided by the plotter resolution set in pap.
%
72 resolution div
dup
scale
%
% Move the origin of the plot up and to the right so the plotters margin
% is observed.
%
offsetX offsetY translate
/stippleArray 10 array def
stippleArray
dup 0 <FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF> put
dup 1 <00000000000000000000000000000000
00000000000000000000000000000000> put
dup 2 <00000000000000000000000000000000
00000000000000000000000000000000> put
dup 3 <00000000000000000000000000000000
00000000000000000000000000000000> put
dup 4 <00000000000000000000000000000000
00000000000000000000000000000000> put
dup 5 <00000000000000000000000000000000
00000000000000000000000000000000> put
dup 6 <00000000000000000000000000000000
00000000000000000000000000000000> put
dup 7 <00000000000000000000000000000000
00000000000000000000000000000000> put
dup 8 <08080404020201018080404020201010
08080404020201018080404020201010> put
9 <08081414222241418080414122221414
08081414222241418080414122221414> put
/newFont 10 dict def
newFont begin
/FontType 3 def
/FontMatrix [1 0 0 1 0 0] def
/FontBBox [0 0 1 1] def
/Encoding 256 array def
0 1 255 {Encoding exch /.notdef put} for
Encoding
dup 48 /0 put
dup 49 /1 put
dup 50 /2 put
dup 51 /3 put
dup 52 /4 put
dup 53 /5 put
dup 54 /6 put
dup 55 /7 put
dup 56 /8 put
57 /9 put
/BuildChar {
/char exch def
/fontdict exch def
/charname fontdict /Encoding get char get def
1 0 setcharwidth
16 16 true
[16 0 0 -16 -.5 15.50]
stippleArray char 48 sub 1 getinterval cvx
imagemask
} def
end
/StippleFont newFont definefont 66 scalefont setfont
/fillChar 0 def
/ellipsedict 8 dict def
ellipsedict /mtrx matrix put
/xformdict 8 dict def
xformdict /xformmtrx matrix put
/color 0 def
/lineRed 0 def
/lineGreen 0 def
/lineBlue 0 def
/fillRed 0 def
/fillGreen 0 def
/fillBlue 0 def
/hatchSet 0 def
/rht 0 def
/rw 0 def
/ils 1.0 def
/textalign 1 def
} bind def
%******************************************************************************
% Paper call. Sets resolution page height and page width.
%
/pap {
/resolution exch def
/pageHeight exch def
/pageWidth exch def
/offsetY exch def
/offsetX exch def
} bind def
%******************************************************************************
% Plot is done.
%
/gfs {
showpage
cleartomark
restore
} bind def
%******************************************************************************
% Next Page sequence.
%
/nxp {
showpage
newpath
%
% Scale postscripts 72 dpi divided by the plotter resolution set in pap.
%
72 resolution div
dup
scale
%
% Move the origin of the plot up and to the right so the plotters margin
% is observed.
%
offsetX offsetY translate
/ils 1.0 def
/textalign 1 def
} bind def
%******************************************************************************
% Rotate Plot Sequence.
%
/rotp {
pageWidth 0 translate %% This moves lower left of plot to
%% lower right of page.
90 rotate %% rotate plot 90 degs.
} bind def
%******************************************************************************
% Clipping Window
%
/clwin {
initclip
/y2 exch def
/x2 exch def
/y1 exch def
/x1 exch def
newpath
x1 y1 moveto
x2 y1 lineto
x2 y2 lineto
x1 y2 lineto
closepath
clip
} bind def
%******************************************************************************
% These to routines keep track of the bounding box of the shape.
% This information is used when filling the drawn shape.
%
/bblineto {
dup dup
/cury exch def
miny lt {/miny exch def}
{dup maxy gt { /maxy exch def }
{pop } ifelse } ifelse
dup dup
minx lt {/minx exch def}
{dup maxx gt { /maxx exch def }
{ pop } ifelse } ifelse
cury lineto
} bind def
/bbmoveto {
dup dup
/miny exch def /maxy exch def /cury exch def
dup dup
/minx exch def /maxx exch def
cury moveto
} bind def
%******************************************************************************
% Internal ellipical arc routine.
% x y xradius yradius startangle endangle ellipse
%
/ellipse
{
/endangle exch def
/startangle exch def
/yrad exch def
/xrad exch def
/y exch def
/x exch def
startangle endangle gt {
save
/tmpangle startangle def
/startangle endangle def
/endangle tmpangle def
restore
} if
ellipsedict begin
/savematrix mtrx currentmatrix def
x y translate
xrad yrad scale
0 0 1 startangle endangle arc
savematrix setmatrix
end
} bind def
%******************************************************************************
% Resident Font Scale Sequence
% x y rfss
%
/rfss {
4 2 roll
dup
3 div
add
scalefont
setfont
0 color ne {setLineColor}
{ 0 setgray } ifelse
} bind def
%******************************************************************************
% Resident Font End
%
%
/rfe
{
/width exch def
5 1 roll
moveto
xformdict begin
/savematrix xformmtrx currentmatrix def
exch % rotate mirror to mirror rotate
matrix rotate concat % add rotation to current transform matrix
dup 1 eq
{pop 1 -1} % X mirror
{2 eq
{-1 1} % Y mirror
{1 1} % No mirror
ifelse}
ifelse matrix scale concat % add mirror to current transform matrix
dup % duplicate (string)
length % replace one of the strings with its length
dup 0 ne
{
3 -1 roll % move fixed width flag to top of stack
0 eq
{ % if flag is false (0) do old string handling
/numChr exch def
dup stringwidth %stack wy,wx,(string)
pop
width
exch sub %stack xdiff,ydiff,(string)
cvi
numChr idiv %stack xspace,ydiff,(string)
/xoff exch def
{ % this is the positioning function for kshow
pop pop
xoff
0
rmoveto
}
exch
kshow
}
{ % if flag is true (not 0) just show string
pop show
}
ifelse
}
{
pop pop pop
}
ifelse
savematrix setmatrix
end
} bind def
%******************************************************************************
% Resident Font Text Alignment
%
/rfta { % <align> rfta
/textalign exch def
} bind def
%******************************************************************************
% Resident Font Interline Space
%
/rfis { % <space> rfis
/ils exch def
} bind def
%******************************************************************************
% Resident Font Scale
%
/rfsc { % <ht> <rotate> <mirror> rfs
% What I need to do here is to validate <ht>. <ht> can not be 0. If it is 0
% then make it 1. To do this I will need to use the roll operation and exch
% and maybe dup. The algorithm looks like this:
% Roll stack to make it look like : <rotate> <mirror> <ht>
% duplicate <ht> so I can test it.
% If <ht> is equal to 0 then
% exchange 1 for <ht>
% In any case roll stack to make it look like: <ht> <rotate> <mirror>
% qed.
%
3 -1 roll % <rotate> <mirror> <ht>
dup 0 eq
{
1 exch pop % <rotate> <mirror> <ht=1>
}
if
3 1 roll % <ht> <rotate> <mirror>
0 color ne
{
setLineColor
}
{
0 setgray
}
ifelse
/tasz 60 def
/taln 59 def
/ta tasz array def
/cta ta def
/tc 0 def
/sa tasz array def
/sc 0 def
} bind def
%******************************************************************************
% Resident Font Restricted Text
%
/rfrt { % <height> <width> rfrt
/rht exch def
/rw exch def
% Since restricting one dimension and not the other is not supported
% if one dimension is turned off then ensure that both dimensions
% are turned off (a value of 0 means no restriction)
rht 0 eq rw 0 eq or
{
/rht 0 def
/rw 0 def
}
if
} bind def
%******************************************************************************
% Resident Font Text Score
%
/rfts { % <score> <start> <end> rfts
sc tasz lt
{
3 -1 roll 3 array astore
sa sc 3 -1 roll put
/sc sc 1 add def
}
{
pop pop pop
} ifelse
} bind def
%******************************************************************************
% Resident Font Text
%
/rft { % (text) rft
tc taln gt tc tasz mod 0 eq and
{
cta /cta tasz array dup def put
} if
tc tasz mod exch cta 3 1 roll sc
sa dup length array copy
3 array astore put
/sc 0 def
/tc tc 1 add def
} bind def
%******************************************************************************
% Resident Font Complete
%
/rfc { % <x> <y> rfc
/cta ta def
%
% If text is restricted or if text alignment is not left, find the
% longest text string
%
/mw 0 def
rw 0 ne textalign 3 gt or
{
%
% Find the widest text string
%
5 index % <fn> <ht> <rot> <mir> <x> <y> <fn>
setfont
0 1 tc 1 sub
{
dup taln gt 1 index tasz mod 0 eq and
{
/cta cta tasz get def
}
if
tasz mod cta exch get 0 get
stringwidth pop dup mw gt
{
/mw exch def null
}
if
pop
}
for
/cta ta def
}
if
%
% Operand stack: <fn> <ht> <rot> <mir> <x> <y>
% Check for restricted text
%
rw 0 ne
{
%
% Compute font scale factors
%
6 -2 roll pop % <rot> <mir> <x> <y> <fn>
rw mw div
rht tc div dup ils mul 0.5 add cvi /tht exch def
matrix scale makefont % <rot> <mir> <x> <y> <fn>
/mw rw def
}
{
6 -2 roll % <rot> <mir> <x> <y> <fn> <ht>
dup 0 eq % Test if height is 0
{ % change to 1 if it is
1 exch pop % <rot> <mir> <x> <y> <fn> <1>
}
if
dup ils mul 0.5 add cvi /tht exch def
dup mw mul /mw exch def scalefont
}
ifelse
setfont % <rot> <mir> <x> <y>
moveto % <rot> <mir>
xformdict begin
/savematrix xformmtrx currentmatrix def
exch matrix rotate concat
dup 1 eq
{
pop 1.0 -1.0 % x mirror
}
{
2 eq
{
-1.0 1.0 % y mirror
}
{
1.0 1.0 % no mirror
}
ifelse
}
ifelse
matrix scale concat
currentpoint
%
% Adjust origin for text alignment. For lc (4), cc (5), and uc
% (6) move left by width / 2. For lr (7), cr (8), and ur (9)
% move left by width. For cl (2), cc (5), and cr (8) move down
% by height / 2. For ul (3), uc (6), and ur (9) move down by
% height.
%
textalign 2 eq textalign 5 eq or textalign 8 eq or
{
tht tc mul 2 div sub
} if
textalign 3 eq textalign 6 eq or textalign 9 eq or
{
tht tc mul sub
} if
/oy exch def
textalign 3 gt textalign 7 lt and
{
mw 2 div sub
} if
textalign 6 gt textalign 10 lt and
{
mw sub
} if
/ox exch def
0 1 tc 1 sub
{
dup taln gt 1 index tasz mod 0 eq and
{
/cta cta tasz get def
}
if
cta exch tasz mod get aload pop
dup 3 -1 roll % (str) [score] [score] <cnt>
0 1 3 -1 roll 1 sub % (str) [score] [score] 0 1 <cnt>
{
newpath ox oy moveto
get aload pop pop exch % ... <len> <start>
dup 0 exch % ... <len> <start> 0 <s
5 index 3 1 roll % ... (str) 0 <start>
getinterval % ... <len> <start> (.)
stringwidth pop tht rmoveto
3 index % ... <len> <start> (str)
3 1 roll exch % ... (str) <start> <len>
% dup 3 1 roll
% sub
getinterval stringwidth pop
0 rlineto stroke
dup
}
for
pop pop
ox oy moveto
show
%
% Move origin for next line
%
/oy oy tht sub def
}
for
savematrix setmatrix
end
pop % throw away the "0"
} bind def
%******************************************************************************
% Draw line sequence.
%
/dls {
newpath
moveto
rlineto
gsave
0 color ne { setLineColor }
{ 0 setgray } ifelse
stroke
grestore
} bind def
%******************************************************************************
% Draw line to.
%
/dlt {
newpath
gsave
0 color ne { setLineColor }
{ 0 setgray } ifelse
moveto
} bind def
%******************************************************************************
%
/dslt {
newpath
gsave
0 color ne { setLineColor }
{ 0 setgray } ifelse
moveto
} bind def
%******************************************************************************
%
/dlv {
rlineto
} bind def
%******************************************************************************
%
/dle {
stroke
grestore
} bind def
%******************************************************************************
% Move to.
/mps {
newpath
moveto
} bind def
%******************************************************************************
%
% Draw Box Unfilled
% x1 y1 x2 y2 dbu
%
/dbu {
0 color ne { setLineColor } if
newpath
moveto
dup 0 rlineto
0 3 -1 roll
rlineto
neg 0 rlineto
closepath
stroke
} bind def
%******************************************************************************
%
% Draw Box Filled
% x1 y1 x2 y2 dbf
%
/dbf {
/y2 exch def
/x2 exch def
/y1 exch def
/x1 exch def
newpath
x1 y1 bbmoveto
x2 y1 bblineto
x2 y2 bblineto
x1 y2 bblineto
closepath
gsave
0 color ne { setFillColor } if
clip fillpath grestore
} bind def
%******************************************************************************
% Draw Box Solid
% x1 y1 x2 y2 dsb
%
/dbs {
/y2 exch def
/x2 exch def
/y1 exch def
/x1 exch def
newpath
x1 y1 moveto
x2 y1 lineto
x2 y2 lineto
x1 y2 lineto
closepath
gsave
0 color ne { setFillColor }
{ 0 setgray } ifelse
fill grestore
0 color ne { setLineColor } if stroke
} bind def
%******************************************************************************
% Draw Polygon Begin
% x y dpb
%
/dpb {
newpath bbmoveto
} bind def
%******************************************************************************
% Draw Polygon Unfilled
% x y dpu
%
/dpu {
closepath
gsave
0 color ne { setLineColor } if
stroke
grestore
} bind def
%******************************************************************************
% Draw Polygon Filled
% x y dpf
%
/dpf {
closepath
gsave
0 color ne { setFillColor } if
clip fillpath grestore
} bind def
%******************************************************************************
% Draw Polygon Solid
% x y dps
%
/dps {
closepath
gsave
0 color ne { setFillColor }
{ 0 setgray } ifelse
fill grestore
0 color ne { setLineColor } if stroke
} bind def
%******************************************************************************
% Draw Polygon Vertex
% x y dpv
%
/dpv {
bblineto
} bind def
%******************************************************************************
% Draw Circle Unfilled
% x y radius dcu
%
/dcu {
/radius exch def
/y exch def
/x exch def
newpath
x y radius radius 0 360 ellipse
gsave
0 color ne { setLineColor } if
stroke
grestore
} bind def
%******************************************************************************
% Draw Circle Filled
% x y radius dcs
%
/dcf {
/radius exch def
/y exch def
/x exch def
/minx x radius sub def
/miny y radius sub def
/maxx x radius add def
/maxy y radius add def
newpath
x y radius radius 0 360 ellipse
gsave
0 color ne { setFillColor } if
clip fillpath
grestore
} bind def
%******************************************************************************
% Draw Circle Solid
% x y radius dcs
%
/dcs {
/radius exch def
/y exch def
/x exch def
newpath
x y radius radius 0 360 ellipse
gsave
0 color ne { setFillColor }
{ 0 setgray } ifelse
fill grestore
0 color ne {setLineColor} if stroke
} bind def
%******************************************************************************
% Draw Ellipse Unfilled
% x y xradius yradius deu
%
/delu {
/yradius exch def
/xradius exch def
/y exch def
/x exch def
newpath
x y xradius yradius 0 360 ellipse
gsave
0 color ne { setLineColor } if
stroke
grestore
} bind def
%******************************************************************************
% Draw Ellipse Filled
% x y xradius yradius def
%
/delf {
/yradius exch def
/xradius exch def
/y exch def
/x exch def
/minx x xradius sub def
/miny y yradius sub def
/maxx x xradius add def
/maxy y yradius add def
newpath
x y xradius yradius 0 360 ellipse
gsave
0 color ne { setFillColor } if
clip fillpath
grestore
} bind def
%******************************************************************************
% Draw Ellipse Solid
% x y xradius yradius des
%
/dels {
/yradius exch def
/xradius exch def
/y exch def
/x exch def
newpath
x y xradius yradius 0 360 ellipse
gsave
0 color ne { setFillColor }
{ 0 setgray } ifelse
fill grestore
0 color ne {setLineColor} if stroke
} bind def
%******************************************************************************
% Draw Arc Unfilled
% x y xradius yradius startangle endangle das
%
/dau { newpath ellipse
gsave
0 color ne { setLineColor } if
stroke
grestore
} bind def
%******************************************************************************
% Line Define Code.
%
/setlinedash {
1 index length 11 gt
{exch dup length 11 sub 11 getinterval exch } if
setdash
} bind def
/lpb {
pop
[
/offset 0 def
/offcount 0 def
/oncount 0 def
} bind def
/lpon {
/oncount exch def
pop
oncount
} bind def
/lpoff {
/offcount exch def
pop
oncount 0 eq
{/offset offcount def }
{ offcount } ifelse
} bind def
/lpe {
/linewidth exch def
pop
offset 0 ne
{ offset } if ] 0 setlinedash
linewidth dup 1 eq {pop 0} if setlinewidth
} bind def
/sls { pop } bind def
/ssls { [] 0 setdash
1 setlinewidth
} bind def
%******************************************************************************
% Fill pattern define code.
%
/fillpath {
0 color ne { setFillColor } if
/str 1 string def
/minx minx 66 div
truncate 66 mul def
/miny miny 66 div
truncate 66 mul def
/fillLine maxx minx sub cvi 66 idiv 1 add string def
0 1 fillLine length 1 sub {
fillLine exch fillChar str cvs cvi 48 add put
} for
minx
miny 66 maxy
{ exch dup 3 -1 roll moveto fillLine show
} for pop
hatchSet 1 eq {0 color ne { setLineColor } if stroke} if
} bind def
/fds { pop /currchar 30 def} bind def
/fdf {
exch
/char exch def
/stipple stippleArray char get def
stipple exch currchar
exch putinterval
stippleArray char stipple put
/currchar currchar 2 sub def
} bind def
/fde {
pop
} bind def
/sfp {
/fillChar exch def
/hatchSet 0 def
fillChar 8 ge {/hatchSet 1 def} if
/StippleFont findfont 66 scalefont setfont
} bind def
/setLineColor {
lineRed 1000 div
lineGreen 1000 div
lineBlue 1000 div
setrgbcolor
} bind def
/setFillColor {
fillRed 1000 div
fillGreen 1000 div
fillBlue 1000 div
setrgbcolor
} bind def
/slc {
/lineBlue exch def
/lineGreen exch def
/lineRed exch def
/color 1 def
lineBlue 1000 eq {lineGreen 1000 eq {lineRed 1000 eq {
/lineBlue 0 def
/lineGreen 0 def
/lineRed 0 def
} if} if} if
} bind def
/sfc {
/fillBlue exch def
/fillGreen exch def
/fillRed exch def
/color 1 def
fillBlue 1000 eq {fillGreen 1000 eq {fillRed 1000 eq {
/fillBlue 0 def
/fillGreen 0 def
/fillRed 0 def
} if} if} if
} bind def
%******************************************************************************
%
% End of Cadence ps.prologue