added `xschem fill_reset` command to reset fill patterns defined via tcl array pixdata(n)

This commit is contained in:
stefan schippers 2024-01-15 15:53:49 +01:00
parent c46afdc582
commit 38ff460694
6 changed files with 164 additions and 9 deletions

View File

@ -546,8 +546,6 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
@ -683,6 +681,9 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
xschem expandlabel {2*A[3:0]} --> A[3],A[2],A[1],A[0],A[3],A[2],A[1],A[0] 8
last field is the number of bits
since [ and ] are TCL special characters argument must be quoted with { and } </pre>
<li><kbd> fill_reset [nodraw]</kbd></li><pre>
After setting tcl array pixdata(n) reset fill patterns on all layers
If 'nodraw' is given do not redraw window.</pre>
<li><kbd> fill_type n fill_type [nodraw]</kbd></li><pre>
Set fill type for layer 'n', fill_type may be 'solid' or 'stipple' or 'empty'
If 'nodraw' is given do not redraw window.</pre>
@ -1489,6 +1490,8 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"

View File

@ -908,11 +908,28 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
else { cmd_found = 0;}
break;
case 'f': /*----------------------------------------------*/
/* fill_reset [nodraw]
* After setting tcl array pixdata(n) reset fill patterns on all layers
* If 'nodraw' is given do not redraw window.
*/
if(!strcmp(argv[1], "fill_reset"))
{
int dr = 1;
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
init_pixdata();
free_gc();
create_gc();
enable_layers();
build_colors(0.0, 0.0);
resetwin(1, 0, 1, 0, 0); /* recreate pixmap. resetwin(create_pixmap, clear_pixmap, force, w, h) */
if(argc > 2 && !strcmp(argv[2], "nodraw")) dr = 0;
if(dr) draw();
}
/* fill_type n fill_type [nodraw]
* Set fill type for layer 'n', fill_type may be 'solid' or 'stipple' or 'empty'
* If 'nodraw' is given do not redraw window.
*/
if(!strcmp(argv[1], "fill_type"))
else if(!strcmp(argv[1], "fill_type"))
{
int dr = 1;
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}

View File

@ -325,17 +325,39 @@ static void init_color_array(double dim, double dim_bg)
}
}
static void init_pixdata()/* populate xctx->fill_type array that is used in create_gc() to set fill styles */
void init_pixdata()/* populate xctx->fill_type array that is used in create_gc() to set fill styles */
{
int i,j, full, empty;
const char *tclpixdata;
const char *tclword;
int found_data;
for(i=0;i<cadlayers; ++i) {
tclpixdata = Tcl_GetVar2(interp, "pixdata", my_itoa(i), TCL_GLOBAL_ONLY);
dbg(1, "pixdata(%d)=%s\n", i, tclpixdata);
full=1; empty=1;
for(j=0;j<32; ++j) {
if(i<sizeof(pixdata_init)/sizeof(pixdata_init[0]))
pixdata[i][j] = pixdata_init[i][j];
else
pixdata[i][j] = 0x00;
found_data = 0;
if(tclpixdata) {
tclvareval("lindex {", tclpixdata, "} ", my_itoa(j >> 1), NULL);
tclword = tclresult();
if(tclword[0]) {
unsigned int word;
unsigned char byte;
sscanf(tclword, "%x", &word);
if(j%2) byte = word & 0xff;
else byte = (word >> 8) & 0xff;
dbg(1, "byte=%02x\n", byte);
found_data = 1;
pixdata[i][j] = byte;
}
}
if(!found_data) {
if(i<sizeof(pixdata_init)/sizeof(pixdata_init[0]))
pixdata[i][j] = pixdata_init[i][j];
else
pixdata[i][j] = 0x00;
}
if(pixdata[i][j]!=0xff) full=0;
if(pixdata[i][j]!=0x00) empty=0;
}

View File

@ -1665,6 +1665,7 @@ extern int shorted_instance(int i, int lvs_ignore);
extern int compare_schematics(const char *filename);
extern void create_gc(void);
extern void free_gc(void);
extern void init_pixdata();
extern int warning_overlapped_symbols(int sel);
extern void free_simdata(void);
extern void delete_netlist_structs(void);

View File

@ -8059,6 +8059,99 @@ if {!$rainbow_colors} {
}
}
# every 0x#### hex data represents one 16 bit row of the 16x16 bit fill bitmap
# of the specified layer number.
set_ne pixdata(0) {
0xffff 0xffff 0xffff 0xffff 0xffff 0xffff 0xffff 0xffff
0xffff 0xffff 0xffff 0xffff 0xffff 0xffff 0xffff 0xffff
}
set_ne pixdata(1) {
0xffff 0xffff 0xffff 0xffff 0xffff 0xffff 0xffff 0xffff
0xffff 0xffff 0xffff 0xffff 0xffff 0xffff 0xffff 0xffff
}
set_ne pixdata(2) {
0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000
0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000
}
set_ne pixdata(3) {
0x5555 0x0000 0xaaaa 0x0000 0x5555 0x0000 0xaaaa 0x0000
0x5555 0x0000 0xaaaa 0x0000 0x5555 0x0000 0xaaaa 0x0000
}
set_ne pixdata(4) {
0xffff 0xffff 0xffff 0xffff 0xffff 0xffff 0xffff 0xffff
0xffff 0xffff 0xffff 0xffff 0xffff 0xffff 0xffff 0xffff
}
set_ne pixdata(5) {
0xffff 0xffff 0xffff 0xffff 0xffff 0xffff 0xffff 0xffff
0xffff 0xffff 0xffff 0xffff 0xffff 0xffff 0xffff 0xffff
}
set_ne pixdata(6) {
0x0101 0x0000 0x0000 0x0000 0x1010 0x0000 0x0000 0x0000
0x0101 0x0000 0x0000 0x0000 0x1010 0x0000 0x0000 0x0000
}
set_ne pixdata(7) {
0x0000 0x8000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0200
0x0000 0x0080 0x0000 0x0000 0x0000 0x0000 0x0000 0x0002
}
set_ne pixdata(8) {
0x1111 0x0000 0x0000 0x0000 0x1111 0x0000 0x0000 0x0000
0x1111 0x0000 0x0000 0x0000 0x1111 0x0000 0x0000 0x0000
}
set_ne pixdata(9) {
0x0441 0x0000 0x1004 0x0000 0x4110 0x0000 0x0441 0x0000
0x1004 0x0000 0x4110 0x0000 0x0441 0x0000 0x1004 0x0000
}
set_ne pixdata(10) {
0xffff 0xffff 0xffff 0xffff 0xffff 0xffff 0xffff 0xffff
0xffff 0xffff 0xffff 0xffff 0xffff 0xffff 0xffff 0xffff
}
set_ne pixdata(11) {
0x1111 0x0000 0x4444 0x0000 0x1111 0x0000 0x4444 0x0000
0x1111 0x0000 0x4444 0x0000 0x1111 0x0000 0x4444 0x0000
}
set_ne pixdata(12) {
0x0404 0x0202 0x0101 0x8080 0x4040 0x2020 0x1010 0x0808
0x0404 0x0202 0x0101 0x8080 0x4040 0x2020 0x1010 0x0808
}
set_ne pixdata(13) {
0x1111 0x2222 0x4444 0x8888 0x1111 0x2222 0x4444 0x8888
0x1111 0x2222 0x4444 0x8888 0x1111 0x2222 0x4444 0x8888
}
set_ne pixdata(14) {
0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000
0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000
}
set_ne pixdata(15) {
0x4444 0x0000 0x0000 0x0000 0x4444 0x0000 0x0000 0x0000
0x4444 0x0000 0x0000 0x0000 0x4444 0x0000 0x0000 0x0000
}
set_ne pixdata(16) {
0x1111 0x0000 0x0000 0x0000 0x2222 0x0000 0x0000 0x0000
0x4444 0x0000 0x0000 0x0000 0x8888 0x0000 0x0000 0x0000
}
set_ne pixdata(17) {
0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000
0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000
}
set_ne pixdata(18) {
0x5555 0xaaaa 0x5555 0xaaaa 0x5555 0xaaaa 0x5555 0xaaaa
0x5555 0xaaaa 0x5555 0xaaaa 0x5555 0xaaaa 0x5555 0xaaaa
}
set_ne pixdata(19) {
0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000
0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000
}
set_ne pixdata(20) {
0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000
0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000
}
set_ne pixdata(21) {
0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000
0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000
}
# for svg and pdf draw 20121108
regsub -all {"} $dark_colors {} svg_colors
regsub -all {#} $svg_colors {0x} svg_colors

View File

@ -321,6 +321,25 @@
# "#ff7777" "#bfff81" "#00ffcc" "#ce0097" "#d2d46b"
# "#ef6158" "#fdb200" }
###########################################################################
#### CUSTOM FILL PATTERNS MAY BE DEFINED HERE
###########################################################################
#### every 0x#### hex data represents one 16 bit row of the 16x16 bit fill bitmap
#### of the specified layer number.
#### following examples set a checkerboard fill pattern
#### for symbol shape drawing layer (layer 4)
#### and for pin layer (layer 5)
#
# set pixdata(4) {
# 0x8888 0x0000 0x0000 0x0000 0x2222 0x0000 0x0000 0x0000
# 0x8888 0x0000 0x0000 0x0000 0x2222 0x0000 0x0000 0x0000
# }
# set pixdata(5) {
# 0x5555 0xaaaa 0x5555 0xaaaa 0x5555 0xaaaa 0x5555 0xaaaa
# 0x5555 0xaaaa 0x5555 0xaaaa 0x5555 0xaaaa 0x5555 0xaaaa
# }
###########################################################################
#### CAIRO STUFF
###########################################################################