小第写了一段代码,但是用QUARTUS II仿真出来,总是不能够对其中的CMDX_R寄存器正确赋值,请高手们帮忙看看,有问题请告诉我,谢谢大家.代码如下:
module sd_cmd(sel,en,clk,cmd,cmd_right);
input[3:0] sel;
input en;
input clk;
output cmd;
output cmd_right;
reg[5:0] num;
reg cmd_r;
reg[47:0] cmdx_r;
reg cmd_right_r;
always @ (negedge clk or negedge en)
begin
if(!en)
begin
num <= 6'd0;
cmd_right_r <= 1'b0;
cmd_r <= 1'b1;
case(sel)
4'b0000:cmdx_r = 48'h400000000095;
4'b0001:cmdx_r = 48'h7700000000ff;
4'b0010:cmdx_r = 48'h6900000000ff;
4'b0011:cmdx_r = 48'h5100000000ff;
default:;
endcase
end
else begin
num <= num+1'b1;
if(num <= 6'd47)
begin
cmd_r <= cmdx_r[47-num];
cmd_right_r <= 1'b0;
end
else begin
num <= 6'd0;
cmd_right_r <= 1'b1;
cmd_r <= 1'b1;
end
end
end
assign cmd = cmd_r;
assign cmd_right = cmd_right_r;
endmodule |