00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "mergeSchema.h"
00024 #include <iostream>
00025 #include <assert.h>
00026
00027 using namespace std;
00028
00029
00035 schema* makeMergeSchema (schema* s1, schema* s2)
00036 {
00037
00038 schema * a = makeEnlargedSchema(s1, dWire);
00039 schema * b = makeEnlargedSchema(s2, dWire);
00040 double hgap = (a->height()+b->height())/4;
00041 return new mergeSchema(a,b,hgap);
00042 }
00043
00044
00050 mergeSchema::mergeSchema (schema* s1, schema* s2, double hgap)
00051 : schema( s1->inputs(),
00052 s2->outputs(),
00053 s1->width() + s2->width() + hgap,
00054 max(s1->height(), s2->height()) ),
00055 fSchema1(s1),
00056 fSchema2(s2),
00057 fHorzGap(hgap)
00058 {
00059 }
00060
00061
00066 void mergeSchema::place(double ox, double oy, int orientation)
00067 {
00068 beginPlace(ox, oy, orientation);
00069
00070 double dy1 = max(0.0, fSchema2->height()-fSchema1->height()) / 2.0;
00071 double dy2 = max(0.0, fSchema1->height()-fSchema2->height()) / 2.0;
00072
00073 if (orientation == kLeftRight) {
00074 fSchema1->place(ox, oy+dy1, orientation);
00075 fSchema2->place(ox+fSchema1->width()+fHorzGap, oy+dy2, orientation);
00076 } else {
00077 fSchema2->place(ox, oy+dy2, orientation);
00078 fSchema1->place(ox+fSchema2->width()+fHorzGap, oy+dy1, orientation);
00079 }
00080 endPlace();
00081 }
00082
00083
00087 point mergeSchema::inputPoint(unsigned int i)
00088 {
00089 return fSchema1->inputPoint(i);
00090 }
00091
00092
00096 point mergeSchema::outputPoint(unsigned int i)
00097 {
00098 return fSchema2->outputPoint(i);
00099 }
00100
00101
00105 void mergeSchema::draw(device& dev)
00106 {
00107 assert(placed());
00108
00109
00110 fSchema1->draw(dev);
00111 fSchema2->draw(dev);
00112
00113 unsigned int r = fSchema2->inputs();
00114 assert(r>0);
00115
00116
00117 for (unsigned int i=0; i<fSchema1->outputs(); i++) {
00118 point p = fSchema1->outputPoint(i);
00119 point q = fSchema2->inputPoint(i%r);
00120 dev.trait(p.x, p.y, q.x, q.y);
00121 }
00122 }
00123
00124