114 Chapter Five
‘ 0 ’—Logical 0 value
‘ 1 ’—Logical 1 value
‘Z’—High-impedance or open-collector value
From the description of the two value systems, the conversion function
is trivial. Following is an example of one:
FUNCTION convert4val(S : fourval) RETURN fourvalue IS
BEGIN
CASE S IS
WHEN X =>
RETURN ‘X’;
WHEN L =>
RETURN ‘ 0 ’;
WHEN H =>
RETURN ‘ 1 ’;
WHEN Z =>
RETURN ‘Z’;
END CASE;
END convert4val;
This function accepts a value of type fourvaland returns a value of
type fourvalue. The next example shows where such a function might
be used:
PACKAGE my_std IS
TYPE fourval IS (X, L, H, Z);
TYPE fourvalue IS (‘X’, ‘ 0 ’, ‘ 1 ’, ‘Z’);
TYPE fvector4 IS ARRAY(0 TO 3) OF fourval;
END my_std;
USE WORK.my_std.ALL;
ENTITY reg IS
PORT(a : IN fvector4;
clr : IN fourval;
clk : IN fourval;
q : OUT fvector4);
FUNCTION convert4val(S : fourval)
RETURN fourvalue IS
BEGIN
CASE S IS
WHEN X =>
RETURN ‘X’;
WHEN L =>
RETURN ‘ 0 ’;
WHEN H =>
RETURN ‘ 1 ’;
WHEN Z =>