2021-05-14 06:37:47 +00:00
|
|
|
/*
|
|
|
|
Copyright 2021 Blue Liang, liangkangnan@163.com
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
`define REG_CTRL 0
|
|
|
|
`define REG_PRINT 4
|
2021-08-20 03:50:21 +00:00
|
|
|
`define REG_DUMP 8
|
2021-05-14 06:37:47 +00:00
|
|
|
|
|
|
|
module sim_ctrl(
|
|
|
|
input logic clk_i,
|
|
|
|
input logic rst_ni,
|
|
|
|
|
2021-08-20 03:50:21 +00:00
|
|
|
output logic dump_wave_en_o,
|
|
|
|
|
2021-05-14 06:37:47 +00:00
|
|
|
input logic req_i,
|
|
|
|
output logic gnt_o,
|
|
|
|
input logic[31:0] addr_i,
|
|
|
|
input logic we_i,
|
|
|
|
input logic[3:0] be_i,
|
|
|
|
input logic[31:0] wdata_i,
|
2021-09-01 01:54:32 +00:00
|
|
|
output logic rvalid_o,
|
2021-05-14 06:37:47 +00:00
|
|
|
output logic[31:0] rdata_o
|
|
|
|
);
|
|
|
|
|
|
|
|
logic[7:0] reg_addr;
|
|
|
|
|
|
|
|
assign reg_addr = {addr_i[7:2], 2'b0};
|
|
|
|
assign gnt_o = req_i;
|
|
|
|
|
|
|
|
assign rdata_o = 32'h0;
|
|
|
|
|
|
|
|
always_ff @ (posedge clk_i or negedge rst_ni) begin
|
|
|
|
if (!rst_ni) begin
|
2021-08-20 03:50:21 +00:00
|
|
|
dump_wave_en_o <= 1'b0;
|
2021-09-01 01:54:32 +00:00
|
|
|
rvalid_o <= 1'b0;
|
2021-05-14 06:37:47 +00:00
|
|
|
end else begin
|
2021-09-01 01:54:32 +00:00
|
|
|
rvalid_o <= req_i;
|
|
|
|
if (req_i & we_i) begin
|
2021-05-14 06:37:47 +00:00
|
|
|
case (reg_addr)
|
|
|
|
`REG_CTRL: begin
|
|
|
|
if (be_i[0] & wdata_i[0]) begin
|
|
|
|
$display("sim finish...");
|
|
|
|
$finish;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
`REG_PRINT: begin
|
|
|
|
if (be_i[0]) begin
|
|
|
|
$display("%c", wdata_i[7:0]);
|
|
|
|
end
|
|
|
|
end
|
2021-08-20 03:50:21 +00:00
|
|
|
|
|
|
|
`REG_DUMP: begin
|
|
|
|
if (be_i[0] & wdata_i[0]) begin
|
|
|
|
dump_wave_en_o <= 1'b1;
|
|
|
|
end else if (be_i[0] & (!wdata_i[0])) begin
|
|
|
|
dump_wave_en_o <= 1'b0;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
default: ;
|
2021-05-14 06:37:47 +00:00
|
|
|
endcase
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
endmodule
|