Lesson 8. The card — into a chip with 8 legs

In pictures

Everything built in seven lessons is the card's computer. We fold it into one chip with eight legs, make a second card with another identity — and swap the cards in the tester, like in an ATM.


8.1. The idea: a card is what is inside

From outside a card has only what the terminal gives it: power, ground, reset, clock and the data wire. Everything else — processor, memory, program, identity — is inside. The card's inputs are Input ports, the data wire IO is an Output port: the card pulls it itself. If you make ground or FAC an output, the editor shows a lightning bolt: two outputs on one wire.

8.2. The idea: two cards — one program

The second card is a copy of the chip (button ⧉ in the library) with another matrix. The program, the processor, the memory are the same. From outside the cards look the same; the difference is 29 transistors out of 6,500. They answer the same challenge differently — that is how the bank tells cards apart.

CARDC1 VCCC2 RSTC3 CLKC4C5 GNDC6 FACC7 IOC8TERMIOCLKRSTSENDsr0…7lampdata wire IOswitches T0–T7, SEND —outside, on the panelCARD 2C1 …C6C7 IOthe second card: the same circuit, 29 different matrix transistors."Insert" — move the terminal labels onto its legs.
Two devices on the table: the card — a chip with eight legs like a contact pad — and the tester — a chip with its panel outside. One wire IO between them. The second card is inserted instead of the first — and gives a different answer to the same challenge.

8.3. Building

The same project as in lesson 7.

C1 VCCGND C5
C2 RSTFAC C6
C3 CLKIO C7
C4 —— C8

Step 1. What stays outside

Outside the chip is what belongs to the terminal, not to the card:

  • Clock (clock CLK), switches RST and FAC;
  • the whole adapter of lesson 5: the resistor and the TPULL transistor on the IO wire, switches T0–T7, button SEND, everything from sendS to WTB, lamps sr0–sr7 and lamp;
  • Power and Ground.

Everything else is the card: from DEC16 of lesson 1 to the matrix transistors of lesson 6, together with the display and lamps A and PC (they end up inside the chip — you can see them if you dive into it with a double click).

Step 2. Eight legs — ports

Next to the card put 8 ports. Everything the card gets from the terminal (power, ground, reset, clock, FAC) is an Input port: C1–C6 in a column from top to bottom (the order from top to bottom = the order of the chip's legs). IO is data both ways, the card pulls this wire itself — Output port C7, and an empty C8 below it. The port name — double-click on it. A label goes on the port (the net inside the card):

PartPort nameLabelWhat
Input portC1VCCpower
Input portC2RSTreset
Input portC3CLKclock
Input portC4—not used
Input portC5GNDground
Input portC6FACfactory preparation
Output portC7IOdata
Output portC8—not used

C4 and C8 are not connected to anything — the same on real cards: these contacts exist but are not used.

A chip draws inputs on the left and outputs on the right, so the legs will stand like this: C1–C6 on the left, C7 and C8 on the right — not like on the pad, 4 and 4. If you make GND or FAC an output (Output port), the editor shows a red lightning bolt: the chip "drives" a wire that is already driven by ground and a switch — two outputs on one wire.

Step 3. Fold

Select the card and the 8 ports with a frame (without what is in step 1) → Ctrl+G → name CARD. The program in the ROM is baked into the chip by itself.

Step 4. Insert the card into the terminal

PartPinLabel
CARDC1
C2
C3
C4
C5
C6
C7
C8
VCC
RST
CLK
— (do not connect)
GND
FAC
IO
— (do not connect)

8.4. Checking

The same as in lesson 7 — but now through the chip's 8 legs. First the factory preparation: after folding the chip starts anew.

№What to doLamps (● lit)What it is
1Clock — MAX
2switch FAC and RST on, wait a second, switch both off○○●●●○●● 59the card chip said hello
3switches T7…T0 = 0100 1110, press SEND○○○○○○○● 1N — account 1
4switches T7…T0 = 0101 0000, press SEND○○○○○○○○ go offthe byte went, the card waits for the next one
5switches T7…T0 = 0001 0010, press SEND○○○○○○○○ go offthe byte went, the card waits for the next one
6switches T7…T0 = 0011 0100, press SEND●○○●○○○○ 144P 12 34 — PIN correct
7switches T7…T0 = 0100 0001, press SEND○○○○○○○○ go offthe byte went, the card waits for the next one
8switches T7…T0 = 1010 0101, press SEND○○○○○○○○ go offthe byte went, the card waits for the next one
9switches T7…T0 = 0011 1100, press SEND○●●○●○○○ 104A A5 3C — first byte of the answer ($68)
10switches T7…T0 = 0101 0010, press SEND●●●●○●●● 247R — second byte ($F7)

Step 5. A second card: a copy with another identity

In the library, chip CARD has the button ⧉ (copy) → name CARD2. The copy is the same device: processor, program in the ROM, memory. Only the identity will differ — the matrix transistors.

CARD2 → "Edit". Find the matrix: 7 rows pr0–pr6 (bytes 16–22) and 8 columns pb7–pb0 (bits). Go down the rows from top to bottom and in each cell do what it says:

RowByte: was → nowpb7pb6pb5pb4pb3pb2pb1pb0What
pr001 → 02······+✕account number
pr112 → 43·+·✕··●+PIN, digits 1–2
pr234 → 21··●✕·✕·+PIN, digits 3–4
pr35A → 21·✕+✕✕·✕+key, byte 1
pr4C3 → 9F●✕·+++●●key, byte 2
pr517 → E4+++✕·●✕✕key, byte 3
pr68E → 3B✕·++●✕●+key, byte 4

● — there is a transistor and it stays, do not touch · ✕ — delete · + — place a new one · · — empty and stays empty. A new transistor is nmos: gate on row pr, drain on column pb, source on GND.

In total: delete 14, place 15, keep 8 — the CARD2 matrix has exactly 23 transistors.

Save the chip.

Step 6. Take one card out, insert another

Put CARD2 on the table next to CARD. The card inserted into the terminal is the one whose legs carry the terminal's labels (step 4). Only one is ever inserted: two cards on the same labels are two outputs on the IO wire.

ActionWhat to do
take out CARDremove the labels VCC, RST, CLK, GND, FAC, IO from the legs of CARD (delete the labels or detach the wires)
insert CARD2hang the same 6 labels on the same legs of CARD2: C1 VCC, C2 RST, C3 CLK, C5 GND, C6 FAC, C7 IO

The new card has not "come from the factory" yet: the first time — FAC and RST. Then the check:

№What to doLamps (● lit)What it is
1switch FAC and RST on, wait a second, switch both off○○●●●○●● 59greeting
2switches T7…T0 = 0100 1110, press SEND○○○○○○●○ 2N — now account 2
3switches T7…T0 = 0101 0000, press SEND○○○○○○○○ go offthe byte went, the card waits for the next one
4switches T7…T0 = 0001 0010, press SEND○○○○○○○○ go offthe byte went, the card waits for the next one
5switches T7…T0 = 0011 0100, press SEND○●●○○○●○ 98P 12 34 — the PIN of card 1 does not fit
6switches T7…T0 = 0101 0000, press SEND○○○○○○○○ go offthe byte went, the card waits for the next one
7switches T7…T0 = 0100 0011, press SEND○○○○○○○○ go offthe byte went, the card waits for the next one
8switches T7…T0 = 0010 0001, press SEND●○○●○○○○ 144P 43 21 — its own PIN
9switches T7…T0 = 0100 0001, press SEND○○○○○○○○ go offthe byte went, the card waits for the next one
10switches T7…T0 = 1010 0101, press SEND○○○○○○○○ go offthe byte went, the card waits for the next one
11switches T7…T0 = 0011 1100, press SEND●●●○●○●○ 234A A5 3C — a different answer ($EA)
12switches T7…T0 = 0101 0010, press SEND●●○●●●○● 221R — ($DD)

To the same challenge A5 3C card 1 answered 68 F7, card 2 — EA DD. From outside the chips are the same; the difference is 29 transistors of the matrix out of 6,500. That is how the bank tells cards apart: not by their look, but by the answer that only its own card can give.

Insert CARD back (the labels again on its legs), FAC and RST — and N answers 1 again: the identity of card 1 has not gone anywhere, it is in its transistors.

Step 7. The tester — into a chip too

The card tester (the adapter of lesson 5) is a device too: electronics inside, a panel outside. Let us fold it as well, so that the table holds two clear devices: the card and the tester. Lamps and displays inside a chip are not visible on the canvas, so everything you look at and press stays outside: switches T0–T7, button SEND, lamps sr0–sr7 and lamp, the display.

Next to the tester put the ports (port name = label, double-click to rename):

PartPort name and label
Input portCLK
Input portRST
Input portSEND
Input portT0
Input portT1
Input portT2
Input portT3
Input portT4
Input portT5
Input portT6
Input portT7
Output portsr0
Output portsr1
Output portsr2
Output portsr3
Output portsr4
Output portsr5
Output portsr6
Output portsr7
Output portlamp
Output portIO

IO is an output: the tester pulls the wire itself. Select with a frame the tester's electronics (the resistor, transistor TPULL, everything from NOT(RST) = nRT to DFF → WTB) and the ports — without the switches, the button, the lamps and the display → Ctrl+G → name TERM. The legs of TERM go to labels with the same names:

PartPinLabel
TERMCLK
RST
SEND
T0
T1
T2
T3
T4
T5
T6
T7
sr0
sr1
sr2
sr3
sr4
sr5
sr6
sr7
lamp
IO
CLK
RST
SEND
T0
T1
T2
T3
T4
T5
T6
T7
sr0
sr1
sr2
sr3
sr4
sr5
sr6
sr7
lamp
IO

Check — any row of the "Check by hand" step: N → display 1. Inside the tester — 1,729 transistors and a resistor.

⚠ A common mistake. When rewiring card 2, the transistors that the cards share (● in the grid) were deleted too. The account number is then correct, but the PIN and the key are not. The card 2 matrix must have exactly 23 transistors.

Lesson 8 paste (Cmd+I)

The card's eight ports — put them next to the card, then select the card together with them and press Ctrl+G.

# Lesson 8 — the card's 8 legs: put the ports next to the card, select the card with them and press Ctrl+G -> CARD.portIn{name=C1}(VCC)portIn{name=C2}(RST)portIn{name=C3}(CLK)portIn{name=C4}(nc4)portIn{name=C5}(GND)portIn{name=C6}(FAC)portOut{name=C7}(IO)portOut{name=C8}(nc8)

¿No te sale? Algo no funciona →