Skip to content

Commit ac355f1

Browse files
committed
Initial Commit
0 parents  commit ac355f1

16 files changed

+463
-0
lines changed

.clang-format

+177
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
---
2+
Language: Cpp
3+
BasedOnStyle: LLVM
4+
AccessModifierOffset: -2
5+
AlignAfterOpenBracket: DontAlign
6+
AlignArrayOfStructures: None
7+
AlignConsecutiveMacros: false
8+
AlignConsecutiveAssignments: false
9+
AlignConsecutiveBitFields: false
10+
AlignConsecutiveDeclarations: false
11+
AlignEscapedNewlines: Right
12+
AlignOperands: DontAlign
13+
AlignTrailingComments: true
14+
AllowAllArgumentsOnNextLine: false
15+
AllowAllConstructorInitializersOnNextLine: false
16+
AllowAllParametersOfDeclarationOnNextLine: false
17+
AllowShortEnumsOnASingleLine: true
18+
AllowShortBlocksOnASingleLine: Empty
19+
AllowShortCaseLabelsOnASingleLine: false
20+
AllowShortFunctionsOnASingleLine: Empty
21+
AllowShortLambdasOnASingleLine: All
22+
AllowShortIfStatementsOnASingleLine: Never
23+
AllowShortLoopsOnASingleLine: false
24+
AlwaysBreakAfterDefinitionReturnType: None
25+
AlwaysBreakAfterReturnType: None
26+
AlwaysBreakBeforeMultilineStrings: true
27+
AlwaysBreakTemplateDeclarations: No
28+
AttributeMacros:
29+
- __capability
30+
BinPackArguments: true
31+
BinPackParameters: true
32+
BraceWrapping:
33+
AfterCaseLabel: false
34+
AfterClass: false
35+
AfterControlStatement: Never
36+
AfterEnum: false
37+
AfterFunction: false
38+
AfterNamespace: false
39+
AfterObjCDeclaration: false
40+
AfterStruct: false
41+
AfterUnion: false
42+
AfterExternBlock: false
43+
BeforeCatch: false
44+
BeforeElse: false
45+
BeforeLambdaBody: false
46+
BeforeWhile: false
47+
IndentBraces: false
48+
SplitEmptyFunction: true
49+
SplitEmptyRecord: true
50+
SplitEmptyNamespace: true
51+
BreakBeforeBinaryOperators: None
52+
BreakBeforeConceptDeclarations: true
53+
BreakBeforeBraces: Attach
54+
BreakBeforeInheritanceComma: false
55+
BreakInheritanceList: BeforeColon
56+
BreakBeforeTernaryOperators: true
57+
BreakConstructorInitializersBeforeComma: false
58+
BreakConstructorInitializers: BeforeColon
59+
BreakAfterJavaFieldAnnotations: false
60+
BreakStringLiterals: true
61+
ColumnLimit: 80
62+
CommentPragmas: '^ IWYU pragma:'
63+
CompactNamespaces: false
64+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
65+
ConstructorInitializerIndentWidth: 4
66+
ContinuationIndentWidth: 4
67+
Cpp11BracedListStyle: true
68+
DeriveLineEnding: true
69+
DerivePointerAlignment: false
70+
DisableFormat: false
71+
EmptyLineAfterAccessModifier: Never
72+
EmptyLineBeforeAccessModifier: LogicalBlock
73+
ExperimentalAutoDetectBinPacking: false
74+
FixNamespaceComments: true
75+
ForEachMacros:
76+
- foreach
77+
- Q_FOREACH
78+
- BOOST_FOREACH
79+
IfMacros:
80+
- KJ_IF_MAYBE
81+
IncludeBlocks: Preserve
82+
IncludeCategories:
83+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
84+
Priority: 2
85+
SortPriority: 0
86+
CaseSensitive: false
87+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
88+
Priority: 3
89+
SortPriority: 0
90+
CaseSensitive: false
91+
- Regex: '.*'
92+
Priority: 1
93+
SortPriority: 0
94+
CaseSensitive: false
95+
IncludeIsMainRegex: '(Test)?$'
96+
IncludeIsMainSourceRegex: ''
97+
IndentAccessModifiers: false
98+
IndentCaseLabels: true
99+
IndentCaseBlocks: false
100+
IndentGotoLabels: true
101+
IndentPPDirectives: None
102+
IndentExternBlock: AfterExternBlock
103+
IndentRequires: false
104+
IndentWidth: 2
105+
IndentWrappedFunctionNames: false
106+
InsertTrailingCommas: None
107+
JavaScriptQuotes: Leave
108+
JavaScriptWrapImports: true
109+
KeepEmptyLinesAtTheStartOfBlocks: true
110+
LambdaBodyIndentation: Signature
111+
MacroBlockBegin: ''
112+
MacroBlockEnd: ''
113+
MaxEmptyLinesToKeep: 2
114+
NamespaceIndentation: None
115+
ObjCBinPackProtocolList: Auto
116+
ObjCBlockIndentWidth: 2
117+
ObjCBreakBeforeNestedBlockParam: true
118+
ObjCSpaceAfterProperty: false
119+
ObjCSpaceBeforeProtocolList: true
120+
PenaltyBreakAssignment: 2
121+
PenaltyBreakBeforeFirstCallParameter: 19
122+
PenaltyBreakComment: 300
123+
PenaltyBreakFirstLessLess: 120
124+
PenaltyBreakString: 1000
125+
PenaltyBreakTemplateDeclaration: 10
126+
PenaltyExcessCharacter: 1000000
127+
PenaltyReturnTypeOnItsOwnLine: 60
128+
PenaltyIndentedWhitespace: 0
129+
PointerAlignment: Left
130+
PPIndentWidth: -1
131+
ReferenceAlignment: Pointer
132+
ReflowComments: true
133+
ShortNamespaceLines: 1
134+
SortIncludes: CaseInsensitive
135+
SortJavaStaticImport: Before
136+
SortUsingDeclarations: true
137+
SpaceAfterCStyleCast: true
138+
SpaceAfterLogicalNot: false
139+
SpaceAfterTemplateKeyword: true
140+
SpaceBeforeAssignmentOperators: true
141+
SpaceBeforeCaseColon: false
142+
SpaceBeforeCpp11BracedList: true
143+
SpaceBeforeCtorInitializerColon: true
144+
SpaceBeforeInheritanceColon: true
145+
SpaceBeforeParens: Never
146+
SpaceAroundPointerQualifiers: Default
147+
SpaceBeforeRangeBasedForLoopColon: true
148+
SpaceInEmptyBlock: false
149+
SpaceInEmptyParentheses: false
150+
SpacesBeforeTrailingComments: 1
151+
SpacesInAngles: Never
152+
SpacesInConditionalStatement: false
153+
SpacesInContainerLiterals: false
154+
SpacesInCStyleCastParentheses: false
155+
SpacesInLineCommentPrefix:
156+
Minimum: 1
157+
Maximum: -1
158+
SpacesInParentheses: false
159+
SpacesInSquareBrackets: false
160+
SpaceBeforeSquareBrackets: false
161+
BitFieldColonSpacing: Both
162+
Standard: Latest
163+
StatementAttributeLikeMacros:
164+
- Q_EMIT
165+
StatementMacros:
166+
- Q_UNUSED
167+
- QT_REQUIRE_VERSION
168+
TabWidth: 8
169+
UseCRLF: false
170+
UseTab: Never
171+
WhitespaceSensitiveMacros:
172+
- STRINGIZE
173+
- PP_STRINGIZE
174+
- BOOST_PP_STRINGIZE
175+
- NS_SWIFT_NAME
176+
- CF_SWIFT_NAME
177+
...

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.vscode
2+
build/

CMakeLists.txt

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
cmake_minimum_required(VERSION 3.25)
2+
3+
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
4+
include(FetchContent)
5+
FetchContent_Declare(
6+
vcpkg
7+
GIT_REPOSITORY https://github.com/microsoft/vcpkg.git
8+
GIT_TAG master
9+
GIT_SHALLOW TRUE
10+
)
11+
FetchContent_MakeAvailable(vcpkg)
12+
set(CMAKE_TOOLCHAIN_FILE
13+
${vcpkg_SOURCE_DIR}/scripts/buildsystems/vcpkg.cmake
14+
CACHE FILEPATH "Vcpkg toolchain file"
15+
)
16+
endif()
17+
18+
project(week-two-lab)
19+
20+
set(NYU_BUILD_TESTS TRUE)
21+
22+
find_package(nyu-cmake CONFIG REQUIRED)
23+
find_package(Catch2 3 CONFIG REQUIRED)
24+
25+
nyu_setup_test(
26+
TEST_NAME exercise1
27+
TOP_MODULE Exercise1
28+
CPP_SOURCES dv/exercise1.cpp
29+
CPP_LIBS Catch2::Catch2WithMain
30+
SV_SOURCES rtl/Exercise1.sv
31+
)
32+
33+
nyu_setup_test(
34+
TEST_NAME exercise2
35+
TOP_MODULE Exercise2
36+
CPP_SOURCES dv/exercise2.cpp
37+
CPP_LIBS Catch2::Catch2WithMain
38+
SV_SOURCES rtl/Exercise2.sv
39+
)
40+
target_compile_features(exercise2 PRIVATE cxx_std_20)
41+
42+
nyu_setup_test(
43+
TEST_NAME exercise3
44+
TOP_MODULE Exercise3
45+
CPP_SOURCES dv/exercise3.cpp
46+
CPP_LIBS Catch2::Catch2WithMain
47+
SV_SOURCES rtl/Exercise3.sv rtl/Mysteries/Mystery1.sv rtl/Mysteries/Mystery2.sv
48+
)
49+
50+
nyu_setup_test(
51+
TEST_NAME exercise4
52+
TOP_MODULE Exercise4
53+
CPP_SOURCES dv/exercise4.cpp
54+
CPP_LIBS Catch2::Catch2WithMain
55+
SV_SOURCES rtl/Exercise4.sv
56+
)

ReadMe.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Week 3 Lab: Verification
2+
3+
Fill out this readme as required by lab guidance

dv/exercise1.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include <VExercise1.h>
2+
3+
int main() {
4+
VExercise1 model;
5+
}

dv/exercise2.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include <VExercise2.h>
2+
3+
int main() {
4+
VExercise2 model;
5+
}

dv/exercise3.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include <VExercise3.h>
2+
3+
int main() {
4+
VExercise3 model;
5+
}

dv/exercise4.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include <VExercise4.h>
2+
3+
int main() {
4+
VExercise4 model;
5+
}

rtl/Exercise1.sv

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
@brief A simple ALU-like module
3+
4+
@input op opcode for the operation to perform
5+
@input a input to calculation
6+
@input b input to calulation
7+
@output out result of calculation
8+
*/
9+
module Exercise1 (
10+
input [1:0] op,
11+
input [7:0] a,
12+
input [7:0] b,
13+
output logic [7:0] out
14+
);
15+
always_comb
16+
case (op)
17+
0: out = a ^ b;
18+
1: out = a << b;
19+
2: out = a % b;
20+
3: out = ~(a & b);
21+
endcase
22+
endmodule

rtl/Exercise2.sv

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
@brief A fibonacci linear feedback shift register module
3+
4+
@input clk clock
5+
@input reset active-high reset
6+
@input init inverse of initial value following a reset
7+
@output out current output
8+
*/
9+
module Exercise2 (
10+
input clk,
11+
input reset,
12+
input [15:0] init,
13+
output logic [15:0] out
14+
);
15+
always_ff @(negedge clk)
16+
if (reset) out <= ~init;
17+
else out <= {out[14:0], out[10] ^ out[8] ^ out[3] ^ out[1]};
18+
endmodule

rtl/Exercise3.sv

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
@brief A module of mysterious purpose
3+
4+
@input clk clock
5+
@input nReset active-low reset
6+
@input a an input
7+
@input b an input
8+
@input c an input
9+
10+
@output out output
11+
*/
12+
module Exercise3 (
13+
input clk,
14+
input reset,
15+
input [3:0] a,
16+
input [15:0] b,
17+
input [15:0] c,
18+
output [15:0] out
19+
);
20+
logic [7:0] a_in;
21+
logic [7:0] b_in;
22+
23+
Mystery1 alpha (
24+
.a(a[1:0]),
25+
.b(b[7:0]),
26+
.c(c[7:0]),
27+
.d(a_in)
28+
);
29+
Mystery1 beta (
30+
.a(a[3:2]),
31+
.b(b[15:8]),
32+
.c(c[15:8]),
33+
.d(b_in)
34+
);
35+
36+
Mystery2 gamma (.*);
37+
endmodule

rtl/Exercise4.sv

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
@brief An asynchronous mux/decoder
3+
4+
@input sel input select
5+
@input cs chip select
6+
7+
@input alpha alpha input
8+
@input beta beta input
9+
@input gamma gamma input
10+
11+
@output out output
12+
*/
13+
module Exercise4 (
14+
input [1:0] sel,
15+
input cs,
16+
17+
input [7:0] alpha,
18+
input [7:0] beta,
19+
input [7:0] gamma,
20+
21+
output logic [7:0] out
22+
);
23+
always_comb begin
24+
if (!cs) out = 0;
25+
else
26+
case (sel)
27+
0: out = alpha;
28+
1: out = beta;
29+
2: out = gamma;
30+
default: out = alpha & (beta | gamma);
31+
endcase
32+
end
33+
endmodule

0 commit comments

Comments
 (0)