E21 Lecture #23

VHDL: VHSIC Hardware Description Language

Time to dive into data types and syntax

Statements (processes, wait statements, if, loops, conditional assignments)

  1. wait statements
  2. wait statements suspend a process until a set of conditions is true
  3. wait on sensititvity-list;
  4. wait until boolean-expression;
  5. wait for time-expression;
  6. wait on sensitivity-list until boolean-expression for time-expression;
  7. The last statement means to wait until all of the conditions are true.
  8. You can use wait statements to create waveforms
  9. You can use wait statements to allow processes to talk to one another
  10. if statements
  11. if X then statements elsif Y then statements else statements end if;
  12. case statements
  13. case expression is when choices => statements;
  14. loop statements
  15. for, while, loop expressions
  16. loops can have labels (a good thing)
  17. loop1: for index in 1 to N loop statements end loop loop1;
  18. loop2: while N < 20 loop statements end loop loop2;
  19. loop3: loop statements exit when N > 20; end loop loop3;
  20. null statements
  21. Useful in case or if statements where you don't want to do anything
  22. exit statements
  23. Can exit loops
  24. exit with no identifier leaves the innermost loop
  25. exit with an identifier leaves the identified loop
  26. next statements
  27. Like the continue statement in C, goes back to the top of the loop
  28. assertion statements
  29. Used for debugging purposes
  30. report statements
  31. Can be used to display a message
  32. procedure calls
  33. return statements

Concurrent v. Sequential Statements and how VHDL models digital systems

We've covered the basic syntax for sequential statements, now we need to turn to a more detailed analysis of how VHDL models digital systems. In particular, how does it deal with signals, which form the basis for the transfer of information and the dataflow level of modeling.

Signal drivers

  • Signal drivers schedule events for a signal
  • They are essential to understand within a process
  • One signal driver exists for each concurrent signal assignment (signal assignments within a process are considered sequential wrt adding events to a single signal driver

Sequential v. Concurrent signal assignments

A concurrent signal assignment (not in a process) is executed whenever there is an event on one of the signals on the right hand side of the assignments.

Example: propagating signals

  • Architecture using a process to pass a value from A to B to C
  • Architecture using concurrent statements to pass a value from A to B to C

Concurrent statements still use delta delays to pass events around at a given simulation time (unless specific event times are given in the assignment statement(s)).

Example: flip-flop

pp. 109 of Bhasker

Concurrent signal drivers

Each concurrent signal assignment statement creates a driver for that signal.

What happens if more than one statement assigns a value to a single signal (multiple drivers)?

  • You create a resolution function: it decides what value the signal should have given the list of proposed values from all of the signal drivers
  • You can implement a wired-or or a wired-and function using a resolution function
  • The type std_logic is a resolved type (std_ulogic is not)

Dataflow-level Design and Modeling State Machines

-- modeling a Dff given the input signal D and output signal Q

architecture dff1 of dff is

begin

b1: block (clock = `1' and not clock'stable) -- rising edge

q <= guarded d;

qbar <= guarded not d;

end block;

end architecture;

Structural-level Design

Components

-- component declaration and usage

architecture foo1 of foo is

component andgate port(a, b: in bit; z: out bit); end component;

component orgate port(a, b: in bit; z: out bit); end component;

begin

l1: andgate port map (i1, i2, o1);

l2: andgate port map (not i1, not i2, o2);

l3: orgate port map (o1, o2, q);

end architecture;

Examples

State machine using dataflow and behavioral techniques

entity detector is

port(x clk: in bit; z: out bit);

end detector;

architecture dataflow_statemachine of detector is

type state is (reset, got1, got10, got101);

type state_vector is array (natural range <>) of state;

function one_of(sources: state_vector) return state is

begin return(sources(sources'left); end;

signal current: one_of state register := reset;

begin

clocking: block (clk = `1' and not clk'stable) begin

s1: block (current = reset and guard) begin

current <= guarded got1 when x = `1' else reset;

end block s1;

s2: block (current = got1 and guard) begin

current <= guarded got10 when x = `0' else got1;

end block s2;

s3: block (current = got10 and guard) begin

current <= guarded got101 when x = `1' else reset;

end block s3;

s4: block (current = got101 and guard) begin

current <= guarded got1 when x = `1' else got10;

-- note that the next statement is not guarded

-- and therefore could be placed anywhere

z <= `1' when (current = got101 and x = `1') else `0';

end block s4;

end block clocking;

end architecture dataflow_statemachine;

Behavioral description of two processes communicating to one another

entity twoprocess is

port (serial_in, clk: in bit;

parallel_out: out bit_vector (0 to 7));

end twoprocess;

architecture twoprocess1 of twoprocess is

signal ready, ack: bit;

data: bit_vector (0 to 7);

begin

rx: process begin -- no sensitivity list b/c of wait stmts

read_word(serial_in, clk, data); -- function to read a word

ready <= `1';

wait until ack = `1';

ready <= `0';

wait for 40ns;

end process rx;

mp: process begin

wait until ready = `1';

parallel_out <= data;

ack <= `1', `0' after 25ns; -- wait 25ns

wait 25 ns;

end process mp;

end twoprocess1;