Trung tâm đào tạo thiết kế vi mạch Semicon


  • ĐĂNG KÝ TÀI KHOẢN ĐỂ TRUY CẬP NHIỀU TÀI LIỆU HƠN!
  • Create an account
    *
    *
    *
    *
    *
    Fields marked with an asterisk (*) are required.
semicon_lab.jpg

Verilog Code for Binary to 7-segment LED converter - Bộ chuyển đổi số nhị phân sang LED 7 đoạn bằng Verilog

E-mail Print PDF

Binary to 7-segment LED display is very easy , it is more like the decoding logic.

Below is the rtl code in Verilog for the same.

7 -Segment Display ->

 


Binary            7-segment

                       
0000                 a b c d e f g  =>   1 1 1 1 1 1 0
0001                 a b c d e f g  =>   0 1 1 0 0 0 0
0010                 a b c d e f g  =>   1 1 0 1 1 0 1
0011                 a b c d e f g  =>   1 1 1 1 0 0 1
0100                 a b c d e f g  =>   0 1 1 0 0 1 1
0101                 a b c d e f g  =>   1 0 1 1 0 1 1
0110                 a b c d e f g  =>   1 0 1 1 1 1 1
0111                 a b c d e f g  =>   1 1 1 0 0 0 0
1000                 a b c d e f g  =>   1 1 1 1 1 1 1
1001                 a b c d e f g  =>   1 1 1 1 0 1 1


Below is the RTL code for the 7-segment LED Display.

// ---- RTL Code
module led_7_segment_dis (

input [3:0] bin_data,
output reg [6:0] led_7seg

);


always @(*) begin
  led_7seg = 7'b0;
  case(bin_data)    //  abcdefg
   4'h0:  led_7seg = 7'b1111110;
   4'h1:  led_7seg = 7'b0110000;
   4'h2:  led_7seg = 7'b1101101;
   4'h3:  led_7seg = 7'b1111001;
   4'h4:  led_7seg = 7'b0110011;
   4'h5:  led_7seg = 7'b1011011;
   4'h6:  led_7seg = 7'b1011111;
   4'h7:  led_7seg = 7'b1110000;
   4'h8:  led_7seg = 7'b1111111;
   4'h9:  led_7seg = 7'b1111011;
   default : led_7seg = 7'b0;
  endcase
end

always @(*) begin
   $display("Binary number = %d", bin_data);
end

always @(*) begin
  #1;
  if(led_7seg[6])
    $display("       ------");
  if(led_7seg[5] && led_7seg[1]) begin
    $display("       |    |");
    $display("       |    |");
  end
  else if(led_7seg[5]) begin
    $display("            |");
    $display("            |");
  end
  else if(led_7seg[1]) begin
    $display("       |     ");
    $display("       |     ");
  end
  if(led_7seg[0])
    $display("       ------");
  if(led_7seg[4] && led_7seg[2]) begin
    $display("       |    |");
    $display("       |    |");
  end
  else if(led_7seg[4]) begin
    $display("            |");
    $display("            |");
  end
  else if(led_7seg[2]) begin
    $display("       |     ");
    $display("       |     ");
  end
  if(led_7seg[3])
    $display("       ------");
 
end

endmodule

Bạn Có Đam Mê Với Vi Mạch hay Nhúng      -     Bạn Muốn Trau Dồi Thêm Kĩ Năng

Mong Muốn Có Thêm Cơ Hội Trong Công Việc

Và Trở Thành Một Người Có Giá Trị Hơn

Bạn Chưa Biết Phương Thức Nào Nhanh Chóng Để Đạt Được Chúng

Hãy Để Chúng Tôi Hỗ Trợ Cho Bạn. SEMICON  

 

Last Updated ( Thursday, 13 May 2021 14:13 )  

Related Articles

Chat Zalo