1.1100110Դ?源码?
2.EDA课ç¨è®¾è®¡ï¼ç¨VHDLç¼ç¨ååºç§è½¦è®¡è´¹å¨
3.vhdl 实现时钟整点报时功能
1100110Դ??
= b = o = ox
= b = o = ox
源码
反码 (正数的反码与原码相同)
补码 (正数的补码与反码相同)
-
源码
反码
补码
EDA课ç¨è®¾è®¡ï¼ç¨VHDLç¼ç¨ååºç§è½¦è®¡è´¹å¨
课ç¨è®¾è®¡å 容ä¸è¦æ±
1ï¼ç¨å¼å ³æé®è¡¨ç¤ºèå²ï¼æ¯ä¸ªèå²ä»£è¡¨ç±³ï¼ä¸ªèå²1å ¬éï¼æ¯å ¬é1.4å ï¼è½åæ¥æ¾ç¤ºéç¨åè´¹ç¨ï¼
2ï¼ä½äº2å ¬é5å 计费ï¼é«äº2å ¬éæ»è´¹ç¨=èµ·æ¥è´¹ç¨+ï¼éç¨-2å ¬éï¼*éç¨åä»·+
çåæ¶é´*çååä»·ï¼
3ï¼çåæ¶é´å¤§äº2åéï¼ææ¯åé1.3å 计费ï¼
4ï¼å¯ä»¥è®¾å®èµ·æ¥ä»·åéç¨åä»·ã
ä¸ã设计åçä¸ææ¯æ¹æ³ï¼
å æ¬ï¼çµè·¯å·¥ä½åçåæä¸åçå¾ãå å¨ä»¶éæ©ä¸åæ°è®¡ç®ãçµè·¯è°è¯æ¹æ³ä¸ç»æ说æï¼
软件设计说æ书ä¸æµç¨å¾ã软件æºç¨åºä»£ç ã软件è°è¯æ¹æ³ä¸è¿è¡ç»æ说æã
æ ¹æ®è®¾è®¡è¦æ±ï¼ç³»ç»çè¾å ¥ä¿¡å·clkï¼è®¡ä»·å¼å§ä¿¡å·startï¼çå¾ ä¿¡å·stopï¼éç¨èå²ä¿¡å·finãç³»ç»çè¾åºä¿¡å·æï¼æ»è´¹ç¨æ°C0âc3ï¼è¡é©¶è·ç¦»k0âk1ï¼çå¾ æ¶é´m0âm1çãç³»ç»æ两个èå²è¾å ¥ä¿¡å·clk_k,fin,å ¶ä¸clk_kå°æ ¹æ®è®¾è®¡è¦æ±åé¢æhzï¼hzå1hzåå«ä½ä¸ºå ¬é计费åè¶ æ¶è®¡è´¹çèå²ã两个æ§å¶è¾å ¥å¼å ³startï¼stopï¼æ§å¶è¿ç¨ä¸ºï¼startä½ä¸ºè®¡è´¹å¼å§çå¼å ³ï¼å½start为é«çµå¹³æ¶ï¼ç³»ç»å¼å§æ ¹æ®è¾å ¥çæ åµè®¡è´¹ãå½æä¹å®¢ä¸è½¦å¹¶å¼å§è¡é©¶æ¶ï¼finèå²å°æ¥ï¼è¿è¡è¡é©¶è®¡è´¹ï¼æ¤æ¶çstopéè¦ç½®ä¸º0ï¼å¦éå车çå¾ ï¼å°±æstopå为é«çµå¹³ï¼
并å»é¤finè¾å ¥èå²ï¼è¿è¡çå¾ è®¡è´¹ï¼å½ä¹å®¢ä¸è½¦ä¸ä¸çå¾ æ¶ï¼ç´æ¥å°start置为0ï¼ç³»ç»åæ¢å·¥ä½ï¼ä»·æ ¼å¼å§å½ä¸ºèµ·æ¥ä»·5.0å ã
æ´ä¸ªè®¾è®¡ç±åé¢æ¨¡åï¼è®¡é模åï¼è®¡è´¹æ¨¡åï¼æ§å¶æ¨¡ååæ¾ç¤ºæ¨¡åäºä¸ªé¨åç»æã
å ¶ä¸è®¡é模åæ¯æ´ä¸ªç³»ç»å®ç°éç¨è®¡æ°åæ¶é´è®¡æ°çéè¦é¨åï¼æ§å¶æ¨¡åæ¯å®ç°ä¸å计费æ¹å¼çéæ©é¨åï¼æ ¹æ®æ设计ç使è½ç«¯éæ©æ¯æ ¹æ®éç¨è®¡è´¹è¿æ¯æ ¹æ®çå¾ æ¶é´è®¡è´¹ï¼åæ¶è®¾è®¡éè¿åé¢æ¨¡å产çä¸åé¢ççèå²ä¿¡å·æ¥å®ç°ç³»ç»ç计费ã计é模åéç¨1hzç驱å¨ä¿¡å·ï¼è®¡è´¹æ¨¡åéç¨hzï¼hzç驱å¨ä¿¡å·ï¼è®¡é模åæ¯è®¡æ°ä¸æ¬¡ï¼è®¡é模åå°±å®ç°æ¬¡æè 次计æ°ï¼å³ä¸ºå®ç°è®¡æ¶ç1.3å /minï¼è®¡ç¨æ¶ç1.4å /kmçæ¶è´¹ãç»ææ¡å¾å¦ä¸æ示ï¼
1.ç¾è¿å¶æ¨¡åï¼
å®ç°ç¾ç±³èå²ç驱å¨ä¿¡å·ï¼å 件æ¡å¾å¦å¾3æ示ï¼
å¾3 ç¾è¿å¶æ¨¡åæ¡å¾
æºç¨åºå¦ä¸ï¼
library ieee;
use ieee.std_logic_.all;
use ieee.std_logic_unsigned.all;
entity baijinzhi is
port(start,clk2: in std_logic; --ç§èå²
a: out std_logic_vector(3 downto 0));
end baijinzhi;
architecture rt1 of baijinzhi is
signal count_1:std_logic_vector(3 downto 0);
begin
a<=count_1;
process(start,clk2)
begin
if(start='0')then
count_1<="";
elsif(clk2'event and clk2='1')then
if(count_1="")then
count_1<="";
else
count_1<=count_1+'1';
end if;
end if;
end process;
end rt1
2.计费模å
; å®ç°éç¨åçåæ¶é´ç计费并è¾åºå°æ¾ç¤ºï¼å 件æ¡å¾4å¦ä¸ï¼
å¾4 计费模åæ¡å¾
æºç¨åºå¦ä¸ï¼
Library IEEE;
use IEEE.std_logic_.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
entity jifei is
port(clk2:in std_logic; --计费驱å¨ä¿¡å·
start:in std_logic; --计费å¼å§ä¿¡å·
c0,c1,c2,c3:buffer std_logic_vector(3 downto 0));
end jifei;
architecture rt1 of jifei is
begin
process(clk2,start)
begin
if start='0'then c3<="";c2<="";c1<="";c0<=""; --èµ·æ¥ä»·5å
elsif clk2'event and clk2='1'then
if c0="" then c0<="";
if c1="" then c1<="";
if c2="" then c2<="";
if c3="" then c3<="";
else c3<=c3+1;
end if;
else c2<=c2+1;
end if;
else c1<=c1+1;
end if;
else c0<=c0+1;
end if;
end if;
end process;
end rt1;
3.å ¬é模å
å®ç°åç¨ç计æ°åè¾åºè®¡è´¹èå²ï¼å 件æ¡å¾5å¦ä¸ï¼
å¾5 å ¬é模åæ¡å¾
æºç¨åºå¦ä¸ï¼
library ieee;
use ieee.std_logic_.all;
use ieee.std_logic_unsigned.all;
entity gongli is
port(clk1,start: in std_logic; --ç¾ç±³èå²
k1,k2,k3,k4: out std_logic_vector(3 downto 0); --éç¨æ¾ç¤º
temp2 : out std_logic);
end gongli;
architecture rt1 of gongli is
signal count_1: std_logic_vector(3 downto 0);
signal count_2: std_logic_vector(3 downto 0);
signal count_3: std_logic_vector(3 downto 0);
signal count_4: std_logic_vector(3 downto 0);
begin
k1<=count_1;
k2<=count_2;
k3<=count_3;
k4<=count_4;
process(start,clk1)
begin
if(start='0')then
count_1<="";
count_2<="";
count_3<="";
count_4<=""; ---å ¬éæ¸ é¶
elsif(clk1'event and clk1='1')then
if(count_1="")then --å ¬é计æ°å¨
count_1<="";count_2<=count_2+1;temp2<='1';
if(count_2="")then
count_2<="";count_3<=count_3+'1';
if(count_3="")then
count_3<="";count_4<=count_4+'1';
end if;
end if;
else
count_1<=count_1+'1';temp2<='0';
end if;
end if;
end process;
end rt1;
4.è¾åºæ¨¡å
å®ç°æææ°æ®çè¾åºï¼å 件æ¡å¾6å¦ä¸ï¼
å¾6 è¾åºæ¨¡åæ¡å¾
æºç¨åºå¦ä¸ï¼
library ieee;
use ieee.std_logic_.all;
use ieee.std_logic_unsigned.all;
entity shuchu is
port(y: in std_logic_vector(3 downto 0);
e: out std_logic_vector(6 downto 0));
end shuchu;
architecture rt1of shuchu is
begin
process
begin
case y is
when""=>e<="";
when""=>e<="";
when""=>e<="";
when""=>e<="";
when""=>e<="";
when""=>e<="";
when""=>e<="";
when""=>e<="";
when""=>e<="";
when""=>e<="";
when others=>e<="";
end case;
end process;
end rt1;
5.æ¾ç¤ºæ¨¡å
å®ç°æææ°æ®çæ¾ç¤ºï¼å 件æ¡å¾7å¦ä¸ï¼
å¾7 æ¾ç¤ºæ¨¡åæ¡å¾
æºç¨åºå¦ä¸ï¼
library ieee;
use ieee.std_logic_.all;
use ieee.std_logic_unsigned.all;
entity xianshi is
port(start: in std_logic;
a:in std_logic_vector(3 downto 0); --éæ©ä¿¡å·
c1,c2,c3,c4,out1,out2,out3,out4:in std_logic_vector(3 downto 0); --éç¨æ¾ç¤º,æ¶é´æ¾ç¤ºè¾å ¥
y:out std_logic_vector(3 downto 0)); --éç¨æ¾ç¤º,æ¶é´æ¾ç¤ºè¾åº
end xianshi;
architecture rt1 of xianshi is
begin
process
begin
if(start='0')then
y<="";
else case a is
when ""=> y<=c1 ;
when ""=> y<=c2 ;
when ""=> y<=c3 ;
when ""=> y<=c4 ;
when ""=> y<=out1 ;
when ""=> y<=out2;
when ""=> y<=out3 ;
when ""=> y<=out4;
when others =>y<= "";
end case;
end if;
end process;
end rt1;
6.dian模å
å¾8 dian模åæ¡å¾
æºç¨åºå¦ä¸ï¼
library ieee;
use ieee.std_logic_.all;
use ieee.std_logic_unsigned.all;
entity dian is
port(a: in std_logic_vector(3 downto 0);
e: out std_logic);
end dian;
architecture rt1 of dian is
begin
process
begin
case a is
when ""=>e<='1';
when ""=>e<='1';
when others=>e<='0';
end case;
end process;
end rt1;
ä¸ãä¸å个模å设计åæ
ç³»ç»æ»ä½é¡¶å±æ¡å¾å¦ä¸ï¼
ç³»ç»æ»ä½é¡¶å±æ¡å¾
ç¨åºæç»åè½å®ç°æ³¢å½¢ä»¿ç
1. åé¢æ¨¡å
ç±äºå®éªç®±ä¸æ²¡æhzåhzçæ´æ°åæ¶éä¿¡å·ï¼å æ¤éç¨é¢çè¾å¤§çkhzè¿è¡åé¢ï¼ä»¥è¿ä¼¼å¾å°hzï¼hzå1hzçæ¶éé¢çãéè¿ä»¥ä¸ä¸ç§ä¸åé¢ççèå²ä¿¡å·å®è¡åºç§è½¦è¡é©¶ï¼çå¾ ä¸¤ç§æ åµä¸çä¸å计费ã模åå 件å¦ä¸ï¼
åé¢æ¨¡åæ¡å¾
æºç¨åºå¦ä¸ï¼
Library IEEE;
use IEEE.std_logic_.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
entity fenpin is
port(clk_k:in std_logic; --ç³»ç»æ¶é
clk_:buffer std_logic; --åé¢
clk_:buffer std_logic; --åé¢
clk_1 : buffer std_logic); --1åé¢
end fenpin ;
architecture rt1 of fenpin is
signal q_:integer range 0 to ; --å®ä¹ä¸é´ä¿¡å·é
signal q_:integer range 0 to ;
signal q_1:integer range 0 to ;
begin
process(clk_k)
begin
If(clk_k' event and clk_k='1')then
If q_= then q_<=0;clk_<=not clk_;
else q_<=q_+1;
end if; --å¾hzé¢çä¿¡å·
If q_= then q_<=0;clk_<=not clk_;
else q_<=q_+1;
end if; --å¾hzé¢çä¿¡å·
If q_1= then q_1<=0;clk_1<=not clk_1;
else q_1<=q_1+1;
end if; --å¾1hzé¢çä¿¡å·
end if;
end process;
end rt1ï¼
2. 计é模å
计é模å主è¦å®æ计æ¶å计ç¨åè½ã
计æ¶é¨åï¼è®¡ç®ä¹å®¢ççå¾ ç´¯ç§¯æ¶é´ï¼å½çå¾ æ¶é´å¤§äº2minæ¶ï¼æ¬æ¨¡åä¸en1使è½ä¿¡å·å为1ï¼å½clk1æ¯æ¥ä¸ä¸ªä¸å沿ï¼è®¡æ¶å¨å°±èªå¢1ï¼è®¡æ¶å¨çéç¨ä¸ºminï¼æ»¡éç¨åèªå¨å½é¶ã
计ç¨é¨åï¼è®¡ç®ä¹å®¢æè¡é©¶çå ¬éæ°ï¼å½è¡é©¶éç¨å¤§äº2kmæ¶ï¼æ¬æ¨¡åä¸en0使è½ä¿¡å·å为1ï¼å½clkæ¯æ¥ä¸ä¸ªä¸å沿ï¼è®¡ç¨å¨å°±èªå¢1ï¼è®¡ç¨å¨çéç¨ä¸ºkmï¼æ»¡éç¨åèªå¨å½é¶ã
å 件æ¡å¾ä¸ºï¼
计é模åæ¡å¾
计é模å仿ç波形为ï¼
æºç¨åºå¦ä¸ï¼
library ieee;
use ieee.std_logic_.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity jiliang is
port(start:in std_logic; --计费å¼å§ä¿¡å·
fin:in std_logic; --éç¨èå²ä¿¡å·
stop:in std_logic; --è¡é©¶ä¸éçå¾ ä¿¡å·
clk1:in std_logic; --驱å¨èå²
en1,en0:buffer std_logic; --计费å价使è½ä¿¡å·
k1,k0:buffer std_logic_vector(3 downto 0); --è¡é©¶å ¬é计æ°
m1,m0:buffer std_logic_vector(3 downto 0)); --çå¾ æ¶é´è®¡æ°
end jiliang;
architecture rt2 of jiliang is
signal w:integer range 0 to ; --计æ¶èå´0~
begin
process(clk1)
begin
if(clk1'event and clk1='1')then
if start='0' then
w<=0;en1<='0';en0<='0';m1<="";
m0<="";k1<="";k0<="";
elsif stop='1' then --计æ¶å¼å§ä¿¡å·
if w= then
w<=0;
else w<=w+1;
end if;
if m0="" then
m0<="";
if m1="" then
m1<="";
else m1<=m1+1;
end if;
else m0<=m0+1;
end if;
if stop='1' then en0<='0';
if m1&m0>"" then en1<='1'; --è¥çå¾ æ¶é´å¤§äº2minåen1ç½®1
else en1<='0';
end if;
end if;
elsif fin='1' then --éç¨è®¡æ°å¼å§
if k0="" then k0<="";
if k1="" then k1<=""; --计ç¨èå´0~
else k1<=k1+1;
end if;
else k0<=k0+1;
end if;
if stop='0' then
en1<='0';
if k1&k0>"" then
en0<='1'; --è¥è¡ä½¿éç¨å¤§äº2kmï¼åen0ç½®1
else en0<='0';
end if;
end if;
end if;
end if;
end process;
end rt2;
3. æ§å¶æ¨¡å
æ¬æ¨¡å主è¦æ¯éè¿è®¡é模å产çç两个ä¸åçè¾å ¥ä½¿è½ä¿¡å·en0ï¼en1ï¼å¯¹æ¯ä¸ªåé¢æ¨¡åè¾åºçhzï¼hzçèå²è¿è¡éæ©è¾åºçè¿ç¨ï¼æ¬æ¨¡åå®ç°äºåèå²çäºéä¸ï¼æç»ç®ç为äºè®¡è´¹æ¨¡åä¸å¯¹è¡é©¶è¿ç¨ä¸ä¸åçæ¶æ®µè¿è¡è®¡ä»·ã
模åå 件å¦ä¸ï¼
æ§å¶æ¨¡åæ¡å¾
æ§å¶æ¨¡å仿ç波形为ï¼
æºç¨åºå¦ä¸ï¼
Library IEEE;
use IEEE.std_logic_.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
entity kongzhi is
port(en0,en1:in std_logic; --使è½éæ©ä¿¡å·
clk_in1:in std_logic; --åé¢è¾å ¥ä¿¡å·
clk_in2:in std_logic; --åé¢è¾å ¥ä¿¡å·
clk_out:out std_logic); --è¾åºä¿¡å·
end kongzhi;
architecture rt3 of kongzhi is
begin
process(en0,en1)
begin
if en0='1' then --å®ç°äºéä¸åè½
clk_out<=clk_in1;
elsif en1='1' then
clk_out<=clk_in2;
end if;
end process;
end rt3;
4.计费模å
å½è®¡è´¹ä¿¡å·startä¸ç´å¤äºé«çµå¹³å³è®¡è´¹ç¶ææ¶ï¼æ¬æ¨¡åæ ¹æ®æ§å¶æ¨¡åéæ©åºçä¿¡å·ä»è对ä¸åçåä»·æ¶æ®µè¿è¡è®¡è´¹ãå³è¡ç¨å¨2kmå ï¼èä¸çå¾ ç´¯è®¡æ¶é´å°äº2minå为起æ¥ä»·5å ï¼2kmå¤ä»¥æ¯å ¬é1.4.å 计费ï¼çå¾ ç´¯ç§¯æ¶é´è¶ è¿2minåææ¯åé1.3å 计费ãc0ï¼c1ï¼c2ï¼c3åå«è¡¨ç¤ºè´¹ç¨çæ¾ç¤ºã
模åå 件为ï¼
计费模åæ¡å¾
计费模å仿ç波形为ï¼
æºç¨åºå¦ä¸ï¼
Library IEEE;
use IEEE.std_logic_.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
entity jifei is
port(clk2:in std_logic; --计费驱å¨ä¿¡å·
start:in std_logic; --计费å¼å§ä¿¡å·
c0,c1,c2,c3:buffer std_logic_vector(3 downto 0));
end jifei;
architecture rt4 of jifei is
begin
process(clk2,start)
begin
if start='0'then c3<="";c2<="";c1<="";c0<=""; --èµ·æ¥ä»·5å
elsif clk2'event and clk2='1'then
if c0="" then c0<="";
if c1="" then c1<="";
if c2="" then c2<="";
if c3="" then c3<=""; --计价èå´0~.9
else c3<=c3+1;
end if;
else c2<=c2+1;
end if;
else c1<=c1+1;
end if;
else c0<=c0+1;
end if;
end if;
end process;
end rt4;
5.æ¾ç¤ºæ¨¡å
æ¾ç¤ºæ¨¡åå®æ计价ï¼è®¡æ¶å计ç¨æ°æ®æ¾ç¤ºã计费æ°æ®éå ¥æ¾ç¤ºæ¨¡åè¿è¡è¯ç ï¼æåéè³ä»¥ç¾å ï¼åå ï¼å ï¼è§ä¸ºåä½å¯¹åºçæ°ç 管ä¸æ¾ç¤ºã计æ¶æ°æ®éå ¥æ¾ç¤ºæ¨¡åè¿è¡è¯ç ï¼æåéè³ä»¥å为åä½å¯¹åºçæ°ç 管ä¸æ¾ç¤ºã计ç¨æ°æ®éå ¥æ¾ç¤ºæ¨¡åè¿è¡è¯ç ï¼æåéè³ä»¥km为åä½çæ°ç 管ä¸æ¾ç¤ºã
模åå 件为ï¼
æ¾ç¤ºæ¨¡åæ¡å¾
æºç¨åºå¦ä¸ï¼
library ieee;
use ieee.std_logic_.all;
use ieee.std_logic_unsigned.all; --å®ä¹åºå
entity xianshi is --å®ä¹å®ä½
port(
clk_scan:in std_logic; --æ«ææ¶éä¿¡å·ç«¯å£è®¾ç½®
c3,c2,c1,c0:in std_logic_vector(3 downto 0); --æ»è´¹ç¨è¾å ¥ç«¯å£
k0,k1:in std_logic_vector(3 downto 0); --éç¨è¾å ¥ç«¯å£
m0,m1:in std_logic_vector(3 downto 0); --çå¾ æ¶é´è¾å ¥ç«¯å£
sel:out std_logic_vector(2 downto 0); --æ§å¶æ°ç 管ä½éä¿¡å·çæ«æä¿¡å·è¾åºç«¯å£
led:out std_logic_vector(6 downto 0); --æ°ç 管çæ§å¶ç«¯å£
led_dp:out std_logic --æ°ç 管çå°æ°ç¹è¾åºç«¯å£
);
end xianshi;
architecture rt5 of xianshi is
signal duan:std_logic_vector(6 downto 0); --æ°ç æ¾ç¤ºç®¡ä¸é´åé
signal shuju:std_logic_vector(3 downto 0); --éæ©è¾å ¥ç«¯çä¸é´åé
signal cnt:std_logic_vector(2 downto 0); --æ§å¶æ°ç 管çä¸é´åé
signal xiaodian:std_logic; --å°æ°ç¹çä¸é´åé
begin
process(clk_scan) --å¼å§è¿ç¨
begin
if clk_scan'event and clk_scan='1' then
cnt<=cnt+1; --æ¯æä¸ä¸ªæ«æä¿¡å·ä¸å沿å®ç°å 1æ«æ
end if;
end process; --ç»æè¿ç¨
process(cnt) --å¼å§è¿ç¨(éæ©æ«ææ¾ç¤ºæ°ç 管)
begin
case cnt is --æ«ææ¶ç»æ¯ä¸ªæ°ç 管èµå¼
when ""=>shuju<=c0;
when ""=>shuju<=c1;
when ""=>shuju<=c2;
when ""=>shuju<=c3;
when ""=>shuju<=k0;
when ""=>shuju<=k1;
when ""=>shuju<=m0;
when ""=>shuju<=m1;
when others=> null;
end case;
if (cnt="" or cnt="")
then xiaodian<='1'; --å¨éç¨åæ»è´¹ç¨ç个ä½å¤æ¾ç¤ºå°æ°ç¹
else xiaodian<='0';
end if;
end process; --ç»æè¿ç¨
process(shuju) --å¼å§è¿ç¨(è¯ç æ¾ç¤º)
begin
case shuju is
when ""=>duan<=""; --0
when ""=>duan<=""; --1
when ""=>duan<=""; --2
when ""=>duan<=""; --3
when ""=>duan<=""; --4
when ""=>duan<=""; --5
when ""=>duan<=""; --6
when ""=>duan<=""; --7
when ""=>duan<=""; --8
when ""=>duan<=""; --9
when others=>null;
end case;
end process;
sel<=cnt;
led<=duan;
led_dp<=xiaodian;
end rt5;
äºã课ç¨è®¾è®¡å·¥ä½è®°å½ï¼
å æ¬ï¼è®¾è®¡æ¥éª¤ä¸æ¶é´å®æãè°è¯æ¥éª¤ä¸æ¶é´å®æã课é¢å®æç»æ说æ
2.课é¢å®æç»æ说æï¼
æ¤è®¡è´¹å¨è½å®ç°èµ·æ¥ä»·æ¯5å ï¼å®ç°å®éªè¦æ±ç1å ¬é计费ä¸æ¬¡åä»·ï¼è¡é©¶å ¬é大äº2kmæ¶æ¯å ¬éæ1.4å 计费并è½æ¾ç¤ºéç¨åæ»å ±çè´¹ç¨ãå½è¡é©¶äº6å ¬éï¼çå¾ äº4åéæ¶ï¼è´¹ç¨æ¾ç¤ºä¸º.8å ãä¸è®¡ç®å ¬å¼æ»è´¹ç¨=èµ·æ¥è´¹ç¨+ï¼éç¨-2å ¬éï¼*éç¨åä»·+çåæ¶é´*çååä»·ï¼å³.8=5+ï¼6-2ï¼*1.4+4*1.3ãå®éªç»æä¸ç论ç»æå®å ¨ä¸è´ï¼å®éªè®¾è®¡æåã
vhdl 实现时钟整点报时功能
1、完成秒/分/时的源码依次显示并正确计数;
2、秒/分/时各段个位满正确进位,源码秒/分能做到满向前进位;
3、源码定时闹钟:实现每到整点时报时,源码扬声器发出报时声音;
4、源码Java 队列 源码时间设置,源码也就是源码手动调时功能:当认为时钟不准确时,可以分别对分/时钟进行调整;秒还可以手动调0;
分频模块:
源代码:
library ieee;
use ieee.std_logic_.all;
use ieee.std_logic_unsigned.all;
entity yxfrequencydivider is
port(clk:in std_logic;
hz,源码hz,hz,hz4,hz1:out std_logic);
end yxfrequencydivider ;
architecture hz of yxfrequencydivider is
signal count:std_logic_vector(9 downto 0);
begin
process(clk)
begin
if (clk'event and clk='1') then
if (count="") then
count<="";
else
count<= count+1;
end if;
end if;
end process;
hz <= count(0);
hz <= count(1);
hz <= count(3);
hz4<=count(7);
hz1<=count(9);
end architecture;
模块说明:由于clk的频率为hz,所以可以定义一个std_logic_vecture(9 downto 0),源码使它不停地从加到然后又返回,由于最低位在clk脉冲到来时从0变成1,源码然后又在下一个脉冲变回0,源码因此最低位的源码Asp引擎三端源码时钟周期为clk的时钟周期的两倍,它的源码频率就为clk频率的1/2即HZ。同理,源码次高位的频率就为clk频率的1/2*1/2=1/4,用这种方法就可以得到各种能整除的频率,从而实现分频功能。
进制模块
源程序
library ieee;
use ieee.std_logic_.all;
use ieee.std_logic_unsigned.all;
entity m is
port(cp:in std_logic;
sqmsl,桃江王麻将棋牌源码sqmsh:out std_logic_vector(3 downto 0));
end m;
architecture arh_m of m is
signal stempl,stemph:std_logic_vector(3 downto 0);
begin
process(cp)
begin
if cp='1' then
if stempl="" and stemph="" then
stempl<="";
stemph<="";
else
if stempl=9 then
stempl<="";
stemph<=stemph+1;
else
stempl<=stempl+1;
end if;
end if;
end if;
end process;
sqmsl<=stempl;
sqmsh<=stemph;
end architecture;
本模块端口说明:cp为脉冲输入端;sqmsh和sqmsl分别为小时的高位和低位输出,用来在数码管中分别显示小时的高位和低位数值,定义为std_logic_vector(3 downto 0).
功能实现:在cp高脉冲到时执行以下程序块,如果高位为2,低位为3则高位各低位都变回0,不然再低位进行判断,若为9低位变回0,高位加1,若不为9则低位直接加1即可同样实现.
进制模块
源程序
library ieee;
use ieee.std_logic_.all;
use ieee.std_logic_unsigned.all;
entity m is
port(cp,clr:in std_logic;
co:out std_logic;
sqmsl,sqmsh:out std_logic_vector(3 downto 0));
end m;
architecture arh_m of m is
signal stempl,stemph:std_logic_vector(3 downto 0);
signal stempco:std_logic;
begin
process(cp,clr)
begin
if clr='0' then
stemph<="";
stempl<="";
else
if cp'event and cp='1' then
stempco<='0';
if stempl=9 then
if stemph=5 then
stempco<='1';
stempl<="";
stemph<="";
else
stempl<="";
stemph<=stemph+1;
end if;
else
stempl<=stempl+1;
end if;
end if;
end if;
end process;
co<=stempco;
sqmsl<=stempl;
sqmsh<=stemph;
end architecture;
本模块端口说明:cp为脉冲信号输入端;clr为置0端,并且低电平有效,用来在校时时秒位清零;co为进位输入端;sqmsh和sqmsl分别是秒或分的高位或低位,定义为std_logic_vector(3 downto 0),用来分别在数码管中显示读数.
功能说明:以cp和clr而敏感变量,先判断clr是否为0,若为0则stemph种stempl都为,然后分别赋值给sqmsh和sqmsl;如果不为0,则执行累加;否则,再判断高位是否为5,若为5则进位输出为1、低位和高位都赋予0,若不为5则高位加1,低位赋予0.从而实现了进制的累加.
扫描显示及译码模块
源程序
library ieee;
use ieee.std_logic_.all;
use ieee.std_logic_unsigned.all;
entity dongtaism is
port(clk:in std_logic;
s:in std_logic_vector(7 downto 0);
f:in std_logic_vector(7 downto 0);
m:in std_logic_vector(7 downto 0);
selout:out std_logic_vector(5 downto 0);
segout:out std_logic_vector(6 downto 0));
end dongtaism;
architecture a of dongtaism is
signal temp:std_logic_vector(2 downto 0);
signal seg:std_logic_vector(6 downto 0);
signal sel:std_logic_vector(5 downto 0);
begin
process(clk)
variable num:std_logic_vector(3 downto 0);
begin
if (clk'event and clk='1' ) then
if temp>=5 then
temp<="";
else
temp<=temp+1;
end if;
case temp is
when "" =>num:=s(7 downto 4);
sel<="";
when "" =>num:=s(3 downto 0);
sel<="";
when "" =>num:=f(7 downto 4);
sel<="";
when "" =>num:=f(3 downto 0);
sel<="";
when "" =>num:=m(7 downto 4);
sel<="";
when "" =>num:=m(3 downto 0);
sel<="";
when others=>sel<="";
end case;
case num is
when""=>seg<="";
when""=>seg<="";
when""=>seg<="";
when""=>seg<="";
when""=>seg<="";
when""=>seg<="";
when""=>seg<="";
when""=>seg<="";
when""=>seg<="";
when""=>seg<="";
when others=>seg<="";
end case;
end if;
end process;
selout<=sel;
segout<=seg;
end architecture;
本模块端口说明:stempl、stemph、ftempl 、ftemph、mtempl、视频即时聊天源码mtemph
分别为时,分,秒的输入端,定义为std_logic_vector(7 downto 0);segout为七端显示管的输出,定义为std_logic_vector(6 downto 0);selout为扫描地址端,定义为std_logic_vector(5 downto 0),某一时刻只有一个为1,对应的数组号即为当前扫描的数码管的编号.
功能实现:定义一个std_signal_vector(2 downto 0)变量addr,它在0和5之间不断的循环,用来指示当前扫描的哪一根管,循环用if addr>=5 then addr<=””; else addr<=addr+1;end if;实现.再定义一个类型为std_logic_vector(5 downto 0)的tempaddr信号,它用来产生一个长度为6的数,该数在同一时刻只有一位是高电平表示正在扫描该显示管,在进程结束时它的值将赋给selout输出.定义一个std_logic_vector(6 downto 0)类型的temp_display,用来存放将由4位BCD码编码而来的7段显示码.最后在进程中定义一个std_logic_vector(3 downto 0)类型的tempnum变量,用来存放时、分、秒的高位或低位,然后将该数编码成7段显示码,并赋给temp_display信号。具体算法如下:
建立一个以cp脉冲为敏感变量的Cs源码查询余额代码进程,先判断是否是cp的高电平脉冲,若不是则什么也不执行,若是高电平脉冲,则执行以下程序。Adder加1,用case语句根据adder的值,给tempnum赋予当前要扫描的数码管的值,用case语句根据tempnum的值编译成对应的7段显示管的值并赋给temp_display,当进程结束时把temp_display的值赋给segout,把tempaddr的值赋给selout,然后由这两个端口输出。
整点报时模块:
源程序
library ieee;
use ieee.std_logic_.all;
use ieee.std_logic_unsigned.all;
entity baoshi is
port(m1,m0,s1,s0:in std_logic_vector(3 downto 0);
sig,sig1k:out std_logic);
end baoshi;
architecture behave of baoshi is
begin
process(m0)
begin
sig<='0';
sig1k<='0';
if m1="" and m0="" then
if s1=""and (s0="" or s0="" or s0="" or s0="" or s0="") then
sig<='1';
else
sig<='0';
end if;
end if;
if m1="" and m0=""and s1="" and s0="" then
sig1k<='1';
else
sig1k<='0';
end if;
end process;
end behave;
本模块端口说明:m1,m0,s1,s0分别为分和秒的高低位的输入;sig,sig1k分别为hz和1khz鸣叫的控制信号。
功能实现:定义temp,temp1k信号,用于存放两种频率报时的控制信号;定义一个以m0为敏感信号的一个比较进程,在进程一开始的时候先给temp和temp1k赋予初值0,然后判断分是否为分,若是则判断秒的高位是否是5,若是则如果秒的低位为0、2、6、8则temp为1;若分不是则判断分和秒是否都为0,若都为0则temp1k为1。进程结束时把temp,temp1k的值分别赋给sig,sig1k。
然后连接顶层图
2024-12-28 21:01421人浏览
2024-12-28 20:471496人浏览
2024-12-28 20:121578人浏览
2024-12-28 19:471992人浏览
2024-12-28 19:232717人浏览
2024-12-28 18:46485人浏览
陷入家族詐騙風暴的國民黨立委徐巧芯,今2)天在立法院遇上國民黨總召傅崐萁,兩人互動有來有往,而傅崐萁還牽起徐巧芯的手打氣表示,越被民進黨攻擊的人,就是民進黨越怕的人。傅崐萁今天遇上徐巧芯時,先是對她說
1.php??ʾ??ҳԴ??2.浏览器打开php文件时候直接出现源代码 editplus正常3.php获得网页源代码抓取网页内容的几种方法?php??ʾ??ҳԴ?? 如果出现输出php的源码,那说
1.VB 修改一个股票行情监测脚本 到了预定的股价就启动程序a.exe2.å®ä¹ä¸ä¸ªè¡ç¥¨ç±»Stock3.求个高手把通达信指标改成选股公式红柱4.两个ç¹è¿çº¿