Session four

468 views
403 views

Published on

Published in: Education, Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
468
On SlideShare
0
From Embeds
0
Number of Embeds
45
Actions
Shares
0
Downloads
40
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Session four

  1. 1. http://www.bized.co.uk Session 4Prepared by Alaa Salah Shehata Mahmoud A. M. Abd El Latif Mohamed Mohamed Tala’t Mohamed Salah Mahmoud Version 02 – October 2011 Copyright 2006 – Biz/ed
  2. 2. http://www.bized.co.uk 4 -Data Operators -AggregateContents -Concatenation -Attributes -LABs -Counters -Rotating LEDs 2 Copyright 2006 – Biz/ed
  3. 3. Session 4 http://www.bized.co.uk Data Operators 3 Copyright 2006 – Biz/ed
  4. 4. Session 4 http://www.bized.co.ukData Operators ConcatenationUsed to merge two operands together using the concatenation operator (&).This result is an array in which length is the sum of lengths of both operands. C <= A & B A B C 4 Copyright 2006 – Biz/ed
  5. 5. Session 4 http://www.bized.co.ukShift registers Example 19 5 Copyright 2006 – Biz/ed
  6. 6. Session 4 http://www.bized.co.ukData Operators Concatenation A7 A0 Shift Right Register: A <= „0‟ & A(7 downto 1); 0 A7 A1 A7 A0 Shift Left Register: A <= A(6 downto 0) & „0‟ ; 0 A6 A0 6 Copyright 2006 – Biz/ed
  7. 7. Session 4 http://www.bized.co.ukData Operators Concatenation A7 A0 Shift Right Register: A <= A(7) & A(7 downto 1); A7 A7 A1 we use this shifting when we need to keep the sign in our vector and not losing it. A7 A7 A7 A2 7 Copyright 2006 – Biz/ed
  8. 8. Session 4 http://www.bized.co.ukRotating registers Example 20 8 Copyright 2006 – Biz/ed
  9. 9. Session 4 http://www.bized.co.ukData Operators Concatenation A7 A0 Rotate Right Register: A <= A(0)& A(7 downto 1); A0 A7 A1 A7 A0 Shift Left Register: A <= A(6 downto 0) & A(7); A6 A0 A7 9 Copyright 2006 – Biz/ed
  10. 10. Session 4 http://www.bized.co.ukData Operators AggregateProvides an easy way of assigning objects of composite typesThe aggregate assigns values to a selected elements of an array or a record.Example 20Signal data_bus : std_logic_vector(15 downto 0);data_bus <= (15 downto 8 => 0 , others => 1); “0000000011111111”data_bus <= (1 | 4 | 7 => 1, 2 | 3 => 0, others => Z); “ZZZZZZZZ1ZZ1001Z”data_bus <= (others => ‘Z); -- fill data_bus with ones “ZZZZZZZZZZZZZZZZ” 10 Copyright 2006 – Biz/ed
  11. 11. Session 4 http://www.bized.co.uk Exercise 5 11 Copyright 2006 – Biz/ed
  12. 12. Session 4 http://www.bized.co.ukWrite the statement“0000000100000000” --16bit“11111111” --8 bits“11110011” --8bits 12 Copyright 2006 – Biz/ed
  13. 13. Session 4 http://www.bized.co.ukWrite the statement“0000000100000000” --16bit data_bus <= ( 8 => ‘1’ , others => ‘0’ ) ;“11111111” --8 bits data_bus <= (others => ‘1’ ) ;“11110011” --8bits data_bus <= ( 3|2 => ‘0’,others => ‘1’ ) ; 13 Copyright 2006 – Biz/ed
  14. 14. Session 4 http://www.bized.co.ukAttributes Attribute Return valueAttributes allow returning information about entities , architectures ,types , signals Count’left 0„left, „right, „high, „length, ‟range, „event, … States’left Idle Word’left 15NotePronounce the apostrophe as “tick “ Count’right 127 States’right WriteExample Word’right 0Type count is integer range 0 to 127 ; Count’high 127 States’high WriteType states is ( idle , decision , read , write ) ; Word’high 15Type word is array ( 15 downto 0 ) of std_logic ; Count’low 0Note States’low IdleAs we know if we need to ask about the rising edge of the clk we Word’low 0can say if rising_sdge(clk) then Count’length 128 States’length 4by using attributes we also can ask about the clk with other formula Word’length 16that saysif (clk’event and clk = ‘1’) then 14 Copyright 2006 – Biz/ed
  15. 15. Session 4 http://www.bized.co.uk• General example on Attributes Example 21 15 Copyright 2006 – Biz/ed
  16. 16. Session 4 http://www.bized.co.ukARCHITECTURE examp OF attrs IS Type myInt is range 0 to 15; Type states is (red, yellow, green); Type word is array (15 downto 0) of std_logic; Signal count: integer; signal mySig: myInt; signal state : states;BEGIN process begin mySig <= myIntleft; count <= wordleft; state <= statesleft; wait for 10 ns; mySig <= myIntright; count <= wordright; state <= statesright; wait for 10 ns; mySig <= myIntlow; count <= wordlow; state <= stateslow; wait for 10 ns; mySig <= myInthigh; count <= wordhigh; state <= stateshigh; wait for 10 ns; count <= wordlength; wait; end process;END ARCHITECTURE examp; 16 Copyright 2006 – Biz/ed
  17. 17. Session 4 http://www.bized.co.ukSequential Circuits on Modelsim 17 Copyright 2006 – Biz/ed
  18. 18. Session 4 http://www.bized.co.ukAs clock is found in your design..the output registered (saved) and appeared next clk cycle 18 Copyright 2006 – Biz/ed
  19. 19. Session 4 http://www.bized.co.uk• 4-Bit binary Counter lab 5 19 Copyright 2006 – Biz/ed
  20. 20. Session 4 http://www.bized.co.uk• 4-Bit binary Counter with asynchronous load lab 6 20 Copyright 2006 – Biz/ed
  21. 21. Session 4 http://www.bized.co.ukAssignment Session-44-Bit binary Up-Down Counter with asynchronous load 21 Copyright 2006 – Biz/ed
  22. 22. Session 4 http://www.bized.co.uk• One way rotating LEDs lab 7 22 Copyright 2006 – Biz/ed
  23. 23. Session 4 http://www.bized.co.ukAssignment Session-4Two Ways Rotating LEDs 23 Copyright 2006 – Biz/ed
  24. 24. Session 4 http://www.bized.co.ukDownload Session 4 material Session 4.pdf Labs4.txtAsk for the material through mail start.courses@gmail.comFacebook group start.group@groups.facebook.com 24 Copyright 2006 – Biz/ed
  25. 25. Session 4 http://www.bized.co.ukQuestions Session-4 25 Copyright 2006 – Biz/ed
  26. 26. Session 4 http://www.bized.co.ukTake Your Notes Print the slides and take your notes here--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 26 Copyright 2006 – Biz/ed
  27. 27. Session 4 http://www.bized.co.ukTake Your Notes Print the slides and take your notes here--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 27 Copyright 2006 – Biz/ed
  28. 28. Session 4 http://www.bized.co.ukSee You Next Session 28 Copyright 2006 – Biz/ed

×