Advertisement
Guest User

Untitled

a guest
Mar 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. module Sys (KEY, LEDR, SW, HEX1,HEX2,HEX3,HEX0 );
  2. input[0:2] KEY;
  3. input [9:0] SW ;
  4. output [9:0] LEDR;
  5. output[6:0] HEX0;
  6. output[6:0] HEX1;
  7. output[6:0] HEX2;
  8. output[6:0] HEX3;
  9.  
  10. reg [9:0]out;
  11. reg [6:0]o;
  12.  
  13. assign LEDR = out;
  14. assign HEX3 = o;
  15.  
  16.  
  17. always
  18. begin
  19.  
  20. if (KEY[0] == 0)
  21. begin
  22. out <= SW[9:5] + SW[4:0];
  23. o <= 7'b1111111;
  24. end
  25. else if (KEY[1]== 0 && SW[9:5] > SW[4:0])
  26. begin
  27. out <= SW[9:5] - SW[4:0];
  28. o <= 7'b1111111;
  29. end
  30. else if (KEY[1]== 0 && SW[9:5] < SW[4:0])
  31. begin
  32. out <= SW[4:0] - SW[9:5];
  33. o <= 7'b0111111;
  34. end
  35. else if (KEY[2] == 0)
  36. begin
  37. out <= SW[9:5] * SW[4:0];
  38. o <= 7'b1111111;
  39. end
  40. end
  41.  
  42. zamiana ((LEDR / 10) % 10, HEX1);
  43. zamiana ((LEDR /100) % 10, HEX2);
  44. zamiana (LEDR % 10, HEX0);
  45. endmodule
  46.  
  47. module zamiana (in,ou);
  48. input [3:0] in;
  49. output reg [6:0] ou;
  50.  
  51. always
  52. begin
  53. if (in == 4'd0)
  54. ou = 7'b1000000;
  55. else if (in == 4'd1)
  56. ou = 7'b1111001;
  57. else if (in == 4'd2)
  58. ou = 7'b0100100;
  59. else if (in == 4'd3)
  60. ou = 7'b0110000;
  61. else if (in == 4'd4)
  62. ou = 7'b0011001;
  63. else if (in == 4'd5)
  64. ou = 7'b0010010;
  65. else if (in == 4'd6)
  66. ou = 7'b0000010;
  67. else if (in == 4'd7)
  68. ou = 7'b1111000;
  69. else if (in == 4'd8)
  70. ou = 7'b0000000;
  71. else if (in == 4'd9)
  72. ou = 7'b0010000;
  73. end
  74. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement