Discussion and technical support related to USRP, UHD, RFNoC
View all threadsDear Dexter,
you can of course implement your own gain_impl for GR integration, but
why would you do that if there is a generic implementation provided by
GR that get's the job done?
Have a look at my original reply on the mailing list again (cited
below): There I described how I instantiate a generic RFNoC block from
gr-uhd/lib (uhd.rfnoc_block_generic
https://github.com/gnuradio/gnuradio/blob/2e59108989fb8e06a54abee0f23cba33827e0b2f/gr-uhd/lib/rfnoc_block_generic_impl.h)
instead of a custom gain block implementation in gr-oot/lib; and use the
concept of user properties to pass parameters. Properties are a very
powerful and useful concept in RFNoC, not only to handle sampling rate
changes (|PROP_KEY_SAMP_RATE|) but for any user parameter. This is also
the mechanism most of the default blocks in gr-uhd use
https://github.com/search?q=repo%3Agnuradio%2Fgnuradio+rfnoc_block_generic+language%3AYAML&type=code&l=YAML.
How does it connect to the FPGA?
The third parameter of uhd.rfnoc_block_generic is the block name
("Gain"), and in the very bottom of gain_block_control.cpp
https://git.gsi.de/p.niedermayer/exciter/-/blob/cf444ed055274ec826bc0956eed0b94debbab912/rfnoc-beam_exciter/lib/gain_block_control.cpp#L63-64
the macro |UHD_RFNOC_BLOCK_REGISTER_DIRECT| is used to tell UHD, that a
block with name "Gain" should use this block controller to connect to a
certain NoC-ID. In the block controller you can then handles properties
and pokes registers.
Kind regards
Philipp
Generally, I found that using "|uhd.rfnoc_block_generic|" in
combination with properties makes things a lot easier regarding
bindings, since it means you need much less code and no custom Python
bindings.
In my_rfnoc_gain.block.yml
https://git.gsi.de/p.niedermayer/exciter/-/blob/cf444ed055274ec826bc0956eed0b94debbab912/rfnoc-beam_exciter/grc/beam_exciter_rfnoc_gain.block.yml:
templates:
imports:|-
from gnuradio import uhd
make:|-
uhd.rfnoc_block_generic(
self.rfnoc_graph,
uhd.device_addr(""),
"Gain",
-1, # device_select
-1, # instance_index
)
self.${id}.set_property('gain', ${constant})
callbacks:
-set_property('gain',${constant})
And in gain_block_control.cpp
https://git.gsi.de/p.niedermayer/exciter/-/blob/cf444ed055274ec826bc0956eed0b94debbab912/rfnoc-beam_exciter/lib/gain_block_control.cpp
|property_t<int> _prop_gain = property_t<int>(PROP_GAIN, DEFAULT_GAIN,
{res_source_info::USER});|
void_register_props(){
register_property(&_prop_gain);
add_property_resolver({&_prop_gain}, {&_prop_gain}, this{
this->set_gain_value(this->_prop_gain.get());
});
} RFNOC_BLOCK_CONSTRUCTOR(gain_block_control){
_register_props();
}
voidset_gain_value(constintgain){
//The gain block fromthe tutorial only supports integer gain values
regs().poke32(REG_GAIN, (uint32_t)gain);
}
intget_gain_value(){
returnregs().peek32(REG_GAIN);
}
UHD_RFNOC_BLOCK_REGISTER_DIRECT(gain_block_control, 0xb16, "Gain",
CLOCK_KEY_GRAPH, "bus_clk")
From: Dexter Lee [mailto:Dexter.Lee@Millennium-Space.com]
Date: Wednesday, June 19, 2024 at 01:16 UTC+2
Subject: [USRP-users] Re: Building OOT RFNoC modules for GNURadio 3.10
Hi Phillip,
Thank you for your post regarding the gain example for UHD 4 in the
absence of RFNOCMODTOOL. I have been frustrated with this lately and
your repo was immensely helpful.
One question I had was how you were able to create the RFNOC block in
GNU Radio Companion without the need for a “gain_impl.h” and
“gain_impl.cc” under your lib directory. I know those are generated
usually be RFNOCMODTOOL (screenshot below from UHD3), do we not need
to create those for UHD4?
https://kb.ettus.com/Getting_Started_with_RFNoC_Development
Thank you!
-Dexter