DSD Assignment 1
DSD Assignment 1
Degree: 43
Department: Electrical
Syndicate: B
Assignment no: 01
Question#01:
Microcontroller
Microprocessor
DSP
SoC (System on chip
MICROCONTROLLER(8051):
MICROPROCESSOR(8085):
DSP:
SoC (system on chip):
Comparison :
Q2
•Write Verilog code for 8 to 3 line simple encoder and priority
encoder
•Show both circuits synthesized by Intel Quartus/Xilinx ISE
•Compare and discuss the results
module encoder_8to3_mod (
input [7:0] data_in,
output reg [2:0] encoded_out
);
always @(*) begin
case (data_in)
8'b00000001: encoded_out = 3'b000;
8'b00000010: encoded_out = 3'b001;
8'b00000100: encoded_out = 3'b010;
8'b00001000: encoded_out = 3'b011;
8'b00010000: encoded_out = 3'b100;
8'b00100000: encoded_out = 3'b101;
8'b01000000: encoded_out = 3'b110;
8'b10000000: encoded_out = 3'b111;
default: encoded_out = 3'bxxx; // Undefined input
endcase
end
endmodule
TEST BENCH :
module tb_encoder_8to3_mod;
// Inputs
reg [7:0] test_in;
// Outputs
wire [2:0] test_out;
initial begin
// Initialize input
test_in = 8'b00000000;
// Apply test vectors
#10 test_in = 8'b00000001; // Expected output: 000
#10 test_in = 8'b00000010; // Expected output: 001
#10 test_in = 8'b00000100; // Expected output: 010
#10 test_in = 8'b00001000; // Expected output: 011
#10 test_in = 8'b00010000; // Expected output: 100
#10 test_in = 8'b00100000; // Expected output: 101
#10 test_in = 8'b01000000; // Expected output: 110
#10 test_in = 8'b10000000; // Expected output: 111
initial begin
$monitor("Time = %d, Input = %b, Output = %b", $time, test_in,
test_out);
end
endmodule
OUTPUT:
priority encoder :
CODE:
module prio_encoder_8to3 (
input [7:0] data_in,
output reg [2:0] encoded_out
);
always @(*) begin
if (data_in[7]) encoded_out = 3'b111;
else if (data_in[6]) encoded_out = 3'b110;
else if (data_in[5]) encoded_out = 3'b101;
else if (data_in[4]) encoded_out = 3'b100;
else if (data_in[3]) encoded_out = 3'b011;
else if (data_in[2]) encoded_out = 3'b010;
else if (data_in[1]) encoded_out = 3'b001;
else if (data_in[0]) encoded_out = 3'b000;
else encoded_out = 3'bxxx; // Undefined case
end
endmodule
TEST BENCH :
module tb_prio_encoder_8to3;
// Test Inputs
reg [7:0] test_data_in;
// Test Outputs
wire [2:0] test_encoded_out;
initial begin
// Initialize test data
test_data_in = 8'b00000000;
initial begin
$monitor("Time = %d, Input = %b, Output = %b", $time,
test_data_in, test_encoded_out);
end
endmodule
OUTPUT:
Simple Encoder:
Priority Encoder:
o If multiple input bits are high, the encoder outputs the index of
the highest-priority bit.
3) Functional Behavior:
Simple Encoder:
o It operates under a strict one-to-one input-output mapping. It
does not handle cases where more than one input bit is active.
Priority Encoder:
Summary: