|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
人生的第一个实验:数字电压表,下面是我写的控制ad0809的程序,仿真是正确的,可是下载到版子上后ad0809输出一直是11111111,是程序的问题吗?
其中cs∩wr=START=ALE,cs∩rd=ENABLE
跪谢前辈们!!
module ad0809(clk,reset,eoc,data,cs,wr,rd,dout_h,dout_l);
input clk,reset,eoc;
input[7:0] data;
output cs,wr,rd;
output[3:0] dout_h,dout_l;
reg cs,wr,rd;
reg[3:0] state;
reg[3:0] dout_h,dout_l;
parameter IDLE = 4'b0001,
CLEAR = 4'b0010,
CONVERT = 4'b0100,
READ = 4'b1000;
//----------------change states---------------------
always @ (posedge clk or negedge reset)
begin
if(!reset)
state <= IDLE;
else
case (state)
IDLE:
state <= CLEAR;
CLEAR:
state <= CONVERT;
CONVERT:
if(eoc)
state <= READ;
else
state <= CONVERT;
READ:
state <= IDLE;
default: state <= IDLE;
endcase
end
//---------------output----------------------------
always @ (state)
begin
case (state)
IDLE:
begin
cs <= 0;
wr <= 0;
rd <= 0;
end
CLEAR:
begin
cs <= 1;
wr <= 1;
rd <= 0;
end
CONVERT:
begin
cs <= 0;
wr <= 0;
rd <= 0;
end
READ:
begin
cs <= 1;
wr <= 0;
rd <= 1;
{dout_h,dout_l} <= data;
end
endcase
end
endmodule |
|