Verified Interfacing Program
Verified Interfacing Program
Verified Interfacing Program
endcase
i=i+1;
end
endmodule
#PACE: Start of PACE I/O Pin Assignments
NET "clk" LOC = "p80" ;
NET "q<0>" LOC = "p114" ;
NET "q<1>" LOC = "p109" ;
NET "q<2>" LOC = "p108" ;
NET "q<3>" LOC = "p107" ;
NET "q<4>" LOC = "p102" ;
NET "q<5>" LOC = "p101" ;
NET "q<6>" LOC = "p100" ;
NET "s<0>" LOC = "p96" ;
NET "s<1>" LOC = "p95" ;
NET "s<2>" LOC = "p94" ;
NET "s<3>" LOC = "p90" ;
NET "s<4>" LOC = "p86" ;
NET "s<5>" LOC = "p81" ;
Apply manual clock, to change each state press manual clockk each time.
LCD
Module LCD (clk, lcd_rs, lcd_rw, lcd_e, lcd_4, lcd_5, lcd_6, lcd_7);
parameter n = 27;
parameter k = 17;
(* LOC="p80" *) input clk; // synthesis attribute PERIOD clk "100.0 MHz"
reg [n-1:0] count=0;
reg lcd_busy=1; // Lumex LCM-S01602DTR/B
reg lcd_stb;
reg [7:0] lcd_code;
reg [6:0] lcd_stuff;
(* LOC="p96" *) output reg lcd_rs;
(* LOC="p95" *) output reg lcd_rw;
(* LOC="p97" *) output reg lcd_7;
(* LOC="p100" *) output reg lcd_6;
(* LOC="p101" *) output reg lcd_5;
(* LOC="p102" *) output reg lcd_4;
(* LOC="p94" *) output reg lcd_e;
1. Write HDL code to interface Hex key pad and display the key code on seven
segment display.
module LCD_HEX(col,row,clk,disp_sel,ss);
initial col=4'b0001;
input clk;
reg [3:0]col;
reg[6:0] ss;
reg[3:0] disp_sel;
reg [11:0]dclk;
begin
dclk=dclk+1'b1;
end
begin
col={col[2:0],col[3]};
disp_sel= 4'b1110;
end
always @*
begin
case (col)
4'b0001:case (row)
4'b0001:ss= 7'b1111110;
4'b0010:ss= 7'b0110011;
4'b0100:ss= 7'b1111111;
4'b1000:ss= 7'b1001110;
default:ss= 7'b0000000;
endcase
4'b0001:ss = 7'b0110000;
4'b0010:ss = 7'b1011011;
4'b0100:ss = 7'b1111011;
4'b1000:ss = 7'b0111101;
default:ss = 7'b0000000;
endcase
4'b0001:ss = 7'b1101101;
4'b0010:ss = 7'b1011111;
4'b0100:ss = 7'b1110111;
4'b1000:ss = 7'b1001111;
default:ss = 7'b0000000;
endcase
4'b0001:ss = 7'b1111001;
4'b0010:ss = 7'b1110000;
4'b0100:ss = 7'b0011111;
4'b1000:ss = 7'b1000111;
default:ss = 7'b0000000;
endcase
default:ss=7'b0000000;
endcase
end
endmodule
procedure
1. Make the connection between FRC5 of the FPGA board to the Seven Segment.
2. Make the connection between FRC4 of the FPGA board to the Key board.
3. Make the connection between FRC6 of the FPGA board to the Dip switch.
procedure
1. Make the connection between FRC9 of the FPGA board to the DC motor connector.
2. Make the connection between FRC7 of the FPGA board to the Keyboard connector.
3. Make the connection between FRC1 of the FPGA board to the Dip switch connector.
Or
module motor_clock(clk,inp,output1);
input clk,inp;
reg iclk;
begin
delay=delay+1;
iclk=delay[8];
end
begin
if(cnt<=9'b110010000)
begin
output1=seq;
cnt=cnt+1;
end
else
begin
output1=4'b1111;
end
end
endmodule
(B)Write a Verilog code to control the speed and direction of the stepper motor
always@(clk_div)
clk_int=clk_div[15];
always@(posedge clk_int)
begin
if (dir == 0)
shift_reg = {shift_reg[0] , shift_reg[3:1]};
else
shift_reg = {shift_reg[2:0] , shift_reg[3]};
d_out = shift_reg;
end
endmodule
Connections:
a. Make the connection between FRC9 of the FPGA board to the Stepper motor connector.
b. Make the connection between FRC1 of the FPGA board to the DIP switch connector.
a. Square wave
always@(posedge temp[3])
begin
if (reset)
counter = 8'b00000000;
else if ((counter < 255) && (enable == 0))
begin
counter = counter+1;
dac_out = 8'b00000000;
end
else if (counter == 0)
enable = 0;
else
begin
enable = 1;
counter = counter-1;
dac_out = 8'b11111111;
end
end
endmodule
b. Triangular wave
always@(posedge clk)
temp = temp + 1;
always@(posedge temp[3])
begin
if (reset)
counter = 8'b00000000;
else if ((counter < 255) && (enable == 0))
begin
counter = counter+1;
dac_out = counter;
end
else if (counter == 0)
enable = 0;
else
begin
enable = 1;
counter = counter-1;
dac_out = counter;
end
end
endmodule
c. Sawtooth wave
always@(posedge temp[3])
begin
if (reset)
counter = 8'b00000000;
else
counter = counter+1;
dac_out = counter;
end
endmodule
d. Sine wave
always@(posedge clk)
temp = temp + 1;
Connections:
a) Make the connection between FRC5 of the FPGA board to the DAC connector.
b) Make the connection between FRC1 of the FPGA board to the DIP switch connector.