Verilog Vivado tb_count_8bit.v Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: I am a college student.
// Testbench for count_8bit
//////////////////////////////////////////////////////////////////////////////////
module tb_count_8bit(

    );
    reg clk, rst, en;
    wire [7:0] count, mod_cnt, mod_02;
    wire tc01, tc02;
    
    count_8bit U0(.clk(clk), .rst(rst), .cntout(count));
    
    //Modulus 60: 0,1,2,.... 58, 59, 0, 1, 2, 3,....
    defparam U1.MOD = 10; //0,1,2,....9,0,1,2,3....
    mod_n U1 (.clk(clk), .rst(rst), .en(en), .cntout(mod_cnt), .TC(tc01));

    defparam U1.MOD = 6; //0,1,2,....5,0,1,2,3....
    mod_n U2 (.clk(clk), .rst(rst), .en(tc01), .cntout(mod_02), .TC(tc02));
        
    initial begin
        clk=1'b0;
        rst=1'b0;
        en = 1'b1;
        #1 rst=1'b1;
        #5 rst=1'b0;
        #100 $stop;
    end
    
    //100MHz clock
    always begin
        #5 clk = ~clk;
    end
    
endmodule

This is the Verilog code that written with Vivado for implementing Stopwatch in FPGA Board(Xilinx; Nexys S).

'Study' 카테고리의 다른 글

University 'Logic Design' Midterm Exam  (0) 2019.06.16
한동대 '상담이론과 실제' 기말고사  (0) 2019.06.16
Verilog Vivado Stopwatch.v Code  (0) 2019.05.26
Verilog Vivado mod_n.v Code  (0) 2019.05.26
Verilog Vivado tb_Stopwatch.v Code  (0) 2019.05.26

Verilog Vivado Stopwatch.v Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Stopwatch
// Input : clk, rst, enable
// Output :
// secled : on and off at every second
// Q10, Q1, Qs1, Qs10 : second subsecond output
//////////////////////////////////////////////////////////////////////////////////
module stopwatch(
    input rst,
    input en,
    input clk,
    output reg secled,
    output [3:0] Q10,
    output [3:0] Q1,
    output [3:0] Qs1,
    output [3:0] Qs10
    );
    
    wire tc01, tc02, tc03, tc04, tc05, tc06, tc07;
    wire [7:0] mcnt01, mcnt02, mcnt03;
    wire [3:0] tmp01, tmp02, tmp03, tmp04;
    
    //Modulus count 100: 10ns -> 1us
    defparam U0.MOD=100;
    mod_n U0(.rst(rst), .en(en), .clk(clk), .cntout(mcnt01), .TC(tc01));
    //1us -> 100us
    defparam U1.MOD=100;
    mod_n U1(.rst(rst), .en(tc01), .clk(clk), .cntout(mcnt02), .TC(tc02));
    
    //100us -> 10ms
    defparam U2.MOD=100;
    mod_n U2(.rst(rst), .en(en), .clk(clk), .cntout(mcnt03), .TC(tc03));
    
    defparam U3.MOD=10;
    mod_n U3(.rst(rst), .en(tc03), .clk(clk), .cntout({tmp01, Qs10}), .TC(tc04));
        
    defparam U4.MOD=10;
    mod_n U4(.rst(rst), .en(tc04), .clk(clk), .cntout({tmp02, Qs1}), .TC(tc05));
    
    always @ (posedge tc05) begin
        secled <= ~secled;
    end
    
    defparam U5.MOD=10;
    mod_n U5(.rst(rst), .en(tc05), .clk(clk), .cntout({tmp03, Q1}), .TC(tc06));
    
    defparam U6.MOD=6;
    mod_n U6(.rst(rst), .en(tc06), .clk(clk), .cntout({tmp04, Q10}), .TC(tc07));
endmodule

This is the Verilog code that written with Vivado for implementing Stopwatch in FPGA Board(Xilinx; Nexys S).

'Study' 카테고리의 다른 글

한동대 '상담이론과 실제' 기말고사  (0) 2019.06.16
Verilog Vivado tb_count_8bit.v Code  (0) 2019.05.26
Verilog Vivado mod_n.v Code  (0) 2019.05.26
Verilog Vivado tb_Stopwatch.v Code  (0) 2019.05.26
Verilog Vivado Stopwatch.xdc Code  (0) 2019.05.26

Verilog Vivado mod_n.v Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Modulus N Counter
// Input: rst, clk, en
// Output: cntout[7:0], TC
// parameter : MOD
//////////////////////////////////////////////////////////////////////////////////
module mod_n(
    input rst,
    input clk,
    input en,
    output [7:0] cntout,
    output reg TC
    );
    
    reg [7:0] cnt;
    parameter MOD = 5;
    
    always @ (posedge clk or posedge rst) begin
        if(rst==1'b1) begin
            cnt <= 8'b0000_0000;
            TC = 1'b0;
        end
        else begin
            cnt <= (en) ? cnt+1'b1 : cnt;
            TC  <= 1'b0;
            if(en & cnt == MOD-1) begin
                cnt <= 8'b0000_0000;
                TC <= 1'b1;
            end
        end
    end
    assign cntout = cnt;
endmodule

This is the Verilog code that written with Vivado for implementing Stopwatch in FPGA Board(Xilinx; Nexys S).

'Study' 카테고리의 다른 글

Verilog Vivado tb_count_8bit.v Code  (0) 2019.05.26
Verilog Vivado Stopwatch.v Code  (0) 2019.05.26
Verilog Vivado tb_Stopwatch.v Code  (0) 2019.05.26
Verilog Vivado Stopwatch.xdc Code  (0) 2019.05.26
Verilog Vivado Count_8 Bit.v Code  (0) 2019.05.26

Verilog Vivado tb_Stopwatch.v Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Testbench for stopwatch
//////////////////////////////////////////////////////////////////////////////////
module tb_stopwatch(

    );
    reg clk, en, rst;
    wire [3:0] X0, X1, X2, X3;
    wire secled;
    stopwatch U0(.rst(rst), .en(en), .clk(clk), .secled(secled), .Q10(X0), .Q1(X1), .Qs1(X2), .Qs10(X3));
    
    initial begin
        clk=1'b0;
        en = 1'b1;
        rst = 1'b0;
        #5 rst = 1'b1;
        #6 rst = 1'b0;
        #100 $stop;
    end
    
    always begin
        #5 clk <= ~clk;
    end
    
endmodule

This is the Verilog code that written with Vivado for implementing Stopwatch in FPGA Board(Xilinx; Nexys S).

'Study' 카테고리의 다른 글

Verilog Vivado Stopwatch.v Code  (0) 2019.05.26
Verilog Vivado mod_n.v Code  (0) 2019.05.26
Verilog Vivado Stopwatch.xdc Code  (0) 2019.05.26
Verilog Vivado Count_8 Bit.v Code  (0) 2019.05.26
Verilog Vivado Lab14Stopwatch.v Code  (0) 2019.05.26

Verilog Vivado Stopwatch.xdc Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
## XDC for stop watch
# clock: 100MHz
set_property -dict { PACKAGE_PIN E3     IOSTANDARD LVCMOS33 } [get_ports { clk }];

# rest
set_property -dict { PACKAGE_PIN N17     IOSTANDARD LVCMOS33 } [get_ports { rst }];

#enable
set_property -dict { PACKAGE_PIN J15     IOSTANDARD LVCMOS33 } [get_ports { en }];

#secled
set_property -dict { PACKAGE_PIN H17     IOSTANDARD LVCMOS33 } [get_ports { secled }];

## 7 segment display

set_property -dict { PACKAGE_PIN T10     IOSTANDARD LVCMOS33 } [get_ports { Seg[6] }];
set_property -dict { PACKAGE_PIN R10     IOSTANDARD LVCMOS33 } [get_ports { Seg[5] }];
set_property -dict { PACKAGE_PIN K16     IOSTANDARD LVCMOS33 } [get_ports { Seg[4] }];
set_property -dict { PACKAGE_PIN K13     IOSTANDARD LVCMOS33 } [get_ports { Seg[3] }];
set_property -dict { PACKAGE_PIN P15     IOSTANDARD LVCMOS33 } [get_ports { Seg[2] }];
set_property -dict { PACKAGE_PIN T11     IOSTANDARD LVCMOS33 } [get_ports { Seg[1] }];
set_property -dict { PACKAGE_PIN L16     IOSTANDARD LVCMOS33 } [get_ports { Seg[0] }];

set_property -dict { PACKAGE_PIN H15     IOSTANDARD LVCMOS33 } [get_ports { Seg[7] }];

set_property -dict { PACKAGE_PIN J17     IOSTANDARD LVCMOS33 } [get_ports { AN[0] }];
set_property -dict { PACKAGE_PIN J18     IOSTANDARD LVCMOS33 } [get_ports { AN[1] }];
set_property -dict { PACKAGE_PIN T9     IOSTANDARD LVCMOS33 } [get_ports { AN[2] }];
set_property -dict { PACKAGE_PIN J14     IOSTANDARD LVCMOS33 } [get_ports { AN[3] }];
set_property -dict { PACKAGE_PIN P14     IOSTANDARD LVCMOS33 } [get_ports { AN[4] }];
set_property -dict { PACKAGE_PIN T14     IOSTANDARD LVCMOS33 } [get_ports { AN[5] }];
set_property -dict { PACKAGE_PIN K2     IOSTANDARD LVCMOS33 } [get_ports { AN[6] }];
set_property -dict { PACKAGE_PIN U13     IOSTANDARD LVCMOS33 } [get_ports { AN[7] }];

This is the Verilog code that written with Vivado for implementing Stopwatch in FPGA Board(Xilinx; Nexys S).

'Study' 카테고리의 다른 글

Verilog Vivado mod_n.v Code  (0) 2019.05.26
Verilog Vivado tb_Stopwatch.v Code  (0) 2019.05.26
Verilog Vivado Count_8 Bit.v Code  (0) 2019.05.26
Verilog Vivado Lab14Stopwatch.v Code  (0) 2019.05.26
Verilog tb_HalfAdder.v Code  (0) 2019.05.26

+ Recent posts