Advertisement
Krystian102

Untitled

Apr 1st, 2020
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module counter_T_4_bits(
  2.     input [0:1] SW,
  3.     input [0:0] KEY,
  4.     output [0:6] HEX0);
  5.    
  6.     wire [3:0] counterOut;
  7.    
  8.     inner_counter_T_4_bits ex0(KEY[0],SW[0],SW[1],counterOut);
  9.     decoder_hex_16 ex1(counterOut,HEX0);
  10.    
  11. endmodule
  12.  
  13. module decoder_hex_16(
  14.     input [3:0] x,
  15.     output reg [0:6] h);
  16.    
  17.     always@(*)
  18.         case(x)
  19.             4'b0000: h=7'b0000001;
  20.             4'b0001: h=7'b1001111;
  21.             4'b0010: h=7'b0010010;
  22.             4'b0011: h=7'b0000110;
  23.             4'b0100: h=7'b1001100;
  24.             4'b0101: h=7'b0100100;
  25.             4'b0110: h=7'b0100000;
  26.             4'b0111: h=7'b0001111;
  27.             4'b1000: h=7'b0000000;
  28.             4'b1001: h=7'b0000100;
  29.             4'b1010: h=~7'b1110111; //A
  30.             4'b1011: h=~7'b0011111; //B
  31.             4'b1100: h=~7'b1001110; //C
  32.             4'b1101: h=~7'b0111101; //D
  33.             4'b1110: h=~7'b1001111; //E
  34.             4'b1111: h=~7'b1000111; //F
  35.        
  36.         endcase
  37.    
  38. endmodule
  39.  
  40. module inner_counter_T_4_bits(
  41.     input clk, aclr, enable,
  42.     output [3:0] q);
  43.    
  44.     wire [3:1] c;
  45.    
  46.     assign c[1] = q[0]&enable;
  47.     assign c[2] = q[1]&c[1];
  48.     assign c[3] = q[2]&c[2];
  49.    
  50.     FFT_areset ex0(enable,clk,aclr,q[0]);
  51.     FFT_areset ex1(c[1],clk,aclr,q[1]);
  52.     FFT_areset ex2(c[2],clk,aclr,q[2]);
  53.     FFT_areset ex3(c[3],clk,aclr,q[3]);
  54.    
  55. endmodule
  56.  
  57. module FFT_areset(
  58.     input T, clk, aclr,
  59.     output reg Q);
  60.    
  61.     always@(posedge clk, negedge aclr)
  62.         if(!aclr) Q<=1'b0;
  63.         else if(T) Q<=~Q;
  64.         else Q<=Q;
  65.    
  66. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement