我想分析一个组合数字电路。ASCII文件包含回路的描述,格式如下:
<name> <logic gate> <inputs> <outputs> <input 1>…<last input> <output> <delay>其中:<name>是一个不超过20个字符的字符串,其中包含逻辑门的名称。<logic gate>是一个不超过20个字符的字符串,用于标识逻辑门的类型。它可以是INPUT、OUTPUT、AND、OR、NOT。<inputs>是一个整数,等于0表示输入,1表示NOT或OUTPUT,2表示AND和OR。对于输出,<outputs>是一个等于0的整数,否则为大于0的整数。<input 1>、<last input>, <output>是字符串,每个字符串不超过20个字符,用于标识逻辑门的输入/输出网络的名称。<delay>是一个整数,用于标识逻辑门计算其功能所需的时间。
在读取包含电路描述的文件之后,程序必须计算电路的关键路径,该关键路径可以被定义为连接输入型门和输出型门的路径,对于该路径,该路径中的门的延迟之和在电路中的所有可能路径中是最高的。
Can anyone please tell me the data structures that are best suited for storing the information the program has to elaborate.
How could i load the the data structure into the memory?示例
A INPUT 0 1 net1 1
B INPUT 0 1 net2 1
C INPUT 0 1 net3 1
G1 NOT 1 1 net1 net4 1
G2 OR 2 1 met3 net4 net5 1
G3 AND 2 1 net4 net2 net6 2
G4 AND 2 1 net6 net5 net7 2
D OUTPUT 1 0 net6 1
E OUTPUT 1 0 E 1
In this example the critical path is A/G1/G2/G4/E with a delay of 7.我如何才能实现这一点?
发布于 2010-12-26 03:56:01
如果我没理解错的话,你真的想知道你应该使用哪种算法来计算关键路径。这似乎类似于一个“最短路径是什么?”的问题-type。对于这个问题,我推荐使用Dijkstra's Algorithm。
https://stackoverflow.com/questions/4530161
复制相似问题