always@(cu_state, pc, md_rd)begin case(cu_state) 2'b00: begin //reset cu_state_tmp = 2'b01; pc_tmp = pc; ir_tmp = 16'b0; acc_tmp = acc; mar = 13'b0; wr = 1'b0; rd = 1'b0; md_wr = 8'b0; end 2'b01: begin cu_state_tmp = 2'b10; //cu_state_tmp = cu_state_tmp + 1 pc_tmp = pc + 13'b1; ir_tmp = {8'b0, md_rd}; acc_tmp = acc; mar = pc; wr = 1'b0; rd = 1'b1; md_wr = 8'b0; end 2'b10: begin cu_state_tmp = 2'b11; //cu_state_tmp = cu_state_tmp + 1 pc_tmp = pc + 13'b1; ir_tmp = {md_rd, ir[7:0]}; acc_tmp = acc; mar = pc; wr = 1'b0; rd = 1'b1; md_wr = 8'b0; end 2'b11: begin cu_state_tmp = 2'b01; ir_tmp = 16'b0; pc_tmp = pc; //mar = 13'b0; //wr = 1'b0; //rd = 1'b0; //md_wr = 8'b0; ALU; end default: begin cu_state_tmp = 2'b00; pc_tmp = 8'b0; ir_tmp = 16'b0; acc_tmp = acc; mar = 13'b0; wr = 1'b0; rd = 1'b0; md_wr = 8'b0; end endcase end加入间接寻址周期
时间: 2024-03-11 12:49:17 浏览: 54
uart2.rar_STC UART2
在这段代码中,加入间接寻址周期可以通过在cu_state为特定状态时,设置mar变量的值为acc寄存器中存储的内容。具体实现方法如下:
在case语句中添加一个新的分支,当cu_state为特定状态时执行间接寻址周期:
```
2'b11: begin // 间接寻址周期
cu_state_tmp = 2'b01;
ir_tmp = 16'b0;
pc_tmp = pc;
mar = acc; // 设置mar为acc寄存器中存储的内容
wr = 1'b0;
rd = 1'b1;
md_wr = 8'b0;
end
```
需要注意的是,间接寻址周期在cu_state为2'b11时执行,因此需要在此分支中执行ALU操作,而不是在默认分支中执行。
阅读全文