zwpride commited on
Commit
91024fe
·
verified ·
1 Parent(s): 38af1ce

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +4 -57
  2. DATASET_STRUCTURE.md +35 -0
  3. LICENSE.md +30 -0
  4. RAI.md +39 -0
  5. README.md +99 -0
  6. bundles/L1_basic/001_and_gate/config.yaml +28 -0
  7. bundles/L1_basic/001_and_gate/problem.md +48 -0
  8. bundles/L1_basic/001_and_gate/testbench.v +75 -0
  9. bundles/L1_basic/002_or_gate/config.yaml +18 -0
  10. bundles/L1_basic/002_or_gate/problem.md +27 -0
  11. bundles/L1_basic/002_or_gate/testbench.v +24 -0
  12. bundles/L1_basic/003_not_gate/config.yaml +17 -0
  13. bundles/L1_basic/003_not_gate/problem.md +26 -0
  14. bundles/L1_basic/003_not_gate/testbench.v +17 -0
  15. bundles/L1_basic/004_xor_gate/config.yaml +18 -0
  16. bundles/L1_basic/004_xor_gate/problem.md +27 -0
  17. bundles/L1_basic/004_xor_gate/testbench.v +16 -0
  18. bundles/L1_basic/005_mux2to1/config.yaml +31 -0
  19. bundles/L1_basic/005_mux2to1/problem.md +27 -0
  20. bundles/L1_basic/005_mux2to1/testbench.v +62 -0
  21. bundles/L1_basic/006_mux4to1/config.yaml +21 -0
  22. bundles/L1_basic/006_mux4to1/problem.md +31 -0
  23. bundles/L1_basic/006_mux4to1/testbench.v +25 -0
  24. bundles/L1_basic/007_half_adder/config.yaml +19 -0
  25. bundles/L1_basic/007_half_adder/problem.md +27 -0
  26. bundles/L1_basic/007_half_adder/testbench.v +16 -0
  27. bundles/L1_basic/008_full_adder/config.yaml +34 -0
  28. bundles/L1_basic/008_full_adder/problem.md +31 -0
  29. bundles/L1_basic/008_full_adder/testbench.v +83 -0
  30. bundles/L1_basic/009_decoder2to4/config.yaml +18 -0
  31. bundles/L1_basic/009_decoder2to4/problem.md +30 -0
  32. bundles/L1_basic/009_decoder2to4/testbench.v +23 -0
  33. bundles/L1_basic/010_priority_encoder/config.yaml +18 -0
  34. bundles/L1_basic/010_priority_encoder/problem.md +28 -0
  35. bundles/L1_basic/010_priority_encoder/testbench.v +23 -0
  36. bundles/L1_basic/011_not_gate/config.yaml +21 -0
  37. bundles/L1_basic/011_not_gate/problem.md +35 -0
  38. bundles/L1_basic/011_not_gate/testbench.v +52 -0
  39. bundles/L1_basic/012_and_gate/config.yaml +24 -0
  40. bundles/L1_basic/012_and_gate/problem.md +36 -0
  41. bundles/L1_basic/012_and_gate/testbench.v +70 -0
  42. bundles/L1_basic/013_or_gate/config.yaml +24 -0
  43. bundles/L1_basic/013_or_gate/problem.md +36 -0
  44. bundles/L1_basic/013_or_gate/testbench.v +70 -0
  45. bundles/L1_basic/014_xor_gate/config.yaml +24 -0
  46. bundles/L1_basic/014_xor_gate/problem.md +36 -0
  47. bundles/L1_basic/014_xor_gate/testbench.v +70 -0
  48. bundles/L1_basic/015_nand_gate/config.yaml +24 -0
  49. bundles/L1_basic/015_nand_gate/problem.md +36 -0
  50. bundles/L1_basic/015_nand_gate/testbench.v +70 -0
.gitattributes CHANGED
@@ -1,60 +1,7 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.avro filter=lfs diff=lfs merge=lfs -text
4
- *.bin filter=lfs diff=lfs merge=lfs -text
5
- *.bz2 filter=lfs diff=lfs merge=lfs -text
6
- *.ckpt filter=lfs diff=lfs merge=lfs -text
7
- *.ftz filter=lfs diff=lfs merge=lfs -text
8
- *.gz filter=lfs diff=lfs merge=lfs -text
9
- *.h5 filter=lfs diff=lfs merge=lfs -text
10
- *.joblib filter=lfs diff=lfs merge=lfs -text
11
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
12
- *.lz4 filter=lfs diff=lfs merge=lfs -text
13
- *.mds filter=lfs diff=lfs merge=lfs -text
14
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
15
- *.model filter=lfs diff=lfs merge=lfs -text
16
- *.msgpack filter=lfs diff=lfs merge=lfs -text
17
- *.npy filter=lfs diff=lfs merge=lfs -text
18
- *.npz filter=lfs diff=lfs merge=lfs -text
19
- *.onnx filter=lfs diff=lfs merge=lfs -text
20
- *.ot filter=lfs diff=lfs merge=lfs -text
21
- *.parquet filter=lfs diff=lfs merge=lfs -text
22
- *.pb filter=lfs diff=lfs merge=lfs -text
23
- *.pickle filter=lfs diff=lfs merge=lfs -text
24
- *.pkl filter=lfs diff=lfs merge=lfs -text
25
- *.pt filter=lfs diff=lfs merge=lfs -text
26
- *.pth filter=lfs diff=lfs merge=lfs -text
27
- *.rar filter=lfs diff=lfs merge=lfs -text
28
- *.safetensors filter=lfs diff=lfs merge=lfs -text
29
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
30
- *.tar.* filter=lfs diff=lfs merge=lfs -text
31
- *.tar filter=lfs diff=lfs merge=lfs -text
32
- *.tflite filter=lfs diff=lfs merge=lfs -text
33
- *.tgz filter=lfs diff=lfs merge=lfs -text
34
- *.wasm filter=lfs diff=lfs merge=lfs -text
35
- *.xz filter=lfs diff=lfs merge=lfs -text
36
- *.zip filter=lfs diff=lfs merge=lfs -text
37
- *.zst filter=lfs diff=lfs merge=lfs -text
38
- *tfevents* filter=lfs diff=lfs merge=lfs -text
39
- # Audio files - uncompressed
40
- *.pcm filter=lfs diff=lfs merge=lfs -text
41
- *.sam filter=lfs diff=lfs merge=lfs -text
42
- *.raw filter=lfs diff=lfs merge=lfs -text
43
- # Audio files - compressed
44
- *.aac filter=lfs diff=lfs merge=lfs -text
45
- *.flac filter=lfs diff=lfs merge=lfs -text
46
- *.mp3 filter=lfs diff=lfs merge=lfs -text
47
- *.ogg filter=lfs diff=lfs merge=lfs -text
48
- *.wav filter=lfs diff=lfs merge=lfs -text
49
- # Image files - uncompressed
50
- *.bmp filter=lfs diff=lfs merge=lfs -text
51
- *.gif filter=lfs diff=lfs merge=lfs -text
52
  *.png filter=lfs diff=lfs merge=lfs -text
53
- *.tiff filter=lfs diff=lfs merge=lfs -text
54
- # Image files - compressed
55
  *.jpg filter=lfs diff=lfs merge=lfs -text
56
  *.jpeg filter=lfs diff=lfs merge=lfs -text
57
- *.webp filter=lfs diff=lfs merge=lfs -text
58
- # Video files - compressed
59
- *.mp4 filter=lfs diff=lfs merge=lfs -text
60
- *.webm filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  *.png filter=lfs diff=lfs merge=lfs -text
 
 
2
  *.jpg filter=lfs diff=lfs merge=lfs -text
3
  *.jpeg filter=lfs diff=lfs merge=lfs -text
4
+ *.pdf filter=lfs diff=lfs merge=lfs -text
5
+ *.zip filter=lfs diff=lfs merge=lfs -text
6
+ *.tar filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
DATASET_STRUCTURE.md ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Dataset Structure
2
+
3
+ ## Atomic unit
4
+
5
+ The atomic unit is one problem bundle.
6
+
7
+ Each bundle should contain:
8
+
9
+ - `problem.md`
10
+ - `config.yaml`
11
+ - `testbench.v`
12
+
13
+ The default public release excludes `reference.v`.
14
+
15
+ ## Example layout
16
+
17
+ ```text
18
+ bundles/
19
+ ├── L1_basic/
20
+ │ ├── problem_0001/
21
+ │ └── ...
22
+ ├── L2_sequential/
23
+ ├── L3_module/
24
+ ├── L4_system/
25
+ └── L5_ultimate/
26
+ ```
27
+
28
+ ## Release notes
29
+
30
+ Before publishing, update this file with:
31
+
32
+ - final problem count
33
+ - exact level names
34
+ - whether a separate validation package includes `reference.v`
35
+ - any held-out or omitted assets
LICENSE.md ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # VeriScope Dataset License
2
+
3
+ The released VeriScope benchmark bundles in this dataset repository are
4
+ distributed under the terms of the Creative Commons Attribution 4.0
5
+ International License:
6
+
7
+ - https://creativecommons.org/licenses/by/4.0/
8
+
9
+ ## Scope of this license
10
+
11
+ This license applies to the benchmark bundles released in this repository,
12
+ including:
13
+
14
+ - rewritten `problem.md` task briefs
15
+ - benchmark-side `config.yaml` metadata
16
+ - public `testbench.v` files
17
+ - accompanying dataset metadata and documentation
18
+
19
+ ## Third-party source material
20
+
21
+ VeriScope was constructed using public and open-source Verilog material,
22
+ including a source crawl of public HDL educational problems. Those raw
23
+ third-party source materials are not redistributed verbatim in this default
24
+ public dataset release and remain under their original terms.
25
+
26
+ ## Reference RTL
27
+
28
+ The default public dataset release excludes `reference.v`. Reference RTL is
29
+ treated as a benchmark-side validation anchor rather than as part of the default
30
+ public evaluation package.
RAI.md ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Responsible AI and Release Notes
2
+
3
+ This file is a draft for the RAI fields expected in the NeurIPS 2026 E&D submission package.
4
+
5
+ ## Resource type
6
+
7
+ - benchmark dataset
8
+ - evaluation suite companion data release
9
+
10
+ ## Intended use
11
+
12
+ - evaluation of first-pass Verilog code generation
13
+ - comparison of hardware coding models under a common benchmark
14
+ - study of execution-only vs. quality-aware evaluation
15
+
16
+ ## Foreseeable misuse
17
+
18
+ - generation of unsafe or malicious RTL
19
+ - unauthorized recreation of proprietary-style hardware patterns
20
+ - overclaiming model readiness for production chip design
21
+
22
+ ## Limitations
23
+
24
+ - public third-party models are not fully decontaminated
25
+ - top-end expert-scale coverage is still limited
26
+ - benchmark scores do not replace synthesis, timing, formal verification, or human sign-off
27
+ - the default public dataset excludes `reference.v`, so benchmark-side gold verification is not fully reproduced from the dataset release alone
28
+
29
+ ## Human oversight
30
+
31
+ The benchmark should be used as an evaluation aid, not as a final arbiter of production hardware quality.
32
+
33
+ ## Release safeguards
34
+
35
+ - clear licensing and attribution
36
+ - explicit statement of intended use
37
+ - explicit statement of out-of-scope uses
38
+ - public documentation of benchmark limitations
39
+ - default exclusion of benchmark-side reference RTL from the public dataset
README.md ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pretty_name: VeriScope
3
+ license: cc-by-4.0
4
+ task_categories:
5
+ - text-generation
6
+ task_ids:
7
+ - text-to-code
8
+ language:
9
+ - en
10
+ size_categories:
11
+ - n<1K
12
+ annotations_creators:
13
+ - expert-generated
14
+ source_datasets:
15
+ - extended
16
+ multilinguality:
17
+ - monolingual
18
+ configs:
19
+ - config_name: default
20
+ data_files:
21
+ - split: train
22
+ path: "bundles/**"
23
+ ---
24
+
25
+ # VeriScope
26
+
27
+ VeriScope is an open benchmark dataset for first-pass Verilog coding.
28
+
29
+ This Hugging Face repository is intended to host the released benchmark bundles and dataset metadata that accompany the public code release.
30
+
31
+ ## Dataset summary
32
+
33
+ - domain: Verilog / RTL generation
34
+ - unit of release: task bundle
35
+ - target setting: first-pass code generation from natural-language task briefs
36
+ - public paper size: 568 problems
37
+
38
+ ## Dataset structure
39
+
40
+ Each public example is a task bundle containing:
41
+
42
+ - `problem.md`
43
+ - `config.yaml`
44
+ - `testbench.v`
45
+
46
+ The default public release excludes `reference.v`. The reference RTL is treated as a benchmark-side validation anchor rather than as part of the default evaluation package.
47
+
48
+ Suggested tree:
49
+
50
+ ```text
51
+ bundles/
52
+ ├── L1_basic/
53
+ ├── L2_sequential/
54
+ ├── L3_module/
55
+ ├── L4_system/
56
+ └── L5_ultimate/
57
+ ```
58
+
59
+ ## Supported uses
60
+
61
+ - evaluation of Verilog code generation models
62
+ - evaluation of first-pass hardware coding agents
63
+ - analysis of functional correctness vs. structural quality
64
+
65
+ ## Out-of-scope uses
66
+
67
+ - production sign-off
68
+ - security certification
69
+ - claims of complete training-data decontamination
70
+
71
+ ## Dataset creation
72
+
73
+ The benchmark is built from a curated Verilog seed corpus and standardized into reusable problem bundles with benchmark-side validation harnesses. Public task briefs are rewritten and packaged rather than copied verbatim from source material.
74
+
75
+ ## Evaluation
76
+
77
+ The companion GitHub repository contains the public evaluation harness, scoring logic, and reproduction instructions.
78
+
79
+ ## Licensing
80
+
81
+ The released benchmark bundles are distributed under `CC BY 4.0`. This license applies to the released task packages in this repository. Third-party source material used during benchmark construction is not redistributed verbatim here and remains under its original terms.
82
+
83
+ ## Citation
84
+
85
+ ```bibtex
86
+ @inproceedings{veriscope2026,
87
+ title={VeriScope: An Open Benchmark and Evaluation Suite for First-Pass Verilog Coding},
88
+ author={Wei Zhang and collaborators},
89
+ booktitle={NeurIPS},
90
+ year={2026}
91
+ }
92
+ ```
93
+
94
+ ## Additional metadata
95
+
96
+ - Croissant metadata: `croissant.json`
97
+ - responsible release notes: `RAI.md`
98
+ - dataset layout notes: `DATASET_STRUCTURE.md`
99
+ - dataset license note: `LICENSE.md`
bundles/L1_basic/001_and_gate/config.yaml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ problem_id: "001"
2
+ title: "AND Gate"
3
+ level: 1
4
+ category: "basic_gates"
5
+ description: "Implement a 2-input AND gate"
6
+
7
+ module_name: "and_gate"
8
+ ports:
9
+ a:
10
+ direction: "input"
11
+ width: "1"
12
+ b:
13
+ direction: "input"
14
+ width: "1"
15
+ y:
16
+ direction: "output"
17
+ width: "1"
18
+
19
+ testbench_file: "testbench.v"
20
+ timeout_compile: 10
21
+ timeout_simulate: 10
22
+
23
+ require_synthesis: false
24
+ check_waveform: false
25
+
26
+ weight_functional: 1.0
27
+ weight_synthesis: 0.0
28
+ weight_resource: 0.0
bundles/L1_basic/001_and_gate/problem.md ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Problem 001: AND Gate
2
+
3
+ ## Description
4
+
5
+ Implement a 2-input AND gate.
6
+
7
+ ## Module Interface
8
+
9
+ ```verilog
10
+ module and_gate(
11
+ input a,
12
+ input b,
13
+ output y
14
+ );
15
+ // Your code here
16
+ endmodule
17
+ ```
18
+
19
+ ## Specification
20
+
21
+ - Inputs: `a`, `b` (1-bit each)
22
+ - Output: `y` (1-bit)
23
+ - Function: `y = a & b`
24
+
25
+ ## Truth Table
26
+
27
+ | a | b | y |
28
+ |---|---|---|
29
+ | 0 | 0 | 0 |
30
+ | 0 | 1 | 0 |
31
+ | 1 | 0 | 0 |
32
+ | 1 | 1 | 1 |
33
+
34
+ ## Example
35
+
36
+ ```verilog
37
+ module and_gate(
38
+ input a,
39
+ input b,
40
+ output y
41
+ );
42
+ assign y = a & b;
43
+ endmodule
44
+ ```
45
+
46
+ ## Scoring
47
+
48
+ - Functional correctness: 100%
bundles/L1_basic/001_and_gate/testbench.v ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ `timescale 1ns/1ps
2
+
3
+ module tb_and_gate;
4
+ reg a, b;
5
+ wire y;
6
+
7
+ // Instantiate the module under test
8
+ and_gate uut (
9
+ .a(a),
10
+ .b(b),
11
+ .y(y)
12
+ );
13
+
14
+ integer pass_count = 0;
15
+ integer fail_count = 0;
16
+
17
+ initial begin
18
+ $display("Testing AND gate...");
19
+
20
+ // Test case 1: 0 & 0 = 0
21
+ a = 0; b = 0; #10;
22
+ if (y === 1'b0) begin
23
+ pass_count = pass_count + 1;
24
+ $display("[PASS] Test 1: %b & %b = %b", a, b, y);
25
+ end else begin
26
+ fail_count = fail_count + 1;
27
+ $display("[FAIL] Test 1: %b & %b = %b (expected 0)", a, b, y);
28
+ end
29
+
30
+ // Test case 2: 0 & 1 = 0
31
+ a = 0; b = 1; #10;
32
+ if (y === 1'b0) begin
33
+ pass_count = pass_count + 1;
34
+ $display("[PASS] Test 2: %b & %b = %b", a, b, y);
35
+ end else begin
36
+ fail_count = fail_count + 1;
37
+ $display("[FAIL] Test 2: %b & %b = %b (expected 0)", a, b, y);
38
+ end
39
+
40
+ // Test case 3: 1 & 0 = 0
41
+ a = 1; b = 0; #10;
42
+ if (y === 1'b0) begin
43
+ pass_count = pass_count + 1;
44
+ $display("[PASS] Test 3: %b & %b = %b", a, b, y);
45
+ end else begin
46
+ fail_count = fail_count + 1;
47
+ $display("[FAIL] Test 3: %b & %b = %b (expected 0)", a, b, y);
48
+ end
49
+
50
+ // Test case 4: 1 & 1 = 1
51
+ a = 1; b = 1; #10;
52
+ if (y === 1'b1) begin
53
+ pass_count = pass_count + 1;
54
+ $display("[PASS] Test 4: %b & %b = %b", a, b, y);
55
+ end else begin
56
+ fail_count = fail_count + 1;
57
+ $display("[FAIL] Test 4: %b & %b = %b (expected 1)", a, b, y);
58
+ end
59
+
60
+ // Summary
61
+ $display("");
62
+ $display("=================================");
63
+ $display("PASS: %0d", pass_count);
64
+ $display("FAIL: %0d", fail_count);
65
+
66
+ if (fail_count == 0) begin
67
+ $display("TEST PASSED");
68
+ end else begin
69
+ $display("TEST FAILED");
70
+ end
71
+ $display("=================================");
72
+
73
+ $finish;
74
+ end
75
+ endmodule
bundles/L1_basic/002_or_gate/config.yaml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ problem_id: "002"
2
+ title: "OR Gate"
3
+ level: 1
4
+ category: "basic_gates"
5
+ description: "Implement a 2-input OR gate"
6
+ module_name: "or_gate"
7
+ ports:
8
+ a: { direction: "input", width: "1" }
9
+ b: { direction: "input", width: "1" }
10
+ y: { direction: "output", width: "1" }
11
+ testbench_file: "testbench.v"
12
+ timeout_compile: 10
13
+ timeout_simulate: 10
14
+ require_synthesis: false
15
+ check_waveform: false
16
+ weight_functional: 1.0
17
+ weight_synthesis: 0.0
18
+ weight_resource: 0.0
bundles/L1_basic/002_or_gate/problem.md ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Problem 002: OR Gate
2
+
3
+ ## Description
4
+
5
+ Implement a 2-input OR gate.
6
+
7
+ ## Module Interface
8
+
9
+ ```verilog
10
+ module or_gate(
11
+ input a,
12
+ input b,
13
+ output y
14
+ );
15
+ // Your code here
16
+ endmodule
17
+ ```
18
+
19
+ ## Specification
20
+
21
+ - Inputs: `a`, `b` (1-bit each)
22
+ - Output: `y` (1-bit)
23
+ - Function: `y = a | b`
24
+
25
+ ## Scoring
26
+
27
+ - Functional correctness: 100%
bundles/L1_basic/002_or_gate/testbench.v ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ `timescale 1ns/1ps
2
+ module tb_or_gate;
3
+ reg a, b;
4
+ wire y;
5
+ or_gate uut(.a(a), .b(b), .y(y));
6
+ integer pass_count = 0;
7
+ integer fail_count = 0;
8
+ task check(input expected);
9
+ begin
10
+ #10;
11
+ if (y === expected) pass_count = pass_count + 1;
12
+ else fail_count = fail_count + 1;
13
+ end
14
+ endtask
15
+ initial begin
16
+ a=0; b=0; check(1'b0);
17
+ a=0; b=1; check(1'b1);
18
+ a=1; b=0; check(1'b1);
19
+ a=1; b=1; check(1'b1);
20
+ if (fail_count == 0) $display("TEST PASSED");
21
+ else $display("TEST FAILED");
22
+ $finish;
23
+ end
24
+ endmodule
bundles/L1_basic/003_not_gate/config.yaml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ problem_id: "003"
2
+ title: "NOT Gate"
3
+ level: 1
4
+ category: "basic_gates"
5
+ description: "Implement a NOT gate"
6
+ module_name: "not_gate"
7
+ ports:
8
+ a: { direction: "input", width: "1" }
9
+ y: { direction: "output", width: "1" }
10
+ testbench_file: "testbench.v"
11
+ timeout_compile: 10
12
+ timeout_simulate: 10
13
+ require_synthesis: false
14
+ check_waveform: false
15
+ weight_functional: 1.0
16
+ weight_synthesis: 0.0
17
+ weight_resource: 0.0
bundles/L1_basic/003_not_gate/problem.md ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Problem 003: NOT Gate
2
+
3
+ ## Description
4
+
5
+ Implement a NOT gate (inverter).
6
+
7
+ ## Module Interface
8
+
9
+ ```verilog
10
+ module not_gate(
11
+ input a,
12
+ output y
13
+ );
14
+ // Your code here
15
+ endmodule
16
+ ```
17
+
18
+ ## Specification
19
+
20
+ - Input: `a` (1-bit)
21
+ - Output: `y` (1-bit)
22
+ - Function: `y = ~a`
23
+
24
+ ## Scoring
25
+
26
+ - Functional correctness: 100%
bundles/L1_basic/003_not_gate/testbench.v ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ `timescale 1ns/1ps
2
+ module tb_not_gate;
3
+ reg a;
4
+ wire y;
5
+ not_gate uut(.a(a), .y(y));
6
+ integer pass_count = 0;
7
+ integer fail_count = 0;
8
+ initial begin
9
+ a = 0; #10;
10
+ if (y === 1'b1) pass_count = pass_count + 1; else fail_count = fail_count + 1;
11
+ a = 1; #10;
12
+ if (y === 1'b0) pass_count = pass_count + 1; else fail_count = fail_count + 1;
13
+ if (fail_count == 0) $display("TEST PASSED");
14
+ else $display("TEST FAILED");
15
+ $finish;
16
+ end
17
+ endmodule
bundles/L1_basic/004_xor_gate/config.yaml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ problem_id: "004"
2
+ title: "XOR Gate"
3
+ level: 1
4
+ category: "basic_gates"
5
+ description: "Implement a 2-input XOR gate"
6
+ module_name: "xor_gate"
7
+ ports:
8
+ a: { direction: "input", width: "1" }
9
+ b: { direction: "input", width: "1" }
10
+ y: { direction: "output", width: "1" }
11
+ testbench_file: "testbench.v"
12
+ timeout_compile: 10
13
+ timeout_simulate: 10
14
+ require_synthesis: false
15
+ check_waveform: false
16
+ weight_functional: 1.0
17
+ weight_synthesis: 0.0
18
+ weight_resource: 0.0
bundles/L1_basic/004_xor_gate/problem.md ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Problem 004: XOR Gate
2
+
3
+ ## Description
4
+
5
+ Implement a 2-input XOR gate.
6
+
7
+ ## Module Interface
8
+
9
+ ```verilog
10
+ module xor_gate(
11
+ input a,
12
+ input b,
13
+ output y
14
+ );
15
+ // Your code here
16
+ endmodule
17
+ ```
18
+
19
+ ## Specification
20
+
21
+ - Inputs: `a`, `b` (1-bit each)
22
+ - Output: `y` (1-bit)
23
+ - Function: `y = a ^ b`
24
+
25
+ ## Scoring
26
+
27
+ - Functional correctness: 100%
bundles/L1_basic/004_xor_gate/testbench.v ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ `timescale 1ns/1ps
2
+ module tb_xor_gate;
3
+ reg a, b;
4
+ wire y;
5
+ xor_gate uut(.a(a), .b(b), .y(y));
6
+ integer pass_count = 0;
7
+ integer fail_count = 0;
8
+ initial begin
9
+ a=0; b=0; #10; if (y===1'b0) pass_count=pass_count+1; else fail_count=fail_count+1;
10
+ a=0; b=1; #10; if (y===1'b1) pass_count=pass_count+1; else fail_count=fail_count+1;
11
+ a=1; b=0; #10; if (y===1'b1) pass_count=pass_count+1; else fail_count=fail_count+1;
12
+ a=1; b=1; #10; if (y===1'b0) pass_count=pass_count+1; else fail_count=fail_count+1;
13
+ if (fail_count==0) $display("TEST PASSED"); else $display("TEST FAILED");
14
+ $finish;
15
+ end
16
+ endmodule
bundles/L1_basic/005_mux2to1/config.yaml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ problem_id: "005"
2
+ title: "2-to-1 Multiplexer"
3
+ level: 1
4
+ category: "mux"
5
+ description: "Implement a 2-to-1 mux for 8-bit data"
6
+
7
+ module_name: "mux2to1"
8
+ ports:
9
+ a:
10
+ direction: "input"
11
+ width: "8"
12
+ b:
13
+ direction: "input"
14
+ width: "8"
15
+ sel:
16
+ direction: "input"
17
+ width: "1"
18
+ y:
19
+ direction: "output"
20
+ width: "8"
21
+
22
+ testbench_file: "testbench.v"
23
+ timeout_compile: 10
24
+ timeout_simulate: 10
25
+
26
+ require_synthesis: false
27
+ check_waveform: false
28
+
29
+ weight_functional: 1.0
30
+ weight_synthesis: 0.0
31
+ weight_resource: 0.0
bundles/L1_basic/005_mux2to1/problem.md ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Problem 005: 2-to-1 Multiplexer
2
+
3
+ ## Description
4
+
5
+ Implement a 2-to-1 multiplexer that selects between two 8-bit inputs.
6
+
7
+ ## Module Interface
8
+
9
+ ```verilog
10
+ module mux2to1(
11
+ input [7:0] a,
12
+ input [7:0] b,
13
+ input sel,
14
+ output [7:0] y
15
+ );
16
+ // Your code here
17
+ endmodule
18
+ ```
19
+
20
+ ## Specification
21
+
22
+ - When `sel = 0`: output `y = a`
23
+ - When `sel = 1`: output `y = b`
24
+
25
+ ## Scoring
26
+
27
+ - Functional correctness: 100%
bundles/L1_basic/005_mux2to1/testbench.v ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ `timescale 1ns/1ps
2
+
3
+ module tb_mux2to1;
4
+ reg [7:0] a, b;
5
+ reg sel;
6
+ wire [7:0] y;
7
+
8
+ mux2to1 uut (
9
+ .a(a),
10
+ .b(b),
11
+ .sel(sel),
12
+ .y(y)
13
+ );
14
+
15
+ integer pass_count = 0;
16
+ integer fail_count = 0;
17
+ integer i;
18
+
19
+ initial begin
20
+ $display("Testing 2-to-1 Multiplexer...");
21
+
22
+ // Test with various values
23
+ for (i = 0; i < 10; i = i + 1) begin
24
+ a = $random;
25
+ b = $random;
26
+
27
+ // Test sel = 0 (should select a)
28
+ sel = 0; #10;
29
+ if (y === a) begin
30
+ pass_count = pass_count + 1;
31
+ $display("[PASS] sel=0: y=%h (a=%h, b=%h)", y, a, b);
32
+ end else begin
33
+ fail_count = fail_count + 1;
34
+ $display("[FAIL] sel=0: y=%h, expected a=%h", y, a);
35
+ end
36
+
37
+ // Test sel = 1 (should select b)
38
+ sel = 1; #10;
39
+ if (y === b) begin
40
+ pass_count = pass_count + 1;
41
+ $display("[PASS] sel=1: y=%h (a=%h, b=%h)", y, a, b);
42
+ end else begin
43
+ fail_count = fail_count + 1;
44
+ $display("[FAIL] sel=1: y=%h, expected b=%h", y, b);
45
+ end
46
+ end
47
+
48
+ // Summary
49
+ $display("");
50
+ $display("=================================");
51
+ $display("PASS: %0d", pass_count);
52
+ $display("FAIL: %0d", fail_count);
53
+
54
+ if (fail_count == 0)
55
+ $display("TEST PASSED");
56
+ else
57
+ $display("TEST FAILED");
58
+ $display("=================================");
59
+
60
+ $finish;
61
+ end
62
+ endmodule
bundles/L1_basic/006_mux4to1/config.yaml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ problem_id: "006"
2
+ title: "4-to-1 Multiplexer"
3
+ level: 1
4
+ category: "basic_mux"
5
+ description: "Implement a 4-to-1 multiplexer"
6
+ module_name: "mux4to1"
7
+ ports:
8
+ a: { direction: "input", width: "8" }
9
+ b: { direction: "input", width: "8" }
10
+ c: { direction: "input", width: "8" }
11
+ d: { direction: "input", width: "8" }
12
+ sel: { direction: "input", width: "2" }
13
+ y: { direction: "output", width: "8" }
14
+ testbench_file: "testbench.v"
15
+ timeout_compile: 10
16
+ timeout_simulate: 10
17
+ require_synthesis: false
18
+ check_waveform: false
19
+ weight_functional: 1.0
20
+ weight_synthesis: 0.0
21
+ weight_resource: 0.0
bundles/L1_basic/006_mux4to1/problem.md ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Problem 006: 4-to-1 Multiplexer
2
+
3
+ ## Description
4
+
5
+ Implement a 4-to-1 multiplexer with 8-bit data inputs.
6
+
7
+ ## Module Interface
8
+
9
+ ```verilog
10
+ module mux4to1(
11
+ input [7:0] a,
12
+ input [7:0] b,
13
+ input [7:0] c,
14
+ input [7:0] d,
15
+ input [1:0] sel,
16
+ output [7:0] y
17
+ );
18
+ // Your code here
19
+ endmodule
20
+ ```
21
+
22
+ ## Specification
23
+
24
+ - When `sel = 00`: `y = a`
25
+ - When `sel = 01`: `y = b`
26
+ - When `sel = 10`: `y = c`
27
+ - When `sel = 11`: `y = d`
28
+
29
+ ## Scoring
30
+
31
+ - Functional correctness: 100%
bundles/L1_basic/006_mux4to1/testbench.v ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ `timescale 1ns/1ps
2
+ module tb_mux4to1;
3
+ reg [7:0] a, b, c, d;
4
+ reg [1:0] sel;
5
+ wire [7:0] y;
6
+ mux4to1 uut(.a(a), .b(b), .c(c), .d(d), .sel(sel), .y(y));
7
+ integer pass_count = 0;
8
+ integer fail_count = 0;
9
+ integer i;
10
+ initial begin
11
+ a = 8'hAA; b = 8'hBB; c = 8'hCC; d = 8'hDD;
12
+ sel = 2'b00; #10; if (y===8'hAA) pass_count=pass_count+1; else fail_count=fail_count+1;
13
+ sel = 2'b01; #10; if (y===8'hBB) pass_count=pass_count+1; else fail_count=fail_count+1;
14
+ sel = 2'b10; #10; if (y===8'hCC) pass_count=pass_count+1; else fail_count=fail_count+1;
15
+ sel = 2'b11; #10; if (y===8'hDD) pass_count=pass_count+1; else fail_count=fail_count+1;
16
+ // More tests with different values
17
+ a = 8'h12; b = 8'h34; c = 8'h56; d = 8'h78;
18
+ sel = 2'b00; #10; if (y===8'h12) pass_count=pass_count+1; else fail_count=fail_count+1;
19
+ sel = 2'b01; #10; if (y===8'h34) pass_count=pass_count+1; else fail_count=fail_count+1;
20
+ sel = 2'b10; #10; if (y===8'h56) pass_count=pass_count+1; else fail_count=fail_count+1;
21
+ sel = 2'b11; #10; if (y===8'h78) pass_count=pass_count+1; else fail_count=fail_count+1;
22
+ if (fail_count==0) $display("TEST PASSED"); else $display("TEST FAILED");
23
+ $finish;
24
+ end
25
+ endmodule
bundles/L1_basic/007_half_adder/config.yaml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ problem_id: "007"
2
+ title: "Half Adder"
3
+ level: 1
4
+ category: "basic_arithmetic"
5
+ description: "Implement a half adder"
6
+ module_name: "half_adder"
7
+ ports:
8
+ a: { direction: "input", width: "1" }
9
+ b: { direction: "input", width: "1" }
10
+ sum: { direction: "output", width: "1" }
11
+ carry: { direction: "output", width: "1" }
12
+ testbench_file: "testbench.v"
13
+ timeout_compile: 10
14
+ timeout_simulate: 10
15
+ require_synthesis: false
16
+ check_waveform: false
17
+ weight_functional: 1.0
18
+ weight_synthesis: 0.0
19
+ weight_resource: 0.0
bundles/L1_basic/007_half_adder/problem.md ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Problem 007: Half Adder
2
+
3
+ ## Description
4
+
5
+ Implement a half adder.
6
+
7
+ ## Module Interface
8
+
9
+ ```verilog
10
+ module half_adder(
11
+ input a,
12
+ input b,
13
+ output sum,
14
+ output carry
15
+ );
16
+ // Your code here
17
+ endmodule
18
+ ```
19
+
20
+ ## Specification
21
+
22
+ - `sum = a ^ b`
23
+ - `carry = a & b`
24
+
25
+ ## Scoring
26
+
27
+ - Functional correctness: 100%
bundles/L1_basic/007_half_adder/testbench.v ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ `timescale 1ns/1ps
2
+ module tb_half_adder;
3
+ reg a, b;
4
+ wire sum, carry;
5
+ half_adder uut(.a(a), .b(b), .sum(sum), .carry(carry));
6
+ integer pass_count = 0;
7
+ integer fail_count = 0;
8
+ initial begin
9
+ a=0; b=0; #10; if (sum===1'b0 && carry===1'b0) pass_count=pass_count+1; else fail_count=fail_count+1;
10
+ a=0; b=1; #10; if (sum===1'b1 && carry===1'b0) pass_count=pass_count+1; else fail_count=fail_count+1;
11
+ a=1; b=0; #10; if (sum===1'b1 && carry===1'b0) pass_count=pass_count+1; else fail_count=fail_count+1;
12
+ a=1; b=1; #10; if (sum===1'b0 && carry===1'b1) pass_count=pass_count+1; else fail_count=fail_count+1;
13
+ if (fail_count==0) $display("TEST PASSED"); else $display("TEST FAILED");
14
+ $finish;
15
+ end
16
+ endmodule
bundles/L1_basic/008_full_adder/config.yaml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ problem_id: "008"
2
+ title: "8-bit Adder"
3
+ level: 1
4
+ category: "arithmetic"
5
+ description: "Implement an 8-bit adder with carry"
6
+
7
+ module_name: "adder8"
8
+ ports:
9
+ a:
10
+ direction: "input"
11
+ width: "8"
12
+ b:
13
+ direction: "input"
14
+ width: "8"
15
+ cin:
16
+ direction: "input"
17
+ width: "1"
18
+ sum:
19
+ direction: "output"
20
+ width: "8"
21
+ cout:
22
+ direction: "output"
23
+ width: "1"
24
+
25
+ testbench_file: "testbench.v"
26
+ timeout_compile: 10
27
+ timeout_simulate: 10
28
+
29
+ require_synthesis: false
30
+ check_waveform: false
31
+
32
+ weight_functional: 1.0
33
+ weight_synthesis: 0.0
34
+ weight_resource: 0.0
bundles/L1_basic/008_full_adder/problem.md ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Problem 008: 8-bit Adder
2
+
3
+ ## Description
4
+
5
+ Implement an 8-bit adder with carry output.
6
+
7
+ ## Module Interface
8
+
9
+ ```verilog
10
+ module adder8(
11
+ input [7:0] a,
12
+ input [7:0] b,
13
+ input cin,
14
+ output [7:0] sum,
15
+ output cout
16
+ );
17
+ // Your code here
18
+ endmodule
19
+ ```
20
+
21
+ ## Specification
22
+
23
+ - Compute `{cout, sum} = a + b + cin`
24
+ - `a`, `b`: 8-bit inputs
25
+ - `cin`: carry input
26
+ - `sum`: 8-bit sum output
27
+ - `cout`: carry output
28
+
29
+ ## Scoring
30
+
31
+ - Functional correctness: 100%
bundles/L1_basic/008_full_adder/testbench.v ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ `timescale 1ns/1ps
2
+
3
+ module tb_adder8;
4
+ reg [7:0] a, b;
5
+ reg cin;
6
+ wire [7:0] sum;
7
+ wire cout;
8
+
9
+ adder8 uut (
10
+ .a(a),
11
+ .b(b),
12
+ .cin(cin),
13
+ .sum(sum),
14
+ .cout(cout)
15
+ );
16
+
17
+ integer pass_count = 0;
18
+ integer fail_count = 0;
19
+ integer i;
20
+ reg [8:0] expected;
21
+
22
+ initial begin
23
+ $display("Testing 8-bit Adder...");
24
+
25
+ // Test cases
26
+ for (i = 0; i < 50; i = i + 1) begin
27
+ a = $random;
28
+ b = $random;
29
+ cin = $random & 1'b1;
30
+
31
+ #10;
32
+
33
+ expected = a + b + cin;
34
+
35
+ if ({cout, sum} === expected) begin
36
+ pass_count = pass_count + 1;
37
+ $display("[PASS] %d + %d + %d = {%b,%h} (expected %h)",
38
+ a, b, cin, cout, sum, expected);
39
+ end else begin
40
+ fail_count = fail_count + 1;
41
+ $display("[FAIL] %d + %d + %d = {%b,%h}, expected %h",
42
+ a, b, cin, cout, sum, expected);
43
+ end
44
+ end
45
+
46
+ // Edge cases
47
+ // Max + Max
48
+ a = 8'hFF; b = 8'hFF; cin = 1; #10;
49
+ expected = 9'h1FF;
50
+ if ({cout, sum} === expected) begin
51
+ pass_count = pass_count + 1;
52
+ $display("[PASS] Edge: FF + FF + 1 = {%b,%h}", cout, sum);
53
+ end else begin
54
+ fail_count = fail_count + 1;
55
+ $display("[FAIL] Edge: FF + FF + 1 = {%b,%h}, expected %h", cout, sum, expected);
56
+ end
57
+
58
+ // Zero + Zero
59
+ a = 8'h00; b = 8'h00; cin = 0; #10;
60
+ expected = 9'h000;
61
+ if ({cout, sum} === expected) begin
62
+ pass_count = pass_count + 1;
63
+ $display("[PASS] Edge: 00 + 00 + 0 = {%b,%h}", cout, sum);
64
+ end else begin
65
+ fail_count = fail_count + 1;
66
+ $display("[FAIL] Edge: 00 + 00 + 0 = {%b,%h}, expected %h", cout, sum, expected);
67
+ end
68
+
69
+ // Summary
70
+ $display("");
71
+ $display("=================================");
72
+ $display("PASS: %0d", pass_count);
73
+ $display("FAIL: %0d", fail_count);
74
+
75
+ if (fail_count == 0)
76
+ $display("TEST PASSED");
77
+ else
78
+ $display("TEST FAILED");
79
+ $display("=================================");
80
+
81
+ $finish;
82
+ end
83
+ endmodule
bundles/L1_basic/009_decoder2to4/config.yaml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ problem_id: "009"
2
+ title: "2-to-4 Decoder"
3
+ level: 1
4
+ category: "basic_decoder"
5
+ description: "Implement a 2-to-4 decoder with enable"
6
+ module_name: "decoder2to4"
7
+ ports:
8
+ in: { direction: "input", width: "2" }
9
+ en: { direction: "input", width: "1" }
10
+ out: { direction: "output", width: "4" }
11
+ testbench_file: "testbench.v"
12
+ timeout_compile: 10
13
+ timeout_simulate: 10
14
+ require_synthesis: false
15
+ check_waveform: false
16
+ weight_functional: 1.0
17
+ weight_synthesis: 0.0
18
+ weight_resource: 0.0
bundles/L1_basic/009_decoder2to4/problem.md ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Problem 009: 2-to-4 Decoder
2
+
3
+ ## Description
4
+
5
+ Implement a 2-to-4 decoder with enable.
6
+
7
+ ## Module Interface
8
+
9
+ ```verilog
10
+ module decoder2to4(
11
+ input [1:0] in,
12
+ input en,
13
+ output [3:0] out
14
+ );
15
+ // Your code here
16
+ endmodule
17
+ ```
18
+
19
+ ## Specification
20
+
21
+ - When `en = 1`: exactly one bit of `out` is high based on `in`
22
+ - `in=00`: `out=0001`
23
+ - `in=01`: `out=0010`
24
+ - `in=10`: `out=0100`
25
+ - `in=11`: `out=1000`
26
+ - When `en = 0`: `out = 0000`
27
+
28
+ ## Scoring
29
+
30
+ - Functional correctness: 100%
bundles/L1_basic/009_decoder2to4/testbench.v ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ `timescale 1ns/1ps
2
+ module tb_decoder2to4;
3
+ reg [1:0] in;
4
+ reg en;
5
+ wire [3:0] out;
6
+ decoder2to4 uut(.in(in), .en(en), .out(out));
7
+ integer pass_count = 0;
8
+ integer fail_count = 0;
9
+ initial begin
10
+ // Enable tests
11
+ en=1; in=2'b00; #10; if (out===4'b0001) pass_count=pass_count+1; else fail_count=fail_count+1;
12
+ en=1; in=2'b01; #10; if (out===4'b0010) pass_count=pass_count+1; else fail_count=fail_count+1;
13
+ en=1; in=2'b10; #10; if (out===4'b0100) pass_count=pass_count+1; else fail_count=fail_count+1;
14
+ en=1; in=2'b11; #10; if (out===4'b1000) pass_count=pass_count+1; else fail_count=fail_count+1;
15
+ // Disable tests
16
+ en=0; in=2'b00; #10; if (out===4'b0000) pass_count=pass_count+1; else fail_count=fail_count+1;
17
+ en=0; in=2'b01; #10; if (out===4'b0000) pass_count=pass_count+1; else fail_count=fail_count+1;
18
+ en=0; in=2'b10; #10; if (out===4'b0000) pass_count=pass_count+1; else fail_count=fail_count+1;
19
+ en=0; in=2'b11; #10; if (out===4'b0000) pass_count=pass_count+1; else fail_count=fail_count+1;
20
+ if (fail_count==0) $display("TEST PASSED"); else $display("TEST FAILED");
21
+ $finish;
22
+ end
23
+ endmodule
bundles/L1_basic/010_priority_encoder/config.yaml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ problem_id: "010"
2
+ title: "Priority Encoder"
3
+ level: 1
4
+ category: "basic_encoder"
5
+ description: "Implement a 4-bit priority encoder"
6
+ module_name: "priority_encoder"
7
+ ports:
8
+ in: { direction: "input", width: "4" }
9
+ out: { direction: "output", width: "2" }
10
+ valid: { direction: "output", width: "1" }
11
+ testbench_file: "testbench.v"
12
+ timeout_compile: 10
13
+ timeout_simulate: 10
14
+ require_synthesis: false
15
+ check_waveform: false
16
+ weight_functional: 1.0
17
+ weight_synthesis: 0.0
18
+ weight_resource: 0.0
bundles/L1_basic/010_priority_encoder/problem.md ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Problem 010: Priority Encoder
2
+
3
+ ## Description
4
+
5
+ Implement a 4-bit priority encoder.
6
+
7
+ ## Module Interface
8
+
9
+ ```verilog
10
+ module priority_encoder(
11
+ input [3:0] in,
12
+ output reg [1:0] out,
13
+ output valid
14
+ );
15
+ // Your code here
16
+ endmodule
17
+ ```
18
+
19
+ ## Specification
20
+
21
+ - Output encodes the highest-priority (most significant) active input
22
+ - `in[3]` has highest priority, `in[0]` has lowest
23
+ - `valid` is high when any input is active
24
+ - When no input is active: `out = 00`, `valid = 0`
25
+
26
+ ## Scoring
27
+
28
+ - Functional correctness: 100%
bundles/L1_basic/010_priority_encoder/testbench.v ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ `timescale 1ns/1ps
2
+ module tb_priority_encoder;
3
+ reg [3:0] in;
4
+ wire [1:0] out;
5
+ wire valid;
6
+ priority_encoder uut(.in(in), .out(out), .valid(valid));
7
+ integer pass_count = 0;
8
+ integer fail_count = 0;
9
+ initial begin
10
+ in=4'b0000; #10; if (valid===1'b0 && out===2'b00) pass_count=pass_count+1; else fail_count=fail_count+1;
11
+ in=4'b0001; #10; if (valid===1'b1 && out===2'b00) pass_count=pass_count+1; else fail_count=fail_count+1;
12
+ in=4'b0010; #10; if (valid===1'b1 && out===2'b01) pass_count=pass_count+1; else fail_count=fail_count+1;
13
+ in=4'b0100; #10; if (valid===1'b1 && out===2'b10) pass_count=pass_count+1; else fail_count=fail_count+1;
14
+ in=4'b1000; #10; if (valid===1'b1 && out===2'b11) pass_count=pass_count+1; else fail_count=fail_count+1;
15
+ in=4'b0011; #10; if (valid===1'b1 && out===2'b01) pass_count=pass_count+1; else fail_count=fail_count+1;
16
+ in=4'b0110; #10; if (valid===1'b1 && out===2'b10) pass_count=pass_count+1; else fail_count=fail_count+1;
17
+ in=4'b1111; #10; if (valid===1'b1 && out===2'b11) pass_count=pass_count+1; else fail_count=fail_count+1;
18
+ in=4'b1010; #10; if (valid===1'b1 && out===2'b11) pass_count=pass_count+1; else fail_count=fail_count+1;
19
+ in=4'b0101; #10; if (valid===1'b1 && out===2'b10) pass_count=pass_count+1; else fail_count=fail_count+1;
20
+ if (fail_count==0) $display("TEST PASSED"); else $display("TEST FAILED");
21
+ $finish;
22
+ end
23
+ endmodule
bundles/L1_basic/011_not_gate/config.yaml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ problem_id: '011'
2
+ title: NOT Gate
3
+ level: 1
4
+ category: basic_gates
5
+ description: Implement a NOT gate
6
+ module_name: not_gate
7
+ ports:
8
+ a:
9
+ direction: input
10
+ width: 1
11
+ y:
12
+ direction: output
13
+ width: 1
14
+ testbench_file: testbench.v
15
+ timeout_compile: 10
16
+ timeout_simulate: 30
17
+ require_synthesis: false
18
+ check_waveform: false
19
+ weight_functional: 1.0
20
+ weight_synthesis: 0.0
21
+ weight_resource: 0.0
bundles/L1_basic/011_not_gate/problem.md ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # NOT Gate
2
+
3
+ **Level**: 1 (Basic Combinational Logic)
4
+ **Category**: basic_gates
5
+
6
+ ## Problem Description
7
+
8
+ Implement a NOT gate
9
+
10
+ ## Module Interface
11
+
12
+ ```verilog
13
+ module not_gate(
14
+ input a,
15
+ output y
16
+ );
17
+ ```
18
+
19
+ ## Specifications
20
+
21
+ **Inputs:**
22
+ - `a` (1-bit): Input signal
23
+
24
+ **Outputs:**
25
+ - `y` (1-bit): Output signal
26
+
27
+ ## Examples
28
+
29
+ See testbench for comprehensive test cases.
30
+
31
+ ## Notes
32
+
33
+ - This is a purely combinational circuit
34
+ - No clock or reset signals needed
35
+ - Output should be valid after propagation delay
bundles/L1_basic/011_not_gate/testbench.v ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ `timescale 1ns/1ps
2
+
3
+ module tb_not_gate;
4
+ reg a;
5
+ wire y;
6
+
7
+ // Instantiate the module under test
8
+ not_gate uut (
9
+
10
+ .a(a),
11
+ .y(y)
12
+ );
13
+
14
+ integer pass_count = 0;
15
+ integer fail_count = 0;
16
+
17
+ initial begin
18
+ $display("Testing not_gate...");
19
+
20
+ // Test 1
21
+ a = 1'b0; #10;
22
+ if ((y === 1'b1)) begin
23
+ pass_count = pass_count + 1;
24
+ end else begin
25
+ fail_count = fail_count + 1;
26
+ $display("[FAIL] Test 1");
27
+ end
28
+ // Test 2
29
+ a = 1'b1; #10;
30
+ if ((y === 1'b0)) begin
31
+ pass_count = pass_count + 1;
32
+ end else begin
33
+ fail_count = fail_count + 1;
34
+ $display("[FAIL] Test 2");
35
+ end
36
+
37
+ // Summary
38
+ $display("");
39
+ $display("=================================");
40
+ $display("PASS: %0d", pass_count);
41
+ $display("FAIL: %0d", fail_count);
42
+
43
+ if (fail_count == 0) begin
44
+ $display("TEST PASSED");
45
+ end else begin
46
+ $display("TEST FAILED");
47
+ end
48
+ $display("=================================");
49
+
50
+ $finish;
51
+ end
52
+ endmodule
bundles/L1_basic/012_and_gate/config.yaml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ problem_id: '012'
2
+ title: AND Gate
3
+ level: 1
4
+ category: basic_gates
5
+ description: Implement a 2-input AND gate
6
+ module_name: and_gate
7
+ ports:
8
+ a:
9
+ direction: input
10
+ width: 1
11
+ b:
12
+ direction: input
13
+ width: 1
14
+ y:
15
+ direction: output
16
+ width: 1
17
+ testbench_file: testbench.v
18
+ timeout_compile: 10
19
+ timeout_simulate: 30
20
+ require_synthesis: false
21
+ check_waveform: false
22
+ weight_functional: 1.0
23
+ weight_synthesis: 0.0
24
+ weight_resource: 0.0
bundles/L1_basic/012_and_gate/problem.md ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AND Gate
2
+
3
+ **Level**: 1 (Basic Combinational Logic)
4
+ **Category**: basic_gates
5
+
6
+ ## Problem Description
7
+
8
+ Implement a 2-input AND gate
9
+
10
+ ## Module Interface
11
+
12
+ ```verilog
13
+ module and_gate(
14
+ input a, input b,
15
+ output y
16
+ );
17
+ ```
18
+
19
+ ## Specifications
20
+
21
+ **Inputs:**
22
+ - `a` (1-bit): Input signal
23
+ - `b` (1-bit): Input signal
24
+
25
+ **Outputs:**
26
+ - `y` (1-bit): Output signal
27
+
28
+ ## Examples
29
+
30
+ See testbench for comprehensive test cases.
31
+
32
+ ## Notes
33
+
34
+ - This is a purely combinational circuit
35
+ - No clock or reset signals needed
36
+ - Output should be valid after propagation delay
bundles/L1_basic/012_and_gate/testbench.v ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ `timescale 1ns/1ps
2
+
3
+ module tb_and_gate;
4
+ reg a;
5
+ reg b;
6
+ wire y;
7
+
8
+ // Instantiate the module under test
9
+ and_gate uut (
10
+
11
+ .a(a),
12
+ .b(b),
13
+ .y(y)
14
+ );
15
+
16
+ integer pass_count = 0;
17
+ integer fail_count = 0;
18
+
19
+ initial begin
20
+ $display("Testing and_gate...");
21
+
22
+ // Test 1
23
+ a = 1'b0; b = 1'b0; #10;
24
+ if ((y === 1'b0)) begin
25
+ pass_count = pass_count + 1;
26
+ end else begin
27
+ fail_count = fail_count + 1;
28
+ $display("[FAIL] Test 1");
29
+ end
30
+ // Test 2
31
+ a = 1'b1; b = 1'b0; #10;
32
+ if ((y === 1'b0)) begin
33
+ pass_count = pass_count + 1;
34
+ end else begin
35
+ fail_count = fail_count + 1;
36
+ $display("[FAIL] Test 2");
37
+ end
38
+ // Test 3
39
+ a = 1'b0; b = 1'b1; #10;
40
+ if ((y === 1'b0)) begin
41
+ pass_count = pass_count + 1;
42
+ end else begin
43
+ fail_count = fail_count + 1;
44
+ $display("[FAIL] Test 3");
45
+ end
46
+ // Test 4
47
+ a = 1'b1; b = 1'b1; #10;
48
+ if ((y === 1'b1)) begin
49
+ pass_count = pass_count + 1;
50
+ end else begin
51
+ fail_count = fail_count + 1;
52
+ $display("[FAIL] Test 4");
53
+ end
54
+
55
+ // Summary
56
+ $display("");
57
+ $display("=================================");
58
+ $display("PASS: %0d", pass_count);
59
+ $display("FAIL: %0d", fail_count);
60
+
61
+ if (fail_count == 0) begin
62
+ $display("TEST PASSED");
63
+ end else begin
64
+ $display("TEST FAILED");
65
+ end
66
+ $display("=================================");
67
+
68
+ $finish;
69
+ end
70
+ endmodule
bundles/L1_basic/013_or_gate/config.yaml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ problem_id: '013'
2
+ title: OR Gate
3
+ level: 1
4
+ category: basic_gates
5
+ description: Implement a 2-input OR gate
6
+ module_name: or_gate
7
+ ports:
8
+ a:
9
+ direction: input
10
+ width: 1
11
+ b:
12
+ direction: input
13
+ width: 1
14
+ y:
15
+ direction: output
16
+ width: 1
17
+ testbench_file: testbench.v
18
+ timeout_compile: 10
19
+ timeout_simulate: 30
20
+ require_synthesis: false
21
+ check_waveform: false
22
+ weight_functional: 1.0
23
+ weight_synthesis: 0.0
24
+ weight_resource: 0.0
bundles/L1_basic/013_or_gate/problem.md ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # OR Gate
2
+
3
+ **Level**: 1 (Basic Combinational Logic)
4
+ **Category**: basic_gates
5
+
6
+ ## Problem Description
7
+
8
+ Implement a 2-input OR gate
9
+
10
+ ## Module Interface
11
+
12
+ ```verilog
13
+ module or_gate(
14
+ input a, input b,
15
+ output y
16
+ );
17
+ ```
18
+
19
+ ## Specifications
20
+
21
+ **Inputs:**
22
+ - `a` (1-bit): Input signal
23
+ - `b` (1-bit): Input signal
24
+
25
+ **Outputs:**
26
+ - `y` (1-bit): Output signal
27
+
28
+ ## Examples
29
+
30
+ See testbench for comprehensive test cases.
31
+
32
+ ## Notes
33
+
34
+ - This is a purely combinational circuit
35
+ - No clock or reset signals needed
36
+ - Output should be valid after propagation delay
bundles/L1_basic/013_or_gate/testbench.v ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ `timescale 1ns/1ps
2
+
3
+ module tb_or_gate;
4
+ reg a;
5
+ reg b;
6
+ wire y;
7
+
8
+ // Instantiate the module under test
9
+ or_gate uut (
10
+
11
+ .a(a),
12
+ .b(b),
13
+ .y(y)
14
+ );
15
+
16
+ integer pass_count = 0;
17
+ integer fail_count = 0;
18
+
19
+ initial begin
20
+ $display("Testing or_gate...");
21
+
22
+ // Test 1
23
+ a = 1'b0; b = 1'b0; #10;
24
+ if ((y === 1'b0)) begin
25
+ pass_count = pass_count + 1;
26
+ end else begin
27
+ fail_count = fail_count + 1;
28
+ $display("[FAIL] Test 1");
29
+ end
30
+ // Test 2
31
+ a = 1'b1; b = 1'b0; #10;
32
+ if ((y === 1'b1)) begin
33
+ pass_count = pass_count + 1;
34
+ end else begin
35
+ fail_count = fail_count + 1;
36
+ $display("[FAIL] Test 2");
37
+ end
38
+ // Test 3
39
+ a = 1'b0; b = 1'b1; #10;
40
+ if ((y === 1'b1)) begin
41
+ pass_count = pass_count + 1;
42
+ end else begin
43
+ fail_count = fail_count + 1;
44
+ $display("[FAIL] Test 3");
45
+ end
46
+ // Test 4
47
+ a = 1'b1; b = 1'b1; #10;
48
+ if ((y === 1'b1)) begin
49
+ pass_count = pass_count + 1;
50
+ end else begin
51
+ fail_count = fail_count + 1;
52
+ $display("[FAIL] Test 4");
53
+ end
54
+
55
+ // Summary
56
+ $display("");
57
+ $display("=================================");
58
+ $display("PASS: %0d", pass_count);
59
+ $display("FAIL: %0d", fail_count);
60
+
61
+ if (fail_count == 0) begin
62
+ $display("TEST PASSED");
63
+ end else begin
64
+ $display("TEST FAILED");
65
+ end
66
+ $display("=================================");
67
+
68
+ $finish;
69
+ end
70
+ endmodule
bundles/L1_basic/014_xor_gate/config.yaml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ problem_id: '014'
2
+ title: XOR Gate
3
+ level: 1
4
+ category: basic_gates
5
+ description: Implement a 2-input XOR gate
6
+ module_name: xor_gate
7
+ ports:
8
+ a:
9
+ direction: input
10
+ width: 1
11
+ b:
12
+ direction: input
13
+ width: 1
14
+ y:
15
+ direction: output
16
+ width: 1
17
+ testbench_file: testbench.v
18
+ timeout_compile: 10
19
+ timeout_simulate: 30
20
+ require_synthesis: false
21
+ check_waveform: false
22
+ weight_functional: 1.0
23
+ weight_synthesis: 0.0
24
+ weight_resource: 0.0
bundles/L1_basic/014_xor_gate/problem.md ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # XOR Gate
2
+
3
+ **Level**: 1 (Basic Combinational Logic)
4
+ **Category**: basic_gates
5
+
6
+ ## Problem Description
7
+
8
+ Implement a 2-input XOR gate
9
+
10
+ ## Module Interface
11
+
12
+ ```verilog
13
+ module xor_gate(
14
+ input a, input b,
15
+ output y
16
+ );
17
+ ```
18
+
19
+ ## Specifications
20
+
21
+ **Inputs:**
22
+ - `a` (1-bit): Input signal
23
+ - `b` (1-bit): Input signal
24
+
25
+ **Outputs:**
26
+ - `y` (1-bit): Output signal
27
+
28
+ ## Examples
29
+
30
+ See testbench for comprehensive test cases.
31
+
32
+ ## Notes
33
+
34
+ - This is a purely combinational circuit
35
+ - No clock or reset signals needed
36
+ - Output should be valid after propagation delay
bundles/L1_basic/014_xor_gate/testbench.v ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ `timescale 1ns/1ps
2
+
3
+ module tb_xor_gate;
4
+ reg a;
5
+ reg b;
6
+ wire y;
7
+
8
+ // Instantiate the module under test
9
+ xor_gate uut (
10
+
11
+ .a(a),
12
+ .b(b),
13
+ .y(y)
14
+ );
15
+
16
+ integer pass_count = 0;
17
+ integer fail_count = 0;
18
+
19
+ initial begin
20
+ $display("Testing xor_gate...");
21
+
22
+ // Test 1
23
+ a = 1'b0; b = 1'b0; #10;
24
+ if ((y === 1'b0)) begin
25
+ pass_count = pass_count + 1;
26
+ end else begin
27
+ fail_count = fail_count + 1;
28
+ $display("[FAIL] Test 1");
29
+ end
30
+ // Test 2
31
+ a = 1'b1; b = 1'b0; #10;
32
+ if ((y === 1'b1)) begin
33
+ pass_count = pass_count + 1;
34
+ end else begin
35
+ fail_count = fail_count + 1;
36
+ $display("[FAIL] Test 2");
37
+ end
38
+ // Test 3
39
+ a = 1'b0; b = 1'b1; #10;
40
+ if ((y === 1'b1)) begin
41
+ pass_count = pass_count + 1;
42
+ end else begin
43
+ fail_count = fail_count + 1;
44
+ $display("[FAIL] Test 3");
45
+ end
46
+ // Test 4
47
+ a = 1'b1; b = 1'b1; #10;
48
+ if ((y === 1'b0)) begin
49
+ pass_count = pass_count + 1;
50
+ end else begin
51
+ fail_count = fail_count + 1;
52
+ $display("[FAIL] Test 4");
53
+ end
54
+
55
+ // Summary
56
+ $display("");
57
+ $display("=================================");
58
+ $display("PASS: %0d", pass_count);
59
+ $display("FAIL: %0d", fail_count);
60
+
61
+ if (fail_count == 0) begin
62
+ $display("TEST PASSED");
63
+ end else begin
64
+ $display("TEST FAILED");
65
+ end
66
+ $display("=================================");
67
+
68
+ $finish;
69
+ end
70
+ endmodule
bundles/L1_basic/015_nand_gate/config.yaml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ problem_id: '015'
2
+ title: NAND Gate
3
+ level: 1
4
+ category: basic_gates
5
+ description: Implement a 2-input NAND gate
6
+ module_name: nand_gate
7
+ ports:
8
+ a:
9
+ direction: input
10
+ width: 1
11
+ b:
12
+ direction: input
13
+ width: 1
14
+ y:
15
+ direction: output
16
+ width: 1
17
+ testbench_file: testbench.v
18
+ timeout_compile: 10
19
+ timeout_simulate: 30
20
+ require_synthesis: false
21
+ check_waveform: false
22
+ weight_functional: 1.0
23
+ weight_synthesis: 0.0
24
+ weight_resource: 0.0
bundles/L1_basic/015_nand_gate/problem.md ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # NAND Gate
2
+
3
+ **Level**: 1 (Basic Combinational Logic)
4
+ **Category**: basic_gates
5
+
6
+ ## Problem Description
7
+
8
+ Implement a 2-input NAND gate
9
+
10
+ ## Module Interface
11
+
12
+ ```verilog
13
+ module nand_gate(
14
+ input a, input b,
15
+ output y
16
+ );
17
+ ```
18
+
19
+ ## Specifications
20
+
21
+ **Inputs:**
22
+ - `a` (1-bit): Input signal
23
+ - `b` (1-bit): Input signal
24
+
25
+ **Outputs:**
26
+ - `y` (1-bit): Output signal
27
+
28
+ ## Examples
29
+
30
+ See testbench for comprehensive test cases.
31
+
32
+ ## Notes
33
+
34
+ - This is a purely combinational circuit
35
+ - No clock or reset signals needed
36
+ - Output should be valid after propagation delay
bundles/L1_basic/015_nand_gate/testbench.v ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ `timescale 1ns/1ps
2
+
3
+ module tb_nand_gate;
4
+ reg a;
5
+ reg b;
6
+ wire y;
7
+
8
+ // Instantiate the module under test
9
+ nand_gate uut (
10
+
11
+ .a(a),
12
+ .b(b),
13
+ .y(y)
14
+ );
15
+
16
+ integer pass_count = 0;
17
+ integer fail_count = 0;
18
+
19
+ initial begin
20
+ $display("Testing nand_gate...");
21
+
22
+ // Test 1
23
+ a = 1'b0; b = 1'b0; #10;
24
+ if ((y === 1'b1)) begin
25
+ pass_count = pass_count + 1;
26
+ end else begin
27
+ fail_count = fail_count + 1;
28
+ $display("[FAIL] Test 1");
29
+ end
30
+ // Test 2
31
+ a = 1'b1; b = 1'b0; #10;
32
+ if ((y === 1'b1)) begin
33
+ pass_count = pass_count + 1;
34
+ end else begin
35
+ fail_count = fail_count + 1;
36
+ $display("[FAIL] Test 2");
37
+ end
38
+ // Test 3
39
+ a = 1'b0; b = 1'b1; #10;
40
+ if ((y === 1'b1)) begin
41
+ pass_count = pass_count + 1;
42
+ end else begin
43
+ fail_count = fail_count + 1;
44
+ $display("[FAIL] Test 3");
45
+ end
46
+ // Test 4
47
+ a = 1'b1; b = 1'b1; #10;
48
+ if ((y === 1'b0)) begin
49
+ pass_count = pass_count + 1;
50
+ end else begin
51
+ fail_count = fail_count + 1;
52
+ $display("[FAIL] Test 4");
53
+ end
54
+
55
+ // Summary
56
+ $display("");
57
+ $display("=================================");
58
+ $display("PASS: %0d", pass_count);
59
+ $display("FAIL: %0d", fail_count);
60
+
61
+ if (fail_count == 0) begin
62
+ $display("TEST PASSED");
63
+ end else begin
64
+ $display("TEST FAILED");
65
+ end
66
+ $display("=================================");
67
+
68
+ $finish;
69
+ end
70
+ endmodule