Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
饶先宏
hdl4se
提交
f453d05a
H
hdl4se
项目概览
饶先宏
/
hdl4se
通知
12
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hdl4se
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f453d05a
编写于
8月 25, 2021
作者:
饶先宏
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
202108250635
上级
3ec993fc
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
924 addition
and
1 deletion
+924
-1
examples/hdl4se_riscv/hdl4se_riscv_sim/CMakeLists.txt
examples/hdl4se_riscv/hdl4se_riscv_sim/CMakeLists.txt
+1
-1
examples/hdl4se_riscv/hdl4se_riscv_sim/hdl4se_riscv.h
examples/hdl4se_riscv/hdl4se_riscv_sim/hdl4se_riscv.h
+2
-0
examples/hdl4se_riscv/hdl4se_riscv_sim/hdl4se_riscv_core_v2.c
...ples/hdl4se_riscv/hdl4se_riscv_sim/hdl4se_riscv_core_v2.c
+714
-0
examples/hdl4se_riscv/hdl4se_riscv_sim/hdl4se_riscv_ram8k.c
examples/hdl4se_riscv/hdl4se_riscv_sim/hdl4se_riscv_ram8k.c
+207
-0
未找到文件。
examples/hdl4se_riscv/hdl4se_riscv_sim/CMakeLists.txt
浏览文件 @
f453d05a
...
...
@@ -7,7 +7,7 @@ add_executable(riscv_sim
"hdl4se_riscv_core.c"
"riscv_sim_main.c"
"main.c"
)
"hdl4se_riscv_core_v2.c"
"hdl4se_riscv_ram8k.c"
)
add_definitions
(
-D_CRT_SECURE_NO_WARNINGS
)
...
...
examples/hdl4se_riscv/hdl4se_riscv_sim/hdl4se_riscv.h
浏览文件 @
f453d05a
...
...
@@ -46,6 +46,8 @@ extern "C" {
#include "guid.h"
DEFINE_GUID
(
CLSID_HDL4SE_RISCV_CORE
,
0x638e8bc3
,
0xb0e0
,
0x41dc
,
0x9e
,
0xdd
,
0xd3
,
0x5a
,
0x39
,
0xfd
,
0x80
,
0x51
);
// {EE3409B2-6D04-42B3-A44D-7F2444DDC00D}
DEFINE_GUID
(
CLSID_HDL4SE_RISCV_RAM
,
0xee3409b2
,
0x6d04
,
0x42b3
,
0xa4
,
0x4d
,
0x7f
,
0x24
,
0x44
,
0xdd
,
0xc0
,
0xd
);
#endif
...
...
examples/hdl4se_riscv/hdl4se_riscv_sim/hdl4se_riscv_core_v2.c
0 → 100644
浏览文件 @
f453d05a
此差异已折叠。
点击以展开。
examples/hdl4se_riscv/hdl4se_riscv_sim/hdl4se_riscv_ram8k.c
0 → 100644
浏览文件 @
f453d05a
/*
** HDL4SE: 软件Verilog综合仿真平台
** Copyright (C) 2021-2021, raoxianhong<raoxianhong@163.net>
** LCOM: 轻量级组件对象模型
** Copyright (C) 2021-2021, raoxianhong<raoxianhong@163.net>
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are met:
**
** * Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright notice,
** this list of conditions and the following disclaimer in the documentation
** and/or other materials provided with the distribution.
** * The name of the author may be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
** THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* hdl4se_riscv_ram8k.c
202108250608: rxh, initial version
*/
#include "stdlib.h"
#include "stdio.h"
#include "object.h"
#include "dlist.h"
#include "string.h"
#include "stdarg.h"
#include "bignumber.h"
#include "hdl4secell.h"
#define IMPLEMENT_GUID
#include "hdl4se_riscv.h"
#undef IMPLEMENT_GUID
#ifdef WIN32
#define DATADIR "d:/gitwork/hdl4se/examples/hdl4se_riscv/"
#else
#define DATADIR "/media/raoxianhong/_dde_data/gitwork/hdl4se/examples/hdl4se_riscv/"
#endif
#define riscv_ram_MODULE_VERSION_STRING "0.4.0-20210825.0610 RISCV RAM cell"
#define riscv_ram_MODULE_CLSID CLSID_HDL4SE_RISCV_RAM
#define M_ID(id) riscv_ram##id
/*
跟alter生成的端口一致
module ram8kb (
address,
byteena,
clock,
data,
wren,
q);
input [10:0] address;
input [3:0] byteena;
input clock;
input [31:0] data;
input wren;
output [31:0] q;
`ifndef ALTERA_RESERVED_QIS
// synopsys translate_off
`endif
tri1 [3:0] byteena;
tri1 clock;
`ifndef ALTERA_RESERVED_QIS
// synopsys translate_on
`endif
endmodule
*/
#define RAMSIZE 2048
IDLIST
VID
(
address
),
VID
(
byteena
),
VID
(
clock
),
VID
(
data
),
VID
(
wren
),
VID
(
q
),
VID
(
lastaddr
),
END_IDLIST
MODULE_DECLARE
(
riscv_ram
)
unsigned
int
*
ram
;
unsigned
int
ramaddr
;
unsigned
int
ramwrdata
;
unsigned
int
ramwren
;
unsigned
int
rambyteena
;
END_MODULE_DECLARE
(
riscv_ram
)
DEFINE_FUNC
(
riscv_ram_gen_q
,
"address, byteena, data, wren, lastaddr"
)
{
unsigned
int
lastaddr
;
lastaddr
=
vget
(
lastaddr
);
if
(
lastaddr
<
RAMSIZE
)
vput
(
q
,
pobj
->
ram
[
vget
(
lastaddr
)]);
else
vput
(
q
,
0xdeadbeef
);
}
END_DEFINE_FUNC
DEFINE_FUNC
(
riscv_ram_clktick
,
""
)
{
pobj
->
ramwren
=
vget
(
wren
);
pobj
->
ramwrdata
=
vget
(
data
);
pobj
->
rambyteena
=
vget
(
byteena
);
pobj
->
ramaddr
=
vget
(
address
);
vput
(
lastaddr
,
vget
(
address
));
}
END_DEFINE_FUNC
DEFINE_FUNC
(
riscv_ram_deinit
,
""
)
{
if
(
pobj
->
ram
!=
NULL
)
free
(
pobj
->
ram
);
}
END_DEFINE_FUNC
DEFINE_FUNC
(
riscv_ram_setup
,
""
)
{
if
(
pobj
->
ramwren
)
{
unsigned
int
mask
=
(
pobj
->
rambyteena
&
1
?
0x000000ff
:
0
)
|
(
pobj
->
rambyteena
&
2
?
0x0000ff00
:
0
)
|
(
pobj
->
rambyteena
&
4
?
0x00ff0000
:
0
)
|
(
pobj
->
rambyteena
&
8
?
0xff000000
:
0
);
pobj
->
ram
[
pobj
->
ramaddr
]
=
(
pobj
->
ram
[
pobj
->
ramaddr
]
&
(
~
mask
))
|
(
pobj
->
ramwrdata
&
mask
);
}
pobj
->
ramwren
=
0
;
}
END_DEFINE_FUNC
int
loadExecImage
(
unsigned
char
*
data
,
int
maxlen
)
{
unsigned
int
addr
;
FILE
*
pFile
=
fopen
(
DATADIR
"test_code/test.cod"
,
"rt"
);
if
(
pFile
==
NULL
)
{
printf
(
"File %s can not open
\n
"
,
DATADIR
"test_code/test.bin"
);
exit
(
-
1
);
}
addr
=
0
;
while
(
!
feof
(
pFile
))
{
char
line
[
256
];
fgets
(
line
,
256
,
pFile
);
if
(
strlen
(
line
)
<
2
)
break
;
if
(
line
[
0
]
==
'@'
)
{
sscanf
(
line
+
1
,
"%08x"
,
&
addr
);
}
else
{
int
len
;
if
(
addr
>=
maxlen
-
16
)
{
printf
(
"loadExecImage failed, address [%08x] overflow
\n
"
,
addr
);
exit
(
-
5
);
}
len
=
sscanf
(
line
,
"%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X"
,
data
+
addr
+
0
,
data
+
addr
+
1
,
data
+
addr
+
2
,
data
+
addr
+
3
,
data
+
addr
+
4
,
data
+
addr
+
5
,
data
+
addr
+
6
,
data
+
addr
+
7
,
data
+
addr
+
8
,
data
+
addr
+
9
,
data
+
addr
+
10
,
data
+
addr
+
11
,
data
+
addr
+
12
,
data
+
addr
+
13
,
data
+
addr
+
14
,
data
+
addr
+
15
);
addr
+=
len
;
}
}
fclose
(
pFile
);
}
MODULE_INIT
(
riscv_ram
)
pobj
->
ram
=
malloc
(
RAMSIZE
*
4
);
loadExecImage
(
pobj
->
ram
,
RAMSIZE
*
4
);
pobj
->
ramwren
=
0
;
PORT_IN
(
clock
,
1
);
PORT_IN
(
wren
,
1
);
PORT_IN
(
address
,
11
);
PORT_IN
(
data
,
32
);
PORT_IN
(
byteena
,
4
);
GPORT_OUT
(
q
,
32
,
riscv_ram_gen_q
);
REG
(
lastaddr
,
11
);
CLKTICK_FUNC
(
riscv_ram_clktick
);
SETUP_FUNC
(
riscv_ram_setup
);
DEINIT_FUNC
(
riscv_ram_deinit
);
END_MODULE_INIT
(
riscv_ram
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录