完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
嗨,大家好,
你们中的许多人可能不知道PSoC 5LP中饱和指令是怎么做的。PSoC 5lp采用Cortex-M3内核有两个特殊的指令称为“SSAT”(签署饱和度)和“门”(无符号饱和)。这些指令是用来限制变量或一定数量的位值。(参考文献: 例如,如果你有一个8位的变量,当然如果你知道该变量的值不会超过127号说,你想把任何价值127以上为127本身(饱和度)和任何低于0的值为零的本身。在这种情况下,你需要其他的条件语句比较变127和采取必要的行动,以写一个大的C代码。相反,为了简化这个逻辑,你可以利用饱和assemblyinstructions,Cortex-M3(PSoC 5lp核心)支持。请注意,GCC和MDK编译器不将此指令本身等价的C代码。 例如,在上面的例子中,限制我的结果的比特数是7(2 ^ 7-1 = 127)。假设我在登记R0如果我想储存饱和导致登记R3的饱和值,我的汇编指令会 “USAT R3,8,R0” 类似的语法是签署了饱和指定一个正极限和签名变消极的限制。我希望你知道的语法包括C代码的汇编指令。 问候,Asha 注: 仅供参考,如果您想指定一个变量的一个特定的登记,语法是“登记(数据类型)* variable_name ASM(“登记名字”);“ 例如:注册UTIN 8*输出ASM(“R0”); DDI037EYCORTEXM3R1P1TRO.PDF 2.1兆字节 以上来自于百度翻译 以下为原文 Hi All, Many of you may not be aware of what saturation instructions do in PSoC 5LP. PSoC 5LP uses Cortex-M3 core which has two special instructions called "SSAT" (Signed saturation) and "USAT" (Unsigned saturation). These instructions are used to limit a variable or a value to a certain number of bits. (Reference: For example, if you have an 8 bit variable and for sure if you know that the value of the variable will not exceed a number 127 say, you would like to round off any value above 127 as 127 itself ( saturation) and any value below 0 as zero itself. In this case you need to write a big C code using if-else conditional statement to compare the variable with 127 and take the necessary action. Instead, to simplify this logic, you can make use of the saturation assembly instructions which Cortex-M3 (core of PSoC 5LP) supports. Please note that both GCC and MDK compilers do not append this instruction by itself for an equivalent C code. For example, in the above example, the number of bits to restrict my result to would be 7 (2^7-1 = 127). Assuming I have the unsaturated value in register r0 and if I would like to store the saturated result in register r3, my assembly instruction would be "usat r3, 8, r0" Similar syntax is for signed saturation for specifying a positive limit and a negative limit for a signed variable. I hope you know the syntax to include an assembly instruction in C code. Regards, Asha Note: FYI, if you would like to assign a variable to a particular register, the syntax is "register (data type)* variable_name asm("register name");" For example: register uint8* output asm ("r0"); |
|
相关推荐
10个回答
|
|
学习新事物很好。然而,除了一些时间功能,大多数项目经理都倾向于使用高级语言。
以上来自于百度翻译 以下为原文 Good to learn somthing new. However, except for some time critial functions, most project managers would prefer to use high level language. |
|
|
|
@ Asha,正如你指出的,登高算法的特点非常重要。
性能的DSP应用,这将严重影响C溶液,如样品 速率等。 结合内联C使其易于实现。 有趣。让我不知道有多少代码空间/速度可以更换保存/改进 的… var =(var & gt;10)?10,VAR + 1;/ /类型的构造。 问候,Dana。 以上来自于百度翻译 以下为原文 @Asha, as you point out the feature of staurating arithmetic very importent to high performance DSP applications, which C solution would severly impact, eg. sample rate, etc.. Coupled with inline C makes it easy to implement. Interesting. Makes me wonder how much code space/speed could be saved/improved in replacement of .... var = ( var > 10 ) ? 10, var + 1; // type of constructs. Regards, Dana. |
|
|
|
…代码不太多。因为你的“10”从你的例子将不工作(不是2的幂)我们必须rewite上面的例子
var =(var & gt;127)?0:无功+ 1;//记住:C需要冒号分开的两个值 我已经建立了一个工程实例看多少指令将需要执行的任务的需要。我添加了一些硬件,所以GCC没有优化出我所有的代码(这真的发生过!!(主)中没有代码。 另外,我花了一些时间来了解main.lst并我所写的结果却并不像我所写的东西。 鲍勃 设计01.CyPRJ.CaseV01.Zip 430.1 K 以上来自于百度翻译 以下为原文 ... not too much code. Since your given "10" from your example will not work (it is not a power of two) we have to rewite the above example to var = (var > 127)?0:var+1; // Remember: C needs a colon to separate the two values I've built an example project to see how many instructions will be needed to perform the wanted task. I had to add some hardware, so GCC did not optimize out all my code (wich really did happen!! No code left in main()). Additionally it took me some time to understand the result in main.lst which does what I wrote but does not look like what I wrote. Bob
|
|
|
|
我确实把测试语句弄错了。你可以看到我在哪里度过我的大部分时间
在设计中的时间… 当我在做这篇文章时,我想知道(但没有做作业)是否饱和。 只限于两个力量,谢谢你的澄清。 除了把最近的正弦波发生器使用IIR和积极的反馈,我尝试了 种子值,得到下图中的例子,因为我没有使用坐 算术。 以上来自于百度翻译 以下为原文 I did indeed mistype the test statement. You can see where I spend most of my time in a design..... As I was doing the post I wondered (but did not do my homework) if saturation was limited to power of two, thanks for clarifiying that. As an aside in posting a recent sine generator using IIR and positive fdbk I experimented with seed values and got the middle example shown below because I did not use sat arithmetic. |
|
|
|
图像不后,附-(grrrrr的…)
SAT算法CORTEX.JPG 106.4 K 以上来自于百度翻译 以下为原文 The image that did not post, attached - (Grrrrr....)
|
|
|
|
…原来是写“MWMW”的一种复杂方式。
鲍勃 以上来自于百度翻译 以下为原文 ... turns out to be a complicated way to write "MWMW" Bob |
|
|
|
多波长银河系?(HTTP//MWMW.GSFC.NASAGOV/)
以上来自于百度翻译 以下为原文 Multiwavelength Milky Way? (http://mwmw.gsfc.nasa.gov/) |
|
|
|
感谢链接,HLI。这让我想起caneveral起跳角的火星任务专家。
鲍勃 以上来自于百度翻译 以下为原文 Thanx for the link, hli. It reminded me of the take-off at Cape Caneveral of the mars-mission MAVEN. Bob |
|
|
|
嗨,大家好,
是的,你给出的例子(var=(var & gt;127))?0:VAR + 1;是正确的。然而,饱和极限被限制在2 ^ n-1,在这里您可以指定n的值。 虽然大多数themprefer采用高水平的C代码,这可能是有用的DSP运算的操作数。 问候,Asha 以上来自于百度翻译 以下为原文 Hi All, Yes, the example given by you ( var = (var > 127)?0:var+1;) is right. However, the saturation limit is restricted to 2^n-1 where you can specify the value of n. Though most of them prefer using high level C code, this operand might be useful for DSP operations. Regards, Asha |
|
|
|
刚刚加入基于编译器指令的使用一个饱和点(GCC或MDK)
而使用GCC编译器,如上面提到的,我们需要使用寄存器。例如:ASM(“USAT R3,8,R0”); 所以首先我们需要存储的变量将包含不饱和和饱和的结果使用后的第一次给出的语法。 然而,对于MDK编译器可以直接使用在本说明书的局部变量和不需要指定寄存器: 例如:AS-ASM(SSAT DATASAT,8,DATAUUNSAT); 当做 PSoC奇观 以上来自于百度翻译 以下为原文 Just adding one more point on the usage of saturation instruction based on the compiler- (GCC or MDK ) While using GCC compiler, as mentioned above, we need to use the registers. eg: asm(“USAT r3,8,r0"); So first we need to store the variables that will contain the unsaturated and saturated results using the syntax given in the first post. However, for MDK compilers you can directly use the local variables along with this instruction and there is no need to specify the registers: eg: __asm(“ssat data_sat,8,data_unsat"); Regards PSoC Wonders |
|
|
|
只有小组成员才能发言,加入小组>>
756个成员聚集在这个小组
加入小组2124 浏览 1 评论
1865 浏览 1 评论
3681 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1800 浏览 6 评论
1545 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
605浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
450浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
448浏览 2评论
400浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
1081浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-1-11 05:27 , Processed in 0.924277 second(s), Total 65, Slave 59 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号