You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+49-3Lines changed: 49 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -122,19 +122,51 @@ These examples serve as a learning resource or starting point for building, simu
122
122
34.**Mealy Finite State Machine (FSM)** – 🟢 Easy – 🏢 Google, Microsoft
123
123
- FSM where outputs depend on both current state and input.
124
124
125
+
## Implementation Notes
126
+
127
+
> [!NOTE]
128
+
> **Deviations from ChipDev.io Specifications**
129
+
>
130
+
> This repository makes two consistent changes across all implementations:
131
+
>
132
+
> 1.**Reset signal naming**: ChipDev.io uses various names (`resetn`, `reset_n`, `reset`). This repository uniformly uses **`rst_n`** for consistency.
133
+
>
134
+
> 2.**Generic parameters**: Some quests specify hardcoded bit widths. This repository adds **`DATA_WIDTH`** and similar generic parameters where appropriate to improve reusability.
135
+
>
136
+
> Some signal names from the original problems (e.g., port naming conventions) may not be optimal but were preserved to maintain alignment with the source material. Quest-specific deviations are documented in individual README files.
137
+
138
+
## Testbench Methodology
139
+
140
+
> [!NOTE]
141
+
> **Professional Verification Approach**
142
+
>
143
+
> All testbenches follow industry-standard practices:
144
+
>
145
+
> -**VUnit framework**: Automated test execution with pass/fail reporting
146
+
> -**OSVVM RandomPkg**: Constrained-random stimulus generation for better coverage than sequential patterns
147
+
> -**Dual verification**: Checker procedures use different coding styles than the DUT to avoid systematic errors
148
+
> -**Edge case testing**: Explicit tests for boundary conditions, resets, and corner cases
149
+
> -**ModelSim .do files**: Pre-configured waveform views for debugging
150
+
>
151
+
> Test strategies typically include:
152
+
>
153
+
> 1.**Directed tests**: Exhaustive testing of all valid states/combinations
154
+
> 2.**Random tests**: Hundreds of randomized inputs to catch unexpected corner cases
155
+
> 3.**Reset testing**: Verify proper initialization and reset behavior
156
+
125
157
## Minimum System Requirements
126
158
127
159
-**OS**: (Anything that can run the following)
128
-
***IDE**:
160
+
-**IDE**:
129
161
-[`VSCode latest`](https://code.visualstudio.com/download) with following plugins:
130
162
-[`Python`](https://marketplace.visualstudio.com/items?itemName=ms-python.python) by Microsoft
131
163
-[`Pylance`](https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance) by Microsoft
132
164
-[`Draw.io`](https://marketplace.visualstudio.com/items?itemName=hediet.vscode-drawio) by Henning Dieterichs
133
165
-[`Draw.io Integration: WaveDrom plugin`](https://marketplace.visualstudio.com/items?itemName=nopeslide.vscode-drawio-plugin-wavedrom) by nopeslide
134
166
-[`TerosHDL`](https://marketplace.visualstudio.com/items?itemName=teros-technology.teroshdl) by Teros Technology
135
167
-[`VHDL-LS`](https://marketplace.visualstudio.com/items?itemName=hbohlin.vhdl-ls) by Henrik Bohlin (Deactivate the one provided by TerosHDL)
136
-
***VHDL Simulator**: (Anything that supports **VHDL-2008**):
137
-
***Script execution environment**:
168
+
-**VHDL Simulator**: (Anything that supports **VHDL-2008**):
169
+
-**Script execution environment**:
138
170
-`Python 3.11.4` to automatise testing via **VUnit**
139
171
140
172
## Initial Setup
@@ -260,3 +292,17 @@ run_all_testbenches_lib(
260
292
xunit_xml="./test/res.xml"# Output file for test results
261
293
)
262
294
```
295
+
296
+
## License
297
+
298
+
All VHDL source code, testbenches, and scripts in this repository are licensed under the GNU General Public License v3.0 (GPLv3).
299
+
See the [LICENSE](./LICENSE) file for full details.
300
+
301
+
> [!NOTE]
302
+
> Problem statements and task descriptions referenced from [chipdev.io](https://chipdev.io) are **not** part of this license.
Build a router circuit which forwards data from the input (din) to one of four outputs (dout0, dout1, dout2, or dout3), specified by the address input (addr).
8
+
9
+
The address is a two bit value whose decimal representation determines which output value to use. Append to dout the decimal representation of addr to get the output signal name. For example, if addr=b11 then the decimal representation of addr is 3, so the output signal name is dout3.
10
+
11
+
The input has an enable signal (din_en), which allows the input to be forwarded to an output when enabled. If an output is not currently being driven to, then it should be set to 0.
12
+
13
+
### Input and Output Signals
14
+
15
+
`din` - Input data
16
+
`din_en` - Enable signal for din. Forwards data from input to an output if 1, does not forward data otherwise
17
+
`addr` - Two bit destination address. For example addr = b11 = 3 indicates din should be forwarded to output value 3 (dout3)
18
+
`dout0` - Output 0. Corresponds to addr = b00
19
+
`dout1` - Output 1. Corresponds to addr = b01
20
+
`dout2` - Output 2. Corresponds to addr = b10
21
+
`dout3` - Output 3. Corresponds to addr = b11
22
+
23
+
> [!NOTE]
24
+
> For the complete problem description, please visit:
25
+
> <https://chipdev.io/question/1>
26
+
27
+
## Description
28
+
29
+
Combinational router using a `case` statement to decode the 2-bit address and route input data to one of four outputs. All outputs default to zero, then the selected output is conditionally assigned when `din_en` is high. Synthesises to a simple 4:1 demultiplexer with AND gates gating the enable signal.
30
+
31
+
## Source
32
+
33
+
This quest is from [chipdev.io](https://chipdev.io/question/1).
34
+
35
+
The problem description above is used under fair use for educational purposes.
36
+
For licensing information, see [LICENSE-THIRD-PARTY.md](../../LICENSE-THIRD-PARTY.md).
Given a clocked sequence of unsigned values, output the second-largest value seen so far in the sequence. If only one value is seen, then the output (dout) should equal 0. Note that repeated values are treated as separate candidates for being the second largest value.
8
+
9
+
When the reset-low signal (`resetn`) goes low, all previous values seen in the input sequence should no longer be considered for the calculation of the second largest value, and the output dout should restart from 0 on the next cycle.
10
+
11
+
### Input and Output Signals
12
+
13
+
`clk` - Clock signal
14
+
`resetn` - Synchronous reset-low signal
15
+
`din` - Input data sequence
16
+
`dout` - Second-largest value seen so far
17
+
18
+
### Output signals during reset
19
+
20
+
`dout` - 0 when resetn is active
21
+
22
+
> [!NOTE]
23
+
> For the complete problem description, please visit:
24
+
> <https://chipdev.io/question/2>
25
+
26
+
## Description
27
+
28
+
Design a sequential circuit that monitors a stream of unsigned values and continuously outputs the **second-largest value** observed so far. If only a single value has been seen, then the output (`dout`) must remain `0`.
29
+
30
+
Each value, even if repeated, should be treated as a distinct observation. That means duplicates are still valid inputs when determining the second largest.
31
+
32
+
If the active-low reset (`resetn`) signal is asserted, any previously observed values must be discarded, and the calculation of the second-largest value starts fresh. In this reset state, `dout` should immediately return to `0`.
33
+
34
+
---
35
+
36
+
## Source Reference
37
+
38
+
This task is inspired by the "Second Largest" problem available at [chipdev.io](https://chipdev.io).
39
+
The description here has been paraphrased for clarity and adapted under fair use for educational and research purposes.
40
+
41
+
Please refer to [LICENSE.third_party.md](../LICENSE.third_party.md) for licensing information.
42
+
43
+
This quest is from [chipdev.io](https://chipdev.io/question/2).
Divide an input number by a power of two and round the result to the nearest integer. The power of two is calculated using 2^DIV_LOG2 where DIV_LOG2 is a module parameter. Remainders of 0.5 or greater should be rounded up to the nearest integer. If the output were to overflow, then the result should be saturated instead.
8
+
9
+
### Input and Output Signals
10
+
11
+
`din` - Input number
12
+
`dout` - Rounded result
13
+
14
+
> [!NOTE]
15
+
> For the complete problem description, please visit:
16
+
> <https://chipdev.io/question/3>
17
+
18
+
## Description
19
+
20
+
Divider that performs power-of-2 division with rounding.
21
+
The division is accomplished via right-shift by `DIV_LOG2` positions.
22
+
The rounding logic examines the bit at position `DIV_LOG2-1` (representing the 0.5 threshold) - if this bit is set, it adds 1 to the quotient.
23
+
The `resize()` function handles saturation when the result overflows the output width.
24
+
25
+
## Source
26
+
27
+
This quest is from [chipdev.io](https://chipdev.io/question/3).
28
+
29
+
The problem description above is used under fair use for educational purposes.
30
+
For licensing information, see [LICENSE-THIRD-PARTY.md](../../LICENSE-THIRD-PARTY.md).
Build a circuit that generates a Gray code sequence starting from 0 on the output (dout).
8
+
9
+
Gray code is an ordering of binary numbers such that two successive values only have one bit difference between them. For example, a Gray code sequence for a two bit value could be:
10
+
11
+
b00
12
+
b01
13
+
b11
14
+
b10
15
+
16
+
The Gray code sequence should use the standard encoding. In the standard encoding the least significant bit follows a repetitive pattern of 2 on, 2 off ( ... 11001100 ... ); the next digit a pattern of 4 on, 4 off ( ... 1111000011110000 ... ); the nth least significant bit a pattern of 2n on 2n off.
17
+
18
+
When the reset-low signal (resetn) goes to 0, the Gray code sequence should restart from 0.
19
+
20
+
### Input and Output Signals
21
+
22
+
`clk` - Clock signal
23
+
`resetn` - Synchronous reset-low signal
24
+
`out` - Gray code counter value
25
+
26
+
### Output signals during reset
27
+
28
+
`out` - 0 when resetn is active
29
+
30
+
> [!NOTE]
31
+
> For the complete problem description, please visit:
32
+
> <https://chipdev.io/question/4>
33
+
34
+
## Description
35
+
36
+
Combinational bit-reversal circuit using a loop that maps `dout(i) <= din(din'high - i)` to mirror the input vector.
37
+
Synthesises to pure wiring with no logic gates required.
38
+
39
+
## Source
40
+
41
+
This quest is from [chipdev.io](https://chipdev.io/question/4).
42
+
43
+
The problem description above is used under fair use for educational purposes.
44
+
For licensing information, see [LICENSE-THIRD-PARTY.md](../../LICENSE-THIRD-PARTY.md).
Reverse the bits of an input value's binary representation.
8
+
9
+
### Input and Output Signals
10
+
11
+
`din` - Input value
12
+
`dout` - Bitwise reversed value
13
+
14
+
> [!NOTE]
15
+
> For the complete problem description, please visit:
16
+
> <https://chipdev.io/question/5>
17
+
18
+
## Description
19
+
20
+
Sequential Gray code counter implemented as a binary counter with conversion output.
21
+
Each clock cycle increments a binary counter variable, then converts it to Gray code using the standard formula: `gray = count XOR shift_right(count, 1)`.
22
+
This produces the characteristic Gray code property where consecutive values differ by only one bit.
23
+
24
+
## Source
25
+
26
+
This quest is from [chipdev.io](https://chipdev.io/question/5).
27
+
28
+
The problem description above is used under fair use for educational purposes.
29
+
For licensing information, see [LICENSE-THIRD-PARTY.md](../../LICENSE-THIRD-PARTY.md).
Build a circuit that pulses `dout` one cycle after the rising edge of `din`. A pulse is defined as writing a single-cycle `1` as shown in the examples below. When `resetn` is asserted, the value of `din` should be treated as `0`.
8
+
9
+
Bonus - can you enhance your design to pulse `dout` on the same cycle as the rising edge? Note that this enhancement will not pass our test suite, but is still a useful exercise.
10
+
11
+
### Input and Output Signals
12
+
13
+
`clk` - Clock signal
14
+
`resetn` - Synchronous reset-low signal
15
+
`din` - Input signal
16
+
`dout` - Output signal
17
+
18
+
### Output signals during reset
19
+
20
+
`dout` - `0` when `resetn` is active
21
+
22
+
> [!NOTE]
23
+
> For the complete problem description, please visit:
24
+
> <https://chipdev.io/question/6>
25
+
26
+
## Description
27
+
28
+
Rising edge detector that registers the previous input value each clock cycle and outputs a single-cycle pulse when `din='1'` and differs from the registered value.
29
+
The comparison `din /= din_reg` detects the transition, while the `din = '1'` check ensures it's specifically a rising edge.
30
+
31
+
## Source
32
+
33
+
This quest is from [chipdev.io](https://chipdev.io/question/6).
34
+
35
+
The problem description above is used under fair use for educational purposes.
36
+
For licensing information, see [LICENSE-THIRD-PARTY.md](../../LICENSE-THIRD-PARTY.md).
Build a circuit that takes the multi-bit input (`din`) and shifts the input value's least significant bit (rightmost bit) to the single-bit output (`dout`) one bit at a time.
8
+
9
+
The circuit should begin shifting the input's least significant bit when the the input enable signal (`din_en`) goes high. In other words, the input enable signal going high indicates that this circuit should start shifting the current input signal from it's least significant bit, regardless of which bits the circuit has already shifted.
10
+
11
+
If all the input's bits have been shifted to the output so that there are no more bits to shift, the output must output `0`.
12
+
13
+
When reset (`resetn`) is active, the input value that is being shifted is treated as `0`. Even when reset goes back to being inactive, the input value will still be treated as `0`, unless the input enable signal makes the circuit begin shifting from the input again.
14
+
15
+
### Input and Output Signals
16
+
17
+
`clk` - Clock signal
18
+
`resetn` - Synchronous reset-low signal
19
+
`din` - Input signal
20
+
`din_en` - Enable signal for input data
21
+
`dout` - Output signal
22
+
23
+
### Output signals during reset
24
+
25
+
`dout` - `0` when `resetn` is active
26
+
27
+
> [!NOTE]
28
+
> For the complete problem description, please visit:
29
+
> <https://chipdev.io/question/7>
30
+
31
+
> [!NOTE]
32
+
> **Implementation Deviation**
33
+
>
34
+
> This implementation adds a `DATA_WIDTH` generic parameter for configurability, though the original problem doesn't specify a particular bit width.
35
+
36
+
## Description
37
+
38
+
Serializer that captures a parallel input word when `din_en` asserts and shifts it out LSB-first over subsequent clock cycles.
39
+
A `bit_index` counter tracks which bit to output, incrementing from 0 to `DATA_WIDTH-1`.
40
+
The captured data remains in `din_reg` until the entire word is transmitted, then zeros out.
41
+
42
+
## Source
43
+
44
+
This quest is from [chipdev.io](https://chipdev.io/question/7).
45
+
46
+
The problem description above is used under fair use for educational purposes.
47
+
For licensing information, see [LICENSE-THIRD-PARTY.md](../../LICENSE-THIRD-PARTY.md).
0 commit comments