程序要完成的功能是在地址1110和11110内写入两个不同的值,然后读出1110的值送LCD显示,看是否能够正确读写SRAM.
事实是CD显示的仍然是要写入11110的值,也就是没有正确写入和读出SRAM的值.
高手改错了!!!
inout [15:0] datbus;
output oe;
output ce;
output we;
output lb;
output ub;
output [17:0] adress;
reg [17:0] r_adress;
reg [15:0] r_datbus;
reg dat_dir;
reg r_oe;
reg r_ce;
reg r_we;
reg [3:0] i;
reg [3:0] r_count_clk1;
reg ddclk;
reg flag; //读写SRAM转换
if(flag)
begin
dat_dir <= 1;
if(r_count_clk1 == 0)
begin
r_adress <= 18'b00_0000_0000_0000_1110; //SRAM 送地址
r_we <= 1'd0; //write
r_ce <= 1'd0;
r_oe <= 1'd1;
r_datbus <= 16'b0000_0000_0001_1111; //送数据
end
else if(r_count_clk1 ==3)
begin
r_adress <= 18'b00_0000_0000_0001_1110; //送地址
r_datbus <= 16'b0000_0011_1110_0000; //送数据
end
else if(r_count_clk1 == 5)
begin
r_adress = 18'bzz_zzzz_zzzz_zzzz_zzzz;
r_oe <= 1;
r_we <= 1;
end
end
////////////////////read//////////////////////////////////////////////////////
else
begin
dat_dir <= 0;
if(r_count_clk1 == 0)
begin
r_adress <= 18'b00_0000_0000_0000_1110; //SRAM 地址
r_oe <= 1'd0; //read
r_ce <= 1'd0;
r_we <= 1'd1;
end
else if(r_count_clk1 == 3)
begin
r_red <= r_datbus & 16'b0000_0000_0001_1111;
r_green <= (r_datbus & 16'b0000_0111_1110_0000)>>5;
r_blue <= (r_datbus & 16'b1111_1000_0000_0000)>>11;
end
else if(r_count_clk1 == 5)
begin
r_adress = 18'bzz_zzzz_zzzz_zzzz_zzzz;
r_oe <= 1'd1; //read
r_we <= 1'd1;
end
end
assign adress = r_adress;
assign datbus = dat_dir?r_datbus:16'bzzzz_zzzz_zzzz_zzzz;
assign oe = r_oe;
assign ce = r_ce;
assign we = r_we;
assign tclk1 = iclk1;
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |