Advertisement
Sb93

Lab3 7segment

Oct 17th, 2024
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. `timescale 1ns / 1ps
  2. //////////////////////////////////////////////////////////////////////////////////
  3. // Company:
  4. // Engineer:
  5. //
  6. // Create Date: 25.02.2020 15:48:02
  7. // Design Name:
  8. // Module Name: vsevenseg
  9. // Project Name: Lab3
  10. // Target Devices:
  11. // Tool Versions:
  12. // Description:
  13. //
  14. // Dependencies:
  15. //
  16. // Revision:
  17. // Revision 0.01 - File Created
  18. // Additional Comments:
  19. //
  20. //////////////////////////////////////////////////////////////////////////////////
  21.  
  22.  
  23. // Experiment 3
  24. // 7 segment display with SOP logic expressions
  25. //
  26.  
  27.  
  28. module vsevenseg(
  29.     input [3:0] x,         // 4 rightmost switches
  30.     output [6:0] seg_L,    // active low segment display
  31.     output [3:0] anode_L   // active low digit display
  32.     );
  33.  
  34. // declare internal active high segments
  35. wire [6:0] seg;             // 1:on, 0:off
  36.  
  37. // turn on only the two rightmost digits - active low
  38. assign anode_L = 4'b1100;  
  39.  
  40. // pull cathode low to light up segment - active low
  41. assign seg_L = ~seg;
  42.  
  43. // x format {msb, ., ., lsb}
  44. // seg[6:0] format {g, f, e, d, c, b, a} - active high
  45. // segment a, b, e, g expressions are given
  46.   // segment a= x3'x2x0 + x2x1 + x3'x1 + x3x0' + x3x2'x1' + x2'x0'
  47.    assign seg[0] = ~x[3]&x[2]&x[0]|x[2]&x[1]|~x[3]&x[1]|x[3]&~x[0]|x[3]&~x[2]&~x[1]|~x[2]&~x[0];
  48.   // segment b= x3'x2' + x2'x0' + x3'x1'x0' + x3'x1x0 + x3x1'x0
  49.    assign seg[1] = ~x[3]&~x[2]|~x[2]&~x[0]|~x[3]&~x[1]&~x[0]|~x[3]&x[1]&x[0]|x[3]&~x[1]&x[0];
  50.   // segment e= x3x2 + x3x1 + x2'x0' + x1x0'
  51.    assign seg[4] = x[3]&x[2]|x[3]&x[1]|~x[2]&~x[0]|x[1]&~x[0];
  52.   // segment g= x1x0' + x3x2' + x3x0 + x2'x1 + x3'x2x1'
  53.    assign seg[6] = x[1]&~x[0]|x[3]&~x[2]|x[3]&x[0]|~x[2]&x[1]|~x[3]&x[2]&~x[1];
  54.    
  55. ////////////////////////////////////////////
  56. // students to fill in these 3 expressions
  57. // remember to end each statement with a semicolon ";"
  58.   // segment c
  59.    assign seg[2] = ~x[3]&~x[1]|~x[3]&x[0]|~x[1]&x[0]|~x[3]&x[2]|x[3]&~x[2];
  60.  
  61.   // segment d
  62.    assign seg[3] = x[3]&~x[1]|~x[3]&~x[2]&~x[0]|~x[2]&x[1]&x[0]|x[2]&~x[1]&x[0]|x[2]&x[1]&~x[0];
  63.  
  64.   // segment f
  65.    assign seg[5] = ~x[1]&~x[0]|x[2]&~x[0]|x[3]&~x[2]|x[3]&x[1]|~x[3]&x[2]&~x[1];
  66.  
  67.  
  68. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement