subdesign fp
(inclk:input;f1,f1k:output)
variable
tcount[24..0],tf1:dff; tscancount[14..0],tscanf1:dff;
begin
------1Hz------
(tcount[],tf1).clk=inclk;
if tcount[]==19999999 then
tcount[]=0;tf1=!tf1;
else
tcount[]=tcount[]+1;tf1=tf1;
end if;
-----1kHz----
(tscancount[],tscanf1).clk=inclk;
if tscancount[]==19999 then
tscancount[]=0;tscanf1=!tscanf1;
else
tscancount[]=tscancount[]+1;tscanf1=tscanf1;
end if;
----waibu-----
f1k=tf1;f1=tscanf1;
end;
subdesign count60
(inclk:input;oh[3..0],ol[3..0],co:output)
variable
tcounth[3..0],tcountl[3..0]:dff;
begin
(tcounth[3..0],tcountl[3..0]).clk=inclk;
if tcounth[]==5 and tcountl[]==9 then
tcounth[]=0;tcountl[]=0;co=Gnd;
elseif tcountl[]==9 then
tcounth[]=tcounth[]+1;tcountl[]=0;co=Vcc;
else
tcounth[]=tcounth[];tcountl[]=tcountl[]+1;co=Vcc;
end if;
oh[]=tcounth[];ol[]=tcountl[];
end;
subdesign count12
(inclk:input;oh[3..0],ol[3..0]:output)
variable
tcounth[3..0],tcountl[3..0]:dff;
begin
(tcounth[3..0],tcountl[3..0]).clk=inclk;
if tcounth[]==1 and tcountl[]==2 then
tcounth[]=0;tcountl[]=1;
elseif tcountl[]==9 then
tcounth[]=tcounth[]+1;tcountl[]=0;
else
tcounth[]=tcounth[];tcountl[]=tcountl[]+1;
end if;
oh[]=tcounth[];ol[]=tcountl[];
end;
subdesign YMSM
(inclk,SH[3..0],SL[3..0],MH[3..0],ML[3..0]:input;
data[6..0],vbit[3..0]:output)
variable
st[1..0],tseg[3..0]:dff;
begin
(st[],tseg[]).clk=inclk;
case st[] is
when 0=>tseg[]=MH[];vbit[]=b"0111";st[]=1;
when 1=>tseg[]=ML[];vbit[]=b"1011";st[]=2;
when 2=>tseg[]=SH[];vbit[]=b"1101";st[]=3;
when 3=>tseg[]=SL[];vbit[]=b"1110";st[]=0;
end case;
table
tseg[3..0]=>data[6..0];
0=>b"1111110";
1=>b"0110000";
2=>b"1101101";
3=>b"1111001";
4=>b"0110011";
5=>b"1011011";
6=>b"1011111";
7=>b"1110000";
8=>b"1111111";
9=>b"1111011";
end table;
end;
subdesign YMH
(inclk,HH[3..0],HL[3..0]:input;
data[6..0],vbit[1..0]:output)
variable
st[1..0],tseg[3..0]:dff;
begin
(st[],tseg[]).clk=inclk;
case st[] is
when 0=>tseg[]=HH[];vbit[]=b"01";st[]=1;
when 1=>tseg[]=HL[];vbit[]=b"10";st[]=0;
end case;
table
tseg[3..0]=>data[6..0];
0=>b"1111110";
1=>b"0110000";
2=>b"1101101";
3=>b"1111001";
4=>b"0110011";
5=>b"1011011";
6=>b"1011111";
7=>b"1110000";
8=>b"1111111";
9=>b"1111011";
end table;