Skip to content

Commit 9aa00e9

Browse files
committed
retorna o Makefile ao que era antes
1 parent 1761022 commit 9aa00e9

File tree

4 files changed

+51
-41
lines changed

4 files changed

+51
-41
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ export VERILATOR_ROOT
4141
VERILATOR = $(VERILATOR_ROOT)/bin/verilator
4242
endif
4343

44-
default: gui.h gui.cpp top.sv
44+
default:
4545
$(VERILATOR) -cc --exe +1800-2012ext+sv top.sv sim_main.cpp gui.cpp $(FLTK)
4646
$(MAKE) -j 2 -C obj_dir -f Vtop.mk
4747
obj_dir/Vtop
4848

49-
#gui.o: gui.cpp gui.h
50-
# g++ $(CFLTK) -c gui.cpp
49+
gui.o: gui.cpp gui.h
50+
g++ $(CFLTK) -c gui.cpp
5151

5252
######################################################################
5353

gui.cpp

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,15 @@
99
#include "gui.h"
1010

1111
Fl_PNG_Image * FPGA::image = new Fl_PNG_Image("Assets/FPGA.png");
12-
FPGA::FPGA(int x, int y) : Fl_Widget(x, y, image->w(), image->h()) {
13-
disp = new display(x + image->w() / 2, y + image->h() / 2);
14-
disp->position(x + image->w() / 2 - disp->w() / 2, y + image->h() / 2);
15-
16-
board = new Board(x + image->w() / 2 - board->image->w() / 2, y);
17-
18-
int led_offset = 30;
19-
int led_x = x + image->w() / 2 - (leds->led_on->w() * 8 + 7 * (led_offset - leds->led_on->w())) / 2;
20-
leds = new LEDs(led_x, y + LEDS_VERTICAL_OFFSET, led_offset);
21-
}
12+
FPGA::FPGA(int x, int y) : Fl_Widget(x, y, image->w(), image->h()) { }
2213

2314
void FPGA::draw() {
24-
if (damage() == 0x80) {
25-
image->draw(x(), y());
26-
}
27-
if (damage() & 1) {
28-
leds->redraw();
29-
board->damage(1);
30-
disp->redraw();
31-
}
15+
image->draw(x(), y());
16+
//board->damage(1);
3217
}
3318

3419
Fl_PNG_Image * Board::image = new Fl_PNG_Image("Assets/Board.png");
35-
Board::Board(int x, int y) :
36-
swis(new SWIs(x + image->w() / 2 - (8 * SWIs::swi_on->w() + 7 * (SWIS_OFFSET - SWIs::swi_on->w()) + SegmentsDisplay::base->w()) / 2,
37-
y + image->h() / 2 - SWIs::swi_on->h() / 2, SWIS_OFFSET)),
38-
segments(new SegmentsDisplay(x + image->w() / 2 - segments->base->w() / 2, y + image->h() / 2 - segments->base->h() / 2)),
39-
Fl_Widget(x, y, image->w(), image->h()) {
40-
41-
}
20+
Board::Board(int x, int y) : Fl_Widget(x, y, image->w(), image->h()) { }
4221

4322
void Board::draw() {
4423
if (damage() & 0x80) {
@@ -47,9 +26,7 @@ void Board::draw() {
4726
}
4827
if (damage() & 1) {
4928
image->draw(x(), y());
50-
//image->draw(swis->x(), swis->y(), swis->w(), swis->h(), x() + swis->x(), y() + swis->y());
5129
swis->redraw();
52-
//image->draw(segments->x(), segments->y(), segments->w(), segments->h(), x() + segments->x(), y() + segments->y());
5330
segments->redraw();
5431
}
5532
}
@@ -132,7 +109,27 @@ void init_gui(int argc, char** argv) {
132109
int window_height = FPGA::image->h();;
133110
window = new Fl_Window(Fl::w() / 2 - window_width / 2, Fl::h() / 2 - window_height / 2, window_width, window_height, "Labarc FPGA Simulator");
134111

112+
// Instance FPGA
135113
fpga = new FPGA(0, 0);
114+
115+
// Instance upper board of FPGA
116+
board = new Board(fpga->x() + FPGA::image->w() / 2 - Board::image->w() / 2, fpga->y());
117+
118+
// Instance SWITCHES
119+
swis = new SWIs(board->x() + Board::image->w() / 2 - (8 * SWIs::swi_on->w() + 7 * (SWIS_OFFSET - SWIs::swi_on->w()) + SegmentsDisplay::base->w()) / 2,
120+
board->y() + Board::image->h() / 2 - SWIs::swi_on->h() / 2, SWIS_OFFSET);
121+
122+
// Instance 7-segment display
123+
segments = new SegmentsDisplay(board->x() + Board::image->w() / 2 - SegmentsDisplay::base->w() / 2, board->y() + Board::image->h() / 2 - SegmentsDisplay::base->h() / 2);
124+
125+
// Instance LED's
126+
int led_offset = 30;
127+
int led_x = fpga->x() + fpga->image->w() / 2 - (LEDs::led_on->w() * 8 + 7 * (led_offset - LEDs::led_on->w())) / 2;
128+
leds = new LEDs(led_x, fpga->y() + LEDS_VERTICAL_OFFSET, led_offset);
129+
130+
// Instance display
131+
disp = new display(fpga->x() + FPGA::image->w() / 2, fpga->y() + FPGA::image->h() / 2);
132+
disp->position(fpga->x() + FPGA::image->w() / 2 - disp->w() / 2, fpga->y() + FPGA::image->h() / 2);
136133

137134
int i=0;
138135
do { // search for an existin mono-space font

gui.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ class Board : public Fl_Widget {
7474
public:
7575
static Fl_PNG_Image *image;
7676

77-
SWIs *swis;
78-
SegmentsDisplay *segments;
79-
8077
virtual void draw();
8178
Board(int x, int y);
8279
};
@@ -85,16 +82,17 @@ class FPGA : public Fl_Widget {
8582
public:
8683
static Fl_PNG_Image *image;
8784

88-
display *disp;
89-
Board *board;
90-
LEDs *leds;
91-
9285
virtual void draw();
9386
FPGA(int x, int y);
9487
};
9588

9689
extern Fl_Window *window;
9790
extern FPGA *fpga;
91+
extern LEDs *leds;
92+
extern display *disp;
93+
extern Board *board;
94+
extern SWIs *swis;
95+
extern SegmentsDisplay *segments;
9896

9997
void init_gui(int, char**);
10098
void delete_gui();

sim_main.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
Vtop* top; // Verilated model
2121
Fl_Window *window; // Window representing FPGA board
2222
FPGA *fpga;
23+
LEDs *leds;
24+
display *disp;
25+
Board *board;
26+
SWIs *swis;
27+
SegmentsDisplay *segments;
2328

2429
vluint64_t main_time = 0; // Current Verilator simulation time
2530
// This is a 64-bit integer to reduce wrap over issues and
@@ -42,7 +47,13 @@ int SWI::handle(int event) {
4247

4348
top->eval();
4449

45-
fpga->damage(1);
50+
swis->redraw();
51+
52+
segments->redraw();
53+
54+
leds->redraw();
55+
56+
disp->redraw();
4657
}
4758
}
4859

@@ -126,9 +137,13 @@ void callback(void*) {
126137

127138
// Evaluate Verilated SystemVerilog model
128139
top->eval();
129-
130-
fpga->damage(1);
131-
140+
141+
segments->redraw();
142+
143+
leds->redraw();
144+
145+
disp->redraw();
146+
132147
Fl::repeat_timeout(0.25, callback); // retrigger timeout after 0.1 seconds
133148
}
134149

0 commit comments

Comments
 (0)