commit source changes for cpud-hack
This commit is contained in:
		| @@ -1,6 +1,6 @@ | |||||||
| #import "@preview/cetz:0.3.2": draw | #import "@preview/cetz:0.3.2": draw | ||||||
| #import "element.typ" | #import "element.typ" | ||||||
| #import "ports.typ": add-port | #import "ports.typ": add-ports, add-port | ||||||
|  |  | ||||||
| #let draw-shape(id, tl, tr, br, bl, fill, stroke) = { | #let draw-shape(id, tl, tr, br, bl, fill, stroke) = { | ||||||
|   let p0 = tl |   let p0 = tl | ||||||
| @@ -31,15 +31,15 @@ | |||||||
|     draw.anchor("name", (p5, 50%, (p1, 50%, p2))) |     draw.anchor("name", (p5, 50%, (p1, 50%, p2))) | ||||||
|   }) |   }) | ||||||
|  |  | ||||||
|   let f2 = add-port(id, "west", (id: "in1"), (p0, 50%, p6)) |   // let f2 = add-port(id, "west", (id: "in1"), (p0, 50%, p6)) | ||||||
|   let f3 = add-port(id, "west", (id: "in2"), (p3, 50%, p4)) |   // let f3 = add-port(id, "west", (id: "in2"), (p3, 50%, p4)) | ||||||
|   let f4 = add-port(id, "east", (id: "out"), (p1, 50%, p2)) |   // let f4 = add-port(id, "east", (id: "out"), (p1, 50%, p2)) | ||||||
|  |  | ||||||
|   let f = { |   // let f = { | ||||||
|     f1; f2; f3; f4 |   //   f1; f2; f3; f4 | ||||||
|   } |   // } | ||||||
|  |  | ||||||
|   return (f, tl, tr, br, bl) |   return (f1, tl, tr, br, bl) | ||||||
| } | } | ||||||
|  |  | ||||||
| /// Draws an ALU with two inputs | /// Draws an ALU with two inputs | ||||||
| @@ -53,14 +53,7 @@ | |||||||
|   h: none, |   h: none, | ||||||
|   name: none, |   name: none, | ||||||
|   name-anchor: "center", |   name-anchor: "center", | ||||||
|   fill: none, |   ports: ( | ||||||
|   stroke: black + 1pt, |  | ||||||
|   id: "", |  | ||||||
|   debug: ( |  | ||||||
|     ports: false |  | ||||||
|   ) |  | ||||||
| ) = { |  | ||||||
|   let ports = ( |  | ||||||
|     west: ( |     west: ( | ||||||
|       (id: "in1"), |       (id: "in1"), | ||||||
|       (id: "in2"), |       (id: "in2"), | ||||||
| @@ -68,8 +61,15 @@ | |||||||
|     east: ( |     east: ( | ||||||
|       (id: "out"), |       (id: "out"), | ||||||
|     ) |     ) | ||||||
|  |   ), | ||||||
|  |   ports-margins: (west: (-30%, -30%)), | ||||||
|  |   fill: none, | ||||||
|  |   stroke: black + 1pt, | ||||||
|  |   id: "", | ||||||
|  |   debug: ( | ||||||
|  |     ports: false | ||||||
|   ) |   ) | ||||||
|    | ) = { | ||||||
|   element.elmt( |   element.elmt( | ||||||
|     draw-shape: draw-shape, |     draw-shape: draw-shape, | ||||||
|     x: x, |     x: x, | ||||||
| @@ -79,15 +79,16 @@ | |||||||
|     name: name, |     name: name, | ||||||
|     name-anchor: name-anchor, |     name-anchor: name-anchor, | ||||||
|     ports: ports, |     ports: ports, | ||||||
|  |     ports-margins: ports-margins, | ||||||
|     fill: fill, |     fill: fill, | ||||||
|     stroke: stroke, |     stroke: stroke, | ||||||
|     id: id, |     id: id, | ||||||
|     auto-ports: false, |     // auto-ports: false, | ||||||
|     ports-y: ( |     // ports-y: ( | ||||||
|       in1: (h) => {h * 0.225}, |     //   in1: (h) => {h * 0.225}, | ||||||
|       in2: (h) => {h * 0.775}, |     //   in2: (h) => {h * 0.775}, | ||||||
|       out: (h) => {h * 0.5} |     //   out: (h) => {h * 0.5} | ||||||
|     ), |     // ), | ||||||
|     debug: debug |     debug: debug | ||||||
|   ) |   ) | ||||||
| } | } | ||||||
| @@ -24,8 +24,10 @@ | |||||||
|  |  | ||||||
|     let pos1 = (rel: offset, to: pos) |     let pos1 = (rel: offset, to: pos) | ||||||
|  |  | ||||||
|  |     let clock-line-style = port.at("clock-line-style", default: (:)) | ||||||
|  |  | ||||||
|     // TODO: use context or vectors to have the height relative to the width |     // TODO: use context or vectors to have the height relative to the width | ||||||
|     draw.line(prev, pos1, next) |     draw.line(prev, pos1, next, ..clock-line-style) | ||||||
|   } |   } | ||||||
|   draw.content( |   draw.content( | ||||||
|     pos, |     pos, | ||||||
|   | |||||||
							
								
								
									
										14
									
								
								src/wire.typ
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/wire.typ
									
									
									
									
									
								
							| @@ -215,7 +215,7 @@ | |||||||
|   if name != none { |   if name != none { | ||||||
|     let names = () |     let names = () | ||||||
|      |      | ||||||
|     if type(name) == str { |     if type(name) == str or type(name) == content { | ||||||
|       names = ((name, name-pos),) |       names = ((name, name-pos),) | ||||||
|        |        | ||||||
|     } else if type(name) == array { |     } else if type(name) == array { | ||||||
| @@ -267,7 +267,9 @@ | |||||||
| /// - vertical (bool): Whether the name should be displayed vertically | /// - vertical (bool): Whether the name should be displayed vertically | ||||||
| /// - length (number): The length of the stub | /// - length (number): The length of the stub | ||||||
| /// - name-offset (number): The name offset, perpendicular to the stub | /// - name-offset (number): The name offset, perpendicular to the stub | ||||||
| #let stub(port-id, side, name: none, vertical: false, length: 1em, name-offset: 0) = { | #let stub(port-id, side, name: none, vertical: false, length: none, name-offset: 0, directed: false) = { | ||||||
|  |   let length = if length != none { length } else if directed { 1.5em } else { 1em } | ||||||
|  |  | ||||||
|   let end-offset = ( |   let end-offset = ( | ||||||
|     north: (0, length), |     north: (0, length), | ||||||
|     east: (length, 0), |     east: (length, 0), | ||||||
| @@ -282,9 +284,15 @@ | |||||||
|     west: (-length, name-offset) |     west: (-length, name-offset) | ||||||
|   ).at(side) |   ).at(side) | ||||||
|  |  | ||||||
|  |   let mark = (:) | ||||||
|  |   if directed { | ||||||
|  |     mark = (end: ">", fill: black) | ||||||
|  |   } | ||||||
|  |  | ||||||
|   draw.line( |   draw.line( | ||||||
|  |     (rel: end-offset, to: port-id), | ||||||
|     port-id, |     port-id, | ||||||
|     (rel: end-offset, to: port-id) |     mark: mark | ||||||
|   ) |   ) | ||||||
|   if name != none { |   if name != none { | ||||||
|     let text-anchor = if vertical { |     let text-anchor = if vertical { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user