Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flash-spoof mode to make large management-core programs run faster #7

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion verilog/dv/caravel/user_proj_example/io_ports/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ GCC_PATH?=/ef/apps/bin
GCC_PREFIX?=riscv32-unknown-elf
PDK_PATH?=/ef/tech/SW/sky130A

SPOOF_FAST_FLASH=

.SUFFIXES:

PATTERN = io_ports
Expand All @@ -15,8 +17,9 @@ all: ${PATTERN:=.vcd}

hex: ${PATTERN:=.hex}

spoof_var := $(if $(SPOOF_FAST_FLASH),-DSPOOF_FAST_FLASH=\"$(PATTERN).hex\",)
%.vvp: %_tb.v %.hex
iverilog -DFUNCTIONAL -I $(BEHAVIOURAL_MODELS) \
iverilog $(spoof_var) -DFUNCTIONAL -I $(BEHAVIOURAL_MODELS) \
-I $(PDK_PATH) -I $(IP_PATH) -I $(RTL_PATH) \
-o $@ $<

Expand Down
5 changes: 4 additions & 1 deletion verilog/dv/caravel/user_proj_example/la_test1/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ GCC_PATH?=/ef/apps/bin
GCC_PREFIX?=riscv32-unknown-elf
PDK_PATH?=/ef/tech/SW/sky130A

SPOOF_FAST_FLASH=

.SUFFIXES:

PATTERN = la_test1
Expand All @@ -15,8 +17,9 @@ all: ${PATTERN:=.vcd}

hex: ${PATTERN:=.hex}

spoof_var := $(if $(SPOOF_FAST_FLASH),-DSPOOF_FAST_FLASH=\"$(PATTERN).hex\",)
%.vvp: %_tb.v %.hex
iverilog -DFUNCTIONAL -I $(BEHAVIOURAL_MODELS) \
iverilog $(spoof_var) -DFUNCTIONAL -I $(BEHAVIOURAL_MODELS) \
-I $(PDK_PATH) -I $(IP_PATH) -I $(RTL_PATH) \
-o $@ $<

Expand Down
5 changes: 4 additions & 1 deletion verilog/dv/caravel/user_proj_example/la_test2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ GCC_PATH?=/ef/apps/bin
GCC_PREFIX?=riscv32-unknown-elf
PDK_PATH?=/ef/tech/SW/sky130A

SPOOF_FAST_FLASH=

.SUFFIXES:

PATTERN = la_test2
Expand All @@ -15,8 +17,9 @@ all: ${PATTERN:=.vcd}

hex: ${PATTERN:=.hex}

spoof_var := $(if $(SPOOF_FAST_FLASH),-DSPOOF_FAST_FLASH=\"$(PATTERN).hex\",)
%.vvp: %_tb.v %.hex
iverilog -DFUNCTIONAL -I $(BEHAVIOURAL_MODELS) \
iverilog $(spoof_var) -DFUNCTIONAL -I $(BEHAVIOURAL_MODELS) \
-I $(PDK_PATH) -I $(IP_PATH) -I $(RTL_PATH) \
-o $@ $<

Expand Down
64 changes: 64 additions & 0 deletions verilog/rtl/spimemio.v
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,69 @@ module spimemio_wb (
input flash_io3_di

);

`ifdef SPOOF_FAST_FLASH
assign wb_cfg_ack_o = 0;
assign wb_cfg_dat_o = 0;

assign pass_thru_sdo = 0;
assign flash_csb = 0;
assign flash_clk = 0;
assign flash_csb_oeb = 0;
assign flash_clk_oeb = 0;
assign flash_io0_oeb = 0;
assign flash_io1_oeb = 0;
assign flash_io2_oeb = 0;
assign flash_io3_oeb = 0;
assign flash_csb_ieb = 0;
assign flash_clk_ieb = 0;
assign flash_io0_ieb = 0;
assign flash_io1_ieb = 0;
assign flash_io2_ieb = 0;
assign flash_io3_ieb = 0;
assign flash_io0_do = 0;
assign flash_io1_do = 0;
assign flash_io2_do = 0;
assign flash_io3_do = 0;

// 16 MB (128Mb) Flash
reg [7:0] memory [0:16*1024*1024-1];

reg ack_reg;
reg [31:0] dat_reg;

assign wb_flash_ack_o = ack_reg;
assign wb_flash_dat_o = dat_reg;

wire [31:0] adr = {7'b0, wb_adr_i[23:0]};

initial begin
$display("============================================================");
$display("Spoofing flash from file %s", `SPOOF_FAST_FLASH);
$display("Warning: this is experimental and \ndoes not match exact hardware behavior");
$display("(assumes that flash base is a multiple of 0x1000000)");
$display("============================================================");
$readmemh(`SPOOF_FAST_FLASH, memory);
end

always @(posedge wb_clk_i) begin
if (wb_cyc_i & wb_cfg_stb_i) $error("wb_cfg_stb_i unsupported in SPOOF_FAST_FLASH mode. Please use normal flash emulation.");
if (pass_thru) $error("pass_thru unsupported in SPOOF_FAST_FLASH mode. Please use normal flash emulation.");

ack_reg <= 0;

if (wb_cyc_i & wb_flash_stb_i & ~wb_flash_ack_o) begin
ack_reg <= 1;
dat_reg <= {memory[adr+3], memory[adr+2], memory[adr+1], memory[adr+0]};

if (wb_we_i & wb_sel_i[0]) memory[adr+0] <= wb_dat_i[7:0];
if (wb_we_i & wb_sel_i[1]) memory[adr+1] <= wb_dat_i[15:8];
if (wb_we_i & wb_sel_i[2]) memory[adr+2] <= wb_dat_i[23:16];
if (wb_we_i & wb_sel_i[3]) memory[adr+3] <= wb_dat_i[31:24];
end
end

`else
wire spimem_ready;
wire [23:0] mem_addr;
wire [31:0] spimem_rdata;
Expand Down Expand Up @@ -141,6 +204,7 @@ module spimemio_wb (
.pass_thru_sdi(pass_thru_sdi),
.pass_thru_sdo(pass_thru_sdo)
);
`endif

endmodule

Expand Down