ALTERA DE1-SoC开发板硬件实验指南与流程详解

需积分: 9 2 下载量 51 浏览量 更新于2024-07-22 收藏 8.04MB PPT 举报
本资源是一份关于ALTERA公司DE1-SoC开发板的硬件例程培训PPT,涵盖了多个关键主题。首先,它从DE1-SoC的快速入门开始,引导学习者熟悉开发设计软件,如Altera Quartus II和Altera SoC Embedded Design Suite,这些工具对于进行FPGA设计至关重要。提供的教材文件包括DE1-SoC开发板光盘,其中包含了原理图、设计范例以及实验所需的驱动和软件工具。 DE1-SoC本身是一个高度集成的平台,拥有双核ARM Cortex-A9处理器,每个核心具有高达800MHz的性能,配备了NEON媒体处理引擎,以及丰富的内嵌外围设备,包括高速缓存(L1Caches和L2Cache)。这使得它非常适合进行复杂的系统级应用设计。 硬件实验部分,重点介绍了DE1-SoC的硬件配置,如通过MSEL引脚设置不同的工作模式,如FPGA配置来自EPCQ(默认)、FPGA配置由HPS(Hard Processor System)软件控制,如Linux或U-Boot,以及使用SD卡加载图像。此外,还提到了如何使用USB Blaster II进行FPGA代码下载和调试,以及如何通过UART-to-USB接口与DE1-SoC进行串口通信,并配置合适的波特率、线路和连接方式。 软件实验方面,PPT可能会涉及在DE1-SoC上运行Linux操作系统的过程,包括插入MicroSD卡,以及如何利用这些硬件资源进行实际的系统开发。对于SoCFPGA设计流程,讲解了完整的系统开发流程,包括处理器特性、硬核内存控制器的介绍,这些都是构建高效应用的关键步骤。 整个课程旨在帮助学员掌握ALTERA DE1-SoC开发板的硬件和软件操作,了解其在系统级设计中的角色,并通过实践项目提升实际操作技能。这对于从事嵌入式系统设计、FPGA开发或深入理解SoC架构的工程师来说,是一份实用且深入的培训资料。

import torch import torch.nn as nn import numpy as np import matplotlib.pyplot as plt from torch import autograd """ 用神经网络模拟微分方程,f(x)'=f(x),初始条件f(0) = 1 """ class Net(nn.Module): def __init__(self, NL, NN): # NL n个l(线性,全连接)隐藏层, NN 输入数据的维数, # NL是有多少层隐藏层 # NN是每层的神经元数量 super(Net, self).__init__() self.input_layer = nn.Linear(1, NN) self.hidden_layer = nn.Linear(NN,int(NN/2)) ## 原文这里用NN,我这里用的下采样,经过实验验证,“等采样”更优。更多情况有待我实验验证。 self.output_layer = nn.Linear(int(NN/2), 1) def forward(self, x): out = torch.tanh(self.input_layer(x)) out = torch.tanh(self.hidden_layer(out)) out_final = self.output_layer(out) return out_final net=Net(4,20) # 4层 20个 mse_cost_function = torch.nn.MSELoss(reduction='mean') # Mean squared error 均方误差求 optimizer = torch.optim.Adam(net.parameters(),lr=1e-4) # 优化器 def ode_01(x,net): y=net(x) y_x = autograd.grad(y, x,grad_outputs=torch.ones_like(net(x)),create_graph=True)[0] return y-y_x # y-y' = 0 # requires_grad=True).unsqueeze(-1) plt.ion() # 动态图 iterations=200000 for epoch in range(iterations): optimizer.zero_grad() # 梯度归0 ## 求边界条件的损失函数 x_0 = torch.zeros(2000, 1) y_0 = net(x_0) mse_i = mse_cost_function(y_0, torch.ones(2000, 1)) # f(0) - 1 = 0 ## 方程的损失函数 x_in = np.random.uniform(low=0.0, high=2.0, size=(2000, 1)) pt_x_in = autograd.Variable(torch.from_numpy(x_in).float(), requires_grad=True) # x 随机数 pt_y_colection=ode_01(pt_x_in,net) pt_all_zeros= autograd.Variable(torch.from_numpy(np.zeros((2000,1))).float(), requires_grad=False) mse_f=mse_cost_function(pt_y_colection, pt_all_zeros) # y-y' = 0 loss = mse_i + mse_f loss.backward() # 反向传播 optimizer.step() # 优化下一步。This is equivalent to : theta_new = theta_old - alpha * derivative of J w.r.t theta if epoch%1000==0: y = torch.exp(pt_x_in) # y 真实值 y_train0 = net(pt_x_in) # y 预测值 print(epoch, "Traning Loss:", loss.data) print(f'times {epoch} - loss: {loss.item()} - y_0: {y_0}') plt.cla() plt.scatter(pt_x_in.detach().numpy(), y.detach().numpy()) plt.scatter(pt_x_in.detach().numpy(), y_train0.detach().numpy(),c='red') plt.pause(0.1)

2023-02-15 上传
2023-06-01 上传

import numpy as np import pandas as pd import matplotlib.pyplot as plt plt.rcParams['font.sans-serif'] = ["SimHei"] # 单使用会使负号显示错误 plt.rcParams['axes.unicode_minus'] = False # 把负号正常显示 # 读取北京房价数据 path = 'data.txt' data = pd.read_csv(path, header=None, names=['房子面积', '房子价格']) print(data.head(10)) print(data.describe()) # 绘制散点图 data.plot(kind='scatter', x='房子面积', y='房子价格') plt.show() def computeCost(X, y, theta): inner = np.power(((X * theta.T) - y), 2) return np.sum(inner) / (2 * len(X)) data.insert(0, 'Ones', 1) cols = data.shape[1] X = data.iloc[:,0:cols-1]#X是所有行,去掉最后一列 y = data.iloc[:,cols-1:cols]#X是所有行,最后一列 print(X.head()) print(y.head()) X = np.matrix(X.values) y = np.matrix(y.values) theta = np.matrix(np.array([0,0])) print(theta) print(X.shape, theta.shape, y.shape) def gradientDescent(X, y, theta, alpha, iters): temp = np.matrix(np.zeros(theta.shape)) parameters = int(theta.ravel().shape[1]) cost = np.zeros(iters) for i in range(iters): error = (X * theta.T) - y for j in range(parameters): term = np.multiply(error, X[:, j]) temp[0, j] = theta[0, j] - ((alpha / len(X)) * np.sum(term)) theta = temp cost[i] = computeCost(X, y, theta) return theta, cost alpha = 0.01 iters = 1000 g, cost = gradientDescent(X, y, theta, alpha, iters) print(g) print(computeCost(X, y, g)) x = np.linspace(data.Population.min(), data.Population.max(), 100) f = g[0, 0] + (g[0, 1] * x) fig, ax = plt.subplots(figsize=(12,8)) ax.plot(x, f, 'r', label='Prediction') ax.scatter(data.Population, data.Profit, label='Traning Data') ax.legend(loc=2) ax.set_xlabel('房子面积') ax.set_ylabel('房子价格') ax.set_title('北京房价拟合曲线图') plt.show()

2023-06-04 上传
2023-06-01 上传