Task Verilog
Task Verilog
Assignments
By Aditi mam
1. single bit subtractor
2. 8*3 Encoder (Octal to Binary)
3. 4x1 Mux
4. 4x2 Priority encoder
5. 1x4 Demux
6. Excess3 to Binary code converter
7. 2 Bit Adder
8.Full adder using half adder
9. D Flip-Flop
10. S R Flip-Flop
11. J K Flip-Flop
12.T Flip-Flop
13.Write down verilog for this mention block
Test bench :
14. Read about procedural blocks and their functionality. Write a short note with pseudocode examples.
1.always block
•Executes continuously, triggered by changes in sensitivity list.
•Commonly used for both combinational and sequential logic.
2.initial block
•Executes only once at the start of the simulation.
•Used for testbenches and initializing variables.
Example 1: Combinational Logic (Using always)
always @(*) begin
if (a && b)
out = 1;
else
out = 0;
end
1.Half Adder:
assign sum = a ^ b; // XOR for sum
assign carry = a & b; // AND for carry
2.Comparator:
assign is_equal = (a == b); // Check equality
assign is_greater = (a > b); // Check greater than
16. Read about all the operators . Write working example codes for
each type of operator (logical, arithmetic, etc.).
1. Arithmetic Operators
These are used for performing basic mathematical operations like addition, subtraction,
multiplication, etc.
Example:
Example:
•&& Logical AND: Returns true if both operands are true. EX:assign result_and = a && b
•|| Logical OR: Returns true if at least one operand is true. EX:assign result_or = a || b;
•! Logical NOT: Returns true if the operand is false.EX: assign result_not = !a;
3. Relational Operators
These operators compare two operands and return a boolean result.
Example:
•== Equality: Returns true if operands are equal. Example: assign eq = (a == b);
•!= Inequality: Returns true if operands are not equal. Example: assign neq = (a != b);
•< Less than: Returns true if the left operand is smaller. Example: assign less = (a < b);
•> Greater than: Returns true if the left operand is larger. Example: assign greater = (a >
b);
3. Relational Operators
Example:
•& Bitwise AND: Performs AND operation on each bit. Example: assign and_result = a & b;
•| Bitwise OR: Performs OR operation on each bit. Example: assign or_result = a | b;
•^ Bitwise XOR: Performs XOR operation on each bit. Example: assign xor_result = a ^ b;
•~ Bitwise NOT: Inverts all bits. Example: assign not_result = ~a;
5. Shift Operators
Shift the bits of the operand left or right.
Example:
•<< Left shift: Shifts bits to the left, filling with 0. Example: assign shifted_left = a << 2;
•>> Right shift: Shifts bits to the right. Example: assign shifted_right = a >> 2;
17.Read about all the data types. Write example codes for showing
use and format specifiers for displaying each data types.
18.Read about arrays and vectors in verilog. Write short note woth
examples of how to instantiate them.
1. Vectors
Vectors represent a group of related signals packed into a single variable. They are
commonly used to represent multi-bit signals like buses.