verilog: 32-bit (FFbbggrr) rgb output, testing w/ Silice

This commit is contained in:
Steven Hugg 2020-12-16 10:48:33 -06:00
parent 1d952ad63b
commit b3b93e150d
20 changed files with 8204 additions and 12 deletions

View File

@ -195,6 +195,7 @@ TODO:
- don't include start/end line on platforms w/o raster timing
- BIOS symbols
- show current tool for file
- download non-text incbin source file
Probing
- probe log doesn't start @ reset

View File

@ -0,0 +1,102 @@
// -------------------------
$include('ntsc.ice')
// -------------------------
algorithm frame_display(
input uint10 pix_x,
input uint10 pix_y,
input uint1 pix_active,
input uint1 pix_vblank,
output! uint$color_depth$ pix_r,
output! uint$color_depth$ pix_g,
output! uint$color_depth$ pix_b
) <autorun> {
uint7 wave[64] = {
$$for i=0,63 do
$math.floor(127.0 * (0.5+0.5*math.cos(math.pi + 2*math.pi*i/63)))$,
$$end
};
uint$color_depth$ v = 0;
uint6 frame = 0;
int9 pos[4] = {0,0,0,0};
pix_r := 0; pix_g := 0; pix_b := 0;
// ---------- show time!
while (1) {
// display frame
while (pix_vblank == 0) {
if (pix_active) {
4x {
if (pix_y + 20 > pos[__id] && pix_y < pos[__id] + 20) {
v = ((wave[pix_y-pos[__id] + 32]>>1) * (__id+5)) >> 3;
pix_r = v*4;
pix_g = v*3;
pix_b = v*2;
}
}
}
}
// prepare next
frame = frame + 1;
4x {
pos[__id] = $240 - 127$ + (wave[(frame + (__id << 3)) & 63] << 1);
}
// wait for sync
while (pix_vblank == 1) {}
}
}
// -------------------------
algorithm main(
output! uint$color_depth$ video_r,
output! uint$color_depth$ video_g,
output! uint$color_depth$ video_b,
output! uint1 video_hs,
output! uint1 video_vs
)
<@clock,!reset>
{
uint1 active = 0;
uint1 vblank = 0;
uint10 pix_x = 0;
uint10 pix_y = 0;
ntsc ntsc_driver (
ntsc_hs :> video_hs,
ntsc_vs :> video_vs,
active :> active,
vblank :> vblank,
ntsc_x :> pix_x,
ntsc_y :> pix_y
);
frame_display display (
pix_x <: pix_x,
pix_y <: pix_y,
pix_active <: active,
pix_vblank <: vblank,
pix_r :> video_r,
pix_g :> video_g,
pix_b :> video_b
);
uint8 frame = 0;
// forever
while (1) {
while (vblank == 0) { }
frame = frame + 1;
}
}

View File

@ -0,0 +1,259 @@
brom uint8 font_cp437_8x8[2048] = {
8h00,8h00,8h00,8h00,8h00,8h00,8h00,8h00, //0
8h7e,8h81,8ha5,8h81,8hbd,8h99,8h81,8h7e, //1
8h7e,8hff,8hdb,8hff,8hc3,8he7,8hff,8h7e, //2
8h6c,8hfe,8hfe,8hfe,8h7c,8h38,8h10,8h00, //3
8h10,8h38,8h7c,8hfe,8h7c,8h38,8h10,8h00, //4
8h38,8h7c,8h38,8hfe,8hfe,8hd6,8h10,8h38, //5
8h10,8h10,8h38,8h7c,8hfe,8h7c,8h10,8h38, //6
8h00,8h00,8h18,8h3c,8h3c,8h18,8h00,8h00, //7
8hff,8hff,8he7,8hc3,8hc3,8he7,8hff,8hff, //8
8h00,8h3c,8h66,8h42,8h42,8h66,8h3c,8h00, //9
8hff,8hc3,8h99,8hbd,8hbd,8h99,8hc3,8hff, //10
8h0f,8h07,8h0f,8h7d,8hcc,8hcc,8hcc,8h78, //11
8h3c,8h66,8h66,8h66,8h3c,8h18,8h7e,8h18, //12
8h3f,8h33,8h3f,8h30,8h30,8h70,8hf0,8he0, //13
8h7f,8h63,8h7f,8h63,8h63,8h67,8he6,8hc0, //14
8h99,8h5a,8h3c,8he7,8he7,8h3c,8h5a,8h99, //15
8h80,8he0,8hf8,8hfe,8hf8,8he0,8h80,8h00, //16
8h02,8h0e,8h3e,8hfe,8h3e,8h0e,8h02,8h00, //17
8h18,8h3c,8h7e,8h18,8h18,8h7e,8h3c,8h18, //18
8h66,8h66,8h66,8h66,8h66,8h00,8h66,8h00, //19
8h7f,8hdb,8hdb,8h7b,8h1b,8h1b,8h1b,8h00, //20
8h7e,8hc3,8h78,8hcc,8hcc,8h78,8h8c,8hf8, //21
8h00,8h00,8h00,8h00,8h7e,8h7e,8h7e,8h00, //22
8h18,8h3c,8h7e,8h18,8h7e,8h3c,8h18,8hff, //23
8h18,8h3c,8h7e,8h18,8h18,8h18,8h18,8h00, //24
8h18,8h18,8h18,8h18,8h7e,8h3c,8h18,8h00, //25
8h00,8h18,8h0c,8hfe,8h0c,8h18,8h00,8h00, //26
8h00,8h30,8h60,8hfe,8h60,8h30,8h00,8h00, //27
8h00,8h00,8hc0,8hc0,8hc0,8hfe,8h00,8h00, //28
8h00,8h24,8h66,8hff,8h66,8h24,8h00,8h00, //29
8h00,8h18,8h3c,8h7e,8hff,8hff,8h00,8h00, //30
8h00,8hff,8hff,8h7e,8h3c,8h18,8h00,8h00, //31
8h00,8h00,8h00,8h00,8h00,8h00,8h00,8h00, //32
8h30,8h78,8h78,8h30,8h30,8h00,8h30,8h00, //33
8h6c,8h6c,8h6c,8h00,8h00,8h00,8h00,8h00, //34
8h6c,8h6c,8hfe,8h6c,8hfe,8h6c,8h6c,8h00, //35
8h30,8h7c,8hc0,8h78,8h0c,8hf8,8h30,8h00, //36
8h00,8hc6,8hcc,8h18,8h30,8h66,8hc6,8h00, //37
8h38,8h6c,8h38,8h76,8hdc,8hcc,8h76,8h00, //38
8h60,8h60,8hc0,8h00,8h00,8h00,8h00,8h00, //39
8h18,8h30,8h60,8h60,8h60,8h30,8h18,8h00, //40
8h60,8h30,8h18,8h18,8h18,8h30,8h60,8h00, //41
8h00,8h66,8h3c,8hff,8h3c,8h66,8h00,8h00, //42
8h00,8h30,8h30,8hfc,8h30,8h30,8h00,8h00, //43
8h00,8h00,8h00,8h00,8h00,8h70,8h30,8h60, //44
8h00,8h00,8h00,8hfc,8h00,8h00,8h00,8h00, //45
8h00,8h00,8h00,8h00,8h00,8h30,8h30,8h00, //46
8h06,8h0c,8h18,8h30,8h60,8hc0,8h80,8h00, //47
8h78,8hcc,8hdc,8hfc,8hec,8hcc,8h78,8h00, //48
8h30,8hf0,8h30,8h30,8h30,8h30,8hfc,8h00, //49
8h78,8hcc,8h0c,8h38,8h60,8hcc,8hfc,8h00, //50
8h78,8hcc,8h0c,8h38,8h0c,8hcc,8h78,8h00, //51
8h1c,8h3c,8h6c,8hcc,8hfe,8h0c,8h0c,8h00, //52
8hfc,8hc0,8hf8,8h0c,8h0c,8hcc,8h78,8h00, //53
8h38,8h60,8hc0,8hf8,8hcc,8hcc,8h78,8h00, //54
8hfc,8hcc,8h0c,8h18,8h30,8h60,8h60,8h00, //55
8h78,8hcc,8hcc,8h78,8hcc,8hcc,8h78,8h00, //56
8h78,8hcc,8hcc,8h7c,8h0c,8h18,8h70,8h00, //57
8h00,8h00,8h30,8h30,8h00,8h30,8h30,8h00, //58
8h00,8h00,8h30,8h30,8h00,8h70,8h30,8h60, //59
8h18,8h30,8h60,8hc0,8h60,8h30,8h18,8h00, //60
8h00,8h00,8hfc,8h00,8hfc,8h00,8h00,8h00, //61
8h60,8h30,8h18,8h0c,8h18,8h30,8h60,8h00, //62
8h78,8hcc,8h0c,8h18,8h30,8h00,8h30,8h00, //63
8h7c,8hc6,8hde,8hde,8hde,8hc0,8h78,8h00, //64
8h30,8h78,8hcc,8hcc,8hfc,8hcc,8hcc,8h00, //65
8hfc,8h66,8h66,8h7c,8h66,8h66,8hfc,8h00, //66
8h3c,8h66,8hc0,8hc0,8hc0,8h66,8h3c,8h00, //67
8hfc,8h6c,8h66,8h66,8h66,8h6c,8hfc,8h00, //68
8hfe,8h62,8h68,8h78,8h68,8h62,8hfe,8h00, //69
8hfe,8h62,8h68,8h78,8h68,8h60,8hf0,8h00, //70
8h3c,8h66,8hc0,8hc0,8hce,8h66,8h3e,8h00, //71
8hcc,8hcc,8hcc,8hfc,8hcc,8hcc,8hcc,8h00, //72
8h78,8h30,8h30,8h30,8h30,8h30,8h78,8h00, //73
8h1e,8h0c,8h0c,8h0c,8hcc,8hcc,8h78,8h00, //74
8he6,8h66,8h6c,8h78,8h6c,8h66,8he6,8h00, //75
8hf0,8h60,8h60,8h60,8h62,8h66,8hfe,8h00, //76
8hc6,8hee,8hfe,8hd6,8hc6,8hc6,8hc6,8h00, //77
8hc6,8he6,8hf6,8hde,8hce,8hc6,8hc6,8h00, //78
8h38,8h6c,8hc6,8hc6,8hc6,8h6c,8h38,8h00, //79
8hfc,8h66,8h66,8h7c,8h60,8h60,8hf0,8h00, //80
8h78,8hcc,8hcc,8hcc,8hdc,8h78,8h1c,8h00, //81
8hfc,8h66,8h66,8h7c,8h78,8h6c,8he6,8h00, //82
8h78,8hcc,8he0,8h38,8h1c,8hcc,8h78,8h00, //83
8hfc,8hb4,8h30,8h30,8h30,8h30,8h78,8h00, //84
8hcc,8hcc,8hcc,8hcc,8hcc,8hcc,8hfc,8h00, //85
8hcc,8hcc,8hcc,8hcc,8hcc,8h78,8h30,8h00, //86
8hc6,8hc6,8hc6,8hd6,8hfe,8hee,8hc6,8h00, //87
8hc6,8hc6,8h6c,8h38,8h6c,8hc6,8hc6,8h00, //88
8hcc,8hcc,8hcc,8h78,8h30,8h30,8h78,8h00, //89
8hfe,8hcc,8h98,8h30,8h62,8hc6,8hfe,8h00, //90
8h78,8h60,8h60,8h60,8h60,8h60,8h78,8h00, //91
8hc0,8h60,8h30,8h18,8h0c,8h06,8h02,8h00, //92
8h78,8h18,8h18,8h18,8h18,8h18,8h78,8h00, //93
8h10,8h38,8h6c,8hc6,8h00,8h00,8h00,8h00, //94
8h00,8h00,8h00,8h00,8h00,8h00,8h00,8hff, //95
8h30,8h30,8h18,8h00,8h00,8h00,8h00,8h00, //96
8h00,8h00,8h78,8h0c,8h7c,8hcc,8h76,8h00, //97
8he0,8h60,8h7c,8h66,8h66,8h66,8hbc,8h00, //98
8h00,8h00,8h78,8hcc,8hc0,8hcc,8h78,8h00, //99
8h1c,8h0c,8h0c,8h7c,8hcc,8hcc,8h76,8h00, //100
8h00,8h00,8h78,8hcc,8hfc,8hc0,8h78,8h00, //101
8h38,8h6c,8h60,8hf0,8h60,8h60,8hf0,8h00, //102
8h00,8h00,8h76,8hcc,8hcc,8h7c,8h0c,8hf8, //103
8he0,8h60,8h6c,8h76,8h66,8h66,8he6,8h00, //104
8h30,8h00,8h70,8h30,8h30,8h30,8h78,8h00, //105
8h18,8h00,8h78,8h18,8h18,8h18,8hd8,8h70, //106
8he0,8h60,8h66,8h6c,8h78,8h6c,8he6,8h00, //107
8h70,8h30,8h30,8h30,8h30,8h30,8h78,8h00, //108
8h00,8h00,8hec,8hfe,8hd6,8hc6,8hc6,8h00, //109
8h00,8h00,8hf8,8hcc,8hcc,8hcc,8hcc,8h00, //110
8h00,8h00,8h78,8hcc,8hcc,8hcc,8h78,8h00, //111
8h00,8h00,8hdc,8h66,8h66,8h7c,8h60,8hf0, //112
8h00,8h00,8h76,8hcc,8hcc,8h7c,8h0c,8h1e, //113
8h00,8h00,8hd8,8h6c,8h6c,8h60,8hf0,8h00, //114
8h00,8h00,8h7c,8hc0,8h78,8h0c,8hf8,8h00, //115
8h10,8h30,8h7c,8h30,8h30,8h34,8h18,8h00, //116
8h00,8h00,8hcc,8hcc,8hcc,8hcc,8h76,8h00, //117
8h00,8h00,8hcc,8hcc,8hcc,8h78,8h30,8h00, //118
8h00,8h00,8hc6,8hc6,8hd6,8hfe,8h6c,8h00, //119
8h00,8h00,8hc6,8h6c,8h38,8h6c,8hc6,8h00, //120
8h00,8h00,8hcc,8hcc,8hcc,8h7c,8h0c,8hf8, //121
8h00,8h00,8hfc,8h98,8h30,8h64,8hfc,8h00, //122
8h1c,8h30,8h30,8he0,8h30,8h30,8h1c,8h00, //123
8h18,8h18,8h18,8h00,8h18,8h18,8h18,8h00, //124
8he0,8h30,8h30,8h1c,8h30,8h30,8he0,8h00, //125
8h76,8hdc,8h00,8h00,8h00,8h00,8h00,8h00, //126
8h10,8h38,8h6c,8hc6,8hc6,8hc6,8hfe,8h00, //127
8h78,8hcc,8hc0,8hcc,8h78,8h18,8h0c,8h78, //128
8h00,8hcc,8h00,8hcc,8hcc,8hcc,8h7e,8h00, //129
8h1c,8h00,8h78,8hcc,8hfc,8hc0,8h78,8h00, //130
8h7e,8hc3,8h3c,8h06,8h3e,8h66,8h3f,8h00, //131
8hcc,8h00,8h78,8h0c,8h7c,8hcc,8h7e,8h00, //132
8he0,8h00,8h78,8h0c,8h7c,8hcc,8h7e,8h00, //133
8h30,8h30,8h78,8h0c,8h7c,8hcc,8h7e,8h00, //134
8h00,8h00,8h7c,8hc0,8hc0,8h7c,8h06,8h3c, //135
8h7e,8hc3,8h3c,8h66,8h7e,8h60,8h3c,8h00, //136
8hcc,8h00,8h78,8hcc,8hfc,8hc0,8h78,8h00, //137
8he0,8h00,8h78,8hcc,8hfc,8hc0,8h78,8h00, //138
8hcc,8h00,8h70,8h30,8h30,8h30,8h78,8h00, //139
8h7c,8hc6,8h38,8h18,8h18,8h18,8h3c,8h00, //140
8he0,8h00,8h70,8h30,8h30,8h30,8h78,8h00, //141
8hcc,8h30,8h78,8hcc,8hcc,8hfc,8hcc,8h00, //142
8h30,8h30,8h00,8h78,8hcc,8hfc,8hcc,8h00, //143
8h1c,8h00,8hfc,8h60,8h78,8h60,8hfc,8h00, //144
8h00,8h00,8h7f,8h0c,8h7f,8hcc,8h7f,8h00, //145
8h3e,8h6c,8hcc,8hfe,8hcc,8hcc,8hce,8h00, //146
8h78,8hcc,8h00,8h78,8hcc,8hcc,8h78,8h00, //147
8h00,8hcc,8h00,8h78,8hcc,8hcc,8h78,8h00, //148
8h00,8he0,8h00,8h78,8hcc,8hcc,8h78,8h00, //149
8h78,8hcc,8h00,8hcc,8hcc,8hcc,8h7e,8h00, //150
8h00,8he0,8h00,8hcc,8hcc,8hcc,8h7e,8h00, //151
8h00,8hcc,8h00,8hcc,8hcc,8hfc,8h0c,8hf8, //152
8hc6,8h38,8h7c,8hc6,8hc6,8h7c,8h38,8h00, //153
8hcc,8h00,8hcc,8hcc,8hcc,8hcc,8h78,8h00, //154
8h18,8h18,8h7e,8hc0,8hc0,8h7e,8h18,8h18, //155
8h38,8h6c,8h64,8hf0,8h60,8he6,8hfc,8h00, //156
8hcc,8hcc,8h78,8hfc,8h30,8hfc,8h30,8h00, //157
8hf0,8hd8,8hd8,8hf4,8hcc,8hde,8hcc,8h0e, //158
8h0e,8h1b,8h18,8h7e,8h18,8h18,8hd8,8h70, //159
8h1c,8h00,8h78,8h0c,8h7c,8hcc,8h7e,8h00, //160
8h38,8h00,8h70,8h30,8h30,8h30,8h78,8h00, //161
8h00,8h1c,8h00,8h78,8hcc,8hcc,8h78,8h00, //162
8h00,8h1c,8h00,8hcc,8hcc,8hcc,8h7e,8h00, //163
8h00,8hf8,8h00,8hf8,8hcc,8hcc,8hcc,8h00, //164
8hfc,8h00,8hcc,8hec,8hfc,8hdc,8hcc,8h00, //165
8h3c,8h6c,8h6c,8h3e,8h00,8h7e,8h00,8h00, //166
8h3c,8h66,8h66,8h3c,8h00,8h7e,8h00,8h00, //167
8h30,8h00,8h30,8h60,8hc0,8hcc,8h78,8h00, //168
8h00,8h00,8h00,8hfc,8hc0,8hc0,8h00,8h00, //169
8h00,8h00,8h00,8hfc,8h0c,8h0c,8h00,8h00, //170
8hc6,8hcc,8hd8,8h3e,8h63,8hce,8h98,8h1f, //171
8hc6,8hcc,8hd8,8hf3,8h67,8hcf,8h9f,8h03, //172
8h00,8h18,8h00,8h18,8h18,8h3c,8h3c,8h18, //173
8h00,8h33,8h66,8hcc,8h66,8h33,8h00,8h00, //174
8h00,8hcc,8h66,8h33,8h66,8hcc,8h00,8h00, //175
8h22,8h88,8h22,8h88,8h22,8h88,8h22,8h88, //176
8h55,8haa,8h55,8haa,8h55,8haa,8h55,8haa, //177
8hdd,8h77,8hdd,8h77,8hdd,8h77,8hdd,8h77, //178
8h18,8h18,8h18,8h18,8h18,8h18,8h18,8h18, //179
8h18,8h18,8h18,8h18,8hf8,8h18,8h18,8h18, //180
8h18,8h18,8hf8,8h18,8hf8,8h18,8h18,8h18, //181
8h36,8h36,8h36,8h36,8hf6,8h36,8h36,8h36, //182
8h00,8h00,8h00,8h00,8hfe,8h36,8h36,8h36, //183
8h00,8h00,8hf8,8h18,8hf8,8h18,8h18,8h18, //184
8h36,8h36,8hf6,8h06,8hf6,8h36,8h36,8h36, //185
8h36,8h36,8h36,8h36,8h36,8h36,8h36,8h36, //186
8h00,8h00,8hfe,8h06,8hf6,8h36,8h36,8h36, //187
8h36,8h36,8hf6,8h06,8hfe,8h00,8h00,8h00, //188
8h36,8h36,8h36,8h36,8hfe,8h00,8h00,8h00, //189
8h18,8h18,8hf8,8h18,8hf8,8h00,8h00,8h00, //190
8h00,8h00,8h00,8h00,8hf8,8h18,8h18,8h18, //191
8h18,8h18,8h18,8h18,8h1f,8h00,8h00,8h00, //192
8h18,8h18,8h18,8h18,8hff,8h00,8h00,8h00, //193
8h00,8h00,8h00,8h00,8hff,8h18,8h18,8h18, //194
8h18,8h18,8h18,8h18,8h1f,8h18,8h18,8h18, //195
8h00,8h00,8h00,8h00,8hff,8h00,8h00,8h00, //196
8h18,8h18,8h18,8h18,8hff,8h18,8h18,8h18, //197
8h18,8h18,8h1f,8h18,8h1f,8h18,8h18,8h18, //198
8h36,8h36,8h36,8h36,8h37,8h36,8h36,8h36, //199
8h36,8h36,8h37,8h30,8h3f,8h00,8h00,8h00, //200
8h00,8h00,8h3f,8h30,8h37,8h36,8h36,8h36, //201
8h36,8h36,8hf7,8h00,8hff,8h00,8h00,8h00, //202
8h00,8h00,8hff,8h00,8hf7,8h36,8h36,8h36, //203
8h36,8h36,8h37,8h30,8h37,8h36,8h36,8h36, //204
8h00,8h00,8hff,8h00,8hff,8h00,8h00,8h00, //205
8h36,8h36,8hf7,8h00,8hf7,8h36,8h36,8h36, //206
8h18,8h18,8hff,8h00,8hff,8h00,8h00,8h00, //207
8h36,8h36,8h36,8h36,8hff,8h00,8h00,8h00, //208
8h00,8h00,8hff,8h00,8hff,8h18,8h18,8h18, //209
8h00,8h00,8h00,8h00,8hff,8h36,8h36,8h36, //210
8h36,8h36,8h36,8h36,8h3f,8h00,8h00,8h00, //211
8h18,8h18,8h1f,8h18,8h1f,8h00,8h00,8h00, //212
8h00,8h00,8h1f,8h18,8h1f,8h18,8h18,8h18, //213
8h00,8h00,8h00,8h00,8h3f,8h36,8h36,8h36, //214
8h36,8h36,8h36,8h36,8hf7,8h36,8h36,8h36, //215
8h18,8h18,8hff,8h00,8hff,8h18,8h18,8h18, //216
8h18,8h18,8h18,8h18,8hf8,8h00,8h00,8h00, //217
8h00,8h00,8h00,8h00,8h1f,8h18,8h18,8h18, //218
8hff,8hff,8hff,8hff,8hff,8hff,8hff,8hff, //219
8h00,8h00,8h00,8h00,8hff,8hff,8hff,8hff, //220
8hf0,8hf0,8hf0,8hf0,8hf0,8hf0,8hf0,8hf0, //221
8h0f,8h0f,8h0f,8h0f,8h0f,8h0f,8h0f,8h0f, //222
8hff,8hff,8hff,8hff,8h00,8h00,8h00,8h00, //223
8h00,8h00,8h76,8hdc,8hc8,8hdc,8h76,8h00, //224
8h00,8h78,8hcc,8hf8,8hcc,8hf8,8hc0,8hc0, //225
8h00,8hfe,8hc6,8hc0,8hc0,8hc0,8hc0,8h00, //226
8h00,8hfe,8h6c,8h6c,8h6c,8h6c,8h6c,8h00, //227
8hfe,8h66,8h30,8h18,8h30,8h66,8hfe,8h00, //228
8h00,8h00,8h7e,8hcc,8hcc,8hcc,8h78,8h00, //229
8h00,8h66,8h66,8h66,8h66,8h7c,8h60,8hc0, //230
8h00,8h76,8hdc,8h18,8h18,8h18,8h18,8h00, //231
8hfc,8h30,8h78,8hcc,8hcc,8h78,8h30,8hfc, //232
8h38,8h6c,8hc6,8hfe,8hc6,8h6c,8h38,8h00, //233
8h38,8h6c,8hc6,8hc6,8h6c,8h6c,8hee,8h00, //234
8h1c,8h30,8h18,8h7c,8hcc,8hcc,8h78,8h00, //235
8h00,8h00,8h7e,8hdb,8hdb,8h7e,8h00,8h00, //236
8h06,8h0c,8h7e,8hdb,8hdb,8h7e,8h60,8hc0, //237
8h3c,8h60,8hc0,8hfc,8hc0,8h60,8h3c,8h00, //238
8h78,8hcc,8hcc,8hcc,8hcc,8hcc,8hcc,8h00, //239
8h00,8hfc,8h00,8hfc,8h00,8hfc,8h00,8h00, //240
8h30,8h30,8hfc,8h30,8h30,8h00,8hfc,8h00, //241
8h60,8h30,8h18,8h30,8h60,8h00,8hfc,8h00, //242
8h18,8h30,8h60,8h30,8h18,8h00,8hfc,8h00, //243
8h0e,8h1b,8h1b,8h18,8h18,8h18,8h18,8h18, //244
8h18,8h18,8h18,8h18,8h18,8hd8,8hd8,8h70, //245
8h30,8h30,8h00,8hfc,8h00,8h30,8h30,8h00, //246
8h00,8h72,8h9c,8h00,8h72,8h9c,8h00,8h00, //247
8h38,8h6c,8h6c,8h38,8h00,8h00,8h00,8h00, //248
8h00,8h00,8h00,8h18,8h18,8h00,8h00,8h00, //249
8h00,8h00,8h00,8h00,8h18,8h00,8h00,8h00, //250
8h0f,8h0c,8h0c,8h0c,8hec,8h6c,8h3c,8h1c, //251
8h78,8h6c,8h6c,8h6c,8h6c,8h00,8h00,8h00, //252
8h78,8h0c,8h38,8h60,8h7c,8h00,8h00,8h00, //253
8h00,8h00,8h3c,8h3c,8h3c,8h3c,8h00,8h00, //254
8h00,8h00,8h00,8h00,8h00,8h00,8h00,8h00 //255
};

125
presets/verilog/life.ice Normal file
View File

@ -0,0 +1,125 @@
$include('ntsc.ice')
// -------------------------
algorithm frame_display(
input uint10 pix_x,
input uint10 pix_y,
input uint1 pix_active,
input uint1 pix_vblank,
output! uint$color_depth$ pix_r,
output! uint$color_depth$ pix_g,
output! uint$color_depth$ pix_b
) <autorun> {
$include('font_cp437_8x8.ice')
// 256x256 cells (240 lines used)
dualport_bram uint1 cells[65536] = uninitialized;
// previous 2 rows
dualport_bram uint1 row1[256] = uninitialized;
dualport_bram uint1 row2[256] = uninitialized;
// 3x3 pixel mask around x/y
uint9 neigh = 0;
// offsets to X and Y coordinate
uint8 xx := pix_x[0,8];
uint8 yy := pix_y[0,8];
uint8 xxm3 := xx - 3;
uint8 xxm1 := xx - 1;
uint8 yym1 := yy - 1;
// count # of live neigbors (up to 8)
uint3 ncount ::=
neigh[0,1] + neigh[1,1] + neigh[2,1]
+ neigh[3,1] + neigh[5,1]
+ neigh[6,1] + neigh[7,1] + neigh[8,1];
// pixel is set if:
// * 3 live neighbors
// * 2 live neigbors and was already alive
uint1 alive ::= (ncount == 3) || (ncount == 2 && neigh[4,1]);
// by default r,g,b are set to zero
pix_r := 0;
pix_g := 0;
pix_b := 0;
// set dual-port block RAM bus addresses (continuously)
row1.addr0 := xx;
row2.addr0 := xx;
cells.addr0 := {yy, xx};
row1.addr1 := xxm1;
row2.addr1 := xxm1;
cells.addr1 := {yym1, xxm3};
row1.wenable1 := 1;
row2.wenable1 := 1;
cells.wenable1 = 1;
// ---------- show time!
while (1) {
// display frame
while (pix_vblank == 0) {
if (pix_active) {
// shift neighbor cells to the left by 1 pixel
// while adding right pix from row1/row2/cells array
neigh = {
neigh[6,2], row1.rdata0,
neigh[3,2], row2.rdata0,
neigh[0,2], cells.rdata0
};
// copy alive -> cells -> row2 -> row1
row1.wdata1 = row2.rdata0;
row2.wdata1 = cells.rdata0;
cells.wdata1 = alive;
// set RGB color based on surroundings
pix_r = ncount * 31;
pix_g = neigh[4,1] * 255;
pix_b = alive * 255;
}
}
}
}
// -------------------------
algorithm main(
output! uint$color_depth$ video_r,
output! uint$color_depth$ video_g,
output! uint$color_depth$ video_b,
output! uint1 video_hs,
output! uint1 video_vs
)
<@clock,!reset>
{
uint1 active = 0;
uint1 vblank = 0;
uint10 pix_x = 0;
uint10 pix_y = 0;
ntsc ntsc_driver (
ntsc_hs :> video_hs,
ntsc_vs :> video_vs,
active :> active,
vblank :> vblank,
ntsc_x :> pix_x,
ntsc_y :> pix_y
);
frame_display display (
pix_x <: pix_x,
pix_y <: pix_y,
pix_active <: active,
pix_vblank <: vblank,
pix_r :> video_r,
pix_g :> video_g,
pix_b :> video_b
);
// forever
while (1) {
}
}

80
presets/verilog/ntsc.ice Executable file
View File

@ -0,0 +1,80 @@
// SL 2019-10
//
// GNU AFFERO GENERAL PUBLIC LICENSE
// Version 3, 19 November 2007
//
// A copy of the license full text is included in
// the distribution, please refer to it for details.
algorithm ntsc(
output! uint1 ntsc_hs,
output! uint1 ntsc_vs,
output! uint1 active,
output! uint1 vblank,
output! uint10 ntsc_x,
output! uint10 ntsc_y
) <autorun> {
uint10 H_FRT_PORCH = 7;
uint10 H_SYNCH = 23;
uint10 H_BCK_PORCH = 23;
uint10 H_RES = 256;
uint10 V_FRT_PORCH = 5;
uint10 V_SYNCH = 3;
uint10 V_BCK_PORCH = 14;
uint10 V_RES = 240;
uint10 HS_START = 0;
uint10 HS_END = 0;
uint10 HA_START = 0;
uint10 H_END = 0;
uint10 VS_START = 0;
uint10 VS_END = 0;
uint10 VA_START = 0;
uint10 V_END = 0;
uint10 xcount = 0;
uint10 ycount = 0;
HS_START := H_FRT_PORCH;
HS_END := H_FRT_PORCH + H_SYNCH;
HA_START := H_FRT_PORCH + H_SYNCH + H_BCK_PORCH;
H_END := H_FRT_PORCH + H_SYNCH + H_BCK_PORCH + H_RES;
VS_START := V_FRT_PORCH;
VS_END := V_FRT_PORCH + V_SYNCH;
VA_START := V_FRT_PORCH + V_SYNCH + V_BCK_PORCH;
V_END := V_FRT_PORCH + V_SYNCH + V_BCK_PORCH + V_RES;
ntsc_hs := ((xcount >= HS_START && xcount < HS_END));
ntsc_vs := ((ycount >= VS_START && ycount < VS_END));
active := (xcount >= HA_START && xcount < H_END)
&& (ycount >= VA_START && ycount < V_END);
vblank := (ycount < VA_START);
xcount = 0;
ycount = 0;
while (1) {
ntsc_x = (active) ? xcount - HA_START : 0;
ntsc_y = (vblank) ? 0 : ycount - VA_START;
if (xcount == H_END-1) {
xcount = 0;
if (ycount == V_END-1) {
ycount = 0;
} else {
ycount = ycount + 1;
}
} else {
xcount = xcount + 1;
}
}
}
// -------------------------

View File

@ -0,0 +1,141 @@
$include('ntsc.ice')
// SL 2020-04-22
// A rotating texture using BRAM
// -------------------------
algorithm frame_display(
input uint10 pix_x,
input uint10 pix_y,
input uint1 pix_active,
input uint1 pix_vblank,
output! uint$color_depth$ pix_r,
output! uint$color_depth$ pix_g,
output! uint$color_depth$ pix_b
) <autorun> {
uint8 frame = 0;
uint8 angle = 0;
int20 u = 0;
int20 v = 0;
int20 cos = 0;
int20 sin = 0;
int20 cornerx = 320;
int20 cornery = 240;
//int20 cornerx = -320;
//int20 cornery = -240;
int20 corneru = 0;
int20 cornerv = 0;
int20 deltau_x = 0;
int20 deltau_y = 0;
int20 deltav_x = 0;
int20 deltav_y = 0;
brom uint18 tbl[$32*32$] = {
$$write_image_in_table('tile.tga',6)
};
brom int10 cosine[256] = {
$$for i=0,255 do
$math.floor(511.0 * math.cos(2*math.pi*i/255))$,
$$end
};
pix_r := 0; pix_g := 0; pix_b := 0;
// ---------- show time!
while (1) {
// display frame
while (pix_vblank == 0) {
if (pix_active) {
pix_b = tbl.rdata[0,6]<<2;
pix_g = tbl.rdata[6,6]<<2;
pix_r = tbl.rdata[12,6]<<2;
// update u,v
if (pix_x == 0) {
u = corneru;
v = cornerv;
} else {
if (pix_x == 255) {
corneru = corneru + deltau_y;
cornerv = cornerv + deltav_y;
} else {
u = u + deltau_x;
v = v + deltav_x;
}
}
// tbl bram access
tbl.addr = ((u>>11)&31) + (((v>>11)&31)<<5);
// access during loop (one cycle to go back)
}
}
// prepare next (we are in vblank, there is time)
cosine.addr = frame;
frame = frame + 1;
++:
angle = ((512+cosine.rdata) >> 2);
cosine.addr = angle;
++: // sine bram access
cos = cosine.rdata;
cosine.addr = angle + 64;
++: // sine bram access
sin = cosine.rdata;
// prepare scanline with mapping
corneru = - ((cornerx * cos) - (cornery * sin));
cornerv = - ((cornerx * sin) + (cornery * cos));
//corneru = ((cornerx * cos) - (cornery * sin));
//cornerv = ((cornerx * sin) + (cornery * cos));
deltau_x = cos;
deltau_y = - sin;
deltav_x = sin;
deltav_y = cos;
u = corneru;
v = cornerv;
// wait for sync
while (pix_vblank == 1) {}
}
}
// -------------------------
algorithm main(
output! uint$color_depth$ video_r,
output! uint$color_depth$ video_g,
output! uint$color_depth$ video_b,
output! uint1 video_hs,
output! uint1 video_vs
)
<@clock,!reset>
{
uint1 active = 0;
uint1 vblank = 0;
uint10 pix_x = 0;
uint10 pix_y = 0;
ntsc ntsc_driver (
ntsc_hs :> video_hs,
ntsc_vs :> video_vs,
active :> active,
vblank :> vblank,
ntsc_x :> pix_x,
ntsc_y :> pix_y
);
frame_display display (
pix_x <: pix_x,
pix_y <: pix_y,
pix_active <: active,
pix_vblank <: vblank,
pix_r :> video_r,
pix_g :> video_g,
pix_b :> video_b
);
// forever
while (1) {
}
}

View File

@ -0,0 +1,83 @@
// -------------------------
$include('ntsc.ice')
// -------------------------
algorithm frame_display(
input uint10 pix_x,
input uint10 pix_y,
input uint1 pix_active,
input uint1 pix_vblank,
output! uint$color_depth$ pix_r,
output! uint$color_depth$ pix_g,
output! uint$color_depth$ pix_b
) <autorun> {
uint8 frame = 0;
// by default r,g,b are set to zero
pix_r := 0;
pix_g := 0;
pix_b := 0;
// ---------- show time!
while (1) {
// display frame
while (pix_vblank == 0) {
if (pix_active) {
pix_b = frame << 2;
pix_g = pix_y[0,$color_depth$];
pix_r = pix_x[0,$color_depth$];
}
}
while (pix_vblank == 1) {} // wait for sync
frame = frame + 1;
}
}
// -------------------------
algorithm main(
// NTSC
output! uint$color_depth$ video_r,
output! uint$color_depth$ video_g,
output! uint$color_depth$ video_b,
output! uint1 video_hs,
output! uint1 video_vs
)
<@clock,!reset>
{
uint1 active = 0;
uint1 vblank = 0;
uint10 pix_x = 0;
uint10 pix_y = 0;
ntsc ntsc_driver (
ntsc_hs :> video_hs,
ntsc_vs :> video_vs,
active :> active,
vblank :> vblank,
ntsc_x :> pix_x,
ntsc_y :> pix_y
);
frame_display display (
pix_x <: pix_x,
pix_y <: pix_y,
pix_active <: active,
pix_vblank <: vblank,
pix_r :> video_r,
pix_g :> video_g,
pix_b :> video_b
);
// forever
while (1) {
while (vblank == 0) { }
}
}

View File

@ -0,0 +1,81 @@
// -------------------------
$include('ntsc.ice')
// -------------------------
algorithm frame_display(
input uint10 pix_x,
input uint10 pix_y,
input uint1 pix_active,
input uint1 pix_vblank,
output! uint$color_depth$ pix_r,
output! uint$color_depth$ pix_g,
output! uint$color_depth$ pix_b
) <autorun> {
// by default r,g,b are set to zero
pix_r := 0;
pix_g := 0;
pix_b := 0;
// ---------- show time!
while (1) {
// display frame
while (pix_vblank == 0) {
if (pix_active) {
pix_b = pix_x[0,$color_depth$]<<3;
pix_g = pix_y[0,$color_depth$]<<2;
pix_r = pix_x[0,$color_depth$]<<1;
}
}
while (pix_vblank == 1) {} // wait for sync
}
}
// -------------------------
algorithm main(
output! uint$color_depth$ video_r,
output! uint$color_depth$ video_g,
output! uint$color_depth$ video_b,
output! uint1 video_hs,
output! uint1 video_vs
)
<@clock,!reset>
{
uint1 active = 0;
uint1 vblank = 0;
uint10 pix_x = 0;
uint10 pix_y = 0;
ntsc ntsc_driver (
ntsc_hs :> video_hs,
ntsc_vs :> video_vs,
active :> active,
vblank :> vblank,
ntsc_x :> pix_x,
ntsc_y :> pix_y
);
frame_display display (
pix_x <: pix_x,
pix_y <: pix_y,
pix_active <: active,
pix_vblank <: vblank,
pix_r :> video_r,
pix_g :> video_g,
pix_b :> video_b
);
uint8 frame = 0;
// forever
while (1) {
while (vblank == 0) { }
frame = frame + 1;
}
}

BIN
presets/verilog/tile.tga Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -86,6 +86,11 @@ export class CodeProject {
while (m = re1.exec(text)) {
this.pushAllFiles(files, m[2]);
}
// for Silice
let re1a = /^\s*\$(include|\$dofile|\$write_image_in_table)\('(.+?)'/gmi;
while (m = re1a.exec(text)) {
this.pushAllFiles(files, m[2]);
}
// include .arch (json) statements
let re2 = /^\s*([.]arch)\s+(\w+)/gmi;
while (m = re2.exec(text)) {
@ -104,7 +109,7 @@ export class CodeProject {
this.pushAllFiles(files, m[2]);
}
// for .c -- //#resource "file" (or ;resource or #resource)
let re3 = /^\s*([;]|[/][/])#resource\s+"(.+?)"/gm;
let re3 = /^\s*([;']|[/][/])#resource\s+"(.+?)"/gm;
while (m = re3.exec(text)) {
this.pushAllFiles(files, m[2]);
}

View File

@ -82,6 +82,7 @@ var TOOL_TO_SOURCE_STYLE = {
'inform6': 'inform6',
'fastbasic': 'fastbasic',
'basic': 'basic',
'silice': 'verilog',
}
function gaEvent(category:string, action:string, label?:string, value?:string) {

View File

@ -67,7 +67,7 @@ export class WaveformView {
w: width,
h: $(this.parent).height(),
itemHeight: rowHeight,
totalRows: this.meta.length,
totalRows: this.meta.length+1,
generatorFn: (row : number) => {
var metarow = this.meta[row]; // TODO: why null?
var s = metarow != null ? metarow.label : "";

View File

@ -97,6 +97,9 @@ export function VL_GTES_III(x,lbits,y,lhs,rhs) {
export function VL_DIV_III(lbits,lhs,rhs) {
return (((rhs)==0)?0:(lhs)/(rhs)); }
export function VL_MULS_III(lbits,lhs,rhs) {
return (((rhs)==0)?0:(lhs)*(rhs)); }
export function VL_MODDIV_III(lbits,lhs,rhs) {
return (((rhs)==0)?0:(lhs)%(rhs)); }
@ -120,11 +123,11 @@ export function VL_REDXOR_32(r) {
export var VL_WRITEF = console.log; // TODO: $write
export function vl_finish(filename,lineno,hier) {
console.log("Finished at " + filename + ":" + lineno, hier);
if (!vl_finished) console.log("Finished at " + filename + ":" + lineno, hier);
vl_finished = true;
}
export function vl_stop(filename,lineno,hier) {
console.log("Stopped at " + filename + ":" + lineno, hier);
if (!vl_stopped) console.log("Stopped at " + filename + ":" + lineno, hier);
vl_stopped = true;
}
@ -534,7 +537,8 @@ var VerilogPlatform = function(mainElement, options) {
if (inspect) {
inspect_data[frameidx] = inspect_obj[inspect_sym];
}
idata[frameidx] = RGBLOOKUP[gen.rgb & 15];
let rgb = gen.rgb;
idata[frameidx] = rgb & 0x80000000 ? rgb : RGBLOOKUP[rgb & 15];
frameidx++;
}
} else if (!framehsync && gen.hsync) {
@ -744,19 +748,22 @@ var VerilogPlatform = function(mainElement, options) {
gen.tick2();
}
getToolForFilename(fn) {
if (fn.endsWith("asm"))
return "jsasm";
else
return "verilator";
if (fn.endsWith(".asm")) return "jsasm";
else if (fn.endsWith(".ice")) return "silice";
else return "verilator";
}
getDefaultExtension() { return ".v"; };
inspect(name:string) : string {
if (!gen) return;
if (name && !name.match(/^\w+$/)) return;
if (name) name = name.replace('.','_');
if (!name || !name.match(/^\w+$/)) {
inspect_obj = inspect_sym = null;
return;
}
var val = gen[name];
if (val === undefined && current_output.code) {
var re = new RegExp("(\\w+__DOT__" + name + ")\\b", "gm");
var re = new RegExp("(\\w+__DOT__(?:_[dcw]_)" + name + ")\\b", "gm");
var m = re.exec(current_output.code);
if (m) {
name = m[1];

6952
src/worker/fs/fsSilice.data Normal file

File diff suppressed because it is too large Load Diff

213
src/worker/fs/fsSilice.js Normal file
View File

@ -0,0 +1,213 @@
var Module = typeof Module !== 'undefined' ? Module : {};
if (!Module.expectedDataFileDownloads) {
Module.expectedDataFileDownloads = 0;
}
Module.expectedDataFileDownloads++;
(function() {
var loadPackage = function(metadata) {
var PACKAGE_PATH;
if (typeof window === 'object') {
PACKAGE_PATH = window['encodeURIComponent'](window.location.pathname.toString().substring(0, window.location.pathname.toString().lastIndexOf('/')) + '/');
} else if (typeof location !== 'undefined') {
// worker
PACKAGE_PATH = encodeURIComponent(location.pathname.toString().substring(0, location.pathname.toString().lastIndexOf('/')) + '/');
} else {
throw 'using preloaded data can only be done on a web page or in a web worker';
}
var PACKAGE_NAME = '/home/hugg/8bitworkshop-compilers/output/fs/fsSilice.data';
var REMOTE_PACKAGE_BASE = 'fsSilice.data';
if (typeof Module['locateFilePackage'] === 'function' && !Module['locateFile']) {
Module['locateFile'] = Module['locateFilePackage'];
err('warning: you defined Module.locateFilePackage, that has been renamed to Module.locateFile (using your locateFilePackage for now)');
}
var REMOTE_PACKAGE_NAME = Module['locateFile'] ? Module['locateFile'](REMOTE_PACKAGE_BASE, '') : REMOTE_PACKAGE_BASE;
var REMOTE_PACKAGE_SIZE = metadata['remote_package_size'];
var PACKAGE_UUID = metadata['package_uuid'];
function fetchRemotePackage(packageName, packageSize, callback, errback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', packageName, true);
xhr.responseType = 'arraybuffer';
xhr.onprogress = function(event) {
var url = packageName;
var size = packageSize;
if (event.total) size = event.total;
if (event.loaded) {
if (!xhr.addedTotal) {
xhr.addedTotal = true;
if (!Module.dataFileDownloads) Module.dataFileDownloads = {};
Module.dataFileDownloads[url] = {
loaded: event.loaded,
total: size
};
} else {
Module.dataFileDownloads[url].loaded = event.loaded;
}
var total = 0;
var loaded = 0;
var num = 0;
for (var download in Module.dataFileDownloads) {
var data = Module.dataFileDownloads[download];
total += data.total;
loaded += data.loaded;
num++;
}
total = Math.ceil(total * Module.expectedDataFileDownloads/num);
if (Module['setStatus']) Module['setStatus']('Downloading data... (' + loaded + '/' + total + ')');
} else if (!Module.dataFileDownloads) {
if (Module['setStatus']) Module['setStatus']('Downloading data...');
}
};
xhr.onerror = function(event) {
throw new Error("NetworkError for: " + packageName);
}
xhr.onload = function(event) {
if (xhr.status == 200 || xhr.status == 304 || xhr.status == 206 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
var packageData = xhr.response;
callback(packageData);
} else {
throw new Error(xhr.statusText + " : " + xhr.responseURL);
}
};
xhr.send(null);
};
function handleError(error) {
console.error('package error:', error);
};
var fetchedCallback = null;
var fetched = Module['getPreloadedPackage'] ? Module['getPreloadedPackage'](REMOTE_PACKAGE_NAME, REMOTE_PACKAGE_SIZE) : null;
if (!fetched) fetchRemotePackage(REMOTE_PACKAGE_NAME, REMOTE_PACKAGE_SIZE, function(data) {
if (fetchedCallback) {
fetchedCallback(data);
fetchedCallback = null;
} else {
fetched = data;
}
}, handleError);
function runWithFS() {
function assert(check, msg) {
if (!check) throw msg + new Error().stack;
}
Module['FS_createPath']('/', 'frameworks', true, true);
Module['FS_createPath']('/frameworks', 'templates', true, true);
Module['FS_createPath']('/frameworks', 'libraries', true, true);
Module['FS_createPath']('/frameworks', 'verilator', true, true);
Module['FS_createPath']('/frameworks', 'boards', true, true);
Module['FS_createPath']('/frameworks/boards', 'icebreaker', true, true);
Module['FS_createPath']('/frameworks/boards', 'orangecrab', true, true);
Module['FS_createPath']('/frameworks/boards', 'de10nano', true, true);
Module['FS_createPath']('/frameworks/boards', 'techgraph', true, true);
Module['FS_createPath']('/frameworks/boards', '8bitworkshop', true, true);
Module['FS_createPath']('/frameworks/boards', 'fomu', true, true);
Module['FS_createPath']('/frameworks/boards', 'ulx3s', true, true);
Module['FS_createPath']('/frameworks/boards', 'icestick', true, true);
Module['FS_createPath']('/frameworks/boards', 'verilator', true, true);
Module['FS_createPath']('/frameworks/boards', 'crosslink_nx_evn', true, true);
Module['FS_createPath']('/frameworks/boards', 'mojov3', true, true);
Module['FS_createPath']('/frameworks/boards', 'icarus', true, true);
/** @constructor */
function DataRequest(start, end, audio) {
this.start = start;
this.end = end;
this.audio = audio;
}
DataRequest.prototype = {
requests: {},
open: function(mode, name) {
this.name = name;
this.requests[name] = this;
Module['addRunDependency']('fp ' + this.name);
},
send: function() {},
onload: function() {
var byteArray = this.byteArray.subarray(this.start, this.end);
this.finish(byteArray);
},
finish: function(byteArray) {
var that = this;
Module['FS_createDataFile'](this.name, null, byteArray, true, true, true); // canOwn this data in the filesystem, it is a slide into the heap that will never change
Module['removeRunDependency']('fp ' + that.name);
this.requests[this.name] = null;
}
};
var files = metadata['files'];
for (var i = 0; i < files.length; ++i) {
new DataRequest(files[i]['start'], files[i]['end'], files[i]['audio']).open('GET', files[i]['filename']);
}
function processPackageData(arrayBuffer) {
assert(arrayBuffer, 'Loading data file failed.');
assert(arrayBuffer instanceof ArrayBuffer, 'bad input to processPackageData');
var byteArray = new Uint8Array(arrayBuffer);
var curr;
// Reuse the bytearray from the XHR as the source for file reads.
DataRequest.prototype.byteArray = byteArray;
var files = metadata['files'];
for (var i = 0; i < files.length; ++i) {
DataRequest.prototype.requests[files[i].filename].onload();
}
Module['removeRunDependency']('datafile_/home/hugg/8bitworkshop-compilers/output/fs/fsSilice.data');
};
Module['addRunDependency']('datafile_/home/hugg/8bitworkshop-compilers/output/fs/fsSilice.data');
if (!Module.preloadResults) Module.preloadResults = {};
Module.preloadResults[PACKAGE_NAME] = {fromCache: false};
if (fetched) {
processPackageData(fetched);
fetched = null;
} else {
fetchedCallback = processPackageData;
}
}
if (Module['calledRun']) {
runWithFS();
} else {
if (!Module['preRun']) Module['preRun'] = [];
Module["preRun"].push(runWithFS); // FS is not initialized yet, wait for it
}
Module['removeRunDependency']('fsSilice.js.metadata');
}
function runMetaWithFS() {
Module['addRunDependency']('fsSilice.js.metadata');
var REMOTE_METADATA_NAME = Module['locateFile'] ? Module['locateFile']('fsSilice.js.metadata', '') : 'fsSilice.js.metadata';
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
loadPackage(JSON.parse(xhr.responseText));
}
}
xhr.open('GET', REMOTE_METADATA_NAME, true);
xhr.overrideMimeType('application/json');
xhr.send(null);
}
if (Module['calledRun']) {
runMetaWithFS();
} else {
if (!Module['preRun']) Module['preRun'] = [];
Module["preRun"].push(runMetaWithFS);
}
})();

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,60 @@
/* for Silice: https://github.com/sylefeb/Silice */
`define VERILATOR 1
`define COLOR_DEPTH 8
/*verilator lint_off pinmissing */
/*verilator lint_off undriven */
/*verilator lint_off width */
$$VERILATOR = 1
$$NUM_LEDS = 0
$$SIMULATION = 1
$$color_depth = 8
$$color_max = 255
`timescale 1ns / 1ps
`default_nettype none
module top(
`ifdef NTSC
// NTSC
output reg [31:0] rgb,
output hsync,
output vsync,
`endif
input clk,
input reset
);
wire [7:0] __main_video_r;
wire [7:0] __main_video_g;
wire [7:0] __main_video_b;
wire __main_video_hs;
wire __main_video_vs;
// main
wire run_main;
assign run_main = 1'b1;
wire done_main;
M_main __main(
.clock(clk),
.reset(reset),
`ifdef NTSC
.out_video_r(__main_video_r),
.out_video_g(__main_video_g),
.out_video_b(__main_video_b),
.out_video_hs(__main_video_hs),
.out_video_vs(__main_video_vs),
`endif
.in_run(run_main),
.out_done(done_main)
);
assign rgb = {8'hff, __main_video_b, __main_video_g, __main_video_r};
assign hsync = __main_video_hs;
assign vsync = __main_video_vs;
endmodule

21
src/worker/wasm/silice.js Normal file

File diff suppressed because one or more lines are too long

BIN
src/worker/wasm/silice.wasm Executable file

Binary file not shown.

View File

@ -209,6 +209,7 @@ var PLATFORM_PARAMS = {
libargs: ['atari5200.lib', '-D', '__CARTFLAGS__=255'],
},
'verilog': {
extra_compile_files: ['8bitworkshop.v'],
},
'astrocade': {
code_start: 0x2000,
@ -271,7 +272,7 @@ var PLATFORM_PARAMS = {
cfgfile: 'devel-6502.cfg',
libargs: ['crt0.o', 'sim6502.lib'],
extra_link_files: ['crt0.o', 'devel-6502.cfg'],
},
},
};
PLATFORM_PARAMS['sms-sms-libcv'] = PLATFORM_PARAMS['sms-sg1000-libcv'];
@ -770,6 +771,7 @@ function assembleDASM(step:BuildStep) {
var errors = [];
var errorMatcher = msvcErrorMatcher(errors);
function match_fn(s) {
// TODO: what if s is not string? (startsWith is not a function)
var matches = re_usl.exec(s);
if (matches) {
var key = matches[1];
@ -2670,6 +2672,62 @@ function compileBASIC(step:BuildStep) {
}
}
function compileSilice(step:BuildStep) {
// TODO: fastbasic-fp?
loadNative("silice");
var params = step.params;
gatherFiles(step, {mainFilePath:"main.ice"});
var destpath = step.prefix + '.v';
var errors : WorkerError[] = [];
var errfile : string;
var errline : number;
if (staleFiles(step, [destpath])) {
var match_fn = (s: string) => {
s = (s as any).replaceAll(/\033\[\d+\w/g, '');
var mf = /file:\s*(\w+)/.exec(s);
var ml = /line:\s+(\d+)/.exec(s);
if (mf) errfile = mf[1];
else if (ml) errline = parseInt(ml[1]);
else if (errfile && errline && s.length > 1) {
if (s.length > 2) {
errors.push({path:errfile+".ice", line:errline, msg:s});
} else {
errfile = null;
errline = null;
}
}
}
var silice = emglobal.silice({
instantiateWasm: moduleInstFn('silice'),
noInitialRun:true,
print:match_fn,
printErr:match_fn,
});
var FS = silice['FS'];
setupFS(FS, 'Silice');
populateFiles(step, FS);
populateExtraFiles(step, FS, params.extra_compile_files);
const FWDIR = '/share/frameworks';
var args = [
'-D', 'NTSC=1',
'--frameworks_dir', FWDIR,
'-f', `/8bitworkshop.v`,
'-o', destpath,
step.path];
execMain(step, silice, args);
if (errors.length)
return {errors:errors};
var vout = FS.readFile(destpath, {encoding:'utf8'});
putWorkFile(destpath, vout);
}
return {
nexttool:"verilator",
path:destpath,
args:[destpath],
files:[destpath],
};
}
////////////////////////////
var TOOLS = {
@ -2703,6 +2761,7 @@ var TOOLS = {
'merlin32': assembleMerlin32,
'fastbasic': compileFastBasic,
'basic': compileBASIC,
'silice': compileSilice,
}
var TOOL_PRELOADFS = {
@ -2726,6 +2785,7 @@ var TOOL_PRELOADFS = {
'bataribasic': '2600basic',
'inform6': 'inform',
'fastbasic': '65-atari8',
'silice': 'Silice',
}
function applyDefaultErrorPath(errors:WorkerError[], path:string) {