📄 ch13.2.htm
字号:
and</SPAN>
, <SPAN CLASS="BodyComputer">
or</SPAN>
) to describe the behavior of a MUX, but this is not how the logic cell is implemented. </P>
<P CLASS="Body">
<A NAME="pgfId=49066">
</A>
To simulate the optimized structural model, module <SPAN CLASS="BodyComputer">
comp_mux_o2.v</SPAN>
, we use the library cell models (module <SPAN CLASS="BodyComputer">
mx21d1</SPAN>
and the other five that are not shown here) together with the following new testbench model: </P>
<P CLASS="ComputerFirstLabelV">
<A NAME="pgfId=49454">
</A>
`timescale 1 ps / 1 ps // comp_mux_testbench2.v</P>
<P CLASS="ComputerLabelV">
<A NAME="pgfId=49455">
</A>
<B CLASS="Keyword">
module</B>
comp_mux_testbench2;</P>
<P CLASS="ComputerLabelV">
<A NAME="pgfId=49456">
</A>
<B CLASS="Keyword">
integer</B>
i, j; <B CLASS="Keyword">
integer</B>
error;</P>
<P CLASS="ComputerLabelV">
<A NAME="pgfId=134080">
</A>
<B CLASS="Keyword">
reg</B>
[2:0] x, y, smaller; <B CLASS="Keyword">
wire</B>
[2:0] z, ref;</P>
<P CLASS="ComputerLabelV">
<A NAME="pgfId=134081">
</A>
<B CLASS="Keyword">
always</B>
@(x) $display("t x y derived reference");</P>
<P CLASS="ComputerLabelV">
<A NAME="pgfId=49459">
</A>
<A NAME="25978">
</A>
// <B CLASS="Keyword">
initial</B>
$monitor("%8.2f",$time/1e3,,x,,y,,z,,,,,,,,ref);</P>
<P CLASS="ComputerLabelV">
<A NAME="pgfId=49460">
</A>
<B CLASS="Keyword">
initial</B>
$dumpvars; </P>
<P CLASS="ComputerLabelV">
<A NAME="pgfId=49461">
</A>
<B CLASS="Keyword">
initial</B>
<B CLASS="Keyword">
begin</B>
</P>
<P CLASS="ComputerLabelV">
<A NAME="pgfId=49462">
</A>
error = 0; #1e6 $display("%4g", error, " errors"); </P>
<P CLASS="ComputerLabelV">
<A NAME="pgfId=49463">
</A>
$finish; </P>
<P CLASS="ComputerLabelV">
<A NAME="pgfId=49464">
</A>
<B CLASS="Keyword">
end</B>
</P>
<P CLASS="ComputerLabelV">
<A NAME="pgfId=49465">
</A>
<B CLASS="Keyword">
initial</B>
<B CLASS="Keyword">
begin</B>
</P>
<P CLASS="ComputerLabelV">
<A NAME="pgfId=49466">
</A>
<B CLASS="Keyword">
for</B>
(i = 0; i <= 7; i = i + 1) <B CLASS="Keyword">
begin</B>
</P>
<P CLASS="ComputerLabelV">
<A NAME="pgfId=49467">
</A>
<B CLASS="Keyword">
for</B>
(j = 0; j <= 7; j = j + 1) <B CLASS="Keyword">
begin</B>
</P>
<P CLASS="ComputerLabelV">
<A NAME="pgfId=49468">
</A>
x = i; y = j; #10e3;</P>
<P CLASS="ComputerLabelV">
<A NAME="pgfId=49469">
</A>
<A NAME="20284">
</A>
$display("%8.2f",$time/1e3,,x,,y,,z,,,,,,,,ref);</P>
<P CLASS="ComputerLabelV">
<A NAME="pgfId=49470">
</A>
<B CLASS="Keyword">
if</B>
(z != ref) </P>
<P CLASS="ComputerLabelV">
<A NAME="pgfId=49471">
</A>
<B CLASS="Keyword">
begin</B>
$display("error"); error = error + 1; <B CLASS="Keyword">
end</B>
</P>
<P CLASS="ComputerLabelV">
<A NAME="pgfId=49472">
</A>
<B CLASS="Keyword">
end</B>
</P>
<P CLASS="ComputerLabelV">
<A NAME="pgfId=49473">
</A>
<B CLASS="Keyword">
end</B>
</P>
<P CLASS="ComputerLabelV">
<A NAME="pgfId=49474">
</A>
<B CLASS="Keyword">
end</B>
</P>
<P CLASS="ComputerLabelV">
<A NAME="pgfId=49475">
</A>
comp_mux_o v_1 (x, y, z); // comp_mux_o2.v</P>
<P CLASS="ComputerLabelV">
<A NAME="pgfId=49476">
</A>
reference v_2 (x, y, ref);</P>
<P CLASS="ComputerLastLabelV">
<A NAME="pgfId=48706">
</A>
<B CLASS="Keyword">
endmodule</B>
</P>
<P CLASS="ComputerFirstLabelV">
<A NAME="pgfId=56200">
</A>
// reference.v</P>
<P CLASS="ComputerLabelV">
<A NAME="pgfId=48433">
</A>
<B CLASS="Keyword">
module</B>
reference(a, b, outp);</P>
<P CLASS="ComputerLabelV">
<A NAME="pgfId=61365">
</A>
<B CLASS="Keyword">
input</B>
[2:0] a, b;<B CLASS="Keyword">
output</B>
[2:0] outp;</P>
<P CLASS="ComputerLabelV">
<A NAME="pgfId=48434">
</A>
<A NAME="25951">
</A>
<B CLASS="Keyword">
assign</B>
outp = (a <= b) ? a : b; // different from comp_mux</P>
<P CLASS="ComputerLastLabelV">
<A NAME="pgfId=48435">
</A>
<B CLASS="Keyword">
endmodule</B>
</P>
<P CLASS="Body">
<A NAME="pgfId=49334">
</A>
In this testbench we have instantiated two models: a <A NAME="marker=56368">
</A>
<SPAN CLASS="Emphasis">
reference model</SPAN>
(module <SPAN CLASS="BodyComputer">
reference</SPAN>
) and a <A NAME="marker=56489">
</A>
<SPAN CLASS="Emphasis">
derived model</SPAN>
(module <SPAN CLASS="BodyComputer">
comp_mux_o</SPAN>
, the optimized structural model). The high-level behavioral model that represents the initial system specification (module <SPAN CLASS="BodyComputer">
reference</SPAN>
) may be different from the model that we use as input to the logic-synthesis tool (module <SPAN CLASS="BodyComputer">
comp_mux</SPAN>
). Which is the real reference model? We postpone this question until we discuss <SPAN CLASS="Emphasis">
formal verification</SPAN>
in <A HREF="CH13.8.htm#10040" CLASS="XRef">
Section 13.8</A>
. For the moment, we shall simply perform simulations to check the reference model against the derived model. The simulation results are as follows:</P>
<P CLASS="ComputerFirst">
<A NAME="pgfId=49447">
</A>
t x y derived reference</P>
<P CLASS="Computer">
<A NAME="pgfId=49448">
</A>
10.00 0 0 0 0</P>
<P CLASS="Computer">
<A NAME="pgfId=49449">
</A>
20.00 0 1 0 0</P>
<P CLASS="Computer">
<A NAME="pgfId=49335">
</A>
... 60 lines omitted...</P>
<P CLASS="Computer">
<A NAME="pgfId=49560">
</A>
630.00 7 6 6 6</P>
<P CLASS="Computer">
<A NAME="pgfId=49561">
</A>
640.00 7 7 7 7</P>
<P CLASS="ComputerLast">
<A NAME="pgfId=49562">
</A>
0 errors</P>
<P CLASS="BodyAfterHead">
<A NAME="pgfId=49393">
</A>
(A summary is printed at the end of the simulation to catch any errors.) The next step is to examine the timing of the structural model (by switching the leading <SPAN CLASS="BodyComputer">
'//'</SPAN>
from line <A HREF="CH13.2.htm#25978" CLASS="XRef">
6</A>
to <A HREF="CH13.2.htm#20284" CLASS="XRef">
16</A>
in module <SPAN CLASS="BodyComputer">
comp_mux_testbench2</SPAN>
). It is important to simulate using the worst-case delays by using a command-line <SPAN CLASS="Definition">
switch</SPAN>
<A NAME="marker=61420">
</A>
as follows: <SPAN CLASS="BodyComputer">
verilog +maxdelays</SPAN>
. We can then find the longest path delay by searching through the simulator output, part of which follows:</P>
<P CLASS="ComputerFirst">
<A NAME="pgfId=56305">
</A>
t x y derived reference</P>
<P CLASS="Computer">
<A NAME="pgfId=51318">
</A>
... lines omitted...</P>
<P CLASS="Computer">
<A NAME="pgfId=51300">
</A>
260.00 3 2 1 2</P>
<P CLASS="Computer">
<A NAME="pgfId=51301">
</A>
260.80 3 2 3 2</P>
<P CLASS="Computer">
<A NAME="pgfId=51302">
</A>
260.85 3 2 2 2</P>
<P CLASS="Computer">
<A NAME="pgfId=51303">
</A>
270.00 3 3 2 3</P>
<P CLASS="Computer">
<A NAME="pgfId=51304">
</A>
270.80 3 3 3 3</P>
<P CLASS="Computer">
<A NAME="pgfId=51305">
</A>
280.00 3 4 3 3</P>
<P CLASS="Computer">
<A NAME="pgfId=51306">
</A>
280.85 3 4 0 3</P>
<P CLASS="Computer">
<A NAME="pgfId=51307">
</A>
283.17 3 4 3 3</P>
<P CLASS="ComputerLast">
<A NAME="pgfId=51322">
</A>
... lines omitted...</P>
<P CLASS="Body">
<A NAME="pgfId=56334">
</A>
At time 280 ns, the input vectors, <SPAN CLASS="BodyComputer">
x</SPAN>
and <SPAN CLASS="BodyComputer">
y</SPAN>
, switch from (<SPAN CLASS="BodyComputer">
x = 3</SPAN>
, <SPAN CLASS="BodyComputer">
y = 3</SPAN>
) to (<SPAN CLASS="BodyComputer">
x = 3</SPAN>
, <SPAN CLASS="BodyComputer">
y = 4</SPAN>
). The output of the derived model (which should be equal to the smaller of <SPAN CLASS="BodyComputer">
x</SPAN>
and <SPAN CLASS="BodyComputer">
y</SPAN>
) is the same for both of these input vectors and should remain unchanged. In fact there is a glitch at the output of the derived model, as it changes from 3 to 0 and back to 3 again, taking 3.17 ns to settle to its final value (this is the longest delay that occurs using this testbench). The glitch occurs because one of the input vectors (input <SPAN CLASS="BodyComputer">
y</SPAN>
) changes from <SPAN CLASS="BodyComputer">
'011'</SPAN>
(3 in decimal) to <SPAN CLASS="BodyComputer">
'100'</SPAN>
(decimal 4). Changing several input bits simultaneously causes the output to vacillate.</P>
<P CLASS="Body">
<A NAME="pgfId=57958">
</A>
Notice that the nominal and worst-case simulations will not necessarily give the same longest path delay. In addition the longest path delay found using this testbench is not necessarily the critical path delay. For example, the longest, and therefore critical, path delay might result from a transition from <SPAN CLASS="BodyComputer">
x = 3</SPAN>
, <SPAN CLASS="BodyComputer">
y = 4 to x = 4</SPAN>
,<SPAN CLASS="BodyComputer">
y = 3</SPAN>
(to choose a random but possible candidate set of input vectors). This testbench does not include tests with such transitions. To find the critical path using logic simulation requires simulating all possible input transitions (64 <SPAN CLASS="Symbol">
¥</SPAN>
64 = 4096) and then sifting through the output to find the critical path. </P>
<P CLASS="Body">
<A NAME="pgfId=57969">
</A>
<SPAN CLASS="Definition">
Vector-based simulation </SPAN>
<A NAME="marker=57970">
</A>
(or <SPAN CLASS="Definition">
dynamic simulation</SPAN>
<A NAME="marker=57974">
</A>
) can show us that our design functions correctly—hence the name functional simulation. However, functional simulation does not work well if we wish to find the critical path. For this we turn to a different type of simulation—static simulation or static timing analysis.</P>
<TABLE>
<TR>
<TD ROWSPAN="1" COLSPAN="2">
<P CLASS="TableTitle">
<A NAME="pgfId=85478">
</A>
TABLE 13.1 <A NAME="23209">
</A>
Timing analysis of the comparator/MUX structural model, <SPAN CLASS="BodyComputer">
comp_mux_o2.v</SPAN>
, from <A HREF="/Humuhumu/from Antibes/Prof.htm#32025" CLASS="XRef">
Figure 12.8</A>
.</P>
</TD>
</TR>
<TR>
<TD ROWSPAN="1" COLSPAN="1">
<P CLASS="TableFirst">
<A NAME="pgfId=85485">
</A>
Command</P>
</TD>
<TD ROWSPAN="1" COLSPAN="1">
<P CLASS="TableFirst">
<A NAME="pgfId=85490">
</A>
Timing analyzer/logic synthesizer output<A HREF="#pgfId=85489" CLASS="footnote">
1</A>
1</P>
</TD>
</TR>
<TR>
<TD ROWSPAN="1" COLSPAN="1">
<P CLASS="Computer">
<A NAME="pgfId=85492">
</A>
> report timing</P>
</TD>
<TD ROWSPAN="1" COLSPAN="1">
<P CLASS="Computer">
<A NAME="pgfId=85494">
</A>
instance name </P>
<P CLASS="Computer">
<A NAME="pgfId=85495">
</A>
inPin --> outPin incr arrival trs rampDel cap cell </P>
<P CLASS="Computer">
<A NAME="pgfId=85496">
</A>
(ns) (ns) (ns) (pf) </P>
<P CLASS="Computer">
<A NAME="pgfId=85497">
</A>
---------------------------------------------------------------------- </P>
<P CLASS="Computer">
<A NAME="pgfId=85498">
</A>
a[0] .00 .00 R .00 .12 comp_m...</P>
<P CLASS="Computer">
<A NAME="pgfId=85499">
</A>
b1_i3 </P>
<P CLASS="Computer">
<A NAME="pgfId=85500">
</A>
A2 --> ZN .31 .31 F .23 .08 nd02d0 </P>
<P CLASS="Computer">
<A NAME="pgfId=85501">
</A>
b1_i4 </P>
<P CLASS="Computer">
<A NAME="pgfId=85502">
</A>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -