commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r9954 - in gnuradio/branches/developers/eb/cppdb-wip:


From: eb
Subject: [Commit-gnuradio] r9954 - in gnuradio/branches/developers/eb/cppdb-wip: gnuradio-examples/c++/usrp_test gr-usrp/src usrp/host/lib/legacy
Date: Fri, 7 Nov 2008 14:51:37 -0700 (MST)

Author: eb
Date: 2008-11-07 14:51:36 -0700 (Fri, 07 Nov 2008)
New Revision: 9954

Modified:
   
gnuradio/branches/developers/eb/cppdb-wip/gnuradio-examples/c++/usrp_test/usrp_test.cc
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_sink_base.cc
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_sink_base.h
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_source_base.cc
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_source_base.h
   gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_basic.cc
   gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_basic.h
   
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_standard.cc
   
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_standard.h
Log:
work-in-progress: determine_{tx,rx}_mux_value

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/gnuradio-examples/c++/usrp_test/usrp_test.cc
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/gnuradio-examples/c++/usrp_test/usrp_test.cc
      2008-11-07 19:48:03 UTC (rev 9953)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/gnuradio-examples/c++/usrp_test/usrp_test.cc
      2008-11-07 21:51:36 UTC (rev 9954)
@@ -37,7 +37,7 @@
   int decim = 64;
   usrp_source_c_sptr usrp = usrp_make_source_c(0, decim);
 
-  std::vector<int> spec(2,0);
+  usrp_subdev_spec spec(2,0);
   db_base_sptr subdev = usrp->selected_subdev(spec);
   printf("Subdevice name is %s\n", subdev->name().c_str());
   printf("Subdevice freq range: (%f, %f)\n", subdev->freq_min(), 
subdev->freq_max());

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_sink_base.cc
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_sink_base.cc     
2008-11-07 19:48:03 UTC (rev 9953)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_sink_base.cc     
2008-11-07 21:51:36 UTC (rev 9954)
@@ -145,6 +145,12 @@
   return d_usrp->set_mux (mux);
 }
 
+int
+usrp_sink_base::determine_tx_mux_value(const usrp_subdev_spec &ss)
+{
+  return d_usrp->determine_tx_mux_value(ss);
+}
+
 bool
 usrp_sink_base::set_tx_freq (int channel, double freq)
 {

Modified: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_sink_base.h
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_sink_base.h      
2008-11-07 19:48:03 UTC (rev 9953)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_sink_base.h      
2008-11-07 21:51:36 UTC (rev 9954)
@@ -85,6 +85,7 @@
   bool set_interp_rate (unsigned int rate);
   bool set_nchannels (int nchan);
   bool set_mux (int mux);
+  int determine_tx_mux_value(const usrp_subdev_spec &ss);
 
   /*!
    * \brief set the frequency of the digital up converter.

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_source_base.cc
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_source_base.cc   
2008-11-07 19:48:03 UTC (rev 9953)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_source_base.cc   
2008-11-07 21:51:36 UTC (rev 9954)
@@ -142,6 +142,12 @@
   return d_usrp->set_mux (mux);
 }
 
+int
+usrp_source_base::determine_rx_mux_value(const usrp_subdev_spec &ss)
+{
+  return d_usrp->determine_rx_mux_value(ss);
+}
+
 bool
 usrp_source_base::set_rx_freq (int channel, double freq)
 {

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_source_base.h
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_source_base.h    
2008-11-07 19:48:03 UTC (rev 9953)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_source_base.h    
2008-11-07 21:51:36 UTC (rev 9954)
@@ -98,6 +98,7 @@
   bool set_decim_rate (unsigned int rate);
   bool set_nchannels (int nchan);
   bool set_mux (int mux);
+  int determine_rx_mux_value(const usrp_subdev_spec &ss);
 
   /*!
    * \brief set the center frequency of the digital down converter.

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_basic.cc
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_basic.cc    
    2008-11-07 19:48:03 UTC (rev 9953)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_basic.cc    
    2008-11-07 21:51:36 UTC (rev 9954)
@@ -181,21 +181,25 @@
   return d_db[which_side];
 }
 
-db_base_sptr
-usrp_basic::selected_subdev(usrp_subdev_spec ss)
+bool
+usrp_basic::is_valid(const usrp_subdev_spec &ss)
 {
-  
-  if (!(0 <= ss.side && ss.side <= 1))
-    throw std::invalid_argument("invalid subdev_spec side");
+  if (ss.side < 0 || ss.side > 1)
+    return false;
 
-  std::vector<db_base_sptr> v = db(ss.side);
+  if (ss.subdev < 0 || ss.subdev >= d_db[ss.side].size())
+    return false;
 
-  assert(v.size() >= 1);
+  return true;
+}
 
-  if (!(0 <= ss.subdev && (size_t) ss.subdev < v.size()))
-    throw std::invalid_argument("invalid subdev_spec subdev");
+db_base_sptr
+usrp_basic::selected_subdev(const usrp_subdev_spec &ss)
+{
+  if (!is_valid(ss))
+    throw std::invalid_argument("invalid subdev_spec");
 
-  return v[ss.subdev];
+  return d_db[ss.side][ss.subdev];
 }
 
 bool

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_basic.h
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_basic.h 
2008-11-07 19:48:03 UTC (rev 9953)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_basic.h 
2008-11-07 21:51:36 UTC (rev 9954)
@@ -148,12 +148,17 @@
   std::vector<db_base_sptr> db(int which_side);
 
   /*!
+   * \brief is the subdev_spec valid?
+   */
+  bool is_valid(const usrp_subdev_spec &ss);
+
+  /*!
    * \brief given a subdev_spec, return the corresponding daughterboard object.
    * \throws std::invalid_ argument if ss is invalid.
    *
    * \param ss specifies the side and subdevice
    */
-  db_base_sptr selected_subdev(usrp_subdev_spec ss);
+  db_base_sptr selected_subdev(const usrp_subdev_spec &ss);
 
   /*!
    * \brief return frequency of master oscillator on USRP

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_standard.cc
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_standard.cc 
    2008-11-07 19:48:03 UTC (rev 9953)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_standard.cc 
    2008-11-07 21:51:36 UTC (rev 9954)
@@ -368,7 +368,113 @@
   return ok;
 }
 
+int
+usrp_standard_rx::determine_rx_mux_value(const usrp_subdev_spec &ss)
+{
+  /*
+    Determine appropriate Rx mux value as a function of the subdevice choosen 
and the
+    characteristics of the respective daughterboard.
+    
+    @param u:           instance of USRP source
+    @param subdev_spec: return value from subdev option parser.  
+    @type  subdev_spec: (side, subdev), where side is 0 or 1 and subdev is 0 
or 1
+    @returns:           the Rx mux value
+  
+    Figure out which A/D's to connect to the DDC.
+    
+    Each daughterboard consists of 1 or 2 subdevices.  (At this time,
+    all but the Basic Rx have a single subdevice.  The Basic Rx
+    has two independent channels, treated as separate subdevices).
+    subdevice 0 of a daughterboard may use 1 or 2 A/D's.  We determine this
+    by checking the is_quadrature() method.  If subdevice 0 uses only a single
+    A/D, it's possible that the daughterboard has a second subdevice, 
subdevice 1,
+    and it uses the second A/D.
+    
+    If the card uses only a single A/D, we wire a zero into the DDC Q input.
+    
+    (side, 0) says connect only the A/D's used by subdevice 0 to the DDC.
+    (side, 1) says connect only the A/D's used by subdevice 1 to the DDC.
+  */
 
+  struct truth_table_element
+  {
+    int          d_side;
+    int         d_uses;
+    bool         d_swap_iq;
+    unsigned int d_mux_val;
+
+    truth_table_element(int side, unsigned int uses, bool swap_iq, unsigned 
int mux_val=0)
+      : d_side(side), d_uses(uses), d_swap_iq(swap_iq), d_mux_val(mux_val){}
+      
+    bool operator==(const truth_table_element &in)
+    {
+      return (d_side == in.d_side && d_uses == in.d_uses && d_swap_iq == 
in.d_swap_iq);
+    }
+
+    unsigned int mux_val() { return d_mux_val; }
+  };
+
+
+  if (!is_valid(ss))
+    throw std::invalid_argument("subdev_spec");
+
+
+  // This is a tuple of length 1 or 2 containing the subdevice
+  // classes for the selected side.
+  std::vector<db_base_sptr> db = this->db(ss.side);
+  
+  unsigned int subdev0_uses, subdev1_uses, uses;
+
+  // compute bitmasks of used A/D's
+  
+  if(db[0]->is_quadrature())
+    subdev0_uses = 0x3;               // uses A/D 0 and 1
+  else
+    subdev0_uses = 0x1;               // uses A/D 0 only
+
+  if(db.size() > 1)                   // more than 1 subdevice?
+    subdev1_uses = 0x2;               // uses A/D 1 only
+  else
+    subdev1_uses = 0x0;               // uses no A/D (doesn't exist)
+  
+  if(ss.subdev == 0)
+    uses = subdev0_uses;
+  else if(ss.subdev == 1)
+    uses = subdev1_uses;
+  else
+    throw std::invalid_argument("subdev_spec");
+
+  if(uses == 0){
+    throw std::runtime_error("Daughterboard doesn't have a subdevice 1");
+  }
+  
+  bool swap_iq = db[0]->i_and_q_swapped();
+  
+  truth_table_element truth_table[8] = {
+    // (side, uses, swap_iq) : mux_val
+    truth_table_element(0, 0x1, false, 0xf0f0f0f0),
+    truth_table_element(0, 0x2, false, 0xf0f0f0f1),
+    truth_table_element(0, 0x3, false, 0x00000010),
+    truth_table_element(0, 0x3, true,  0x00000001),
+    truth_table_element(1, 0x1, false, 0xf0f0f0f2),
+    truth_table_element(1, 0x2, false, 0xf0f0f0f3),
+    truth_table_element(1, 0x3, false, 0x00000032),
+    truth_table_element(1, 0x3, true,  0x00000023)
+  };
+  size_t nelements = sizeof(truth_table)/sizeof(truth_table[0]);
+  
+  truth_table_element target(ss.side, uses, swap_iq, 0);
+  
+  size_t i;
+  for(i = 0; i < nelements; i++){
+    if (truth_table[i] == target)
+      return truth_table[i].mux_val();
+  }
+  throw std::runtime_error("internal error");
+}
+
+
+
 bool
 usrp_standard_rx::set_rx_freq (int channel, double freq)
 {
@@ -662,6 +768,39 @@
   return ok;
 }
 
+int
+usrp_standard_tx::determine_tx_mux_value(const usrp_subdev_spec &ss)
+{
+  /*
+    Determine appropriate Tx mux value as a function of the subdevice choosen.
+
+    @param u:           instance of USRP source
+    @param subdev_spec: return value from subdev option parser.  
+    @type  subdev_spec: (side, subdev), where side is 0 or 1 and subdev is 0
+    @returns:           the Rx mux value
+  
+    This is simpler than the rx case.  Either you want to talk
+    to side A or side B.  If you want to talk to both sides at once,
+    determine the value manually.
+  */
+
+  if (!is_valid(ss))
+    throw std::invalid_argument("subdev_spec");
+
+  std::vector<db_base_sptr> db = this->db(ss.side);
+  
+  if(db[0]->i_and_q_swapped()) {
+    unsigned int mask[2] = {0x0089, 0x8900};
+    return mask[ss.side];
+  }
+  else {
+    unsigned int mask[2] = {0x0098, 0x9800};
+    return mask[ss.side];
+  }
+}
+
+
+
 #ifdef USE_FPGA_TX_CORDIC
 
 bool

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_standard.h
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_standard.h  
    2008-11-07 19:48:03 UTC (rev 9953)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_standard.h  
    2008-11-07 21:51:36 UTC (rev 9954)
@@ -163,6 +163,12 @@
   bool set_mux  (int mux);
 
   /*!
+   * Determine the appropriate Rx mux value as a function of the subdevice 
choosen
+   * and the characteristics of the respective daughterboard.
+   */
+  int determine_rx_mux_value(const usrp_subdev_spec &ss);
+
+  /*!
    * \brief set the frequency of the digital down converter.
    *
    * \p channel must be in the range [0,3].  \p freq is the center
@@ -351,6 +357,12 @@
   bool set_mux  (int mux);
 
   /*!
+   * Determine the appropriate Tx mux value as a function of the subdevice 
choosen
+   * and the characteristics of the respective daughterboard.
+   */
+  int determine_tx_mux_value(const usrp_subdev_spec &ss);
+
+  /*!
    * \brief set the frequency of the digital up converter.
    *
    * \p channel must be in the range [0,1].  \p freq is the center





reply via email to

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