当前位置:   article > 正文

CPU设计实战:Loongarch版 lab7:不考虑相关冲突处理的简单流水线CPU_cpu设计实战loongarch版 lab

cpu设计实战loongarch版 lab

首先上来看到了这两句话,那么直接起手改变一下接口

  1. // inst sram interface
  2. output wire inst_sram_en,
  3. output wire [ 3:0] inst_sram_we,
  4. output wire [31:0] inst_sram_addr,
  5. output wire [31:0] inst_sram_wdata,
  6. input wire [31:0] inst_sram_rdata,
  7. // data sram interface
  8. output wire data_sram_en,
  9. output wire [ 3:0] data_sram_we,
  10. output wire [31:0] data_sram_addr,
  11. output wire [31:0] data_sram_wdata,
  12. input wire [31:0] data_sram_rdata,

ok,添加完成后先进行运行,看看报错在什么地方(舔舌)。

直接出来这个了,我滴妈,难道,我滴任务完成辣?nonono,一看输出全为0,显然不是的,再查下去发现指令ram使能信号一直高阻态,好嘛,那大致明白要干什么了,那就要把mycpu的单周期改为流水线再来看看怎么事吧。这里借用了龙芯团队胡伟武老师等人编写的计算机体系结构基础的一些图。

然后流水线的设计参考汪文祥工程师等人攥写的CPU设计实战,引入了同步ram,所以考虑采用nextpc作为指令ram的读地址(视作pre-IF),并且要注意设置好各级流水线之间的握手信号。

或者还有一种方案是在IF阶段请求读指令ram,然后在ID阶段获取到指令,我第一次分割时候是这样做的,但是实现完之后一直会有一些小bug,改起来比较头疼,于是换了上面的方案。

我在一开始将每个需要传递到下一个阶段的信号都写在输入输出那里,发现这在我后面连线时会变得异常麻烦,参考了openla500后发现可以简化一下,于是就设置了每级流水之间的bus,会让连线变得简单一点。

我认为在了解了怎么将单周期分割成流水线之后最主要就是要细心了,将mycpu分成5个module之后,有时候会出现丢掉几个赋值语句(在ctrl+C和ctrl+V时)或者是数据位宽的问题,比如我就忘掉了数据ram的使能信号和读出数据的赋值,导致我卡了很久,而且在复制的时候我认为要给不同阶段之间传递的需要保持的信号附上不同的名字,这样就可以知道是哪个阶段出了问题。不过最终也是解决了问题,通过测试。

IF stage

  1. module IF_stage(
  2. input clk,
  3. input reset,
  4. input ID_allow_in,
  5. input [32:0] br_bus,
  6. output inst_sram_en,
  7. output [ 3:0] inst_sram_we,
  8. output [31:0] inst_sram_addr,
  9. output [31:0] inst_sram_wdata,
  10. input [31:0] inst_sram_rdata,
  11. output [63:0] IF_ID_bus,
  12. output IF_to_ID_valid
  13. );
  14. wire br_taken;
  15. wire [31:0] br_target;
  16. wire [31:0] IF_inst;
  17. reg [31:0] IF_pc;
  18. wire [31:0] seq_pc;
  19. wire [31:0] nextpc;
  20. wire IF_ready_go;
  21. wire IF_allow_in;
  22. wire to_IF_valid;
  23. wire IF_to_ID_valid;
  24. reg IF_valid;
  25. assign to_IF_valid = ~reset;
  26. assign IF_ready_go = 1'b1;
  27. assign IF_allow_in = !IF_valid || IF_ready_go && ID_allow_in;
  28. assign IF_to_ID_valid = IF_valid && IF_ready_go;
  29. assign IF_ID_bus = {IF_pc, IF_inst};
  30. assign {br_taken, br_target} = br_bus;
  31. always @(posedge clk) begin
  32. if (reset) begin
  33. IF_valid <= 1'b0;
  34. end
  35. else if (IF_allow_in) begin
  36. IF_valid <= to_IF_valid;
  37. end
  38. end
  39. always @(posedge clk) begin
  40. if(reset) begin
  41. IF_pc <= 32'h1bfffffc;
  42. end else begin
  43. IF_pc <= nextpc;
  44. end
  45. end
  46. assign seq_pc = IF_pc + 3'h4;
  47. assign nextpc = br_taken ? br_target : seq_pc;
  48. assign inst_sram_en = to_IF_valid && IF_allow_in;
  49. assign inst_sram_addr = nextpc;
  50. assign IF_inst = inst_sram_rdata;
  51. assign inst_sram_we = 4'b0;
  52. assign inst_sram_wdata = 32'b0;
  53. endmodule

ID stage

  1. `timescale 1ns / 1ps
  2. //
  3. // Company:
  4. // Engineer:
  5. //
  6. // Create Date: 2024/05/29 10:44:41
  7. // Design Name:
  8. // Module Name: ID_stage
  9. // Project Name:
  10. // Target Devices:
  11. // Tool Versions:
  12. // Description:
  13. //
  14. // Dependencies:
  15. //
  16. // Revision:
  17. // Revision 0.01 - File Created
  18. // Additional Comments:
  19. //
  20. //
  21. module ID_stage(
  22. input clk,
  23. input reset,
  24. input EX_allow_in,
  25. input IF_to_ID_valid,
  26. input [63:0]IF_ID_bus,
  27. input [37:0]WB_rf_bus,
  28. output ID_allow_in,
  29. output [32:0]br_bus,
  30. output [150:0]ID_EX_bus,
  31. output ID_to_EX_valid,
  32. output to_EX_inst_bl
  33. );
  34. reg [31:0] ID_pc;
  35. reg [31:0] ID_inst;
  36. reg ID_valid;
  37. wire ID_ready_go;
  38. reg delay_slot;
  39. wire [31:0] br_offs;
  40. wire [31:0] jirl_offs;
  41. wire src_reg_is_rd;
  42. wire dst_is_r1;
  43. wire [ 5:0] op_31_26;
  44. wire [ 3:0] op_25_22;
  45. wire [ 1:0] op_21_20;
  46. wire [ 4:0] op_19_15;
  47. wire [ 4:0] rd;
  48. wire [ 4:0] rj;
  49. wire [ 4:0] rk;
  50. wire [11:0] i12;
  51. wire [19:0] i20;
  52. wire [15:0] i16;
  53. wire [25:0] i26;
  54. wire rf_we ;
  55. wire [4:0]rf_waddr;
  56. wire [31:0]rf_wdata;
  57. wire [4:0]rf_raddr1;
  58. wire [31:0]rf_rdata1;
  59. wire [4:0]rf_raddr2;
  60. wire [31:0]rf_rdata2;
  61. wire [11:0] alu_op;
  62. wire src1_is_pc;
  63. wire src2_is_imm;
  64. wire src2_is_4;
  65. wire res_from_mem;
  66. wire gr_we;
  67. wire mem_we;
  68. wire [4: 0] dest;
  69. wire [31:0] rj_value;
  70. wire [31:0] rkd_value;
  71. wire [31:0] imm;
  72. wire br_taken;
  73. wire [31:0]br_target;
  74. wire [63:0] op_31_26_d;
  75. wire [15:0] op_25_22_d;
  76. wire [ 3:0] op_21_20_d;
  77. wire [31:0] op_19_15_d;
  78. wire inst_add_w;
  79. wire inst_sub_w;
  80. wire inst_slt;
  81. wire inst_sltu;
  82. wire inst_nor;
  83. wire inst_and;
  84. wire inst_or;
  85. wire inst_xor;
  86. wire inst_slli_w;
  87. wire inst_srli_w;
  88. wire inst_srai_w;
  89. wire inst_addi_w;
  90. wire inst_ld_w;
  91. wire inst_st_w;
  92. wire inst_jirl;
  93. wire inst_b;
  94. wire inst_bl;
  95. wire inst_beq;
  96. wire inst_bne;
  97. wire inst_lu12i_w;
  98. wire need_ui5;
  99. wire need_si12;
  100. wire need_si16;
  101. wire need_si20;
  102. wire need_si26;
  103. wire [31:0]alu_src1;
  104. wire [31:0]alu_src2;
  105. assign op_31_26 = ID_inst[31:26];
  106. assign op_25_22 = ID_inst[25:22];
  107. assign op_21_20 = ID_inst[21:20];
  108. assign op_19_15 = ID_inst[19:15];
  109. assign rd = ID_inst[ 4: 0];
  110. assign rj = ID_inst[ 9: 5];
  111. assign rk = ID_inst[14:10];
  112. assign i12 = ID_inst[21:10];
  113. assign i20 = ID_inst[24: 5];
  114. assign i16 = ID_inst[25:10];
  115. assign i26 = {ID_inst[ 9: 0], ID_inst[25:10]};
  116. decoder_6_64 u_dec0(.in(op_31_26 ), .out(op_31_26_d ));
  117. decoder_4_16 u_dec1(.in(op_25_22 ), .out(op_25_22_d ));
  118. decoder_2_4 u_dec2(.in(op_21_20 ), .out(op_21_20_d ));
  119. decoder_5_32 u_dec3(.in(op_19_15 ), .out(op_19_15_d ));
  120. assign inst_add_w = op_31_26_d[6'h00] & op_25_22_d[4'h0] & op_21_20_d[2'h1] & op_19_15_d[5'h00];
  121. assign inst_sub_w = op_31_26_d[6'h00] & op_25_22_d[4'h0] & op_21_20_d[2'h1] & op_19_15_d[5'h02];
  122. assign inst_slt = op_31_26_d[6'h00] & op_25_22_d[4'h0] & op_21_20_d[2'h1] & op_19_15_d[5'h04];
  123. assign inst_sltu = op_31_26_d[6'h00] & op_25_22_d[4'h0] & op_21_20_d[2'h1] & op_19_15_d[5'h05];
  124. assign inst_nor = op_31_26_d[6'h00] & op_25_22_d[4'h0] & op_21_20_d[2'h1] & op_19_15_d[5'h08];
  125. assign inst_and = op_31_26_d[6'h00] & op_25_22_d[4'h0] & op_21_20_d[2'h1] & op_19_15_d[5'h09];
  126. assign inst_or = op_31_26_d[6'h00] & op_25_22_d[4'h0] & op_21_20_d[2'h1] & op_19_15_d[5'h0a];
  127. assign inst_xor = op_31_26_d[6'h00] & op_25_22_d[4'h0] & op_21_20_d[2'h1] & op_19_15_d[5'h0b];
  128. assign inst_slli_w = op_31_26_d[6'h00] & op_25_22_d[4'h1] & op_21_20_d[2'h0] & op_19_15_d[5'h01];
  129. assign inst_srli_w = op_31_26_d[6'h00] & op_25_22_d[4'h1] & op_21_20_d[2'h0] & op_19_15_d[5'h09];
  130. assign inst_srai_w = op_31_26_d[6'h00] & op_25_22_d[4'h1] & op_21_20_d[2'h0] & op_19_15_d[5'h11];
  131. assign inst_addi_w = op_31_26_d[6'h00] & op_25_22_d[4'ha];
  132. assign inst_ld_w = op_31_26_d[6'h0a] & op_25_22_d[4'h2];
  133. assign inst_st_w = op_31_26_d[6'h0a] & op_25_22_d[4'h6];
  134. assign inst_jirl = op_31_26_d[6'h13];
  135. assign inst_b = op_31_26_d[6'h14];
  136. assign inst_bl = op_31_26_d[6'h15];
  137. assign inst_beq = op_31_26_d[6'h16];
  138. assign inst_bne = op_31_26_d[6'h17];
  139. assign inst_lu12i_w= op_31_26_d[6'h05] & ~ID_inst[25];
  140. assign to_EX_inst_bl = inst_bl;
  141. assign alu_op[ 0] = inst_add_w | inst_addi_w | inst_ld_w | inst_st_w
  142. | inst_jirl | inst_bl;
  143. assign alu_op[ 1] = inst_sub_w;
  144. assign alu_op[ 2] = inst_slt;
  145. assign alu_op[ 3] = inst_sltu;
  146. assign alu_op[ 4] = inst_and;
  147. assign alu_op[ 5] = inst_nor;
  148. assign alu_op[ 6] = inst_or;
  149. assign alu_op[ 7] = inst_xor;
  150. assign alu_op[ 8] = inst_slli_w;
  151. assign alu_op[ 9] = inst_srli_w;
  152. assign alu_op[10] = inst_srai_w;
  153. assign alu_op[11] = inst_lu12i_w;
  154. assign need_ui5 = inst_slli_w | inst_srli_w | inst_srai_w;
  155. assign need_si12 = inst_addi_w | inst_ld_w | inst_st_w;
  156. assign need_si16 = inst_jirl | inst_beq | inst_bne;
  157. assign need_si20 = inst_lu12i_w;
  158. assign need_si26 = inst_b | inst_bl;
  159. assign src2_is_4 = inst_jirl | inst_bl;
  160. assign imm = src2_is_4 ? 32'h4 :
  161. need_si20 ? {i20[19:0], 12'b0} :
  162. /*need_ui5 || need_si12*/{{20{i12[11]}}, i12[11:0]} ;
  163. assign br_offs = need_si26 ? {{ 4{i26[25]}}, i26[25:0], 2'b0} :
  164. {{14{i16[15]}}, i16[15:0], 2'b0} ;
  165. assign jirl_offs = {{14{i16[15]}}, i16[15:0], 2'b0};
  166. assign src_reg_is_rd = inst_beq | inst_bne | inst_st_w;
  167. assign src1_is_pc = inst_jirl | inst_bl;
  168. assign src2_is_imm = inst_slli_w |
  169. inst_srli_w |
  170. inst_srai_w |
  171. inst_addi_w |
  172. inst_ld_w |
  173. inst_st_w |
  174. inst_lu12i_w|
  175. inst_jirl |
  176. inst_bl ;
  177. assign res_from_mem = inst_ld_w;
  178. assign dst_is_r1 = inst_bl;
  179. assign gr_we = ~inst_st_w & ~inst_beq & ~inst_bne & ~inst_b;
  180. assign mem_we = inst_st_w;
  181. assign dest = dst_is_r1 ? 5'd1 : rd;
  182. assign rf_raddr1 = rj;
  183. assign rf_raddr2 = src_reg_is_rd ? rd :rk;
  184. assign {rf_we, rf_waddr, rf_wdata} = WB_rf_bus;
  185. regfile u_regfile(
  186. .clk (clk ),
  187. .raddr1 (rf_raddr1),
  188. .rdata1 (rf_rdata1),
  189. .raddr2 (rf_raddr2),
  190. .rdata2 (rf_rdata2),
  191. .we (rf_we ),
  192. .waddr (rf_waddr ),
  193. .wdata (rf_wdata )
  194. );
  195. assign rj_value = rf_rdata1;
  196. assign rkd_value = rf_rdata2;
  197. assign ID_EX_bus = {
  198. ID_pc,//150:119
  199. alu_op,//118:107
  200. src2_is_4,//106
  201. src1_is_pc,//105
  202. src2_is_imm,//104
  203. gr_we,//103
  204. mem_we,//102
  205. dest,//101:97
  206. imm,//96:65
  207. rj_value,//64:33
  208. rkd_value,//32:1
  209. res_from_mem //0:0
  210. };
  211. assign rj_eq_rd = (rj_value == rkd_value);
  212. assign br_taken = ( inst_beq && rj_eq_rd
  213. || inst_bne && !rj_eq_rd
  214. || inst_jirl
  215. || inst_bl
  216. || inst_b
  217. ) && ID_valid;
  218. assign br_target = (inst_beq || inst_bne || inst_bl || inst_b) ? (ID_pc + br_offs) :
  219. /*inst_jirl*/ (rj_value + jirl_offs);
  220. assign br_bus = {br_taken,//32
  221. br_target //31:0
  222. };
  223. assign ID_ready_go = 1'b1;
  224. assign ID_allow_in = !ID_valid || ID_ready_go && EX_allow_in;
  225. assign ID_to_EX_valid = ID_valid && ID_ready_go && !delay_slot;
  226. always @(posedge clk) begin
  227. if (reset) begin
  228. ID_valid <= 1'b0;
  229. delay_slot <= 1'b0;
  230. end
  231. else if (ID_allow_in) begin
  232. ID_valid <= IF_to_ID_valid;
  233. end
  234. if (IF_to_ID_valid && ID_allow_in) begin
  235. {ID_pc,ID_inst} <= IF_ID_bus;
  236. if (br_taken) begin
  237. delay_slot <= 1'b1;
  238. end else begin
  239. delay_slot <=1'b0;
  240. end
  241. end
  242. end
  243. endmodule

EX stage

  1. module EX_stage(
  2. input clk,
  3. input reset,
  4. input MEM_allow_in,
  5. input ID_to_EX_valid,
  6. output EX_allow_in,
  7. input [150:0]ID_EX_bus,
  8. input inst_bl,
  9. output [70:0]EX_MEM_bus,
  10. output EX_to_MEM_valid,
  11. output data_sram_en,
  12. output [ 3:0] data_sram_we,
  13. output [31:0] data_sram_addr,
  14. output [31:0] data_sram_wdata
  15. );
  16. reg [31:0] EX_pc;
  17. reg EX_valid;
  18. wire EX_ready_go;
  19. reg [11:0] EX_alu_op;
  20. reg EX_src1_is_pc;
  21. reg EX_src2_is_imm;
  22. reg EX_src2_is_4;
  23. reg EX_res_from_mem;
  24. reg EX_gr_we;
  25. reg EX_mem_we;
  26. reg [4: 0] EX_dest;
  27. reg [31:0] EX_rj_value;
  28. reg [31:0] EX_rkd_value;
  29. reg [31:0] EX_imm;
  30. wire [31:0] alu_result;
  31. reg EX_inst_bl;
  32. wire [31:0] alu_src1;
  33. wire [31:0] alu_src2;
  34. assign EX_ready_go = 1'b1;
  35. assign EX_allow_in = !EX_valid || EX_ready_go && MEM_allow_in;
  36. assign EX_to_MEM_valid = EX_valid && EX_ready_go;
  37. assign EX_MEM_bus = {
  38. EX_pc,//70:39
  39. EX_gr_we,//38
  40. EX_dest,//37:33
  41. alu_result,//32:1
  42. EX_res_from_mem//0
  43. };
  44. always @(posedge clk) begin
  45. if (reset) begin
  46. EX_valid <= 1'b0;
  47. end
  48. else if (EX_allow_in) begin
  49. EX_valid <= ID_to_EX_valid;
  50. end
  51. if (ID_to_EX_valid && EX_allow_in) begin
  52. {EX_pc ,
  53. EX_alu_op ,
  54. EX_src2_is_4,
  55. EX_src1_is_pc,
  56. EX_src2_is_imm,
  57. EX_gr_we,
  58. EX_mem_we,
  59. EX_dest,
  60. EX_imm,
  61. EX_rj_value,
  62. EX_rkd_value,
  63. EX_res_from_mem} <= ID_EX_bus;
  64. EX_inst_bl <= inst_bl;
  65. end
  66. end
  67. alu u_alu(
  68. .alu_op (EX_alu_op ),
  69. .alu_src1 (alu_src1 ),
  70. .alu_src2 (alu_src2 ),
  71. .alu_result (alu_result)
  72. );
  73. assign alu_src1 = EX_src1_is_pc ? EX_pc : EX_rj_value;
  74. assign alu_src2 = EX_src2_is_imm ? EX_imm : (EX_inst_bl ? 32'd4 : EX_rkd_value);
  75. assign data_sram_en = 1'b1;
  76. assign data_sram_we = EX_mem_we && EX_valid ? 4'b1111 : 4'b0000;
  77. assign data_sram_addr = alu_result;
  78. assign data_sram_wdata = EX_rkd_value;
  79. endmodule

MEM stage

  1. module MEM_stage(
  2. input clk,
  3. input reset,
  4. input WB_allow_in,
  5. output MEM_allow_in,
  6. input [70:0]EX_MEM_bus,
  7. input [31:0] data_sram_rdata,
  8. input EX_to_MEM_valid,
  9. output MEM_to_WB_valid,
  10. output [69:0]MEM_WB_bus
  11. );
  12. reg [31:0] MEM_pc;
  13. reg MEM_res_from_mem;
  14. reg MEM_gr_we;
  15. reg [4:0]MEM_dest;
  16. reg [31:0]MEM_alu_result;
  17. wire [31:0] MEM_final_result;
  18. wire [31:0] MEM_result;
  19. reg MEM_valid;
  20. wire MEM_ready_go;
  21. assign MEM_ready_go = 1'b1;
  22. assign MEM_allow_in = !MEM_valid || MEM_ready_go && WB_allow_in;
  23. assign MEM_to_WB_valid = MEM_valid && MEM_ready_go;
  24. always @(posedge clk) begin
  25. if (reset) begin
  26. MEM_valid <= 1'b0;
  27. end
  28. else if (MEM_allow_in) begin
  29. MEM_valid <= EX_to_MEM_valid;
  30. end
  31. if (EX_to_MEM_valid && MEM_allow_in) begin
  32. {MEM_pc ,
  33. MEM_gr_we ,
  34. MEM_dest,
  35. MEM_alu_result,
  36. MEM_res_from_mem } <= EX_MEM_bus;
  37. end
  38. end
  39. assign MEM_result = data_sram_rdata;
  40. assign MEM_final_result = MEM_res_from_mem ? MEM_result : MEM_alu_result;
  41. assign MEM_WB_bus = {
  42. MEM_pc,//69:38
  43. MEM_gr_we,//37
  44. MEM_dest,// 36:32
  45. MEM_final_result//31:0
  46. };
  47. endmodule

WB stage

  1. module WB_stage(
  2. input clk,
  3. input reset,
  4. output WB_allow_in,
  5. input MEM_to_WB_valid,
  6. input [69:0] MEM_WB_bus,
  7. output [37:0] WB_rf_bus,
  8. output [31:0] debug_wb_pc,
  9. output [ 3:0] debug_wb_rf_we,
  10. output [ 4:0] debug_wb_rf_wnum,
  11. output [31:0] debug_wb_rf_wdata
  12. );
  13. reg [31:0] WB_pc;
  14. reg WB_valid;
  15. wire WB_ready_go;
  16. reg WB_gr_we;
  17. reg [4:0]WB_dest;
  18. reg [31:0]WB_final_result;
  19. wire rf_we ;
  20. wire [4:0]rf_waddr;
  21. wire [31:0]rf_wdata;
  22. assign WB_ready_go = 1'b1;
  23. assign WB_allow_in = !WB_valid || WB_ready_go;
  24. always @(posedge clk) begin
  25. if (reset) begin
  26. WB_valid <= 1'b0;
  27. end
  28. else if (WB_allow_in) begin
  29. WB_valid <= MEM_to_WB_valid;
  30. end
  31. if (MEM_to_WB_valid && WB_allow_in) begin
  32. {WB_pc,
  33. WB_gr_we,
  34. WB_dest,
  35. WB_final_result} <= MEM_WB_bus;
  36. end
  37. end
  38. assign rf_we = WB_gr_we && WB_valid;
  39. assign rf_waddr = WB_dest;
  40. assign rf_wdata = WB_final_result;
  41. assign WB_rf_bus = {rf_we,//37
  42. rf_waddr,//36:32
  43. rf_wdata//31:0
  44. };
  45. assign debug_wb_pc = rf_we ? WB_pc : debug_wb_pc;
  46. assign debug_wb_rf_we = {4{rf_we}};
  47. assign debug_wb_rf_wnum = WB_valid && rf_we ? WB_dest : debug_wb_rf_wnum;
  48. assign debug_wb_rf_wdata = WB_valid && rf_we ? WB_final_result : debug_wb_rf_wdata;
  49. endmodule

mycpu top

  1. module mycpu_top(
  2. input wire clk,
  3. input wire resetn,
  4. // inst sram interface
  5. output wire inst_sram_en,
  6. output wire [ 3:0] inst_sram_we,
  7. output wire [31:0] inst_sram_addr,
  8. output wire [31:0] inst_sram_wdata,
  9. input wire [31:0] inst_sram_rdata,
  10. // data sram interface
  11. output wire data_sram_en,
  12. output wire [ 3:0] data_sram_we,
  13. output wire [31:0] data_sram_addr,
  14. output wire [31:0] data_sram_wdata,
  15. input wire [31:0] data_sram_rdata,
  16. // trace debug interface
  17. output wire [31:0] debug_wb_pc,
  18. output wire [ 3:0] debug_wb_rf_we,
  19. output wire [ 4:0] debug_wb_rf_wnum,
  20. output wire [31:0] debug_wb_rf_wdata
  21. );
  22. reg reset;
  23. always @(posedge clk) reset <= ~resetn;
  24. // allow_in
  25. wire ID_allow_in;
  26. wire EX_allow_in;
  27. wire MEM_allow_in;
  28. wire WB_allow_in;
  29. //bus
  30. wire [63:0]IF_ID_bus;
  31. wire [150:0]ID_EX_bus;
  32. wire [70:0]EX_MEM_bus;
  33. wire [69:0]MEM_WB_bus;
  34. wire [32:0]br_bus;
  35. wire [37:0]WB_rf_bus;
  36. //valid
  37. wire IF_to_ID_valid;
  38. wire ID_to_EX_valid;
  39. wire EX_to_MEM_valid;
  40. wire MEM_to_WB_valid;
  41. //inst_bl
  42. wire inst_bl;
  43. IF_stage IF(
  44. .clk(clk),
  45. .reset(reset),
  46. .ID_allow_in(ID_allow_in),
  47. .br_bus(br_bus),
  48. .inst_sram_en(inst_sram_en),
  49. .inst_sram_we(inst_sran_we),
  50. .inst_sram_addr(inst_sram_addr),
  51. .inst_sram_wdata(inst_sram_wdata),
  52. .inst_sram_rdata(inst_sram_rdata),
  53. .IF_ID_bus(IF_ID_bus),
  54. .IF_to_ID_valid(IF_to_ID_valid)
  55. );
  56. ID_stage ID(
  57. .clk(clk),
  58. .reset(reset),
  59. .EX_allow_in(EX_allow_in),
  60. .IF_to_ID_valid(IF_to_ID_valid),
  61. .IF_ID_bus(IF_ID_bus),
  62. .WB_rf_bus(WB_rf_bus),
  63. .ID_allow_in(ID_allow_in),
  64. .br_bus(br_bus),
  65. .ID_EX_bus(ID_EX_bus),
  66. .ID_to_EX_valid(ID_to_EX_valid),
  67. .to_EX_inst_bl(inst_bl)
  68. );
  69. EX_stage EX(
  70. .clk(clk),
  71. .reset(reset),
  72. .MEM_allow_in(MEM_allow_in),
  73. .ID_to_EX_valid(ID_to_EX_valid),
  74. .EX_allow_in(EX_allow_in),
  75. .ID_EX_bus(ID_EX_bus),
  76. .inst_bl(inst_bl),
  77. .EX_MEM_bus(EX_MEM_bus),
  78. .EX_to_MEM_valid(EX_to_MEM_valid),
  79. .data_sram_en(data_sram_en),
  80. .data_sram_we(data_sram_we),
  81. .data_sram_addr(data_sram_addr),
  82. .data_sram_wdata(data_sram_wdata)
  83. );
  84. MEM_stage MEM(
  85. .clk(clk),
  86. .reset(reset),
  87. .WB_allow_in(WB_allow_in),
  88. .MEM_allow_in(MEM_allow_in),
  89. .EX_MEM_bus(EX_MEM_bus),
  90. .data_sram_rdata(data_sram_rdata),
  91. .EX_to_MEM_valid(EX_to_MEM_valid),
  92. .MEM_to_WB_valid(MEM_to_WB_valid),
  93. .MEM_WB_bus(MEM_WB_bus)
  94. );
  95. WB_stage WB(
  96. .clk(clk),
  97. .reset(reset),
  98. .WB_allow_in(WB_allow_in),
  99. .MEM_to_WB_valid(MEM_to_WB_valid),
  100. .MEM_WB_bus(MEM_WB_bus),
  101. .WB_rf_bus(WB_rf_bus),
  102. .debug_wb_pc(debug_wb_pc) ,
  103. .debug_wb_rf_we(debug_wb_rf_we),
  104. .debug_wb_rf_wnum(debug_wb_rf_wnum),
  105. .debug_wb_rf_wdata(debug_wb_rf_wdata)
  106. );
  107. endmodule

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/码创造者/article/detail/942004
推荐阅读
相关标签
  

闽ICP备14008679号