Skip to content

star-bits/sogang-cse3016

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

컴퓨터공학실험II (컴실2)

1주차 + 2주차

  • 'Vivado 2017.3' 프로그램을 실행. ('Vivado HLS 2017.3' 프로그램이 아니라.)
  • 새로 RTL Project를 만들고, inv.v 파일을 만들고, Default Part로 xc7a75tfgg484-1를 추가함.
  • Sources 창의 Design Sources 아래 inv 파일 확인.
  • Flow Navigator 창의 Project Manager 아래의 Add Sources를 클릭하고 simulation source를 선택함. 이름은 inv_tb.v.
  • Sources 창의 Simulation Sources 아래 inv_tb 파일 확인.
  • Flow Navigator 창의 Simulation - Run Simulation - Run Behavioral Simulation 클릭.

4주차

  • inv.v
  • inv_tb.v
  • inv.xdc
  • RTL ANALYSIS - Open Elaborated Design - Window - I/O Ports
  • Run Synthesis
  • Run Implementation
  • Generate Bitstream - Open Target - Auto Connect - Program Device - Program

10주차

BCD design code

`timescale 1ns / 1ps

module inv(a, b, cin, sum, dout);
input [3:0] a, b;
input cin;          
output [3:0] sum;
output dout;

wire [3:0] s;               
wire c1, c2, c3, cout;
assign s[0] = a[0] ^ b[0] ^ cin;                    
assign c1 = (a[0] & b[0]) | (a[0] & cin) | (b[0] & cin); 
assign s[1] = a[1] ^ b[1] ^ c1;                      
assign c2 = (a[1] & b[1]) | (a[1] & c1) | (b[1] & c1); 
assign s[2] = a[2] ^ b[2] ^ c2;                    
assign c3 = (a[2] & b[2]) | (a[2] & c2) | (b[2] & c2);  
assign s[3] = a[3] ^ b[3] ^ c3;                      
assign cout = (a[3] & b[3]) | (a[3] & c3) | (b[3] & c3);

wire oc;
assign oc = (cout | (s[3] & s[2]) | (s[3] & s[1]));

wire [3:0] o = {1'b0, oc, oc, 1'b0};
wire d1, d2, d3;
assign sum[0] = o[0] ^ s[0] ^ 0;                    
assign d1 = (o[0] & s[0]) | (o[0] & 0) | (s[0] & 0); 
assign sum[1] = o[1] ^ s[1] ^ d1;                      
assign d2 = (o[1] & s[1]) | (o[1] & d1) | (s[1] & d1); 
assign sum[2] = o[2] ^ s[2] ^ d2;                    
assign d3 = (o[2] & s[2]) | (o[2] & d2) | (s[2] & d2);  
assign sum[3] = o[3] ^ s[3] ^ d3;                      
assign dout = oc;   

endmodule

BCD testbench code

`timescale 1ns / 1ps

module inv_tb;
reg [3:0] a, b;
reg cin;
wire [3:0] sum;
wire dout;

inv u_test(a, b, cin, sum, dout);

initial begin
a = 4'D0;
b = 4'D0;
cin = 1'b0;
end

always@(a or b or cin) begin
a <= #10 a+4'D1;
b <= #20 a-4'D1;
cin <= #30 ~cin;
end

initial begin
#1000
$finish;
end

endmodule

11주차

RS Flip-Flop inv.v

`timescale 1ns / 1ps

module inv(
input r, s, clk,
output q, nq
);

// NOR
// assign q = ~((c & clk) | nq);
// assign nq = ~((s & clk) | q);

// NAND
assign q = ~(~(r & clk) & nq);
assign nq = ~(~(s & clk) & q);

endmodule

RS Flip-Flop inv_tb.v

`timescale 1ns / 1ps

module inv_tb;
reg r, s, clk;
wire q, nq;

inv u_test(
.r(r),
.s(s),
.clk(clk),
.q(q),
.nq(nq)
);

initial begin
r = 1'b0;
s = 1'b0;
clk = 1'b0;
end

always@(r or s or clk) begin
r <= #200 ~r;
s <= #100 ~s;
clk <= #50 ~clk;
end

initial begin
#800
$finish;
end

endmodule

RS Flip-Flop inv.xdc

set_property -dict {PACKAGE_PIN J4 IOSTANDARD LVCMOS18} [get_ports r]
set_property -dict {PACKAGE_PIN L3 IOSTANDARD LVCMOS18} [get_ports s]
set_property -dict {PACKAGE_PIN K3 IOSTANDARD LVCMOS18} [get_ports clk]

set_property -dict {PACKAGE_PIN F15 IOSTANDARD LVCMOS18} [get_ports q]
set_property -dict {PACKAGE_PIN F13 IOSTANDARD LVCMOS18} [get_ports nq]
set_property ALLOW_COMBINATORIAL_LOOPS TRUE [get_nets q_OBUF]

About

컴퓨터공학실험II (2024-2) 실습

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published