Skip to content

Commit a815395

Browse files
eltosmarcusmueller
authored andcommitted
gr-blocks: Unify "Multiply Const" and "Fast Multiply Const" blocks
Signed-off-by: Eltos <[email protected]>
1 parent 5660b55 commit a815395

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

gr-blocks/grc/blocks_multiply_const_vxx.block.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,16 @@ parameters:
1212
const_type: [complex, real, int, int]
1313
fcn: [cc, ff, ii, ss]
1414
hide: part
15+
- id: mode
16+
label: Mode
17+
dtype: enum
18+
options: [scalar, vector]
19+
option_labels: ['Scalar constant', 'Vector constant']
20+
default: 'vector'
21+
hide: ${ 'part' if vlen > 1 else 'all' }
1522
- id: const
1623
label: Constant
17-
dtype: ${ type.const_type if vlen == 1 else type.vconst_type }
24+
dtype: ${ type.const_type if vlen == 1 or mode == 'scalar' else type.vconst_type }
1825
default: '1'
1926
- id: vlen
2027
label: Vector Length
@@ -34,18 +41,28 @@ outputs:
3441

3542
asserts:
3643
- ${ vlen > 0 }
37-
- ${ (vlen > 1 and len(const) == vlen) or (vlen == 1) }
44+
- ${ vlen == 1 or mode == 'scalar' or len(const) == vlen }
3845

3946
templates:
4047
imports: from gnuradio import blocks
41-
make: blocks.multiply_const_${ 'v' if context.get('vlen')() > 1 else '' }${type.fcn}(${const})
48+
make: |-
49+
% if context.get("vlen")() == 1 or mode == 'scalar':
50+
blocks.multiply_const_${type.fcn}(${const}, ${vlen})
51+
% else:
52+
blocks.multiply_const_v${type.fcn}(${const})
53+
% endif
4254
callbacks:
4355
- set_k(${const})
4456

4557
cpp_templates:
46-
includes: ['#include <gnuradio/blocks/multiply_const${"_v" if context.get("vlen")() > 1 else "" }.h>']
47-
declarations: 'blocks::multiply_const_${"v" if context.get("vlen")() > 1 else "" }${type.fcn}::sptr ${id};'
48-
make: 'this->${id} = blocks::multiply_const_${"v" if context.get("vlen")() > 1 else "" }${type.fcn}::make(${const});'
58+
includes: ['#include <gnuradio/blocks/multiply_const${ "" if context.get("vlen")() == 1 or mode == "scalar" else "_v" }.h>']
59+
declarations: 'blocks::multiply_const_${ "" if context.get("vlen")() == 1 or mode == "scalar" else "v" }${type.fcn}::sptr ${id};'
60+
make: |-
61+
% if context.get("vlen")() == 1 or mode == 'scalar':
62+
this->${id} = blocks::multiply_const_${type.fcn}::make(${const}, ${vlen});
63+
% else:
64+
this->${id} = blocks::multiply_const_v${type.fcn}::make(${const});
65+
% endif
4966
callbacks:
5067
- set_k(${const})
5168

gr-blocks/grc/blocks_multiply_const_xx.block.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
id: blocks_multiply_const_xx
22
label: Fast Multiply Const
3-
flags: [ python, cpp ]
3+
flags: [ python, cpp, deprecated ]
44

55
parameters:
66
- id: type

0 commit comments

Comments
 (0)