【发布时间】:2016-04-01 00:45:26
【问题描述】:
我是 VHDL 新手,但在一些帮助下,我设法用 VHDL 创建了一个处理器(它具有 ALU、乘法器和访问 SRAM 存储器的总线架构)。处理器解码 32 位指令(其中包含操作类型和内存地址)。
如何在处理器中编写以下 C 代码?
int i = 0;
int c = 0;
int a[10] = "0,1,2,3,4,5,6,7,8,9";
int b[10] = "1,0,-1,0,1,0,2,1,-1,1";
for (i = 0; i < 9; i++) c += (a[i]*b[i]);
我猜我会在测试台中为此 C 代码编写指令列表:
1st instruction: multiply a[0] with b[0]
2nd instruction: add the result to c
并重复 9 次。
这是正确的方法吗?有没有更好的方法来实现 for 循环?有没有办法直接在我的 tb_top.vhd 中编写 C 代码?
【问题讨论】:
标签: c vhdl processor test-bench