Skip to content

Commit 5a7354a

Browse files
committed
feat: yowasp integration, icestick script
1 parent b7920ad commit 5a7354a

File tree

3 files changed

+80
-39
lines changed

3 files changed

+80
-39
lines changed

bin/silice-make.py

+37-28
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,33 @@
3636
def colored(str,clr,attrs=0):
3737
return str
3838

39+
def prepare_call(args,variant_pin_sets):
40+
# prepare additional defines
41+
defines = ""
42+
if args.pins:
43+
for pin_set in args.pins.split(','):
44+
if not pin_set in variant_pin_sets:
45+
print(colored("pin set '" + pin_set + "' not defined in board variant",'red'))
46+
sys.exit(-1)
47+
else:
48+
if 'define' in variant_pin_sets[pin_set]:
49+
defines = defines + " -D " + variant_pin_sets[pin_set]['define']
50+
key_value = variant_pin_sets[pin_set]['define'].split('=')
51+
if len(key_value) == 2:
52+
os.environ[key_value[0]] = key_value[1]
53+
elif len(key_value) == 1:
54+
os.environ[key_value[0]] = 1
55+
# adding command line defines
56+
if args.defines:
57+
for define in args.defines.split(','):
58+
defines = defines + " -D " + define
59+
# additional command line parameters
60+
add_args = ""
61+
if args.args:
62+
for arg in args.args.split(','):
63+
add_args = add_args + " --" + arg
64+
return defines, add_args
65+
3966
def make(cmd_args):
4067
# command line
4168
parser = argparse.ArgumentParser(description='silice-make is the Silice build tool')
@@ -254,6 +281,9 @@ def make(cmd_args):
254281
os.environ["PATH"] += os.pathsep + os.path.realpath(os.path.join(make_dir,"../tools/fpga-binutils/mingw64/bin/"))
255282
os.environ["PATH"] += os.pathsep + os.path.realpath("c:/intelFPGA_lite/19.1/quartus/bin64/")
256283

284+
# top module name
285+
os.environ["SILICE_TOP"] = args.top
286+
257287
if target_builder['builder'] == 'shell':
258288

259289
# ==== building with a custom script
@@ -263,39 +293,13 @@ def make(cmd_args):
263293
if not sysconfig.get_platform().startswith("mingw"):
264294
print(colored("to build from scripts please run MinGW python from a shell",'red'))
265295
sys.exit(-1)
266-
267296
# script check
268297
script = os.path.join(board_path,target_builder['command'])
269298
if not os.path.exists(script):
270299
print(colored("script " + script + " not found", 'red'))
271300
sys.exit()
272-
273-
# prepare additional defines
274-
defines = ""
275-
if args.pins:
276-
for pin_set in args.pins.split(','):
277-
if not pin_set in variant_pin_sets:
278-
print(colored("pin set '" + pin_set + "' not defined in board variant",'red'))
279-
sys.exit(-1)
280-
else:
281-
if 'define' in variant_pin_sets[pin_set]:
282-
defines = defines + " -D " + variant_pin_sets[pin_set]['define']
283-
key_value = variant_pin_sets[pin_set]['define'].split('=')
284-
if len(key_value) == 2:
285-
os.environ[key_value[0]] = key_value[1]
286-
elif len(key_value) == 1:
287-
os.environ[key_value[0]] = 1
288-
# adding command line defines
289-
if args.defines:
290-
for define in args.defines.split(','):
291-
defines = defines + " -D " + define
292-
# top module name
293-
os.environ["SILICE_TOP"] = args.top
294-
# additional command line parameters
295-
add_args = ""
296-
if args.args:
297-
for arg in args.args.split(','):
298-
add_args = add_args + " --" + arg
301+
# prepare call
302+
defines, add_args = prepare_call(args, variant_pin_sets)
299303
# execute
300304
command = script + " " + source_file
301305
print('launching command ', colored(command,'cyan'))
@@ -307,15 +311,20 @@ def make(cmd_args):
307311

308312
elif target_builder['builder'] == 'yowasp':
309313

314+
# ==== building with yowasp (custom python script)
315+
310316
# script check
311317
script = os.path.join(board_path,target_builder['command'])
312318
if not os.path.exists(script):
313319
print(colored("script " + script + " not found", 'red'))
314320
sys.exit()
321+
# prepare call
322+
defines, add_args = prepare_call(args, variant_pin_sets)
315323
# execute
316324
import importlib.util
317325
spec = importlib.util.spec_from_file_location("module_name", script)
318326
module = importlib.util.module_from_spec(spec)
327+
module.silice_args = (source_file + " " + defines + " " + add_args + " --top " + args.top).strip()
319328
sys.modules["module_name"] = module
320329
spec.loader.exec_module(module)
321330

+33-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,37 @@
1+
import os
2+
import sys
3+
14
import yowasp_silice
25
import yowasp_yosys
36
import yowasp_nextpnr_ice40
47

5-
# test Silice
6-
yowasp_silice.run_silice(["--help"])
7-
# test Yosys
8-
yowasp_yosys.run_yosys(["--help"])
9-
# test Nextpnr
10-
yowasp_nextpnr_ice40.run_nextpnr_ice40(["--help"])
8+
print("+ Silice bin directory : ",os.getenv("SILICE_DIR",""))
9+
print("+ Build output directory : ",os.getenv("BUILD_DIR",""))
10+
print("+ Silice frameworks directory: ",os.getenv("FRAMEWORKS_DIR",""))
11+
print("+ Frameworks file : ",os.getenv("FRAMEWORK_FILE",""))
12+
print("+ Board directory : ",os.getenv("BOARD_DIR",""))
13+
print("+ Board variant : ",os.getenv("BOARD_VARIANT",""))
14+
print("+ Top module : ",os.getenv("SILICE_TOP",""))
15+
16+
# go inside the build directory
17+
os.chdir(os.getenv("BUILD_DIR",""))
18+
19+
# call silice
20+
args = sys.argv[1:]
21+
yowasp_silice.run_silice(["--frameworks_dir",os.getenv("FRAMEWORKS_DIR",""),
22+
"--framework",os.getenv("FRAMEWORK_FILE",""),
23+
*silice_args.split(" ")])
24+
# call yosys
25+
yosys_args = ['-l','yosys.log','-p',"read_verilog -sv out.v",'-p',"synth_ice40 -relut -top top -json build.json"]
26+
print(yosys_args)
27+
yowasp_yosys.run_yosys(yosys_args)
28+
29+
# call nextpnr
30+
nextpnr_args=['--force','--hx1k','--json','build.json','--pcf',os.getenv("BOARD_DIR","") + '/icestick.pcf','--asc','build.asc','--package','tq144','--freq','12']
31+
yowasp_nextpnr_ice40.run_nextpnr_ice40(nextpnr_args)
32+
33+
# call icepack
34+
yowasp_nextpnr_ice40.run_icepack(['build.asc','build.bin'])
35+
36+
print("---")
37+
print("Bitstream produced in " + os.getenv("BUILD_DIR","") + "/build.bin, you can now program your board.")

src/libs/lua/src/ldo.c

+10-5
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,17 @@
5353
** longjmp/setjmp otherwise.
5454
*/
5555
#if !defined(LUAI_THROW) /* { */
56-
56+
#include <stdio.h>
5757
#if defined(__wasi__) /* { */
58-
59-
#define LUAI_THROW(L,c) { abort(); }
58+
#define LUAI_THROW(L,c) { \
59+
char str[4096];\
60+
int errline = -1;\
61+
const char *errmsg = lua_tostring(L, -1);\
62+
snprintf(str, 4049, "[[LUA]exit] %s\n", errmsg);\
63+
fprintf(stderr,str);\
64+
fprintf(stderr,"preprocessor error\n");\
65+
exit(2);\
66+
}
6067
#define LUAI_TRY(L,c,a) { a }
6168
#define luai_jmpbuf int /* dummy variable */
6269

@@ -809,5 +816,3 @@ int luaD_protectedparser (lua_State *L, ZIO *z, const char *name,
809816
L->nny--;
810817
return status;
811818
}
812-
813-

0 commit comments

Comments
 (0)