void TestProxySerialization() { filesystem::FileSystem filesystem; auto tempFile = filesystem.GetTempPath() / filesystem.UniquePath(); TestProxyConfig<bool, std::string> config1( [](const std::string& v) { return v == "yes"; }, [](bool v) { return v ? std::string("yes") : std::string("no"); }, true); { JsonOutputArchive ar(tempFile.ToShortString()); ar.Serialize(config1, L"config"); } TestProxyConfig<bool, std::string> config2( [](const std::string& v) { return v == "yes"; }, [](bool v) { return v ? std::string("yes") : std::string("no"); }); { JsonInputArchive ar(tempFile.ToShortString()); ar.Serialize(config2, L"config"); } TS_ASSERT_EQUALS(config1.GetValue(), config2.GetValue()); filesystem.Remove(tempFile); }
void TestStringSerialization() { filesystem::FileSystem filesystem; auto tempFile = filesystem.GetTempPath() / filesystem.UniquePath(); TestConfig<std::string> config1("hello"); TestConfig<std::wstring> configW1(L"whello"); { JsonOutputArchive ar(tempFile.ToShortString()); ar.Serialize(config1, L"config"); ar.Serialize(configW1, L"configw"); } TestConfig<std::string> config2("hello"); TestConfig<std::wstring> configW2(L"whello"); { JsonInputArchive ar(tempFile.ToShortString()); ar.Serialize(config2, L"config"); ar.Serialize(configW2, L"configw"); } TS_ASSERT_EQUALS(config1.GetValue(), config2.GetValue()); TS_ASSERT_EQUALS(configW1.GetValue(), configW2.GetValue()); filesystem.Remove(tempFile); }
/** * @function SegmentFeasible * @brief Check if the segment between these two configurations is collision-free */ bool MyFeasibilityChecker::SegmentFeasible( const Vector & a, const Vector & b ) { Eigen::VectorXd config1(ndim), config2(ndim); for( int i = 0; i < ndim; i++ ) { config1(i) = a[i]; config2(i) = b[i]; } int n = (int)( (config2 - config1).norm() / stepsize ); for(int i = 0; i < n; i++) { Eigen::VectorXd conf = (double)(n - i)/(double)n * config1 + (double)(i)/(double)n * config2; world->robots[robot]->setConf(links, conf, true); if(world->checkCollisions()) { return false; } } return true; }
void TestBoolSerialization() { filesystem::FileSystem filesystem; auto tempFile = filesystem.GetTempPath() / filesystem.UniquePath(); TestConfig<bool> config1(true); { JsonOutputArchive ar(tempFile.ToShortString()); ar.Serialize(config1, L"config"); } TestConfig<bool> config2; { JsonInputArchive ar(tempFile.ToShortString()); ar.Serialize(config2, L"config"); } TS_ASSERT_EQUALS(config1.GetValue(), config2.GetValue()); filesystem.Remove(tempFile); }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1) return -1; m_wndClientArea.ModifyStyleEx(WS_EX_CLIENTEDGE, 0); // create a view to occupy the client area of the frame //if (!m_wndView.Create(IDD_ABOUTBOX, this)) //m_wndView.Create(GetSafeHwnd(), CRect(10,300,100,330), _T("My button"), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, NULL, 2); //if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL)) //{ // TRACE0("Failed to create view window\n"); // return -1; //} // set the visual manager and style based on persisted value OnApplicationLook(theApp.m_nAppLook); //// create a view to occupy the client area of the frame //if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL)) //{ // TRACE0("Failed to create view window\n"); // return -1; //} boost::filesystem::path iniPath; GetIniPath(iniPath); CComPtr<IConfig> ini = CreateIConfig(AMT_INI, iniPath); CString config1( ini->Get(g_szConfigSection, RepLabel1, _T("0")) ); CString config2( ini->Get(g_szConfigSection, RepLabel2, _T("1")) ); m_splitter.Create(m_hWndMDIClient, ATL::CWindow::rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN); m_repositoryDlg.Create(m_splitter); //m_detailSheetView.SetReflectNotifications(true); m_detailSheetView.SetTabStyles(CTCS_BOTTOM | CTCS_TOOLTIPS); m_detailSheetView.Create(m_splitter, ATL::CWindow::rcDefault); //m_detailView.SetFont(WTL::AtlGetDefaultGuiFont()); m_sourceEclView.Create(m_detailSheetView, ATL::CWindow::rcDefault); m_sourceEclView.DoInit(); m_sourceEclView.SetReadOnly(true); //TODO: InitEclCommandMixin(this, this, &m_sourceEclView, this); m_detailSheetView.AddTab(m_sourceEclView, _T("Source ECL")); m_diffView.Create(m_detailSheetView, ATL::CWindow::rcDefault, _T(""), WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WS_EX_CLIENTEDGE); m_detailSheetView.AddTab(m_diffView, _T("Differences")); m_targetEclView.Create(m_detailSheetView, ATL::CWindow::rcDefault); m_targetEclView.DoInit(); m_targetEclView.SetReadOnly(true); //TODO: InitEclCommandMixin(this, this, &m_targetEclView, this); m_detailSheetView.AddTab(m_targetEclView, _T("Target ECL")); m_dependees.Create(m_detailSheetView, ATL::CWindow::rcDefault, NULL, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WS_EX_CLIENTEDGE); m_dependees.SetFont(WTL::AtlGetDefaultGuiFont()); m_detailSheetView.AddTab(m_dependees, _T("Dependee Check")); m_logView.Create(m_detailSheetView, ATL::CWindow::rcDefault, NULL, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VSCROLL | LBS_NOINTEGRALHEIGHT, WS_EX_CLIENTEDGE); m_logView.SetFont(WTL::AtlGetDefaultGuiFont()); m_detailSheetView.AddTab(m_logView, _T("Log")); WTL::CEdit edit; edit.Create(m_detailSheetView, ATL::CWindow::rcDefault, NULL, ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_HSCROLL | WS_VSCROLL, WS_EX_CLIENTEDGE); CString face = _T("MS Shell Dlg"); int nPointSize = 8; WTL::CFont font; WTL::CLogFont logFont; logFont.lfCharSet = DEFAULT_CHARSET; logFont.lfHeight = nPointSize*10; ::_tcsncpy(logFont.lfFaceName, face, LF_FACESIZE); logFont.lfWeight = FW_LIGHT; logFont.lfQuality = PROOF_QUALITY; logFont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; logFont.lfOutPrecision = OUT_TT_PRECIS; if ( font.CreatePointFontIndirect(&logFont,0) ) { edit.SetFont(font.Detach(),false); } m_warnView.SetEditCtrl(edit.Detach()); m_detailSheetView.AddTab(m_warnView, _T("Warnings")); m_detailSheetView.GetTabCtrl().SetCurSel(1); m_splitter.SetSplitterPanes(m_repositoryDlg, m_detailSheetView); m_splitter.SetSplitterPosPct(50); m_wndRibbonBar.Create(this); InitializeRibbon(); if (!m_wndStatusBar.Create(this)) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } m_wndStatusBar.AddElement(new CMFCRibbonStatusBarPane(ID_STATUSBAR_PANE1, _T(""), TRUE), _T("")); m_wndStatusBar.AddExtendedElement(new CMFCRibbonStatusBarPane(ID_STATUSBAR_PANE2, _T(""), TRUE), _T("")); CMFCRibbonProgressBar * elem = new CMFCRibbonProgressBar(ID_STATUSBAR_PANE3); m_wndStatusBar.AddExtendedElement(elem, _T("Progress")); elem->SetRange(1, 1); elem->SetPos(0); // enable Visual Studio 2005 style docking window behavior CDockingManager::SetDockingMode(DT_SMART); // enable Visual Studio 2005 style docking window auto-hide behavior EnableAutoHidePanes(CBRS_ALIGN_ANY); // Enable enhanced windows management dialog //EnableWindowsDialog(ID_WINDOW_MANAGER, IDS_WINDOWS_MANAGER, TRUE); HICON newIcon = LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME_AMT)); HICON oldIcon = SetIcon(newIcon, false); HICON oldIcon2 = SetIcon(newIcon, true); RecalcLayout(); if ( !m_bStreamInit ) { m_pOldBuf = std::cerr.rdbuf(&m_EditStrBuf); m_pOldBufW = std::wcerr.rdbuf(&m_EditStrBufW); m_bStreamInit = true; } PostMessage(UM_INITIALIZE); return 0; }
void IMU::Initiate() { XsPortInfoArray portInfoArray; xsEnumerateUsbDevices(portInfoArray); if (!portInfoArray.size()) { #ifdef PLATFORM_IS_WINDOWS throw std::runtime_error("IMU: failed to find IMU sensor"); #endif #ifdef PLATFORM_IS_LINUX XsPortInfo portInfo(pDevice->port, XsBaud::numericToRate(pDevice->baudRate)); portInfoArray.push_back(portInfo); #endif } pDevice->mtPort = portInfoArray.at(0); // Open the port with the detected device if (!pDevice->openPort(pDevice->mtPort)) throw std::runtime_error("IMU: could not open port."); Aris::Core::Sleep(10); // Put the device in configuration mode if (!pDevice->gotoConfig()) // Put the device into configuration mode before configuring the device { throw std::runtime_error("IMU: could not put device into configuration mode"); } // Request the device Id to check the device type pDevice->mtPort.setDeviceId(pDevice->getDeviceId()); // Check if we have an MTi / MTx / MTmk4 device if (!pDevice->mtPort.deviceId().isMtMk4()) { throw std::runtime_error("IMU: No MTi / MTx / MTmk4 device found."); } // Check device type if (pDevice->mtPort.deviceId().isMtMk4()) { XsOutputConfiguration config0(XDI_Quaternion, pDevice->sampleRate); XsOutputConfiguration config1(XDI_DeltaQ, pDevice->sampleRate); XsOutputConfiguration config2(XDI_DeltaV, pDevice->sampleRate); XsOutputConfiguration config3(XDI_Acceleration, pDevice->sampleRate); XsOutputConfigurationArray configArray; configArray.push_back(config0); configArray.push_back(config1); configArray.push_back(config2); configArray.push_back(config3); if (!pDevice->setOutputConfiguration(configArray)) { throw std::runtime_error("IMU: Could not configure MTmk4 pDevice-> Aborting."); } } else { throw std::runtime_error("IMU: Unknown device while configuring. Aborting."); } // Put the device in measurement mode if (!pDevice->gotoMeasurement()) { throw std::runtime_error("IMU: Could not put device into measurement mode. Aborting."); } }
Device* config(void) { int c, m; Device *d; char *icp; if(f.error) return devnone; d = malloc(sizeof(Device)); c = *f.charp++; switch(c) { default: cdiag("unknown type", c); return devnone; case '(': /* (d+) one or multiple cat */ case '[': /* [d+] one or multiple interleave */ case '{': /* {d+} a mirrored device and optional mirrors */ return config1(c); case 'f': /* fd fake worm */ d->type = Devfworm; d->fw.fw = config(); break; case 'n': d->type = Devnone; break; case 'w': /* w[#.]#[.#] wren [ctrl] unit [lun] */ case 'r': /* r# worm side */ case 'l': /* l# labelled-worm side */ icp = f.charp; d->type = Devwren; d->wren.ctrl = 0; d->wren.targ = cnumb(); d->wren.lun = 0; m = *f.charp; if(m == '.') { f.charp++; d->wren.lun = cnumb(); m = *f.charp; if(m == '.') { f.charp++; d->wren.ctrl = d->wren.targ; d->wren.targ = d->wren.lun; d->wren.lun = cnumb(); } } if(f.nextiter >= 0) f.charp = icp-1; if(c == 'r') /* worms are virtual and not uniqued */ d->type = Devworm; else if(c == 'l') d->type = Devlworm; else map(d); /* subject wrens to optional mapping */ break; case 'o': /* o ro part of last cw */ if(f.lastcw == 0) { cdiag("no cw to match", c); return devnone; } return f.lastcw->cw.ro; case 'j': /* DD jukebox */ d->type = Devjuke; d->j.j = config(); d->j.m = config(); break; case 'c': /* cache/worm */ d->type = Devcw; d->cw.c = config(); d->cw.w = config(); d->cw.ro = malloc(sizeof(Device)); d->cw.ro->type = Devro; d->cw.ro->ro.parent = d; f.lastcw = d; break; case 'p': /* pd#.# partition base% size% */ d->type = Devpart; d->part.d = config(); d->part.base = cnumb(); c = *f.charp++; if(c != '.') cdiag("dot expected", c); d->part.size = cnumb(); break; case 'x': /* xD swab a device's metadata */ d->type = Devswab; d->swab.d = config(); break; } d->dlink = f.devlist; f.devlist = d; return d; }
int main() { typedef boost::mt19937 rng_type; typedef std::vector<unsigned int> vector_type; rng_type rng(seed); boost::variate_generator<rng_type&, boost::uniform_real<> > random(rng, boost::uniform_real<>(0, 1)); std::cout << "[[random permutaion test 1]]\n"; std::cout << "generating " << trial1 << " random permutations of " << n << " integers [0..." << n - 1 << "]\n"; for (unsigned int i = 0; i < trial1; ++i) { vector_type result(n); for (unsigned int j = 0; j < n; ++j) result[j] = j; looper::random_shuffle(result.begin(), result.end(), random); for (unsigned int j = 0; j < n; ++j) { std::cout << result[j] << '\t'; } std::cout << std::endl; } std::cout << "\n[[random permutaion test 2 (with restrictions)]]\n"; std::cout << "generating " << trial2 << " partitioned random permutations\n"; for (unsigned int t = 0; t < trial2; t++) { vector_type config0(n); for (unsigned int i = 0; i < n; i++) { config0[i] = 2 * random(); } vector_type config1(config0); looper::random_shuffle(config1.begin(), config1.end(), random); std::cout << "conf0"; for (unsigned int i = 0; i < n; i++) std::cout << '\t' << config0[i]; std::cout << std::endl; std::cout << "conf1"; for (unsigned int i = 0; i < n; i++) std::cout << '\t' << config1[i]; std::cout << std::endl; vector_type result(n); for (unsigned int j = 0; j < n; ++j) result[j] = j; // generate partitioned permutation looper::partitioned_random_shuffle(result.begin(), result.end(), config0.begin(), config1.begin(), random); std::cout << "perm"; for (unsigned int i = 0; i < n; i++) std::cout << '\t' << result[i]; std::cout << std::endl; std::cout << "check"; int chk = 0; for (unsigned int i = 0; i < n; i++) { std::cout << '\t' << (config0[i] ^ config1[result[i]]); chk += (config0[i] ^ config1[result[i]]); } std::cout << std::endl; if (chk > 0) { std::cout << "Error occurs! Stop.\n"; std::exit(-1); } std::cout << std::endl; } }
configure() { config1() ; xshift = 0 ; yshift = 0 ; zxshift = 0 ; zyshift = 0 ; for( pad = numcells + 1 ; pad <= numcells + numterms ; pad++ ) { if( carray[pad]->padside == B ) { count = 1 ; height = carray[pad]->tileptr->top - carray[pad]->tileptr->bottom ; width = carray[pad]->tileptr->right - carray[pad]->tileptr->left ; for( pad++ ; pad <= numcells + numterms ; pad++ ) { if( carray[pad]->padside != B ) { break ; } count++ ; if( carray[pad]->tileptr->top - carray[pad]->tileptr->bottom > height ) { height = carray[pad]->tileptr->top - carray[pad]->tileptr->bottom ; } width += carray[pad]->tileptr->right - carray[pad]->tileptr->left ; } maxHeight = height ; if( fixLRBT[2] == 0 ) { space = coreWidth - width ; separation = space / (count + 1) ; if( separation < 0 ) { separation = 0 ; zxshift = ABS( space ) ; } } else { space = ( coreWidth >= width ) ? coreWidth : width ; } /* * Shift all rows up by maxHeight + extraSpace */ yshift = maxHeight + extraSpace ; for( row = 1 ; row <= numRows ; row++ ) { rowArray[row].ypos += yshift ; } for( pad = numcells + 1; pad <= numcells + numterms; pad++){ if( carray[pad]->padside == B ) { height = carray[pad]->tileptr->top - carray[pad]->tileptr->bottom ; width = carray[pad]->tileptr->right - carray[pad]->tileptr->left ; if( fixLRBT[2] == 0 ) { carray[pad]->cxcenter = separation + width / 2 ; } else { carray[pad]->cxcenter = padspace[ pad - numcells ] * space ; } carray[pad]->cycenter = maxHeight - height / 2 - 1 ; last = separation + width ; for( pad++ ; pad <= numcells + numterms ; pad++ ) { if( carray[pad]->padside != B ) { break ; } height = carray[pad]->tileptr->top - carray[pad]->tileptr->bottom ; width = carray[pad]->tileptr->right - carray[pad]->tileptr->left ; if( fixLRBT[2] == 0 ) { carray[pad]->cxcenter = last + separation + width / 2 ; } else { carray[pad]->cxcenter = padspace[ pad - numcells ] * space ; } carray[pad]->cycenter = maxHeight - height / 2 - 1 ; last += separation + width ; } } } } } for( pad = numcells + 1 ; pad <= numcells + numterms ; pad++ ) { if( carray[pad]->padside == T ) { count = 1 ; width = carray[pad]->tileptr->right - carray[pad]->tileptr->left ; for( pad++ ; pad <= numcells + numterms ; pad++ ) { if( carray[pad]->padside != T ) { break ; } count++ ; width += carray[pad]->tileptr->right - carray[pad]->tileptr->left ; } if( fixLRBT[3] == 0 ) { space = coreWidth - width ; separation = space / (count + 1) ; if( separation < 0 ) { separation = 0 ; if( ABS( space ) > zxshift ) { zxshift = ABS( space ) ; } } } else { space = (coreWidth >= width ) ? coreWidth : width ; } /* * Keep all pads above rowArray[numRows].ypos + * rowHeight/2 + extraSpace + mttshift */ coreTop = rowArray[numRows].ypos + rowHeight / 2 + extraSpace + mttshift ; for( pad = numcells + 1; pad <= numcells + numterms; pad++){ if( carray[pad]->padside == T ) { height = carray[pad]->tileptr->top - carray[pad]->tileptr->bottom ; width = carray[pad]->tileptr->right - carray[pad]->tileptr->left ; if( fixLRBT[3] == 0 ) { carray[pad]->cxcenter = separation + width / 2 ; } else { carray[pad]->cxcenter = padspace[ pad - numcells ] * space ; } carray[pad]->cycenter = coreTop + height / 2 ; last = separation + width ; for( pad++ ; pad <= numcells + numterms ; pad++ ) { if( carray[pad]->padside != T ) { break ; } height = carray[pad]->tileptr->top - carray[pad]->tileptr->bottom ; width = carray[pad]->tileptr->right - carray[pad]->tileptr->left ; if( fixLRBT[3] == 0 ) { carray[pad]->cxcenter = last + separation + width / 2 ; } else { carray[pad]->cxcenter = padspace[ pad - numcells ] * space ; } carray[pad]->cycenter = coreTop + height / 2 ; last += separation + width ; } } } } } for( pad = numcells + 1 ; pad <= numcells + numterms ; pad++ ) { if( carray[pad]->padside == L ) { count = 1 ; height = carray[pad]->tileptr->top - carray[pad]->tileptr->bottom ; width = carray[pad]->tileptr->right - carray[pad]->tileptr->left ; for( pad++ ; pad <= numcells + numterms ; pad++ ) { if( carray[pad]->padside != L ) { break ; } count++ ; if( carray[pad]->tileptr->right - carray[pad]->tileptr->left > width ) { width = carray[pad]->tileptr->right - carray[pad]->tileptr->left ; } height += carray[pad]->tileptr->top - carray[pad]->tileptr->bottom ; } maxWidth = width ; if( fixLRBT[0] == 0 ) { space = coreHeight - height ; separation = space / (count + 1) ; if( separation < 0 ) { separation = 0 ; zyshift = ABS( space ) ; } } else { space = (coreHeight >= height ) ? coreHeight : height ; } /* * Shift all rows rite by maxWidth + extraSpace */ xshift = maxWidth + extraSpace ; for( row = 1 ; row <= numRows ; row++ ) { rowArray[row].startx += xshift ; rowArray[row].endx += xshift ; if( rowArray[row].endx1 > 0 ) { rowArray[row].endx1 += xshift ; rowArray[row].startx2 += xshift ; } } for( pad = numcells + 1; pad <= numcells + numterms; pad++){ if( carray[pad]->padside == L ) { height = carray[pad]->tileptr->top - carray[pad]->tileptr->bottom ; width = carray[pad]->tileptr->right - carray[pad]->tileptr->left ; if( fixLRBT[0] == 0 ) { carray[pad]->cycenter = rowArray[1].ypos - rowHeight / 2 + separation + height / 2 - mbbshift ; } else { carray[pad]->cycenter = rowArray[1].ypos - rowHeight / 2 - mbbshift + padspace[ pad - numcells ] * space ; } carray[pad]->cxcenter = maxWidth - width / 2 - 1 ; last = rowArray[1].ypos - rowHeight / 2 + separation + height - mbbshift ; for( pad++ ; pad <= numcells + numterms ; pad++ ) { if( carray[pad]->padside != L ) { break ; } height = carray[pad]->tileptr->top - carray[pad]->tileptr->bottom ; width = carray[pad]->tileptr->right - carray[pad]->tileptr->left ; if( fixLRBT[0] == 0 ) { carray[pad]->cycenter = last + separation + height / 2 ; } else { carray[pad]->cycenter = rowArray[1].ypos - rowHeight / 2 - mbbshift + padspace[ pad - numcells ] * space ; } carray[pad]->cxcenter = maxWidth - width / 2 - 1 ; last += separation + height ; } } } } } for( pad = numcells + 1 ; pad <= numcells + numterms ; pad++ ) { if( carray[pad]->padside == R ) { count = 1 ; height = carray[pad]->tileptr->top - carray[pad]->tileptr->bottom ; for( pad++ ; pad <= numcells + numterms ; pad++ ) { if( carray[pad]->padside != R ) { break ; } count++ ; height += carray[pad]->tileptr->top - carray[pad]->tileptr->bottom ; } if( fixLRBT[1] == 0 ) { space = coreHeight - height ; separation = space / (count + 1) ; if( separation < 0 ) { separation = 0 ; if( ABS( space ) > zyshift ) { zyshift = ABS( space ) ; } } } else { space = (coreHeight >= height) ? coreHeight : height ; } coreRite = coreWidth + xshift + extraSpace ; for( pad = numcells + 1; pad <= numcells + numterms; pad++){ if( carray[pad]->padside == R ) { height = carray[pad]->tileptr->top - carray[pad]->tileptr->bottom ; width = carray[pad]->tileptr->right - carray[pad]->tileptr->left ; if( fixLRBT[1] == 0 ) { carray[pad]->cycenter = rowArray[1].ypos - rowHeight / 2 + separation + height / 2 - mbbshift ; } else { carray[pad]->cycenter = rowArray[1].ypos - rowHeight / 2 - mbbshift + padspace[ pad - numcells ] * space ; } carray[pad]->cxcenter = coreRite + width / 2 ; last = rowArray[1].ypos - rowHeight / 2 + separation + height - mbbshift ; for( pad++ ; pad <= numcells + numterms ; pad++ ) { if( carray[pad]->padside != R ) { break ; } height = carray[pad]->tileptr->top - carray[pad]->tileptr->bottom ; width = carray[pad]->tileptr->right - carray[pad]->tileptr->left ; if( fixLRBT[1] == 0 ) { carray[pad]->cycenter = last + separation + height / 2 ; } else { carray[pad]->cycenter = rowArray[1].ypos - rowHeight / 2 - mbbshift + padspace[ pad - numcells ] * space ; } carray[pad]->cxcenter = coreRite + width / 2 ; last += separation + height ; } } } } } /* * Now its time to shift the macro blocks by the same amount * the rows were shifted above during pad placement */ for( macro = 1 ; macro <= numMacro ; macro++ ) { pad = padArray[macro] ; carray[pad]->cxcenter = macroArray[macro].mx + xshift ; carray[pad]->cycenter = macroArray[macro].my + yshift + mbbshift ; } for( pad = numcells + 1 ; pad <= numcells + numterms ; pad++ ) { if( carray[pad]->padside == B || carray[pad]->padside == T ) { carray[pad]->cxcenter += xshift ; } else if( carray[pad]->padside == MTT || carray[pad]->padside == MBB ) { carray[pad]->cxcenter += xshift ; carray[pad]->cycenter += yshift ; } } /* * Shift all rows rite by zxshift / 2 ( center the core * for pad limited cases ) */ for( row = 1 ; row <= numRows ; row++ ) { rowArray[row].startx += zxshift / 2 ; rowArray[row].endx += zxshift / 2 ; if( rowArray[row].endx1 > 0 ) { rowArray[row].endx1 += zxshift / 2 ; rowArray[row].startx2 += zxshift / 2 ; } } for( macro = 1 ; macro <= numMacro ; macro++ ) { pad = padArray[macro] ; carray[pad]->cxcenter += zxshift / 2 ; } for( pad = numcells + 1 ; pad <= numcells + numterms ; pad++ ) { if( carray[pad]->padside == R ) { carray[pad]->cxcenter += zxshift ; } else if( carray[pad]->padside == MTT || carray[pad]->padside == MBB ) { carray[pad]->cxcenter += zxshift / 2 ; } } /* * Shift all rows up by zyshift / 2 ( center the core for * pad limited cases ) */ yshift = maxHeight + rowHeight + extraSpace ; for( row = 1 ; row <= numRows ; row++ ) { rowArray[row].ypos += zyshift / 2 ; } for( macro = 1 ; macro <= numMacro ; macro++ ) { pad = padArray[macro] ; carray[pad]->cycenter += zyshift / 2 ; } for( pad = numcells + 1 ; pad <= numcells + numterms ; pad++ ) { if( carray[pad]->padside == T ) { carray[pad]->cycenter += zyshift ; } else if( carray[pad]->padside == MTT || carray[pad]->padside == MBB ) { carray[pad]->cycenter += zyshift / 2 ; } } /* * Now its time to blast away the old barray and * generate the new one. */ /* * Find the number of blocks */ block = 0 ; for( row = 1 ; row <= numRows ; row++ ) { block++ ; if( rowArray[row].endx1 > 0 ) { block++ ; } } totalBlock = block ; oldbarray = barray ; blkToRow = (int *) safe_malloc( (totalBlock + 1) * sizeof(int) ) ; barray = (BBOXPTR *) safe_malloc( (totalBlock + 1) * sizeof(BBOXPTR) ) ; for( block = 1 ; block <= totalBlock ; block++ ) { barray[block] = (BBOXPTR) safe_malloc( sizeof(BBOX) ) ; } block = 0 ; for( row = 1 ; row <= numRows ; row++ ) { boxptr = oldbarray[row] ; if( rowArray[row].endx1 > 0 ) { block++ ; blkToRow[block] = row ; barray[block]->bxcenter = (rowArray[row].startx + rowArray[row].endx1 ) / 2 ; barray[block]->bycenter = rowArray[row].ypos ; barray[block]->bleft = rowArray[row].startx - barray[block]->bxcenter ; barray[block]->bright = rowArray[row].endx1 - barray[block]->bxcenter ; barray[block]->bbottom = boxptr->bbottom ; barray[block]->btop = boxptr->btop ; barray[block]->bheight = boxptr->btop - boxptr->bbottom ; barray[block]->blength = rowArray[row].endx1 - rowArray[row].startx ; barray[block]->bclass = boxptr->bclass ; barray[block]->borient = boxptr->borient ; barray[block]->oldsize = 0 ; block++ ; blkToRow[block] = row ; barray[block]->bxcenter = (rowArray[row].startx2 + rowArray[row].endx ) / 2 ; barray[block]->bycenter = rowArray[row].ypos ; barray[block]->bleft = rowArray[row].startx2 - barray[block]->bxcenter ; barray[block]->bright = rowArray[row].endx - barray[block]->bxcenter ; barray[block]->bbottom = boxptr->bbottom ; barray[block]->btop = boxptr->btop ; barray[block]->bheight = boxptr->btop - boxptr->bbottom ; barray[block]->blength = rowArray[row].endx - rowArray[row].startx2 ; barray[block]->bclass = boxptr->bclass ; barray[block]->borient = boxptr->borient ; ratio = (double) barray[block - 1]->blength / (double) (barray[block - 1]->blength + barray[block]->blength) ; barray[block]->desire = 1 + (int)((1.0 - ratio) * rowArray[row].desiredL) ; barray[block - 1]->desire = 1 + (int)(ratio * rowArray[row].desiredL) ; barray[block]->oldsize = 0 ; } else { block++ ; blkToRow[block] = row ; barray[block]->bxcenter = (rowArray[row].startx + rowArray[row].endx ) / 2 ; barray[block]->bycenter = rowArray[row].ypos ; barray[block]->bleft = rowArray[row].startx - barray[block]->bxcenter ; barray[block]->bright = rowArray[row].endx - barray[block]->bxcenter ; barray[block]->bbottom = boxptr->bbottom ; barray[block]->btop = boxptr->btop ; barray[block]->bheight = boxptr->btop - boxptr->bbottom ; barray[block]->blength = rowArray[row].endx - rowArray[row].startx ; barray[block]->bclass = boxptr->bclass ; barray[block]->borient = boxptr->borient ; barray[block]->desire = rowArray[row].desiredL ; barray[block]->oldsize = 0 ; } } /* * Now blow array the old block array, rowArray, macroArray */ for( row = 1 ; row <= numblock ; row++ ) { safe_free( oldbarray[row] ) ; } safe_free( oldbarray ) ; numblock = totalBlock ; fprintf(fpo,"\n******************\nBLOCK DATA\n"); desiredL = 0 ; for( block = 1 ; block <= numblock ; block++ ) { desiredL += barray[block]->desire ; fprintf(fpo,"block:%d desire:%d\n",block,barray[block]->desire); /* barray[block]->bright += 0.10 * barray[block]->blength ; barray[block]->blength += 0.10 * barray[block]->blength ; */ } fprintf(fpo,"Total Desired Length: %d\n", desiredL ) ; ckt_size_factor = (double) desiredL ; /* * And now, folks, its time for cell placement, that is, * real random cell placement */ filledTo = (int *) safe_malloc( (numblock + 1) * sizeof( int ) ) ; endRow = (int *) safe_malloc( (numblock + 1) * sizeof( int ) ) ; for( row = 1 ; row <= numblock ; row++ ) { filledTo[row] = barray[row]->bxcenter + barray[row]->bleft ; endRow[row] = barray[row]->bxcenter + barray[row]->bright ; } /* * On first pass, place the cells with specific block assignments */ for( cell = 1 ; cell <= numcells ; cell++ ) { cellptr = carray[cell] ; row = cellptr->cblock ; if( row == 0 ) { continue ; } blk = RtoB( row , cellptr->cycenter ) ; borient = barray[blk]->borient ; cellptr->cblock = blk ; width = cellptr->tileptr->right - cellptr->tileptr->left ; if( cellptr->cycenter > 0 ) { carray[cell]->cxcenter = barray[blk]->bxcenter + barray[blk]->bleft + cellptr->cxcenter + width / 2 ; carray[cell]->cycenter = barray[blk]->bycenter ; } else { carray[cell]->cxcenter = barray[blk]->bxcenter + barray[blk]->bright + cellptr->cxcenter - (width - width / 2) ; carray[cell]->cycenter = barray[blk]->bycenter ; } if( borient == 2 ) { cellptr->corient = 1 ; } else { /* borient was 1 */ cellptr->corient = 0 ; } } /* * Final pass, place all unassigned cells */ for( cell = 1 ; cell <= numcells ; cell++ ) { if( carray[cell]->cblock != 0 ) { continue ; } /* * cute strategy: place cell in the most empty row */ empty = -32000 ; for( row = 1 ; row <= numblock ; row++ ) { if( endRow[row] - filledTo[row] > empty ) { empty = endRow[row] - filledTo[row] ; block = row ; } } borient = barray[block]->borient ; width = carray[cell]->tileptr->right - carray[cell]->tileptr->left ; carray[cell]->cblock = block ; if( borient > 0 ) { carray[cell]->cxcenter = filledTo[block] + width / 2 ; carray[cell]->cycenter = barray[block]->bycenter ; if( borient == 2 ) { carray[cell]->corient = 1 ; } else { /* borient was 1 */ carray[cell]->corient = 0 ; } } else { carray[cell]->cycenter = filledTo[block] + width / 2 ; carray[cell]->cxcenter = barray[block]->bxcenter ; if( borient == -2 ) { carray[cell]->corient = 4 ; } else { /* borient was -1 */ carray[cell]->corient = 7 ; } } filledTo[block] += width ; } /* * Ah ha, done */ return ; }