signal data: Bit_vector (0 to 7);
parity_in, parity_out: Bit;
process
variable : Bit;
begin
tmp:= `0'; -- 0 xor a = a
for i in 0 to 7 loop
tmp:= tmp xor data(i);
end loop;
parity_out <= (tmp = parity_in);
end process;
signal data: Bit_vector (0 to 7);
parity_in, parity_out: Bit;
signal tmp: Bit_vector (0 to 7);
process
begin
tmp(0) <= `0';
for i in 0 to 6 loop -- why not 7?
tmp(i+1) <= tmp(i) xor data(i);
end loop;
parity_out <= (tmp(7) = parity_in);
end process;
entity countMod10 is
port (clear: in Bit;
clk: in Bit;
count: buffer Integer range 0 to 9);
end countMod10;
architecture rtl of countMod10 is
begin
process
begin
wait until (clk'event and clk='1');
if (clear='1' or count >=9) then count<=0;
else count <= count+1;
end if;
end process;
end rtl;
process (clk,data)
begin
if (clk'event and clk='1') then
q<=data;
end if;
end process;
prosess(clk,reset_low,sync_data)
begin
if reset_low='0' then
q<='0';
elsif (clk'event and clk='1') then
q<=sync_data;
end if;
end process;
process (reset_low,clk,sync_data)
begin
if (clk'event and clk='1') then
if reset_low='0' then
q<='0';
else q<=sync_data;
end if;
end if;
end process;
process (clk,reset)
begin
if (reset='0') then
rega <= "0000";
regb <= "0000";
regc <= "0000";
elsif (clk'event and clk='1') then
rega <= data;
regb <= rega + "0001";
regc <= regb + "0001";
end if;
end process;
Signals are ``updated'' once at the end of process body - the above VHDL fragment results in the pipeline:
entity MEALY is
port(X, CLOCK, RESET: in BIT;
Z: out BIT);
end;
architecture BEHAVIOR of MEALY is
type STATE_TYPE is (S0, S1, S2, S3);
signal CURRENT_STATE, NEXT_STATE: STATE_TYPE;
attribute STATE_VECTOR : STRING;
attribute STATE_VECTOR of BEHAVIOR : architecture is "CURRENT_STATE";
begin
COMBIN: process(CURRENT_STATE, X)
begin
case CURRENT_STATE is
when S0 =>
if X = '0' then
Z <= '0';
NEXT_STATE <= S0;
else
Z <= '1';
NEXT_STATE <= S2;
end if;
when S1 =>
if X = '0' then
Z <= '0';
NEXT_STATE <= S0;
else
Z <= '0';
NEXT_STATE <= S2;
end if;
when S2 =>
if X = '0' then
Z <= '1';
NEXT_STATE <= S2;
else
Z <= '0';
NEXT_STATE <= S3;
end if;
when S3 =>
if X = '0' then
Z <= '0';
NEXT_STATE <= S3;
else
Z <= '1';
NEXT_STATE <= S1;
end if;
end case;
end process;
-- Process to hold synchronous elements (flip-flops)
SYNCH: process(CLOCK, RESET)
begin -- async. reset
if (RESET = '0' ) then
CURRENT_STATE <= S0;
elsif (CLOCK'EVENT AND CLOCK = '1') then
CURRENT_STATE <= NEXT_STATE;
end if;
end process;
end BEHAVIOR;
fib 0 = 1
fib 1 = 1
fib (n+2) = fib (n+1) + fib (n)
fib x = fib' (x,1,1)
fib' (x,y,z)
= if x=N then y else
fib' (x+1,z,y+z)
fib' (x,y,z:Integer) return Integer
is while (x<N) do
{x <= x + 1;
y <= z;
z <= y + z
};
return y
if (cond='1') then
Z <= A + B;
else
Z <= A + C;
Z1 <=A;
if (cond='1') then
Z2 <= B;
else
Z2 <= C;
Z <= Z1 + Z2;
z <= a + b + c + d;
z < (a + b) + (c + d);