commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r5558 - in gnuradio/branches/developers/jcorgan/snd/gr


From: jcorgan
Subject: [Commit-gnuradio] r5558 - in gnuradio/branches/developers/jcorgan/snd/gr-sounder/src: fpga/tb python
Date: Mon, 28 May 2007 14:38:36 -0600 (MDT)

Author: jcorgan
Date: 2007-05-28 14:38:36 -0600 (Mon, 28 May 2007)
New Revision: 5558

Modified:
   
gnuradio/branches/developers/jcorgan/snd/gr-sounder/src/fpga/tb/sounder_tb.sav
   gnuradio/branches/developers/jcorgan/snd/gr-sounder/src/fpga/tb/sounder_tb.v
   gnuradio/branches/developers/jcorgan/snd/gr-sounder/src/python/test_lp.sh
   gnuradio/branches/developers/jcorgan/snd/gr-sounder/src/python/test_rx.sh
   gnuradio/branches/developers/jcorgan/snd/gr-sounder/src/python/test_tx.sh
   
gnuradio/branches/developers/jcorgan/snd/gr-sounder/src/python/usrp_sounder.py
Log:
Work in progress.

Modified: 
gnuradio/branches/developers/jcorgan/snd/gr-sounder/src/fpga/tb/sounder_tb.sav
===================================================================
--- 
gnuradio/branches/developers/jcorgan/snd/gr-sounder/src/fpga/tb/sounder_tb.sav  
    2007-05-28 19:58:33 UTC (rev 5557)
+++ 
gnuradio/branches/developers/jcorgan/snd/gr-sounder/src/fpga/tb/sounder_tb.sav  
    2007-05-28 20:38:36 UTC (rev 5558)
@@ -1,4 +1,4 @@
-*-26.117517 250000000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 
-1 -1 -1 -1 -1 -1 -1
+*-24.753519 93900000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 
-1 -1 -1 -1 -1 -1 -1
 @28
 sounder_tb.uut.clk_i
 sounder_tb.rst
@@ -23,7 +23,9 @@
 -
 @22
 sounder_tb.fifo_strobe
address@hidden
 sounder_tb.fifo_i[15:0]
address@hidden
 sounder_tb.fifo_q[15:0]
 @200
 -
@@ -32,3 +34,7 @@
 sounder_tb.uut.receiver.pn_ref
 @200
 -
address@hidden
+sounder_tb.tx_strobe
address@hidden
+sounder_tb.uut.receiver.sum_i[31:0]

Modified: 
gnuradio/branches/developers/jcorgan/snd/gr-sounder/src/fpga/tb/sounder_tb.v
===================================================================
--- 
gnuradio/branches/developers/jcorgan/snd/gr-sounder/src/fpga/tb/sounder_tb.v    
    2007-05-28 19:58:33 UTC (rev 5557)
+++ 
gnuradio/branches/developers/jcorgan/snd/gr-sounder/src/fpga/tb/sounder_tb.v    
    2007-05-28 20:38:36 UTC (rev 5558)
@@ -197,14 +197,14 @@
         #20 enable_rx(1);
         #20 enable_lp(1);
         #20 set_reset(0);
-        #((uut.len+1)*uut.len*20);
+        #((uut.len+1)*uut.len*20*2);
       end
    endtask // test_lp
    
    // Execute tests
    initial
      begin
-        #20 test_tx(12);
+        // #20 test_tx(12);
        #20 test_lp(12);
        #100 $finish;
      end

Modified: 
gnuradio/branches/developers/jcorgan/snd/gr-sounder/src/python/test_lp.sh
===================================================================
--- gnuradio/branches/developers/jcorgan/snd/gr-sounder/src/python/test_lp.sh   
2007-05-28 19:58:33 UTC (rev 5557)
+++ gnuradio/branches/developers/jcorgan/snd/gr-sounder/src/python/test_lp.sh   
2007-05-28 20:38:36 UTC (rev 5558)
@@ -1,4 +1,4 @@
 #!/bin/sh
 
-usrp_sounder.py -r -l -t -n5000 -d12
+./usrp_sounder.py -r -l -t -n65536 -d10 -v
 hexdump output.dat >output.hex

Modified: 
gnuradio/branches/developers/jcorgan/snd/gr-sounder/src/python/test_rx.sh
===================================================================
--- gnuradio/branches/developers/jcorgan/snd/gr-sounder/src/python/test_rx.sh   
2007-05-28 19:58:33 UTC (rev 5557)
+++ gnuradio/branches/developers/jcorgan/snd/gr-sounder/src/python/test_rx.sh   
2007-05-28 20:38:36 UTC (rev 5558)
@@ -1,4 +1,4 @@
 #!/bin/sh
 
-usrp_sounder.py -r -n5000 -d12
+time ./usrp_sounder.py -r -n65536 -d10 -R A -f 1.8G -v
 hexdump output.dat >output.hex

Modified: 
gnuradio/branches/developers/jcorgan/snd/gr-sounder/src/python/test_tx.sh
===================================================================
--- gnuradio/branches/developers/jcorgan/snd/gr-sounder/src/python/test_tx.sh   
2007-05-28 19:58:33 UTC (rev 5557)
+++ gnuradio/branches/developers/jcorgan/snd/gr-sounder/src/python/test_tx.sh   
2007-05-28 20:38:36 UTC (rev 5558)
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-usrp_sounder.py -t -f 16M -d12
+./usrp_sounder.py -t -f 16M -d16 -v

Modified: 
gnuradio/branches/developers/jcorgan/snd/gr-sounder/src/python/usrp_sounder.py
===================================================================
--- 
gnuradio/branches/developers/jcorgan/snd/gr-sounder/src/python/usrp_sounder.py  
    2007-05-28 19:58:33 UTC (rev 5557)
+++ 
gnuradio/branches/developers/jcorgan/snd/gr-sounder/src/python/usrp_sounder.py  
    2007-05-28 20:38:36 UTC (rev 5558)
@@ -36,6 +36,81 @@
 
 FR_DEGREE = usrp.FR_USER_1
 
+def pick_subdevice(u):
+    """
+    The user didn't specify a subdevice on the command line.
+    If there's a daughterboard on A, select A.
+    If there's a daughterboard on B, select B.
+    Otherwise, select A.
+    """
+    if u.db[0][0].dbid() >= 0:       # dbid is < 0 if there's no d'board or a 
problem
+        return (0, 0)
+    if u.db[1][0].dbid() >= 0:
+        return (1, 0)
+    return (0, 0)
+
+class sounder_tx:
+    def __init__(self, options):
+        self._options = options
+        self._u = usrp.sink_s(fpga_filename='usrp_sounder.rbf')
+        self._subdev_spec = usrp.pick_tx_subdevice(self._u)
+        self._subdev = usrp.selected_subdev(self._u, self._subdev_spec)
+        if options.verbose:
+            print "Using", self._subdev.name(), "for sounder transmitter."     
       
+        self._u.start()
+
+    def tune(self, frequency):
+        if self._options.verbose:
+            print "Setting transmitter frequency to", n2s(frequency)
+        result = self._u.tune(0, self._subdev, frequency)
+        if result == False:
+            raise RuntimeError("Failed to set transmitter frequency.")
+
+class sounder_rx:
+    def __init__(self, options):
+        self._options = options
+        self._fg = gr.flow_graph()
+        self._u = usrp.source_c(fpga_filename='usrp_sounder.rbf')
+        if options.rx_subdev_spec == None:
+            options.rx_subdev_spec = usrp.pick_rx_subdevice(self._u)
+        self._u.set_mux(usrp.determine_rx_mux_value(self._u, 
options.rx_subdev_spec))
+        self._subdev = usrp.selected_subdev(self._u, options.rx_subdev_spec)
+        if options.verbose:
+            print "Using", self._subdev.name(), "for sounder receiver."
+        self._sink = gr.file_sink(gr.sizeof_gr_complex, "output.dat")
+
+        if options.samples >= 0:
+            self._head = gr.head(gr.sizeof_gr_complex, options.samples)
+            self._fg.connect(self._u, self._head, self._sink)
+        else:
+            self._fg.connect(self._u, self._sink)
+
+    def tune(self, frequency):
+        if self._options.verbose:
+            print "Setting receiver frequency to", n2s(frequency)
+        result = self._u.tune(0, self._subdev, frequency)
+        if result == False:
+            raise RuntimeError("Failed to set receiver frequency.")
+
+    def start(self):
+        if self._options.debug:
+            print "Starting receiver flow graph."
+        self._fg.start()
+
+    def wait(self):
+        self._fg.wait()
+
+    def stop(self):
+        if self._options.debug:
+            print "Stopping receiver flow graph."
+        self._fg.stop()
+        if self._options.debug:
+            print "Waiting for threads..."
+        self._fg.wait()
+        if self._options.debug:
+            print "Receiver flow graph stopped."
+
+
 class sounder:
     def __init__(self, options):
        self._options = options
@@ -48,95 +123,82 @@
        self._receiving = False
                
        if options.transmit:
-           print "Creating sounder transmitter."
-           self._trans = usrp.sink_s(fpga_filename='usrp_sounder.rbf')
-            self._trans_subdev_spec = usrp.pick_tx_subdevice(self._trans)
-           self._trans_subdev = usrp.selected_subdev(self._trans, 
self._trans_subdev_spec)
-           self._trans.start()
-           self._u = self._trans
-               
+           self._trans = sounder_tx(options)
+            self._u = self._trans._u
+            
        if options.receive:
-           print "Creating sounder receiver."
-            self._fg = gr.flow_graph()
-           self._rcvr = usrp.source_s(fpga_filename='usrp_sounder.rbf', 
decim_rate=128)
-           self._rcvr_subdev_spec = usrp.pick_rx_subdevice(self._rcvr)
-           self._rcvr_subdev = usrp.selected_subdev(self._rcvr, 
self._rcvr_subdev_spec)
-           self._sink = gr.file_sink(gr.sizeof_short, "output.dat")
-
-           if options.samples >= 0:
-               self._head = gr.head(gr.sizeof_short, 
options.samples*gr.sizeof_short)
-               self._fg.connect(self._rcvr, self._head, self._sink)
-           else:
-               self._fg.connect(self._rcvr, self._sink)
-           self._u = self._rcvr # either receiver or transmitter object will do
+            self._rcvr = sounder_rx(options)
+           self._u = self._rcvr._u # either receiver or transmitter object 
will do
        
        self.set_reset(True)
-       self.set_freq(options.frequency)
+        if options.loopback == False:
+            self.tune(options.frequency)
        self.set_degree(options.degree)
        self.set_loopback(options.loopback)     
        self.set_reset(False)
                
-    def set_freq(self, frequency):
-       print "Setting center frequency to", n2s(frequency)
+    def tune(self, frequency):
        if self._rcvr:
-           self._rcvr.tune(0, self._rcvr_subdev, frequency)
-       
+            self._rcvr.tune(frequency)
        if self._trans:
-           self._trans.tune(0, self._trans_subdev, frequency)
+           self._trans.tune(frequency)
 
     def set_degree(self, degree):
-       print "Setting PN code degree to", degree
+        if self._options.verbose:
+            print "Setting PN code degree to", degree
         self._u._write_fpga_reg(FR_DEGREE, degree);
            
     def _write_mode(self):
-       print "Writing mode register with:", hex(self._mode)
+        if self._options.debug:
+            print "Writing mode register with:", hex(self._mode)
         self._u._write_fpga_reg(FR_MODE, self._mode)
 
     def enable_tx(self, value):
        if value:
-           print "Enabling transmitter."
+            if self._options.verbose:
+                print "Enabling transmitter."
            self._mode |= bmFR_MODE_TX
            self._transmitting = True
        else:
-           print "Disabling transmitter."
+            if self._options.verbose:
+                print "Disabling transmitter."
            self._mode &= ~bmFR_MODE_TX
        self._write_mode()
                    
     def enable_rx(self, value):
        if value:
-           print "Starting receiver flow graph."
            self._mode |= bmFR_MODE_RX
            self._write_mode()
-           self._fg.start()
+           self._rcvr.start()
            self._receiving = True
            if self._options.samples >= 0:
-               self._fg.wait()
+               self._rcvr.wait()
        else:
-           print "Stopping receiver flow graph."
            if self._options.samples < 0:
-               self._fg.stop()
-               print "Waiting for threads..."
-               self._fg.wait()
-               print "Receiver flow graph stopped."
+                self._rcvr.stop()
            self._mode &= ~bmFR_MODE_RX
            self._write_mode()
            self._receiving = False
                
     def set_loopback(self, value):
        if value:
-           print "Enabling digital loopback."
+            if self._options.verbose:
+                print "Enabling digital loopback."
            self._mode |= bmFR_MODE_LP
        else:
-           print "Disabling digital loopback."
+            if self._options.verbose:
+                print "Disabling digital loopback."
            self._mode &= ~bmFR_MODE_LP
        self._write_mode()
 
     def set_reset(self, value):
        if value:
-           print "Asserting reset."
+            if self._options.debug:
+                print "Asserting reset."
            self._mode |= bmFR_MODE_RESET
        else:
-           print "De-asserting reset."
+            if self._options.debug:
+                print "De-asserting reset."
            self._mode &= ~bmFR_MODE_RESET
        self._write_mode()
 
@@ -151,23 +213,24 @@
     
 def main():
     parser = OptionParser(option_class=eng_option)
+    parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=(0, 0),
+                      help="select USRP Rx side A or B")
     parser.add_option("-f", "--frequency", type="eng_float", default=0.0,
                       help="set frequency to FREQ in Hz, default is %default", 
metavar="FREQ")
-
     parser.add_option("-d", "--degree", type="int", default=16,
                       help="set souding sequence degree (len=2^degree-1), 
default is %default")
-
     parser.add_option("-t", "--transmit", action="store_true", default=False,
                       help="enable sounding transmitter")
-
     parser.add_option("-r", "--receive", action="store_true", default=False,
                       help="enable sounding receiver")
-
     parser.add_option("-n", "--samples", type="int", default=-1,
                       help="number of samples to capture on receive, default 
is infinite")
-
     parser.add_option("-l", "--loopback", action="store_true", default=False,
                       help="enable digital loopback, default is disabled")
+    parser.add_option("-v", "--verbose", action="store_true", default=False,
+                      help="enable verbose output, default is disabled")
+    parser.add_option("-D", "--debug", action="store_true", default=False,
+                      help="enable debugging output, default is disabled")
 
     (options, args) = parser.parse_args()
 
@@ -175,8 +238,10 @@
         parser.print_help()
         sys.exit(1)
 
-    print "Using PN code degree of", options.degree, "length", 
2**options.degree-1
-    print "Sounding frequency range is", n2s(options.frequency-16e6), "to", 
n2s(options.frequency+16e6)
+    if options.verbose:
+        print "Using PN code degree of", options.degree, "length", 
2**options.degree-1
+       if options.loopback == False:
+            print "Sounding frequency range is", n2s(options.frequency-16e6), 
"to", n2s(options.frequency+16e6)
     
     s = sounder(options)
 





reply via email to

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