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.

Variable clock generation in verilog using task

Status
Not open for further replies.

raghavkmr

Junior Member level 2
Joined
Nov 26, 2013
Messages
23
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
194
I have used following code to generate clock (whichever value i pass through task it will create that frequency), but the code only works if i use CLKSEL_global = clksel_local (line no. 23)(i.e. blocking assignment) but that creates delta delay.


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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
`timescale 1ns/1ps
module new(CLK,CLK_OUT);
input CLK;
output CLK_OUT;
 
and(CLK_OUT,1,CLK);
 
 
endmodule
`timescale 1ns/1ps
module tb();
real CLKSEL_global;
reg clk;
reg CLK7;
wire clk_out;
 
new dut(clk,clk_out);
 
task task_CLOCK;
 
input real clksel_local;
begin
CLKSEL_global = clksel_local;
 
end
endtask
 
initial begin
 CLK7 = 0;
 forever begin
  #(500.0/CLKSEL_global) CLK7 = 1;
  #(500.0/CLKSEL_global) CLK7 = 0;
 end
end
 
always @(CLK7) begin
   clk = CLK7;
 end
 
 initial begin
task_CLOCK(340.0);
  end
  
 initial begin
 #100 $finish ;
 end
 endmodule



how do i generate variable clock without creating delta delay
 

Re: variable clock generation in verilog using task

I don't get why you generate your clocks with this code.

It's a lot simpler to use a clock module that generates the clock. Then it represents a clock oscillator on a board (the testbench).

I use a generic clock generator module that accepts parameters for either period/frequency, value(either period/frequency), differential/single-ended. It has 2 outputs +/- and 1 input an enable/disable port.

I'd rather write something like the clock generate I use once and never have to write it again, instead of doing what you are doing by adding all that code (a lot of which seems redundant and convoluted) to generate a simple clock at a specific frequency.
 
Re: variable clock generation in verilog using task

how can i pass real values through module that is the problem ,thats why i shiftedto task
 

Re: variable clock generation in verilog using task

Use parameters and assign a real value to it, when you instantiate the module.
 

Re: variable clock generation in verilog using task

And don't forget that for most simulations you perform, your clock should be ideal anyway. This notion of clock frequency in RTL is rarely needed, but often implemented by naive designers/students.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top