📄 37_test_105.vhd
字号:
--Page :308,309
--Objective :Function slices
--Filename :test_105.vhd
--Author :Joseph Pick
entity Test_105 is
end Test_105;
architecture Behave_1 of Test_105 is
type Logic4 is ('x','0','1','z');
type Logic4_Vector is array (NATURAL range <> ) of Logic4;
type Logic4_Table is array ( Logic4,Logic4) of Logic4;
constant Sample_Tb1 : Logic4_Table := (('x','x','1','x'),
('x','0','1','z'),
('1','1','1','1'),
('x','z','1','z'));
function Manipulate_Vectors(L_V,R_V : Logic4_Vector)
return Logic4_Vector is
alias L_V_Alias : Logic4_Vector(L_V'LENGTH downto 1) is L_V;
alias R_V_Alias : Logic4_Vector(R_V'LENGTH downto 1) is R_V;
variable Result : Logic4_Vector(L_V'LENGTH downto 1);
begin
for I in Result'RANGE loop
Result(I) := Sample_Tb1(L_V_Alias(I), R_V_Alias(I));
end loop;
return Result;
end Manipulate_Vectors;
signal Vector_A : Logic4_Vector(0 to 7);
signal Vector_B : Logic4_Vector(0 to 7);
signal Vector_C : Logic4_Vector(0 to 7);
begin
Funct_Slice_Test:
process
--variable Vector_A : Logic4_Vector(0 to 7);
--variable Vector_B : Logic4_Vector(0 to 7);
--variable Vector_C : Logic4_Vector(0 to 7);
begin
Vector_A <= "xxx1z1x1";
Vector_B <= "111100x0";
Vector_C <= Manipulate_Vectors(Vector_A,Vector_B);
--Following line should result in a run_time errorr
--due to the fact that the function slice has an ascending
--range whereas the returned result is declared
--to have a descending one .
--Vector_C := Manipulate_Vectors(Vector_A,Vector_B)(4 downto 1);
--Following line result in a run_time error due to the fact
--element result(0) does not exist.
--Vector_C := Manipulate_Vectors(Vector_A,Vector_B)
-- (4 downto 1);
wait for 50 ns;
end process Funct_Slice_Test;
Finish:
process
begin
wait for 400 ns;
assert false
report "--------End of Simulation--------"
severity error;
end process Finish;
end Behave_1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -