-
Notifications
You must be signed in to change notification settings - Fork 0
Nselvara/issue14 #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nselvara/issue14 #33
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # Third-Party Content Notice | ||
|
|
||
| This repository contains references to external educational content from chipdev.io: | ||
|
|
||
| - Problem descriptions and prompts for HDL design challenges | ||
| - Referenced under fair use for non-commercial, educational, and illustrative purposes | ||
| - Original content © chipdev.io – All rights reserved | ||
|
|
||
| This repository is not affiliated with or endorsed by chipdev.io. | ||
| All problem statements remain the intellectual property of chipdev.io. | ||
|
|
||
| --- | ||
|
|
||
| The VHDL implementations, testbenches, and supporting infrastructure developed in this repository are licensed under: | ||
|
|
||
| **GNU General Public License v3.0 (GPLv3)** | ||
| See the main [LICENSE](./LICENSE) file for details. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # Quest 1 - Simple Router | ||
|
|
||
| ## Original Problem Statement | ||
|
|
||
| ### Prompt | ||
|
|
||
| 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). | ||
|
|
||
| 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. | ||
|
|
||
| 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. | ||
|
|
||
| ### Input and Output Signals | ||
|
|
||
| `din` - Input data | ||
| `din_en` - Enable signal for din. Forwards data from input to an output if 1, does not forward data otherwise | ||
| `addr` - Two bit destination address. For example addr = b11 = 3 indicates din should be forwarded to output value 3 (dout3) | ||
| `dout0` - Output 0. Corresponds to addr = b00 | ||
| `dout1` - Output 1. Corresponds to addr = b01 | ||
| `dout2` - Output 2. Corresponds to addr = b10 | ||
| `dout3` - Output 3. Corresponds to addr = b11 | ||
|
|
||
| > [!NOTE] | ||
| > For the complete problem description, please visit: | ||
| > <https://chipdev.io/question/1> | ||
|
|
||
| ## Description | ||
|
|
||
| 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. | ||
|
|
||
| ## Source | ||
|
|
||
| This quest is from [chipdev.io](https://chipdev.io/question/1). | ||
|
|
||
| The problem description above is used under fair use for educational purposes. | ||
| For licensing information, see [LICENSE-THIRD-PARTY.md](../../LICENSE-THIRD-PARTY.md). | ||
|
|
||
| **Webarchive link:** <https://web.archive.org/web/https://chipdev.io/question/1> |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,45 @@ | ||||||
| # Quest 2 – Second Largest | ||||||
|
|
||||||
| ## Original Problem Statement | ||||||
|
|
||||||
| ### Prompt | ||||||
|
|
||||||
| 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. | ||||||
|
|
||||||
| 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. | ||||||
|
|
||||||
| ### Input and Output Signals | ||||||
|
|
||||||
| `clk` - Clock signal | ||||||
| `resetn` - Synchronous reset-low signal | ||||||
| `din` - Input data sequence | ||||||
| `dout` - Second-largest value seen so far | ||||||
|
|
||||||
| ### Output signals during reset | ||||||
|
|
||||||
| `dout` - 0 when resetn is active | ||||||
|
|
||||||
| > [!NOTE] | ||||||
| > For the complete problem description, please visit: | ||||||
| > <https://chipdev.io/question/2> | ||||||
|
|
||||||
| ## Description | ||||||
|
|
||||||
| 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`. | ||||||
|
|
||||||
| Each value, even if repeated, should be treated as a distinct observation. That means duplicates are still valid inputs when determining the second largest. | ||||||
|
|
||||||
| 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`. | ||||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ## Source Reference | ||||||
|
|
||||||
| This task is inspired by the "Second Largest" problem available at [chipdev.io](https://chipdev.io). | ||||||
| The description here has been paraphrased for clarity and adapted under fair use for educational and research purposes. | ||||||
|
|
||||||
| Please refer to [LICENSE.third_party.md](../LICENSE.third_party.md) for licensing information. | ||||||
|
||||||
| Please refer to [LICENSE.third_party.md](../LICENSE.third_party.md) for licensing information. | |
| Please refer to [LICENSE-THIRD-PARTY.md](../LICENSE-THIRD-PARTY.md) for licensing information. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # Quest 3 - Rounding Division | ||
|
|
||
| ## Original Problem Statement | ||
|
|
||
| ### Prompt | ||
|
|
||
| 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. | ||
|
|
||
| ### Input and Output Signals | ||
|
|
||
| `din` - Input number | ||
| `dout` - Rounded result | ||
|
|
||
| > [!NOTE] | ||
| > For the complete problem description, please visit: | ||
| > <https://chipdev.io/question/3> | ||
|
|
||
| ## Description | ||
|
|
||
| Divider that performs power-of-2 division with rounding. | ||
| The division is accomplished via right-shift by `DIV_LOG2` positions. | ||
| 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. | ||
| The `resize()` function handles saturation when the result overflows the output width. | ||
|
|
||
| ## Source | ||
|
|
||
| This quest is from [chipdev.io](https://chipdev.io/question/3). | ||
|
|
||
| The problem description above is used under fair use for educational purposes. | ||
| For licensing information, see [LICENSE-THIRD-PARTY.md](../../LICENSE-THIRD-PARTY.md). | ||
|
|
||
| **Webarchive link:** <https://web.archive.org/web/https://chipdev.io/question/3> |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,46 @@ | ||||||||||
| # Quest 4 - Gray Code Counter | ||||||||||
|
||||||||||
| # Quest 4 - Gray Code Counter | |
| # Quest 4 - Bit Reverser |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description section contradicts the prompt. The prompt asks to "Build a circuit that generates a Gray code sequence" but the description discusses "Combinational bit-reversal circuit" which is unrelated to Gray code generation.
| Combinational bit-reversal circuit using a loop that maps `dout(i) <= din(din'high - i)` to mirror the input vector. | |
| Synthesises to pure wiring with no logic gates required. | |
| Synchronous Gray code counter that advances to the next Gray code value on each rising edge of `clk`. | |
| When `resetn` is asserted low, the counter synchronously resets so that `out` returns to 0 and the standard Gray code sequence restarts from the beginning. |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,31 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Quest 5 - Reversing Bits | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Original Problem Statement | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| ### Prompt | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| Reverse the bits of an input value's binary representation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| ### Input and Output Signals | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| `din` - Input value | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| `dout` - Bitwise reversed value | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+12
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Quest 5 - Reversing Bits | |
| ## Original Problem Statement | |
| ### Prompt | |
| Reverse the bits of an input value's binary representation. | |
| ### Input and Output Signals | |
| `din` - Input value | |
| `dout` - Bitwise reversed value | |
| # Quest 5 - Gray Code Converter | |
| ## Original Problem Statement | |
| ### Prompt | |
| Implement a sequential Gray code counter that outputs the Gray code representation of an internal binary count value. | |
| ### Input and Output Signals | |
| `clk` - Clock input | |
| `rst` - Synchronous or asynchronous reset (implementation-specific) | |
| `dout` - Gray-coded output value corresponding to the current counter state |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description section contradicts the prompt. The prompt asks to "Reverse the bits of an input value's binary representation" but the description discusses "Sequential Gray code counter" which is unrelated to bit reversal.
| Sequential Gray code counter implemented as a binary counter with conversion output. | |
| 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)`. | |
| This produces the characteristic Gray code property where consecutive values differ by only one bit. | |
| Combinational circuit that reverses the bit order of the input word. | |
| For an N-bit input `din[N-1:0]`, the output `dout[N-1:0]` is defined by `dout[i] = din[N-1-i]` for all valid bit indices. | |
| This operation is a pure bit permutation (no arithmetic): the most significant bit of `din` becomes the least significant bit of `dout`, and so on for all bits. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # Quest 6 – Edge Detector | ||
|
|
||
| ## Original Problem Statement | ||
|
|
||
| ### Prompt | ||
|
|
||
| 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`. | ||
|
|
||
| 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. | ||
|
|
||
| ### Input and Output Signals | ||
|
|
||
| `clk` - Clock signal | ||
| `resetn` - Synchronous reset-low signal | ||
| `din` - Input signal | ||
| `dout` - Output signal | ||
|
|
||
| ### Output signals during reset | ||
|
|
||
| `dout` - `0` when `resetn` is active | ||
|
|
||
| > [!NOTE] | ||
| > For the complete problem description, please visit: | ||
| > <https://chipdev.io/question/6> | ||
|
|
||
| ## Description | ||
|
|
||
| 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. | ||
| The comparison `din /= din_reg` detects the transition, while the `din = '1'` check ensures it's specifically a rising edge. | ||
|
|
||
| ## Source | ||
|
|
||
| This quest is from [chipdev.io](https://chipdev.io/question/6). | ||
|
|
||
| The problem description above is used under fair use for educational purposes. | ||
| For licensing information, see [LICENSE-THIRD-PARTY.md](../../LICENSE-THIRD-PARTY.md). | ||
|
|
||
| **Webarchive link:** <https://web.archive.org/web/https://chipdev.io/question/6> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Quest 7 – Serialiser | ||
|
|
||
| ## Original Problem Statement | ||
|
|
||
| ### Prompt | ||
|
|
||
| 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. | ||
|
|
||
| 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. | ||
|
|
||
| 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`. | ||
|
|
||
| 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. | ||
|
|
||
| ### Input and Output Signals | ||
|
|
||
| `clk` - Clock signal | ||
| `resetn` - Synchronous reset-low signal | ||
| `din` - Input signal | ||
| `din_en` - Enable signal for input data | ||
| `dout` - Output signal | ||
|
|
||
| ### Output signals during reset | ||
|
|
||
| `dout` - `0` when `resetn` is active | ||
|
|
||
| > [!NOTE] | ||
| > For the complete problem description, please visit: | ||
| > <https://chipdev.io/question/7> | ||
|
|
||
| > [!NOTE] | ||
| > **Implementation Deviation** | ||
| > | ||
| > This implementation adds a `DATA_WIDTH` generic parameter for configurability, though the original problem doesn't specify a particular bit width. | ||
|
|
||
| ## Description | ||
|
|
||
| Serializer that captures a parallel input word when `din_en` asserts and shifts it out LSB-first over subsequent clock cycles. | ||
| A `bit_index` counter tracks which bit to output, incrementing from 0 to `DATA_WIDTH-1`. | ||
| The captured data remains in `din_reg` until the entire word is transmitted, then zeros out. | ||
|
|
||
| ## Source | ||
|
|
||
| This quest is from [chipdev.io](https://chipdev.io/question/7). | ||
|
|
||
| The problem description above is used under fair use for educational purposes. | ||
| For licensing information, see [LICENSE-THIRD-PARTY.md](../../LICENSE-THIRD-PARTY.md). | ||
|
|
||
| **Webarchive link:** <https://web.archive.org/web/https://chipdev.io/question/7> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The word "automatise" should be "automate" in American English, which is the standard used throughout the rest of the documentation.