Пример #1
0
        /**
         * Runs the BIST function (built-in self test)
         *
         * Not completely implemented as of 09.06.2013
         *
         * dac.py : runBIST
         */
        public void RunBIST(DAC dac)
        {
            WaveForm.ZeroWave wave    = new WaveForm.ZeroWave();
            Data.Data[]       packets = wave.Prep().Run();
            this.server.SendAll(this.mac_address, packets.Select(x => x.data).ToArray());

            WaveForm.RandomWave bist = new WaveForm.RandomWave(1004);
            for (int i = 0; i < 4; i++)
            {
                bist.wave[i] = 0.0;
            }
            bist.Prep(shift: dac.name);
            Data.Data[] bist_packets = bist.Run();
            // send all but the last packet from bist_packets
            // this last packet executes the wave - this is sent later
            server.SendAll(this.mac_address, bist_packets.Take(bist_packets.Length - 1).Select(x => x.data).ToArray());

            Data.Data[] serial_packets = Data.SerialData.LoadSerialData(dac.mode, new int[] { 0x000004, 0x001107, 0x001106 }, readback: 0x00);
            this.server.SendAll(this.mac_address, serial_packets.Select(x => x.data).ToArray());

            // executes the wave
            server.Send(this.mac_address, bist_packets[bist_packets.Length - 1].data);

            Data.Data[] queries = Data.SerialData.LoadSerialData(dac.mode, new int[] {
                0x001126, 0x009200, 0x009300, 0x009400, 0x009500,
                0x001166, 0x009200, 0x009300, 0x009400, 0x009500,
                0x0011A6, 0x009200, 0x009300, 0x009400, 0x009500,
                0x0011E6, 0x009200, 0x009300, 0x009400, 0x009500
            }, readback: 0x01);

            Data.RegisterResponse[] responses = Data.RegisterResponse.LoadRegisterResponse(server.SendAll(this.mac_address, queries.Select(x => x.data).ToArray()));
        }
Пример #2
0
        /**
         * Sets FIFO
         *
         * dac.py : setFIFO
         */
        public bool FIFOReset(DAC dac)
        {
            int  target_fifo  = Board.fifo_counter;
            bool clock_invert = false;

            int  tries   = 1;
            bool success = false;

            server.Send(this.mac_address, new Data.ClockPolarity(dac.name, clock_invert, readback: 0x00).data);

            while (tries <= Board.max_fifo_tries && !success)
            {
                Data.Data[] queries = Data.SerialData.LoadSerialData(dac.mode, new int[] {
                    0x000700, 0x008700, 0x000701, 0x008700, 0x000702, 0x008700, 0x000703, 0x008700
                }, readback: 0x01);
                Data.RegisterResponse[] responses = Data.RegisterResponse.LoadRegisterResponse(server.SendAll(this.mac_address, queries.Select(x => x.data).ToArray()));

                List <int> fifo_counters = new List <int>();
                foreach (int i in new int[] { 1, 3, 5, 7 })
                {
                    fifo_counters.Add((responses[i].serial_dac >> 4) & 0x0F);
                }

                success = this.CheckPHOF(dac, fifo_counters.ToArray(), target_fifo);
                if (success)
                {
                    break;
                }
                else
                {
                    clock_invert = !clock_invert;
                    server.Send(this.mac_address, new Data.ClockPolarity(dac.name, clock_invert, readback: 0x00).data);
                    tries += 1;
                }
            }
            return(success);
        }
Пример #3
0
        public bool CheckPHOF(DAC dac, int[] fifo_counters, int target_fifo)
        {
            bool success = true;

            int[] PHOFs = fifo_counters.Where(x => (x == target_fifo)).ToArray();
            if (PHOFs.Length > 0)
            {
                foreach (int PHOF in PHOFs)
                {
                    Data.Data[]             queries   = Data.SerialData.LoadSerialData(dac.mode, new int[] { 0x000700 + PHOF, 0x008700 }, readback: 0x01);
                    Data.RegisterResponse[] responses = Data.RegisterResponse.LoadRegisterResponse(this.server.SendAll(this.mac_address, queries.Select(x => x.data).ToArray()));
                    if (((responses[0].serial_dac >> 4) & 0x0F) == target_fifo)
                    {
                        success = true;
                        break;
                    }
                }
            }
            else
            {
                success = false;
            }
            return(success);
        }
Пример #4
0
        /**
         * Sets the LVDS
         *
         * dac.py : setLVDS
         */
        public bool LVDSReset(DAC dac)
        {
            bool success = true;

            int  t   = lvds_sd & 0x0F;
            int  msd = -1;
            int  mhd = -1;
            bool set = true;

            int[] int_data = new int[65];
            int_data[0] = 0x000500 + (t << 4);
            for (int i = 0; i < 16; i++)
            {
                int_data[1 + i * 4 + 0] = 0x000400 + (i << 4);
                int_data[1 + i * 4 + 1] = 0x008500;
                int_data[1 + i * 4 + 2] = 0x000400 + i;
                int_data[1 + i * 4 + 3] = 0x008500;
            }

            Data.Data[]             queries   = Data.SerialData.LoadSerialData(dac.mode, int_data, readback: 0x01);
            Data.RegisterResponse[] responses = Data.RegisterResponse.LoadRegisterResponse(server.SendAll(this.mac_address, queries.Select(x => x.data).ToArray()));

            bool[] msd_bits = new bool[16];
            bool[] mhd_bits = new bool[16];
            for (int i = 0; i < 16; i++)
            {
                msd_bits[i] = (responses[i * 4 + 2].serial_dac & 0x01) == 0x01;
                mhd_bits[i] = (responses[i * 4 + 4].serial_dac & 0x01) == 0x01;
            }
            bool[] msd_switch = new bool[15];
            bool[] mhd_switch = new bool[15];
            for (int i = 0; i < 15; i++)
            {
                msd_switch[i] = msd_bits[i + 1] != msd_bits[i];
                mhd_switch[i] = mhd_bits[i + 1] != mhd_bits[i];
            }

            int lead_edge = System.Array.IndexOf(msd_switch, true);
            int last_edge = System.Array.IndexOf(mhd_switch, true);
            int msd_sum   = msd_switch.Select(x => Convert.ToInt32(x)).Sum();
            int mhd_sum   = mhd_switch.Select(x => Convert.ToInt32(x)).Sum();

            if (set)
            {
                if (msd_sum == 1)
                {
                    msd = lead_edge;
                }
                if (mhd_sum == 1)
                {
                    mhd = last_edge;
                }
            }

            if ((Math.Abs(last_edge - lead_edge) <= 1) && (msd_sum == 1) && (mhd_sum == 1))
            {
                success &= true;
            }
            else
            {
                success &= false;
            }
            return(success);
        }
Пример #5
0
 /**
  * Initializes the digital-analog converters
  */
 public void DACInitialize(DAC dac)
 {
     Data.Data[] packets = Data.SerialData.LoadSerialData(dac.mode, new int[] { 0x000024, 0x000004, 0x001603, 0x000500 }, readback: 0x00);
     this.server.SendAll(this.mac_address, packets.Select(x => x.data).ToArray());
 }