Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] problem about scanning 3x4 keypad in verilog

Status
Not open for further replies.

pkl520

Newbie level 1
Joined
May 26, 2015
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
8
hello i'm new here and a beginner in verilog

i have problem about scanning 3x4 keypad in verilog

lab2.JPG

above is question

now i already have 4-2 priority encoder to put row&column into keypad scanning and then

put data into binary to bcd converter

but now i'm stuck here. because i dont know how to put data into binary to bcd converter

can some give a help or hint?

i will be apreciate.

p.s: the attachment is my verilog code
Code:
module prio_encoder4_2 ( d0,d1,d2,d3 ,x ,y );
input d0 ;
input d1 ;
input d2 ;
input d3 ;
output reg  x ;
output reg  y ;



always @ (d0 or d1 or d2 or d3)
  if (d3 == 1)
  {x,y} = 3'b11 ;
else if (d2 == 1)
  {x,y} = 3'b10 ;
else if (d1 == 1)
  {x,y} = 3'b01 ;
else if (d0 == 1)
  {x,y} = 3'b00 ;
else
  {x,y} = 3'bxx ;

endmodule

module matrix_scan(co1,row,a1,b1,c1,d1);//a1~d1 is output

input [3:0] co1;
input [3:0] row;
output a1;
output b1;
output c1;
output d1;
prio_encoder4_2 en1(.d0(co1[0]) ,.d1(co1[1]) ,.d2(co1[2]) ,.d3(co1[3]) ,.x(a1) ,.y(b1) );
prio_encoder4_2 en2(.d0(row[0]) ,.d1(row[1]) ,.d2(row[2]) ,.d3(row[3]) ,.x(c1) ,.y(d1) );

endmodule

module add3(in,out);
input [3:0] in;

output [3:0] out;
reg [3:0] out;
matrix_scan aa(.co1(co1),.row(co1),.a(in[0]),.b(in[1]),.c(in[2]),.d(in[3]));//have problem here~!!!
always @ (in)       
 case (in)        
 4'b0000: out <= 4'b0000;       
 4'b0001: out <= 4'b0001;       
 4'b0010: out <= 4'b0010;       
 4'b0011: out <= 4'b0011;       
 4'b0100: out <= 4'b0100;       
 4'b0101: out <= 4'b1000;       
 4'b0110: out <= 4'b1001;       
 4'b0111: out <= 4'b1010;       
 4'b1000: out <= 4'b1011;       
 4'b1001: out <= 4'b1100;       
 default: out <= 4'b0000;      
  endcase
endmodule




module seg7 (bcd, leds);
	input [3:0] bcd;
	output [1:7] leds;
	reg [1:7] leds;
	
	always @(bcd)
		case (bcd)       //abcdefg
			0: leds = 7'b1111110;
	   		1: leds = 7'b0110000;
			2: leds = 7'b1101101;
			3: leds = 7'b1111001;
			4: leds = 7'b0110011;
			5: leds = 7'b1011011;
			6: leds = 7'b1011111;
			7: leds = 7'b1110000;
			8: leds = 7'b1111111;
			9: leds = 7'b1111011;
			default: leds = 7'bx;
		endcase
		
endmodule
 

ads-ee

Super Moderator
Staff member
Joined
Sep 10, 2013
Messages
7,805
Helped
1,809
Reputation
3,628
Reaction score
1,768
Trophy points
1,393
Location
USA
Activity points
58,915
We aren't going to do your homework for you...but I'll give you a hint.

The table in your picture of the problem statement shows that the codes that come out on ABCD need to be translated to BCD (i.e. Binary Coded Decimal). To perform logic transformation of some inputs into new outputs can be done by using a truth table.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top