-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
48 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
// Assignment: Create a counter with a direction flag | ||
|
||
// student submission (13 logic cells) | ||
always_comb begin | ||
for (int i = 0; i<WIDTH; i++) begin | ||
// logic here is to toggle if counting up and lowerbits = max | ||
// or counting down and lowerbits = 0 | ||
lower_mask = (1<<i) - 1; | ||
count_d[i] = | ||
count_q[i] ^ (~dir_i & (count_q & lower_mask) == lower_mask | | ||
dir_i & (count_q & lower_mask) == 0); | ||
end | ||
end | ||
|
||
// teacher solution (14 logic cells) | ||
always_comb begin | ||
count_d = count_q + ((dir_i) ? -1 : 1); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
\begin{figure}[t] | ||
\centering | ||
\inputminted[frame=single]{systemverilog}{code/unreadable_opt.svh} | ||
\caption{Student drastically reduced readability and transferability in order to save 1 logic cell over the teacher solution.} | ||
\label{fig:unreadable_opt} | ||
\end{figure} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters