Advertisement
robtee

lab4

May 9th, 2019
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module counter (
  2. input clk,
  3. input rst,
  4. input drc,
  5. input [2:0] num,
  6. output [2:0] count
  7. //output wire [7:0] out
  8. );
  9. //reg [6:0] count;
  10.  
  11. always @ (posedge clk) begin
  12.   if (rst)
  13.     if (drc)
  14.        assign count = 3'b000; //rst high, count down
  15.     else
  16.        assign count = count;       //rst high, count up          
  17.   else
  18.     if (drc)
  19.        assign count = count + 1;   //
  20.     else
  21.        assign count = count - 1;
  22. end
  23.  
  24. endmodule
  25.  
  26. module seven_seg_decoder (
  27. input [2:0] num,
  28. output [6:0] count
  29. );
  30.  
  31. always @(*)
  32.     begin
  33.         case(num)
  34.         3'b000: assign count = 7'b1111110; // "0"    
  35.         3'b001: assign count = 7'b0110000; // "1"
  36.         3'b010: assign count = 7'b1101101; // "2"
  37.         3'b011: assign count = 7'b1111001; // "3"
  38.         3'b100: assign count = 7'b0110011; // "4"
  39.         3'b101: assign count = 7'b1011011; // "5"
  40.         3'b110: assign count = 7'b1011111; // "6"
  41.         3'b111: assign count = 7'b1110000; // "7"
  42.         default: assign count = 7'b0000000;
  43.  
  44.         endcase
  45. end
  46. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement