標題: 24進制計數(shù)器的vhdl語言設計 求幫助 [打印本頁]

作者: ch29    時間: 2018-10-22 10:32
標題: 24進制計數(shù)器的vhdl語言設計 求幫助
24進制計數(shù)器的vhdl語言設計

作者: dongriqinghao    時間: 2018-10-23 14:17
這是以前寫的,把里面的23改成別的也能實現(xiàn)任意進制。代碼如下:
library ieee;

use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity countern is
   generic (N: integer:=24);
port
(
  clk:in std_logic;
  reset:in std_logic;---------------------------復位端
  enable:in std_logic;--------------------------使能端
  q:out integer range 0 to N-1
);
end entity countern;
architecture bhv of countern is
begin
process (clk)
variable   cnt : integer range 0 to 23;
   begin
   if reset = '1' then cnt:= 0;--reset為1時計數(shù)器復位
   elsif enable = '1'then--使能端為1時計數(shù)器正常工作
  if(clk'event and clk='1') then--時鐘上升沿到來時計數(shù)
   if(cnt<23) then--加法計數(shù)
         cnt:= cnt+1;
         else
         cnt := 0;
         end if;                  
      end if;
end if;
q <= cnt; ----輸出計數(shù)值
   end process;
end bhv;
仿真波形:


TIM截圖20181023141257.jpg (162.49 KB, 下載次數(shù): 43)

TIM截圖20181023141257.jpg





歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1