-
Notifications
You must be signed in to change notification settings - Fork 8
/
gui.h
162 lines (136 loc) · 3.54 KB
/
gui.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
// Labarc FPGA Simulator
// This program is based in part on the work of the FLTK project (http://www.fltk.org).
// This program is free software; you can
// redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.1.
// Icaro Dantas de Araujo Lima and Elmar Melcher at UFCG, 2019
#include <sstream>
#include <iomanip>
#include <FL/Fl.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_PNG_Image.H>
#include <FL/Fl_Check_Button.H>
#include <FL/Fl_Spinner.H>
#include <FL/Fl_Window.H>
using std::stringstream;
using std::hex;
using std::setw;
using std::setfill;
using std::uppercase;
using std::nouppercase;
using std::string;
#define ASSETS_DIR "Assets/"
#define ASSET(F) (string(ASSETS_DIR) + F).c_str()
#define XMARGIN 10
#define YMARGIN 10
#define NSWIS 8
#define SWIS_OFFSET 64
#define LCD_OFFSET 270
#define NLEDS 8
#define LEDS_VERTICAL_OFFSET 212
#define CLOCK_PERIOD_WIDTH 50
#define LCD_FONT ((Fl_Font)56)
#define LCD_FONT_SIZE 32
#define LCD_NCHAR 16
#define DISPLAY_FONT ((Fl_Font)55)
#define DISPLAY_FONT_SIZE 13
#define NREGS 16 // use reduced register count to optimize remote FPGA response time
#define NREGS_PER_LINE 4
#define NREG_LINES (NREGS/NREGS_PER_LINE)
#define CLOCK 0.25
#define LABEL_SIZE 16
class SWI : public Fl_Widget {
int id;
public:
bool state;
virtual void draw();
virtual int handle(int event);
SWI(int x, int y, int id);
};
class SWIs : public Fl_Widget {
SWI *swis[NSWIS];
public:
static Fl_PNG_Image *swi_on, *swi_off;
SWIs(int x, int y, int offset);
virtual void draw();
};
class LEDs : public Fl_Widget {
int x_origin, y_origin, offset;
public:
static Fl_PNG_Image *led_on, *led_off;
LEDs(int x_origin, int y_origin, int offset);
virtual void draw();
};
// show SystemVerilog output signal in graphic interface
class display : public Fl_Widget { // FLTK Widget
public:
void draw();
display(int x, int y, int w);
private:
int offset;
void lcd_labels();
void register_labels();
};
class hexval : public Fl_Widget {
public:
void draw();
hexval(int x, int y, int w);
private:
int offset;
void lcd_lines(long a, long b);
};
class LCD_check : public Fl_Check_Button {
public:
LCD_check(int x, int y);
virtual int handle(int event);
};
class RISCV_check : public Fl_Check_Button {
public:
RISCV_check(int x, int y);
virtual int handle(int event);
};
class SegmentsDisplay : public Fl_Widget {
bool *previous;
Fl_PNG_Image *point_on, *point_off, *vertical_on, *vertical_off, *horizontal_on, *horizontal_off;
public:
static Fl_PNG_Image *base;
virtual void draw();
SegmentsDisplay(int x, int y);
private:
void draw_segments(char s);
};
class Board : public Fl_Widget {
public:
static Fl_PNG_Image *image;
virtual void draw();
Board(int x, int y);
SWIs *swis; // switches
SegmentsDisplay *segments; // seven LED segment display
};
// not used
class Clock : public Fl_Spinner {
public:
Clock(int x, int y);
};
class FPGA : public Fl_Widget {
public:
static Fl_PNG_Image *image;
float display_char_width;
float lcd_char_width;
LCD_check *lcd_check;
RISCV_check *riscv_check;
FPGA(int x, int y);
virtual void draw();
private:
Board *board; // printed circuit board attached to the FPGA board
LEDs *leds;
display *disp; // RISC-V processor display
hexval *hexv; // display for two hexadecimal number of 16 digits each
};
void init_gui(int, char**, char *);
void delete_gui();
void callback(void*);
void rec_set_lcd();
extern FPGA *fpga;