Trending News
各位大大幫忙看看這VHDL程式要怎麼編譯
有個題目我不會,可以幫我解題嗎?拜託
以下是一個上數計數器UP Counter程式,其計數範圍依序為 5 ~ 255。然後每加到15、25、35 則給它一個 輸出 'A'
不知道還要再加什麼訊號給它?
或要怎麼寫才對?
請各位指導指導 謝謝
entity counter8 is
Port ( CLK : in STD_LOGIC;
Q : inout STD_LOGIC_VECTOR (0 to 7);
RESET : in STD_LOGIC );
end counter8;
architecture Behavioral of counter8 is
PROCESS (CLK,RESET,Q)
begin
if clk_in'event and clk_in='1' then
if clk_counter=255 then
clk_counter<=5;
counter_buffer<=counter_buffer+'1';
else
clk_counter<=clk_counter+10;
end process;
counter_out<=counter_buffer;
end 'A';
end if;
end if;
end Behavioral;
2 Answers
- ?Lv 61 decade agoFavorite Answer
你好,
程式重新整理並略為修改過,這樣應該都正確了。
簡單說明如下:
>程式碼前面的行號,僅供說明使用,正式的程式碼是沒有的;
>依題意要求,要有一A輸出信號,新增在第9行增;
>第15、16行定義內部運作的信號;
>第21~23定義RESET時的起始值;
>第25~29描述8位元的計數器
>第30~33描述A輸出的組合,因為有經過CLK,所以比較的嘗試值比實際的少1;
以上希望能幫得上大大的忙!如有需要,請再補充。
--
01 library ieee;
02 use ieee.std_logic_1164.all;
03 use ieee.std_logic_unsigned.all;
04
05 entity counter8 is
06 Port (
07 CLK : in std_logic;
08 Q : out std_logic_vector (0 to 7);
09 A : out std_logic;
10 RESET : in std_logic
11 );
12 end counter8;
13
14 architecture behavioral of counter8 is
15 signal clk_counter : std_logic_vector(7 downto 0);
16 signal out_counter : std_logic;
17 begin
18
19 process (CLK,RESET)
20 begin
21 if (RESET='1') then
22 clk_counter<=x"05";
23 out_counter<='0';
24 elsif CLK'event and CLK='1' then
25 if (clk_counter=x"FF") then
26 clk_counter<=x"05";
27 else
28 clk_counter<=clk_counter+'1';
29 end if;
30 if ((clk_counter=x"0E") or (clk_counter=x"18") or (clk_counter=x"22")) then
31 out_counter<='1';
32 else
33 out_counter<='0';
34 end if;
35 end if;
36 end process;
37
38 Q<=clk_counter;
39 A<=out_counter;
40
41 end behavioral;
- Anonymous7 years ago
【亞洲36588合法彩券公司直營 官網: A36588.NET 】
【 最新活動→迎接新會員,首存狂送20% 】
【運動→電子→對戰→現場→彩球 】
【免費服務 →電影區、討論區、KTV歡唱、運動轉播、即時比分、24H客服 】
【亞洲36588合法彩券公司直營 官網: A36588.NET 】