c - Nios 2 "Hello World"?

标签 c fpga intel-fpga nios

我已经成功地在 Nios 2 Altera DE2 板上运行了一个复杂的项目,在该项目中我使用输入和输出创建了一个带有汇编和 C 代码的定时器。使用 Nios 2 IDE,我可以将项目下载到 DE2 FPGA,并且时钟按预期运行。但我并不了解有关编程模型的所有内容,而且我还在尝试了解基本的 Hello World 示例和 IDE 附带的诊断示例。

Hello World 例子就是

/*
 * "Hello World" example.
 *
 * This example prints 'Hello from Nios II' to the STDOUT stream. It runs on
 * the Nios II 'standard', 'full_featured', 'fast', and 'low_cost' example
 * designs. It runs with or without the MicroC/OS-II RTOS and requires a STDOUT
 * device in your system's hardware.
 * The memory footprint of this hosted application is ~69 kbytes by default
 * using the standard reference design.
 *
 * For a reduced footprint version of this template, and an explanation of how
 * to reduce the memory footprint for a given application, see the
 * "small_hello_world" template.
 *
 */

#include <stdio.h>

int main()
{
  printf("Hello from Nios II!\n");

  return 0;
}

但是当我“作为 Nios 2 硬件”编译和运行这个程序时,它只会在 IDE 中按照标准输出 Hello World,它不会下载并在板上运行——难道不应该那样做吗?如果它不在板上运行,这个例子有什么意义?我做错了什么,如果是的话,因为示例编译并运行了?我必须对 BSD 编辑器进行设置吗?

更新

它根本不起作用。我在 BSP 编辑器中尝试了不同的组合,但都没有用。当我尝试将项目作为“Nios II 硬件”运行时,板上没有任何反应,即使它在 IDE 中显示项目正在下载到板上。为什么容易的事情很难?用户体验很糟糕,不得不猜测是不科学的。

enter image description here

最佳答案

这是 a link来自哥伦比亚大学的嵌入式系统设计类(class)。

检查 link to lab 3用于在 Altera DE2 板上使用 VHDL 和 C 实现闪烁 LED。

此实现使用 Altera Quartus、Nios II 和 SOPC Builder。我将尝试总结以下步骤:

  1. 您需要在 VHDL/Verilog 中编写 SRAM 和 LED Controller 以连接到 Avalon 总线。在 SOPC Builder 上创建系统。使用这些 Controller 在 SOPC Builder 中创建组件(SRAM 和 LED 组件)。

  2. 将组件连接到 Nios II 处理器和 JTAG 调试模块。分配基地址并生成您的系统。

  3. 在 Nios II 中,使用 SOPC Builder 生成的 SOPC 文件创建一个 C 项目(Nios II 应用程序和来自模板的 BSP)。

  4. 将模板中的代码替换为 C 程序(在本例中为 LED 闪光器程序)。使用您之前生成的基地址访问 LED。

  5. 构建并运行您的程序作为 Nios II 硬件。

更多信息 here .

关于c - Nios 2 "Hello World"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17966235/

相关文章:

C、unknown conversion type character 0x20 in format [-Wformat=]错误

c - 访问特定内存地址

c - Linux 上的 read() 和页对齐缓冲区

C 编程如果函数返回错误则退出主程序

c - 从主机程序动态配置 FPGA

vhdl - 为什么在 FPGA 设计中使用多个相同速度的时钟?

VHDL整数范围包括在内? FPGA 与仿真的区别

compiler-errors - 错误10818-无法推断寄存器,因为它不在时钟沿以外保持其值

linux-kernel - configfs 不挂载设备树/覆盖

linux - 尝试使用 'aocl install' 安装 de5a_net_i2 驱动程序但失败