verilog_vhdl7
Newbie level 5
- Joined
- Nov 15, 2014
- Messages
- 9
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 103
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 module xyz(); reg clk1; reg [7:0] data_read; reg [7:0] mem [0:7]; reg [3:0] rd_wr_addr; reg rd; task mem_rd; input [3:0] addr; input clk; output [7:0] data; begin @ (posedge clk) rd = 1; rd_wr_addr = addr; @ (negedge clk) data = mem[rd_wr_addr]; data_read = mem[rd_wr_addr]; @ (posedge clk) rd = 0; rd_wr_addr = 0; end endtask initial begin clk1 = 0; reg [3:0] rd_wr_addr = 0; reg rd = 0; $readmemb("data.txt",mem); mem_rd(4'b4,clk1,data_read); end always #20 clk1 = ~ clk1; endmodule
hi...
This is a sample code of task read. I have a doubt here. I have mentioned a reg clk1 and used a task input called clk. Its compiling fine. but when i simulate in model sim this task is not taking clk1 but i can see my clk1 pulse.
Secondly if i remove the clk input from this task and trigger the task using clk1 its simulating fine.
Is it so that i cant use a clock input in my task and map it as i did using the above task.
i am getting my clk1 pulse ....then why is this task not taking this clk1 input.
thank you
Last edited by a moderator: