Advanced Embedded Systems Lecture on Sequential Elements in VHDL and Mod 10 Counters

csce 436 advanced embedded systems lecture n.w
1 / 35
Embed
Share

Discover the intricacies of sequential elements in VHDL and Mod 10 counters in this advanced embedded systems lecture series. Learn to convert decimal numbers to unsigned vectors, design cascaded counters, and differentiate between combinational and sequential counters. Master the translation between schematic, truth table, and VHDL code for a comprehensive understanding of embedded systems design.

  • Embedded Systems
  • VHDL
  • Sequential Elements
  • Mod 10 Counter
  • Embedded Design

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. CSCE 436 Advanced Embedded Systems Lecture 4 Sequential Element Prof Jeffrey Falkinburg Avery Hall 368 472-5120

  2. Using Unsigned and Decimal Numbers Convert Decimal number to Unsigned Vector (7 downto 0) to_unsigned(17, 8) First argument is the decimal number Second argument is the number of bits Conditional with unsigned number LED_Trigger <= '1' when (Binary_Input = to_unsigned(17, 8) ) else 0'; 2 CSCE 436 Advanced Embedded Systems

  3. Lesson Outline Time Logs! HW #3 Due Now! 1. Sequential Elements 2. Mod 10 Counter Example Truth Table Timing Diagram Circuit Diagram VHDL 3. General VHDL Rules 4. Adding Signals to Xsim 3 CSCE 436 Advanced Embedded Systems

  4. Sequential Elements 4 CSCE 436 Advanced Embedded Systems

  5. Sequential Elements Goals: basic sequential process and sensitivity list register, counter in VHDL Combination of sequential and combinational logic (counters) Translate between schematic, truth table, and VHDL code 5 CSCE 436 Advanced Embedded Systems

  6. Cascaded Counters Mod 10 Counter clk reset_n ctrl Mod 10 Counter clk reset_n ctrl roll rollQ clk clk reset_n ctrl ctrl Most Significant Digit Least Significant Digit 6 CSCE 436 Advanced Embedded Systems

  7. Cascaded Counters Mod 10 Counter clk reset_n ctrl Mod 10 Counter clk reset_n ctrl glue roll rollQ clk clk reset_n ctrl Most Significant Digit Least Significant Digit 7 CSCE 436 Advanced Embedded Systems

  8. Combinational vs Sequential Counter Combinational Way: Output = F(inputs) Sequential Way Output = F(input, state) With the state we accumulate memory or a history of inputs 8 CSCE 436 Advanced Embedded Systems

  9. Mod 10 Counter Example 9 CSCE 436 Advanced Embedded Systems

  10. Mod 10 Counter Example State Table clk 0,1,falling rising rising rising rising rising reset x 0 1 1 1 1 ctrl xx xx 00 01 10 11 D x x x x D x Q+ Q 0 Q Q+1 mod 10 D 0 10 CSCE 436 Advanced Embedded Systems

  11. Mod 10 Counter Example Memory: The first line tells us that only a positive clock edge will result in an increment. Any other condition results in the next state of Q (denoted Q+) being unchanged (equal to Q). clk 0,1,falling rising rising rising rising rising reset x 0 1 1 1 1 Ctrl xx xx 00 01 10 11 D x x x x D x Q+ Q 0 Q Q+1 mod 10 D 0 11 CSCE 436 Advanced Embedded Systems

  12. Mod 10 Counter Example Reset: The second line defines the behavior when the reset is active low (to agree with the active-low reset on the Nexys Video board). clk 0,1,falling rising rising rising rising rising reset x 0 1 1 1 1 Ctrl xx xx 00 01 10 11 D x x x x D x Q+ Q 0 Q Q+1 mod 10 D 0 12 CSCE 436 Advanced Embedded Systems

  13. Mod 10 Counter Example Hold: The third row tells us that the counter will hold when the 2-bit control is equal to 00. clk 0,1,falling rising rising rising rising rising reset x 0 1 1 1 1 Ctrl xx xx 00 01 10 11 D x x x x D x Q+ Q 0 Q Q+1 mod 10 D 0 13 CSCE 436 Advanced Embedded Systems

  14. Mod 10 Counter Example Count Up Mod 10: The fourth row tells us that the counter will count up when the 2-bit control is equal to 01. The "mod 10" means that the counter is supposed to count from 0 to 9 and then, on the next count, roll back to 0. clk reset Ctrl 0,1,falling x xx rising 0 xx rising 1 00 rising 1 01 rising 1 10 rising 1 11 D x x x x D x Q+ Q 0 Q Q+1 mod 10 D 0 14 CSCE 436 Advanced Embedded Systems

  15. Mod 10 Counter Example Load D: The fifth row tells us that the counter will load in the value 'D' when the 2-bit control is equal to 10. clk 0,1,falling rising rising rising rising rising reset x 0 1 1 1 1 Ctrl xx xx 00 01 10 11 D x x x x D x Q+ Q 0 Q Q+1 mod 10 D 0 15 CSCE 436 Advanced Embedded Systems

  16. Mod 10 Counter Example Sync Reset: The sixth row tells us that the counter will synchronously reset when the 2-bit control is equal to 11. clk 0,1,falling rising rising rising rising rising reset x 0 1 1 1 1 Ctrl xx xx 00 01 10 11 D x x x x D x Q+ Q 0 Q Q+1 mod 10 D 0 16 CSCE 436 Advanced Embedded Systems

  17. Mod 10 Counter Example Truth Table Behavior Summary: clk 0,1,falling rising rising rising rising rising reset x 0 1 1 1 1 Ctrl xx xx 00 01 10 11 D x x x x D x Q+ Q 0 Q Q+1 mod 10 Count Up D 0 Behavior Memory Reset Hold Load D Sync Reset 17 CSCE 436 Advanced Embedded Systems

  18. Timing Diagram 18 CSCE 436 Advanced Embedded Systems

  19. Mod 10 Counter - Timing Diagram Complete the Q trace in the following timing diagram based on the state table for the mod-10 counter. reset Ctrl D 0,1,falling x xx rising 0 xx rising 1 00 rising 1 01 rising 1 10 rising 1 11 clk Q+ Q 0 Q Q+1 mod 10 Count Up D 0 Behavior Memory Reset Hold x x x x D x Load D Sync Reset 19 CSCE 436 Advanced Embedded Systems

  20. Mod 10 Counter - Timing Diagram 20 CSCE 436 Advanced Embedded Systems

  21. Mod 10 Counter - Timing Diagram 21 CSCE 436 Advanced Embedded Systems

  22. Mod 10 Counter - Timing Diagram 22 CSCE 436 Advanced Embedded Systems

  23. Circuit Diagram 23 CSCE 436 Advanced Embedded Systems

  24. Circuit Diagram After completing the timing diagram, see if you can figure out how to construct the counter using the arrangement of devices show in the picture below. You may assume that all these inputs are able to handle 4-bit values - to indicate this, draw a hash through the signal lines with a "4" next to it. You should not draw additional lines in this picture. Instead, label the wires with names and use these names to create logical connections between signals with the same name. Draw a border around your circuit. The only signals that should cross the boundary are those which are part of the entity description. 24 CSCE 436 Advanced Embedded Systems

  25. Circuit Diagram Build the Architecture for the Mod 10 Counter 25 CSCE 436 Advanced Embedded Systems

  26. VHDL 26 CSCE 436 Advanced Embedded Systems

  27. Mod 10 Counter VHDL Code Entity entity lec4 is Port( end lec4; 1. architecture behavior of lec4 is 2. signal rollSynch, rollCombo: STD_LOGIC; 3. signal processQ: unsigned (3 downto 0); clk: in STD_LOGIC; reset : in STD_LOGIC; ctrl: in std_logic_vector(1 downto 0); D: in unsigned (3 downto 0); Q: out unsigned (3 downto 0)); 4. begin 27 CSCE 436 Advanced Embedded Systems

  28. Mod 10 Counter VHDL Code Architecture 5. process(clk) 6. begin 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. end process; Sensitivity List Line 1 of State Table if (rising_edge(clk)) then if (reset = '0') then processQ <= (others => '0'); rollSynch <= '0'; elsif ((processQ < 9) and (ctrl = "01")) then processQ <= processQ + 1; rollSynch <= '0'; elsif ((processQ = 9) and (ctrl = "01")) then processQ <= (others => '0'); rollSynch <= '1'; elsif (ctrl = "10") then processQ <= unsigned(D); elsif (ctrl = "11") then processQ <= (others => '0'); end if; end if; Line 2 of ST: -- Reset Line 3 of ST: Not Here -- Hold Line 4 -- Count Up Line 5 of ST: -- Load D Line 6 of ST: -- Synch Reset 28 CSCE 436 Advanced Embedded Systems

  29. Mod 10 Counter VHDL Code Architecture -- Concurrent Signal Assignments 24. rollCombo <= '1' when (processQ = 9) else '0'; 25. Q <= processQ; 26. end behavior; Can add and (ctrl = "01") to confirm it only happens when counting up and count = 9 29 CSCE 436 Advanced Embedded Systems

  30. General VHDL Rules 30 CSCE 436 Advanced Embedded Systems

  31. General VHDL Rules Introduce the following rules for designing in VHDL in order to write code that can be synthesized. Never use processes for combinational logic. Only the clk should appear in the sensitivity list The outermost structure should be "if (rising_edge(clk)) then" Inside this structure should be "if (reset = '0') then" to reinitialize the state element used by the process The else clause of the reset element (the body) should consist of a set of exclusive signal conditions in an if/then case structure. Any signal on the left-hand side of an assignment statement (in the body) may not be put on the left-hand side of any assignment statement outside the process. 31 CSCE 436 Advanced Embedded Systems

  32. Adding Signals in Xsim 32 CSCE 436 Advanced Embedded Systems

  33. Adding Signals in Xsim Sometimes it is necessary to examine signals not directly visible in a design. In the Instances and Process subwindow, reveal the instances inside the lec4_tb by clicking on the arrow to the left lec4_tb. Reveal the signals inside the lec4 instance (called uut) by clicking on the label "uut". In the Objects subwindow select the signal that you want to observe on the timing diagram. In our case the ctrl signal. Drag and drop the signal into the timing diagram. In most cases you will have to restart the simulation to get a complete trace of the newly added signal. And the rerun it for the needed amount of time. 1. 2. 3. 4. 5. 33 CSCE 436 Advanced Embedded Systems

  34. Adding Signals in Xsim Vivado Simulator 34 CSCE 436 Advanced Embedded Systems

  35. Lesson Outline 1. Sequential Elements 2. Mod 10 Counter Example Truth Table Timing Diagram Circuit Diagram VHDL 3. General VHDL Rules 4. Adding Signals to Xsim 35 CSCE 436 Advanced Embedded Systems

More Related Content