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.
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.
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)).
-- modeling a Dff given the input signal D and output signal Q
-- component declaration and usage
component andgate port(a, b: in bit; z: out bit); end component;
component orgate port(a, b: in bit; z: out bit); end component;
l1: andgate port map (i1, i2, o1);
l2: andgate port map (not i1, not i2, o2);
State machine using dataflow and behavioral techniques
port(x clk: in bit; z: out bit);
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;
clocking: block (clk = `1' and not clk'stable) begin
s1: block (current = reset and guard) begin
current <= guarded got1 when x = `1' else reset;
s2: block (current = got1 and guard) begin
current <= guarded got10 when x = `0' else got1;
s3: block (current = got10 and guard) begin
current <= guarded got101 when x = `1' else reset;
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 architecture dataflow_statemachine;
Behavioral description of two processes communicating to one another
parallel_out: out bit_vector (0 to 7));
architecture twoprocess1 of twoprocess is
rx: process begin -- no sensitivity list b/c of wait stmts
read_word(serial_in, clk, data); -- function to read a word