[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] reading and writing fpga registers

From: Johnathan Corgan
Subject: Re: [Discuss-gnuradio] reading and writing fpga registers
Date: Thu, 31 May 2007 11:17:12 -0700
User-agent: Thunderbird (X11/20070403)

Roshan Baliga wrote:

> (1) My write returns "true", but the read returns 0, regardless of which
> fpga register I read/write to (I've tried a few). For example:
> <snip>
> if (utx->_write_fpga_reg(FR_ADC_OFFSET_0,0x7777))
> <snip>
> int readregvalue2 = (utx->_read_fpga_reg(FR_ADC_OFFSET_0));
> I must be doing something wrong here.

The FPGA registers are write-only.  When reading, instead of the
register contents, you get 'readback' register contents which are
actually a number of useful signals inside the FPGA.  See line numbers
304 and 305 of usrp_std.v to see what signals are read back.

The typical way of dealing with write-only registers is to maintain a
shadow copy in your code that you update every time you write to a
register, then if you later want to "read" the register, just look at
the shadow copy.  You can also use this if you want to do a

> (2) I believe that the user-defined FPGA registers don't exist in the
> verilog code. Do I need to add them manually? I was going to do that in
> usrp_std.v.  I'm happy to submit a patch if I get things working where
> you can IFDEF the extra registers out if you need the space.

Correct.  The actual registers are not instantiated (they would get
pruned out anyway during synthesis if you did.)  If you are writing
custom FPGA code, you can instantiate any number of:

setting_reg #(FR_USER_x) user_reg(...);

...in whatever verilog module you create, and just be sure to include:


The path in the include statement will vary depending on where your
verilog module is in the filesystem.  Also, if you are adding setting
registers to existing modules, then the include may already be done for you.

Finally, the constants FR_USER_0 through FR_USER_15 are available from
C++ by including:


(again, path may vary.)

Johnathan Corgan
Corgan Enterprises LLC

reply via email to

[Prev in Thread] Current Thread [Next in Thread]