1 / 60

ENG6530 Reconfigurable Computing Systems

ENG6530 Reconfigurable Computing Systems. Hardware Description Languages Synthesis. Topics. Synthesizable/Non-Synthesizable Code Translation to Hardware Simulation vs. Synthesis Synthesis: Hints, Guidelines Summary. References.

Download Presentation

ENG6530 Reconfigurable Computing Systems

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. ENG6530Reconfigurable ComputingSystems Hardware Description Languages Synthesis ENG6530 RCS

  2. Topics • Synthesizable/Non-Synthesizable Code • Translation to Hardware • Simulation vs. Synthesis • Synthesis: Hints, Guidelines • Summary ENG6530 RCS

  3. 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. ENG6530 RCS

  4. 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 ENG6530 RCS

  5. 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!

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

  7. Synthesis • Hardware implementation of VHDL code depends • Coding convention • Fitter technology • Optimization option • Nature of application • Not all designs are synthesizable: • several constructs defined in the language cannot be synthesized! ENG6530 RCS

  8. 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 ENG6530 RCS

  9. dataflow VHDL Design Styles VHDL Design Styles behavioral (algorithmic) structural Components and interconnects Concurrent statements Sequential statements • Registers • State machines • Test benches Subset most suitable for synthesis ENG6530 RCS

  10. Design Units • Design units are the fundamental building blocks in a VHDL program. • When a program is processed, it is broken into individual design units and each unit is analyzed and stored independently. • There are five kinds of design units • Entity declaration • Architecture declaration • Package declaration • Package body • Configuration ENG6530 RCS

  11. Libraries & Packages • A Package normally contains a collection of • commonly used items, such as data types, • subprograms and components, which are needed • by many VHDL programs. • Each design unit – entity, architecture, configuration • package, declaration is analyzed (compiled) and • placed in a design library. • Libraries are generally implemented as directories ENG6530 RCS

  12. Library: Example • For standard logic (std_logic) the basic package is ieee.std_logic_1164. • This package defines the values and basic logic operators for type std_logic. • The declarations can be made visible in our model file by : library IEEE; Use IEEE.STD_LOGIC_1164.ALL; Library Package ENG6530 RCS

  13. 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? ENG6530 RCS

  14. 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 these constructs differ when translated to hardware? • If-Else, Case, • For, While, …

  15. VHDL Hardware Correspondence

  16. 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. ENG6530 RCS

  17. 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; endprocess proc2; endarchitecture 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; begin var_s1:= x and y; var_s2:= var_s1 xor z; res1 <= var_s1 and var_s2; endprocess proc1; var_s1 var_s2 • Variables, Signals usually translate into Wires • PS: Simulation mismatch • synthesis collapses multiple simulation cycles sig_s1 sig_s2

  18. Variables and Signals

  19. 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; begin 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 ENG6530 RCS

  20. 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;

  21. 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; ENG6530 RCS

  22. Synthesis of Case Statement ENG6530 RCS

  23. Synthesis of an IF Statement ENG6530 RCS

  24. 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. ENG6530 RCS

  25. 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 ENG6530 RCS

  26. 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) .. ENG6530 RCS

  27. FlipFlop/Latch Inference Rules ENG6530 RCS

  28. D Latch

  29. Variable as Latch

  30. Nested Constructs: D Latch architecture behavior of nested_if is begin process (x,y,z,sel1,sel2,sel3) begin 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; Condition under which a latch is inferred When sel1,sel2,sel3 are all zero sel3 res z x y sel2 sel1 Add an else to avoid latch inferring • Latch inference due to the absence of the last “else” ENG6530 RCS

  31. Positive Edge Triggered FF

  32. D FF with Async Reset

  33. Two Types of Resets

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

  35. Revisit the Example architecture behavior of inflate is begin process (x, y, z, sel) is variable s1, s2: std_logic; begin 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; endprocess; endarchitecture behavior; No Latches ENG6530 RCS

  36. Muxes vs. Latches ENG6530 RCS

  37. Case Statements No Latch architecture behavior of case_st is begin process (x,y,z,sel) is begin case sel is when 0 => res <= x and y; when 1 => res <= y xor z; when 2 => res <= x nand z; whenothers => res <= x nor z; endcase; endprocess; endarchitecture behavior; • Synthesis of a multiplexor • Any incomplete when clause  syntax error ENG6530 RCS

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

  39. Case Statements: Avoiding Latches • 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. 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; whenothers => null; -- in this case the value of res -- remains unaltered endcase; endprocess; endarchitecture behavior; ENG6530 RCS

  40. Process: Incomplete Sensitivity List signal a, b, c, y: std_logic ….. process (a, b, c) is begin y <= a and b and c end process; signal a, b, c, y: std_logic ….. process (a) 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 ENG6530 RCS

  41. Ensuring compatibility between simulation and synthesis. Both VHDL descriptions below generate the same synthesis output, but differ in their simulation. Synthesis Modeling Issues 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; Note: most synthesis tools ignore the sensitivity list, but IEEE RTL standard recommends using a full sensitivity list to ensure compatibility with the simulation. ENG6530 RCS

  42. 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 ENG6530 RCS

  43. 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’ ENG6530 RCS

  44. Tri-State Buses ENG6530 RCS

  45. Signal selection in VHDL for some FPGA targets could be different from that used for ASICs, as shown below: Signal Selection in VHDL 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 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

  46. 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); ENG6530 RCS

  47. While loop: unrolling ENG6530 RCS

  48. Replicated Logic: Procedures

  49. While Statements ENG6530 RCS

  50. 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, b c d a Output <= a + b + c + d; Output <= (a + b) + (c + d) b a c Synthesis Modeling Issues d

More Related