Documente Academic
Documente Profesional
Documente Cultură
LAB MANUAL
List of Experiments
Lab code: VL9225
INDEX
S.No.
Page no.
1.
8 bit ALU
4-7
2.
8-11
3.
Elevator controller
4.
16-19
5.
20-32
6.
12-15
33-38
Algorithm:
1. Start.
2. Declare the input and output ports.
3. Perform the calculations and assign the result to output port.
4. Create the test bench waveform.
5. Simulate and verify the output.
6. Stop.
7. Implement of FPGA kit.
Verilog Module:
module alu8(z,read,data,s);
output reg [7:0]z;
input[7:0]data;
input read;
input[1:0]s;
reg[7:0]y[1:0];
integer i;
always@(data or s)
begin
y[read]=data;
case(s)
2'b00:z=y[0]&y[1];
2'b01:z=y[0]|y[1];
2'b10:z=y[0]^y[1];
2'b11:z=y[0]-y[1];
endcase
end
endmodule
RTL SCHEMATIC
OUTPUT WAVEFORM
10
11
Exp. No. 3
AIM:
Implementation of elevator controller using embedded microcontroller.
Tools used: Basic Microcontroller kit, Interface Elevator kit VBMB 022
Steps:
1.
2.
3.
4.
Program:
12
ADDRESS
OPCODE
MNEUMONICS
4100
74 03
4102
4105
F0
Movx @dptr,a
4106
12 41 41
Lcall delay
4109
74 02
Mov a,#02h
410B
F0
Movx @dptr,a
410C
74 80
Mov a,#80h
410E
90 FF C0
Mov dptr,#lift1
4111
F0
Movx @dptr,a
4112
74 01
Mov a,#01h
4114
90 FF C4
Mov dptr,#lift2
4117
F0
Movx @dptr,a
4118
12 41 41
Lcall delay
411B
90 FF C0
Mov dptr,#lift1
411E
74 40
Mov a,#40h
4120
F0
Movx @dptr,a
4121
12 41 41
Lcall delay
4124
74 20
Mov a,#20h
4126
F0
Movx @dptr,a
4127
12 41 41
Lcall delay
412A
74 10
Mov a,#10h
412C
F0
Movx @dptr,a
412D
12 41 41
Lcall delay
4130
74 08
Mov a,#08h
4132
F0
Movx @dptr,a
4133
74 0B
Mov a,#0bh
4135
90 FF CC Mov dptr,#stat_ou
4138
F0
Mov a,#03h
COMMENTS
Movx @dptr,a
13
4139
12 41 41
ADDRESS
OPCODE
413C
74 03
Mov a,#03h
413E
F0
Movx @dptr,a
413F
413F
MNEUMONICS
COMMENTS
door open
Here:
80 FE
4141
Sjmp here
Delay:
4141
75 31 0A
4144
75 30 64
4144
4147
Lcall delay
Mov
count1,#0A
Mov count,#64
Dl2:
12 41 51
4147
414A
D5 30 FA Djnz count,d2
414D
D5 31 F4
Djnz count1,dl2
4150
22
Ret
4151
Delay 1ms:
1 millisecond
Mov t10,#017h
4151
75 8A 17
4154
75 8C FC Mov th0,#0FCh
4157
12 41 5B
Lcall t0 delay
415A
22
Ret
415B
T0 delay
415B
E5 89
Mov a,tmod
415D
54 F0
Anl a,#0F0h
415F
44 01
Orl a,#t0_ml
4161
F5 89
Mov tmod,a
2 timer0, mode1
4163
D2 8C
Setb 8C
4165
30 8D
FD
C2 8C
Jnb 8D,4165
4168
Clr 8C
14
C2 8D
Clr tf0 8D
416C
22
ret
4165
4168
C2 8C
Clr 8C
416A C2 8D
Clr tf0 8D
416C 22
ret
Exp. No. 4
15
16
17
18
Exp. No. 5
19
20
21
//write the
//write the
//write the data
//write the data
if(c != 0x0)
goto stoptrain;
if(i>=0x05)
{
i2c_start();
i2c_write(sel[j]);
i2c_write(k+1);
i2c_write(ls0[i-0x04]);
i2c_stop();
i2c_start();
i2c_write(sel[j+1]);
i2c_write(k);
i2c_write(ls0[i1-0x04]);
i1++;
printf("Rotate one movement here\n");
}
i2c_stop();
stoptrain1:
sw();
the buffer.
//
high.
//
if((c != 0x0))
goto stoptrain1;
sensor();
if(senout == 0x00)
goto stop1;
senout++;
if(senout < 0x06)
delay_ms(200);
else if(senout == 0x06)
station1.
{
22
//check the
//wait some
delay in station1.
initbuf();
output_d(0x10);
the yellow led for station1 in forward.
output_low(PIN_E2);
output_high(PIN_E2);
//glow
delay_ms(1000);
initbuf();
output_d(0x08);
//glow
//check the
station2.
{
delay_ms(0x2000);
//wait some
delay in station2.
initbuf();
output_d(0x04);
the yellow led for station2 in forward.
output_low(PIN_E1);
output_high(PIN_E1);
//glow
delay_ms(1000);
initbuf();
output_d(0x02);
the green led for station2 in forward.
output_low(PIN_E1);
output_high(PIN_E1);
23
//glow
/*
}
}
}
}
void init()
{
for(i=0;i<0x08;i++)
{
i2c_start();
i2c_write(sel[i]);
i2c_write(0x15);
i2c_write(0x00);
i2c_write(0x00);
i2c_stop();
printf("Clear the display here\n");
}
}
void sensor()
{
output_low(PIN_B4);
a=input_d();
output_high(PIN_B4);
b = a;
b = b & 0x02;
if(b == 0x02)
level crossing.
{
do{
output_low(PIN_B4);
24
c = a;
c = (c & 0x80);
}while(c != 0x0);
crossingon();
}
b = a;
b = b & 0x04;
if(b == 0x04)
level crossing.
crossingoff();
b = a;
b = b & 0x08;
if(b == 0x08)
station2forward();
b = a;
b = b & 0x20;
if(b == 0x20)
station1forward();
}
void crossingon()
{
output_d(0xF0);
output_low(PIN_E1);
output_high(PIN_E1);
output_d(0xFF);
output_low(PIN_E0);
output_high(PIN_E0);
output_d(0x00);
output_low(PIN_E2);
output_high(PIN_E2);
buzzon = 0x01;
}
void crossingoff()
{
initbuf();
25
delay_ms(100);
train in station1.
senout=0x01;
}
void station2forward()
{
initbuf();
output_d(0x08);
forward.
output_low(PIN_E1);
output_high(PIN_E1);
delay_ms(100);
train in station1.
senout1 = 0x01;
}
void sw()
{
output_low(PIN_B4);
a=input_d();
output_high(PIN_B4);
b=a;
b= b & 0x40;
c=a;
c= (c & 0x80);
if(b == 0x40)
reverse();
26
//write the
//write the
//write the data
//write the
//write
if(c != 0x0)
goto stoptrain2;
27
if(i>=0x05)
{
i2c_start();
i2c_write(sel1[j]);
i2c_write(0x05);
i2c_write(ls1[i-0x04]);
i2c_stop();
i2c_start();
i2c_write(sel1[j+1]);
i2c_write(0x06);
i2c_write(ls1[i1-0x04]);
i1++;
printf("Rotate one movement here\n");
}
stoptrain3:
sw1();
the buffer.
//
high.
//
if((c != 0x0))
goto stoptrain3;
sensor1();
if(senout2 == 0x00)
goto stop3;
senout2++;
if(senout2 < 0x06)
delay_ms(200);
else if(senout2 == 0x06)
reverse dircetion.
{
delay_ms(0x2000);
//wait some
28
//glow
//glow
//check the
station1.
{
delay_ms(0x2000);
//wait some
delay in station1.
initbuf();
output_d(0x02);
//glow
if(i != 0x08)
delay_ms(200);
if(buzzon == 0x01)
{
output_low(PIN_E0);
delay_ms(10);
29
//glow
output_low(PIN_B4);
a=input_d();
output_high(PIN_B4);
c = a;
c = (c & 0x80);
}while(c != 0x0);
crossingon();
}
b = a;
b = b & 0x02;
if(b == 0x02)
level crossing.
crossingoff();
b = a;
b = b & 0x01;
if(b == 0x01)
station1reverse();
30
void station1reverse()
{
initbuf();
output_d(0x04);
forward.
output_low(PIN_E2);
output_high(PIN_E2);
delay_ms(100);
train in station1.
senout3=0x01;
}
void station2reverse()
{
initbuf();
output_d(0x01);
forward.
output_low(PIN_E1);
output_high(PIN_E1);
delay_ms(100);
train in station1.
senout2=0x01;
}
void sw1()
{
output_low(PIN_B4);
a=input_d();
output_high(PIN_B4);
b=a;
b= b & 0x40;
c=a;
c= c & 0x80;
}
void initbuf()
{
output_d(0x00);
output_low(PIN_E1);
31
output_d(0x00);
output_low(PIN_E0);
output_high(PIN_E0);
Exp. 6
AIM: System design using PLL.
32
33
34
35
36
RTL SCHEMATIC:
37
38