Advertisement
Guest User

Untitled

a guest
Apr 30th, 2011
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. `timescale 1ns / 1ps
  2.  
  3. module hex_to_sseg(
  4.     input wire [3:0] hex,    
  5.     output wire [7:0] sseg
  6.     );
  7.  
  8.     always @ *
  9.     begin
  10.         case(hex)
  11.             4'h0: sseg [6:0] = 7'b0000001;
  12.             4'h1: sseg [6:0] = 7'b1001111;
  13.             4'h2: sseg [6:0] = 7'b0010010;
  14.             4'h3: sseg [6:0] = 7'b0000110;
  15.             4'h4: sseg [6:0] = 7'b1001100;
  16.             4'h5: sseg [6:0] = 7'b0100100;
  17.             4'h6: sseg [6:0] = 7'b0100000;
  18.             4'h7: sseg [6:0] = 7'b0001111;
  19.             4'h8: sseg [6:0] = 7'b0000000;
  20.             4'h9: sseg [6:0] = 7'b0000100;
  21.             4'ha: sseg [6:0] = 7'b0001000;
  22.             4'hb: sseg [6:0] = 7'b1100000;
  23.             4'hc: sseg [6:0] = 7'b0110001;
  24.             4'hd: sseg [6:0] = 7'b1000010;
  25.             4'he: sseg [6:0] = 7'b0110000;
  26.         default: sseg [6:0] = 7'b0111000; //4 'hf
  27.     endcase    
  28.      end
  29. endmodule
  30.  
  31. module test2(
  32.     input wire [3:0] sw,
  33.     output wire [3:0] an,
  34.     output wire [7:0] seg
  35.     );
  36.      
  37.     assign an = 4'b0000;
  38.      
  39.     hex_to_sseg sseg_unit_0(.hex(sw[3:0]), .sseg(seg));
  40.  
  41. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement