main Content

comm.hdlrsdecoder

使用芦苇 - 固体解码器解码消息

Description

HDL优化hdlrsdecoderSystem Object™从Reed-Solomon(RS)CodeWord向量恢复了消息向量。为了进行适当的解码,该对象的代码和多项式属性值必须匹配相应的编码器中的这些值。

要从芦苇 - 固体密码字向量恢复消息向量:

  1. Create thecomm.hdlrsdecoder对象并设置其属性。

  2. 用参数调用对象,就好像它是一个函数一样。

要了解有关系统对象如何工作的更多信息,请参阅什么是系统对象?

故障排除

  • 每个输入框必须包含的多于(N-K)*2符号,少于或确切n符号。当对象缩短代码时,当有效的数据示例数量之间startIn终结小于n。缩短的代码仍然需要n循环进行Chien搜索。如果输入消息小于n符号,至少留下一个警卫区间n-尺寸在开始下一个框架之前,不活动的循环尺寸是消息长度。

  • 解码器可以操作4的消息a time. If the object receives the start of a fifth message before completely decoding the first message, the object drops data samples from the first message. To avoid this issue, increase the number of inactive cycles between input messages.

  • 发电机多项式未明确指定。但是,它是由编码值长度,消息长度和根指数的B值定义的。要从发电机多项式获取B的值,请使用genpoly2b功能。

创建

Description

RSDEC= comm.hdlrsdecoder创建HDL优化的RS解码器系统对象,RSDEC,执行芦苇 - 溶剂解码。

RSDEC= comm.hdlrsdecoder((name,Value)使用一个或多个名称值对设置属性。将每个属性名称包装在单引号中。例如,

comm.hdlrsdecoder('bsource','属性','b',2)
为原始多项式的根设定2个起始功率。

例子

RSDEC= comm.hdlrsdecoder(n,k,name,value)设置CodeFordLength财产为n, 这messageLength财产为k,以及指定值的其他指定属性名称。

Properties

expand all

Unless otherwise indicated, properties arenontunable,,,,which means you cannot change their values after calling the object. Objects lock when you call them, and the发布功能解锁它们。

如果a property istunable,您可以随时更改其价值。

有关更改属性值的更多信息,请参见使用系统对象在MATLAB中的系统设计

Starting power for roots of the primitive polynomial, specified as a positive integer.

依赖性

The object uses this value when you setBsource'Property'

原始多项式根的起始功率的来源,指定为'Property'或者'汽车'。当您选择时'汽车', 这OBJect usesb=1

符号数量,n,,,,in the RS codeword, specified as a positive integer. This value is rounded up to 2m–1。m是原始多项式的程度,如原始分析Source原始分析properties. The difference ofCodeFordLength-messageLength必须是一个整数。

如果该属性的价值小于2m-1, 这OBJect assumes a shortened RS code.

如果您设置原始分析Source'汽车', 然后CodeFordLengthmust be in the range 3 <CodeFordLength≤216-1。

如果您设置原始分析Source'Property', 然后CodeFordLength必须在3≤的范围内CodeFordLength≤2m-1。m必须在3≤的范围内m≤16。

message length,k,指定为正整数。差异CodeFordLength-messageLength必须是一个整数。

当您将此属性设置为真的,该对象返回校正错误的数量。校正错误的数量无效错误真的,由于错误的错误要比可以纠正的更多。

原始多项式的来源,指定为'Property'或者'汽车'

  • 当您将此属性设置为'汽车',对象使用原始的多项式m=Ceil((log2((CodeFordLength+1)),这是int2bit((primpoly((m),BPI)',,,,whereBPI是每个整数的位数。

  • 当您将此属性设置为'Property',您必须使用原始分析财产。

原始多项式,,,,specified as a binary row vector that represents a primitive polynomial overGF(2)of degreem,,,,in descending order of powers. The polynomial defines the finite fieldGF(2m)corresponding to the integers that form messages and codewords.

依赖性

The object uses this value when you set原始分析Source'Property'

用法

Description

例子

[[y,,,,开始,,,,结尾Out,,,,validOut,,,,错误] = rsdec(X,,,,startIn,,,,终结,,,,validIn解码一个编码的消息符号,X并返回解码的符号y。Thestart结尾signals indicate the message frame boundaries. If错误1((真的),then the object detected uncorrectable errors in the input frame.

[[y,,,,开始,,,,结尾Out,,,,validOut,,,,错误,,,,numErrors] = rsdec(X,,,,startIn,,,,终结,,,,validIn解码输入数据,还返回检测到的错误数量。要使用此语法,请设置numErrorSoutputport财产为真的。如果错误1((真的),然后对象在输出框架中检测到了不可纠正的错误,并且numErrors是invalid.

输入参数

expand all

Input message data and parity symbols, one symbol at a time, specified as an unsigned integer orfi()进行任何二进制缩放。

doubletype is allowed for simulation but not supported for HDL code generation.

Data Types:double|UINT8|uint16|UINT32|fi

输入数据框的启动,指定为逻辑标量。

Data Types:逻辑

输入数据框架的结尾,,,,specified as a logical scalar.

Data Types:逻辑

输入数据的有效性,指定为逻辑标量。

Data Types:逻辑

Output Arguments

expand all

消息数据符号,一次返回一个符号,作为一个与输入消息相同的数据类型的整数,X

Data Types:double|UINT8|uint16|UINT32|fi

输出数据框架的启动,作为逻辑标量返回。

Data Types:逻辑

输出数据框的结尾,返回为逻辑标量。

Data Types:逻辑

输出数据的有效性,作为逻辑标量返回。

Data Types:逻辑

输出数据框中的不可纠正的错误,作为逻辑标量返回。此信号为1(真的)当消息框架包含不可纠正的错误时。在这种情况下,输出数据符号被损坏。当此值是有效的结尾Out是1(真的)。

Data Types:逻辑

number of errors detected and corrected, returned as an integer. This value is valid when结尾Out是1(真的)和错误是0(错误的)。

Data Types:UINT8

对象功能

要使用对象函数,请将系统对象指定为第一个输入参数。例如,释放名称的系统对象的系统资源OBJ,,,,use this syntax:

释放(OBJ)

expand all

step System object算法
发布 释放资源并允许更改System object属性值和输入特征
reset Reset internal states ofSystem object

Examples

全部收缩

使用芦苇所罗门编码器和解码器系统对象编码和解码信号。此示例显示了如何将每个对象包含在HDL代码生成的函数中。

创建一个随机消息来编码。此消息小于代码长的长度,以显示对象如何支持缩短代码。金宝app用零填充消息,以适应解码器的延迟,包括Chien搜索。

messageLength = 188; dataIn = [randi([0,255],1,messageLength,'uint8')零(1,1024-messageLength)];

编写一个创建并调用的函数HDLRSENCODERSystem Object™具有RS(255,239)代码。该代码用于IEEE®802.16宽带无线访问标准中。b是原始多项式根部的起始力。您可以从此功能生成HDL。

笔记:This object syntax runs only in R2016b or later. If you are using an earlier release, replace each call of an object with the equivalentstep句法。例如,替换myObject(x)step(myObject,x)

功能[dataOut,stint,endout,valifout] = hdlrsenc80216(datain,startin,endin,validin)%HDLRSENC80216%使用COMM.HDLRSENCODER SYSTEM对象(TM)处理一个数据样本% dataIn is a uint8 scalar, representing 8 bits of binary data.%startin,endin和varyin是逻辑标量值。% You can generate HDL code from this function.执着的rsEnc80216;如果ISEMPTY(RSENC80216)RSENC80216 = COMM.HDLRSENCODER(255,239,'bsource',,,,'Property',,,,'b',,,,0)结尾[dataOut,startOut,endout,validout] = rsenc80216(datain,startin,endin,vilitin);结尾

Call the function to encode the message.

为了ii = 1:1024 messageStart = (ii==1); messageEnd = (ii==messageLength); validIn = (ii<=messageLength); [encOut(ii),startOut(ii),endOut(ii),validOut(ii)] =...HDLRSEnc80216(dataIn(ii),messageStart,messageEnd,validIn);结尾
rsEnc80216 = comm.HDLRSEncoder with properties: CodewordLength: 255 MessageLength: 239 PrimitivePolynomialSource: 'Auto' PuncturePatternSource: 'None' BSource: 'Property' B: 0

Inject errors at random locations in the encoded message. Reed-Solomon can correct up to (n-k)/2中的错误n符号。因此,在此示例中,误差校正功能为(255 - 239)/2 = 8符号。

numErrors = 8; loc = randperm(messageLength,numErrors);%excout通过有效的限定,使用偏移来注入错误vi = find(validOut==true,1);为了i = 1:numErrors idx = loc(i)+vi;符号= encout(idx);encout(idx)= randi([0 255],,'uint8');fprintf('符号(%d):为0x%x,现在0x%x \ n',loc(i),符号,encout(idx))结尾
Symbol(147): was 0x1f, now 0x82 Symbol(16): was 0x6b, now 0x82 Symbol(173): was 0x3, now 0xd1 Symbol(144): was 0x66, now 0xcb Symbol(90): was 0x13, now 0xa4 Symbol(80): was 0x5a, now 0x60 Symbol(82): was 0x95, now 0xcf Symbol(56): was 0xf5, now 0x88

编写一个创建并调用的函数hdlrsdecoder系统对象™。该对象必须具有与编码器相同的代码和多项式。您可以从此功能生成HDL。

功能[dataOut,stint,endout,validout,err] = hdlrsdec80216(datain,startin,endin,endin,validin)%HDLRSDEC80216%使用COMM.HDLRSDECODER系统对象(TM)处理一个数据样本% dataIn is a uint8 scalar, representing 8 bits of binary data.%startin,endin和varyin是逻辑标量值。% You can generate HDL code from this function.执着的RSDEC80216;如果ISEMPTY(RSDEC80216)RSDEC80216 = COMM.HDLRSDECODER(255,239,'bsource',,,,'Property',,,,'b',,,,0)结尾[[dataOut,startOut,endOut,validOut,err] = rsDec80216(dataIn,startIn,endIn,validIn);结尾

调用该函数以检测编码消息中的错误。

为了ii = 1:1024 [decout(ii),desstartout(ii),cendent(ii),decvalidout(ii),decerrout(ii)] =...HDLRSDEC80216(ENCOUT(II),StartOut(ii),endout(ii),有效out(ii));结尾
rsdec80216 = comm.hdlrsdecoder具有属性:codeWordLength:255 MessageLength:239 Primitive -PolyNomialSource:'auto'bsource:'auto'bsource:'属性'b:0 numErrorSoutputport port:false:false:false

选择有效的解码器输出,然后将解码的符号与原始消息进行比较。

decout = decout(decvalidout == 1);OriginalMessage =数据(1:MessageLength);如果所有(ointractMessage == decout)fprintf('All %d message symbols were correctly decoded.\n',,,,messageLength)别的为了JJ = 1:MessageLength如果datain(jj)〜= decout(jj)fprintf('Error in decoded symbol(%d). Original 0x%x, Decoded 0x%x.\n',JJ,Datain(JJ),撤销(JJ))结尾结尾结尾
All 188 message symbols were correctly decoded.

扩展功能

版本历史记录

在R2012B中引入