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

Subversion Repositories ha1588

[/] [ha1588/] [trunk/] [sim/] [rtc/] [rtc_timer_tb.v] - Diff between revs 37 and 38

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

Rev 37 Rev 38
Line 1... Line 1...
/*
/*
 * $rtc_timer_tb.v
 * rtc_timer_tb.v
 *
 *
 * Copyright (c) 2012, BABY&HW. All rights reserved.
 * Copyright (c) 2012, BABY&HW. All rights reserved.
 *
 *
 * This library is free software; you can redistribute it and/or
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * modify it under the terms of the GNU Lesser General Public
Line 23... Line 23...
 
 
module rtc_timer_tb  ;
module rtc_timer_tb  ;
 
 
  reg rst;
  reg rst;
  reg clk;
  reg clk;
 
  wire         adj_ld_done;
  wire [37:0]  time_reg_ns;
  wire [37:0]  time_reg_ns;
  wire [47:0]  time_reg_sec;
  wire [47:0]  time_reg_sec;
  reg period_ld;
  reg period_ld;
  reg [39:0]  period_in;
  reg [39:0]  period_in;
  reg [37:0]  time_acc_modulo;
 
  reg adj_ld;
  reg adj_ld;
  reg [31:0]  adj_ld_data;
  reg [31:0]  adj_ld_data;
  reg [39:0]  period_adj;
  reg [39:0]  period_adj;
  reg time_ld;
  reg time_ld;
  reg [37:0] time_reg_ns_in;
  reg [37:0] time_reg_ns_in;
Line 43... Line 43...
      .time_ld (time_ld ) ,
      .time_ld (time_ld ) ,
      .time_reg_ns_in (time_reg_ns_in ) ,
      .time_reg_ns_in (time_reg_ns_in ) ,
      .time_reg_sec_in (time_reg_sec_in ) ,
      .time_reg_sec_in (time_reg_sec_in ) ,
      .time_reg_ns (time_reg_ns ) ,
      .time_reg_ns (time_reg_ns ) ,
      .time_reg_sec (time_reg_sec ) ,
      .time_reg_sec (time_reg_sec ) ,
 
      .time_ptp_ns ( ) ,
 
      .time_ptp_sec ( ) ,
      .period_ld (period_ld ) ,
      .period_ld (period_ld ) ,
      .period_in (period_in ) ,
      .period_in (period_in ) ,
      .time_acc_modulo (time_acc_modulo ) ,
 
      .adj_ld (adj_ld ) ,
      .adj_ld (adj_ld ) ,
      .period_adj (period_adj ) ,
      .period_adj (period_adj ) ,
      .adj_ld_data (adj_ld_data ) );
      .adj_ld_data (adj_ld_data ) ,
 
      .adj_ld_done ( ) );
 
 
 
 
initial begin
initial begin
        clk = 1'b0;
        clk = 1'b0;
        forever #4  clk = !clk;
        forever #4  clk = !clk;
Line 79... Line 81...
        @(posedge rst);
        @(posedge rst);
        // frequency load
        // frequency load
        period_ld        =  1'b0;
        period_ld        =  1'b0;
        period_in[39:32] =  8'h00;        // ns
        period_in[39:32] =  8'h00;        // ns
        period_in[31: 0] = 32'h00000000;  // ns fraction
        period_in[31: 0] = 32'h00000000;  // ns fraction
        time_acc_modulo  = 38'd256_000000000;
 
        // time load
        // time load
        time_ld              =  1'b0;
        time_ld              =  1'b0;
        time_reg_ns_in[37:8] = 30'd0;          // ns
        time_reg_ns_in[37:8] = 30'd0;          // ns
        time_reg_ns_in[ 7:0] =  8'h00;         // ns fraction
        time_reg_ns_in[ 7:0] =  8'h00;         // ns fraction
        time_reg_sec_in      = 48'd0;
        time_reg_sec_in      = 48'd0;
Line 140... Line 141...
        @(posedge clk);
        @(posedge clk);
        adj_ld            =  1'b0;
        adj_ld            =  1'b0;
end
end
 
 
// sec+ns watchpoint
// sec+ns watchpoint
wire [29:0] time_acc_modulo_ns_ = time_acc_modulo[37:8];
 
wire [47:0] time_reg_sec_in_    = time_reg_sec_in[47:0];
wire [47:0] time_reg_sec_in_    = time_reg_sec_in[47:0];
wire [29:0] time_reg_ns_in_     = time_reg_ns_in[37:8];
wire [29:0] time_reg_ns_in_     = time_reg_ns_in[37:8];
wire [47:0] time_reg_sec_       = time_reg_sec[47:0];
wire [47:0] time_reg_sec_       = time_reg_sec[47:0];
wire [29:0] time_reg_ns_        = time_reg_ns[37:8];
wire [29:0] time_reg_ns_        = time_reg_ns[37:8];
wire [ 7:0] period_ns_          = period_in[39:32];
wire [ 7:0] period_ns_          = period_in[39:32];
wire [ 7:0] period_adj_ns_      = period_adj[39:32];
wire [ 7:0] period_adj_ns_      = period_adj[39:32];
wire        time_reg_sec_inc_   = DUT.time_acc_48s_inc;
wire        time_reg_sec_inc_   = DUT.time_acc_48s_inc;
// ns fraction watchpoint
// ns fraction watchpoint
wire [ 7:0] time_acc_modulo_ns_f = time_acc_modulo[7:0];
 
wire [ 7:0] time_reg_ns_in_f     = time_reg_ns_in[7:0];
wire [ 7:0] time_reg_ns_in_f     = time_reg_ns_in[7:0];
wire [ 7:0] time_reg_ns_f        = time_reg_ns[7:0];
wire [ 7:0] time_reg_ns_f        = time_reg_ns[7:0];
wire [31:0] period_ns_f          = period_in[31:0];
wire [31:0] period_ns_f          = period_in[31:0];
wire [31:0] period_adj_ns_f      = period_adj[31:0];
wire [31:0] period_adj_ns_f      = period_adj[31:0];
 
 
Line 163... Line 162...
always @(posedge clk) begin
always @(posedge clk) begin
        time_reg_sec__d1 <= time_reg_sec_;
        time_reg_sec__d1 <= time_reg_sec_;
        time_reg_ns__d1  <= time_reg_ns_;
        time_reg_ns__d1  <= time_reg_ns_;
end
end
wire [29:0] time_reg_ns__delta = (time_reg_sec__d1!=time_reg_sec_)?
wire [29:0] time_reg_ns__delta = (time_reg_sec__d1!=time_reg_sec_)?
                                (time_acc_modulo_ns_-(time_reg_ns__d1-time_reg_ns_)):
                                (DUT.time_acc_modulo/256-(time_reg_ns__d1-time_reg_ns_)):
                                (time_reg_ns_-time_reg_ns__d1);
                                (time_reg_ns_-time_reg_ns__d1);
 
 
// Delta-Sigma circuit watchpoint
// Delta-Sigma circuit watchpoint
wire [23:0] time_adj_08n_32f_24f = rtc_timer_tb.DUT.time_adj_08n_32f[23:0];
wire [23:0] time_adj_08n_32f_24f = rtc_timer_tb.DUT.time_adj_08n_32f[23:0];
 
 

powered by: WebSVN 2.1.0

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