element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • Product Groups
  • Store
    Store
    • Visit Your Store
    • Choose Another Store
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
FPGA
  • Technologies
  • More
FPGA
Documents 2-Minute FPGAs: Blocking vs Nonblocking Statements in Verilog
  • Blog
  • Forum
  • Documents
  • Events
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
FPGA requires membership for participation - click to join
Actions
  • Share
  • More
  • Cancel
Engagement
  • Author Author: cstanton
  • Date Created: 22 Jul 2021 2:46 PM Date Created
  • Last Updated Last Updated: 23 Nov 2021 4:57 PM
  • Views 3388 views
  • Likes 9 likes
  • Comments 10 comments
Related
Recommended

2-Minute FPGAs: Blocking vs Nonblocking Statements in Verilog

Summer of FPGA
Blocking vs Nonblocking Statements in Verilog

FPGA Group | The Summer of FPGAs - Agenda

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

Join Whitney Knitter of Knitronics for two minutes as we discuss the logic and computer science behind programming with Lattice's ICE40 tinyFPGA! Today we discuss blocking vs nonblocking statements in Verilog! This's the first part in a series of videos and blog posts over the course of the Summer of FPGA.

 

Supplemental Content

 

  • Summer of FPGAs: 2-Minute FPGAs with Whitney Knitter
  • Getting Started with the TinyFPGA & Lattice Diamond 3.12 on Ubuntu 18.04

 

Additional Parts:

 

Product Name
iCE40 FPGAiCE40 FPGA
tinyFPGAtinyFPGA

 

Summer of FPGA 2-Minute FPGAs - More Videos Coming Soon!

  • tinyfpga
  • summer_of_fpgas
  • whitney knitter
  • e14presents_whitney
  • fpga
  • knitronics
  • whitney_knitter
  • Share
  • History
  • More
  • Cancel
  • Sign in to reply

Top Comments

  • javagoza
    javagoza over 1 year ago in reply to albertabeef +4
    I learned VHDL in 1992 in college, one of the first versions of VHDL. It was a very intense course designing our own chip. Then I started working as an application programmer and I have practically forgotten…
  • knitronics
    knitronics over 1 year ago in reply to javagoza +3
    Looking at the LEDs does not show the difference, which is part of the point of the demonstration. It is that exact same circuit, but the blocking statement evaluates the first AND gate before the second…
  • albertabeef
    albertabeef over 1 year ago +2
    Great video Whitney ! I have not written HDL in a very long time ... Back then, we called the two statements you described as combinatorial and sequential synchronous. Referring to your video: - non-blocking…
  • sam_desd@yahoo.com
    sam_desd@yahoo.com over 1 year ago

    Does the toolset for this FPGA is free? Is there link/url to the available ip core of kit?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • javagoza
    javagoza over 1 year ago in reply to knitronics

    I think I have managed to visualize the difference in behavior in the example. I am totally neophyte with verilog and with digital electronics. These are my first modules on Verilog. My hello world, but I think I am already understanding something.

     

    image

     

    https://www.edaplayground.com/x/FrFL

    image

    `timescale 1ns/100ps
    
    module blocking_assignment(
      input iA, iB, iX,
      output reg oC, oY);
      
     assign #2 oC = iA & iB; 
     assign #2 oY = oC & iX;
    
    endmodule
    
    module non_blocking_assignment(
      input iA, iB, iX, CLK,
      output reg oC, oY);
      
      always @ (posedge CLK)
          begin
            #2 oC <= iA & iB;
            #2 oY <= oC & iX;
          end
      
    endmodule

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • javagoza
    javagoza over 1 year ago in reply to knitronics

    Thank you very much Whitney for your response.

    I already have two pending tasks: to learn Verilog and improve my understanding of the English language.

    Greetings from Spain.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • knitronics
    knitronics over 1 year ago in reply to javagoza

    Looking at the LEDs does not show the difference, which is part of the point of the demonstration. It is that exact same circuit, but the blocking statement evaluates the first AND gate before the second one, while the non-blocking statement is evaluating both AND gates at the same time so long at the clock is running. Understanding this different in the circuit that is otherwise the exact same is the key takeaway.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • knitronics
    knitronics over 1 year ago in reply to albertabeef

    Verilog is just what they happened to be teaching in the digital logic classes at my university when I first was learning HDL. I've picked up VHDL in the field out of necessity when I have to take over a project that's already done in VHDL. But just because Verilog is what I learned first, that's just what I tend towards.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • javagoza
    javagoza over 1 year ago

    I understand the difference between blocking or non-blocking assignment. What I don't understand is what the example is trying to explain. What difference should I expect between the two modes in the example?

    I have built the example with an Arduino MKR Vidor 4000

     

    wire wY_b;
    wire wY_nb;
    wire wC_b;
    wire wC_nb;
    
    assign bMKR_D[6] = wC_b;
    assign bMKR_D[7] = wY_b;
    assign bMKR_D[4] = wC_nb;
    assign bMKR_D[5] = wY_nb;
    
    assign iX = bMKR_D[3];
    assign iA = bMKR_D[2];
    assign iB = bMKR_D[1];
    
    // Blocking statements
    assign wC_b = iA & iB;
    assign wY_b= wC_b & iX;
    
    // Non blocking statements
    always @(posedge wOSC_CLK)
    begin
      wC_nb <= iA & iB;
      wY_nb <= wC_nb & iX;
    end

     

    A=1 B =1 X=1

     

    image

     

    A=1 B=1 X=0

     

    image

     

    A=1 B=0 X=1

     

    image

     

     

    Edited: added logic trace

    image

     

     

    I can't find what difference to expect between the two assignment modes for this particular example just by looking at the leds..

    From the diagrams the blocking one is combinational logic and the non blocking one is sequential logic.

     

    In any case, a big thanks, very interesting, I look forward to the next video.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • colporteur
    colporteur over 1 year ago

    Enjoyed the video. Look forward to more.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • javagoza
    javagoza over 1 year ago in reply to albertabeef

    I learned VHDL in 1992 in college, one of the first versions of VHDL. It was a very intense course designing our own chip. Then I started working as an application programmer and I have practically forgotten everything. Now I try to learn Verilog just out of curiosity and fun.

    • Cancel
    • Vote Up +4 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • beacon_dave
    beacon_dave over 1 year ago in reply to albertabeef

    "...Back then, we called the two statements you described as combinatorial and sequential..."

    I could potentially see mixing such terminology being confusing for those coming from a discrete logic background.

     

    Combinatorial/combinational logic in the discrete logic world would perhaps generally refer to logic where the output state would be dependent upon the input state at any given time. 

     

    Whereas sequential logic would perhaps generally refer to logic where the output state could depend not only on the current input state but also on the previous state, at the next clock cycle.

     

    So far the comparison holds out.

     

    However, in the video; at first glance, the logic diagram for blocking statements would perhaps appear to look more like combinatorial logic, whereas the logic diagram for non-blocking would perhaps appear to look more like sequential logic due to the addition of the clocks.

     

    Depending upon which way 'your brain is wired', then this logic perhaps may now appear to be inverted from discrete logic terminology.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • albertabeef
    albertabeef over 1 year ago

    Great video Whitney !

    I have not written HDL in a very long time ...

    Back then, we called the two statements you described as combinatorial and sequential synchronous.
    Referring to your video:
    - non-blocking statement => combinatorial
    - blocking statement => sequential synchronous

    I agree that knowing the difference between the two is very important.

     

    Interestingly, back then, the language I coded with depended on my location:
    - when I worked on the west coast, I coded in Verilog

    - when I worked on the east coast, I coded in VHDL

    This may have must been coincidence, but was wondering if anyone else noticed this.

     

    Since I joined Avnet, I have been coding in both Verilog and VHDL.

    Again, have not touched these languages for quite a while now ... is anyone still using HDL languages ?

     

    Regards,

     

    Mario.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2023 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • Facebook
  • Twitter
  • linkedin
  • YouTube