From: Matthijs Kooijman Date: Thu, 1 Oct 2009 10:29:02 +0000 (+0200) Subject: Add multiplexer metapost object. X-Git-Tag: final-thesis~233 X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=5d17eedd2ad157c9d35d72093eb3acca851342e8;p=matthijs%2Fmaster-project%2Freport.git Add multiplexer metapost object. --- diff --git a/Utils/Metapost.tex b/Utils/Metapost.tex index e017780..6c46ece 100644 --- a/Utils/Metapost.tex +++ b/Utils/Metapost.tex @@ -8,6 +8,7 @@ input metaobj; setObjectDefaultOption("Box")("framewidth")(.75mm); setObjectDefaultOption("Circle")("framewidth")(.75mm); setObjectDefaultOption("Circle")("circmargin")(3mm); +setObjectDefaultOption("Mux")("framewidth")(.75mm); %ahlength := 1.5mm; ahangle := 60; @@ -94,6 +95,57 @@ define_global_boolean_option("labels"); setObjectDefaultOption("Reg")("reflect")(false); setObjectDefaultOption("Reg")("labels")(false); +% Define a Multiplexer. +vardef newMux@# text options= + ExecuteOptions(@#)(options); + assignObj(@#,"Mux"); + StandardInterface; + % Add ports + ObjPoint inpa, inpb, out; + + ObjCode MinimumStandardEquations, + % Make it a parallel trapezium + "xpart(@#ne - @#nw) = xpart(@#se - @#sw)", + "ypart(@#ne - @#nw) = -1 * ypart(@#se - @#sw)", + % Use a 22.5 degree angle for the sides + "ypart(@#nw) - ypart(@#ne) = xpart(@#ne-@#nw) / 2", + % With a specific width and height + "@#e-@#w = (" & decimal OptionValue@#("width") & ", 0mm)", + "@#n-@#s = (0mm, " & decimal OptionValue@#("height") & ")", + % And space the input ports evenly + "@#inpa = midpoint(@#nw, @#w)", + "@#inpb = midpoint(@#w, @#sw)", + "@#out = @#e"; + + StandardTies; +enddef; + +% Draw a multiplexer +def drawMux(suffix mux)= + draw mux.n -- mux.s; + % Use our bounding path to draw + drawFramedOrFilledObject_(mux); +enddef; + +% Bounding path for a multiplexer +def BpathMux(suffix n)=StandardBpath(n) enddef; + +% Define options +define_local_numeric_option("width"); +define_local_numeric_option("height"); +setObjectDefaultOption("Mux")("width")(5mm); +setObjectDefaultOption("Mux")("height")(20mm); +setObjectDefaultOption("Mux")("framed")(true); +% Overidden above +%setObjectDefaultOption("Mux")("framewidth")(.5bp); +setObjectDefaultOption("Mux")("framecolor")(black); +setObjectDefaultOption("Mux")("framestyle")(""); +setObjectDefaultOption("Mux")("shadow")(false); +setObjectDefaultOption("Mux")("shadowcolor")(black); +setObjectDefaultOption("Mux")("filled")(false); +setObjectDefaultOption("Mux")("fillcolor")(black); + + def midpoint(expr a, b) = ((a + b) / 2) enddef; \stopMPinclusions