.PS # Muxcct # https://www.reddit.com/r/ECE/comments/1p2j8ot/how_you_guys_draw_a_diagram_like_this_any_pro_way/ log_init iflatex(`command "{\scriptsize\sf"', `ifsvg(svg_font(sans-serif,8bp__))') define(`slash',`line by (2,3.5)*L_unit') boxht = dimen_/2 boxwid = boxht*3/2 foreach_(`ttx',`{ L`'m4Lx: Here ifelse(m4Lx,1,,`dot'); line right_ box "patsubst(ttx,`:.*$')" line right_ AND`'m4Lx: AND_gate with .In2 at Here {line left_ dimen_/2 from last [].In1; I`'m4Lx: dot} line right_ dimen_ Q`'m4Lx: box wid boxwid*3/2 with .nw at Here+(0,boxht/4) IQ`'m4Lx`'_1: Q`'m4Lx.nw+(0,-boxht/4) IQ`'m4Lx`'_2: Q`'m4Lx.sw+(0, boxht/4) { "WrEn" at last box.nw+(boxht/9,-boxht/4) ljust "D" at last box.sw+(boxht/9,boxht/4) ljust "Q" at last box.e-(boxht/9,0) rjust "patsubst(ttx,`^.*:')" at last box.nw+(boxht/9,0) above ljust } } move down_ boxht*1.6; right_', =0x4:DATAOUT,=0x8:OUTENABLE,=0xC:INTEN,=0x10:INTYPE,=0x14:INTPOLARITY) L6: dot; line right_ box "=0x18" AND6: AND_gate(3) with .Out at 2 between AND4.Out and AND5.Out {line from last box.e right_ dimen_/3 continue to (Here,AND6.In2) then to AND6.In2 line from AND6.In1 to (I5,AND6.In1) then to I1} line right_ dimen_ Q6: box wid boxwid*3/2 with .nw at Here+(0,boxht/4) { "Clear" at Q6.nw+(boxht/8,-boxht/4) ljust "Set" at Q6.sw+(boxht/8,boxht/4) ljust "Q" at Q6.e-(boxht/8,0) rjust "INTSTATE" at Q6.nw+(boxht/8,0) above ljust } pushdef(`lg_plen',6) Mx: Mux(7,,,dimen_*3/4,(Q1.y-Q6.y)*7/5:(Q1.y-Q6.y)) with .In6.end at Here popdef(`lg_plen') for_(0,6,1,`slash at Mx.In`'m4x') slash at Mx.Out.start+(dimen_/6,0) "MUX" below at Mx "Synchronized" at Mx.In0.end rjust "DATAIN" rjust line from L1 to (L1,Mx.Sel.end); dot {PADDR: Here-(dimen_/2,0); "PADDR[4:2]" wid 42bp__ at PADDR rjust} line from I1 up_ to (I1,Mx.In0) then right_ -dimen_/2 AND01: AND_gate(3) with .Out at Here "WriteEnable" at AND01.Out ljust above line from AND01.In3 to (PADDR,AND01.In3); "PENABLE" rjust AND00: AND_gate at AND01.n+(0,AND_ht*L_unit) "ReadEnable" at AND00.Out ljust above line from AND00.In1 to (PADDR,AND00.In1); "PSEL" rjust dot(at AND00.In1+(-dimen_*3/4,0)) line to (Here,AND01.In1) then to AND01.In1 line from AND01.In2 left_ to (L1,AND01.In2); continue to (Here,AND00.In2); dot {line to (PADDR,Here); "PWRITE" rjust} line right_ dimen_/2 N: NOT_gate line to AND00.In2 line from IQ1_2 left_ dimen_/2; continue to (Here,PADDR)+(0,-dimen_/2) continue to (PADDR,Here); {"PWDATA" rjust}; {slash at Here+(dimen_/2,0)} dot(at (I1,Here)); line to (Here,AND6.In3) then to AND6.In3 for_(2,5,1,`dot(at IQ`'m4x`'_2-(dimen_/2,0)); line to (Q`'m4x.w,Here)') line from PADDR to (Mx.Sel,PADDR) then to Mx.Sel.end "Hardware registers" at (Q6.x+dimen_/6,PADDR.y) above line from Q6.sw+(0,boxht/4) left_ dimen_/4 then down_ Q6.s.y-PADDR.y+dimen_ "Interrupts" below define(`customFF',`FlipFlopX(wid dimen_*3/4 ht dimen_ fill_(1), , :D;:En;E:, , :Q;;, , 0 ) ') right_; for_(2,0,-1,`F`'m4x: customFF \ with .W1.end at Mx.Out.end+(1/2,-1)*L_unit*m4x') DO: dot(at F0.W2.end+(-dimen_/4,dimen_*3/2)) line from F0.W2.end left_ F0.W2.end.x-DO.x then up_ AND00.Out.y-F0.W2.y \ then to AND00.Out; right_ line from F0.E1 right_ dimen_*2/3 AND0: AND_gate with .In2 at Here slash at F0.E1+(dimen_/3,0) line from AND0.Out right_ dimen_/2 slash at AND0.Out+(dimen_/4,0) line from AND0.In1 left_ dimen_/2; continue to (Here,DO) then to DO iflatex(`command "}%"',`ifsvg(command "")') .PE