daily pastebin goal
16%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //7 binary_7_bits_BCD
  2. module binary_7_bits_BCD ( // display decimal value of 7-digit binary input
  3.     input [6:0] SW,
  4.     output [6:0] LEDR,
  5.     output [0:6] HEX0, HEX1, HEX2);
  6.    
  7.     assign LEDR[6:0] = SW[6:0];
  8.     wire [0:6] sw1 = SW[6:0];  // max 128
  9.     reg hundreds = 0;
  10.     reg tens = 0;
  11.     reg n1 = 0;
  12.    
  13.     showDigitDec ex1(n1, HEX0);
  14.     showDigitDec ex2(tens, HEX1);
  15.     showDigitDec ex3(hundreds, HEX2);
  16.    
  17.     always @*
  18.         begin
  19.            
  20.             if(sw1 >= 100) hundreds = 1;
  21.             else hundreds = 0;
  22.            
  23.             if (sw1 >= 90 + hundreds * 100) tens = 9;
  24.             else (sw1 >= 80 + hundreds * 100) tens = 8;
  25.             else (sw1 >= 70 + hundreds * 100) tens = 7;
  26.             else (sw1 >= 60 + hundreds * 100) tens = 6;
  27.             else (sw1 >= 50 + hundreds * 100) tens = 5;
  28.             else (sw1 >= 40 + hundreds * 100) tens = 4;
  29.             else (sw1 >= 30 + hundreds * 100) tens = 3;
  30.             else (sw1 >= 20 + hundreds * 100) tens = 2;
  31.             else (sw1 >= 10 + hundreds * 100) tens = 1;
  32.             else tens = 0;
  33.        
  34.             n1 = sw1 - tens * 10 - hundreds * 100;
  35.            
  36.         end
  37.        
  38. endmodule
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top