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.

Verilog Code Is Not Producings The Expected Results

Status
Not open for further replies.

luyunfei330

Newbie level 1
Newbie level 1
Joined
Sep 28, 2014
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
7
I'm fresh about verilog,please help me find out where the mistake is.
Code:
  reset=1;
  #10 @(posedge clk);
  enable=1;
  #30 @(posedge clk);
  enable=0;
  #100 $finish;
 
Last edited by a moderator:

in what context? is this mean to be testbench code? or synthesisable (because it very much isnt).
 

Hello,

Remove the ";" from "@(posedge clk)" on lines 2 and 4. Once you put them, you are basically doing nothing when posedge clock is detected.
 

Hello,

Remove the ";" from "@(posedge clk)" on lines 2 and 4. Once you put them, you are basically doing nothing when posedge clock is detected.

No, that isn't a problem.

I'm not sure what the OP's problem is but the code posted works fine, as long as you generate a clock.

Code Verilog - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module test2;
 
reg clk, reset, enable;
initial begin  
  clk = 0;
  forever clk = #100 ~clk;
end
 
initial begin
  reset=1;
  #10 @(posedge clk);
  enable=1;
  #30 @(posedge clk);
  enable=0;
  #100 $finish;
end
 
endmodule


Capture.PNG

Perhaps the OP should define what they are expecting the results should be.

Regards

- - - Updated - - -

Forgot to mention the #10 and #30 really don't do anything as long as the clock period is bigger than the time control statement. They actually should be removed as the @(posedge clk) is the only time control statement that is doing something useful.

If those #10 & #30 were moved to after the @(posedge clk) then the assignment of enable would be delayed accordingly.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top