Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Zhuoyu Zhang
SD_HW4
Commits
7e773922
Commit
7e773922
authored
Mar 27, 2023
by
Zhuoyu Zhang
Browse files
Upload New File
parent
d63a5443
Changes
1
Hide whitespace changes
Inline
Side-by-side
README.md
0 → 100644
View file @
7e773922
# HW4第一题说明
### 一、文件结构
*
sim:存放modelsim工程文件
*
src: 存放Verilog源代码
*
README.md: 说明文档
### 二、源代码
*
encoder_d.v :
```
verilog
module
encoder_d
(
D
,
x
,
y
,
V
);
input
[
3
:
0
]
D
;
output
x
,
y
,
V
;
wire
[
3
:
0
]
D
;
reg
x
,
y
,
V
;
always
@
(
D
)
begin
if
(
D
[
3
])
begin
x
=
1'b1
;
y
=
1'b1
;
V
=
1'b1
;
end
else
if
(
D
[
2
])
begin
x
=
1'b1
;
y
=
1'b0
;
V
=
1'b1
;
end
else
if
(
D
[
1
])
begin
x
=
1'b0
;
y
=
1'b1
;
V
=
1'b1
;
end
else
if
(
D
[
0
])
begin
x
=
1'b0
;
y
=
1'b0
;
V
=
1'b1
;
end
else
begin
x
=
1'b0
;
y
=
1'b0
;
V
=
1'b0
;
end
end
endmodule
```
*
encoder_tb.v:
```
verilog
`timescale
1
ns
/
1
ps
`include
"encoder_d.v"
module
encoder_tb
(
D
,
x
,
y
,
V
);
output
[
3
:
0
]
D
;
input
x
,
y
,
V
;
reg
[
3
:
0
]
D
;
wire
x
,
y
,
V
;
encoder_d
enc
(
D
,
x
,
y
,
V
);
initial
begin
#
10
D
=
4'b0000
;
#
10
D
=
4'b0001
;
#
10
D
=
4'b0010
;
#
10
D
=
4'b0100
;
#
10
D
=
4'b0101
;
#
10
D
=
4'b0110
;
#
10
D
=
4'b0111
;
#
10
D
=
4'b1000
;
#
10
D
=
4'b1001
;
#
10
D
=
4'b1010
;
#
10
D
=
4'b1011
;
#
10
D
=
4'b1100
;
#
10
D
=
4'b1101
;
#
10
D
=
4'b1110
;
#
10
D
=
4'b1111
;
#
10
$
finish
;
end
endmodule
```
### 三、仿真结果

### 四、其他
代码已保存在个人gitlab主页,如文件打开有问题可查看gitlab:
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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