dsh-digital-logic-lectern 0.6.3 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +31 -30
- package/README.md +55 -56
- package/_selftest.mjs +1 -1
- package/package.json +2 -2
- package/skills/digital-logic-lectern/SKILL.md +24 -56
- package/skills/digital-logic-lectern/references/m1_number_code.md +1 -1
- package/skills/digital-logic-lectern/references/m2_boolean_algebra.md +1 -1
- package/skills/digital-logic-lectern/references/m3_combinational.md +1 -1
- package/skills/digital-logic-lectern/references/m4_sequential.md +1 -1
- package/skills/digital-logic-lectern/references/m5_memory.md +1 -1
- package/skills/digital-logic-lectern/references/m6_pld_fpga.md +1 -1
- package/skills/digital-logic-lectern/references/m7_controller.md +1 -1
- package/skills/digital-logic-lectern/references/m8_verilog.md +1 -1
- package/skills/digital-logic-lectern/references/textbook_map.md +1 -1
- package/skills/digital-logic-lectern/scripts/dlquiz.js +451 -5
- package/skills/digital-logic-lectern/ui/book.js +1 -1
- package/skills/digital-logic-lectern/ui/index.html +1 -1
- package/skills/digital-logic-lectern/ui/questions.js +1025 -305
- package/skills/digital-logic-lectern/examples/demo_draft.md +0 -41
- package/skills/digital-logic-lectern/examples/demo_draft_bad.md +0 -24
- package/skills/digital-logic-lectern/examples/evidence.txt +0 -13
- package/skills/digital-logic-lectern/scripts/dlcheck.js +0 -145
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* dlquiz —— 从确定性计算生成答题题库,供 ui/index.html 使用(零依赖)
|
|
4
4
|
*
|
|
5
5
|
* 用法:
|
|
6
|
-
* node dlquiz.js --build 生成 ui/questions.js(默认
|
|
6
|
+
* node dlquiz.js --build 生成 ui/questions.js(默认 80 题)
|
|
7
7
|
* node dlquiz.js --build --count 20
|
|
8
8
|
* node dlquiz.js --check 用 dltool 逐题复核计算类答案
|
|
9
9
|
*/
|
|
@@ -354,6 +354,31 @@ function questionHamming(random) {
|
|
|
354
354
|
};
|
|
355
355
|
}
|
|
356
356
|
|
|
357
|
+
function questionHammingCheck(random) {
|
|
358
|
+
const data = random.int(0, 15);
|
|
359
|
+
const bits = bitsOf(data, 4);
|
|
360
|
+
const [d1, d2, d3, d4] = bits.split("").map(Number);
|
|
361
|
+
const p1 = d1 ^ d2 ^ d4;
|
|
362
|
+
const p2 = d1 ^ d3 ^ d4;
|
|
363
|
+
const p4 = d2 ^ d3 ^ d4;
|
|
364
|
+
const code = `${p1}${p2}${d1}${p4}${d2}${d3}${d4}`;
|
|
365
|
+
const position = random.int(1, 7);
|
|
366
|
+
const index = position - 1;
|
|
367
|
+
const received = `${code.slice(0, index)}${code[index] === "1" ? "0" : "1"}${code.slice(index + 1)}`;
|
|
368
|
+
const others = [1, 2, 3, 4, 5, 6, 7].filter((item) => item !== position);
|
|
369
|
+
const { options, answer } = buildOptions(String(position), others.map(String), random);
|
|
370
|
+
return {
|
|
371
|
+
module: "M1",
|
|
372
|
+
type: "hamming",
|
|
373
|
+
difficulty: 3,
|
|
374
|
+
stem: `接收到的 7 位海明码是 ${received}(偶校验,(7,4) 码),按综合症判断,第几位出错?`,
|
|
375
|
+
options,
|
|
376
|
+
answer,
|
|
377
|
+
explain: `对 p1、p2、p4 三组分别求偶校验,综合症 S4S2S1 的十进制值就是出错位号 ${position};把该位取反即可纠正。`,
|
|
378
|
+
verify: { args: ["hamming", "--check", received], field: "position" },
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
|
|
357
382
|
/* ---------- 概念类题目 ---------- */
|
|
358
383
|
|
|
359
384
|
const CONCEPTS = [
|
|
@@ -497,6 +522,419 @@ const CONCEPTS = [
|
|
|
497
522
|
wrong: ["时序逻辑,每个时钟沿更新", "初始化赋值,只执行一次", "模块端口声明"],
|
|
498
523
|
explain: "assign 是连续赋值,等价于一根线加一个门,没有时钟概念。",
|
|
499
524
|
},
|
|
525
|
+
{
|
|
526
|
+
module: "M1", difficulty: 1,
|
|
527
|
+
stem: "十六进制 2F 换成十进制是多少?",
|
|
528
|
+
correct: "47",
|
|
529
|
+
wrong: ["45", "51", "2F"],
|
|
530
|
+
explain: "2×16+15=47。十六进制中 F 代表 15。",
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
module: "M1", difficulty: 2,
|
|
534
|
+
stem: "八进制数 573.7 的十六进制写法是?",
|
|
535
|
+
correct: "(17B.E)₁₆",
|
|
536
|
+
wrong: ["(17C.7)₁₆", "(17B.7)₁₆", "(17C.E)₁₆"],
|
|
537
|
+
explain: "先化成十进制 379.875,整数部分 379=0x17B,小数 0.875=0xE。",
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
module: "M1", difficulty: 1,
|
|
541
|
+
stem: "8421BCD 码 1001 0110 表示十进制几?",
|
|
542
|
+
correct: "96",
|
|
543
|
+
wrong: ["69", "156", "10010110"],
|
|
544
|
+
explain: "每四位一组:1001 是 9,0110 是 6,按高低位拼成 96。",
|
|
545
|
+
},
|
|
546
|
+
{
|
|
547
|
+
module: "M1", difficulty: 2,
|
|
548
|
+
stem: "余 3 码 0101 表示十进制数字几?",
|
|
549
|
+
correct: "2",
|
|
550
|
+
wrong: ["5", "8", "12"],
|
|
551
|
+
explain: "余 3 码等于 8421 码加 3:0101 按 8421 读是 5,减 3 得 2。",
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
module: "M1", difficulty: 2,
|
|
555
|
+
stem: "数据 1011 采用奇校验,校验位应取什么?",
|
|
556
|
+
correct: "0",
|
|
557
|
+
wrong: ["1", "无法确定", "与偶校验相同"],
|
|
558
|
+
explain: "1011 里已有三个 1,是奇数;校验位取 0 后 1 的个数仍为奇数。",
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
module: "M1", difficulty: 1,
|
|
562
|
+
stem: "8 位补码 11111111 表示十进制几?",
|
|
563
|
+
correct: "−1",
|
|
564
|
+
wrong: ["−0", "255", "−127"],
|
|
565
|
+
explain: "补码全 1 按位取反加一得 1,符号为负,所以是 −1。",
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
module: "M1", difficulty: 2,
|
|
569
|
+
stem: "十进制 −5 的 8 位反码是哪一个?",
|
|
570
|
+
correct: "11111010",
|
|
571
|
+
wrong: ["11111011", "10000101", "00000101"],
|
|
572
|
+
explain: "先写 +5 的 00000101,逐位取反得反码 11111010;再加一才是补码。",
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
module: "M1", difficulty: 2,
|
|
576
|
+
stem: "2421 码 1111 表示十进制数字几?",
|
|
577
|
+
correct: "9",
|
|
578
|
+
wrong: ["15", "6", "7"],
|
|
579
|
+
explain: "2421 码按 2、4、2、1 加权:2+4+2+1=9。",
|
|
580
|
+
},
|
|
581
|
+
{
|
|
582
|
+
module: "M1", difficulty: 3,
|
|
583
|
+
stem: "格雷码 0101 对应的二进制数是什么?",
|
|
584
|
+
correct: "0110",
|
|
585
|
+
wrong: ["0100", "1100", "1010"],
|
|
586
|
+
explain: "最高位照抄得 0,其后每位等于上一位二进制结果与本位格雷码异或,得 0110。",
|
|
587
|
+
},
|
|
588
|
+
{
|
|
589
|
+
module: "M1", difficulty: 2,
|
|
590
|
+
stem: "8 位补码能表示的整数范围是?",
|
|
591
|
+
correct: "−128 到 127",
|
|
592
|
+
wrong: ["−127 到 127", "0 到 255", "−128 到 128"],
|
|
593
|
+
explain: "n 位补码范围是 −2ⁿ⁻¹ 到 2ⁿ⁻¹−1;负数比正数多一个。",
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
module: "M2", difficulty: 2,
|
|
597
|
+
stem: "逻辑函数 F=A+A′B 化简后等于?",
|
|
598
|
+
correct: "A+B",
|
|
599
|
+
wrong: ["A", "B", "AB"],
|
|
600
|
+
explain: "A+A′B=(A+A′)(A+B)=A+B,用的是吸收律和分配律。",
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
module: "M2", difficulty: 2,
|
|
604
|
+
stem: "三变量 A、B、C 的最小项 m5 对应哪组输入?",
|
|
605
|
+
correct: "101",
|
|
606
|
+
wrong: ["011", "110", "010"],
|
|
607
|
+
explain: "5 的二进制是 101,按 A B C 顺序读,即 A=1、B=0、C=1。",
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
module: "M2", difficulty: 2,
|
|
611
|
+
stem: "卡诺图中四个相邻的 1 圈在一起,能消去几个变量?",
|
|
612
|
+
correct: "2 个",
|
|
613
|
+
wrong: ["1 个", "3 个", "4 个"],
|
|
614
|
+
explain: "2 个相邻消 1 个变量,4 个消 2 个,8 个消 3 个。",
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
module: "M2", difficulty: 1,
|
|
618
|
+
stem: "三变量卡诺图一共有多少个格子?",
|
|
619
|
+
correct: "8 个",
|
|
620
|
+
wrong: ["4 个", "6 个", "16 个"],
|
|
621
|
+
explain: "n 变量卡诺图有 2ⁿ 格,三变量是 8 格。",
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
module: "M2", difficulty: 3,
|
|
625
|
+
stem: "F=AB+C 的反函数 F′ 是?",
|
|
626
|
+
correct: "(A′+B′)·C′",
|
|
627
|
+
wrong: ["A′B′+C′", "(A+B)·C", "A′B′C′"],
|
|
628
|
+
explain: "对整个式子用德摩根定律:先变或为与,再逐项取反,得 (A′+B′)·C′。",
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
module: "M2", difficulty: 3,
|
|
632
|
+
stem: "F=AB+C 的对偶式是?",
|
|
633
|
+
correct: "(A+B)·C",
|
|
634
|
+
wrong: ["A′B′+C′", "AB+C", "(A+B)+C"],
|
|
635
|
+
explain: "对偶式把与换成或、或换成与,0 和 1 互换,变量保持不变。",
|
|
636
|
+
},
|
|
637
|
+
{
|
|
638
|
+
module: "M2", difficulty: 2,
|
|
639
|
+
stem: "关于最小项,下面哪个说法正确?",
|
|
640
|
+
correct: "任意两个不同最小项之积恒为 0",
|
|
641
|
+
wrong: ["任意两个最小项之和恒为 1", "最小项之间互为反函数", "最小项的变量可以重复"],
|
|
642
|
+
explain: "每个最小项只在一种输入组合下为 1,所以不同最小项不可能同时为 1。",
|
|
643
|
+
},
|
|
644
|
+
{
|
|
645
|
+
module: "M2", difficulty: 3,
|
|
646
|
+
stem: "卡诺图化简时,无关项的取值原则是?",
|
|
647
|
+
correct: "按需取 0 或 1,能让圈更大就用",
|
|
648
|
+
wrong: ["一律取 0", "一律取 1", "必须成对出现才能用"],
|
|
649
|
+
explain: "无关项对应不会出现的输入,取 0 或 1 都不影响功能;化简时只为合并服务。",
|
|
650
|
+
},
|
|
651
|
+
{
|
|
652
|
+
module: "M2", difficulty: 2,
|
|
653
|
+
stem: "判断两个逻辑函数是否相等,最可靠的方法是?",
|
|
654
|
+
correct: "列出真值表逐行比较",
|
|
655
|
+
wrong: ["看表达式长得是否一样", "看变量个数是否相同", "看卡诺图圈数是否相同"],
|
|
656
|
+
explain: "表达式形式可以不同而功能相同;真值表相同才是函数相等的定义。",
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
module: "M3", difficulty: 1,
|
|
660
|
+
stem: "半加器的进位输出 C 等于?",
|
|
661
|
+
correct: "AB",
|
|
662
|
+
wrong: ["A+B", "A⊕B", "AB′"],
|
|
663
|
+
explain: "只有 A、B 同时为 1 才进位,所以 C=AB;本位和是 A⊕B。",
|
|
664
|
+
},
|
|
665
|
+
{
|
|
666
|
+
module: "M3", difficulty: 2,
|
|
667
|
+
stem: "全加器的本位和 S 等于?",
|
|
668
|
+
correct: "A⊕B⊕Cin",
|
|
669
|
+
wrong: ["A+B+Cin", "AB+Cin", "A⊕B"],
|
|
670
|
+
explain: "三个输入中 1 的个数为奇数时本位为 1,即三次异或。",
|
|
671
|
+
},
|
|
672
|
+
{
|
|
673
|
+
module: "M3", difficulty: 2,
|
|
674
|
+
stem: "八选一数据选择器需要几根地址线?",
|
|
675
|
+
correct: "3 根",
|
|
676
|
+
wrong: ["2 根", "4 根", "8 根"],
|
|
677
|
+
explain: "8=2³,3 根地址线正好选中 8 路数据中的一路。",
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
module: "M3", difficulty: 1,
|
|
681
|
+
stem: "8 线−3 线编码器的输出端有几根?",
|
|
682
|
+
correct: "3 根",
|
|
683
|
+
wrong: ["8 根", "2 根", "4 根"],
|
|
684
|
+
explain: "8 个输入用 3 位二进制编号即可区分,所以输出 3 根。",
|
|
685
|
+
},
|
|
686
|
+
{
|
|
687
|
+
module: "M3", difficulty: 3,
|
|
688
|
+
stem: "组合逻辑中消除静态冒险的常用方法是?",
|
|
689
|
+
correct: "增加冗余项,把相邻的圈搭接起来",
|
|
690
|
+
wrong: ["提高时钟频率", "把所有门换成与非门", "减少输入变量个数"],
|
|
691
|
+
explain: "冒险来自不同路径的延迟差;补一个冗余项可让两条路径互相覆盖。",
|
|
692
|
+
},
|
|
693
|
+
{
|
|
694
|
+
module: "M3", difficulty: 2,
|
|
695
|
+
stem: "74LS138 译码器有几个输出端?",
|
|
696
|
+
correct: "8 个",
|
|
697
|
+
wrong: ["3 个", "4 个", "16 个"],
|
|
698
|
+
explain: "138 是 3 线−8 线译码器,3 根地址输入对应 8 个低有效输出。",
|
|
699
|
+
},
|
|
700
|
+
{
|
|
701
|
+
module: "M3", difficulty: 3,
|
|
702
|
+
stem: "用数据选择器实现任意组合函数,依据是什么?",
|
|
703
|
+
correct: "把真值表的输出值接到对应数据端",
|
|
704
|
+
wrong: ["内部有触发器可以存储结果", "地址端可以编程", "输出端能自动化简"],
|
|
705
|
+
explain: "地址端接变量,数据端接 0 或 1,选择器就按真值表逐行输出。",
|
|
706
|
+
},
|
|
707
|
+
{
|
|
708
|
+
module: "M3", difficulty: 3,
|
|
709
|
+
stem: "把 3 线−8 线译码器改作数据分配器,数据应从哪个引脚输入?",
|
|
710
|
+
correct: "使能端",
|
|
711
|
+
wrong: ["地址端", "输出端", "电源端"],
|
|
712
|
+
explain: "地址端选通道,把数据加到使能端,被选中的那一路输出就随数据变化。",
|
|
713
|
+
},
|
|
714
|
+
{
|
|
715
|
+
module: "M4", difficulty: 2,
|
|
716
|
+
stem: "D 触发器的特性方程是?",
|
|
717
|
+
correct: "Q*=D",
|
|
718
|
+
wrong: ["Q*=JQ′+K′Q", "Q*=T⊕Q", "Q*=D′"],
|
|
719
|
+
explain: "D 触发器在时钟沿把输入端 D 的值送到输出,次态等于 D。",
|
|
720
|
+
},
|
|
721
|
+
{
|
|
722
|
+
module: "M4", difficulty: 2,
|
|
723
|
+
stem: "JK 触发器在 J=K=1 时,次态会怎样?",
|
|
724
|
+
correct: "翻转",
|
|
725
|
+
wrong: ["保持", "置 0", "置 1"],
|
|
726
|
+
explain: "J=K=1 是计数状态,每个时钟沿输出取反。",
|
|
727
|
+
},
|
|
728
|
+
{
|
|
729
|
+
module: "M4", difficulty: 2,
|
|
730
|
+
stem: "同步计数器与异步计数器的主要区别是?",
|
|
731
|
+
correct: "各级触发器是否由同一个时钟同时触发",
|
|
732
|
+
wrong: ["模值大小不同", "能否可逆计数", "有没有进位输出"],
|
|
733
|
+
explain: "同步计数器所有触发器共用时钟;异步计数器把前级输出当时钟,逐级翻转。",
|
|
734
|
+
},
|
|
735
|
+
{
|
|
736
|
+
module: "M4", difficulty: 1,
|
|
737
|
+
stem: "4 位二进制计数器的模是多少?",
|
|
738
|
+
correct: "16",
|
|
739
|
+
wrong: ["8", "15", "10"],
|
|
740
|
+
explain: "4 位可表示 0000 到 1111 共 16 个状态,计满 16 个脉冲回绕。",
|
|
741
|
+
},
|
|
742
|
+
{
|
|
743
|
+
module: "M4", difficulty: 2,
|
|
744
|
+
stem: "4 位串入串出移位寄存器,把 4 位数据全部移入需要几个时钟?",
|
|
745
|
+
correct: "4 个",
|
|
746
|
+
wrong: ["1 个", "3 个", "8 个"],
|
|
747
|
+
explain: "每个时钟移入一位,4 位就要 4 个时钟;再移出同样需要 4 个。",
|
|
748
|
+
},
|
|
749
|
+
{
|
|
750
|
+
module: "M4", difficulty: 2,
|
|
751
|
+
stem: "时序逻辑电路的输出取决于什么?",
|
|
752
|
+
correct: "当前输入和电路原来的状态",
|
|
753
|
+
wrong: ["只取决于当前输入", "只取决于原来的状态", "只取决于时钟频率"],
|
|
754
|
+
explain: "时序逻辑有记忆,输出由输入与现态共同决定,这也是它有别于组合逻辑的地方。",
|
|
755
|
+
},
|
|
756
|
+
{
|
|
757
|
+
module: "M4", difficulty: 3,
|
|
758
|
+
stem: "主从 JK 触发器在 CP=1 期间输出会怎样?",
|
|
759
|
+
correct: "保持不变,到 CP 下降沿才更新",
|
|
760
|
+
wrong: ["随 J、K 立即变化", "每半个周期翻转一次", "进入不定状态"],
|
|
761
|
+
explain: "CP=1 时主触发器接收、从触发器封锁;下降沿从触发器才接收主触发器的结果。",
|
|
762
|
+
},
|
|
763
|
+
{
|
|
764
|
+
module: "M4", difficulty: 3,
|
|
765
|
+
stem: "设计同步时序电路时,第一步通常做什么?",
|
|
766
|
+
correct: "根据功能要求画出原始状态图或状态表",
|
|
767
|
+
wrong: ["先画电路图", "先列出全部真值表", "先选定触发器型号"],
|
|
768
|
+
explain: "先把功能变成状态与转移关系,再谈状态化简、编码和触发器选型。",
|
|
769
|
+
},
|
|
770
|
+
{
|
|
771
|
+
module: "M5", difficulty: 2,
|
|
772
|
+
stem: "DRAM 需要定期刷新的原因是?",
|
|
773
|
+
correct: "靠电容存电荷,电荷会泄漏",
|
|
774
|
+
wrong: ["读写速度太快", "存储容量太小", "掉电后数据会丢失"],
|
|
775
|
+
explain: "DRAM 单元是一个电容加一个管子,电荷会漏掉,所以必须周期性刷新。",
|
|
776
|
+
},
|
|
777
|
+
{
|
|
778
|
+
module: "M5", difficulty: 2,
|
|
779
|
+
stem: "SRAM 的存储单元本质上是什么?",
|
|
780
|
+
correct: "双稳态触发器",
|
|
781
|
+
wrong: ["一个电容", "一根熔丝", "一个浮栅管"],
|
|
782
|
+
explain: "SRAM 用六个管子构成双稳态,只要供电就保持,不需要刷新。",
|
|
783
|
+
},
|
|
784
|
+
{
|
|
785
|
+
module: "M5", difficulty: 2,
|
|
786
|
+
stem: "1K×8 的存储器需要几根地址线?",
|
|
787
|
+
correct: "10 根",
|
|
788
|
+
wrong: ["8 根", "11 根", "16 根"],
|
|
789
|
+
explain: "1K=2¹⁰,地址线 10 根;8 是数据位宽,不参与地址。",
|
|
790
|
+
},
|
|
791
|
+
{
|
|
792
|
+
module: "M5", difficulty: 2,
|
|
793
|
+
stem: "用 1K×4 的芯片组成 1K×8 的存储器,需要几片?",
|
|
794
|
+
correct: "2 片",
|
|
795
|
+
wrong: ["4 片", "8 片", "1 片"],
|
|
796
|
+
explain: "字数不变、位宽翻倍,属于位扩展,两片并排共用地址即可。",
|
|
797
|
+
},
|
|
798
|
+
{
|
|
799
|
+
module: "M5", difficulty: 1,
|
|
800
|
+
stem: "ROM 在掉电后数据会怎样?",
|
|
801
|
+
correct: "保持不变",
|
|
802
|
+
wrong: ["全部丢失", "变成全 1", "需要重新刷新"],
|
|
803
|
+
explain: "ROM 是非易失性存储器,断电后内容仍在;RAM 才需要持续供电。",
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
module: "M5", difficulty: 2,
|
|
807
|
+
stem: "存储器地址译码器的作用是?",
|
|
808
|
+
correct: "根据高位地址选中对应的芯片或存储单元",
|
|
809
|
+
wrong: ["放大地址信号", "保存写入的数据", "产生读写时钟"],
|
|
810
|
+
explain: "地址译码把地址空间划分开,避免多片存储器同时被选中。",
|
|
811
|
+
},
|
|
812
|
+
{
|
|
813
|
+
module: "M6", difficulty: 3,
|
|
814
|
+
stem: "4 输入 LUT 需要多少位配置数据?",
|
|
815
|
+
correct: "16 位",
|
|
816
|
+
wrong: ["4 位", "8 位", "32 位"],
|
|
817
|
+
explain: "4 个输入有 16 种组合,每种组合对应一位输出值,所以是 16 位。",
|
|
818
|
+
},
|
|
819
|
+
{
|
|
820
|
+
module: "M6", difficulty: 3,
|
|
821
|
+
stem: "PAL 器件的阵列结构是?",
|
|
822
|
+
correct: "与阵列可编程,或阵列固定",
|
|
823
|
+
wrong: ["与、或阵列都可编程", "与阵列固定,或阵列可编程", "两个阵列都固定"],
|
|
824
|
+
explain: "PAL 用可编程与阵列产生乘积项,或阵列出厂已连好;PLA 才是两者都可编程。",
|
|
825
|
+
},
|
|
826
|
+
{
|
|
827
|
+
module: "M6", difficulty: 2,
|
|
828
|
+
stem: "基于 SRAM 工艺的 FPGA 掉电后配置会怎样?",
|
|
829
|
+
correct: "丢失,上电需要重新加载",
|
|
830
|
+
wrong: ["保留,随时可用", "变成只读", "自动恢复出厂设置"],
|
|
831
|
+
explain: "SRAM 掉电即失,比特流通常存在外部 Flash,上电时再装入 FPGA。",
|
|
832
|
+
},
|
|
833
|
+
{
|
|
834
|
+
module: "M6", difficulty: 3,
|
|
835
|
+
stem: "CPLD 的基本结构通常由什么组成?",
|
|
836
|
+
correct: "可编程与或阵列加宏单元",
|
|
837
|
+
wrong: ["LUT 加触发器", "只有分立门电路", "微程序控制存储器"],
|
|
838
|
+
explain: "CPLD 沿用 PAL 的与或阵列,再配宏单元和互连,适合组合逻辑与简单时序。",
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
module: "M6", difficulty: 3,
|
|
842
|
+
stem: "GAL 器件的输出逻辑宏单元主要作用是什么?",
|
|
843
|
+
correct: "配置输出极性、寄存器和三态方式",
|
|
844
|
+
wrong: ["放大输出电流", "存储用户程序", "产生系统时钟"],
|
|
845
|
+
explain: "宏单元让同一器件可以按需配成组合输出、寄存输出或双向口。",
|
|
846
|
+
},
|
|
847
|
+
{
|
|
848
|
+
module: "M7", difficulty: 3,
|
|
849
|
+
stem: "ASM 图中的状态框表示什么?",
|
|
850
|
+
correct: "一个时钟周期内保持的状态及该状态的输出",
|
|
851
|
+
wrong: ["一个组合逻辑门", "一条微指令", "一个输入变量"],
|
|
852
|
+
explain: "状态框对应现态,框内写输出;框之间用判断框按条件分支。",
|
|
853
|
+
},
|
|
854
|
+
{
|
|
855
|
+
module: "M7", difficulty: 2,
|
|
856
|
+
stem: "微程序控制器的控制信号来自哪里?",
|
|
857
|
+
correct: "控制存储器中的微指令",
|
|
858
|
+
wrong: ["用户程序的内存", "组合逻辑门的直接输出", "数据总线"],
|
|
859
|
+
explain: "每条微指令的各个字段直接控制门电路,属于硬件的一部分。",
|
|
860
|
+
},
|
|
861
|
+
{
|
|
862
|
+
module: "M7", difficulty: 2,
|
|
863
|
+
stem: "硬布线控制器的主要特点是?",
|
|
864
|
+
correct: "速度快,但修改控制逻辑困难",
|
|
865
|
+
wrong: ["速度慢,但容易修改", "速度与微程序控制器完全相同", "不需要时钟信号"],
|
|
866
|
+
explain: "控制信号由组合逻辑直接产生,路径短所以快;要改功能就得改电路。",
|
|
867
|
+
},
|
|
868
|
+
{
|
|
869
|
+
module: "M7", difficulty: 2,
|
|
870
|
+
stem: "数据通路主要完成什么任务?",
|
|
871
|
+
correct: "在各部件之间传送数据并完成运算",
|
|
872
|
+
wrong: ["产生全部控制信号", "存储微程序", "对指令地址进行译码"],
|
|
873
|
+
explain: "数据通路管数据怎么走、在哪算;控制信号由控制器给出。",
|
|
874
|
+
},
|
|
875
|
+
{
|
|
876
|
+
module: "M7", difficulty: 3,
|
|
877
|
+
stem: "微指令中的下地址字段作用是什么?",
|
|
878
|
+
correct: "指出下一条微指令的地址",
|
|
879
|
+
wrong: ["指出操作数地址", "指出主存地址", "指出 I/O 端口号"],
|
|
880
|
+
explain: "微程序按微指令顺序执行,下地址字段决定下一步跳到哪里。",
|
|
881
|
+
},
|
|
882
|
+
{
|
|
883
|
+
module: "M8", difficulty: 2,
|
|
884
|
+
stem: "Verilog 中 reg 与 wire 的主要区别是?",
|
|
885
|
+
correct: "reg 可在 always 中赋值并保持,wire 需要连续赋值",
|
|
886
|
+
wrong: ["reg 一定综合成寄存器", "wire 能存多位而 reg 只能存一位", "两者完全等价"],
|
|
887
|
+
explain: "reg 只是过程赋值的目标,是否综合成触发器取决于写法;wire 表示连线般的连续驱动。",
|
|
888
|
+
},
|
|
889
|
+
{
|
|
890
|
+
module: "M8", difficulty: 2,
|
|
891
|
+
stem: "描述组合逻辑的 always 块里应使用哪种赋值?",
|
|
892
|
+
correct: "阻塞赋值 =",
|
|
893
|
+
wrong: ["非阻塞赋值 <=", "两种混用", "只能用 assign"],
|
|
894
|
+
explain: "组合逻辑要求按书写顺序立即得到结果,阻塞赋值符合这一语义。",
|
|
895
|
+
},
|
|
896
|
+
{
|
|
897
|
+
module: "M8", difficulty: 2,
|
|
898
|
+
stem: "always @(*) 的敏感列表等价于什么?",
|
|
899
|
+
correct: "块内读取到的所有信号",
|
|
900
|
+
wrong: ["只有时钟信号", "只有输出信号", "工程里的全部信号"],
|
|
901
|
+
explain: "@(*) 由工具自动补全敏感列表,避免漏写信号导致仿真与综合不一致。",
|
|
902
|
+
},
|
|
903
|
+
{
|
|
904
|
+
module: "M8", difficulty: 2,
|
|
905
|
+
stem: "位拼接 {2'b10, 2'b01} 的结果是?",
|
|
906
|
+
correct: "4'b1001",
|
|
907
|
+
wrong: ["4'b1010", "2'b11", "4'b0101"],
|
|
908
|
+
explain: "拼接按书写顺序左高右低,10 在前、01 在后,得到 1001。",
|
|
909
|
+
},
|
|
910
|
+
{
|
|
911
|
+
module: "M8", difficulty: 2,
|
|
912
|
+
stem: "testbench 中产生周期性时钟的常见写法是?",
|
|
913
|
+
correct: "initial 置初值,再用 always #5 clk=~clk",
|
|
914
|
+
wrong: ["assign clk=~clk", "initial clk=~clk 单独一行", "always @(clk) clk=~clk"],
|
|
915
|
+
explain: "always 加延时反复取反才能持续翻转;assign 自引用和敏感列表写法都不成立。",
|
|
916
|
+
},
|
|
917
|
+
{
|
|
918
|
+
module: "M8", difficulty: 3,
|
|
919
|
+
stem: "阻塞赋值的特点是?",
|
|
920
|
+
correct: "按书写顺序立即执行并更新",
|
|
921
|
+
wrong: ["所有语句并行更新", "延迟到时间步结束才更新", "只能用于时序逻辑"],
|
|
922
|
+
explain: "阻塞赋值像普通程序语句,前一句的结果立刻影响后一句。",
|
|
923
|
+
},
|
|
924
|
+
{
|
|
925
|
+
module: "M8", difficulty: 3,
|
|
926
|
+
stem: "`timescale 1ns/1ps 的含义是?",
|
|
927
|
+
correct: "时间单位 1ns,时间精度 1ps",
|
|
928
|
+
wrong: ["时钟周期 1ns,频率 1ps", "延时 1ns,误差 1ps", "单位 1ps,精度 1ns"],
|
|
929
|
+
explain: "斜杠前是单位,斜杠后是精度;精度不能大于单位。",
|
|
930
|
+
},
|
|
931
|
+
{
|
|
932
|
+
module: "M8", difficulty: 2,
|
|
933
|
+
stem: "Verilog 中 parameter 的作用是?",
|
|
934
|
+
correct: "定义模块内常量,实例化时可覆盖",
|
|
935
|
+
wrong: ["定义可变的寄存器", "定义模块端口", "产生时钟信号"],
|
|
936
|
+
explain: "parameter 常用来写位宽和延时,让同一模块在不同实例中取不同值。",
|
|
937
|
+
},
|
|
500
938
|
];
|
|
501
939
|
|
|
502
940
|
function conceptQuestions(random, used) {
|
|
@@ -521,9 +959,10 @@ function conceptQuestions(random, used) {
|
|
|
521
959
|
|
|
522
960
|
function generateQuestions(count, seed) {
|
|
523
961
|
const random = makeRandom(seed);
|
|
524
|
-
const computed = [questionBase, questionTwosComplement, questionGray, questionBcd, questionHamming, questionMinterms, questionKmap];
|
|
962
|
+
const computed = [questionBase, questionTwosComplement, questionGray, questionBcd, questionHamming, questionHammingCheck, questionMinterms, questionKmap];
|
|
525
963
|
const questions = [];
|
|
526
964
|
const conceptPool = [];
|
|
965
|
+
const seenStems = new Set();
|
|
527
966
|
|
|
528
967
|
// 计算题与概念题交替出现,保证八个模块都有覆盖
|
|
529
968
|
let guard = 0;
|
|
@@ -531,12 +970,19 @@ function generateQuestions(count, seed) {
|
|
|
531
970
|
guard += 1;
|
|
532
971
|
const index = questions.length;
|
|
533
972
|
if (index % 2 === 1) {
|
|
534
|
-
|
|
973
|
+
const candidate = conceptQuestions(random, conceptPool);
|
|
974
|
+
if (candidate && !seenStems.has(candidate.stem)) {
|
|
975
|
+
seenStems.add(candidate.stem);
|
|
976
|
+
questions.push(candidate);
|
|
977
|
+
}
|
|
535
978
|
continue;
|
|
536
979
|
}
|
|
537
980
|
const generator = computed[(index / 2) % computed.length];
|
|
538
981
|
const candidate = generator(random);
|
|
539
|
-
if (candidate.options.length === 4
|
|
982
|
+
if (candidate.options.length === 4 && !seenStems.has(candidate.stem)) {
|
|
983
|
+
seenStems.add(candidate.stem);
|
|
984
|
+
questions.push(candidate);
|
|
985
|
+
}
|
|
540
986
|
}
|
|
541
987
|
return questions.map((question, index) => ({ id: `q${index + 1}`, ...question }));
|
|
542
988
|
}
|
|
@@ -586,7 +1032,7 @@ function main() {
|
|
|
586
1032
|
}
|
|
587
1033
|
|
|
588
1034
|
const seed = Number(flags.get("seed") ?? 20261125);
|
|
589
|
-
const count = Number(flags.get("count") ??
|
|
1035
|
+
const count = Number(flags.get("count") ?? 80);
|
|
590
1036
|
const questions = generateQuestions(count, seed);
|
|
591
1037
|
|
|
592
1038
|
if (flags.get("check") === true) {
|
|
@@ -455,7 +455,7 @@
|
|
|
455
455
|
var app = document.getElementById("app");
|
|
456
456
|
var footer = document.getElementById("footer");
|
|
457
457
|
var STORAGE_KEY = "dl-wrong-book-v1";
|
|
458
|
-
var APP_VERSION = "0.6.
|
|
458
|
+
var APP_VERSION = "0.6.4";
|
|
459
459
|
|
|
460
460
|
var MODULES = {
|
|
461
461
|
M1: "数制与编码", M2: "逻辑代数", M3: "组合逻辑", M4: "时序逻辑",
|