module MAX197(clk,rst,INT,data,cs,wr,rd,hben,q);
input clk;
input rst;
input INT;
inout[7:0]data;
output cs,wr,rd,hben;
output[15:0]q;
reg[7:0]data;
reg cs,wr,rd,hben,en,temp_H,temp_L;
reg[15:0]q;
reg[5:0]current_time,next_time;
reg[7:0]temp;
//assign data=(en)?temp:8'bz;
[email=always@(posedge]always@(posedge[/email] clk)
begin
if(en)
data<=8'h50;
else if(temp_H)
begin
q[15:8]<=data;
data<=8'bz;
end
else if(temp_L)
begin
q[7:0]<=data;
data<=8'bz;
end
end
reg[15:0]count;
reg count_rst;
[email=always@(posedge]always@(posedge[/email] clk)
begin
if(!count_rst)
count<=0;
else count<=count+1;
end
[email=always@(posedge]always@(posedge[/email] clk)current_time<=next_time;
parameter st0=6'd0;
parameter st1=6'd1;
parameter st2=6'd2;
parameter st3=6'd3;
parameter st4=6'd4;
parameter st5=6'd5;
parameter st6=6'd6;
parameter st7=6'd7;
parameter st8=6'd8;
parameter st9=6'd9;
always@(*)
begin
if(!rst)
next_time<=st0;
case(current_time)
st0:
begin
cs<=1;wr<=1;rd<=1;en<=1;temp_H<=0;temp_L<=0;
next_time<=st1;
end
st1:
begin
cs<=0;wr<=0;rd<=1;en<=1;temp_H<=0;temp_L<=0;
next_time<=st2;
end
st2:
begin
cs<=0;wr<=0;rd<=1;en=1;temp_H<=0;temp_L<=0;
// data<=8'h50;
next_time<=st3;
end
st3:
begin
count_rst<=0;
count_rst<=1;
if(count==500)
next_time<=st4;
else next_time<=st3;
end
st4:
begin
cs<=1;wr<=1;rd<=1;en=1;temp_H<=0;temp_L<=0;
if(INT)
next_time<=st4;
else next_time<=st5;
end
st5:
begin
cs<=0;wr<=1;rd<=0;en=0;hben<=1;temp_H<=0;temp_L<=0;
next_time<=st6;
end
st6:
begin
cs<=0;wr<=1;rd<=0;en=0;hben<=1;temp_H<=1;temp_L<=0;
next_time<=st7;
end
st7:
begin
cs<=0;wr<=1;rd<=0;en=0;hben<=0;temp_H<=0;temp_L<=0;
next_time<=st8;
end
st8:
begin
cs<=0;wr<=1;rd<=0;en=0;hben<=0;temp_H<=0;temp_L<=1;
next_time<=st9;
end
st9:
begin
cs<=1;wr<=1;rd<=1;en=1;temp_H<=0;temp_L<=0;
next_time<=st0;
end
default:
begin
cs<=1;wr<=1;rd<=1;en=1;hben<=1;temp_H<=0;temp_L<=0;
next_time<=st0;
end
endcase
end
endmodule
我这个程序一直没有反应,应该是三态门那里出问题了,但我不知道怎么改,请教高手解决 |