Skip to content

Commit aa9315c

Browse files
committed
fixed BrunoLevy#90 (ST_NICCC demo was too large to fit in BRAM)
1 parent 0bac913 commit aa9315c

File tree

10 files changed

+62
-16
lines changed

10 files changed

+62
-16
lines changed

Basic/FOMU/FOMU_VGA/vga.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ module vga (
2828
wire pixel_clk;
2929

3030
// Choose your video mode here:
31-
`define VGA_MODE_640x480
32-
//`define VGA_MODE_1024x768
31+
//`define VGA_MODE_640x480
32+
`define VGA_MODE_1024x768
3333
//`define VGA_MODE_1280x1024
3434

3535
`ifdef VGA_MODE_640x480

FemtoRV/FIRMWARE/ASM_EXAMPLES/mandelbrot_terminal.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ exit_Z:
8787

8888
li a0,13
8989
call putchar
90-
li a0,10
91-
call putchar
90+
# li a0,10
91+
# call putchar
9292

9393
add s1,s1,1
9494
add s3,s3,dy

FemtoRV/FIRMWARE/EXAMPLES/hello_LED.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
int main() {
77
MAX7219_tty_init(); // redirect printf() to led matrix scroller
88
for(;;) {
9-
printf("Hello, RISC-V world \001 \002 \001 \002 ");
10-
// printf("Hello, TelecomNancy ! \001 \002 Best school ! \001 \002 ");
9+
// printf("Hello, RISC-V world \001 \002 \001 \002 ");
10+
// printf("Hello, TelecomNancy ! \001 \002 Best school ! \001 \002 ");
1111
// printf("Hello FemtoRV friend !!! \001 \002 \001 \002 ");
1212
// printf("Hello, Hackaday \001 \002 Greetings from FemtoRV !!! ");
13+
// printf("Hello, RISC-V world \001 \002 \001 \002 ");
14+
printf("Hello, caf\202 LoOPS ! \001 \002 \001 \002 ");
1315
}
1416
return 0;
1517
}

FemtoRV/FIRMWARE/EXAMPLES/mandel_float.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ void mandel() {
3232
for(int Y=0; Y<H; ++Y) {
3333
float Cr = xmin;
3434
for(int X=0; X<W; ++X) {
35+
printf("%d %d\n",X,Y);
3536
float Zr = Cr;
3637
float Zi = Ci;
3738
int iter = 15;
@@ -54,6 +55,7 @@ void mandel() {
5455
}
5556

5657
int main() {
58+
printf("Mandel float");
5759
for(;;) {
5860
GL_init(GL_MODE_CHOOSE);
5961
GL_tty_init(FGA_mode);

FemtoRV/RTL/CONFIGS/icestick_config.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
`define NRV_IO_LEDS // Mapped IO, LEDs D1,D2,D3,D4 (D5 is used to display errors)
66
`define NRV_IO_IRDA // In IO_LEDS, support for the IRDA on the IceStick (WIP)
77
`define NRV_IO_UART // Mapped IO, virtual UART (USB)
8-
//`define NRV_IO_SSD1351 // Mapped IO, 128x128x64K OLED screen
8+
`define NRV_IO_SSD1351 // Mapped IO, 128x128x64K OLED screen
99
`define NRV_IO_MAX7219 // Mapped IO, 8x8 led matrix
1010
`define NRV_MAPPED_SPI_FLASH // SPI flash mapped in address space. Can be used to run code from SPI flash.
1111

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
PROJECTNAME=SOC
2+
BOARD=icestick
3+
BOARD_FREQ=12
4+
CPU_FREQ=45
5+
FPGA_VARIANT=hx1k
6+
FPGA_PACKAGE=tq144
7+
VERILOGS=$1
8+
yosys -q -DICE_STICK -DBOARD_FREQ=$BOARD_FREQ -DCPU_FREQ=$CPU_FREQ -p "synth_ice40 -relut -top $PROJECTNAME -json $PROJECTNAME.json" $VERILOGS || exit
9+
nextpnr-ice40 --gui --force --timing-allow-fail --json $PROJECTNAME.json --pcf BOARDS/$BOARD.pcf --asc $PROJECTNAME.asc --freq $CPU_FREQ --$FPGA_VARIANT --package $FPGA_PACKAGE --pcf-allow-unconstrained --opt-timing || exit

FemtoRV/TUTORIALS/FROM_BLINKER_TO_RISCV/FIRMWARE/ST_NICCC.c

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,27 @@
2020
#ifdef __linux__
2121
#include <stdlib.h>
2222
#include <unistd.h>
23+
#else
24+
#include "io.h"
2325
#endif
2426

25-
27+
// when compiling for SPI flash, uncomment to fit some routines in fast BRAM
28+
// (but it does not change much, the bottleneck is ANSI RGB encoding and uart.
2629
//#define RV32_FASTCODE __attribute((section(".fastcode")))
2730
#define RV32_FASTCODE
2831

32+
// when compiling for SPI flash, uncomment to enable wireframe mode (but it is ugly
33+
// and it will not fit in BRAM !)
34+
// #define WITH_WIREFRAME
35+
36+
#ifdef WITH_WIREFRAME
2937
int wireframe = 0;
38+
#endif
3039

3140
#define MIN(x,y) ((x) < (y) ? (x) : (y))
3241
#define MAX(x,y) ((x) > (y) ? (x) : (y))
3342

43+
3444
/**********************************************************************************/
3545
/* Graphics routines */
3646
/**********************************************************************************/
@@ -46,13 +56,11 @@ static inline uint8_t map_y(uint8_t y) {
4656
return y >> 2;
4757
}
4858

49-
5059
void GL_clear() {
5160
printf("\033[48;5;16m" // set background color black
5261
"\033[2J"); // clear screen
5362
}
5463

55-
5664
/*
5765
* Set background color using 6x6x6 colorcube codes
5866
* see https://stackoverflow.com/questions/4842424/list-of-ansi-color-escape-sequences
@@ -69,6 +77,7 @@ static inline void GL_setpixel(int x, int y) {
6977
printf("\033[%d;%dH ",y,x); // Goto_XY(x1,y) and print space
7078
}
7179

80+
#ifdef WITH_WIREFRAME
7281
void GL_line(int x1, int y1, int x2, int y2) RV32_FASTCODE;
7382
void GL_line(int x1, int y1, int x2, int y2) {
7483
int x,y,dx,dy,sy,tmp;
@@ -83,7 +92,7 @@ void GL_line(int x1, int y1, int x2, int y2) {
8392
y1 = tmp;
8493
}
8594

86-
/* Bresenham line drawing. */
95+
// Bresenham line drawing.
8796
dy = y2 - y1;
8897
sy = 1;
8998
if(dy < 0) {
@@ -127,6 +136,7 @@ void GL_line(int x1, int y1, int x2, int y2) {
127136
}
128137
}
129138
}
139+
#endif
130140

131141
void GL_fillpoly(int nb_pts, int* points) RV32_FASTCODE;
132142
void GL_fillpoly(int nb_pts, int* points) {
@@ -163,12 +173,14 @@ void GL_fillpoly(int nb_pts, int* points) {
163173
int x2 = points[2*i2];
164174
int y2 = points[2*i2+1];
165175

176+
#ifdef WITH_WIREFRAME
166177
if(wireframe) {
167178
if((clockwise > 0) ^ (y2 > y1)) {
168179
GL_line(x1,y1,x2,y2);
169180
}
170181
continue;
171182
}
183+
#endif
172184

173185
char* x_buffer = ((clockwise > 0) ^ (y2 > y1)) ? x_left : x_right;
174186
int dx = x2 - x1;
@@ -208,7 +220,10 @@ void GL_fillpoly(int nb_pts, int* points) {
208220
}
209221
}
210222

211-
if(!wireframe) {
223+
#ifdef WITH_WIREFRAME
224+
if(!wireframe)
225+
#endif
226+
{
212227
for(int y = miny; y <= maxy; ++y) {
213228
int x1 = x_left[y];
214229
int x2 = x_right[y];
@@ -431,18 +446,35 @@ int read_frame() {
431446

432447
int main() {
433448
// printf("\x1B[?25l"); // hide cursor
434-
wireframe = 0;
449+
450+
#ifndef __linux__
451+
IO_OUT(IO_LEDS,15);
452+
#endif
453+
printf("starting\n");
454+
455+
#ifdef WITH_WIREFRAME
456+
wireframe = 0;
457+
#endif
458+
int frame = 0;
435459
GL_clear();
436460
for(;;) {
437461
spi_reset();
462+
frame = 0;
438463
while(read_frame()) {
464+
#ifdef WITH_WIREFRAME
439465
if(wireframe) {
440466
GL_clear();
441467
}
468+
#endif
442469
#ifdef __linux__
443470
usleep(20000);
444-
#endif
471+
#else
472+
IO_OUT(IO_LEDS,frame);
473+
#endif
474+
++frame;
445475
}
476+
#ifdef WITH_WIREFRAME
446477
wireframe = !wireframe;
478+
#endif
447479
}
448480
}

FemtoRV/TUTORIALS/FROM_BLINKER_TO_RISCV/emitter_uart.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module corescore_emitter_uart
22
#(
33
parameter clk_freq_hz = 0,
4-
parameter baud_rate = 57600)
4+
parameter baud_rate = 1000000)
55
(
66
input wire i_clk,
77
input wire i_rst,

FemtoRV/TUTORIALS/FROM_BLINKER_TO_RISCV/pipelineZ.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
`define CONFIG_RV32M // RV32M instruction set (MUL,DIV,REM)
1414

15-
`define CONFIG_DEBUG // debug mode, displays execution
15+
//`define CONFIG_DEBUG // debug mode, displays execution
1616
// See "debugger" section in source
1717
// to define breakpoints
1818

FemtoRV/TUTORIALS/FROM_BLINKER_TO_RISCV/terminal.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
DEVICE=/dev/ttyUSB1 # replace by the terminal used by your device
22
BAUDS=1000000
33

4+
45
# MINITERM exit: <ctrl> ] package: sudo apt-get install python3-serial
56
#miniterm --dtr=0 $DEVICE $BAUDS
67

0 commit comments

Comments
 (0)