闀跨煭鏃惰蹇嗙缁忕綉缁減ython浠g爜

Python实现Hopfield神经网络详解
这篇博客介绍了Hopfield神经网络的原理和Python实现。网络结构为全连接单层,具有反馈迭代特性,用于存储和检索信息。博主通过9行Python代码展示了神经网络的简单构建,包括权重初始化、异步更新、Sigmoid激活函数和误差反向传播。此外,还讨论了权重调整的公式。代码示例中包含训练和预测过程,以及数据增强的方法。

Hopfield神经网络用python实现讲解?

神经网络结构具有以下三个特点:神经元之间全连接,并且为单层神经网络。每个神经元既是输入又是输出,导致得到的权重矩阵相对称,故可节约计算量。

在输入的激励下,其输出会产生不断的状态变化,这个反馈过程会一直反复进行。

假如Hopfield神经网络是一个收敛的稳定网络,则这个反馈与迭代的计算过程所产生的变化越来越小,一旦达到了稳定的平衡状态,Hopfield网络就会输出一个稳定的恒值。

Hopfield网络可以储存一组平衡点,使得当给定网络一组初始状态时,网络通过自行运行而最终收敛于这个设计的平衡点上。

当然,根据热力学上,平衡状态分为stablestate和metastablestate,这两种状态在网络的收敛过程中都是非常可能的。为递归型网络,t时刻的状态与t-1时刻的输出状态有关。

之后的神经元更新过程也采用的是异步更新法(Asynchronous)。Hopfield神经网络用python实现。

谷歌人工智能写作项目:爱发猫

下面是一段python代码 谁能解释下 详细之后在给高分

写作猫

逐行对应如下:定义getNodeMeta函数,定义userid等变量...datetime函数最大值把用户访问信息存入result变量用户信息包括内容项判断result变量是否存在判断include_deleted为False和result第一项被删除同时成立返回返回result第一项PS:这段代码不是独立的吧?

感觉很乱,而且一些地方有问题,单独执行肯定报错。

如何用9行Python代码编写一个简易神经网络

学习人工智能时,我给自己定了一个目标--用Python写一个简单的神经网络。为了确保真得理解它,我要求自己不使用任何神经网络库,从头写起。多亏了AndrewTrask写得一篇精彩的博客,我做到了!

下面贴出那九行代码:在这篇文章中,我将解释我是如何做得,以便你可以写出你自己的。我将会提供一个长点的但是更完美的源代码。首先,神经网络是什么?人脑由几千亿由突触相互连接的细胞(神经元)组成。

突触传入足够的兴奋就会引起神经元的兴奋。这个过程被称为“思考”。我们可以在计算机上写一个神经网络来模拟这个过程。不需要在生物分子水平模拟人脑,只需模拟更高层级的规则。

我们使用矩阵(二维数据表格)这一数学工具,并且为了简单明了,只模拟一个有3个输入和一个输出的神经元。我们将训练神经元解决下面的问题。前四个例子被称作训练集。你发现规律了吗?‘?’是0还是1?

你可能发现了,输出总是等于输入中最左列的值。所以‘?’应该是1。训练过程但是如何使我们的神经元回答正确呢?赋予每个输入一个权重,可以是一个正的或负的数字。

拥有较大正(或负)权重的输入将决定神经元的输出。首先设置每个权重的初始值为一个随机数字,然后开始训练过程:取一个训练样本的输入,使用权重调整它们,通过一个特殊的公式计算神经元的输出。

计算误差,即神经元的输出与训练样本中的期待输出之间的差值。根据误差略微地调整权重。重复这个过程1万次。最终权重将会变为符合训练集的一个最优解。

如果使用神经元考虑这种规律的一个新情形,它将会给出一个很棒的预测。这个过程就是backpropagation。计算神经元输出的公式你可能会想,计算神经元输出的公式是什么?

首先,计算神经元输入的加权和,即接着使之规范化,结果在0,1之间。为此使用一个数学函数--Sigmoid函数:Sigmoid函数的图形是一条“S”状的曲线。

把第一个方程代入第二个,计算神经元输出的最终公式为:你可能注意到了,为了简单,我们没有引入最低兴奋阈值。调整权重的公式我们在训练时不断调整权重。但是怎么调整呢?

可以使用“ErrorWeightedDerivative”公式:为什么使用这个公式?首先,我们想使调整和误差的大小成比例。其次,乘以输入(0或1),如果输入是0,权重就不会调整。

最后,乘以Sigmoid曲线的斜率(图4)。

为了理解最后一条,考虑这些:我们使用Sigmoid曲线计算神经元的输出如果输出是一个大的正(或负)数,这意味着神经元采用这种(或另一种)方式从图四可以看出,在较大数值处,Sigmoid曲线斜率小如果神经元认为当前权重是正确的,就不会对它进行很大调整。

乘以Sigmoid曲线斜率便可以实现这一点Sigmoid曲线的斜率可以通过求导得到:把第二个等式代入第一个等式里,得到调整权重的最终公式:当然有其他公式,它们可以使神经元学习得更快,但是这个公式的优点是非常简单。

构造Python代码虽然我们没有使用神经网络库,但是将导入Python数学库numpy里的4个方法。

分别是:exp--自然指数array--创建矩阵dot--进行矩阵乘法random--产生随机数比如,我们可以使用array()方法表示前面展示的训练集:“.T”方法用于矩阵转置(行变列)。

所以,计算机这样存储数字:我觉得我们可以开始构建更优美的源代码了。给出这个源代码后,我会做一个总结。我对每一行源代码都添加了注释来解释所有内容。注意在每次迭代时,我们同时处理所有训练集数据。

所以变量都是矩阵(二维数据表格)。下面是一个用Python写地完整的示例代码。我们做到了!我们用Python构建了一个简单的神经网络!首先神经网络对自己赋予随机权重,然后使用训练集训练自己。

接着,它考虑一种新的情形[1,0,0]并且预测了0.99993704。正确答案是1。非常接近!传统计算机程序通常不会学习。

而神经网络却能自己学习,适应并对新情形做出反应,这是多么神奇,就像人类一样。

Python这一行代码什么意思?这是神经网络里的一部分Python实现代码,正在手工往C++迁移

关于Python的BP神经网络的一个代码 100

怎样用python构建一个卷积神经网络

用keras框架较为方便首先安装anaconda,然后通过pip安装keras以下转自wphh的博客。

#coding:utf-8'''    GPU run command:        THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python     CPU run command:        python 2016.06.06更新:这份代码是keras开发初期写的,当时keras还没有现在这么流行,文档也还没那么丰富,所以我当时写了一些简单的教程。

现在keras的API也发生了一些的变化,建议及推荐直接上看更加详细的教程。

'''#导入各种用到的模块组件from __future__ import absolute_importfrom __future__ import print_functionfrom keras.preprocessing.image import ImageDataGeneratorfrom keras.models import Sequentialfrom  import Dense, Dropout, Activation, Flattenfrom keras.layers.advanced_activations import PReLUfrom keras.layers.convolutional import Convolution2D, MaxPooling2Dfrom keras.optimizers import SGD, Adadelta, Adagradfrom keras.utils import np_utils, generic_utilsfrom six.moves import rangefrom data import load_dataimport randomimport numpy as np(1024)  # for reproducibility#加载数据data, label = load_data()#打乱数据index = [i for i in range(len(data))]random.shuffle(index)data = data[index]label = label[index]print(data.shape[0], ' samples')#label为0~9共10个类别,keras要求格式为binary class matrices,转化一下,直接调用keras提供的这个函数label = np_utils.to_categorical(label, 10)################开始建立CNN模型################生成一个modelmodel = Sequential()#第一个卷积层,4个卷积核,每个卷积核大小5*5。

1表示输入的图片的通道,灰度图为1通道。

#border_mode可以是valid或者full,具体看这里说明:.conv2d#激活函数用tanh#你还可以在(Activation('tanh'))后加上dropout的技巧: (Dropout(0.5))(Convolution2D(4, 5, 5, border_mode='valid',input_shape=(1,28,28))) (Activation('tanh'))#第二个卷积层,8个卷积核,每个卷积核大小3*3。

4表示输入的特征图个数,等于上一层的卷积核个数#激活函数用tanh#采用maxpooling,poolsize为(2,2)(Convolution2D(8, 3, 3, border_mode='valid'))(Activation('tanh'))(MaxPooling2D(pool_size=(2, 2)))#第三个卷积层,16个卷积核,每个卷积核大小3*3#激活函数用tanh#采用maxpooling,poolsize为(2,2)(Convolution2D(16, 3, 3, border_mode='valid')) (Activation('relu'))(MaxPooling2D(pool_size=(2, 2)))#全连接层,先将前一层输出的二维特征图flatten为一维的。

#Dense就是隐藏层。16就是上一层输出的特征图个数。

4是根据每个卷积层计算出来的:(28-5+1)得到24,(24-3+1)/2得到11,(11-3+1)/2得到4#全连接有128个神经元节点,初始化方式为normal(Flatten())(Dense(128, init='normal'))(Activation('tanh'))#Softmax分类,输出是10类别(Dense(10, init='normal'))(Activation('softmax'))##############开始训练模型###############使用SGD + momentum#model.compile里的参数loss就是损失函数(目标函数)sgd = SGD(lr=0.05, decay=1e-6, momentum=0.9, nesterov=True)model.compile(loss='categorical_crossentropy', optimizer=sgd,metrics=["accuracy"])#调用fit方法,就是一个训练过程. 训练的epoch数设为10,batch_size为100.#数据经过随机打乱shuffle=True。

verbose=1,训练过程中输出的信息,0、1、2三种方式都可以,无关紧要。show_accuracy=True,训练时每一个epoch都输出accuracy。

#validation_split=0.2,将20%的数据作为验证集。

(data, label, batch_size=100, nb_epoch=10,shuffle=True,verbose=1,validation_split=0.2)"""#使用data augmentation的方法#一些参数和调用的方法,请看文档datagen = ImageDataGenerator(        featurewise_center=True, # set input mean to 0 over the dataset        samplewise_center=False, # set each sample mean to 0        featurewise_std_normalization=True, # divide inputs by std of the dataset        samplewise_std_normalization=False, # divide each input by its std        zca_whitening=False, # apply ZCA whitening        rotation_range=20, # randomly rotate images in the range (degrees, 0 to 180)        width_shift_range=0.2, # randomly shift images horizontally (fraction of total width)        height_shift_range=0.2, # randomly shift images vertically (fraction of total height)        horizontal_flip=True, # randomly flip images        vertical_flip=False) # randomly flip images# compute quantities required for featurewise normalization # (std, mean, and principal components if ZCA whitening is applied)(data)for e in range(nb_epoch):    print('-'*40)    print('Epoch', e)    print('-'*40)    print("Training...")    # batch train with realtime data augmentation    progbar = generic_utils.Progbar(data.shape[0])    for X_batch, Y_batch in (data, label):        loss,accuracy = model.train(X_batch, Y_batch,accuracy=True)        (X_batch.shape[0], values=[("train loss", loss),("accuracy:", accuracy)] )"""。

一小段python代码求解释

 

璇诲彇琛? [2025-06-03 14:14:27.360]# RECV HEX> >> 鍙戠幇RECV鍧?#5163 鏃堕棿鎴宠: [2025-06-03 14:14:27.360]# RECV HEX> 璇诲彇琛? 02 10 00 00 00 10 C1 F6 -- 甯ф暟鎹? 02 10 00 00 00 10 C1 F6 熻鍊? hex_count=8 (鏈熸湜: 7) 垮害涓嶅尮閰? 鏈熸湜 7锛屽疄闄?8 璇诲彇琛? 璇诲彇琛? [2025-06-03 14:14:27.903]# RECV HEX> >> 鍙戠幇RECV鍧?#5164 鏃堕棿鎴宠: [2025-06-03 14:14:27.903]# RECV HEX> 璇诲彇琛? 02 10 00 00 00 10 20 55 55 00 00 00 00 03 E7 0D 6C 06 A8 1E 51 00 00 00 00 00 00 0C 06 0B AD 02 EE 02 E1 00 00 00 00 DB 58 -- 甯ф暟鎹? 02 10 00 00 00 10 20 55 55 00 00 00 00 03 E7 0D 6C 06 A8 1E 51 00 00 00 00 00 00 0C 06 0B AD 02 EE 02 E1 00 00 00 00 DB 58 熻鍊? hex_count=41 (鏈熸湜: 7) 垮害涓嶅尮閰? 鏈熸湜 7锛屽疄闄?41 璇诲彇琛? 璇诲彇琛? [2025-06-03 14:14:28.043]# RECV HEX> >> 鍙戠幇RECV鍧?#5165 鏃堕棿鎴宠: [2025-06-03 14:14:28.043]# RECV HEX> 璇诲彇琛? 02 10 00 00 00 10 C1 F6 -- 甯ф暟鎹? 02 10 00 00 00 10 C1 F6 熻鍊? hex_count=8 (鏈熸湜: 7) 垮害涓嶅尮閰? 鏈熸湜 7锛屽疄闄?8 璇诲彇琛? 璇诲彇琛? [2025-06-03 14:14:28.613]# RECV HEX> >> 鍙戠幇RECV鍧?#5166 鏃堕棿鎴宠: [2025-06-03 14:14:28.613]# RECV HEX> 璇诲彇琛? 02 10 00 00 00 10 20 55 55 00 00 00 00 03 E7 0D 6C 06 A8 1E 51 00 00 00 00 00 00 0C 06 0B AD 02 EE 02 E1 00 00 00 00 DB 58 -- 甯ф暟鎹? 02 10 00 00 00 10 20 55 55 00 00 00 00 03 E7 0D 6C 06 A8 1E 51 00 00 00 00 00 00 0C 06 0B AD 02 EE 02 E1 00 00 00 00 DB 58 熻鍊? hex_count=41 (鏈熸湜: 7) 垮害涓嶅尮閰? 鏈熸湜 7锛屽疄闄?41 璇诲彇琛? 璇诲彇琛? [2025-06-03 14:14:28.753]# RECV HEX> >> 鍙戠幇RECV鍧?#5167 鏃堕棿鎴宠: [2025-06-03 14:14:28.753]# RECV HEX> 璇诲彇琛? 02 10 00 00 00 10 C1 F6 -- 甯ф暟鎹? 02 10 00 00 00 10 C1 F6 熻鍊? hex_count=8 (鏈熸湜: 7) 垮害涓嶅尮閰? 鏈熸湜 7锛屽疄闄?8 璇诲彇琛? 璇诲彇琛? [2025-06-03 14:14:29.314]# RECV HEX> >> 鍙戠幇RECV鍧?#5168 鏃堕棿鎴宠: [2025-06-03 14:14:29.314]# RECV HEX> 璇诲彇琛? 02 10 00 00 00 10 20 55 55 00 00 00 00 03 E7 0D 6C 06 A8 1E 51 00 00 00 00 00 00 0C 06 0B AD 02 EE 02 E1 00 00 00 00 DB 58 -- 甯ф暟鎹? 02 10 00 00 00 10 20 55 55 00 00 00 00 03 E7 0D 6C 06 A8 1E 51 00 00 00 00 00 00 0C 06 0B AD 02 EE 02 E1 00 00 00 00 DB 58 熻鍊? hex_count=41 (鏈熸湜: 7) 垮害涓嶅尮閰? 鏈熸湜 7锛屽疄闄?41 璇诲彇琛? 璇诲彇琛? [2025-06-03 14:14:29.440]# RECV HEX> >> 鍙戠幇RECV鍧?#5169 鏃堕棿鎴宠: [2025-06-03 14:14:29.440]# RECV HEX> 璇诲彇琛? 02 10 00 00 00 10 C1 F6 -- 甯ф暟鎹? 02 10 00 00 00 10 C1 F6 熻鍊? hex_count=8 (鏈熸湜: 7) 垮害涓嶅尮閰? 鏈熸湜 7锛屽疄闄?8 璇诲彇琛? 璇诲彇琛? [2025-06-03 14:14:29.999]# RECV HEX> >> 鍙戠幇RECV鍧?#5170 鏃堕棿鎴宠: [2025-06-03 14:14:29.999]# RECV HEX> 璇诲彇琛? 02 10 00 00 00 10 20 55 55 00 00 00 00 03 E7 0D 6C 06 A8 1E 51 00 00 00 00 00 00 0C 06 0B AD 02 EE 02 E1 00 00 00 00 DB 58 -- 甯ф暟鎹? 02 10 00 00 00 10 20 55 55 00 00 00 00 03 E7 0D 6C 06 A8 1E 51 00 00 00 00 00 00 0C 06 0B AD 02 EE 02 E1 00 00 00 00 DB 58 熻鍊? hex_count=41 (鏈熸湜: 7) 垮害涓嶅尮閰? 鏈熸湜 7锛屽疄闄?41 璇诲彇琛? 璇诲彇琛? [2025-06-03 14:14:30.154]# RECV HEX> >> 鍙戠幇RECV鍧?#5171 鏃堕棿鎴宠: [2025-06-03 14:14:30.154]# RECV HEX> 璇诲彇琛? 02 10 00 00 00 10 C1 F6 -- 甯ф暟鎹? 02 10 00 00 00 10 C1 F6 熻鍊? hex_count=8 (鏈熸湜: 7) 垮害涓嶅尮閰? 鏈熸湜 7锛屽疄闄?8 ==== 澶勭悊瀹屾垚 ==== 鎵弿RECV鍧? 5171 鍖归厤甯ф暟: 0 杈撳嚭鏂囦欢: extracted_timestamps.txt [璀﹀憡] 娌℃湁鎵惧埌鍖归厤鐨勫抚鏁版嵁锛屽彲鑳藉師鍥? 1. 鏃ュ織涓棤鐩爣甯ф暟鎹? 02 10 00 00 00 10 20 2. 甯уぇ灏忎笉姝g‘(褰撳墠璁剧疆: 7瀛楄妭) 3. 鏃ュ織鏍煎紡涓嶇鍚堥鏈? PS D:\Desktop\4H测试记录>
06-04
输出是 鏁版嵁闆嗘憳瑕�: 鏈堢閲� 鍑虹鐜� 绌虹疆鐜� GDP澧為�� 鏂板叴浜т笟鍗犳瘮 鏂板渚涘簲 浜烘墠鍑�娴佸叆 绉熼噾鏀剁泭鎸囨暟 渚涢渶骞宠 鎸囨暟 count 16.000000 16.000000 16.000000 16.000000 16.000000 16.00000 16.000000 16.000000 16.000000 mean 129.750000 81.562500 17.437500 5.618750 31.531250 99.80625 1.681250 105.795125 7.832530 std 56.414537 7.869339 9.291206 1.250716 8.877666 48.87634 1.297803 47.612849 4.307680 min 40.000000 61.800000 5.400000 3.800000 18.900000 35.70000 -0.500000 33.520000 1.961165 25% 84.750000 76.825000 10.050000 4.475000 22.725000 59.85000 0.600000 71.872500 4.876060 50% 131.000000 83.950000 13.900000 5.850000 31.050000 89.95000 2.200000 100.906500 7.601001 75% 172.750000 87.075000 27.625000 6.700000 39.000000 145.77500 2.650000 146.284250 9.242916 max 234.000000 90.000000 32.600000 7.400000 44.100000 174.20000 3.400000 193.752000 18.753247 ================================================== 鍥炲綊鍒嗘瀽撴灉 ================================================== 绾挎�у洖褰掔粨鏋滄憳瑕�: OLS Regression Results ============================================================================== Dep. Variable: 鍑虹鐜� R-squared: 0.000 Model: OLS Adj. R-squared: -0.071 Method: Least Squares F-statistic: 0.0008390 Date: 鍛ㄤ竴, 09 6鏈� 2025 Prob (F-statistic): 0.977 Time: 01:03:07 Log-Likelihood: -55.194 No. Observations: 16 AIC: 114.4 Df Residuals: 14 BIC: 115.9 Df Model: 1 Covariance Type: nonrobust ============================================================================== coef std err t P>|t| [0.025 0.975] ------------------------------------------------------------------------------ const 81.7026 5.248 15.568 0.000 70.446 92.959 鏈堢閲� -0.0011 0.037 -0.029 0.977 -0.081 0.079 ============================================================================== Omnibus: 5.039 Durbin-Watson: 2.468 Prob(Omnibus): 0.081 Jarque-Bera (JB): 2.835 Skew: -1.009 Prob(JB): 0.242 Kurtosis: 3.428 Cond. No. 363. ============================================================================== Notes: [1] Standard Errors assume that the covariance matrix of the errors is correctly specified. 澶氶」寮忓洖褰扲虏鍊�: 0.0722 宸蹭繚瀛樺洖褰掑垎鏋愮粨鏋滃浘鍍� ================================================== 鑱氱被鍒嗘瀽撴灉 ================================================== 宸蹭繚瀛樿仛绫诲垎鏋愮粨鏋滃浘鍍� ================================================== 鍏宠仈瑙勫垯鍒嗘瀽撴灉 ================================================== D:\conda\Lib\site-packages\mlxtend\frequent_patterns\fpcommon.py:109: DeprecationWarning: DataFrames with non-bool types result in worse computationalperformance and their support might be discontinued in the future.Please use a DataFrame with bool type warnings.warn( 寮哄叧鑱旇鍒�: 瑙勫垯 support confidence lift {'楂�'} 鈫� {'浣�'} 0.3125 0.833333 2.666667 {'楂�', '浼�'} 鈫� {'浣�'} 0.3125 0.833333 2.666667 {'楂�'} 鈫� {'浣�', '浼�'} 0.3125 0.833333 2.666667 {'浣�'} 鈫� {'楂�'} 0.3125 1.000000 2.666667 {'浣�', '浼�'} 鈫� {'楂�'} 0.3125 1.000000 2.666667 {'浣�'} 鈫� {'楂�', '浼�'} 0.3125 1.000000 2.666667 宸蹭繚瀛樺叧鑱旇鍒欏垎鏋愬浘鍍� ================================================== 涓氬姟绛栫暐寤鸿 ================================================== 鍚勫煄甯傜瓥鐣ュ缓璁�: 鍩庡競 鏈堢閲� 鍑虹鐜� 绌虹疆鐜� 绛栫暐寤鸿 鍖椾含 234.0 82.8 29.1 椋庨櫓鎺у埗锛氱閲戣皟鏁�(褰撳墠29.1%绌虹疆鐜�)锛屾帰绱㈠叡浜姙鍏紝鎺ㄥ嚭鍘诲寲浼樻儬鏀瓥锛屾彁鍗囪祫浜у洖鎶ョ巼 涓婃捣 171.0 77.3 13.1 涓瓑甯傚満瀹氫綅锛氫紭鍖栫鎴风粨鏋�(鍑虹鐜囷細77.3%)锛屾彁鍗囨湇鍔℃按骞� 骞垮窞 105.0 74.4 10.2 楂樼甯傚満瀹氫綅锛氱淮鎸侀珮风瓥鐣�(105.0鍏�/骞崇背)锛屽惛寮曞ご閮ㄧ鎶�浼佷笟 娣卞湷 196.0 77.0 27.6 椋庨櫓鎺у埗锛氱閲戣皟鏁�(褰撳墠27.6%绌虹疆鐜�)锛屾帰绱㈠叡浜姙鍏紝鎺ㄥ嚭鍘诲寲浼樻儬鏀瓥 鏉窞 86.0 85.5 32.6 椋庨櫓鎺у埗锛氱閲戣皟鏁�(褰撳墠32.6%绌虹疆鐜�)锛屾帰绱㈠叡浜姙鍏紝鎺ㄥ嚭鍘诲寲浼樻儬鏀瓥锛屾彁鍗囪祫浜у洖鎶ョ巼 鍗椾含 178.0 86.5 9.6 椋庨櫓鎺у埗锛氱閲戣皟鏁�(褰撳墠9.6%绌虹疆鐜�)锛屾帰绱㈠叡浜姙鍏紝鎻愬崌璧勪骇鍥炴姤鐜� 鎴愰兘 161.0 89.9 18.8 椋庨櫓鎺у埗锛氱閲戣皟鏁�(褰撳墠18.8%绌虹疆鐜�)锛屾帰绱㈠叡浜姙鍏紝鎻愬崌璧勪骇鍥炴姤鐜� 姝︽眽 81.0 61.8 8.1 椋庨櫓鎺у埗锛氱閲戣皟鏁�(褰撳墠8.1%绌虹疆鐜�)锛屾帰绱㈠叡浜姙鍏� 澶╂触 94.0 84.1 5.4 涓瓑甯傚満瀹氫綅锛氫紭鍖栫鎴风粨鏋�(鍑虹鐜囷細84.1%)锛屾彁鍗囨湇鍔℃按骞筹紝鎻愬崌璧勪骇鍥炴姤鐜� 閲嶅簡 40.0 83.8 19.5 楂樼甯傚満瀹氫綅锛氱淮鎸侀珮风瓥鐣�(40.0鍏�/骞崇背)锛屽惛寮曞ご閮ㄧ鎶�浼佷笟锛屾彁鍗囪祫浜у洖鎶ョ巼 瑗垮畨 132.0 76.3 27.7 涓瓑甯傚満瀹氫綅锛氫紭鍖栫鎴风粨鏋�(鍑虹鐜囷細76.3%)锛屾彁鍗囨湇鍔℃按骞筹紝鎺ㄥ嚭鍘诲寲浼樻儬鏀瓥 鑻忓窞 130.0 88.8 12.4 椋庨櫓鎺у埗锛氱閲戣皟鏁�(褰撳墠12.4%绌虹疆鐜�)锛屾帰绱㈠叡浜姙鍏紝鎻愬崌璧勪骇鍥炴姤鐜� 挎矙 197.0 85.9 31.2 椋庨櫓鎺у埗锛氱閲戣皟鏁�(褰撳墠31.2%绌虹疆鐜�)锛屾帰绱㈠叡浜姙鍏紝鎺ㄥ嚭鍘诲寲浼樻儬鏀瓥锛屾彁鍗囪祫浜у洖鎶ョ巼 闈掑矝 55.0 90.0 10.3 楂樼甯傚満瀹氫綅锛氱淮鎸侀珮风瓥鐣�(55.0鍏�/骞崇背)锛屽惛寮曞ご閮ㄧ鎶�浼佷笟锛屾彁鍗囪祫浜у洖鎶ョ巼 閮戝窞 141.0 71.7 8.7 涓瓑甯傚満瀹氫綅锛氫紭鍖栫鎴风粨鏋�(鍑虹鐜囷細71.7%)锛屾彁鍗囨湇鍔℃按骞� 鍚堣偉 75.0 89.2 14.7 涓瓑甯傚満瀹氫綅锛氫紭鍖栫鎴风粨鏋�(鍑虹鐜囷細89.2%)锛屾彁鍗囨湇鍔℃按骞筹紝鎻愬崌璧勪骇鍥炴姤鐜� 姝e湪淇濆瓨撴灉... 鍒嗘瀽瀹屾垚! 撴灉宸蹭繚瀛樺埌'鍐欏瓧妤煎競鍦哄垎鏋愮粨鏋�.xlsx'鏂囦欢 这样的怎么解决
06-10
library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.numeric_std.all; use ieee.std_logic_arith.all; entity sync is port( clk:in std_logic; --VGA鏃堕挓淇″彿杈撳叆 data_in:in std_logic_vector(7 downto 0);--ADC閲囬泦鏁版嵁杈撳叆 ok:in std_logic; ar:in std_logic; br:in std_logic; hsync,vsync:out std_logic; --杈撳嚭琛屽満淇″彿 r,g,b:out std_logic_vector(3 downto 0)--杈撳嚭RGB淇″彿 ); end; architecture main of sync is --琛屽満淇″彿璁℃暟 signal hpos:integer range 0 to 1688:=0; signal vpos:integer range 0 to 1066:=0; --娉㈠舰璁$畻鍙傛暟 signal V_max:integer range 0 to 5000000:=0; signal V_min:integer range 0 to 5000000:=0; signal Vpp:integer range 0 to 5000000:=0; signal Vrms:integer:=0; signal Hz:integer:=0; --娉㈠舰鏄剧ず鍖哄煙闃靛垪 type data_arr is array(0 to 1024)of integer range 0 to 800;--鏄剧ず灞忔樉绀烘渶澶ч珮搴? signal i:integer range 0 to 1024:=0; signal pic_data:data_arr;--800 X 1024 signal xu:std_logic; signal xu1:std_logic; type picture is array(15 downto 0)of std_logic_vector(7 downto 0); constant num_0 :picture:=(x"00",x"00",x"00",x"38",x"6c",x"c6",x"c6",x"c6",x"c6",x"c6",x"c6",x"c6",x"6c",x"38",x"00",x"00"); constant num_1 :picture:=(x"00",x"00",x"00",x"0c",x"3c",x"0c",x"0c",x"0c",x"0c",x"0c",x"0c",x"0c",x"0c",x"3f",x"00",x"00"); constant num_2 :picture:=(x"00",x"00",x"00",x"3e",x"63",x"63",x"63",x"03",x"06",x"0c",x"18",x"30",x"63",x"7f",x"00",x"00"); constant num_3 :picture:=(x"00",x"00",x"00",x"3e",x"63",x"63",x"03",x"06",x"1c",x"06",x"03",x"63",x"63",x"3e",x"00",x"00"); constant num_4 :picture:=(x"00",x"00",x"00",x"04",x"0c",x"14",x"24",x"24",x"44",x"44",x"7e",x"04",x"04",x"1e",x"00",x"00"); constant num_5 :picture:=(x"00",x"00",x"00",x"7e",x"40",x"40",x"40",x"58",x"64",x"02",x"02",x"42",x"44",x"38",x"00",x"00"); constant num_6 :picture:=(x"00",x"00",x"00",x"1c",x"24",x"40",x"40",x"58",x"64",x"42",x"42",x"42",x"24",x"18",x"00",x"00"); constant num_7 :picture:=(x"00",x"00",x"00",x"7e",x"44",x"44",x"08",x"08",x"10",x"10",x"10",x"10",x"10",x"10",x"00",x"00"); constant num_8 :picture:=(x"00",x"00",x"00",x"3c",x"42",x"42",x"42",x"24",x"18",x"24",x"42",x"42",x"42",x"3c",x"00",x"00"); constant num_9 :picture:=(x"00",x"00",x"00",x"18",x"24",x"42",x"42",x"42",x"26",x"1a",x"02",x"02",x"24",x"38",x"00",x"00"); constant char_dot :picture:=(x"00",x"00",x"00",x"00",x"00",x"00",x"00",x"00",x"00",x"00",x"00",x"00",x"60",x"60",x"00",x"00");--灏忔暟鐐? constant char_V :picture:=(x"00",x"00",x"00",x"e7",x"42",x"42",x"44",x"24",x"24",x"28",x"28",x"18",x"10",x"10",x"00",x"00"); constant char_t :picture:=(x"00",x"00",x"00",x"00",x"00",x"18",x"18",x"7e",x"18",x"18",x"18",x"1b",x"0e",x"00",x"00",x"00"); constant char_u :picture:=(x"00",x"00",x"00",x"00",x"00",x"00",x"63",x"21",x"21",x"21",x"21",x"21",x"23",x"1d",x"00",x"00"); constant char_0 :picture:=(x"00",x"00",x"00",x"18",x"24",x"42",x"42",x"42",x"42",x"42",x"42",x"42",x"24",x"18",x"00",x"00"); constant char_1 :picture:=(x"00",x"00",x"00",x"00",x"C0",x"38",x"04",x"00",x"00",x"60",x"18",x"07",x"00",x"00",x"00",x"00"); constant char_vsou :picture:=(x"80",x"c0",x"e0",x"f0",x"f8",x"fc",x"fe",x"ff",x"fe",x"fc",x"f8",x"f0",x"e0",x"c0",x"80",x"00"); constant char_hsou1 :picture:=(x"00",x"80",x"80",x"c0",x"c0",x"e0",x"e0",x"f0",x"f0",x"f8",x"f8",x"fc",x"fc",x"fe",x"fe",x"ff"); constant char_hsou2 :picture:=(x"00",x"01",x"01",x"03",x"03",x"07",x"07",x"0f",x"0f",x"1f",x"1f",x"3f",x"3f",x"7f",x"7f",x"ff"); type picture2 is array(31 downto 0)of std_logic_vector(15 downto 0); constant char_M :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"f00f",x"381c",x"381c",x"381c",x"381c",x"382c",x"2c2c",x"2c2c",x"2c2c", x"2c4c",x"2c4c",x"264c",x"264c",x"264c",x"268c",x"228c",x"238c",x"238c",x"230c",x"230c",x"210c",x"f13f",x"0000",x"0000",x"0000",x"0000"); constant char_a :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"07e0",x"1830", x"3018",x"3018",x"3018",x"0038",x"07d8",x"1c18",x"3018",x"6018",x"6018",x"6018",x"6019",x"3079",x"1f8e",x"0000",x"0000",x"0000",x"0000"); constant char_x :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"3e7c",x"0c10", x"0e10",x"0620",x"0340",x"0340",x"0180",x"0180",x"01c0",x"0260",x"0460",x"0430",x"0818",x"1818",x"7c7e",x"0000",x"0000",x"0000",x"0000"); constant char_dV :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"7c1e",x"180c",x"1808",x"1808",x"1808",x"0c10",x"0c10",x"0c10",x"0c10", x"0c20",x"0620",x"0620",x"0620",x"0640",x"0340",x"0340",x"0340",x"0380",x"0180",x"0180",x"0100",x"0100",x"0000",x"0000",x"0000",x"0000"); constant char_r :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"061c",x"7e66", x"0686",x"0780",x"0700",x"0600",x"0600",x"0600",x"0600",x"0600",x"0600",x"0600",x"0600",x"0600",x"7fe0",x"0000",x"0000",x"0000",x"0000"); constant char_xm :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"2000",x"ef3c",x"71c6", x"6186",x"6186",x"6186",x"6186",x"6186",x"6186",x"6186",x"6186",x"6186",x"6186",x"6186",x"6186",x"f3cf",x"0000",x"0000",x"0000",x"0000"); constant char_s :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"03e4",x"061c", x"0c0c",x"0c04",x"0c04",x"0e00",x"07c0",x"01f0",x"0078",x"001c",x"100c",x"100c",x"180c",x"1c18",x"13f0",x"0000",x"0000",x"0000",x"0000"); constant char_q :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"03c8",x"0c78", x"1838",x"1818",x"3018",x"3018",x"3018",x"3018",x"3018",x"3018",x"3018",x"1018",x"1838",x"0c78",x"0798",x"0018",x"0018",x"0018",x"007e"); constant char_i :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0180",x"03c0",x"0180",x"0000",x"0000",x"0000",x"0080",x"1f80",x"0180", x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",x"1ff8",x"0000",x"0000",x"0000",x"0000"); constant char_n :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"09e0",x"7a30", x"1c18",x"1818",x"1818",x"1818",x"1818",x"1818",x"1818",x"1818",x"1818",x"1818",x"1818",x"1818",x"7e7e",x"0000",x"0000",x"0000",x"0000"); constant char_p :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"09e0",x"7a30", x"1c18",x"1808",x"180c",x"180c",x"180c",x"180c",x"180c",x"180c",x"180c",x"1818",x"1c18",x"1e30",x"19e0",x"1800",x"1800",x"1800",x"7e00"); constant char_e :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"03C0",x"0C30", x"0818",x"1808",x"300C",x"300C",x"300C",x"3FFC",x"3000",x"3000",x"3000",x"1804",x"1808",x"0E18",x"03E0",x"0000",x"0000",x"0000",x"0000"); constant char_F :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"7ffc",x"181c",x"1804",x"1802",x"1802",x"1800",x"1800",x"1810",x"1810", x"1830",x"1ff0",x"1830",x"1810",x"1810",x"1810",x"1800",x"1800",x"1800",x"1800",x"1800",x"1800",x"7e00",x"0000",x"0000",x"0000",x"0000"); constant num_d0 :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"03c0",x"0620",x"0c30",x"1818",x"1818",x"1808",x"300c",x"300c",x"300c", x"300c",x"300c",x"300c",x"300c",x"300c",x"300c",x"300c",x"1808",x"1818",x"1818",x"0c30",x"0620",x"03c0",x"0000",x"0000",x"0000",x"0000"); constant num_d1 :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0080",x"0180",x"1f80",x"0180",x"0180",x"0180",x"0180",x"0180",x"0180", x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",x"03c0",x"1ff8",x"0000",x"0000",x"0000",x"0000"); constant num_d2 :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"07e0",x"0838",x"1018",x"200c",x"200c",x"300c",x"300c",x"000c",x"0018", x"0018",x"0030",x"0060",x"00c0",x"0180",x"0300",x"0200",x"0404",x"0804",x"1004",x"200c",x"3ff8",x"3ff8",x"0000",x"0000",x"0000",x"0000"); constant num_d3 :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"07c0",x"1860",x"3030",x"3018",x"3018",x"3018",x"0018",x"0018",x"0030", x"0060",x"03c0",x"0070",x"0018",x"0008",x"000c",x"000c",x"300c",x"300c",x"3008",x"3018",x"1830",x"07c0",x"0000",x"0000",x"0000",x"0000"); constant num_d4 :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0060",x"0060",x"00e0",x"00e0",x"0160",x"0160",x"0260",x"0460",x"0460", x"0860",x"0860",x"1060",x"3060",x"2060",x"4060",x"7ffc",x"0060",x"0060",x"0060",x"0060",x"0060",x"03fc",x"0000",x"0000",x"0000",x"0000"); constant num_d5 :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0ffc",x"0ffc",x"1000",x"1000",x"1000",x"1000",x"1000",x"1000",x"13e0", x"1430",x"1818",x"1008",x"000c",x"000c",x"000c",x"000c",x"300c",x"300c",x"2018",x"2018",x"1830",x"07c0",x"0000",x"0000",x"0000",x"0000"); constant num_d6 :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"01e0",x"0618",x"0c18",x"0818",x"1800",x"1000",x"1000",x"3000",x"33e0", x"3630",x"3818",x"3808",x"300c",x"300c",x"300c",x"300c",x"300c",x"180c",x"1808",x"0c18",x"0e30",x"03e0",x"0000",x"0000",x"0000",x"0000"); constant num_d7 :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"1ffc",x"1ffc",x"1008",x"3010",x"2010",x"2020",x"0020",x"0040",x"0040", x"0040",x"0080",x"0080",x"0100",x"0100",x"0100",x"0100",x"0300",x"0300",x"0300",x"0300",x"0300",x"0300",x"0000",x"0000",x"0000",x"0000"); constant num_d8 :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"07e0",x"0c30",x"1818",x"300c",x"300c",x"300c",x"380c",x"3808",x"1e18", x"0f20",x"07c0",x"18f0",x"3078",x"3038",x"601c",x"600c",x"600c",x"600c",x"600c",x"3018",x"1830",x"07c0",x"0000",x"0000",x"0000",x"0000"); constant num_d9 :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"07c0",x"1820",x"3010",x"3018",x"6008",x"600c",x"600c",x"600c",x"600c", x"600c",x"701c",x"302c",x"186c",x"0f8c",x"000c",x"0018",x"0018",x"0010",x"3030",x"3060",x"30c0",x"0f80",x"0000",x"0000",x"0000",x"0000"); constant char_H :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"fc3f",x"300c",x"300c",x"300c",x"300c",x"300c",x"300c",x"300c",x"300c", x"300c",x"3ffc",x"300c",x"300c",x"300c",x"300c",x"300c",x"300c",x"300c",x"300c",x"300c",x"300c",x"fc3f",x"0000",x"0000",x"0000",x"0000"); constant char_z :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"3ff8",x"3038", x"3030",x"2060",x"20e0",x"00c0",x"0180",x"0380",x"0300",x"0600",x"0e04",x"0c04",x"180c",x"3018",x"3ff8",x"0000",x"0000",x"0000",x"0000"); constant char_G :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"03C0",x"0C30",x"0810",x"1818",x"3008",x"3008",x"2000",x"6000",x"6000", x"6000",x"6000",x"6000",x"607E",x"6018",x"6018",x"2018",x"3018",x"3018",x"1018",x"1818",x"0C20",x"07C0",x"0000",x"0000",x"0000",x"0000"); constant char_do :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"03C0",x"0C30", x"0818",x"1818",x"100C",x"300C",x"300C",x"300C",x"300C",x"300C",x"300C",x"1818",x"1818",x"0C30",x"03C0",x"0000",x"0000",x"0000",x"0000"); constant char_du :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0808",x"7878",x"1818", x"1818",x"1818",x"1818",x"1818",x"1818",x"1818",x"1818",x"1818",x"1818",x"1818",x"1838",x"0C5E",x"0790",x"0000",x"0000",x"0000",x"0000"); constant char_dL :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"7E00",x"1800",x"1800",x"1800",x"1800",x"1800",x"1800",x"1800",x"1800", x"1800",x"1800",x"1800",x"1800",x"1800",x"1800",x"1800",x"1800",x"1802",x"1802",x"1804",x"180C",x"7FFC",x"0000",x"0000",x"0000",x"0000"); constant char_dX :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"7C3E",x"1808",x"1810",x"0C10",x"0C20",x"0620",x"0640",x"0340",x"0380", x"0180",x"0180",x"0180",x"01C0",x"02C0",x"0260",x"0460",x"0470",x"0830",x"0830",x"1818",x"101C",x"7C3E",x"0000",x"0000",x"0000",x"0000"); constant char_dH :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"FC3F",x"300C",x"300C",x"300C",x"300C",x"300C",x"300C",x"300C",x"300C", x"300C",x"3FFC",x"300C",x"300C",x"300C",x"300C",x"300C",x"300C",x"300C",x"300C",x"300C",x"300C",x"FC3F",x"0000",x"0000",x"0000",x"0000"); ----------------------------------------- type picture3 is array(254 downto 0)of std_logic_vector(255 downto 0); begin --oooooooooooooooooooooooooooooo1鏃堕挓 process(clk,vpos,hpos) variable hp:integer range 0 to 16:=0; variable vp:integer range 0 to 16:=0; begin if(clk'event and clk='1')then ----- if(hpos<1688)then hpos<=hpos+1; else hpos<=0; if(vpos<1066)then vpos<=vpos+1; else vpos<=0; end if; --- vp:=vp+1; if(vp<=8)then xu1<='0'; else xu1<='1'; end if; if(vp=16)then vp:=0; end if; --- end if; ---- hp:=hp+1; if(hp<=8)then xu<='0'; else xu<='1'; end if; if(hp=16)then hp:=0; end if; ----- ----- if(hpos>48 and hpos<160)then hsync<='0'; else hsync<='1'; end if; ----- if(vpos>0 and vpos<4)then vsync<='0'; else vsync<='1'; end if; ----- end if; end process; ------------------------------------------鏁版嵁澶勭悊涓庤绠? process(ok) variable data:integer range 0 to 500000:=0;--杈撳叆鏁版嵁 variable h:integer:=0;--棰戠巼 variable flag:integer:=0; variable count:integer:=0;--ok鏃堕挓璁℃暟 variable V:integer range 0 to 255:=0;--鏈€澶у€? variable Vi:integer range 0 to 255:=255;--鏈€灏忓€? variable first:integer range 0 to 1:=0; variable last_data:integer range 0 to 500000:=0; variable j:integer range 0 to 5:=0; begin if(ok'event and ok='1')then data:=conv_integer(data_in); if(data = V_max/129/2)and (data>last_data) then first:=1; end if; j:=j+1; if(j=5)then last_data:=data; j:=0; end if; if (first=1)then pic_data(i)<=data*2; i<=i+1; end if; if(i=1024)then i<=0; first:=0; end if; if(count=49999)then V_max<=V*129;--V*3.3/255*10000 V_min<=Vi*129; Vpp<=V_max-V_min; Vrms<=Vpp*85355/100000;--/2*1.707... Hz<=h; h:=0; V:=0; Vi:=255; count:=0; else count:=count+1; if(V<data)then V:=data; end if; if(data<Vi)then Vi:=data; end if; if(data*129<(V_max+V_min)/2)then flag:=1; elsif(flag=1)then h:=h+1; flag:=0; end if; end if; end if; end process; --樺埗 process(clk,ar) variable do:std_logic:='0';--鍍礌鐐规樉绀烘爣椾俊鍙? variable data_x:integer range 0 to 2000;--娉㈠舰鏄剧ず鍖哄煙X杞村潗鏍? variable an:integer range 0 to 20000:=1; begin --------------------------------樺埗鍧愭爣绯?------------------------------------ --妯珫鍧愭爣杞? --绔栫嚎瀹? --绔栫嚎? --妯嚎瀹? --妯嚎? if(((hpos>506 and hpos<510) and(vpos>205+250 and vpos<750+250)) or ((vpos>748+250 and vpos<752+250) and (hpos>508 and hpos<1579)))then r<=(others=>'1'); g<=(others=>'1'); b<=(others=>'1'); --妯埢搴︾偣 --涓婄偣 --涓偣 --涓嬬偣 --鐐归暱 elsif((((vpos>283+250 and vpos<287+250) or (vpos>438+250 and vpos<442+250) or (vpos>593+250 and vpos<597+250))and(hpos>=508 and hpos<=516)))then r<=(others=>'1'); g<=(others=>'1'); b<=(others=>'1'); --妯埢搴︾嚎 --涓婄嚎 --涓嚎 --涓嬬嚎 --妯嚎? elsif(((vpos=285+250) or (vpos=440+250) or (vpos=595+250)) and (hpos>=508 and hpos<=1579))then r<=(others=>'1'); g<=(others=>'1'); b<=(others=>'1'); --绔栧埢搴︾嚎 --宸︾嚎 --鍙崇嚎 --绔栫嚎? elsif((((hpos=615) or (hpos=722) or (hpos=829)or(hpos=936) or (hpos=1043) or (hpos=1150)or(hpos=1257) or (hpos=1364) or (hpos=1471)or (hpos=1578))and(vpos>205+250 and vpos<750+250)))then --鍒诲害绾? r<=(others=>'1'); g<=(others=>'1'); b<=(others=>'1'); --鍏朵綑娑傞粦 else r<=(others=>'0'); g<=(others=>'0'); b<=(others=>'0'); end if; ---------------------------------------------------------------------------------- ------------------------------鍒诲害鏁?--------------------------------- if(hpos>484 and hpos<492)then---------------0 if(vpos>740+250 and vpos<758+250)then do:=num_0(758+250-vpos)(492-hpos); if(do='1')then r<=(others=>'1'); g<=(others=>'1'); b<=(others=>'1'); end if; end if; if(vpos>586+250 and vpos<604+250)then---1 do:=num_1(604+250-vpos)(492-hpos); if(do='1')then r<=(others=>'1'); g<=(others=>'1'); b<=(others=>'1'); end if; end if; if(vpos>431+250 and vpos<449+250)then---2 do:=num_2(449+250-vpos)(492-hpos); if(do='1')then r<=(others=>'1'); g<=(others=>'1'); b<=(others=>'1'); end if; end if; if(vpos>276+250 and vpos<294+250)then---3 do:=num_3(294+250-vpos)(492-hpos); if(do='1')then r<=(others=>'1'); g<=(others=>'1'); b<=(others=>'1'); end if; end if; end if; --------------鏍囩--------------------- --鏍囩max if(vpos>832-600 and vpos<865-600)then if(hpos>767-240 and hpos<783-240)then do:=char_M(865-600-vpos)(783-240-hpos); if(do='1')then r<=(others=>'1'); g<=(others=>'1'); b<=(others=>'1'); end if; end if; if(hpos>790-240 and hpos<806-240)then do:=char_a(865-600-vpos)(806-240-hpos); if(do='1')then r<=(others=>'1'); g<=(others=>'1'); b<=(others=>'1'); end if; end if; if(hpos>813-240 and hpos<829-240)then do:=char_x(865-600-vpos)(829-240-hpos); if(do='1')then r<=(others=>'1'); g<=(others=>'1'); b<=(others=>'1'); end if; end if; --鏍囩min if(hpos>867-240 and hpos<883-240)then do:=char_M(865-600-vpos)(883-240-hpos); if(do='1')then r<=(others=>'1'); g<=(others=>'1'); b<=(others=>'1'); end if; end if; if(hpos>890-240 and hpos<906-240)then do:=char_i(865-600-vpos)(906-240-hpos); if(do='1')then r<=(others=>'1'); g<=(others=>'1'); b<=(others=>'1'); end if; end if; if(hpos>913-240 and hpos<929-240)then do:=char_n(865-600-vpos)(929-240-hpos); if(do='1')then r<=(others=>'1'); g<=(others=>'1'); b<=(others=>'1'); end if; end if; --鏍囩vrms if(hpos>1558-240 and hpos<1574-240)then do:=char_dV(865-600-vpos)(1574-240-hpos); if(do='1')then r<=(others=>'1'); g<=(others=>'1'); b<=(others=>'1'); end if; end if; if(hpos>1583-240 and hpos<1599-240)then do:=char_r(865-600-vpos)(1599-240-hpos); if(do='1')then r<=(others=>'1'); g<=(others=>'1'); b<=(others=>'1'); end if; end if; if(hpos>1608-240 and hpos<1624-240)then do:=char_xm(865-600-vpos)(1624-240-hpos); if(do='1')then r<=(others=>'1'); g<=(others=>'1'); b<=(others=>'1'); end if; end if; if(hpos>1633-240 and hpos<1649-240)then do:=char_s(865-600-vpos)(1649-240-hpos); if(do='1')then r<=(others=>'1'); g<=(others=>'1'); b<=(others=>'1'); end if; end if; --鏍囩freq if(hpos>1662-240 and hpos<1678-240)then do:=char_F(865-600-vpos)(1678-240-hpos); if(do='1')then r<=(others=>'1'); g<=(others=>'1'); b<=(others=>'1'); end if; end if; if(hpos>1687-240 and hpos<1703-240)then do:=char_r(865-600-vpos)(1703-240-hpos); if(do='1')then r<=(others=>'1'); g<=(others=>'1'); b<=(others=>'1'); end if; end if; if(hpos>1712-240 and hpos<1728-240)then do:=char_e(865-600-vpos)(1728-240-hpos); if(do='1')then r<=(others=>'1'); g<=(others=>'1'); b<=(others=>'1'); end if; end if; if(hpos>1737-240 and hpos<1753-240)then do:=char_q(865-600-vpos)(1753-240-hpos); if(do='1')then r<=(others=>'1'); g<=(others=>'1'); b<=(others=>'1'); end if; end if; end if; ------------------------------------鏁版嵁-------------------------------- ---------Vmax if(vpos>932-600and vpos<965-600)then if(hpos>760-240 and hpos<776-240)then case (V_max/10000) is when 0=> do:=num_d0(965-600-vpos)(776-240-hpos); when 1=> do:=num_d1(965-600-vpos)(776-240-hpos); when 2=> do:=num_d2(965-600-vpos)(776-240-hpos); when 3=> do:=num_d3(965-600-vpos)(776-240-hpos); when 4=> do:=num_d4(965-600-vpos)(776-240-hpos); when 5=> do:=num_d5(965-600-vpos)(776-240-hpos); when 6=> do:=num_d6(965-600-vpos)(776-240-hpos); when 7=> do:=num_d7(965-600-vpos)(776-240-hpos); when 8=> do:=num_d8(965-600-vpos)(776-240-hpos); when 9=> do:=num_d9(965-600-vpos)(776-240-hpos); when others => do:='0'; end case; if(do='1')then r<="0001"; g<="0001"; b<="0001"; end if; end if; if(hpos>776-240 and hpos<784-240 and vpos>949-600) then do:=char_dot(965-600-vpos)(784-240-hpos); if(do='1') then r<="0001"; g<="0001"; b<="0001"; end if; end if; if(hpos>784-240 and hpos<800-240)then case ((V_max/1000)REM 10) is when 0=> do:=num_d0(965-600-vpos)(800-240-hpos); when 1=> do:=num_d1(965-600-vpos)(800-240-hpos); when 2=> do:=num_d2(965-600-vpos)(800-240-hpos); when 3=> do:=num_d3(965-600-vpos)(800-240-hpos); when 4=> do:=num_d4(965-600-vpos)(800-240-hpos); when 5=> do:=num_d5(965-600-vpos)(800-240-hpos); when 6=> do:=num_d6(965-600-vpos)(800-240-hpos); when 7=> do:=num_d7(965-600-vpos)(800-240-hpos); when 8=> do:=num_d8(965-600-vpos)(800-240-hpos); when 9=> do:=num_d9(965-600-vpos)(800-240-hpos); when others => do:='0'; end case; if(do='1')then r<="0001"; g<="0001"; b<="0001"; end if; end if; if(hpos>800-240 and hpos<816-240)then case ((V_max/100)REM 10) is when 0=> do:=num_d0(965-600-vpos)(816-240-hpos); when 1=> do:=num_d1(965-600-vpos)(816-240-hpos); when 2=> do:=num_d2(965-600-vpos)(816-240-hpos); when 3=> do:=num_d3(965-600-vpos)(816-240-hpos); when 4=> do:=num_d4(965-600-vpos)(816-240-hpos); when 5=> do:=num_d5(965-600-vpos)(816-240-hpos); when 6=> do:=num_d6(965-600-vpos)(816-240-hpos); when 7=> do:=num_d7(965-600-vpos)(816-240-hpos); when 8=> do:=num_d8(965-600-vpos)(816-240-hpos); when 9=> do:=num_d9(965-600-vpos)(816-240-hpos); when others => do:='0'; end case; if(do='1')then r<="0001"; g<="0001"; b<="0001"; end if; end if; --鍗曚綅 if(hpos>816-240 and hpos<832-240)then do:=char_dV(965-600-vpos)(832-240-hpos); if(do='1')then r<="0001"; g<="0001"; b<="0001"; end if; end if; ---------V_min if(hpos>860-240 and hpos<876-240)then case (V_min/10000) is when 0=> do:=num_d0(965-600-vpos)(876-240-hpos); when 1=> do:=num_d1(965-600-vpos)(876-240-hpos); when 2=> do:=num_d2(965-600-vpos)(876-240-hpos); when 3=> do:=num_d3(965-600-vpos)(876-240-hpos); when 4=> do:=num_d4(965-600-vpos)(876-240-hpos); when 5=> do:=num_d5(965-600-vpos)(876-240-hpos); when 6=> do:=num_d6(965-600-vpos)(876-240-hpos); when 7=> do:=num_d7(965-600-vpos)(876-240-hpos); when 8=> do:=num_d8(965-600-vpos)(876-240-hpos); when 9=> do:=num_d9(965-600-vpos)(876-240-hpos); when others => do:='0'; end case; if(do='1')then r<="0001"; g<="0001"; b<="0001"; end if; end if; if(hpos>876-240 and hpos<884-240 and vpos>949-600) then do:=char_dot(965-600-vpos)(884-240-hpos); if(do='1') then r<="0001"; g<="0001"; b<="0001"; end if; end if; if(hpos>884-240 and hpos<900-240)then case ((V_min/1000)REM 10) is when 0=> do:=num_d0(965-600-vpos)(900-240-hpos); when 1=> do:=num_d1(965-600-vpos)(900-240-hpos); when 2=> do:=num_d2(965-600-vpos)(900-240-hpos); when 3=> do:=num_d3(965-600-vpos)(900-240-hpos); when 4=> do:=num_d4(965-600-vpos)(900-240-hpos); when 5=> do:=num_d5(965-600-vpos)(900-240-hpos); when 6=> do:=num_d6(965-600-vpos)(900-240-hpos); when 7=> do:=num_d7(965-600-vpos)(900-240-hpos); when 8=> do:=num_d8(965-600-vpos)(900-240-hpos); when 9=> do:=num_d9(965-600-vpos)(900-240-hpos); when others => do:='0'; end case; if(do='1')then r<="0001"; g<="0001"; b<="0001"; end if; end if; if(hpos>900-240 and hpos<916-240)then case ((V_min/100)REM 10) is when 0=> do:=num_d0(965-600-vpos)(916-240-hpos); when 1=> do:=num_d1(965-600-vpos)(916-240-hpos); when 2=> do:=num_d2(965-600-vpos)(916-240-hpos); when 3=> do:=num_d3(965-600-vpos)(916-240-hpos); when 4=> do:=num_d4(965-600-vpos)(916-240-hpos); when 5=> do:=num_d5(965-600-vpos)(916-240-hpos); when 6=> do:=num_d6(965-600-vpos)(916-240-hpos); when 7=> do:=num_d7(965-600-vpos)(916-240-hpos); when 8=> do:=num_d8(965-600-vpos)(916-240-hpos); when 9=> do:=num_d9(965-600-vpos)(916-240-hpos); when others => do:='0'; end case; if(do='1')then r<="0001"; g<="0001"; b<="0001"; end if; end if; --鍗曚綅 if(hpos>916-240 and hpos<932-240)then do:=char_dV(965-600-vpos)(932-240-hpos); if(do='1')then r<="0001"; g<="0001"; b<="0001"; end if; end if; ---------Vrms if(hpos>1557-240 and hpos<1573-240)then case (Vrms/10000) is when 0=> do:=num_d0(965-600-vpos)(1573-240-hpos); when 1=> do:=num_d1(965-600-vpos)(1573-240-hpos); when 2=> do:=num_d2(965-600-vpos)(1573-240-hpos); when 3=> do:=num_d3(965-600-vpos)(1573-240-hpos); when 4=> do:=num_d4(965-600-vpos)(1573-240-hpos); when 5=> do:=num_d5(965-600-vpos)(1573-240-hpos); when 6=> do:=num_d6(965-600-vpos)(1573-240-hpos); when 7=> do:=num_d7(965-600-vpos)(1573-240-hpos); when 8=> do:=num_d8(965-600-vpos)(1573-240-hpos); when 9=> do:=num_d9(965-600-vpos)(1573-240-hpos); when others => do:='0'; end case; if(do='1')then r<="0001"; g<="0001"; b<="0001"; end if; end if; if(hpos>1573-240 and hpos<1589-240 and vpos>949-600) then do:=char_dot(965-600-vpos)(1589-240-hpos); if(do='1') then r<="0001"; g<="0001"; b<="0001"; end if; end if; if(hpos>1589-240 and hpos<1605-240)then case ((Vrms/1000)REM 10) is when 0=> do:=num_d0(965-600-vpos)(1605-240-hpos); when 1=> do:=num_d1(965-600-vpos)(1605-240-hpos); when 2=> do:=num_d2(965-600-vpos)(1605-240-hpos); when 3=> do:=num_d3(965-600-vpos)(1605-240-hpos); when 4=> do:=num_d4(965-600-vpos)(1605-240-hpos); when 5=> do:=num_d5(965-600-vpos)(1605-240-hpos); when 6=> do:=num_d6(965-600-vpos)(1605-240-hpos); when 7=> do:=num_d7(965-600-vpos)(1605-240-hpos); when 8=> do:=num_d8(965-600-vpos)(1605-240-hpos); when 9=> do:=num_d9(965-600-vpos)(1605-240-hpos); when others => do:='0'; end case; if(do='1')then r<="0001"; g<="0001"; b<="0001"; end if; end if; if(hpos>1605-240 and hpos<1621-240)then case ((Vrms/100)REM 10) is when 0=> do:=num_d0(965-600-vpos)(1621-240-hpos); when 1=> do:=num_d1(965-600-vpos)(1621-240-hpos); when 2=> do:=num_d2(965-600-vpos)(1621-240-hpos); when 3=> do:=num_d3(965-600-vpos)(1621-240-hpos); when 4=> do:=num_d4(965-600-vpos)(1621-240-hpos); when 5=> do:=num_d5(965-600-vpos)(1621-240-hpos); when 6=> do:=num_d6(965-600-vpos)(1621-240-hpos); when 7=> do:=num_d7(965-600-vpos)(1621-240-hpos); when 8=> do:=num_d8(965-600-vpos)(1621-240-hpos); when 9=> do:=num_d9(965-600-vpos)(1621-240-hpos); when others => do:='0'; end case; if(do='1')then r<="0001"; g<="0001"; b<="0001"; end if; end if; --鍗曚綅 if(hpos>1621-240 and hpos<1637-240)then do:=char_dV(965-600-vpos)(1637-240-hpos); if(do='1')then r<="0001"; g<="0001"; b<="0001"; end if; end if; ---------Freq if(hpos>1657-240 and hpos<1673-240)then case (Hz/1000) is when 0=> do:=num_d0(965-600-vpos)(1673-240-hpos); when 1=> do:=num_d1(965-600-vpos)(1673-240-hpos); when 2=> do:=num_d2(965-600-vpos)(1673-240-hpos); when 3=> do:=num_d3(965-600-vpos)(1673-240-hpos); when 4=> do:=num_d4(965-600-vpos)(1673-240-hpos); when 5=> do:=num_d5(965-600-vpos)(1673-240-hpos); when 6=> do:=num_d6(965-600-vpos)(1673-240-hpos); when 7=> do:=num_d7(965-600-vpos)(1673-240-hpos); when 8=> do:=num_d8(965-600-vpos)(1673-240-hpos); when 9=> do:=num_d9(965-600-vpos)(1673-240-hpos); when others => do:='0'; end case; if(do='1')then r<="0001"; g<="0001"; b<="0001"; end if; end if; if(hpos>1673-240 and hpos<1689-240)then case ((Hz/100)REM 10) is when 0=> do:=num_d0(965-600-vpos)(1689-240-hpos); when 1=> do:=num_d1(965-600-vpos)(1689-240-hpos); when 2=> do:=num_d2(965-600-vpos)(1689-240-hpos); when 3=> do:=num_d3(965-600-vpos)(1689-240-hpos); when 4=> do:=num_d4(965-600-vpos)(1689-240-hpos); when 5=> do:=num_d5(965-600-vpos)(1689-240-hpos); when 6=> do:=num_d6(965-600-vpos)(1689-240-hpos); when 7=> do:=num_d7(965-600-vpos)(1689-240-hpos); when 8=> do:=num_d8(965-600-vpos)(1689-240-hpos); when 9=> do:=num_d9(965-600-vpos)(1689-240-hpos); when others => do:='0'; end case; if(do='1')then r<="0001"; g<="0001"; b<="0001"; end if; end if; if(hpos>1689-240 and hpos<1705-240)then case ((Hz/10)REM 10) is when 0=> do:=num_d0(965-600-vpos)(1705-240-hpos); when 1=> do:=num_d1(965-600-vpos)(1705-240-hpos); when 2=> do:=num_d2(965-600-vpos)(1705-240-hpos); when 3=> do:=num_d3(965-600-vpos)(1705-240-hpos); when 4=> do:=num_d4(965-600-vpos)(1705-240-hpos); when 5=> do:=num_d5(965-600-vpos)(1705-240-hpos); when 6=> do:=num_d6(965-600-vpos)(1705-240-hpos); when 7=> do:=num_d7(965-600-vpos)(1705-240-hpos); when 8=> do:=num_d8(965-600-vpos)(1705-240-hpos); when 9=> do:=num_d9(965-600-vpos)(1705-240-hpos); when others => do:='0'; end case; if(do='1')then r<="0001"; g<="0001"; b<="0001"; end if; end if; if(hpos>1705-240 and hpos<1721-240)then case (Hz REM 10) is when 0=> do:=num_d0(965-600-vpos)(1721-240-hpos); when 1=> do:=num_d1(965-600-vpos)(1721-240-hpos); when 2=> do:=num_d2(965-600-vpos)(1721-240-hpos); when 3=> do:=num_d3(965-600-vpos)(1721-240-hpos); when 4=> do:=num_d4(965-600-vpos)(1721-240-hpos); when 5=> do:=num_d5(965-600-vpos)(1721-240-hpos); when 6=> do:=num_d6(965-600-vpos)(1721-240-hpos); when 7=> do:=num_d7(965-600-vpos)(1721-240-hpos); when 8=> do:=num_d8(965-600-vpos)(1721-240-hpos); when 9=> do:=num_d9(965-600-vpos)(1721-240-hpos); when others => do:='0'; end case; if(do='1')then r<="0001"; g<="0001"; b<="0001"; end if; end if; --鍗曚綅 if(hpos>1721-240 and hpos<1737-240)then do:=char_H(965-600-vpos)(1737-240-hpos); if(do='1')then r<="0001"; g<="0001"; b<="0001"; end if; end if; if(hpos>1737-240 and hpos<1753-240)then do:=char_z(965-600-vpos)(1753-240-hpos); if(do='1')then r<="0001"; g<="0001"; b<="0001"; end if; end if; end if; if(falling_edge(ar))then if(br='1' and an < 20000)then an:=an+1; elsif(br='0' and an > 0)then an:=an-1; end if; end if; ----------------------------娉㈠舰樺埗----------------------------- if(hpos>=508 and hpos<1532)then--鏄剧ず垮害鍒掑畾 data_x := hpos-508;--X鍧愭爣 if(vpos<750+250-pic_data(data_x)-an/100+3 and vpos>750+250-pic_data(data_x)-an/100-3) then r<=(others=>'1'); g<=(others=>'1'); b<=(others=>'0'); elsif (data_x < 1024) and ( vpos=((750+250-pic_data(data_x)) + (750+250-pic_data(data_x+1)))/2 -an/100 or vpos=((750+250-pic_data(data_x)) + 2 * (750+250-pic_data(data_x+1)))/3 -an/100 or vpos=(2 * (750+250-pic_data(data_x)) + (750+250-pic_data(data_x+1)))/3 -an/100 ) then r<=(others=>'1'); g<=(others=>'1'); b<=(others=>'0'); end if; end if; end process; end; 帮我分析这个VGA显示器的工作原理
最新发布
09-21
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值