cariboulabs-cariboulite/firmware/sys_ctrl.v

81 wiersze
2.5 KiB
Coq
Czysty Zwykły widok Historia

2021-06-13 11:45:08 +00:00
module sys_ctrl
(
input i_rst_b, // FPGA Reset
input i_sys_clk, // FPGA Clock
input [4:0] i_ioc,
input [7:0] i_data_in,
output reg [7:0] o_data_out,
input i_cs,
input i_fetch_cmd,
2021-07-14 13:11:06 +00:00
input i_load_cmd,
output reg o_soft_reset );
2021-06-13 11:45:08 +00:00
// MODULE SPECIFIC IOC LIST
// ------------------------
localparam
ioc_module_version = 5'b00000, // read only
ioc_system_version = 5'b00001, // read only
2021-07-14 13:11:06 +00:00
ioc_manu_id = 5'b00010, // read only
ioc_error_state = 5'b00011, // read only
ioc_soft_reset = 5'b00100; // write only
2021-06-13 11:45:08 +00:00
// MODULE SPECIFIC PARAMS
// ----------------------
localparam
module_version = 8'b00000001,
system_version = 8'b00000001,
manu_id = 8'b00000001;
2021-07-14 13:11:06 +00:00
reg [3:0] reset_count;
2021-06-13 11:45:08 +00:00
always @(posedge i_sys_clk)
begin
if (i_cs == 1'b1) begin
2021-07-14 13:11:06 +00:00
//=============================================
// READ OPERATIONS
//=============================================
2021-06-13 11:45:08 +00:00
if (i_fetch_cmd == 1'b1) begin
case (i_ioc)
ioc_module_version: o_data_out <= module_version;
ioc_system_version: o_data_out <= system_version;
ioc_manu_id: o_data_out <= manu_id;
2021-07-14 13:11:06 +00:00
ioc_error_state: o_data_out <= 8'b00000000;
2021-06-13 11:45:08 +00:00
endcase
end
2021-07-14 13:11:06 +00:00
//=============================================
// WRITE OPERATIONS
//=============================================
else if (i_load_cmd == 1'b1) begin
2021-07-14 18:27:55 +00:00
case (i_ioc)
ioc_soft_reset: begin reset_cmd <= 1'b1; end
endcase
2021-07-14 13:11:06 +00:00
end
2021-07-14 18:27:55 +00:00
end else begin
reset_cmd <= 1'b0;
2021-06-13 11:45:08 +00:00
end
end
2021-07-14 18:27:55 +00:00
reg reset_cmd;
2021-07-14 13:11:06 +00:00
// Reset state process
always @(posedge i_sys_clk)
begin
2021-07-14 18:27:55 +00:00
if (reset_cmd) begin
reset_count <= 0;
2021-07-14 13:11:06 +00:00
end else begin
2021-07-14 18:27:55 +00:00
if (reset_count < 4'd15) begin
reset_count <= reset_count + 1'b1;
o_soft_reset <= 1'b1;
end else if (reset_count == 4'd15) begin
reset_count <= reset_count;
o_soft_reset <= 1'b0;
end else begin
reset_count <= 0;
end
2021-07-14 13:11:06 +00:00
end
2021-07-14 18:27:55 +00:00
2021-07-14 13:11:06 +00:00
end
2021-06-13 11:45:08 +00:00
endmodule // sys_ctrl