- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm using SystemVerilog, writing a test bench to test a device that has a bidirectional bus. I have been successful directly writing a sequence of statements that put the data on the bus and pulse the write line. But that is cumbersome to write a lot of data. So I want to use the Verilog task capability. I can't seem to get it to drive the bus at all.
Here is the code simplified:
module test();
wire data; // the bidirectional data bus
reg wr; // the write enable line
logic send_data; // the register for writing data
my_device u1(
.data,
.wr
);
assign data = send_data;
initial begin
write_gpbus(8'h08);
end
task write_gpbus;
input reg data_to_send;
begin
send_data = data_to_send;
# 50ns wr = 1'b1;
# 50ns wr = 1'b0;
end
endmodule
When I run this I can see send_data getting the correct value of the parameter passed into the task. But data (the actual bus) is always unknown, never gets a value. If I were to just write directly to the send_data not using the task (as in the code below), then data does get the value. What am I doing wrong here?
initial begin
send_data = 8'h08;
end
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Never mind! I had some unfinished faulty logic in my_device that was driving the data bus to the unknown state. After turning that off the task correctly drives the bidirectional bus (at least in the output direction).

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page