summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/circuit-macros/examples/svg/ShiftRSVG.m4
blob: de8e13843e5ce3a4992ecebfd0ce50f7049eae36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
.PS
# ShiftR.m4
log_init(svg_font(sans-serif,11*0.9bp__))
textoffset = textht/6

define(`lg_plen',3)

define(`customFF',`FlipFlopX(wid 10*L_unit ht FF_ht*L_unit,,
    :S;NE:CK;:R, N:PR, :Q;;ifelse(`$1',1,:svg_ol(Q)), N:CLR,,)')

  F0: customFF(1)

  BUFFER_gate(,N) with .Out at F0.W1.end
    line left 2*L_unit from last [].In1
  T: dot
    reversed(`NOT_gate',left 10*L_unit)
    {move left textht*8}
  Serial: "SERIAL" rjust "INPUT" rjust
    line from T to (T,F0.W3) then to F0.W3.end

  NCLR: NOT_gate(right T.x-Serial.x from (Serial,F0.S1.end),N)
    "svg_ol(CLEAR)" wid 33bp__ at NCLR.start rjust 

  CLK: NOT_gate(right T.x-Serial.x from NCLR.start+(0,-BUF_ht*3/2*L_unit))
    "CLOCK" at CLK.start rjust

for_(1,4,1,`
  F`'m4x: customFF(eval(m4x!=4)) with .W3.end at F`'eval(m4x-1).E3.end
  ')

  "OUTPUT" wid 0.7 at F4.E1.end ljust
  line from NCLR.end to F4.S1.end

  down_
for_(0,4,1,`
  line from F`'m4x.W2.end down F0.W2.y-CLK.y
  ifelse(eval(m4x!=4),1,`dot',`line to CLK.end')
  N`'m4x: NAND_gate with .Out at F`'m4x.N1.end 
    line up 2*L_unit from N`'m4x.In2
    { line up 6*L_unit from N`'m4x.In1
      "PR`'eval(4-m4x)" rjust }
    ifelse(eval(m4x!=4),1,
     `dot; dot(at F`'m4x.S1.end)',
     `line to (Serial,Here)
      "PRESET" rjust "ENABLE" rjust ')
  ')

 command "</g>" # end font
.PE