1 /* 2 PADRING -- a padring generator for ASICs. 3 4 Copyright (c) 2019, Niels Moseley <niels@symbioticeda.com> 5 6 Permission to use, copy, modify, and/or distribute this software for any 7 purpose with or without fee is hereby granted, provided that the above 8 copyright notice and this permission notice appear in all copies. 9 10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 18 */ 19 20 #ifndef defwriter_h 21 #define defwriter_h 22 23 #include <stdio.h> 24 #include <stdint.h> 25 #include <complex> 26 #include <string> 27 #include <sstream> 28 29 #include "layout.h" 30 31 /** a very minimal SVG writer */ 32 class DEFWriter 33 { 34 public: 35 DEFWriter(std::ostream &os, uint32_t width, uint32_t height); 36 virtual ~DEFWriter(); 37 38 void writeCell(const LayoutItem *item); 39 setDatabaseUnits(double databaseUnits)40 void setDatabaseUnits(double databaseUnits) 41 { 42 m_databaseUnits = databaseUnits; 43 } 44 setDesignName(const std::string & designName)45 void setDesignName(const std::string &designName) 46 { 47 m_designName = designName; 48 } 49 50 protected: 51 52 /** convert to DEF database units / coordinates. 53 this function will issue a warning when 54 m_databaseUnits has not been set and set it 55 to 1000. 56 */ 57 void toDEFCoordinates(double &x, double &y); 58 59 void writeToFile(); 60 61 std::stringstream m_ss; 62 std::string m_designName; 63 std::ostream &m_def; 64 65 uint32_t m_width; 66 uint32_t m_height; 67 uint32_t m_cellCount; 68 double m_databaseUnits; 69 }; 70 71 #endif