/* * nextpnr -- Next Generation Place and Route * * Copyright (C) 2018 Clifford Wolf * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include "gfx.h" NEXTPNR_NAMESPACE_BEGIN void gfxTileWire(std::vector &g, int x, int y, GfxTileWireId id, GraphicElement::style_t style) { GraphicElement el; el.type = GraphicElement::G_LINE; el.style = style; // Horizontal Span-4 Wires if (id >= TILE_WIRE_SP4_H_L_36 && id <= TILE_WIRE_SP4_H_L_47) { int idx = (id - TILE_WIRE_SP4_H_L_36) + 48; float y1 = y + 1.0 - (0.03 + 0.0025 * (60 - (idx ^ 1))); float y2 = y + 1.0 - (0.03 + 0.0025 * (60 - idx)); el.x1 = x; el.x2 = x + 0.01; el.y1 = y1; el.y2 = y1; g.push_back(el); el.x1 = x + 0.01; el.x2 = x + 0.02; el.y1 = y1; el.y2 = y2; g.push_back(el); el.x1 = x + 0.02; el.x2 = x + 0.9; el.y1 = y2; el.y2 = y2; g.push_back(el); el.x1 = x + main_swbox_x1 + 0.0025 * (idx + 35); el.x2 = el.x1; el.y1 = y2; el.y2 = y + main_swbox_y2; g.push_back(el); } if (id >= TILE_WIRE_SP4_H_R_0 && id <= TILE_WIRE_SP4_H_R_47) { int idx = id - TILE_WIRE_SP4_H_R_0; float y1 = y + 1.0 - (0.03 + 0.0025 * (60 - idx)); float y2 = y + 1.0 - (0.03 + 0.0025 * (60 - (idx ^ 1))); float y3 = y + 1.0 - (0.03 + 0.0025 * (60 - (idx ^ 1) - 12)); if (idx >= 12) { el.x1 = x; el.x2 = x + 0.01; el.y1 = y1; el.y2 = y1; g.push_back(el); el.x1 = x + 0.01; el.x2 = x + 0.02; el.y1 = y1; el.y2 = y2; g.push_back(el); } el.x1 = x + 0.02; el.x2 = x + 0.9; el.y1 = y2; el.y2 = y2; g.push_back(el); el.x1 = x + 0.9; el.x2 = x + 1.0; el.y1 = y2; el.y2 = y3; g.push_back(el); el.x1 = x + main_swbox_x1 + 0.0025 * ((idx ^ 1) + 35); el.x2 = el.x1; el.y1 = y2; el.y2 = y + main_swbox_y2; g.push_back(el); } // Vertical Span-4 Wires if (id >= TILE_WIRE_SP4_V_T_36 && id <= TILE_WIRE_SP4_V_T_47) { int idx = (id - TILE_WIRE_SP4_V_T_36) + 48; float x1 = x + 0.03 + 0.0025 * (60 - (idx ^ 1)); float x2 = x + 0.03 + 0.0025 * (60 - idx); el.y1 = y + 1.00; el.y2 = y + 0.99; el.x1 = x1; el.x2 = x1; g.push_back(el); el.y1 = y + 0.99; el.y2 = y + 0.98; el.x1 = x1; el.x2 = x2; g.push_back(el); el.y1 = y + 0.98; el.y2 = y + 0.10; el.x1 = x2; el.x2 = x2; g.push_back(el); el.y1 = y + 1.0 - (0.03 + 0.0025 * (270 - idx)); el.y2 = el.y1; el.x1 = x2; el.x2 = x + main_swbox_x1; g.push_back(el); } if (id >= TILE_WIRE_SP4_V_B_0 && id <= TILE_WIRE_SP4_V_B_47) { int idx = id - TILE_WIRE_SP4_V_B_0; float x1 = x + 0.03 + 0.0025 * (60 - idx); float x2 = x + 0.03 + 0.0025 * (60 - (idx ^ 1)); float x3 = x + 0.03 + 0.0025 * (60 - (idx ^ 1) - 12); if (idx >= 12) { el.y1 = y + 1.00; el.y2 = y + 0.99; el.x1 = x1; el.x2 = x1; g.push_back(el); el.y1 = y + 0.99; el.y2 = y + 0.98; el.x1 = x1; el.x2 = x2; g.push_back(el); } el.y1 = y + 0.98; el.y2 = y + 0.10; el.x1 = x2; el.x2 = x2; g.push_back(el); el.y1 = y + 0.10; el.y2 = y; el.x1 = x2; el.x2 = x3; g.push_back(el); el.y1 = y + 1.0 - (0.03 + 0.0025 * (145 - (idx ^ 1))); el.y2 = el.y1; el.x1 = x; el.x2 = x2; g.push_back(el); el.y1 = y + 1.0 - (0.03 + 0.0025 * (270 - (idx ^ 1))); el.y2 = el.y1; el.x1 = x2; el.x2 = x + main_swbox_x1; g.push_back(el); } // Horizontal Span-12 Wires if (id >= TILE_WIRE_SP12_H_L_22 && id <= TILE_WIRE_SP12_H_L_23) { int idx = (id - TILE_WIRE_SP12_H_L_22) + 24; float y1 = y + 1.0 - (0.03 + 0.0025 * (90 - (idx ^ 1))); float y2 = y + 1.0 - (0.03 + 0.0025 * (90 - idx)); el.x1 = x; el.x2 = x + 0.01; el.y1 = y1; el.y2 = y1; g.push_back(el); el.x1 = x + 0.01; el.x2 = x + 0.02; el.y1 = y1; el.y2 = y2; g.push_back(el); el.x1 = x + 0.02; el.x2 = x + 0.98333; el.y1 = y2; el.y2 = y2; g.push_back(el); el.x1 = x + main_swbox_x1 + 0.0025 * (idx + 5); el.x2 = el.x1; el.y1 = y2; el.y2 = y + main_swbox_y2; g.push_back(el); } if (id >= TILE_WIRE_SP12_H_R_0 && id <= TILE_WIRE_SP12_H_R_23) { int idx = id - TILE_WIRE_SP12_H_R_0; float y1 = y + 1.0 - (0.03 + 0.0025 * (90 - idx)); float y2 = y + 1.0 - (0.03 + 0.0025 * (90 - (idx ^ 1))); float y3 = y + 1.0 - (0.03 + 0.0025 * (90 - (idx ^ 1) - 2)); if (idx >= 2) { el.x1 = x; el.x2 = x + 0.01; el.y1 = y1; el.y2 = y1; g.push_back(el); el.x1 = x + 0.01; el.x2 = x + 0.02; el.y1 = y1; el.y2 = y2; g.push_back(el); } el.x1 = x + 0.02; el.x2 = x + 0.98333; el.y1 = y2; el.y2 = y2; g.push_back(el); el.x1 = x + 0.98333; el.x2 = x + 1.0; el.y1 = y2; el.y2 = y3; g.push_back(el); el.x1 = x + main_swbox_x1 + 0.0025 * ((idx ^ 1) + 5); el.x2 = el.x1; el.y1 = y2; el.y2 = y + main_swbox_y2; g.push_back(el); } // Vertical Right Span-4 if (id >= TILE_WIRE_SP4_R_V_B_0 && id <= TILE_WIRE_SP4_R_V_B_47) { int idx = id - TILE_WIRE_SP4_R_V_B_0;
/*
Copyright 2011 Jun Wako <wakojun@gmail.com>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef DEBUG_H
#define DEBUG_H 1

#include <stdbool.h>
#include "print.h"


#ifdef __cplusplus
extern "C" {
#endif

/*
 * Debug output control
 */
typedef union {
    struct {
        bool enable:1;
        bool matrix:1;
        bool keyboard:1;
        bool mouse:1;
        uint8_t reserved:4;
    };
    uint8_t raw;
} debug_config_t;

extern debug_config_t debug_config;

#ifdef __cplusplus
}
#endif

/* for backward compatibility */
#define debug_enable    (debug_config.enable)
#define debug_matrix    (debug_config.matrix)
#define debug_keyboard  (debug_config.keyboard)
#define debug_mouse     (debug_config.mouse)


/*
 * Debug print utils
 */
#ifndef NO_DEBUG

#define dprint(s)                   do { if (debug_enable) print(s); } while (0)
#define dprintln(s)                 do { if (debug_enable) println(s); } while (0)
#define dprintf(fmt, ...)           do { if (debug_enable) xprintf(fmt, ##__VA_ARGS__); } while (0)
#define dmsg(s)                     dprintf("%s at %s: %S\n", __FILE__, __LINE__, PSTR(s))

/* Deprecated. DO NOT USE these anymore, use dprintf instead. */
#define debug(s)                    do { if (debug_enable) print(s); } while (0)
#define debugln(s)                  do { if (debug_enable) println(s); } while (0)
#define debug_msg(s)                do { \
    if (debug_enable) { \
        print(__FILE__); print(" at "); print_dec(__LINE__); print(" in "); print(": "); print(s); \
    } \
} while (0)
#define debug_dec(data)             do { if (debug_enable) print_dec(data); } while (0)
#define debug_decs(data)            do { if (debug_enable) print_decs(data); } while (0)
#define debug_hex4(data)            do { if (debug_enable) print_hex4(data); } while (0)
#define debug_hex8(data)            do { if (debug_enable) print_hex8(data); } while (0)
#define debug_hex16(data)           do { if (debug_enable) print_hex16(data); } while (0)
#define debug_hex32(data)           do { if (debug_enable) print_hex32(data); } while (0)
#define debug_bin8(data)            do { if (debug_enable) print_bin8(data); } while (0)
#define debug_bin16(data)           do { if (debug_enable) print_bin16(data); } while (0)
#define debug_bin32(data)           do { if (debug_enable) print_bin32(data); } while (0)
#define debug_bin_reverse8(data)    do { if (debug_enable) print_bin_reverse8(data); } while (0)
#define debug_bin_reverse16(data)   do { if (debug_enable) print_bin_reverse16(data); } while (0)
#define debug_bin_reverse32(data)   do { if (debug_enable) print_bin_reverse32(data); } while (0)
#define debug_hex(data)             debug_hex8(data)
#define debug_bin(data)             debug_bin8(data)
#define debug_bin_reverse(data)     debug_bin8(data)

#else /* NO_DEBUG */

#define dprint(s)
#define dprintln(s)
#define dprintf(fmt, ...)
#define dmsg(s)
#define debug(s)
#define debugln(s)
#define debug_msg(s)
#define debug_dec(data)
#define debug_decs(data)
#define debug_hex4(data)
#define debug_hex8(data)
#define debug_hex16(data)
#define debug_hex32(data)
#define debug_bin8(data)
#define debug_bin16(data)
#define debug_bin32(data)
#define debug_bin_reverse8(data)
#define debug_bin_reverse16(data)
#define debug_bin_reverse32(data)
#define debug_hex(data)
#define debug_bin(data)
#define debug_bin_reverse(data)

#endif /* NO_DEBUG */

#endif