# Decimal to 7-seg display with Reset
---
**學號:B1095105
姓名:李彥霆
指導老師:林宏益**
---
# 1.實驗目的
實現Decimal to 7-seg display with Reset(RTL、Testbench),並嘗試在工作站上進行編譯、驗證和查看波形。
>
>
> 實驗所附真值表
# 2.實驗結果
### RTL
```
module dec_7seg (Reset_n, Dec_input,a,b,c,d,e,f,g,dp);
input Reset_n;
input [3:0]Dec_input;
reg [7:0]seg_out;
output a,b,c,d,e,f,g,dp;
always@(Dec_input or Reset_n)
begin
if (Reset_n)
begin
case (Dec_input)
4'b0000:seg_out = 8'b00000011;
4'b0001:seg_out = 8'b10011111;
4'b0010:seg_out = 8'b00100101;
4'b0011:seg_out = 8'b00001101;
4'b0100:seg_out = 8'b10011001;
4'b0101:seg_out = 8'b01001001;
4'b0110:seg_out = 8'b01000001;
4'b0111:seg_out = 8'b00011111;
4'b1000:seg_out = 8'b00000001;
4'b1001:seg_out = 8'b00001001;
4'b1010:seg_out = 8'b00010001;
4'b1011:seg_out = 8'b11000001;
4'b1100:seg_out = 8'b11100101;
4'b1101:seg_out = 8'b10000101;
4'b1110:seg_out = 8'b01100001;
4'b1111:seg_out = 8'b01110001;
default:seg_out=8'b10010001;
endcase
end
else
seg_out=8'b10010001;
end
assign a = seg_out[7];
assign b = seg_out[6];
assign c = seg_out[5];
assign d = seg_out[4];
assign e = seg_out[3];
assign f = seg_out[2];
assign g = seg_out[1];
assign dp = seg_out[0];
endmodule
```
### Testbench
```
module dec_7seg_tb;
reg Reset_n;
reg [3:0] Dec_input;
reg [7:0] seg_out;
wire a,b,c,d,e,f,g,dp;
integer i;
initial
begin
$dumpfile("dec_7seg.vcd");
$dumpvars(0, s);
for ( i=0; i<16; i=i+1)
begin
Reset_n = 1;
{Dec_input} = i;
#50;
end
for ( i=0; i<16; i=i+1)
begin
Reset_n = 0;
{Dec_input} = i;
#50;
end
#50$finish;
end
dec_7seg s(Reset_n, Dec_input,a,b,c,d,e,f,g,dp);
endmodule
```
### Schematic
>
>Synthesis前
>
>Synthesis後
### On-Chip Power
>
### nWave
>
>Reset_n = 0
>
>Reset_n = 1
### PYNQ-Z2
>
>Reset_n=0,output=H
>
>Reset_n=1,Dec_input=0,output=0
>
>Reset_n=1,Dec_input=1,output=1
>
>Reset_n=1,Dec_input=2,output=2
>
>Reset_n=1,Dec_input=3,output=3
>
>Reset_n=1,Dec_input=4,output=4
>
>Reset_n=1,Dec_input=5,output=5
>
>Reset_n=1,Dec_input=6,output=6
>
>Reset_n=1,Dec_input=7,output=7
>
>Reset_n=1,Dec_input=8,output=8
>
>Reset_n=1,Dec_input=9,output=9
>
>Reset_n=1,Dec_input=10,output=A
>
>Reset_n=1,Dec_input=11,output=b
>
>Reset_n=1,Dec_input=12,output=c
>
>Reset_n=1,Dec_input=13,output=d
>
>Reset_n=1,Dec_input=14,output=E
>
>Reset_n=1,Dec_input=15,output=F
# 3.實驗心得
這次的作業,老師主要是想讓我們試著在工作站上使用各種EDA工具(VCS、Verdi)進行RTL的撰寫、模擬並觀看波形,而我在進行專題時就有使用過這些工具,因此這次作業也算是在幫我複習了一遍。
# 4.參考文獻
>漫談七段顯示器
>https://www.slideshare.net/ssuser1f4677/ss-78737038