网站公告列表

  没有公告

加入收藏
设为首页
联系站长
您现在的位置: 61EDA中国电子网 >> 服务导航 >> 培训教程 >> HDL语言 >> 正文
  七段数码管.(Verilog)           ★★★ 【字体:
七段数码管.(Verilog)
作者:Free    文章来源:Free    点击数:    更新时间:2008-7-27    

1. 七段数码管的lookup table
module SEG7_LUT (
  input [3:0] iDIG,
  output reg [6:0] oSEG
);

always@(iDIG)
begin
  case(iDIG)
    4'h1: oSEG = 7'b1111001;  // ---t----
    4'h2: oSEG = 7'b0100100;  // |      |
    4'h3: oSEG = 7'b0110000;  // lt     rt
    4'h4: oSEG = 7'b0011001;  // |      |
    4'h5: oSEG = 7'b0010010;  // ---m----
    4'h6: oSEG = 7'b0000010;  // |      |
    4'h7: oSEG = 7'b1111000;  // lb     rb
    4'h8: oSEG = 7'b0000000;  // |      |
    4'h9: oSEG = 7'b0011000;  // ---b----
    4'ha: oSEG = 7'b0001000;
    4'hb: oSEG = 7'b0000011; 
    4'hc: oSEG = 7'b1000110; 
    4'hd: oSEG = 7'b0100001; 
    4'he: oSEG = 7'b0000110; 
    4'hf: oSEG = 7'b0001110; 
    4'h0: oSEG = 7'b1000000; 
  endcase                    
end                          
                             
endmodule

1) 注释说明的是七段数码管的结构,其中:
   t=top
   b=bottom
   m="middle"
   l="left"
   r="right"
   若表示为下面的格式,则有可能更好理解。
   ---0----
   |      |
   5      1
   |      |
   ---6----
   |      |
   4      2
   |      |
   ---3----

2) 关于Verilog HDL entity,可在定义module时,先指定端口;然后,再声明端口的类型。如:
   module example (oC, iA, iB);
     output  oC;
     input   iA, iB;
   当然,也可以直接在定义module时,指定端口及声明其类型。如:
   module example (
     output  oC,
     input   iA,
     input   iB
   );

2. 实例化(调用)
   SEG_LUT7 name (
     .iDIG(porta[msb:lsb]);
     .oSEG(portb)
   );

  supply0 Gnd; // 定义地

 

  pmos (out, Vdd, in);

  nmos (out, Gnd, in);

endmodule

文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章: 没有了
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
    没有相关文章
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    湘ICP备08001332号 站长:61EDA