LIBRARY IEEE;
USE IEEE.Std_logic_1164.ALL;
USE IEEE.Std_logic_unsigned.All;
USE IEEE.Std_logic_arith.All;
ENTITY Dccount IS
Port (
Clk : IN STD_LOGIC;
AI : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
CO : Out STD_LOGIC_VECTOR(3 DOWNTO 0);
Pulse: IN STD_LOGIC;
DriverA, DriverB: OUT STD_LOGIC;
S : OUT STD_LOGIC_VECTOR(6 DOWNTO 0);
P : OUT STD_LOGIC_VECTOR(5 DOWNTO 0);
Sp : Out STD_LOGIC);
END Dccount;
ARCHITECTURE A OF Dccount IS
SIGNAL F: STD_LOGIC_VECTOR(5 Downto 0);
SIGNAL F_hz: STD_LOGIC;
SIGNAL OSC: STD_LOGIC;
SIGNAL OSC1: STD_LOGIC;
SIGNAL C: STD_LOGIC_VECTOR(3 DOWNTO 0);
SIGNAL A: STD_LOGIC_VECTOR(3 DOWNTO 0);
SIGNAL CODE: STD_LOGIC_VECTOR(2 DOWNTO 0);
SIGNAL Bcd: STD_LOGIC_VECTOR (23 Downto 0);
SIGNAL COUNT:STD_LOGIC_VECTOR(23 Downto 0);
SIGNAL SUM: STD_LOGIC_VECTOR(4 DOWNTO 0);
SIGNAL D: STD_LOGIC_VECTOR(3 DOWNTO 0):=“0000â€;
SIGNAL Ind_coil: STD_LOGIC_VECTOR(3 Downto 0) := "0001";
SIGNAL Hz: STD_LOGIC;
SIGNAL Spo: STD_LOGIC;
SIGNAL SW:STD_LOGIC;
SIGNAL KEY:STD_LOGIC;
SIGNAL DRA,DRB:STD_LOGIC;
BEGIN
DRIVERA "=DRA;
DRIVERB "=DRB;
P(5 Downto 0) = F(5 Downto 0);
CO(3 DOWNTO 0) =C(3 DOWNTO 0);
A (3 DOWNTO 0) "=AI(3 DOWNTO 0);
SP "=SPO;
-----------------Div------------------------
PROCESS (OSC)
VARIABLE D_ff: STD_LOGIC_VECTOR (20 Downto 0);
VARIABLE DELAY: STD_LOGIC_VECTOR(23 DOWNTO 0);
BEGIN
WAIT UNTIL Clk = ''1'';
IF D_ff(20 Downto 0) 》= 2E6 THEN
D_ff (20 Downto 0) := "000000000000000000000";
ELSE
D_ff (20 Downto 0) := D_ff + 1;
END IF;
F_hz "= Not D_ff (6);
OSC = Not D_ff(10);
OSC1 == Not D_ff(17);
IF DELAY="500000 THEN
DELAY:="000000000000000000000000"; HZ "=NOT Hz;
ELSE DELAY:=DELAY+1;
END IF;
END PROCESS ;
----------------------------------------------
PROCESS (F_HZ,OSC,OSC1,HZ,PULSE)
VARIABLE B: STD_LOGIC;
VARIABLE INT: STD_LOGIC;
VARIABLE Data: STD_LOGIC_VECTOR(3 DOWNTO 0);
VARIABLE UP: STD_LOGIC_VECTOR(2 DOWNTO 0);
VARIABLE ST: STD_LOGIC_VECTOR(2 DOWNTO 0);
VARIABLE Seq: STD_LOGIC_VECTOR(1 DOWNTO 0);
VARIABLE Sound: STD_LOGIC_VECTOR(1 DOWNTO 0);
VARIABLE STOP: STD_LOGIC;
VARIABLE DirecTIon: STD_LOGIC;
BEGIN
---------------7seg Scan-------------------------------
IF (F_HZ=''1'' AND F_HZ''EVENT) THEN
IF ST (2 DOWNTO 0) = "101" THEN
ST (2 DOWNTO 0): = "000";
ELSE ST(2 DOWNTO 0):=ST(2 DOWNTO 0)+1;
END IF;
END IF;
-----------------------------------------------
IF (OSC = ''1'' And OSC''EVENT) THEN
If A="1111" Then
IF Seq=“11†Then Seq:=“00†;
Else Seq:=Seq+1;
End If;
Else Seq:=Seq;
End If;
IF Seq="00" Then C(3 DOWNTO 0)="="1110" ;
Elsif Seq="01" Then C(3 DOWNTO 0)="="1101";
Elsif Seq = "10" Then C (3 DOWNTO 0) = "1011";
Elsif Seq="11" Then C(3 DOWNTO 0)="="0111";
End If;
End If;
IF A="1111" THEN INT:=''0'';
ELSE INT:=''1'';
END IF;
IF (HZ''EVENT AND HZ=''1'') THEN
IF STOP=''1'' THEN UP:=UP+1;
ELSE UP:="000";
END IF;
END IF;
IF KEY=''1'' AND COUNT/=0 THEN
IF DIRECTION=''0'' THEN DRA "=''1'';DRB "=''0'';STOP:=''0'';
ELSE DRA "=''0'';DRB "=''1'';STOP:=''0'';
END IF;
ELSIF KEY=''1'' AND COUNT=0 THEN STOP:=''1'';
ELSIF STOP=''1'' AND UP "110" THEN DRA "=NOT DRA; DRB"=NOT DRB;
ELSE DRA "=''0'';DRB "=''0'';STOP:=''0'';
END IF;
IF (OSC1''EVENT AND OSC1=''1'') THEN B:=(INT And (B And INT) );
----------------Direction Choice-----------------------
IF SW=''0'' AND B=''1'' AND Data(3 DOWNTO 0)="1010" THEN
BCD(23 DOWNTO 0)==BCD(23 DOWNTO 0); B:=''0''; Direction:=''1'';
ELSIF SW=''0'' AND B=''1'' AND Data(3 DOWNTO 0)="1011" THEN
BCD (23 DOWNTO 0) "=BCD (23 DOWNTO 0); B:=''0''; Direction:=''0'';
------------------KEY LOCK ON/OFF--------------------------- ---------
ELSIF B=''1'' AND Data(3 DOWNTO 0)="1100" THEN
BCD "=BCD; B:=''0''; SW "=NOT SW;
-------------------BACK------------------------------ -
ELSIF SW=''0'' AND B=''1'' AND Data(3 DOWNTO 0)="1101" THEN
BCD (23 DOWNTO 0) "=("0000" & Bcd(23 Downto 4) ); B:=''0'';
-------------------CLEAR------------------------------ ---
ELSIF B=''1'' AND Data(3 DOWNTO 0)="1110" THEN
BCD "="000000000000000000000000" ;B:=''0'';SW "=''0'';
------------------DOWNCOUNT 0 ------------------------------ ------
ELSIF BCD=0 AND KEY=''1'' THEN SW "=''0''; KEY "=''0''; BCD "= BCD;
-------------------------------------------------- ----------------
ELSIF SW=''1'' AND KEY=''1'' AND DATA(3 DOWNTO 0)/="1110" THEN BCD "=COUNT;
ELSIF SW=''1'' AND DATA(3 DOWNTO 0)="1110" THEN SW "=''0'';
BCD "="000000000000000000000000"; KEY "=''0'';
-------------------ENTER------------------------------
ELSIF SW=''0'' AND B=''1'' AND Data(3 DOWNTO 0)="1111" AND BCD/=0 THEN
B:=''0'';SW "=''1'';KEY"=''1'';
ELSIF SW=''0'' AND B=''1'' AND Data(3 DOWNTO 0)="1111" AND BCD=0 THEN
BCD "=BCD;B:=''0'';SW "=''0'';KEY"=''0'';
----------------------NUMBER SHIFT-------------------------- -
ELSIF SW=''0'' AND B=''1'' THEN Bcd(23 Downto 0)== Bcd(19 Downto 0) & DATA(3 DOWNTO 0); B:=''0'';
Elsif INT=''0'' Then Bcd "=Bcd;
B:=''1'';
END IF;
END IF;
-------------------------------------------------- ----
SUM(1 DOWNTO 0)== Seq;
Sum (4 Downto 2) "= Code;
---------------------SOUND---------------------------- -
If (Osc''Event And Osc=''1'') Then
If INT=''1'' AND SW=''0'' Then Sound:=Sound+1;Spo "=Sound(1) ;
Else Spo "=''0'';
End If;
End If;
-------------------------------------------------- -----
---------------------------DOWNCOUNT--------------------
IF SW=''0'' THEN COUNT "= BCD;
ELSE
If (PULSE = ''1'' And PULSE''EVENT) THEN
IF KEY=''1'' AND COUNT/=0 THEN
----------------------------1--------------------- ------------------------------
IF COUNT(3 DOWNTO 0) = 0 AND COUNT(23 DOWNTO 4)》=1 THEN
COUNT(3 DOWNTO 0) = "1001";
ELSE COUNT(3 DOWNTO 0) == COUNT(3 DOWNTO 0)-1;
END IF;
----------------------------2--------------------- ------------------------------------
IF COUNT(7 DOWNTO 4) = 0 AND COUNT(23 DOWNTO 8)"=1 AND COUNT(3 DOWNTO 0)=0 THEN
COUNT(7 DOWNTO 4) = "1001";
ELSIF COUNT(3 DOWNTO 0)=0 AND COUNT(23 DOWNTO 4)》=1 THEN
COUNT(7 DOWNTO 4) =COUNT(7 DOWNTO 4 )-1;
END IF;
----------------------------3--------------------- ----------------------------------
IF COUNT(11 DOWNTO 8) = 0 AND COUNT(23 DOWNTO 12)"=1 AND COUNT(7 DOWNTO 0)=0 THEN
COUNT(11 DOWNTO 8) = "1001";
ELSIF COUNT(7 DOWNTO 0)=0 AND COUNT(23 DOWNTO 8)》=1 THEN
COUNT(11 DOWNTO 8) =COUNT(11 DOWNTO 8 )-1;
END IF;
---------------------------4---------------------- ----------------------------------------
IF COUNT(15 DOWNTO 12) = 0 AND COUNT(23 DOWNTO 16)"=1 AND COUNT(11 DOWNTO 0)=0 THEN
COUNT(15 DOWNTO 12) = "1001";
ELSIF COUNT(11 DOWNTO 8)=0 AND COUNT(23 DOWNTO 12)"=1 AND COUNT(7 DOWNTO 0)=0 THEN
COUNT(15 DOWNTO 12) =COUNT(15 DOWNTO 12 )-1;
END IF;
-------------------------5------------------------ ------------------------------------
IF COUNT(19 DOWNTO 16) = 0 AND COUNT(23 DOWNTO 20)"=1 AND COUNT(15 DOWNTO 0)=0 THEN
COUNT(19 DOWNTO 16) = "1001";
ELSIF COUNT(15 DOWNTO 12)=0 AND COUNT(23 DOWNTO 16)"=1 AND COUNT(11 DOWNTO 0)=0 THEN
COUNT(19 DOWNTO 16) =COUNT(19 DOWNTO 16 )-1;
END IF;
-------------------------6------------------------ -------------------------
IF COUNT(23 DOWNTO 20) = 0 THEN
COUNT(23 DOWNTO 20) ="="0000;
ELSIF COUNT(19 DOWNTO 16)=0 AND COUNT(23 DOWNTO 20 )"=1 AND COUNT(15 DOWNTO 0)=0 THEN
COUNT(23 DOWNTO 20) =COUNT(23 DOWNTO 20 )-1;
END IF;
END IF;
END IF;
END IF;
------------------7seg Scan---------------------------
CASE ST IS --? @tide
WHEN "000" = "D (3 DOWNTO 0) "= Bcd (3 DOWNTO 0) ; F (5 Downto 0) "=" 111110";
WHEN "001" = "D (3 DOWNTO 0) "= Bcd (7 DOWNTO 4) ; F (5 Downto 0) "= "111101";
WHEN "010" = "D (3 DOWNTO 0) "= Bcd (11 DOWNTO 8) ; F (5 Downto 0) "=" 111011";
WHEN "011" = "D (3 DOWNTO 0) "= Bcd (15 DOWNTO 12); F (5 Downto 0) "= "110111";
WHEN "100" = "D (3 DOWNTO 0) = "Bcd (19 DOWNTO 16); F (5 Downto 0) "= "101111";
WHEN "101" = "D (3 DOWNTO 0) "= Bcd (23 DOWNTO 20); F (5 Downto 0) "= "011111";
WHEN OTHERS = "D (3 DOWNTO 0) "="1100" ; F (5 Downto 0) "=" 111111";
END CASE;
------------------Key Scan-------------------------
CASE A(3 DOWNTO 0) IS
WHEN "1110" = "CODE" = "100";
WHEN "1101" = "CODE" = "101";
WHEN "1011" = "CODE" = "110";
WHEN "0111" = "CODE" = "111";
WHEN OTHERS =" CODE "= "000";
End Case;
---------------------Key Table------------------------
CASE SUM(4 DOWNTO 0) IS
WHEN "10000" = " Data: = "0001"; --0
WHEN "10001" = " Data: = "0101"; --1
WHEN "10010" = " Data: = "1001"; -2
WHEN "10011" = " Data: = "1100"; -3
Liquid Crystal Display For Medical Use
Liquid Crystal Display For Medical Use,Super Liquid Crystal Instrument Medical Display,Medical Liquid Crystal Instrument Lcd Display,Thin Transparent Lcd Medical Display
Dongguan Yijia Optoelectronics Co., Ltd. , https://www.everbestlcdlcm.com