Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sv2v
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
sv2v
Commits
ef42fc04
Commit
ef42fc04
authored
Mar 27, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use builtin $clog2 in test/relong/array.v
parent
a646a858
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
21 deletions
+2
-21
test/relong/array.v
+2
-21
No files found.
test/relong/array.v
View file @
ef42fc04
...
@@ -41,31 +41,13 @@ endmodule
...
@@ -41,31 +41,13 @@ endmodule
module
Array
#(
parameter
ELEMENTS
=
16
,
WIDTH
=
32
)(
module
Array
#(
parameter
ELEMENTS
=
16
,
WIDTH
=
32
)(
input
wire
[
clog2
(
ELEMENTS
)
-
1
:
0
]
index
,
input
wire
[
$
clog2
(
ELEMENTS
)
-
1
:
0
]
index
,
input
wire
[
WIDTH
-
1
:
0
]
element
,
input
wire
[
WIDTH
-
1
:
0
]
element
,
// Flattened array
// Flattened array
output
wire
[(
ELEMENTS
*
WIDTH
)
-
1
:
0
]
array
,
output
wire
[(
ELEMENTS
*
WIDTH
)
-
1
:
0
]
array
,
input
wire
clock
,
clear
,
enable
input
wire
clock
,
clear
,
enable
)
;
)
;
// Manually implemented clog2 (which the toolchain could in theory just copy
// into the source where-ever the build-in $clog2 is referenced)
// Verilog functions are super gross. This is defining a function called
// clog2 which takes a 32-bit input value.
function
integer
clog2
;
input
[
31
:
0
]
value
;
begin
value
=
value
-
1
;
// The return value is simply a variable with the same name as the
// function and the last value written to that variable is the return
// value.
for
(
clog2
=
0
;
value
>
0
;
clog2
=
clog2
+
1
)
begin
value
=
value
>>
1
;
end
end
endfunction
reg
[
WIDTH
-
1
:
0
]
__
array
[
ELEMENTS
-
1
:
0
]
;
reg
[
WIDTH
-
1
:
0
]
__
array
[
ELEMENTS
-
1
:
0
]
;
genvar
g_index
;
genvar
g_index
;
generate
generate
...
@@ -86,4 +68,4 @@ module Array #(parameter ELEMENTS=16, WIDTH=32)(
...
@@ -86,4 +68,4 @@ module Array #(parameter ELEMENTS=16, WIDTH=32)(
end
else
if
(
enable
)
end
else
if
(
enable
)
__
array
[
index
]
<=
element
;
__
array
[
index
]
<=
element
;
endmodule
endmodule
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment