Kraklog

[Verilog_LAB2] Part2 본문

[Harman] 하만 반도체 설계/CPU설계

[Verilog_LAB2] Part2

Krakens 2023. 12. 19. 01:13
728x90

프로그램 : Quaturs Prime lite edition 18.1

사용문법 : Verilog 2001

보드 : DE1-SOC

 

 

 

설계 목표 : 비교기를 통해 9보다 높으면 d1 (HEX1) 에, 그보다 낮으면 d0 (HEX0)에 출력하여 표시한다.
-여태 설계한 MUX를 통해서 구별을 해준다.

`define BUS_SIZE 2
`define SL_SIZE 10	//switch LED size
`define SEG7_WD	7

module part2 (
 	input		[`SL_SIZE-1:0]		SW		,
  output  [`SL_SIZE-1:0]    LEDR  ,
	output	[`SEG7_WD-1:0]		HEX0	,
	output	[`SEG7_WD-1:0]		HEX1	 
);

  wire [3:0]            V;
  wire [3:0]            A;
  wire [3:0]            B1;
  wire [3:0]            B0;
  wire                  Z;
  //wire [`SEG7_WD-1:0]		HEX0;
 // wire [`SEG7_WD-1:0]		HEX1;
  wire [`SEG7_WD-1:0]		H0;
  wire [`SEG7_WD-1:0]		H1;
  assign V = SW[3:0];
	assign LEDR = SW;

  comp uComp_0(
    .V(V),
    .Z(Z)
  );

  circuitA uCircuitA_0(
    .V(V),
    .A(A)
  );

    mux_4bit_2x1 uMux_4bit_2x1_0(
    .x(V),
    .y(A),
    .s(Z),
    .m(B0)
  );

  bcd7seg ubcd7seg_1(
    .B({3'b0,Z}),
    .H(H1)
  );

    bcd7seg ubcd7seg_0(
    .B(B0),
    .H(H0)
  );

  
  assign HEX0 = H0;
  assign HEX1 = H1;
  
endmodule

 

`define USE_BOOL

module comp (
  input    [3:0]    V ,
  output            Z
);
  //  HEX   BIN   Z
  //  9 :  1001 : 0 V[1] & V[3] | V[2] & V[3]
  //  A :  1010 : 1
  //  B :  1011 : 1
  //  C :  1100 : 1
  //  D :  1101 : 1
  //  E :  1110 : 1
  //  F :  1111 : 1

  
`ifdef USE_BOOL
    assign Z = (V[1] & V[3]) | (V[2] & V[3]);
`else
    assign Z = (V>9);
`endif   

endmodule

비교기

module circuitA (
  input   [3:0] V,
  output  [3:0] A 
);
  
  //  HEX  3 210   3 210
  //  9 :  1 001 :  
  //  A :  1 010 : 0 000
  //  B :  1 011 : 0 001
  //  C :  1 100 : 0 010
  //  D :  1 101 : 0 011
  //  E :  1 110 : 0 100
  //  F :  1 111 : 0 101 

  assign A[3] = 1'b0;
  assign A[2] = V[2]&V[1];
  assign A[1] = V[2]&~V[1];
  assign A[0] = V[0];


endmodule

 

카르노맵을 적용하여 조건을 할당해주었다.

 

728x90

'[Harman] 하만 반도체 설계 > CPU설계' 카테고리의 다른 글

[Verilog_LAB2] Part4  (0) 2023.12.19
[Verilog_LAB2] Part3  (1) 2023.12.19
[Verilog_LAB2] Part1  (0) 2023.12.19
[Verilog_LAB1] Part5  (0) 2023.12.18
[Verilog_LAB1] Part4  (1) 2023.12.18