OpenCores
URL https://opencores.org/ocsvn/rtcclock/rtcclock/trunk

Subversion Repositories rtcclock

[/] [rtcclock/] [trunk/] [rtl/] [rtcclock.v] - Diff between revs 3 and 4

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 3 Rev 4
Line 158... Line 158...
        assign  tm_stopped = ~timer[24];
        assign  tm_stopped = ~timer[24];
        assign  tm_running =  timer[24];
        assign  tm_running =  timer[24];
        assign  tm_alarm   =  timer[25];
        assign  tm_alarm   =  timer[25];
        reg     [23:0]           tm_start;
        reg     [23:0]           tm_start;
        reg     [7:0]            tm_sub;
        reg     [7:0]            tm_sub;
        initial tm_start = 16'h00;
        initial tm_start = 24'h00;
        initial timer  = 18'h00;
        initial timer    = 26'h00;
        initial tm_int   = 1'b0;
        initial tm_int   = 1'b0;
        initial tm_pps   = 1'b0;
        initial tm_pps   = 1'b0;
        always @(posedge i_clk)
        always @(posedge i_clk)
        begin
        begin
                if (ck_carry)
                if (ck_carry)
Line 249... Line 249...
        // will only clear it if it was already stopped.
        // will only clear it if it was already stopped.
        reg             sw_pps, sw_ppm, sw_pph;
        reg             sw_pps, sw_ppm, sw_pph;
        reg     [7:0]    sw_sub;
        reg     [7:0]    sw_sub;
        wire    sw_running;
        wire    sw_running;
        assign  sw_running = stopwatch[0];
        assign  sw_running = stopwatch[0];
        initial stopwatch = 32'h00001;
        initial stopwatch = 32'h00000;
        always @(posedge i_clk)
        always @(posedge i_clk)
        begin
        begin
                sw_pps <= 1'b0;
                sw_pps <= 1'b0;
                if (sw_running)
                if (sw_running)
                begin
                begin
Line 400... Line 400...
        // on another clock, but we'll get there.
        // on another clock, but we'll get there.
        //
        //
        reg             r_hack_carry;
        reg             r_hack_carry;
        reg     [29:0]   hack_time;
        reg     [29:0]   hack_time;
        reg     [39:0]   hack_counter;
        reg     [39:0]   hack_counter;
 
        initial hack_time    = 30'h0000;
 
        initial hack_counter = 40'h0000;
        always @(posedge i_clk)
        always @(posedge i_clk)
                if (i_hack)
                if (i_hack)
                begin
                begin
                        hack_time <= { clock[21:0], ck_sub };
                        hack_time <= { clock[21:0], ck_sub };
                        hack_counter <= ck_counter;
                        hack_counter <= ck_counter;
Line 416... Line 418...
                        hack_time <= { clock[21:0], ck_sub };
                        hack_time <= { clock[21:0], ck_sub };
                        r_hack_carry <= 1'b0;
                        r_hack_carry <= 1'b0;
                end
                end
 
 
        reg     [15:0]   h_sseg;
        reg     [15:0]   h_sseg;
 
        reg     [3:0]    dmask;
        always @(posedge i_clk)
        always @(posedge i_clk)
                case(clock[27:24])
                case(clock[27:24])
                4'h0: h_sseg <= { 2'b00, ck_last_clock[21:8] };
                4'h1: begin h_sseg <= timer[15:0];
                4'h1: h_sseg <= timer[15:0];
                        if (tm_alarm) dmask <= 4'hf;
                4'h2: h_sseg <= stopwatch[19:4];
                        else begin
                4'h3: h_sseg <= ck_last_clock[15:0];
                                dmask[3] <= (12'h000 != timer[23:12]); // timer[15:12]
                default: h_sseg <= { 2'b00, ck_last_clock[21:8] };
                                dmask[2] <= (16'h000 != timer[23: 8]); // timer[11: 8]
 
                                dmask[1] <= (20'h000 != timer[23: 4]); // timer[ 7: 4]
 
                                dmask[0] <= 1'b1; // Always on
 
                        end end
 
                4'h2: begin h_sseg <= stopwatch[19:4];
 
                                dmask[3] <= (12'h00  != stopwatch[27:16]);
 
                                dmask[2] <= (16'h000 != stopwatch[27:12]);
 
                                dmask[1] <= 1'b1; // Always on, stopwatch[11:8]
 
                                dmask[0] <= 1'b1; // Always on, stopwatch[7:4]
 
                        end
 
                4'h3: begin h_sseg <= ck_last_clock[15:0];
 
                                dmask[3:0] <= 4'hf;
 
                        end
 
                default: begin // 4'h0
 
                        h_sseg <= { 2'b00, ck_last_clock[21:8] };
 
                        dmask[2:0] <= 3'hf;
 
                        dmask[3] <= (2'b00 != ck_last_clock[21:20]);
 
                        end
                endcase
                endcase
 
 
        wire    [31:0]   w_sseg;
        wire    [31:0]   w_sseg;
        assign  w_sseg[ 0] = (~ck_sub[7]);
        assign  w_sseg[ 0] = (~ck_sub[7]);
        assign  w_sseg[ 8] = 1'b0;
        assign  w_sseg[ 8] =  (clock[27:24] == 4'h2);
        assign  w_sseg[16] = 1'b0;
        assign  w_sseg[16] = ((clock[27:24] == 4'h0)&&(~ck_sub[7]))||(clock[27:24] == 4'h3);
        assign  w_sseg[24] = 1'b0;
        assign  w_sseg[24] = 1'b0;
        hexmap  ha(i_clk, h_sseg[ 3: 0], w_sseg[ 7: 1]);
        hexmap  ha(i_clk, h_sseg[ 3: 0], w_sseg[ 7: 1]);
        hexmap  hb(i_clk, h_sseg[ 7: 4], w_sseg[15: 9]);
        hexmap  hb(i_clk, h_sseg[ 7: 4], w_sseg[15: 9]);
        hexmap  hc(i_clk, h_sseg[11: 8], w_sseg[23:17]);
        hexmap  hc(i_clk, h_sseg[11: 8], w_sseg[23:17]);
        hexmap  hd(i_clk, h_sseg[15:12], w_sseg[31:25]);
        hexmap  hd(i_clk, h_sseg[15:12], w_sseg[31:25]);
 
 
        always @(posedge i_clk)
        always @(posedge i_clk)
                if ((tm_alarm || al_tripped)&&(ck_sub[7]))
                if ((tm_alarm || al_tripped)&&(ck_sub[7]))
                        o_sseg <= 32'h0000;
                        o_sseg <= 32'h0000;
                else
                else
                        o_sseg <= w_sseg;
                        o_sseg <= {
 
                                (dmask[3])?w_sseg[31:24]:8'h00,
 
                                (dmask[2])?w_sseg[23:16]:8'h00,
 
                                (dmask[1])?w_sseg[15: 8]:8'h00,
 
                                (dmask[0])?w_sseg[ 7: 0]:8'h00 };
 
 
        reg     [17:0]   ledreg;
        reg     [17:0]   ledreg;
        always @(posedge i_clk)
        always @(posedge i_clk)
                if ((ck_pps)&&(ck_ppm))
                if ((ck_pps)&&(ck_ppm))
                        ledreg <= 18'h00;
                        ledreg <= 18'h00;
                else if (ck_carry)
                else if (ck_carry)
                        ledreg <= ledreg + 18'h11;
                        ledreg <= ledreg + 18'h11;
        assign  o_led = (tm_alarm||al_tripped)?{ (16){ck_sub[7]}}:ledreg[17:2];
        assign  o_led = (tm_alarm||al_tripped)?{ (16){ck_sub[7]}}:
 
                                { ledreg[17:10],
 
                                ledreg[10], ledreg[11], ledreg[12], ledreg[13],
 
                                ledreg[14], ledreg[15], ledreg[16], ledreg[17] };
 
 
        assign  o_interrupt = tm_int || al_int;
        assign  o_interrupt = tm_int || al_int;
 
 
        always @(posedge i_clk)
        always @(posedge i_clk)
                case(i_wb_addr[2:0])
                case(i_wb_addr[2:0])
                3'b000: o_data <= { clock[31:22], ck_last_clock };
                3'b000: o_data <= { clock[31:22], ck_last_clock };
                3'b001: o_data <= { 14'h00, timer };
                3'b001: o_data <= { 6'h00, timer };
                3'b010: o_data <= stopwatch;
                3'b010: o_data <= stopwatch;
                3'b011: o_data <= { 6'h00, al_tripped, al_enabled, 2'b00, alarm_time };
                3'b011: o_data <= { 6'h00, al_tripped, al_enabled, 2'b00, alarm_time };
                3'b100: o_data <= ckspeed;
                3'b100: o_data <= ckspeed;
                3'b101: o_data <= { 2'b00, hack_time };
                3'b101: o_data <= { 2'b00, hack_time };
                3'b110: o_data <= hack_counter[39:8];
                3'b110: o_data <= hack_counter[39:8];

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.