Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] [Moved]: Verilog-A model for generating a waveform

Status
Not open for further replies.

electronics_rama

Member level 3
Joined
Aug 8, 2015
Messages
57
Helped
2
Reputation
4
Reaction score
5
Trophy points
1,288
Activity points
1,887
Hello,

I want to generate a 5% duty cycle clock using verilog-A model with frequency of 5MHz.
can anyone help me with this?

I have written the code as attached. But it doesnt work. :sad:



verilog-A.png
 

Re: Verilog-A model for generating a waveform

Show your verilog-a code by text, so that I can modify it.
 

Re: Verilog-A model for generating a waveform

Show your verilog-a code by text, so that I can modify it.


Code Verilog - [expand]
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
`include “constants.vams”
`include “disciplines.vams”
module clk_veriloga(clk);
output clk;
electrical clk;
real clk_var1;
real per1,per2;
parameter real tt=0.01n;
 
analog
begin
    @(initial_step)
        begin
            per1=$abstime+200n;
        end
    @(timer(0,per1))begin
        clk_var1=1;
        per2=$abstime+12.5n;
            @(timer(0,per2))begin
                clk_var1=0;
                per2=0;
            end
    end
V(clk) <+ transition(clk_var1,0,tt);
end
endmodule

 
Last edited by a moderator:

I could find a way to generate the non-50% duty cycle clock.

Below is the code and it works fine.


`include “constants.vams”
`include “disciplines.vams”
module clk_veriloga(clk);
output clk;
electrical clk;
real clk_var1,clk_var2;
integer clk_var3;
real per1;
parameter real tt=0.01n;

analog
begin
@(initial_step)
begin
per1=$abstime+100n;
clk_var1=1;
end
@(timer(0,per1))begin
clk_var1=!clk_var1;
end
clk_var2=absdelay(clk_var1,87.5n);
clk_var3=clk_var1 && clk_var2;
V(clk) <+ transition(clk_var3,0,tt);
end
endmodule
 

Try the following
Code:
`include "constants.vams"
`include "disciplines.vams"

module vclock(PLUS, MINUS);
inout PLUS, MINUS;
electrical PLUS, MINUS;

parameter real delay = 0.0 from [0.0:inf); //Output Waveform Delay Time.
parameter real val0 = 0.0; //Zero Value used in Output Pulse Waveform.
parameter real val1 = 1.0; //One Value used in Output Pulse Waveform.
parameter real period = 100.0u from (0.0:inf); //Period of Input Waveform.
parameter integer ndiv = 1 from [1:inf); //Divide Ratio of Output Frequency.
parameter real rise = (ndiv*period) / 100.0 from (0.0:period);
//Rise Time for Output Pulse Waveform (Time for Transition from 'val0' to 'val1').
parameter real fall = (ndiv*period) / 100.0 from (0.0:period);
//Fall Time for Output Pulse Waveform (Time for Transition from 'val1' to 'val0').
parameter real duty = 0.5 from (0.0:1.0); //Duty Factor for Output Pulse Waveform.

/*
5 edgetype=linear   Type of the rising and falling edges.
This is for pulse waveform and pulse-like piecewise linear waveform.
Possible values are linear or halfsine.
*/

integer trigger;
real width; //Output Pulse Width (Duration of 'val1').
real period_1, duty_1, max_step;

analog begin
   @(initial_step) begin
      if(ndiv == 1) begin
         period_1 = period;
         duty_1 = duty;
      end
      else begin
         period_1 = ndiv * period;
         duty_1 = floor(ndiv/2) / ndiv;
      end

      $display("%M (Ndiv=%d, Duty_Factor=%.1f)\n", ndiv, duty_1);

      max_step = min(rise, fall);
      width = duty_1 * (period_1 - (rise + fall));
   end //initial_step

   $bound_step(max_step);

   @( timer(delay, period_1) ) trigger = 1; //Generation of Rise Edge
   @( timer(delay+rise+width, period_1) ) trigger = 0; //Generation of Fall Edge

   V(PLUS, MINUS) <+ val0 + (val1-val0) * transition(trigger, 0.0, rise, fall);
end //analog

endmodule
 
  • Like
Reactions: Strek

    Strek

    Points: 2
    Thanks for this code! :) I tried to use it in order to generate triangular analog controlled waveform in VA but with different rising and falling time. :) This gave me idea how to create it.
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top