3 module System(input clk, output wire bubbleshield, output wire [31:0] insn, output wire [31:0] pc);
13 assign bus_req = {7'b0, bus_req_icache};
14 wire bus_ack_icache = bus_ack[`BUS_ICACHE];
16 wire [31:0] bus_addr_icache;
17 wire [31:0] bus_wdata_icache;
21 wire [31:0] bus_rdata_blockram;
22 wire bus_ready_blockram;
24 assign bus_addr = bus_addr_icache;
25 assign bus_rdata = bus_rdata_blockram;
26 assign bus_wdata = bus_wdata_icache;
27 assign bus_rd = bus_rd_icache;
28 assign bus_wr = bus_wr_icache;
29 assign bus_ready = bus_ready_blockram;
31 wire [31:0] icache_rd_addr;
34 wire [31:0] icache_rd_data;
36 wire stall_cause_issue;
37 wire stall_cause_execute;
39 wire [31:0] decode_out_op0, decode_out_op1, decode_out_op2;
40 wire decode_out_carry;
41 wire [3:0] regfile_read_0, regfile_read_1, regfile_read_2;
42 wire [31:0] regfile_rdata_0, regfile_rdata_1, regfile_rdata_2;
43 wire execute_out_stall, execute_out_bubble;
44 wire execute_out_write_reg;
45 wire [3:0] execute_out_write_num;
46 wire [31:0] execute_out_write_data;
48 wire bubble_out_fetch;
49 wire bubble_out_issue;
50 wire [31:0] insn_out_fetch;
51 wire [31:0] insn_out_issue;
52 wire [31:0] pc_out_fetch;
53 wire [31:0] pc_out_issue;
55 assign bubbleshield = bubble_out_issue;
56 assign insn = insn_out_issue;
57 assign pc = pc_out_issue;
59 BusArbiter busarbiter(.bus_req(bus_req), .bus_ack(bus_ack));
64 .rd_addr(icache_rd_addr), .rd_req(icache_rd_req),
65 .rd_wait(icache_rd_wait), .rd_data(icache_rd_data),
66 .bus_req(bus_req_icache), .bus_ack(bus_ack_icache),
67 .bus_addr(bus_addr_icache), .bus_rdata(bus_rdata),
68 .bus_wdata(bus_wdata_icache), .bus_rd(bus_rd_icache),
69 .bus_wr(bus_wr_icache), .bus_ready(bus_ready));
73 .bus_addr(bus_addr), .bus_rdata(bus_rdata_blockram),
74 .bus_wdata(bus_wdata), .bus_rd(bus_rd), .bus_wr(bus_wr),
75 .bus_ready(bus_ready_blockram));
80 .rd_addr(icache_rd_addr), .rd_req(icache_rd_req),
81 .rd_wait(icache_rd_wait), .rd_data(icache_rd_data),
82 .stall(stall_cause_issue), .jmp(0 /* XXX */), .jmppc(0 /* XXX */),
83 .bubble(bubble_out_fetch), .insn(insn_out_fetch),
89 .stall(stall_cause_execute), .flush(0 /* XXX */),
90 .inbubble(bubble_out_fetch), .insn(insn_out_fetch),
91 .inpc(pc_out_fetch), .cpsr(0 /* XXX */),
92 .outstall(stall_cause_issue), .outbubble(bubble_out_issue),
93 .outpc(pc_out_issue), .outinsn(insn_out_issue));
97 .read_0(regfile_read_0), .read_1(regfile_read_1), .read_2(regfile_read_2),
98 .rdata_0(regfile_rdata_0), .rdata_1(regfile_rdata_1), .rdata_2(regfile_rdata_2),
99 .write(0), .write_req(0), .write_data(0 /* XXX */));
103 .insn(insn_out_fetch), .inpc(pc_out_fetch), .incpsr(0 /* XXX */),
104 .op0(decode_out_op0), .op1(decode_out_op1), .op2(decode_out_op2),
105 .carry(decode_out_carry),
106 .read_0(regfile_read_0), .read_1(regfile_read_1), .read_2(regfile_read_2),
107 .rdata_0(regfile_rdata_0), .rdata_1(regfile_rdata_1), .rdata_2(regfile_rdata_2));
111 .stall(0 /* XXX */), .flush(0 /* XXX */),
112 .inbubble(bubble_out_issue), .pc(pc_out_issue), .insn(insn_out_issue),
113 .cpsr(0 /* XXX */), .op0(decode_out_op0), .op1(decode_out_op1),
114 .op2(decode_out_op2), .carry(decode_out_carry),
115 .outstall(stall_cause_execute), .outbubble(execute_out_bubble),
116 .write_reg(execute_out_write_reg), .write_num(execute_out_write_num),
117 .write_data(execute_out_write_data));
119 reg [31:0] clockno = 0;
120 always @(posedge clk)
122 clockno <= clockno + 1;
123 $display("------------------------------------------------------------------------------");
124 $display("%3d: FETCH: Bubble: %d, Instruction: %08x, PC: %08x", clockno, bubble_out_fetch, insn_out_fetch, pc_out_fetch);
125 $display("%3d: ISSUE: Stall: %d, Bubble: %d, Instruction: %08x, PC: %08x", clockno, stall_cause_issue, bubble_out_issue, insn_out_issue, pc_out_issue);
126 $display("%3d: DECODE: op1 %08x, op2 %08x, op3 %08x, carry %d", clockno, decode_out_op0, decode_out_op1, decode_out_op2, decode_out_carry);