Pattern Detector (pattern_detector_b)
Finds a set binary pattern in a boolean stream.
Design
The input boolean stream is checked to see if it contains a set pattern.
The mathematical representation of when a match with the set pattern is given in (23).
In (23) the \(\texttt{AND}\) and \(\texttt{XOR}\) are bit-wise operations, with a match detected when \(result\) takes the value 0xFFFFFFFFFFFFFFFF.
\(memory\) is the most recently received bits being searched for the pattern.
\(bitmask\) selects which bits are used in the pattern match.
\(pattern\) is the pattern being searched for in the boolean stream.
When a pattern is detected a metadata opcode message is generated.
Interface
<?xml version="1.0"?>
<componentspec>
<property name="pattern" type="longlong" writable="true" default="-1" description="Value to be detected."/>
<property name="bitmask" type="longlong" writable="true" default="-1"
description="Selects which bits to use for pattern matching."/>
<property name="metadata_id" type="ulong" writable="true" default="0" description="Metadata ID when a pattern is found."/>
<property name="metadata_value" type="ulonglong" writable="true" default="0" description="Metadata value when a pattern is found."/>
<port name="input" producer="false" protocol="bool_timed_sample-prot"/>
<port name="output" producer="true" protocol="bool_timed_sample-prot"/>
</componentspec>
Ports
Inputs:
input: Primary input samples port.Protocol:
bool_timed_sample-protOptional:
False
Outputs:
output: Primary output samples port.Protocol:
bool_timed_sample-protOptional:
False
Opcode Handling
Sample opcode messages are searched for the set pattern but otherwise passed directly from input to output without modification.
A metadata message is inserted at the moment a pattern match occurs. The value field of the metadata message is set by the metadata_value property, and the id field is set by the metadata_id property.
Incoming flush opcode messages are passed through the component. Incoming flush opcode messages cause the memory of the last 64 samples to be reset to all zeros.
All other opcodes are passed through the component.
Properties
pattern: Value to be detected.Type:
longlongAccess:
Parameter:
FalseWritable:
TrueInitial:
FalseVolatile:
False
Default value:
-1
bitmask: Selects which bits to use for pattern matching. Can be used to match patterns shorter than 64 bits, or to ignore specific bits in a pattern. A value of 0 in the N-th bit ofbitmaskwill exclude the N-th bit of pattern and memory from being compared. A value of 1 in the N-th bit ofbitmaskwill include the N-th bit of pattern and memory in the comparison. When set to all zero bits all bits are excluded from the check and so no match can occur.Type:
longlongAccess:
Parameter:
FalseWritable:
TrueInitial:
FalseVolatile:
False
Default value:
-1
metadata_id: Metadata ID when a pattern is found.Type:
ulongAccess:
Parameter:
FalseWritable:
TrueInitial:
FalseVolatile:
False
Default value:
0
metadata_value: Metadata value when a pattern is found.Type:
ulonglongAccess:
Parameter:
FalseWritable:
TrueInitial:
FalseVolatile:
False
Default value:
0
Implementations
Example Application
<?xml version="1.0"?>
<application done="file_write">
<instance component="ocpi.core.file_read" connect="pattern_detector_b">
<property name="filename" value="input.bin"/>
</instance>
<instance component="ocpi.comp.sdr.communication.pattern_detector_b" connect="file_write">
<property name="pattern" value="123456789"/>
<property name="bitmask" value="-1"/>
<property name="metadata_id" value="0"/>
<property name="metadata_value" value="0"/>
</instance>
<instance component="ocpi.core.file_write">
<property name="filename" value="output.bin"/>
</instance>
</application>
Dependencies
The dependencies to other elements in OpenCPI are:
None.
There is also a dependency on:
ieee.std_logic_1164
ieee.numeric_std
ieee.math_real.all
Limitations
Limitations of pattern_detector_b are:
Pattern must be 64 bits or less.
bitmaskmust be 64 bits or less.Setting
bitmaskto0x0000000000000000(all zeros) will cause the component to insert a metadata message every time an input sample is processed; this is because setting a mask of all zeros is logically equivalent to setting both memory and pattern to be all zeros, which continuously results in a match.
Testing
Tested platforms: None
Component testing not completed.