Theory
હવે engineer તમે છો
કૉલેજની lab માં એક smart door લગાડવામાં આવે છે. Rule સીધા શબ્દોમાં આવો છે:
"Open only for someone with a valid ID card who has morning or evening slot permission."
હવે આ વાક્ય અને door ની અંદરના wires, એ 2 ની વચ્ચે એક translation નું કામ પડ્યું છે. એ કામને જ design કહેવાય, અને આ topic પૂરો થાય ત્યાં સુધીમાં તમે એ આખું કામ જાતે કરી શકશો, sentence થી લઈને છેક circuit સુધી.
Theory
gatekeeper માટે નો rulebook
Output ને એક એવો gatekeeper સમજો જે વિચારી શકતો નથી, ફક્ત rulebook પ્રમાણે જ ચાલે છે. Design એટલે એ rulebook એટલો ચોક્કસ લખવો કે conditions ના દરેકે દરેક combination માટે જવાબ સ્પષ્ટ મળે, કાં તો open (1) કાં તો બંધ રહે (0). English એ કામ માટે બહુ ઢીલી ભાષા છે; Boolean algebra એ ચોક્કસ ભાષા છે.
Theory
Step 1: inputs અને output ને નામ આપો
દરેક condition ને એક 0/1 variable માં ફેરવો:
- A = 1 જ્યારે ID card valid હોય
- M = 1 જ્યારે morning permission હોય
- E = 1 જ્યારે evening permission હોય
- F = 1 જ્યારે door ખૂલવો જોઈએ (આ output છે)
આ step જોવામાં એકદમ સહેલો લાગે, પણ મોટા ભાગના ખોટા જવાબ અહીંથી જ જન્મે છે. ધુંધળો variable ("A = the card") એની સાથે compute કરી શકાય જ નહીં. એટલે દરેકને yes/no test તરીકે define કરો.
Theory
Step 2: વાક્યનું translation કરો
"Valid ID and (morning or evening permission)" આ પ્રમાણે બને છે:
F = A·(M + E)
- "and" → · (AND)
- "or" → + (inclusive OR: જેની પાસે બંને slot હોય એ પણ અંદર જઈ શકે)
- brackets વાક્યના grouping પ્રમાણે
Distribute કરીએ તો SOP view મળે: F = A·M + A·E, 2 entry cases, અને બંનેમાં ID તો જોઈએ જ.
Quiz
F = A·(M + E) વાપરીને: એક student પાસે valid ID છે (A = 1), morning permission નથી (M = 0), evening permission છે (E = 1). Door ખૂલશે?
- હા, F = 1
- ના, F = 0 કારણ કે M = 0
- ના, બંને slot જોઈએ
- Expression પરથી કહી ન શકાય
Show the answer
હા, F = 1
M + E = 0 + 1 = 1, પછી F = 1·1 = 1: door ખૂલે છે. Option B અને C એ OR ને AND સમજી લે છે, જે translation ની સૌથી common ભૂલ છે. Inclusive OR માટે ઓછામાં ઓછું એક જોઈએ, બધા નહીં. આમ values મૂકીને check કરવું એ જ કોઈ પણ design ને verify કરવાની રીત છે.
Theory
Step 3: gates તરીકે દોરો
F = A·(M + E) સીધું જ wire થઈ જાય છે:
- એક OR gate M અને E લે, જે (M + E) આપે
- એક AND gate A અને એ result લે, જે F આપે
કુલ 2 gates. જ્યારે expanded form A·M + A·E ને 2 AND gates અને એક OR gate જોઈએ: એ જ function માટે 3 gates. Truth table એ જ, પણ cost અલગ, અને એટલે જ wiring પહેલાં simplification (ગયા topic માં જોયું એ) મહત્ત્વનું છે.
Think first
નવો brief: "A machine runs only when the power is on, the cover is closed, and there is no fault."
મનમાં જ variables define કરો અને expression લખો: P = power on, C = cover closed, F = fault present, R = machine runs.
Show the answer
R = P·C·¬F
ત્રણેય conditions AND થી જોડાય છે, અને "no fault" એટલે F નું complement, જે NOT gate થી બને છે અને એ AND માં જાય છે. ધ્યાન ખેંચે એવો point: F ને "fault PRESENT" તરીકે define કર્યું હતું, એટલે rule ને ¬F જોઈએ. Expression લખતાં પહેલાં તમારી પોતાની variable definitions એક વાર ફરી વાંચી લેવી.
Quiz
machine વાળા example માં expression F ને બદલે ¬F કેમ વાપરે છે?
- કારણ કે NOT gates AND gates કરતાં સસ્તા છે
- કારણ કે F ને "fault present" તરીકે define કર્યું હતું અને rule ને fault ગેરહાજર જોઈએ
- કારણ કે outputs હંમેશા complement કરવા પડે
- એ ભૂલ છે; R = P·C·F સાચું છે
Show the answer
કારણ કે F ને "fault present" તરીકે define કર્યું હતું અને rule ને fault ગેરહાજર જોઈએ
Variable માં "fault present" store થાય છે; rule ને એનું ઊલટું જોઈએ, એટલે complement બંને ને જોડે છે. જો F ને "no fault" તરીકે define કર્યું હોત, તો સાદું F સાચું હોત. શીખવાનું એ કે expression સંપૂર્ણપણે variables ને કઈ રીતે define કર્યા એના પર આધાર રાખે છે, એટલે જ step 1 ને લખી નાખવાનું, ધારી ન લેવાનું.
Formula
exam માટે ની 4 step ની recipe
દરેક design question આ જ steps થી ઉકલી જાય: (1) 0/1 inputs અને output ને એક એક line માં define કરો, (2) વાક્યના grouping પ્રમાણે ·, + અને ¬ થી translate કરો, (3) simplify ત્યારે જ કરો જ્યારે ખરેખર terms ઓછા થતા હોય, અને laws ના નામ લખો, (4) gates describe કરો કે sketch કરો. આ 4 steps ને headings તરીકે લખશો તો marks એની મેળે આવશે.
Watch out
English માં translation ના traps
Rules માં "Or" inclusive જ હોય, જ્યાં સુધી વાક્ય "but not both" ન કહે (એ XOR થાય). "Only if" એ requirement બતાવે છે, guarantee નહીં: "opens only if ID is valid" એટલે ID ન હોય તો entry નહીં, પણ ફક્ત valid ID પૂરતું હોય એ જરૂરી નથી. અને negative શબ્દો (no, unless, without) લગભગ હંમેશા complement નો signal આપે છે.
Theory
આ ફરી ક્યાં મળશે
આ જ flow થી real hardware જન્મે છે: engineers Verilog જેવી ભાષામાં conditions લખે અને tools એને minimize કરીને wire કરી નાખે. Software બાજુએ, તમે જે પણ access-control check code કરશો (user.isValid && (slot === 'AM' || slot === 'PM')) એ આજનો door જ છે, ફક્ત JavaScript ના કપડામાં.
Summary
Key takeaways
- Design એક જ રસ્તે ચાલે છે: 0/1 variables define કરો, વાક્યનું translation કરો, ઉપયોગી હોય તો simplify કરો, પછી gates માં map કરો.
- "and" → ·, "or" → + (inclusive), "no/not" → complement, અને brackets વાક્યના grouping પ્રમાણે.
- F = A·(M + E) 2 gates વાપરે; એનું expansion A·M + A·E 3 gates વાપરે: function એ જ, cost અલગ.
- Expression નો અર્થ variable definitions પરથી આવે છે, એટલે definitions પહેલાં લખો.
- યાદ રાખવાની ચાવી: sentence, symbols, simplify, circuit.