1 / 22

Behavioral Modeling in VHDL

Behavioral Modeling in VHDL. Dr. Alaaeldin Amin. HW5. Process Statement. Main Construct for Behavioral Modeling. Other Concurrent Statements Can Be Modeled By an Equivalent Process.

elani
Download Presentation

Behavioral Modeling in VHDL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Behavioral Modeling in VHDL Dr. Alaaeldin Amin

  2. HW5

  3. Process Statement • Main Construct for Behavioral Modeling. • Other Concurrent Statements Can Be Modeled By an Equivalent Process. • Process Statement is a Concurrent Construct which Performs a Set of Consecutive (Sequential) Actions once it is Activated. Thus, Only Sequential Statements Are Allowed within the Process Body. • Optional Optional Process_Label: PROCESS(Sensitivity_List) Process_Declarations; Begin SequentialStatements; END Process; • Whenever a SIGNAL in the Sensitivity_List of the Process Changes, The Process is Activated. • After Executing the Last Statement, the Process is SUSPENDED Until one (or more) Signal in the Process Sensitivity_ListChanges Value where it will be REACTIVATED. Constant/Variables No Signal Declarations Allowed

  4. A Process Statement Without a Sensitivity_List is ALWAYS ACTIVE, i.e. After the Last Statement is Executed, Execution returns to the First Statement and Continues (Infinite Looping). • It is ILLEGAL to Use WAIT-Statement Inside a Process Which Has a Sensitivity_List . • In case no Sensitivity_List exists, a Process may be activated or suspended Using the WAIT-Statement : Syntax : • WAIT; -- Process Suspended Indefinitely • WAIT ON Signal_List; -- Waits for Events on one of the -- Signals in the List Equiv. To Process With Sensitivity_List. • WAIT UNTIL Condition; -- Event Makes Condition True • WAIT FOR Time_Out_Expression; Notes : • When a WAIT-Statement is Executed, The process Suspends and Conditions for its Reactivation Are Set. • Process Reactivation conditions may be Mixed as follows WAIT ON Signal_ListUNTIL ConditionFOR Time_Expression; • Process Reactivated IF: • Event Occurred on the Signal_Listwhile theConditionis True, OR • Wait Period Exceeds ``Time_Expression`` • UNLESS SUSPENDED, Process Execution • (1) Takes Zero Real Time (Process Executed in one Simulation Cycle DeltaTime). • (2) Repeats Forever (Infinite Loop)

  5. Example: Process Begin A<= `1`; B <= `0`; End Process; __________________________________________________________________________________________________ • Sequential Processing: • First A is Scheduled to Have a Value `1` • Second B is Scheduled to Have a Value `0` • A & B Get their New Values At the SAME TIME (1 Delta Time Later) __________________________________________________________________________________________________ Example: Process Begin A<= `1`; IF (A= `1`) ThenAction1; ElseAction2; End IF; End Process; • Assuming a `0` Initial Value of A, • First A is Scheduled to Have a Value `1` One Delta Time Later • Thus, Upon Execution of IF_Statement, A Has a Value of `0` and Action 2 will be Taken. • If Awas Declared as a ProcessVariable, Action1 Would Have Been Taken

  6. Example- Delayed Clock Library ieee; Use ieee.STd_Logic_1164.ALL; --------------------------------------------------------------------------------------- Entity Delayed_Clk is Generic(TDel, T1: Time :=20 NS; TPer :Time := 100 NS; Initial: STd_Logic:='0'); Port( DClk : out STd_Logic); End Delayed_Clk ; Architecture Behave of Delayed_Clk is Signal Delay: Bit:='0'; Begin Delay <= '1' after Tdel; -- Flag Signal osc: Process Variable Tinitial : Time:=TPer-T1; Begin DClk <= Initial; If Initial = '1' Then Tinitial := T1; EndIf; If Delay='0' Thenwaitfor TDel+Tinitial ; Elsewaitfor Tinitial ; Endif; Dclk <= not Initial; waitfor TPer - Tinitial; End Process ; End Behave ; --____________________________________

  7. Examples : An Edge-Triggered D-FF D_FF: PROCESS(CLK) Begin IF (CLK`Eventand CLK = `1`) Then Q <= D After TDelay; END IF; END Process; D_FF: PROCESS -- No Sensitivity_List Begin WAIT UNTIL CLK = `1`; Q <= D After TDelay; END Process; D_FF: PROCESS(Clk, Clr) -- FF With Asynchronous Clear Begin IF Clr= `1` Then Q <= `0` After TD0; ELSIF (CLK`Eventand CLK = `1`) Then Q <= D After TD1; END IF; END Process; wait on X,Y until (Z = 0) for 70 NS; --Process Resumes After 70 NS OR (in Case X or Y Changes Value and Z=0 is True) Whichever Occurs First

  8. Hand Shaking Protocol • A prepares 4 bit data words, B needs 16 bit data word • Interface system I Assembles 4-Data words from A and Pass them to B. • Talk to A to get data, talk to B to put data ________________________________________________________________________________________________ ENTITYsystem_iIS PORT (in_data : In Bit_vector (3 Downto 0); Out_data : Out Bit_vector (15 Downto 0); In_ready, Out_received : In Bit; In_received, Out_ready : out Bit); END system_i; --

  9. ARCHITECTURE waiting OF system_i IS SIGNAL buffer_full, buffer_picked : BIT := '0'; SIGNAL word_buffer : Bit_vector (15 Downto 0); BEGIN a_talk: PROCESS BEGIN . . . ……………-- Talk to A, collect 4 4-bit data, keep a count -- When ready, pass 16-bit data to b_talk . . . …………… END PROCESS a_talk; _______________________________________________________________________________________________ b_talk: PROCESS BEGIN …………... . . -- Wait for 16-bit data from a_talk -- When data is received, send to B using proper handshaking . . . END PROCESS b_talk; _______________________________________________________________________________________________ END waiting; • a_talk process & b_talk process also talk to each other • Use buffer_full, buffer_picked, and word_buffer for a_talk and b_talk communication • a_talk gets data from A and talks to b_talk • b_talk talks to a_talk and sends data to B

  10. a_talk: PROCESS VARIABLE Count : INTEGER RANGE 0 TO 4 := 0; BEGIN Wait Until in_ready = '1'; count := count + 1; CASE count IS When 0 => NULL; When 1 => Word_buffer (03 DOWNTO 00) <= In_data; When 2 => Word_buffer (07 DOWNTO 04) <= In_data; When 3 => Word_buffer (11 Downto 08) <= In_data; When 4 => word_buffer (15 DOWNTO 12) <= in_data; buffer_full <= '1'; -- Setting Wait UNTIL buffer_picked = '1'; buffer_full <= '0'; -- Resetting count := 0; -- Reset Counter END CASE; in_received <= '1'; WAIT UNTIL in_ready = '0';in_received <= '0'; END PROCESS a_talk;

  11. b_talk: PROCESS BEGIN IfBuffer_full = '0' ThenWaitUntilBuffer_full = '1‘ ; EndIf; Out_data <= Word_buffer; buffer_picked<= '1'; Wait Until buffer_full = '0'; buffer_picked <= '0'; out_ready <= '1'; Wait Until out_received = '1'; out_ready <= '0'; END PROCESS b_talk; _____________________________________________________________________________

  12. X Z F2 Y F1 Register D Can Be One Process Generalized VHDL Mealy Model ArchitectureMealy of fsm is Signal D, Y: Std_Logic_Vector( ...); -- Local Signals Begin FFs: Process( Clk) Begin IF (Clk`EVENT and Clk = `1`) Then Y <= D; End IF; End Process; Transitions: Process(X, Y) Begin D <= F1(X, Y); End Process; Output: Process(X, Y) Begin Z <= F2(X, Y); End Process; End Mealy;

  13. X F1 Z F2 Y D Register Generalized VHDL MOORE Model Architecture Moore of fsm is SignalD, Y: Std_Logic_Vector( ...); -- Local Signals Begin FFs: Process( Clk) Begin IF (Clk`EVENT and Clk = `1`) Then Y <= D; End IF; End Process; Transitions: Process(X, Y) Begin D <= F1(X, Y); End Process; Output: Process(Y) Begin Z <= F2(Y); End Process; End Moore;

  14. FSM example entityfsm is port ( Clk, Reset : in Std_Logic; X : in Std_Logic_Vector(0 to 1); Z : out Std_Logic_Vector(1 downto 0)); endfsm; Architecturebehavior of fsm is Type States is (st0, st1, st2, st3); SignalPresent_State , Next_State : States ; Begin register:Process(Reset, Clk) Begin IF Reset = `1` Then Present_State <= st0; -- Machine -- Reset to st01st. Process elsIF (Clk`EVENT and Clk = `1`) Then Present_State <= Next_state; End IF; End Process;

  15. Transitions: Process(Present_State, X) Begin CASEPresent_Stateis whenst0 => Z <= ``00``; IF X = ``11`` Then Next_State <= st0; else Next_State <= st1; End IF; when st1 => Z <= ``01``; IF X = ``11`` Then Next_State <= st0; else Next_State <= st2; End IF; when st2 => Z <= ``10``; IF X = ``11`` Then Next_State <= st2; else Next_State <= st3; End IF; when st3 => Z <= ``11``; IF X = ``11`` Then Next_State <= st3; else Next_State <= st0; End IF; End CASE; End Process; End behavior;

  16. Z = F(X) X Z CL Behvioral Modeling of Combinational Logic Modeling Strategy 1. Put All Input Signals (X) in the Process Sensitivity List. 2. Define Local Process Variables(Zvar) Corresponding To the Output SignalsZ 3. In the Process Body, Compute The Local Output Variables (Zvar) as Function of the Inputs X. 4. Circuit delay is modeled by assigning ZVAR to the Signals Z After Delay DEL. Process(X) -- Declare Process Variables VariableZVAR: Bit; Begin -- Compute ZVAR=F(X) Z<=ZVARAfterDel; End Process ;

  17. Z = F(X, Y) X Z SL Y = F(X, Y) Y Behvioral Modeling of Sequential Logic Modeling Strategy 1. Put Both the Input Signals (X) AND the Feedback Signals (Y) in the Process Sensitivity List. 2. Define Local Process Variables(Yvar and Zvar) Corresponding To the FeedbackSignals(Y) and Output SignalsZ Respectively. 3. In the Process Body, Compute The Local Variables (Yvar and Zvar) as Function of X and Yvar. 4. Circuit delay is modeled by assigning Yvar and Zvar to the Signals Y and Z After the Corresponding Delays. Process(X, Y) -- Declare Process Variables VariableYvar, Zvar: Bit; Begin -- Compute YVAR and Zvar=F(X, Y) Z<=ZvarAfterDelz; Y<=YvarAfterDely; End Process ;

  18. Activates 3 Times Once Per Sensitivity List Signal Change Postponed Processes (VHDL-93) Ex: Process (a, b, c) Begin . . . . . . End Process; • IF a, b, c Change in Zero-Time but with one d-Delay from one another  • Multiple Process Activation (within d-Delay of Each other) • The final Activation Signal Transactions will Dominate • Unnecessary Execution of Processes result in Slower Operation • PostponedProcessesActivate Only After All Sensitivity List Signals Stabilize.

  19. Activates Only After All Sensitivity List Signals Stabilize (c in this case). Postponed Process (VHDL-93) Ex: Postponed Process (a, b, c) Begin . . . . . . End Process; • Concurrent Statements, e.g. Signal Assignment, Are Also Sensitive to Changes in Signals on Their Right Hand Side  Postponed Keyword Can Be Used in This Case As Well. Example Concurrent1: Postponed a <= b AND c OR d ;

  20. Passive Process • A Process Which Assigns No Value to Any Signal Object is a Passive Process • A Concurrent Procedure Call which Assigns No Value to Any Signal Object is also Passive. • Passive Processes and Procedure Calls May be included in the Entity Specification. BASIC Declarations 1. Type Declarations 2. SubType Declarations 3. Constant Declarations 4. File Declarations 4. Alias Declarations 5. Subprogram Declarations 6. Use Clause Declarations Allowed After Port Statement in Entity: • Basic Declarations • Signal Declarations • Subprogram Body • Disconnection Specification • Attribute Declarations & Specifications

  21. ENDEntity ; is Also allowed in VHDL-93 Entity Specifications The Following May be Included After A Begin Statement in an Entity Body 1. A Passive Process 2. A Passive Procedure Call 3. Concurrent Assert Statement Syntax: ENTITYEntity_NameIS [Generic ( Component Parameters)] [PORT ( Definition of Input/Output Connectors )] [ Allowed Entity Declarations] [ Begin Passive Process, Passive Procedure Call or Assert Statements ] ENDEntity _Name;

  22. Example: Assert Statements Placed in the Entity Declaration Example +ive Edge Triggered Register Design Entity Entity Register IS Generic (Ts, Th, TPW : Time; En_Del, Out_Del, Clk_Del: Time n : in Positive) ; -- n = Number of Register Bits Port ( Din : in Bit_Vector(n-1 DownTo 0) ; Dout: Out Bit_Vector(n-1 DownTo 0) ; En, Clk : in Bit); Begin -- Set-Up Time Check Assert (Clk=`0`) or Clk`Stable or Din`Stable(Ts) Report ``Setup Time Violation`` Severity Note; -- Hold Time Check Assert (Clk`Delayed(Th)=`0`) or Clk`Delayed(HT)`Stable or Din`Stable(Th) Report ``Hold Time Violation`` Severity Note; -- Check for Minimum Pulse Width Assert (Clk=`1`) or Clk`Stable or Clk`Delayed`Stable(TPW) Report ``Min Clock Pulse Width Violation`` Severity Note; ENDRegister;

More Related