qh[3..0]、ql[3..0]分别输出高位和低位的BCD码。
subdesign bcd_m60
(
clk, cr, en : input;
qh[3..0], ql[3..0], c0 : output;
)
variable
counth[3..0], countl[3..0]: dff;
begin
counth[].clk = clk;
countl[].clk = clk;
counth[].clrn = cr;
countl[].clrn = cr;
qh[] = counth[];
ql[] = countl[];
if en then
if countl[] < 9 then
countl[] = countl[] + 1;
counth[] = counth[];
c0 = gnd;
elsif counth[] < 5 then
counth[] = counth[] + 1;
countl[] = 0;
c0 = gnd;
else
counth[] = 0;
countl[] = 0;
c0 = vcc;
end if;
else
counth[] = counth[];
countl[] = countl[];
end if;
end;
评论