Sr. No. Name of The I/O Direction Width Description 1 2 3
Sr. No. Name of The I/O Direction Width Description 1 2 3
Sr. No. Name of The I/O Direction Width Description 1 2 3
Clock 5: left shift {t,a}; compare t with b; // here t = 0001 0010, a = 001 XXXXX
As t > b, qu[3]=1; t = t-b // t= 0000 1000
Clock 6: left shift {t,a}; compare t with b; // here t = 0001 0000, a = 01 XXXXXX
As t > b, qu[2]=1; t = t-b // t= 0000 0110
Clock 7: left shift {t,a}; compare t with b; // here t = 0000 1100, a = 1 XXXXXXX
As t > b, qu[1]=1; t = t-b // t= 0000 0010
Clock 8: left shift {t,a}; compare t with b; // here t = 0000 0101, a = XXXXXXXX
As t < b, qu[0]=0;
Ready_out =1; rem = t;
Seq Divider
output reg [7:0] qu;
always @(posedge clk)
output reg ready_out; begin
input [7:0] a; if (rst)
input [3:0] b; begin
input clk,rst; rem=4'b0000;
output reg [3:0] rem; ready_out=1'b0;
count=0;
tmp = {8'b00000000,a};
reg [3:0] count; tmp0 = 8'b00000000;
reg [15:0] tmp; qu =8'b11111111;
reg [7:0] tmp0; end
Seq Divdider
end
Seq Divider: TB
initial begin
// Initialize Inputs
a = 54;
b = 7;
clk = 0;
rst = 0;
#5
rst = 1;
#20
rst = 0;
end
// Wait 100 ns for global reset to finish
always #10 clk=~clk;
Loop
module looopadd(
input [3:0] a,
input [3:0] b,
for (i=0; i <=3; i=i+1)
output reg[3:0] c
begin
); c[i] = a[i] + b[i];
integer i; end
always @(a or b) end
begin
endmodule
Shift Register with parallel load
1. Design an 8-Bit register circuit with the following specifications.—PARALLEL LOAD and
Left SHIFTER
a. If input line parallelload is high, the register loads the value from input bus
parallelinput.
b. If the parallelload is low,
The value in (i-1) th Bit of the register is loaded into the ith Bit of the register
for i=1 to i=7. The value in the input line Seq-In is loaded into the 0th Bit of
the register and value in the 7th Bit of the register is sent as output from
line Seq-Out.
c. Step a is repeated at each edge of the clock.
parallelload
7 6 5 4 3 2 1 0
Seq-In
8 Bit Register (Memory)
Clock
8 Bit input
parallelinput
Seq-Out
• Shift Register with parallel load
module parallelload1(
always @(posedge clk)
input clk, begin
input parallelload, if (parallelload)
input [7:0] input1, tmp <= input1;
input sin, else
output sout begin
tmp = {tmp[6:0], sin};
);
end
end
assign sout = tmp[7];
reg [7:0] tmp; endmodule
Test Bench for Shift Register Parallel Load
initial begin
forever begin #10
clk <= 0; parallelload = 0;
#5 end
clk <= 1;
#5
clk <= 0; initial begin
end forever begin
end sin = 0;
#7
initial begin
sin = 0;
parallelload = 0; #8
#10 sin = 0;
input1=8'b11111111; end
#10 end
parallelload = 1;
1. Design of traffic light controller with the following specifications.
The controller is to be designed for a traffic light to be positioned at an intersection
between a north-south and an east-west street.
The traffic moves in north-south or east-west, direction only. There is no
perpendicular movement.
On the reset signal, system will enter into the configuration –North-South GREEN
and East-West RED.
After a delay of 15 units of time the next configuration –North-South YELLOW and
East-West YELLOW.
Table below, illustrates all the configurations and delays.
From configuration 6, the controller moves to configuration 1.
Traffic North East Delay
Light South West
sequenc
es
1 Green Red 15
2 Yellow Red 3
N o r th 3 Red Red 1
4 Red Green 15
W est E ast 5 Red Yellow 3
6 Red Red 1
S o u th
Delay 15 Delay 3 Delay 1
So S1 S2 S3
000 001 010 100
Delay 15
Delay 3
Delay 1 S5 S4
110 101
initial begin
// Initialize Inputs
clk = 0;
clr = 0;
#2;
clr = 1;
#2;
clr = 0;
#2;
end