1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
| module seg_test( input clk, input rst_n, output[5:0]seg_sel, output[7:0]seg_data ); reg[31:0] timer_cnt; reg en_1hz; always@(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) begin en_1hz <= 1'b0; timer_cnt <= 32'd0; end else if(timer_cnt >= 32'd49_999_999) begin en_1hz <= 1'b1; timer_cnt <= 32'd0; end else begin en_1hz <= 1'b0; timer_cnt <= timer_cnt + 32'd1; end end wire[3:0] count0; wire t0; count_m10 count10_m0( .clk (clk), .rst_n (rst_n), .en (en_1hz), .clr (1'b0), .data (count0), .t (t0) ); wire[3:0] count1; wire t1; count_m6 count6_m1( .clk (clk), .rst_n (rst_n), .en (t0), .clr (1'b0), .data (count1), .t (t1) );
wire[3:0] count2; wire t2; count_m10 count10_m2( .clk (clk), .rst_n (rst_n), .en (t1), .clr (1'b0), .data (count2), .t (t2) );
wire[3:0] count3; wire t3; count_m10 count10_m3( .clk (clk), .rst_n (rst_n), .en (t2), .clr (1'b0), .data (count3), .t (t3) );
wire[3:0] count4; wire t4; count_m10 count10_m4( .clk (clk), .rst_n (rst_n), .en (t3), .clr (1'b0), .data (count4), .t (t4) );
wire[3:0] count5; wire t5; count_m10 count10_m5( .clk (clk), .rst_n (rst_n), .en (t4), .clr (1'b0), .data (count5), .t (t5) );
wire[6:0] seg_data_0; seg_decoder seg_decoder_m0( .bin_data (count5), .seg_data (seg_data_0) ); wire[6:0] seg_data_1; seg_decoder seg_decoder_m1( .bin_data (count4), .seg_data (seg_data_1) ); wire[6:0] seg_data_2; seg_decoder seg_decoder_m2( .bin_data (count3), .seg_data (seg_data_2) ); wire[6:0] seg_data_3; seg_decoder seg_decoder_m3( .bin_data (count2), .seg_data (seg_data_3) ); wire[6:0] seg_data_4; seg_decoder seg_decoder_m4( .bin_data (count1), .seg_data (seg_data_4) );
wire[6:0] seg_data_5; seg_decoder seg_decoder_m5( .bin_data (count0), .seg_data (seg_data_5) );
seg_scan seg_scan_m0( .clk (clk), .rst_n (rst_n), .seg_sel (seg_sel), .seg_data (seg_data),
.seg_data_4 ({1'b1,seg_data_4}), .seg_data_5 ({1'b1,seg_data_5}) ); endmodule
|