assign inout wire (verilog)

Status
Not open for further replies.

spman

Advanced Member level 4
Joined
Aug 15, 2010
Messages
113
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Activity points
2,061
i have wriiten a sram code :

Code:
module t5(Addr, IO, Clk, RWL, ResetL);
	input	[2:0] Addr;
	input	Clk, RWL, ResetL;
	inout	[7:0] IO;
	
	reg	[7:0] r [7:0];
	integer	i;
	
	always @(posedge Clk or negedge ResetL)
		if (!ResetL) begin
			for (i = 0; i < 8; i=i+1)
				r[i] <= 0;
		end
		else	begin
			if (!RWL)
				r [Addr] <= IO;
		end
		
		assign IO = (!RWL) ? 8'bz : r[Addr];
		
endmodule

now i want to test it with test fixture.


Code:
module tt5;

	// Inputs
	reg [2:0] Addr;
	reg Clk;
	reg RWL;
	reg ResetL;

	// Bidirs
	wire [7:0] IO;

	// Instantiate the Unit Under Test (UUT)
	t5 uut (
		.Addr(Addr), 
		.IO(IO), 
		.Clk(Clk), 
		.RWL(RWL), 
		.ResetL(ResetL)
	);

	initial begin
		// Initialize Inputs
		Addr = 0;
		Clk = 0;
		RWL = 0;
		ResetL = 0;

		// Wait 100 ns for global reset to finish
		#100;
		ResetL = 1;
		Addr = 1;
		IO = 10;
		#50;
		Clk = 1;
		#50;
		Clk = 0;
		RWL = 1;
		
		
		// Add stimulus here

	end
      
endmodule

ISE gives an error in this line :
IO = 10;

"Procedural assignment to a non-register <IO> is not permitted."

also i tried this code :
assign IO = 10;
but the same error was repeated!
how to solve it?
 

in module tt5,
the IO should be a reg type, not a wire...
 
Reactions: spman

    spman

    Points: 2
    Helpful Answer Positive Rating
Try something like this..

Code:
wire [10:0] IO;
reg [10:0] IOreg;

assign IO = IOreg;

initial
  begin
    IOreg = some value;
    #(some time) IOreg = some value;
    #(some time) IOreg = {10{1'bz}};             // tristate
  end
 
Reactions: spman

    spman

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…