A
Agreychu
Guest
Hello,i am new to Verilog HDL.i have a module with a inout signal.But
i don't know what problem to my verilog code.
I want to write a module like this:
<----->DATA |
------>ADDR |
------>WR |
------>RD |
------>RESET|
DATA is an inout signal,controled by WR or RD(Write enable or Read
enable).ADDR is address.
Here is my verilog code:
module mem(ADDR,DATA,RD,WR,RESET);
input [7:0] ADDR;
inout [7:0] DATA;
tri [7:0] DATA;
input RESET;
input WR;
input RD;
reg [7:0] b[0:255];
reg [7:0] a;
assign DATA = (WR)? a : 8'bz ;
always @ (posedge WR or RD or RESET)
begin
if (!RESET)
a<=8'bz;
else if(RD)
b[ADDR]<=DATA;
else if(WR)
a <= b[ADDR];
else
a<=8'bz;
end
endmodule
But simulation result was wrong.Please tell me how should I fix it,or
another method to implement bidirectional data,thx.
Have a nice day.
i don't know what problem to my verilog code.
I want to write a module like this:
<----->DATA |
------>ADDR |
------>WR |
------>RD |
------>RESET|
DATA is an inout signal,controled by WR or RD(Write enable or Read
enable).ADDR is address.
Here is my verilog code:
module mem(ADDR,DATA,RD,WR,RESET);
input [7:0] ADDR;
inout [7:0] DATA;
tri [7:0] DATA;
input RESET;
input WR;
input RD;
reg [7:0] b[0:255];
reg [7:0] a;
assign DATA = (WR)? a : 8'bz ;
always @ (posedge WR or RD or RESET)
begin
if (!RESET)
a<=8'bz;
else if(RD)
b[ADDR]<=DATA;
else if(WR)
a <= b[ADDR];
else
a<=8'bz;
end
endmodule
But simulation result was wrong.Please tell me how should I fix it,or
another method to implement bidirectional data,thx.
Have a nice day.