rtl: add reset module

Signed-off-by: liangkangnan <liangkangnan@163.com>
pull/4/head
liangkangnan 2021-04-13 14:12:47 +08:00
parent 7803e89d68
commit 9ac1b31965
4 changed files with 32 additions and 34 deletions

View File

@ -18,7 +18,7 @@
../rtl/core/ifu.sv ../rtl/core/ifu.sv
../rtl/core/ifu_idu.sv ../rtl/core/ifu_idu.sv
../rtl/core/pipe_ctrl.sv ../rtl/core/pipe_ctrl.sv
../rtl/core/rst_ctrl.sv ../rtl/core/rst_gen.sv
../rtl/core/tinyriscv_core.sv ../rtl/core/tinyriscv_core.sv
../rtl/core/tracer.sv ../rtl/core/tracer.sv

View File

@ -17,43 +17,27 @@
`include "defines.sv" `include "defines.sv"
// 复位控制模块 // 复位控制模块
module rst_ctrl( module rst_gen #(
parameter RESET_FIFO_DEPTH = 5
)(
input wire clk, input wire clk,
input wire rst_ni,
input wire rst_ext_i, output wire rst_no
input wire rst_jtag_i,
output wire core_rst_n_o,
output wire jtag_rst_n_o
); );
wire ext_rst_r; reg[RESET_FIFO_DEPTH-1:0] synch_regs_q;
gen_ticks_sync #( always @ (posedge clk or negedge rst_ni) begin
.DP(2), if (~rst_ni) begin
.DW(1) synch_regs_q <= 0;
) ext_rst_sync(
.rst_n(rst_ext_i),
.clk(clk),
.din(1'b1),
.dout(ext_rst_r)
);
reg[`JTAG_RESET_FF_LEVELS-1:0] jtag_rst_r;
always @ (posedge clk) begin
if (!rst_ext_i) begin
jtag_rst_r[`JTAG_RESET_FF_LEVELS-1:0] <= {`JTAG_RESET_FF_LEVELS{1'b1}};
end if (rst_jtag_i) begin
jtag_rst_r[`JTAG_RESET_FF_LEVELS-1:0] <= {`JTAG_RESET_FF_LEVELS{1'b0}};
end else begin end else begin
jtag_rst_r[`JTAG_RESET_FF_LEVELS-1:0] <= {jtag_rst_r[`JTAG_RESET_FF_LEVELS-2:0], 1'b1}; synch_regs_q <= {synch_regs_q[RESET_FIFO_DEPTH-2:0], 1'b1};
end end
end end
assign core_rst_n_o = ext_rst_r & jtag_rst_r[`JTAG_RESET_FF_LEVELS-1]; assign rst_no = synch_regs_q[RESET_FIFO_DEPTH-1];
assign jtag_rst_n_o = ext_rst_r;
endmodule endmodule

View File

@ -20,7 +20,7 @@
module tinyriscv_soc_top( module tinyriscv_soc_top(
input wire clk, input wire clk,
input wire rst_ext_i, input wire rst_ext_ni,
output wire halted_ind, // jtag是否已经halt住CPU信号 output wire halted_ind, // jtag是否已经halt住CPU信号
@ -69,13 +69,17 @@ module tinyriscv_soc_top(
wire [31:0] slave_addr_mask [SLAVES]; wire [31:0] slave_addr_mask [SLAVES];
wire [31:0] slave_addr_base [SLAVES]; wire [31:0] slave_addr_base [SLAVES];
wire ndmreset;
wire ndmreset_n;
assign ndmreset = 1'b0;
tinyriscv_core #( tinyriscv_core #(
.DEBUG_HALT_ADDR(`DEBUG_ADDR_BASE + 16'h800), .DEBUG_HALT_ADDR(`DEBUG_ADDR_BASE + 16'h800),
.DEBUG_EXCEPTION_ADDR(`DEBUG_ADDR_BASE + 16'h808) .DEBUG_EXCEPTION_ADDR(`DEBUG_ADDR_BASE + 16'h808)
) u_tinyriscv_core ( ) u_tinyriscv_core (
.clk(clk), .clk(clk),
.rst_n(rst_ext_i), .rst_n(ndmreset_n),
.instr_req_o(master_req[CoreI]), .instr_req_o(master_req[CoreI]),
.instr_gnt_i(master_gnt[CoreI]), .instr_gnt_i(master_gnt[CoreI]),
@ -111,7 +115,7 @@ module tinyriscv_soc_top(
.DP(`ROM_DEPTH) .DP(`ROM_DEPTH)
) u_rom( ) u_rom(
.clk(clk), .clk(clk),
.rst_n(rst_ext_i), .rst_n(ndmreset_n),
.addr_i(slave_addr[Rom]), .addr_i(slave_addr[Rom]),
.data_i(slave_wdata[Rom]), .data_i(slave_wdata[Rom]),
.sel_i(slave_be[Rom]), .sel_i(slave_be[Rom]),
@ -126,7 +130,7 @@ module tinyriscv_soc_top(
.DP(`RAM_DEPTH) .DP(`RAM_DEPTH)
) u_ram( ) u_ram(
.clk(clk), .clk(clk),
.rst_n(rst_ext_i), .rst_n(ndmreset_n),
.addr_i(slave_addr[Ram]), .addr_i(slave_addr[Ram]),
.data_i(slave_wdata[Ram]), .data_i(slave_wdata[Ram]),
.sel_i(slave_be[Ram]), .sel_i(slave_be[Ram]),
@ -139,7 +143,7 @@ module tinyriscv_soc_top(
.SLAVES(SLAVES) .SLAVES(SLAVES)
) bus ( ) bus (
.clk_i(clk), .clk_i(clk),
.rst_ni(rst_ext_i), .rst_ni(ndmreset_n),
.master_req_i(master_req), .master_req_i(master_req),
.master_gnt_o(master_gnt), .master_gnt_o(master_gnt),
.master_rvalid_o(master_rvalid), .master_rvalid_o(master_rvalid),
@ -160,4 +164,14 @@ module tinyriscv_soc_top(
.slave_rdata_i(slave_rdata) .slave_rdata_i(slave_rdata)
); );
rst_gen #(
.RESET_FIFO_DEPTH(5)
) u_rst (
.clk(clk),
.rst_ni(rst_ext_ni & (~ndmreset)),
.rst_no(ndmreset_n)
);
endmodule endmodule

View File

@ -68,7 +68,7 @@ module tb_top_verilator #(
tinyriscv_soc_top u_tinyriscv_soc_top( tinyriscv_soc_top u_tinyriscv_soc_top(
.clk(clk_i), .clk(clk_i),
.rst_ext_i(rst_ni) .rst_ext_ni(rst_ni)
); );
endmodule // tb_top_verilator endmodule // tb_top_verilator