// Numbas version: finer_feedback_settings {"name": "Fei's copy of EEE2013 Digital Electronics Assignment 2019", "metadata": {"description": "", "licence": "All rights reserved"}, "duration": 3600, "percentPass": "40", "showQuestionGroupNames": false, "showstudentname": true, "question_groups": [{"name": "Group", "pickingStrategy": "all-ordered", "pickQuestions": 1, "questionNames": ["", "", "", "", ""], "questions": [{"name": "CLA adder", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Graeme Chester", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/189/"}, {"name": "Fei Xia", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2603/"}], "advice": "", "statement": "
A binary carry look-ahead adder produces propagate and generate signals internally when adding two 4-bit numbers A and B together. The values for a particular addition are shown in the following table:-
\n{table([['<i>P<sub>k']+reverse(p),['<i>G<sub>k']+reverse(g)],['<i>k',3,2,1,0])}
\nThese are used inside the adder to calculate the carry outputs for each bit $C_{k}$.
\na {bin2str(a)} {bin2dec(a)}
\nb {bin2str(b)} {bin2dec(b)}
\np {bin2str(p)}
\ng {bin2str(g)}
\nc {bin2str(c)}
\ns {bin2str(s)} cout {bin2str([c[3]])} {bin2dec(s+[c[3]])}
\n", "tags": [], "preamble": {"css": "", "js": ""}, "functions": {"bin2dec": {"definition": "if(abs(bin)=0,\n 0,\n bin[0]+2*bin2dec(bin[1..abs(bin)])\n)", "type": "number", "parameters": [["bin", "list"]], "language": "jme"}, "bin2str": {"definition": "join(map(if(x=0,'0','1'),x,reverse(bin)),'')", "type": "string", "parameters": [["bin", "list"]], "language": "jme"}, "carry": {"definition": "if(abs(p)=0 or abs(g)=0,\n [],\n [if(p[0]*cin+g[0]>0.5,1,0)]+carry(if(p[0]*cin+g[0]>0.5,1,0),p[1..abs(p)],g[1..abs(g)])\n)", "type": "number", "parameters": [["cin", "number"], ["p", "list"], ["g", "list"]], "language": "jme"}}, "variables": {"cin": {"definition": "0", "description": "", "name": "cin", "templateType": "number", "group": "Ungrouped variables"}, "c1": {"definition": "carry(0,p,g)[1]", "description": "", "name": "c1", "templateType": "anything", "group": "Ungrouped variables"}, "g": {"definition": "map(x*y,[x,y],zip(a,b))\n", "description": "", "name": "g", "templateType": "anything", "group": "Ungrouped variables"}, "p": {"definition": "map(mod(x+y,2),[x,y],zip(a,b))\n", "description": "", "name": "p", "templateType": "anything", "group": "Ungrouped variables"}, "na": {"definition": "bin2dec(a)", "description": "", "name": "na", "templateType": "anything", "group": "Ungrouped variables"}, "ns": {"definition": "bin2dec(s+[c[abs(c)-1]])", "description": "", "name": "ns", "templateType": "anything", "group": "Ungrouped variables"}, "gp": {"definition": "carry(0,p,g)[abs(p)-1]", "description": "", "name": "gp", "templateType": "anything", "group": "Ungrouped variables"}, "a": {"definition": "[1]+repeat(random(0..1),3)", "description": "", "name": "a", "templateType": "anything", "group": "Ungrouped variables"}, "c": {"definition": "carry(0,p,g)\n", "description": "", "name": "c", "templateType": "anything", "group": "Ungrouped variables"}, "b": {"definition": "repeat(random(0..1),4)", "description": "", "name": "b", "templateType": "anything", "group": "Ungrouped variables"}, "nb": {"definition": "bin2dec(b)", "description": "", "name": "nb", "templateType": "anything", "group": "Ungrouped variables"}, "ss": {"definition": "bin2str(s)", "description": "", "name": "ss", "templateType": "anything", "group": "Ungrouped variables"}, "c2ci": {"definition": "carry(1,p,g)[2]", "description": "", "name": "c2ci", "templateType": "anything", "group": "Ungrouped variables"}, "debug": {"definition": "false", "description": "", "name": "debug", "templateType": "anything", "group": "Ungrouped variables"}, "s": {"definition": "map(mod(x+y,2),[x,y],zip(p,[cin]+c[0..abs(c)-1]))", "description": "", "name": "s", "templateType": "anything", "group": "Ungrouped variables"}, "pp": {"definition": "carry(1,p,repeat(0,abs(p)))[abs(p)-1]", "description": "", "name": "pp", "templateType": "anything", "group": "Ungrouped variables"}}, "rulesets": {}, "parts": [{"unitTests": [], "correctAnswerStyle": "plain", "type": "numberentry", "extendBaseMarkingAlgorithm": true, "correctAnswerFraction": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "scripts": {}, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "maxValue": "c1", "allowFractions": false, "showFeedbackIcon": true, "mustBeReducedPC": 0, "minValue": "c1", "marks": 1, "prompt": "Calculate the value of $C_1$ if $C_{IN}=0$
", "customMarkingAlgorithm": "", "mustBeReduced": false}, {"unitTests": [], "correctAnswerStyle": "plain", "type": "numberentry", "extendBaseMarkingAlgorithm": true, "correctAnswerFraction": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "scripts": {}, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "maxValue": "c2ci", "allowFractions": false, "showFeedbackIcon": true, "mustBeReducedPC": 0, "minValue": "c2ci", "marks": "2", "prompt": "Calculate the value of $C_2$ if $C_{IN}=1$
", "customMarkingAlgorithm": "", "mustBeReduced": false}, {"unitTests": [], "correctAnswerStyle": "plain", "type": "numberentry", "extendBaseMarkingAlgorithm": true, "correctAnswerFraction": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "scripts": {}, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "maxValue": "bin2dec(s+[c[3]])", "allowFractions": false, "showFeedbackIcon": true, "mustBeReducedPC": 0, "minValue": "bin2dec(s+[c[3]])", "marks": "3", "prompt": "The carry input $C_{IN}$ is {cin}. Find the sum of A and B as an unsigned decimal number
", "customMarkingAlgorithm": "", "mustBeReduced": false}, {"unitTests": [], "type": "gapfill", "extendBaseMarkingAlgorithm": true, "gaps": [{"unitTests": [], "correctAnswerStyle": "plain", "type": "numberentry", "extendBaseMarkingAlgorithm": true, "correctAnswerFraction": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "scripts": {}, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "maxValue": "pp", "allowFractions": false, "showFeedbackIcon": true, "mustBeReducedPC": 0, "minValue": "pp", "marks": 1, "customMarkingAlgorithm": "", "mustBeReduced": false}, {"unitTests": [], "correctAnswerStyle": "plain", "type": "numberentry", "extendBaseMarkingAlgorithm": true, "correctAnswerFraction": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "scripts": {}, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "maxValue": "gp", "allowFractions": false, "showFeedbackIcon": true, "mustBeReducedPC": 0, "minValue": "gp", "marks": 1, "customMarkingAlgorithm": "", "mustBeReduced": false}], "variableReplacements": [], "sortAnswers": false, "scripts": {}, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "showFeedbackIcon": true, "marks": 0, "prompt": "This adder is now to be used in a block carry look-ahead scheme. Find the values of the signals
\nblock propagate $P'_{3\\dots0}$[[0]] and
\nblock generate $G'_{3\\dots0}$[[1]]
", "customMarkingAlgorithm": ""}], "variable_groups": [], "ungrouped_variables": ["a", "b", "p", "g", "c1", "c2ci", "pp", "gp", "c", "s", "cin", "ns", "na", "nb", "ss", "debug"], "variablesTest": {"maxRuns": 100, "condition": ""}, "metadata": {"licence": "All rights reserved", "description": ""}, "type": "question"}, {"name": "Filling a Karnaugh Map", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Graeme Chester", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/189/"}, {"name": "Fei Xia", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2603/"}], "advice": "", "statement": "A Boolean function of 4 variables is given as
\n$f=${join(cubetotext(c1,labels),'.')+'+'+join(cubetotext(c2,labels),'.')+'+'+join(cubetotext(c3,labels),'.')}
\n{usermap()}
", "rulesets": {}, "tags": [], "metadata": {"description": "", "licence": "All rights reserved"}, "parts": [{"markPerCell": false, "unitTests": [], "numColumns": "4", "prompt": "Complete the Karnaugh map for $f$ by inserting 0 or 1 in each element of the following matrix.
", "numRows": "4", "scripts": {}, "type": "matrix", "correctAnswer": "kmap", "variableReplacementStrategy": "originalfirst", "tolerance": 0, "showFeedbackIcon": true, "marks": "3", "showCorrectAnswer": true, "variableReplacements": [], "allowResize": false, "correctAnswerFractions": false, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "allowFractions": false}], "variable_groups": [], "functions": {"usermap": {"language": "javascript", "definition": "// draw a 4x4 Karnaugh map for a function given as a truth table\nfunction drawKmap(ctx,bits,literals)\n{\n\nctx.font = \"20px Arial\";ctx.textAlign=\"center\"; ctx.textBaseline=\"middle\";\n ctx.lineWidth=2;\n\n//ctx.fillText(n,10,50);\nctx.beginPath();\nctx.moveTo(20,20);\nctx.lineTo(60,60);\nctx.stroke();\n\nctx.fillText(literals[0]+\" \"+literals[1],15,50);\nctx.fillText(literals[2]+\" \"+literals[3],50,10);\ngraycodebin=[\"00\",\"01\",\"11\",\"10\"];\nfor (ncol=0;ncol<=3;ncol++) {\n\tctx.fillText(graycodebin[ncol],80+ncol*40,40);\n\t}\n\nfor (nrow=0;nrow<=3;nrow++) {\n\tctx.fillText(graycodebin[nrow],40,80+nrow*40);\n\tfor (ncol=0;ncol<=3;ncol++) {\n\t\tctx.rect(60+ncol*40,60+nrow*40,40,40);\n\t\tctx.stroke();\n\t\tbitval=bits[nrow][ncol].toString();\n\t\tctx.fillText(bitval,80+ncol*40,80+nrow*40);\n\t\t}\n\t}\n\n}\n\nvar canv=document.createElement(\"canvas\");\ncanv.setAttribute(\"height\",\"250px\");\ncanv.setAttribute(\"width\",\"500px\");\nvar ctx = canv.getContext(\"2d\");\n\nquestion.signals.on('HTMLAttached',function(e) {\n \n // Create a Knockout.js observable\n ko.computed(function(){\n // Get the student's input string from part 0.\n var studentString = question.parts[0].display.studentAnswer();\n ctx.clearRect(0, 0, canv.width, canv.height);\n drawKmap(ctx,studentString,['a','b','c','d'])\n });\n});\n \nreturn canv;", "parameters": [], "type": "html"}, "cubetotext": {"language": "jme", "definition": "// convert a cube to a formatted text string using recursion \n// fixed for bounding box problem 24-04-18\nif(abs(cube)=0,\n [],\n switch(cube[0]=0,\n [\"$\\\\bbox[2pt]{\\\\bar{\"+labels[0]+\"}}$\"],\n cube[0]=1,\n [\"$\"+labels[0]+\"$\"],[]) + cubetotext(cube[1..abs(cube)],labels[1..abs(labels)]\n )\n)\n", "parameters": [["cube", "list"], ["labels", "list"]], "type": "string"}, "f": {"language": "jme", "definition": "// convert a cube to canonical set form using recursion\nif(abs(p)=1, //terminate on the last or only element of p\n if(p[abs(p)-1]=2, //a \"don't care\" so include both 1 and 0\n set(0,1),\n if(p[abs(p)-1]=1,\n set(1),\n set(0)\n )\n ),\n//else\n if(p[abs(p)-1]=2,\n set(map(x*2,x,f(p[0..abs(p)-1]))) or set(map(x*2+1,x,f(p[0..abs(p)-1]))),\n if(p[abs(p)-1]=1,\n set(map(x*2+1,x,f(p[0..abs(p)-1]))),\n set(map(x*2,x,f(p[0..abs(p)-1])))\n )\n )\n)", "parameters": [["p", "list"]], "type": "set"}, "mat2cube": {"language": "jme", "definition": "if(abs(list(m))=0,\n [],\n [m[0]*2]+mat2cube(m[1..abs(list(m))])\n )", "parameters": [["m", "matrix"]], "type": "list"}}, "ungrouped_variables": ["a", "b", "c", "d", "e", "m", "n", "kmap1", "canonicalsum", "c1", "c2", "c3", "labels", "kmap"], "preamble": {"js": "", "css": ""}, "variablesTest": {"condition": "abs(list(f(c1)-f(c2)))>0 and\nabs(list(f(c2)-f(c3)))>0 and\nabs(list(f(c3)-f(c1)))>0\n", "maxRuns": 100}, "variables": {"n": {"description": "mat2cube(m)
", "templateType": "anything", "definition": "0\n", "group": "Ungrouped variables", "name": "n"}, "d": {"description": "", "templateType": "anything", "definition": "false", "group": "Ungrouped variables", "name": "d"}, "canonicalsum": {"description": "", "templateType": "anything", "definition": "union(union(f(c1),f(c2)),f(c3))", "group": "Ungrouped variables", "name": "canonicalsum"}, "kmap": {"description": "Convert a 4-variable Boolean function from canonical (minterm) set to Karnaugh map matrix
", "templateType": "anything", "definition": "map(if(x in canonicalsum,1,0),x,matrix(repeat([0,1,3,2],4))+4*transpose(matrix(repeat([0,1,3,2],4))))", "group": "Ungrouped variables", "name": "kmap"}, "b": {"description": "", "templateType": "anything", "definition": "false", "group": "Ungrouped variables", "name": "b"}, "labels": {"description": "", "templateType": "list of strings", "definition": "[ safe(\"a\"), safe(\"b\"), safe(\"c\"), safe(\"d\") ]", "group": "Ungrouped variables", "name": "labels"}, "a": {"description": "", "templateType": "anything", "definition": "false", "group": "Ungrouped variables", "name": "a"}, "m": {"description": "", "templateType": "anything", "definition": "matrix([1,2],[3,4],[5,6])", "group": "Ungrouped variables", "name": "m"}, "c1": {"description": "", "templateType": "anything", "definition": "shuffle([random(0..1),random(0..1),2,2])", "group": "Ungrouped variables", "name": "c1"}, "c3": {"description": "", "templateType": "anything", "definition": "shuffle([random(0..1),random(0..1),random(0..2),2])", "group": "Ungrouped variables", "name": "c3"}, "kmap1": {"description": "Convert a 4-variable Boolean function from canonical (minterm) set to Karnaugh map matrix
\nmap(if((4*r+c) in canonicalsum,1,0),[r,c],product([0,1,3,2],[0,1,3,2]))
", "templateType": "anything", "definition": "map(if((4*r+c) in canonicalsum,1,0),[r,c],product([0,1,3,2],[0,1,3,2]))", "group": "Ungrouped variables", "name": "kmap1"}, "c2": {"description": "", "templateType": "anything", "definition": "shuffle([random(0..1),random(0..1),random(0..2),2])", "group": "Ungrouped variables", "name": "c2"}, "c": {"description": "", "templateType": "anything", "definition": "false", "group": "Ungrouped variables", "name": "c"}, "e": {"description": "", "templateType": "anything", "definition": "123", "group": "Ungrouped variables", "name": "e"}}, "type": "question"}, {"name": "Fei's copy of tidied copy of Karnaugh map test", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Graeme Chester", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/189/"}, {"name": "Fei Xia", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2603/"}], "tags": [], "metadata": {"description": "A Boolean algebra question which displays a Karnaugh map of a function which is the product of 3 minterms. The student is asked to identify the minterms from four possible choices, two of which are distractors.
", "licence": "All rights reserved"}, "statement": "The function shown on this map is $f=${join([join(cubetotext(cube1,labels2),\".\"),join(cubetotext(cube2,labels2),\".\"),join(cubetotext(cube3,labels2),\".\")],'+')}
", "rulesets": {}, "variables": {"cube2": {"name": "cube2", "group": "Ungrouped variables", "definition": "shuffle([random(0..1),random(0..1),random(0..2),2])", "description": "A random cube with 1 or 2 don't cares
", "templateType": "anything"}, "canonical1": {"name": "canonical1", "group": "Ungrouped variables", "definition": "f(cube1)", "description": "cube1 as a set of minterms
", "templateType": "anything"}, "notcube1": {"name": "notcube1", "group": "Ungrouped variables", "definition": "shuffle([random(0..1),random(0..1),random(0..2),2])", "description": "A random cube with 1 or 2 don't cares - a distractor
", "templateType": "anything"}, "canonical3": {"name": "canonical3", "group": "Ungrouped variables", "definition": "f(cube3)", "description": "cube3 as a set of minterms
", "templateType": "anything"}, "canonicalsum": {"name": "canonicalsum", "group": "Ungrouped variables", "definition": "canonical1 or canonical2 or canonical3", "description": "Sum of 3 product terms using canonical set form
", "templateType": "anything"}, "canonical2": {"name": "canonical2", "group": "Ungrouped variables", "definition": "f(cube2)", "description": "cube2 as a set of minterms
", "templateType": "anything"}, "cube3": {"name": "cube3", "group": "Ungrouped variables", "definition": "shuffle([random(0..1),random(0..1),random(0..2),2])", "description": "A random cube with 1 or 2 don't cares
", "templateType": "anything"}, "cube1": {"name": "cube1", "group": "Ungrouped variables", "definition": "shuffle([random(0..1),random(0..1),random(0..2),2])", "description": "A random cube with 1 or 2 don't cares
", "templateType": "anything"}, "truthtablesum": {"name": "truthtablesum", "group": "Ungrouped variables", "definition": "map(if(x in canonicalsum,1,0),x,0..15)", "description": "Used to enumerate the K-map entries
", "templateType": "anything"}, "notcube2": {"name": "notcube2", "group": "Ungrouped variables", "definition": "shuffle([random(0..1),random(0..1),random(0..2),2])", "description": "A random cube with 1 or 2 don't cares - a distractor
", "templateType": "anything"}, "labels2": {"name": "labels2", "group": "Ungrouped variables", "definition": "[ \"a\", \"b\", \"c\", \"d\" ]", "description": "Literals used in the Boolean expression
\n", "templateType": "list of strings"}}, "variablesTest": {"condition": "abs(list(f(cube1)-f(cube2)))>0 and\nabs(list(f(notcube1)-canonicalsum))>0 and\nabs(list(f(notcube2)-canonicalsum))>0 \n", "maxRuns": 100}, "ungrouped_variables": ["labels2", "cube1", "cube2", "cube3", "canonical1", "canonical2", "canonical3", "truthtablesum", "canonicalsum", "notcube1", "notcube2"], "variable_groups": [], "functions": {"drawcanvas": {"parameters": [["bits", "list"], ["literals", "list"]], "type": "html", "language": "javascript", "definition": "// draw a 4x4 Karnaugh map for a function given as a truth table\nfunction drawKmap(ctx,bits,literals)\n{\n\nctx.font = \"20px Arial\";ctx.textAlign=\"center\"; ctx.textBaseline=\"middle\";\n ctx.lineWidth=2;\n\n//ctx.fillText(n,10,50);\nctx.beginPath();\nctx.moveTo(20,20);\nctx.lineTo(60,60);\nctx.stroke();\n\nctx.fillText(literals[0]+\" \"+literals[1],15,50);\nctx.fillText(literals[2]+\" \"+literals[3],50,10);\ngraycode=[0,1,3,2];\ngraycodebin=[\"00\",\"01\",\"11\",\"10\"];\nfor (ncol=0;ncol<=3;ncol++) {\n\tctx.fillText(graycodebin[ncol],80+ncol*40,40);\n\t}\n\nfor (nrow=0;nrow<=3;nrow++) {\n\tctx.fillText(graycodebin[nrow],40,80+nrow*40);\n\tfor (ncol=0;ncol<=3;ncol++) {\n\t\tctx.rect(60+ncol*40,60+nrow*40,40,40);\n\t\tctx.stroke();\n\t\tbitval=bits[graycode[nrow]*4+graycode[ncol]].toString();\n\t\tctx.fillText(bitval,80+ncol*40,80+nrow*40);\n\t\t}\n\t}\n\n}\n\n function drawcanvas(ctx)\n {\nvar num = 15;\nvar n = num.toString();\nctx.font = \"20px Arial\";ctx.textAlign=\"center\"; ctx.textBaseline=\"middle\";\n\nctx.fillText(n,10,50);\n\n\nfor (nrow=0;nrow<=3;nrow++) {\n\tctx.fillText(\"00\",40,80+nrow*40);\n\tfor (ncol=0;ncol<=3;ncol++) {\n\t\tctx.rect(60+ncol*40,60+nrow*40,40,40);\n\t\tctx.stroke();\n\t\tbitval=bits[nrow*4+ncol].toString();\n\t\tctx.fillText(bitval,80+ncol*40,80+nrow*40);\n\t\t}\n\t}\n\nctx.rect(0,0,400,300);\nctx.stroke();\n \n \n\t}\n\n\nvar canv=document.createElement(\"canvas\");\ncanv.setAttribute(\"height\",\"250px\");\ncanv.setAttribute(\"width\",\"500px\");\nvar ctx = canv.getContext(\"2d\");\n\n//literals=[\"a\",\"b\",\"c\",\"d\"];\ndrawKmap(ctx,bits,literals);\n//drawcanvas(ctx)\nreturn canv;"}, "f": {"parameters": [["p", "list"]], "type": "set", "language": "jme", "definition": "// convert a cube to canonical set form using recursion\nif(abs(p)=1, //terminate on the last or only element of p\n if(p[abs(p)-1]=2, //a \"don't care\" so include both 1 and 0\n set(0,1),\n if(p[abs(p)-1]=1,\n set(1),\n set(0)\n )\n ),\n//else\n if(p[abs(p)-1]=2,\n set(map(x*2,x,f(p[0..abs(p)-1]))) or set(map(x*2+1,x,f(p[0..abs(p)-1]))),\n if(p[abs(p)-1]=1,\n set(map(x*2+1,x,f(p[0..abs(p)-1]))),\n set(map(x*2,x,f(p[0..abs(p)-1])))\n )\n )\n)"}, "cubetotext": {"parameters": [["cube", "list"], ["labels", "list"]], "type": "expression", "language": "jme", "definition": "// convert a cube to a formatted text string using recursion\nif(abs(cube)=0,\n [],\n switch(cube[0]=0,\n [\"$\\\\bar{\"+labels[0]+\"}$\"],\n cube[0]=1,\n [\"$\"+labels[0]+\"$\"],[]) + cubetotext(cube[1..abs(cube)],labels[1..abs(labels)]\n )\n)\n"}}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "m_n_2", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "Which of the following product terms are covered by $f$?
", "minMarks": 0, "maxMarks": 0, "shuffleChoices": true, "displayType": "checkbox", "displayColumns": 0, "minAnswers": 0, "maxAnswers": "0", "warningType": "none", "showCellAnswerState": true, "markingMethod": "sum ticked cells", "choices": ["{join(cubetotext(cube1,labels2),\".\")}
", "{join(cubetotext(cube2,labels2),\".\")}
", "{join(cubetotext(notcube1,labels2),\".\")}
", "{join(cubetotext(notcube2,labels2),\".\")}
"], "matrix": ["1", "1", "-1", "-1"], "distractors": ["{join(cubetotext(cube1,labels2),\".\")} is a valid term", "{join(cubetotext(cube2,labels2),\".\")} is a valid term", "{join(cubetotext(notcube1,labels2),\".\")} is not a valid term", "{join(cubetotext(notcube2,labels2),\".\")} is not a valid term"]}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "type": "question"}, {"name": "Fei's copy of Fanout 1", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Graeme Chester", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/189/"}, {"name": "Fei Xia", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2603/"}], "variables": {"k2": {"description": "", "templateType": "randrange", "definition": "random(1..4#1)", "name": "k2", "group": "Ungrouped variables"}, "ttot": {"description": "", "templateType": "anything", "definition": "L*tbuf", "name": "ttot", "group": "Ungrouped variables"}, "L": {"description": "", "templateType": "randrange", "definition": "random(3..5#1)", "name": "L", "group": "Ungrouped variables"}, "N": {"description": "", "templateType": "anything", "definition": "B^L", "name": "N", "group": "Ungrouped variables"}, "tbuf": {"description": "", "templateType": "anything", "definition": "k1+k2*B", "name": "tbuf", "group": "Ungrouped variables"}, "B": {"description": "", "templateType": "randrange", "definition": "random(2..5#1)", "name": "B", "group": "Ungrouped variables"}, "k1": {"description": "", "templateType": "randrange", "definition": "random(10..20#1)", "name": "k1", "group": "Ungrouped variables"}}, "statement": "A buffer tree is needed to drive the clock inputs of {N} latches from an external clock signal $CK$. Either the clock $CK$ or its inverse $\\overline{CK}$ can be used at the input. The external clock can drive only one gate input load.
\nEach inverter in the buffer tree has a delay of $t=\\simplify {{k1} + {k2}B} $ picoseconds where B is the branching ratio.
\nHow many levels are required in the buffer tree if a branching ratio of $\\var{B}$ is used?
", "scripts": {}, "type": "numberentry", "integerAnswer": true, "variableReplacementStrategy": "originalfirst", "minValue": "L", "integerPartialCredit": 0, "correctAnswerFraction": false, "marks": 1, "showCorrectAnswer": true, "variableReplacements": [], "allowFractions": false}, {"gaps": [{"showPrecisionHint": false, "scripts": {}, "maxValue": "ttot+0.5", "marks": 1, "variableReplacements": [], "showCorrectAnswer": true, "correctAnswerFraction": false, "type": "numberentry", "allowFractions": false, "variableReplacementStrategy": "originalfirst", "minValue": "ttot-0.5"}], "marks": 0, "prompt": "What is the delay between the external clock input and the clock input of a latch?
\n[[0]] picoseconds
", "showCorrectAnswer": true, "variableReplacements": [], "scripts": {}, "type": "gapfill", "variableReplacementStrategy": "originalfirst"}], "variable_groups": [], "functions": {}, "advice": "", "showQuestionGroupNames": false, "ungrouped_variables": ["B", "L", "N", "k1", "k2", "tbuf", "ttot"], "preamble": {"js": "", "css": ""}, "variablesTest": {"condition": "N>30", "maxRuns": "235"}}, {"name": "PLA minimisation 2017", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Graeme Chester", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/189/"}, {"name": "Fei Xia", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2603/"}], "statement": "A programmable logic array has to implement the following functions y0, y1 and y2:-
\ny0 = {cset2textshuffled((y0),labels)}
\ny1 = {cset2textshuffled((y1),labels)}
\ny2 = {cset2textshuffled((y2),labels)}
\nComplete the table below with 0 or 1 in each box to program the corresponding AND-plane and OR-plane links in the PLA.(Hint: minimisation must be performed before entering the values).
\ny0={join(cubetotext(c0,labels),'.')+'+'+join(cubetotext(cboth,labels),'.')} {y0}
\ny1={join(cubetotext(c1,labels),'.')+'+'+join(cubetotext(cboth2,labels),'.')} {y1}
\ny2={join(cubetotext(cboth,labels),'.')+'+'+join(cubetotext(cboth2,labels),'.')} {y2}
\nDevelopment versin for increasing size of PLA
", "licence": "All rights reserved"}, "advice": "The common terms {join(cubetotext(cboth,labels),'.')} and {join(cubetotext(cboth2,labels),'.')} can be used to reduce the functions:-
\ny0={join(cubetotext(c0,labels),'.')+'+'+join(cubetotext(cboth,labels),'.')}
\ny1={join(cubetotext(c1,labels),'.')+'+'+join(cubetotext(cboth2,labels),'.')}
\ny2={join(cubetotext(cboth,labels),'.')+'+'+join(cubetotext(cboth2,labels),'.')}
", "tags": [], "parts": [{"extendBaseMarkingAlgorithm": true, "allowFractions": false, "numColumns": "length(labels)*2+length(outlabels)", "marks": "9", "type": "matrix", "showFeedbackIcon": true, "prompt": "{userpla1(labels,outlabels,terms)}
\nProgramming table (note that the columns are in the order: AND plane, OR plane)
", "correctAnswerFractions": false, "variableReplacements": [], "correctAnswer": "ans", "showCorrectAnswer": true, "markPerCell": false, "scripts": {"validate": {"order": "instead", "script": "debugger;\n// Use the built-in validation function to catch syntax errors and so on\nif(!Numbas.parts.MatrixEntryPart.prototype.validate.apply(this)) {\n return false;\n}\nreturn true;"}, "mark": {"order": "instead", "script": "\t\t\t\t\tfunction PLA(andplanearray, orplanearray, innames, outnames) {\n\t\t\t\t\t\t//need to add some error checking for row/columnn counts etc.\n\t\t\t\t\t\t// andplanearray=array(npterms,innames*2)\n\t\t\t\t\t\t// orplanearray=array(npterms,outnames)\n\t\t\t\t\t\tthis.andplane = andplanearray;\n\t\t\t\t\t\tthis.orplane = orplanearray;\n\t\t\t\t\t\tthis.inlabels = innames;\n\t\t\t\t\t\tthis.outlabels = outnames;\n\n\t\t\t\t\t\tthis.npterms = function() {\n\t\t\t\t\t\t\treturn this.andplane.length;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tthis.ninputs = function() {\n\t\t\t\t\t\t\treturn this.inlabels.length;\n\t\t\t\t\t\t};\n\t\t\t\t\t\tthis.noutputs = function() {\n\t\t\t\t\t\t\treturn this.outlabels.length;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tthis.eval = function(invalues) {\n\t\t\t\t\t\t\tvar outvalues = new Array(this.noutputs());\n for (var ind = 0; ind < outvalues.length; ind++) {\n outvalues[ind] = 0;\n }\n //not supported in some browsers outvalues.fill(0, 0, this.noutputs());\n\t\t\t\t\t\t\tfor (var nrow = 0; nrow < this.npterms(); nrow++) {\n\t\t\t\t\t\t\t\tvar ptout = 1;\n\t\t\t\t\t\t\t\tfor (var ncol = 0; ncol < this.ninputs(); ncol++) {\n\t\t\t\t\t\t\t\t\tif ((this.andplane[nrow][2 * ncol] == 1) && (invalues[ncol] == 0) || (this.andplane[nrow][2 * ncol + 1] == 1) && (invalues[ncol] == 1)) {\n\t\t\t\t\t\t\t\t\t\tptout = 0;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfor (var ncol = 0; ncol < this.noutputs(); ncol++) {\n\t\t\t\t\t\t\t\t\tif ((this.orplane[nrow][ncol] == 1) && (ptout == 1)) {\n\t\t\t\t\t\t\t\t\t\toutvalues[ncol] = 1;\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn outvalues;\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\ndebugger;\nthis.answered=true;\nvar studentPLA = this.studentAnswer;\nvar studentandp = studentPLA.map(function(value,index) { return value.slice(0,8); });\nvar studentorp = studentPLA.map(function(value,index) { return value.slice(8,11); });\nconsole.log('andplane ', studentandp);\nconsole.log('orplane ', studentorp);\nthePLA=new PLA(studentandp,studentorp,['a','b','c','d'],['y0','y1','y2']);\n\n//andplane = [[1, 0, 1, 1], [1, 1, 1, 0], [0, 1, 0, 1]];\n//orplane = [[1, 0], [0, 1], [1, 1], ];\n//inlabels = [\"a\", \"b\"];\n//outlabels = [\"y0\", \"y1\"];\n//thePLA = new PLA(andplane, orplane, inlabels, outlabels);\n\n\nvar y0set=[]; var y1set=[]; var y2set=[];\nfor (var aval=0;aval<2;aval++){\n\tfor (var bval=0;bval<2;bval++){\n \tfor (var cval=0;cval<2;cval++){\n \tfor (var dval=0;dval<2;dval++){\n \t\t var k=8*aval+4*bval+2*cval+dval;\n\t \t var y=thePLA.eval([aval,bval,cval,dval]);\n\t\t if (y[0]==1) y0set.push(new Numbas.jme.types.TNum(k));\n\t\t if (y[1]==1) y1set.push(new Numbas.jme.types.TNum(k));\n\t\t if (y[2]==1) y2set.push(new Numbas.jme.types.TNum(k));\n }\n }\n\t}\n}\n\n//console.log('y0 ', y0set);\n//console.log('y1 ', y1set);\n//get the canonical set variables y0 y1\nvar variables = this.question.scope.variables;\nvar unwrap = Numbas.jme.unwrapValue;\nvar setmath = Numbas.setmath;\n\nvar y0ans=(unwrap(variables.y0));\nvar y1ans=unwrap((variables.y1));\nvar y2ans=unwrap((variables.y2));\nconsole.log('y0 ', y0set, y0ans);\nconsole.log('y1 ', y1set, y1ans);\nconsole.log('y2 ', y0set, y0ans);\n\n//compare the answers\nif (setmath.eq(y0set,y0ans)) { this.addCredit(1.0/3,'Output y0 is correct. ');}\nelse{this.addCredit(0,'Output y0 is incorrect. ');\n};\n\nif (setmath.eq(y1set,y1ans)) { this.addCredit(1.0/3,'Output y1 is correct. ');}\nelse{this.addCredit(0,'Output y1 is incorrect. ');\n};\n\nif (setmath.eq(y2set,y2ans)) { this.addCredit(1.0/3,'Output y2 is correct. ');}\nelse{this.addCredit(0,'Output y2 is incorrect. ');\n};\n"}}, "variableReplacementStrategy": "originalfirst", "tolerance": 0, "numRows": "terms", "customMarkingAlgorithm": "", "allowResize": false, "unitTests": []}], "variable_groups": [], "preamble": {"js": "", "css": ""}, "rulesets": {}, "ungrouped_variables": ["c1", "c0", "cboth", "cboth2", "labels", "y0", "y1", "y2", "displayc", "ans", "test", "outlabels", "terms"], "variablesTest": {"condition": "//abs(list(f(c1)-f(cboth)))>0 and abs(list(f(cboth)-f(c1)))>0 and\n//abs(list(f(cboth)-f(c0)))>0 and abs(list(f(c0)-f(cboth)))>0 and\n//abs(list(f(c0)-f(c1)))>0 and abs(list(f(c1)-f(c0)))>0 and\n//cubedist(cboth,c0)>1 and cubedist(cboth,c1)>1\n\nabs(list(f(c1)-union(union(f(c0),f(cboth)),f(cboth2))))>0 and //no redundant or duplicate terms\nabs(list(f(c0)-union(union(f(c1),f(cboth)),f(cboth2))))>0 and \nabs(list(f(cboth)-union(union(f(c0),f(c1)),f(cboth2))))>0 and \nabs(list(f(cboth2)-union(union(f(c0),f(cboth)),f(c1))))>0 and \nabs(list((f(c1)-union(f(cboth),f(cboth2))) and (f(c0)-union(f(cboth),f(cboth2)))))=0 and //no common terms except cboth,cboth2\ncubedist(cboth2,cboth)>1 //common terms are prime", "maxRuns": "40"}, "variables": {"y2": {"name": "y2", "definition": "union(f(cboth),f(cboth2))", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "cboth2": {"name": "cboth2", "definition": "shuffle([random(0..1),random(0..1),random(0..1),2])", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "c1": {"name": "c1", "definition": "shuffle([random(0..1),random(0..1),random(0..1),random(0..2)])", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "outlabels": {"name": "outlabels", "definition": "[ safe(\"y0\"), safe(\"y1\"), safe(\"y2\") ]", "group": "Ungrouped variables", "description": "", "templateType": "list of strings"}, "terms": {"name": "terms", "definition": "4", "group": "Ungrouped variables", "description": "", "templateType": "number"}, "test": {"name": "test", "definition": "matrix(reduce([[1,2],[2,3]]))", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "labels": {"name": "labels", "definition": "[ safe(\"a\"), safe(\"b\"), safe(\"c\"), safe(\"d\") ]", "group": "Ungrouped variables", "description": "", "templateType": "list of strings"}, "ans": {"name": "ans", "definition": "matrix(\n reduce(map(switch(x=0,[0,1],x=1,[1,0],[0,0]),x,c0) +[1,0,0] ),\n reduce(map(switch(x=0,[0,1],x=1,[1,0],[0,0]),x,c1) +[0,1,0] ),\n reduce(map(switch(x=0,[0,1],x=1,[1,0],[0,0]),x,cboth) +[1,0,1] ), \n reduce(map(switch(x=0,[0,1],x=1,[1,0],[0,0]),x,cboth2)+[0,1,1] )\n)", "group": "Ungrouped variables", "description": "map(if(x==2,0,1),x,c0)+[0,0],c1+[0,0],cboth+[1,1])matrix(
", "templateType": "anything"}, "y0": {"name": "y0", "definition": "union(f(c0),f(cboth))\n", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "y1": {"name": "y1", "definition": "union(f(c1),f(cboth2))", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "displayc": {"name": "displayc", "definition": "matrix(c0,c1,cboth)", "group": "Ungrouped variables", "description": "Used to display lists in editor here, not used at run time
", "templateType": "anything"}, "c0": {"name": "c0", "definition": "shuffle([random(0..1),random(0..1),random(0..1),2])", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "cboth": {"name": "cboth", "definition": "shuffle([random(0..1),random(0..1),random(0..1),2])", "group": "Ungrouped variables", "description": "", "templateType": "anything"}}, "type": "question"}]}], "allowPrinting": true, "navigation": {"allowregen": false, "reverse": true, "browse": true, "allowsteps": true, "showfrontpage": true, "showresultspage": "oncompletion", "navigatemode": "sequence", "onleave": {"action": "none", "message": ""}, "preventleave": true, "startpassword": ""}, "timing": {"allowPause": false, "timeout": {"action": "warn", "message": "Timeout
"}, "timedwarning": {"action": "warn", "message": "Only 5 minutes left!
"}}, "feedback": {"showactualmark": false, "showtotalmark": true, "showanswerstate": false, "allowrevealanswer": false, "advicethreshold": 0, "intro": "", "reviewshowscore": true, "reviewshowfeedback": true, "reviewshowexpectedanswer": true, "reviewshowadvice": true, "feedbackmessages": [], "enterreviewmodeimmediately": true, "showexpectedanswerswhen": "inreview", "showpartfeedbackmessageswhen": "oncompletion", "showactualmarkwhen": "oncompletion", "showtotalmarkwhen": "always", "showanswerstatewhen": "oncompletion", "showadvicewhen": "inreview"}, "type": "exam", "contributors": [{"name": "Graeme Chester", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/189/"}, {"name": "Fei Xia", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2603/"}], "extensions": [], "custom_part_types": [], "resources": []}