Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- gpio
- stop watch
- hc-sr04
- vivado
- atmega 128a
- Recursion
- i2c 통신
- pwm
- structural modeling
- FND
- BASYS3
- KEYPAD
- Algorithm
- verilog
- test bench
- half adder
- uart 통신
- ATMEGA128A
- soc 설계
- Pspice
- java
- Edge Detector
- behavioral modeling
- D Flip Flop
- prescaling
- ring counter
- Linked List
- DHT11
- LED
- dataflow modeling
Archives
- Today
- Total
거북이처럼 천천히
1 bit Comparator 본문
1. 1 bit Comparator (by using case)
<Source>
// Behavioral Modeling of 1bit comparator (by using case)
module Comparator_1bit_Behavioral_Modeling_by_using_case(
input a, b,
output reg equal, greater, less);
always @(a, b) begin
case({a, b})
2'b00 : begin equal = 1; greater = 0; less = 0; end
2'b01 : begin equal = 0; greater = 0; less = 1; end
2'b10 : begin equal = 0; greater = 1; less = 0; end
2'b11 : begin equal = 1; greater = 0; less = 0; end
endcase
end
endmodule
<Simulation>
<RTL Analysis>
<Synthesis>
2. 1 bit Comparator (by using if-else)
<Source>
module Comparator_1bit_Behavioral_Modeling_by_using_if_else(
input a, b,
output reg equal, greater, less);
always @(a, b) begin
if(a == b) begin equal = 1; greater = 0; less = 0; end
else if(a > b) begin equal = 0; greater = 1; less = 0; end
else begin equal = 0; greater = 0; less = 1; end
end
endmodule
<Simulation>
<RTL Analysis>
<Synthesis>
3. 1 bit Comparator (Structural Modeling)
<Source>
// Behavioral Modeling of xnor gate.
module xnor_gate (
input a, b,
output reg out);
always @(a, b) begin
case({a, b})
2'b00 : out = 1;
2'b01 : out = 0;
2'b10 : out = 0;
2'b11 : out = 1;
endcase
end
endmodule
// Behavioral Modeling of and gate.
module and_gate (
input a, b,
output reg out);
always @(a, b) begin
case({a, b})
2'b00 : out = 0;
2'b01 : out = 0;
2'b10 : out = 0;
2'b11 : out = 1;
endcase
end
endmodule
// Structural Modeling of 1 bit Comparator.
module Comparator_1bit_Structural_Modeling(
input a, b,
output equal, greater, less );
xnor_gate xnor0 (a, b, equal);
and_gate and0 (a, ~b, greater);
and_gate and1 (~a, b, less);
endmodule
<Simulation>
<RTL Analysis>
<Synthesis>
4. 1 bit Comparator (Dataflow Modeling)
<Source>
// Dataflow Modeling of 1 bit Comparator.
module Comparator_1bit_Dataflow_Modeling(
input a, b,
output equal, greater, less );
assign equal = (a==b)? 1 : 0;
assign greater = (a>b)? 1 : 0;
assign less = (a<b)? 1 : 0;
endmodule
<Simulation>
<RTL Analysis>
<Synthesis>
'RTL Design > Verilog 연습' 카테고리의 다른 글
Module with parameters (0) | 2024.06.30 |
---|---|
4 bit Comparator / 32 bit Comparator (0) | 2024.06.30 |
4 bit parallel adder / subtractor (0) | 2024.06.30 |
4 bit parallel adder (0) | 2024.06.30 |
Full adder (0) | 2024.06.29 |