---
# System prepended metadata

title: Decimal to 7-seg display with Reset

---

# Decimal to 7-seg display with Reset
---
**學號:B1095105
姓名:李彥霆
指導老師:林宏益**

---

#  1.實驗目的
實現Decimal to 7-seg display with Reset(RTL、Testbench)，並嘗試在工作站上進行編譯、驗證和查看波形。
>![](https://hackmd.io/_uploads/r1FUXx3Mp.png)

>![](https://hackmd.io/_uploads/HyBm5Rsza.png)
> 實驗所附真值表

# 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
>![](https://hackmd.io/_uploads/BJh7fGAf6.png)
>Synthesis前

>![](https://hackmd.io/_uploads/ryQLXfCG6.png)
>Synthesis後

### On-Chip Power
>![](https://hackmd.io/_uploads/rJv2YtRz6.png)


### nWave
>![](https://hackmd.io/_uploads/B1eA8rRGT.png)
>Reset_n = 0

>![](https://hackmd.io/_uploads/SJQfPr0zp.png)
>Reset_n = 1

### PYNQ-Z2
>![image.png](https://hackmd.io/_uploads/r1oXlELm6.png)
>Reset_n=0,output=H

>![image.png](https://hackmd.io/_uploads/HkNdxV8Xp.png)
>Reset_n=1,Dec_input=0,output=0

>![image.png](https://hackmd.io/_uploads/rJ1jgEUQ6.png)
>Reset_n=1,Dec_input=1,output=1

>![image.png](https://hackmd.io/_uploads/BJAnlNLQT.png)
>Reset_n=1,Dec_input=2,output=2

>![image.png](https://hackmd.io/_uploads/SymJb4LXa.png)
>Reset_n=1,Dec_input=3,output=3

>![image.png](https://hackmd.io/_uploads/r1WxbN8X6.png)
>Reset_n=1,Dec_input=4,output=4

>![image.png](https://hackmd.io/_uploads/Sk1ZbVUmT.png)
>Reset_n=1,Dec_input=5,output=5

>![image.png](https://hackmd.io/_uploads/Syef-VUmp.png)
>Reset_n=1,Dec_input=6,output=6

>![image.png](https://hackmd.io/_uploads/SJCM-NIma.png)
>Reset_n=1,Dec_input=7,output=7

>![image.png](https://hackmd.io/_uploads/rkimbEImT.png)
>Reset_n=1,Dec_input=8,output=8

>![image.png](https://hackmd.io/_uploads/ByjEb4Lm6.png)
>Reset_n=1,Dec_input=9,output=9

>![image.png](https://hackmd.io/_uploads/BJx5BWEIQ6.png)
>Reset_n=1,Dec_input=10,output=A

>![image.png](https://hackmd.io/_uploads/HkP8W4LQT.png)
>Reset_n=1,Dec_input=11,output=b

>![image.png](https://hackmd.io/_uploads/HkNDWELma.png)
>Reset_n=1,Dec_input=12,output=c

>![image.png](https://hackmd.io/_uploads/HylObNIXp.png)
>Reset_n=1,Dec_input=13,output=d

>![image.png](https://hackmd.io/_uploads/HyCOb48ma.png)
>Reset_n=1,Dec_input=14,output=E

>![image.png](https://hackmd.io/_uploads/rkiKW4LQp.png)
>Reset_n=1,Dec_input=15,output=F
#  3.實驗心得
這次的作業，老師主要是想讓我們試著在工作站上使用各種EDA工具(VCS、Verdi)進行RTL的撰寫、模擬並觀看波形，而我在進行專題時就有使用過這些工具，因此這次作業也算是在幫我複習了一遍。
# 4.參考文獻
>漫談七段顯示器
>https://www.slideshare.net/ssuser1f4677/ss-78737038