矿大CUMT----电路与数字系统实验四 计数、译码、显示的HDL设计

本文详细描述了四个Verilog设计子模块:两个用于不同频率计数的模块(1Hz和1kHz),以及两个状态机子模块(YMSM和YMH),它们处理数据编码和输出控制。每个模块涉及计数器、同步分频器和状态转换逻辑。
摘要由CSDN通过智能技术生成

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;
end;

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值