芯片规划过程中的布图表示

布图

布图表示有三种:

  • 如何将一个布图转化为一个约束图对
  • 如何将一个布图转化为一个序列对
  • 如何将一个序列对转化为一个布图

PS:现代的序列对算法不需要直接计算约束图,但约束图提供了一个有用的布图和序列对之间的中间表示,这样从概念上会更易于理解。

从布图到一个约束图对
  1. 对于每个约束图,为n个块中的一个mi创建一个块节点vi, 1<= i <= n,一个源点s和一个汇点t;
  2. 对于垂直(水平)约束图,如果mi在mj下面(左边),则增加一条有向边(vi,vj);
  3. 对于每个约束图,删除所有不能通过传递到达的边。
从布图到一个序列对
  1. 给定两个块a和b,在序列对中,如果在S+中,a在b前面,即<…a…b…>,且在S-中,a也在b之前,即<…a…b…>,则a在b左边;
  2. 如果在S+中,a在b前面,即<…a…b…>,且在S-中,a在b之后,即<…b…a…>,则a在b上边;
  3. 理论上,先生成约束图,然后才用块的排序规则生成序列对,但是,约束图并不需要明确地建立起来。
从序列对到一个布图
必要信息
  1. 布图的起始点;
  2. 每个块的宽和高;
  3. 布图的布局方向。
流程图
Created with Raphaël 2.2.0 导入数据(包括序列对,宽高) s1=s~+~,s2=s~-~ 找出各个块在s2中的索引号 初始化所有块的总长度 选取初始块(起始点),获取其在s2中的索引号 计算块的位置,确定当前块的长度 当前块长度受否大于先前的长度 当前块的长度替代先前的 保留先前的长度 返回块位置,长度 yes no
C++编码源码
#include <iostream>

using namespace std;

const int BLOCKS = 5;
const char s1[] = { 'a', 'c', 'd', 'b', 'e' };
const char s2[] = { 'c', 'd', 'a', 'e', 'b' };
const char s3[] = { 'a', 'b', 'c', 'd', 'e' };

void xPosition(int Lengths[], int Width[], int positionX[])
{
	int index_1, index_2, index;
	int blocksOrder[BLOCKS] = { 0 };
	for (index_1 = 0; index_1 < BLOCKS; ++index_1)
	{
		for (index_2 = 0; index_2 < BLOCKS; ++index_2)
		{
			if (s3[index_1] == s2[index_2])
			{
				blocksOrder[index_1] = index_2;
				break;
			}
		}
	}

	for (index_1 = 0; index_1 < BLOCKS; ++index_1)
	{
		for (index = 0; index < BLOCKS; ++index)
		{
			if (s1[index_1] == s3[index])
				break;
		}
		positionX[index] = Lengths[blocksOrder[index]];
		for (index_2 = blocksOrder[index]; index_2 < BLOCKS; ++index_2)
		{
			if (Lengths[index_2] < (positionX[index] + Width[index]))
				Lengths[index_2] = positionX[index] + Width[index];
		}
	}
}

void yPosition(int Lengths[], int height[], int positionY[])
{
	int index_1, index_2, index, s1_R[BLOCKS];
	int blocksOrder[BLOCKS] = { 0 };
	for (index = 0; index < BLOCKS; ++index)
	{
		s1_R[BLOCKS - index - 1] = s1[index];
	}

	for (index_1 = 0; index_1 < BLOCKS; ++index_1)
	{
		for (index_2 = 0; index_2 < BLOCKS; ++index_2)
		{
			if (s3[index_1] == s2[index_2])
			{
				blocksOrder[index_1] = index_2;
				break;
			}
		}
	}

	for (index_1 = 0; index_1 < BLOCKS; ++index_1)
	{
		for (index = 0; index < BLOCKS; ++index)
		{
			if (s1_R[index_1] == s3[index])
				break;
		}
		positionY[index] = Lengths[blocksOrder[index]];
		for (index_2 = blocksOrder[index]; index_2 < BLOCKS; ++index_2)
		{
			Lengths[index_2] = positionY[index] + height[index];
		}
	}
}

int main()
{
	int widthAndHeight[2 * BLOCKS] = {8,4,4,3,4,5,4,5,4,6};
	int width[BLOCKS], height[BLOCKS];
	int index;
	for (index = 0; index < BLOCKS; ++index)
	{
		width[index] = widthAndHeight[2 * index];
		height[index] = widthAndHeight[2 * index + 1];
	}

	int xLengths[BLOCKS] = { 0, 0, 0, 0, 0 };
	int yLengths[BLOCKS] = { 0, 0, 0, 0, 0 };
	int positonX[BLOCKS];
	int positonY[BLOCKS];
	xPosition(xLengths, width, positonX);
	yPosition(yLengths, height, positonY);

	for (index = 0; index < BLOCKS; ++index)
	{
		cout << s3[index] << "( " << positonX[index] << " , " << positonY[index] << " )" << endl;
	}
	return 0;
}

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值