<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6837615239980912050</id><updated>2011-12-28T21:42:45.621-08:00</updated><title type='text'>Tech Funda of the Day</title><subtitle type='html'>&lt;BR&gt;
                    Maintain By :  Kartik Kariya, Bangalore
&lt;BR&gt;
Send your feedback to feedback@dreamroutes.net</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://techfundaoftheday.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6837615239980912050/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://techfundaoftheday.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>kdkariya</name><uri>http://www.blogger.com/profile/16154005894727727725</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp1.blogger.com/_GBhwIPW1FbY/SAltSM1KEPI/AAAAAAAAA5Q/kBl9S8H8r80/S220/DSC05163.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6837615239980912050.post-4419327302005600719</id><published>2007-04-25T23:47:00.000-07:00</published><updated>2007-04-26T00:29:20.664-07:00</updated><title type='text'>The 2007  Verification Census</title><content type='html'>&lt;strong&gt;1. Verilog Vs VHDL&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;2005 - "Does your project do mixed Verilog/VHDL simulations?"&lt;br /&gt;&lt;br /&gt;Verilog only : ############################## 59%&lt;br /&gt;mixed : ################### 38%&lt;br /&gt;VHDL only : # 3%&lt;br /&gt;&lt;br /&gt;Now here's the 2007 data with the break out of that vague "mixed" term:&lt;br /&gt;&lt;br /&gt;2007 - "Does your project do mixed Verilog/VHDL simulations?"&lt;br /&gt;&lt;br /&gt;Verilog only : ############################ 55.3%&lt;br /&gt;mostly Verilog : ######### 18.0%&lt;br /&gt;both equally : ### 6.5%&lt;br /&gt;mostly VHDL : ######## 16.4%&lt;br /&gt;VHDL only : ## 4.0%&lt;br /&gt;&lt;br /&gt;Clearly Verilog is the winner and VHDL is used only military project or for legacy reasons.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2. Cadence NC-Sim, Synopsys VCS, Mentor ModelSim, Aldec&lt;/strong&gt;&lt;br /&gt;2005 - "Whose Verilog or VHDL simulator(s) do you currenty use?"&lt;br /&gt;&lt;br /&gt;Cadence NC-Sim : ########################### 27%&lt;br /&gt;NC-Verilog : ##################### 21%&lt;br /&gt;Verilog-XL : ## 2%&lt;br /&gt;NC-VHDL : # 1%&lt;br /&gt;&lt;br /&gt;Synopsys VCS : ########################################### 43%&lt;br /&gt;VCS-MX : #### 4%&lt;br /&gt;&lt;br /&gt;Mentor ModelSim : ################################### 35%&lt;br /&gt;&lt;br /&gt;Aldec : ### 3%&lt;br /&gt;Icarus : .5%&lt;br /&gt;Veriwell : .5%&lt;br /&gt;SimuCAD Silos-III : .5%&lt;br /&gt;Finsim : .5%&lt;br /&gt;&lt;br /&gt;Here's the new 2007 mindshare data:&lt;br /&gt;&lt;br /&gt;2007 - "Whose Verilog or VHDL simulator(s) do you currenty use?"&lt;br /&gt;&lt;br /&gt;Cadence NC-Sim : ######################## 24.3%&lt;br /&gt;NC-Verilog : ################## 18.0%&lt;br /&gt;Verilog-XL : # 0.7%&lt;br /&gt;NC-VHDL : # 1.1%&lt;br /&gt;&lt;br /&gt;Synopsys VCS : ############################################# 44.7%&lt;br /&gt;VCS-MX : ######### 8.5%&lt;br /&gt;&lt;br /&gt;Mentor ModelSim : ################################### 35.3%&lt;br /&gt;&lt;br /&gt;Aldec : ### 2.8%&lt;br /&gt;Icarus : .4%&lt;br /&gt;Veripool Verilator : # .6%&lt;br /&gt;SimuCAD Silos-III : 0%&lt;br /&gt;Finsim : 0%&lt;br /&gt;&lt;br /&gt;For 2007, Cadence came in second with a 24.3 + 18 + 0.7 + 1.1 = 44.1% total&lt;br /&gt;Verilog/VHDL mindshare. Synopsys took the lead with a 44.7 + 8.5 = 53.2%&lt;br /&gt;total mindshare.&lt;br /&gt;&lt;br /&gt;Few Interesting Comments :&lt;br /&gt;Mentor Modelsim. We do do some mixed verilog/vhdl sim's but these&lt;br /&gt;are usually forced on us by IP models only being availble in&lt;br /&gt;Verilog. We currently design using vhdl but are starting to think&lt;br /&gt;about jumping to System Verilog.&lt;br /&gt;&lt;br /&gt;- Jeremy Ellis of Ericsson&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Synopsys VCS-MX. Mixed, because design is traditionally in VHDL,&lt;br /&gt;IP sometimes in Verilog, testbench in System Verilog.&lt;br /&gt;&lt;br /&gt;- [ An Anon Engineer ]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Cadence Incisive 80%, Synopsys VCS 15%, Synopsys VCS-MX (for VHDL&lt;br /&gt;due to acquired IP) 5% currently, emphasis shifting to VCS due to&lt;br /&gt;better System Verilog support.&lt;br /&gt;&lt;br /&gt;- [ An Anon Engineer ]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Principally Synopsys VCS.&lt;br /&gt;&lt;br /&gt;We tried to keep the code building with Cadence NC-Sim too, but there&lt;br /&gt;were too many differences in scope of System Verilog support to&lt;br /&gt;maintain this for the entire code base (at the time we looked - may&lt;br /&gt;have improved now) - some people use NC-Sim for module test though.&lt;br /&gt;&lt;br /&gt;- [ An Anon Engineer ]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Our group is all Verilog. We use Cadence NC Verilog. We are looking&lt;br /&gt;at switching to VCS because their simulator offers more support for&lt;br /&gt;System Verilog.&lt;br /&gt;&lt;br /&gt;- [ An Anon Engineer ]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Were currently using a mixture of Synopsys VCS (for unit-level) and&lt;br /&gt;Cadence Incisive (for system-level). We do run mixed simulations&lt;br /&gt;because of IP coming from an internal European group which was using&lt;br /&gt;VHDL at the time they were acquired.&lt;br /&gt;&lt;br /&gt;- Kelly Larson of Analog Devices&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3:&lt;strong&gt;Atrenta Spyglass, Synopsys Leda, Cadence HAL, 0-In CheckList&lt;/strong&gt;&lt;br /&gt;2007 - "Which linter/coverage tool(s) do you use?  Atrenta SpyGlass,&lt;br /&gt;          Cadence HAL, Synopsys Leda, Mentor DesignAnalyst, TransEDA or&lt;br /&gt;          do you use only the built-in linter/coverage in Synopsys VCS,&lt;br /&gt;          Cadence NC-Sim, Mentor ModelSim, Aldec?  Please be specific."&lt;br /&gt;&lt;br /&gt;             Cadence built-in :  ######################## 24.0%&lt;br /&gt;                  Cadence HAL :  ########### 11.3%&lt;br /&gt;                     Verisity :  ## 2.0%&lt;br /&gt;&lt;br /&gt;            Synopsys built-in :  ############################ 28.2%&lt;br /&gt;                Synopsys LEDA :  ##################### 20.8%&lt;br /&gt;&lt;br /&gt;          Mentor MTI built-in :  ####################### 23.0%&lt;br /&gt;         Mentor DesignAnalyst :  ## 1.9%&lt;br /&gt;               0-In CheckList :  ## 1.6%&lt;br /&gt;&lt;br /&gt;               Aldec built-in :  ## 2.4%&lt;br /&gt;&lt;br /&gt;             Atrenta Spyglass :  ########################## 25.9%&lt;br /&gt;&lt;br /&gt;                  Novas nLint :  ### 2.7%&lt;br /&gt;                     TransEDA :  ## 2.2%&lt;br /&gt;            Certess Certitude :  # 1.1%&lt;br /&gt;                        Axiom :  # 0.8%&lt;br /&gt;&lt;br /&gt;                    homegrown :  ## 1.9%&lt;br /&gt;&lt;br /&gt;It must not be that bad, though, for the Atrenta Spyglass folks because if&lt;br /&gt;you look at their 2005 mindshare numbers and the 2007 numbers:&lt;br /&gt;&lt;br /&gt;        Atrenta Spyglass 2005 :  ################## 18.0%&lt;br /&gt;&lt;br /&gt;        Atrenta Spyglass 2007 :  ########################## 25.9%&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;4.Novas Debussy &amp; Verdi, Veritools UnderTow, DAI SignalScan&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;"What waveform/debug tools do you use?  Veritools Undertow or&lt;br /&gt;          Novas DeBussy &amp; nSchema &amp; Verdi vs. only the waveform/debug&lt;br /&gt;          built-into Cadence, Synopsys, Mentor, Aldec?  Be specific."&lt;br /&gt;&lt;br /&gt;         Cadence built-in debug :  ############################## 29.6%&lt;br /&gt;         Cadence DAI SignalScan :  ## 1.7%&lt;br /&gt;&lt;br /&gt;        Synopsys built-in debug :  ################################# 33.2%&lt;br /&gt;&lt;br /&gt;      Mentor MTI built-in debug :  ########################## 26.3%&lt;br /&gt;&lt;br /&gt;           Aldec built-in debug :  ### 2.5%&lt;br /&gt;&lt;br /&gt;                  Novas Debussy :  ################################# 33.1%&lt;br /&gt;                    Novas Verdi :  ##################### 20.8%&lt;br /&gt;                  Novas nSchema :  ##### 4.5%&lt;br /&gt;                    Novas nWave :  # 1.3%&lt;br /&gt;                   Novas Siloti :  0.3%&lt;br /&gt;&lt;br /&gt;             Veritools UnderTow :  ### 2.8%&lt;br /&gt;                 Bybell GTKwave :  # 0.8%&lt;br /&gt;             Veripool Dinotrace :  # 0.6%&lt;br /&gt;           Axiom built-in debug :  # 0.8%&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;5:Cadence Verisity Specman "e" vs. Synopsys Vera&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;2005 - "What do you think about Verisity Specman 'e' vs. Synopsys&lt;br /&gt;            Vera?  Does your project use either of these?"&lt;br /&gt;&lt;br /&gt;             don't use :  ################################# 43%&lt;br /&gt;  Verisity Specman "e" :  ###################### 29%&lt;br /&gt;         Synopsys Vera :  ##################### 27%&lt;br /&gt;           we use both :  # 1%&lt;br /&gt;&lt;br /&gt;And now here's the newer 2007 stats:&lt;br /&gt;&lt;br /&gt;    2007 - "Does your project use either Cadence Verisity Specman "e" or&lt;br /&gt;            Synopsys Vera? (Yes/No)  If yes, which one?"&lt;br /&gt;&lt;br /&gt;             don't use :  ############################################ 57.1%&lt;br /&gt;  Verisity Specman "e" :  ############## 18.2%&lt;br /&gt;         Synopsys Vera :  ################ 20.7%&lt;br /&gt;           we use both :  ### 3.9%&lt;br /&gt;&lt;br /&gt;Yup, you're seeing that right.  All forms of Vera and "e" use has noticeably&lt;br /&gt;dropped in the past 2 years.  The "don't use" responses have vividly jumped&lt;br /&gt;from a 43% minority of projects in 2005 to a 57.1% majority of projects in&lt;br /&gt;2007.  This is the demise that was being openly talked about back in 2005.&lt;br /&gt;&lt;br /&gt;    2005 - "Where do you think specialty functional verification languages&lt;br /&gt;            like Specman "e" and Vera be in 5 years?  (Choose one): Dead&lt;br /&gt;            or an ever growing part of the chip verification process?"&lt;br /&gt;&lt;br /&gt;             Dead :  ####################################### 78%&lt;br /&gt;&lt;br /&gt;          Growing :  ########### 22%&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    2007 - "Where do you think specialty functional verification languages&lt;br /&gt;            like Specman "e" and Vera be in 5 years?  (Choose one): Dead&lt;br /&gt;            or an ever growing part of the chip verification process?"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;             Dead :  ######################################### 81.7%&lt;br /&gt;&lt;br /&gt;          Growing :  ######### 18.3%&lt;br /&gt;&lt;br /&gt;From the comments, it seems System Verilog (and to a lessor degree) SystemC&lt;br /&gt;use is finally now taking that long predicted bite out of Vera and "e".  And&lt;br /&gt;even as a shrinking minority, I did notice a number of fanatical Specman "e"&lt;br /&gt;users who were still very enthusiastic about their language.  Vera didn't&lt;br /&gt;seem to have such fanatics -- instead, its users seemed to be OK just giving&lt;br /&gt;in to the big, aggressive Synopsys/Mentor/ARM System Verilog marketing push.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.deepchip.com/posts/dvcon07.html#foo"&gt;Courtesy : deepchip.com&lt;/a&gt; (Checkout the site for detail description, only abstract /interesting points printed here)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6837615239980912050-4419327302005600719?l=techfundaoftheday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techfundaoftheday.blogspot.com/feeds/4419327302005600719/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6837615239980912050&amp;postID=4419327302005600719' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6837615239980912050/posts/default/4419327302005600719'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6837615239980912050/posts/default/4419327302005600719'/><link rel='alternate' type='text/html' href='http://techfundaoftheday.blogspot.com/2007/04/2007-verification-census.html' title='The 2007  Verification Census'/><author><name>kdkariya</name><uri>http://www.blogger.com/profile/16154005894727727725</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp1.blogger.com/_GBhwIPW1FbY/SAltSM1KEPI/AAAAAAAAA5Q/kBl9S8H8r80/S220/DSC05163.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6837615239980912050.post-7018791564820420475</id><published>2007-04-25T00:15:00.000-07:00</published><updated>2007-04-25T00:22:08.593-07:00</updated><title type='text'>Backspace in Xterm</title><content type='html'>If you're using xterm and hitting the backspace key doesn't do what you expect, add this to your .Xdefaults file:&lt;br /&gt;&lt;br /&gt;xterm.*.backarrowKey: false&lt;br /&gt;&lt;br /&gt;OR add following to .Xdefaults  file:&lt;br /&gt;&lt;br /&gt;XTerm.VT100.Translations: #override \&lt;br /&gt;       Key BackSpace: string(0x7F)\n\&lt;br /&gt;       Key Delete:    string("\033[3~")\n\&lt;br /&gt;       Key Home:      string("\033[1~")\n\&lt;br /&gt;       Key End:       string("\033[4~")&lt;br /&gt;&lt;br /&gt;*put Key word inside &lt;&gt;&lt;br /&gt;Keywords: Xterm, backspace, Delete&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6837615239980912050-7018791564820420475?l=techfundaoftheday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techfundaoftheday.blogspot.com/feeds/7018791564820420475/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6837615239980912050&amp;postID=7018791564820420475' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6837615239980912050/posts/default/7018791564820420475'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6837615239980912050/posts/default/7018791564820420475'/><link rel='alternate' type='text/html' href='http://techfundaoftheday.blogspot.com/2007/04/backspace-in-xterm.html' title='Backspace in Xterm'/><author><name>kdkariya</name><uri>http://www.blogger.com/profile/16154005894727727725</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp1.blogger.com/_GBhwIPW1FbY/SAltSM1KEPI/AAAAAAAAA5Q/kBl9S8H8r80/S220/DSC05163.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6837615239980912050.post-626717168962342081</id><published>2007-01-31T01:19:00.000-08:00</published><updated>2007-01-31T01:24:02.130-08:00</updated><title type='text'>Verilog in 1 day !!!!</title><content type='html'>&lt;b&gt;&lt;/b&gt;&lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;b&gt; &lt;a name="RTFToC1"&gt;1. Introduction &lt;/a&gt;&lt;/b&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;  Verilog HDL is a &lt;b&gt;Hardware Description Language (HDL)&lt;/b&gt;. A Hardware Description Language is a language used to describe a digital system, for example, a computer or a component of a computer. One may describe a digital system at several levels. For example, an HDL might describe the layout of the wires, resistors and transistors on an &lt;b&gt;Integrated Circuit (IC)&lt;/b&gt; chip, i. e., the &lt;b&gt;switch level&lt;/b&gt;.  Or, it might describe the logical gates and flip flops in a digital system, i. e., the &lt;b&gt;gate level&lt;/b&gt;. An even higher level describes the registers and the transfers of vectors of information between registers. This is called the &lt;b&gt;Register Transfer Level (RTL)&lt;/b&gt;. Verilog supports all of these levels. However, this handout focuses on only the portions of Verilog which support the RTL level. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;  &lt;b&gt; &lt;a name="RTFToC2"&gt;1.1 What is Verilog? &lt;/a&gt;&lt;/b&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; Verilog is one of the two major Hardware Description Languages (HDL) used by hardware designers in industry and academia. VHDL is the other one. The industry is currently split on which is better. Many feel that Verilog is easier to learn and use than VHDL. As one hardware designer puts it, "I hope the competition uses VHDL." VHDL was made an IEEE Standard in 1987, while Verilog is still in the IEEE standardization process. Verilog is very C-like and liked by electrical and computer engineers as most learn the C language in college. VHDL is very Ada-like and most engineers have no experience with Ada.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; Verilog was introduced in 1985 by Gateway Design System Corporation, now a part of Cadence Design Systems, Inc.'s Systems Division. Until May, 1990, with the formation of Open Verilog International (OVI), Verilog HDL was a proprietary language of Cadence. Cadence was motivated to open the language to the Public Domain with the expectation that the market for Verilog HDL-related software products would grow more rapidly with broader acceptance of the language. Cadence realized that Verilog HDL users wanted other software and service companies to embrace the language and develop Verilog-supported design tools. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; Verilog HDL allows a hardware designer to describe designs at a high level of abstraction such as at the architectural or behavioral level as well as the lower implementation levels (i. e. , gate and switch levels) leading to Very Large Scale Integration (VLSI) Integrated Circuits (IC) layouts and chip fabrication. A primary use of HDLs is the simulation of designs before the designer must commit to fabrication. This handout does not cover all of Verilog HDL but focuses on the use of Verilog HDL at the architectural or behavioral levels. The handout emphasizes design at the Register Transfer Level (RTL).&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;  &lt;b&gt; &lt;a name="RTFToC3"&gt;1.2 What is VeriWell? &lt;/a&gt;&lt;/b&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; VeriWell is a comprehensive implementation of Verilog HDL from Wellspring Solutions, Inc. VeriWell supports the Verilog language as specified by the OVI language Reference Manual. VeriWell was first introduced in December, 1992, and was written to be compatible with both the OVI standard and with Cadence's Verilog-XL.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;  Wellspring offers free versions of their VeriWell product available from &lt;tt&gt;ftp://iii.net/pub/pub-site/wellspring&lt;/tt&gt;. Wellspring offers free versions for DOS, Sparc and Linux. The free versions are the same as the industrial versions except they are restricted to a maximum of 1000 lines of HDL code.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;b&gt;  &lt;a name="RTFToC4"&gt;1.3 Why Use Verilog HDL? &lt;/a&gt;&lt;/b&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; Digital systems are highly complex. At their most detailed level, they may consists of millions of elements, i. e., transistors or logic gates. Therefore, for large digital systems, gate-level design is dead. For many decades, logic schematics served as the &lt;i&gt;lingua franca&lt;/i&gt; of logic design, but not any more. Today, hardware complexity has grown to such a degree that a schematic with logic gates is almost useless as it shows only a web of connectivity and not the functionality of design. Since the 1970s, Computer engineers and electrical engineers have moved toward hardware description languages (HDLs). The most prominent modern HDLs in industry are Verilog and VHDL. Verilog is the top HDL used by over 10,000 designers at such hardware vendors as Sun Microsystems, Apple Computer and Motorola. Industrial designers like Verilog. It works.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; The Verilog language provides the digital designer with a means of describing a digital system at a wide range of levels of abstraction, and, at the same time, provides access to computer-aided design tools to aid in the design process at these levels.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;  Verilog allows hardware designers to express their design with &lt;b&gt;behavioral constructs&lt;/b&gt;, deterring the details of implementation to a later stage of design in the design. An abstract representation helps the designer explore architectural alternatives through &lt;b&gt;simulations&lt;/b&gt; and to detect design bottlenecks before detailed design begins.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; Though the behavioral level of Verilog is a high level description of a digital system, it is still a precise notation. Computer aided design tools, i. e., programs, exist which will "compile" programs in the Verilog notation to the level of circuits consisting of logic gates and flip flops. One could then go to the lab and wire up the logical circuits and have a functioning system. And, other tools can "compile" programs in Verilog notation to a description of the integrated circuit masks for &lt;b&gt;very large scale integration &lt;/b&gt;(VLSI). Therefore, with the proper automated tools, one can create a VLSI description of a design in Verilog and send the VLSI description via electronic mail to a &lt;b&gt;silicon foundry &lt;/b&gt;in California and receive the integrated chip in a few weeks by way of snail mail. Verilog also allows the designer to specific designs at the logical gate level using &lt;b&gt;gate constructs&lt;/b&gt; and the transistor level using &lt;b&gt;switch constructs&lt;/b&gt;.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;  Our goal in the course is not to create VLSI chips but to use Verilog to precisely describe the &lt;i&gt;functionality&lt;/i&gt; of &lt;i&gt;any&lt;/i&gt; digital system, for example, a computer. However, a VLSI chip designed by way of Verilog's behavioral constructs will be rather slow and be wasteful of chip area. The lower levels in Verilog allow engineers to optimize the logical circuits and VLSI layouts to maximize speed and minimize area of the VLSI chip.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;b&gt; &lt;a name="RTFToC5"&gt;2. The Verilog Language &lt;/a&gt;&lt;/b&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; There is no attempt in this handout to describe the complete Verilog language. It describes only the portions of the language needed to allow students to explore the architectural aspects of computers. In fact, this handout covers only a small fraction of the language. For the complete description of the Verilog HDL, consult the references at the end of the handout.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; We begin our study of the Verilog language by looking at a simple Verilog program. Looking at the assignment statements, we notice that the language is very C-like. Comments have a C++ flavor, i e., they are shown by "//" to the end of the line. The Verilog language describes a digital system as a set of &lt;b&gt;modules&lt;/b&gt;, but here we have only a single module called "simple".&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;  &lt;b&gt; &lt;a name="RTFToC6"&gt;2.1 A First Verilog Program &lt;/a&gt;&lt;/b&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;pre&gt;&lt;tt&gt;//By Dan Hyde; August 9, 1995&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;//A first digital model in Verilog&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;module simple;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;// Simple Register Transfer Level (RTL) example to demo Verilog.&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;// The register A is incremented by one.  Then first four bits of B is&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;// set to "not" of the last four bits of A.  C is the "and" reduction&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;// of the last two bits of A.&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;//declare registers and flip-flops&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;reg [0:7] A, B;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;reg       C;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;// The two "initial"s and "always" will run concurrently&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;initial begin: stop_at&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   // Will stop the execution after 20 simulation units.&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   #20; $stop;    &lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;end&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;// These statements done at simulation time 0 (since no #k)&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;initial begin: Init&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;    // Initialize the register A.  The other registers have values of "x"&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;    A = 0;   &lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  &lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;    // Display a header&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;    $display("Time   A         B    C");  &lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;            &lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;    // Prints the values anytime a value of A, B or C changes&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;    $monitor("  %0d %b %b %b", $time, A, B, C);&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;end&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;//main_process will loop until simulation is over&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;always begin: main_process&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;    // #1 means do after one unit of simulation time&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;    #1 A = A + 1;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;    #1 B[0:3] = ~A[4:7];  // ~ is bitwise "not" operator&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;    #1 C = &amp;A[6:7];       // bitwise "and" reduction of last two bits&lt;br /&gt;of A&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;    &lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;end&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;endmodule&lt;/tt&gt; &lt;/pre&gt;  &lt;p&gt;  In &lt;tt&gt;&lt;b&gt;module simple&lt;/b&gt;&lt;/tt&gt;, we declared &lt;b&gt;A&lt;/b&gt; and &lt;b&gt;B&lt;/b&gt; as 8-bit registers and &lt;b&gt;C&lt;/b&gt; a 1-bit register or flip-flop.  Inside of the module, the one "&lt;tt&gt;&lt;b&gt;always&lt;/b&gt;&lt;/tt&gt;" and two "&lt;tt&gt;&lt;b&gt;initial&lt;/b&gt;&lt;/tt&gt;" constructs describe three &lt;b&gt;threads of control,&lt;/b&gt; i. e., they run at the same time or &lt;b&gt;concurrently&lt;/b&gt;.  Within the &lt;tt&gt;&lt;b&gt;initial&lt;/b&gt;&lt;/tt&gt; construct, statements are executed sequentially much like in C or other traditional imperative programming languages.  The &lt;tt&gt;&lt;b&gt;always&lt;/b&gt;&lt;/tt&gt; construct is the same as the &lt;tt&gt;&lt;b&gt;initial&lt;/b&gt;&lt;/tt&gt; construct except that it loops forever as long as the simulation runs.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;  The notation &lt;tt&gt;&lt;b&gt;#1&lt;/b&gt;&lt;/tt&gt; means to execute the statement after delay of one unit of simulated time. Therefore, the thread of control caused by the first &lt;tt&gt;&lt;b&gt;initial&lt;/b&gt;&lt;/tt&gt; construct will delay for 20 time units before calling the system task &lt;tt&gt;&lt;b&gt;$stop&lt;/b&gt;&lt;/tt&gt; and stop the simulation.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;  The &lt;tt&gt;&lt;b&gt;$display&lt;/b&gt;&lt;/tt&gt; system task allows the designer to print a message much like &lt;tt&gt;&lt;b&gt;printf&lt;/b&gt;&lt;/tt&gt; does in the language C.  Every time unit that one of the listed variables' value changes, the &lt;tt&gt;&lt;b&gt;$monitor&lt;/b&gt;&lt;/tt&gt; system task prints a message.  The system function &lt;tt&gt;&lt;b&gt;$time&lt;/b&gt;&lt;/tt&gt; returns the current value of simulated time.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;tt&gt; &lt;/tt&gt;Below is the output of the VeriWell Simulator:  (See Section 3 on how to use the VeriWell simulator.)&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;pre&gt;&lt;tt&gt;Time   A         B    C&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  0 00000000 xxxxxxxx x&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  1 00000001 xxxxxxxx x&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  2 00000001 1110xxxx x&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  3 00000001 1110xxxx 0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  4 00000010 1110xxxx 0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  5 00000010 1101xxxx 0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  7 00000011 1101xxxx 0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  8 00000011 1100xxxx 0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  9 00000011 1100xxxx 1&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  10 00000100 1100xxxx 1&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  11 00000100 1011xxxx 1&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  12 00000100 1011xxxx 0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  13 00000101 1011xxxx 0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  14 00000101 1010xxxx 0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  16 00000110 1010xxxx 0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  17 00000110 1001xxxx 0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  19 00000111 1001xxxx 0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;Stop at simulation time 20&lt;/tt&gt; &lt;/pre&gt; You should carefully study the program and its output before going on. The structure of the program is typical of the Verilog programs you will write for this course, i. e., an &lt;tt&gt;&lt;b&gt;initial&lt;/b&gt;&lt;/tt&gt; construct to specify the length of the simulation, another &lt;tt&gt;&lt;b&gt;initial&lt;/b&gt;&lt;/tt&gt; construct to initialize registers and specify which registers to monitor and an &lt;tt&gt;&lt;b&gt;always&lt;/b&gt;&lt;/tt&gt; construct for the digital system you are modeling.  Notice that all the statements in the second &lt;tt&gt;&lt;b&gt;initial&lt;/b&gt;&lt;/tt&gt; are done at time = 0, since there are no delay statements, i. e.,&lt;b&gt; #&lt;integer&gt;&lt;/integer&gt;&lt;/b&gt;. &lt;p&gt; &lt;/p&gt; &lt;p&gt;  &lt;b&gt; &lt;a name="RTFToC7"&gt;2.2 Lexical Conventions &lt;/a&gt;&lt;/b&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;  The lexical conventions are close to the programming language C++.  Comments are designated by &lt;tt&gt;&lt;b&gt;//&lt;/b&gt;&lt;/tt&gt; to the end of a line or by &lt;tt&gt;&lt;b&gt;/*&lt;/b&gt;&lt;/tt&gt; to &lt;tt&gt;&lt;b&gt;*/&lt;/b&gt;&lt;/tt&gt;&lt;b&gt; &lt;/b&gt;across several lines. Keywords, e. g., &lt;tt&gt;&lt;b&gt;module,&lt;/b&gt;&lt;/tt&gt; are reserved and in all lower case letters. The language is case sensitive, meaning upper and lower case letters are different. Spaces are important in that they delimit tokens in the language.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;  Numbers are specified in the traditional form of a series of digits with or without a  sign but also in the following form:&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;pre&gt;  &lt;size&gt;&lt;base&gt;&lt;number&gt;&lt;br /&gt;&lt;/number&gt;&lt;/size&gt;&lt;/pre&gt;  where &lt;b&gt;&lt;size&gt;&lt;/size&gt;&lt;/b&gt; contains &lt;i&gt;decimal&lt;/i&gt; digits that specify the size of the constant in the number of &lt;i&gt;bits&lt;/i&gt;.  The &lt;b&gt;&lt;size&gt;&lt;/size&gt;&lt;/b&gt; is optional.  The &lt;b&gt;&lt;base&gt;&lt;/b&gt; is the single character &lt;b&gt;'&lt;/b&gt; followed by one of the following characters &lt;b&gt;b&lt;/b&gt;, &lt;b&gt;d&lt;/b&gt;, &lt;b&gt;o&lt;/b&gt; and &lt;b&gt;h&lt;/b&gt;, which stand for binary, decimal, octal and hex, respectively.  The &lt;b&gt;&lt;number&gt;&lt;/number&gt;&lt;/b&gt; part contains digits which are legal for the &lt;b&gt;&lt;base&gt;&lt;/b&gt;.  Some examples: &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;pre&gt;  &lt;tt&gt;549 // decimal number&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  'h 8FF // hex number&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  'o765 // octal number&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  4'b11 // 4-bit binary number 0011&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  3'b10x // 3-bit binary number with least significant bit unknown&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  5'd3 // 5-bit decimal number&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  -4'b11 // 4-bit two's complement of 0011 or 1101&lt;/tt&gt; &lt;/pre&gt;  &lt;p&gt; The &lt;tt&gt;&lt;b&gt;&lt;number&gt;&lt;/number&gt;&lt;/b&gt;&lt;/tt&gt; part may &lt;i&gt;not &lt;/i&gt;contain a sign.  Any sign must go on the front.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;  A string is a sequence of characters enclosed in double quotes.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;pre&gt;  &lt;tt&gt;"this is a string"&lt;/tt&gt; &lt;/pre&gt;   Operators are one, two or three characters and are used in expressions.  See Section 2.5 for the operators. &lt;p&gt; &lt;/p&gt; &lt;p&gt; An identifier is specified by a letter or underscore followed by zero or more letters, digits, dollar signs and underscores. Identifiers can be up to 1024 characters.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;  &lt;b&gt; &lt;a name="RTFToC8"&gt;2.3 Program Structure &lt;/a&gt;&lt;/b&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; The Verilog language describes a digital system as a set of modules. Each of these modules has an interface to other modules to describe how they are interconnected. Usually we place one module per file but that is not a requirement. The modules may run concurrently, but usually we have one top level module which specifies a closed system containing both test data and hardware models. The top level module invokes instances of other modules. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; Modules can represent bits of hardware ranging from simple gates to complete systems, e. g., a microprocessor. Modules can either be specified behaviorally or structurally (or a combination of the two). A &lt;b&gt;behavioral specification&lt;/b&gt; defines the behavior of a digital system (module) using traditional programming language constructs, e. g., &lt;b&gt;if&lt;/b&gt;s, assignment statements.  A &lt;b&gt;structural specification &lt;/b&gt;expresses the behavior of a digital system (module) as a hierarchical interconnection of sub modules. At the bottom of the hierarchy the components must be primitives or specified behaviorally. Verilog primitives include gates, e. g., nand, as well as pass transistors (switches).&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;  The structure of a module is the following:&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;pre&gt;  &lt;tt&gt;module&lt;/tt&gt; &lt;module&gt; (&lt;port&gt;);&lt;br /&gt;&lt;declares&gt;&lt;br /&gt;&lt;module&gt;&lt;br /&gt;&lt;tt&gt;endmodule&lt;/tt&gt; &lt;/module&gt;&lt;/declares&gt;&lt;/port&gt;&lt;/module&gt;&lt;/pre&gt;  The &lt;b&gt;&lt;module&gt;&lt;/module&gt;&lt;/b&gt; is an identifier that uniquely names the module. The &lt;b&gt;&lt;port&gt;&lt;/port&gt;&lt;/b&gt; is a list of input, inout and output ports which are used to connect to other modules.  The &lt;b&gt;&lt;declares&gt;&lt;/declares&gt;&lt;/b&gt; section specifies data objects as registers, memories and wires as wells as procedural constructs such as &lt;b&gt;function&lt;/b&gt;s and &lt;b&gt;task&lt;/b&gt;s. &lt;p&gt; &lt;/p&gt; &lt;p&gt;  The &lt;b&gt;&lt;module&gt;&lt;/module&gt;&lt;/b&gt; may be &lt;tt&gt;&lt;b&gt;initial&lt;/b&gt;&lt;/tt&gt; constructs, &lt;tt&gt;&lt;b&gt;always&lt;/b&gt;&lt;/tt&gt; constructs, continuous assignments or instances of modules.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;  Here is a behavior specification of a module &lt;b&gt;NAND&lt;/b&gt;.  The output &lt;b&gt;out&lt;/b&gt; is the &lt;b&gt;not&lt;/b&gt; of the &lt;b&gt;and&lt;/b&gt; of the inputs &lt;b&gt;in1&lt;/b&gt; and &lt;b&gt;in2&lt;/b&gt;.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;pre&gt;&lt;tt&gt;// Behavioral Model of a Nand gate&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;// By Dan Hyde, August 9, 1995&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;module NAND(in1, in2, out);&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  input in1, in2;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  output out;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                 // continuous assign statement&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  assign out = ~(in1 &amp; in2);&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;endmodule&lt;/tt&gt; &lt;/pre&gt;   The ports &lt;b&gt;in1&lt;/b&gt;, i&lt;b&gt;n2&lt;/b&gt; and &lt;b&gt;out&lt;/b&gt; are labels on wires. The continuous assignment &lt;b&gt;assign&lt;/b&gt; continuously watches for changes to variables in its right hand side and whenever that happens the right hand side is re-evaluated and the result immediately propagated to the left hand side (&lt;b&gt;out&lt;/b&gt;). &lt;p&gt; The continuous assignment statement is used to model &lt;b&gt;combinational circuits&lt;/b&gt; where the outputs change when one wiggles the input.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;  Here is a structural specification of a module &lt;b&gt;AND&lt;/b&gt; obtained by connecting the output of one &lt;b&gt;NAND&lt;/b&gt; to both inputs of another one.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;pre&gt;&lt;tt&gt;module AND(in1, in2, out);&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;// Structural model of AND gate from two NANDS&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  input in1, in2;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  output out;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  wire w1;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                 // two instances of the module NAND&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  NAND NAND1(in1, in2, w1);&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  NAND NAND2(w1, w1, out);&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;endmodule&lt;/tt&gt; &lt;/pre&gt;   This module has two instances of the &lt;b&gt;NAND&lt;/b&gt; module called &lt;b&gt;NAND1&lt;/b&gt; and &lt;b&gt;NAND2&lt;/b&gt; connected together by an internal wire &lt;b&gt;w1&lt;/b&gt;. &lt;p&gt; &lt;/p&gt; &lt;p&gt;  The general form to invoke an instance of a module is :&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;pre&gt;  &lt;module&gt;  &lt;parameter&gt; &lt;instance&gt; (&lt;port&gt;);&lt;br /&gt;&lt;/port&gt;&lt;/instance&gt;&lt;/parameter&gt;&lt;/module&gt;&lt;/pre&gt;  where &lt;b&gt;&lt;parameter&gt;&lt;/parameter&gt;&lt;/b&gt; are values of parameters passed to the instance.  An example parameter passed would be the delay for a gate. &lt;p&gt;  The following module is a high level module which sets some test data and sets up the monitoring of variables.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;pre&gt;&lt;tt&gt;module test_AND;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;// High level module to test the two other modules&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  reg a, b;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  wire out1, out2;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  initial begin  // Test data&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;     a = 0;  b = 0;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;     #1 a = 1;  &lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;     #1 b = 1;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;     #1 a = 0;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  end&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  initial begin // Set up monitoring&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;    $monitor("Time=%0d a=%b b=%b out1=%b out2=%b",&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;              $time, a, b, out1, out2);&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  end&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                // Instances of modules AND and NAND&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  AND  gate1(a, b, out2);&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  NAND gate2(a, b, out1);&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;endmodule&lt;/tt&gt; &lt;/pre&gt;   Notice that we need to hold the values &lt;b&gt;a &lt;/b&gt;and b over time.  Therefore, we had to use 1-bit registers.  &lt;b&gt;reg&lt;/b&gt; variables store the last value that was &lt;i&gt;procedurally assigned&lt;/i&gt; to them (just like variables in traditional imperative programming languages).  &lt;b&gt;wire&lt;/b&gt;s have no storage capacity. They can be continuously driven, e. g., with a continuous &lt;tt&gt;&lt;b&gt;assign&lt;/b&gt;&lt;/tt&gt; statement or by the output of a module, or if input wires are left unconnected, they get the special value of &lt;b&gt;x&lt;/b&gt; for unknown. &lt;p&gt; &lt;/p&gt; &lt;p&gt;  Continuous assignments use the keyword &lt;b&gt;assign&lt;/b&gt; whereas procedural assignments have the form &lt;b&gt;&lt;reg&gt; = &lt;expression&gt;&lt;/expression&gt;&lt;/reg&gt;&lt;/b&gt; where the &lt;b&gt;&lt;reg&gt;&lt;/reg&gt;&lt;/b&gt; must be a register or memory.  Procedural assignment may only appear in &lt;tt&gt;&lt;b&gt;initial&lt;/b&gt;&lt;/tt&gt; and &lt;tt&gt;&lt;b&gt;always&lt;/b&gt;&lt;/tt&gt; constructs.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;  The statements in the block of the first &lt;tt&gt;&lt;b&gt;initial&lt;/b&gt;&lt;/tt&gt; construct will be executed sequentially, some of which are delayed by &lt;b&gt;#1&lt;/b&gt;, i. e., one unit of simulated time.  The &lt;tt&gt;&lt;b&gt;always&lt;/b&gt;&lt;/tt&gt; construct behaves the same as the &lt;tt&gt;&lt;b&gt;initial&lt;/b&gt;&lt;/tt&gt;construct except that it loops forever (until the simulation stops).  The &lt;tt&gt;&lt;b&gt;initial&lt;/b&gt;&lt;/tt&gt; and &lt;tt&gt;&lt;b&gt;always&lt;/b&gt;&lt;/tt&gt; constructs are used to model &lt;b&gt;sequential logic&lt;/b&gt; (i. e., &lt;b&gt;finite state automata&lt;/b&gt;).  &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;  Verilog makes an important distinction between procedural assignment and the continuous assignment &lt;tt&gt;&lt;b&gt;assign&lt;/b&gt;&lt;/tt&gt; .  Procedural assignment changes the state of a register, i. e., &lt;i&gt;sequential logic&lt;/i&gt;, whereas the continuous statement is used to model &lt;b&gt;combinational logic&lt;/b&gt;.  Continuous assignments drive &lt;tt&gt;&lt;b&gt;wire&lt;/b&gt;&lt;/tt&gt; variables and are evaluated and updated whenever an input operand changes value. It is important to understand and remember the difference.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;  We place all three modules in a file and run the simulator to produce the following output.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;pre&gt;&lt;tt&gt;Time=0 a=0 b=0 out1=1 out2=0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;Time=1 a=1 b=0 out1=1 out2=0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;Time=2 a=1 b=1 out1=0 out2=1&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;Time=3 a=0 b=1 out1=1 out2=0&lt;/tt&gt; &lt;/pre&gt;  Since the simulator ran out of events, I didn't need to explicit stop the simulation. &lt;p&gt; &lt;/p&gt; &lt;p&gt;   &lt;b&gt; &lt;a name="RTFToC9"&gt;2.4 Data Types &lt;/a&gt;&lt;/b&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;b&gt;  &lt;a name="RTFToC10"&gt;2.4.1 Physical Data Types &lt;/a&gt;&lt;/b&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;b&gt; &lt;/b&gt;Since the purpose of Verilog HDL is to model digital hardware, the primary data types are for modeling registers (&lt;tt&gt;&lt;b&gt;reg&lt;/b&gt;&lt;/tt&gt;) and wires (&lt;tt&gt;&lt;b&gt;wire&lt;/b&gt;&lt;/tt&gt;).  The &lt;tt&gt;&lt;b&gt;reg&lt;/b&gt;&lt;/tt&gt; variables store the last value that was procedurally assigned to them whereas the &lt;tt&gt;&lt;b&gt;wire&lt;/b&gt;&lt;/tt&gt; variables represent physical connections between structural entities such as gates.  A &lt;tt&gt;&lt;b&gt;wire&lt;/b&gt;&lt;/tt&gt; does not store a value.  A &lt;tt&gt;&lt;b&gt;wire&lt;/b&gt;&lt;/tt&gt; variable is really only a label on a wire.  (Note that the &lt;tt&gt;&lt;b&gt;wire&lt;/b&gt;&lt;/tt&gt; data type is only one of several &lt;tt&gt;&lt;b&gt;net&lt;/b&gt;&lt;/tt&gt; data types in Verilog HDL which include wired and (&lt;tt&gt;&lt;b&gt;wand&lt;/b&gt;&lt;/tt&gt;), wired or (&lt;tt&gt;&lt;b&gt;wor&lt;/b&gt;&lt;/tt&gt;) and tristate bus (&lt;tt&gt;&lt;b&gt;tri&lt;/b&gt;&lt;/tt&gt;).  This handout is restricted to only the &lt;tt&gt;&lt;b&gt;wire&lt;/b&gt;&lt;/tt&gt; data type.)&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;  The &lt;tt&gt;&lt;b&gt;reg&lt;/b&gt;&lt;/tt&gt; and &lt;tt&gt;&lt;b&gt;wire&lt;/b&gt;&lt;/tt&gt; data objects may have the following possible values:&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;pre&gt;  0 logical zero or false&lt;br /&gt;1 logical one or true&lt;br /&gt;x unknown logical value&lt;br /&gt;z  high impedance of tristate gate&lt;br /&gt;&lt;/pre&gt;   The &lt;tt&gt;&lt;b&gt;reg&lt;/b&gt;&lt;/tt&gt; variables are initialized to &lt;tt&gt;&lt;b&gt;x&lt;/b&gt;&lt;/tt&gt; at the start of the simulation.  Any &lt;tt&gt;&lt;b&gt;wire&lt;/b&gt;&lt;/tt&gt; variable not connected to something has the &lt;b&gt;x&lt;/b&gt; value. &lt;p&gt; &lt;/p&gt; &lt;p&gt;  You may specify the size of a register or wire in the declaration  For example, the declarations&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;pre&gt;&lt;tt&gt;  reg [0:7] A, B;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  wire [0:3] Dataout;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  reg [7:0] C;&lt;/tt&gt; &lt;/pre&gt;  specify registers A and &lt;b&gt;B&lt;/b&gt; to be 8-bit wide with the most significant bit the zeroth bit, whereas the most significant bit of register &lt;b&gt;C&lt;/b&gt; is bit seven.  The wire &lt;b&gt;Dataout&lt;/b&gt; is 4 bits wide. &lt;p&gt; &lt;/p&gt; &lt;p&gt;  The bits in a register or wire can be referenced by the notation &lt;b&gt;[&lt;start-bit&gt;:&lt;end-bit&gt;]&lt;/end-bit&gt;&lt;/start-bit&gt;&lt;/b&gt;.&lt;/p&gt; &lt;p&gt; For example, in the second procedural assignment statement&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;pre&gt;&lt;tt&gt;  initial begin: int1&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   A = 8'b01011010;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   B = {A[0:3] | A[4:7], 4'b0000};&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  end&lt;/tt&gt; &lt;/pre&gt;  &lt;b&gt;B&lt;/b&gt; is set to the first four bits of &lt;b&gt;A&lt;/b&gt; bitwise or-ed with the last four bits of &lt;b&gt;A&lt;/b&gt; and then concatenated with 0000.  &lt;b&gt;B&lt;/b&gt; now holds a value of 11110000.  The &lt;b&gt;{} &lt;/b&gt;brackets means the bits of the two or more arguments separated by commas are concatenated together. &lt;p&gt; &lt;/p&gt; &lt;p&gt;  &lt;u&gt;The range referencing in an expression &lt;b&gt;must &lt;/b&gt;have constant expression indices&lt;/u&gt;.  However, a single bit may be referenced by a variable.  For example:&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;pre&gt;&lt;tt&gt;  reg [0:7] A, B;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  B = 3;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  A[0: B] = 3'b111; // ILLEGAL - indices MUST be constant!!&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  A[B] = 1'b1;      // A single bit reference is LEGAL&lt;/tt&gt; &lt;/pre&gt; Why such a strict requirement of constant indices in register references? Since we are describing hardware, we want only expressions which are realizable. &lt;p&gt; &lt;/p&gt; &lt;p&gt;  Memories are specified as vectors of registers.  For example,&lt;b&gt; Mem&lt;/b&gt; is 1K words each 32-bits.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;pre&gt;  &lt;tt&gt;reg [31:0] Mem [0:1023];&lt;/tt&gt; &lt;/pre&gt;   The notation &lt;b&gt;Mem[0]&lt;/b&gt; references the zeroth word of memory.  The array index for memory (register vector) may be a register.  Notice that one can &lt;i&gt;not&lt;/i&gt; reference at the bit-level of a memory in Verilog HDL. If you want a specific range of bits in a word of memory, you must first transfer the data in the word to a temporary register. &lt;p&gt; &lt;/p&gt; &lt;p&gt;  &lt;b&gt; &lt;a name="RTFToC11"&gt;2.4.2 Abstract Data Types &lt;/a&gt;&lt;/b&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; In addition to modeling hardware, there are other uses for variables in a hardware model. For example, the designer might want to use an &lt;tt&gt;&lt;b&gt;integer&lt;/b&gt;&lt;/tt&gt; variable to count the number of times an event occurs. For the convenience of the designer, Verilog HDL has several data types which do not have a corresponding hardware realization. These data types include &lt;tt&gt;&lt;b&gt;integer&lt;/b&gt;&lt;/tt&gt;, &lt;tt&gt;&lt;b&gt;real&lt;/b&gt;&lt;/tt&gt; and &lt;tt&gt;&lt;b&gt;time&lt;/b&gt;&lt;/tt&gt;.  The data types &lt;tt&gt;&lt;b&gt;integer&lt;/b&gt;&lt;/tt&gt; and &lt;tt&gt;&lt;b&gt;real&lt;/b&gt;&lt;/tt&gt; behave pretty much as in other languages, e. g., C.  Be warned that a &lt;tt&gt;&lt;b&gt;reg&lt;/b&gt;&lt;/tt&gt; variable is unsigned and that an &lt;tt&gt;&lt;b&gt;integer&lt;/b&gt;&lt;/tt&gt; variable is a signed 32-bit integer.  This has important consequences when you subtract.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;  &lt;tt&gt;&lt;b&gt;time&lt;/b&gt;&lt;/tt&gt; variables hold 64-bit quantities and are used in conjunction with the &lt;tt&gt;&lt;b&gt;$time&lt;/b&gt;&lt;/tt&gt; system function.  Arrays of &lt;tt&gt;&lt;b&gt;integer&lt;/b&gt;&lt;/tt&gt; and &lt;tt&gt;&lt;b&gt;time&lt;/b&gt;&lt;/tt&gt; variables (but &lt;i&gt;not&lt;/i&gt; reals) are allowed.  Multiple dimensional arrays are &lt;i&gt;not&lt;/i&gt; allowed in Verilog HDL.  Some examples:&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;pre&gt;&lt;tt&gt;   integer Count;     // simple 32-bit integer&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   integer K[1:64];   // an array of 64 integers&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   time Start, Stop;  // Two 64-bit time variables&lt;/tt&gt; &lt;/pre&gt;  &lt;b&gt;  &lt;a name="RTFToC12"&gt;2.5 Operators &lt;/a&gt;&lt;/b&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;  &lt;b&gt; &lt;a name="RTFToC13"&gt;2.5.1 Binary Arithmetic Operators &lt;/a&gt;&lt;/b&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; Binary arithmetic operators operate on two operands. Register and net (wire) operands are treated as unsigned. However, real and integer operands may be signed. If any bit is unknown ('&lt;b&gt;x&lt;/b&gt;') then result is unknown.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;pre&gt;&lt;b&gt;   Operator Name         Comments &lt;/b&gt;  + Addition&lt;br /&gt;- Subtraction&lt;br /&gt;* Multiplication&lt;br /&gt;/ Division Divide by zero produces an &lt;b&gt;x&lt;/b&gt;.&lt;br /&gt;% Modulus&lt;br /&gt;&lt;/pre&gt;   &lt;b&gt; &lt;a name="RTFToC14"&gt;2.5.2 Unary Arithmetic Operators &lt;/a&gt;&lt;/b&gt; &lt;p&gt; &lt;/p&gt; &lt;pre&gt;&lt;b&gt;  Operator Name         Comments &lt;/b&gt;  - Unary Minus Changes sign of its operand.&lt;br /&gt;&lt;/pre&gt;   &lt;b&gt; &lt;a name="RTFToC15"&gt;2.5.3 Relational Operators &lt;/a&gt;&lt;/b&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; Relational operators compare two operands and return a logical value, i. e., TRUE(1) or FALSE(0). If any bit is unknown, the relation is ambiguous and the result is unknown. &lt;/p&gt; &lt;pre&gt;&lt;b&gt;  Operator Name                Comments &lt;/b&gt;&lt;p&gt;&lt;br /&gt;&gt; Greater than&lt;br /&gt;&gt;= Greater than or equal&lt;br /&gt;&lt; equal  ="="&gt;&lt;/p&gt;&lt;/pre&gt;  &lt;b&gt;  &lt;a name="RTFToC16"&gt;2.5.4 Logical Operators &lt;/a&gt;&lt;/b&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;  Logical operators operate on logical operands and return a logical value, i. e., TRUE(1) or FALSE(0).  Used typically in &lt;b&gt;if&lt;/b&gt; and &lt;b&gt;while&lt;/b&gt; statements. Do not confuse logical operators with the bitwise Boolean operators. For example , ! is a logical NOT and ~ is a bitwise NOT. The first negates, e. g., !(5 == 6) is TRUE. The second complements the bits, e. g., ~{1,0,1,1} is 0100.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;pre&gt;&lt;b&gt; Operator Name Comments &lt;/b&gt;  ! Logical negation&lt;br /&gt;&amp;&amp;amp; Logical AND&lt;br /&gt;|| Logical OR&lt;br /&gt;&lt;/pre&gt;   &lt;b&gt;  &lt;a name="RTFToC17"&gt;2.5.5 Bitwise Operators &lt;/a&gt;&lt;/b&gt; &lt;p&gt;  &lt;/p&gt; &lt;p&gt; Bitwise operators operate on the bits of the operand or operands. For example, the result of A &amp; B is the AND of each corresponding bit of A with B. Operating on an unknown (&lt;b&gt;x&lt;/b&gt;) bit results in the expected value.  For example, the AND of an &lt;b&gt;x&lt;/b&gt; with a FALSE is an &lt;b&gt;x&lt;/b&gt;.  The OR of an &lt;b&gt;x&lt;/b&gt; with a TRUE is a TRUE.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;pre&gt;&lt;b&gt; Operator Name Comments &lt;/b&gt;  ~  Bitwise negation&lt;br /&gt;&amp;amp;  Bitwise AND&lt;br /&gt;|  Bitwise OR&lt;br /&gt;^  Bitwise XOR&lt;br /&gt;~&amp;  Bitwise NAND&lt;br /&gt;~|  Bitwise NOR&lt;br /&gt;~^ or ^~ Equivalence Bitwise NOT XOR&lt;br /&gt;&lt;/pre&gt;   &lt;b&gt; &lt;a name="RTFToC18"&gt;2.5.6 Unary Reduction Operators &lt;/a&gt;&lt;/b&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; Unary reduction operators produce a single bit result from applying the operator to all of the bits of the operand. For example, &lt;b&gt;&amp;amp;A&lt;/b&gt; will &lt;b&gt;AND&lt;/b&gt; all the bits of &lt;b&gt;A&lt;/b&gt;.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;pre&gt;&lt;b&gt; Operator Name Comments &lt;/b&gt;  &amp; AND reduction&lt;br /&gt;| OR reduction&lt;br /&gt;^ XOR reduction&lt;br /&gt;~&amp;amp; NAND reduction&lt;br /&gt;~| NOR reduction&lt;br /&gt;~^ XNOR reduction&lt;br /&gt;&lt;/pre&gt;  &lt;b&gt;   &lt;a name="RTFToC19"&gt;2.5.7 Other Operators &lt;/a&gt;&lt;/b&gt; &lt;p&gt; &lt;b&gt; &lt;/b&gt;The conditional operator operates much like in the language C.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;pre&gt;&lt;b&gt;Operator Name Comments &lt;/b&gt;&lt;br /&gt;=== Case equality The bitwise comparison includes comparison of &lt;b&gt;x&lt;/b&gt; and &lt;b&gt;z&lt;/b&gt;&lt;br /&gt;                  values.  All bits must match for equality.  Returns TRUE&lt;br /&gt;                  or FALSE.&lt;br /&gt;!== Case inequality The bitwise comparison includes comparison of &lt;b&gt;x&lt;/b&gt; and &lt;b&gt;z&lt;/b&gt;&lt;br /&gt;                  values.  Any bit difference produces inequality.  Returns&lt;br /&gt;                  TRUE or FALSE.&lt;br /&gt;{ , } Concatenation Joins bits together with 2 or more comma-separated expressions,&lt;br /&gt;                  e, g. {A[0], B[1:7]} concatenates the zeroth bit of A to&lt;br /&gt;                  bits 1 to 7 of B.&lt;br /&gt;&lt;&lt;&gt;A = A &lt;&lt;&gt; shifts A two bits to left with zero fill.&lt;br /&gt;&gt;&gt; Shift right Vacated bit positions are filled with zeros.&lt;br /&gt;?: Conditional Assigns one of two values depending on the conditional&lt;br /&gt;                  expression.  E. g., &lt;tt&gt;A = C&gt;D ? B+3 : B-2&lt;/tt&gt;  means&lt;br /&gt;                  if C greater than D, the value of A is B+3 otherwise B-2.&lt;br /&gt;&lt;/pre&gt;&lt;b&gt;  &lt;b&gt;  &lt;a name="RTFToC20"&gt;2.5.8 &lt;/a&gt;&lt;/b&gt;&lt;a name="RTFToC20"&gt;&lt;b&gt;Operator Precedence &lt;/b&gt;&lt;/a&gt; &lt;/b&gt;&lt;p&gt;&lt;b&gt; &lt;/b&gt;&lt;/p&gt;&lt;b&gt; &lt;/b&gt;&lt;p&gt;&lt;b&gt; The precedence of operators is shown below. The top of the table is the highest precedence and the bottom is the lowest. Operators on the same line have the same precedence and associate left to right in an expression. Parentheses can be used to change the precedence or clarify the situation. We strongly urge you to use parentheses to improve readability.&lt;/b&gt;&lt;/p&gt;&lt;b&gt; &lt;/b&gt;&lt;p&gt;&lt;b&gt;  &lt;/b&gt;&lt;/p&gt;&lt;b&gt; &lt;/b&gt;&lt;center&gt;&lt;b&gt; &lt;/b&gt;&lt;pre&gt;&lt;b&gt;unary operators: &lt;tt&gt;!  &amp;  ~&amp;amp;  |  ~|  ^  ~^  +  - &lt;/tt&gt;  (highest precedence)&lt;br /&gt;&lt;tt&gt;*  /  %&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;+  -&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;&lt;  &gt;&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;  &lt;=  &gt;  &gt;+&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;==  !=  ===  ~==&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&amp;  ~&amp;amp;amp;amp;amp;amp;amp;  ^  ~^&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;|  ~|&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&amp;&amp;amp;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;||&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;?:&lt;/tt&gt; &lt;/b&gt;&lt;/pre&gt;&lt;b&gt; &lt;/b&gt;&lt;/center&gt;&lt;b&gt;   &lt;b&gt; &lt;a name="RTFToC21"&gt;2.6 Control Constructs &lt;/a&gt;&lt;/b&gt; &lt;/b&gt;&lt;p&gt;&lt;b&gt; &lt;/b&gt;&lt;/p&gt;&lt;b&gt; &lt;/b&gt;&lt;p&gt;&lt;b&gt;  Verilog HDL has a rich collection of control statements which can used in the procedural sections of code, i. e., within an &lt;tt&gt;&lt;b&gt;initial&lt;/b&gt;&lt;/tt&gt; or &lt;tt&gt;&lt;b&gt;always&lt;/b&gt;&lt;/tt&gt; block. Most of them will be familiar to the programmer of traditional programming languages like C. The main difference is instead of C's &lt;b&gt;{ }&lt;/b&gt; brackets, Verilog HDL uses &lt;tt&gt;&lt;b&gt;begin&lt;/b&gt;&lt;/tt&gt; and &lt;tt&gt;&lt;b&gt;end&lt;/b&gt;&lt;/tt&gt;.  In Verilog, the &lt;b&gt;{ }&lt;/b&gt; brackets are used for concatenation of bit strings. Since most users are familiar with C, the following subsections typically show only an example of each construct.&lt;/b&gt;&lt;/p&gt;&lt;b&gt; &lt;/b&gt;&lt;p&gt;&lt;b&gt; &lt;/b&gt;&lt;/p&gt;&lt;b&gt; &lt;/b&gt;&lt;p&gt;&lt;b&gt;  &lt;b&gt; &lt;a name="RTFToC22"&gt;2.6.1 Selection - &lt;tt&gt;if&lt;/tt&gt; and &lt;tt&gt;case&lt;/tt&gt; Statements &lt;/a&gt;&lt;/b&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt; &lt;/b&gt;&lt;p&gt;&lt;b&gt; &lt;/b&gt;&lt;/p&gt;&lt;b&gt; &lt;/b&gt;&lt;p&gt;&lt;b&gt;  The &lt;b&gt;if&lt;/b&gt; statement is easy to use.&lt;/b&gt;&lt;/p&gt;&lt;b&gt; &lt;/b&gt;&lt;p&gt;&lt;b&gt; &lt;/b&gt;&lt;/p&gt;&lt;b&gt; &lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;    if (A == 4)&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;       begin&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;         B = 2;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;       end&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;    else&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;       begin&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;         B = 4;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;       end&lt;/tt&gt; &lt;/b&gt;&lt;/pre&gt;&lt;b&gt;   Unlike the &lt;tt&gt;&lt;b&gt;case&lt;/b&gt;&lt;/tt&gt; statement in C, the first &lt;b&gt;&lt;value&gt;&lt;/value&gt;&lt;/b&gt; that matches the value of the &lt;b&gt;&lt;expression&gt;&lt;/expression&gt;&lt;/b&gt; is selected and the associated statement is executed then control is transferred to after the &lt;tt&gt;&lt;b&gt;endcase&lt;/b&gt;&lt;/tt&gt;, i. e., no &lt;tt&gt;&lt;b&gt;break&lt;/b&gt;&lt;/tt&gt; statements are needed as in C. &lt;/b&gt;&lt;p&gt;&lt;b&gt; &lt;/b&gt;&lt;/p&gt;&lt;b&gt; &lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;    case (&lt;/tt&gt;&lt;expression&gt;&lt;tt&gt;)&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;      &lt;/tt&gt;&lt;value1&gt;&lt;tt&gt;: &lt;/tt&gt;&lt;statement&gt;&lt;br /&gt;&lt;tt&gt;      &lt;/tt&gt;&lt;value2&gt;&lt;tt&gt;: &lt;/tt&gt;&lt;statement&gt;&lt;br /&gt;&lt;tt&gt;      default: &lt;/tt&gt;&lt;statement&gt;&lt;br /&gt;&lt;tt&gt;    endcase&lt;/tt&gt; &lt;/statement&gt;&lt;/statement&gt;&lt;/value2&gt;&lt;/statement&gt;&lt;/value1&gt;&lt;/expression&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;   The following example checks a 1-bit signal for its value. &lt;/b&gt;&lt;p&gt;&lt;b&gt; &lt;/b&gt;&lt;/p&gt;&lt;b&gt; &lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;    case (sig)&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;      1'bz: $display("Signal is floating");&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;      1'bx: $display("Signal is unknown");&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;      default: $display("Signal is %b", sig);&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;    endcase&lt;/tt&gt; &lt;/b&gt;&lt;/pre&gt;&lt;b&gt;   &lt;b&gt; &lt;a name="RTFToC23"&gt;2.6.2 Repetition - &lt;tt&gt;for&lt;/tt&gt;, &lt;tt&gt;while&lt;/tt&gt; and &lt;tt&gt;repeat&lt;/tt&gt; Statements &lt;/a&gt;&lt;/b&gt; &lt;/b&gt;&lt;p&gt;&lt;b&gt; &lt;/b&gt;&lt;/p&gt;&lt;b&gt; &lt;/b&gt;&lt;p&gt;&lt;b&gt;  The &lt;tt&gt;&lt;b&gt;for&lt;/b&gt;&lt;/tt&gt; statement is very close to C's &lt;tt&gt;&lt;b&gt;for&lt;/b&gt;&lt;/tt&gt; statement except that the ++ and -- operators do not exist in Verilog. Therefore, we need to use &lt;b&gt;i = i + 1&lt;/b&gt;.&lt;/b&gt;&lt;/p&gt;&lt;b&gt; &lt;/b&gt;&lt;p&gt;&lt;b&gt; &lt;/b&gt;&lt;/p&gt;&lt;b&gt; &lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;    for(i = 0; i &lt; i =" i"&gt;&lt;br /&gt;&lt;tt&gt;      begin&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;        $display("i= %0d", i);&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;      end&lt;/tt&gt; &lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;   The &lt;tt&gt;&lt;b&gt;while&lt;/b&gt;&lt;/tt&gt; statement acts in the normal fashion. &lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;    i = 0;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;    while(i &lt;&gt;&lt;br /&gt;&lt;tt&gt;       begin&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;         $display("i= %0d", i);&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;         i = i + 1;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;       end  &lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;   The &lt;tt&gt;&lt;b&gt;repeat&lt;/b&gt;&lt;/tt&gt; statement repeats the following block a fixed number of times, in this example, five times. &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;tt&gt;    repeat (5)&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;       begin&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;         $display("i= %0d", i);&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;         i = i + 1;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;       end&lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  &lt;b&gt;  &lt;a name="RTFToC24"&gt;2.7 Other Statements &lt;/a&gt;&lt;/b&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  &lt;b&gt; &lt;a name="RTFToC25"&gt;2.7.1 parameter Statement &lt;/a&gt;&lt;/b&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; The parameter statement allows the designer to give a constant a name. Typical uses are to specify width of registers and delays. For example, the following allows the designer to parameterized the declarations of a model.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;tt&gt;  parameter byte_size = 8;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  reg [byte_size - 1:0] A, B;&lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;   &lt;b&gt; &lt;a name="RTFToC26"&gt;2.7.2 Continuous Assignment &lt;/a&gt;&lt;/b&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  Continuous assignments drive &lt;tt&gt;&lt;b&gt;wire&lt;/b&gt;&lt;/tt&gt; variables and are evaluated and updated whenever an input operand changes value.  The following &lt;b&gt;and&lt;/b&gt;s the values on the wires &lt;b&gt;in1&lt;/b&gt; and &lt;b&gt;in2&lt;/b&gt; and drives the wire &lt;b&gt;out&lt;/b&gt;.  The keyword &lt;tt&gt;&lt;b&gt;assign&lt;/b&gt;&lt;/tt&gt; is used to distinguish the continuous assignment from the procedural assignment. See Section 2.3 for more discussion on continuous assignment.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  &lt;tt&gt;assign out = ~(in1 &amp; in2);&lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;   &lt;b&gt; &lt;a name="RTFToC27"&gt;2.7.3 Blocking and Non-blocking Procedural Assignments &lt;/a&gt;&lt;/b&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; The Verilog language has two forms of the procedural assignment statement: blocking and non-blocking. The two are distinguished by the &lt;tt&gt;&lt;b&gt;=&lt;/b&gt;&lt;/tt&gt; and &lt;tt&gt;&lt;b&gt;&lt;=&lt;/b&gt;&lt;/tt&gt; assignment operators. The blocking assignment statement (= operator) acts much like in traditional programming languages. The whole statement is done before control passes on to the next statement. The non-blocking (&lt;= operator) evaluates all the right-hand sides &lt;i&gt;for the current time unit &lt;/i&gt;and assigns the left-hand sides at the end of the time unit.  For example, the following Verilog program&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;tt&gt;// testing blocking and non-blocking assignment&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;module blocking;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;reg [0:7] A, B;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;initial begin: init1&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;        A = 3;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;        #1 A = A + 1;   // blocking procedural assignment&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;           B = A + 1;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;           $display("Blocking:     A= %b B= %b", A, B );&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;        A = 3;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;        #1 A &lt;= A + 1;  // non-blocking procedural assignment&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;           B &lt;= A + 1;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;          &lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;        #1 $display("Non-blocking: A= %b B= %b", A, B ); &lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;end&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;endmodule&lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  produces the following output: &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;tt&gt;Blocking:     A= 00000100 B= 00000101&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;Non-blocking: A= 00000100 B= 00000100&lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; The effect is for all the non-blocking assignments to use the old values of the variables at the beginning of the current time unit and to assign the registers new values at the end of the current time unit. This reflects how register transfers occur in some hardware systems. &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  &lt;b&gt; &lt;a name="RTFToC28"&gt;2.8 Tasks and Functions &lt;/a&gt;&lt;/b&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  &lt;b&gt;Tasks&lt;/b&gt; are like procedures in other programming languages, e. g., tasks may have zero or more arguments and do not return a value. Functions act like function subprograms in other languages. &lt;u&gt;Except:&lt;/u&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; 1. A Verilog function must execute during one simulation time unit. That is, no time controlling statements, i. e., no delay control (#), no event control (&lt;b&gt;@&lt;/b&gt;) or &lt;tt&gt;&lt;b&gt;wait&lt;/b&gt;&lt;/tt&gt; statements, allowed.  A task can contain time controlled statements.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;   2. A Verilog function can &lt;i&gt;not&lt;/i&gt; invoke (call, enable) a task; whereas a task may call other tasks and functions.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  The definition of a task is the following:&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  &lt;tt&gt;task&lt;/tt&gt; &lt;task&gt;;&lt;tt&gt;   // Notice: no list inside ()s&lt;/tt&gt;    &lt;argument&gt;&lt;br /&gt; &lt;declarations&gt;&lt;br /&gt; &lt;statements&gt;&lt;br /&gt;&lt;tt&gt;endtask&lt;/tt&gt; &lt;/statements&gt;&lt;/declarations&gt;&lt;/argument&gt;&lt;/task&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  An invocation of a task is of the following form: &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  &lt;name&gt; (&lt;port&gt;);&lt;br /&gt;&lt;/port&gt;&lt;/name&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  where &lt;b&gt;&lt;port&gt;&lt;/port&gt;&lt;/b&gt; is a list of expressions which correspond to the &lt;b&gt;&lt;argument&gt;&lt;/argument&gt;&lt;/b&gt; of the definition.  Port arguments in the definition may be &lt;tt&gt;&lt;b&gt;input&lt;/b&gt;&lt;/tt&gt;, &lt;tt&gt;&lt;b&gt;inout&lt;/b&gt;&lt;/tt&gt; or &lt;tt&gt;&lt;b&gt;output&lt;/b&gt;&lt;/tt&gt;.  Since the &lt;b&gt;&lt;argument&gt;&lt;/argument&gt;&lt;/b&gt; in the task definition look like declarations, the programmer must be careful in adding declares at the beginning of a task. &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;tt&gt;// Testing tasks and functions&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;// Dan Hyde, Aug 28, 1995&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;module tasks;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;task add;      // task definition&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt; input a, b;   // two input argument ports&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt; output c;     // one output argument port&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt; reg R;        // register declaration&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt; begin&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   R = 1;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   if (a == b)&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;     c = 1 &amp; R;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   else&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;     c = 0;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt; end&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;endtask&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;initial begin: init1&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   reg p;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   add(1, 0, p);  // invocation of task with 3 arguments&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   $display("p= %b", p);    &lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;end&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;endmodule&lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;   &lt;tt&gt;&lt;b&gt;input&lt;/b&gt;&lt;/tt&gt; and &lt;tt&gt;&lt;b&gt;inout&lt;/b&gt;&lt;/tt&gt; parameters are passed by value to the task and &lt;tt&gt;&lt;b&gt;output&lt;/b&gt;&lt;/tt&gt; and &lt;tt&gt;&lt;b&gt;inout &lt;/b&gt;&lt;/tt&gt;parameters are passed back to invocation by value on return.  Call by reference is not available. &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; Allocation of all variables is static. Therefore, a task may call itself but each invocation of the task uses the same storage, i. e., the local variables are &lt;i&gt;not&lt;/i&gt; pushed on a stack. Since concurrent threads may invoke the same task, the programmer must be aware of the static nature of storage and avoid unwanted overwriting of shared storage space.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; The purpose of a function is to return a value that is to be used in an expression. A function definition must contain at least one &lt;tt&gt;&lt;b&gt;input&lt;/b&gt;&lt;/tt&gt; argument. The passing of arguments in functions is the same as with tasks (see above). The definition of a function is the following:&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;tt&gt;function&lt;/tt&gt; &lt;range&gt; &lt;function&gt;;&lt;tt&gt; // Notice: no list inside ()s&lt;/tt&gt;   &lt;argument&gt;&lt;br /&gt;&lt;declarations&gt;&lt;br /&gt;&lt;statements&gt;&lt;br /&gt;&lt;tt&gt;endfunction&lt;/tt&gt; &lt;/statements&gt;&lt;/declarations&gt;&lt;/argument&gt;&lt;/function&gt;&lt;/range&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  where &lt;b&gt;&lt;range&gt;&lt;/range&gt;&lt;/b&gt; is the type of the results passed back to the expression where the function was called. Inside the function, one must assign the function name a value. Below is a function which is similar to the task above. &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;tt&gt;// Testing functions&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;// Dan Hyde, Aug 28, 1995&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;module functions;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;function [1:1] add2; // function definition&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt; input a, b;         // two input argument ports&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt; reg R;              // register declaration&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt; begin&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   R = 1;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   if (a == b)&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;     add2 = 1 &amp; R;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   else&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;     add2 = 0;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt; end&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;endfunction&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;initial begin: init1&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   reg p;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   p = add2(1, 0);  // invocation of function with 2 arguments&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   $display("p= %b", p);    &lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;end&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;endmodule&lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  &lt;b&gt; &lt;a name="RTFToC29"&gt;2.9 Timing Control &lt;/a&gt;&lt;/b&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; The Verilog language provides two types of explicit timing control over when simulation time procedural statements are to occur. The first type is a &lt;b&gt;delay control&lt;/b&gt; in which an expression specifies the time duration between initially encountering the statement and when the statement actually executes. The second type of timing control is the &lt;b&gt;event expression&lt;/b&gt;, which allows statement execution.  The third subsection describes the &lt;tt&gt;&lt;b&gt;wait&lt;/b&gt;&lt;/tt&gt; statement which waits for a specific variable to change.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  Verilog is a &lt;b&gt;discrete event time simulator&lt;/b&gt;, i. e., events are scheduled for discrete times and placed on an ordered-by-time wait queue. The earliest events are at the front of the wait queue and the later events are behind them. The simulator removes all the events for the current simulation time and processes them. During the processing, more events may be created and placed in the proper place in the queue for later processing. When all the events of the current time have been processed, the simulator advances time and processes the next events at the front of the queue.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  If there is no timing control, simulation time does not advance.  Simulated time can &lt;i&gt;only&lt;/i&gt; progress by one of the following:&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  1. gate or wire delay, if specified.&lt;br /&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;2. a delay control, introduced by the # symbol.&lt;br /&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;3. an event control, introduced by the &lt;b&gt;@&lt;/b&gt; symbol.&lt;br /&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;4. the &lt;tt&gt;&lt;b&gt;wait&lt;/b&gt;&lt;/tt&gt;&lt;b&gt; &lt;/b&gt;statement.&lt;br /&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;   The order of execution of events in the same clock time may not be predictable. &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;b&gt;  &lt;a name="RTFToC30"&gt;2.9.1 Delay Control (&lt;/a&gt;&lt;/b&gt; &lt;b&gt;&lt;a name="RTFToC31"&gt;#)&lt;/a&gt;&lt;/b&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;a name="RTFToC31"&gt;&lt;/a&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;a name="RTFToC31"&gt;&lt;b&gt; &lt;/b&gt;A&lt;b&gt; delay control&lt;/b&gt; expression specifies the time duration between initially encountering the statement and when the statement actually executes. For example:&lt;/a&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;a name="RTFToC31"&gt;  #10 A = A + 1;&lt;br /&gt;&lt;/a&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  &lt;a name="RTFToC31"&gt;specifies to delay 10 time units before executing the procedural assignment statement. The # may be followed by an expression with variables.&lt;/a&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;a name="RTFToC31"&gt;&lt;b&gt; 2.9.2 Events &lt;/b&gt;&lt;/a&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;b&gt; &lt;/b&gt;The execution of a procedural statement can be triggered with a value change on a wire or register, or the occurrence of a named event. Some examples:&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;tt&gt; @r begin                  // controlled by any value change in &lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  A = B&amp;C;                 // the register r&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt; end&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt; @(posedge clock2) A = B&amp;C;   // controlled by positive edge of clock2&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt; @(negedge clock3) A = B&amp;C;   // controlled by negative edge of clock3&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt; forever @(negedge clock)     // controlled by negative edge&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  begin&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  A = B&amp;C;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt; end&lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;   In the forms using &lt;tt&gt;&lt;b&gt;posedge&lt;/b&gt;&lt;/tt&gt; and &lt;tt&gt;&lt;b&gt;negedge,&lt;/b&gt;&lt;/tt&gt; they must be followed by a 1-bit expression, typically a clock.  A &lt;tt&gt;&lt;b&gt;negedge&lt;/b&gt;&lt;/tt&gt; is detected on the transition from 1 to 0 (or unknown).  A &lt;tt&gt;&lt;b&gt;posedge&lt;/b&gt;&lt;/tt&gt; is detected on the transition from 0 to 1 (or unknown). &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; Verilog also provides features to name an event and then to trigger the occurrence of that event. We must first declare the event:&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  &lt;tt&gt;event event6;&lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  To trigger the event, we use the &lt;b&gt;-&gt;&lt;/b&gt; symbol : &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;tt&gt;  -&gt; event6;&lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  To control a block of code, we use the &lt;tt&gt;&lt;b&gt;@&lt;/b&gt;&lt;/tt&gt; symbol as shown: &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;tt&gt;  @(event6)  begin&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   &lt;some&gt;&lt;/some&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  end&lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; We assume that the event occurs in one thread of control, i. e., concurrently, and the controlled code is in another thread. Several events may to &lt;b&gt;or&lt;/b&gt;-ed inside the parentheses. &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;b&gt;  &lt;a name="RTFToC32"&gt;2.9.3 Wait Statement &lt;/a&gt;&lt;/b&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;b&gt; &lt;/b&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  The &lt;tt&gt;&lt;b&gt;wait&lt;/b&gt;&lt;/tt&gt; statement allows a procedural statement or a block to be delayed until a condition becomes true.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;tt&gt;  wait (A == 3)&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  begin&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;      A = B&amp;C;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  end&lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;   The difference between the behavior of a &lt;tt&gt;&lt;b&gt;wait&lt;/b&gt;&lt;/tt&gt; statement and an event is that the &lt;tt&gt;&lt;b&gt;wait&lt;/b&gt;&lt;/tt&gt; statement is &lt;b&gt;level sensitive&lt;/b&gt; whereas &lt;tt&gt;&lt;b&gt;@(posedge clock);&lt;/b&gt;&lt;/tt&gt; is triggered by a &lt;b&gt;signal transition&lt;/b&gt; or is &lt;b&gt;edge sensitive&lt;/b&gt;. &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;b&gt;  &lt;a name="RTFToC33"&gt;2.10 Traffic Light Example &lt;/a&gt;&lt;/b&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  To demonstrate tasks as well as events, we will show a hardware model of a traffic light.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;tt&gt;// Digital model of a traffic light&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;// By Dan Hyde August 10, 1995&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;module traffic;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;parameter on = 1, off = 0, red_tics = 35, &lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;          amber_tics = 3, green_tics = 20;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;reg clock, red, amber, green;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;// will stop the simulation after 1000 time units&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;initial begin: stop_at&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   #1000; $stop;    &lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;end&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;// initialize the lights and set up monitoring of registers&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;initial begin: Init&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;    red = off; amber = off; green = off;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;    $display("                 Time green amber red");  &lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;    $monitor("%3d    %b     %b    %b", $time, green, amber, red);&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;end&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;// task to wait for 'tics' positive edge clocks&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;// before turning light off&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;task light;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   output color;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   input [31:0] tics;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   begin&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;      repeat(tics)  // wait to detect tics positive edges on clock&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;         @(posedge clock);&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;      color = off;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   end&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;endtask&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;// waveform for clock period of 2 time units&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;always begin: clock_wave&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  #1 clock = 0;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  #1 clock = 1;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;end&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;always begin: main_process&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   red = on;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   light(red, red_tics);  // call task to wait &lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   green = on;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   light(green, green_tics);&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   amber = on;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;   light(amber, amber_tics);&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;end&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;endmodule&lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  The output of the traffic light simulator is the following: &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;tt&gt;                 Time green amber red&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                   0    0     0    1&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                  70    1     0    0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                 110    0     1    0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                 116    0     0    1&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                 186    1     0    0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                 226    0     1    0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                 232    0     0    1&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                 302    1     0    0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                 342    0     1    0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                 348    0     0    1&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                 418    1     0    0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                 458    0     1    0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                 464    0     0    1&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                 534    1     0    0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                 574    0     1    0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                 580    0     0    1&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                 650    1     0    0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                 690    0     1    0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                 696    0     0    1&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                 766    1     0    0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                 806    0     1    0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                 812    0     0    1&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                 882    1     0    0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                 922    0     1    0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                 928    0     0    1&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;                 998    1     0    0&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;Stop at simulation time 1000&lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  &lt;b&gt; &lt;a name="RTFToC34"&gt;3. Using the VeriWell Simulator &lt;/a&gt;&lt;/b&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;b&gt;  &lt;a name="RTFToC35"&gt;3.1 Creating the Model File &lt;/a&gt;&lt;/b&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;b&gt; &lt;/b&gt;Enter the Verilog code using your favorite editor.  We recommend that you use "&lt;b&gt;.v&lt;/b&gt;" as the extension on the source file.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;b&gt;  &lt;a name="RTFToC36"&gt;3.2 Starting the &lt;/a&gt;&lt;/b&gt;&lt;a name="RTFToC36"&gt;&lt;b&gt;Simulator &lt;/b&gt;&lt;/a&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;b&gt; &lt;/b&gt;VeriWell is run from the UNIX shell window. Type "veriwell" followed by the names of the files containing the models and the options. The options can appear in any order and anywhere on the command line. For example:&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  host-name% veriwell cpu.v bus.v top.v -s&lt;br /&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  This will load each of the files into memory, compile them, and enter interactive mode.  Removing the "&lt;b&gt;-s&lt;/b&gt;" option would cause the simulation to begin immediately. Options are processed in the order that they appear on the command line. Files are processed in the order that they appear after the options are processed. &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;b&gt;  &lt;a name="RTFToC37"&gt;3.3 How to Exit the Simulator? &lt;/a&gt;&lt;/b&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  To exit the simulator, you can type &lt;tt&gt;&lt;b&gt;$finish;&lt;/b&gt;&lt;/tt&gt; or press &lt;b&gt;Control-d&lt;/b&gt;.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  To stop the simulation, you press &lt;b&gt;Control-c&lt;/b&gt;.  Executing a &lt;tt&gt;&lt;b&gt;$stop&lt;/b&gt;&lt;/tt&gt; system task in the code will also stop the simulation.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  &lt;b&gt; &lt;a name="RTFToC38"&gt;3.4 &lt;/a&gt;&lt;/b&gt;&lt;a name="RTFToC38"&gt;&lt;b&gt;Simulator Options &lt;/b&gt;&lt;/a&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  Commonly used options typed on the command line are shown below.  One should consult the &lt;a href="http://hdlplanet.tripod.com/verilog/verilog-manual.html#RTFToC51"&gt;&lt;i&gt;VeriWell User's Guide&lt;/i&gt;&lt;/a&gt; for the others.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;tt&gt;&lt;b&gt;-i &lt;inputfilename&gt;&lt;/inputfilename&gt;&lt;/b&gt;&lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; Specifies a file that contains interactive commands to be executed as soon as interactive command mode is entered. This option should be used with the "&lt;b&gt;-s&lt;/b&gt;" option.  This can be used to initialize variables and set time limits on the simulation. &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;tt&gt;&lt;b&gt;-s&lt;/b&gt;&lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  Causes interactive mode to be entered before the simulation begins. &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;tt&gt;&lt;b&gt;-t&lt;/b&gt;&lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  Causes all statements to be traced.  Trace mode may be disabled with the &lt;tt&gt;&lt;b&gt;$cleartrace&lt;/b&gt;&lt;/tt&gt; system task. &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;b&gt;  &lt;a name="RTFToC39"&gt;3.5 &lt;/a&gt;&lt;/b&gt;&lt;a name="RTFToC39"&gt;&lt;b&gt;Debugging &lt;/b&gt;&lt;/a&gt; &lt;b&gt;Using VeriWell's Interactive Mode&lt;/b&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; VeriWell is interactive. Once invoked, the simulation can be controlled with simple commands. Also, VeriWell accepts any Verilog statement (but new modules or declarations cannot be added).&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  Interactive mode is entered in one of three ways:&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  1). When the "&lt;b&gt;-s&lt;/b&gt;" option is used on the command line (or in a command file), interactive mode is entered before the simulation begins,&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  2). When the simulation encounters the &lt;tt&gt;&lt;b&gt;$stop&lt;/b&gt;&lt;/tt&gt; system task, or, &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  3). When the user types &lt;b&gt;Control-c&lt;/b&gt; during simulation (but not during compilation).&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;b&gt;Interactive Commands&lt;/b&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; Continue ('&lt;b&gt;.&lt;/b&gt;') [period]&lt;br /&gt;Resume execution from the current location.&lt;br /&gt;&lt;br /&gt;Single-step with trace (',') [comma]&lt;br /&gt;Execute a single statement and display the trace for that statement.&lt;br /&gt;&lt;br /&gt;Single-step without trace ('&lt;b&gt;;&lt;/b&gt;') [semicolon]&lt;br /&gt;Execute a single statement without trace.&lt;br /&gt;&lt;br /&gt;Current location ('&lt;b&gt;:&lt;/b&gt;') [colon]&lt;br /&gt;Display the current location.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Control-d &lt;/b&gt;or&lt;b&gt; $finish;&lt;/b&gt;&lt;br /&gt;Exit VeriWell simulator.&lt;br /&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  Typically, the kinds of Verilog statements executed interactively are used for debugging and information-gathering.  &lt;tt&gt;&lt;b&gt;$display &lt;/b&gt;&lt;/tt&gt;and &lt;tt&gt;&lt;b&gt;$showvars&lt;/b&gt;&lt;/tt&gt; can be typed at the interactive prompt to show the values of variables. Notice the complete system task statement must be typed including parameters and semicolon. &lt;tt&gt;&lt;b&gt;$scope(&lt;name&gt;);&lt;/name&gt;&lt;/b&gt;&lt;/tt&gt; and &lt;tt&gt;&lt;b&gt;$showscopes;&lt;/b&gt;&lt;/tt&gt; can be typed to traverse the model hierarchy. &lt;tt&gt;&lt;b&gt;$settrace;&lt;/b&gt;&lt;/tt&gt; and &lt;tt&gt;&lt;b&gt;$cleartrace;&lt;/b&gt;&lt;/tt&gt; will enter and exit trace mode. Typing "&lt;tt&gt;&lt;b&gt;#100; $stop;&lt;/b&gt;&lt;/tt&gt;" will stop the execution after 100 simulation units. &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;b&gt; &lt;a name="RTFToC40"&gt;4. System Tasks and Functions &lt;/a&gt;&lt;/b&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; System tasks are not part of the Verilog language but are build-in tasks contained in a library. A few of the more commonly used one are described below. The Verilog Language Reference Manual has many more.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  &lt;b&gt; &lt;a name="RTFToC41"&gt;4.1&lt;/a&gt;&lt;/b&gt; &lt;a name="RTFToC41"&gt;&lt;tt&gt;&lt;b&gt;$cleartrace &lt;/b&gt;&lt;/tt&gt;&lt;/a&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  The &lt;tt&gt;&lt;b&gt;$cleartrace&lt;/b&gt;&lt;/tt&gt; system task turns off the trace.  See &lt;tt&gt;&lt;b&gt;$settrace&lt;/b&gt;&lt;/tt&gt; system task to set the trace.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  &lt;tt&gt;$cleartrace;&lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;   &lt;b&gt; &lt;a name="RTFToC42"&gt;4.2 &lt;/a&gt;&lt;/b&gt;&lt;a name="RTFToC42"&gt;&lt;tt&gt;&lt;b&gt;$display &lt;/b&gt;&lt;/tt&gt;&lt;/a&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  Displays text to the screen much like the &lt;tt&gt;&lt;b&gt;printf&lt;/b&gt;&lt;/tt&gt; statement from the language C.  The general form is &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  &lt;tt&gt;$display(&lt;/tt&gt;&lt;parameter&gt;, &lt;parameter&gt;, ... &lt;parameter&gt;);&lt;/parameter&gt;&lt;/parameter&gt;&lt;/parameter&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  where &lt;b&gt;&lt;parameter&gt;&lt;/parameter&gt;&lt;/b&gt; may be a quoted string, an expression that returns a value or a null parameter.  For example, the following displays a header. &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;tt&gt;  $display("Registers:   A   B   C");&lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; The special character % indicates that the next character is a format specification. For each % character that appears in the string, a corresponding expression must be supplied after the string. For example, the following prints the value of A in binary, octal, decimal and hex. &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  &lt;tt&gt;$display("A=%b binary %o octal %d decimal %h hex",A,A,A,A);&lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  produces the following output &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;A=00001111 binary 017 octal  15 decimal 0f hex&lt;br /&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  The commonly used format specifiers are &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  &lt;tt&gt;%b &lt;/tt&gt; display in binary format&lt;br /&gt;&lt;tt&gt;%c&lt;/tt&gt; display in ASCII character format&lt;br /&gt;&lt;tt&gt;%d&lt;/tt&gt; display in decimal format&lt;br /&gt;&lt;tt&gt;%h&lt;/tt&gt; display in hex format&lt;br /&gt;&lt;tt&gt;%o&lt;/tt&gt; display in octal format&lt;br /&gt;&lt;tt&gt;%s&lt;/tt&gt; display in string format&lt;br /&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; A 0 between the % and format specifier allocates the exact number of characters required to display the expression result, instead of the expression's largest possible value (the default). For example, this is useful for displaying the time as shown by the difference between the following two &lt;tt&gt;&lt;b&gt;$display&lt;/b&gt;&lt;/tt&gt; statements. &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;tt&gt;  $display("Time = %d", $time);&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;  $display("Time = %0d", $time);&lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  produces the following output &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;tt&gt;Time =                    1&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;Time = 1&lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;   Escape sequences may be included in a string.  The commonly used escape sequences are the following: &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  &lt;tt&gt;\n&lt;/tt&gt; the newline character&lt;br /&gt;&lt;tt&gt;\t&lt;/tt&gt; the tab character&lt;br /&gt;\\ the &lt;tt&gt;\&lt;/tt&gt; character&lt;br /&gt;\" the &lt;tt&gt;" &lt;/tt&gt;character&lt;br /&gt;&lt;tt&gt;%%&lt;/tt&gt; the percent sign&lt;br /&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; A null parameter produces a single space character in the display. A null parameter is characterized by two adjacent commas in the parameter list. &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  Note that &lt;tt&gt;&lt;b&gt;$display&lt;/b&gt;&lt;/tt&gt; automatically adds a newline character to the end of its output.  See &lt;tt&gt;&lt;b&gt;$write&lt;/b&gt;&lt;/tt&gt; in Verilog Language Reference Manual if you don't want a newline.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;   &lt;a name="RTFToC43"&gt;4.3 &lt;tt&gt;&lt;b&gt;$finish &lt;/b&gt;&lt;/tt&gt;&lt;/a&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  The &lt;tt&gt;&lt;b&gt;$finish&lt;/b&gt;&lt;/tt&gt; system task exits the simulator to the host operating system.  Don't forget to type the semicolon while in interactive mode.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;   $finish;&lt;br /&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;   &lt;b&gt; &lt;a name="RTFToC44"&gt;4.4 &lt;tt&gt;$monitor &lt;/tt&gt;&lt;/a&gt;&lt;/b&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  The &lt;tt&gt;&lt;b&gt;$monitor&lt;/b&gt;&lt;/tt&gt; system task provides the ability to monitor and display the values of any variable or expression specified as parameters to the task. The parameters are specified in exactly the same manner as the &lt;tt&gt;&lt;b&gt;$display&lt;/b&gt;&lt;/tt&gt; system task.  When you invoke the &lt;tt&gt;&lt;b&gt;$monitor&lt;/b&gt;&lt;/tt&gt; task, the simulator sets up a mechanism whereby each time a variable or an expression in the parameter list changes value, with the exception of &lt;tt&gt;&lt;b&gt;$time&lt;/b&gt;&lt;/tt&gt;, the entire parameter list is displayed at the end of the time step as if reported by the &lt;tt&gt;&lt;b&gt;$display&lt;/b&gt;&lt;/tt&gt; task. If two or more parameters change values at the same time, however, only one display is produced. For example, the following will display a line anytime one of the registers A, B or C changes.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;   &lt;tt&gt;$monitor("  %0d %b %b "%b, $time, A, B, C);&lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;   Only one &lt;tt&gt;&lt;b&gt;$monitor&lt;/b&gt;&lt;/tt&gt; statement may be active at any one time. The monitoring may be turned off and on by the following: &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;tt&gt;  $monitoroff;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;    &lt;/tt&gt;&lt;some&gt;&lt;br /&gt;&lt;tt&gt;  $monitoron;&lt;/tt&gt; &lt;/some&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;   &lt;b&gt; &lt;a name="RTFToC45"&gt;4.5 &lt;tt&gt;$scope &lt;/tt&gt;&lt;/a&gt;&lt;/b&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  The &lt;tt&gt;&lt;b&gt;$scope&lt;/b&gt;&lt;/tt&gt; system task lets the user assign a particular level of hierarchy as the interactive scope for identifying objects. &lt;tt&gt;&lt;b&gt;$scope&lt;/b&gt;&lt;/tt&gt; is useful during debugging as the user may change the scope to inspect the values of variables in different modules, tasks and functions.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  $scope(&lt;name&gt;&lt;tt&gt;);&lt;/tt&gt; &lt;/name&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  The &lt;b&gt;&lt;name&gt;&lt;/name&gt;&lt;/b&gt; parameter must be the complete hierarchical name of a module, task, function or named block.  See &lt;tt&gt;&lt;b&gt;$showscopes&lt;/b&gt;&lt;/tt&gt; system task to display the names. &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  &lt;b&gt; &lt;a name="RTFToC46"&gt;4.6&lt;/a&gt;&lt;/b&gt; &lt;a name="RTFToC46"&gt;&lt;tt&gt;&lt;b&gt;$settrace &lt;/b&gt;&lt;/tt&gt;&lt;/a&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  The &lt;tt&gt;&lt;b&gt;$settrace&lt;/b&gt;&lt;/tt&gt; system task enables tracing of simulation activity. The trace consists of various information, including the current simulation time, the line number, the file name, module and any results from executing the statement.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  &lt;tt&gt;$settrace;&lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;   You can turn off the trace using the &lt;tt&gt;&lt;b&gt;$cleartrace&lt;/b&gt;&lt;/tt&gt; system task. &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  &lt;b&gt; &lt;a name="RTFToC47"&gt;4.7&lt;/a&gt;&lt;/b&gt; &lt;a name="RTFToC47"&gt;&lt;tt&gt;&lt;b&gt;$showscopes &lt;/b&gt;&lt;/tt&gt;&lt;/a&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  The &lt;tt&gt;&lt;b&gt;$showscopes&lt;/b&gt;&lt;/tt&gt; system task displays a complete lists of all the modules, tasks, functions and named blocks that are defined &lt;i&gt;at the current scope level.&lt;/i&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  &lt;tt&gt;$showscopes;&lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt; &lt;b&gt;&lt;br /&gt;&lt;a name="RTFToC48"&gt;4.8&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;&lt;a name="RTFToC48"&gt;&lt;tt&gt;&lt;b&gt;$showvars&lt;br /&gt;&lt;/b&gt;&lt;/tt&gt;&lt;/a&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;The &lt;tt&gt;&lt;b&gt;$showvars&lt;/b&gt;&lt;/tt&gt; system task produces status information for&lt;br /&gt;register and net (wires) variables, both scalar and vector.  When invoked&lt;br /&gt;without parameters, &lt;tt&gt;&lt;b&gt;$showvars&lt;/b&gt;&lt;/tt&gt; displays the status of all&lt;br /&gt;variables in the current scope.  When invoked with a list of variables, it&lt;br /&gt;shows only the status of the specified variables.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  &lt;tt&gt;$showvars;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;$showvars(&lt;/tt&gt;&lt;list&gt;&lt;tt&gt;);&lt;/tt&gt; &lt;/list&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;a name="RTFToC49"&gt;4.9&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;&lt;a name="RTFToC49"&gt;&lt;tt&gt;&lt;b&gt;$stop&lt;br /&gt;&lt;/b&gt;&lt;/tt&gt;&lt;/a&gt;&lt;br /&gt;&lt;tt&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;The &lt;tt&gt;&lt;b&gt;$stop&lt;/b&gt;&lt;/tt&gt; system task puts the simulator into&lt;br /&gt;a halt mode, issues an interactive command prompt  and passes control to the&lt;br /&gt;user.  See Section 3.5 on using VeriWell's interactive mode.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;  &lt;tt&gt;$stop;&lt;/tt&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;a name="RTFToC50"&gt;4.10&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;&lt;a name="RTFToC50"&gt;&lt;tt&gt;&lt;b&gt;$time&lt;br /&gt;&lt;/b&gt;&lt;/tt&gt;&lt;/a&gt; &lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;The &lt;tt&gt;&lt;b&gt;$time&lt;/b&gt;&lt;/tt&gt; system function returns the current simulation time&lt;br /&gt;as a 64-bit integer.  &lt;tt&gt;&lt;b&gt;$time&lt;/b&gt;&lt;/tt&gt; must be used in an expression.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;hr /&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;a name="RTFToC51"&gt;References&lt;/a&gt;&lt;/b&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;1. Cadence Design Systems, Inc., &lt;i&gt;Verilog-XL Reference Manual.&lt;/i&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;2. Open Verilog International (OVI), &lt;i&gt;Verilog HDL Language Reference Manual&lt;br /&gt;(LRM)&lt;/i&gt;, 15466 Los Gatos Boulevard, Suite 109-071, Los Gatos, CA 95032; Tel:&lt;br /&gt;(408)353-8899, Fax: (408) 353-8869, Email: OVI@netcom.com, $100.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;3. Sternheim, E. , R. Singh, Y. Trivedi, R. Madhaven and W. Stapleton,&lt;br /&gt;&lt;i&gt;Digital Design and Synthesis with Verilog HDL&lt;/i&gt;, published by Automata&lt;br /&gt;Publishing Co., Cupertino, CA, 1993, ISBN 0-9627488-2-X, $65.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;4. Thomas, Donald E., and Philip R. Moorby, &lt;i&gt;The Verilog Hardware Description&lt;br /&gt;Language&lt;/i&gt;, second edition, published by Kluwer Academic Publishers, Norwell&lt;br /&gt;MA, 1994, ISBN 0-7923-9523-9, $98, includes DOS version of VeriWell simulator&lt;br /&gt;and programs on diskette.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;5. Wellspring Solutions, Inc., &lt;i&gt;VeriWell User's Guide&lt;/i&gt; &lt;i&gt;1.2&lt;/i&gt;, August,&lt;br /&gt;1994, part of free distribution of VeriWell, available online.&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;6. World Wide Web Pages:&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;FAQ for comp.lang.verilog - http://www.cray.com/verilog/verilog-faq.html&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;comp.lang.verilog archives - http://www.cray.com/verilog/archive.html&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;Cadence Design Systems, Inc. - http://www.cadence.com/&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;Wellspring Solutions, Inc. - ftp://iii.net/pub/pub-site/wellspring&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;&lt;tt&gt;&lt;br /&gt;Verilog research at Cambridge, England -&lt;br /&gt;http://www.cl.cam.uk/users/mjcg/Verilog/&lt;/tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/p&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6837615239980912050-626717168962342081?l=techfundaoftheday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techfundaoftheday.blogspot.com/feeds/626717168962342081/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6837615239980912050&amp;postID=626717168962342081' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6837615239980912050/posts/default/626717168962342081'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6837615239980912050/posts/default/626717168962342081'/><link rel='alternate' type='text/html' href='http://techfundaoftheday.blogspot.com/2007/01/verilog-in-1-day.html' title='Verilog in 1 day !!!!'/><author><name>kdkariya</name><uri>http://www.blogger.com/profile/16154005894727727725</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp1.blogger.com/_GBhwIPW1FbY/SAltSM1KEPI/AAAAAAAAA5Q/kBl9S8H8r80/S220/DSC05163.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6837615239980912050.post-72182595819024449</id><published>2007-01-09T20:55:00.000-08:00</published><updated>2007-01-28T21:31:39.924-08:00</updated><title type='text'>Core 2 Duo Vs. Core Duo</title><content type='html'>&lt;a href="http://crave.cnet.co.uk/laptops/0,39029450,49283370,00.htm"&gt;Core 2 Duo Vs Core Duo&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6837615239980912050-72182595819024449?l=techfundaoftheday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techfundaoftheday.blogspot.com/feeds/72182595819024449/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6837615239980912050&amp;postID=72182595819024449' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6837615239980912050/posts/default/72182595819024449'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6837615239980912050/posts/default/72182595819024449'/><link rel='alternate' type='text/html' href='http://techfundaoftheday.blogspot.com/2007/01/core-2-duo-vs-core-duo.html' title='Core 2 Duo Vs. Core Duo'/><author><name>kdkariya</name><uri>http://www.blogger.com/profile/16154005894727727725</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp1.blogger.com/_GBhwIPW1FbY/SAltSM1KEPI/AAAAAAAAA5Q/kBl9S8H8r80/S220/DSC05163.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6837615239980912050.post-36430754800842375</id><published>2007-01-09T04:06:00.000-08:00</published><updated>2007-01-09T04:07:25.787-08:00</updated><title type='text'>BFM - Bus functional Model</title><content type='html'>&lt;span style="font-family:Verdana,Arial,Helvetica;font-size:85%;color:black;"&gt;Bus functional models are simplified simulation models that accurately reflect the I/O level behavior of a device without modeling its internal computational abilities. For example, a bus functional model of a microprocessor would be able to generate PCI read and write transactions to a PCI device model to initialize and test the PCI device's functionality, but the microprocessor BFM would not be capable of reading CPU instructions from a memory and properly executing the instructions (this would require a complete behavioral level model of the processor). Bus functional models are commonly used in test benches to stimulate design models and verify their functionality&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6837615239980912050-36430754800842375?l=techfundaoftheday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techfundaoftheday.blogspot.com/feeds/36430754800842375/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6837615239980912050&amp;postID=36430754800842375' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6837615239980912050/posts/default/36430754800842375'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6837615239980912050/posts/default/36430754800842375'/><link rel='alternate' type='text/html' href='http://techfundaoftheday.blogspot.com/2007/01/bfm-bus-functional-model.html' title='BFM - Bus functional Model'/><author><name>kdkariya</name><uri>http://www.blogger.com/profile/16154005894727727725</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp1.blogger.com/_GBhwIPW1FbY/SAltSM1KEPI/AAAAAAAAA5Q/kBl9S8H8r80/S220/DSC05163.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6837615239980912050.post-5007479746374597569</id><published>2007-01-02T04:01:00.000-08:00</published><updated>2007-01-02T04:03:28.165-08:00</updated><title type='text'>GAIM: Connect and Use Google's Gtalk Servers</title><content type='html'>Since gtalk is based on jabber, however, you can use it with any jabber compatable client. Here is how to use the wonderful freeware program &lt;a href="http://gaim.sourceforge.net/" target="_blank" class="postlink"&gt;GAIM&lt;/a&gt; to connect to the gtalk/google servers.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt; 1. Open &lt;span style="font-weight: bold;"&gt;GAIM&lt;/span&gt;&lt;br /&gt;2. From the buddy list screen, click &lt;span style="font-weight: bold;"&gt;Tools&lt;/span&gt;&lt;br /&gt;3. Then click &lt;span style="font-weight: bold;"&gt;Accounts&lt;/span&gt;&lt;br /&gt;4. Click the &lt;span style="font-weight: bold;"&gt;Add&lt;/span&gt; button&lt;br /&gt;5. Select &lt;span style="font-weight: bold;"&gt;Jabber&lt;/span&gt; as the protocol&lt;br /&gt;6. Your &lt;span style="font-weight: bold;"&gt;screen name &lt;/span&gt;is your gmail login.  (For example, &lt;span style="font-weight: bold;"&gt;login&lt;/span&gt;@gmail.com)&lt;br /&gt;7. Server is &lt;span style="font-weight: bold;"&gt;gmail.com&lt;/span&gt;&lt;br /&gt;8. Resource is &lt;span style="font-weight: bold;"&gt;Gaim&lt;/span&gt;&lt;br /&gt;9. Your &lt;span style="font-weight: bold;"&gt;password&lt;/span&gt; is your gmail password.&lt;br /&gt;10. Select as &lt;span style="font-weight: bold;"&gt;alias&lt;/span&gt; what you want to be called on your IM screen. If you leave this blank, it'll use your whole gmail address which is way too big for your little IM screen. If nothing else, just put in &lt;span style="font-weight: bold;"&gt;Me&lt;/span&gt; in the alias box.&lt;br /&gt;11. Click &lt;span style="font-weight: bold;"&gt;Show More Options&lt;/span&gt;&lt;br /&gt;12. Select the &lt;span style="font-weight: bold;"&gt;Use TLS if available &lt;/span&gt;checkbox&lt;br /&gt;13. As you connect server type: &lt;span style="font-weight: bold;"&gt;talk.google.com&lt;/span&gt;&lt;br /&gt;14. Click &lt;span style="font-weight: bold;"&gt;Save&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;Ref: http://www.tech-recipes.com/instant_messaging_tips1180.html&lt;br /&gt; &lt;br /&gt;Keywords: gtalk, gaim, google talk&lt;br /&gt;&lt;/span&gt; &lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6837615239980912050-5007479746374597569?l=techfundaoftheday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techfundaoftheday.blogspot.com/feeds/5007479746374597569/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6837615239980912050&amp;postID=5007479746374597569' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6837615239980912050/posts/default/5007479746374597569'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6837615239980912050/posts/default/5007479746374597569'/><link rel='alternate' type='text/html' href='http://techfundaoftheday.blogspot.com/2007/01/gaim-connect-and-use-googles-gtalk.html' title='GAIM: Connect and Use Google&apos;s Gtalk Servers'/><author><name>kdkariya</name><uri>http://www.blogger.com/profile/16154005894727727725</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp1.blogger.com/_GBhwIPW1FbY/SAltSM1KEPI/AAAAAAAAA5Q/kBl9S8H8r80/S220/DSC05163.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6837615239980912050.post-8694119405931904044</id><published>2006-12-21T22:44:00.000-08:00</published><updated>2006-12-21T22:51:20.348-08:00</updated><title type='text'>LFSR - Linear Feedback Shift Registers</title><content type='html'>&lt;i&gt;Linear Feedback Shift Register (LFSR)&lt;/i&gt;, in which the output from a standard shift &lt;a href="http://www.pldesignline.com/encyclopedia/defineterm.jhtml?term=register&amp;x=&amp;amp;y="&gt;register&lt;/a&gt; is cunningly manipulated and fed back into its input in such a way as to cause the function to endlessly cycle through a sequence of patterns. &lt;p&gt; &lt;b&gt;Many-to-one implementations&lt;/b&gt;&lt;br /&gt;LFSRs are simple to construct and are useful for a wide variety of applications, but are often sadly neglected by designers. One of the more common forms of LFSR is formed from a simple shift register with feedback from two or more points, or &lt;i&gt;taps&lt;/i&gt;, in the register chain (&lt;i&gt;Fig 1&lt;/i&gt;). &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;center&gt;&lt;img src="http://i.cmpnet.com/pldesignline/2006/12/lfsr-01-01.gif" border="0" /&gt;&lt;br /&gt;&lt;i&gt;1. LFSR with XOR feedback path.&lt;/i&gt;&lt;/center&gt;  &lt;p&gt; The taps in this example are at bit 0 and &lt;a href="http://www.pldesignline.com/encyclopedia/defineterm.jhtml?term=bit&amp;x=&amp;amp;y="&gt;bit&lt;/a&gt; 2, and can be referenced as [0,2]. All of the register elements share a common &lt;a href="http://www.pldesignline.com/encyclopedia/defineterm.jhtml?term=clock&amp;x=&amp;amp;y="&gt;clock&lt;/a&gt; input, which is omitted from the symbol for reasons of clarity. The data input to the LFSR is generated by XOR-ing or XNOR-ing the tap bits; the remaining bits function as a standard shift register. The sequence of values generated by an LFSR is determined by its feedback function (XOR versus XNOR) and tap selection. For example, consider two 3-bit XOR based LFSRs with different tap selections (&lt;i&gt;Fig 2&lt;/i&gt;). &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;center&gt;&lt;img src="http://i.cmpnet.com/pldesignline/2006/12/lfsr-01-02.gif" border="0" /&gt;&lt;br /&gt;&lt;i&gt;2. Comparison of alternative tap selections.&lt;/i&gt;&lt;/center&gt;  &lt;p&gt; Both LFSRs start with the same initial value but, due to the different taps, their sequences rapidly diverge as clock pulses are applied. In some cases an LFSR will end up cycling round a loop comprising a limited number of values. However, both of the LFSRs shown in &lt;i&gt;Fig 2&lt;/i&gt; are said to be of &lt;i&gt;maximal length&lt;/i&gt; because they sequence through every possible value (excluding all of the bits being 0) before returning to their initial values. &lt;/p&gt; &lt;p&gt;A binary field with 'n' bits can assume 2^n unique values, but a maximal-length LFSR with 'n' register bits will only sequence through (2^n – 1) values. This is because LFSRs with XOR feedback paths will not sequence through the value where all the bits are 0, while their XNOR equivalents will not sequence through the value where all the bits are 1 (&lt;i&gt;Fig 3&lt;/i&gt;). &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;center&gt;&lt;img src="http://i.cmpnet.com/pldesignline/2006/12/lfsr-01-03.gif" border="0" /&gt;&lt;br /&gt;&lt;i&gt;3. Comparison of XOR versus XNOR feedback paths.&lt;/i&gt;&lt;/center&gt;   &lt;!-- &lt;/div&gt; --&gt;                &lt;!--end body--&gt;  &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;center&gt;&lt;i&gt;&lt;/i&gt;&lt;br /&gt;&lt;/center&gt;   &lt;!-- &lt;/div&gt; --&gt;                &lt;!--end body--&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6837615239980912050-8694119405931904044?l=techfundaoftheday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techfundaoftheday.blogspot.com/feeds/8694119405931904044/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6837615239980912050&amp;postID=8694119405931904044' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6837615239980912050/posts/default/8694119405931904044'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6837615239980912050/posts/default/8694119405931904044'/><link rel='alternate' type='text/html' href='http://techfundaoftheday.blogspot.com/2006/12/lfsr-linear-feedback-shift-registers.html' title='LFSR - Linear Feedback Shift Registers'/><author><name>kdkariya</name><uri>http://www.blogger.com/profile/16154005894727727725</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp1.blogger.com/_GBhwIPW1FbY/SAltSM1KEPI/AAAAAAAAA5Q/kBl9S8H8r80/S220/DSC05163.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6837615239980912050.post-9222024503912431115</id><published>2006-12-18T07:09:00.000-08:00</published><updated>2008-05-12T03:07:06.834-07:00</updated><title type='text'>Verilog Free Simulator and Viewer</title><content type='html'>&lt;a href="http://www.icarus.com/eda/verilog" style="text-decoration: none;"&gt;Icarus Verilog  &lt;/a&gt;: This is best Free Verilog simulator out there, it is simulation and synthesis tool. It operates as a compiler, compiling source code written in Verilog (IEEE-1364) into some target format. For batch simulation, the compiler can generate an intermediate form called vvp assembly. This intermediate form is executed by the ``vvp'' command. Icarus continues to get better and better. Icarus is being used for real design work by companies now as a simulator, and is starting to be useful as a synthesizer for a Xilinx FPGA flow as well.&lt;br /&gt;&lt;a href="http://www.veripool.com/" style="text-decoration: none;"&gt;Dinotrace  &lt;/a&gt;: Freeware VCD viewer from veritools&lt;br /&gt;&lt;br /&gt;I have tested above combination on linux. Both works fine...and is good to start with.&lt;br /&gt;&lt;br /&gt;Sample Design:&lt;br /&gt;^^^^^^^^^^^^&lt;br /&gt;//-----------------------------------------------------&lt;br /&gt;module encoder_using_if(&lt;br /&gt;binary_out , //  4 bit binary output&lt;br /&gt;encoder_in , //  16-bit input&lt;br /&gt;enable       //  Enable for the encoder&lt;br /&gt;);&lt;br /&gt;//-----------Output Ports---------------&lt;br /&gt;output [3:0] binary_out  ;&lt;br /&gt;//-----------Input Ports---------------&lt;br /&gt;input  enable ;&lt;br /&gt;input [15:0] encoder_in ;&lt;br /&gt;//------------Internal Variables--------&lt;br /&gt;reg [3:0] binary_out ;&lt;br /&gt;//-------------Code Start-----------------&lt;br /&gt;always @ (enable or encoder_in)&lt;br /&gt;begin&lt;br /&gt; binary_out = 0;&lt;br /&gt; if (enable) begin&lt;br /&gt;   if (encoder_in == 16'h0002) begin&lt;br /&gt;    binary_out = 1;&lt;br /&gt;   end  if (encoder_in == 16'h0004) begin&lt;br /&gt;    binary_out = 2;&lt;br /&gt;   end  if (encoder_in == 16'h0008) begin&lt;br /&gt;    binary_out = 3;&lt;br /&gt;   end  if (encoder_in == 16'h0010) begin&lt;br /&gt;    binary_out = 4;&lt;br /&gt;   end  if (encoder_in == 16'h0020) begin&lt;br /&gt;    binary_out = 5;&lt;br /&gt;   end  if (encoder_in == 16'h0040) begin&lt;br /&gt;    binary_out = 6;&lt;br /&gt;   end  if (encoder_in == 16'h0080) begin&lt;br /&gt;    binary_out = 7;&lt;br /&gt;   end  if (encoder_in == 16'h0100) begin&lt;br /&gt;    binary_out = 8;&lt;br /&gt;   end  if (encoder_in == 16'h0200) begin&lt;br /&gt;    binary_out = 9;&lt;br /&gt;   end if (encoder_in == 16'h0400) begin&lt;br /&gt;    binary_out = 10;&lt;br /&gt;   end  if (encoder_in == 16'h0800) begin&lt;br /&gt;    binary_out = 11;&lt;br /&gt;   end  if (encoder_in == 16'h1000) begin&lt;br /&gt;    binary_out = 12;&lt;br /&gt;   end  if (encoder_in == 16'h2000) begin&lt;br /&gt;    binary_out = 13;&lt;br /&gt;   end  if (encoder_in == 16'h4000) begin&lt;br /&gt;    binary_out = 14;&lt;br /&gt;   end if (encoder_in == 16'h8000) begin&lt;br /&gt;    binary_out = 15;&lt;br /&gt;   end&lt;br /&gt;end&lt;br /&gt;end&lt;br /&gt;endmodule&lt;br /&gt;&lt;br /&gt;TestBench:&lt;br /&gt;`timescale 1ns/1ps&lt;br /&gt;`include "encoder_using_if.v"&lt;br /&gt;module encoder_test;&lt;br /&gt;wire [3:0] binary_out;&lt;br /&gt;reg enable;&lt;br /&gt;reg [15:0] encoder_in;&lt;br /&gt;&lt;br /&gt;encoder_using_if encode(.binary_out (binary_out), .encoder_in (encoder_in) , .enable (enable));&lt;br /&gt;&lt;br /&gt;initial begin&lt;br /&gt;#1 enable = 0;&lt;br /&gt; encoder_in = 16'h0;&lt;br /&gt;&lt;br /&gt;#2 enable = 1;&lt;br /&gt; encoder_in = 16'h0001;&lt;br /&gt;&lt;br /&gt;#3&lt;br /&gt; encoder_in = 16'h0010;&lt;br /&gt;#1 $finish;&lt;br /&gt;end&lt;br /&gt;initial begin&lt;br /&gt; $monitor("Encoder out = %h \n",binary_out);&lt;br /&gt;end&lt;br /&gt;//always @ (enable or encoder_in)&lt;br /&gt;initial&lt;br /&gt;begin&lt;br /&gt; $dumpfile( "foo.vcd" );&lt;br /&gt; $dumpvars( 0, encoder_test );&lt;br /&gt;end&lt;br /&gt;endmodule&lt;br /&gt;&lt;br /&gt;Command Used:&lt;br /&gt;^^^^^^^^^^^^^&lt;br /&gt;&lt;br /&gt;iverilog testbench.v&lt;br /&gt;./a.out&lt;br /&gt;./dinotrace foo.vcd&lt;br /&gt;&lt;br /&gt;Keywords: Verilog, free simulator, waveform viewer, &lt;a href="http://www.icarus.com/eda/verilog" style="text-decoration: none;"&gt;Icarus Verilog&lt;/a&gt;, Dinotrace&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6837615239980912050-9222024503912431115?l=techfundaoftheday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techfundaoftheday.blogspot.com/feeds/9222024503912431115/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6837615239980912050&amp;postID=9222024503912431115' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6837615239980912050/posts/default/9222024503912431115'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6837615239980912050/posts/default/9222024503912431115'/><link rel='alternate' type='text/html' href='http://techfundaoftheday.blogspot.com/2006/12/verilog-free-simulator-and-viewer.html' title='Verilog Free Simulator and Viewer'/><author><name>kdkariya</name><uri>http://www.blogger.com/profile/16154005894727727725</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp1.blogger.com/_GBhwIPW1FbY/SAltSM1KEPI/AAAAAAAAA5Q/kBl9S8H8r80/S220/DSC05163.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6837615239980912050.post-2226371881633515322</id><published>2006-12-18T02:59:00.000-08:00</published><updated>2006-12-19T01:27:38.998-08:00</updated><title type='text'>Latex</title><content type='html'>&lt;h3 style="text-align: justify;"&gt;&lt;span class="mw-headline"&gt;What is TeX&lt;/span&gt;&lt;/h3&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;p style="text-align: justify;"&gt;&lt;b&gt;&lt;a href="http://en.wikibooks.org/wiki/TeX" title="TeX"&gt;TeX&lt;/a&gt;&lt;/b&gt; (pronounced "Tech") is mainly a low level programming language aimed to typesetting documents. It is very powerful but, since you have to take care of everything, it is difficult and time-consuming to use it for long documents.&lt;/p&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;p style="text-align: justify;"&gt;&lt;a name="What_is_LaTeX" id="What_is_LaTeX"&gt;&lt;/a&gt;&lt;/p&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;h3 style="text-align: justify;"&gt;&lt;span class="mw-headline"&gt;What is LaTeX&lt;/span&gt;&lt;/h3&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;p style="text-align: justify;"&gt;&lt;b&gt;LaTeX&lt;/b&gt; (pronounced either "Lah-tech" or "Lay-tech") is a macro package created by &lt;a href="http://en.wikipedia.org/wiki/Leslie_Lamport" class="extiw" title="w:Leslie_Lamport"&gt;Leslie Lamport&lt;/a&gt; based on the TeX typesetting language of &lt;a href="http://en.wikipedia.org/wiki/Donald_Knuth" class="extiw" title="w:Donald_Knuth"&gt;Donald Knuth&lt;/a&gt;. Its purpose is to produce professional looking and correctly typeset documents, in particular those with mathematical formulae. It is currently maintained by the &lt;a href="http://www.latex-project.org/latex3.html" class="external text" title="http://www.latex-project.org/latex3.html" rel="nofollow"&gt;LaTeX3 project&lt;/a&gt;. Numerous authors have contributed extensions, called &lt;i&gt;packages&lt;/i&gt; or &lt;i&gt;styles&lt;/i&gt;, to LaTeX. A number of these is usually bundled with a TeX/LaTeX software distribution or can be found in the Comprehensive TeX Archive Network (&lt;a href="http://www.ctan.org/" class="external text" title="http://www.ctan.org" rel="nofollow"&gt;CTAN&lt;/a&gt;).&lt;/p&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;p style="text-align: justify;"&gt;Since LaTeX comprises a group of &lt;a href="http://en.wikibooks.org/wiki/TeX" title="TeX"&gt;TeX&lt;/a&gt; commands, LaTeX document processing follows a programming perspective. One creates a text file in LaTeX markup, which is then to be read by the LaTeX macro, which produces the final document.&lt;/p&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;p style="text-align: justify;"&gt;Obviously, this has its disadvantages, compared with a &lt;a href="http://en.wikipedia.org/wiki/WYSIWYG" class="extiw" title="w:WYSIWYG"&gt;WYSIWYG&lt;/a&gt; (What You See Is What You Get) program such as &lt;a href="http://en.wikipedia.org/wiki/Openoffice.org" class="extiw" title="w:Openoffice.org"&gt;Openoffice.org&lt;/a&gt; Writer or Microsoft Word.&lt;/p&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;ul style="text-align: justify;"&gt; &lt;li&gt;One can't see the final result straight away.&lt;/li&gt;&lt;li&gt;One needs to know the necessary commands for LaTeX markup.&lt;/li&gt;&lt;li&gt;It can sometimes be difficult to obtain a certain 'look'.&lt;/li&gt; &lt;/ul&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;p style="text-align: justify;"&gt;On the other hand, there are certain advantages to the markup language approach:&lt;/p&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;ul style="text-align: justify;"&gt; &lt;li&gt;The layout, fonts, tables, etc. is consistent throughout.&lt;/li&gt;&lt;li&gt;Mathematical formulae can be easily typeset.&lt;/li&gt;&lt;li&gt;Indexes, footnotes, references, etc., are generated easily.&lt;/li&gt;&lt;li&gt;It encourages correctly structured documents.&lt;/li&gt; &lt;/ul&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;p style="text-align: justify;"&gt;The LaTeX-like approach can be called WYSIWYM, i.e. What You See Is What You Mean: you can't see how the final version will look like while typing, but you can see only the logical structure of the document, LaTeX will take care of the formatting for you.&lt;/p&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;p style="text-align: justify;"&gt;The LaTeX document is a plain text file containing the content of the document, with additional markup. When the source file is processed by the macro package, it can produce documents in several formats such as &lt;a href="http://en.wikipedia.org/wiki/DVI_file_format" class="extiw" title="w:DVI_file_format"&gt;DVI&lt;/a&gt;, PDF or PostScript.&lt;/p&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;p style="text-align: justify;"&gt;&lt;a name="Prerequisites" id="Prerequisites"&gt;&lt;/a&gt;&lt;/p&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;h3 style="text-align: justify;"&gt; &lt;span class="mw-headline"&gt;Prerequisites&lt;/span&gt;&lt;/h3&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;p style="text-align: justify;"&gt;At a minimum, you'll need the following programs to edit LaTeX:&lt;/p&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;ul style="text-align: justify;"&gt; &lt;li&gt;An editor (You can use a basic text editor like notepad, but a dedicated LaTeX editor will be more useful). &lt;ul&gt;&lt;li&gt;On Windows, TeXnicCenter(&lt;a href="http://www.texniccenter.org/" class="external autonumber" title="http://www.texniccenter.org/" rel="nofollow"&gt;[1]&lt;/a&gt;) is a popular free and open source LaTeX editor.&lt;/li&gt;&lt;li&gt;On *nix (including Mac OS X) systems, Emacsen and gvim provide powerful TeX enviroments for the tech-savvy, while Texmaker and Kile &lt;a href="http://kile.sf.net/" class="external autonumber" title="http://kile.sf.net" rel="nofollow"&gt;[2]&lt;/a&gt; provide more user-friendly development environments.&lt;/li&gt;&lt;/ul&gt; &lt;/li&gt;&lt;li&gt;The LaTeX binaries and style sheets - e.g. MiKTeX &lt;a href="http://www.miktex.de/" class="external autonumber" title="http://www.miktex.de/" rel="nofollow"&gt;[3]&lt;/a&gt; for Windows, teTeX &lt;a href="http://www.tug.org/teTeX/" class="external autonumber" title="http://www.tug.org/teTeX/" rel="nofollow"&gt;[4]&lt;/a&gt; for Linux and teTeX for Mac OS X &lt;a href="http://www.rna.nl/tex.html" class="external autonumber" title="http://www.rna.nl/tex.html" rel="nofollow"&gt;[5]&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;A DVI viewer to view and print the final result. Usually, a DVI viewer is included in the editor or is available with the binary distribution.&lt;/li&gt; &lt;/ul&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;p style="text-align: justify;"&gt;A distribution of LaTeX, with many packages, add-ins, editors and viewers for Unix, Linux, Mac and Windows can be obtained from the TeX users group at &lt;a href="http://www.tug.org/texlive/" class="external free" title="http://www.tug.org/texlive/" rel="nofollow"&gt;http://www.tug.org/texlive/&lt;/a&gt;.&lt;/p&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;p style="text-align: justify;"&gt;&lt;a name="Applications_within_a_distribution" id="Applications_within_a_distribution"&gt;&lt;/a&gt;&lt;/p&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;h3 style="text-align: justify;"&gt;&lt;span class="mw-headline"&gt;Applications within a distribution&lt;/span&gt;&lt;/h3&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;p style="text-align: justify;"&gt;Here are the main programs you expect to find in any (La)TeX distribution:&lt;/p&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;ul style="text-align: justify;"&gt; &lt;li&gt;&lt;b&gt;tex&lt;/b&gt;: the simplest compiler, it gets a TeX file and creates DVI&lt;/li&gt;&lt;li&gt;&lt;b&gt;pdftex&lt;/b&gt;: it gets a TeX file, but creates a PDF file&lt;/li&gt;&lt;li&gt;&lt;b&gt;latex&lt;/b&gt;: the most used one: it gets a LaTeX file and creates a DVI&lt;/li&gt;&lt;li&gt;&lt;b&gt;pdflatex&lt;/b&gt;: from a LaTeX creates a PDF&lt;/li&gt;&lt;li&gt;&lt;b&gt;dvi2ps&lt;/b&gt;: converts the DVI file to PostScript&lt;/li&gt;&lt;li&gt;&lt;b&gt;dvipdfm&lt;/b&gt;: converts the DVI file to PDF&lt;/li&gt; &lt;/ul&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;p style="text-align: justify;"&gt;When LaTeX was created, the only format it could create was DVI; then the PDF support was added by &lt;i&gt;pdflatex&lt;/i&gt;, even if several people still don't use it. As it is clear from this short list, PDF files can be created with both &lt;i&gt;pdflatex&lt;/i&gt; and &lt;i&gt;dvipdfm&lt;/i&gt;; anyway, the output of &lt;i&gt;pdflatex&lt;/i&gt; is much better than the other. DVI is an old format, and it does not support hyperlinks for example, while PDF does, so passing through DVI you will bring all the bad points of that format to PDF. Moreover the general output will be better using only &lt;i&gt;pdflatex&lt;/i&gt;.&lt;/p&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;p style="text-align: justify;"&gt;Strictly speaking, the document you are writing should be sightly different according to the compiler you are using (&lt;i&gt;latex&lt;/i&gt; or &lt;i&gt;pdflatex&lt;/i&gt;), but as we will see later, it is possible to add a sort of abstraction layer so to ignore what you are using, the applications will do everything by themselves.&lt;/p&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;p style="text-align: justify;"&gt;Note that, since LaTeX is just a collection of macros for TeX, if you compile a plain TeX document with a LaTeX compiler (such as &lt;i&gt;pdflatex&lt;/i&gt;) it will work, while the opposite is not true: if you try to compile a LaTeX source with a TeX compiler you will get only a lot of errors.&lt;/p&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;p style="text-align: justify;"&gt;The following diagram shows the relationships between the (La)TeX source code and all the formats you can create from it:&lt;/p&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;div style="text-align: justify;" class="center"&gt; &lt;div class="floatnone"&gt;&lt;span&gt;&lt;a href="http://en.wikibooks.org/wiki/Image:LaTeX_diagram.svg" class="image" title=""&gt;&lt;img src="http://upload.wikimedia.org/wikipedia/commons/thumb/7/78/LaTeX_diagram.svg/600px-LaTeX_diagram.svg.png" alt="" longdesc="/wiki/Image:LaTeX_diagram.svg" height="250" width="400" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;p style="text-align: justify;"&gt;The boxed red text represents the file formats, the blue text on the arrows represents the commands you have to use, the small dark green text under the boxes represents the image formats that are supported. Anytime you pass through an arrow you lose some information, that might decrease the quality of your document. Therefore, in order to achieve the highest quality in your output file, you should choose the shortest route to reach your target format. This is probably the most convenient way to obtain an output in your desired format anyway. Starting from a LaTeX source, the best way is to use only &lt;i&gt;latex&lt;/i&gt; for a DVI output or &lt;i&gt;pdflatex&lt;/i&gt; for a PDF output, converting to PostScript only when it is necessary to do it to print the document.&lt;/p&gt; &lt;div style="text-align: justify;"&gt;  &lt;/div&gt; &lt;p style="text-align: justify;"&gt;Most of the programs should be already within your LaTeX distribution, the others come with Ghostscript, that is a free and multi-platform software as well.&lt;br /&gt;&lt;/p&gt; &lt;div style="text-align: justify;"&gt; &lt;/div&gt; &lt;p style="text-align: justify;"&gt;Reference: http://en.wikibooks.org/wiki/LaTeX/Introduction&lt;br /&gt;&lt;/p&gt; &lt;p style="text-align: justify;"&gt;Script use for compilation, and dvi to PDF file conversion&lt;/p&gt; &lt;p style="text-align: justify;"&gt;run.pl:&lt;/p&gt; &lt;p style="text-align: justify;"&gt;#!/usr/bin/perl&lt;br /&gt;my $text1 = shift @ARGV or die print "No tex file is given as input\n";&lt;br /&gt;#print "Inputed argument is $text1\n";&lt;br /&gt;chop;&lt;br /&gt;my @fname = split(/\./,$text1);&lt;br /&gt;#print "Input array is @fname \n";&lt;br /&gt;#print "Input text is $fname[0] . $fname[1] \n";&lt;br /&gt;&lt;br /&gt;system("latex $text1");&lt;br /&gt;system("dvips -Ppdf $fname[0].dvi");&lt;br /&gt;system("ps2pdf $fname[0].ps $fname[0].pdf");&lt;br /&gt;system("xpdf $fname[0].pdf");&lt;br /&gt;&lt;/p&gt; &lt;p style="text-align: justify;"&gt;Usage: ./run.pl filename.tex      -  Gives you PDF file as output directly&lt;br /&gt;&lt;/p&gt; &lt;p style="text-align: justify;"&gt;Keywords: Latex, Tex, PDF writer, dvi to pdf conversion&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6837615239980912050-2226371881633515322?l=techfundaoftheday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techfundaoftheday.blogspot.com/feeds/2226371881633515322/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6837615239980912050&amp;postID=2226371881633515322' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6837615239980912050/posts/default/2226371881633515322'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6837615239980912050/posts/default/2226371881633515322'/><link rel='alternate' type='text/html' href='http://techfundaoftheday.blogspot.com/2006/12/latex.html' title='Latex'/><author><name>kdkariya</name><uri>http://www.blogger.com/profile/16154005894727727725</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp1.blogger.com/_GBhwIPW1FbY/SAltSM1KEPI/AAAAAAAAA5Q/kBl9S8H8r80/S220/DSC05163.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6837615239980912050.post-4447945658398024685</id><published>2006-12-14T21:06:00.000-08:00</published><updated>2006-12-19T07:47:48.646-08:00</updated><title type='text'>RISC Vs CISC</title><content type='html'>&lt;h3&gt;RISC&lt;/h3&gt; The concept was developed by John Cocke of IBM Research during 1974. His argument was based upon the notion that a computer uses only 20% of the instructions, making the other 80% superfluous to requirement. A processor based upon this concept would use few instructions, which would require fewer transistors, and make them cheaper to manufacture. By reducing the number of transistors and instructions to only those most frequently used, the computer would get more done in a shorter amount of time. The term 'RISC' (short for Reduced Instruction Set Computer) was later coined by David Patterson, a teacher at the University of California in Berkeley. &lt;p&gt;The RISC concept was used to simplify the design of the IBM PC/XT, and was later used in the IBM RISC System/6000 and Sun Microsystems' SPARC microprocessors. The latter CPU led to the founding of MIPS Technologies, who developed the M.I.P.S. RISC microprocessor (Microprocessor without Interlocked Pipe Stages). Many of the MIPS architects also played an instrumental role in the creation of the Motorola 68000, as used in the first Amigas (MIPS Technologies were later bought by Silicon Graphics).. The MIPS processor has continued development, remaining a popular choice in embedded and low-end market. At one time, it was suspected the Amiga MCC would use this CPU to reduce the cost of manufacture. However, the consumer desktop market is limited, only the PowerPC processor remains popular in the choice of RISC alternatives. This is mainly due to Apple's continuous use of the series for its PowerMac range. &lt;/p&gt; &lt;h3&gt; CISC&lt;/h3&gt; CISC (Complex Instruction Set Computer) is a retroactive definition that was introduced to distinguish the design from RISC microprocessors. In contrast to RISC, CISC chips have a large amount of different and complex instruction. The argument for its continued use indicates that the chip designers should make life easier for the programmer by reducing the amount of instructions required to program the CPU. Due to the high cost of memory and storage CISC microprocessors were considered superior due to the requirements for small, fast code. In an age of dwindling memory hard disk prices, code size has become a non-issue (MS Windows, hello?). However, CISC-based systems still cover the vast majority of the consumer desktop market. The majority of these systems are based upon the x86 architecture or a variant. The Amiga, Atari, and pre-1994 Macintosh systems also use a CISC microprocessor. &lt;h3&gt; RISC Vs. CISC&lt;/h3&gt; The argument over which concept is better has been repeated over the past few years. Macintosh owners have elevated the argument to a pseudo religious level in support of their RISC-based God (the PowerPC sits next to the Steve Jobs statue on every Mac altar). Both positions have been blurred by the argument that we have entered a Post-RISC stage. &lt;blockquote&gt;&lt;b&gt;RISC: For and Against&lt;/b&gt;&lt;br /&gt;RISC supporters argue that it the way of the future, producing faster and cheaper processors - an Apple Mac G3 offers a significant performance advantage over its Intel equivalent. Instructions are executed over 4x faster providing a significant performance boost! However, RISC chips require more lines of code to produce the same results and are increasingly complex. This will increase the size of the application and the amount of overhead required. RISC developers have also failed to remain in competition with CISC alternatives. The Macintosh market has been damaged by several problems that have affected the availability of 500MHz+ PowerPC chips. In contrast, the PC compatible market has stormed ahead and has broken the 1GHz barrier. Despite the speed advantages of the RISC processor, it cannot compete with a CISC CPU that boasts twice the number of clock cycles. &lt;p&gt;&lt;b&gt;CISC: For and Against&lt;/b&gt;&lt;br /&gt;As discussed above, CISC microprocessors are more expensive to make than their RISC cousins. However, the average Macintosh is more expensive than the WIntel PC. This is caused by one factor that the RISC manufacturers have no influence over - market factors. In particular, the WIntel market has become the definition of personal computing, creating a demand from people who have not used a computer previous. The x86 market has been opened by the development of several competing processors, from the likes of AMD, Cyrix, and Intel. This has continually reduced the price of a CPU of many months. In contrast, the PowerPC Macintosh market is dictated by Apple. This reduces the cost of x86 - based microprocessors, while the PowerPC market remains stagnant.&lt;/p&gt;&lt;/blockquote&gt;   &lt;h3&gt; Post-RISC&lt;/h3&gt; As the world enters the 21st century the CISC Vs. RISC arguments have been swept aside by the recognition that neither terms are accurate in their description. The definition of 'Reduced' and 'Complex' instructions has begun to blur, RISC chips have increased in their complexity (compare the PPC 601 to the G4 as an example) and CISC chips have become more efficient. The result are processors that are defined as RISC or CISC only by their ancestry. The PowerPC 601, for example, supports more instructions than the Pentium. Yet the Pentium is a CISC chip, while the 601 is considered to be RISC. CISC chips have also gained techniques associated with RISC processors. Intel describe the Pentium II as a CRISC processor, while AMD use a RISC architecture but remain compatible with the dominant x86 CISC processors. Thus it is no longer important which camp the processor comes from, the emphasis has once-again been placed upon the operating system and the speed that it can execute instructions. &lt;h3&gt; EPIC&lt;/h3&gt; In the aftermath of the CISC-RISC conflict, a new enemy has appeared to threaten the peace. EPIC (Explicitly Parallel Instruction Computing) was developed by Intel for the server market, thought it will undoubtedly appear in desktops over the next few years. The first EPIC processor will be the 64-bit Merced, due for release sometime during 2001 (or 2002, 2003, etc.). The market may be divided between combined CISC-RISC systems in the low-end and EPIC in the high-end. &lt;h3&gt;   &lt;/h3&gt;   &lt;h3&gt; &lt;b&gt;Famous RISC microprocessors&lt;/b&gt;&lt;/h3&gt; &lt;b&gt;ARM&lt;/b&gt;&lt;br /&gt;&lt;p&gt;One of the most well known RISC developers is Cambridge based Advanced Research Machines (originally Acorn Research Machines). Their ARM and StrongARM chips power the old Acorn Archimedes and the Apple Newton handwriting recognition systems. Since the unbundling of ARM from Acorn, Intel have invested a considerable amount of money in the company and have utilized the technology in their processor design.&lt;br /&gt;&lt;/p&gt; &lt;p&gt;Keywords: RISC, CISC, RISC Vs CISC, ARM, DSP Processor&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6837615239980912050-4447945658398024685?l=techfundaoftheday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techfundaoftheday.blogspot.com/feeds/4447945658398024685/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6837615239980912050&amp;postID=4447945658398024685' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6837615239980912050/posts/default/4447945658398024685'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6837615239980912050/posts/default/4447945658398024685'/><link rel='alternate' type='text/html' href='http://techfundaoftheday.blogspot.com/2006/12/risc-vs-cisc.html' title='RISC Vs CISC'/><author><name>kdkariya</name><uri>http://www.blogger.com/profile/16154005894727727725</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp1.blogger.com/_GBhwIPW1FbY/SAltSM1KEPI/AAAAAAAAA5Q/kBl9S8H8r80/S220/DSC05163.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6837615239980912050.post-500885012869514459</id><published>2006-12-13T20:59:00.000-08:00</published><updated>2006-12-19T01:29:22.999-08:00</updated><title type='text'>IEEE 754 - Floating Point number representation at a Glance</title><content type='html'>&lt;story&gt;&lt;b&gt;IEEE 754 at a Glance&lt;/b&gt;&lt;br /&gt;A floating-point number representation on a computer uses something similar to a scientific notation with a base and an exponent. A scientific representation of 30,064,771 is 3.0064771 x 10&lt;sup&gt;7&lt;/sup&gt;, whereas 1.001 can be written as 1.001 x 10&lt;sup&gt;0&lt;/sup&gt;. &lt;/story&gt; &lt;p&gt; In the first example, 3.0064771 is called the mantissa, 10 the exponent base, and 7 the exponent. &lt;/p&gt; &lt;p&gt; &lt;a href="http://www.dspdesignline.com/encyclopedia/defineterm.jhtml?term=IEEE&amp;x=&amp;amp;y="&gt;IEEE&lt;/a&gt; standard 754 specifies a common format for representing floating-point numbers in a computer. Two grades of precision are defined: single precision and double precision. The representations use 32 and 64 bits, respectively. This is shown in &lt;i&gt;Figure 2&lt;/i&gt;.  &lt;/p&gt; &lt;center&gt;&lt;a href="http://i.cmpnet.com/dspdesignline/2006/12/xilinxfigure2_big.gif"&gt; &lt;img src="http://i.cmpnet.com/dspdesignline/2006/12/xilinxfigure2.gif" border="0" /&gt;&lt;br /&gt;&lt;i&gt;(Click to enlarge)&lt;/i&gt;&lt;/a&gt;&lt;i&gt;&lt;br /&gt;Figure 2: IEEE floating-point formats&lt;/i&gt;&lt;/center&gt;  &lt;p&gt; In IEEE 754 floating-point representation, each number comprises three basic components: the sign, the exponent, and the mantissa. To maximize the range of possible numbers, the mantissa is divided into a fraction and leading digit. As I'll explain, the latter is implicit and left out of the representation. &lt;/p&gt; &lt;p&gt; The sign &lt;a href="http://www.dspdesignline.com/encyclopedia/defineterm.jhtml?term=bit&amp;x=&amp;amp;y="&gt;bit&lt;/a&gt; simply defines the polarity of the number. A value of zero means that the number is positive, whereas a 1 denotes a negative number. &lt;/p&gt; &lt;p&gt;The exponent represents a range of numbers, positive and negative; thus a bias value must be subtracted from the stored exponent to yield the actual exponent. The single precision bias is 127, and the double precision bias is 1,023. This means that a stored value of 100 indicates a single-precision exponent of -27. The exponent base is always 2, and this implicit value is not stored. &lt;/p&gt; &lt;p&gt; For both representations, exponent representations of all 0s and all 1s are reserved and indicate special numbers:&lt;br /&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Zero: all digits set to 0, sign bit can be either 0 or 1 &lt;/li&gt;&lt;li&gt;±∞: exponent all 1s, fraction all 0s &lt;/li&gt;&lt;li&gt;Not a Number (NaN): exponent all 1s, non-zero fraction. Two versions of NaN are used to signal the result of invalid operations such as dividing by zero, and indeterminate results such as operations with non-initialized operand(s). &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The mantissa represents the number to be multiplied by 2 raised to the power of the exponent. Numbers are always normalized; that is, represented with one non-zero leading digit in front of the radix point. In binary math, there is only one non-zero number, 1. Thus the leading digit is always 1, allowing us to leave it out and use all the mantissa bits to represent the fraction (the decimals). &lt;/p&gt; &lt;p&gt;Following the previous number examples, here is what the single precision representation of the decimal value 30,064,771 will look like: &lt;/p&gt; &lt;p&gt;The binary integer representation of 30,064,771 is 1 1100 1010 1100 0000 1000 0011. This can be written as 1.110010101100000010000011 x 2&lt;sup&gt;24&lt;/sup&gt;. The leading digit is omitted, and the fraction—the string of digits following the radix point—is 1100 1010 1100 0000 1000 0011. The sign is positive and the exponent is 24 decimal. Adding the bias of 127 and converting to binary yields an IEEE 754 exponent of 1001 0111. &lt;/p&gt; &lt;p&gt; Putting all of the pieces together, the single representation for 30,064,771 is shown in &lt;i&gt;Figure 3&lt;/i&gt;. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;center&gt;&lt;img src="http://i.cmpnet.com/dspdesignline/2006/12/xilinxfigure3.gif" /&gt;&lt;br /&gt;&lt;i&gt;Figure 3: 30,064,771 represented in IEEE 754 single-precision format&lt;/i&gt;&lt;/center&gt;  &lt;p&gt; &lt;b&gt;Gain Some, Lose Some&lt;/b&gt;&lt;br /&gt;Notice that you lose the least significant bit (LSB) of value 1 from the 32-bit integer representation—this is because of the limited precision for this format. &lt;/p&gt; &lt;p&gt; The range of numbers that can be represented with single precision IEEE 754 representation is ±(2-2&lt;sup&gt;-23&lt;/sup&gt;) x 2&lt;sup&gt;127&lt;/sup&gt;, or approximately ±10&lt;sup&gt;38.53&lt;/sup&gt;. This range is astronomical compared to the maximum range of 32-bit integer numbers, which by comparison is limited to around ±2.15 x 10&lt;sup&gt;9&lt;/sup&gt;. Also, whereas the integer representation cannot represent values between 0 and 1, single-precision floating-point can represent values down to ±2&lt;sup&gt;-149&lt;/sup&gt;, or ±~10&lt;sup&gt;-44.85&lt;/sup&gt;. And we are still using only 32 bits—so this has to be a much more convenient way to represent numbers, right? &lt;/p&gt; &lt;p&gt; The answer depends on the requirements.&lt;br /&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Yes, because in our example of multiplying 30,064,771 by 1.001, we can simply multiply the two numbers and the result will be extremely accurate. &lt;/li&gt;&lt;li&gt;No, because as in the preceding example the number 30,064,771 is not represented with full precision. In fact, 30,064,771 and 30,064,770 are represented by the exact same 32-bit bit pattern, meaning that a &lt;a href="http://www.dspdesignline.com/encyclopedia/defineterm.jhtml?term=software&amp;x=&amp;amp;y="&gt;software&lt;/a&gt; &lt;a href="http://www.dspdesignline.com/encyclopedia/defineterm.jhtml?term=algorithm&amp;x=&amp;amp;y="&gt;algorithm&lt;/a&gt; will treat the numbers as identical. Worse yet, if you increment either number by 1 a billion times, none of them will change. By using 64 bits and representing the numbers in double precision format, that particular example could be made to work, but even double-precision representation will face the same limitations once the numbers get big—or small enough. &lt;/li&gt;&lt;li&gt;No, because most embedded processor cores ALUs (arithmetic logic units) only support integer operations, which leaves floating-point operations to be emulated in software. This severely affects processor performance. A 32-bit CPU can add two 32-bit integers with one machine code instruction; however, a &lt;a href="http://www.dspdesignline.com/encyclopedia/defineterm.jhtml?term=library&amp;x=&amp;amp;y="&gt;library&lt;/a&gt; routine including bit manipulations and multiple arithmetic operations is needed to add two IEEE single-precision floating-point values. With multiplication and division, the performance gap just increases; thus for many applications, software floating-point emulation is not practical.&lt;/li&gt; &lt;/ul&gt;Keywords: IEEE 754, Floating point representaion&lt;br /&gt;  &lt;!-- &lt;/div&gt; --&gt;                &lt;!--end body--&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6837615239980912050-500885012869514459?l=techfundaoftheday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techfundaoftheday.blogspot.com/feeds/500885012869514459/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6837615239980912050&amp;postID=500885012869514459' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6837615239980912050/posts/default/500885012869514459'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6837615239980912050/posts/default/500885012869514459'/><link rel='alternate' type='text/html' href='http://techfundaoftheday.blogspot.com/2006/12/ieee-754-floating-point-number.html' title='IEEE 754 - Floating Point number representation at a Glance'/><author><name>kdkariya</name><uri>http://www.blogger.com/profile/16154005894727727725</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp1.blogger.com/_GBhwIPW1FbY/SAltSM1KEPI/AAAAAAAAA5Q/kBl9S8H8r80/S220/DSC05163.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6837615239980912050.post-7758874028654729668</id><published>2006-12-12T21:24:00.000-08:00</published><updated>2006-12-19T01:30:11.974-08:00</updated><title type='text'>Memory Types</title><content type='html'>&lt;div class="articleImg"&gt;&lt;img src="http://www.pcmech.com/previews/categories/memory.jpg" class="articlelistimageholder" alt="Memory Types" height="90" width="150" /&gt;&lt;/div&gt;  &lt;span name="KonaBody"&gt; There are several different technologies when it comes to memory.  &lt;p&gt;&lt;b&gt;ROM&lt;/b&gt;  &lt;/p&gt;&lt;p&gt;This is read-only memory, memory that can only be read, but cannot be written to. ROM is used in situations where the data must be held permanently. This is due to the fact that it is non-volatile memory. This means the data is "hard-wired" into the ROM chip.You can store the chip forever and the data will always be there. Besides, the data is very secure. The BIOS is stored on ROM because the user cannot disrupt the information. &lt;/p&gt;&lt;p&gt;There are different types of ROM, too:&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;&lt;u&gt;Programmable ROM(PROM)&lt;/u&gt;&lt;/b&gt;. This is basically a blank ROM chip that can be written to, but only once. It is much like a CD-R drive that burns the data into the CD. Some companies use special machinery to write PROMs for special purposes. &lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;u&gt;Erasable Programmable ROM (EPROM)&lt;/u&gt;&lt;/b&gt;. This is just like PROM, except that you can erase the ROM by shining a special ultra-violet light into a sensor atop the ROM chip for a certain amount of time. Doing this wipes the data out, allowing it to be rewritten. &lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;u&gt;Electrically Erasable Programmable ROM (EEPROM)&lt;/u&gt;&lt;/b&gt;. Also called flash BIOS. This ROM can be rewritten through the use of a special software program. Flash BIOS operates this way, allowing users to upgrade their BIOS.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;ROM is slower than RAM, which is why some try to shadow it to increase speed. &lt;/p&gt; &lt;p&gt;&lt;strong&gt;RAM&lt;/strong&gt;&lt;span class="down" style="display: block;" id="formatbar_CreateLink" title="Link" onmouseover="ButtonHoverOn(this);" onmouseout="ButtonHoverOff(this);" onmouseup="" onmousedown="CheckFormatting(event);FormatbarButton('richeditorframe', this, 8);ButtonMouseDown(this);"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kLink" style="text-decoration: underline ! important; position: static;"&gt;&lt;/span&gt;Random Access Memory (RAM) is what most of us think of when we hear the word memory associated with computer&lt;span style="text-decoration: underline;"&gt;&lt;/span&gt;. It is volatile memory, meaning all data is lost when power is turned off. The RAM is used for temporary storage of program data, allowing performance to be optimum. &lt;/p&gt;&lt;p&gt;Like ROM, there are different types of RAM:&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Static RAM (SRAM) This RAM will maintain it's data as long as power is provided to the memory chips&lt;span style="text-decoration: underline;"&gt;&lt;/span&gt;. It does not need to be re-written periodically. In fact, the only time the data on the memory is refreshed or changed is when an actual write command is executed. SRAM is very fast, but is much more expensive than DRAM. SRAM is often used as cache memory due to its speed. &lt;p&gt;There are a few types of SRAM: &lt;/p&gt;&lt;/li&gt;&lt;/ul&gt; &lt;blockquote&gt; &lt;ul&gt;&lt;li&gt;&lt;b&gt;Async SRAM&lt;/b&gt;. An older type of SRAM used in many PC's for &lt;a onclick="openWindow(this,'test')" href="http://www.pcmech.com/glossary/l2_cache.htm"&gt;L2 cache&lt;/a&gt;. It is asynchronous, meaning that it works independently of the &lt;a id="KonaLink6" target="_top" class="kLink" style="text-decoration: underline ! important; position: static;" href="http://www.pcmech.com/show/memory/110/#"&gt;&lt;span style=""&gt;&lt;span class="kLink" style=""&gt;system&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; clock. This means that the CPU found itself waiting for info from the L2 cache.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Sync SRAM&lt;/b&gt;. This type of SRAM is synchronous, meaning it is synchronized with the system clock. While this speeds it up, it makes it rather expensive at the same time.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Pipeline Burst SRAM&lt;/b&gt;. Commonly used. SRAM requests are &lt;a onclick="openWindow(this,'test')" href="http://www.pcmech.com/glossary/pipelining.htm"&gt;pipelined&lt;/a&gt;, meaning larger packets of data re sent to the memory at once, and acted on very quickly. This breed of SRAM can operate at &lt;a onclick="openWindow(this,'test')" href="http://www.pcmech.com/glossary/bus.htm"&gt;bus&lt;/a&gt; speeds higher than 66MHz, so is often used.&lt;/li&gt;&lt;/ul&gt;&lt;/blockquote&gt; &lt;ul&gt;&lt;li&gt;&lt;b&gt;&lt;u&gt;Dynamic RAM (DRAM)&lt;/u&gt;&lt;/b&gt;. DRAM, unlike SRAM, must be continually re-written in order for it to maintain its data. This is done by placing the memory on a refresh circuit that re-writes the data several hundred time per second. DRAM is used for most system memory because it is cheap and small. &lt;p&gt;There are several types of DRAM, complicating the memory scene even more: &lt;/p&gt;&lt;/li&gt;&lt;/ul&gt; &lt;blockquote&gt; &lt;ul&gt;&lt;li&gt;&lt;b&gt;Fast Page Mode DRAM (FPM DRAM)&lt;/b&gt;. FPM DRAM is only slightly faster than regular DRAM. Before there was EDO RAM, FPM RAM was the main type used in PC's. It is pretty slow stuff, with an access time of 120 ns. It was eventually tweaked to 60 ns, but FPM was still too slow to work on the 66MHz system bus. For this reason, FPM RAM was replaced by EDO RAM. FPM RAM is not much used today due to its slow speed, but is almost universally supported. &lt;/li&gt;&lt;li&gt;&lt;b&gt;Extended Data Out DRAM (EDO DRAM)&lt;/b&gt;. EDO memory incorporates yet another tweak in the method of access. It allows one access to begin while another is being completed. While this might sound ingenious, the performance increase over FPM DRAM is only around 30%. EDO DRAM must be properly supported by the chipset. EDO RAM comes on a SIMM. EDO RAM cannot operate on a bus speed faster than 66MHz, so, with the increasing use of higher bus speeds, EDO RAM has taken the path of FPM RAM. &lt;/li&gt;&lt;li&gt;&lt;b&gt;Burst EDO DRAM (BEDO DRAM)&lt;/b&gt;. Original EDO RAM was too slow for the newer systems coming out at the time. Therefore, a new method of memory access had to be developed to speed up the memory. Bursting was the method devised. This means that larger blocks of data were sent to the memory at a time, and each "block" of data not only carried the memory address of the immediate page, but info on the next several pages. Therefore, the next few accesses would not experience any delays due to the preceding memory requests. This technology increases EDO RAM speed up to around 10 ns, but it did not give it the ability to operate stably at bus speeds over 66MHz. BEDO RAM was an effort to make EDO RAM compete with SDRAM.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Synchronous DRAM (SDRAM)&lt;/b&gt;. SDRAM became the new standard after EDO bit the dust. Its speed is synchronous, meaning that it is directly dependent on the clock speed of the entire system. Standard SDRAM can handle higher bus speeds. In theory, it could operate at up to 100MHz, although it was found that many other variable factors went into whether or not it could stabily do so. The actual speed capacity of the module depended on the actual memory chips as well as design factors in the memory PCB itself.&lt;br /&gt;&lt;br /&gt;Do get around the variability, Intel created the PC100 standard. The PC100 standard ensures compatibility of SDRAM subsystems with Intel's 100MHz FSB processors. The new design, production, and test requirements created challenges for semiconductor companies and memory module suppliers. Each PC100 SDRAM module required key attributes to guarantee full compliance, such as the use of 8ns DRAM components (chips) that are capable of operating at 125MHz. This provided a margin of safety in ensuring that that the memory module could run at PC100 speeds. Additionally, SDRAM chips must be used in conjunction with a correctly programmed EEPROM on a properly designed printed circuit board. The shorter the distance the signal needs to travel, the faster it runs. For this reason, there were additional layers of internal circuitry on PC100 modules.&lt;br /&gt;&lt;br /&gt;As PC speeds increased, the same problem was encountered for the 133 MHz bus, so the PC133 standard was developed.&lt;/li&gt;&lt;li&gt;&lt;b&gt;RAMBus DRAM (RDRAM)&lt;/b&gt;. Developed by Rambus, Inc. and endorsed by Intel as the chosen successor to SDRAM. RDRAM narrows the memory bus to 16-bit and runs at up to 800 MHz. Since this narrow bus takes up less space on the board, systems can get more speed by running multiple channels in parallel. Despite the speed, RDRAM has had a tough time taking off in the market because of compatibility and timing issues. Heat is also an issue, but RDRAM has heatsinks to dissipate this. Cost is a major issue with RDRAM, with manufacturers needing to make major facility changes to make it and the product cost to consumers being too high for people to swallow.&lt;/li&gt;&lt;li&gt;&lt;b&gt;DDR-SDRAM&lt;/b&gt;. This type of memory is the natural evolution from SDRAM and most manufacturers prefer this to Rambus because not much needs to be changed to make it. Also, memory makers are free to manufacture it because it is an open standard, whereas they would have to pay license fees to Rambus, Inc. in order make RDRAM. DDR stands for Double Data Rate. DDR shuffles data over the bus over both the rise and fall of the clock cycle, effectively doubling the speed over that of standard SDRAM. Of course, chipset support is necessary. DDR-DRAM is now the new standard in PC memory, with ever increasing speed support coming out, even so that it can compete quite well up against Rambus.&lt;/li&gt;&lt;/ul&gt;Ref: http://www.pcmech.com/show/memory/110/&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;Keywords: Memory, SSRAM, DDR SDRAM, Rambus,&lt;br /&gt;&lt;/blockquote&gt; &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6837615239980912050-7758874028654729668?l=techfundaoftheday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techfundaoftheday.blogspot.com/feeds/7758874028654729668/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6837615239980912050&amp;postID=7758874028654729668' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6837615239980912050/posts/default/7758874028654729668'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6837615239980912050/posts/default/7758874028654729668'/><link rel='alternate' type='text/html' href='http://techfundaoftheday.blogspot.com/2006/12/memory-types.html' title='Memory Types'/><author><name>kdkariya</name><uri>http://www.blogger.com/profile/16154005894727727725</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp1.blogger.com/_GBhwIPW1FbY/SAltSM1KEPI/AAAAAAAAA5Q/kBl9S8H8r80/S220/DSC05163.JPG'/></author><thr:total>0</thr:total></entry></feed>
