The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Mar 29th, 2024, 3:56am
Pages: 1
Send Topic Print
Writing to a file for DNL calculations of an ADC (Read 984 times)
K22
New Member
*
Offline



Posts: 2

Writing to a file for DNL calculations of an ADC
Oct 10th, 2020, 12:11pm
 
Hello,

I have an ADC output which I want to write to a file. Everything works fine except that the ADC output has some glicthes. I am using '@cross' to detect an event and it's also creating events and calculating the wrong decimal value corresponding to the digital output because of the glitches. So I am setting two thesholds: one for the rising edge and one for the falling edge. The problem I'm having is in taking into account the direction of my outputs while writing a decimal value for it.

Here is my code

`include  "discipline.h"
`include  "constants.h"
`define NUM_DAC_BITS   8

module d2a_ideal (din, ramp);

input    [`NUM_DAC_BITS-1:0] din;
electrical  [`NUM_DAC_BITS-1:0] din;
input   ramp;
electrical  ramp;
     parameter real vthp = 0.7;
     parameter real vthn = 0.3;
     real vramp;
     real decimal_value;
     integer outfile;

   analog begin

     @(initial_step or initial_step("dc","ac","tran","xf"))  begin
       decimal_value = 0;
       //outfile = $fopen("~/ece792/vikas_pipeline/i_%P_%A.dat");
     outfile = $fopen("/afs/unity.ncsu.edu/users/k/kvmaru/Desktop/ECE714/Pipelined_ADC/MC_i_%P%
T%A.dat","a");
     $fstrobe(outfile, "%f\t%f",12345.0,0.0);            
     end
     @(final_step) begin
           $fclose(outfile);
     end

      @(cross(V(din[0])-vthp,1) or cross(V(din[1])-vthp,1) or cross(V(din[2])-vthp,1) or cross(V(din[3])-vthp,1) or cross(V(din[4])-vthp,1) or cross(V(din[5])-vthp,1) or cross(V(din[6])-vthp,1) or cross(V(din[7])-vthp,1) or cross(V(din[0])-vthn,-1) or cross(V(din[1])-vthn,-1) or cross(V(din[2])-vthn,-1) or cross(V(din[3])-vthn,-1) or cross(V(din[4])-vthn,-1) or cross(V(din[5])-vthn,-1) or cross(V(din[6])-vthn,-1) or cross(V(din[7])-vthn,-1)  )
    begin
        decimal_value=0;
        generate i (`NUM_DAC_BITS-1, 0) begin
           decimal_value = decimal_value + (( V(din[i]) > vthp ) ? 1 << i :0);
        end
     vramp = V(ramp);
     $fstrobe(outfile, "%f\t%f",vramp,decimal_value);
      end
 end

endmodule

`undef NUM_DAC_BITS


Does any one have any suggestions for how I may be able to calculate the decimal value using binary with two thresholds? Appreciate any help!
Back to top
 
 
View Profile   IP Logged
K22
New Member
*
Offline



Posts: 2

Re: Writing to a file for DNL calculations of an ADC
Reply #1 - Oct 10th, 2020, 12:41pm
 
Nevermind, I've figured it out thanks!
Back to top
 
 
View Profile   IP Logged
Horror Vacui
Senior Member
****
Offline



Posts: 127
Dresden, Germany
Re: Writing to a file for DNL calculations of an ADC
Reply #2 - Feb 19th, 2021, 5:29am
 
It would have been nice to share to solution for others...
Back to top
 
 
View Profile   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.