📄 floorplan.h
字号:
/* File: Floorplan.h * Author: Dan Gibson * ECE 556 HW 3 * Contents: * Class Floorplan, representing a circuit * floorplan, and vital member functions * * Last modified: * Development platforms: Solaris 9, MS-DOS, WINNT * Intended platforms: Solaris 9 */#ifndef __FLOORPLAN_GIBSON__#define __FLOORPLAN_GIBSON__#ifndef NULL#define NULL 0x00000000#endif/* Class: FloorplanObject * Author: Dan Gibson * ECE 556 HW 3 * * Global Instances: * * Public Methods: * type - one of {Operator|Operand} * * Public Data members: * * Private Methods: * * Private Data members: * * Notes: * Modules and Operands are derived from this object * type * */
class Rect {
public:
Rect();
int x;
int y;
Rect * myNext;
};/* Class: Module * Author: Dan Gibson * ECE 556 HW 3 * * Global Instances: * * Public Methods: * * GenerateList() Do a post-order traversal to generate * the linked-list from the tree * * Public Data members: * * unsigned int index - Name of the module, or V/H for operators * unsigned short height - Module height * unsigned short width - Module width * * Module * next - ptr to next module or operator in list * Module * prev - ptr to prev module or operator in list * * NodeType myType - flags a node as operator or module * * Private Methods: * * Private Data members: * */enum NodeType {ModuleType,OperatorType};class Module { public: Module(); ~Module(); unsigned int myIndex; unsigned short myHeight; unsigned short myWidth; Module *myNext, *myPrev; NodeType myType; Module * GenerateListForward(Module * next); Module * FindModuleWithIndex(unsigned int index); Module * FindNthModule(unsigned int index, unsigned int current); Module * FindParent(); Module * Clone();
bool M3OK(bool v_found, bool h_found);
// cost-related functions
Rect * getRectangles();
// old cost functions// unsigned short getHeight();// unsigned short getWidth(); void dumpTree(); void dumpList();};class ModuleStack {public: ModuleStack(unsigned int nCapacity); ~ModuleStack(); void push(Module * mod); Module * pop();private: int * array; unsigned int tos; // points to next open spot unsigned int size;};/* Class: Operator * Author: Dan Gibson * ECE 556 HW 3 * * Global Instances: * * Public Methods: * * Public Data members: * * char op * * Private Methods: * * Private Data members: * */class Operator : public Module {public: Operator(); ~Operator(); Module * myLeftChild; Module * myRightChild; Module * GenerateListForward(Module * next); void GenerateTree(ModuleStack * stack); bool M3OK(bool v_found, bool h_found); Operator * Clone(); void dumpTree(); void dumpList();
Rect * getRectangles();
// old cost functions// unsigned short getHeight();// unsigned short getWidth();};/* Class: Floorplan * Author: Dan Gibson * ECE 556 HW 3 * * Global Instances: * * Public Methods: * * Constructor: * Floorplan() Default constructor (do not call) (debug only) * * Floorplan(int x6) * Creates an initial floorplan, the information * On the first two modules must be given * * AddModule() Adds a module to the floorplan * * Clone() Returns an exact copy of the current solution * * Public Data members: * * Private Methods: * * Private Data members: * Module * modules; * */class Floorplan {public: Floorplan(); // default constructor, DO NOT CALL Floorplan(int first_index , int first_width , int first_height, int second_index, int second_width, int second_height); Floorplan(Operator * newTree); ~Floorplan(); void AddModule(int index, int width, int height); Floorplan * Clone(); // cost function int getArea(); // move functions bool SwapAdjacentOperands(unsigned int index_of_first); bool M1(unsigned int index_of_first); unsigned int ChainInvert(unsigned int first_operator); unsigned int M2(unsigned int first_operator); // there are conditions under which M3 moves cannot occur: // namely all operators are of the same type bool M3OK(); unsigned int SwapAdjacentOperandAndOperator(unsigned int index); unsigned int M3(unsigned int index); bool RotateModule(unsigned int index_of_module); bool M4(unsigned int index_of_module); // meta-data delivery functions unsigned int getModuleCount(); unsigned int getOperatorCount(); unsigned int getLength(); // debugging functions void dumpTree(); void dumpList();private: // assume the tree is accurate, the list pointers // are not accurate void GenerateList(); void GenerateListBackward(); // assume the list is accurate, the tree pointers // are not accurate void GenerateTree(); unsigned int nModules; unsigned int nOperators; Operator * tree; Module * list; ModuleStack * stack; // used to generate a tree from a list};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -