viresh128
Newbie level 3
- Joined
- Aug 7, 2011
- Messages
- 3
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- Long Beach
- Activity points
- 1,301
Hi, I am trying to learn task and function in verilog. Here's what i tried-
code-
and the TESTBENCH-
THE PROBLEM IS THAT I AM GETTING A DELAYED OUTPUT, APPROX 10ns. COULD SOMEBODY PLS EXPLAIN WHY IS IT SO? FOR THE FIRST 15ns THE "Y" SIGNAL IS xxxx, ITS ONLY AFTER THIS THE ADDITION VALUES ARE BEING DISPLAYED. :sad::sad: PLEASE HELP.
code-
Code Verilog - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 module add_task(a,b,y, clk); input [3:0] a, b; output [4:0] y; input clk; reg[4:0] y; always @(posedge clk) begin add(a,b,y); end task add; input [3:0] in1, in2; output [4:0] out; reg [4:0]out; begin out<=in1+in2; end endtask endmodule
and the TESTBENCH-
Code Verilog - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 module tb_add_task; reg [3:0] a=0; reg [3:0] b=0; reg clk=0; wire [4:0] y; add_task uut (.a(a), .b(b), .y(y), .clk(clk)); always #5 clk=~clk; always @(negedge clk) begin a = $random; b = $random; end endmodule
THE PROBLEM IS THAT I AM GETTING A DELAYED OUTPUT, APPROX 10ns. COULD SOMEBODY PLS EXPLAIN WHY IS IT SO? FOR THE FIRST 15ns THE "Y" SIGNAL IS xxxx, ITS ONLY AFTER THIS THE ADDITION VALUES ARE BEING DISPLAYED. :sad::sad: PLEASE HELP.
Last edited by a moderator: