pencil and rubber

Logo of Triple-A Level WCAG-1 Conformance, W3C-WAI Web Content Accessibility Guidelines 1.0

XHTML 1.0 Conformance Validation CSS 3 Conformance Validation
Logo of Department of Mathematics and Computer Science, Course on Dedicated systems, link to Forum

Sequential network examples in VHDL, hardware implementation of dataflow models

Tutorial 05 on Dedicated systems

Teacher: Giuseppe Scollo

University of Catania
Department of Mathematics and Computer Science
Graduate Course in Computer Science, 2017-18

Table of Contents

  1. Sequential network examples in VHDL, hardware implementation of dataflow models
  2. tutorial outline
  3. latches, flip-flops, registers
  4. counters, serial input registers
  5. single-rate SDF graph to hardware
  6. example: Euclid's GCD algorithm, SDF graph analysis
  7. hardware implementation of Euclid's GCD algorithm
  8. hardware pipelining
  9. pipelining in SDF graphs with loops
  10. lab experience
  11. references

tutorial outline

this tutorial deals with:

latches, flip-flops, registers

  • latch : level-sensitive one-bit memory
  • flip-flop : edge-triggered one-bit memory
  • (parallel) register: bank of flip-flops

basic D latch symbol

D latch symbol

D type flip-flop

D type flip-flop

library ieee;
use ieee.std_logic_1164.all;
entity latch is
  port (
    d : in std_logic;
    en : in std_logic;
    q : out std_logic
  );
end entity latch;

architecture beh of latch is
begin
process (d, en) is
begin
  if (en = ’1’) then
    q <= d;
  end if;
end process;
end architecture beh;

library ieee;
use ieee.std_logic_1164.all;
entity dff is
  port (
    d : in std_logic;
    clk : in std_logic;
    q : out std_logic
  );
end entity dff;

architecture simple of dff is
begin
process (clk) is
begin
  if rising_edge(clk) then
    q <= d;
  end if;
end process;
end architecture simple;

library ieee;
use ieee.std_logic_1164.all;
entity register is
  generic ( n : natural := 8 );
  port (
    d : in std_logic_vector(n−1 downto 1);
    clk : in std_logic;
    nrst : in std_logic;
    load : in std_logic;
    q : out std_logic_vector(n−1 downto 1)
  );
end entity register;

architecture beh of register is
begin
process (clk, nrst) is
begin
  if (nrst = ’0’) then
    q <= (others => ’0’);
  elsif (rising_edge(clk) and (load = 1)) then
    q <= d;
  end if;
end process;
end architecture beh;

D-type flip-flop with asynchronous set and reset

D-type flip-flop with asynchronous set and reset

counters, serial input registers

  • counters: registers counting specified clock edges
    • also used to implement timers
  • serial input registers: partly similar to counters
    • used for data input from serial lines, output is parallel

binary counter

binary counter

the use of variables easies the VHDL description in behavioural style

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity counter is
  generic ( n : integer := 4 );
  port (
    clk : in std_logic;
    rst : in std_logic;
    output : out std_logic_vector((n−1) downto 0)
  );
end;
architecture simple of counter is
begin
  process(clk, rst)
    variable count : unsigned((n−1) downto 0);
  begin
    if rst = ’0’ then
      count := (others => ’0’);
    elsif rising_edge(clk) then
      count := count + 1;
    end if;
    output <= std_logic_vector(count);
  end process;
end;

library ieee;
use ieee.std_logic_1164.all;
entity shift_register is
  generic ( n : integer := 4 );
  port (
    clk : in std_logic;
    rst : in std_logic;
    din : in std_logic;
    q : out std_logic_vector((n−1) downto 0)
  );
end entity;
architecture simple of shift_register is
begin
  process(clk, rst)
    variable shift_reg : std_logic_vector((n−1) downto 0);
  begin
    if rst = ’0’ then
      shift_reg := (others => ’0’);
    elsif rising_edge(clk) then
      shift_reg := shift_reg(n−2 downto 0) & din;
    end if;
    q <= shift_reg;
  end process;
end architecture simple;

single-rate SDF graph to hardware

hardware implementation assumption:

three implementation rules:

  1. all actors are implemented as combinational circuits
  2. all communication queues are implemented as wires (without storage)
  3. each initial token on a communication queue is replaced by a register

two definitions:

maximum clock frequency for the circuit: reciprocal of latency through critical path

example: Euclid's GCD algorithm, SDF graph analysis

algorithm: at each step (a, b) is replaced by (|a-b|, min(a,b))

Schaumont, Figure 3.10 - Euclid’s greatest common divisor as 
          an SDF graph

Schaumont, Figure 3.10 - Euclid’s greatest common divisor as an SDF graph

PASS analysis:

Schaumont, Equation 3.3 - topological matrix G of the SDF graph 
          for Euclid’s GCD algorithm

rank(G) = 1

Schaumont, Equation 3.4 - valid firing vector for matrix G

hardware implementation of Euclid's GCD algorithm

by the aforementioned three rules for a hardware implementation of the SDF model:

implementing the actors is a simple matter, by means of a few commonly used modules (multiplexers, comparators and a subtractor)

Schaumont, Figure 3.11 - Hardware implementation of Euclid’s 
          algorithm

Schaumont, Figure 3.11 - Hardware implementation of Euclid’s algorithm

hardware pipelining

example of throughput enhancement by pipelining:

Schaumont, Figure 3.12 - SDF graph of a simple moving-average 
          application

Schaumont, Figure 3.12
SDF graph of a simple moving-average application

Schaumont, Figure 3.13 - Pipelining the moving-average filter 
          by inserting additional tokens (1)

Schaumont, Figure 3.13
Pipelining the moving-average filter by inserting additional tokens (1)

Schaumont, Figure 3.14 - Pipelining the moving-average filter 
          by inserting additional tokens (2)

Schaumont, Figure 3.14
Pipelining the moving-average filter by inserting additional tokens (2)

Schaumont, Figure 3.15 - Hardware implementation of the 
          moving-average filter

Schaumont, Figure 3.15
Hardware implementation of the moving-average filter

remarks:

pipelining in SDF graphs with loops

by introducing new tokens, pipelining may change the behaviour of an SDF graph

Schaumont, Figure 3.16 - Loops in SDF graphs cannot be pipelined

Schaumont, Figure 3.16 - Loops in SDF graphs cannot be pipelined

in order to apply pipelining without changing the functional behaviour of an SDF graph with cycles, the additional tokens should be placed outside of any loop in the graph

lab experience

the circuit depicted in figure 3.11 implements the computational core of Euclid's GCD algorithm, yet it does not contain elements apt to signal the start and the end of the computation nor to distinguish inputs and output; the aims of this experience are: to extend that circuit to this purpose, to describe it in Gezel, to translate it to VHDL ad to simulate it, and finally to implement it on the DE1-SoC FPGA

  1. extend the schematic of the circuit in figure 3.11 with three input signals and two output signals:
    • a, b: the input data, 5-bit wide each
    • start: 1-bit input, to signal availability of the input data
    • gcd: the 5-bit output result
    • done: 1-bit output, to signal the end of computation and availability of the output result
    and with additional elements (flip-flop, multiplexers, maybe a comparator) useful to the stated purpose
  2. produce a Gezel description of the designed circuit and translate it to VHDL by means of the fdlvhd program
  3. create a Quartus project Euclid, assign it the produced .vhd files, compile, and simulate the behaviour of the circuit with a few input data pairs
  4. create a new Quartus project Euclid_on_DE1SoC, assign it the previous .vhd files together with the 7-segment display decoder employed in lab tutorial 4 and a new top-level VHDL entity, composing the former one with an instance of the aforementioned decoder, while mapping the I/O signals to FPGA pins as follows:
    • a, b: SW9-5, SW4-0
    • start: not KEY1
    • RST: not KEY0
    • CLK: CLOCK_50 (50 MHz system clock)
    • done: LEDR0
    • gcd: LEDR1, HEX0
  5. import the DE1-SoC pin assignments, compile, program the FPGA with the resulting .sof file, and test the functioning of the implementation with a few input data pairs

references

recommended readings:

readings for further consultation:

useful materials for the proposed lab experience
(source: Altera University Program, 2016)

VHDL sources: