ENG3050 Embedded Reconfigurable Computing Systems

Slides:



Advertisements
Similar presentations
VERILOG: Synthesis - Combinational Logic Combination logic function can be expressed as: logic_output(t) = f(logic_inputs(t)) Rules Avoid technology dependent.
Advertisements

Combinational Logic.
ECE 551 Digital System Design & Synthesis Lecture 08 The Synthesis Process Constraints and Design Rules High-Level Synthesis Options.
ENG6530 RCS ENG6530 Reconfigurable Computing Systems Hardware Description Languages Synthesis.
1 Lecture 13 VHDL 3/16/09. 2 VHDL VHDL is a hardware description language. The behavior of a digital system can be described (specified) by writing a.
Dr. Turki F. Al-Somani VHDL synthesis and simulation – Part 3 Microcomputer Systems Design (Embedded Systems)
Introduction to VHDL CSCE 496/896: Embedded Systems Witawas Srisa-an.
HDL-Based Digital Design Part I: Introduction to VHDL (I) Dr. Yingtao Jiang Department Electrical and Computer Engineering University of Nevada Las Vegas.
VHDL And Synthesis Review. VHDL In Detail Things that we will look at: –Port and Types –Arithmetic Operators –Design styles for Synthesis.
Simple Testbenches Behavioral Modeling of Combinational Logic
Overview Logistics Last lecture Today HW5 due today
Introduction to VHDL (part 2)
1 H ardware D escription L anguages Basic Language Concepts.
IAY 0600 Digitaalsüsteemide disain Event-Driven Simulation Alexander Sudnitson Tallinn University of Technology.
Synthesis Presented by: Ms. Sangeeta L. Mahaddalkar ME(Microelectronics) Sem II Subject: Subject:ASIC Design and FPGA.
1 H ardware D escription L anguages Modeling Complex Systems.
A VHDL Tutorial ENG2410. ENG241/VHDL Tutorial2 Goals Introduce the students to the following: –VHDL as Hardware description language. –How to describe.
1 H ardware D escription L anguages Modeling Digital Systems.
ENG241 Digital Design Week #6 Sequential Circuits (Part A)
VHDL Introduction. V- VHSIC Very High Speed Integrated Circuit H- Hardware D- Description L- Language.
7/10/2007DSD,USIT,GGSIPU1 Basic concept of Sequential Design.
Language Concepts Ver 1.1, Copyright 1997 TS, Inc. VHDL L a n g u a g e C o n c e p t s Page 1.
Copyright(c) 1996 W. B. Ligon III1 Getting Started with VHDL VHDL code is composed of a number of entities Entities describe the interface of the component.
(1) Basic Language Concepts © Sudhakar Yalamanchili, Georgia Institute of Technology, 2006.
Introduction to VHDL Simulation … Synthesis …. The digital design process… Initial specification Block diagram Final product Circuit equations Logic design.
VHDL Discussion Sequential Sytems. Memory Elements. Registers. Counters IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology.
1 Part III: VHDL CODING. 2 Design StructureData TypesOperators and AttributesConcurrent DesignSequential DesignSignals and VariablesState Machines A VHDL.
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
Introduction to ASIC flow and Verilog HDL
CS/EE 3700 : Fundamentals of Digital System Design
04/26/20031 ECE 551: Digital System Design & Synthesis Lecture Set : Introduction to VHDL 12.2: VHDL versus Verilog (Separate File)
5-1 Logic System Design I VHDL Design Principles ECGR2181 Reading: Chapter 5.0, 5.1, 5.3 port ( I: in STD_LOGIC_VECTOR (1 to 9); EVEN, ODD: out STD_LOGIC.
EE121 John Wakerly Lecture #17
VHDL Discussion Subprograms IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology 1.
VHDL Programming Fundamentals Presented By Dr. Pradyut Kumar Biswal Department of Electronics, IIIT Bhubaneswar.
IAY 0600 Digital Systems Design Event-Driven Simulation VHDL Discussion Alexander Sudnitson Tallinn University of Technology.
VHDL 7: use of signals v.5a1 VHDL 7 Use of signals In processes and concurrent statements.
George Mason University Behavioral Modeling of Sequential-Circuit Building Blocks ECE 545 Lecture 8.
Case Study: Xilinx Synthesis Tool (XST). Arrays & Records 2.
George Mason University Data Flow Modeling of Combinational Logic ECE 545 Lecture 5.
1 Introduction to Engineering Spring 2007 Lecture 18: Digital Tools 2.
Overview Logistics Last lecture Today HW5 due today
Combinational logic circuit
Basic Language Concepts
Behavioral Style Combinational Design with VHDL
IAY 0600 Digital Systems Design
EMT 351/4 DIGITAL IC DESIGN Week # Synthesis of Sequential Logic 10.
B e h a v i o r a l to R T L Coding
Introduction Introduction to VHDL Entities Signals Data & Scalar Types
CHAPTER 17 VHDL FOR SEQUENTIAL LOGIC
Custom Designed Integrated Circuits
Behavioral Style Combinational Design with VHDL
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
In processes and concurrent statements
IAS 0600 Digital Systems Design
ECE 434 Advanced Digital System L08
RTL Style در RTL مدار ترتيبي به دو بخش (تركيبي و عناصر حافظه) تقسيم مي شود. مي توان براي هر بخش يك پروسس نوشت يا براي هر دو فقط يك پروسس نوشت. مرتضي صاحب.
IAS 0600 Digital Systems Design
SYNTHESIS OF SEQUENTIAL LOGIC
Data Flow Modeling of Combinational Logic
VHDL Discussion Subprograms
Behavioral Modeling of Sequential-Circuit Building Blocks
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
VHDL Discussion Subprograms
IAS 0600 Digital Systems Design
IAS 0600 Digital Systems Design
ECE 551: Digital System Design & Synthesis
ECE 448 Lecture 6 Finite State Machines State Diagrams, State Tables, Algorithmic State Machine (ASM) Charts, and VHDL code ECE 448 – FPGA and ASIC Design.
Sequntial-Circuit Building Blocks
EEL4712 Digital Design (VHDL Tutorial).
Presentation transcript:

ENG3050 Embedded Reconfigurable Computing Systems Hardware Description Languages Synthesis

Topics Synthesizable/Non-Synthesizable Code Translation to Hardware Simulation vs. Synthesis Synthesis: Hints, Guidelines Summary ENG3050 ERCS

References Kenneth Short, “VHDL For Engineers”, Prentice Hall, 2008. Sudhakar Yalamanchili, “Introductory VHDL: From Simulation to Synthesis”, Prentice Hall, 2001. VHDL Guidelines for Synthesis”, Siemens Semiconductor Group. “RTL Hardware Design Using VHDL”, Pong Chu, Wiley, 2006. ENG3050 ERCS

Execution Models for VHDL Programs Two classes of execution models govern the application of VHDL programs For Simulation Discrete event simulation Understanding is invaluable in debugging programs For Synthesis Hardware inference The resulting circuit is a function of the building blocks used for implementation Primitives: NAND vs. NOR Cost/performance ENG3050 ERCS

VHDL for Synthesis VHDL for Synthesis VHDL for Simulation Only a subset of the VHDL language is synthesizable You need to understand what is meant for simulation versus what is meant for producing hardware (i.e. synthesis) The VHDL subset that is synthesizable is tool specific! Do not expect two different tools to produce the same hardware! ENG3050 ERCS

Synthesis and Hardware Inference Design Specification HDL Author #2 HDL Author #1 HDL Synthesis engine Author Hardware Design Processes can produce very different results! Why? ENG3050 ERCS

Synthesis Hardware implementation of VHDL code depends on: Coding convention & style used Fitter technology (synthesis based on compiler) Optimization option (area vs. speed vs. power) Nature of application (simple vs. complex) Not all designs are synthesizable: several constructs defined in the language cannot be synthesized! ENG3050 ERCS

Non Synthesizable Subset Examples of constructs that cannot be synthesized into hardware: File operations including text I/O Wait and After statements. Assertion/Report statements Loops with no bound (infinite while loop) Real data types are not supported Certain operators e.g., /, **, mod, rem Recursive Functions ENG3050 ERCS

VHDL versus C Terminology The following comparison shows some rough equivalents between the VHDL Concepts and C programming. Analyze or compile the package declaration? Instantiate a component? Use a Package? ENG3050 ERCS

Synthesis: Hardware Translation How does a data type translate to hardware? Integer, Real, Boolean, … How do data objects map to hardware? Signals, variables, constants, … How are statements translated to hardware? Assignments, operators, … How do constructs differ when translated to hardware? If-Else, Case, For, While, … ENG3050 ERCS

VHDL Hardware Correspondence A resolution function defines how values from multiple sources, multiple drivers, are resolved into a single value. ENG3050 ERCS

Variables versus Signals When a variable is assigned a value, it takes that value immediately (similar to conventional programming languages). When a signal is assigned a value, the assigned value does not take effect immediately. The signal does not take the new value until after the process has suspended. As a general guideline, a variable is used to store data within a process when the new value assigned to the variable is to be used (read) in the same execution of the process. ENG3050 ERCS

Simple Assignment Statements proc2: process (x, y, z) -- Process 2 using signals begin sig_s1 <= x and y; sig_s2 <= sig_s1 xor z; res2 <= sig_s1 and sig_s2; end process proc2; end architecture behavior; architecture behavior of stover is signal sig_s1, sig_s2: std_logic; begin proc1: process (x, y, z) is -- Process 1 using variables variable var_s1, var_s2: std_logic; var_s1:= x and y; var_s2:= var_s1 xor z; res1 <= var_s1 and var_s2; end process proc1; var_s1 var_s2 Variables, Signals usually translate into Wires PS: Simulation mismatch synthesis collapses multiple simulation cycles sig_s1 sig_s2

Variables and Signals ENG3050 ERCS

Inferring Storage for Variables A variable used before it is defined There exists an execution sequence (first) where use precedes definition architecture behavior of sig_var is begin process variable var_s1, var_s2 :std_logic; wait until (rising_edge(clk)); var_s1 := x nand var_s2; var_s2 := var_s1 xor y; res <= var_s1 xor var_s2; end process; end behavior; Latch? Why? var_s2 ENG3050 ERCS

Concurrent When Statement library IEEE; use IEEE.std_logic_1164.all; ENTITY mux2 is PORT(a : IN std_logic; b : IN std_logic; sel : IN std_logic; y : OUT std_logic); END mux2; ARCHITECTURE behavior OF mux2 IS BEGIN y <= a WHEN (sel = '0') ELSE b WHEN (sel = '1') ELSE 'X'; END behavior; The conditional if statement results in a multiplexor as shown in the example above.

Concurrent With Statements library IEEE; use IEEE.std_logic_1164.all; ENTITY mux4 is PORT(a : IN std_logic; b : IN std_logic; c : IN std_logic; d : IN std_logic; sel : IN std_logic_vector(1 DOWNTO 0); y : OUT std_logic); END mux4; ARCHITECTURE behavior OF mux4 IS BEGIN WITH sel SELECT y <= a WHEN "00", b WHEN "01", c WHEN "10", d WHEN "11", 'X' WHEN OTHERS; END behavior; The selected signal assignment is an alternative realization of a multiplexor. ENG3050 ERCS

Synthesis of Case Statement ENG3050 ERCS

Synthesis of an IF Statement ENG3050 ERCS

Case vs. If Statements Any case statement does have an equivalent (functionally) formulation in an if-then-elsif form. However the if-then-else must produce priority logic to maintain the priority order implicit in the nesting of the branches. This is not the situation for the case statement. Which is more efficient? As a result we would expect that the case statement is a more efficient alternative when there is no priority ordering among the alternatives. ENG3050 ERCS

Inference of basic Memory Elements VHDL code should be clear so that the pre-designed cells can be inferred. VHDL code can (might) produce: D Latch Positive edge-triggered D FF Negative edge-triggered D FF D FF with asynchronous reset ENG3050 ERCS

Latch vs. Flip Flop Inference Predicates in conditional expressions lead to latch inference if ( sel = ‘1’) then... Edge detection expressions lead to flip flop inference if (rising_edge(clk)) then... if (clk’event and clk = ‘0’) then.. if (clk’lastvalue = ‘0’ and clk = ‘1’ and clk’event) .. ENG3050 ERCS

FlipFlop/Latch Inference Rules ENG3050 ERCS

D Latch ENG3050 ERCS

Variable as Latch

Nested Constructs: D Latch Condition under which a latch is inferred When sel1,sel2,sel3 are all zero architecture behavior of nested_if is begin process (x,y,z,sel1,sel2,sel3) if (sel1 = ‘1’)then res <= x and y; elsif (sel2 =’1’) then res <= y xor z; elsif (sel3 =’1’) then res <= x or y; end if; end process; sel3 res z x y sel2 sel1 Add an else to avoid latch inferring Latch inference due to the absence of the last “else” ENG3050 ERCS

Positive Edge Triggered FF ENG3050 ERCS

D FF with Async Reset ENG3050 ERCS

Two Types of Resets (Sync, Async)

Conditional Statement architecture behavior of inflate is begin process (x, y, z, sel) is variable s1, s2: std_logic; if (sel = ‘1’)then s1:= x and z; s2:= s1 xor y; w <= s2 and s1; end if; end process; end architecture behavior; How can we avoid latch inference without using else statement? -- w gets a value only conditionally -- hence a latch is inferred conditional body S1 latch enable S2 ENG3050 ERCS

Revisit the Example architecture behavior of inflate is begin process (x, y, z, sel) is variable s1, s2: std_logic; w <= ‘0’; -- output signal set to a default value to avoid latch inference if (sel = ‘1’)then s1:= x and z; -- body generates combinational logic s2:= s1 xor y; w <= s2 and s1; end if; end process; end architecture behavior; No Latches ENG3050 ERCS

Muxes vs. Latches ENG3050 ERCS

Case Statements No Latch Synthesis of a multiplexor architecture behavior of case_st is begin process (x,y,z,sel) is case sel is when 0 => res <= x and y; when 1 => res <= y xor z; when 2 => res <= x nand z; when others => res <= x nor z; end case; end process; end architecture behavior; Synthesis of a multiplexor Any incomplete when clause  syntax error ENG3050 ERCS

Case Statements (cont.) architecture behavior of case_ex is begin process (x,y,z,sel) is case sel is when 0 => res <= x and y; when 1 => res <= y xor z; when 2 => res <= x nand z; when others => null; -- in this case the value of res -- remains unaltered end case; end process; end architecture behavior; Use of the “null” statement and latch inference How do we avoid a latch in this case? ENG3050 ERCS

Case Statements: Avoiding Latches architecture behavior of case_ex is begin process (x,y,z,sel) is Begin res <= ‘0’; case sel is when 0 => res <= x and y; when 1 => res <= y xor z; when 2 => res <= x nand z; when others => null; -- in this case the value of res -- remains unaltered end case; end process; end architecture behavior; By having an initialization statement prior to case. Use don’t care values in the “when others” clause often synthesis compilers can use this information to optimize the generated hardware. ENG3050 ERCS

Process: Incomplete Sensitivity List signal a, b, c, y: std_logic ….. process (a) is begin y <= a and b and c end process; signal a, b, c, y: std_logic ….. process (a, b, c) is begin y <= a and b and c end process; When the ‘a’ signal changes, the process is activated and the circuit acts as expected. On the other hand, when ‘b’ or ‘c’ signal changes, the process remains suspended and the ‘y’ signal keeps its previous value. This implies that the circuit has some sort of memory element ENG3050 ERCS

Synthesis Modeling Issues Ensuring compatibility between simulation and synthesis. Both VHDL descriptions below generate the same synthesis output, but differ in their simulation. Incomplete sensitivity list Full sensitivity list Process (enable, in1, in2) Process (enable, in1, in2, in3) begin begin if (enable =‘0’) then if (enable =‘0’) then output <= (in1 and in2) or in3; output <= (in1 and in2) or in3; end if ; end if; end process; end process; It is safe to include all signals at the right hand side in the sensitivity list to maintain compatibility between the simulation and synthesis. Note: most synthesis tools ignore the sensitivity list, but IEEE RTL standard recommends using a full sensitivity list to ensure compatibility with the simulation. ENG3050 ERCS

Avoiding Latch Inference Ensure every path computes a value for every signal Presence of the else branch Nested structures if-then-elsif structure Complete sensitivity list Use initial values Basic principle: ensure that every combination of input signal values leads to a computation of a value for every output signal combinational logic ENG3050 ERCS

Synthesis of 3-state Driver To specify that an output should be set to the high-impedance state, we use a signal of type std_logic and assign it a value of ‘Z’ ENG3050 ERCS

Tri-State Buses ENG3050 ERCS

Signal Selection in VHDL Signal selection in VHDL for some FPGA targets could be different from that used for ASICs, as shown below: General signal selection in VHDL if (sel =‘0’) then output <= signal_0; else output <= signal_1; end if; Signal selection is implemented here using muxes This is true for some FPGA families (e.g., Xilinx), but not for all. Preferred signal selection for FPGAs using tri-state busses output <= signal_0 when (EnA = ‘1’) else ‘Z’; output <= signal_1 when (EnB = ‘1) else ‘Z’; In some FPGAs, muxes can be expensive, and tri-state buffers are cheaper ENG3050 ERCS

Loop Statements What/How much hardware should be generated? Most commonly supported is the for loop Number of iterations is known a priori Loop is unrolled and optimized as a sequence of sequential statements for N in 3 downto 1 loop shift_reg (n) <= shift_reg (n-1); end loop; shift_reg (3) <= shift_reg (2); shift_reg (2) <= shift_reg (1); shift_reg (1) <= shift_reg (0); ENG3050 ERCS

While loop: unrolling ENG3050 ERCS

Replicated Logic: Procedures ENG3050 ERCS

While Statements ENG3050 ERCS

Synthesis Modeling Issues Using parentheses in arithmetic expressions facilitates optimization through resource sharing, and specification of concurrency, and improves critical path. The second statement below has a shorter critical path, for instance, Output <= a + b + c + d; Output <= (a + b) + (c + d) a b c d These optimizations are dependent on support from the synthesis tools. d ENG3050 ERCS

Efficiency Considerations Now that we can control latch inferencing what about circuit size and speed? Move common operations (hardware) out of the branches Good programming practice in general Trade multiplexors for more expensive hardware Set up operands ENG3050 ERCS

Efficiency Considerations

Efficiency Considerations

Efficiency Considerations entity inference is port (sel : in std_logic; x, y, z: in std_logic; w: out std_logic ); end entity inference; architecture behavior of inference is begin process (x, y, z, sel) is if (sel = ‘1’)then w <= x and y; else w <= x and z; end if; end process; end architecture behavior; entity inference is port (sel : in std_logic; x, y, z: in std_logic; w: out std_logic ); end inference; architecture behavior of inference is begin process (x, y, z, sel) variable right: std_logic; if (sel = ‘1’)then right:= y; else right:= z; end if; w <= x and right; end process; end behavior; Computation (logical AND) preceded by operand selection (mux)

Synthesis Hints: Inferring Storage Generally, edge-detection expressions will cause flip-flops rather than latches to be inferred. Otherwise latches will be inferred. If you wish to avoid having a latch inferred for a signal in a process then every execution path through the process must assign a value for that signal. If you use variables in a process before they are defined a latch will be inferred for that variable. To avoid the inference of latches, make sure that default values are assigned to signals before a conditional block of code. For variables or signals assigned within a for-loop a default value must be assigned before the for-loop to avoid latch inference. ENG3050 ERCS

Synthesis Hints Avoid programming in C or Java where we try to exploit the sequentially of the code. This will lead to long signal paths. Attempt to minimize dependencies between statements and try to promote concurrency. Move common complex operations out of the branches of if-then-else statements and place them after the conditional code. This will generally lead to less hardware. Using don’t care values to cover the when others case in a case statement can enable the synthesis compiler to optimize the logic and create a smaller circuit than if all remaining options were set to values. Using a case statement rather than an if-then-else construct will produce less logic since priority logic will have to be generated for if-.. ENG3050 ERCS

Consistency with Simulation In a simulation model delays can be specified using the after clause in the signal assignment statements. During synthesis the delay value of the operations are derived from the synthesized implementation. This may differ from the values that the designer specified for simulation. Include all signals in a process in the sensitivity list of the process to avoid pre-synthesis and post-synthesis simulation mismatches. Use a VARIABLE instead of a SIGNAL; Variables may be synthesized the same as signals but simulation is faster. Minimize the number of processes. This avoids the overhead of multiple processes suspending and restarting. ENG3050 ERCS

Extra Slides ENG3050 ERCS

Variables vs. Signals: Example proc1: process (x, y, z) is -- Process 1 variable var_s1, var_s2: std_logic; begin L1: var_s1 := x and y; L2: var_s2 := var_s1 xor z; L3: res1 <= var_s1 nand var_s2; end process; proc2: process (x, y, z) -- Process 2 begin L1: sig_s1 <= x and y; L2: sig_s2 <= sig_s1 xor z; L3: res2 <= sig_s1 nand sig_s2; end process; variables signals Distinction between the use of variables vs. signals ENG3050 ERCS

Relational Operations ENG3050 ERCS