提交 9f842a1a 编写于 作者: Y Yinan Xu

device,sdcard: fix inline SDHelper read behavior

上级 46951036
......@@ -32,23 +32,22 @@ class SDHelper extends BlackBox with HasBlackBoxInline {
setInline("SDHelper.v",
s"""
|import "DPI-C" function void sd_setaddr(input int addr);
|import "DPI-C" function int sd_read(input bit ren);
|import "DPI-C" function void sd_read(output int data);
|
|module SDHelper (
| input clk,
| input setAddr,
| input [31:0] addr,
| input ren,
| output [31:0] data
| output reg [31:0] data
|);
|
| always @(posedge clk) begin
| if (setAddr) begin
| sd_setaddr(addr);
| end
| always @(negedge clk) begin
| if (ren) sd_read(data);
| end
| always@(posedge clk) begin
| if (setAddr) sd_setaddr(addr);
| end
|
| assign data = sd_read(ren);
|
|endmodule
""".stripMargin)
......
......@@ -11,18 +11,14 @@ void sd_setaddr(uint32_t addr) {
//assert(0);
}
uint32_t sd_read(int ren) {
if (ren) {
uint32_t data;
fread(&data, 4, 1, fp);
//printf("read data = 0x%08x\n", *data);
return data;
}
return 0xdeadbeaf;
void sd_read(uint32_t *data) {
fread(data, 4, 1, fp);
//printf("read data = 0x%08x\n", *data);
//assert(0);
}
void init_sd(void) {
fp = fopen("/home/xyn/debian/debian.img", "r");
fp = fopen("/home/xyn/workloads/debian/riscv-debian.img", "r");
if(!fp)
{
eprintf(ANSI_COLOR_MAGENTA "[warning] sdcard img not found\n");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册