我想分析一个组合数字电路。 ASCII文件包含电路的描述,根据以下格式:
<name> <logic gate> <inputs> <outputs> <input 1>…<last input> <output> <delay>
其中:
<name>
是一个不超过20个字符的字符串,其中包含逻辑门的名称。
<logic gate>
是一个不超过20个字符的字符串,用于标识逻辑门的类型。它可以是INPUT
,OUTPUT
,AND
,OR
,NOT
。
<inputs>
是INPUT的整数,0表示NOT或OUTPUT,2表示AND和OR。
对于OUTPUT,<outputs>
是一个等于0的整数,否则为0。
<input 1>
,<last input>, <output
&gt;是每个不超过20个字符的字符串,它标识逻辑门的输入/输出网络的名称。
<delay>
是一个整数,用于标识逻辑门计算其功能所需的时间。
程序在读取包含电路描述的文件后,必须计算电路的关键路径,该路径可以定义为连接INPUT类型的门与OUTPUT类型之一的路径,延迟之和在路径中所有可能的路径中,路径中的门是最高的。
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.
我怎样才能实现这个目标。?
答案 0 :(得分:1)
如果我理解你的问题,你真的想知道你应该使用哪种算法来计算关键路径。这看起来类似于“什么是最短路径?” - 问题类型。我建议Dijkstra's Algorithm解决这个问题。