Confused

The favorite HDL language in North America

Confused

Postby seattleEE » Tue Jun 21, 2011 6:36 am

Hi, I have a problem that I'm not understanding in Verilog. Hopefully I have simplified it and it still makes sense.

I create a wire and connect to an inout in another module. That wire is always driven from my module. But it doesn't work. However, when I add a debug line to send it, it starts to work. Below is a stripped down bit of code that hopefully illustrates the issue.

---
module X
(
output wire [7:0] DebugOut
)

// Register to hold the data to write
reg [31:0] DataToWrite
wire [31:0] MyData

// Define a module. Note that .Data is defined in ExtModule as inout wire [31:0] Data
ExtModule MyModule(.Data(MyData) );

// If this line below is uncommented, it works as expected. If I comment it out, the value written to ExtModule is usually all '1'
assign DebugOut = MyData[15:8];

// If we're in a certain state, the drive the data we want to write. Otherwise, just drive the value 32'b1. I'd expect this to work as a mux,
// where it either drive the MyData bus from the DataToWrite latch or from a fixed value of 32'b1.
assign MyData = (State == TRASHSTATE ? DataToWrite : 32'b1);
---


Can anyone add any clarity?

Thanks very much.
seattleEE
 
Posts: 13
Joined: Sat Sep 13, 2008 4:42 pm

Re: Confused

Postby julytiger » Tue Jun 21, 2011 10:08 am

try "output [31:0] MyData;", which instead of "wire [31:0] MyData;".
Good luck!
julytiger
 
Posts: 3
Joined: Mon Jun 20, 2011 2:45 am

Re: Confused

Postby seattleEE » Tue Jun 21, 2011 2:38 pm

I did try it, but as expected in/out statements are only allowed at the top. Compiler complained and said "expecting 'endmodule' found 'output'
seattleEE
 
Posts: 13
Joined: Sat Sep 13, 2008 4:42 pm

Re: Confused

Postby julytiger » Wed Jun 22, 2011 10:12 am

module Data ( CLK, Data);
input Clk;
output [31:0] Data;
...

reg [31:0] DataToWrite;
...
assign Data = (State == TRASHSTATE ? DataToWrite : 32'b1);
endmoudle

/******************************************************************************/
module top_module(CLK, MyData);
input CLK;
ouput [31:0] MyData;

wire [31:0] rMyData;

Data rMyData
(
.CLK(CLK),
.Data(rMyData),
);

assign MyData=rMyData;

endmoudle
julytiger
 
Posts: 3
Joined: Mon Jun 20, 2011 2:45 am


Return to Verilog HDL