1 常用函数
(1) conv_std_logic_vector
-- conv_std_logic_vector 是一个函数 :将十进制数转换成二进制补码
frequncy <= conv_std_logic_vector(19600,16); --将十进制数转化为16bit的二进制补码
(2)
a<= std_logic_vector(resize(temp_a,16));–// 十进制temp_a转16bit的二进制数a
2 case 语句
process( clk, reset ) begin
if( clk'event and clk = '1' ) then
if( reset = '1' ) then
frequncy_temp<= 0;
else
case Send_carry is
when"00000000"=> frequncy_temp <= 180;
when"00000001"=> frequncy_temp <= 190;
when"00000010"=> frequncy_temp <= 200;
when"00000011"=> frequncy_temp <= 210;
when"00000100"=> frequncy_temp <= 220;
when"00000101"=> frequncy_temp <= 230;
when others => frequncy_temp <= 200;
end case;
end if;
end if;
end process;
2 易错点
定义一个unsigned整数a时,要注意定义的a的范围是否能够达到后面判断语句的取值(a=20)。例如:如果a的范围定义为0~12,那么肯定不会满足(a=20),此时就会进入死循环。