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 macros to disable Mem and SimJTAG DPI-C functions #259

Merged
merged 1 commit into from
Jan 18, 2024
Merged
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: 2 additions & 3 deletions palladium.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ PLDM_MACRO_FLAGS += +define+RANDOMIZE_DELAY=0
ifeq ($(RELEASE_WITH_ASSERT), 1)
PLDM_MACRO_FLAGS += +define+SYNTHESIS +define+TB_NO_DPIC
else
PLDM_MACRO_FLAGS += +define+DIFFTEST
PLDM_MACRO_FLAGS += +define+DIFFTEST +define+DISABLE_DIFFTEST_RAM_DPIC +define+DISABLE_SIMJTAG_DPIC
endif
PLDM_MACRO_FLAGS += $(PLDM_EXTRA_MACRO)

Expand All @@ -27,7 +27,7 @@ endif

# Compiler Args
IXCOM_FLAGS += -xecompile compilerOptions=$(PLDM_SCRIPTS_DIR)/compilerOptions.qel
IXCOM_FLAGS += +tb_import_systf+fwrite +tb_import_systf+fflush
IXCOM_FLAGS += +gfifoDisp+tb_top
IXCOM_FLAGS += $(addprefix -incdir , $(PLDM_VSRC_DIR))
IXCOM_FLAGS += $(PLDM_MACRO_FLAGS)
IXCOM_FLAGS += +dut+$(PLDM_TB_TOP)
Expand All @@ -40,7 +40,6 @@ endif

# Other Args
IXCOM_FLAGS += -v $(PLDM_IXCOM)/IXCclkgen.sv
IXCOM_FLAGS += +iscdisp+tb_top
ifneq ($(RELEASE_WITH_ASSERT), 1)
IXCOM_FLAGS += +rtlCommentPragma +tran_relax -relativeIXCDIR -rtlNameForGenerate
endif
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/common/Flash.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class FlashHelper extends ExtModule with HasExtModuleInline {
| end
|`else
|`ifdef PALLADIUM
| initial $ixc_ctrl("tb_import", "display");
| initial $ixc_ctrl("tb_import", "$display");
|`endif // PALLADIUM
| // 1K entries. 8KB size.
| `define FLASH_SIZE (8 * 1024)
Expand Down
31 changes: 20 additions & 11 deletions src/main/scala/common/Mem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import chisel3.util._
trait HasMemInit { this: ExtModule =>
val mem_init =
"""
|`ifdef SYNTHESIS
|`ifdef DISABLE_DIFFTEST_RAM_DPIC
|`ifdef PALLADIUM
| initial $ixc_ctrl("tb_import", "display");
| initial $ixc_ctrl("tb_import", "$display");
|`endif // PALLADIUM
| // 1536MB memory
| `define RAM_SIZE (1536 * 1024 * 1024)
Expand Down Expand Up @@ -56,7 +56,7 @@ trait HasMemInit { this: ExtModule =>
| $display("%m: load %d bytes from %s.", n_read, bin_file);
| end
|end
|`endif // SYNTHESIS
|`endif // DISABLE_DIFFTEST_RAM_DPIC
|""".stripMargin
}

Expand All @@ -69,9 +69,9 @@ trait HasReadPort { this: ExtModule =>

val r_dpic =
"""
|`ifndef SYNTHESIS
|`ifndef DISABLE_DIFFTEST_RAM_DPIC
|import "DPI-C" function longint difftest_ram_read(input longint rIdx);
|`endif // SYNTHESIS
|`endif // DISABLE_DIFFTEST_RAM_DPIC
|""".stripMargin

val r_if =
Expand All @@ -83,15 +83,15 @@ trait HasReadPort { this: ExtModule =>

val r_func =
"""
|`ifndef SYNTHESIS
|`ifndef DISABLE_DIFFTEST_RAM_DPIC
|if (r_enable) begin
| r_data <= difftest_ram_read(r_index);
|end
|`else
|if (r_enable) begin
| r_data <= memory[r_index];
|end
|`endif // SYNTHESIS
|`endif // DISABLE_DIFFTEST_RAM_DPIC
|""".stripMargin

def read(enable: Bool, index: UInt): UInt = {
Expand All @@ -112,14 +112,14 @@ trait HasWritePort { this: ExtModule =>

val w_dpic =
"""
|`ifndef SYNTHESIS
|`ifndef DISABLE_DIFFTEST_RAM_DPIC
|import "DPI-C" function void difftest_ram_write
|(
| input longint index,
| input longint data,
| input longint mask
|);
|`endif // SYNTHESIS
|`endif // DISABLE_DIFFTEST_RAM_DPIC
|""".stripMargin

val w_if =
Expand All @@ -132,15 +132,15 @@ trait HasWritePort { this: ExtModule =>

val w_func =
"""
|`ifndef SYNTHESIS
|`ifndef DISABLE_DIFFTEST_RAM_DPIC
|if (w_enable) begin
| difftest_ram_write(w_index, w_data, w_mask);
|end
|`else
|if (w_enable) begin
| memory[w_index] <= (w_data & w_mask) | (memory[w_index] & ~w_mask);
|end
|`endif // SYNTHESIS
|`endif // DISABLE_DIFFTEST_RAM_DPIC
|""".stripMargin

def write(enable: Bool, index: UInt, data: UInt, mask: UInt): HasWritePort = {
Expand All @@ -157,6 +157,9 @@ class MemRHelper extends ExtModule with HasExtModuleInline with HasReadPort with

setInline("MemRHelper.v",
s"""
|`ifdef SYNTHESIS
| `define DISABLE_DIFFTEST_RAM_DPIC
|`endif
|$r_dpic
|module MemRHelper(
| $r_if
Expand All @@ -175,6 +178,9 @@ class MemWHelper extends ExtModule with HasExtModuleInline with HasWritePort wit

setInline("MemWHelper.v",
s"""
|`ifdef SYNTHESIS
| `define DISABLE_DIFFTEST_RAM_DPIC
|`endif
|$w_dpic
|module MemWHelper(
| $w_if
Expand All @@ -194,6 +200,9 @@ class MemRWHelper extends ExtModule with HasExtModuleInline with HasReadPort wit

setInline("MemRWHelper.v",
s"""
|`ifdef SYNTHESIS
| `define DISABLE_DIFFTEST_RAM_DPIC
|`endif
|$r_dpic
|$w_dpic
|module MemRWHelper(
Expand Down
11 changes: 7 additions & 4 deletions src/test/vsrc/common/SimJTAG.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// See LICENSE.SiFive for license details.
//VCS coverage exclude_file
`ifndef SYNTHESIS
`ifdef SYNTHESIS
`define DISABLE_SIMJTAG_DPIC
`endif // SYNTHESIS
`ifndef DISABLE_SIMJTAG_DPIC
import "DPI-C" function int jtag_tick
(
output bit jtag_TCK,
Expand All @@ -10,7 +13,7 @@ import "DPI-C" function int jtag_tick

input bit jtag_TDO
);
`endif // SYNTHESIS
`endif // DISABLE_SIMJTAG_DPIC

module SimJTAG #(
parameter TICK_DELAY = 50
Expand All @@ -33,7 +36,7 @@ module SimJTAG #(
output [31:0] exit
);

`ifndef SYNTHESIS
`ifndef DISABLE_SIMJTAG_DPIC
`ifdef PALLADIUM
initial $ixc_ctrl("map_delays");
`endif
Expand Down Expand Up @@ -92,6 +95,6 @@ module SimJTAG #(
assign jtag_TDI = 1'b0;
assign jtag_TRSTn = 1'b1;
assign exit = 32'b0;
`endif // SYNTHESIS
`endif // DISABLE_SIMJTAG_DPIC

endmodule