def __generate_pixels_evenly(self, number): # TODO: Finish
        self.pixels = []

        for i in range(number):
            new_pixel = pixel.Pixel(self.grid_width, self.grid_height)

            self.pixels.append(new_pixel)
Beispiel #2
0
    def __iter__(self):
        """Return this Picture's Pixels from top to bottom,
        left to right."""

        width = self.get_width()
        height = self.get_height()

        for x in xrange(0, width):
            for y in xrange(0, height):
                yield pixel.Pixel(self.pixels, x, y)
Beispiel #3
0
 def read(self, raw_frame):
     width = raw_frame["width"]
     height = raw_frame["height"]
     raw_data = base64.b64decode(raw_frame["pixels"])
     pixels = [
         pixel.Pixel(ord(raw_data[i]), ord(raw_data[i + 1]),
                     ord(raw_data[i + 2]))
         for i in range(0, len(raw_data), 3)
     ]
     frame = Frame(width, height, pixels)
     return frame
Beispiel #4
0
    def setUp(self):

        fw_path = os.path.join(get_basil_dir(), 'firmware/modules')
        cocotb_compile_and_run([
            os.path.join(fw_path, 'gpio/gpio.v'),
            os.path.join(fw_path, 'gpio/gpio_core.v'),
            os.path.join(fw_path, 'utils/reset_gen.v'),
            os.path.join(fw_path, 'utils/bus_to_ip.v'),
            os.path.join(fw_path, 'rrp_arbiter/rrp_arbiter.v'),
            os.path.join(fw_path, 'utils/ODDR_sim.v'),
            os.path.join(fw_path, 'utils/generic_fifo.v'),
            os.path.join(fw_path, 'utils/cdc_pulse_sync.v'),
            os.path.join(fw_path, 'utils/fx2_to_bus.v'),
            os.path.join(fw_path, 'utils/BUFG_sim.v'),
            os.path.join(fw_path, 'utils/cdc_syncfifo.v'),
            os.path.join(fw_path, 'utils/ddr_des.v'),
            os.path.join(fw_path, 'utils/IDDR_sim.v'),
            os.path.join(fw_path, 'utils/DCM_sim.v'),
            os.path.join(fw_path, 'utils/clock_divider.v'),
            os.path.join(fw_path, 'utils/clock_multiplier.v'),
            os.path.join(fw_path, 'utils/flag_domain_crossing.v'),
            os.path.join(fw_path, 'utils/3_stage_synchronizer.v'),
            os.path.join(fw_path, 'fast_spi_rx/fast_spi_rx.v'),
            os.path.join(fw_path, 'fast_spi_rx/fast_spi_rx_core.v'),
            os.path.join(fw_path, 'seq_gen/seq_gen.v'),
            os.path.join(fw_path, 'seq_gen/seq_gen_core.v'),
            os.path.join(fw_path, 'tdc_s3/tdc_s3.v'),
            os.path.join(fw_path, 'tdc_s3/tdc_s3_core.v'),
            os.path.join(fw_path, 'sram_fifo/sram_fifo_core.v'),
            os.path.join(fw_path, 'sram_fifo/sram_fifo.v'),
            os.path.join(os.path.dirname(__file__),
                         '../firmware/src/clk_gen.v'),
            os.path.join(os.path.dirname(__file__), '../firmware/src/pixel.v'),
            os.path.join(os.path.dirname(__file__), '../tests/tb.v')
        ],
                               top_level='tb',
                               sim_bus='basil.utils.sim.SiLibUsbBusDriver')

        with open(os.path.join(os.path.dirname(__file__), '../pixel.yaml'),
                  'r') as f:
            cnfg = yaml.safe_load(f)

        # change to simulation interface
        cnfg['transfer_layer'][0]['type'] = 'SiSim'

        self.chip = pixel.Pixel(cnfg)
        self.chip.init()
    def __generate_pixels_randomly(self, number, infected = -1):
        self.pixels = []

        # Handle the default infected value
        if infected < 0:
            infected = int(number * 0.2) + 1

        # Create the requested number of pixels
        for i in range(number):
            new_pixel = pixel.Pixel(self.grid_width, self.grid_height)

            new_pixel.x = random.randint(0, self.grid_width - 1)
            new_pixel.y = random.randint(0, self.grid_height - 1)

            # Infect the number of pixels defined by the infected variable
            if i < infected:
                new_pixel.color = pixel.Pixel.red

            self.pixels.append(new_pixel)
Beispiel #6
0
    def get_pixel(self, x, y):
        """Return the Pixel at coordinates (x, y)."""

        return pixel.Pixel(self.pixels, x, y)